]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wmalosslessdec.c
mpeg12: disable checked reader.
[ffmpeg] / libavcodec / wmalosslessdec.c
index 3b3ff0f7493f9309999e96c8403c86a3e2c0ee8f..2b32bccba10a4503b26be305796d645a35d1913a 100644 (file)
@@ -222,7 +222,7 @@ typedef struct WmallDecodeCtx {
     WmallChannelCtx channel[WMALL_MAX_CHANNELS];    ///< per channel data
 
     // WMA lossless
-    
+
     uint8_t do_arith_coding;
     uint8_t do_ac_filter;
     uint8_t do_inter_ch_decorr;
@@ -245,11 +245,11 @@ typedef struct WmallDecodeCtx {
     int quant_stepsize;
 
     struct {
-       int order;
-       int scaling;
-       int coefsend;
-       int bitsend;
-       int16_t coefs[256];
+        int order;
+        int scaling;
+        int coefsend;
+        int bitsend;
+        int16_t coefs[256];
     int16_t lms_prevvalues[512];    // FIXME: see above
     int16_t lms_updates[512];   // and here too
     int recent;
@@ -514,12 +514,12 @@ static int decode_tilehdr(WmallDecodeCtx *s)
         for (c = 0; c < s->num_channels; c++) {
             if (num_samples[c] == min_channel_len) {
                 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
-                   (min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) {
+                    (min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) {
                     contains_subframe[c] = 1;
-               }                   
+                }
                 else {
                     contains_subframe[c] = get_bits1(&s->gb);
-               }
+                }
             } else
                 contains_subframe[c] = 0;
         }
@@ -544,7 +544,7 @@ static int decode_tilehdr(WmallDecodeCtx *s)
                 if (num_samples[c] > s->samples_per_frame) {
                     av_log(s->avctx, AV_LOG_ERROR, "broken frame: "
                            "channel len(%d) > samples_per_frame(%d)\n",
-                          num_samples[c], s->samples_per_frame);
+                           num_samples[c], s->samples_per_frame);
                     return AVERROR_INVALIDDATA;
                 }
             } else if (num_samples[c] <= min_channel_len) {
@@ -574,7 +574,7 @@ static int my_log2(unsigned int i)
 {
     unsigned int iLog2 = 0;
     while ((i >> iLog2) > 1)
-       iLog2++;
+        iLog2++;
     return iLog2;
 }
 
@@ -589,7 +589,7 @@ static void decode_ac_filter(WmallDecodeCtx *s)
     s->acfilter_scaling = get_bits(&s->gb, 4);
 
     for(i = 0; i < s->acfilter_order; i++) {
-       s->acfilter_coeffs[i] = get_bits(&s->gb, s->acfilter_scaling) + 1;
+        s->acfilter_coeffs[i] = get_bits(&s->gb, s->acfilter_scaling) + 1;
     }
 }
 
@@ -602,26 +602,26 @@ static void decode_mclms(WmallDecodeCtx *s)
     s->mclms_order = (get_bits(&s->gb, 4) + 1) * 2;
     s->mclms_scaling = get_bits(&s->gb, 4);
     if(get_bits1(&s->gb)) {
-       // mclms_send_coef
-       int i;
-       int send_coef_bits;
-       int cbits = av_log2(s->mclms_scaling + 1);
-       assert(cbits == my_log2(s->mclms_scaling + 1));
-       if(1 << cbits < s->mclms_scaling + 1)
-           cbits++;
-
-       send_coef_bits = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;
-
-       for(i = 0; i < s->mclms_order * s->num_channels * s->num_channels; i++) {
-           s->mclms_coeffs[i] = get_bits(&s->gb, send_coef_bits);
-       }           
-
-       for(i = 0; i < s->num_channels; i++) {
-           int c;
-           for(c = 0; c < i; c++) {
-               s->mclms_coeffs_cur[i * s->num_channels + c] = get_bits(&s->gb, send_coef_bits);
-           }
-       }
+        // mclms_send_coef
+        int i;
+        int send_coef_bits;
+        int cbits = av_log2(s->mclms_scaling + 1);
+        assert(cbits == my_log2(s->mclms_scaling + 1));
+        if(1 << cbits < s->mclms_scaling + 1)
+            cbits++;
+
+        send_coef_bits = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;
+
+        for(i = 0; i < s->mclms_order * s->num_channels * s->num_channels; i++) {
+            s->mclms_coeffs[i] = get_bits(&s->gb, send_coef_bits);
+        }
+
+        for(i = 0; i < s->num_channels; i++) {
+            int c;
+            for(c = 0; c < i; c++) {
+                s->mclms_coeffs_cur[i * s->num_channels + c] = get_bits(&s->gb, send_coef_bits);
+            }
+        }
     }
 }
 
