Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files.
@ 2022-12-28 20:20 etemesicaleb
  2023-01-06 15:46 ` Tomas Härdin
  0 siblings, 1 reply; 7+ messages in thread
From: etemesicaleb @ 2022-12-28 20:20 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: caleb, pal, git

From: caleb <etemesicaleb@gmail.com>

---
 libavcodec/jpeg2000dec.c |  88 +---------------------------
 libavcodec/jpeg2000dec.h | 121 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+), 87 deletions(-)
 create mode 100644 libavcodec/jpeg2000dec.h

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index c2b81ec103..5994e29ae3 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -42,6 +42,7 @@
 #include "jpeg2000.h"
 #include "jpeg2000dsp.h"
 #include "profiles.h"
+#include "jpeg2000dec.h"
 
 #define JP2_SIG_TYPE    0x6A502020
 #define JP2_SIG_VALUE   0x0D0A870A
@@ -51,93 +52,6 @@
 #define HAD_COC 0x01
 #define HAD_QCC 0x02
 
-#define MAX_POCS 32
-
-typedef struct Jpeg2000POCEntry {
-    uint16_t LYEpoc;
-    uint16_t CSpoc;
-    uint16_t CEpoc;
-    uint8_t RSpoc;
-    uint8_t REpoc;
-    uint8_t Ppoc;
-} Jpeg2000POCEntry;
-
-typedef struct Jpeg2000POC {
-    Jpeg2000POCEntry poc[MAX_POCS];
-    int nb_poc;
-    int is_default;
-} Jpeg2000POC;
-
-typedef struct Jpeg2000TilePart {
-    uint8_t tile_index;                 // Tile index who refers the tile-part
-    const uint8_t *tp_end;
-    GetByteContext header_tpg;          // bit stream of header if PPM header is used
-    GetByteContext tpg;                 // bit stream in tile-part
-} Jpeg2000TilePart;
-
-/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
- * one per component, so tile_part elements have a size of 3 */
-typedef struct Jpeg2000Tile {
-    Jpeg2000Component   *comp;
-    uint8_t             properties[4];
-    Jpeg2000CodingStyle codsty[4];
-    Jpeg2000QuantStyle  qntsty[4];
-    Jpeg2000POC         poc;
-    Jpeg2000TilePart    tile_part[32];
-    uint8_t             has_ppt;                // whether this tile has a ppt marker
-    uint8_t             *packed_headers;        // contains packed headers. Used only along with PPT marker
-    int                 packed_headers_size;    // size in bytes of the packed headers
-    GetByteContext      packed_headers_stream;  // byte context corresponding to packed headers
-    uint16_t tp_idx;                    // Tile-part index
-    int coord[2][2];                    // border coordinates {{x0, x1}, {y0, y1}}
-} Jpeg2000Tile;
-
-typedef struct Jpeg2000DecoderContext {
-    AVClass         *class;
-    AVCodecContext  *avctx;
-    GetByteContext  g;
-
-    int             width, height;
-    int             image_offset_x, image_offset_y;
-    int             tile_offset_x, tile_offset_y;
-    uint8_t         cbps[4];    // bits per sample in particular components
-    uint8_t         sgnd[4];    // if a component is signed
-    uint8_t         properties[4];
-
-    uint8_t         has_ppm;
-    uint8_t         *packed_headers; // contains packed headers. Used only along with PPM marker
-    int             packed_headers_size;
-    GetByteContext  packed_headers_stream;
-    uint8_t         in_tile_headers;
-
-    int             cdx[4], cdy[4];
-    int             precision;
-    int             ncomponents;
-    int             colour_space;
-    uint32_t        palette[256];
-    int8_t          pal8;
-    int             cdef[4];
-    int             tile_width, tile_height;
-    unsigned        numXtiles, numYtiles;
-    int             maxtilelen;
-    AVRational      sar;
-
-    Jpeg2000CodingStyle codsty[4];
-    Jpeg2000QuantStyle  qntsty[4];
-    Jpeg2000POC         poc;
-    uint8_t             roi_shift[4];
-
-    int             bit_index;
-
-    int             curtileno;
-
-    Jpeg2000Tile    *tile;
-    Jpeg2000DSPContext dsp;
-
-    /*options parameters*/
-    int             reduction_factor;
-} Jpeg2000DecoderContext;
-
 /* get_bits functions for JPEG2000 packet bitstream
  * It is a get_bit function with a bit-stuffing routine. If the value of the
  * byte is 0xFF, the next byte includes an extra zero bit stuffed into the MSB.
diff --git a/libavcodec/jpeg2000dec.h b/libavcodec/jpeg2000dec.h
new file mode 100644
index 0000000000..c148416889
--- /dev/null
+++ b/libavcodec/jpeg2000dec.h
@@ -0,0 +1,121 @@
+/*
+ * JPEG 2000 image decoder
+ * Copyright (c) 2007 Kamil Nowosad
+ * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
+ * Copyright (c) 2022 Caleb Etemesi <etemesicaleb@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_JPEG2000DEC_H
+#define AVCODEC_JPEG2000DEC_H
+
+#include "bytestream.h"
+#include "jpeg2000.h"
+#include "jpeg2000dsp.h"
+
+
+#define MAX_POCS 32
+
+typedef struct Jpeg2000POCEntry {
+    uint16_t LYEpoc;
+    uint16_t CSpoc;
+    uint16_t CEpoc;
+    uint8_t RSpoc;
+    uint8_t REpoc;
+    uint8_t Ppoc;
+} Jpeg2000POCEntry;
+
+typedef struct Jpeg2000POC {
+    Jpeg2000POCEntry poc[MAX_POCS];
+    int nb_poc;
+    int is_default;
+} Jpeg2000POC;
+
+typedef struct Jpeg2000TilePart {
+    uint8_t tile_index;                 // Tile index who refers the tile-part
+    const uint8_t *tp_end;
+    GetByteContext header_tpg;          // bit stream of header if PPM header is used
+    GetByteContext tpg;                 // bit stream in tile-part
+} Jpeg2000TilePart;
+
+/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
+ * one per component, so tile_part elements have a size of 3 */
+typedef struct Jpeg2000Tile {
+    Jpeg2000Component   *comp;
+    uint8_t             properties[4];
+    Jpeg2000CodingStyle codsty[4];
+    Jpeg2000QuantStyle  qntsty[4];
+    Jpeg2000POC         poc;
+    Jpeg2000TilePart    tile_part[32];
+    uint8_t             has_ppt;                // whether this tile has a ppt marker
+    uint8_t             *packed_headers;        // contains packed headers. Used only along with PPT marker
+    int                 packed_headers_size;    // size in bytes of the packed headers
+    GetByteContext      packed_headers_stream;  // byte context corresponding to packed headers
+    uint16_t tp_idx;                    // Tile-part index
+    int coord[2][2];                    // border coordinates {{x0, x1}, {y0, y1}}
+} Jpeg2000Tile;
+
+typedef struct Jpeg2000DecoderContext {
+    AVClass         *class;
+    AVCodecContext  *avctx;
+    GetByteContext  g;
+
+    int             width, height;
+    int             image_offset_x, image_offset_y;
+    int             tile_offset_x, tile_offset_y;
+    uint8_t         cbps[4];    // bits per sample in particular components
+    uint8_t         sgnd[4];    // if a component is signed
+    uint8_t         properties[4];
+
+    uint8_t         has_ppm;
+    uint8_t         *packed_headers; // contains packed headers. Used only along with PPM marker
+    int             packed_headers_size;
+    GetByteContext  packed_headers_stream;
+    uint8_t         in_tile_headers;
+
+    int             cdx[4], cdy[4];
+    int             precision;
+    int             ncomponents;
+    int             colour_space;
+    uint32_t        palette[256];
+    int8_t          pal8;
+    int             cdef[4];
+    int             tile_width, tile_height;
+    unsigned        numXtiles, numYtiles;
+    int             maxtilelen;
+    AVRational      sar;
+
+    Jpeg2000CodingStyle codsty[4];
+    Jpeg2000QuantStyle  qntsty[4];
+    Jpeg2000POC         poc;
+    uint8_t             roi_shift[4];
+
+    int             bit_index;
+
+    int             curtileno;
+
+    Jpeg2000Tile    *tile;
+    Jpeg2000DSPContext dsp;
+
+    /*options parameters*/
+    int             reduction_factor;
+    /*HTJ2K params*/
+    uint8_t         is_htj2k;
+} Jpeg2000DecoderContext;
+
+#endif //AVCODEC_JPEG2000DEC_H
-- 
2.38.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files.
  2022-12-28 20:20 [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files etemesicaleb
@ 2023-01-06 15:46 ` Tomas Härdin
  2023-02-21 11:29   ` Caleb Etemesi
  0 siblings, 1 reply; 7+ messages in thread
From: Tomas Härdin @ 2023-01-06 15:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

ons 2022-12-28 klockan 23:20 +0300 skrev etemesicaleb@gmail.com:
> From: caleb <etemesicaleb@gmail.com>
> 
> ---
>  libavcodec/jpeg2000dec.c |  88 +---------------------------
>  libavcodec/jpeg2000dec.h | 121
> +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 122 insertions(+), 87 deletions(-)
>  create mode 100644 libavcodec/jpeg2000dec.h

Just responding here to mark that I've noticed these two patches but
I'm not back on j2k work until probably February

/Tomas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files.
  2023-01-06 15:46 ` Tomas Härdin
