[MPlayer-cvslog] CVS: main/libmpdemux demux_vqf.c, NONE, 1.1 Makefile, 1.84, 1.85 demuxer.c, 1.179, 1.180 demuxer.h, 1.72, 1.73
Roberto Togni CVS
syncmail at mplayerhq.hu
Wed Dec 29 20:51:59 CET 2004
- Previous message: [MPlayer-cvslog] CVS: main/libmpcodecs ad_twin.c, NONE, 1.1 vqf.h, NONE, 1.1 Makefile, 1.137, 1.138 ad.c, 1.19, 1.20
- Next message: [MPlayer-cvslog] CVS: main ChangeLog,1.161,1.162
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
CVS change done by Roberto Togni CVS
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv7943/libmpdemux
Modified Files:
Makefile demuxer.c demuxer.h
Added Files:
demux_vqf.c
Log Message:
TwinVQ decoder and demuxer
--- NEW FILE ---
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include "bswap.h"
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
#include "../libmpcodecs/vqf.h"
extern void resync_audio_stream(sh_audio_t *sh_audio);
int demux_probe_vqf(demuxer_t* demuxer)
{
char buf[KEYWORD_BYTES];
stream_t *s;
s = demuxer->stream;
stream_read(s,buf,KEYWORD_BYTES);
if(memcmp(buf,"TWIN",KEYWORD_BYTES)==0) return 1; /*version: 97012000*/
return 0;
}
demuxer_t* demux_open_vqf(demuxer_t* demuxer) {
sh_audio_t* sh_audio;
WAVEFORMATEX* w;
stream_t *s;
headerInfo *hi;
s = demuxer->stream;
sh_audio = new_sh_audio(demuxer,0);
sh_audio->wf = w = (WAVEFORMATEX*)malloc(sizeof(WAVEFORMATEX)+sizeof(headerInfo));
hi = (headerInfo *)&w[1];
memset(hi,0,sizeof(headerInfo));
w->wFormatTag = 0x1;
sh_audio->format = mmioFOURCC('T','W','I','N'); /* TWinVQ */
w->nChannels = sh_audio->channels = 2;
w->nSamplesPerSec = sh_audio->samplerate = 44100;
w->nAvgBytesPerSec = w->nSamplesPerSec*sh_audio->channels*2;
w->nBlockAlign = 0;
sh_audio->samplesize = 2;
w->wBitsPerSample = 8*sh_audio->samplesize;
w->cbSize = 0;
strcpy(hi->ID,"TWIN");
stream_read(s,hi->ID+KEYWORD_BYTES,VERSION_BYTES); /* fourcc+version_id */
while(1)
{
char chunk_id[4];
unsigned chunk_size;
hi->size=chunk_size=stream_read_dword(s); /* include itself */
stream_read(s,chunk_id,4);
if(*((uint32_t *)&chunk_id[0])==mmioFOURCC('C','O','M','M'))
{
char buf[chunk_size-8];
unsigned i,subchunk_size;
if(stream_read(s,buf,chunk_size-8)!=chunk_size-8) return NULL;
i=0;
subchunk_size=be2me_32(*((uint32_t *)&buf[0]));
hi->channelMode=be2me_32(*((uint32_t *)&buf[4]));
w->nChannels=sh_audio->channels=hi->channelMode+1; /*0-mono;1-stereo*/
hi->bitRate=be2me_32(*((uint32_t *)&buf[8]));
sh_audio->i_bps=hi->bitRate*1000/8; /* bitrate kbit/s */
w->nAvgBytesPerSec = sh_audio->i_bps;
hi->samplingRate=be2me_32(*((uint32_t *)&buf[12]));
switch(hi->samplingRate){
case 44:
w->nSamplesPerSec=44100;
break;
case 22:
w->nSamplesPerSec=22050;
break;
case 11:
w->nSamplesPerSec=11025;
break;
default:
w->nSamplesPerSec=hi->samplingRate*1000;
break;
}
sh_audio->samplerate=w->nSamplesPerSec;
hi->securityLevel=be2me_32(*((uint32_t *)&buf[16]));
w->nBlockAlign = 0;
sh_audio->samplesize = 4;
w->wBitsPerSample = 8*sh_audio->samplesize;
w->cbSize = 0;
i+=subchunk_size+4;
while(i<chunk_size-8)
{
unsigned slen,sid;
char sdata[chunk_size];
sid=*((uint32_t *)&buf[i]); i+=4;
slen=be2me_32(*((uint32_t *)&buf[i])); i+=4;
if(sid==mmioFOURCC('D','S','I','Z'))
{
hi->Dsiz=be2me_32(*((uint32_t *)&buf[i]));
continue; /* describes the same info as size of DATA chunk */
}
memcpy(sdata,&buf[i],slen); sdata[slen]=0; i+=slen;
if(sid==mmioFOURCC('N','A','M','E'))
{
memcpy(hi->Name,sdata,min(BUFSIZ,slen));
demux_info_add(demuxer,"Title",sdata);
}
else
if(sid==mmioFOURCC('A','U','T','H'))
{
memcpy(hi->Auth,sdata,min(BUFSIZ,slen));
demux_info_add(demuxer,"Author",sdata);
}
else
if(sid==mmioFOURCC('C','O','M','T'))
{
memcpy(hi->Comt,sdata,min(BUFSIZ,slen));
demux_info_add(demuxer,"Comment",sdata);
}
else
if(sid==mmioFOURCC('(','c',')',' '))
{
memcpy(hi->Cpyr,sdata,min(BUFSIZ,slen));
demux_info_add(demuxer,"Copyright",sdata);
}
else
if(sid==mmioFOURCC('F','I','L','E'))
{
memcpy(hi->File,sdata,min(BUFSIZ,slen));
}
else
if(sid==mmioFOURCC('A','L','B','M')) demux_info_add(demuxer,"Album",sdata);
else
if(sid==mmioFOURCC('Y','E','A','R')) demux_info_add(demuxer,"Date",sdata);
else
if(sid==mmioFOURCC('T','R','A','C')) demux_info_add(demuxer,"Track",sdata);
else
if(sid==mmioFOURCC('E','N','C','D')) demux_info_add(demuxer,"Encoder",sdata);
else
mp_msg(MSGT_DEMUX, MSGL_V, "Unhandled subchunk '%c%c%c%c'='%s'\n",((char *)&sid)[0],((char *)&sid)[1],((char *)&sid)[2],((char *)&sid)[3],sdata);
/* other stuff is unrecognized due untranslatable japan's idiomatics */
}
}
else
if(*((uint32_t *)&chunk_id[0])==mmioFOURCC('D','A','T','A'))
{
demuxer->movi_start=stream_tell(s);
demuxer->movi_end=demuxer->movi_start+chunk_size-8;
mp_msg(MSGT_DEMUX, MSGL_V, "Found data at %llX size %llu\n",demuxer->movi_start,demuxer->movi_end);
/* Done! play it */
break;
}
else
{
mp_msg(MSGT_DEMUX, MSGL_V, "Unhandled chunk '%c%c%c%c' %u bytes\n",((char *)&chunk_id)[0],((char *)&chunk_id)[1],((char *)&chunk_id)[2],((char *)&chunk_id)[3],chunk_size);
stream_skip(s,chunk_size-8); /*unknown chunk type */
}
}
demuxer->audio->sh = sh_audio;
sh_audio->ds = demuxer->audio;
stream_seek(s,demuxer->movi_start);
demuxer->seekable=0;
return demuxer;
}
int demux_vqf_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) {
sh_audio_t* sh_audio = demuxer->audio->sh;
int l = sh_audio->wf->nAvgBytesPerSec;
off_t spos = stream_tell(demuxer->stream);
demux_packet_t* dp;
if(stream_eof(demuxer->stream))
return 0;
dp = new_demux_packet(l);
ds->pts = spos / (float)(sh_audio->wf->nAvgBytesPerSec);
ds->pos = spos;
l=stream_read(demuxer->stream,dp->buffer,l);
resize_demux_packet(dp,l);
ds_add_packet(ds,dp);
return 1;
}
void demux_seek_vqf(demuxer_t *demuxer,float rel_seek_secs,int flags){
#if 0
stream_t* s = demuxer->stream;
sh_audio_t* sh_audio = demuxer->audio->sh;
off_t base,pos;
base = (flags & 1) ? demuxer->movi_start : stream_tell(s);
if(flags & 2)
pos = base + ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs);
else
pos = base + (rel_seek_secs*sh_audio->i_bps);
pos -= (pos % (sh_audio->channels * sh_audio->samplesize) );
stream_seek(s,pos);
resync_audio_stream(sh_audio);
#endif
}
void demux_close_vqf(demuxer_t* demuxer) {}
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- Makefile 15 Dec 2004 18:39:51 -0000 1.84
+++ Makefile 29 Dec 2004 19:51:56 -0000 1.85
@@ -3,7 +3,7 @@
include ../config.mak
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.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 demux_ogg.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c demux_lavf.c demux_nsv.c
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.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 demux_ogg.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c demux_lavf.c demux_nsv.c demux_vqf.c
ifeq ($(XMMS_PLUGINS),yes)
SRCS += demux_xmms.c
endif
Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -r1.179 -r1.180
--- demuxer.c 27 Dec 2004 17:30:14 -0000 1.179
+++ demuxer.c 29 Dec 2004 19:51:56 -0000 1.180
@@ -156,6 +156,7 @@
extern void demux_close_ra(demuxer_t* demuxer);
extern void demux_close_ty(demuxer_t* demuxer);
extern void demux_close_lavf(demuxer_t* demuxer);
+extern void demux_close_vqf(demuxer_t* demuxer);
#ifdef USE_TV
@@ -241,6 +242,8 @@
demux_close_mpg(demuxer); break;
case DEMUXER_TYPE_REALAUDIO:
demux_close_ra(demuxer); break;
+ case DEMUXER_TYPE_VQF:
+ demux_close_vqf(demuxer); break;
#ifdef USE_LIBAVFORMAT
case DEMUXER_TYPE_LAVF:
demux_close_lavf(demuxer); break;
@@ -326,6 +329,7 @@
int demux_gif_fill_buffer(demuxer_t *demux);
int demux_ts_fill_buffer(demuxer_t *demux);
int demux_ra_fill_buffer(demuxer_t *demux);
+int demux_vqf_fill_buffer(demuxer_t *demux);
extern int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
extern int demux_ogg_fill_buffer(demuxer_t *d);
@@ -390,6 +394,7 @@
case DEMUXER_TYPE_MPEG_TS:
return demux_ts_fill_buffer(demux);
case DEMUXER_TYPE_REALAUDIO: return demux_ra_fill_buffer(demux);
+ case DEMUXER_TYPE_VQF: return demux_vqf_fill_buffer(demux);
#ifdef USE_LIBAVFORMAT
case DEMUXER_TYPE_LAVF: return demux_lavf_fill_buffer(demux);
#endif
@@ -634,6 +639,8 @@
extern int demux_open_mkv(demuxer_t *demuxer);
extern int ra_check_file(demuxer_t *demuxer);
extern int demux_open_ra(demuxer_t* demuxer);
+extern int demux_probe_vqf(demuxer_t *demuxer);
+extern int demux_open_vqf(demuxer_t* demuxer);
#ifdef HAVE_MATROSKA
extern int demux_mkv_open(demuxer_t *demuxer);
#endif
@@ -809,6 +816,18 @@
}
}
+//=============== Try to open as VQF file: =================
+if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_VQF){
+ demuxer=new_demuxer(stream,DEMUXER_TYPE_VQF,audio_id,video_id,dvdsub_id);
+ if(demux_probe_vqf(demuxer)){
+ mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"VQF");
+ file_format=DEMUXER_TYPE_VQF;
+ } else {
+ free_demuxer(demuxer);
+ demuxer = NULL;
+ }
+}
+
//=============== Try based on filename EXTENSION: =================
// Ok. We're over the stable detectable fileformats, the next ones are a bit
// fuzzy. So by default (extension_parsing==1) try extension-based detection
@@ -1355,6 +1374,10 @@
if (!demux_open_ra(demuxer)) return NULL;
break;
}
+ case DEMUXER_TYPE_VQF: {
+ if (!demux_open_vqf(demuxer)) return NULL;
+ break;
+ }
#ifdef USE_LIBAVFORMAT
case DEMUXER_TYPE_LAVF: {
if (!demux_open_lavf(demuxer)) return NULL;
@@ -1474,6 +1497,7 @@
extern void demux_rawvideo_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
extern void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
extern void demux_mkv_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
+extern void demux_seek_vqf(demuxer_t *demuxer,float rel_seek_secs,int flags);
int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
demux_stream_t *d_audio=demuxer->audio;
@@ -1576,6 +1600,8 @@
case DEMUXER_TYPE_LAVF:
demux_seek_lavf(demuxer,rel_seek_secs,flags); break;
#endif
+ case DEMUXER_TYPE_VQF:
+ demux_seek_vqf(demuxer,rel_seek_secs,flags); break;
} // switch(demuxer->file_format)
Index: demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- demuxer.h 15 Dec 2004 18:39:51 -0000 1.72
+++ demuxer.h 29 Dec 2004 19:51:56 -0000 1.73
@@ -44,11 +44,12 @@
#define DEMUXER_TYPE_LMLM4 34
#define DEMUXER_TYPE_LAVF 35
#define DEMUXER_TYPE_NSV 36
+#define DEMUXER_TYPE_VQF 37
// This should always match the higest demuxer type number.
// Unless you want to disallow users to force the demuxer to some types
#define DEMUXER_TYPE_MIN 0
-#define DEMUXER_TYPE_MAX 36
+#define DEMUXER_TYPE_MAX 37
#define DEMUXER_TYPE_DEMUXERS (1<<16)
// A virtual demuxer type for the network code
- Previous message: [MPlayer-cvslog] CVS: main/libmpcodecs ad_twin.c, NONE, 1.1 vqf.h, NONE, 1.1 Makefile, 1.137, 1.138 ad.c, 1.19, 1.20
- Next message: [MPlayer-cvslog] CVS: main ChangeLog,1.161,1.162
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list