[FFmpeg-cvslog] lavc/hevcdec: switch to receive_frame()
Anton Khirnov
git at videolan.org
Mon Aug 19 22:38:13 EEST 2024
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Jun 4 10:51:17 2024 +0200| [2fdecbb239714b6203e37067fda2521f80e19d47] | committer: Anton Khirnov
lavc/hevcdec: switch to receive_frame()
Required by following commits, where we will want to output multiple
frames per packet.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2fdecbb239714b6203e37067fda2521f80e19d47
---
libavcodec/hevc/hevcdec.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 193d624fc9..534736650c 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3405,22 +3405,25 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int f
return 0;
}
-static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
- int *got_output, AVPacket *avpkt)
+static int hevc_receive_frame(AVCodecContext *avctx, AVFrame *frame)
{
+ HEVCContext *s = avctx->priv_data;
+ AVCodecInternal *avci = avctx->internal;
+ AVPacket *avpkt = avci->in_pkt;
+
int ret;
uint8_t *sd;
size_t sd_size;
- HEVCContext *s = avctx->priv_data;
- if (!avpkt->size) {
- ret = ff_hevc_output_frame(s, rframe, 1);
+ av_packet_unref(avpkt);
+ ret = ff_decode_get_packet(avctx, avpkt);
+ if (ret == AVERROR_EOF) {
+ ret = ff_hevc_output_frame(s, frame, 1);
if (ret < 0)
return ret;
-
- *got_output = ret;
- return 0;
- }
+ return (ret > 0) ? 0 : AVERROR_EOF;
+ } else if (ret < 0)
+ return ret;
sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &sd_size);
if (sd && sd_size > 0) {
@@ -3444,11 +3447,11 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
return ret;
if (s->output_frame->buf[0]) {
- av_frame_move_ref(rframe, s->output_frame);
- *got_output = 1;
+ av_frame_move_ref(frame, s->output_frame);
+ return 0;
}
- return avpkt->size;
+ return AVERROR(EAGAIN);
}
static int hevc_ref_frame(HEVCFrame *dst, const HEVCFrame *src)
@@ -3725,7 +3728,7 @@ const FFCodec ff_hevc_decoder = {
.p.priv_class = &hevc_decoder_class,
.init = hevc_decode_init,
.close = hevc_decode_free,
- FF_CODEC_DECODE_CB(hevc_decode_frame),
+ FF_CODEC_RECEIVE_FRAME_CB(hevc_receive_frame),
.flush = hevc_decode_flush,
UPDATE_THREAD_CONTEXT(hevc_update_thread_context),
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
More information about the ffmpeg-cvslog
mailing list