comparison dca.c @ 6022:6dd429a5d0be libavcodec

Make DCA decoder honor avctx->request_channels in a more advisory way.
author andoma
date Sat, 15 Dec 2007 07:01:33 +0000
parents ae05d6d12f12
children 99e470e62bad
comparison
equal deleted inserted replaced
6021:90b36c43c4ef 6022:6dd429a5d0be
1157 //set AVCodec values with parsed data 1157 //set AVCodec values with parsed data
1158 avctx->sample_rate = s->sample_rate; 1158 avctx->sample_rate = s->sample_rate;
1159 avctx->bit_rate = s->bit_rate; 1159 avctx->bit_rate = s->bit_rate;
1160 1160
1161 channels = s->prim_channels + !!s->lfe; 1161 channels = s->prim_channels + !!s->lfe;
1162 avctx->channels = avctx->request_channels; 1162 if(avctx->request_channels == 2 && s->prim_channels > 2) {
1163 if(avctx->channels == 0) { 1163 channels = 2;
1164 avctx->channels = channels;
1165 } else if(channels < avctx->channels) {
1166 av_log(avctx, AV_LOG_WARNING, "DTS source channels are less than "
1167 "specified: output to %d channels.\n", channels);
1168 avctx->channels = channels;
1169 }
1170 if(avctx->channels == 2) {
1171 s->output = DCA_STEREO; 1164 s->output = DCA_STEREO;
1172 } else if(avctx->channels != channels) { 1165 }
1173 av_log(avctx, AV_LOG_ERROR, "Cannot downmix DTS to %d channels.\n", 1166
1174 avctx->channels); 1167 avctx->channels = channels;
1175 return -1;
1176 }
1177
1178 channels = avctx->channels;
1179 if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) 1168 if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels)
1180 return -1; 1169 return -1;
1181 *data_size = 0; 1170 *data_size = 0;
1182 for (i = 0; i < (s->sample_blocks / 8); i++) { 1171 for (i = 0; i < (s->sample_blocks / 8); i++) {
1183 dca_decode_block(s); 1172 dca_decode_block(s);