[FFmpeg-soc] [soc]: r3905 - in dirac/libavcodec: dirac.c dirac.h diracdec.c

conrad subversion at mplayerhq.hu
Thu Jan 1 21:31:16 CET 2009


Author: conrad
Date: Thu Jan  1 21:31:16 2009
New Revision: 3905

Log:
Move variables that differ for each plane to Plane struct, and init them from a single place

Modified:
   dirac/libavcodec/dirac.c
   dirac/libavcodec/dirac.h
   dirac/libavcodec/diracdec.c

Modified: dirac/libavcodec/dirac.c
==============================================================================
--- dirac/libavcodec/dirac.c	Thu Jan  1 21:31:13 2009	(r3904)
+++ dirac/libavcodec/dirac.c	Thu Jan  1 21:31:16 2009	(r3905)
@@ -537,6 +537,7 @@ static void motion_comp_block2refs(Dirac
     const uint8_t *w1 = NULL;
     const uint8_t *w2 = NULL;
     int xfix1 = 0, xfix2 = 0;
+    Plane *p = &s->plane[comp];
 
     vect1[0] = currblock->vect[0][0];
     vect1[1] = currblock->vect[0][1];
@@ -595,22 +596,22 @@ static void motion_comp_block2refs(Dirac
         return;
     }
 
-    spatialwt = &s->spatialwt[s->xblen * (ys - ystart)];
+    spatialwt = &s->spatialwt[p->xblen * (ys - ystart)];
 
     /* Make sure the vector doesn't point to a block outside the
        padded frame. */
-    refystart1 = av_clip(refystart1, -s->yblen, s->height * 2 - 1);
-    refystart2 = av_clip(refystart2, -s->yblen, s->height * 2 - 1);
-    if (refxstart1 < -s->xblen)
-        xfix1 = -s->xblen - refxstart1;
-    else if (refxstart1 >= (s->width - 1) * 2)
-        xfix1 = (s->width - 1) * 2 - refxstart1;
-    if (refxstart2 < -s->xblen * 2)
-        xfix2 = -s->xblen * 2 - refxstart2;
-    else if (refxstart2 >= (s->width - 1) * 2)
-        xfix2 = (s->width - 1) * 2 - refxstart2;
+    refystart1 = av_clip(refystart1, -p->yblen, p->height * 2 - 1);
+    refystart2 = av_clip(refystart2, -p->yblen, p->height * 2 - 1);
+    if (refxstart1 < -p->xblen)
+        xfix1 = -p->xblen - refxstart1;
+    else if (refxstart1 >= (p->width - 1) * 2)
+        xfix1 = (p->width - 1) * 2 - refxstart1;
+    if (refxstart2 < -p->xblen * 2)
+        xfix2 = -p->xblen * 2 - refxstart2;
+    else if (refxstart2 >= (p->width - 1) * 2)
+        xfix2 = (p->width - 1) * 2 - refxstart2;
 
-    line = &coeffs[s->width * ys];
+    line = &coeffs[p->width * ys];
     refline1 = &ref1[refystart1 * s->refwidth];
     refline2 = &ref2[refystart2 * s->refwidth];
     for (y = ys; y < ystop; y++) {
@@ -672,10 +673,10 @@ static void motion_comp_block2refs(Dirac
                 val *= spatialwt[bx];
             } else {
                 val = (val
-                       * spatial_wt(i, x, s->xbsep, s->xblen,
-                                    s->xoffset, s->current_blwidth)
-                       * spatial_wt(j, y, s->ybsep, s->yblen,
-                                    s->yoffset, s->current_blheight));
+                       * spatial_wt(i, x, p->xbsep, p->xblen,
+                                    p->xoffset, p->current_blwidth)
+                       * spatial_wt(j, y, p->ybsep, p->yblen,
+                                    p->yoffset, p->current_blheight));
             }
 
             line[x] += val;
@@ -683,8 +684,8 @@ static void motion_comp_block2refs(Dirac
         }
         refline1 += s->refwidth << 1;
         refline2 += s->refwidth << 1;
-        line += s->width;
-        spatialwt += s->xblen;
+        line += p->width;
+        spatialwt += p->xblen;
     }
 }
 
