diff mbox

[FFmpeg-devel] lavc/jpeg2000dec: Support reading 64-bit atom size.

Message ID CAB0OVGo6=sdwL1tJorFPiesBQyys=dzu8BNd-Rw_ZCv=tASeiA@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Dec. 27, 2017, 10:29 p.m. UTC
Hi!

Attached patch fixes ticket #6935 for me, files with actual atom size
>= 2^32 cannot be read by the current bytestream system afaict.

Please comment, Carl Eugen

Comments

Michael Niedermayer Dec. 28, 2017, 12:51 a.m. UTC | #1
On Wed, Dec 27, 2017 at 11:29:33PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #6935 for me, files with actual atom size
> >= 2^32 cannot be read by the current bytestream system afaict.
> 
> Please comment, Carl Eugen

>  jpeg2000dec.c |   11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> ed0d56505f018b8e24594cd14584b6b7ee55ec5b  0001-lavc-jpeg2000dec-Support-reading-64-bit-atom-size.patch
> From db1010aec864cb963fac243907565fdd8c8a1636 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Wed, 27 Dec 2017 23:18:58 +0100
> Subject: [PATCH] lavc/jpeg2000dec: Support reading 64-bit atom size.
> 
> Fixes ticket #6935.
> ---
>  libavcodec/jpeg2000dec.c |   11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

LGTM

thx

[...]
Carl Eugen Hoyos Dec. 28, 2017, 2:01 a.m. UTC | #2
2017-12-28 1:51 GMT+01:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Wed, Dec 27, 2017 at 11:29:33PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes ticket #6935 for me, files with actual atom size
>> >= 2^32 cannot be read by the current bytestream system afaict.
>>
>> Please comment, Carl Eugen
>
>>  jpeg2000dec.c |   11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>> ed0d56505f018b8e24594cd14584b6b7ee55ec5b  0001-lavc-jpeg2000dec-Support-reading-64-bit-atom-size.patch
>> From db1010aec864cb963fac243907565fdd8c8a1636 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> Date: Wed, 27 Dec 2017 23:18:58 +0100
>> Subject: [PATCH] lavc/jpeg2000dec: Support reading 64-bit atom size.
>>
>> Fixes ticket #6935.
>> ---
>>  libavcodec/jpeg2000dec.c |   11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> LGTM

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

From db1010aec864cb963fac243907565fdd8c8a1636 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Wed, 27 Dec 2017 23:18:58 +0100
Subject: [PATCH] lavc/jpeg2000dec: Support reading 64-bit atom size.

Fixes ticket #6935.
---
 libavcodec/jpeg2000dec.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 8071dc3..01fe4b3 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2009,7 +2009,16 @@  static int jp2_find_codestream(Jpeg2000DecoderContext *s)
            bytestream2_get_bytes_left(&s->g) >= 8) {
         atom_size = bytestream2_get_be32u(&s->g);
         atom      = bytestream2_get_be32u(&s->g);
-        atom_end  = bytestream2_tell(&s->g) + atom_size - 8;
+        if (atom_size == 1) {
+            if (bytestream2_get_be32u(&s->g)) {
+                avpriv_request_sample(s->avctx, "Huge atom");
+                return 0;
+            }
+            atom_size = bytestream2_get_be32u(&s->g);
+            atom_end  = bytestream2_tell(&s->g) + atom_size - 16;
+        } else {
+            atom_end  = bytestream2_tell(&s->g) + atom_size -  8;
+        }
 
         if (atom == JP2_CODESTREAM)
             return 1;
-- 
1.7.10.4