Mercurial > libavcodec.hg
comparison dca.c @ 11908:9b1095b2616a libavcodec
Support DTS-ES extension (XCh) in dca: move subband_samples into context structure
Patch by Nick Brereton, nick at nbrereton dot net
author | mstorsjo |
---|---|
date | Tue, 22 Jun 2010 08:32:01 +0000 |
parents | 771f6e96ea43 |
children | 3bfcb8fd3dc9 |
comparison
equal
deleted
inserted
replaced
11907:defe337cf643 | 11908:9b1095b2616a |
---|---|
43 | 43 |
44 #define DCA_PRIM_CHANNELS_MAX (5) | 44 #define DCA_PRIM_CHANNELS_MAX (5) |
45 #define DCA_SUBBANDS (32) | 45 #define DCA_SUBBANDS (32) |
46 #define DCA_ABITS_MAX (32) /* Should be 28 */ | 46 #define DCA_ABITS_MAX (32) /* Should be 28 */ |
47 #define DCA_SUBSUBFRAMES_MAX (4) | 47 #define DCA_SUBSUBFRAMES_MAX (4) |
48 #define DCA_BLOCKS_MAX (16) | |
48 #define DCA_LFE_MAX (3) | 49 #define DCA_LFE_MAX (3) |
49 | 50 |
50 enum DCAMode { | 51 enum DCAMode { |
51 DCA_MONO = 0, | 52 DCA_MONO = 0, |
52 DCA_CHANNEL, | 53 DCA_CHANNEL, |
235 | 236 |
236 int output; ///< type of output | 237 int output; ///< type of output |
237 float add_bias; ///< output bias | 238 float add_bias; ///< output bias |
238 float scale_bias; ///< output scale | 239 float scale_bias; ///< output scale |
239 | 240 |
241 DECLARE_ALIGNED(16, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]; | |
240 DECLARE_ALIGNED(16, float, samples)[1536]; /* 6 * 256 = 1536, might only need 5 */ | 242 DECLARE_ALIGNED(16, float, samples)[1536]; /* 6 * 256 = 1536, might only need 5 */ |
241 const float *samples_chanptr[6]; | 243 const float *samples_chanptr[6]; |
242 | 244 |
243 uint8_t dca_buffer[DCA_MAX_FRAME_SIZE]; | 245 uint8_t dca_buffer[DCA_MAX_FRAME_SIZE]; |
244 int dca_buffer_size; ///< how much data is in the dca_buffer | 246 int dca_buffer_size; ///< how much data is in the dca_buffer |
905 } | 907 } |
906 | 908 |
907 static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 }; | 909 static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 }; |
908 static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 }; | 910 static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 }; |
909 | 911 |
910 static int dca_subsubframe(DCAContext * s) | 912 static int dca_subsubframe(DCAContext * s, int block_index) |
911 { | 913 { |
912 int k, l; | 914 int k, l; |
913 int subsubframe = s->current_subsubframe; | 915 int subsubframe = s->current_subsubframe; |
914 | 916 |
915 const float *quant_step_table; | 917 const float *quant_step_table; |
916 | 918 |
917 /* FIXME */ | 919 /* FIXME */ |
918 LOCAL_ALIGNED_16(float, subband_samples, [DCA_PRIM_CHANNELS_MAX], [DCA_SUBBANDS][8]); | 920 float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index]; |
919 LOCAL_ALIGNED_16(int, block, [8]); | 921 LOCAL_ALIGNED_16(int, block, [8]); |
920 | 922 |
921 /* | 923 /* |
922 * Audio data | 924 * Audio data |
923 */ | 925 */ |
1105 * Decode a dca frame block | 1107 * Decode a dca frame block |
1106 * | 1108 * |
1107 * @param s pointer to the DCAContext | 1109 * @param s pointer to the DCAContext |
1108 */ | 1110 */ |
1109 | 1111 |
1110 static int dca_decode_block(DCAContext * s) | 1112 static int dca_decode_block(DCAContext * s, int block_index) |
1111 { | 1113 { |
1112 | 1114 |
1113 /* Sanity check */ | 1115 /* Sanity check */ |
1114 if (s->current_subframe >= s->subframes) { | 1116 if (s->current_subframe >= s->subframes) { |
1115 av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i", | 1117 av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i", |
1128 | 1130 |
1129 /* Read subsubframe */ | 1131 /* Read subsubframe */ |
1130 #ifdef TRACE | 1132 #ifdef TRACE |
1131 av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n"); | 1133 av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n"); |
1132 #endif | 1134 #endif |
1133 if (dca_subsubframe(s)) | 1135 if (dca_subsubframe(s, block_index)) |
1134 return -1; | 1136 return -1; |
1135 | 1137 |
1136 /* Update state */ | 1138 /* Update state */ |
1137 s->current_subsubframe++; | 1139 s->current_subsubframe++; |
1138 if (s->current_subsubframe >= s->subsubframes) { | 1140 if (s->current_subsubframe >= s->subsubframes) { |
1261 | 1263 |
1262 if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) | 1264 if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) |
1263 return -1; | 1265 return -1; |
1264 *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels; | 1266 *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels; |
1265 for (i = 0; i < (s->sample_blocks / 8); i++) { | 1267 for (i = 0; i < (s->sample_blocks / 8); i++) { |
1266 dca_decode_block(s); | 1268 dca_decode_block(s, i); |
1267 s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels); | 1269 s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels); |
1268 samples += 256 * channels; | 1270 samples += 256 * channels; |
1269 } | 1271 } |
1270 | 1272 |
1271 return buf_size; | 1273 return buf_size; |