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

Function av_frame_replace

libavutil/frame.c:376–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374}
375
376int av_frame_replace(AVFrame *dst, const AVFrame *src)
377{
378 int ret = 0;
379
380 if (dst == src)
381 return AVERROR(EINVAL);
382
383 if (!src->buf[0]) {
384 av_frame_unref(dst);
385
386 /* duplicate the frame data if it's not refcounted */
387 if ( src->data[0] || src->data[1]
388 || src->data[2] || src->data[3])
389 return av_frame_ref(dst, src);
390
391 ret = frame_copy_props(dst, src, 0);
392 if (ret < 0)
393 goto fail;
394 }
395
396 dst->format = src->format;
397 dst->width = src->width;
398 dst->height = src->height;
399 dst->nb_samples = src->nb_samples;
400
401 ret = av_channel_layout_copy(&dst->ch_layout, &src->ch_layout);
402 if (ret < 0)
403 goto fail;
404
405 av_frame_side_data_free(&dst->side_data, &dst->nb_side_data);
406 av_dict_free(&dst->metadata);
407 ret = frame_copy_props(dst, src, 0);
408 if (ret < 0)
409 goto fail;
410
411 /* replace the buffers */
412 for (int i = 0; i < FF_ARRAY_ELEMS(src->buf); i++) {
413 ret = av_buffer_replace(&dst->buf[i], src->buf[i]);
414 if (ret < 0)
415 goto fail;
416 }
417
418 if (src->extended_buf) {
419 if (dst->nb_extended_buf != src->nb_extended_buf) {
420 int nb_extended_buf = FFMIN(dst->nb_extended_buf, src->nb_extended_buf);
421 void *tmp;
422
423 for (int i = nb_extended_buf; i < dst->nb_extended_buf; i++)
424 av_buffer_unref(&dst->extended_buf[i]);
425
426 tmp = av_realloc_array(dst->extended_buf, src->nb_extended_buf,
427 sizeof(*dst->extended_buf));
428 if (!tmp) {
429 ret = AVERROR(ENOMEM);
430 goto fail;
431 }
432 dst->extended_buf = tmp;
433 dst->nb_extended_buf = src->nb_extended_buf;

Callers 15

av_hwframe_mapFunction · 0.85
ff_hwframe_map_replaceFunction · 0.85
xan_decode_frameFunction · 0.85
mss2_decode_frameFunction · 0.85
ipvideo_decode_frameFunction · 0.85
encode_frameFunction · 0.85
gif_encode_frameFunction · 0.85
tgv_decode_frameFunction · 0.85
submit_frameFunction · 0.85
ff_thread_replace_frameFunction · 0.85
smc_encode_frameFunction · 0.85
qtrle_encode_frameFunction · 0.85

Calls 11

av_frame_unrefFunction · 0.85
av_frame_refFunction · 0.85
frame_copy_propsFunction · 0.85
av_channel_layout_copyFunction · 0.85
av_frame_side_data_freeFunction · 0.85
av_dict_freeFunction · 0.85
av_buffer_replaceFunction · 0.85
av_buffer_unrefFunction · 0.85
av_realloc_arrayFunction · 0.85
av_freepFunction · 0.85
av_memdupFunction · 0.85

Tested by

no test coverage detected