wma.c 16.5 KB
Newer Older
Michael Niedermayer's avatar
Michael Niedermayer committed
1 2
/*
 * WMA compatible codec
3
 * Copyright (c) 2002-2007 The Libav Project
Michael Niedermayer's avatar
Michael Niedermayer committed
4
 *
5
 * This file is part of Libav.
Michael Niedermayer's avatar
Michael Niedermayer committed
6
 *
7
 * Libav is free software; you can redistribute it and/or
Michael Niedermayer's avatar
Michael Niedermayer committed
8 9 10 11
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
12
 * Libav is distributed in the hope that it will be useful,
Michael Niedermayer's avatar
Michael Niedermayer committed
13 14 15 16 17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with Libav; if not, write to the Free Software
Michael Niedermayer's avatar
Michael Niedermayer committed
19 20 21 22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "avcodec.h"
23
#include "sinewin.h"
Michael Niedermayer's avatar
Michael Niedermayer committed
24 25 26 27 28 29 30 31
#include "wma.h"
#include "wmadata.h"

#undef NDEBUG
#include <assert.h>

/* XXX: use same run/length optimization as mpeg decoders */
//FIXME maybe split decode / encode or pass flag
32
static void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
33
                          float **plevel_table, uint16_t **pint_table,
Michael Niedermayer's avatar
Michael Niedermayer committed
34 35 36
                          const CoefVLCTable *vlc_table)
{
    int n = vlc_table->n;
37 38
    const uint8_t  *table_bits   = vlc_table->huffbits;
    const uint32_t *table_codes  = vlc_table->huffcodes;
Michael Niedermayer's avatar
Michael Niedermayer committed
39 40
    const uint16_t *levels_table = vlc_table->levels;
    uint16_t *run_table, *level_table, *int_table;
41
    float *flevel_table;
Michael Niedermayer's avatar
Michael Niedermayer committed
42 43 44 45
    int i, l, j, k, level;

    init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4, 0);

46
    run_table   = av_malloc(n * sizeof(uint16_t));
Michael Niedermayer's avatar
Michael Niedermayer committed
47
    level_table = av_malloc(n * sizeof(uint16_t));
48
    flevel_table= av_malloc(n * sizeof(*flevel_table));
49
    int_table   = av_malloc(n * sizeof(uint16_t));
Michael Niedermayer's avatar
Michael Niedermayer committed
50 51 52 53
    i = 2;
    level = 1;
    k = 0;
    while (i < n) {
54
        int_table[k] = i;
Michael Niedermayer's avatar
Michael Niedermayer committed
55
        l = levels_table[k++];
56 57
        for (j = 0; j < l; j++) {
            run_table[i]   = j;
Michael Niedermayer's avatar
Michael Niedermayer committed
58
            level_table[i] = level;
59
            flevel_table[i]= level;
Michael Niedermayer's avatar
Michael Niedermayer committed
60 61 62 63
            i++;
        }
        level++;
    }
64
    *prun_table   = run_table;
65
    *plevel_table = flevel_table;
66
    *pint_table   = int_table;
67
    av_free(level_table);
Michael Niedermayer's avatar
Michael Niedermayer committed
68 69
}

70 71 72 73 74 75 76 77 78 79 80 81 82
/**
 *@brief Get the samples per frame for this stream.
 *@param sample_rate output sample_rate
 *@param version wma version
 *@param decode_flags codec compression features
 *@return log2 of the number of output samples per frame
 */
int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version,
                                      unsigned int decode_flags)
{

    int frame_len_bits;

83
    if (sample_rate <= 16000) {
84
        frame_len_bits = 9;
85 86
    } else if (sample_rate <= 22050 ||
             (sample_rate <= 32000 && version == 1)) {
87
        frame_len_bits = 10;
88
    } else if (sample_rate <= 48000) {
89
        frame_len_bits = 11;
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
    } else if (sample_rate <= 96000) {
        frame_len_bits = 12;
    } else {
        frame_len_bits = 13;
    }

    if (version == 3) {
        int tmp = decode_flags & 0x6;
        if (tmp == 0x2) {
            ++frame_len_bits;
        } else if (tmp == 0x4) {
            --frame_len_bits;
        } else if (tmp == 0x6) {
            frame_len_bits -= 2;
        }
    }
106 107 108 109

    return frame_len_bits;
}

