[FFmpeg-cvslog] get_audio_buffer: fix usage where channels are not set but layout is

Michael Niedermayer git at videolan.org
Wed Nov 27 11:45:15 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Nov 27 10:52:26 2013 +0100| [60b099c37100d94e114cefefdd101af831287b9f] | committer: Michael Niedermayer

get_audio_buffer: fix usage where channels are not set but layout is

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=60b099c37100d94e114cefefdd101af831287b9f
---

 libavutil/frame.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 39e2a13..62a4a6d 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -183,11 +183,17 @@ fail:
 
 static int get_audio_buffer(AVFrame *frame, int align)
 {
-    int channels = frame->channels;
+    int channels;
     int planar   = av_sample_fmt_is_planar(frame->format);
-    int planes   = planar ? channels : 1;
+    int planes;
     int ret, i;
 
+    if (!frame->channels)
+        frame->channels = av_get_channel_layout_nb_channels(frame->channel_layout);
+
+    channels = frame->channels;
+    planes = planar ? channels : 1;
+
     CHECK_CHANNELS_CONSISTENCY(frame);
     if (!frame->linesize[0]) {
         ret = av_samples_get_buffer_size(&frame->linesize[0], channels,



More information about the ffmpeg-cvslog mailing list