diff mbox

[FFmpeg-devel,1/3] avcodec/mpeg4videodec: Fix nonsense warning

Message ID 20190202193412.572-1-andreas.rheinhardt@googlemail.com
State Superseded
Headers show

Commit Message

Andreas Rheinhardt Feb. 2, 2019, 7:34 p.m. UTC
Since db772308941a2a338c7809f90d347219a6a93074 parsing of
mpeg4-extradata lead to a "Failed to parse extradata" warning, because
ff_mpeg4_decode_picture_header returns AVERROR_INVALIDDATA in case that
no VOP was found. This patch changes the return value back to -1 in case
no error occured and no VOP was found.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
---
 libavcodec/mpeg4videodec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Feb. 4, 2019, 6:56 p.m. UTC | #1
On Sat, Feb 02, 2019 at 08:34:10PM +0100, Andreas Rheinhardt wrote:
> Since db772308941a2a338c7809f90d347219a6a93074 parsing of
> mpeg4-extradata lead to a "Failed to parse extradata" warning, because
> ff_mpeg4_decode_picture_header returns AVERROR_INVALIDDATA in case that
> no VOP was found. This patch changes the return value back to -1 in case
> no error occured and no VOP was found.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
> ---
>  libavcodec/mpeg4videodec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
> index f44ee76bd4..9d820c2d71 100644
> --- a/libavcodec/mpeg4videodec.c
> +++ b/libavcodec/mpeg4videodec.c
> @@ -3202,7 +3202,8 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
>  
>  /**
>   * Decode MPEG-4 headers.
> - * @return <0 if no VOP found (or a damaged one)
> + * @return -1 if no error occured, but no VOP was found
> + *         <0 if no VOP found (or a damaged one)
>   *         FRAME_SKIPPED if a not coded VOP is found
>   *         0 if a VOP is found
>   */
> @@ -3235,6 +3236,8 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb)
>                  (ctx->divx_version >= 0 || ctx->xvid_build >= 0) || s->codec_tag == AV_RL32("QMP4")) {
>                  av_log(s->avctx, AV_LOG_VERBOSE, "frame skip %d\n", gb->size_in_bits);
>                  return FRAME_SKIPPED;  // divx bug
> +            } else if (get_bits_count(gb) == gb->size_in_bits) {
> +                return -1; // ordinary return value for parsing of extradata

There is no gurantee that this condition is only true within extradata
also -1 is not an ideal code because it can overlap with some
AVERROR(E*)

Its probably cleaner to just pass a flag as argument that indicates if
the code is parsing a frame or a global header.

Thanks
[...]
diff mbox

Patch

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index f44ee76bd4..9d820c2d71 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3202,7 +3202,8 @@  static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
 
 /**
  * Decode MPEG-4 headers.
- * @return <0 if no VOP found (or a damaged one)
+ * @return -1 if no error occured, but no VOP was found
+ *         <0 if no VOP found (or a damaged one)
  *         FRAME_SKIPPED if a not coded VOP is found
  *         0 if a VOP is found
  */
@@ -3235,6 +3236,8 @@  int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb)
                 (ctx->divx_version >= 0 || ctx->xvid_build >= 0) || s->codec_tag == AV_RL32("QMP4")) {
                 av_log(s->avctx, AV_LOG_VERBOSE, "frame skip %d\n", gb->size_in_bits);
                 return FRAME_SKIPPED;  // divx bug
+            } else if (get_bits_count(gb) == gb->size_in_bits) {
+                return -1; // ordinary return value for parsing of extradata
             } else
                 return AVERROR_INVALIDDATA;  // end of stream
         }