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

Function hw_base_encode_send_frame

libavcodec/hw_base_encode.c:420–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420static int hw_base_encode_send_frame(AVCodecContext *avctx, FFHWBaseEncodeContext *ctx,
421 AVFrame *frame)
422{
423 FFHWBaseEncodePicture *pic;
424 int err;
425
426 if (frame) {
427 av_log(avctx, AV_LOG_DEBUG, "Input frame: %ux%u (%"PRId64").\n",
428 frame->width, frame->height, frame->pts);
429
430 err = hw_base_encode_check_frame(ctx, frame);
431 if (err < 0)
432 return err;
433
434 pic = av_mallocz(sizeof(*pic));
435 if (!pic)
436 return AVERROR(ENOMEM);
437
438 pic->input_image = av_frame_alloc();
439 if (!pic->input_image) {
440 err = AVERROR(ENOMEM);
441 goto fail;
442 }
443
444 if (ctx->recon_frames_ref) {
445 pic->recon_image = av_frame_alloc();
446 if (!pic->recon_image) {
447 err = AVERROR(ENOMEM);
448 goto fail;
449 }
450
451 err = av_hwframe_get_buffer(ctx->recon_frames_ref, pic->recon_image, 0);
452 if (err < 0) {
453 err = AVERROR(ENOMEM);
454 goto fail;
455 }
456 }
457
458 pic->priv = av_mallocz(ctx->op->priv_size);
459 if (!pic->priv) {
460 err = AVERROR(ENOMEM);
461 goto fail;
462 }
463
464 if (ctx->input_order == 0 || frame->pict_type == AV_PICTURE_TYPE_I)
465 pic->force_idr = 1;
466
467 pic->pts = frame->pts;
468 pic->duration = frame->duration;
469
470 if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
471 err = av_buffer_replace(&pic->opaque_ref, frame->opaque_ref);
472 if (err < 0)
473 goto fail;
474
475 pic->opaque = frame->opaque;
476 }
477

Callers 1

Calls 8

av_logFunction · 0.85
av_frame_allocFunction · 0.85
av_hwframe_get_bufferFunction · 0.85
av_buffer_replaceFunction · 0.85
av_frame_move_refFunction · 0.85
base_encode_pic_freeFunction · 0.85
av_malloczFunction · 0.50

Tested by

no test coverage detected