[Ffmpeg-cvslog] r6728 - trunk/libavformat/raw.c

bcoudurier subversion
Wed Oct 18 13:57:24 CEST 2006


Author: bcoudurier
Date: Wed Oct 18 13:57:24 2006
New Revision: 6728

Modified:
   trunk/libavformat/raw.c

Log:
simplify pcm read seek, use av_get_bits_per_sample

Modified: trunk/libavformat/raw.c
==============================================================================
--- trunk/libavformat/raw.c	(original)
+++ trunk/libavformat/raw.c	Wed Oct 18 13:57:24 2006
@@ -183,26 +183,11 @@
     int64_t pos;
 
     st = s->streams[0];
-    switch(st->codec->codec_id) {
-    case CODEC_ID_PCM_S16LE:
-    case CODEC_ID_PCM_S16BE:
-    case CODEC_ID_PCM_U16LE:
-    case CODEC_ID_PCM_U16BE:
-        block_align = 2 * st->codec->channels;
-        byte_rate = block_align * st->codec->sample_rate;
-        break;
-    case CODEC_ID_PCM_S8:
-    case CODEC_ID_PCM_U8:
-    case CODEC_ID_PCM_MULAW:
-    case CODEC_ID_PCM_ALAW:
-        block_align = st->codec->channels;
-        byte_rate = block_align * st->codec->sample_rate;
-        break;
-    default:
-        block_align = st->codec->block_align;
-        byte_rate = st->codec->bit_rate / 8;
-        break;
-    }
+
+    block_align = st->codec->block_align ? st->codec->block_align :
+        (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
+    byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
+        block_align * st->codec->sample_rate;
 
     if (block_align <= 0 || byte_rate <= 0)
         return -1;




More information about the ffmpeg-cvslog mailing list