summaryrefslogtreecommitdiff
path: root/libavcodec/ac3enc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-03-26 02:42:40 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-03-26 03:06:30 +0100
commit27ef7b1bcd0577e3f5bdfc524b42b0548567be20 (patch)
treedbb243f25cf614d4951ce9352c89befb3526ed23 /libavcodec/ac3enc.c
parent0bfe349d4a3e2a98c6f4f02fb03d8585e531d850 (diff)
parenteb81cf860cbb23ece082e6a463a2c6ced8c55ead (diff)
Merge remote-tracking branch 'newdev/master'
* newdev/master: mov: set audio service type for AC-3 from bitstream mode in the 'dac3' atom. Get audio_service_type for AC-3 based on bitstream mode in the AC-3 parser and decoder, and vice-versa for the AC-3 encoder. Use audio_service_type to set stream disposition. Add APIchanges entry for audio_service_type. Add audio_service_type field to AVCodecContext for encoding and reporting of the service type in the audio bitstream. configure: in check_ld, place new -l flags before existing ones support @heading, @subheading, @subsubheading, and @subsubsection in texi2pod.pl doc: update build system documentation aacenc: indentation aacenc: fix the side calculation in search_for_ms vp8.c: rename EDGE_* to VP8_EDGE_*. Conflicts: doc/APIchanges libavcodec/avcodec.h libavcodec/version.h libavcodec/vp8.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r--libavcodec/ac3enc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 72b0291727..f41fd2da61 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1657,6 +1657,18 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
if (s->cutoff > (s->sample_rate >> 1))
s->cutoff = s->sample_rate >> 1;
+ /* validate audio service type / channels combination */
+ if ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_KARAOKE &&
+ avctx->channels == 1) ||
+ ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_COMMENTARY ||
+ avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_EMERGENCY ||
+ avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_VOICE_OVER)
+ && avctx->channels > 1)) {
+ av_log(avctx, AV_LOG_ERROR, "invalid audio service type for the "
+ "specified number of channels\n");
+ return AVERROR(EINVAL);
+ }
+
return 0;
}
@@ -1799,7 +1811,9 @@ static av_cold int ac3_encode_init(AVCodecContext *avctx)
return ret;
s->bitstream_id = 8 + s->bit_alloc.sr_shift;
- s->bitstream_mode = 0; /* complete main audio service */
+ s->bitstream_mode = avctx->audio_service_type;
+ if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE)
+ s->bitstream_mode = 0x7;
s->frame_size_min = 2 * ff_ac3_frame_size_tab[s->frame_size_code][s->bit_alloc.sr_code];
s->bits_written = 0;