@@ -722,6 +723,7 @@ static void motion_comp_block1ref(DiracC
     int rx, ry;
     const uint8_t *w = NULL;
     int xfix = 0;
+    Plane *p = &s->plane[comp];
 
     vect[0] = currblock->vect[ref][0];
     vect[1] = currblock->vect[ref][1];
@@ -764,15 +766,15 @@ static void motion_comp_block1ref(DiracC
 
     /* Make sure the vector doesn't point to a block outside the
        padded frame. */
-    refystart = av_clip(refystart, -s->yblen * 2, s->height * 2 - 1);
-    if (refxstart < -s->xblen * 2)
-        xfix = -s->xblen - refxstart;
-    else if (refxstart >= (s->width - 1) * 2)
-        xfix = (s->width - 1) * 2 - refxstart;
+    refystart = av_clip(refystart, -p->yblen * 2, p->height * 2 - 1);
+    if (refxstart < -p->xblen * 2)
+        xfix = -p->xblen - refxstart;
+    else if (refxstart >= (p->width - 1) * 2)
+        xfix = (p->width - 1) * 2 - refxstart;
 
-    spatialwt = &s->spatialwt[s->xblen * (ys - ystart)];
+    spatialwt = &s->spatialwt[p->xblen * (ys - ystart)];
 
-    line = &coeffs[s->width * ys];
+    line = &coeffs[p->width * ys];
     refline = &refframe[refystart * s->refwidth];
     for (y = ys; y < ystop; y++) {
         int bx = xs - xstart;
@@ -818,18 +820,18 @@ static void motion_comp_block1ref(DiracC
                 val *= spatialwt[bx];
             } else {
                 val = (val
-                       * spatial_wt(i, x, s->xbsep, s->xblen,
-                                    s->xoffset, s->current_blwidth)
-                       * spatial_wt(j, y, s->ybsep, s->yblen,
-                                    s->yoffset, s->current_blheight));
+                       * spatial_wt(i, x, p->xbsep, p->xblen,
+                                    p->xoffset, p->current_blwidth)
+                       * spatial_wt(j, y, p->ybsep, p->yblen,
+                                    p->yoffset, p->current_blheight));
             }
 
             line[x] += val;
             bx++;
         }
-        line += s->width;
+        line += p->width;
         refline += s->refwidth << 1;
-        spatialwt += s->xblen;
+        spatialwt += p->xblen;
     }
 }
 
@@ -849,20 +851,21 @@ static void motion_comp_block1ref(DiracC
 static inline
 void motion_comp_dc_block(DiracContext *s, int16_t *coeffs, int i, int j,
                           int xstart, int xstop, int ystart, int ystop,
-                          int dcval, int border)
+                          int dcval, int comp, int border)
 {
     int x, y;
     int xs, ys;
     int16_t *line;
     int16_t *spatialwt;
+    Plane *p = &s->plane[comp];
 
     ys = FFMAX(ystart, 0);
     xs = FFMAX(xstart, 0);
 
     dcval <<= s->decoding.picture_weight_precision;
 
-    spatialwt = &s->spatialwt[s->xblen * (ys - ystart)];
-    line = &coeffs[s->width * ys];
+    spatialwt = &s->spatialwt[p->xblen * (ys - ystart)];
+    line = &coeffs[p->width * ys];
     for (y = ys; y < ystop; y++) {
         int bx = xs - xstart;
         for (x = xs; x < xstop; x++) {
@@ -872,17 +875,17 @@ void motion_comp_dc_block(DiracContext *
                 val = dcval * spatialwt[bx];
             } else {
                 val = dcval
-                    * spatial_wt(i, x, s->xbsep, s->xblen,
-                                 s->xoffset, s->current_blwidth)
-                    * spatial_wt(j, y, s->ybsep, s->yblen,
-                                 s->yoffset, s->current_blheight);
+                    * spatial_wt(i, x, p->xbsep, p->xblen,
+                                 p->xoffset, p->current_blwidth)
+                    * spatial_wt(j, y, p->ybsep, p->yblen,
+                                 p->yoffset, p->current_blheight);
             }
 
             line[x] += val;
             bx++;
         }
-        line += s->width;
-        spatialwt += s->xblen;
+        line += p->width;
+        spatialwt += p->xblen;
     }
 }
 