110
int ff_wma_init(AVCodecContext *avctx, int flags2)
Michael Niedermayer's avatar
Michael Niedermayer committed
111
{
112
    WMACodecContext *s = avctx->priv_data;
Michael Niedermayer's avatar
Michael Niedermayer committed
113 114 115 116 117 118
    int i;
    float bps1, high_freq;
    volatile float bps;
    int sample_rate1;
    int coef_vlc_table;

119 120 121
    if (   avctx->sample_rate <= 0 || avctx->sample_rate > 50000
        || avctx->channels    <= 0 || avctx->channels    > 8
        || avctx->bit_rate    <= 0)
122 123
        return -1;

Michael Niedermayer's avatar
Michael Niedermayer committed
124 125
    s->sample_rate = avctx->sample_rate;
    s->nb_channels = avctx->channels;
126
    s->bit_rate    = avctx->bit_rate;
Michael Niedermayer's avatar
Michael Niedermayer committed
127 128 129
    s->block_align = avctx->block_align;

    dsputil_init(&s->dsp, avctx);
130
    ff_fmt_convert_init(&s->fmt_conv, avctx);
Michael Niedermayer's avatar
Michael Niedermayer committed
131 132 133 134 135 136 137 138

    if (avctx->codec->id == CODEC_ID_WMAV1) {
        s->version = 1;
    } else {
        s->version = 2;
    }

    /* compute MDCT block size */
139 140
    s->frame_len_bits = ff_wma_get_frame_len_bits(s->sample_rate, s->version, 0);

Michael Niedermayer's avatar
Michael Niedermayer committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154
    s->frame_len = 1 << s->frame_len_bits;
    if (s->use_variable_block_len) {
        int nb_max, nb;
        nb = ((flags2 >> 3) & 3) + 1;
        if ((s->bit_rate / s->nb_channels) >= 32000)
            nb += 2;
        nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
        if (nb > nb_max)
            nb = nb_max;
        s->nb_block_sizes = nb + 1;
    } else {
        s->nb_block_sizes = 1;
    }

155
    /* init rate dependent parameters */
Michael Niedermayer's avatar
Michael Niedermayer committed
156 157 158 159 160 161
    s->use_noise_coding = 1;
    high_freq = s->sample_rate * 0.5;

    /* if version 2, then the rates are normalized */
    sample_rate1 = s->sample_rate;
    if (s->version == 2) {
162
        if (sample_rate1 >= 44100) {
Michael Niedermayer's avatar
Michael Niedermayer committed
163
            sample_rate1 = 44100;
164
        } else if (sample_rate1 >= 22050) {
Michael Niedermayer's avatar
Michael Niedermayer committed
165
            sample_rate1 = 22050;
166
        } else if (sample_rate1 >= 16000) {
Michael Niedermayer's avatar
Michael Niedermayer committed
167
            sample_rate1 = 16000;
168
        } else if (sample_rate1 >= 11025) {
Michael Niedermayer's avatar
Michael Niedermayer committed
169
            sample_rate1 = 11025;
170
        } else if (sample_rate1 >= 8000) {
Michael Niedermayer's avatar
Michael Niedermayer committed
171
            sample_rate1 = 8000;
172
        }
Michael Niedermayer's avatar
Michael Niedermayer committed
173 174 175 176 177 178 179 180 181 182 183
    }

    bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
    s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0 + 0.5)) + 2;

    /* compute high frequency value and choose if noise coding should
       be activated */
    bps1 = bps;
    if (s->nb_channels == 2)
        bps1 = bps * 1.6;
    if (sample_rate1 == 44100) {
184
        if (bps1 >= 0.61) {
Michael Niedermayer's avatar
Michael Niedermayer committed
185
            s->use_noise_coding = 0;
186
        } else {
Michael Niedermayer's avatar
Michael Niedermayer committed
187
            high_freq = high_freq * 0.4;
188
        }
Michael Niedermayer's avatar
Michael Niedermayer committed
189
    } else if (sample_rate1 == 22050) {
190
        if (bps1 >= 1.16) {
Michael Niedermayer's avatar
Michael Niedermayer committed
191
            s->use_noise_coding = 0;
192
        } else if (bps1 >= 0.72) {
Michael Niedermayer's avatar
Michael Niedermayer committed
193
            high_freq = high_freq * 0.7;
194
        } else {
Michael Niedermayer's avatar
Michael Niedermayer committed
195
            high_freq = high_freq * 0.6;
196
        }
Michael Niedermayer's avatar
Michael Niedermayer committed
197
    } else if (sample_rate1 == 16000) {
198
        if (bps > 0.5) {
Michael Niedermayer's avatar
Michael Niedermayer committed
199
            high_freq = high_freq * 0.5;
200
        } else {
Michael Niedermayer's avatar
Michael Niedermayer committed
201
            high_freq = high_freq * 0.3;
202
        }
Michael Niedermayer's avatar
Michael Niedermayer committed
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
    } else if (sample_rate1 == 11025) {
        high_freq = high_freq * 0.7;
    } else if (sample_rate1 == 8000) {
        if (bps <= 0.625) {
            high_freq = high_freq * 0.5;
        } else if (bps > 0.75) {
            s->use_noise_coding = 0;
        } else {
            high_freq = high_freq * 0.65;
        }
    } else {
        if (bps >= 0.8) {
            high_freq = high_freq * 0.75;
        } else if (bps >= 0.6) {
            high_freq = high_freq * 0.6;
        } else {
            high_freq = high_freq * 0.5;
        }
    }
