changeset 12281:e6f6dac5d77b

needed for a/v sync with compressed audio (e.g. raw .mp2 or .ac3 file)
author rfelker
date Mon, 26 Apr 2004 03:11:08 +0000
parents f5cb1afdff53
children 76dc8fd54dec
files libmpdemux/demux_rawaudio.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_rawaudio.c	Sun Apr 25 22:43:03 2004 +0000
+++ b/libmpdemux/demux_rawaudio.c	Mon Apr 26 03:11:08 2004 +0000
@@ -17,6 +17,7 @@
 static int channels = 2;
 static int samplerate = 44100;
 static int samplesize = 2;
+static int bitrate = 0;
 static int format = 0x1; // Raw PCM
 
 m_option_t demux_rawaudio_opts[] = {
@@ -24,6 +25,7 @@
   { "channels", &channels, CONF_TYPE_INT,CONF_RANGE,1,8, NULL },
   { "rate", &samplerate, CONF_TYPE_INT,CONF_RANGE,1000,8*48000, NULL },
   { "samplesize", &samplesize, CONF_TYPE_INT,CONF_RANGE,1,8, NULL },
+  { "bitrate", &bitrate, CONF_TYPE_INT,CONF_MIN,0,0, NULL },
   { "format", &format, CONF_TYPE_INT, CONF_MIN, 0 , 0, NULL },
   {NULL, NULL, 0, 0, 0, 0, NULL}
 };
@@ -40,7 +42,12 @@
   w->wFormatTag = sh_audio->format = format;
   w->nChannels = sh_audio->channels = channels;
   w->nSamplesPerSec = sh_audio->samplerate = samplerate;
-  w->nAvgBytesPerSec = samplerate*samplesize*channels;
+  if (bitrate > 999)
+    w->nAvgBytesPerSec = bitrate/8;
+  else if (bitrate > 0)
+    w->nAvgBytesPerSec = bitrate*125;
+  else
+    w->nAvgBytesPerSec = samplerate*samplesize*channels;
   w->nBlockAlign = channels*samplesize;
   sh_audio->samplesize = samplesize;
   w->wBitsPerSample = 8*samplesize;