@ 2023-02-21 11:29   ` Caleb Etemesi
  0 siblings, 0 replies; 7+ messages in thread
From: Caleb Etemesi @ 2023-02-21 11:29 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Ping on this

On Fri, 6 Jan 2023, 18:46 Tomas Härdin, <git@haerdin.se> wrote:

> ons 2022-12-28 klockan 23:20 +0300 skrev etemesicaleb@gmail.com:
> > From: caleb <etemesicaleb@gmail.com>
> >
> > ---
> >  libavcodec/jpeg2000dec.c |  88 +---------------------------
> >  libavcodec/jpeg2000dec.h | 121
> > +++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 122 insertions(+), 87 deletions(-)
> >  create mode 100644 libavcodec/jpeg2000dec.h
>
> Just responding here to mark that I've noticed these two patches but
> I'm not back on j2k work until probably February
>
> /Tomas
>
> _______________________________________________
> 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".
>
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files
  2022-12-15 18:59 etemesicaleb
@ 2022-12-15 23:26 ` Andreas Rheinhardt
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2022-12-15 23:26 UTC (permalink / raw)
  To: ffmpeg-devel

etemesicaleb@gmail.com:
> From: caleb <etemesicaleb@gmail.com>
> 
> This should pave way for HTJ2K decoding
> 
> ---
>  libavcodec/jpeg2000dec.c |  96 +----------------------------
>  libavcodec/jpeg2000dec.h | 126 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 127 insertions(+), 95 deletions(-)
>  create mode 100644 libavcodec/jpeg2000dec.h
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index c2b81ec103..7fc09cb558 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -42,101 +42,7 @@
>  #include "jpeg2000.h"
>  #include "jpeg2000dsp.h"
>  #include "profiles.h"
> -
> -#define JP2_SIG_TYPE    0x6A502020
> -#define JP2_SIG_VALUE   0x0D0A870A
> -#define JP2_CODESTREAM  0x6A703263
> -#define JP2_HEADER      0x6A703268
> -
> -#define HAD_COC 0x01
> -#define HAD_QCC 0x02
> -
> -#define MAX_POCS 32
> -
> -typedef struct Jpeg2000POCEntry {
> -    uint16_t LYEpoc;
> -    uint16_t CSpoc;
> -    uint16_t CEpoc;
> -    uint8_t RSpoc;
> -    uint8_t REpoc;
> -    uint8_t Ppoc;
> -} Jpeg2000POCEntry;
> -
> -typedef struct Jpeg2000POC {
> -    Jpeg2000POCEntry poc[MAX_POCS];
> -    int nb_poc;
> -    int is_default;
> -} Jpeg2000POC;
> -
> -typedef struct Jpeg2000TilePart {
> -    uint8_t tile_index;                 // Tile index who refers the tile-part
> -    const uint8_t *tp_end;
> -    GetByteContext header_tpg;          // bit stream of header if PPM header is used
> -    GetByteContext tpg;                 // bit stream in tile-part
> -} Jpeg2000TilePart;
> -
> -/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
> - * one per component, so tile_part elements have a size of 3 */
> -typedef struct Jpeg2000Tile {
> -    Jpeg2000Component   *comp;
> -    uint8_t             properties[4];
> -    Jpeg2000CodingStyle codsty[4];
> -    Jpeg2000QuantStyle  qntsty[4];
> -    Jpeg2000POC         poc;
> -    Jpeg2000TilePart    tile_part[32];
> -    uint8_t             has_ppt;                // whether this tile has a ppt marker
> -    uint8_t             *packed_headers;        // contains packed headers. Used only along with PPT marker
> -    int                 packed_headers_size;    // size in bytes of the packed headers
> -    GetByteContext      packed_headers_stream;  // byte context corresponding to packed headers
> -    uint16_t tp_idx;                    // Tile-part index
> -    int coord[2][2];                    // border coordinates {{x0, x1}, {y0, y1}}
> -} Jpeg2000Tile;
> -
> -typedef struct Jpeg2000DecoderContext {
> -    AVClass         *class;
> -    AVCodecContext  *avctx;
> -    GetByteContext  g;
> -
> -    int             width, height;
> -    int             image_offset_x, image_offset_y;
> -    int             tile_offset_x, tile_offset_y;
> -    uint8_t         cbps[4];    // bits per sample in particular components
> -    uint8_t         sgnd[4];    // if a component is signed
> -    uint8_t         properties[4];
> -
> -    uint8_t         has_ppm;
> -    uint8_t         *packed_headers; // contains packed headers. Used only along with PPM marker
> -    int             packed_headers_size;
> -    GetByteContext  packed_headers_stream;
> -    uint8_t         in_tile_headers;
> -
> -    int             cdx[4], cdy[4];
> -    int             precision;
> -    int             ncomponents;
> -    int             colour_space;
> -    uint32_t        palette[256];
> -    int8_t          pal8;
> -    int             cdef[4];
> -    int             tile_width, tile_height;
> -    unsigned        numXtiles, numYtiles;
> -    int             maxtilelen;
> -    AVRational      sar;
> -
> -    Jpeg2000CodingStyle codsty[4];
> -    Jpeg2000QuantStyle  qntsty[4];
> -    Jpeg2000POC         poc;
> -    uint8_t             roi_shift[4];
> -
> -    int             bit_index;
> -
> -    int             curtileno;
> -
> -    Jpeg2000Tile    *tile;
> -    Jpeg2000DSPContext dsp;
> -
> -    /*options parameters*/
> -    int             reduction_factor;
> -} Jpeg2000DecoderContext;
> +#include "jpeg2000dec.h"
>  
>  /* get_bits functions for JPEG2000 packet bitstream
>   * It is a get_bit function with a bit-stuffing routine. If the value of the
> diff --git a/libavcodec/jpeg2000dec.h b/libavcodec/jpeg2000dec.h
> new file mode 100644
> index 0000000000..b6410c1432
> --- /dev/null
> +++ b/libavcodec/jpeg2000dec.h
> @@ -0,0 +1,126 @@
> +/*
> + * JPEG 2000 image decoder
> + * Copyright (c) 2007 Kamil Nowosad
> + * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
> + * Copyright (c) 2022 Caleb Etemesi <etemesicaleb@gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVCODEC_JPEG2000DEC_H
> +#define AVCODEC_JPEG2000DEC_H
> +
> +#include "bytestream.h"
> +#include "jpeg2000.h"
> +#include "jpeg2000dsp.h"
> +
> +#define JP2_SIG_TYPE    0x6A502020
> +#define JP2_SIG_VALUE   0x0D0A870A
> +#define JP2_CODESTREAM  0x6A703263
> +#define JP2_HEADER      0x6A703268
> +

This stuff seems to be only used in jpeg2000dec.c, so it can stay there.
Given that this is format-specific (and not specific to our
decoder-implementation, a better place for this would be jpeg2000.h if
it were moved out of jpeg2000dec.c).

> +#define HAD_COC 0x01
> +#define HAD_QCC 0x02
> +

These two should not be in this header, they are only used in
jpeg2000dec.c and seems to be decoder-only and not format specific at all.

> +#define MAX_POCS 32

If this is moved to a header, it should have a proper prefix in order to
avoid future clashes.

> +
> +typedef struct Jpeg2000POCEntry {
> +    uint16_t LYEpoc;
> +    uint16_t CSpoc;
> +    uint16_t CEpoc;
> +    uint8_t RSpoc;
> +    uint8_t REpoc;
> +    uint8_t Ppoc;
> +} Jpeg2000POCEntry;
> +
> +typedef struct Jpeg2000POC {
> +    Jpeg2000POCEntry poc[MAX_POCS];
> +    int nb_poc;
> +    int is_default;
> +} Jpeg2000POC;
> +
> +typedef struct Jpeg2000TilePart {
> +    uint8_t tile_index;                 // Tile index who refers the tile-part
> +    const uint8_t *tp_end;
> +    GetByteContext header_tpg;          // bit stream of header if PPM header is used
> +    GetByteContext tpg;                 // bit stream in tile-part
> +} Jpeg2000TilePart;
> +
> +/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
> + * one per component, so tile_part elements have a size of 3 */
> +typedef struct Jpeg2000Tile {
> +    Jpeg2000Component   *comp;
> +    uint8_t             properties[4];
> +    Jpeg2000CodingStyle codsty[4];
> +    Jpeg2000QuantStyle  qntsty[4];
> +    Jpeg2000POC         poc;
> +    Jpeg2000TilePart    tile_part[32];
> +    uint8_t             has_ppt;                // whether this tile has a ppt marker
> +    uint8_t             *packed_headers;        // contains packed headers. Used only along with PPT marker
> +    int                 packed_headers_size;    // size in bytes of the packed headers
> +    GetByteContext      packed_headers_stream;  // byte context corresponding to packed headers
> +    uint16_t tp_idx;                    // Tile-part index
> +    int coord[2][2];                    // border coordinates {{x0, x1}, {y0, y1}}
> +} Jpeg2000Tile;

