47 if (l_data_size > SIZE_MAX) {
55 uint32_t rw,rh,rw_next,rh_next;
56 uint8_t cas_row,cas_col;
59 auto a = tilec->
buf->
ptr();
61 auto next_res = cur_res - 1;
63 auto bj_array =
new int32_t*[ThreadPool::get()->num_threads()];
64 for (uint32_t i = 0; i < ThreadPool::get()->num_threads(); ++i){
65 bj_array[i] =
nullptr;
67 for (uint32_t i = 0; i < ThreadPool::get()->num_threads(); ++i){
75 for (uint32_t decompno = 0; decompno < num_decomps; ++decompno) {
78 rw = cur_res->x1 - cur_res->x0;
80 rh = cur_res->y1 - cur_res->y0;
82 rw_next = next_res->x1 - next_res->x0;
84 rh_next = next_res->y1 - next_res->y0;
87 cas_row = cur_res->x0 & 1;
89 cas_col = cur_res->y0 & 1;
93 const uint32_t linesPerThreadV =
static_cast<uint32_t
>(std::ceil((
float)rw / (
float)ThreadPool::get()->num_threads()));
94 const uint32_t s_n = rh_next;
95 const uint32_t d_n = rh - rh_next;
96 if (ThreadPool::get()->num_threads() == 1){
98 for (
auto m = 0U;m < std::min<uint32_t>(linesPerThreadV, rw); ++m) {
99 auto bj = bj_array[0];
101 for (uint32_t k = 0; k < rh; ++k)
102 bj[k] = aj[k * stride];
103 wavelet.encode_line(bj, (int32_t)d_n, (int32_t)s_n, cas_col);
107 std::vector< std::future<int> > results;
108 for(uint32_t i = 0; i < ThreadPool::get()->num_threads(); ++i) {
110 results.emplace_back(
111 ThreadPool::get()->enqueue([index, bj_array,a,
116 for (uint32_t m = index * linesPerThreadV;
117 m < std::min<uint32_t>((index+1)*linesPerThreadV, rw); ++m) {
118 auto bj = bj_array[index];
120 for (uint32_t k = 0; k < rh; ++k)
121 bj[k] = aj[k * stride];
122 wavelet.encode_line(bj, (int32_t)d_n, (int32_t)s_n, cas_col);
129 for(
auto &result: results)
136 const uint32_t s_n = rw_next;
137 const uint32_t d_n = rw - rw_next;
138 const uint32_t linesPerThreadH =
static_cast<uint32_t
>(std::ceil((
float)rh / (
float)ThreadPool::get()->num_threads()));
139 if (ThreadPool::get()->num_threads() == 1){
141 for (
auto m = 0U;m < std::min<uint32_t>(linesPerThreadH, rh); ++m) {
142 auto bj = bj_array[0];
143 auto aj = a + m * stride;
144 memcpy(bj,aj,rw << 2);
145 wavelet.encode_line(bj, (int32_t)d_n, (int32_t)s_n, cas_row);
150 std::vector< std::future<int> > results;
151 for(uint32_t i = 0; i < ThreadPool::get()->num_threads(); ++i) {
153 results.emplace_back(
154 ThreadPool::get()->enqueue([index, bj_array,a,
159 for (
auto m = index * linesPerThreadH;
160 m < std::min<uint32_t>((index+1)*linesPerThreadH, rh); ++m) {
161 int32_t *bj = bj_array[index];
162 int32_t *aj = a + m * stride;
163 memcpy(bj,aj,rw << 2);
164 wavelet.encode_line(bj, (int32_t)d_n, (int32_t)s_n, cas_row);
171 for(
auto &result: results)
179 for (uint32_t i = 0; i < ThreadPool::get()->num_threads(); ++i)