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

Michael Niedermayer michael at niedermayer.cc
Mon Mar 30 03:36:51 EEST 2020


On Sat, Mar 28, 2020 at 09:16:41PM +0530, gautamramk at gmail.com wrote:
> From: Gautam Ramakrishnan <gautamramk at 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
 
[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200330/2f28e692/attachment.sig>


More information about the ffmpeg-devel mailing list