1 #include <unistd.h> /* getpid() */
3 #include <stdio.h> /* "intf_msg.h" */
4 #include <stdlib.h> /* malloc(), free() */
5 #include <sys/soundcard.h> /* "audio_output.h" */
7 #include <sys/uio.h> /* "input.h" */
12 #include "vlc_thread.h"
13 #include "debug.h" /* "input_netlist.h" */
15 #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
17 #include "input.h" /* pes_packet_t */
18 #include "input_netlist.h" /* input_NetlistFreePES() */
19 #include "decoder_fifo.h" /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
21 #include "audio_output.h"
23 #include "ac3_decoder.h"
24 #include "ac3_parse.h"
25 #include "ac3_exponent.h"
26 #include "ac3_bit_allocate.h"
27 #include "ac3_mantissa.h"
28 #include "ac3_rematrix.h"
30 struct rematrix_band_s
36 static struct rematrix_band_s rematrix_band[] = { {13,24}, {25,36}, {37 ,60}, {61,252}};
38 static __inline__ u32 min( u32 a, u32 b )
40 return( a < b ? a : b );
43 /* This routine simply does stereo rematixing for the 2 channel
45 void rematrix( ac3dec_t * p_ac3dec )
53 if(p_ac3dec->audblk.cplinu || p_ac3dec->audblk.cplbegf > 2)
55 else if (p_ac3dec->audblk.cplbegf > 0)
60 for(i=0;i < num_bands; i++)
62 if(!p_ac3dec->audblk.rematflg[i])
65 start = rematrix_band[i].start;
66 end = min(rematrix_band[i].end ,12 * p_ac3dec->audblk.cplbegf + 36);
68 for(j=start;j < end; j++)
70 left = 0.5f * (p_ac3dec->coeffs.fbw[0][j] + p_ac3dec->coeffs.fbw[1][j]);
71 right = 0.5f * (p_ac3dec->coeffs.fbw[0][j] - p_ac3dec->coeffs.fbw[1][j]);
72 p_ac3dec->coeffs.fbw[0][j] = left;
73 p_ac3dec->coeffs.fbw[1][j] = right;