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

Function frame_data_ensure

fftools/ffmpeg.c:413–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413static int frame_data_ensure(AVBufferRef **dst, int writable)
414{
415 AVBufferRef *src = *dst;
416
417 if (!src || (writable && !av_buffer_is_writable(src))) {
418 FrameData *fd;
419
420 fd = av_mallocz(sizeof(*fd));
421 if (!fd)
422 return AVERROR(ENOMEM);
423
424 *dst = av_buffer_create((uint8_t *)fd, sizeof(*fd),
425 frame_data_free, NULL, 0);
426 if (!*dst) {
427 av_buffer_unref(&src);
428 av_freep(&fd);
429 return AVERROR(ENOMEM);
430 }
431
432 if (src) {
433 const FrameData *fd_src = (const FrameData *)src->data;
434
435 memcpy(fd, fd_src, sizeof(*fd));
436 fd->par_enc = NULL;
437 fd->side_data = NULL;
438 fd->nb_side_data = 0;
439
440 if (fd_src->par_enc) {
441 int ret = 0;
442
443 fd->par_enc = avcodec_parameters_alloc();
444 ret = fd->par_enc ?
445 avcodec_parameters_copy(fd->par_enc, fd_src->par_enc) :
446 AVERROR(ENOMEM);
447 if (ret < 0) {
448 av_buffer_unref(dst);
449 av_buffer_unref(&src);
450 return ret;
451 }
452 }
453
454 if (fd_src->nb_side_data) {
455 int ret = clone_side_data(&fd->side_data, &fd->nb_side_data,
456 fd_src->side_data, fd_src->nb_side_data, 0);
457 if (ret < 0) {
458 av_buffer_unref(dst);
459 av_buffer_unref(&src);
460 return ret;
461 }
462 }
463
464 av_buffer_unref(&src);
465 } else {
466 fd->dec.frame_num = UINT64_MAX;
467 fd->dec.pts = AV_NOPTS_VALUE;
468
469 for (unsigned i = 0; i < FF_ARRAY_ELEMS(fd->wallclock); i++)
470 fd->wallclock[i] = INT64_MIN;

Callers 4

frame_dataFunction · 0.85
frame_data_cFunction · 0.85
packet_dataFunction · 0.85
packet_data_cFunction · 0.85

Calls 8

av_buffer_is_writableFunction · 0.85
av_buffer_createFunction · 0.85
av_buffer_unrefFunction · 0.85
av_freepFunction · 0.85
avcodec_parameters_allocFunction · 0.85
avcodec_parameters_copyFunction · 0.85
clone_side_dataFunction · 0.85
av_malloczFunction · 0.50

Tested by

no test coverage detected