changeset 3801:3cea69dda1b3

added NuppelVideo demuxer, based on Panagiotis Issaris' patch
author alex
date Thu, 27 Dec 2001 21:24:56 +0000
parents 3080ef830f93
children bf37d5cd3e6e
files libmpdemux/Makefile libmpdemux/demux_nuv.c libmpdemux/demuxer.c libmpdemux/demuxer.h
diffstat 4 files changed, 192 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/Makefile	Thu Dec 27 19:54:36 2001 +0000
+++ b/libmpdemux/Makefile	Thu Dec 27 21:24:56 2001 +0000
@@ -3,7 +3,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 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 frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c
+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 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 frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c
 ifeq ($(STREAMING),yes)
 SRCS += asf_streaming.c url.c http.c network.c rtp.c
 endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpdemux/demux_nuv.c	Thu Dec 27 21:24:56 2001 +0000
@@ -0,0 +1,172 @@
+/*
+ * NuppelVideo 0.05 file parser
+ * for MPlayer
+ * by Panagiotis Issaris <takis@lumumba.luc.ac.be>
+ *
+ * Reworked by alex
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
+#include "stream.h"
+#include "demuxer.h"
+#include "stheader.h"
+#include "nuppelvideo.h" 
+//#include "RTjpegN.h"
+//#include "minilzo.h"
+
+
+struct nuv_signature
+{ 
+	char finfo[12];     /* "NuppelVideo" + \0 */
+	char version[5];    /* "0.05" + \0 */
+};
+
+
+void demux_seek_nuv ( demuxer_t *demuxer, float rel_seek_secs, int flags )
+{
+}
+
+
+int demux_nuv_fill_buffer ( demuxer_t *demuxer )
+{
+	struct rtframeheader rtjpeg_frameheader;
+	int orig_pos;
+
+	orig_pos = stream_tell ( demuxer->stream );
+	if (stream_read ( demuxer->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader))
+	    return 0; /* EOF */
+
+#if 0
+	printf("NUV frame read: %c packetlength: %d orig: %d new: %d\n", rtjpeg_frameheader.frametype,rtjpeg_frameheader.packetlength, orig_pos, orig_pos+rtjpeg_frameheader.packetlength);
+#endif
+
+	/* Skip Seekpoint, Text and Sync for now */
+	if ((rtjpeg_frameheader.frametype == 'R') ||
+	    (rtjpeg_frameheader.frametype == 'T') ||
+	    (rtjpeg_frameheader.frametype == 'S'))
+	    return 1;
+	
+	if (((rtjpeg_frameheader.frametype == 'D') &&
+	    (rtjpeg_frameheader.comptype == 'R')) ||
+	    (rtjpeg_frameheader.frametype == 'V'))
+	{
+	    /* put RTjpeg tables, Video info to video buffer */
+	    stream_seek ( demuxer->stream, orig_pos );
+	    ds_read_packet ( demuxer->video, demuxer->stream, rtjpeg_frameheader.packetlength + 12, 
+		rtjpeg_frameheader.timecode / 1000, orig_pos, 0 );
+	}
+	
+	/* copy PCM only */
+	if (demuxer->audio && (rtjpeg_frameheader.frametype == 'A') &&
+	    (rtjpeg_frameheader.comptype == '0'))
+	{
+	    /* put Audio to audio buffer */
+	    stream_seek ( demuxer->stream, orig_pos );
+	    ds_read_packet ( demuxer->audio, demuxer->stream, rtjpeg_frameheader.packetlength + 12, 
+		rtjpeg_frameheader.timecode / 1000, orig_pos, 0 );
+	}
+
+	return 1;
+}
+
+
+demuxer_t* demux_open_nuv ( demuxer_t* demuxer )
+{
+	sh_video_t *sh_video = NULL;
+	sh_audio_t *sh_audio = NULL;
+	struct rtfileheader rtjpeg_fileheader;
+	struct rtframeheader rtjpeg_frameheader;
+	unsigned long int tbls[128];
+	int bytes_read;
+
+	/* Go to the start */
+	stream_reset(demuxer->stream);
+	stream_seek(demuxer->stream, 0);
+
+	stream_read ( demuxer->stream, (char*)& rtjpeg_fileheader, sizeof(rtjpeg_fileheader) );
+
+	/* no video */
+	if (rtjpeg_fileheader.videoblocks == 0)
+	{
+	    printf("No video blocks in file\n");
+	    return NULL;
+	}
+
+	/* Create a new video stream header */
+	sh_video = new_sh_video ( demuxer, 0 );
+
+	/* Make sure the demuxer knows about the new video stream header
+	 * (even though new_sh_video() ought to take care of it)
+	 */
+	demuxer->video->sh = sh_video;
+
+	/* Make sure that the video demuxer stream header knows about its
+	 * parent video demuxer stream (this is getting wacky), or else
+	 * video_read_properties() will choke
+         */
+	sh_video->ds = demuxer->video;
+
+	/* Custom fourcc for internal MPlayer use */
+	sh_video->format = mmioFOURCC('N', 'U', 'V', '1');
+
+	sh_video->disp_w = rtjpeg_fileheader.width;
+	sh_video->disp_h = rtjpeg_fileheader.height;
+	
+	sh_video->aspect = rtjpeg_fileheader.aspect;
+
+	/* Get the FPS */
+	sh_video->fps = rtjpeg_fileheader.fps;
+	sh_video->frametime = 1 / sh_video->fps;
+
+#if 0
+	if (rtjpeg_fileheader.audioblocks != 0)
+	{
+	    sh_audio = new_sh_audio(demuxer, 0);
+	    demuxer->audio->sh = sh_audio;
+	    sh_audio->ds = demuxer->audio;
+	    sh_audio->format = 0x1;
+	    sh_audio->channels = 2;
+	    sh_audio->samplerate = 44100;
+	    
+	    sh_audio->wf = malloc(sizeof(WAVEFORMATEX));
+	    memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX));
+	    sh_audio->wf->wFormatTag = sh_audio->format;
+	    sh_audio->wf->nChannels = sh_audio->channels;
+	    sh_audio->wf->wBitsPerSample = 16;
+	    sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
+	    sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels*
+		sh_audio->wf->wBitsPerSample*sh_audio->wf->nSamplesPerSec/8;
+	    sh_audio->wf->nBlockAlign = sh_audio->channels * 2;
+	    sh_audio->wf->cbSize = 0;
+	}
+#endif
+
+	return demuxer;
+}
+
+int nuv_check_file ( demuxer_t* demuxer )
+{
+	struct nuv_signature ns;
+
+	/* Store original position */
+	int orig_pos = stream_tell(demuxer->stream);
+
+	mp_msg ( MSGT_DEMUX, MSGL_V, "Checking for NuppelVideo\n" );
+
+	stream_read(demuxer->stream,(char*)&ns,sizeof(ns));
+
+	if ( strncmp ( ns.finfo, "NuppelVideo", 12 ) ) 
+		return 0; /* Not a NuppelVideo file */
+	if ( strncmp ( ns.version, "0.05", 5 ) ) 
+		return 0; /* Wrong version NuppelVideo file */
+
+	/* Return to original position */
+	stream_seek ( demuxer->stream, orig_pos );
+	return 1;
+}
--- a/libmpdemux/demuxer.c	Thu Dec 27 19:54:36 2001 +0000
+++ b/libmpdemux/demuxer.c	Thu Dec 27 21:24:56 2001 +0000
@@ -159,7 +159,8 @@
 int demux_asf_fill_buffer(demuxer_t *demux);
 int demux_mov_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
 int demux_vivo_fill_buffer(demuxer_t *demux);