Luca Barbato's avatar
Luca Barbato committed
222 223
    av_dlog(s->avctx, "flags2=0x%x\n", flags2);
    av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
224 225
            s->version, s->nb_channels, s->sample_rate, s->bit_rate,
            s->block_align);
Luca Barbato's avatar
Luca Barbato committed
226
    av_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
227
            bps, bps1, high_freq, s->byte_offset_bits);
Luca Barbato's avatar
Luca Barbato committed
228
    av_dlog(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
229
            s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
Michael Niedermayer's avatar
Michael Niedermayer committed
230 231 232 233 234 235 236 237 238 239 240

    /* compute the scale factor band sizes for each MDCT block size */
    {
        int a, b, pos, lpos, k, block_len, i, j, n;
        const uint8_t *table;

        if (s->version == 1) {
            s->coefs_start = 3;
        } else {
            s->coefs_start = 0;
        }
241
        for (k = 0; k < s->nb_block_sizes; k++) {
Michael Niedermayer's avatar
Michael Niedermayer committed
242 243 244 245
            block_len = s->frame_len >> k;

            if (s->version == 1) {
                lpos = 0;
246
                for (i = 0; i < 25; i++) {
247
                    a = ff_wma_critical_freqs[i];
Michael Niedermayer's avatar
Michael Niedermayer committed
248
                    b = s->sample_rate;
249
                    pos = ((block_len * 2 * a) + (b >> 1)) / b;
Michael Niedermayer's avatar
Michael Niedermayer committed
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
                    if (pos > block_len)
                        pos = block_len;
                    s->exponent_bands[0][i] = pos - lpos;
                    if (pos >= block_len) {
                        i++;
                        break;
                    }
                    lpos = pos;
                }
                s->exponent_sizes[0] = i;
            } else {
                /* hardcoded tables */
                table = NULL;
                a = s->frame_len_bits - BLOCK_MIN_BITS - k;
                if (a < 3) {
265
                    if (s->sample_rate >= 44100) {
Michael Niedermayer's avatar
Michael Niedermayer committed
266
                        table = exponent_band_44100[a];
267
                    } else if (s->sample_rate >= 32000) {
Michael Niedermayer's avatar
Michael Niedermayer committed
268
                        table = exponent_band_32000[a];
269
                    } else if (s->sample_rate >= 22050) {
Michael Niedermayer's avatar
Michael Niedermayer committed
270
                        table = exponent_band_22050[a];
271
                    }
Michael Niedermayer's avatar
Michael Niedermayer committed
272 273 274
                }
                if (table) {
                    n = *table++;
275
                    for (i = 0; i < n; i++)
Michael Niedermayer's avatar
Michael Niedermayer committed
276 277 278 279 280
                        s->exponent_bands[k][i] = table[i];
                    s->exponent_sizes[k] = n;
                } else {
                    j = 0;
                    lpos = 0;
281
                    for (i = 0; i < 25; i++) {
282
                        a = ff_wma_critical_freqs[i];
Michael Niedermayer's avatar
Michael Niedermayer committed
283
                        b = s->sample_rate;
284
                        pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
Michael Niedermayer's avatar
Michael Niedermayer committed
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
                        pos <<= 2;
                        if (pos > block_len)
                            pos = block_len;
                        if (pos > lpos)
                            s->exponent_bands[k][j++] = pos - lpos;
                        if (pos >= block_len)
                            break;
                        lpos = pos;
                    }
                    s->exponent_sizes[k] = j;
                }
            }

            /* max number of coefs */
            s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
            /* high freq computation */
            s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
                                          s->sample_rate + 0.5);
            n = s->exponent_sizes[k];
            j = 0;
            pos = 0;
306
            for (i = 0; i < n; i++) {
Michael Niedermayer's avatar
Michael Niedermayer committed
307 308 309 310 311 312 313 314 315 316 317 318 319
                int start, end;
                start = pos;
                pos += s->exponent_bands[k][i];
                end = pos;
                if (start < s->high_band_start[k])
                    start = s->high_band_start[k];
                if (end > s->coefs_end[k])
                    end = s->coefs_end[k];
                if (end > start)
                    s->exponent_high_bands[k][j++] = end - start;
            }
            s->exponent_high_sizes[k] = j;
#if 0
Michel Bardiaux's avatar
Michel Bardiaux committed
320
            tprintf(s->avctx, "%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
321 322 323 324 325
                    s->frame_len >> k,
                    s->coefs_end[k],
                    s->high_band_start[k],
                    s->exponent_high_sizes[k]);
            for (j = 0; j < s->exponent_high_sizes[k]; j++)
Michel Bardiaux's avatar
Michel Bardiaux committed
326 327
                tprintf(s->avctx, " %d", s->exponent_high_bands[k][j]);
            tprintf(s->avctx, "\n");
Michael Niedermayer's avatar
Michael Niedermayer committed
328 329 330 331 332 333 334
#endif
        }
    }

