[FFmpeg-devel] [PATCH 35/39] lavc/hevcdec: switch to receive_frame()
Anton Khirnov
anton at khirnov.net
Tue Jul 16 20:11:50 EEST 2024
Required by following commits, where we will want to output multiple
frames per packet.
---
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 0e4b26dad3..fc87169a1a 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3401,22 +3401,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) {
@@ -3440,11 +3443,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)
@@ -3721,7 +3724,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 |
--
2.43.0
More information about the ffmpeg-devel
mailing list