[Mplayer-cvslog] CVS: main/libmpdemux aviwrite.c,1.6,1.7 aviwrite.h,1.3,1.4 demuxer.c,1.89,1.90 tv.c,1.25,1.26 tv.h,1.13,1.14 tvi_bsdbt848.c,1.2,1.3 tvi_def.h,1.6,1.7 tvi_dummy.c,1.7,1.8 tvi_v4l.c,1.19,1.20 video.c,1.14,1.15

Arpi of Ize arpi at mplayer.dev.hu
Fri Apr 12 12:40:41 CEST 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv31429/libmpdemux

Modified Files:
	aviwrite.c aviwrite.h demuxer.c tv.c tv.h tvi_bsdbt848.c 
	tvi_def.h tvi_dummy.c tvi_v4l.c video.c 
Log Message:
BSD-BT848 TV update patch by Charles Henrich <henrich at sigbus.com>
- tvi interface changes, grab_audio/video now returns timestamp!
- tv demuxer gets 'ds' hint too
- some verbose skip/dup counters to mencoder
- tvi_bsdbt848.c updates
- aviwrite/mencoder size types int->off_t


Index: aviwrite.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/aviwrite.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- aviwrite.c	3 Nov 2001 20:57:13 -0000	1.6
+++ aviwrite.c	12 Apr 2002 10:40:38 -0000	1.7
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
 
 #include "config.h"
 

Index: aviwrite.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/aviwrite.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- aviwrite.h	3 Nov 2001 20:57:13 -0000	1.3
+++ aviwrite.h	12 Apr 2002 10:40:38 -0000	1.4
@@ -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: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- demuxer.c	3 Apr 2002 17:49:40 -0000	1.89
+++ demuxer.c	12 Apr 2002 10:40:38 -0000	1.90
@@ -214,7 +214,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);
@@ -242,7 +242,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: tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- tv.c	15 Mar 2002 16:07:06 -0000	1.25
+++ tv.c	12 Apr 2002 10:40:38 -0000	1.26
@@ -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)
@@ -286,6 +272,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);
 
@@ -308,6 +303,10 @@
 	int sh_audio_format;
 
 	/* yeah, audio is present */
+
+	funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE, 
+				  &tv_param_audiorate);
+
 	if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE)
 	    goto no_audio;
 
@@ -334,7 +333,6 @@
 	}
 	
 	sh_audio = new_sh_audio(demuxer, 0);
-	sh_audio->wf = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX));
 
 	funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE, 
                    &sh_audio->samplerate);
@@ -347,33 +345,21 @@
 	sh_audio->sample_format = audio_format;
 
 	sh_audio->i_bps = sh_audio->o_bps =
-	    sh_audio->samplerate * sh_audio->samplesize/8 * 
+	    sh_audio->samplerate * sh_audio->samplesize * 
 	    sh_audio->channels;
 
+	// emulate WF for win32 codecs:
+	sh_audio->wf = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX));
 	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->wBitsPerSample = sh_audio->samplesize * 8;
 	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->samplesize * sh_audio->channels;
+	sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;
+
+	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);
 
 	demuxer->audio->sh = sh_audio;
 	sh_audio->ds = demuxer->audio;
@@ -381,7 +367,7 @@
     }
 no_audio:
 
-    return(1);
+    return(funcs->start(tvh->priv));	
 }
 
 /* ================== STREAM_TV ===================== */

Index: tv.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- tv.h	15 Mar 2002 17:58:19 -0000	1.13
+++ tv.h	12 Apr 2002 10:40:38 -0000	1.14
@@ -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: tvi_bsdbt848.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_bsdbt848.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- tvi_bsdbt848.c	16 Mar 2002 19:17:58 -0000	1.2
+++ tvi_bsdbt848.c	12 Apr 2002 10:40:38 -0000	1.3
@@ -1,27 +1,32 @@
 /*
-	(C)2002 Charles R. Henrich (henrich at msu.edu)
-	*BSD (hopefully, requires working driver!) BrookTree capture support.
+    (C)2002 Charles R. Henrich (henrich at msu.edu)
+    *BSD (hopefully, requires working driver!) BrookTree capture support.
 
-	Still in (active) development!
+    Still in (active) development!
 
-	v1.0	Feb 19 2002		First Release, need to add support for changing
-							audio parameters.
[...1108 lines suppressed...]
 switch(innumber)
-	{
-	case 0: return METEOR_INPUT_DEV0; 	/* RCA   */
-	case 1: return METEOR_INPUT_DEV1; 	/* Tuner */
-	case 2: return METEOR_INPUT_DEV2; 	/* In 1  */
-	case 3: return METEOR_INPUT_DEV3; 	/* In 2  */
-	case 4: return METEOR_INPUT_DEV_RGB; 	/* RGB   */
-	case 5: return METEOR_INPUT_DEV_SVIDEO; /* SVid  */
-	}
+    {
+    case 0: return METEOR_INPUT_DEV0;     /* RCA   */
+    case 1: return METEOR_INPUT_DEV1;     /* Tuner */
+    case 2: return METEOR_INPUT_DEV2;     /* In 1  */
+    case 3: return METEOR_INPUT_DEV3;     /* In 2  */
+    case 4: return METEOR_INPUT_DEV_RGB;     /* RGB   */
+    case 5: return METEOR_INPUT_DEV_SVIDEO; /* SVid  */
+    }
 
 return 0;
 }

Index: tvi_def.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_def.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- tvi_def.h	27 Dec 2001 23:52:48 -0000	1.6
+++ tvi_def.h	12 Apr 2002 10:40:38 -0000	1.7
@@ -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: tvi_dummy.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_dummy.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- tvi_dummy.c	27 Dec 2001 23:52:48 -0000	1.7
+++ tvi_dummy.c	12 Apr 2002 10:40:38 -0000	1.8
@@ -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: tvi_v4l.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- tvi_v4l.c	15 Mar 2002 16:08:14 -0000	1.19
+++ tvi_v4l.c	12 Apr 2002 10:40:38 -0000	1.20
@@ -63,7 +63,6 @@
     struct video_mmap		*buf;
     int				nbuf;
     int				queue;
-	int				currentframe;
 
     /* audio */
     int				audio_id;
@@ -807,13 +806,11 @@
     return(TVI_CONTROL_UNKNOWN);
 }
 
-static int grab_video_frame(priv_t *priv, char *buffer, int len)
+static double grab_video_frame(priv_t *priv, char *buffer, int len)
 {
     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)
@@ -849,7 +846,7 @@
     return(priv->bytesperline * priv->height);
 }
 
-static int grab_audio_frame(priv_t *priv, char *buffer, int len)
+static double grab_audio_frame(priv_t *priv, char *buffer, int len)
 {
     int in_len = 0;
 //    int max_tries = 128;
@@ -874,7 +871,7 @@
     }
 //    printf("tries: %d\n", 128-max_tries);
 
-    return(in_len);
+    return 0; //(in_len); // FIXME!
 }
 
 static int get_audio_framesize(priv_t *priv)

Index: video.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/video.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- video.c	31 Mar 2002 18:28:00 -0000	1.14
+++ video.c	12 Apr 2002 10:40:38 -0000	1.15
@@ -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-cvslog mailing list