@@ -900,41 +903,27 @@ int dirac_motion_compensation(DiracConte
     struct dirac_blockmotion *currblock;
     int xstart, ystart;
     int xstop, ystop;
-    int hbits, vbits;
-
-    s->width  = s->source.width  >> (comp ? s->chroma_hshift : 0);
-    s->height = s->source.height >> (comp ? s->chroma_vshift : 0);
-    s->xblen  = s->decoding.xblen[!!comp];
-    s->yblen  = s->decoding.yblen[!!comp];
-    s->xbsep  = s->decoding.xbsep[!!comp];
-    s->ybsep  = s->decoding.ybsep[!!comp];
-
-    s->xoffset = (s->xblen - s->xbsep) / 2;
-    s->yoffset = (s->yblen - s->ybsep) / 2;
-    hbits      = av_log2(s->xoffset) + 2;
-    vbits      = av_log2(s->yoffset) + 2;
-
-    s->total_wt_bits = hbits + vbits + s->decoding.picture_weight_precision;
+    Plane *p = &s->plane[comp];
 
-    s->refwidth = (s->width + 2 * s->xblen) << 1;
-    s->refheight = (s->height + 2 * s->yblen) << 1;
+    s->refwidth = (p->width + 2 * p->xblen) << 1;
+    s->refheight = (p->height + 2 * p->yblen) << 1;
 
-    s->spatialwt = av_malloc(s->xblen * s->yblen * sizeof(int16_t));
+    s->spatialwt = av_malloc(p->xblen * p->yblen * sizeof(int16_t));
     if (!s->spatialwt) {
         av_log(s->avctx, AV_LOG_ERROR, "av_malloc() failed\n");
         return -1;
     }
 
     /* Set up the spatial weighting matrix. */
-    for (x = 0; x < s->xblen; x++) {
-        for (y = 0; y < s->yblen; y++) {
+    for (x = 0; x < p->xblen; x++) {
+        for (y = 0; y < p->yblen; y++) {
             int wh, wv;
-            const int xmax = 2 * (s->xblen - s->xbsep);
-            const int ymax = 2 * (s->yblen - s->ybsep);
+            const int xmax = 2 * (p->xblen - p->xbsep);
+            const int ymax = 2 * (p->yblen - p->ybsep);
 
-            wh = av_clip(s->xblen - FFABS(2*x - (s->xblen - 1)), 0, xmax);
-            wv = av_clip(s->yblen - FFABS(2*y - (s->yblen - 1)), 0, ymax);
-            s->spatialwt[x + y * s->xblen] = wh * wv;
+            wh = av_clip(p->xblen - FFABS(2*x - (p->xblen - 1)), 0, xmax);
+            wv = av_clip(p->yblen - FFABS(2*y - (p->yblen - 1)), 0, ymax);
+            s->spatialwt[x + y * p->xblen] = wh * wv;
         }
     }
 
@@ -954,18 +943,18 @@ int dirac_motion_compensation(DiracConte
                 av_log(s->avctx, AV_LOG_ERROR, "av_malloc() failed\n");
                 return -1;
             }
-            interpolate_frame_halfpel(s->ref_pics[i], s->width, s->height,
-                                      s->refdata[i], comp, s->xblen, s->yblen);
+            interpolate_frame_halfpel(s->ref_pics[i], p->width, p->height,
+                                      s->refdata[i], comp, p->xblen, p->yblen);
     }
 
-    if (avcodec_check_dimensions(s->avctx, s->width, s->height)) {
+    if (avcodec_check_dimensions(s->avctx, p->width, p->height)) {
         for (i = 0; i < s->refs; i++)
             av_free(s->refdata[i]);
 
         return -1;
     }
 
-    s->mcpic = av_malloc(s->width * s->height * sizeof(int16_t));
+    s->mcpic = av_malloc(p->width * p->height * sizeof(int16_t));
     if (!s->mcpic) {
         for (i = 0; i < s->refs; i++)
             av_free(s->refdata[i]);
@@ -973,38 +962,35 @@ int dirac_motion_compensation(DiracConte
         av_log(s->avctx, AV_LOG_ERROR, "av_malloc() failed\n");
         return -1;
     }
-    memset(s->mcpic, 0, s->width * s->height * sizeof(int16_t));
+    memset(s->mcpic, 0, p->width * p->height * sizeof(int16_t));
 
     {
-        s->current_blwidth  = (s->width  - s->xoffset) / s->xbsep + 1;
-        s->current_blheight = (s->height - s->yoffset) / s->ybsep + 1;
-
         currblock = s->blmotion;
-        for (j = 0; j < s->current_blheight; j++) {
-            for (i = 0; i < s->current_blwidth; i++) {
+        for (j = 0; j < p->current_blheight; j++) {
+            for (i = 0; i < p->current_blwidth; i++) {
                 struct dirac_blockmotion *block = &currblock[i];
                 int border;
                 int padding;
 
                 /* XXX: These calculations do not match those in the
                    Dirac specification, but are correct. */
-                xstart  = i * s->xbsep - s->xoffset;
-                ystart  = j * s->ybsep - s->yoffset;
-                xstop   = FFMIN(xstart + s->xblen, s->width);
-                ystop   = FFMIN(ystart + s->yblen, s->height);
+                xstart  = i * p->xbsep - p->xoffset;
+                ystart  = j * p->ybsep - p->yoffset;
+                xstop   = FFMIN(xstart + p->xblen, p->width);
+                ystop   = FFMIN(ystart + p->yblen, p->height);
 
                 border = (i > 0 && j > 0
-                          && i < s->current_blwidth - 1
-                          && j < s->current_blheight - 1);
+                          && i < p->current_blwidth - 1
+                          && j < p->current_blheight - 1);
 
-                padding = 2 * ((s->xblen * 2 + s->width) * 2 * s->yblen
-                               + s->xblen);
+                padding = 2 * ((p->xblen * 2 + p->width) * 2 * p->yblen
+                               + p->xblen);
 
                 /* Intra */
                 if ((block->use_ref & 3) == 0)
                     motion_comp_dc_block(s, s->mcpic, i, j,
                                          xstart, xstop, ystart, ystop,
-                                         block->dc[comp], border);
+                                         block->dc[comp], comp, border);
                 /* Reference frame 1 only. */
                 else if ((block->use_ref & 3) == DIRAC_REF_MASK_REF1)
                     motion_comp_block1ref(s, s->mcpic, i, j,

Modified: dirac/libavcodec/dirac.h
==============================================================================
--- dirac/libavcodec/dirac.h	Thu Jan  1 21:31:13 2009	(r3904)
+++ dirac/libavcodec/dirac.h	Thu Jan  1 21:31:16 2009	(r3905)
@@ -108,11 +108,6 @@ typedef struct {
 struct decoding_parameters {
     uint8_t wavelet_depth;          ///< depth of the IDWT
 
-    uint8_t xbsep[2];
-    uint8_t xblen[2];
-    uint8_t ybsep[2];
-    uint8_t yblen[2];
-
     uint8_t mv_precision;
 
     int16_t picture_weight_ref1;
@@ -160,6 +155,17 @@ typedef struct Plane{
     int padded_width;
     int padded_height;
     SubBand band[MAX_DECOMPOSITIONS][4];
+
+    uint8_t xbsep;
+    uint8_t xblen;
+    uint8_t ybsep;
+    uint8_t yblen;
+
+    uint8_t xoffset;
+    uint8_t yoffset;
+    uint8_t total_wt_bits;
+    uint8_t current_blwidth;
+    uint8_t current_blheight;
 } Plane;
 
 typedef struct DiracContext {
@@ -186,6 +192,7 @@ typedef struct DiracContext {
     unsigned int codeblock_mode;
     unsigned int codeblocksh[MAX_DECOMPOSITIONS+1];
     unsigned int codeblocksv[MAX_DECOMPOSITIONS+1];
+    IDWTELEM *spatial_idwt_buffer;
 
     int low_delay;            ///< use the low delay syntax
     unsigned int x_slices;
@@ -218,19 +225,6 @@ typedef struct DiracContext {
 
     Plane plane[3];
 
-    /* Current component. */
-    int width;
-    int height;
-    int xbsep;
-    int ybsep;
-    int xblen;
-    int yblen;
-    int xoffset;
-    int yoffset;
-    int total_wt_bits;
-    int current_blwidth;
-    int current_blheight;
-
     int *sbsplit;     // XXX: int8_t
     struct dirac_blockmotion *blmotion;
 

Modified: dirac/libavcodec/diracdec.c
==============================================================================
--- dirac/libavcodec/diracdec.c	Thu Jan  1 21:31:13 2009	(r3904)
+++ dirac/libavcodec/diracdec.c	Thu Jan  1 21:31:16 2009	(r3905)
@@ -96,6 +96,7 @@ static int decode_end(AVCodecContext *av
     DiracContext *s = avctx->priv_data;
 
     av_free(s->all_frames);
+    av_free(s->spatial_idwt_buffer);
 
     return 0;
 }
@@ -330,6 +331,71 @@ static void decode_component(DiracContex
     }
 }
 
+static void init_planes(DiracContext *s)
+{
+    int i, w, h, level, orientation;
+
+#define PAD(size, depth) \
+    (((size + (1 << depth) - 1) >> depth) << depth)
+
+    av_freep(&s->spatial_idwt_buffer);
+
+    for (i = 0; i < 3; i++) {
+        Plane *p = &s->plane[i];
+
+        p->width  = s->source.width  >> (i ? s->chroma_hshift : 0);
+        p->height = s->source.height >> (i ? s->chroma_vshift : 0);
+        p->padded_width  = w = PAD(p->width , s->decoding.wavelet_depth);
+        p->padded_height = h = PAD(p->height, s->decoding.wavelet_depth);
+
+        if (i == 0)
+            s->spatial_idwt_buffer =
+                av_malloc(p->padded_width*p->padded_height * sizeof(IDWTELEM));
+
+        for (level = s->decoding.wavelet_depth-1; level >= 0; level--) {
+            for (orientation = level ? 1 : 0; orientation < 4; orientation++) {
+                SubBand *b = &p->band[level][orientation];
+
+                b->ibuf   = s->spatial_idwt_buffer;
+                b->level  = level;
+                b->stride = p->padded_width << (s->decoding.wavelet_depth - level);
+                b->width  = (w + !(orientation&1))>>1;
+                b->height = (h + !(orientation>1))>>1;
+                b->orientation = orientation;
+
+                if (orientation & 1)
+                    b->ibuf += (w+1)>>1;
+                if (orientation > 1)
+                    b->ibuf += b->stride>>1;
+
+                if (level)
+                    b->parent = &p->band[level-1][orientation];
+            }
+            w = (w+1)>>1;
+            h = (h+1)>>1;
+        }
+
+        if (i > 0) {
+            p->xblen = s->plane[0].xblen >> s->chroma_hshift;
+            p->yblen = s->plane[0].yblen >> s->chroma_vshift;
+            p->xbsep = s->plane[0].xbsep >> s->chroma_hshift;
+            p->ybsep = s->plane[0].ybsep >> s->chroma_vshift;
+        }
+
+        p->xoffset = (p->xblen - p->xbsep) / 2;
+        p->yoffset = (p->yblen - p->ybsep) / 2;
+
+        p->total_wt_bits = s->decoding.picture_weight_precision +
+            av_log2(p->xoffset) + av_log2(p->yoffset) + 4;
+
+        if (s->refs) {
+            p->current_blwidth  = (p->width  - p->xoffset) / p->xbsep + 1;
+            p->current_blheight = (p->height - p->yoffset) / p->ybsep + 1;
+        }
+    }
+#undef PAD
+}
+
 /**
  * Unpack the motion compensation parameters
  */
@@ -344,24 +410,17 @@ static int dirac_unpack_prediction_param
         return -1;
 
     if (idx == 0) {
-        s->decoding.xblen[0] = svq3_get_ue_golomb(gb);
-        s->decoding.yblen[0] = svq3_get_ue_golomb(gb);
-        s->decoding.xbsep[0] = svq3_get_ue_golomb(gb);
-        s->decoding.ybsep[0] = svq3_get_ue_golomb(gb);
+        s->plane[0].xblen = svq3_get_ue_golomb(gb);
+        s->plane[0].yblen = svq3_get_ue_golomb(gb);
+        s->plane[0].xbsep = svq3_get_ue_golomb(gb);
+        s->plane[0].ybsep = svq3_get_ue_golomb(gb);
     } else {
-        s->decoding.xblen[0] = ff_dirac_block_param_defaults[idx - 1].xblen;
-        s->decoding.yblen[0] = ff_dirac_block_param_defaults[idx - 1].yblen;
-        s->decoding.xbsep[0] = ff_dirac_block_param_defaults[idx - 1].xbsep;
-        s->decoding.ybsep[0] = ff_dirac_block_param_defaults[idx - 1].ybsep;
+        s->plane[0].xblen = ff_dirac_block_param_defaults[idx - 1].xblen;
+        s->plane[0].yblen = ff_dirac_block_param_defaults[idx - 1].yblen;
+        s->plane[0].xbsep = ff_dirac_block_param_defaults[idx - 1].xbsep;
+        s->plane[0].ybsep = ff_dirac_block_param_defaults[idx - 1].ybsep;
     }
 
-    /* Setup the blen and bsep parameters for the chroma
-       component. */
-    s->decoding.xblen[1] = s->decoding.xblen[0] >> s->chroma_hshift;
-    s->decoding.yblen[1] = s->decoding.yblen[0] >> s->chroma_vshift;
-    s->decoding.xbsep[1] = s->decoding.xbsep[0] >> s->chroma_hshift;
-    s->decoding.ybsep[1] = s->decoding.ybsep[0] >> s->chroma_vshift;
-
     /* Read motion vector precision. */
     s->decoding.mv_precision = svq3_get_ue_golomb(gb);
 
@@ -562,8 +621,8 @@ static int dirac_unpack_block_motion_dat
 
 #define DIVRNDUP(a, b) ((a + b - 1) / b)
 
-    s->sbwidth  = DIVRNDUP(s->source.width,  (s->decoding.xbsep[0] << 2));
-    s->sbheight = DIVRNDUP(s->source.height, (s->decoding.ybsep[0] << 2));
+    s->sbwidth  = DIVRNDUP(s->source.width,  (s->plane[0].xbsep << 2));
+    s->sbheight = DIVRNDUP(s->source.height, (s->plane[0].ybsep << 2));
     s->blwidth  = s->sbwidth  << 2;
     s->blheight = s->sbheight << 2;
 
@@ -649,56 +708,11 @@ static int dirac_unpack_block_motion_dat
  */
 static int dirac_decode_frame_internal(DiracContext *s)
 {
-    int16_t *coeffs;
     int16_t *line;
     int16_t *mcline;
-    int comp, level, orientation;
+    int comp;
     int x, y;
 
-#define PAD(size, depth) \
-         (((size + (1 << depth) - 1) >> depth) << depth)
-
-    for (comp = 0; comp < 3; comp++) {
-        int w = s->source.width  >> (comp ? s->chroma_hshift : 0);
-        int h = s->source.height >> (comp ? s->chroma_vshift : 0);
-
-        s->plane[comp].width  = w;
-        s->plane[comp].height = h;
-        s->plane[comp].padded_width  = w = PAD(w, s->decoding.wavelet_depth);
-        s->plane[comp].padded_height = h = PAD(h, s->decoding.wavelet_depth);
-
-        if (!comp) {
-            coeffs = av_malloc(w * h * sizeof(IDWTELEM));
-    if (! coeffs) {
-        av_log(s->avctx, AV_LOG_ERROR, "av_malloc() failed\n");
-        return -1;
-    }
-        }
-
-        for (level = s->decoding.wavelet_depth-1; level >= 0; level--) {
-            for (orientation = level ? 1 : 0; orientation < 4; orientation++) {
-                SubBand *b = &s->plane[comp].band[level][orientation];
-
-                b->ibuf   = coeffs;
-                b->level  = level;
-                b->stride = s->plane[comp].padded_width << (s->decoding.wavelet_depth - level);
-                b->width  = (w + !(orientation&1))>>1;
-                b->height = (h + !(orientation>1))>>1;
-                b->orientation = orientation;
-
-                if (orientation & 1)
-                    b->ibuf += (w+1)>>1;
-                if (orientation > 1)
-                    b->ibuf += b->stride>>1;
-
-                if (level)
-                    b->parent = &s->plane[comp].band[level-1][orientation];
-            }
-            w = (w+1)>>1;
-            h = (h+1)>>1;
-        }
-    }
-
     for (comp = 0; comp < 3; comp++) {
         uint8_t *frame = s->current_picture->data[comp];
         int width, height;
@@ -706,17 +720,17 @@ static int dirac_decode_frame_internal(D
         width  = s->source.width  >> (comp ? s->chroma_hshift : 0);
         height = s->source.height >> (comp ? s->chroma_vshift : 0);
 
-        memset(coeffs, 0,
-               s->plane[comp].padded_width * s->plane[comp].padded_height * sizeof(int16_t));
+        memset(s->spatial_idwt_buffer, 0,
+               s->plane[comp].padded_width * s->plane[comp].padded_height * sizeof(IDWTELEM));
 
         if (!s->zero_res)
             decode_component(s, comp);
 
-        ff_spatial_idwt2(coeffs, s->plane[comp].padded_width, s->plane[comp].padded_height,
+        ff_spatial_idwt2(s->spatial_idwt_buffer, s->plane[comp].padded_width, s->plane[comp].padded_height,
                   s->plane[comp].padded_width, s->wavelet_idx+2, s->decoding.wavelet_depth);
 
         if (s->refs) {
-            if (dirac_motion_compensation(s, coeffs, comp)) {
+            if (dirac_motion_compensation(s, s->spatial_idwt_buffer, comp)) {
                 av_freep(&s->sbsplit);
                 av_freep(&s->blmotion);
 
@@ -726,20 +740,20 @@ static int dirac_decode_frame_internal(D
 
         /* Copy the decoded coefficients into the frame and also add
            the data calculated by MC. */
-        line = coeffs;
+        line = s->spatial_idwt_buffer;
         if (s->refs) {
-            int bias = 257 << (s->total_wt_bits - 1);
+            int bias = 257 << (s->plane[comp].total_wt_bits - 1);
             mcline    = s->mcpic;
             for (y = 0; y < height; y++) {
                 for (x = 0; x < width; x++) {
                     int coeff = mcline[x] + bias;
-                    coeff = line[x] + (coeff >> s->total_wt_bits);
+                    coeff = line[x] + (coeff >> s->plane[comp].total_wt_bits);
                     frame[x]= av_clip_uint8(coeff);
                 }
 
                 line  += s->plane[comp].padded_width;
                 frame += s->current_picture->linesize[comp];
-                mcline    += s->width;
+                mcline    += s->plane[comp].width;
             }
         } else {
             for (y = 0; y < height; y++) {
@@ -760,7 +774,6 @@ static int dirac_decode_frame_internal(D
         av_freep(&s->sbsplit);
         av_freep(&s->blmotion);
     }
-    av_free(coeffs);
 
     return 0;
 }
@@ -871,6 +884,7 @@ static int parse_frame(DiracContext *s)
                 }
         }
     }
+    init_planes(s);
     return 0;
 }
 



More information about the FFmpeg-soc mailing list