-int demux_real_fill_buffer(demuxer_t *demux);
+int demux_real_fill_buffer(demuxer_t *demuxer);
+int demux_nuv_fill_buffer(demuxer_t *demux);
 #ifdef USE_TV
 #include "tv.h"
 extern tvi_handle_t *tv_handler;
@@ -184,6 +185,7 @@
     case DEMUXER_TYPE_MOV: return demux_mov_fill_buffer(demux,ds);
     case DEMUXER_TYPE_VIVO: return demux_vivo_fill_buffer(demux);
     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);
 #endif
@@ -371,6 +373,9 @@
 extern int real_check_file(demuxer_t *demuxer);
 extern void demux_open_real(demuxer_t *demuxer);
 
+extern int nuv_check_file(demuxer_t *demuxer);
+extern void demux_open_nuv(demuxer_t *demuxer);
+
 demuxer_t* demux_open(stream_t *stream,int file_format,int audio_id,int video_id,int dvdsub_id){
 
 //int file_format=(*file_format_ptr);
@@ -426,6 +431,14 @@
       file_format=DEMUXER_TYPE_Y4M;
   }
 }
+//=============== Try to open as NUV file: =================
+if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_NUV){
+  demuxer=new_demuxer(stream,DEMUXER_TYPE_NUV,audio_id,video_id,dvdsub_id);
+  if(nuv_check_file(demuxer)){
+      mp_msg(MSGT_DEMUXER,MSGL_INFO,"Detected NuppelVideo file format!\n");
+      file_format=DEMUXER_TYPE_NUV;
+  }
+}
 //=============== Try to open as MOV file: =================
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MOV){
   demuxer=new_demuxer(stream,DEMUXER_TYPE_MOV,audio_id,video_id,dvdsub_id);
@@ -551,6 +564,10 @@
   return (demuxer_t*) demux_open_avi(demuxer);
 //  break;
  }
+ case DEMUXER_TYPE_NUV: {
+  demux_open_nuv(demuxer);
+  break;
+ }
  case DEMUXER_TYPE_VIVO: {
   demux_open_vivo(demuxer);
   break;
--- a/libmpdemux/demuxer.h	Thu Dec 27 19:54:36 2001 +0000
+++ b/libmpdemux/demuxer.h	Thu Dec 27 21:24:56 2001 +0000
@@ -15,6 +15,7 @@
 #define DEMUXER_TYPE_FLI 10
 #define DEMUXER_TYPE_REAL 11
 #define DEMUXER_TYPE_Y4M 12
+#define DEMUXER_TYPE_NUV 13
 
 #define DEMUXER_TIME_NONE 0
 #define DEMUXER_TIME_PTS 1