changeset 1327:b12e1817bcc2

some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
author arpi
date Mon, 16 Jul 2001 12:53:48 +0000
parents 76478d16903d
children deab61c9a7e3
files dec_audio.c dec_video.c demux_asf.c mplayer.c
diffstat 4 files changed, 46 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/dec_audio.c	Mon Jul 16 12:11:49 2001 +0000
+++ b/dec_audio.c	Mon Jul 16 12:53:48 2001 +0000
@@ -32,6 +32,10 @@
 #include "loader/DirectShow/DS_AudioDec.h"
 #endif
 
+extern int init_acm_audio_codec(sh_audio_t *sh_audio);
+extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int minlen,int maxlen);
+
+
 static sh_audio_t* dec_audio_sh=NULL;
 
 // AC3 decoder buffer callback:
@@ -51,15 +55,9 @@
   return len;
 }
 
-
 int init_audio(sh_audio_t *sh_audio){
-
 int driver=sh_audio->codec->driver;
 
-extern int init_acm_audio_codec(sh_audio_t *sh_audio);
-//extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int len);
-extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int minlen,int maxlen);
-
 sh_audio->samplesize=2;
 #if WORDS_BIGENDIAN
 sh_audio->sample_format=AFMT_S16_BE;
@@ -344,8 +342,7 @@
 
 #ifdef USE_DIRECTSHOW
       case 7: // DirectShow
-      { int ret;
-        int size_in=0;
+      { int size_in=0;
         int size_out=0;
         int srcsize=DS_AudioDecoder_GetSrcSize(maxlen);
         if(verbose>2)printf("DShow says: srcsize=%d  (buffsize=%d)  out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen);
@@ -373,4 +370,30 @@
     return len;
 }
 
+void resync_audio_stream(sh_audio_t *sh_audio){
+        switch(sh_audio->codec->driver){
+        case 1:
+          MP3_DecodeFrame(NULL,-2); // resync
+          MP3_DecodeFrame(NULL,-2); // resync
+          MP3_DecodeFrame(NULL,-2); // resync
+          break;
+        case 3:
+          ac3_bitstream_reset();    // reset AC3 bitstream buffer
+    //      if(verbose){ printf("Resyncing AC3 audio...");fflush(stdout);}
+          sh_audio->ac3_frame=ac3_decode_frame(); // resync
+    //      if(verbose) printf(" OK!\n");
+          break;
+        case 4:
+        case 7:
+          sh_audio->a_in_buffer_len=0;        // reset ACM/DShow audio buffer
+          break;
+        }
+}
 
+void skip_audio_frame(sh_audio_t *sh_audio){
+              switch(sh_audio->codec->driver){
+                case 1: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame
+                case 3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame
+                default: ds_fill_buffer(sh_audio->ds);  // skip PCM frame
+              }
+}
--- a/dec_video.c	Mon Jul 16 12:11:49 2001 +0000
+++ b/dec_video.c	Mon Jul 16 12:53:48 2001 +0000
@@ -10,6 +10,8 @@
 extern double video_time_usage;
 extern double vout_time_usage;
 
+#include "linux/timer.h"
+
 #include "stream.h"
 #include "demuxer.h"
 
@@ -383,9 +385,7 @@
     break;
 #endif
   case 1: {
-        int in_frame=0;
         int t=0;
-        float newfps;
 
         t-=GetTimer();
           mpeg2_decode_data(video_out, start, start+in_size,drop_frame);
--- a/demux_asf.c	Mon Jul 16 12:11:49 2001 +0000
+++ b/demux_asf.c	Mon Jul 16 12:53:48 2001 +0000
@@ -239,6 +239,7 @@
                  break;
               default:
                  printf("Warning! unknown segtype == 0x%2X  \n",segtype);
+		 x=0;
               }
 
               type=p[0]; p++;        // 0x01: grouping  0x08: single
--- a/mplayer.c	Mon Jul 16 12:11:49 2001 +0000
+++ b/mplayer.c	Mon Jul 16 12:53:48 2001 +0000
@@ -30,12 +30,6 @@
 #define DEFAULT_CDROM_DEVICE    "/dev/cdrom"
 #endif
 
-#ifndef MAX_OUTBURST
-#error "============================================="
-#error "Please re-run ./configure and then try again!"
-#error "============================================="
-#endif
-
 #include "cfgparser.h"
 #include "cfg-mplayer-def.h"
 
@@ -46,9 +40,6 @@
 
 #include "libao2/audio_out.h"
 
-// CODECS:
-#include "mp3lib/mp3.h"
-#include "libac3/ac3.h"
 #include "libmpeg2/mpeg2.h"
 #include "libmpeg2/mpeg2_internal.h"
 
@@ -60,17 +51,8 @@
 #include "dvdauth.h"
 #include "spudec.h"
 
-#ifdef USE_DIRECTSHOW
-//#include "DirectShow/DS_VideoDec.h"
-//#include "DirectShow/DS_AudioDec.h"
-#endif
-
-//#include "opendivx/decore.h"
-
 extern char* win32_codec_name;  // must be set before calling DrvOpen() !!!
 
-// extern int errno;
-
 #include "linux/getch2.h"
 #include "linux/keycodes.h"
 #include "linux/timer.h"
@@ -153,7 +135,6 @@
 //**************************************************************************//
 
 static int max_framesize=0;
-//static int show_packets=0;
 
 #include "stream.h"
 #include "demuxer.h"
@@ -162,8 +143,6 @@
 
 static int avi_bitrate=0;
 
-//#include "aviprint.c"
-
 sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){
     if(demuxer->a_streams[id]){
         printf("Warning! Audio stream header %d redefined!\n",id);
@@ -261,6 +240,7 @@
 
 // IMHO this stuff is no longer of use, or is there a special
 // reason why dshow should be completely disabled? - atmos ::
+// yes, people without working c++ compiler can disable it - A'rpi
 #ifdef USE_DIRECTSHOW
 int allow_dshow=1;
 #else
@@ -395,13 +375,19 @@
 }
 
 extern int vcd_get_track_end(int fd,int track);
-extern int init_audio(sh_audio_t *sh_audio);
 extern int init_video_codec(sh_video_t *sh_video);
-extern void mpeg2_allocate_image_buffers(picture_t * picture);
+//extern void mpeg2_allocate_image_buffers(picture_t * picture);
 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height);
-extern int vo_init(void);
+
+// dec_audio.c:
+extern int init_audio(sh_audio_t *sh_audio);
 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen);
