[Ffmpeg-cvslog] CVS: ffmpeg/libavformat mov.c,1.126,1.127

Baptiste Coudurier CVS bcoudurier
Tue Mar 14 01:25:49 CET 2006


Update of /cvsroot/ffmpeg/ffmpeg/libavformat
In directory mail:/var2/tmp/cvs-serv26429/libavformat

Modified Files:
	mov.c 
Log Message:
fix sample size for uncompressed sound

Index: mov.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/mov.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- mov.c	12 Mar 2006 23:55:34 -0000	1.126
+++ mov.c	14 Mar 2006 00:25:46 -0000	1.127
@@ -1196,8 +1196,33 @@
 #ifdef DEBUG
     av_log(NULL, AV_LOG_DEBUG, "sample_size = %ld sample_count = %ld\n", sc->sample_size, sc->sample_count);
 #endif
-    if(sc->sample_size)
+    if(sc->sample_size) {
+        /* override sample size for uncompressed sound */
+        switch (st->codec->codec_id) {
+        case CODEC_ID_PCM_S32BE:
+        case CODEC_ID_PCM_S32LE:
+            sc->sample_size = 4 * st->codec->channels;
+            break;
+        case CODEC_ID_PCM_S24BE:
+        case CODEC_ID_PCM_S24LE:
+            sc->sample_size = 3 * st->codec->channels;
+            break;
+        case CODEC_ID_PCM_S16BE:
+        case CODEC_ID_PCM_S16LE:
+            sc->sample_size = 2 * st->codec->channels;
+            break;
+        case CODEC_ID_PCM_MULAW:
+        case CODEC_ID_PCM_ALAW:
+        case CODEC_ID_PCM_S8:
+        case CODEC_ID_PCM_U8:
+            sc->sample_size = 1 * st->codec->channels;
+            break;
+        default:
+            break;
+        }
+        assert(sc->sample_size);
         return 0; /* there isn't any table following */
+    }
     sc->sample_sizes = (long*) av_malloc(entries * sizeof(long));
     if (!sc->sample_sizes)
         return -1;
@@ -1768,13 +1793,7 @@
         for(i=0; i<(sc->sample_to_chunk_sz); i++) {
             if( (sc->sample_to_chunk[i].first)<=(sc->next_chunk) )
             {
-                // I can't figure out why for PCM audio sample_size is always 1
-                // (it should actually be channels*bits_per_second/8) but it is.
-                AVCodecContext* cod = s->streams[sc->ffindex]->codec;
-                if (sc->sample_size == 1 && (cod->codec_id == CODEC_ID_PCM_S16BE || cod->codec_id == CODEC_ID_PCM_S16LE))
-                    foundsize=(sc->sample_to_chunk[i].count*cod->channels*cod->bits_per_sample)/8;
-                else
-                    foundsize=sc->sample_to_chunk[i].count*sc->sample_size;
+                foundsize=sc->sample_to_chunk[i].count*sc->sample_size;
             }
             dprintf("sample_to_chunk first=%ld count=%ld, id=%ld\n", sc->sample_to_chunk[i].first, sc->sample_to_chunk[i].count, sc->sample_to_chunk[i].id);
         }





More information about the ffmpeg-cvslog mailing list