comparison vorbis.c @ 3083:0995d7ddeb58 libavcodec

Added support for vorbis files containing floor type 0.
author al
date Sat, 04 Feb 2006 08:55:34 +0000
parents 961af1358c7f
children d37c1e2f715d
comparison
equal deleted inserted replaced
3082:d85afa120256 3083:0995d7ddeb58
54 } 54 }
55 } 55 }
56 56
57 #define ilog(i) av_log2(2*(i)) 57 #define ilog(i) av_log2(2*(i))
58 58
59 #define BARK(x) \
60 (13.1f*atan(0.00074f*(x))+2.24f*atan(1.85e-8f*(x)*(x))+1e-4f*(x))
61
59 static unsigned int nth_root(unsigned int x, unsigned int n) { // x^(1/n) 62 static unsigned int nth_root(unsigned int x, unsigned int n) { // x^(1/n)
60 unsigned int ret=0, i, j; 63 unsigned int ret=0, i, j;
61 64
62 do { 65 do {
63 ++ret; 66 ++ret;
164 free_vlc(&vc->codebooks[i].vlc); 167 free_vlc(&vc->codebooks[i].vlc);
165 } 168 }
166 av_freep(&vc->codebooks); 169 av_freep(&vc->codebooks);
167 170
168 for(i=0;i<vc->floor_count;++i) { 171 for(i=0;i<vc->floor_count;++i) {
169 av_free(vc->floors[i].x_list); 172 if(vc->floors[i].floor_type==0) {
170 av_free(vc->floors[i].x_list_order); 173 av_free(vc->floors[i].data.t0.map);
171 av_free(vc->floors[i].low_neighbour); 174 av_free(vc->floors[i].data.t0.book_list);
172 av_free(vc->floors[i].high_neighbour); 175 av_free(vc->floors[i].data.t0.lsp);
176 }
177 else {
178 av_free(vc->floors[i].data.t1.x_list);
179 av_free(vc->floors[i].data.t1.x_list_order);
180 av_free(vc->floors[i].data.t1.low_neighbour);
181 av_free(vc->floors[i].data.t1.high_neighbour);
182 }
173 } 183 }
174 av_freep(&vc->floors); 184 av_freep(&vc->floors);
175 185
176 for(i=0;i<vc->mapping_count;++i) { 186 for(i=0;i<vc->mapping_count;++i) {
177 av_free(vc->mappings[i].magnitude); 187 av_free(vc->mappings[i].magnitude);
402 } 412 }
403 } 413 }
404 return 0; 414 return 0;
405 } 415 }
406 416
407 // Process floors part - only floor type 1 is supported 417 // Process floors part
408 418
419 static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
420 vorbis_floor_data *vfu, float *vec);
421 static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
422 vorbis_floor_data *vfu, float *vec);
409 static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) { 423 static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) {
410 GetBitContext *gb=&vc->gb; 424 GetBitContext *gb=&vc->gb;
411 uint_fast16_t i,j,k; 425 uint_fast16_t i,j,k;
412 426
413 vc->floor_count=get_bits(gb, 6)+1; 427 vc->floor_count=get_bits(gb, 6)+1;
424 if (floor_setup->floor_type==1) { 438 if (floor_setup->floor_type==1) {
425 uint_fast8_t maximum_class=0; 439 uint_fast8_t maximum_class=0;
426 uint_fast8_t rangebits; 440 uint_fast8_t rangebits;
427 uint_fast16_t floor1_values=2; 441 uint_fast16_t floor1_values=2;
428 442
429 floor_setup->partitions=get_bits(gb, 5); 443 floor_setup->decode=vorbis_floor1_decode;
430 444
431 AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->partitions); 445 floor_setup->data.t1.partitions=get_bits(gb, 5);
432 446
433 for(j=0;j<floor_setup->partitions;++j) { 447 AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->data.t1.partitions);
434 floor_setup->partition_class[j]=get_bits(gb, 4); 448
435 if (floor_setup->partition_class[j]>maximum_class) maximum_class=floor_setup->partition_class[j]; 449 for(j=0;j<floor_setup->data.t1.partitions;++j) {
436 450 floor_setup->data.t1.partition_class[j]=get_bits(gb, 4);
437 AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->partition_class[j]); 451 if (floor_setup->data.t1.partition_class[j]>maximum_class) maximum_class=floor_setup->data.t1.partition_class[j];
452
453 AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]);
438 454
439 } 455 }
440 456
441 AV_DEBUG(" maximum class %d \n", maximum_class); 457 AV_DEBUG(" maximum class %d \n", maximum_class);
442 458
443 floor_setup->maximum_class=maximum_class; 459 floor_setup->data.t1.maximum_class=maximum_class;
444 460
445 for(j=0;j<=maximum_class;++j) { 461 for(j=0;j<=maximum_class;++j) {
446 floor_setup->class_dimensions[j]=get_bits(gb, 3)+1; 462 floor_setup->data.t1.class_dimensions[j]=get_bits(gb, 3)+1;
447 floor_setup->class_subclasses[j]=get_bits(gb, 2); 463 floor_setup->data.t1.class_subclasses[j]=get_bits(gb, 2);
448 464
449 AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->class_dimensions[j], floor_setup->class_subclasses[j]); 465 AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]);
450 466
451 if (floor_setup->class_subclasses[j]) { 467 if (floor_setup->data.t1.class_subclasses[j]) {
452 floor_setup->class_masterbook[j]=get_bits(gb, 8); 468 floor_setup->data.t1.class_masterbook[j]=get_bits(gb, 8);
453 469
454 AV_DEBUG(" masterbook: %d \n", floor_setup->class_masterbook[j]); 470 AV_DEBUG(" masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]);
455 } 471 }
456 472
457 for(k=0;k<(1<<floor_setup->class_subclasses[j]);++k) { 473 for(k=0;k<(1<<floor_setup->data.t1.class_subclasses[j]);++k) {
458 floor_setup->subclass_books[j][k]=get_bits(gb, 8)-1; 474 floor_setup->data.t1.subclass_books[j][k]=get_bits(gb, 8)-1;
459 475
460 AV_DEBUG(" book %d. : %d \n", k, floor_setup->subclass_books[j][k]); 476 AV_DEBUG(" book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]);
461 } 477 }
462 } 478 }
463 479
464 floor_setup->multiplier=get_bits(gb, 2)+1; 480 floor_setup->data.t1.multiplier=get_bits(gb, 2)+1;
465 floor_setup->x_list_dim=2; 481 floor_setup->data.t1.x_list_dim=2;
466 482
467 for(j=0;j<floor_setup->partitions;++j) { 483 for(j=0;j<floor_setup->data.t1.partitions;++j) {
468 floor_setup->x_list_dim+=floor_setup->class_dimensions[floor_setup->partition_class[j]]; 484 floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
469 } 485 }
470 486
471 floor_setup->x_list=(uint_fast16_t *)av_mallocz(floor_setup->x_list_dim * sizeof(uint_fast16_t)); 487 floor_setup->data.t1.x_list=(uint_fast16_t *)av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(uint_fast16_t));
472 floor_setup->x_list_order=(uint_fast16_t *)av_mallocz(floor_setup->x_list_dim * sizeof(uint_fast16_t)); 488 floor_setup->data.t1.x_list_order=(uint_fast16_t *)av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(uint_fast16_t));
473 floor_setup->low_neighbour=(uint_fast16_t *)av_mallocz(floor_setup->x_list_dim * sizeof(uint_fast16_t)); 489 floor_setup->data.t1.low_neighbour=(uint_fast16_t *)av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(uint_fast16_t));
474 floor_setup->high_neighbour=(uint_fast16_t *)av_mallocz(floor_setup->x_list_dim * sizeof(uint_fast16_t)); 490 floor_setup->data.t1.high_neighbour=(uint_fast16_t *)av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(uint_fast16_t));
475 491
476 492
477 rangebits=get_bits(gb, 4); 493 rangebits=get_bits(gb, 4);
478 floor_setup->x_list[0] = 0; 494 floor_setup->data.t1.x_list[0] = 0;
479 floor_setup->x_list[1] = (1<<rangebits); 495 floor_setup->data.t1.x_list[1] = (1<<rangebits);
480 496
481 for(j=0;j<floor_setup->partitions;++j) { 497 for(j=0;j<floor_setup->data.t1.partitions;++j) {
482 for(k=0;k<floor_setup->class_dimensions[floor_setup->partition_class[j]];++k,++floor1_values) { 498 for(k=0;k<floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];++k,++floor1_values) {
483 floor_setup->x_list[floor1_values]=get_bits(gb, rangebits); 499 floor_setup->data.t1.x_list[floor1_values]=get_bits(gb, rangebits);
484 500
485 AV_DEBUG(" %d. floor1 Y coord. %d \n", floor1_values, floor_setup->x_list[floor1_values]); 501 AV_DEBUG(" %d. floor1 Y coord. %d \n", floor1_values, floor_setup->data.t1.x_list[floor1_values]);
486 } 502 }
487 } 503 }
488 504
489 // Precalculate order of x coordinates - needed for decode 505 // Precalculate order of x coordinates - needed for decode
490 506
491 for(k=0;k<floor_setup->x_list_dim;++k) { 507 for(k=0;k<floor_setup->data.t1.x_list_dim;++k) {
492 floor_setup->x_list_order[k]=k; 508 floor_setup->data.t1.x_list_order[k]=k;
493 } 509 }
494 510
495 for(k=0;k<floor_setup->x_list_dim-1;++k) { // FIXME optimize sorting ? 511 for(k=0;k<floor_setup->data.t1.x_list_dim-1;++k) { // FIXME optimize sorting ?
496 for(j=k+1;j<floor_setup->x_list_dim;++j) { 512 for(j=k+1;j<floor_setup->data.t1.x_list_dim;++j) {
497 if(floor_setup->x_list[floor_setup->x_list_order[k]]>floor_setup->x_list[floor_setup->x_list_order[j]]) { 513 if(floor_setup->data.t1.x_list[floor_setup->data.t1.x_list_order[k]]>floor_setup->data.t1.x_list[floor_setup->data.t1.x_list_order[j]]) {
498 uint_fast16_t tmp=floor_setup->x_list_order[k]; 514 uint_fast16_t tmp=floor_setup->data.t1.x_list_order[k];
499 floor_setup->x_list_order[k]=floor_setup->x_list_order[j]; 515 floor_setup->data.t1.x_list_order[k]=floor_setup->data.t1.x_list_order[j];
500 floor_setup->x_list_order[j]=tmp; 516 floor_setup->data.t1.x_list_order[j]=tmp;
501 } 517 }
502 } 518 }
503 } 519 }
504 520
505 // Precalculate low and high neighbours 521 // Precalculate low and high neighbours
506 522
507 for(k=2;k<floor_setup->x_list_dim;++k) { 523 for(k=2;k<floor_setup->data.t1.x_list_dim;++k) {
508 floor_setup->low_neighbour[k]=0; 524 floor_setup->data.t1.low_neighbour[k]=0;
509 floor_setup->high_neighbour[k]=1; // correct according to SPEC requirements 525 floor_setup->data.t1.high_neighbour[k]=1; // correct according to SPEC requirements
510 526
511 for (j=0;j<k;++j) { 527 for (j=0;j<k;++j) {
512 if ((floor_setup->x_list[j]<floor_setup->x_list[k]) && 528 if ((floor_setup->data.t1.x_list[j]<floor_setup->data.t1.x_list[k]) &&
513 (floor_setup->x_list[j]>floor_setup->x_list[floor_setup->low_neighbour[k]])) { 529 (floor_setup->data.t1.x_list[j]>floor_setup->data.t1.x_list[floor_setup->data.t1.low_neighbour[k]])) {
514 floor_setup->low_neighbour[k]=j; 530 floor_setup->data.t1.low_neighbour[k]=j;
515 } 531 }
516 if ((floor_setup->x_list[j]>floor_setup->x_list[k]) && 532 if ((floor_setup->data.t1.x_list[j]>floor_setup->data.t1.x_list[k]) &&
517 (floor_setup->x_list[j]<floor_setup->x_list[floor_setup->high_neighbour[k]])) { 533 (floor_setup->data.t1.x_list[j]<floor_setup->data.t1.x_list[floor_setup->data.t1.high_neighbour[k]])) {
518 floor_setup->high_neighbour[k]=j; 534 floor_setup->data.t1.high_neighbour[k]=j;
519 } 535 }
520 } 536 }
521 } 537 }
522 } 538 }
539 else if(floor_setup->floor_type==0) {
540 uint_fast8_t max_codebook_dim=0;
541
542 floor_setup->decode=vorbis_floor0_decode;
543
544 floor_setup->data.t0.order=get_bits(gb, 8);
545 floor_setup->data.t0.rate=get_bits(gb, 16);
546 floor_setup->data.t0.bark_map_size=get_bits(gb, 16);
547 floor_setup->data.t0.amplitude_bits=get_bits(gb, 6);
548 floor_setup->data.t0.amplitude_offset=get_bits(gb, 8);
549 floor_setup->data.t0.num_books=get_bits(gb, 4)+1;
550
551 /* allocate mem for booklist */
552 floor_setup->data.t0.book_list=
553 av_malloc(floor_setup->data.t0.num_books);
554 if(!floor_setup->data.t0.book_list) { return 1; }
555 /* read book indexes */
556 {
557 int idx;
558 uint_fast8_t book_idx;
559 for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {
560 book_idx=get_bits(gb, 8);
561 floor_setup->data.t0.book_list[idx]=book_idx;
562 if (vc->codebooks[book_idx].dimensions > max_codebook_dim)
563 max_codebook_dim=vc->codebooks[book_idx].dimensions;
564
565 if (floor_setup->data.t0.book_list[idx]>vc->codebook_count)
566 return 1;
567 }
568 }
569
570 /* allocate mem for lsp coefficients */
571 {
572 /* codebook dim is for padding if codebook dim doesn't *
573 * divide order+1 then we need to read more data */
574 floor_setup->data.t0.lsp=
575 av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim)
576 * sizeof(float));
577 if(!floor_setup->data.t0.book_list) { return 1; }
578 }
579
580 #ifdef V_DEBUG /* debug output parsed headers */
581 AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order);
582 AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate);
583 AV_DEBUG("floor0 bark map size: %u\n",
584 floor_setup->data.t0.bark_map_size);
585 AV_DEBUG("floor0 amplitude bits: %u\n",
586 floor_setup->data.t0.amplitude_bits);
587 AV_DEBUG("floor0 amplitude offset: %u\n",
588 floor_setup->data.t0.amplitude_offset);
589 AV_DEBUG("floor0 number of books: %u\n",
590 floor_setup->data.t0.num_books);
591 AV_DEBUG("floor0 book list pointer: %p\n",
592 floor_setup->data.t0.book_list);
593 {
594 int idx;
595 for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {
596 AV_DEBUG( " Book %d: %u\n",
597 idx+1,
598 floor_setup->data.t0.book_list[idx] );
599 }
600 }
601 #endif
602 }
523 else { 603 else {
524 av_log(vc->avccontext, AV_LOG_ERROR, "Only floor type 1 supported. \n"); 604 av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n");
525 return 1; 605 return 1;
526 } 606 }
527 } 607 }
528 return 0; 608 return 0;
529 } 609 }
651 return 0; 731 return 0;
652 } 732 }
653 733
654 // Process modes part 734 // Process modes part
655 735
736 static void create_map( vorbis_context * vc, uint_fast8_t mode_number )
737 {
738 vorbis_floor * floors=vc->floors;
739 vorbis_floor0 * vf;
740 int idx;
741 int_fast32_t * map;
742 int_fast32_t n; //TODO: could theoretically be smaller?
743
744 n=(vc->modes[mode_number].blockflag ?
745 vc->blocksize_1 : vc->blocksize_0) / 2;
746 floors[mode_number].data.t0.map=
747 av_malloc((n+1) * sizeof(int_fast32_t)); // n+sentinel
748
749 map=floors[mode_number].data.t0.map;
750 vf=&floors[mode_number].data.t0;
751
752 for (idx=0; idx<n;++idx) {
753 map[idx]=floor( BARK((vf->rate*idx)/(2.0f*n)) *
754 ((vf->bark_map_size)/
755 BARK(vf->rate/2.0f )) );
756 if (vf->bark_map_size-1 < map[idx]) {
757 map[idx]=vf->bark_map_size-1;
758 }
759 }
760 map[n]=-1;
761 vf->map_size=n;
762
763 # ifdef V_DEBUG
764 for(idx=0;idx<=n;++idx) {
765 AV_DEBUG("floor0 map: map at pos %d is %d\n",
766 idx, map[idx]);
767 }
768 # endif
769 }
770
656 static int vorbis_parse_setup_hdr_modes(vorbis_context *vc) { 771 static int vorbis_parse_setup_hdr_modes(vorbis_context *vc) {
657 GetBitContext *gb=&vc->gb; 772 GetBitContext *gb=&vc->gb;
658 uint_fast8_t i; 773 uint_fast8_t i;
659 774
660 vc->mode_count=get_bits(gb, 6)+1; 775 vc->mode_count=get_bits(gb, 6)+1;
669 mode_setup->windowtype=get_bits(gb, 16); //FIXME check 784 mode_setup->windowtype=get_bits(gb, 16); //FIXME check
670 mode_setup->transformtype=get_bits(gb, 16); //FIXME check 785 mode_setup->transformtype=get_bits(gb, 16); //FIXME check
671 mode_setup->mapping=get_bits(gb, 8); //FIXME check 786 mode_setup->mapping=get_bits(gb, 8); //FIXME check
672 787
673 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); 788 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);
789
790 if (vc->floors[i].floor_type == 0) { create_map( vc, i ); }
674 } 791 }
675 return 0; 792 return 0;
676 } 793 }
677 794
678 // Process the whole setup header using the functions above 795 // Process the whole setup header using the functions above
857 return 0 ; 974 return 0 ;
858 } 975 }
859 976
860 // Decode audiopackets ------------------------------------------------- 977 // Decode audiopackets -------------------------------------------------
861 978
862 // Read and decode floor (type 1 only) 979 // Read and decode floor
863 980
864 static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor *vf, float *vec) { 981 static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
982 vorbis_floor_data *vfu, float *vec) {
983 vorbis_floor0 * vf=&vfu->t0;
984 float * lsp=vf->lsp;
985 uint_fast32_t amplitude;
986 uint_fast32_t book_idx;
987
988 amplitude=get_bits(&vc->gb, vf->amplitude_bits);
989 if (amplitude>0) {
990 float last = 0;
991 uint_fast16_t lsp_len = 0;
992 uint_fast16_t idx;
993 vorbis_codebook codebook;
994
995 book_idx=get_bits(&vc->gb, ilog(vf->num_books));
996 if ( book_idx >= vf->num_books ) {
997 av_log( vc->avccontext, AV_LOG_ERROR,
998 "floor0 dec: booknumber too high!\n" );
999 //FIXME: look above
1000 }
1001 AV_DEBUG( "floor0 dec: booknumber: %u\n", book_idx );
1002 codebook=vc->codebooks[vf->book_list[book_idx]];
1003
1004 while (lsp_len<vf->order) {
1005 int vec_off;
1006
1007 AV_DEBUG( "floor0 dec: book dimension: %d\n", codebook.dimensions );
1008 AV_DEBUG( "floor0 dec: maximum depth: %d\n", codebook.maxdepth );
1009 /* read temp vector */
1010 vec_off=get_vlc2(&vc->gb,
1011 codebook.vlc.table,
1012 codebook.nb_bits,
1013 codebook.maxdepth ) *
1014 codebook.dimensions;
1015 AV_DEBUG( "floor0 dec: vector offset: %d\n", vec_off );
1016 /* copy each vector component and add last to it */
1017 for (idx=0; idx<codebook.dimensions; ++idx) {
1018 lsp[lsp_len+idx]=codebook.codevectors[vec_off+idx]+last;
1019 }
1020 last=lsp[lsp_len+idx-1]; /* set last to last vector component */
1021
1022 lsp_len += codebook.dimensions;
1023 }
1024 #ifdef V_DEBUG
1025 /* DEBUG: output lsp coeffs */
1026 {
1027 int idx;
1028 for ( idx = 0; idx < lsp_len; ++idx )
1029 AV_DEBUG("floor0 dec: coeff at %d is %f\n", idx, lsp[idx] );
1030 }
1031 #endif
1032
1033 /* synthesize floor output vector */
1034 {
1035 int i;
1036 int order=vf->order;
1037 float wstep=M_PI/vf->bark_map_size;
1038
1039 for(i=0;i<order;i++) { lsp[i]=2.0f*cos(lsp[i]); }
1040
1041 AV_DEBUG("floor0 synth: map_size=%d; m=%d; wstep=%f\n",
1042 vf->map_size, order, wstep);
1043
1044 i=0;
1045 while(i<vf->map_size) {
1046 int j, iter_cond=vf->map[i];
1047 float p=0.5f;
1048 float q=0.5f;
1049 float two_cos_w=2.0f*cos(wstep*iter_cond); // needed all times
1050
1051 /* similar part for the q and p products */
1052 for(j=0;j<order;j+=2) {
1053 q *= lsp[j] -two_cos_w;
1054 p *= lsp[j+1]-two_cos_w;
1055 }
1056 if(j==order) { // even order
1057 p *= p*(2.0f-two_cos_w);
1058 q *= q*(2.0f+two_cos_w);
1059 }
1060 else { // odd order
1061 q *= two_cos_w-lsp[j]; // one more time for q
1062
1063 /* final step and square */
1064 p *= p*(4.f-two_cos_w*two_cos_w);
1065 q *= q;
1066 }
1067
1068 /* calculate linear floor value */
1069 {
1070 int_fast32_t pow_of_two=2, exponent=vf->amplitude_bits;
1071 if ( vf->amplitude_bits ) {
1072 while ( --exponent ) { pow_of_two <<= 1; }
1073 }
1074 else { pow_of_two=1; }
1075 q=exp( (
1076 ( (amplitude*vf->amplitude_offset)/
1077 ((pow_of_two-1) * sqrt(p+q)) )
1078 - vf->amplitude_offset ) * .11512925f
1079 );
1080 }
1081
1082 /* fill vector */
1083 do { vec[i]=q; ++i; }while(vf->map[i]==iter_cond);
1084 }
1085 }
1086 }
1087 else {
1088 /* this channel is unused */
1089 return 1;
1090 }
1091
1092 AV_DEBUG(" Floor0 decoded\n");
1093
1094 return 0;
1095 }
1096 static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) {
1097 vorbis_floor1 * vf=&vfu->t1;
865 GetBitContext *gb=&vc->gb; 1098 GetBitContext *gb=&vc->gb;
866 uint_fast16_t range_v[4]={ 256, 128, 86, 64 }; 1099 uint_fast16_t range_v[4]={ 256, 128, 86, 64 };
867 uint_fast16_t range=range_v[vf->multiplier-1]; 1100 uint_fast16_t range=range_v[vf->multiplier-1];
868 uint_fast16_t floor1_Y[vf->x_list_dim]; 1101 uint_fast16_t floor1_Y[vf->x_list_dim];
869 uint_fast16_t floor1_Y_final[vf->x_list_dim]; 1102 uint_fast16_t floor1_Y_final[vf->x_list_dim];
1232 1465
1233 blocksize=vc->modes[mode_number].blockflag ? vc->blocksize_1 : vc->blocksize_0; 1466 blocksize=vc->modes[mode_number].blockflag ? vc->blocksize_1 : vc->blocksize_0;
1234 memset(ch_res_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ? 1467 memset(ch_res_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ?
1235 memset(ch_floor_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ? 1468 memset(ch_floor_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ?
1236 1469
1237 // Decode floor(1) 1470 // Decode floor
1238 1471
1239 for(i=0;i<vc->audio_channels;++i) { 1472 for(i=0;i<vc->audio_channels;++i) {
1240 vorbis_floor *floor; 1473 vorbis_floor *floor;
1241 if (mapping->submaps>1) { 1474 if (mapping->submaps>1) {
1242 floor=&vc->floors[mapping->submap_floor[mapping->mux[i]]]; 1475 floor=&vc->floors[mapping->submap_floor[mapping->mux[i]]];
1243 } else { 1476 } else {
1244 floor=&vc->floors[mapping->submap_floor[0]]; 1477 floor=&vc->floors[mapping->submap_floor[0]];
1245 } 1478 }
1246 1479
1247 no_residue[i]=vorbis_floor1_decode(vc, floor, ch_floor_ptr); 1480 no_residue[i]=floor->decode(vc, &floor->data, ch_floor_ptr);
1248 ch_floor_ptr+=blocksize/2; 1481 ch_floor_ptr+=blocksize/2;
1249 } 1482 }
1250 1483
1251 // Nonzero vector propagate 1484 // Nonzero vector propagate
1252 1485