[FFmpeg-cvslog] r18621 - in trunk: ffmpeg.c libavcodec/audioconvert.c libavcodec/audioconvert.h
jbr
subversion
Sun Apr 19 16:05:55 CEST 2009
Author: jbr
Date: Sun Apr 19 16:05:55 2009
New Revision: 18621
Log:
Check that channel layout is compatible with number of channels for
output audio stream.
Modified:
trunk/ffmpeg.c
trunk/libavcodec/audioconvert.c
trunk/libavcodec/audioconvert.h
Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c Sun Apr 19 15:29:11 2009 (r18620)
+++ trunk/ffmpeg.c Sun Apr 19 16:05:55 2009 (r18621)
@@ -3212,6 +3212,8 @@ static void new_audio_stream(AVFormatCon
audio_enc->channels = audio_channels;
audio_enc->sample_fmt = audio_sample_fmt;
audio_enc->channel_layout = channel_layout;
+ if (avcodec_channel_layout_num_channels(channel_layout) != audio_channels)
+ audio_enc->channel_layout = 0;
if(codec && codec->sample_fmts){
const enum SampleFormat *p= codec->sample_fmts;
Modified: trunk/libavcodec/audioconvert.c
==============================================================================
--- trunk/libavcodec/audioconvert.c Sun Apr 19 15:29:11 2009 (r18620)
+++ trunk/libavcodec/audioconvert.c Sun Apr 19 16:05:55 2009 (r18621)
@@ -153,6 +153,15 @@ void avcodec_get_channel_layout_string(c
}
}
+int avcodec_channel_layout_num_channels(int64_t channel_layout)
+{
+ int count;
+ uint64_t x = channel_layout;
+ for (count = 0; x; count++)
+ x &= x-1; // unset lowest set bit
+ return count;
+}
+
struct AVAudioConvert {
int in_channels, out_channels;
int fmt_pair;
Modified: trunk/libavcodec/audioconvert.h
==============================================================================
--- trunk/libavcodec/audioconvert.h Sun Apr 19 15:29:11 2009 (r18620)
+++ trunk/libavcodec/audioconvert.h Sun Apr 19 16:05:55 2009 (r18621)
@@ -73,6 +73,10 @@ void avcodec_get_channel_layout_string(c
*/
int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
+/**
+ * @return the number of channels in the channel layout.
+ */
+int avcodec_channel_layout_num_channels(int64_t channel_layout);
struct AVAudioConvert;
typedef struct AVAudioConvert AVAudioConvert;
More information about the ffmpeg-cvslog
mailing list