+extern void resync_audio_stream(sh_audio_t *sh_audio);
+extern void skip_audio_frame(sh_audio_t *sh_audio);
 
+// dec_video.c:
+extern int init_video(sh_video_t *sh_video);
+extern int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame);
 
 #include "mixer.h"
 #include "cfg-mplayer.h"
@@ -1517,7 +1503,6 @@
 
   if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG_PS){
         int in_frame=0;
-        int t=0;
         float newfps;
         videobuf_len=0;
         while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
@@ -2106,24 +2091,7 @@
         }
         
         current_module="resync_audio";
-
-        switch(sh_audio->codec->driver){
-        case 1:
-          MP3_DecodeFrame(NULL,-2); // resync
-          MP3_DecodeFrame(NULL,-2); // resync
-          MP3_DecodeFrame(NULL,-2); // resync
-          break;
-        case 3:
-          ac3_bitstream_reset();    // reset AC3 bitstream buffer
-    //      if(verbose){ printf("Resyncing AC3 audio...");fflush(stdout);}
-          sh_audio->ac3_frame=ac3_decode_frame(); // resync
-    //      if(verbose) printf(" OK!\n");
-          break;
-        case 4:
-        case 7:
-          sh_audio->a_in_buffer_len=0;        // reset ACM/DShow audio buffer
-          break;
-        }
+	resync_audio_stream(sh_audio);
 
         // re-sync PTS (MPEG-PS only!!!)
         if(file_format==DEMUXER_TYPE_MPEG_PS)
@@ -2132,11 +2100,7 @@
           
           } else {
             while(d_video->pts > d_audio->pts){
-              switch(sh_audio->codec->driver){
-                case 1: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame
-                case 3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame
-                default: ds_fill_buffer(d_audio);  // skip PCM frame
-              }
+	      skip_audio_frame(sh_audio);
             }
           }
         }