@@ -635,36 +635,36 @@ static void decode_cdlms(WmallDecodeCtx *s)
     int cdlms_send_coef = get_bits1(&s->gb);
 
     for(c = 0; c < s->num_channels; c++) {
-       s->cdlms_ttl[c] = get_bits(&s->gb, 3) + 1;
-       for(i = 0; i < s->cdlms_ttl[c]; i++) {
-           s->cdlms[c][i].order = (get_bits(&s->gb, 7) + 1) * 8;
-       }
-
-       for(i = 0; i < s->cdlms_ttl[c]; i++) {
-           s->cdlms[c][i].scaling = get_bits(&s->gb, 4);
-       }
-
-       if(cdlms_send_coef) {
-           for(i = 0; i < s->cdlms_ttl[c]; i++) {
-               int cbits, shift_l, shift_r, j;
-               cbits = av_log2(s->cdlms[c][i].order);
-               if(1 << cbits < s->cdlms[c][i].order)
-                   cbits++;
-               s->cdlms[c][i].coefsend = get_bits(&s->gb, cbits) + 1;
-
-               cbits = av_log2(s->cdlms[c][i].scaling + 1);
-               if(1 << cbits < s->cdlms[c][i].scaling + 1)
-                   cbits++;
-               
-               s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2;
-               shift_l = 32 - s->cdlms[c][i].bitsend;
-               shift_r = 32 - 2 - s->cdlms[c][i].scaling;
-               for(j = 0; j < s->cdlms[c][i].coefsend; j++) {
-                   s->cdlms[c][i].coefs[j] = 
-                       (get_bits(&s->gb, s->cdlms[c][i].bitsend) << shift_l) >> shift_r;
-               }
-           }
-       }
+        s->cdlms_ttl[c] = get_bits(&s->gb, 3) + 1;
+        for(i = 0; i < s->cdlms_ttl[c]; i++) {
+            s->cdlms[c][i].order = (get_bits(&s->gb, 7) + 1) * 8;
+        }
+
+        for(i = 0; i < s->cdlms_ttl[c]; i++) {
+            s->cdlms[c][i].scaling = get_bits(&s->gb, 4);
+        }
+
+        if(cdlms_send_coef) {
+            for(i = 0; i < s->cdlms_ttl[c]; i++) {
+                int cbits, shift_l, shift_r, j;
+                cbits = av_log2(s->cdlms[c][i].order);
+                if(1 << cbits < s->cdlms[c][i].order)
+                    cbits++;
+                s->cdlms[c][i].coefsend = get_bits(&s->gb, cbits) + 1;
+
+                cbits = av_log2(s->cdlms[c][i].scaling + 1);
+                if(1 << cbits < s->cdlms[c][i].scaling + 1)
+                    cbits++;
+
+                s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2;
+                shift_l = 32 - s->cdlms[c][i].bitsend;
+                shift_r = 32 - 2 - s->cdlms[c][i].scaling;
+                for(j = 0; j < s->cdlms[c][i].coefsend; j++) {
+                    s->cdlms[c][i].coefs[j] =
+                        (get_bits(&s->gb, s->cdlms[c][i].bitsend) << shift_l) >> shift_r;
+                }
+            }
+        }
     }
 }
 
