[xiph-commits] r16253 - trunk/ffmpeg2theora/src

j at svn.xiph.org j at svn.xiph.org
Fri Jul 10 04:29:03 PDT 2009


Author: j
Date: 2009-07-10 04:29:02 -0700 (Fri, 10 Jul 2009)
New Revision: 16253

Modified:
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
Log:
use av_get_bits_per_sample_format to calculate number of samples fixes #1561

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-07-10 08:40:47 UTC (rev 16252)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-07-10 11:29:02 UTC (rev 16253)
@@ -1224,6 +1224,8 @@
                     int samples=0;
                     int samples_out=0;
                     int data_size = 4*AVCODEC_MAX_AUDIO_FRAME_SIZE;
+                    int bytes_per_sample = av_get_bits_per_sample_format(aenc->sample_fmt)/8;
+
                     if (len > 0) {
                         len1 = avcodec_decode_audio2(astream->codec, audio_buf, &data_size, ptr, len);
                         if (len1 < 0) {
@@ -1233,7 +1235,7 @@
                         len -= len1;
                         ptr += len1;
                         if (data_size >0) {
-                            samples = data_size / (aenc->channels * 2);
+                            samples = data_size / (aenc->channels * bytes_per_sample);
                             samples_out = samples;
                             if (this->audio_resample_ctx) {
                                 samples_out = audio_resample(this->audio_resample_ctx, resampled, audio_buf, samples);



More information about the commits mailing list