annotate libmpdemux/demux_vqf.c @ 28638:7b16ccf423b4

Add support for VDPAU deinterlacing, pullup, denoise and sharpening. Deinterlacing can not yet be toggled at runtime, and actually it does not seem to work at all...
author reimar
date Fri, 20 Feb 2009 09:45:48 +0000
parents 1a9b1b7e285f
children d643e4643313
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
1 #include "config.h"
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
2
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
3 #include <stdlib.h>
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
4 #include <stdio.h>
21372
1767c271d710 Remove bswap.h, use libavutil/bswap.h instead.
diego
parents: 19062
diff changeset
5 #include "libavutil/common.h"
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
6 #include "libavutil/intreadwrite.h"
21507
fa99b3d31d13 Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents: 21372
diff changeset
7 #include "mpbswap.h"
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
8
22605
4d81dbdf46b9 Add explicit location for headers from the stream/ directory.
diego
parents: 21531
diff changeset
9 #include "stream/stream.h"
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
10 #include "demuxer.h"
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
11 #include "stheader.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16877
diff changeset
12 #include "libmpcodecs/vqf.h"
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
13
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
14 static int demux_probe_vqf(demuxer_t* demuxer)
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
15 {
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
16 char buf[KEYWORD_BYTES];
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
17 stream_t *s;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
18 s = demuxer->stream;
15818
faust3
parents: 14276
diff changeset
19 if(stream_read(s,buf,KEYWORD_BYTES)!=KEYWORD_BYTES)
faust3
parents: 14276
diff changeset
20 return 0;
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
21 if(memcmp(buf,"TWIN",KEYWORD_BYTES)==0) return DEMUXER_TYPE_VQF; /*version: 97012000*/
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
22 return 0;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
23 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
24
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
25 static demuxer_t* demux_open_vqf(demuxer_t* demuxer) {
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
26 sh_audio_t* sh_audio;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
27 WAVEFORMATEX* w;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
28 stream_t *s;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
29 headerInfo *hi;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
30
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
31 s = demuxer->stream;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
32
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
33 sh_audio = new_sh_audio(demuxer,0);
19062
83c3afeab35d drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents: 17636
diff changeset
34 sh_audio->wf = w = malloc(sizeof(WAVEFORMATEX)+sizeof(headerInfo));
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
35 hi = (headerInfo *)&w[1];
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
36 memset(hi,0,sizeof(headerInfo));
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
37 w->wFormatTag = 0x1;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
38 sh_audio->format = mmioFOURCC('T','W','I','N'); /* TWinVQ */
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
39 w->nChannels = sh_audio->channels = 2;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
40 w->nSamplesPerSec = sh_audio->samplerate = 44100;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
41 w->nAvgBytesPerSec = w->nSamplesPerSec*sh_audio->channels*2;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
42 w->nBlockAlign = 0;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
43 sh_audio->samplesize = 2;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
44 w->wBitsPerSample = 8*sh_audio->samplesize;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
45 w->cbSize = 0;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
46 strcpy(hi->ID,"TWIN");
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
47 stream_read(s,hi->ID+KEYWORD_BYTES,VERSION_BYTES); /* fourcc+version_id */
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
48 while(1)
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
49 {
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
50 char chunk_id[4];
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
51 unsigned chunk_size;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
52 hi->size=chunk_size=stream_read_dword(s); /* include itself */
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
53 stream_read(s,chunk_id,4);
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
54 if (chunk_size < 8) return NULL;
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
55 chunk_size -= 8;
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
56 if(AV_RL32(chunk_id)==mmioFOURCC('C','O','M','M'))
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
57 {
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
58 char buf[BUFSIZ];
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
59 unsigned i,subchunk_size;
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
60 if (chunk_size > sizeof(buf) || chunk_size < 20) return NULL;
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
61 if(stream_read(s,buf,chunk_size)!=chunk_size) return NULL;
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
62 i=0;
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
63 subchunk_size = AV_RB32(buf);
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
64 hi->channelMode = AV_RB32(buf + 4);
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
65 w->nChannels=sh_audio->channels=hi->channelMode+1; /*0-mono;1-stereo*/
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
66 hi->bitRate = AV_RB32(buf + 8);
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
67 sh_audio->i_bps=hi->bitRate*1000/8; /* bitrate kbit/s */
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
68 w->nAvgBytesPerSec = sh_audio->i_bps;
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
69 hi->samplingRate = AV_RB32(buf + 12);
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
70 switch(hi->samplingRate){
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
71 case 44:
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
72 w->nSamplesPerSec=44100;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
73 break;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
74 case 22:
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
75 w->nSamplesPerSec=22050;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
76 break;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
77 case 11:
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
78 w->nSamplesPerSec=11025;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
79 break;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
80 default:
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
81 w->nSamplesPerSec=hi->samplingRate*1000;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
82 break;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
83 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
84 sh_audio->samplerate=w->nSamplesPerSec;
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
85 hi->securityLevel = AV_RB32(buf + 16);
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
86 w->nBlockAlign = 0;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
87 sh_audio->samplesize = 4;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
88 w->wBitsPerSample = 8*sh_audio->samplesize;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
89 w->cbSize = 0;
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
90 if (subchunk_size > chunk_size - 4) continue;
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
91 i+=subchunk_size+4;
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
92 while(i + 8 < chunk_size)
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
93 {
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
94 unsigned slen,sid;
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
95 char sdata[BUFSIZ];
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
96 sid = AV_RL32(buf + i); i+=4;
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
97 slen = AV_RB32(buf + i); i+=4;
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
98 if (slen > sizeof(sdata) - 1 || slen > chunk_size - i) break;
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
99 if(sid==mmioFOURCC('D','S','I','Z'))
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
100 {
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
101 hi->Dsiz=AV_RB32(buf + i);
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
102 continue; /* describes the same info as size of DATA chunk */
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
103 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
104 memcpy(sdata,&buf[i],slen); sdata[slen]=0; i+=slen;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
105 if(sid==mmioFOURCC('N','A','M','E'))
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
106 {
21531
a90aa203186c Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents: 21507
diff changeset
107 memcpy(hi->Name,sdata,FFMIN(BUFSIZ,slen));
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
108 demux_info_add(demuxer,"Title",sdata);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
109 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
110 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
111 if(sid==mmioFOURCC('A','U','T','H'))
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
112 {
21531
a90aa203186c Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents: 21507
diff changeset
113 memcpy(hi->Auth,sdata,FFMIN(BUFSIZ,slen));
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
114 demux_info_add(demuxer,"Author",sdata);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
115 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
116 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
117 if(sid==mmioFOURCC('C','O','M','T'))
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
118 {
21531
a90aa203186c Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents: 21507
diff changeset
119 memcpy(hi->Comt,sdata,FFMIN(BUFSIZ,slen));
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
120 demux_info_add(demuxer,"Comment",sdata);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
121 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
122 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
123 if(sid==mmioFOURCC('(','c',')',' '))
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
124 {
21531
a90aa203186c Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents: 21507
diff changeset
125 memcpy(hi->Cpyr,sdata,FFMIN(BUFSIZ,slen));
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
126 demux_info_add(demuxer,"Copyright",sdata);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
127 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
128 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
129 if(sid==mmioFOURCC('F','I','L','E'))
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
130 {
21531
a90aa203186c Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents: 21507
diff changeset
131 memcpy(hi->File,sdata,FFMIN(BUFSIZ,slen));
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
132 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
133 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
134 if(sid==mmioFOURCC('A','L','B','M')) demux_info_add(demuxer,"Album",sdata);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
135 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
136 if(sid==mmioFOURCC('Y','E','A','R')) demux_info_add(demuxer,"Date",sdata);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
137 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
138 if(sid==mmioFOURCC('T','R','A','C')) demux_info_add(demuxer,"Track",sdata);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
139 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
140 if(sid==mmioFOURCC('E','N','C','D')) demux_info_add(demuxer,"Encoder",sdata);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
141 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
142 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);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
143 /* other stuff is unrecognized due untranslatable japan's idiomatics */
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
144 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
145 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
146 else
28105
3d8fe3f052be Simplify: use AV_RL32/AV_RB32
reimar
parents: 28104
diff changeset
147 if(AV_RL32(chunk_id)==mmioFOURCC('D','A','T','A'))
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
148 {
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
149 demuxer->movi_start=stream_tell(s);
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
150 demuxer->movi_end=demuxer->movi_start+chunk_size;
16750
0a31740dd5e6 Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents: 16175
diff changeset
151 mp_msg(MSGT_DEMUX, MSGL_V, "Found data at %"PRIX64" size %"PRIu64"\n",demuxer->movi_start,demuxer->movi_end);
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
152 /* Done! play it */
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
153 break;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
154 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
155 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
156 {
28104
6ea280cd6b95 Avoid useless casts.
reimar
parents: 26299
diff changeset
157 mp_msg(MSGT_DEMUX, MSGL_V, "Unhandled chunk '%c%c%c%c' %u bytes\n",chunk_id[0],chunk_id[1],chunk_id[2],chunk_id[3],chunk_size);
28115
1a9b1b7e285f Add extra checks to avoid crashes with broken vqf files.
reimar
parents: 28105
diff changeset
158 stream_skip(s,chunk_size); /*unknown chunk type */
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
159 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
160 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
161
26299
4d56038ec730 Fix lots and lots of other demuxers broken by r26301
reimar
parents: 25883
diff changeset
162 demuxer->audio->id = 0;
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
163 demuxer->audio->sh = sh_audio;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
164 sh_audio->ds = demuxer->audio;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
165 stream_seek(s,demuxer->movi_start);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
166 demuxer->seekable=0;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
167 return demuxer;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
168 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
169
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
170 static int demux_vqf_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) {
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
171 sh_audio_t* sh_audio = demuxer->audio->sh;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
172 int l = sh_audio->wf->nAvgBytesPerSec;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
173 off_t spos = stream_tell(demuxer->stream);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
174 demux_packet_t* dp;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
175
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
176 if(stream_eof(demuxer->stream))
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
177 return 0;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
178
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
179 dp = new_demux_packet(l);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
180 ds->pts = spos / (float)(sh_audio->wf->nAvgBytesPerSec);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
181 ds->pos = spos;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
182
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
183 l=stream_read(demuxer->stream,dp->buffer,l);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
184 resize_demux_packet(dp,l);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
185 ds_add_packet(ds,dp);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
186
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
187 return 1;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
188 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
189
17636
b849a99cdc3c Second-try commit of this patch.
corey
parents: 17569
diff changeset
190 static void demux_seek_vqf(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
191 #if 0
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
192 stream_t* s = demuxer->stream;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
193 sh_audio_t* sh_audio = demuxer->audio->sh;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
194 off_t base,pos;
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
195
25883
baf32110d3fc Use defines to give names to the different seek flags.
reimar
parents: 25707
diff changeset
196 base = (flags & SEEK_ABSOLUTE) ? demuxer->movi_start : stream_tell(s);
baf32110d3fc Use defines to give names to the different seek flags.
reimar
parents: 25707
diff changeset
197 if(flags & SEEK_FACTOR)
14276
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
198 pos = base + ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
199 else
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
200 pos = base + (rel_seek_secs*sh_audio->i_bps);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
201
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
202 pos -= (pos % (sh_audio->channels * sh_audio->samplesize) );
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
203 stream_seek(s,pos);
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
204 #endif
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
205 }
fa80ed52127b TwinVQ decoder and demuxer
rtognimp
parents:
diff changeset
206
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
207 static void demux_close_vqf(demuxer_t* demuxer) {}
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
208
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
209
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 22605
diff changeset
210 const demuxer_desc_t demuxer_desc_vqf = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
211 "TwinVQ demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
212 "vqf",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
213 "VQF",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
214 "Nick Kurshev",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
215 "ported frm MPlayerXP",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
216 DEMUXER_TYPE_VQF,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
217 1, // safe autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
218 demux_probe_vqf,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
219 demux_vqf_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
220 demux_open_vqf,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
221 demux_close_vqf,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
222 demux_seek_vqf,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
223 NULL
6b86089c2edd Demuxer modularization
rtognimp
parents: 15818
diff changeset
224 };