From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 48DD144417 for ; Fri, 9 Sep 2022 15:46:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 416E768BB0A; Fri, 9 Sep 2022 18:46:26 +0300 (EEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2E69068B7AB for ; Fri, 9 Sep 2022 18:46:20 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 4A19E60002 for ; Fri, 9 Sep 2022 15:46:18 +0000 (UTC) Date: Fri, 9 Sep 2022 17:46:18 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220909154618.GF2088045@pb2> References: <20220908204953.46737-1-etemesicaleb@gmail.com> MIME-Version: 1.0 In-Reply-To: <20220908204953.46737-1-etemesicaleb@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH v2] avcodec/jpeg2000: Add support for High-Throughput JPEG 2000 (HTJ2K) decoding. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============6634854114930816674==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============6634854114930816674== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kuZFCdxJs1xgWibf" Content-Disposition: inline --kuZFCdxJs1xgWibf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 08, 2022 at 11:49:53PM +0300, etemesicaleb@gmail.com wrote: > From: caleb >=20 > Rebased this patch on master branch > --- > libavcodec/Makefile | 2 +- > libavcodec/j2kenc.c | 26 +- > libavcodec/jpeg2000.h | 103 ++- > libavcodec/jpeg2000dec.c | 193 ++---- > libavcodec/jpeg2000htdec.c | 1212 ++++++++++++++++++++++++++++++++++++ > libavcodec/jpeg2000htdec.h | 210 +++++++ > 6 files changed, 1599 insertions(+), 147 deletions(-) > create mode 100644 libavcodec/jpeg2000htdec.c > create mode 100644 libavcodec/jpeg2000htdec.h >=20 > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 945908e3b8..ecf5c47cad 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -450,7 +450,7 @@ OBJS-$(CONFIG_JACOSUB_DECODER) +=3D jacosubde= c.o ass.o > OBJS-$(CONFIG_JPEG2000_ENCODER) +=3D j2kenc.o mqcenc.o mqc.o jpeg= 2000.o \ > jpeg2000dwt.o > OBJS-$(CONFIG_JPEG2000_DECODER) +=3D jpeg2000dec.o jpeg2000.o jpe= g2000dsp.o \ > - jpeg2000dwt.o mqcdec.o mqc.o > + jpeg2000dwt.o mqcdec.o mqc.o j= peg2000htdec.o > OBJS-$(CONFIG_JPEGLS_DECODER) +=3D jpeglsdec.o jpegls.o > OBJS-$(CONFIG_JPEGLS_ENCODER) +=3D jpeglsenc.o jpegls.o > OBJS-$(CONFIG_JV_DECODER) +=3D jvdec.o > diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c > index e883d5deb7..233d75e96d 100644 > --- a/libavcodec/j2kenc.c > +++ b/libavcodec/j2kenc.c > @@ -106,7 +106,7 @@ static const int dwt_norms[2][4][10] =3D { // [dwt_ty= pe][band][rlevel] (multiplied > typedef struct { > Jpeg2000Component *comp; > double *layer_rates; > -} Jpeg2000Tile; > +} Jpeg2000EncTile; > =20 > typedef struct { > AVClass *class; > @@ -131,7 +131,7 @@ typedef struct { > Jpeg2000CodingStyle codsty; > Jpeg2000QuantStyle qntsty; > =20 > - Jpeg2000Tile *tile; > + Jpeg2000EncTile *tile; > int layer_rates[100]; > uint8_t compression_rate_enc; ///< Is compression done using compres= sion ratio? > =20 > @@ -427,7 +427,7 @@ static void compute_rates(Jpeg2000EncoderContext* s) > int layno, compno; > for (i =3D 0; i < s->numYtiles; i++) { > for (j =3D 0; j < s->numXtiles; j++) { > - Jpeg2000Tile *tile =3D &s->tile[s->numXtiles * i + j]; > + Jpeg2000EncTile *tile =3D &s->tile[s->numXtiles * i + j]; > for (compno =3D 0; compno < s->ncomponents; compno++) { > int tilew =3D tile->comp[compno].coord[0][1] - tile->com= p[compno].coord[0][0]; > int tileh =3D tile->comp[compno].coord[1][1] - tile->com= p[compno].coord[1][0]; > @@ -460,12 +460,12 @@ static int init_tiles(Jpeg2000EncoderContext *s) > s->numXtiles =3D ff_jpeg2000_ceildiv(s->width, s->tile_width); > s->numYtiles =3D ff_jpeg2000_ceildiv(s->height, s->tile_height); > =20 > - s->tile =3D av_calloc(s->numXtiles, s->numYtiles * sizeof(Jpeg2000Ti= le)); > + s->tile =3D av_calloc(s->numXtiles, s->numYtiles * sizeof(Jpeg2000En= cTile)); > if (!s->tile) > return AVERROR(ENOMEM); > for (tileno =3D 0, tiley =3D 0; tiley < s->numYtiles; tiley++) > for (tilex =3D 0; tilex < s->numXtiles; tilex++, tileno++){ > - Jpeg2000Tile *tile =3D s->tile + tileno; > + Jpeg2000EncTile *tile =3D s->tile + tileno; > =20 > tile->comp =3D av_calloc(s->ncomponents, sizeof(*tile->comp)= ); > if (!tile->comp) > @@ -509,7 +509,7 @@ static int init_tiles(Jpeg2000EncoderContext *s) > int tileno, compno, i, y, x; = \ > const PIXEL *line; = \ > for (tileno =3D 0; tileno < s->numXtiles * s->numYtiles; tileno+= +){ \ > - Jpeg2000Tile *tile =3D s->tile + tileno; = \ > + Jpeg2000EncTile *tile =3D s->tile + tileno; = \ > if (s->planar){ = \ > for (compno =3D 0; compno < s->ncomponents; compno++){ = \ > Jpeg2000Component *comp =3D tile->comp + compno; = \ > @@ -701,7 +701,7 @@ static void encode_clnpass(Jpeg2000T1Context *t1, int= width, int height, int ban > } > } > =20 > -static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1= , Jpeg2000Cblk *cblk, Jpeg2000Tile *tile, > +static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1= , Jpeg2000Cblk *cblk, Jpeg2000EncTile *tile, > int width, int height, int bandpos, int lev) > { > int pass_t =3D 2, passno, x, y, max=3D0, nmsedec, bpno; > @@ -935,7 +935,7 @@ static int encode_packet(Jpeg2000EncoderContext *s, J= peg2000ResLevel *rlevel, in > return 0; > } > =20 > -static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile,= int tileno, int nlayers) > +static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000EncTile *ti= le, int tileno, int nlayers) > { > int compno, reslevelno, layno, ret; > Jpeg2000CodingStyle *codsty =3D &s->codsty; > @@ -1181,7 +1181,7 @@ static int encode_packets(Jpeg2000EncoderContext *s= , Jpeg2000Tile *tile, int til > return 0; > } > =20 > -static void makelayer(Jpeg2000EncoderContext *s, int layno, double thres= h, Jpeg2000Tile* tile, int final) > +static void makelayer(Jpeg2000EncoderContext *s, int layno, double thres= h, Jpeg2000EncTile* tile, int final) > { > int compno, resno, bandno, precno, cblkno; > int passno; > @@ -1264,7 +1264,7 @@ static void makelayer(Jpeg2000EncoderContext *s, in= t layno, double thresh, Jpeg2 > } > } > =20 > -static void makelayers(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile) > +static void makelayers(Jpeg2000EncoderContext *s, Jpeg2000EncTile *tile) > { > int precno, compno, reslevelno, bandno, cblkno, lev, passno, layno; > int i; > @@ -1365,7 +1365,7 @@ static int getcut(Jpeg2000Cblk *cblk, int64_t lambd= a, int dwt_norm) > return res; > } > =20 > -static void truncpasses(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile) > +static void truncpasses(Jpeg2000EncoderContext *s, Jpeg2000EncTile *tile) > { > int precno, compno, reslevelno, bandno, cblkno, lev; > Jpeg2000CodingStyle *codsty =3D &s->codsty; > @@ -1399,7 +1399,7 @@ static void truncpasses(Jpeg2000EncoderContext *s, = Jpeg2000Tile *tile) > } > } > =20 > -static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, in= t tileno) > +static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000EncTile *tile,= int tileno) > { > int compno, reslevelno, bandno, ret; > Jpeg2000T1Context t1; > @@ -1514,7 +1514,7 @@ static void reinit(Jpeg2000EncoderContext *s) > { > int tileno, compno; > for (tileno =3D 0; tileno < s->numXtiles * s->numYtiles; tileno++){ > - Jpeg2000Tile *tile =3D s->tile + tileno; > + Jpeg2000EncTile *tile =3D s->tile + tileno; > for (compno =3D 0; compno < s->ncomponents; compno++) > ff_jpeg2000_reinit(tile->comp + compno, &s->codsty); > } Renaming Jpeg2000Tile could be in a seperate patch > diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h > index e5ecb4cbf9..a5dd693392 100644 > --- a/libavcodec/jpeg2000.h > +++ b/libavcodec/jpeg2000.h > @@ -33,8 +33,9 @@ > =20 > #include "avcodec.h" > #include "mqc.h" > +#include "bytestream.h" > #include "jpeg2000dwt.h" > - > +#include "jpeg2000dsp.h" > enum Jpeg2000Markers { > JPEG2000_SOC =3D 0xff4f, // start of codestream > JPEG2000_SIZ =3D 0xff51, // image and tile size > @@ -171,7 +172,6 @@ typedef struct Jpeg2000Layer { > double disto; > int cum_passes; > } Jpeg2000Layer; > - > typedef struct Jpeg2000Cblk { > uint8_t npasses; > uint8_t ninclpasses; // number coding of passes included in codestre= am unintended, i assume > @@ -181,6 +181,7 @@ typedef struct Jpeg2000Cblk { > uint16_t *lengthinc; > uint8_t nb_lengthinc; > uint8_t lblock; > + uint8_t zbp; // Zero bit planes > uint8_t *data; > size_t data_allocated; > int nb_terminations; > @@ -189,6 +190,7 @@ typedef struct Jpeg2000Cblk { > Jpeg2000Pass *passes; > Jpeg2000Layer *layers; > int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} > + int pass_lengths[2]; > } Jpeg2000Cblk; // code block Please use doxygen compatible comments so it all appears on for example https://ffmpeg.org/doxygen/trunk/structJpeg2000Cblk.html > =20 > typedef struct Jpeg2000Prec { > @@ -227,6 +229,103 @@ typedef struct Jpeg2000Component { > uint8_t roi_shift; // ROI scaling value for the component > } Jpeg2000Component; > =20 > +#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 til= e-part > + const uint8_t *tp_end; > + GetByteContext header_tpg; // bit stream of header if PPM h= eader 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 { ^^^^^^^^^^^^=20 > + 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 heade= rs. Used only along with PPT marker > + int packed_headers_size; // size in bytes of the = packed headers > + GetByteContext packed_headers_stream; // byte context correspo= nding to packed headers > + uint16_t tp_idx; // Tile-part index > + int coord[2][2]; // border coordinates {= {x0, x1}, {y0, y1}} > +} Jpeg2000DecTile; ^^^^^^^^^^^^^^^ This difference appears unintended > + > +typedef struct Jpeg2000DecoderContext { This is unneeded for the encoder maybe a jpeg2000dec.h would be better for this also code moving should be in a seperate patch from functional changes [...] > +#endif /* AVCODEC_JPEG2000HTDEC_H */ > \ No newline at end of file needs newline new decoder not reviewed, feel free to wait for someone to review it before= reposting thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin --kuZFCdxJs1xgWibf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYxtfxgAKCRBhHseHBAsP q+4VAJ916f0l5ofNoS8qHwphpo+lP1FV9gCfb+xtuZuvU0MwcOxpxNDoWEqxCaA= =QBWb -----END PGP SIGNATURE----- --kuZFCdxJs1xgWibf-- --===============6634854114930816674== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============6634854114930816674==--