[MPlayer-dev-eng] BT848 Patches

Charles Henrich henrich at sigbus.com
Mon Mar 25 01:42:51 CET 2002


Bringing the tree up to date..  Files changed:

Index: main/cfg-common.h
Index: main/dec_video.c
Index: main/mencoder.c
Index: main/mplayer.c
Index: main/libmpdemux/Makefile
Index: main/libmpdemux/aviwrite.c
Index: main/libmpdemux/aviwrite.h
Index: main/libmpdemux/demuxer.c
Index: main/libmpdemux/demuxer.h
Index: main/libmpdemux/tv.c
Index: main/libmpdemux/tv.h
Index: main/libmpdemux/tvi_def.h
Index: main/libmpdemux/tvi_dummy.c
Index: main/libmpdemux/tvi_v4l.c
Index: main/libmpdemux/video.c

Arpi, please review mencoder.c changes.  Its mostly for user display, shows
the time it takes to encode each audio and video pass (for debugging and
tuning of arguments), as well as adding a field to the output for
skipped/dupped frames (which occur in the thousands for slow CPU's).  I
couldnt figure out how to better merge the two, I hate the >80 col display,
but didnt want to remove any display info you have as well, so I ifdef'd it.

I also added ftello and type off_t for the file seeking to support >2GB files,
whenever aviwrite does.

-Crh

       Charles Henrich                                   henrich at msu.edu

                       http://www.sigbus.com:81/~henrich
-------------- next part --------------
Index: main/cfg-common.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-common.h,v
retrieving revision 1.30
diff -u -u -r1.30 cfg-common.h
--- main/cfg-common.h	15 Mar 2002 16:10:06 -0000	1.30
+++ main/cfg-common.h	25 Mar 2002 01:01:44 -0000
@@ -98,7 +98,11 @@
 #ifdef USE_TV
 struct config tvopts_conf[]={
 	{"on", &tv_param_on, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+#ifdef HAVE_TV_BSDBT848
+	{"immediatemode", &tv_param_immediate, CONF_TYPE_FLAG, 0, 0, 0, NULL},
+#endif
 	{"noaudio", &tv_param_noaudio, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+	{"audiorate", &tv_param_audiorate, CONF_TYPE_INT, 0, 0, 0, NULL},
 	{"driver", &tv_param_driver, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"device", &tv_param_device, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"freq", &tv_param_freq, CONF_TYPE_STRING, 0, 0, 0, NULL},
Index: main/dec_video.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_video.c,v
retrieving revision 1.122
diff -u -u -r1.122 dec_video.c
--- main/dec_video.c	20 Mar 2002 15:37:54 -0000	1.122
+++ main/dec_video.c	25 Mar 2002 01:01:45 -0000
@@ -1141,7 +1141,8 @@
 //    planes[0]=start;
 //    blit_frame=2;
     sh_video->our_out_buffer = start;
-    blit_frame=3;
+    if(in_size<=0) blit_frame=0;
+    else           blit_frame=3;
     break;
   case VFM_RLE:
 //void AVI_Decode_RLE8(char *image,char *delta,int tdsize,
Index: main/mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.100
diff -u -u -r1.100 mencoder.c
--- main/mencoder.c	23 Mar 2002 13:13:12 -0000	1.100
+++ main/mencoder.c	25 Mar 2002 01:01:45 -0000
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
+#include <sys/time.h>
 
 #include "config.h"
 #include "mp_msg.h"
@@ -262,6 +263,25 @@
   }
 }
 
+u_long timediff (struct timeval *start, struct timeval *end)
+{
+struct timeval tmp;
+
+    tmp.tv_sec = end->tv_sec - start->tv_sec;
+    tmp.tv_usec = end->tv_usec - start->tv_usec;
+
+    if(tmp.tv_usec < 0) {
+        tmp.tv_usec += 1000000;
+        tmp.tv_sec -= 1;
+    }
+    if(tmp.tv_usec < 0 || tmp.tv_sec < 0) {
+        tmp.tv_usec = tmp.tv_sec = 0;
+    }
+
+return tmp.tv_sec * 1000 + tmp.tv_usec / 1000;
+}
+
+
 //---------------------------------------------------------------------------
 
 // mini dummy libvo:
@@ -496,11 +516,20 @@
 int file_format=DEMUXER_TYPE_UNKNOWN;
 int i;
 
+struct timeval ptimer_start;
+struct timeval ptimer_stop;
+u_long audiorate=0;
+u_long videorate=0;
+u_long audiosamples=1;
+u_long videosamples=1;
+u_long skippedframes=0;
+u_long duplicatedframes=0;
+
 aviwrite_t* muxer=NULL;
 aviwrite_stream_t* mux_a=NULL;
 aviwrite_stream_t* mux_v=NULL;
 FILE* muxer_f=NULL;
-int muxer_f_size=0;
+off_t muxer_f_size=0;
 
 #ifdef HAVE_DIVX4ENCORE
 ENC_FRAME enc_frame;
@@ -1348,6 +1377,13 @@
     demux_seek(demuxer, d, 1);
 }
 
+if(tv_param_on == 1) 
+	{
+	fprintf(stderr,"Forcing audio preload to 0, max pts correction to 0\n");
+	audio_preload = 0.0;
+	default_max_pts_correction = 0;
+	}
+
 while(!eof){
 
     float frame_time=0;
@@ -1358,7 +1394,7 @@
     int in_size;
     int skip_flag=0; // 1=skip  -1=duplicate
 
-    if((end_at_type == END_AT_SIZE && end_at <= ftell(muxer_f))  ||
+    if((end_at_type == END_AT_SIZE && end_at <= ftello(muxer_f))  ||
        (end_at_type == END_AT_TIME && end_at < sh_video->timer))
         break;
 
@@ -1371,6 +1407,9 @@
     // get audio:
     while(mux_a->timer-audio_preload<mux_v->timer){
 	int len=0;
+
+	gettimeofday(&ptimer_start, NULL);
+
 	if(mux_a->h.dwSampleSize){
 	    // CBR - copy 0.5 sec of audio
 	    switch(mux_a->codec){
@@ -1430,14 +1469,20 @@
 	    mux_a->buffer_len-=len;
 	    memcpy(mux_a->buffer,mux_a->buffer+len,mux_a->buffer_len);
 	}
+
+	gettimeofday(&ptimer_stop, NULL);
+
+	audiosamples++;
+	audiorate+=timediff(&ptimer_start, &ptimer_stop);
     }
 }
 
     // get video frame!
+
     in_size=video_read_frame(sh_video,&frame_time,&start,force_fps);
     if(in_size<0){ eof=1; break; }
     sh_video->timer+=frame_time; ++decoded_frameno;
-    
+
     v_timer_corr-=frame_time-(float)mux_v->h.dwScale/mux_v->h.dwRate;
 
 if(demuxer2){
@@ -1450,7 +1495,7 @@
 	    if(len==4) next_frameno=start[0];
 	}
     if(eof) break;
-	if(skip_flag) printf("!!!!!!!!!!!!\n");
+	// if(skip_flag) printf("!!!!!!!!!!!!\n");
 	skip_flag=next_frameno-decoded_frameno;
     // find next frame:
 	while(next_frameno<=decoded_frameno){
@@ -1502,6 +1547,8 @@
  }
 #endif
 
+gettimeofday(&ptimer_start, NULL);
+
 switch(mux_v->codec){
 case VCODEC_COPY:
     mux_v->buffer=start;
@@ -1658,17 +1705,27 @@
     }
 }
 
+gettimeofday(&ptimer_stop, NULL);
+videosamples++;
+videorate+=timediff(&ptimer_start, &ptimer_stop);
+
 if(skip_flag<0){
     // duplicate frame
+#ifndef USE_TV
     printf("\nduplicate %d frame(s)!!!    \n",-skip_flag);
+#endif
     while(skip_flag<0){
+	duplicatedframes++;
 	aviwrite_write_chunk(muxer,mux_v,muxer_f,0,0);
 	++skip_flag;
     }
 } else
 if(skip_flag>0){
     // skip frame
+#ifndef USE_TV
     printf("\nskip frame!!!    \n");
+#endif
+	skippedframes++;
     --skip_flag;
 }
 
@@ -1735,7 +1792,20 @@
 	    (int)demuxer->filepos,
 	    (int)demuxer->movi_end);
 #else
-	mp_msg(MSGT_AVSYNC,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb  A-V:%5.3f [%d:%d]\r",
+#ifdef USE_TV
+	mp_msg(MSGT_AVSYNC,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb  A-V:%5.3f [%d:%d] A/Vms %d/%d D/S %d/%d \r",
+	    mux_v->timer, decoded_frameno, (int)(p*100),
+	    (t>1) ? (int)(decoded_frameno/t) : 0,
+	    (p>0.001) ? (int)((t/p-t)/60) : 0, 
+	    (p>0.001) ? (int)(ftello(muxer_f)/p/1024/1024) : 0,
+	    v_pts_corr,
+	    (mux_v->timer>1) ? (int)(mux_v->size/mux_v->timer/125) : 0,
+	    (mux_a && mux_a->timer>1) ? (int)(mux_a->size/mux_a->timer/125) : 0,
+		audiorate/audiosamples, videorate/videosamples,
+		duplicatedframes, skippedframes
+	);
+#else
+    mp_msg(MSGT_AVSYNC,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb  A-V:%5.3f [%d:%d]\r",
 	    mux_v->timer, decoded_frameno, (int)(p*100),
 	    (t>1) ? (int)(decoded_frameno/t) : 0,
 	    (p>0.001) ? (int)((t/p-t)/60) : 0, 
@@ -1743,7 +1813,9 @@
 	    v_pts_corr,
 	    (mux_v->timer>1) ? (int)(mux_v->size/mux_v->timer/125) : 0,
 	    (mux_a && mux_a->timer>1) ? (int)(mux_a->size/mux_a->timer/125) : 0
-	);
+	    );
+#endif
+
 #endif
     }
 
