Revision cf3ac543

View differences:

libavcodec/vorbis.c
51 51
// the two bits[p] > 32 checks should be redundant, all calling code should
52 52
// already ensure that, but since it allows overwriting the stack it seems
53 53
// reasonable to check redundantly.
54
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num)
54
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
55 55
{
56 56
    uint_fast32_t exit_at_level[33] = {
57 57
        404, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58 58
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
59 59

  
60
    uint_fast8_t i, j;
61
    uint_fast32_t code, p;
60
    unsigned i, j, p, code;
62 61

  
63 62
#ifdef V_DEBUG
64 63
    GetBitContext gb;
......
78 77
        exit_at_level[i+1] = 1 << i;
79 78

  
80 79
#ifdef V_DEBUG
81
    av_log(NULL, AV_LOG_INFO, " %d. of %d code len %d code %d - ", p, num, bits[p], codes[p]);
82
    init_get_bits(&gb, (uint_fast8_t *)&codes[p], bits[p]);
80
    av_log(NULL, AV_LOG_INFO, " %u. of %u code len %d code %d - ", p, num, bits[p], codes[p]);
81
    init_get_bits(&gb, (uint8_t *)&codes[p], bits[p]);
83 82
    for (i = 0; i < bits[p]; ++i)
84 83
        av_log(NULL, AV_LOG_INFO, "%s", get_bits1(&gb) ? "1" : "0");
85 84
    av_log(NULL, AV_LOG_INFO, "\n");
libavcodec/vorbis.h
38 38

  
39 39
void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values);
40 40
unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n); // x^(1/n)
41
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num);
41
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num);
42 42
void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
43 43
                                  uint_fast16_t * y_list, int * flag,
44 44
                                  int multiplier, float * out, int samples);
libavcodec/vorbisdec.c
177 177
        VALIDATE_INDEX(idx, limit)\
178 178
    }