#ifdef TRACE
    {
        int i, j;
335
        for (i = 0; i < s->nb_block_sizes; i++) {
Michel Bardiaux's avatar
Michel Bardiaux committed
336
            tprintf(s->avctx, "%5d: n=%2d:",
337 338 339
                    s->frame_len >> i,
                    s->exponent_sizes[i]);
            for (j = 0; j < s->exponent_sizes[i]; j++)
Michel Bardiaux's avatar
Michel Bardiaux committed
340 341
                tprintf(s->avctx, " %d", s->exponent_bands[i][j]);
            tprintf(s->avctx, "\n");
Michael Niedermayer's avatar
Michael Niedermayer committed
342 343 344 345 346
        }
    }
#endif

    /* init MDCT windows : simple sinus window */
347
    for (i = 0; i < s->nb_block_sizes; i++) {
348
        ff_init_ff_sine_windows(s->frame_len_bits - i);
349
        s->windows[i] = ff_sine_windows[s->frame_len_bits - i];
Michael Niedermayer's avatar
Michael Niedermayer committed
350 351 352 353 354 355 356
    }

    s->reset_block_lengths = 1;

    if (s->use_noise_coding) {

        /* init the noise generator */
357
        if (s->use_exp_vlc) {
Michael Niedermayer's avatar
Michael Niedermayer committed
358
            s->noise_mult = 0.02;
359
        } else {
Michael Niedermayer's avatar
Michael Niedermayer committed
360
            s->noise_mult = 0.04;
361
        }
Michael Niedermayer's avatar
Michael Niedermayer committed
362 363

#ifdef TRACE
364
        for (i = 0; i < NOISE_TAB_SIZE; i++)
Michael Niedermayer's avatar
Michael Niedermayer committed
365 366 367 368 369 370 371
            s->noise_table[i] = 1.0 * s->noise_mult;
#else
        {
            unsigned int seed;
            float norm;
            seed = 1;
            norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
372
            for (i = 0; i < NOISE_TAB_SIZE; i++) {
Michael Niedermayer's avatar
Michael Niedermayer committed
373 374 375 376 377 378 379 380 381 382
                seed = seed * 314159 + 1;
                s->noise_table[i] = (float)((int)seed) * norm;
            }
        }
#endif
    }

    /* choose the VLC tables for the coefficients */
    coef_vlc_table = 2;
    if (s->sample_rate >= 32000) {
383
        if (bps1 < 0.72) {
Michael Niedermayer's avatar
Michael Niedermayer committed
384
            coef_vlc_table = 0;
385
        } else if (bps1 < 1.16) {
Michael Niedermayer's avatar
Michael Niedermayer committed
386
            coef_vlc_table = 1;
387
        }
Michael Niedermayer's avatar
Michael Niedermayer committed
388 389 390 391 392 393 394 395 396 397 398
    }
    s->coef_vlcs[0]= &coef_vlcs[coef_vlc_table * 2    ];
    s->coef_vlcs[1]= &coef_vlcs[coef_vlc_table * 2 + 1];
    init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0], &s->int_table[0],
                  s->coef_vlcs[0]);
    init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1], &s->int_table[1],
                  s->coef_vlcs[1]);

    return 0;
}