@@ -1771,7 +1843,7 @@
 
 printf("\nWriting AVI index...\n");
 aviwrite_write_index(muxer,muxer_f);
-muxer_f_size=ftell(muxer_f);
+muxer_f_size=ftello(muxer_f);
 printf("Fixup AVI header...\n");
 fseek(muxer_f,0,SEEK_SET);
 aviwrite_write_header(muxer,muxer_f); // update header
@@ -1784,10 +1856,10 @@
 }
 
 printf("\nVideo stream: %8.3f kbit/s  (%d bps)  size: %d bytes  %5.3f secs  %d frames\n",
-    (float)(mux_v->size/mux_v->timer*8.0f/1000.0f), (int)(mux_v->size/mux_v->timer), mux_v->size, (float)mux_v->timer, decoded_frameno);
+    (float)(mux_v->size/mux_v->timer*8.0f/1000.0f), (int)(mux_v->size/mux_v->timer), (int)mux_v->size, (float)mux_v->timer, decoded_frameno);
 if(sh_audio)
 printf("\nAudio stream: %8.3f kbit/s  (%d bps)  size: %d bytes  %5.3f secs\n",
-    (float)(mux_a->size/mux_a->timer*8.0f/1000.0f), (int)(mux_a->size/mux_a->timer), mux_a->size, (float)mux_a->timer);
+    (float)(mux_a->size/mux_a->timer*8.0f/1000.0f), (int)(mux_a->size/mux_a->timer), (int)mux_a->size, (float)mux_a->timer);
 
 if(stream) free_stream(stream); // kill cache thread
 
Index: main/mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.446
diff -u -u -r1.446 mplayer.c
--- main/mplayer.c	23 Mar 2002 22:50:25 -0000	1.446
+++ main/mplayer.c	25 Mar 2002 01:01:46 -0000
@@ -1004,6 +1004,10 @@
     if((eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY))) goto goto_next_file;
 }
 
+#ifdef HAVE_TV_BSDBT848
+tv_param_immediate = 1;
+#endif
+
 //============ Open DEMUXERS --- DETECT file type =======================
 
 if(!has_audio) audio_id=-2; // do NOT read audio packets...
Index: main/libmpdemux/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.26
diff -u -u -r1.26 Makefile
--- main/libmpdemux/Makefile	24 Mar 2002 02:25:41 -0000	1.26
+++ main/libmpdemux/Makefile	25 Mar 2002 01:01:46 -0000
@@ -4,6 +4,7 @@
 include ../config.mak
 
 SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c mpdemux.c demux_ogg.c demux_bmp.c
+
 ifeq ($(STREAMING),yes)
 SRCS += asf_streaming.c url.c http.c network.c rtp.c
 endif
Index: main/libmpdemux/aviwrite.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/aviwrite.c,v
retrieving revision 1.6
diff -u -u -r1.6 aviwrite.c
--- main/libmpdemux/aviwrite.c	3 Nov 2001 20:57:13 -0000	1.6
+++ main/libmpdemux/aviwrite.c	25 Mar 2002 01:01:46 -0000
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
 
 #include "config.h"
 
Index: main/libmpdemux/aviwrite.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/aviwrite.h,v
retrieving revision 1.3
diff -u -u -r1.3 aviwrite.h
--- main/libmpdemux/aviwrite.h	3 Nov 2001 20:57:13 -0000	1.3
+++ main/libmpdemux/aviwrite.h	25 Mar 2002 01:01:46 -0000
@@ -10,7 +10,7 @@
   int id;    // stream no
   unsigned int ckid; // chunk id (00dc 01wb etc)
   double timer;
-  unsigned int size;
+  off_t size;
   // buffering:
   unsigned char *buffer;
   unsigned int buffer_size;
Index: main/libmpdemux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.85
diff -u -u -r1.85 demuxer.c
--- main/libmpdemux/demuxer.c	20 Mar 2002 05:15:53 -0000	1.85
+++ main/libmpdemux/demuxer.c	25 Mar 2002 01:01:46 -0000
@@ -213,7 +213,7 @@
 extern tvi_handle_t *tv_handler;
 extern int tv_param_on;
 
-extern int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh);
+extern int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds, tvi_handle_t *tvh);
 extern int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
 #endif
 int demux_y4m_fill_buffer(demuxer_t *demux);
@@ -241,7 +241,7 @@
     case DEMUXER_TYPE_REAL: return demux_real_fill_buffer(demux);
     case DEMUXER_TYPE_NUV: return demux_nuv_fill_buffer(demux);
 #ifdef USE_TV
-    case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, tv_handler);
+    case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, ds, tv_handler);
 #endif
     case DEMUXER_TYPE_Y4M: return demux_y4m_fill_buffer(demux);
     case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds);
Index: main/libmpdemux/demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.35
diff -u -u -r1.35 demuxer.h
--- main/libmpdemux/demuxer.h	20 Mar 2002 05:15:53 -0000	1.35
+++ main/libmpdemux/demuxer.h	25 Mar 2002 01:01:46 -0000
@@ -2,7 +2,11 @@
 #define __DEMUXER_H 1
 
 #define MAX_PACKS 4096
+#ifdef HAVE_TV_BSDBT848
+#define MAX_PACK_BYTES 0x2000000
+#else
 #define MAX_PACK_BYTES 0x800000
+#endif
 
 #define DEMUXER_TYPE_UNKNOWN 0
 #define DEMUXER_TYPE_MPEG_ES 1
Index: main/libmpdemux/tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.25
diff -u -u -r1.25 tv.c
--- main/libmpdemux/tv.c	15 Mar 2002 16:07:06 -0000	1.25
+++ main/libmpdemux/tv.c	25 Mar 2002 01:01:46 -0000
@@ -6,7 +6,7 @@
  API idea based on libvo2
 
  Feb 19, 2002: Significant rewrites by Charles R. Henrich (henrich at msu.edu)
-	       try to fix audio support, and bktr *BSD support.
+				to add support for audio, and bktr *BSD support.
 
 */
 
@@ -37,7 +37,11 @@
 #include "frequencies.h"
 
 /* some default values */
+int tv_param_audiorate = 44100;
 int tv_param_noaudio = 0;
+#ifdef HAVE_TV_BSDBT848
+int tv_param_immediate = 0;
+#endif
 char *tv_param_freq = NULL;
 char *tv_param_channel = NULL;
 char *tv_param_norm = "pal";
@@ -58,57 +62,39 @@
 */
 /* fill demux->video and demux->audio */
 
-int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh)
+int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds, tvi_handle_t *tvh)
 {
     demux_packet_t* dp;
 
     sh_video_t *sh_video = demux->video->sh;
     u_int len;
-    u_int cframe;
     int aframeswaiting;
 
-    len = cframe = -1;
+    len = 0;
 
     /* ================== ADD AUDIO PACKET =================== */
 
-    if (tv_param_noaudio == 0 && 
+    if (ds==demux->audio && tv_param_noaudio == 0 && 
         tvh->functions->control(tvh->priv, 
                                 TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
         {
         len = tvh->functions->get_audio_framesize(tvh->priv);
 
-        do {
-            dp=new_demux_packet(len);
-            aframeswaiting=tvh->functions->grab_audio_frame(tvh->priv,
-                                                            dp->buffer,len);
-            dp->pts=tvh->seq/sh_video->fps;
-            dp->pos=tvh->seq*len;
-            ds_add_packet(demux->audio,dp);
-
-            tvh->seq++;
-
-           } while (aframeswaiting > 0);
+        dp=new_demux_packet(len);
+        dp->pts=tvh->functions->grab_audio_frame(tvh->priv, dp->buffer,len);
+        ds_add_packet(demux->audio,dp);
         }
 
     /* ================== ADD VIDEO PACKET =================== */
 
-    if (tvh->functions->control(tvh->priv, 
+    if (ds==demux->video && tvh->functions->control(tvh->priv, 
                             TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE)
         {
-        len = tvh->functions->get_video_framesize(tvh->priv);
-
-        dp=new_demux_packet(len);
-
-        cframe=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, 
-                                                len);
-
-        if(tv_param_noaudio == 1) tvh->seq = cframe;
-
-        dp->pos=tvh->seq*len;
-        dp->pts=tvh->seq/sh_video->fps;
-
-        ds_add_packet(demux->video,dp);
-        }
+		len = tvh->functions->get_video_framesize(tvh->priv);
+       	dp=new_demux_packet(len);
+  		dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len);
+   		ds_add_packet(demux->video,dp);
+		}
 
     return 1;
 }
@@ -190,7 +176,7 @@
     if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
     {
 	mp_msg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n");	
-	goto start_device;
+	goto done;
     }
 
     /* select channel list */
@@ -214,7 +200,7 @@
     if (tv_param_freq && tv_param_channel)
     {
 	mp_msg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultanly!\n");
-	goto start_device;
+	goto done;
     }
 
     /* we need to set frequency */
@@ -251,9 +237,9 @@
 	}
     }
 
-start_device:    
+done:    
     /* also start device! */
-    return(funcs->start(tvh->priv));	
+	return 1;
 }
 
 int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh)
@@ -261,6 +247,8 @@
     sh_video_t *sh_video = NULL;
     sh_audio_t *sh_audio = NULL;
     tvi_functions_t *funcs = tvh->functions;
+
+fprintf(stderr,"DEMUXOPEN\n");
     
     sh_video = new_sh_video(demuxer, 0);
 
@@ -286,6 +274,15 @@
 
     printf("fps: %f, frametime: %f\n", sh_video->fps, sh_video->frametime);
 
+#ifdef HAVE_TV_BSDBT848
+    /* If playback only mode, go to immediate mode, fail silently */
+    if(tv_param_immediate == 1)
+        {
+        funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0);
+        tv_param_noaudio = 1; 
+        }
+#endif
+
     /* set width */
     funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
 
@@ -333,8 +330,14 @@
 		goto no_audio;
 	}
 	
+	funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE, 
+				  &tv_param_audiorate);
+
 	sh_audio = new_sh_audio(demuxer, 0);
-	sh_audio->wf = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX));
+    sh_audio->wf = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX));
+
+    sh_audio->format = sh_audio_format;
+	sh_audio->sample_format = audio_format;
 
 	funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE, 
                    &sh_audio->samplerate);
@@ -343,45 +346,33 @@
 	funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS, 
                    &sh_audio->channels);
 
-	sh_audio->format = sh_audio_format;
-	sh_audio->sample_format = audio_format;
-
-	sh_audio->i_bps = sh_audio->o_bps =
-	    sh_audio->samplerate * sh_audio->samplesize/8 * 
-	    sh_audio->channels;
-
-	sh_audio->wf->wFormatTag = sh_audio->format;
-	sh_audio->wf->nChannels = sh_audio->channels;
-	switch(audio_format)
-	{
-	    case AFMT_U8:
-	    case AFMT_S8:
-		sh_audio->wf->wBitsPerSample = 8;
-		break;
-	    case AFMT_U16_LE:
-	    case AFMT_U16_BE:
-	    case AFMT_S16_LE:
-	    case AFMT_S16_BE:
-		sh_audio->wf->wBitsPerSample = 16;
-		break;
-	    case AFMT_S32_LE:
-	    case AFMT_S32_BE:
-		sh_audio->wf->wBitsPerSample = 32;
-		break;
-	}
-	sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
-	sh_audio->wf->nBlockAlign = sh_audio->wf->nAvgBytesPerSec;
-	sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels * 
-                                    sh_audio->samplesize/8 * 
-                                    sh_audio->samplerate;
-
+    sh_audio->wf->nBlockAlign = sh_audio->wf->nAvgBytesPerSec;
 	demuxer->audio->sh = sh_audio;
 	sh_audio->ds = demuxer->audio;
 	demuxer->audio->id = 0;
+
+    sh_audio->o_bps = sh_audio->samplerate * sh_audio->samplesize * 
+                      sh_audio->channels;
+    sh_audio->i_bps = sh_audio->samplerate * sh_audio->samplesize * 
+                      sh_audio->channels;
+
+    // uncompressed PCM format
+    sh_audio->wf->wFormatTag = sh_audio->format;
+    sh_audio->wf->nChannels = sh_audio->channels;
+    sh_audio->wf->wBitsPerSample = sh_audio->samplesize*8;
+    sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
+    sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels * 
+                                    sh_audio->samplesize * 
+                                    sh_audio->samplerate;
+
+    mp_msg(MSGT_DECVIDEO, MSGL_V, "  TV audio: %d channels, %d bits, %d Hz\n",
+          sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,
+          sh_audio->wf->nSamplesPerSec);
+
     }
 no_audio:
 
-    return(1);
+    return(funcs->start(tvh->priv));	
 }
 
 /* ================== STREAM_TV ===================== */
Index: main/libmpdemux/tv.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.h,v
retrieving revision 1.13
diff -u -u -r1.13 tv.h
--- main/libmpdemux/tv.h	15 Mar 2002 17:58:19 -0000	1.13
+++ main/libmpdemux/tv.h	25 Mar 2002 01:01:46 -0000
@@ -21,6 +21,8 @@
 extern char *tv_param_outfmt;
 extern float tv_param_fps;
 extern int tv_param_noaudio;
+extern int tv_param_immediate;
+extern int tv_param_audiorate;
 
 typedef struct tvi_info_s
 {
@@ -36,9 +38,12 @@
     int (*uninit)();
     int (*control)();
     int (*start)();
-    int (*grab_video_frame)();
+    double (*grab_video_frame)();
+#ifdef HAVE_TV_BSDBT848
+    double (*grabimmediate_video_frame)();
+#endif
     int (*get_video_framesize)();
-    int (*grab_audio_frame)();
+    double (*grab_audio_frame)();
     int (*get_audio_framesize)();
 } tvi_functions_t;
 
@@ -67,6 +72,9 @@
 #define TVI_CONTROL_IS_AUDIO		0x1
 #define TVI_CONTROL_IS_VIDEO		0x2
 #define TVI_CONTROL_IS_TUNER		0x3
+#ifdef HAVE_TV_BSDBT848
+#define TVI_CONTROL_IMMEDIATE       0x4
+#endif
 
 /* VIDEO controls */
 #define TVI_CONTROL_VID_GET_FPS		0x101
@@ -107,6 +115,7 @@
 #define TVI_CONTROL_AUD_GET_SAMPLERATE	0x302
 #define TVI_CONTROL_AUD_GET_SAMPLESIZE	0x303
 #define TVI_CONTROL_AUD_GET_CHANNELS	0x304
+#define TVI_CONTROL_AUD_SET_SAMPLERATE	0x305
 
 /* SPECIFIC controls */
 #define TVI_CONTROL_SPC_GET_INPUT	0x401	/* set input channel (tv,s-video,composite..) */
Index: main/libmpdemux/tvi_def.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_def.h,v
retrieving revision 1.6
diff -u -u -r1.6 tvi_def.h
--- main/libmpdemux/tvi_def.h	27 Dec 2001 23:52:48 -0000	1.6
+++ main/libmpdemux/tvi_def.h	25 Mar 2002 01:01:46 -0000
@@ -4,9 +4,12 @@
 static int uninit(priv_t *priv);
 static int control(priv_t *priv, int cmd, void *arg);
 static int start(priv_t *priv);
-static int grab_video_frame(priv_t *priv, char *buffer, int len);
+static double grab_video_frame(priv_t *priv, char *buffer, int len);
+#ifdef HAVE_TV_BSDBT848
+static double grabimmediate_video_frame(priv_t *priv, char *buffer, int len);
+#endif
 static int get_video_framesize(priv_t *priv);
-static int grab_audio_frame(priv_t *priv, char *buffer, int len);
+static double grab_audio_frame(priv_t *priv, char *buffer, int len);
 static int get_audio_framesize(priv_t *priv);
 
 static tvi_functions_t functions =
@@ -16,6 +19,9 @@
     control,
     start,
     grab_video_frame,
+#ifdef HAVE_TV_BSDBT848
+    grabimmediate_video_frame,
+#endif
     get_video_framesize,
     grab_audio_frame,
     get_audio_framesize
Index: main/libmpdemux/tvi_dummy.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_dummy.c,v
retrieving revision 1.7
diff -u -u -r1.7 tvi_dummy.c
--- main/libmpdemux/tvi_dummy.c	27 Dec 2001 23:52:48 -0000	1.7
+++ main/libmpdemux/tvi_dummy.c	25 Mar 2002 01:01:46 -0000
@@ -86,7 +86,15 @@
     return(TVI_CONTROL_UNKNOWN);
 }
 
-static int grab_video_frame(priv_t *priv, char *buffer, int len)
+#ifdef HAVE_TV_BSDBT848
+static double grabimmediate_video_frame(priv_t *priv, char *buffer, int len)
+{
+    memset(buffer, 0xCC, len);
+    return(1);
+}
+#endif
+
+static double grab_video_frame(priv_t *priv, char *buffer, int len)
 {
     memset(buffer, 0x42, len);
     return(1);
@@ -98,7 +106,7 @@
     return(priv->width*priv->height*12/8);
 }
 
-static int grab_audio_frame(priv_t *priv, char *buffer, int len)
+static double grab_audio_frame(priv_t *priv, char *buffer, int len)
 {
     memset(buffer, 0x42, len);
     return(1);
Index: main/libmpdemux/tvi_v4l.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l.c,v
retrieving revision 1.19
diff -u -u -r1.19 tvi_v4l.c
--- main/libmpdemux/tvi_v4l.c	15 Mar 2002 16:08:14 -0000	1.19
+++ main/libmpdemux/tvi_v4l.c	25 Mar 2002 01:01:47 -0000
@@ -63,7 +63,6 @@
     struct video_mmap		*buf;
     int				nbuf;
     int				queue;
-	int				currentframe;
 
     /* audio */
     int				audio_id;
@@ -812,8 +811,6 @@
     int frame = priv->queue % priv->nbuf;
     int nextframe = (priv->queue+1) % priv->nbuf;
 
-	priv->currentframe++;
-
     mp_dbg(MSGT_TV, MSGL_DBG2, "grab_video_frame(priv=%p, buffer=%p, len=%d)\n",
 	priv, buffer, len);
 
@@ -841,7 +838,7 @@
     /* copy the actual frame */
     memcpy(buffer, priv->mmap+priv->mbuf.offsets[frame], len);
 
-    return(priv->currentframe);
+    return(0);
 }
 
 static int get_video_framesize(priv_t *priv)
Index: main/libmpdemux/video.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/video.c,v
retrieving revision 1.12
diff -u -u -r1.12 video.c
--- main/libmpdemux/video.c	16 Mar 2002 19:58:07 -0000	1.12
+++ main/libmpdemux/video.c	25 Mar 2002 01:01:47 -0000
@@ -291,6 +291,10 @@
           sh_video->fps=1.0f/d;
         }
     } else
+    if(demuxer->file_format==DEMUXER_TYPE_TV && !force_fps){
+        // TV has variable video frame rate, fixed audio...
+	frame_time=d_video->pts-pts1;
+	} else
     if(demuxer->file_format==DEMUXER_TYPE_MOV && !force_fps){
         // .MOV files has no fixed FPS - just frame durations!
 	frame_time=d_video->pts-pts1;


More information about the MPlayer-dev-eng mailing list