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 A19E14443E for ; Fri, 9 Sep 2022 16:53:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E59968BB0A; Fri, 9 Sep 2022 19:53:14 +0300 (EEST) Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CDF5768BA38 for ; Fri, 9 Sep 2022 19:53:07 +0300 (EEST) Received: by mail-ej1-f44.google.com with SMTP id y17so303119ejo.6 for ; Fri, 09 Sep 2022 09:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date; bh=8GJ5aH3lAJDXbNW6hiPBIf4ly2M6WYWkoDh3MUVC0lY=; b=hFkFkiBlQt1K250V6ucLYrnLWYWmX/78AHkrXJI9T0kD7XV7ObAQnh3Tx7svtYAd6n kAaiBN1VyBU1hr30Wtj/0BPxIVLdgq4t8U/0/Zf/Ktp7om2hIMTFG2ve1G74SrWc3DDl XU6UTUASN8OTSKix3LEBtYSXzMtYR0ugJ/l7z2yzeSU2BFT/1BvhHRU/eEeU+1Zw7bmB 6yR6kBulUoPgZi+H3V0jEwsXYa60MzMqZW3mCroqDWoL5ApqnNt0SuZekZIaShp1QqUq qHwRnmTRIfZWbOnouERY180602LzO7689ht7Mz9CEKk6kSe4snhjxnhQwtoErFLvuuF3 bt0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date; bh=8GJ5aH3lAJDXbNW6hiPBIf4ly2M6WYWkoDh3MUVC0lY=; b=44qxXAXMZxMS/lgVSnqZnABzJLAX8wqigy8e3zEXwpGoNx1sV+r6BPiKuNBbkqXBx0 ZlLWH41KK/+K7JOlv1l/aWCRxCvR3hcNmzwEm9A1GTjgvolvR4xc1kvi4Ax4IhtYRrcI pYRYSYMZbH06SC2WrMh+vKi1CumDL1/uhxYL3zeL3cmCQVFwh9Hlnmv9dazLgNLHkuBR HBG+uG0zgZ8ccj2fW/TjfIJSQLj9KZ4zEU/sR8K6Cn50MLNCevELg3pgDlJAfbXrA3e/ PxUeSEgy95VywxHVmKzlGhw+TCWWnboqihwcllwHg8VT0yFvywpl7THPU7/ipVmDD9jF S8vQ== X-Gm-Message-State: ACgBeo380skRXf2mP/qb6tGHmYOMfAf6DcYPtzNwqHfnkY4bixJQuZ5E eUMzzgUUNBvBMDmI4WHBgy+sUwuvJhy/KuKYlFwm0U45h5Y= X-Google-Smtp-Source: AA6agR6IyiP0KTeQn1Z/bmbFs00jbIhHAMRuv8FSeXqCqkKnSaeAzKputJWM1saxDjuT7pbK9t0g8JMvFo4VWmwcpks= X-Received: by 2002:a17:907:1df1:b0:779:4f57:6bb2 with SMTP id og49-20020a1709071df100b007794f576bb2mr4199137ejc.407.1662742386751; Fri, 09 Sep 2022 09:53:06 -0700 (PDT) MIME-Version: 1.0 References: <20220908204953.46737-1-etemesicaleb@gmail.com> <20220909154618.GF2088045@pb2> In-Reply-To: <20220909154618.GF2088045@pb2> From: Caleb Etemesi Date: Fri, 9 Sep 2022 19:52:55 +0300 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Will address in the next iteration On Fri, 9 Sept 2022, 18:46 Michael Niedermayer, wrote: > On Thu, Sep 08, 2022 at 11:49:53PM +0300, etemesicaleb@gmail.com wrote: > > From: caleb > > > > 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 > > > > 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) += > jacosubdec.o ass.o > > OBJS-$(CONFIG_JPEG2000_ENCODER) += j2kenc.o mqcenc.o mqc.o > jpeg2000.o \ > > jpeg2000dwt.o > > OBJS-$(CONFIG_JPEG2000_DECODER) += jpeg2000dec.o jpeg2000.o > jpeg2000dsp.o \ > > - jpeg2000dwt.o mqcdec.o mqc.o > > + jpeg2000dwt.o mqcdec.o mqc.o > jpeg2000htdec.o > > OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o > > OBJS-$(CONFIG_JPEGLS_ENCODER) += jpeglsenc.o jpegls.o > > OBJS-$(CONFIG_JV_DECODER) += 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] = { // > [dwt_type][band][rlevel] (multiplied > > typedef struct { > > Jpeg2000Component *comp; > > double *layer_rates; > > -} Jpeg2000Tile; > > +} Jpeg2000EncTile; > > > > typedef struct { > > AVClass *class; > > @@ -131,7 +131,7 @@ typedef struct { > > Jpeg2000CodingStyle codsty; > > Jpeg2000QuantStyle qntsty; > > > > - Jpeg2000Tile *tile; > > + Jpeg2000EncTile *tile; > > int layer_rates[100]; > > uint8_t compression_rate_enc; ///< Is compression done using > compression ratio? > > > > @@ -427,7 +427,7 @@ static void compute_rates(Jpeg2000EncoderContext* s) > > int layno, compno; > > for (i = 0; i < s->numYtiles; i++) { > > for (j = 0; j < s->numXtiles; j++) { > > - Jpeg2000Tile *tile = &s->tile[s->numXtiles * i + j]; > > + Jpeg2000EncTile *tile = &s->tile[s->numXtiles * i + j]; > > for (compno = 0; compno < s->ncomponents; compno++) { > > int tilew = tile->comp[compno].coord[0][1] - > tile->comp[compno].coord[0][0]; > > int tileh = tile->comp[compno].coord[1][1] - > tile->comp[compno].coord[1][0]; > > @@ -460,12 +460,12 @@ static int init_tiles(Jpeg2000EncoderContext *s) > > s->numXtiles = ff_jpeg2000_ceildiv(s->width, s->tile_width); > > s->numYtiles = ff_jpeg2000_ceildiv(s->height, s->tile_height); > > > > - s->tile = av_calloc(s->numXtiles, s->numYtiles * > sizeof(Jpeg2000Tile)); > > + s->tile = av_calloc(s->numXtiles, s->numYtiles * > sizeof(Jpeg2000EncTile)); > > if (!s->tile) > > return AVERROR(ENOMEM); > > for (tileno = 0, tiley = 0; tiley < s->numYtiles; tiley++) > > for (tilex = 0; tilex < s->numXtiles; tilex++, tileno++){ > > - Jpeg2000Tile *tile = s->tile + tileno; > > + Jpeg2000EncTile *tile = s->tile + tileno; > > > > tile->comp = 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 = 0; tileno < s->numXtiles * s->numYtiles; > tileno++){ \ > > - Jpeg2000Tile *tile = s->tile + tileno; > \ > > + Jpeg2000EncTile *tile = s->tile + tileno; > \ > > if (s->planar){ > \ > > for (compno = 0; compno < s->ncomponents; compno++){ > \ > > Jpeg2000Component *comp = tile->comp + compno; > \ > > @@ -701,7 +701,7 @@ static void encode_clnpass(Jpeg2000T1Context *t1, > int width, int height, int ban > > } > > } > > > > -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 = 2, passno, x, y, max=0, nmsedec, bpno; > > @@ -935,7 +935,7 @@ static int encode_packet(Jpeg2000EncoderContext *s, > Jpeg2000ResLevel *rlevel, in > > return 0; > > } > > > > -static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000Tile > *tile, int tileno, int nlayers) > > +static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000EncTile > *tile, int tileno, int nlayers) > > { > > int compno, reslevelno, layno, ret; > > Jpeg2000CodingStyle *codsty = &s->codsty; > > @@ -1181,7 +1181,7 @@ static int encode_packets(Jpeg2000EncoderContext > *s, Jpeg2000Tile *tile, int til > > return 0; > > } > > > > -static void makelayer(Jpeg2000EncoderContext *s, int layno, double > thresh, Jpeg2000Tile* tile, int final) > > +static void makelayer(Jpeg2000EncoderContext *s, int layno, double > thresh, Jpeg2000EncTile* tile, int final) > > { > > int compno, resno, bandno, precno, cblkno; > > int passno; > > @@ -1264,7 +1264,7 @@ static void makelayer(Jpeg2000EncoderContext *s, > int layno, double thresh, Jpeg2 > > } > > } > > > > -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 > lambda, int dwt_norm) > > return res; > > } > > > > -static void truncpasses(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile) > > +static void truncpasses(Jpeg2000EncoderContext *s, Jpeg2000EncTile > *tile) > > { > > int precno, compno, reslevelno, bandno, cblkno, lev; > > Jpeg2000CodingStyle *codsty = &s->codsty; > > @@ -1399,7 +1399,7 @@ static void truncpasses(Jpeg2000EncoderContext *s, > Jpeg2000Tile *tile) > > } > > } > > > > -static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, > int 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 = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ > > - Jpeg2000Tile *tile = s->tile + tileno; > > + Jpeg2000EncTile *tile = s->tile + tileno; > > for (compno = 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 @@ > > > > #include "avcodec.h" > > #include "mqc.h" > > +#include "bytestream.h" > > #include "jpeg2000dwt.h" > > - > > +#include "jpeg2000dsp.h" > > enum Jpeg2000Markers { > > JPEG2000_SOC = 0xff4f, // start of codestream > > JPEG2000_SIZ = 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 > codestream > > 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 > > > > > typedef struct Jpeg2000Prec { > > @@ -227,6 +229,103 @@ typedef struct Jpeg2000Component { > > uint8_t roi_shift; // ROI scaling value for the component > > } Jpeg2000Component; > > > > +#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}} > > +} 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 > > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Those who would give up essential Liberty, to purchase a little > temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin > _______________________________________________ > 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".