399 400
int ff_wma_total_gain_to_bits(int total_gain)
{
Michael Niedermayer's avatar
Michael Niedermayer committed
401 402 403 404 405 406 407 408 409
         if (total_gain < 15) return 13;
    else if (total_gain < 32) return 12;
    else if (total_gain < 40) return 11;
    else if (total_gain < 45) return 10;
    else                      return  9;
}

int ff_wma_end(AVCodecContext *avctx)
{
410
    WMACodecContext *s = avctx->priv_data;
Michael Niedermayer's avatar
Michael Niedermayer committed
411 412
    int i;

413
    for (i = 0; i < s->nb_block_sizes; i++)
Michael Niedermayer's avatar
Michael Niedermayer committed
414 415 416 417 418 419 420 421
        ff_mdct_end(&s->mdct_ctx[i]);

    if (s->use_exp_vlc) {
        free_vlc(&s->exp_vlc);
    }
    if (s->use_noise_coding) {
        free_vlc(&s->hgain_vlc);
    }
422
    for (i = 0; i < 2; i++) {
Michael Niedermayer's avatar
Michael Niedermayer committed
423 424 425
        free_vlc(&s->coef_vlc[i]);
        av_free(s->run_table[i]);
        av_free(s->level_table[i]);
Zdenek Kabelac's avatar
Zdenek Kabelac committed
426
        av_free(s->int_table[i]);
Michael Niedermayer's avatar
Michael Niedermayer committed
427 428 429 430
    }

    return 0;
}
431

