From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 2/4] lavc: add API for exporting reconstructed frames from encoders Date: Mon, 18 Jul 2022 09:35:30 -0300 Message-ID: <7132588d-a8c2-6d23-4c9e-ac7539866cdb@gmail.com> (raw) In-Reply-To: <20220717192700.1077-2-anton@khirnov.net> On 7/17/2022 4:26 PM, Anton Khirnov wrote: > diff --git a/libavcodec/encode.c b/libavcodec/encode.c > index 1f39ab1a2f..f15309ce09 100644 > --- a/libavcodec/encode.c > +++ b/libavcodec/encode.c > @@ -594,6 +594,18 @@ int ff_encode_preinit(AVCodecContext *avctx) > return AVERROR(ENOMEM); > } > > + if ((avctx->flags & AV_CODEC_FLAG_RECON_FRAME)) { > + if (!(avctx->codec->capabilities & AV_CODEC_CAP_ENCODER_RECON_FRAME)) { > + av_log(avctx, AV_LOG_ERROR, "Reconstructed frame output requested " > + "from an encoder not supporting it\n"); > + return AVERROR(ENOSYS); > + } > + > + avci->recon_frame = av_frame_alloc(); > + if (!avci->recon_frame) > + return AVERROR(ENOMEM); > + } > + > return 0; > } > > @@ -630,3 +642,16 @@ int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame) > > return 0; > } > + > +int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame *frame) > +{ > + AVCodecInternal *avci = avctx->internal; > + > + if (!avci->recon_frame) > + return AVERROR(EINVAL); > + if (!avci->recon_frame->buf[0]) > + return avci->draining_done ? AVERROR_EOF : AVERROR(EAGAIN); > + > + av_frame_move_ref(frame, avci->recon_frame); The API for avcodec_receive_frame() mentions frame will be unref'd first thing, so you should do that before even the recon_frame checks. > + return 0; > +} _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-07-18 12:35 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-17 19:26 [FFmpeg-devel] [PATCH 1/4] lavu/frame: allow calling av_frame_make_writable() on non-refcounted frames Anton Khirnov 2022-07-17 19:26 ` [FFmpeg-devel] [PATCH 2/4] lavc: add API for exporting reconstructed frames from encoders Anton Khirnov 2022-07-18 12:35 ` James Almer [this message] 2022-07-18 18:05 ` [FFmpeg-devel] [PATCH] " Anton Khirnov 2022-07-18 21:29 ` James Almer 2022-07-17 19:26 ` [FFmpeg-devel] [PATCH 3/4] lavc/mpegvideo_enc: support AV_CODEC_CAP_ENCODER_RECON_FRAME Anton Khirnov 2022-07-17 19:27 ` [FFmpeg-devel] [PATCH 4/4] lavc/libx264: " Anton Khirnov 2022-07-17 22:06 ` Michael Niedermayer 2022-07-18 7:12 ` [FFmpeg-devel] [PATCH] " Anton Khirnov 2022-07-18 12:23 ` James Almer 2022-07-18 18:15 ` Anton Khirnov 2022-07-18 18:18 ` James Almer 2022-07-18 18:29 ` Anton Khirnov 2022-07-19 11:44 ` Michael Niedermayer 2022-07-19 12:43 ` Anton Khirnov 2022-07-18 17:41 ` James Almer 2022-07-18 18:07 ` Anton Khirnov 2022-07-19 12:47 ` [FFmpeg-devel] [PATCH v2] " Anton Khirnov 2022-07-19 12:51 ` James Almer 2022-07-19 12:57 ` Anton Khirnov 2022-07-19 18:13 ` James Almer 2022-07-28 14:24 ` [FFmpeg-devel] [PATCH] " Anton Khirnov 2022-07-28 14:33 ` James Almer 2022-07-18 12:24 ` [FFmpeg-devel] [PATCH 1/4] lavu/frame: allow calling av_frame_make_writable() on non-refcounted frames James Almer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=7132588d-a8c2-6d23-4c9e-ac7539866cdb@gmail.com \ --to=jamrial@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git