History

lavc/hevcdec: switch to receive_frame()

Required by following commits, where we will want to output multiple frames per packet.

Anton Khirnov committed 2 years ago

Commit 2fdecbb1 parent 4e7b5ac1 file · +16 −13Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/hevc/hevcdec.c+16−13
@@ -3405,22 +3405,25 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int f · 3404 unmodified lines
34053405 return 0;
34063406 }
34073407
3408−static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
3409− int *got_output, AVPacket *avpkt)
3408+static int hevc_receive_frame(AVCodecContext *avctx, AVFrame *frame)
34103409 {
3410+ HEVCContext *s = avctx->priv_data;
3411+ AVCodecInternal *avci = avctx->internal;
3412+ AVPacket *avpkt = avci->in_pkt;
3413+
34113414 int ret;
34123415 uint8_t *sd;
34133416 size_t sd_size;
3414− HEVCContext *s = avctx->priv_data;
34153417
3416− if (!avpkt->size) {
3417− ret = ff_hevc_output_frame(s, rframe, 1);
3418+ av_packet_unref(avpkt);
3419+ ret = ff_decode_get_packet(avctx, avpkt);
3420+ if (ret == AVERROR_EOF) {
3421+ ret = ff_hevc_output_frame(s, frame, 1);
34183422 if (ret < 0)
34193423 return ret;
3420−
3421− *got_output = ret;
3422− return 0;
3423− }
3424+ return (ret > 0) ? 0 : AVERROR_EOF;
3425+ } else if (ret < 0)
3426+ return ret;
34243427
34253428 sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &sd_size);
34263429 if (sd && sd_size > 0) {
@@ -3444,11 +3447,11 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 17 unmodified lines
34443447 return ret;
34453448
34463449 if (s->output_frame->buf[0]) {
3447− av_frame_move_ref(rframe, s->output_frame);
3448− *got_output = 1;
3450+ av_frame_move_ref(frame, s->output_frame);
3451+ return 0;
34493452 }
34503453
3451− return avpkt->size;
3454+ return AVERROR(EAGAIN);
34523455 }
34533456
34543457 static int hevc_ref_frame(HEVCFrame *dst, const HEVCFrame *src)
@@ -3725,7 +3728,7 @@ const FFCodec ff_hevc_decoder = { · 270 unmodified lines
37253728 .p.priv_class = &hevc_decoder_class,
37263729 .init = hevc_decode_init,
37273730 .close = hevc_decode_free,
3728− FF_CODEC_DECODE_CB(hevc_decode_frame),
3731+ FF_CODEC_RECEIVE_FRAME_CB(hevc_receive_frame),
37293732 .flush = hevc_decode_flush,
37303733 UPDATE_THREAD_CONTEXT(hevc_update_thread_context),
37313734 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t