changeset 6861:79f54159ca15

audio preload/density/delay configurable
author arpi
date Thu, 01 Aug 2002 08:39:33 +0000
parents e575f4ee82f1
children fe7095e0adec
files cfg-mencoder.h mencoder.c
diffstat 2 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mencoder.h	Wed Jul 31 20:18:44 2002 +0000
+++ b/cfg-mencoder.h	Thu Aug 01 08:39:33 2002 +0000
@@ -101,6 +101,10 @@
 	{"noskiplimit", &skip_limit, CONF_TYPE_FLAG, 0, 0, -1, NULL},
 	{"noskip", &skip_limit, CONF_TYPE_FLAG, 0, 0, 0, NULL},
 
+	{"audio-density", &audio_density, CONF_TYPE_INT, CONF_RANGE, 1, 50, NULL},
+	{"audio-preload", &audio_preload, CONF_TYPE_FLOAT, CONF_RANGE, 0, 2, NULL},
+	{"audio-delay",   &audio_delay, CONF_TYPE_FLOAT, 0, 0, 0, NULL},
+
 	{"x", "This option is obsolete, use -vop scale=w:h for scaling\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 	{"xsize", "This option is obsolete, use -vop crop=w:h:x0:y0 for cropping\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 
--- a/mencoder.c	Wed Jul 31 20:18:44 2002 +0000
+++ b/mencoder.c	Thu Aug 01 08:39:33 2002 +0000
@@ -140,6 +140,10 @@
 static float max_pts_correction=0;//default_max_pts_correction;
 static float c_total=0;
 
+float audio_preload=0.5;
+float audio_delay=0.0;
+int audio_density=2;
+
 float force_fps=0;
 float force_ofps=0; // set to 24 for inverse telecine
 static int skip_limit=-1;
@@ -331,8 +335,6 @@
 lame_global_flags *lame;
 #endif
 
-float audio_preload=0.5;
-
 double v_pts_corr=0;
 double v_timer_corr=0;
 
@@ -724,6 +726,7 @@
 	mux_a->h.dwSampleSize=sh_audio->audio.dwSampleSize;
 	mux_a->h.dwScale=sh_audio->audio.dwScale;
 	mux_a->h.dwRate=sh_audio->audio.dwRate;
+//	mux_a->h.dwStart=sh_audio->audio.dwStart;
     } else {
 	mux_a->h.dwSampleSize=mux_a->wf->nBlockAlign;
 	mux_a->h.dwScale=mux_a->h.dwSampleSize;
@@ -769,9 +772,15 @@
     ((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nCodecDelay=0;
     break;
 }
+
+if (verbose>1) print_wave_header(mux_a->wf);
+
+if(audio_delay!=0.0){
+    mux_a->h.dwStart=audio_delay*mux_a->h.dwRate/mux_a->h.dwScale;
+    printf("Setting AUDIO DELAY to %5.3f\n",mux_a->h.dwStart*mux_a->h.dwScale/(float)mux_a->h.dwRate);
 }
 
-if (verbose>1) print_wave_header(mux_a->wf);
+} // if(sh_audio)
 
 printf("Writing AVI header...\n");
 aviwrite_write_header(muxer,muxer_f);
@@ -869,13 +878,13 @@
 	    // CBR - copy 0.5 sec of audio
 	    switch(mux_a->codec){
 	    case ACODEC_COPY: // copy
-		len=mux_a->wf->nAvgBytesPerSec/2;
+		len=mux_a->wf->nAvgBytesPerSec/audio_density;
 		len/=mux_a->h.dwSampleSize;if(len<1) len=1;
 		len*=mux_a->h.dwSampleSize;
 		len=demux_read_data(sh_audio->ds,mux_a->buffer,len);
 		break;
 	    case ACODEC_PCM:
-		len=mux_a->h.dwSampleSize*(mux_a->h.dwRate/2);
+		len=mux_a->h.dwSampleSize*(mux_a->h.dwRate/audio_density);
 		len=dec_audio(sh_audio,mux_a->buffer,len);
 		break;
 	    }