432 433
/**
 * Decode an uncompressed coefficient.
434
 * @param gb GetBitContext
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
 * @return the decoded coefficient
 */
unsigned int ff_wma_get_large_val(GetBitContext* gb)
{
    /** consumes up to 34 bits */
    int n_bits = 8;
    /** decode length */
    if (get_bits1(gb)) {
        n_bits += 8;
        if (get_bits1(gb)) {
            n_bits += 8;
            if (get_bits1(gb)) {
                n_bits += 7;
            }
        }
    }
    return get_bits_long(gb, n_bits);
}

454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
/**
 * Decode run level compressed coefficients.
 * @param avctx codec context
 * @param gb bitstream reader context
 * @param vlc vlc table for get_vlc2
 * @param level_table level codes
 * @param run_table run codes
 * @param version 0 for wma1,2 1 for wmapro
 * @param ptr output buffer
 * @param offset offset in the output buffer
 * @param num_coefs number of input coefficents
 * @param block_len input buffer length (2^n)
 * @param frame_len_bits number of bits for escaped run codes
 * @param coef_nb_bits number of bits for escaped level codes
 * @return 0 on success, -1 otherwise
 */
int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb,
                            VLC *vlc,
472
                            const float *level_table, const uint16_t *run_table,
473
                            int version, WMACoef *ptr, int offset,
474 475 476
                            int num_coefs, int block_len, int frame_len_bits,
                            int coef_nb_bits)
{
Sascha Sommer's avatar
Sascha Sommer committed
477
    int code, level, sign;
478 479
    const uint32_t *ilvl = (const uint32_t*)level_table;
    uint32_t *iptr = (uint32_t*)ptr;
Sascha Sommer's avatar
Sascha Sommer committed
480 481
    const unsigned int coef_mask = block_len - 1;
    for (; offset < num_coefs; offset++) {
482
        code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX);
Sascha Sommer's avatar
Sascha Sommer committed
483 484 485
        if (code > 1) {
            /** normal code */
            offset += run_table[code];
486 487
            sign = get_bits1(gb) - 1;
            iptr[offset & coef_mask] = ilvl[code] ^ sign<<31;
Sascha Sommer's avatar
Sascha Sommer committed
488
        } else if (code == 1) {
489
            /** EOB */
490
            break;
Sascha Sommer's avatar
Sascha Sommer committed
491
        } else {
492
            /** escape */
493
            if (!version) {
494
                level = get_bits(gb, coef_nb_bits);
495 496
                /** NOTE: this is rather suboptimal. reading
                    block_len_bits would be better */
Sascha Sommer's avatar
Sascha Sommer committed
497
                offset += get_bits(gb, frame_len_bits);
498 499 500 501 502 503 504 505 506 507
            } else {
                level = ff_wma_get_large_val(gb);
                /** escape decode */
                if (get_bits1(gb)) {
                    if (get_bits1(gb)) {
                        if (get_bits1(gb)) {
                            av_log(avctx,AV_LOG_ERROR,
                                "broken escape sequence\n");
                            return -1;
                        } else
Sascha Sommer's avatar
Sascha Sommer committed
508
                            offset += get_bits(gb, frame_len_bits) + 4;
509
                    } else
Sascha Sommer's avatar
Sascha Sommer committed
510 511
                        offset += get_bits(gb, 2) + 1;
                }
512
            }
513 514
            sign = get_bits1(gb) - 1;
            ptr[offset & coef_mask] = (level^sign) - sign;
515 516
        }
    }
Sascha Sommer's avatar
Sascha Sommer committed
517 518 519 520 521 522
    /** NOTE: EOB can be omitted */
    if (offset > num_coefs) {
        av_log(avctx, AV_LOG_ERROR, "overflow in spectral RLE, ignoring\n");
        return -1;
    }

523 524 525
    return 0;
}