[FFmpeg-devel] [PATCH 1/1] RFC discard all frames when looking for codec parameters

Joakim Plate elupus at ecce.se
Sun Dec 15 17:21:35 CET 2013


The fate failures do look somewhat odd (probed data look identical). I'm
suspecting that the ffmpeg decode is ending up re-using future keyframe
information. Ie, it is not really starting from scratch when it seeks back
and starts decoding, cheating by using future data in a sense.

But i'm not sure yet.


On Sun, Dec 15, 2013 at 5:02 PM, Joakim Plate <elupus at ecce.se> wrote:

> Note - fate breaks on many test after this change, so can't be done exactly
> as this.
>
> On low end systems where playback is normally handled by hardware decode
> decoding large h264 frames in find_stream_info can take very long
> time.
>
> This changes so that we request the frames to be skipped, but still
> run the parsing code.
> ---
>  libavformat/utils.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 838ee18..d486c69 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2463,6 +2463,9 @@ static int try_decode_frame(AVFormatContext *s,
> AVStream *st, AVPacket *avpkt, A
>      AVFrame *frame = av_frame_alloc();
>      AVSubtitle subtitle;
>      AVPacket pkt = *avpkt;
> +    enum AVDiscard skip_frame       = st->codec->skip_frame
> +                 , skip_idct        = st->codec->skip_idct
> +                 , skip_loop_filter = st->codec->skip_loop_filter;
>
>      if (!frame)
>          return AVERROR(ENOMEM);
> @@ -2497,6 +2500,10 @@ static int try_decode_frame(AVFormatContext *s,
> AVStream *st, AVPacket *avpkt, A
>          goto fail;
>      }
>
> +    st->codec->skip_frame       = AVDISCARD_ALL;
> +    st->codec->skip_idct        = AVDISCARD_ALL;
> +    st->codec->skip_loop_filter = AVDISCARD_ALL;
> +
>      while ((pkt.size > 0 || (!pkt.data && got_picture)) &&
>             ret >= 0 &&
>             (!has_codec_parameters(st, NULL)   ||
> @@ -2533,6 +2540,9 @@ static int try_decode_frame(AVFormatContext *s,
> AVStream *st, AVPacket *avpkt, A
>          ret = -1;
>
>  fail:
> +    st->codec->skip_frame       = skip_frame;
> +    st->codec->skip_idct        = skip_idct;
> +    st->codec->skip_loop_filter = skip_loop_filter;
>      avcodec_free_frame(&frame);
>      return ret;
>  }
> --
> 1.8.2
>
>


More information about the ffmpeg-devel mailing list