Required by following commits, where we will want to output multiple frames per packet.
Unified · Split
| @@ -3405,22 +3405,25 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int f · 3404 unmodified lines | ||
| 3405 | 3405 | return 0; |
| 3406 | 3406 | } |
| 3407 | 3407 | |
| 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) | |
| 3410 | 3409 | { |
| 3410 | + HEVCContext *s = avctx->priv_data; | |
| 3411 | + AVCodecInternal *avci = avctx->internal; | |
| 3412 | + AVPacket *avpkt = avci->in_pkt; | |
| 3413 | + | |
| 3411 | 3414 | int ret; |
| 3412 | 3415 | uint8_t *sd; |
| 3413 | 3416 | size_t sd_size; |
| 3414 | − HEVCContext *s = avctx->priv_data; | |
| 3415 | 3417 | |
| 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); | |
| 3418 | 3422 | if (ret < 0) |
| 3419 | 3423 | 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; | |
| 3424 | 3427 | |
| 3425 | 3428 | sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &sd_size); |
| 3426 | 3429 | if (sd && sd_size > 0) { |
| @@ -3444,11 +3447,11 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 17 unmodified lines | ||
| 3444 | 3447 | return ret; |
| 3445 | 3448 | |
| 3446 | 3449 | 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; | |
| 3449 | 3452 | } |
| 3450 | 3453 | |
| 3451 | − return avpkt->size; | |
| 3454 | + return AVERROR(EAGAIN); | |
| 3452 | 3455 | } |
| 3453 | 3456 | |
| 3454 | 3457 | static int hevc_ref_frame(HEVCFrame *dst, const HEVCFrame *src) |
| @@ -3725,7 +3728,7 @@ const FFCodec ff_hevc_decoder = { · 270 unmodified lines | ||
| 3725 | 3728 | .p.priv_class = &hevc_decoder_class, |
| 3726 | 3729 | .init = hevc_decode_init, |
| 3727 | 3730 | .close = hevc_decode_free, |
| 3728 | − FF_CODEC_DECODE_CB(hevc_decode_frame), | |
| 3731 | + FF_CODEC_RECEIVE_FRAME_CB(hevc_receive_frame), | |
| 3729 | 3732 | .flush = hevc_decode_flush, |
| 3730 | 3733 | UPDATE_THREAD_CONTEXT(hevc_update_thread_context), |
| 3731 | 3734 | .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | |