Revision 8b60bbbf libavcodec/ac3dec.c
libavcodec/ac3dec.c  

38  38 
#include "dsputil.h" 
39  39 
#include "random.h" 
40  40  
41 
/** 

42 
* Table of bin locations for rematrixing bands 

43 
* reference: Section 7.5.2 Rematrixing : Frequency Band Definitions 

44 
*/ 

45 
static const uint8_t rematrix_band_tbl[5] = { 13, 25, 37, 61, 253 }; 

46  
41  47 
/* table for exponent to scale_factor mapping 
42  48 
* scale_factor[i] = 2 ^ (i + 15) 
43  49 
*/ 
...  ...  
92  98 
int cplcoe; 
93  99 
uint32_t cplbndstrc; 
94  100 
int rematstr; 
101 
int nrematbnd; 

95  102 
int rematflg[AC3_MAX_CHANNELS]; 
96  103 
int cplexpstr; 
97  104 
int lfeexpstr; 
...  ...  
648  655 
return 0; 
649  656 
} 
650  657  
651 
/* Rematrixing routines. */ 

652 
static void do_rematrixing1(AC3DecodeContext *ctx, int start, int end) 

653 
{ 

654 
float tmp0, tmp1; 

655  
656 
while (start < end) { 

657 
tmp0 = ctx>transform_coeffs[1][start]; 

658 
tmp1 = ctx>transform_coeffs[2][start]; 

659 
ctx>transform_coeffs[1][start] = tmp0 + tmp1; 

660 
ctx>transform_coeffs[2][start] = tmp0  tmp1; 

661 
start++; 

662 
} 

663 
} 

664  
658 
/** 

659 
* Performs stereo rematrixing. 

660 
* reference: Section 7.5.4 Rematrixing : Decoding Technique 

661 
*/ 

665  662 
static void do_rematrixing(AC3DecodeContext *ctx) 
666  663 
{ 
667 
int bnd1 = 13, bnd2 = 25, bnd3 = 37, bnd4 = 61;


664 
int bnd, i;


668  665 
int end, bndend; 
666 
float tmp0, tmp1; 

669  667  
670  668 
end = FFMIN(ctx>endmant[0], ctx>endmant[1]); 
671  669  
672 
if (ctx>rematflg[0]) 

673 
do_rematrixing1(ctx, bnd1, bnd2); 

674  
675 
if (ctx>rematflg[1]) 

676 
do_rematrixing1(ctx, bnd2, bnd3); 

677  
678 
bndend = bnd4; 

679 
if (bndend > end) { 

680 
bndend = end; 

681 
if (ctx>rematflg[2]) 

682 
do_rematrixing1(ctx, bnd3, bndend); 

683 
} else { 

684 
if (ctx>rematflg[2]) 

685 
do_rematrixing1(ctx, bnd3, bnd4); 

686 
if (ctx>rematflg[3]) 

687 
do_rematrixing1(ctx, bnd4, end); 

670 
for(bnd=0; bnd<ctx>nrematbnd; bnd++) { 

671 
if(ctx>rematflg[bnd]) { 

672 
bndend = FFMIN(end, rematrix_band_tbl[bnd+1]); 

673 
for(i=rematrix_band_tbl[bnd]; i<bndend; i++) { 

674 
tmp0 = ctx>transform_coeffs[1][i]; 

675 
tmp1 = ctx>transform_coeffs[2][i]; 

676 
ctx>transform_coeffs[1][i] = tmp0 + tmp1; 

677 
ctx>transform_coeffs[2][i] = tmp0  tmp1; 

678 
} 

679 
} 

688  680 
} 
689  681 
} 
690  682  
...  ...  
766  758 
{ 
767  759 
int nfchans = ctx>nfchans; 
768  760 
int acmod = ctx>acmod; 
769 
int i, bnd, rbnd, seg, grpsize, ch;


761 
int i, bnd, seg, grpsize, ch; 

770  762 
GetBitContext *gb = &ctx>gb; 
771  763 
int bit_alloc_flags = 0; 
772  764 
int8_t *dexps; 
...  ...  
857  849 
if (acmod == AC3_ACMOD_STEREO) {/* rematrixing */ 
858  850 
ctx>rematstr = get_bits1(gb); 
859  851 
if (ctx>rematstr) { 
860 
if (!(ctx>cplinu)  ctx>cplstrtmant > 61) 

861 
for (rbnd = 0; rbnd < 4; rbnd++) 

862 
ctx>rematflg[rbnd] = get_bits1(gb); 

863 
if (ctx>cplstrtmant > 37 && ctx>cplstrtmant <= 61 && ctx>cplinu) 

864 
for (rbnd = 0; rbnd < 3; rbnd++) 

865 
ctx>rematflg[rbnd] = get_bits1(gb); 

866 
if (ctx>cplstrtmant == 37 && ctx>cplinu) 

867 
for (rbnd = 0; rbnd < 2; rbnd++) 

868 
ctx>rematflg[rbnd] = get_bits1(gb); 

852 
ctx>nrematbnd = 4; 

853 
if(ctx>cplinu && ctx>cplstrtmant <= 61) 

854 
ctx>nrematbnd = 1 + (ctx>cplstrtmant == 37); 

855 
for(bnd=0; bnd<ctx>nrematbnd; bnd++) 

856 
ctx>rematflg[bnd] = get_bits1(gb); 

869  857 
} 
870  858 
} 
871  859 
Also available in: Unified diff