[FFmpeg-devel] [PATCH] avcodec/rkmpp : reset end of stream flag on flush

David Sowa onesowa at gmail.com
Thu Oct 29 20:58:54 EET 2020


This is my first code submission to this project which I did a few days
back and received no feedback,
probably because I've done something wrong.  So I will provide more details
on the issue and the
solution in hopes of moving the process forward.
The code I have that uses libavcodec allows the user to loop over a
subsection of the video file. It does
this by starting at a key frame, playing to the end timestamp, issuing a
flush packet and seeking back
to the initial key frame.  This works correctly with both the soft decode
path and the VAAPI decoder but
fails with the rkmpp decoder.
It fails because internally the rkmpp decoder has no mechanism to allow
more packets to be processed
after a flush packet is received.  The solution is simply to have the flush
packet reset the End of Stream
flag so additional packets can be decoded.
I've been using this fix for 11 months and I would like to get it into the
mainline code mostly just to save
having to remember to port it whenever i pull new code.

regards,
David Sowa

On Mon, Oct 26, 2020 at 4:26 PM David Sowa <onesowa at gmail.com> wrote:

> Currently the flag eos_reached is set to 1 on end of stream
> and there is no mechanism to reset it to 0. After a flush new
> buffers should be able to be decoded but the eos_reached flag
> causes all the frames to be dropped. Reset the eos_reached flag
> to 0 during the flush operation to allow new frames to be
> decoded.
> ---
>  libavcodec/rkmppdec.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
> index 248020d5d6..bf1bf0b013 100644
> --- a/libavcodec/rkmppdec.c
> +++ b/libavcodec/rkmppdec.c
> @@ -544,6 +544,7 @@ static void rkmpp_flush(AVCodecContext *avctx)
>      ret = decoder->mpi->reset(decoder->ctx);
>      if (ret == MPP_OK) {
>          decoder->first_packet = 1;
> +        decoder->eos_reached = 0;
>      } else
>          av_log(avctx, AV_LOG_ERROR, "Failed to reset MPI (code = %d)\n",
> ret);
>  }
> --
> 2.25.1
>
>


More information about the ffmpeg-devel mailing list