/work/svt-av1/Source/Lib/Codec/reference_object.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright(c) 2019 Intel Corporation |
3 | | * |
4 | | * This source code is subject to the terms of the BSD 2 Clause License and |
5 | | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
6 | | * was not distributed with this source code in the LICENSE file, you can |
7 | | * obtain it at https://www.aomedia.org/license/software-license. If the Alliance for Open |
8 | | * Media Patent License 1.0 was not distributed with this source code in the |
9 | | * PATENTS file, you can obtain it at https://www.aomedia.org/license/patent-license. |
10 | | */ |
11 | | |
12 | | #include <stdlib.h> |
13 | | #include <string.h> |
14 | | |
15 | | #include "svt_threads.h" |
16 | | #include "reference_object.h" |
17 | | #include "pic_buffer_desc.h" |
18 | | #include "utility.h" |
19 | | #include "enc_mode_config.h" |
20 | | |
21 | | static void initialize_samples_neighboring_reference_picture_8bit(EbByte recon_samples_buffer_ptr, uint16_t stride, |
22 | 2.68k | uint16_t recon_width, uint16_t recon_height) { |
23 | 2.68k | uint8_t* recon_samples_ptr; |
24 | 2.68k | uint16_t sample_count; |
25 | | |
26 | | // 1. zero out the top row |
27 | 2.68k | recon_samples_ptr = recon_samples_buffer_ptr - stride - 1; |
28 | 2.68k | svt_memset(recon_samples_ptr, 0, sizeof(uint8_t) * (1 + recon_width + 1)); |
29 | | |
30 | | // 2. zero out the bottom row |
31 | 2.68k | recon_samples_ptr = recon_samples_buffer_ptr + (recon_height)*stride - 1; |
32 | 2.68k | svt_memset(recon_samples_ptr, 0, sizeof(uint8_t) * (1 + recon_width + 1)); |
33 | | |
34 | | // 3. zero out the left column |
35 | 2.68k | recon_samples_ptr = recon_samples_buffer_ptr - 1; |
36 | 352k | for (sample_count = 0; sample_count < recon_height; sample_count++) { |
37 | 350k | recon_samples_ptr[sample_count * stride] = 0; |
38 | 350k | } |
39 | | // 4. zero out the right column |
40 | 2.68k | recon_samples_ptr = recon_samples_buffer_ptr + recon_width; |
41 | 352k | for (sample_count = 0; sample_count < recon_height; sample_count++) { |
42 | 350k | recon_samples_ptr[sample_count * stride] = 0; |
43 | 350k | } |
44 | 2.68k | } |
45 | | |
46 | 896 | static void initialize_samples_neighboring_reference_picture(EbPictureBufferDesc* ref_pic) { |
47 | 896 | initialize_samples_neighboring_reference_picture_8bit( |
48 | 896 | ref_pic->y_buffer, ref_pic->y_stride, ref_pic->width, ref_pic->height); |
49 | | |
50 | 896 | initialize_samples_neighboring_reference_picture_8bit( |
51 | 896 | ref_pic->u_buffer, ref_pic->u_stride, ref_pic->width >> 1, ref_pic->height >> 1); |
52 | | |
53 | 896 | initialize_samples_neighboring_reference_picture_8bit( |
54 | 896 | ref_pic->v_buffer, ref_pic->v_stride, ref_pic->width >> 1, ref_pic->height >> 1); |
55 | 896 | } |
56 | | |
57 | 896 | static void svt_reference_object_dctor(EbPtr p) { |
58 | 896 | EbReferenceObject* obj = (EbReferenceObject*)p; |
59 | | |
60 | 896 | EB_DELETE(obj->reference_picture); |
61 | 896 | EB_FREE_2D(obj->unit_info); |
62 | 896 | EB_FREE_ALIGNED_ARRAY(obj->mvs); |
63 | 896 | EB_FREE_ARRAY(obj->sb_intra); |
64 | 896 | EB_FREE_ARRAY(obj->sb_skip); |
65 | 896 | EB_FREE_ARRAY(obj->sb_64x64_mvp); |
66 | 896 | EB_FREE_ARRAY(obj->sb_me_64x64_dist); |
67 | 896 | EB_FREE_ARRAY(obj->sb_me_8x8_cost_var); |
68 | 896 | EB_FREE_ARRAY(obj->sb_min_sq_size); |
69 | 896 | EB_FREE_ARRAY(obj->sb_max_sq_size); |
70 | 8.96k | for (uint8_t sr_denom_idx = 0; sr_denom_idx < NUM_SR_SCALES + 1; sr_denom_idx++) { |
71 | 88.7k | for (uint8_t resize_denom_idx = 0; resize_denom_idx < NUM_RESIZE_SCALES + 1; resize_denom_idx++) { |
72 | 80.6k | if (obj->downscaled_reference_picture[sr_denom_idx][resize_denom_idx] != NULL) { |
73 | 0 | EB_DELETE(obj->downscaled_reference_picture[sr_denom_idx][resize_denom_idx]); |
74 | 0 | } |
75 | 80.6k | EB_DESTROY_MUTEX(obj->resize_mutex[sr_denom_idx][resize_denom_idx]); |
76 | 80.6k | } |
77 | 8.06k | } |
78 | 896 | } |
79 | | |
80 | | /* |
81 | | svt_reference_param_update: update the parameters in EbReferenceObject for changing the resolution on the fly |
82 | | */ |
83 | 0 | EbErrorType svt_reference_param_update(EbReferenceObject* ref_object, SequenceControlSet* scs) { |
84 | 0 | EbPictureBufferDescInitData picture_buffer_desc_init_data_ptr; |
85 | |
|
86 | 0 | bool is_16bit = scs->static_config.encoder_bit_depth > EB_EIGHT_BIT; |
87 | | // Initialize the various Picture types |
88 | 0 | picture_buffer_desc_init_data_ptr.max_width = scs->max_input_luma_width; |
89 | 0 | picture_buffer_desc_init_data_ptr.max_height = scs->max_input_luma_height; |
90 | 0 | picture_buffer_desc_init_data_ptr.bit_depth = scs->encoder_bit_depth; |
91 | 0 | picture_buffer_desc_init_data_ptr.color_format = scs->static_config.encoder_color_format; |
92 | 0 | picture_buffer_desc_init_data_ptr.buffer_enable_mask = PICTURE_BUFFER_DESC_FULL_MASK; |
93 | 0 | picture_buffer_desc_init_data_ptr.rest_units_per_tile = scs->rest_units_per_tile; |
94 | 0 | picture_buffer_desc_init_data_ptr.sb_total_count = scs->b64_total_count; |
95 | 0 | uint16_t padding = scs->super_block_size + 32; |
96 | 0 | if (scs->static_config.superres_mode > SUPERRES_NONE || scs->static_config.resize_mode > RESIZE_NONE) { |
97 | 0 | padding += scs->super_block_size; |
98 | 0 | } |
99 | |
|
100 | 0 | picture_buffer_desc_init_data_ptr.border = padding; |
101 | 0 | picture_buffer_desc_init_data_ptr.mfmv = scs->mfmv_enabled; |
102 | 0 | picture_buffer_desc_init_data_ptr.is_16bit_pipeline = scs->is_16bit_pipeline; |
103 | |
|
104 | 0 | picture_buffer_desc_init_data_ptr.split_mode = false; |
105 | 0 | if (is_16bit) { |
106 | 0 | picture_buffer_desc_init_data_ptr.bit_depth = EB_TEN_BIT; |
107 | 0 | } |
108 | |
|
109 | 0 | EbPictureBufferDescInitData picture_buffer_desc_init_data_16bit_ptr = picture_buffer_desc_init_data_ptr; |
110 | | //TODO:12bit |
111 | 0 | if (picture_buffer_desc_init_data_ptr.bit_depth == EB_TEN_BIT) { |
112 | 0 | picture_buffer_desc_init_data_16bit_ptr.split_mode = true; |
113 | 0 | svt_picture_buffer_desc_update(ref_object->reference_picture, (EbPtr)&picture_buffer_desc_init_data_16bit_ptr); |
114 | 0 | } else { |
115 | | // Hsan: set split_mode to 0 to as 8BIT input |
116 | 0 | picture_buffer_desc_init_data_ptr.split_mode = false; |
117 | 0 | svt_picture_buffer_desc_update(ref_object->reference_picture, (EbPtr)&picture_buffer_desc_init_data_ptr); |
118 | |
|
119 | 0 | initialize_samples_neighboring_reference_picture(ref_object->reference_picture); |
120 | 0 | } |
121 | |
|
122 | 0 | ref_object->mi_rows = ref_object->reference_picture->height >> MI_SIZE_LOG2; |
123 | 0 | ref_object->mi_cols = ref_object->reference_picture->width >> MI_SIZE_LOG2; |
124 | 0 | return EB_ErrorNone; |
125 | 0 | } |
126 | | |
127 | | /***************************************** |
128 | | * svt_picture_buffer_desc_ctor |
129 | | * Initializes the Buffer Descriptor's |
130 | | * values that are fixed for the life of |
131 | | * the descriptor. |
132 | | *****************************************/ |
133 | 896 | EbErrorType svt_reference_object_ctor(EbReferenceObject* ref_object, EbPtr object_init_data_ptr) { |
134 | 896 | EbReferenceObjectDescInitData* ref_init_ptr = (EbReferenceObjectDescInitData*)object_init_data_ptr; |
135 | 896 | EbPictureBufferDescInitData* picture_buffer_desc_init_data_ptr = &ref_init_ptr->reference_picture_desc_init_data; |
136 | 896 | EbPictureBufferDescInitData picture_buffer_desc_init_data_16bit_ptr = *picture_buffer_desc_init_data_ptr; |
137 | | |
138 | 896 | ref_object->dctor = svt_reference_object_dctor; |
139 | | //TODO:12bit |
140 | 896 | if (picture_buffer_desc_init_data_16bit_ptr.bit_depth == EB_TEN_BIT) { |
141 | | // Hsan: set split_mode to 0 to construct the packed reference buffer (used @ EP) |
142 | | // Use 10bit here to use in MD |
143 | 0 | picture_buffer_desc_init_data_16bit_ptr.split_mode = true; |
144 | 0 | picture_buffer_desc_init_data_16bit_ptr.bit_depth = EB_TEN_BIT; |
145 | 0 | EB_NEW(ref_object->reference_picture, |
146 | 0 | svt_picture_buffer_desc_ctor, |
147 | 0 | (EbPtr)&picture_buffer_desc_init_data_16bit_ptr); |
148 | 896 | } else { |
149 | | // Hsan: set split_mode to 0 to as 8BIT input |
150 | 896 | picture_buffer_desc_init_data_ptr->split_mode = false; |
151 | 896 | EB_NEW(ref_object->reference_picture, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); |
152 | | |
153 | 896 | initialize_samples_neighboring_reference_picture(ref_object->reference_picture); |
154 | 896 | } |
155 | 896 | uint32_t mi_rows = ref_object->reference_picture->height >> MI_SIZE_LOG2; |
156 | 896 | uint32_t mi_cols = ref_object->reference_picture->width >> MI_SIZE_LOG2; |
157 | | // there should be one unit info per plane and per rest unit |
158 | 896 | EB_MALLOC_2D(ref_object->unit_info, MAX_PLANES, picture_buffer_desc_init_data_ptr->rest_units_per_tile); |
159 | | |
160 | 896 | if (picture_buffer_desc_init_data_ptr->mfmv) { |
161 | | //MFMV map is 8x8 based. |
162 | 896 | const int mem_size = ((mi_rows + 1) >> 1) * ((mi_cols + 1) >> 1); |
163 | 896 | EB_CALLOC_ALIGNED_ARRAY(ref_object->mvs, mem_size); |
164 | 896 | } |
165 | 896 | svt_memset(&ref_object->film_grain_params, 0, sizeof(ref_object->film_grain_params)); |
166 | | // set all supplemental downscaled reference picture pointers to NULL |
167 | | // resize_mutex[][] is only taken by the super-res / reference-rescaling paths (resize.c); |
168 | | // skip creating those mutexes when neither super-res nor resize is enabled. |
169 | 896 | const bool scaling_enabled = ref_init_ptr->static_config->superres_mode > SUPERRES_NONE || |
170 | 896 | ref_init_ptr->static_config->resize_mode > RESIZE_NONE; |
171 | 8.96k | for (uint8_t sr_denom_idx = 0; sr_denom_idx < NUM_SR_SCALES + 1; sr_denom_idx++) { |
172 | 88.7k | for (uint8_t resize_denom_idx = 0; resize_denom_idx < NUM_RESIZE_SCALES + 1; resize_denom_idx++) { |
173 | 80.6k | ref_object->downscaled_reference_picture[sr_denom_idx][resize_denom_idx] = NULL; |
174 | 80.6k | ref_object->downscaled_picture_number[sr_denom_idx][resize_denom_idx] = (uint64_t)~0; |
175 | 80.6k | if (scaling_enabled) { |
176 | 0 | EB_CREATE_MUTEX(ref_object->resize_mutex[sr_denom_idx][resize_denom_idx]); |
177 | 0 | } |
178 | 80.6k | } |
179 | 8.06k | } |
180 | | |
181 | 896 | ref_object->mi_rows = mi_rows; |
182 | 896 | ref_object->mi_cols = mi_cols; |
183 | 896 | EB_MALLOC_ARRAY(ref_object->sb_intra, picture_buffer_desc_init_data_ptr->sb_total_count); |
184 | 896 | EB_MALLOC_ARRAY(ref_object->sb_skip, picture_buffer_desc_init_data_ptr->sb_total_count); |
185 | 896 | EB_MALLOC_ARRAY(ref_object->sb_64x64_mvp, picture_buffer_desc_init_data_ptr->sb_total_count); |
186 | 896 | EB_MALLOC_ARRAY(ref_object->sb_me_64x64_dist, picture_buffer_desc_init_data_ptr->sb_total_count); |
187 | 896 | EB_MALLOC_ARRAY(ref_object->sb_me_8x8_cost_var, picture_buffer_desc_init_data_ptr->sb_total_count); |
188 | 896 | EB_MALLOC_ARRAY(ref_object->sb_min_sq_size, picture_buffer_desc_init_data_ptr->sb_total_count); |
189 | 896 | EB_MALLOC_ARRAY(ref_object->sb_max_sq_size, picture_buffer_desc_init_data_ptr->sb_total_count); |
190 | 896 | return EB_ErrorNone; |
191 | 896 | } |
192 | | |
193 | 896 | EbErrorType svt_reference_object_creator(EbPtr* object_dbl_ptr, EbPtr object_init_data_ptr) { |
194 | 896 | EbReferenceObject* obj; |
195 | | |
196 | 896 | *object_dbl_ptr = NULL; |
197 | 896 | EB_NEW(obj, svt_reference_object_ctor, object_init_data_ptr); |
198 | 896 | *object_dbl_ptr = obj; |
199 | | |
200 | 896 | return EB_ErrorNone; |
201 | 896 | } |
202 | | |
203 | 0 | EbErrorType svt_reference_object_reset(EbReferenceObject* ref_object, SequenceControlSet* scs) { |
204 | 0 | ref_object->mi_rows = scs->max_input_luma_height >> MI_SIZE_LOG2; |
205 | 0 | ref_object->mi_cols = scs->max_input_luma_width >> MI_SIZE_LOG2; |
206 | |
|
207 | 0 | return EB_ErrorNone; |
208 | 0 | } |
209 | | |
210 | 1.79k | static void svt_pa_reference_object_dctor(EbPtr p) { |
211 | 1.79k | EbPaReferenceObject* obj = (EbPaReferenceObject*)p; |
212 | 1.79k | if (obj->dummy_obj) { |
213 | 0 | return; |
214 | 0 | } |
215 | 1.79k | EB_DELETE(obj->input_padded_pic); |
216 | 1.79k | EB_DELETE(obj->quarter_downsampled_picture_ptr); |
217 | 1.79k | EB_DELETE(obj->sixteenth_downsampled_picture_ptr); |
218 | 17.9k | for (uint8_t sr_denom_idx = 0; sr_denom_idx < NUM_SR_SCALES + 1; sr_denom_idx++) { |
219 | 177k | for (uint8_t resize_denom_idx = 0; resize_denom_idx < NUM_RESIZE_SCALES + 1; resize_denom_idx++) { |
220 | 161k | if (obj->downscaled_input_padded_picture_ptr[sr_denom_idx][resize_denom_idx] != NULL) { |
221 | 0 | EB_DELETE(obj->downscaled_input_padded_picture_ptr[sr_denom_idx][resize_denom_idx]); |
222 | 0 | EB_DELETE(obj->downscaled_quarter_downsampled_picture_ptr[sr_denom_idx][resize_denom_idx]); |
223 | 0 | EB_DELETE(obj->downscaled_sixteenth_downsampled_picture_ptr[sr_denom_idx][resize_denom_idx]); |
224 | 0 | } |
225 | 161k | EB_DESTROY_MUTEX(obj->resize_mutex[sr_denom_idx][resize_denom_idx]); |
226 | 161k | } |
227 | 16.1k | } |
228 | 1.79k | } |
229 | | |
230 | 0 | static void svt_tpl_reference_object_dctor(EbPtr p) { |
231 | 0 | EbTplReferenceObject* obj = (EbTplReferenceObject*)p; |
232 | 0 | EB_DELETE(obj->ref_picture_ptr); |
233 | 0 | } |
234 | | |
235 | | /* |
236 | | svt_pa_reference_param_update: update the parameters in EbPaReferenceObject for changing the resolution on the fly |
237 | | */ |
238 | 0 | EbErrorType svt_pa_reference_param_update(EbPaReferenceObject* pa_ref_obj, SequenceControlSet* scs) { |
239 | 0 | EbPictureBufferDescInitData ref_pic_buf_desc_init_data; |
240 | 0 | EbPictureBufferDescInitData quart_pic_buf_desc_init_data; |
241 | 0 | EbPictureBufferDescInitData sixteenth_pic_buf_desc_init_data; |
242 | | // PA Reference Picture Buffers |
243 | | // Currently, only Luma samples are needed in the PA |
244 | 0 | ref_pic_buf_desc_init_data.max_width = scs->max_input_luma_width; |
245 | 0 | ref_pic_buf_desc_init_data.max_height = scs->max_input_luma_height; |
246 | 0 | ref_pic_buf_desc_init_data.bit_depth = EB_EIGHT_BIT; |
247 | 0 | ref_pic_buf_desc_init_data.color_format = EB_YUV420; //use 420 for picture analysis |
248 | | //No full-resolution pixel data is allocated for PA REF, |
249 | | // it points directly to the Luma input samples of the app data |
250 | 0 | ref_pic_buf_desc_init_data.buffer_enable_mask = 0; |
251 | |
|
252 | 0 | ref_pic_buf_desc_init_data.border = scs->border; |
253 | 0 | ref_pic_buf_desc_init_data.split_mode = false; |
254 | 0 | ref_pic_buf_desc_init_data.rest_units_per_tile = scs->rest_units_per_tile; |
255 | 0 | ref_pic_buf_desc_init_data.mfmv = 0; |
256 | 0 | ref_pic_buf_desc_init_data.is_16bit_pipeline = false; |
257 | |
|
258 | 0 | quart_pic_buf_desc_init_data.max_width = scs->max_input_luma_width >> 1; |
259 | 0 | quart_pic_buf_desc_init_data.max_height = scs->max_input_luma_height >> 1; |
260 | 0 | quart_pic_buf_desc_init_data.bit_depth = EB_EIGHT_BIT; |
261 | 0 | quart_pic_buf_desc_init_data.color_format = EB_YUV420; |
262 | 0 | quart_pic_buf_desc_init_data.buffer_enable_mask = PICTURE_BUFFER_DESC_LUMA_MASK; |
263 | 0 | quart_pic_buf_desc_init_data.border = scs->b64_size >> 1; |
264 | 0 | quart_pic_buf_desc_init_data.split_mode = false; |
265 | 0 | quart_pic_buf_desc_init_data.rest_units_per_tile = scs->rest_units_per_tile; |
266 | 0 | quart_pic_buf_desc_init_data.mfmv = 0; |
267 | 0 | quart_pic_buf_desc_init_data.is_16bit_pipeline = false; |
268 | |
|
269 | 0 | sixteenth_pic_buf_desc_init_data.max_width = scs->max_input_luma_width >> 2; |
270 | 0 | sixteenth_pic_buf_desc_init_data.max_height = scs->max_input_luma_height >> 2; |
271 | 0 | sixteenth_pic_buf_desc_init_data.bit_depth = EB_EIGHT_BIT; |
272 | 0 | sixteenth_pic_buf_desc_init_data.color_format = EB_YUV420; |
273 | 0 | sixteenth_pic_buf_desc_init_data.buffer_enable_mask = PICTURE_BUFFER_DESC_LUMA_MASK; |
274 | 0 | sixteenth_pic_buf_desc_init_data.border = scs->b64_size >> 2; |
275 | 0 | sixteenth_pic_buf_desc_init_data.split_mode = false; |
276 | 0 | sixteenth_pic_buf_desc_init_data.rest_units_per_tile = scs->rest_units_per_tile; |
277 | 0 | sixteenth_pic_buf_desc_init_data.mfmv = 0; |
278 | 0 | sixteenth_pic_buf_desc_init_data.is_16bit_pipeline = false; |
279 | | |
280 | | // Reference picture constructor |
281 | 0 | svt_picture_buffer_desc_update(pa_ref_obj->input_padded_pic, (EbPtr)&ref_pic_buf_desc_init_data); |
282 | | // Downsampled reference picture constructor |
283 | 0 | svt_picture_buffer_desc_update(pa_ref_obj->quarter_downsampled_picture_ptr, (EbPtr)&quart_pic_buf_desc_init_data); |
284 | 0 | svt_picture_buffer_desc_update(pa_ref_obj->sixteenth_downsampled_picture_ptr, |
285 | 0 | (EbPtr)&sixteenth_pic_buf_desc_init_data); |
286 | 0 | return EB_ErrorNone; |
287 | 0 | } |
288 | | |
289 | | /***************************************** |
290 | | * svt_pa_reference_object_ctor |
291 | | * Initializes the Buffer Descriptor's |
292 | | * values that are fixed for the life of |
293 | | * the descriptor. |
294 | | *****************************************/ |
295 | 1.79k | EbErrorType svt_pa_reference_object_ctor(EbPaReferenceObject* pa_ref_obj_, EbPtr object_init_data_ptr) { |
296 | 1.79k | EbPictureBufferDescInitData* picture_buffer_desc_init_data_ptr = (EbPictureBufferDescInitData*)object_init_data_ptr; |
297 | 1.79k | const EbPaReferenceObjectDescInitData* pa_init = (EbPaReferenceObjectDescInitData*)object_init_data_ptr; |
298 | | |
299 | 1.79k | pa_ref_obj_->dctor = svt_pa_reference_object_dctor; |
300 | | |
301 | | // Reference picture constructor |
302 | 1.79k | EB_NEW(pa_ref_obj_->input_padded_pic, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); |
303 | | // Downsampled reference picture constructor |
304 | 1.79k | if (picture_buffer_desc_init_data_ptr[1].buffer_enable_mask) { |
305 | 0 | EB_NEW(pa_ref_obj_->quarter_downsampled_picture_ptr, |
306 | 0 | svt_picture_buffer_desc_ctor, |
307 | 0 | (EbPtr)(picture_buffer_desc_init_data_ptr + 1)); |
308 | 0 | } |
309 | 1.79k | if (picture_buffer_desc_init_data_ptr[2].buffer_enable_mask) { |
310 | 0 | EB_NEW(pa_ref_obj_->sixteenth_downsampled_picture_ptr, |
311 | 0 | svt_picture_buffer_desc_ctor, |
312 | 0 | (EbPtr)(picture_buffer_desc_init_data_ptr + 2)); |
313 | 0 | } |
314 | | // set all supplemental downscaled reference picture pointers to NULL |
315 | | // resize_mutex[][] is only taken by the super-res / reference-rescaling paths (resize.c); |
316 | | // skip creating those mutexes when neither super-res nor resize is enabled. |
317 | 1.79k | const bool scaling_enabled = pa_init->static_config->superres_mode > SUPERRES_NONE || |
318 | 1.79k | pa_init->static_config->resize_mode > RESIZE_NONE; |
319 | 17.9k | for (uint8_t sr_down_idx = 0; sr_down_idx < NUM_SR_SCALES + 1; sr_down_idx++) { |
320 | 177k | for (uint8_t resize_down_idx = 0; resize_down_idx < NUM_RESIZE_SCALES + 1; resize_down_idx++) { |
321 | 161k | pa_ref_obj_->downscaled_input_padded_picture_ptr[sr_down_idx][resize_down_idx] = NULL; |
322 | 161k | pa_ref_obj_->downscaled_quarter_downsampled_picture_ptr[sr_down_idx][resize_down_idx] = NULL; |
323 | 161k | pa_ref_obj_->downscaled_sixteenth_downsampled_picture_ptr[sr_down_idx][resize_down_idx] = NULL; |
324 | 161k | pa_ref_obj_->downscaled_picture_number[sr_down_idx][resize_down_idx] = (uint64_t)~0; |
325 | 161k | if (scaling_enabled) { |
326 | 0 | EB_CREATE_MUTEX(pa_ref_obj_->resize_mutex[sr_down_idx][resize_down_idx]); |
327 | 0 | } |
328 | 161k | } |
329 | 16.1k | } |
330 | | |
331 | 1.79k | return EB_ErrorNone; |
332 | 1.79k | } |
333 | | |
334 | 1.79k | EbErrorType svt_pa_reference_object_creator(EbPtr* object_dbl_ptr, EbPtr object_init_data_ptr) { |
335 | 1.79k | EbPaReferenceObject* obj; |
336 | | |
337 | 1.79k | *object_dbl_ptr = NULL; |
338 | 1.79k | EB_NEW(obj, svt_pa_reference_object_ctor, object_init_data_ptr); |
339 | 1.79k | *object_dbl_ptr = obj; |
340 | | |
341 | 1.79k | return EB_ErrorNone; |
342 | 1.79k | } |
343 | | |
344 | | /* |
345 | | svt_tpl_reference_param_update: update the parameters in tpl_ref_obj for changing the resolution on the fly |
346 | | */ |
347 | 0 | EbErrorType svt_tpl_reference_param_update(EbTplReferenceObject* tpl_ref_obj, SequenceControlSet* scs) { |
348 | 0 | EbPictureBufferDescInitData ref_pic_buf_desc_init_data; |
349 | | // PA Reference Picture Buffers |
350 | | // Currently, only Luma samples are needed in the PA |
351 | 0 | ref_pic_buf_desc_init_data.max_width = scs->max_input_luma_width; |
352 | 0 | ref_pic_buf_desc_init_data.max_height = scs->max_input_luma_height; |
353 | 0 | ref_pic_buf_desc_init_data.bit_depth = EB_EIGHT_BIT; |
354 | 0 | ref_pic_buf_desc_init_data.color_format = EB_YUV420; //use 420 for picture analysis |
355 | | |
356 | | // Allocate one ref pic to be used in TPL |
357 | 0 | ref_pic_buf_desc_init_data.buffer_enable_mask = PICTURE_BUFFER_DESC_Y_FLAG; |
358 | |
|
359 | 0 | ref_pic_buf_desc_init_data.border = TPL_PAD; |
360 | 0 | ref_pic_buf_desc_init_data.split_mode = false; |
361 | 0 | ref_pic_buf_desc_init_data.mfmv = 0; |
362 | 0 | ref_pic_buf_desc_init_data.is_16bit_pipeline = false; |
363 | |
|
364 | 0 | ref_pic_buf_desc_init_data.rest_units_per_tile = 0; |
365 | 0 | ref_pic_buf_desc_init_data.sb_total_count = scs->sb_total_count; |
366 | | |
367 | | // Reference picture constructor |
368 | 0 | svt_picture_buffer_desc_update(tpl_ref_obj->ref_picture_ptr, (EbPtr)&ref_pic_buf_desc_init_data); |
369 | |
|
370 | 0 | return EB_ErrorNone; |
371 | 0 | } |
372 | | |
373 | 0 | EbErrorType svt_tpl_reference_object_ctor(EbTplReferenceObject* tpl_ref_obj_, EbPtr object_init_data_ptr) { |
374 | 0 | EbPictureBufferDescInitData* picture_buffer_desc_init_data_ptr = (EbPictureBufferDescInitData*)object_init_data_ptr; |
375 | |
|
376 | 0 | tpl_ref_obj_->dctor = svt_tpl_reference_object_dctor; |
377 | | |
378 | | // Reference picture constructor |
379 | 0 | EB_NEW(tpl_ref_obj_->ref_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); |
380 | | |
381 | 0 | return EB_ErrorNone; |
382 | 0 | } |
383 | | |
384 | 0 | EbErrorType svt_tpl_reference_object_creator(EbPtr* object_dbl_ptr, EbPtr object_init_data_ptr) { |
385 | 0 | EbTplReferenceObject* obj; |
386 | |
|
387 | 0 | *object_dbl_ptr = NULL; |
388 | 0 | EB_NEW(obj, svt_tpl_reference_object_ctor, object_init_data_ptr); |
389 | 0 | *object_dbl_ptr = obj; |
390 | |
|
391 | 0 | return EB_ErrorNone; |
392 | 0 | } |
393 | | |
394 | | /************************************************ |
395 | | * Release Pa Reference Objects |
396 | | ** Check if reference pictures are needed |
397 | | ** release them when appropriate |
398 | | ************************************************/ |
399 | 448 | void svt_aom_release_pa_reference_objects(SequenceControlSet* scs, PictureParentControlSet* pcs) { |
400 | 448 | (void)scs; |
401 | | // PA Reference Pictures |
402 | 448 | if (pcs->slice_type != I_SLICE) { |
403 | | // Release the PA reference Pictures from both lists |
404 | 0 | for (REF_FRAME_MINUS1 ref = LAST; ref < ALT + 1; ref++) { |
405 | 0 | const uint8_t list_idx = get_list_idx(ref + 1); |
406 | 0 | const uint8_t ref_idx = get_ref_frame_idx(ref + 1); |
407 | 0 | if (pcs->ref_pa_pic_ptr_array[list_idx][ref_idx] != NULL) { |
408 | 0 | svt_release_object(pcs->ref_pa_pic_ptr_array[list_idx][ref_idx]); |
409 | 0 | if (pcs->ref_y8b_array[list_idx][ref_idx]) { |
410 | | //y8b needs to get decremented at the same time of pa ref |
411 | 0 | svt_release_object(pcs->ref_y8b_array[list_idx][ref_idx]); |
412 | 0 | } |
413 | 0 | } |
414 | 0 | } |
415 | 0 | } |
416 | | |
417 | 448 | if (pcs->pa_ref_pic_wrapper != NULL) { |
418 | | //assert((int32_t)pcs->pa_ref_pic_wrapper->live_count > 0); |
419 | 448 | svt_release_object(pcs->pa_ref_pic_wrapper); |
420 | | |
421 | 448 | if (pcs->y8b_wrapper) { |
422 | | //y8b needs to get decremented at the same time of pa ref |
423 | 448 | svt_release_object(pcs->y8b_wrapper); |
424 | 448 | } |
425 | 448 | } |
426 | | // Mark that the PCS released PA references |
427 | 448 | pcs->reference_released = 1; |
428 | 448 | return; |
429 | 448 | } |