[FFmpeg-devel] [PATCH] libavcodec/h263dec.c: Duplicate the last decoded frame when xvid marks the packet as skipped.

Michael Niedermayer michael at niedermayer.cc
Wed Oct 25 14:59:40 EEST 2017


On Tue, Oct 24, 2017 at 06:42:54PM -0700, Thierry Foucu wrote:
> Changed the return value when no VOD were encoded in Mpeg4 bistream.
> And if we do have already a decoded frames and we are not in xvid_packed
> mode, output the existing decoded frame instead of nothing.
> ---
>  libavcodec/h263dec.c       | 9 ++++++++-
>  libavcodec/mpeg4videodec.c | 2 +-
>  libavcodec/mpegutils.h     | 1 +
>  3 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
> index c7cf4bc0c2..394a366f9c 100644
> --- a/libavcodec/h263dec.c
> +++ b/libavcodec/h263dec.c
> @@ -506,8 +506,15 @@ retry:
>                  s->height= avctx->coded_height;
>          }
>      }
> -    if (ret == FRAME_SKIPPED)
> +    if (ret == FRAME_SKIPPED || ret == FRAME_NOT_CODED) {
> +        if (s->next_picture_ptr && ret == FRAME_NOT_CODED && !s->divx_packed) {
> +            if ((ret = av_frame_ref(pict, s->next_picture_ptr->f)) < 0) {
> +                return ret;
> +            }
> +            *got_frame = 1;
> +        }
>          return get_consumed_bytes(s, buf_size);
> +    }
>  
>      /* skip if the header was thrashed */
>      if (ret < 0) {
> diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
> index 82c4f8fc8c..3a9ed12971 100644
> --- a/libavcodec/mpeg4videodec.c
> +++ b/libavcodec/mpeg4videodec.c
> @@ -2394,7 +2394,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
>      if (get_bits1(gb) != 1) {
>          if (s->avctx->debug & FF_DEBUG_PICT_INFO)
>              av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n");
> -        return FRAME_SKIPPED;
> +        return FRAME_NOT_CODED;
>      }
>      if (ctx->new_pred)
>          decode_new_pred(ctx, gb);

the return codes are documented currently:
 * @return <0 if no VOP found (or a damaged one)
 *         FRAME_SKIPPED if a not coded VOP is found
 *         0 if a VOP is found

you added a case but did not update all use cases

which seems to
lead to intermittent crashes (i cant say for sure as i failed to
reproduce one in a debugger or with any debuging code added)

Also returning frames for skiped frames when te match the previous
would slow the code down as more frames would need to be processed.
more so i think this is not the only codec that can skip frames
so any downstream problems will likely not be worked around by forcing
constant fps with frame duplication here


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20171025/75c3b8c3/attachment.sig>


More information about the ffmpeg-devel mailing list