[FFmpeg-soc] [soc]: r1070 - in jpeg2000: aec.h j2k.h j2kdec.c j2kenc.c

k.nowosad subversion at mplayerhq.hu
Mon Aug 20 19:28:58 CEST 2007


Author: k.nowosad
Date: Mon Aug 20 19:28:57 2007
New Revision: 1070

Log:
corrected comments; cosmetics


Modified:
   jpeg2000/aec.h
   jpeg2000/j2k.h
   jpeg2000/j2kdec.c
   jpeg2000/j2kenc.c

Modified: jpeg2000/aec.h
==============================================================================
--- jpeg2000/aec.h	(original)
+++ jpeg2000/aec.h	Mon Aug 20 19:28:57 2007
@@ -25,8 +25,6 @@
  * @author Kamil Nowosad
  */
 
-/* arithmetic entropy coder context */
-
 #ifndef AEC_H
 #define AEC_H
 
@@ -47,7 +45,7 @@ typedef struct {
     uint8_t cx_states[19];
 } AecState;
 
-/** encoder */
+/* encoder */
 
 /** initialize the encoder */
 void ff_aec_initenc(AecState *aec, uint8_t *bp);
@@ -61,7 +59,7 @@ int ff_aec_length(AecState *aec);
 /** flush the encoder [returns number of bytes encoded] */
 int ff_aec_flush(AecState *aec);
 
-/** decoder */
+/* decoder */
 
 /** initialize the decoder */
 void ff_aec_initdec(AecState *aec, uint8_t *bp);
