diff mbox series

[FFmpeg-devel,1/2] libavcodec/jpeg2000dec.c: Support for CRG marker

Message ID 20200420193739.15378-1-gautamramk@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,1/2] libavcodec/jpeg2000dec.c: Support for CRG marker
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Gautam Ramakrishnan April 20, 2020, 7:37 p.m. UTC
From: Gautam Ramakrishnan <gautamramk@gmail.com>

This patch adds support for CRG marker. Allows
samples such as p0_03.j2k to be decoded.
---
 libavcodec/jpeg2000dec.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Carl Eugen Hoyos April 20, 2020, 7:42 p.m. UTC | #1
Am Mo., 20. Apr. 2020 um 21:38 Uhr schrieb <gautamramk@gmail.com>:
>
> From: Gautam Ramakrishnan <gautamramk@gmail.com>
>
> This patch adds support for CRG marker. Allows
> samples such as p0_03.j2k to be decoded.

The patch indicates to me that it adds support for
skipping the CRG marker: Am I wrong?

Carl Eugen
Gautam Ramakrishnan April 20, 2020, 7:47 p.m. UTC | #2
On Tue, Apr 21, 2020 at 1:12 AM Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
> Am Mo., 20. Apr. 2020 um 21:38 Uhr schrieb <gautamramk@gmail.com>:
> >
> > From: Gautam Ramakrishnan <gautamramk@gmail.com>
> >
> > This patch adds support for CRG marker. Allows
> > samples such as p0_03.j2k to be decoded.
>
> The patch indicates to me that it adds support for
> skipping the CRG marker: Am I wrong?
>
Yep, that's correct. I guess I just used a standard phrase
to word the patch message. The CRG marker does nothing.
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index af6dcee228..5a7d9e7882 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -798,6 +798,15 @@  static int get_sot(Jpeg2000DecoderContext *s, int n)
     return 0;
 }
 
+static int read_crg(Jpeg2000DecoderContext *s, int n)
+{
+    if (s->ncomponents*4 != n - 2) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid CRG marker.\n");
+        return AVERROR_INVALIDDATA;
+    }
+    bytestream2_skip(&s->g, n - 2);
+    return 0;
+}
 /* Tile-part lengths: see ISO 15444-1:2002, section A.7.1
  * Used to know the number of tile parts and lengths.
  * There may be multiple TLMs in the header.
@@ -2061,6 +2070,9 @@  static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
             // the comment is ignored
             bytestream2_skip(&s->g, len - 2);
             break;
+        case JPEG2000_CRG:
+            ret = read_crg(s, len);
+            break;
         case JPEG2000_TLM:
             // Tile-part lengths
             ret = get_tlm(s, len);