@@ -677,47 +677,47 @@ static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)
     unsigned int ave_mean;
     s->transient[ch] = get_bits1(&s->gb);
     if(s->transient[ch]) {
-           s->transient_pos[ch] = get_bits(&s->gb, av_log2(tile_size));
+            s->transient_pos[ch] = get_bits(&s->gb, av_log2(tile_size));
         if (s->transient_pos[ch])
-               s->transient[ch] = 0;
-           s->channel[ch].transient_counter =
-               FFMAX(s->channel[ch].transient_counter, s->samples_per_frame / 2);
-       } else if (s->channel[ch].transient_counter)
-           s->transient[ch] = 1;
+                s->transient[ch] = 0;
+            s->channel[ch].transient_counter =
+                FFMAX(s->channel[ch].transient_counter, s->samples_per_frame / 2);
+        } else if (s->channel[ch].transient_counter)
+            s->transient[ch] = 1;
 
     if(s->seekable_tile) {
-       ave_mean = get_bits(&s->gb, s->bits_per_sample);
-       s->ave_sum[ch] = ave_mean << (s->movave_scaling + 1);
-//     s->ave_sum[ch] *= 2;
+        ave_mean = get_bits(&s->gb, s->bits_per_sample);
+        s->ave_sum[ch] = ave_mean << (s->movave_scaling + 1);
+//        s->ave_sum[ch] *= 2;
     }
 
     if(s->seekable_tile) {
-       if(s->do_inter_ch_decorr)
-           s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample + 1);
-    else
-           s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample);
-       i++;
+        if(s->do_inter_ch_decorr)
+            s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample + 1);
+        else
+            s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample);
+        i++;
     }
     //av_log(0, 0, "%8d: ", num_logged_tiles++);
     for(; i < tile_size; i++) {
-       int quo = 0, rem, rem_bits, residue;
-       while(get_bits1(&s->gb))
-           quo++;
-       if(quo >= 32)
-           quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1);
-
-               ave_mean = (s->ave_sum[ch] + (1 << s->movave_scaling)) >> (s->movave_scaling + 1);
-       rem_bits = av_ceil_log2(ave_mean);
-       rem = rem_bits ? get_bits(&s->gb, rem_bits) : 0;
-       residue = (quo << rem_bits) + rem;
-
-       s->ave_sum[ch] = residue + s->ave_sum[ch] - (s->ave_sum[ch] >> s->movave_scaling);
-
-       if(residue & 1)
-           residue = -(residue >> 1) - 1;
-       else
-           residue = residue >> 1;
-       s->channel_residues[ch][i] = residue;
+        int quo = 0, rem, rem_bits, residue;
+        while(get_bits1(&s->gb))
+            quo++;
+        if(quo >= 32)
+            quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1);
+
+               ave_mean = (s->ave_sum[ch] + (1 << s->movave_scaling)) >> (s->movave_scaling + 1);
+        rem_bits = av_ceil_log2(ave_mean);
+        rem = rem_bits ? get_bits(&s->gb, rem_bits) : 0;
+        residue = (quo << rem_bits) + rem;
+
+        s->ave_sum[ch] = residue + s->ave_sum[ch] - (s->ave_sum[ch] >> s->movave_scaling);
+
+        if(residue & 1)
+            residue = -(residue >> 1) - 1;
+        else
+            residue = residue >> 1;
+        s->channel_residues[ch][i] = residue;
     }
     dump_int_buffer(s->channel_residues[ch], 4, tile_size, 16);
 
@@ -738,9 +738,9 @@ decode_lpc(WmallDecodeCtx *s)
     s->lpc_intbits = get_bits(&s->gb, 3) + 1;
     cbits = s->lpc_scaling + s->lpc_intbits;
     for(ch = 0; ch < s->num_channels; ch++) {
-       for(i = 0; i < s->lpc_order; i++) {
-           s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);
-       }
+        for(i = 0; i < s->lpc_order; i++) {
+            s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);
+        }
     }
 }
 