Seems like there is no reason to put Jpeg2000TilePart and Jpeg2000Tile
into this header, as it is only used in jpeg2000dec.c (the usage below
only uses a Jpeg2000Tile* and can therefore use an incomplete type).

> +
> +typedef struct Jpeg2000DecoderContext {
> +    AVClass         *class;

const AVClass* would be better.

> +    AVCodecContext  *avctx;
> +    GetByteContext  g;
> +
> +    int             width, height;
> +    int             image_offset_x, image_offset_y;
> +    int             tile_offset_x, tile_offset_y;
> +    uint8_t         cbps[4];    // bits per sample in particular components
> +    uint8_t         sgnd[4];    // if a component is signed
> +    uint8_t         properties[4];
> +
> +    uint8_t         has_ppm;
> +    uint8_t         *packed_headers; // contains packed headers. Used only along with PPM marker
> +    int             packed_headers_size;
> +    GetByteContext  packed_headers_stream;
> +    uint8_t         in_tile_headers;
> +
> +    int             cdx[4], cdy[4];
> +    int             precision;
> +    int             ncomponents;
> +    int             colour_space;
> +    uint32_t        palette[256];
> +    int8_t          pal8;
> +    int             cdef[4];
> +    int             tile_width, tile_height;
> +    unsigned        numXtiles, numYtiles;
> +    int             maxtilelen;
> +    AVRational      sar;
> +
> +    Jpeg2000CodingStyle codsty[4];
> +    Jpeg2000QuantStyle  qntsty[4];
> +    Jpeg2000POC         poc;
> +    uint8_t             roi_shift[4];
> +
> +    int             bit_index;
> +
> +    int             curtileno;
> +
> +    Jpeg2000Tile    *tile;
> +    Jpeg2000DSPContext dsp;
> +
> +    /*options parameters*/
> +    int             reduction_factor;
> +} Jpeg2000DecoderContext;
> +
> +#endif //AVCODEC_JPEG2000DEC_H

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files
@ 2022-12-15 18:59 etemesicaleb
  2022-12-15 23:26 ` Andreas Rheinhardt
  0 siblings, 1 reply; 7+ messages in thread
From: etemesicaleb @ 2022-12-15 18:59 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: caleb, pal, git

From: caleb <etemesicaleb@gmail.com>

This should pave way for HTJ2K decoding

---
 libavcodec/jpeg2000dec.c |  96 +----------------------------
 libavcodec/jpeg2000dec.h | 126 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+), 95 deletions(-)
 create mode 100644 libavcodec/jpeg2000dec.h

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index c2b81ec103..7fc09cb558 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -42,101 +42,7 @@
 #include "jpeg2000.h"
 #include "jpeg2000dsp.h"
 #include "profiles.h"
-
-#define JP2_SIG_TYPE    0x6A502020
-#define JP2_SIG_VALUE   0x0D0A870A
-#define JP2_CODESTREAM  0x6A703263
-#define JP2_HEADER      0x6A703268
-
-#define HAD_COC 0x01
-#define HAD_QCC 0x02
-
-#define MAX_POCS 32
-
-typedef struct Jpeg2000POCEntry {
-    uint16_t LYEpoc;
-    uint16_t CSpoc;
-    uint16_t CEpoc;
-    uint8_t RSpoc;
-    uint8_t REpoc;
-    uint8_t Ppoc;
-} Jpeg2000POCEntry;
-
-typedef struct Jpeg2000POC {
-    Jpeg2000POCEntry poc[MAX_POCS];
-    int nb_poc;
-    int is_default;
-} Jpeg2000POC;
-
-typedef struct Jpeg2000TilePart {
-    uint8_t tile_index;                 // Tile index who refers the tile-part
-    const uint8_t *tp_end;
-    GetByteContext header_tpg;          // bit stream of header if PPM header is used
-    GetByteContext tpg;                 // bit stream in tile-part
-} Jpeg2000TilePart;
-
-/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
- * one per component, so tile_part elements have a size of 3 */
-typedef struct Jpeg2000Tile {
-    Jpeg2000Component   *comp;
-    uint8_t             properties[4];
-    Jpeg2000CodingStyle codsty[4];
-    Jpeg2000QuantStyle  qntsty[4];
-    Jpeg2000POC         poc;
-    Jpeg2000TilePart    tile_part[32];
-    uint8_t             has_ppt;                // whether this tile has a ppt marker
-    uint8_t             *packed_headers;        // contains packed headers. Used only along with PPT marker
-    int                 packed_headers_size;    // size in bytes of the packed headers
-    GetByteContext      packed_headers_stream;  // byte context corresponding to packed headers
-    uint16_t tp_idx;                    // Tile-part index
-    int coord[2][2];                    // border coordinates {{x0, x1}, {y0, y1}}
-} Jpeg2000Tile;
-
-typedef struct Jpeg2000DecoderContext {
-    AVClass         *class;
-    AVCodecContext  *avctx;
-    GetByteContext  g;
-
-    int             width, height;
-    int             image_offset_x, image_offset_y;
-    int             tile_offset_x, tile_offset_y;
-    uint8_t         cbps[4];    // bits per sample in particular components
-    uint8_t         sgnd[4];    // if a component is signed
-    uint8_t         properties[4];
-
-    uint8_t         has_ppm;
-    uint8_t         *packed_headers; // contains packed headers. Used only along with PPM marker
-    int             packed_headers_size;
-    GetByteContext  packed_headers_stream;
-    uint8_t         in_tile_headers;
-
-    int             cdx[4], cdy[4];
-    int             precision;
-    int             ncomponents;
-    int             colour_space;
-    uint32_t        palette[256];
-    int8_t          pal8;
-    int             cdef[4];
-    int             tile_width, tile_height;
-    unsigned        numXtiles, numYtiles;
-    int             maxtilelen;
-    AVRational      sar;
-
-    Jpeg2000CodingStyle codsty[4];
-    Jpeg2000QuantStyle  qntsty[4];
-    Jpeg2000POC         poc;
-    uint8_t             roi_shift[4];
-
-    int             bit_index;
-
-    int             curtileno;
-
-    Jpeg2000Tile    *tile;
-    Jpeg2000DSPContext dsp;
-
-    /*options parameters*/
-    int             reduction_factor;
-} Jpeg2000DecoderContext;
+#include "jpeg2000dec.h"
 
 /* get_bits functions for JPEG2000 packet bitstream
  * It is a get_bit function with a bit-stuffing routine. If the value of the
diff --git a/libavcodec/jpeg2000dec.h b/libavcodec/jpeg2000dec.h
new file mode 100644
index 0000000000..b6410c1432
--- /dev/null
+++ b/libavcodec/jpeg2000dec.h
@@ -0,0 +1,126 @@
+/*
+ * JPEG 2000 image decoder
+ * Copyright (c) 2007 Kamil Nowosad
+ * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
+ * Copyright (c) 2022 Caleb Etemesi <etemesicaleb@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_JPEG2000DEC_H
+#define AVCODEC_JPEG2000DEC_H
+
+#include "bytestream.h"
+#include "jpeg2000.h"
+#include "jpeg2000dsp.h"
+
+#define JP2_SIG_TYPE    0x6A502020
+#define JP2_SIG_VALUE   0x0D0A870A
+#define JP2_CODESTREAM  0x6A703263
+#define JP2_HEADER      0x6A703268
+
+#define HAD_COC 0x01
+#define HAD_QCC 0x02
+
+#define MAX_POCS 32
+
+typedef struct Jpeg2000POCEntry {
+    uint16_t LYEpoc;
+    uint16_t CSpoc;
+    uint16_t CEpoc;
+    uint8_t RSpoc;
+    uint8_t REpoc;
+    uint8_t Ppoc;
+} Jpeg2000POCEntry;
+
+typedef struct Jpeg2000POC {
+    Jpeg2000POCEntry poc[MAX_POCS];
+    int nb_poc;
+    int is_default;
+} Jpeg2000POC;
+
+typedef struct Jpeg2000TilePart {
+    uint8_t tile_index;                 // Tile index who refers the tile-part
+    const uint8_t *tp_end;
+    GetByteContext header_tpg;          // bit stream of header if PPM header is used
+    GetByteContext tpg;                 // bit stream in tile-part
+} Jpeg2000TilePart;
+
+/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
+ * one per component, so tile_part elements have a size of 3 */
+typedef struct Jpeg2000Tile {
+    Jpeg2000Component   *comp;
+    uint8_t             properties[4];
+    Jpeg2000CodingStyle codsty[4];
+    Jpeg2000QuantStyle  qntsty[4];
+    Jpeg2000POC         poc;
+    Jpeg2000TilePart    tile_part[32];
+    uint8_t             has_ppt;                // whether this tile has a ppt marker
+    uint8_t             *packed_headers;        // contains packed headers. Used only along with PPT marker
+    int                 packed_headers_size;    // size in bytes of the packed headers
+    GetByteContext      packed_headers_stream;  // byte context corresponding to packed headers
+    uint16_t tp_idx;                    // Tile-part index
+    int coord[2][2];                    // border coordinates {{x0, x1}, {y0, y1}}
+} Jpeg2000Tile;
+
+typedef struct Jpeg2000DecoderContext {
+    AVClass         *class;
+    AVCodecContext  *avctx;
+    GetByteContext  g;
+
+    int             width, height;
+    int             image_offset_x, image_offset_y;
+    int             tile_offset_x, tile_offset_y;
+    uint8_t         cbps[4];    // bits per sample in particular components
+    uint8_t         sgnd[4];    // if a component is signed
+    uint8_t         properties[4];
+
+    uint8_t         has_ppm;
+    uint8_t         *packed_headers; // contains packed headers. Used only along with PPM marker
+    int             packed_headers_size;
+    GetByteContext  packed_headers_stream;
+    uint8_t         in_tile_headers;
+
+    int             cdx[4], cdy[4];
+    int             precision;
+    int             ncomponents;
+    int             colour_space;
+    uint32_t        palette[256];
+    int8_t          pal8;
+    int             cdef[4];
+    int             tile_width, tile_height;
+    unsigned        numXtiles, numYtiles;
+    int             maxtilelen;
+    AVRational      sar;
+
+    Jpeg2000CodingStyle codsty[4];
+    Jpeg2000QuantStyle  qntsty[4];
+    Jpeg2000POC         poc;
+    uint8_t             roi_shift[4];
+
+    int             bit_index;
+
+    int             curtileno;
+
+    Jpeg2000Tile    *tile;
+    Jpeg2000DSPContext dsp;
+
+    /*options parameters*/
+    int             reduction_factor;
+} Jpeg2000DecoderContext;
+
+#endif //AVCODEC_JPEG2000DEC_H
-- 
2.37.2

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files
  2022-12-02 18:10 etemesicaleb
@ 2022-12-02 18:25 ` Tomas Härdin
  0 siblings, 0 replies; 7+ messages in thread
