diff mbox series

[FFmpeg-devel,v6,2/2] libavcodec/jpeg2000dec.c: Handle non EOC streams

Message ID 20200328154641.1515-2-gautamramk@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,v6,1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Gautam Ramakrishnan March 28, 2020, 3:46 p.m. UTC
From: Gautam Ramakrishnan <gautamramk@gmail.com>

This patch allows decoding of j2k streams which do
not have an EOC marker. OpenJPEG implements a similar
check.
---
 libavcodec/jpeg2000dec.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer March 30, 2020, 12:36 a.m. UTC | #1
On Sat, Mar 28, 2020 at 09:16:41PM +0530, gautamramk@gmail.com wrote:
> From: Gautam Ramakrishnan <gautamramk@gmail.com>
> 
> This patch allows decoding of j2k streams which do
> not have an EOC marker. OpenJPEG implements a similar
> check.
> ---
>  libavcodec/jpeg2000dec.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 55fab00152..4f923d620d 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -2078,8 +2078,12 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
>  
>          len = bytestream2_get_be16(&s->g);
>          if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2) {
> -            av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, bytestream2_get_bytes_left(&s->g));
> -            return AVERROR_INVALIDDATA;
> +            if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
> +                av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, bytestream2_get_bytes_left(&s->g));
> +                return AVERROR_INVALIDDATA;
> +            }
> +            av_log(s->avctx, AV_LOG_WARNING, "Mising EOC Marker.\n");

> +            return 0;

this should be the same as the other EOC handling is (break)
(makes no differences of course but its more consistent and if any code is
 added in the future it could become a bug)

 thx
 
[...]
diff mbox series

Patch

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 55fab00152..4f923d620d 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2078,8 +2078,12 @@  static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
 
         len = bytestream2_get_be16(&s->g);
         if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2) {
-            av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, bytestream2_get_bytes_left(&s->g));
-            return AVERROR_INVALIDDATA;
+            if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
+                av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, bytestream2_get_bytes_left(&s->g));
+                return AVERROR_INVALIDDATA;
+            }
+            av_log(s->avctx, AV_LOG_WARNING, "Mising EOC Marker.\n");
+            return 0;
         }
 
         switch (marker) {