@@ -776,11 +776,12 @@ static void reset_codec(WmallDecodeCtx *s)
     s->mclms_recent = s->mclms_order * s->num_channels;
     for (ich = 0; ich < s->num_channels; ich++) {
         for (ilms = 0; ilms < s->cdlms_ttl[ich]; ilms++)
-            s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order - 1;
+            s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order;
         /* first sample of a seekable subframe is considered as the starting of
            a transient area which is samples_per_frame samples long */
         s->channel[ich].transient_counter = s->samples_per_frame;
         s->transient[ich] = 1;
+        s->transient_pos[ich] = 0;
     }
 }
 
@@ -833,10 +834,10 @@ static void mclms_update(WmallDecodeCtx *s, int icoef)
     }
 
     if (s->mclms_recent == 0) {
-        memcpy(s->mclms_prevvalues[order * num_channels],
+        memcpy(&s->mclms_prevvalues[order * num_channels],
                s->mclms_prevvalues,
                bps * order * num_channels);
-        memcpy(s->mclms_updates[order * num_channels],
+        memcpy(&s->mclms_updates[order * num_channels],
                s->mclms_updates,
                bps * order * num_channels);
         s->mclms_recent = num_channels * order;
@@ -875,7 +876,7 @@ static void revert_mclms(WmallDecodeCtx *s, int tile_size)
 
 static int lms_predict(WmallDecodeCtx *s, int ich, int ilms)
 {
-    int16_t pred = 0;
+    int pred = 0;
     int icoef;
     int recent = s->cdlms[ich][ilms].recent;
 
@@ -883,37 +884,53 @@ static int lms_predict(WmallDecodeCtx *s, int ich, int ilms)
         pred += s->cdlms[ich][ilms].coefs[icoef] *
                     s->cdlms[ich][ilms].lms_prevvalues[icoef + recent];
 
-    pred += (1 << (s->cdlms[ich][ilms].scaling - 1));
+    //pred += (1 << (s->cdlms[ich][ilms].scaling - 1));
     /* XXX: Table 29 has:
             iPred >= cdlms[iCh][ilms].scaling;
        seems to me like a missing > */
-    pred >>= s->cdlms[ich][ilms].scaling;
+    //pred >>= s->cdlms[ich][ilms].scaling;
     return pred;
 }
 
-static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int16_t input, int16_t pred)
+static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int input, int residue)
 {
-    int16_t icoef;
+    int icoef;
     int recent = s->cdlms[ich][ilms].recent;
-    int16_t range = 1 << (s->bits_per_sample - 1);
+    int range = 1 << s->bits_per_sample - 1;
     int bps = s->bits_per_sample > 16 ? 4 : 2; // bytes per sample
 
-    if (input > pred) {
+    if (residue < 0) {
         for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
-            s->cdlms[ich][ilms].coefs[icoef] +=
+            s->cdlms[ich][ilms].coefs[icoef] -=
                 s->cdlms[ich][ilms].lms_updates[icoef + recent];
-    } else {
+    } else if (residue > 0) {
         for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
-            s->cdlms[ich][ilms].coefs[icoef] -=
-                s->cdlms[ich][ilms].lms_updates[icoef];     // XXX: [icoef + recent] ?
+            s->cdlms[ich][ilms].coefs[icoef] +=
+                s->cdlms[ich][ilms].lms_updates[icoef + recent];    /* spec mistakenly
+                                                                    dropped the recent */
     }
-    s->cdlms[ich][ilms].recent--;
-    s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
 
-    if (input > pred)
-        s->cdlms[ich][ilms].lms_updates[recent] = s->update_speed[ich];
-    else if (input < pred)
+    if (recent)
+        recent--;
+    else {
+        /* XXX: This memcpy()s will probably fail if a fixed 32-bit buffer is used.
+                follow kshishkov's suggestion of using a union. */
+        memcpy(&s->cdlms[ich][ilms].lms_prevvalues[s->cdlms[ich][ilms].order],
+               s->cdlms[ich][ilms].lms_prevvalues,
+               bps * s->cdlms[ich][ilms].order);
+        memcpy(&s->cdlms[ich][ilms].lms_updates[s->cdlms[ich][ilms].order],
+               s->cdlms[ich][ilms].lms_updates,
+               bps * s->cdlms[ich][ilms].order);
+        recent = s->cdlms[ich][ilms].order - 1;
+    }
+
+    s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
+    if (!input)
+        s->cdlms[ich][ilms].lms_updates[recent] = 0;
+    else if (input < 0)
         s->cdlms[ich][ilms].lms_updates[recent] = -s->update_speed[ich];
+    else
+        s->cdlms[ich][ilms].lms_updates[recent] = s->update_speed[ich];
 
     /* XXX: spec says:
     cdlms[iCh][ilms].updates[iRecent + cdlms[iCh][ilms].order >> 4] >>= 2;
@@ -923,21 +940,9 @@ static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int16_t input, int1
         seperate buffers? Here I've assumed that the two are same which makes
         more sense to me.
     */
-    s->cdlms[ich][ilms].lms_updates[recent + s->cdlms[ich][ilms].order >> 4] >>= 2;
-    s->cdlms[ich][ilms].lms_updates[recent + s->cdlms[ich][ilms].order >> 3] >>= 1;
-    /* XXX: recent + (s->cdlms[ich][ilms].order >> 4) ? */
-
-    if (s->cdlms[ich][ilms].recent == 0) {
-        /* XXX: This memcpy()s will probably fail if a fixed 32-bit buffer is used.
-                follow kshishkov's suggestion of using a union. */
-        memcpy(s->cdlms[ich][ilms].lms_prevvalues + s->cdlms[ich][ilms].order,
-               s->cdlms[ich][ilms].lms_prevvalues,
-               bps * s->cdlms[ich][ilms].order);
-        memcpy(s->cdlms[ich][ilms].lms_updates + s->cdlms[ich][ilms].order,
-               s->cdlms[ich][ilms].lms_updates,
-               bps * s->cdlms[ich][ilms].order);
-        s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order;
-    }
+    s->cdlms[ich][ilms].lms_updates[recent + (s->cdlms[ich][ilms].order >> 4)] >>= 2;
+    s->cdlms[ich][ilms].lms_updates[recent + (s->cdlms[ich][ilms].order >> 3)] >>= 1;
+    s->cdlms[ich][ilms].recent = recent;
 }
 
 static void use_high_update_speed(WmallDecodeCtx *s, int ich)
@@ -972,33 +977,23 @@ static void use_normal_update_speed(WmallDecodeCtx *s, int ich)
     }
 }
 
