dec_group_border.h (1454B)
1 // Copyright (c) the JPEG XL Project Authors. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 #ifndef LIB_JXL_DEC_GROUP_BORDER_H_ 7 #define LIB_JXL_DEC_GROUP_BORDER_H_ 8 9 #include <stddef.h> 10 11 #include <atomic> 12 13 #include "lib/jxl/base/arch_macros.h" 14 #include "lib/jxl/base/status.h" 15 #include "lib/jxl/frame_dimensions.h" 16 #include "lib/jxl/image.h" 17 18 namespace jxl { 19 20 class GroupBorderAssigner { 21 public: 22 // Prepare the GroupBorderAssigner to handle a given frame. 23 void Init(const FrameDimensions& frame_dim); 24 // Marks a group as done, and returns the (at most 3) rects to run 25 // FinalizeImageRect on. `block_rect` must be the rect corresponding 26 // to the given `group_id`, measured in blocks. 27 void GroupDone(size_t group_id, size_t padx, size_t pady, 28 Rect* rects_to_finalize, size_t* num_to_finalize); 29 // Marks a group as not-done, for running re-paints. 30 void ClearDone(size_t group_id); 31 32 static constexpr size_t kMaxToFinalize = 3; 33 34 private: 35 FrameDimensions frame_dim_; 36 std::unique_ptr<std::atomic<uint8_t>[]> counters_; 37 38 // Constants to identify group positions relative to the corners. 39 static constexpr uint8_t kTopLeft = 0x01; 40 static constexpr uint8_t kTopRight = 0x02; 41 static constexpr uint8_t kBottomRight = 0x04; 42 static constexpr uint8_t kBottomLeft = 0x08; 43 }; 44 45 } // namespace jxl 46 47 #endif // LIB_JXL_DEC_GROUP_BORDER_H_