From: Tomas Härdin @ 2022-12-02 18:25 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

fre 2022-12-02 klockan 21:10 +0300 skrev etemesicaleb@gmail.com:
> From: caleb <etemesicaleb@gmail.com>

Speak of the devil :)

> 
> ---
>  libavcodec/jpeg2000dec.c |  96 +----------------------------
>  libavcodec/jpeg2000dec.h | 126
> +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 127 insertions(+), 95 deletions(-)
>  create mode 100644 libavcodec/jpeg2000dec.h

Looks OK

/Tomas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files
@ 2022-12-02 18:10 etemesicaleb
  2022-12-02 18:25 ` Tomas Härdin
  0 siblings, 1 reply; 7+ messages in thread
From: etemesicaleb @ 2022-12-02 18:10 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: caleb, pal

From: caleb <etemesicaleb@gmail.com>

---
 libavcodec/jpeg2000dec.c |  96 +----------------------------
 libavcodec/jpeg2000dec.h | 126 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+), 95 deletions(-)
 create mode 100644 libavcodec/jpeg2000dec.h

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index c2b81ec103..7fc09cb558 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -42,101 +42,7 @@
 #include "jpeg2000.h"
 #include "jpeg2000dsp.h"
 #include "profiles.h"
-
-#define JP2_SIG_TYPE    0x6A502020
-#define JP2_SIG_VALUE   0x0D0A870A
-#define JP2_CODESTREAM  0x6A703263
-#define JP2_HEADER      0x6A703268
-
-#define HAD_COC 0x01
-#define HAD_QCC 0x02
-
-#define MAX_POCS 32
-
-typedef struct Jpeg2000POCEntry {
-    uint16_t LYEpoc;
-    uint16_t CSpoc;
-    uint16_t CEpoc;
-    uint8_t RSpoc;
-    uint8_t REpoc;
-    uint8_t Ppoc;
-} Jpeg2000POCEntry;
-
-typedef struct Jpeg2000POC {
-    Jpeg2000POCEntry poc[MAX_POCS];
-    int nb_poc;
-    int is_default;
-} Jpeg2000POC;
-
-typedef struct Jpeg2000TilePart {
-    uint8_t tile_index;                 // Tile index who refers the tile-part
-    const uint8_t *tp_end;
-    GetByteContext header_tpg;          // bit stream of header if PPM header is used
-    GetByteContext tpg;                 // bit stream in tile-part
-} Jpeg2000TilePart;
-
-/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
- * one per component, so tile_part elements have a size of 3 */
-typedef struct Jpeg2000Tile {
-    Jpeg2000Component   *comp;
-    uint8_t             properties[4];
-    Jpeg2000CodingStyle codsty[4];
-    Jpeg2000QuantStyle  qntsty[4];
-    Jpeg2000POC         poc;
-    Jpeg2000TilePart    tile_part[32];
-    uint8_t             has_ppt;                // whether this tile has a ppt marker
-    uint8_t             *packed_headers;        // contains packed headers. Used only along with PPT marker
-    int                 packed_headers_size;    // size in bytes of the packed headers
-    GetByteContext      packed_headers_stream;  // byte context corresponding to packed headers
-    uint16_t tp_idx;                    // Tile-part index
-    int coord[2][2];                    // border coordinates {{x0, x1}, {y0, y1}}
-} Jpeg2000Tile;
-
-typedef struct Jpeg2000DecoderContext {
-    AVClass         *class;
-    AVCodecContext  *avctx;
-    GetByteContext  g;
-
-    int             width, height;
-    int             image_offset_x, image_offset_y;
-    int             tile_offset_x, tile_offset_y;
-    uint8_t         cbps[4];    // bits per sample in particular components
-    uint8_t         sgnd[4];    // if a component is signed
-    uint8_t         properties[4];
-
-    uint8_t         has_ppm;
-    uint8_t         *packed_headers; // contains packed headers. Used only along with PPM marker
-    int             packed_headers_size;
-    GetByteContext  packed_headers_stream;
-    uint8_t         in_tile_headers;
-
-    int             cdx[4], cdy[4];
-    int             precision;
-    int             ncomponents;
-    int             colour_space;
-    uint32_t        palette[256];
-    int8_t          pal8;
-    int             cdef[4];
-    int             tile_width, tile_height;
-    unsigned        numXtiles, numYtiles;
-    int             maxtilelen;
-    AVRational      sar;
-
-    Jpeg2000CodingStyle codsty[4];
-    Jpeg2000QuantStyle  qntsty[4];
-    Jpeg2000POC         poc;
-    uint8_t             roi_shift[4];
-
-    int             bit_index;
-
-    int             curtileno;
-
-    Jpeg2000Tile    *tile;
-    Jpeg2000DSPContext dsp;
-
-    /*options parameters*/
-    int             reduction_factor;
-} Jpeg2000DecoderContext;
+#include "jpeg2000dec.h"
 
 /* get_bits functions for JPEG2000 packet bitstream
  * It is a get_bit function with a bit-stuffing routine. If the value of the
diff --git a/libavcodec/jpeg2000dec.h b/libavcodec/jpeg2000dec.h
new file mode 100644
index 0000000000..b6410c1432
--- /dev/null
+++ b/libavcodec/jpeg2000dec.h
@@ -0,0 +1,126 @@
+/*
+ * JPEG 2000 image decoder
+ * Copyright (c) 2007 Kamil Nowosad
+ * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
+ * Copyright (c) 2022 Caleb Etemesi <etemesicaleb@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_JPEG2000DEC_H
+#define AVCODEC_JPEG2000DEC_H
+
+#include "bytestream.h"
+#include "jpeg2000.h"
+#include "jpeg2000dsp.h"
+
+#define JP2_SIG_TYPE    0x6A502020
+#define JP2_SIG_VALUE   0x0D0A870A
+#define JP2_CODESTREAM  0x6A703263
+#define JP2_HEADER      0x6A703268
+
+#define HAD_COC 0x01
+#define HAD_QCC 0x02
+
+#define MAX_POCS 32
+
+typedef struct Jpeg2000POCEntry {
+    uint16_t LYEpoc;
+    uint16_t CSpoc;
+    uint16_t CEpoc;
+    uint8_t RSpoc;
+    uint8_t REpoc;
+    uint8_t Ppoc;
+} Jpeg2000POCEntry;
+
+typedef struct Jpeg2000POC {
+    Jpeg2000POCEntry poc[MAX_POCS];
+    int nb_poc;
+    int is_default;
+} Jpeg2000POC;
+
+typedef struct Jpeg2000TilePart {
+    uint8_t tile_index;                 // Tile index who refers the tile-part
+    const uint8_t *tp_end;
+    GetByteContext header_tpg;          // bit stream of header if PPM header is used
+    GetByteContext tpg;                 // bit stream in tile-part
+} Jpeg2000TilePart;
+
+/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile
+ * one per component, so tile_part elements have a size of 3 */
+typedef struct Jpeg2000Tile {
+    Jpeg2000Component   *comp;
+    uint8_t             properties[4];
+    Jpeg2000CodingStyle codsty[4];
+    Jpeg2000QuantStyle  qntsty[4];
+    Jpeg2000POC         poc;
+    Jpeg2000TilePart    tile_part[32];
+    uint8_t             has_ppt;                // whether this tile has a ppt marker
+    uint8_t             *packed_headers;        // contains packed headers. Used only along with PPT marker
+    int                 packed_headers_size;    // size in bytes of the packed headers
+    GetByteContext      packed_headers_stream;  // byte context corresponding to packed headers
+    uint16_t tp_idx;                    // Tile-part index
+    int coord[2][2];                    // border coordinates {{x0, x1}, {y0, y1}}
+} Jpeg2000Tile;
+
+typedef struct Jpeg2000DecoderContext {
+    AVClass         *class;
+    AVCodecContext  *avctx;
+    GetByteContext  g;
+
+    int             width, height;
+    int             image_offset_x, image_offset_y;
+    int             tile_offset_x, tile_offset_y;
+    uint8_t         cbps[4];    // bits per sample in particular components
+    uint8_t         sgnd[4];    // if a component is signed
+    uint8_t         properties[4];
+
+    uint8_t         has_ppm;
+    uint8_t         *packed_headers; // contains packed headers. Used only along with PPM marker
+    int             packed_headers_size;
+    GetByteContext  packed_headers_stream;
+    uint8_t         in_tile_headers;
+
+    int             cdx[4], cdy[4];
+    int             precision;
+    int             ncomponents;
+    int             colour_space;
+    uint32_t        palette[256];
+    int8_t          pal8;
+    int             cdef[4];
+    int             tile_width, tile_height;
+    unsigned        numXtiles, numYtiles;
+    int             maxtilelen;
+    AVRational      sar;
+
+    Jpeg2000CodingStyle codsty[4];
+    Jpeg2000QuantStyle  qntsty[4];
+    Jpeg2000POC         poc;
+    uint8_t             roi_shift[4];
+
+    int             bit_index;
+
+    int             curtileno;
+
+    Jpeg2000Tile    *tile;
+    Jpeg2000DSPContext dsp;
+
+    /*options parameters*/
+    int             reduction_factor;
+} Jpeg2000DecoderContext;
+
+#endif //AVCODEC_JPEG2000DEC_H
-- 
2.37.2

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-21 11:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-28 20:20 [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files etemesicaleb
2023-01-06 15:46 ` Tomas Härdin
2023-02-21 11:29   ` Caleb Etemesi
  -- strict thread matches above, loose matches on Subject: below --
2022-12-15 18:59 etemesicaleb
2022-12-15 23:26 ` Andreas Rheinhardt
2022-12-02 18:10 etemesicaleb
2022-12-02 18:25 ` Tomas Härdin

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git