changeset 3354:c68f5da1c61c

Using CBR stream format for CBR mp3 audio
author arpi
date Thu, 06 Dec 2001 21:50:35 +0000
parents 7894c75f66ce
children dd4d09be63c8
files mencoder.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mencoder.c	Thu Dec 06 19:14:05 2001 +0000
+++ b/mencoder.c	Thu Dec 06 21:50:35 2001 +0000
@@ -705,7 +705,7 @@
 	if(len<=0) break; // EOF?
 	aviwrite_write_chunk(muxer,mux_a,muxer_f,len,0);
 	if(!mux_a->h.dwSampleSize && mux_a->timer>0)
-	    mux_a->wf->nAvgBytesPerSec=mux_a->size/mux_a->timer; // avg bps (VBR)
+	    mux_a->wf->nAvgBytesPerSec=0.5f+(double)mux_a->size/mux_a->timer; // avg bps (VBR)
 	if(mux_a->buffer_len>=len){
 	    mux_a->buffer_len-=len;
 	    memcpy(mux_a->buffer,mux_a->buffer+len,mux_a->buffer_len);
@@ -856,6 +856,15 @@
 
 } // while(!eof)
 
+// fixup CBR audio header:
+if(sh_audio && mux_a->codec==ACODEC_VBRMP3 && !lame_param_vbr){
+    mux_a->h.dwSampleSize=1;
+    mux_a->h.dwRate=mux_a->wf->nAvgBytesPerSec;
+    mux_a->h.dwScale=1;
+    printf("\n\nCBR audio effective bitrate: %8.3f kbit/s  (%d bytes/sec)\n",
+	    mux_a->h.dwRate*8.0f/1000.0f,mux_a->h.dwRate);
+}
+
 printf("\nWriting AVI index...\n");
 aviwrite_write_index(muxer,muxer_f);
 printf("Fixup AVI header...\n");