diff --git a/libavcodec/lcevcdec.c b/libavcodec/lcevcdec.c index b79401f98d..f0ff739366 100644 --- a/libavcodec/lcevcdec.c +++ b/libavcodec/lcevcdec.c @@ -145,6 +145,31 @@ static int alloc_enhanced_frame(FFLCEVCFrame *frame_ctx, return 0; } +static int lcevc_flush_pictures(FFLCEVCContext *lcevc) +{ + LCEVC_PictureHandle picture; + LCEVC_ReturnCode res; + + while (1) { + AVFrame *base = NULL; + res = LCEVC_ReceiveDecoderBase (lcevc->decoder, &picture); + if (res != LCEVC_Success && res != LCEVC_Again) + return AVERROR_EXTERNAL; + + if (res == LCEVC_Again) + break; + + LCEVC_GetPictureUserData(lcevc->decoder, picture, (void **)&base); + av_frame_free(&base); + + res = LCEVC_FreePicture(lcevc->decoder, picture); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + } + + return 0; +} + static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in) { FFLCEVCContext *lcevc = frame_ctx->lcevc; @@ -270,31 +295,6 @@ static int generate_output(FFLCEVCFrame *frame_ctx, AVFrame *out) return 0; } -static int lcevc_flush_pictures(FFLCEVCContext *lcevc) -{ - LCEVC_PictureHandle picture; - LCEVC_ReturnCode res; - - while (1) { - AVFrame *base = NULL; - res = LCEVC_ReceiveDecoderBase (lcevc->decoder, &picture); - if (res != LCEVC_Success && res != LCEVC_Again) - return AVERROR_EXTERNAL; - - if (res == LCEVC_Again) - break; - - LCEVC_GetPictureUserData(lcevc->decoder, picture, (void **)&base); - av_frame_free(&base); - - res = LCEVC_FreePicture(lcevc->decoder, picture); - if (res != LCEVC_Success) - return AVERROR_EXTERNAL; - } - - return 0; -} - static int lcevc_receive_frame(FFLCEVCFrame *frame_ctx, AVFrame *out) { FFLCEVCContext *lcevc = frame_ctx->lcevc;