/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.84k | uint16_t recon_width, uint16_t recon_height) { |
23 | 2.84k | uint8_t* recon_samples_ptr; |
24 | 2.84k | uint16_t sample_count; |
25 | | |
26 | | // 1. zero out the top row |
27 | 2.84k | recon_samples_ptr = recon_samples_buffer_ptr - stride - 1; |
28 | 2.84k | svt_memset(recon_samples_ptr, 0, sizeof(uint8_t) * (1 + recon_width + 1)); |
29 | | |
30 | | // 2. zero out the bottom row |
31 | 2.84k | recon_samples_ptr = recon_samples_buffer_ptr + (recon_height)*stride - 1; |
32 | 2.84k | svt_memset(recon_samples_ptr, 0, sizeof(uint8_t) * (1 + recon_width + 1)); |
33 | | |
34 | | // 3. zero out the left column |
35 | 2.84k | recon_samples_ptr = recon_samples_buffer_ptr - 1; |
36 | 369k | for (sample_count = 0; sample_count < recon_height; sample_count++) { |
37 | 366k | recon_samples_ptr[sample_count * stride] = 0; |
38 | 366k | } |
39 | | // 4. zero out the right column |
40 | 2.84k | recon_samples_ptr = recon_samples_buffer_ptr + recon_width; |
41 | 369k | for (sample_count = 0; sample_count < recon_height; sample_count++) { |
42 | 366k | recon_samples_ptr[sample_count * stride] = 0; |
43 | 366k | } |
44 | 2.84k | } |
45 | | |
46 | 948 | static void initialize_samples_neighboring_reference_picture(EbPictureBufferDesc* ref_pic) { |
47 | 948 | initialize_samples_neighboring_reference_picture_8bit( |
48 | 948 | ref_pic->y_buffer, ref_pic->y_stride, ref_pic->width, ref_pic->height); |
49 | | |
50 | 948 | initialize_samples_neighboring_reference_picture_8bit( |
51 | 948 | ref_pic->u_buffer, ref_pic->u_stride, ref_pic->width >> 1, ref_pic->height >> 1); |
52 | | |
53 | 948 | initialize_samples_neighboring_reference_picture_8bit( |
54 | 948 | ref_pic->v_buffer, ref_pic->v_stride, ref_pic->width >> 1, ref_pic->height >> 1); |
55 | 948 | } |
56 | | |
57 | 948 | static void svt_reference_object_dctor(EbPtr p) { |
58 | 948 | EbReferenceObject* obj = (EbReferenceObject*)p; |
59 | | |
60 | 948 | EB_DELETE(obj->reference_picture); |
61 | 948 | EB_FREE_2D(obj->unit_info); |
62 | 948 | EB_FREE_ALIGNED_ARRAY(obj->mvs); |
63 | 948 | EB_FREE_ARRAY(obj->sb_intra); |
64 | 948 | EB_FREE_ARRAY(obj->sb_skip); |
65 | 948 | EB_FREE_ARRAY(obj->sb_64x64_mvp); |
66 | 948 | EB_FREE_ARRAY(obj->sb_me_64x64_dist); |
67 | 948 | EB_FREE_ARRAY(obj->sb_me_8x8_cost_var); |
68 | 948 | EB_FREE_ARRAY(obj->sb_min_sq_size); |
69 | 948 | EB_FREE_ARRAY(obj->sb_max_sq_size); |
70 | 9.48k | for (uint8_t sr_denom_idx = 0; sr_denom_idx < NUM_SR_SCALES + 1; sr_denom_idx++) { |
71 | 93.8k | for (uint8_t resize_denom_idx = 0; resize_denom_idx < NUM_RESIZE_SCALES + 1; resize_denom_idx++) { |
72 | 85.3k | 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 | 85.3k | EB_DESTROY_MUTEX(obj->resize_mutex[sr_denom_idx][resize_denom_idx]); |
76 | 85.3k | } |
77 | 8.53k | } |
78 | 948 | } |
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 | 948 | EbErrorType svt_reference_object_ctor(EbReferenceObject* ref_object, EbPtr object_init_data_ptr) { |
134 | 948 | EbReferenceObjectDescInitData* ref_init_ptr = (EbReferenceObjectDescInitData*)object_init_data_ptr; |
135 | 948 | EbPictureBufferDescInitData* picture_buffer_desc_init_data_ptr = &ref_init_ptr->reference_picture_desc_init_data; |
136 | 948 | EbPictureBufferDescInitData picture_buffer_desc_init_data_16bit_ptr = *picture_buffer_desc_init_data_ptr; |
137 | | |
138 | 948 | ref_object->dctor = svt_reference_object_dctor; |
139 | | //TODO:12bit |
140 | 948 | 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 | 948 | } else { |
149 | | // Hsan: set split_mode to 0 to as 8BIT input |
150 | 948 | picture_buffer_desc_init_data_ptr->split_mode = false; |
151 | 948 | EB_NEW(ref_object->reference_picture, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); |
152 | | |
153 | 948 | initialize_samples_neighboring_reference_picture(ref_object->reference_picture); |
154 | 948 | } |
155 | 948 | uint32_t mi_rows = ref_object->reference_picture->height >> MI_SIZE_LOG2; |
156 | 948 | 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 | 948 | EB_MALLOC_2D(ref_object->unit_info, MAX_PLANES, picture_buffer_desc_init_data_ptr->rest_units_per_tile); |
159 | | |
160 | 948 | if (picture_buffer_desc_init_data_ptr->mfmv) { |
161 | | //MFMV map is 8x8 based. |
162 | 948 | const int mem_size = ((mi_rows + 1) >> 1) * ((mi_cols + 1) >> 1); |
163 | 948 | EB_CALLOC_ALIGNED_ARRAY(ref_object->mvs, mem_size); |
164 | 948 | } |
165 | 948 | 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 | 9.48k | for (uint8_t sr_denom_idx = 0; sr_denom_idx < NUM_SR_SCALES + 1; sr_denom_idx++) { |
168 | 93.8k | for (uint8_t resize_denom_idx = 0; resize_denom_idx < NUM_RESIZE_SCALES + 1; resize_denom_idx++) { |
169 | 85.3k | ref_object->downscaled_reference_picture[sr_denom_idx][resize_denom_idx] = NULL; |
170 | 85.3k | ref_object->downscaled_picture_number[sr_denom_idx][resize_denom_idx] = (uint64_t)~0; |
171 | 85.3k | EB_CREATE_MUTEX(ref_object->resize_mutex[sr_denom_idx][resize_denom_idx]); |
172 | 85.3k | } |
173 | 8.53k | } |
174 | | |
175 | 948 | ref_object->mi_rows = mi_rows; |
176 | 948 | ref_object->mi_cols = mi_cols; |
177 | 948 | EB_MALLOC_ARRAY(ref_object->sb_intra, picture_buffer_desc_init_data_ptr->sb_total_count); |
178 | 948 | EB_MALLOC_ARRAY(ref_object->sb_skip, picture_buffer_desc_init_data_ptr->sb_total_count); |
179 | 948 | EB_MALLOC_ARRAY(ref_object->sb_64x64_mvp, picture_buffer_desc_init_data_ptr->sb_total_count); |
180 | 948 | EB_MALLOC_ARRAY(ref_object->sb_me_64x64_dist, picture_buffer_desc_init_data_ptr->sb_total_count); |
181 | 948 | EB_MALLOC_ARRAY(ref_object->sb_me_8x8_cost_var, picture_buffer_desc_init_data_ptr->sb_total_count); |
182 | 948 | EB_MALLOC_ARRAY(ref_object->sb_min_sq_size, picture_buffer_desc_init_data_ptr->sb_total_count); |
183 | 948 | EB_MALLOC_ARRAY(ref_object->sb_max_sq_size, picture_buffer_desc_init_data_ptr->sb_total_count); |
184 | 948 | return EB_ErrorNone; |
185 | 948 | } |
186 | | |
187 | 948 | EbErrorType svt_reference_object_creator(EbPtr* object_dbl_ptr, EbPtr object_init_data_ptr) { |
188 | 948 | EbReferenceObject* obj; |
189 | | |
190 | 948 | *object_dbl_ptr = NULL; |
191 | 948 | EB_NEW(obj, svt_reference_object_ctor, object_init_data_ptr); |
192 | 948 | *object_dbl_ptr = obj; |
193 | | |
194 | 948 | return EB_ErrorNone; |
195 | 948 | } |
196 | | |
197 | 0 | EbErrorType svt_reference_object_reset(EbReferenceObject* ref_object, SequenceControlSet* scs) { |
198 | 0 | ref_object->mi_rows = scs->max_input_luma_height >> MI_SIZE_LOG2; |
199 | 0 | ref_object->mi_cols = scs->max_input_luma_width >> MI_SIZE_LOG2; |
200 | |
|
201 | 0 | return EB_ErrorNone; |
202 | 0 | } |
203 | | |
204 | 1.89k | static void svt_pa_reference_object_dctor(EbPtr p) { |
205 | 1.89k | EbPaReferenceObject* obj = (EbPaReferenceObject*)p; |
206 | 1.89k | if (obj->dummy_obj) { |
207 | 0 | return; |
208 | 0 | } |
209 | 1.89k | EB_DELETE(obj->input_padded_pic); |
210 | 1.89k | EB_DELETE(obj->quarter_downsampled_picture_ptr); |
211 | 1.89k | EB_DELETE(obj->sixteenth_downsampled_picture_ptr); |
212 | 18.9k | for (uint8_t sr_denom_idx = 0; sr_denom_idx < NUM_SR_SCALES + 1; sr_denom_idx++) { |
213 | 187k | for (uint8_t resize_denom_idx = 0; resize_denom_idx < NUM_RESIZE_SCALES + 1; resize_denom_idx++) { |
214 | 170k | if (obj->downscaled_input_padded_picture_ptr[sr_denom_idx][resize_denom_idx] != NULL) { |
215 | 0 | EB_DELETE(obj->downscaled_input_padded_picture_ptr[sr_denom_idx][resize_denom_idx]); |
216 | 0 | EB_DELETE(obj->downscaled_quarter_downsampled_picture_ptr[sr_denom_idx][resize_denom_idx]); |
217 | 0 | EB_DELETE(obj->downscaled_sixteenth_downsampled_picture_ptr[sr_denom_idx][resize_denom_idx]); |
218 | 0 | } |
219 | 170k | EB_DESTROY_MUTEX(obj->resize_mutex[sr_denom_idx][resize_denom_idx]); |
220 | 170k | } |
221 | 17.0k | } |
222 | 1.89k | } |
223 | | |
224 | 0 | static void svt_tpl_reference_object_dctor(EbPtr p) { |
225 | 0 | EbTplReferenceObject* obj = (EbTplReferenceObject*)p; |
226 | 0 | EB_DELETE(obj->ref_picture_ptr); |
227 | 0 | } |
228 | | |
229 | | /* |
230 | | svt_pa_reference_param_update: update the parameters in EbPaReferenceObject for changing the resolution on the fly |
231 | | */ |
232 | 0 | EbErrorType svt_pa_reference_param_update(EbPaReferenceObject* pa_ref_obj, SequenceControlSet* scs) { |
233 | 0 | EbPictureBufferDescInitData ref_pic_buf_desc_init_data; |
234 | 0 | EbPictureBufferDescInitData quart_pic_buf_desc_init_data; |
235 | 0 | EbPictureBufferDescInitData sixteenth_pic_buf_desc_init_data; |
236 | | // PA Reference Picture Buffers |
237 | | // Currently, only Luma samples are needed in the PA |
238 | 0 | ref_pic_buf_desc_init_data.max_width = scs->max_input_luma_width; |
239 | 0 | ref_pic_buf_desc_init_data.max_height = scs->max_input_luma_height; |
240 | 0 | ref_pic_buf_desc_init_data.bit_depth = EB_EIGHT_BIT; |
241 | 0 | ref_pic_buf_desc_init_data.color_format = EB_YUV420; //use 420 for picture analysis |
242 | | //No full-resolution pixel data is allocated for PA REF, |
243 | | // it points directly to the Luma input samples of the app data |
244 | 0 | ref_pic_buf_desc_init_data.buffer_enable_mask = 0; |
245 | |
|
246 | 0 | ref_pic_buf_desc_init_data.border = scs->border; |
247 | 0 | ref_pic_buf_desc_init_data.split_mode = false; |
248 | 0 | ref_pic_buf_desc_init_data.rest_units_per_tile = scs->rest_units_per_tile; |
249 | 0 | ref_pic_buf_desc_init_data.mfmv = 0; |
250 | 0 | ref_pic_buf_desc_init_data.is_16bit_pipeline = false; |
251 | |
|
252 | 0 | quart_pic_buf_desc_init_data.max_width = scs->max_input_luma_width >> 1; |
253 | 0 | quart_pic_buf_desc_init_data.max_height = scs->max_input_luma_height >> 1; |
254 | 0 | quart_pic_buf_desc_init_data.bit_depth = EB_EIGHT_BIT; |
255 | 0 | quart_pic_buf_desc_init_data.color_format = EB_YUV420; |
256 | 0 | quart_pic_buf_desc_init_data.buffer_enable_mask = PICTURE_BUFFER_DESC_LUMA_MASK; |
257 | 0 | quart_pic_buf_desc_init_data.border = scs->b64_size >> 1; |
258 | 0 | quart_pic_buf_desc_init_data.split_mode = false; |
259 | 0 | quart_pic_buf_desc_init_data.rest_units_per_tile = scs->rest_units_per_tile; |
260 | 0 | quart_pic_buf_desc_init_data.mfmv = 0; |
261 | 0 | quart_pic_buf_desc_init_data.is_16bit_pipeline = false; |
262 | |
|
263 | 0 | sixteenth_pic_buf_desc_init_data.max_width = scs->max_input_luma_width >> 2; |
264 | 0 | sixteenth_pic_buf_desc_init_data.max_height = scs->max_input_luma_height >> 2; |
265 | 0 | sixteenth_pic_buf_desc_init_data.bit_depth = EB_EIGHT_BIT; |
266 | 0 | sixteenth_pic_buf_desc_init_data.color_format = EB_YUV420; |
267 | 0 | sixteenth_pic_buf_desc_init_data.buffer_enable_mask = PICTURE_BUFFER_DESC_LUMA_MASK; |
268 | 0 | sixteenth_pic_buf_desc_init_data.border = scs->b64_size >> 2; |
269 | 0 | sixteenth_pic_buf_desc_init_data.split_mode = false; |
270 | 0 | sixteenth_pic_buf_desc_init_data.rest_units_per_tile = scs->rest_units_per_tile; |
271 | 0 | sixteenth_pic_buf_desc_init_data.mfmv = 0; |
272 | 0 | sixteenth_pic_buf_desc_init_data.is_16bit_pipeline = false; |
273 | | |
274 | | // Reference picture constructor |
275 | 0 | svt_picture_buffer_desc_update(pa_ref_obj->input_padded_pic, (EbPtr)&ref_pic_buf_desc_init_data); |
276 | | // Downsampled reference picture constructor |
277 | 0 | svt_picture_buffer_desc_update(pa_ref_obj->quarter_downsampled_picture_ptr, (EbPtr)&quart_pic_buf_desc_init_data); |
278 | 0 | svt_picture_buffer_desc_update(pa_ref_obj->sixteenth_downsampled_picture_ptr, |
279 | 0 | (EbPtr)&sixteenth_pic_buf_desc_init_data); |
280 | 0 | return EB_ErrorNone; |
281 | 0 | } |
282 | | |
283 | | /***************************************** |
284 | | * svt_pa_reference_object_ctor |
285 | | * Initializes the Buffer Descriptor's |
286 | | * values that are fixed for the life of |
287 | | * the descriptor. |
288 | | *****************************************/ |
289 | 1.89k | EbErrorType svt_pa_reference_object_ctor(EbPaReferenceObject* pa_ref_obj_, EbPtr object_init_data_ptr) { |
290 | 1.89k | EbPictureBufferDescInitData* picture_buffer_desc_init_data_ptr = (EbPictureBufferDescInitData*)object_init_data_ptr; |
291 | | |
292 | 1.89k | pa_ref_obj_->dctor = svt_pa_reference_object_dctor; |
293 | | |
294 | | // Reference picture constructor |
295 | 1.89k | EB_NEW(pa_ref_obj_->input_padded_pic, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); |
296 | | // Downsampled reference picture constructor |
297 | 1.89k | if (picture_buffer_desc_init_data_ptr[1].buffer_enable_mask) { |
298 | 0 | EB_NEW(pa_ref_obj_->quarter_downsampled_picture_ptr, |
299 | 0 | svt_picture_buffer_desc_ctor, |
300 | 0 | (EbPtr)(picture_buffer_desc_init_data_ptr + 1)); |
301 | 0 | } |
302 | 1.89k | if (picture_buffer_desc_init_data_ptr[2].buffer_enable_mask) { |
303 | 0 | EB_NEW(pa_ref_obj_->sixteenth_downsampled_picture_ptr, |
304 | 0 | svt_picture_buffer_desc_ctor, |
305 | 0 | (EbPtr)(picture_buffer_desc_init_data_ptr + 2)); |
306 | 0 | } |
307 | | // set all supplemental downscaled reference picture pointers to NULL |
308 | 18.9k | for (uint8_t sr_down_idx = 0; sr_down_idx < NUM_SR_SCALES + 1; sr_down_idx++) { |
309 | 187k | for (uint8_t resize_down_idx = 0; resize_down_idx < NUM_RESIZE_SCALES + 1; resize_down_idx++) { |
310 | 170k | pa_ref_obj_->downscaled_input_padded_picture_ptr[sr_down_idx][resize_down_idx] = NULL; |
311 | 170k | pa_ref_obj_->downscaled_quarter_downsampled_picture_ptr[sr_down_idx][resize_down_idx] = NULL; |
312 | 170k | pa_ref_obj_->downscaled_sixteenth_downsampled_picture_ptr[sr_down_idx][resize_down_idx] = NULL; |
313 | 170k | pa_ref_obj_->downscaled_picture_number[sr_down_idx][resize_down_idx] = (uint64_t)~0; |
314 | 170k | EB_CREATE_MUTEX(pa_ref_obj_->resize_mutex[sr_down_idx][resize_down_idx]); |
315 | 170k | } |
316 | 17.0k | } |
317 | | |
318 | 1.89k | return EB_ErrorNone; |
319 | 1.89k | } |
320 | | |
321 | 1.89k | EbErrorType svt_pa_reference_object_creator(EbPtr* object_dbl_ptr, EbPtr object_init_data_ptr) { |
322 | 1.89k | EbPaReferenceObject* obj; |
323 | | |
324 | 1.89k | *object_dbl_ptr = NULL; |
325 | 1.89k | EB_NEW(obj, svt_pa_reference_object_ctor, object_init_data_ptr); |
326 | 1.89k | *object_dbl_ptr = obj; |
327 | | |
328 | 1.89k | return EB_ErrorNone; |
329 | 1.89k | } |
330 | | |
331 | | /* |
332 | | svt_tpl_reference_param_update: update the parameters in tpl_ref_obj for changing the resolution on the fly |
333 | | */ |
334 | 0 | EbErrorType svt_tpl_reference_param_update(EbTplReferenceObject* tpl_ref_obj, SequenceControlSet* scs) { |
335 | 0 | EbPictureBufferDescInitData ref_pic_buf_desc_init_data; |
336 | | // PA Reference Picture Buffers |
337 | | // Currently, only Luma samples are needed in the PA |
338 | 0 | ref_pic_buf_desc_init_data.max_width = scs->max_input_luma_width; |
339 | 0 | ref_pic_buf_desc_init_data.max_height = scs->max_input_luma_height; |
340 | 0 | ref_pic_buf_desc_init_data.bit_depth = EB_EIGHT_BIT; |
341 | 0 | ref_pic_buf_desc_init_data.color_format = EB_YUV420; //use 420 for picture analysis |
342 | | |
343 | | // Allocate one ref pic to be used in TPL |
344 | 0 | ref_pic_buf_desc_init_data.buffer_enable_mask = PICTURE_BUFFER_DESC_Y_FLAG; |
345 | |
|
346 | 0 | ref_pic_buf_desc_init_data.border = TPL_PAD; |
347 | 0 | ref_pic_buf_desc_init_data.split_mode = false; |
348 | 0 | ref_pic_buf_desc_init_data.mfmv = 0; |
349 | 0 | ref_pic_buf_desc_init_data.is_16bit_pipeline = false; |
350 | |
|
351 | 0 | ref_pic_buf_desc_init_data.rest_units_per_tile = 0; |
352 | 0 | ref_pic_buf_desc_init_data.sb_total_count = scs->sb_total_count; |
353 | | |
354 | | // Reference picture constructor |
355 | 0 | svt_picture_buffer_desc_update(tpl_ref_obj->ref_picture_ptr, (EbPtr)&ref_pic_buf_desc_init_data); |
356 | |
|
357 | 0 | return EB_ErrorNone; |
358 | 0 | } |
359 | | |
360 | 0 | EbErrorType svt_tpl_reference_object_ctor(EbTplReferenceObject* tpl_ref_obj_, EbPtr object_init_data_ptr) { |
361 | 0 | EbPictureBufferDescInitData* picture_buffer_desc_init_data_ptr = (EbPictureBufferDescInitData*)object_init_data_ptr; |
362 | |
|
363 | 0 | tpl_ref_obj_->dctor = svt_tpl_reference_object_dctor; |
364 | | |
365 | | // Reference picture constructor |
366 | 0 | EB_NEW(tpl_ref_obj_->ref_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); |
367 | | |
368 | 0 | return EB_ErrorNone; |
369 | 0 | } |
370 | | |
371 | 0 | EbErrorType svt_tpl_reference_object_creator(EbPtr* object_dbl_ptr, EbPtr object_init_data_ptr) { |
372 | 0 | EbTplReferenceObject* obj; |
373 | |
|
374 | 0 | *object_dbl_ptr = NULL; |
375 | 0 | EB_NEW(obj, svt_tpl_reference_object_ctor, object_init_data_ptr); |
376 | 0 | *object_dbl_ptr = obj; |
377 | |
|
378 | 0 | return EB_ErrorNone; |
379 | 0 | } |
380 | | |
381 | | /************************************************ |
382 | | * Release Pa Reference Objects |
383 | | ** Check if reference pictures are needed |
384 | | ** release them when appropriate |
385 | | ************************************************/ |
386 | 474 | void svt_aom_release_pa_reference_objects(SequenceControlSet* scs, PictureParentControlSet* pcs) { |
387 | 474 | (void)scs; |
388 | | // PA Reference Pictures |
389 | 474 | if (pcs->slice_type != I_SLICE) { |
390 | | // Release the PA reference Pictures from both lists |
391 | 0 | for (REF_FRAME_MINUS1 ref = LAST; ref < ALT + 1; ref++) { |
392 | 0 | const uint8_t list_idx = get_list_idx(ref + 1); |
393 | 0 | const uint8_t ref_idx = get_ref_frame_idx(ref + 1); |
394 | 0 | if (pcs->ref_pa_pic_ptr_array[list_idx][ref_idx] != NULL) { |
395 | 0 | svt_release_object(pcs->ref_pa_pic_ptr_array[list_idx][ref_idx]); |
396 | 0 | if (pcs->ref_y8b_array[list_idx][ref_idx]) { |
397 | | //y8b needs to get decremented at the same time of pa ref |
398 | 0 | svt_release_object(pcs->ref_y8b_array[list_idx][ref_idx]); |
399 | 0 | } |
400 | 0 | } |
401 | 0 | } |
402 | 0 | } |
403 | | |
404 | 474 | if (pcs->pa_ref_pic_wrapper != NULL) { |
405 | | //assert((int32_t)pcs->pa_ref_pic_wrapper->live_count > 0); |
406 | 474 | svt_release_object(pcs->pa_ref_pic_wrapper); |
407 | | |
408 | 474 | if (pcs->y8b_wrapper) { |
409 | | //y8b needs to get decremented at the same time of pa ref |
410 | 474 | svt_release_object(pcs->y8b_wrapper); |
411 | 474 | } |
412 | 474 | } |
413 | | // Mark that the PCS released PA references |
414 | 474 | pcs->reference_released = 1; |
415 | 474 | return; |
416 | 474 | } |