Changeset 03f2c9e9a08a765667d872d9d5ecae85b64d3726
- Timestamp:
- 30/09/04 19:42:27 (4 years ago)
- git-parent:
- Files:
-
- modules/audio_filter/converter/a52tofloat32.c (modified) (7 diffs)
- modules/audio_filter/converter/dtstofloat32.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/audio_filter/converter/a52tofloat32.c
rb28de53 r03f2c9e 66 66 static block_t *Convert( filter_t *, block_t * ); 67 67 68 /* liba52 channel order */ 69 static const uint32_t pi_channels_in[] = 70 { AOUT_CHAN_LFE, AOUT_CHAN_LEFT, AOUT_CHAN_CENTER, AOUT_CHAN_RIGHT, 71 AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, 0 }; 72 /* our internal channel order (WG-4 order) */ 73 static const uint32_t pi_channels_out[] = 74 { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT, AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, 75 AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 }; 76 68 77 /***************************************************************************** 69 78 * Local structures … … 76 85 vlc_bool_t b_dontwarn; 77 86 int i_nb_channels; /* number of float32 per sample */ 87 88 int pi_chan_table[AOUT_CHAN_MAX]; /* channel reordering */ 78 89 }; 79 90 … … 143 154 *****************************************************************************/ 144 155 static int Open( vlc_object_t *p_this, filter_sys_t *p_sys, 145 audio_format_t input, audio_format_t output )156 audio_format_t input, audio_format_t output ) 146 157 { 147 158 p_sys->b_dynrng = config_GetInt( p_this, "a52-dynrng" ); … … 240 251 } 241 252 253 aout_CheckChannelReorder( pi_channels_in, pi_channels_out, 254 output.i_physical_channels & AOUT_CHAN_PHYSMASK, 255 p_sys->i_nb_channels, 256 p_sys->pi_chan_table ); 257 242 258 return VLC_SUCCESS; 243 259 } … … 246 262 * Interleave: helper function to interleave channels 247 263 *****************************************************************************/ 248 static void Interleave( float * p_out, const float * p_in, int i_nb_channels ) 249 { 250 /* We do not only have to interleave, but also reorder the channels 251 * Channel reordering according to number of output channels of libA52 252 * The reordering needs to be different for different channel configurations 253 * (3F2R, 1F2R etc), so this is only temporary. 254 * The WG-4 order is appropriate for stereo, quadrophonia, and 5.1 surround. 255 * 256 * 6 channel mode 257 * channel liba52 order WG-4 order 258 * 0 LFE // L 259 * 1 L // R 260 * 2 C // LS 261 * 3 R // RS 262 * 4 LS // C 263 * 5 RS // LFE 264 * 265 * The liba52 moves channels to the front if there are unused spaces, so 266 * there is no gap between channels. The translation table says which 267 * channel of the new stream is taken from which original channel [use 268 * the new channel as the array index, use the number you get from the 269 * array to address the original channel]. 270 */ 271 272 static const int translation[7][6] = 273 {{ 0, 0, 0, 0, 0, 0 }, /* 0 channels (rarely used) */ 274 { 0, 0, 0, 0, 0, 0 }, /* 1 ch */ 275 { 0, 1, 0, 0, 0, 0 }, /* 2 */ 276 { 1, 2, 0, 0, 0, 0 }, /* 3 */ 277 { 1, 3, 2, 0, 0, 0 }, /* 4 */ 278 { 1, 3, 4, 2, 0, 0 }, /* 5 */ 279 { 1, 3, 4, 5, 2, 0 }}; /* 6 */ 264 static void Interleave( float * p_out, const float * p_in, int i_nb_channels, 265 int *pi_chan_table ) 266 { 267 /* We do not only have to interleave, but also reorder the channels */ 280 268 281 269 int i, j; … … 284 272 for ( i = 0; i < 256; i++ ) 285 273 { 286 p_out[i * i_nb_channels + j] = p_in[translation[i_nb_channels][j] 287 * 256 + i]; 274 p_out[i * i_nb_channels + pi_chan_table[j]] = p_in[j * 256 + i]; 288 275 } 289 276 } … … 384 371 /* Interleave the *$�%�ples. */ 385 372 Interleave( (float *)(p_out_buf->p_buffer + i * i_bytes_per_block), 386 p_samples, p_sys->i_nb_channels );373 p_samples, p_sys->i_nb_channels, p_sys->pi_chan_table); 387 374 } 388 375 } modules/audio_filter/converter/dtstofloat32.c
rb28de53 r03f2c9e 53 53 static block_t *Convert( filter_t *, block_t * ); 54 54 55 /* libdts channel order */ 56 static const uint32_t pi_channels_in[] = 57 { AOUT_CHAN_CENTER, AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT, 58 AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, AOUT_CHAN_LFE, 0 }; 59 /* our internal channel order (WG-4 order) */ 60 static const uint32_t pi_channels_out[] = 61 { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT, AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, 62 AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 }; 63 55 64 /***************************************************************************** 56 65 * Local structures … … 63 72 vlc_bool_t b_dontwarn; 64 73 int i_nb_channels; /* number of float32 per sample */ 74 75 int pi_chan_table[AOUT_CHAN_MAX]; /* channel reordering */ 65 76 }; 66 77 … … 210 221 } 211 222 223 aout_CheckChannelReorder( pi_channels_in, pi_channels_out, 224 output.i_physical_channels & AOUT_CHAN_PHYSMASK, 225 p_sys->i_nb_channels, 226 p_sys->pi_chan_table ); 227 212 228 return VLC_SUCCESS; 213 229 } … … 216 232 * Interleave: helper function to interleave channels 217 233 *****************************************************************************/ 218 static void Interleave( float * p_out, const float * p_in, int i_nb_channels ) 219 { 220 /* We do not only have to interleave, but also reorder the channels 221 * Channel reordering according to number of output channels of libdts 222 * The reordering needs to be different for different channel configurations 223 * (3F2R, 1F2R etc), so this is only temporary. 224 * The WG-4 order is appropriate for stereo, quadrophonia, and 5.1 surround. 225 * 226 * 6 channel mode 227 * channel libdts order WG-4 order 228 * 0 C // L 229 * 1 L // R 230 * 2 R // LS 231 * 3 LS // RS 232 * 4 RS // C 233 * 5 LFE // LFE 234 * 235 * The libdts moves channels to the front if there are unused spaces, so 236 * there is no gap between channels. The translation table says which 237 * channel of the new stream is taken from which original channel [use 238 * the new channel as the array index, use the number you get from the 239 * array to address the original channel]. 240 */ 241 242 static const int translation[7][6] = 243 {{ 0, 0, 0, 0, 0, 0 }, /* 0 channels (rarely used) */ 244 { 0, 0, 0, 0, 0, 0 }, /* 1 ch */ 245 { 0, 1, 0, 0, 0, 0 }, /* 2 */ 246 { 1, 2, 0, 0, 0, 0 }, /* 3 */ 247 { 0, 1, 2, 3, 0, 0 }, /* 4 */ 248 { 1, 2, 3, 4, 0, 0 }, /* 5 */ 249 { 1, 2, 3, 4, 0, 5 }}; /* 6 */ 234 static void Interleave( float * p_out, const float * p_in, int i_nb_channels, 235 int *pi_chan_table ) 236 { 237 /* We do not only have to interleave, but also reorder the channels. */ 250 238 251 239 int i, j; … … 254 242 for ( i = 0; i < 256; i++ ) 255 243 { 256 p_out[i * i_nb_channels + j] = p_in[translation[i_nb_channels][j] 257 * 256 + i]; 244 p_out[i * i_nb_channels + pi_chan_table[j]] = p_in[j * 256 + i]; 258 245 } 259 246 } … … 368 355 /* Interleave the *$�%�ples. */ 369 356 Interleave( (float *)(p_out_buf->p_buffer + i * i_bytes_per_block), 370 p_samples, p_sys->i_nb_channels );357 p_samples, p_sys->i_nb_channels, p_sys->pi_chan_table); 371 358 } 372 359 }
