MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / alloc_picture

Function alloc_picture

libavcodec/h264_slice.c:188–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188static int alloc_picture(H264Context *h, H264Picture *pic)
189{
190 int i, ret = 0;
191
192 av_assert0(!pic->f->data[0]);
193
194 if (h->sei.common.lcevc.info) {
195 HEVCSEILCEVC *lcevc = &h->sei.common.lcevc;
196 ret = ff_frame_new_side_data_from_buf(h->avctx, pic->f, AV_FRAME_DATA_LCEVC, &lcevc->info);
197 if (ret < 0)
198 return ret;
199 }
200
201 pic->tf.f = pic->f;
202 ret = ff_thread_get_ext_buffer(h->avctx, &pic->tf,
203 pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
204 if (ret < 0)
205 goto fail;
206
207 if (pic->needs_fg) {
208 pic->f_grain->format = pic->f->format;
209 pic->f_grain->width = pic->f->width;
210 pic->f_grain->height = pic->f->height;
211 ret = ff_thread_get_buffer(h->avctx, pic->f_grain, 0);
212 if (ret < 0)
213 goto fail;
214 }
215
216 ret = ff_hwaccel_frame_priv_alloc(h->avctx, &pic->hwaccel_picture_private);
217 if (ret < 0)
218 goto fail;
219
220 if (h->decode_error_flags_pool) {
221 pic->decode_error_flags = av_refstruct_pool_get(h->decode_error_flags_pool);
222 if (!pic->decode_error_flags)
223 goto fail;
224 atomic_init(pic->decode_error_flags, 0);
225 }
226
227 if (CONFIG_GRAY && !h->avctx->hwaccel && h->flags & AV_CODEC_FLAG_GRAY && pic->f->data[2]) {
228 int h_chroma_shift, v_chroma_shift;
229 av_pix_fmt_get_chroma_sub_sample(pic->f->format,
230 &h_chroma_shift, &v_chroma_shift);
231
232 for(i=0; i<AV_CEIL_RSHIFT(pic->f->height, v_chroma_shift); i++) {
233 memset(pic->f->data[1] + pic->f->linesize[1]*i,
234 0x80, AV_CEIL_RSHIFT(pic->f->width, h_chroma_shift));
235 memset(pic->f->data[2] + pic->f->linesize[2]*i,
236 0x80, AV_CEIL_RSHIFT(pic->f->width, h_chroma_shift));
237 }
238 }
239
240 if (!h->qscale_table_pool) {
241 ret = init_table_pools(h);
242 if (ret < 0)
243 goto fail;
244 }
245

Callers 1

h264_frame_startFunction · 0.70

Calls 9

av_refstruct_pool_getFunction · 0.85
init_table_poolsFunction · 0.85
av_refstruct_ref_cFunction · 0.85
ff_h264_unref_pictureFunction · 0.85
ff_thread_get_ext_bufferFunction · 0.70
ff_thread_get_bufferFunction · 0.70

Tested by

no test coverage detected