@@ -69,7 +67,7 @@ void ff_aec_initdec(AecState *aec, uint8
 /** returns decoded bit with context cx */
 int ff_aec_decode(AecState *aec, uint8_t *cxstate);
 
-/** common */
+/* common */
 
 /** initialize the contexts */
 void ff_aec_init_contexts(AecState *aec);

Modified: jpeg2000/j2k.h
==============================================================================
--- jpeg2000/j2k.h	(original)
+++ jpeg2000/j2k.h	Mon Aug 20 19:28:57 2007
@@ -53,12 +53,12 @@ enum J2kMarkers{
     J2K_EOC = 0xffd9,
 };
 
-enum J2kTransform{
+enum J2kTransform{ ///< type of wavelet transform
     J2K_DWT97,
     J2K_DWT53
 };
 
-enum J2kQuantsty{
+enum J2kQuantsty{ ///< quantization style
     J2K_QSTY_NONE, ///< no quantization
     J2K_QSTY_SI,   ///< scalar derived
     J2K_QSTY_SE    ///< scalar expoounded
@@ -101,7 +101,7 @@ typedef struct J2kTgtNode {
     struct J2kTgtNode *parent;
 } J2kTgtNode;
 
-/** debug routines */
+/* debug routines */
 #if 0
 #undef fprintf
 #undef printf
@@ -109,7 +109,7 @@ void ff_j2k_printv(int *tab, int l);
 void ff_j2k_printu(uint8_t *tab, int l);
 #endif
 
-/** misc tools */
+/* misc tools */
 static inline int ff_j2k_ceildivpow2(int a, int b)
 {
     return (a + (1 << b) - 1)>> b;
@@ -120,10 +120,10 @@ static inline int ff_j2k_ceildiv(int a, 
     return (a + b - 1) / b;
 }
 
-/** tag tree routines */
+/* tag tree routines */
 J2kTgtNode *ff_j2k_tag_tree_init(int w, int h);
 
-/** TIER-1 routines */
+/* TIER-1 routines */
 void ff_j2k_init_tier1_luts();
 
 void ff_j2k_set_significant(J2kT1Context *t1, int x, int y);

Modified: jpeg2000/j2kdec.c
==============================================================================
--- jpeg2000/j2kdec.c	(original)
+++ jpeg2000/j2kdec.c	Mon Aug 20 19:28:57 2007
@@ -287,24 +287,25 @@ static void copy_defaults(J2kDecoderCont
     }
 }
 
-/** marker segments */
+/* marker segments */
+/** get sizes and offsets of image, tiles; number of components */
 static int get_siz(J2kDecoderContext *s)
 {
     int i;
 
-    bytestream_get_be16(&s->buf); ///< Rsiz (skipped)
-    s->width = bytestream_get_be32(&s->buf); ///< width
-    s->height = bytestream_get_be32(&s->buf); ///< height
-    s->image_offset_x = bytestream_get_be32(&s->buf); ///< X0Siz
-    s->image_offset_y = bytestream_get_be32(&s->buf); ///< Y0Siz
+                        bytestream_get_be16(&s->buf); // Rsiz (skipped)
+             s->width = bytestream_get_be32(&s->buf); // width
+            s->height = bytestream_get_be32(&s->buf); // height
+    s->image_offset_x = bytestream_get_be32(&s->buf); // X0Siz
+    s->image_offset_y = bytestream_get_be32(&s->buf); // Y0Siz
 
-    s->tile_width = bytestream_get_be32(&s->buf); ///< XTSiz
-    s->tile_height = bytestream_get_be32(&s->buf); ///< YTSiz
-    s->tile_offset_x = bytestream_get_be32(&s->buf); ///< XT0Siz
-    s->tile_offset_y = bytestream_get_be32(&s->buf); ///< YT0Siz
-    s->ncomponents = bytestream_get_be16(&s->buf); ///< CSiz
+        s->tile_width = bytestream_get_be32(&s->buf); // XTSiz
+       s->tile_height = bytestream_get_be32(&s->buf); // YTSiz
+     s->tile_offset_x = bytestream_get_be32(&s->buf); // XT0Siz
+     s->tile_offset_y = bytestream_get_be32(&s->buf); // YT0Siz
+       s->ncomponents = bytestream_get_be16(&s->buf); // CSiz
 
-    for (i = 0; i < s->ncomponents; i++){ ///< Ssiz_i XRsiz_i, YRsiz_i
+    for (i = 0; i < s->ncomponents; i++){ // Ssiz_i XRsiz_i, YRsiz_i
         uint8_t x = bytestream_get_byte(&s->buf);
         s->cbps[i] = (x & 0x7f) + 1;
         s->sgnd[i] = (x & 0x80) == 1;
@@ -367,19 +368,21 @@ static int get_siz(J2kDecoderContext *s)
 #define GETFIELDC(field)\
     (s->curtileno == -1 ? s->field[compno] : s->tile[s->curtileno].comp[compno].field)
 
+/** get common part for COD and COC segments */
 static int get_cox(J2kDecoderContext *s, int compno)
 {
-    SETFIELDC(nreslevels, bytestream_get_byte(&s->buf) + 1); ///< num of resolution levels - 1
-    SETFIELDC(log2_cblk_width, bytestream_get_byte(&s->buf) + 2); ///< cblk width
-    SETFIELDC(log2_cblk_height, bytestream_get_byte(&s->buf) + 2); ///< cblk height
-    if (bytestream_get_byte(&s->buf) != 0){ ///< cblk style
+    SETFIELDC(nreslevels, bytestream_get_byte(&s->buf) + 1); // num of resolution levels - 1
+    SETFIELDC(log2_cblk_width, bytestream_get_byte(&s->buf) + 2); // cblk width
+    SETFIELDC(log2_cblk_height, bytestream_get_byte(&s->buf) + 2); // cblk height
+    if (bytestream_get_byte(&s->buf) != 0){ // cblk style
         av_log(s->avctx, AV_LOG_ERROR, "no extra cblk styles supported\n");
         return -1;
     }
-    SETFIELDC(transform, bytestream_get_byte(&s->buf)); ///< transformation
+    SETFIELDC(transform, bytestream_get_byte(&s->buf)); // transformation
     return 0;
 }
 
+/** get coding parameters for a particular tile or whole image*/
 static int get_cod(J2kDecoderContext *s)
 {
     uint8_t *pos;
@@ -388,16 +391,16 @@ static int get_cod(J2kDecoderContext *s)
     csty = bytestream_get_byte(&s->buf);
     for (compno = 0; compno < s->ncomponents; compno++)
         if (!(GETFIELDC(properties) & HAD_COC)){
-            SETFIELDC(csty, csty); ///< Scod
+            SETFIELDC(csty, csty); // Scod
         }
 
-    if (bytestream_get_byte(&s->buf)){ ///< progression level
+    if (bytestream_get_byte(&s->buf)){ // progression level
         av_log(s->avctx, AV_LOG_ERROR, "only LRCP progression supported\n");
         return -1;
     }
 
     SETFIELD(nlayers, bytestream_get_be16(&s->buf));
-    SETFIELD(mct, bytestream_get_byte(&s->buf)); ///< multiple component transformation
+    SETFIELD(mct, bytestream_get_byte(&s->buf)); // multiple component transformation
 
     pos = s->buf;
     for (compno = 0; compno < s->ncomponents; compno++)
@@ -408,6 +411,7 @@ static int get_cod(J2kDecoderContext *s)
     return 0;
 }
 
+/** get coding parameters for a component in the whole image on a particular tile */
 static int get_coc(J2kDecoderContext *s)
 {
     int compno = bytestream_get_byte(&s->buf);
@@ -421,10 +425,11 @@ static int get_coc(J2kDecoderContext *s)
     return 0;
 }
 
+/** get common part for QCD and QCC segments */
 static int get_qcx(J2kDecoderContext *s, int n, int compno)
 {
     int i, x, qst, nguardbits;
-    x = bytestream_get_byte(&s->buf); ///< Sqcd
+    x = bytestream_get_byte(&s->buf); // Sqcd
     nguardbits = x >> 5;
 
     qst = x & 0x1f;
@@ -458,6 +463,7 @@ static int get_qcx(J2kDecoderContext *s,
     return 0;
 }
 
+/** get quantization parameters for a particular tile or a whole image */
 static int get_qcd(J2kDecoderContext *s, int n)
 {
     uint8_t *pos = s->buf;
@@ -471,6 +477,7 @@ static int get_qcd(J2kDecoderContext *s,
     return 0;
 }
 
+/** get quantization paramteres for a component in the whole image on in a particular tile */
 static int get_qcc(J2kDecoderContext *s, int n)
 {
     int compno = bytestream_get_byte(&s->buf);
@@ -481,6 +488,7 @@ static int get_qcc(J2kDecoderContext *s,
     return get_qcx(s, n-1, compno);
 }
 
+/** get start of tile segment */
 static uint8_t get_sot(J2kDecoderContext *s)
 {
     s->curtileno = bytestream_get_be16(&s->buf); ///< Isot
@@ -511,7 +519,7 @@ static int init_tile(J2kDecoderContext *
         return -1;
     for (compno = 0; compno < s->ncomponents; compno++){
         J2kComponent *comp = tile->comp + compno;
-        int gbandno = 0; ///< global bandno
+        int gbandno = 0; // global bandno
 
         comp->x0 = FFMAX(p * s->tile_width + s->tile_offset_x, s->image_offset_x);
         comp->x1 = FFMIN((p+1)*s->tile_width + s->tile_offset_x, s->width);
@@ -753,7 +761,7 @@ static int decode_packets(J2kDecoderCont
     return 0;
 }
 
-/** TIER-1 routines */
+/* TIER-1 routines */
 static void decode_sigpass(J2kT1Context *t1, int width, int height, int bpno, int bandno)
 {
     int mask = 3 << (bpno - 1), y0, x, y;
@@ -866,7 +874,7 @@ static int decode_cblk(J2kDecoderContext
     return 0;
 }
 
-/** inverse discrete wavelet transform routines */
+/* inverse discrete wavelet transform routines */
 static void sr_1d53(int *p, int i0, int i1)
 {
     int i;
@@ -928,10 +936,10 @@ static int dwt_decode53(J2kDecoderContex
             v1 = comp->reslevel[i].y1,
             u = u0, v = v0;
 
-        /// HOR_SD
+        // HOR_SD
         while (v < v1){
             int i, j;
-            /// copy with interleaving
+            // copy with interleaving
             for (i = u0 + (u0 & 1), j = 0; i < u1; i+=2, j++){
                 pu[i] = t[w*(v-v0) + j];
             }
@@ -946,10 +954,10 @@ static int dwt_decode53(J2kDecoderContex
 
             v++;
         }
-        /// VER_SD
+        // VER_SD
         while (u < u1){
             int i, j;
-            /// copy with interleaving
+            // copy with interleaving
             for (i = v0 + (v0 & 1), j = 0; i < v1; i+=2, j++){
                 pv[i] = t[w*j + u-u0];
             }
@@ -987,10 +995,10 @@ static int dwt_decode97(J2kDecoderContex
             v1 = comp->reslevel[i].y1,
             u = u0, v = v0;
 
-        /// HOR_SD
+        // HOR_SD
         while (v < v1){
             int i, j;
-            /// copy with interleaving
+            // copy with interleaving
             for (i = u0 + (u0 & 1), j = 0; i < u1; i+=2, j++){
                 pu[i] = t[w*(v-v0) + j];
             }
@@ -1005,10 +1013,10 @@ static int dwt_decode97(J2kDecoderContex
 
             v++;
         }
-        /// VER_SD
+        // VER_SD
         while (u < u1){
             int i, j;
-            /// copy with interleaving
+            // copy with interleaving
             for (i = v0 + (v0 & 1), j = 0; i < v1; i+=2, j++){
                 pv[i] = t[w*j + u-u0];
             }
@@ -1133,7 +1141,7 @@ static int decode_tile(J2kDecoderContext
     y = tile->comp[0].y0 - s->image_offset_y;
 
     line = s->picture.data[0] + y * s->picture.linesize[0];
-    if (s->avctx->pix_fmt == PIX_FMT_BGRA) /// RGBA -> BGRA
+    if (s->avctx->pix_fmt == PIX_FMT_BGRA) // RGBA -> BGRA
         FFSWAP(int *, src[0], src[2]);
 
     for (; y < tile->comp[0].y1 - s->image_offset_y; y++){
@@ -1219,7 +1227,7 @@ static int decode_codestream(J2kDecoderC
             case J2K_SOT:
                 ret = get_sot(s); break;
             case J2K_COM:
-                /// the comment is ignored
+                // the comment is ignored
                 s->buf += len - 2; break;
             default:
                 av_log(s->avctx, AV_LOG_ERROR, "unsupported marker 0x%.4X at pos 0x%x\n", marker, s->buf - s->buf_start - 4);
@@ -1244,7 +1252,7 @@ static int decode_frame(AVCodecContext *
     s->avctx = avctx;
     av_log(s->avctx, AV_LOG_DEBUG, "start\n");
 
-    /// init
+    // init
     s->buf = s->buf_start = buf;
     s->buf_end = buf + buf_size;
     s->curtileno = -1;

Modified: jpeg2000/j2kenc.c
==============================================================================
--- jpeg2000/j2kenc.c	(original)
+++ jpeg2000/j2kenc.c	Mon Aug 20 19:28:57 2007
@@ -41,8 +41,6 @@ static int lut_nmsedec_ref [1<<NMSEDEC_B
            lut_nmsedec_sig [1<<NMSEDEC_BITS],
            lut_nmsedec_sig0[1<<NMSEDEC_BITS];
 
-// TODO: doxygen-compatible comments
-
 typedef struct {
     uint16_t rate;
     int64_t disto;
@@ -50,16 +48,16 @@ typedef struct {
 
 typedef struct {
     uint8_t npasses;
-    uint8_t ninclpasses; // number of passes included in codestream
+    uint8_t ninclpasses; ///< number coding of passes included in codestream
     uint8_t nonzerobits;
     uint8_t zero;
     uint8_t data[8192];
     J2kPass passes[30];
-} J2kCblk; // code block
+} J2kCblk; ///< code block
 
 typedef struct {
-    uint16_t xi0, xi1, yi0, yi1; /// indices of codeblocks ([xi0, xi1))
-} J2kPrec; // precinct
+    uint16_t xi0, xi1, yi0, yi1; ///< indices of codeblocks ([xi0, xi1))
+} J2kPrec; ///< precinct
 
 typedef struct {
     uint16_t x0, x1, y0, y1;
@@ -67,14 +65,14 @@ typedef struct {
     uint16_t cblknx, cblkny;
     J2kPrec *prec;
     J2kCblk *cblk;
-} J2kBand; // subband
+} J2kBand; ///< subband
 
 typedef struct {
     uint16_t x0, x1, y0, y1;
     uint8_t nbands;
-    uint16_t num_precincts_x, num_precincts_y;
+    uint16_t num_precincts_x, num_precincts_y; ///< number of precincts in x/y direction
     J2kBand *band;
-} J2kResLevel; // resolution level
+} J2kResLevel; ///< resolution level
 
 typedef struct {
    J2kResLevel *reslevel;
@@ -82,7 +80,7 @@ typedef struct {
    uint16_t x0, x1, y0, y1;
 } J2kComponent;
 
-typedef struct { // flatten with context
+typedef struct {
    J2kComponent *comp;
 } J2kTile;
 
@@ -90,20 +88,19 @@ typedef struct {
     AVCodecContext *avctx;
     AVFrame *picture;
 
-    int width, height; // image width and height
-    uint8_t cbps[4]; // numbps in components
-    uint8_t bbps[4][32][3]; // numbps in bands
-    uint8_t expn[4][32][3]; // quantization exponents
+    int width, height; ///< image width and height
+    uint8_t cbps[4]; ///< numbps in components
+    uint8_t bbps[4][32][3]; ///< numbps in bands
+    uint8_t expn[4][32][3]; ///< quantization exponents
     int ncomponents;
-    int log2_prec_width, log2_prec_height; // exponent of the precinct size [global]
-    int log2_cblk_width, log2_cblk_height; // exponent of the code block size
-    int tile_width, tile_height; // tile size
+    int log2_prec_width, log2_prec_height; ///< exponent of the precinct size [global]
+    int log2_cblk_width, log2_cblk_height; ///< exponent of the code block size
+    int tile_width, tile_height; ///< tile size
     int numXtiles, numYtiles;
 
     int nguardbits;
 
-//    int *samples[3];
-    int nreslevels; // number of resolution levels
+    int nreslevels; ///< number of resolution levels
     uint8_t *buf_start;
     uint8_t *buf;
     uint8_t *buf_end;
@@ -203,7 +200,7 @@ static void dump(J2kEncoderContext *s, F
 
 /* bitstream routines */
 
-/* put n times val bit */
+/** put n times val bit */
 static void put_bits(J2kEncoderContext *s, int val, int n) // TODO: optimize
 {
     while (n-- > 0){
@@ -216,14 +213,14 @@ static void put_bits(J2kEncoderContext *
     }
 }
 
-/* put n least significant bits of a number num */
+/** put n least significant bits of a number num */
 static void put_num(J2kEncoderContext *s, int num, int n)
 {
     while(--n >= 0)
         put_bits(s, (num >> n) & 1, 1);
 }
 
-/* flush the bitstream */
+/** flush the bitstream */
 static void j2k_flush(J2kEncoderContext *s)
 {
     if (s->bit_index){
@@ -233,7 +230,8 @@ static void j2k_flush(J2kEncoderContext 
 }
 
 /* tag tree routines */
-/* code the value stored in node */
+
+/** code the value stored in node */
 static void tag_tree_code(J2kEncoderContext *s, J2kTgtNode *node, int threshold)
 {
     J2kTgtNode *stack[30];
@@ -261,7 +259,7 @@ static void tag_tree_code(J2kEncoderCont
     }
 }
 
-/* update the value in node */
+/** update the value in node */
 static void tag_tree_update(J2kTgtNode *node)
 {
     int lev = 0;
@@ -274,7 +272,7 @@ static void tag_tree_update(J2kTgtNode *
     }
 }
 
-/* marker segments */
+/** marker segments */
 static void put_marker(J2kEncoderContext *s, uint16_t marker)
 {
     bytestream_put_be16(&s->buf, marker);
@@ -355,7 +353,8 @@ static uint8_t *put_sot(J2kEncoderContex
     return psotptr;
 }
 
-/* compute the sizes of tiles, resolution levels, bands, etc.
+/**
+ * compute the sizes of tiles, resolution levels, bands, etc.
  * allocate memory for them
  * divide the input image into tile-components
  */
@@ -367,7 +366,7 @@ static int init_tiles(J2kEncoderContext 
     s->numYtiles = ff_j2k_ceildiv(s->height, s->tile_height);
 
     s->tile = av_malloc(s->numXtiles * s->numYtiles * sizeof(J2kTile));
-    if (s->tile)
+    if (!s->tile)
         return -1;
     for (tno = 0; tno < s->numXtiles * s->numYtiles; tno++){
         J2kTile *tile = s->tile + tno;
@@ -375,7 +374,7 @@ static int init_tiles(J2kEncoderContext 
         int q = tno / s->numXtiles;
 
         tile->comp = av_malloc(s->ncomponents * sizeof(J2kComponent));
-        if (tile->comp)
+        if (!tile->comp)
             return -1;
         for (compno = 0; compno < s->ncomponents; compno++){
             J2kComponent *comp = tile->comp + compno;
@@ -384,12 +383,11 @@ static int init_tiles(J2kEncoderContext 
             comp->x1 = FFMIN((p+1)*s->tile_width, s->width);
             comp->y0 = q * s->tile_height;
             comp->y1 = FFMIN((q+1)*s->tile_height, s->height);
-
             comp->data = av_malloc((comp->y1 - comp->y0) * (comp->x1 -comp->x0) * sizeof(int));
-            if (comp->data)
+            if (!comp->data)
                 return -1;
             comp->reslevel = av_malloc(s->nreslevels * sizeof(J2kResLevel));
-            if (comp->reslevel)
+            if (!comp->reslevel)
                 return -1;
             for (reslevelno = 0; reslevelno < s->nreslevels; reslevelno++){
                 int n = s->nreslevels - reslevelno;
@@ -414,9 +412,8 @@ static int init_tiles(J2kEncoderContext 
                     reslevel->num_precincts_y = 0;
                 else
                     reslevel->num_precincts_y = ff_j2k_ceildivpow2(reslevel->y1, s->log2_prec_height) - reslevel->y0 / (1<<s->log2_prec_height);
-
                 reslevel->band = av_malloc(reslevel->nbands * sizeof(J2kBand));
-                if (reslevel->band)
+                if (!reslevel->band)
                     return -1;
                 for (bandno = 0; bandno < reslevel->nbands; bandno++){
                     J2kBand *band = reslevel->band + bandno;
@@ -448,10 +445,10 @@ static int init_tiles(J2kEncoderContext 
                     band->cblkny = ff_j2k_ceildiv(band->y1, band->codeblock_height) - band->y0 / band->codeblock_height;
 
                     band->cblk = av_malloc(band->cblknx * band->cblkny * sizeof(J2kCblk));
-                    if (band->cblk)
+                    if (!band->cblk)
                         return -1;
                     band->prec = av_malloc(reslevel->num_precincts_x * reslevel->num_precincts_y * sizeof(J2kPrec));
-                    if (band->prec)
+                    if (!band->prec)
                         return -1;
 
                     for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){
@@ -751,6 +748,7 @@ static void encode_cblk(J2kEncoderContex
 
     for (passno = 0; bpno >= 0; passno++){
         nmsedec=0;
+
         switch(pass_t){
             case 0: encode_sigpass(t1, width, height, bandpos, &nmsedec, bpno);
                     break;
@@ -1073,7 +1071,7 @@ static int encode_frame(AVCodecContext *
         s->ncomponents = 1;
     }
     else{
-        av_log(avctx, AV_LOG_ERROR, "only rgb24 supported\n");
+        av_log(avctx, AV_LOG_ERROR, "only rgb24 and gray8 supported\n");
         return -1;
     }
 



More information about the FFmpeg-soc mailing list