-static void revert_cdlms(WmallDecodeCtx *s, int tile_size)
+static void revert_cdlms(WmallDecodeCtx *s, int ch, int coef_begin, int coef_end)
 {
-    int icoef, ich;
-    int16_t pred, channel_coeff;
+    int icoef;
+    int pred;
     int ilms, num_lms;
-
-    for (ich = 0; ich < s->num_channels; ich++) {
-        if (!s->is_channel_coded[ich])
-            continue;
-        for (icoef = 0; icoef < tile_size; icoef++) {
-            num_lms = s->cdlms_ttl[ich];
-            channel_coeff = s->channel_residues[ich][icoef];
-            if (icoef == s->transient_pos[ich]) {
-                s->transient[ich] = 1;
-                use_high_update_speed(s, ich);
-            }
-            for (ilms = num_lms - 1; ilms >= 0; ilms--) {
-                pred = lms_predict(s, ich, ilms);
-                channel_coeff += pred;
-                lms_update(s, ich, ilms, channel_coeff, pred);
-            }
-            if (s->transient[ich]) {
-                --s->channel[ich].transient_counter;
-                if(!s->channel[ich].transient_counter)
-                    use_normal_update_speed(s, ich);
-            }
-            s->channel_coeffs[ich][icoef] = channel_coeff;
+    int residue, input;
+
+    num_lms = s->cdlms_ttl[ch];
+    for (ilms = num_lms - 1; ilms >= 0; ilms--) {
+        //s->cdlms[ch][ilms].recent = s->cdlms[ch][ilms].order;
+        for (icoef = coef_begin; icoef < coef_end; icoef++) {
+            pred = 1 << (s->cdlms[ch][ilms].scaling - 1);
+            residue = s->channel_residues[ch][icoef];
+            pred += lms_predict(s, ch, ilms);
+            input = residue + (pred >> s->cdlms[ch][ilms].scaling);
+            lms_update(s, ch, ilms, input, residue);
+            s->channel_residues[ch][icoef] = input;
         }
     }
 }
@@ -1062,76 +1057,81 @@ static int decode_subframe(WmallDecodeCtx *s)
     if(s->seekable_tile) {
         clear_codec_buffers(s);
 
-       s->do_arith_coding    = get_bits1(&s->gb);
-       if(s->do_arith_coding) {
-           dprintf(s->avctx, "do_arith_coding == 1");
-           abort();
-       }
-       s->do_ac_filter       = get_bits1(&s->gb);
-       s->do_inter_ch_decorr = get_bits1(&s->gb);
-       s->do_mclms           = get_bits1(&s->gb);
-       
-       if(s->do_ac_filter)
-           decode_ac_filter(s);
-
-       if(s->do_mclms)
-           decode_mclms(s);
-
-       decode_cdlms(s);
-       s->movave_scaling = get_bits(&s->gb, 3);
-       s->quant_stepsize = get_bits(&s->gb, 8) + 1;
-
-           reset_codec(s);
+        s->do_arith_coding    = get_bits1(&s->gb);
+        if(s->do_arith_coding) {
+            dprintf(s->avctx, "do_arith_coding == 1");
+            abort();
+        }
+        s->do_ac_filter       = get_bits1(&s->gb);
+        s->do_inter_ch_decorr = get_bits1(&s->gb);
+        s->do_mclms           = get_bits1(&s->gb);
+
+        if(s->do_ac_filter)
+            decode_ac_filter(s);
+
+        if(s->do_mclms)
+            decode_mclms(s);
+
+        decode_cdlms(s);
+        s->movave_scaling = get_bits(&s->gb, 3);
+        s->quant_stepsize = get_bits(&s->gb, 8) + 1;
+
+            reset_codec(s);
     }
 
     rawpcm_tile = get_bits1(&s->gb);
 
     for(i = 0; i < s->num_channels; i++) {
-       s->is_channel_coded[i] = 1;
+        s->is_channel_coded[i] = 1;
     }
 
     if(!rawpcm_tile) {
 
-       for(i = 0; i < s->num_channels; i++) {
-           s->is_channel_coded[i] = get_bits1(&s->gb);
-       }
-
-       if(s->bV3RTM) {
-           // LPC
-           s->do_lpc = get_bits1(&s->gb);
-           if(s->do_lpc) {
-               decode_lpc(s);
-           }
-       } else {
-           s->do_lpc = 0;
-       }
+        for(i = 0; i < s->num_channels; i++) {
+            s->is_channel_coded[i] = get_bits1(&s->gb);
+        }
+
+        if(s->bV3RTM) {
+            // LPC
+            s->do_lpc = get_bits1(&s->gb);
+            if(s->do_lpc) {
+                decode_lpc(s);
+            }
+        } else {
+            s->do_lpc = 0;
+        }
     }
 
 
     if(get_bits1(&s->gb)) {
-       padding_zeroes = get_bits(&s->gb, 5);
+        padding_zeroes = get_bits(&s->gb, 5);
     } else {
-       padding_zeroes = 0;
+        padding_zeroes = 0;
     }
 
     if(rawpcm_tile) {
-       
-       int bits = s->bits_per_sample - padding_zeroes;
-       int j;
-       dprintf(s->avctx, "RAWPCM %d bits per sample. total %d bits, remain=%d\n", bits,
-               bits * s->num_channels * subframe_len, get_bits_count(&s->gb));
-       for(i = 0; i < s->num_channels; i++) {
-           for(j = 0; j < subframe_len; j++) {
-               s->channel_coeffs[i][j] = get_sbits(&s->gb, bits);
-//             dprintf(s->avctx, "PCM[%d][%d] = 0x%04x\n", i, j, s->channel_coeffs[i][j]);
-           }
-       }
+
+        int bits = s->bits_per_sample - padding_zeroes;
+        int j;
+        dprintf(s->avctx, "RAWPCM %d bits per sample. total %d bits, remain=%d\n", bits,
+                bits * s->num_channels * subframe_len, get_bits_count(&s->gb));
+        for(i = 0; i < s->num_channels; i++) {
+            for(j = 0; j < subframe_len; j++) {
+                s->channel_coeffs[i][j] = get_sbits(&s->gb, bits);
+//                dprintf(s->avctx, "PCM[%d][%d] = 0x%04x\n", i, j, s->channel_coeffs[i][j]);
+            }
+        }
     } else {
-       for(i = 0; i < s->num_channels; i++)
-           if(s->is_channel_coded[i])
-               decode_channel_residues(s, i, subframe_len);
+        for(i = 0; i < s->num_channels; i++)
+            if(s->is_channel_coded[i]) {
+            decode_channel_residues(s, i, subframe_len);
+            if (s->seekable_tile)
+                use_high_update_speed(s, i);
+            else
+                use_normal_update_speed(s, i);
+            revert_cdlms(s, i, 0, subframe_len);
+        }
     }
-    revert_cdlms(s, subframe_len);
 
     /** handled one subframe */
 
@@ -1241,7 +1241,7 @@ static int decode_frame(WmallDecodeCtx *s)
     } else {
 /*
         while (get_bits_count(gb) < s->num_saved_bits && get_bits1(gb) == 0) {
-           dprintf(s->avctx, "skip1\n");
+            dprintf(s->avctx, "skip1\n");
         }
 */
     }
@@ -1351,8 +1351,8 @@ static int decode_packet(AVCodecContext *avctx,
         /** parse packet header */
         init_get_bits(gb, buf, s->buf_bit_size);
         packet_sequence_number = get_bits(gb, 4);
-       int seekable_frame_in_packet = get_bits1(gb);
-       int spliced_packet = get_bits1(gb);
+        int seekable_frame_in_packet = get_bits1(gb);
+        int spliced_packet = get_bits1(gb);
 
         /** get number of bits that need to be added to the previous frame */
         num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
@@ -1379,7 +1379,7 @@ static int decode_packet(AVCodecContext *avctx,
 
             /** decode the cross packet frame if it is valid */
             if (!s->packet_loss)
-               decode_frame(s);
+                decode_frame(s);
         } else if (s->num_saved_bits - s->frame_offset) {
             dprintf(avctx, "ignoring %x previously saved bits\n",
                     s->num_saved_bits - s->frame_offset);
@@ -1399,7 +1399,7 @@ static int decode_packet(AVCodecContext *avctx,
         s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
         init_get_bits(gb, avpkt->data, s->buf_bit_size);
         skip_bits(gb, s->packet_offset);
-       
+
         if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
             (frame_size = show_bits(gb, s->log2_frame_size)) &&
             frame_size <= remaining_bits(s, gb)) {
@@ -1417,7 +1417,7 @@ static int decode_packet(AVCodecContext *avctx,
             s->packet_done = !decode_frame(s);
         } else {
             s->packet_done = 1;
-       }
+        }
     }
 
     if (s->packet_done && !s->packet_loss &&
@@ -1462,7 +1462,7 @@ AVCodec ff_wmalossless_decoder = {
     NULL,
     decode_end,
     decode_packet,
-    .capabilities = CODEC_CAP_SUBFRAMES,
+    .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_EXPERIMENTAL,
     .flush= flush,
     .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Lossless"),
 };