179 179

  
180
static float vorbisfloat2float(uint_fast32_t val)
180
static float vorbisfloat2float(unsigned val)
181 181
{
182 182
    double mant = val & 0x1fffff;
183 183
    long exp    = (val & 0x7fe00000L) >> 21;
......
191 191

  
192 192
static void vorbis_free(vorbis_context *vc)
193 193
{
194
    int_fast16_t i;
194
    int i;
195 195

  
196 196
    av_freep(&vc->channel_residues);
197 197
    av_freep(&vc->channel_floors);
......
237 237

  
238 238
static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
239 239
{
240
    uint_fast16_t cb;
240
    unsigned cb;
241 241
    uint8_t  *tmp_vlc_bits;
242 242
    uint32_t *tmp_vlc_codes;
243 243
    GetBitContext *gb = &vc->gb;
......
254 254

  
255 255
    for (cb = 0; cb < vc->codebook_count; ++cb) {
256 256
        vorbis_codebook *codebook_setup = &vc->codebooks[cb];
257
        uint_fast8_t ordered;
258
        uint_fast32_t t, used_entries = 0;
259
        uint_fast32_t entries;
257
        unsigned ordered, t, entries, used_entries = 0;
260 258

  
261
        AV_DEBUG(" %d. Codebook \n", cb);
259
        AV_DEBUG(" %u. Codebook\n", cb);
262 260

  
263 261
        if (get_bits(gb, 24) != 0x564342) {
264
            av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook setup data corrupt. \n", cb);
262
            av_log(vc->avccontext, AV_LOG_ERROR,
263
                   " %u. Codebook setup data corrupt.\n", cb);
265 264
            goto error;
266 265
        }
267 266

  
268 267
        codebook_setup->dimensions=get_bits(gb, 16);
269 268
        if (codebook_setup->dimensions > 16 || codebook_setup->dimensions == 0) {
270
            av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook's dimension is invalid (%d). \n", cb, codebook_setup->dimensions);
269
            av_log(vc->avccontext, AV_LOG_ERROR,
270
                   " %u. Codebook's dimension is invalid (%d).\n",
271
                   cb, codebook_setup->dimensions);
271 272
            goto error;
272 273
        }
273 274
        entries = get_bits(gb, 24);
274 275
        if (entries > V_MAX_VLCS) {
275
            av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook has too many entries (%"PRIdFAST32"). \n", cb, entries);
276
            av_log(vc->avccontext, AV_LOG_ERROR,
277
                   " %u. Codebook has too many entries (%u).\n",
278
                   cb, entries);
276 279
            goto error;
277 280
        }
278 281

  
279 282
        ordered = get_bits1(gb);
280 283

  
281
        AV_DEBUG(" codebook_dimensions %d, codebook_entries %d \n", codebook_setup->dimensions, entries);
284
        AV_DEBUG(" codebook_dimensions %d, codebook_entries %u\n",
285
                 codebook_setup->dimensions, entries);
282 286

  
283 287
        if (!ordered) {
284
            uint_fast16_t ce;
285
            uint_fast8_t  flag;
286
            uint_fast8_t  sparse = get_bits1(gb);
288
            unsigned ce, flag;
289
            unsigned sparse = get_bits1(gb);
287 290

  
288 291
            AV_DEBUG(" not ordered \n");
289 292

  
......
307 310
                    tmp_vlc_bits[ce] = get_bits(gb, 5) + 1;
308 311
            }
309 312
        } else {
310
            uint_fast16_t current_entry = 0;
311
            uint_fast8_t current_length = get_bits(gb, 5)+1;
313
            unsigned current_entry  = 0;
314
            unsigned current_length = get_bits(gb, 5) + 1;
312 315

  
313
            AV_DEBUG(" ordered, current length: %d \n", current_length);  //FIXME
316
            AV_DEBUG(" ordered, current length: %u\n", current_length);  //FIXME
314 317

  
315 318
            used_entries = entries;
316 319
            for (; current_entry < used_entries && current_length <= 32; ++current_length) {
317
                uint_fast16_t i, number;
320
                unsigned i, number;
318 321

  
319
                AV_DEBUG(" number bits: %d ", ilog(entries - current_entry));
322
                AV_DEBUG(" number bits: %u ", ilog(entries - current_entry));
320 323

  
321 324
                number = get_bits(gb, ilog(entries - current_entry));
322 325

  
323
                AV_DEBUG(" number: %d \n", number);
326
                AV_DEBUG(" number: %u\n", number);
324 327

  
325 328
                for (i = current_entry; i < number+current_entry; ++i)
326 329
                    if (i < used_entries)
......
341 344
// If the codebook is used for (inverse) VQ, calculate codevectors.
342 345

  
343 346
        if (codebook_setup->lookup_type == 1) {
344
            uint_fast16_t i, j, k;
345
            uint_fast16_t codebook_lookup_values = ff_vorbis_nth_root(entries, codebook_setup->dimensions);
347
            unsigned i, j, k;
348
            unsigned codebook_lookup_values = ff_vorbis_nth_root(entries, codebook_setup->dimensions);
346 349

  
347 350
            float codebook_minimum_value = vorbisfloat2float(get_bits_long(gb, 32));
348 351
            float codebook_delta_value   = vorbisfloat2float(get_bits_long(gb, 32));
349
            uint_fast8_t codebook_value_bits = get_bits(gb, 4)+1;
350
            uint_fast8_t codebook_sequence_p = get_bits1(gb);
352
            unsigned codebook_value_bits = get_bits(gb, 4) + 1;
353
            unsigned codebook_sequence_p = get_bits1(gb);
351 354

  
352 355
            AV_DEBUG(" We expect %d numbers for building the codevectors. \n", codebook_lookup_values);
353 356
            AV_DEBUG("  delta %f minmum %f \n", codebook_delta_value, codebook_minimum_value);
......
365 368
                                                                    sizeof(*codebook_setup->codevectors))
366 369
                                                       : NULL;
367 370
            for (j = 0, i = 0; i < entries; ++i) {
368
                uint_fast8_t dim = codebook_setup->dimensions;
371
                unsigned dim = codebook_setup->dimensions;
369 372

  
370 373
                if (tmp_vlc_bits[i]) {
371 374
                    float last = 0.0;
372
                    uint_fast32_t lookup_offset = i;
375
                    unsigned lookup_offset = i;
373 376

  
374 377
#ifdef V_DEBUG
375
                    av_log(vc->avccontext, AV_LOG_INFO, "Lookup offset %d ,", i);
378
                    av_log(vc->avccontext, AV_LOG_INFO, "Lookup offset %u ,", i);
376 379
#endif
377 380

  
378 381
                    for (k = 0; k < dim; ++k) {
379
                        uint_fast32_t multiplicand_offset = lookup_offset % codebook_lookup_values;
382
                        unsigned multiplicand_offset = lookup_offset % codebook_lookup_values;
380 383
                        codebook_setup->codevectors[j * dim + k] = codebook_multiplicands[multiplicand_offset] * codebook_delta_value + codebook_minimum_value + last;
381 384
                        if (codebook_sequence_p)
382 385
                            last = codebook_setup->codevectors[j * dim + k];
......
385 388
                    tmp_vlc_bits[j] = tmp_vlc_bits[i];
386 389

  
387 390
#ifdef V_DEBUG
388
                    av_log(vc->avccontext, AV_LOG_INFO, "real lookup offset %d, vector: ", j);
391
                    av_log(vc->avccontext, AV_LOG_INFO, "real lookup offset %u, vector: ", j);
389 392
                    for (k = 0; k < dim; ++k)
390 393
                        av_log(vc->avccontext, AV_LOG_INFO, " %f ", codebook_setup->codevectors[j * dim + k]);
391 394
                    av_log(vc->avccontext, AV_LOG_INFO, "\n");
......
445 448
static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc)
446 449
{
447 450
    GetBitContext *gb = &vc->gb;
448
    uint_fast8_t i;
449
    uint_fast8_t vorbis_time_count = get_bits(gb, 6) + 1;
451
    unsigned i, vorbis_time_count = get_bits(gb, 6) + 1;
450 452

  
451 453
    for (i = 0; i < vorbis_time_count; ++i) {
452
        uint_fast16_t vorbis_tdtransform = get_bits(gb, 16);
454
        unsigned vorbis_tdtransform = get_bits(gb, 16);
453 455

  
454
        AV_DEBUG(" Vorbis time domain transform %d: %d \n", vorbis_time_count, vorbis_tdtransform);
456
        AV_DEBUG(" Vorbis time domain transform %u: %u\n",
457
                 vorbis_time_count, vorbis_tdtransform);
455 458

  
456 459
        if (vorbis_tdtransform) {
457 460
            av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis time domain transform data nonzero. \n");
......
465 468

  
466 469
static int vorbis_floor0_decode(vorbis_context *vc,
467 470
                                vorbis_floor_data *vfu, float *vec);
468
static void create_map(vorbis_context *vc, uint_fast8_t floor_number);
471
static void create_map(vorbis_context *vc, unsigned floor_number);
469 472
static int vorbis_floor1_decode(vorbis_context *vc,
470 473
                                vorbis_floor_data *vfu, float *vec);
471 474
static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
......
486 489

  
487 490
        if (floor_setup->floor_type == 1) {
488 491
            int maximum_class = -1;
489
            uint_fast8_t  rangebits;
490
            uint_fast32_t rangemax;
491
            uint_fast16_t floor1_values = 2;
492
            unsigned rangebits, rangemax, floor1_values = 2;
492 493

  
493 494
            floor_setup->decode = vorbis_floor1_decode;
494 495

  
......
543 544
            rangemax = (1 << rangebits);
544 545
            if (rangemax > vc->blocksize[1] / 2) {
545 546
                av_log(vc->avccontext, AV_LOG_ERROR,
546
                       "Floor value is too large for blocksize: %"PRIuFAST32" (%"PRIuFAST32")\n",
547
                       "Floor value is too large for blocksize: %u (%"PRIuFAST32")\n",
547 548
                       rangemax, vc->blocksize[1] / 2);
548 549
                return -1;
549 550
            }
......
554 555
                for (k = 0; k < floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; ++k, ++floor1_values) {
555 556
                    floor_setup->data.t1.list[floor1_values].x = get_bits(gb, rangebits);
556 557

  
557
                    AV_DEBUG(" %d. floor1 Y coord. %d \n", floor1_values, floor_setup->data.t1.list[floor1_values].x);
558
                    AV_DEBUG(" %u. floor1 Y coord. %d\n", floor1_values,
559
                             floor_setup->data.t1.list[floor1_values].x);
558 560
                }
559 561
            }
560 562

  
561 563
// Precalculate order of x coordinates - needed for decode
562 564
            ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim);
563 565
        } else if (floor_setup->floor_type == 0) {
564
            uint_fast8_t max_codebook_dim = 0;
566
            unsigned max_codebook_dim = 0;
565 567

  
566 568
            floor_setup->decode = vorbis_floor0_decode;
567 569

  
......
587 589
            /* read book indexes */
588 590
            {
589 591
                int idx;
590
                uint_fast8_t book_idx;
592
                unsigned book_idx;
591 593
                for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) {
592 594
                    GET_VALIDATED_INDEX(book_idx, 8, vc->codebook_count)
593 595
                    floor_setup->data.t0.book_list[idx] = book_idx;
......
641 643
static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
642 644
{
643 645
    GetBitContext *gb = &vc->gb;
644
    uint_fast8_t i, j, k;
646
    unsigned i, j, k;
645 647

  
646 648
    vc->residue_count = get_bits(gb, 6)+1;
647 649
    vc->residues      = av_mallocz(vc->residue_count * sizeof(*vc->residues));
......
651 653
    for (i = 0; i < vc->residue_count; ++i) {
652 654
        vorbis_residue *res_setup = &vc->residues[i];
653 655
        uint_fast8_t cascade[64];
654
        uint_fast8_t high_bits;
655
        uint_fast8_t low_bits;
656
        unsigned high_bits, low_bits;
656 657

  
657 658
        res_setup->type = get_bits(gb, 16);
658 659

  
659
        AV_DEBUG(" %d. residue type %d \n", i, res_setup->type);
660
        AV_DEBUG(" %u. residue type %d\n", i, res_setup->type);
660 661

  
661 662
        res_setup->begin          = get_bits(gb, 24);
662 663
        res_setup->end            = get_bits(gb, 24);
......
690 691
                high_bits = get_bits(gb, 5);
691 692
            cascade[j] = (high_bits << 3) + low_bits;
692 693

  
693
            AV_DEBUG("     %d class casscade depth: %d \n", j, ilog(cascade[j]));
694
            AV_DEBUG("     %u class cascade depth: %d\n", j, ilog(cascade[j]));
694 695
        }
695 696

  
696 697
        res_setup->maxpass = 0;
......
699 700
                if (cascade[j]&(1 << k)) {
700 701
                    GET_VALIDATED_INDEX(res_setup->books[j][k], 8, vc->codebook_count)
701 702

  
702
                    AV_DEBUG("     %d class casscade depth %d book: %d \n", j, k, res_setup->books[j][k]);
703
                    AV_DEBUG("     %u class cascade depth %u book: %d\n",
704
                             j, k, res_setup->books[j][k]);
703 705

  
704 706
                    if (k>res_setup->maxpass)
705 707
                        res_setup->maxpass = k;
......
717 719
static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
718 720
{
719 721
    GetBitContext *gb = &vc->gb;
720
    uint_fast8_t i, j;
722
    unsigned i, j;
721 723

  
722 724
    vc->mapping_count = get_bits(gb, 6)+1;
723 725
    vc->mappings      = av_mallocz(vc->mapping_count * sizeof(*vc->mappings));
......
751 753
            mapping_setup->coupling_steps = 0;
752 754
        }
753 755

  
754
        AV_DEBUG("   %d mapping coupling steps: %d \n", i, mapping_setup->coupling_steps);
756
        AV_DEBUG("   %u mapping coupling steps: %d\n",
757
                 i, mapping_setup->coupling_steps);
755 758

  
756 759
        if (get_bits(gb, 2)) {
757
            av_log(vc->avccontext, AV_LOG_ERROR, "%d. mapping setup data invalid. \n", i);
760
            av_log(vc->avccontext, AV_LOG_ERROR, "%u. mapping setup data invalid.\n", i);
758 761
            return -1; // following spec.
759 762
        }
760 763

  
......
770 773
            GET_VALIDATED_INDEX(mapping_setup->submap_floor[j],   8, vc->floor_count)
771 774
            GET_VALIDATED_INDEX(mapping_setup->submap_residue[j], 8, vc->residue_count)
772 775

  
773
            AV_DEBUG("   %d mapping %d submap : floor %d, residue %d \n", i, j, mapping_setup->submap_floor[j], mapping_setup->submap_residue[j]);
776
            AV_DEBUG("   %u mapping %u submap : floor %d, residue %d\n",
777
                     i, j,
778
                     mapping_setup->submap_floor[j],
779
                     mapping_setup->submap_residue[j]);
774 780
        }
775 781
    }
776 782
    return 0;
......
778 784

  
779 785
// Process modes part
780 786

  
781
static void create_map(vorbis_context *vc, uint_fast8_t floor_number)
787
static void create_map(vorbis_context *vc, unsigned floor_number)
782 788
{
783 789
    vorbis_floor *floors = vc->floors;
784 790
    vorbis_floor0 *vf;
785 791
    int idx;
786
    int_fast8_t blockflag;
792
    int blockflag, n;
787 793
    int_fast32_t *map;
788
    int_fast32_t n; //TODO: could theoretically be smaller?
789 794

  
790 795
    for (blockflag = 0; blockflag < 2; ++blockflag) {
791 796
        n = vc->blocksize[blockflag] / 2;
......
817 822
static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
818 823
{
819 824
    GetBitContext *gb = &vc->gb;
820
    uint_fast8_t i;
825
    unsigned i;
821 826

  
822 827
    vc->mode_count = get_bits(gb, 6) + 1;
823 828
    vc->modes      = av_mallocz(vc->mode_count * sizeof(*vc->modes));
......
832 837
        mode_setup->transformtype = get_bits(gb, 16); //FIXME check
833 838
        GET_VALIDATED_INDEX(mode_setup->mapping, 8, vc->mapping_count);
834 839

  
835
        AV_DEBUG(" %d mode: blockflag %d, windowtype %d, transformtype %d, mapping %d \n", i, mode_setup->blockflag, mode_setup->windowtype, mode_setup->transformtype, mode_setup->mapping);
840
        AV_DEBUG(" %u mode: blockflag %d, windowtype %d, transformtype %d, mapping %d\n",
841
                 i, mode_setup->blockflag, mode_setup->windowtype,
842
                 mode_setup->transformtype, mode_setup->mapping);
836 843
    }
837 844
    return 0;
838 845
}
......
887 894
static int vorbis_parse_id_hdr(vorbis_context *vc)
888 895
{
889 896
    GetBitContext *gb = &vc->gb;
890
    uint_fast8_t bl0, bl1;
897
    unsigned bl0, bl1;
891 898

  
892 899
    if ((get_bits(gb, 8) != 'v') || (get_bits(gb, 8) != 'o') ||
893 900
        (get_bits(gb, 8) != 'r') || (get_bits(gb, 8) != 'b') ||
......
1028 1035
{
1029 1036
    vorbis_floor0 *vf = &vfu->t0;
1030 1037
    float *lsp = vf->lsp;
1031
    uint_fast32_t amplitude;
1032
    uint_fast32_t book_idx;
1033
    uint_fast8_t blockflag = vc->modes[vc->mode_number].blockflag;
1038
    unsigned amplitude, book_idx;
1039
    unsigned blockflag = vc->modes[vc->mode_number].blockflag;
1034 1040

  
1035 1041
    amplitude = get_bits(&vc->gb, vf->amplitude_bits);
1036 1042
    if (amplitude > 0) {
1037 1043
        float last = 0;
1038
        uint_fast16_t lsp_len = 0;
1039
        uint_fast16_t idx;
1044
        unsigned idx, lsp_len = 0;
1040 1045
        vorbis_codebook codebook;
1041 1046

  
1042 1047
        book_idx = get_bits(&vc->gb, ilog(vf->num_books));
......
1139 1144
    vorbis_floor1 *vf = &vfu->t1;
1140 1145
    GetBitContext *gb = &vc->gb;
1141 1146
    uint_fast16_t range_v[4] = { 256, 128, 86, 64 };
1142
    uint_fast16_t range = range_v[vf->multiplier-1];
1147
    unsigned range = range_v[vf->multiplier-1];
1143 1148
    uint_fast16_t floor1_Y[258];
1144 1149
    uint_fast16_t floor1_Y_final[258];
1145 1150
    int floor1_flag[258];
1146
    uint_fast8_t class;
1147
    uint_fast8_t cdim;
1148
    uint_fast8_t cbits;
1149
    uint_fast8_t csub;
1150
    uint_fast8_t cval;
1151
    int_fast16_t book;
1152
    uint_fast16_t offset;
1153
    uint_fast16_t i,j;
1154
    int_fast16_t adx, ady, dy, off, predicted;
1155
    int_fast32_t err;
1151
    unsigned class, cdim, cbits, csub, cval, offset, i, j;
1152
    int book, adx, ady, dy, off, predicted, err;
1156 1153

  
1157 1154

  
1158 1155
    if (!get_bits1(gb)) // silence
......
1173 1170
        csub = (1 << cbits) - 1;
1174 1171
        cval = 0;
1175 1172

  
1176
        AV_DEBUG("Cbits %d \n", cbits);
1173
        AV_DEBUG("Cbits %u\n", cbits);
1177 1174

  
1178 1175
        if (cbits) // this reads all subclasses for this partition's class
1179 1176
            cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class]].vlc.table,
......
1182 1179
        for (j = 0; j < cdim; ++j) {
1183 1180
            book = vf->subclass_books[class][cval & csub];
1184 1181

  
1185
            AV_DEBUG("book %d Cbits %d cval %d  bits:%d \n", book, cbits, cval, get_bits_count(gb));
1182
            AV_DEBUG("book %d Cbits %u cval %u  bits:%d\n",
1183
                     book, cbits, cval, get_bits_count(gb));
1186 1184

  
1187 1185
            cval = cval >> cbits;
1188 1186
            if (book > -1) {
......
1205 1203
    floor1_Y_final[1] = floor1_Y[1];
1206 1204

  
1207 1205
    for (i = 2; i < vf->x_list_dim; ++i) {
1208
        uint_fast16_t val, highroom, lowroom, room;
1209
        uint_fast16_t high_neigh_offs;
1210
        uint_fast16_t low_neigh_offs;
1206
        unsigned val, highroom, lowroom, room, high_neigh_offs, low_neigh_offs;
1211 1207

  
1212 1208
        low_neigh_offs  = vf->list[i].low;
1213 1209
        high_neigh_offs = vf->list[i].high;
......
1252 1248
            floor1_Y_final[i] = predicted;
1253 1249
        }
1254 1250

  
1255
        AV_DEBUG(" Decoded floor(%d) = %d / val %d \n", vf->list[i].x, floor1_Y_final[i], val);
1251
        AV_DEBUG(" Decoded floor(%d) = %d / val %u\n",
1252
                 vf->list[i].x, floor1_Y_final[i], val);
1256 1253
    }
1257 1254

  
1258 1255
// Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ?
......
1268 1265

  
1269 1266
static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
1270 1267
                                                           vorbis_residue *vr,
1271
                                                           uint_fast8_t ch,
1268
                                                           unsigned ch,
1272 1269
                                                           uint_fast8_t *do_not_decode,
1273 1270
                                                           float *vec,
1274
                                                           uint_fast16_t vlen,
1271
                                                           unsigned vlen,
1275 1272
                                                           int vr_type)
1276 1273
{
1277 1274
    GetBitContext *gb = &vc->gb;
1278
    uint_fast8_t c_p_c = vc->codebooks[vr->classbook].dimensions;
1279
    uint_fast16_t ptns_to_read = vr->ptns_to_read;
1275
    unsigned c_p_c        = vc->codebooks[vr->classbook].dimensions;
1276
    unsigned ptns_to_read = vr->ptns_to_read;
1280 1277
    uint8_t *classifs = vr->classifs;
1281
    uint_fast8_t pass;
1282
    uint_fast8_t ch_used;
1283
    uint_fast8_t i,j,l;
1284
    uint_fast16_t k;
1278
    unsigned pass, ch_used, i, j, k, l;
1285 1279

  
1286 1280
    if (vr_type == 2) {
1287 1281
        for (j = 1; j < ch; ++j)
......
1296 1290
    AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d  cpc %d  \n", ch, c_p_c);
1297 1291

  
1298 1292
    for (pass = 0; pass <= vr->maxpass; ++pass) { // FIXME OPTIMIZE?
1299
        uint_fast16_t voffset;
1300
        uint_fast16_t partition_count;
1301
        uint_fast16_t j_times_ptns_to_read;
1293
        uint16_t voffset, partition_count, j_times_ptns_to_read;
1302 1294

  
1303 1295
        voffset = vr->begin;
1304 1296
        for (partition_count = 0; partition_count < ptns_to_read;) {  // SPEC        error
1305 1297
            if (!pass) {
1306
                uint_fast32_t inverse_class = ff_inverse[vr->classifications];
1298
                unsigned inverse_class = ff_inverse[vr->classifications];
1307 1299
                for (j_times_ptns_to_read = 0, j = 0; j < ch_used; ++j) {
1308 1300
                    if (!do_not_decode[j]) {
1309
                        uint_fast32_t temp = get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table,
1310
                        vc->codebooks[vr->classbook].nb_bits, 3);
1301
                        unsigned temp = get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table,
1302
                                                 vc->codebooks[vr->classbook].nb_bits, 3);
1311 1303

  
1312
                        AV_DEBUG("Classword: %d \n", temp);
1304
                        AV_DEBUG("Classword: %u\n", temp);
1313 1305

  
1314 1306
                        assert(vr->classifications > 1 && temp <= 65536); //needed for inverse[]
1315 1307
                        for (i = 0; i < c_p_c; ++i) {
1316
                            uint_fast32_t temp2;
1308
                            unsigned temp2;
1317 1309

  
1318
                            temp2 = (((uint_fast64_t)temp) * inverse_class) >> 32;
1310
                            temp2 = (((uint64_t)temp) * inverse_class) >> 32;
1319 1311
                            if (partition_count + c_p_c - 1 - i < ptns_to_read)
1320 1312
                                classifs[j_times_ptns_to_read + partition_count + c_p_c - 1 - i] = temp - temp2 * vr->classifications;
1321 1313
                            temp = temp2;
......
1326 1318
            }
1327 1319
            for (i = 0; (i < c_p_c) && (partition_count < ptns_to_read); ++i) {
1328 1320
                for (j_times_ptns_to_read = 0, j = 0; j < ch_used; ++j) {
1329
                    uint_fast16_t voffs;
1321
                    unsigned voffs;
1330 1322

  
1331 1323
                    if (!do_not_decode[j]) {
1332
                        uint_fast8_t vqclass = classifs[j_times_ptns_to_read+partition_count];
1333
                        int_fast16_t vqbook = vr->books[vqclass][pass];
1324
                        unsigned vqclass = classifs[j_times_ptns_to_read + partition_count];
1325
                        int vqbook  = vr->books[vqclass][pass];
1334 1326

  
1335 1327
                        if (vqbook >= 0 && vc->codebooks[vqbook].codevectors) {
1336
                            uint_fast16_t coffs;
1337
                            unsigned dim =  vc->codebooks[vqbook].dimensions; // not uint_fast8_t: 64bit is slower here on amd64
1338
                            uint_fast16_t step = dim == 1 ? vr->partition_size
1339
                                                          : FASTDIV(vr->partition_size, dim);
1328
                            unsigned coffs;
1329
                            unsigned dim  = vc->codebooks[vqbook].dimensions;
1330
                            unsigned step = dim == 1 ? vr->partition_size
1331
                                                     : FASTDIV(vr->partition_size, dim);
1340 1332
                            vorbis_codebook codebook = vc->codebooks[vqbook];
1341 1333

  
1342 1334
                            if (vr_type == 0) {
......
1410 1402
}
1411 1403

  
1412 1404
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
1413
                                        uint_fast8_t ch,
1405
                                        unsigned ch,
1414 1406
                                        uint_fast8_t *do_not_decode,
1415
                                        float *vec, uint_fast16_t vlen)
1407
                                        float *vec, unsigned vlen)
1416 1408
{
1417 1409
    if (vr->type == 2)
1418 1410
        return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2);
......
1456 1448
{
1457 1449
    GetBitContext *gb = &vc->gb;
1458 1450
    FFTContext *mdct;
1459
    uint_fast8_t previous_window = vc->previous_window;
1460
    uint_fast8_t mode_number;
1461
    uint_fast8_t blockflag;
1462
    uint_fast16_t blocksize;
1463
    int_fast32_t i,j;
1451
    unsigned previous_window = vc->previous_window;
1452
    unsigned mode_number, blockflag, blocksize;
1453
    int i, j;
1464 1454
    uint_fast8_t no_residue[255];
1465 1455
    uint_fast8_t do_not_decode[255];
1466 1456
    vorbis_mapping *mapping;
1467 1457
    float *ch_res_ptr   = vc->channel_residues;
1468 1458
    float *ch_floor_ptr = vc->channel_floors;
1469 1459
    uint_fast8_t res_chan[255];
1470
    uint_fast8_t res_num = 0;
1471
    int_fast16_t retlen  = 0;
1460
    unsigned res_num = 0;
1461
    int retlen  = 0;
1472 1462

  
1473 1463
    if (get_bits1(gb)) {
1474 1464
        av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
......
1483 1473
    vc->mode_number = mode_number;
1484 1474
    mapping = &vc->mappings[vc->modes[mode_number].mapping];
1485 1475

  
1486
    AV_DEBUG(" Mode number: %d , mapping: %d , blocktype %d \n", mode_number, vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag);
1476
    AV_DEBUG(" Mode number: %u , mapping: %d , blocktype %d\n", mode_number,
1477
             vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag);
1487 1478

  
1488 1479
    blockflag = vc->modes[mode_number].blockflag;
1489 1480
    blocksize = vc->blocksize[blockflag];
......
1527 1518

  
1528 1519
    for (i = 0; i < mapping->submaps; ++i) {
1529 1520
        vorbis_residue *residue;
1530
        uint_fast8_t ch = 0;
1521
        unsigned ch = 0;
1531 1522

  
1532 1523
        for (j = 0; j < vc->audio_channels; ++j) {
1533 1524
            if ((mapping->submaps == 1) || (i == mapping->mux[j])) {
......
1572 1563

  
1573 1564
    retlen = (blocksize + vc->blocksize[previous_window]) / 4;
1574 1565
    for (j = 0; j < vc->audio_channels; j++) {
1575
        uint_fast16_t bs0 = vc->blocksize[0];
1576
        uint_fast16_t bs1 = vc->blocksize[1];
1566
        unsigned bs0 = vc->blocksize[0];
1567
        unsigned bs1 = vc->blocksize[1];
1577 1568
        float *residue    = vc->channel_residues + res_chan[j] * blocksize / 2;
1578 1569
        float *saved      = vc->saved + j * bs1 / 4;
1579 1570
        float *ret        = vc->channel_floors + j * retlen;
......
1607 1598
    vorbis_context *vc = avccontext->priv_data ;
1608 1599
    GetBitContext *gb = &(vc->gb);
1609 1600
    const float *channel_ptrs[255];
1610
    int i;
1611

  
1612
    int_fast16_t len;
1601
    int i, len;
1613 1602

  
1614 1603
    if (!buf_size)
1615 1604
        return 0;

Also available in: Unified diff