annotate libmpdemux/demux_audio.c @ 7703:386e76d9c0cc

argh 100l
author nexus
date Thu, 10 Oct 2002 09:14:53 +0000
parents e29f95ed5d36
children f1e6a68a42f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
1
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
2 #include "config.h"
4712
9262f4dc332f mp3 position fixed
arpi
parents: 4700
diff changeset
3 #include "../mp_msg.h"
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
4
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
5 #include <stdlib.h>
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
6 #include <stdio.h>
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
7 #include "stream.h"
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
8 #include "demuxer.h"
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
9 #include "stheader.h"
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
10 #include "genres.h"
6763
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
11 #include "mp3_hdr.h"
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
12
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
13 #include <string.h>
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
14 #ifdef MP_DEBUG
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
15 #include <assert.h>
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
16 #endif
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
17
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
18 #define MP3 1
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
19 #define WAV 2
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
20
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
21
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
22 #define HDR_SIZE 4
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
23
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
24 typedef struct da_priv {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
25 int frmt;
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
26 float last_pts;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
27 } da_priv_t;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
28
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
29 extern void free_sh_audio(sh_audio_t* sh);
4700
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
30 extern void resync_audio_stream(sh_audio_t *sh_audio);
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
31
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
32 static int hr_mp3_seek = 0;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
33
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
34 int demux_audio_open(demuxer_t* demuxer) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
35 stream_t *s;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
36 sh_audio_t* sh_audio;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
37 uint8_t hdr[HDR_SIZE];
6763
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
38 int st_pos = 0,frmt = 0, n = 0, pos = 0, step, mp3_freq,mp3_chans;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
39 da_priv_t* priv;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
40 #ifdef MP_DEBUG
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
41 assert(demuxer != NULL);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
42 assert(demuxer->stream != NULL);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
43 #endif
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
44
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
45 s = demuxer->stream;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
46
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
47 while(n < 5 && ! s->eof) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
48 st_pos = stream_tell(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
49 step = 1;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
50 if(pos < HDR_SIZE) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
51 stream_read(s,&hdr[pos],HDR_SIZE-pos);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
52 pos = HDR_SIZE;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
53 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
54
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
55 if( hdr[0] == 'R' && hdr[1] == 'I' && hdr[2] == 'F' && hdr[3] == 'F' ) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
56 stream_skip(s,4);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
57 if(s->eof)
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
58 break;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
59 stream_read(s,hdr,4);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
60 if(s->eof)
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
61 break;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
62 if(hdr[0] != 'W' || hdr[1] != 'A' || hdr[2] != 'V' || hdr[3] != 'E' )
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
63 stream_skip(s,-8);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
64 else
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
65 // We found wav header. Now we can have 'fmt ' or a mp3 header
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
66 // empty the buffer
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
67 step = 4;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
68 } else if( hdr[0] == 'f' && hdr[1] == 'm' && hdr[2] == 't' && hdr[3] == ' ' ) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
69 frmt = WAV;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
70 break;
6763
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
71 } else if((n = mp_get_mp3_header(hdr,&mp3_chans,&mp3_freq)) > 0) {
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
72 frmt = MP3;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
73 break;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
74 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
75 // Add here some other audio format detection
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
76 if(step < HDR_SIZE)
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
77 memmove(hdr,&hdr[step],HDR_SIZE-step);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
78 pos -= step;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
79 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
80
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
81 if(!frmt)
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
82 return 0;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
83
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
84 sh_audio = new_sh_audio(demuxer,0);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
85
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
86 switch(frmt) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
87 case MP3:
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
88 sh_audio->format = 0x55;
4717
b7054dadd2c0 We should skip exactly the first frame on mp3 files.
albeu
parents: 4712
diff changeset
89 demuxer->movi_start = st_pos-HDR_SIZE+n;
6763
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
90 sh_audio->audio.dwSampleSize= 0;
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
91 sh_audio->audio.dwScale = 1152;
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
92 sh_audio->audio.dwRate = mp3_freq;
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
93 sh_audio->wf = malloc(sizeof(WAVEFORMATEX));
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
94 sh_audio->wf->wFormatTag = sh_audio->format;
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
95 sh_audio->wf->nChannels = mp3_chans;
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
96 sh_audio->wf->nSamplesPerSec = mp3_freq;
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
97 sh_audio->wf->nBlockAlign = 1;
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
98 sh_audio->wf->wBitsPerSample = 16;
e29f95ed5d36 Fix vbr muxing and win32 codec crash on init
albeu
parents: 5812
diff changeset
99 sh_audio->wf->cbSize = 0;
4700
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
100 for(n = 0; n < 5 ; n++) {
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
101 pos = mp_decode_mp3_header(hdr);
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
102 if(pos < 0)
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
103 return 0;
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
104 stream_skip(s,pos-4);
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
105 if(s->eof)
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
106 return 0;
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
107 stream_read(s,hdr,4);
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
108 if(s->eof)
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
109 return 0;
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
110 }
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
111 if(s->end_pos) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
112 char tag[4];
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
113 stream_seek(s,s->end_pos-128);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
114 stream_read(s,tag,3);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
115 tag[3] = '\0';
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
116 if(strcmp(tag,"TAG"))
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
117 demuxer->movi_end = s->end_pos;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
118 else {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
119 char buf[31];
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
120 uint8_t g;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
121 demuxer->movi_end = stream_tell(s)-3;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
122 stream_read(s,buf,30);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
123 buf[30] = '\0';
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
124 demux_info_add(demuxer,"Title",buf);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
125 stream_read(s,buf,30);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
126 buf[30] = '\0';
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
127 demux_info_add(demuxer,"Artist",buf);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
128 stream_read(s,buf,30);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
129 buf[30] = '\0';
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
130 demux_info_add(demuxer,"Album",buf);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
131 stream_read(s,buf,4);
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
132 buf[4] = '\0';
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
133 demux_info_add(demuxer,"Year",buf);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
134 stream_read(s,buf,30);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
135 buf[30] = '\0';
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
136 demux_info_add(demuxer,"Comment",buf);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
137 if(buf[28] == 0 && buf[29] != 0) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
138 uint8_t trk = (uint8_t)buf[29];
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
139 sprintf(buf,"%d",trk);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
140 demux_info_add(demuxer,"Track",buf);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
141 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
142 g = stream_read_char(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
143 demux_info_add(demuxer,"Genre",genres[g]);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
144 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
145 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
146 break;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
147 case WAV: {
4720
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
148 unsigned int chunk_type;
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
149 unsigned int chunk_size;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
150 WAVEFORMATEX* w;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
151 int l;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
152 sh_audio->wf = w = (WAVEFORMATEX*)malloc(sizeof(WAVEFORMATEX));
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
153 l = stream_read_dword_le(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
154 if(l < 16) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
155 printf("Bad wav header length : too short !!!\n");
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
156 free_sh_audio(sh_audio);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
157 return 0;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
158 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
159 w->wFormatTag = sh_audio->format = stream_read_word_le(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
160 w->nChannels = sh_audio->channels = stream_read_word_le(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
161 w->nSamplesPerSec = sh_audio->samplerate = stream_read_dword_le(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
162 w->nAvgBytesPerSec = stream_read_dword_le(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
163 w->nBlockAlign = stream_read_word_le(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
164 w->wBitsPerSample = sh_audio->samplesize = stream_read_word_le(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
165 w->cbSize = 0;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
166 l -= 16;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
167 if(l)
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
168 stream_skip(s,l);
4720
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
169 do
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
170 {
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
171 chunk_type = stream_read_fourcc(demuxer->stream);
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
172 chunk_size = stream_read_dword_le(demuxer->stream);
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
173 if (chunk_type != mmioFOURCC('d', 'a', 't', 'a'))
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
174 stream_skip(demuxer->stream, chunk_size);
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
175 } while (chunk_type != mmioFOURCC('d', 'a', 't', 'a'));
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
176 demuxer->movi_start = stream_tell(s);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
177 demuxer->movi_end = s->end_pos;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
178 } break;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
179 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
180
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
181 priv = (da_priv_t*)malloc(sizeof(da_priv_t));
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
182 priv->frmt = frmt;
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
183 priv->last_pts = -1;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
184 demuxer->priv = priv;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
185 demuxer->audio->id = 0;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
186 demuxer->audio->sh = sh_audio;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
187 sh_audio->ds = demuxer->audio;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
188
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
189 if(stream_tell(s) != demuxer->movi_start)
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
190 stream_seek(s,demuxer->movi_start);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
191
4712
9262f4dc332f mp3 position fixed
arpi
parents: 4700
diff changeset
192 mp_msg(MSGT_DEMUX,MSGL_V,"demux_audio: audio data 0x%X - 0x%X \n",demuxer->movi_start,demuxer->movi_end);
9262f4dc332f mp3 position fixed
arpi
parents: 4700
diff changeset
193
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
194 return 1;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
195 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
196
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
197
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
198 int demux_audio_fill_buffer(demux_stream_t *ds) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
199 sh_audio_t* sh_audio;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
200 demuxer_t* demux;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
201 da_priv_t* priv;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
202 stream_t* s;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
203 #ifdef MP_DEBUG
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
204 assert(ds != NULL);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
205 assert(ds->sh != NULL);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
206 assert(ds->demuxer != NULL);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
207 #endif
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
208 sh_audio = ds->sh;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
209 demux = ds->demuxer;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
210 priv = demux->priv;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
211 s = demux->stream;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
212
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
213 if(s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) )
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
214 return 0;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
215
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
216 switch(priv->frmt) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
217 case MP3 :
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
218 while(! s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) ) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
219 uint8_t hdr[4];
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
220 int len;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
221 stream_read(s,hdr,4);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
222 len = mp_decode_mp3_header(hdr);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
223 if(len < 0) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
224 stream_skip(s,-3);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
225 } else {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
226 demux_packet_t* dp;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
227 if(s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) )
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
228 return 0;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
229 dp = new_demux_packet(len);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
230 memcpy(dp->buffer,hdr,4);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
231 stream_read(s,dp->buffer + 4,len-4);
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
232 priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + 1152/(float)sh_audio->samplerate;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
233 ds->pts = priv->last_pts - (ds_tell_pts(demux->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
234 ds_add_packet(ds,dp);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
235 return 1;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
236 }
4700
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
237 } break;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
238 case WAV : {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
239 int l = sh_audio->wf->nAvgBytesPerSec;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
240 demux_packet_t* dp = new_demux_packet(l);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
241 stream_read(s,dp->buffer,l);
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
242 priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + l/(float)sh_audio->i_bps;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
243 ds->pts = priv->last_pts - (ds_tell_pts(demux->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
244 ds_add_packet(ds,dp);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
245 return 1;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
246 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
247 default:
4720
10ad330c1733 fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents: 4717
diff changeset
248 printf("Audio demuxer : unknown format %d\n",priv->frmt);
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
249 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
250
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
251
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
252 return 0;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
253 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
254
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
255 static void high_res_mp3_seek(demuxer_t *demuxer,float time) {
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
256 uint8_t hdr[4];
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
257 int len,nf;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
258 da_priv_t* priv = demuxer->priv;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
259 sh_audio_t* sh = (sh_audio_t*)demuxer->audio->sh;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
260
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
261 nf = time*sh->samplerate/1152;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
262 while(nf > 0) {
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
263 stream_read(demuxer->stream,hdr,4);
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
264 len = mp_decode_mp3_header(hdr);
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
265 if(len < 0) {
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
266 stream_skip(demuxer->stream,-3);
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
267 continue;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
268 }
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
269 stream_skip(demuxer->stream,len-4);
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
270 priv->last_pts += 1152/(float)sh->samplerate;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
271 nf--;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
272 }
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
273 }
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
274
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
275 void demux_audio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
276 sh_audio_t* sh_audio;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
277 stream_t* s;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
278 int base,pos;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
279 float len;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
280 da_priv_t* priv;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
281
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
282 if(!(sh_audio = demuxer->audio->sh))
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
283 return;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
284 s = demuxer->stream;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
285 priv = demuxer->priv;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
286
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
287 if(priv->frmt == MP3 && hr_mp3_seek && !(flags & 2)) {
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
288 len = (flags & 1) ? rel_seek_secs - priv->last_pts : rel_seek_secs;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
289 if(len < 0) {
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
290 stream_seek(s,demuxer->movi_start);
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
291 len = priv->last_pts + len;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
292 priv->last_pts = 0;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
293 }
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
294 if(len > 0)
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
295 high_res_mp3_seek(demuxer,len);
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
296 sh_audio->timer = priv->last_pts - (ds_tell_pts(demuxer->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
297 resync_audio_stream(sh_audio);
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
298 return;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
299 }
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
300
5796
7a4b18b787c0 Fix % seeking
albeu
parents: 4764
diff changeset
301 base = flags&1 ? demuxer->movi_start : stream_tell(s);
7a4b18b787c0 Fix % seeking
albeu
parents: 4764
diff changeset
302 if(flags&2)
7a4b18b787c0 Fix % seeking
albeu
parents: 4764
diff changeset
303 pos = base + ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs);
7a4b18b787c0 Fix % seeking
albeu
parents: 4764
diff changeset
304 else
7a4b18b787c0 Fix % seeking
albeu
parents: 4764
diff changeset
305 pos = base + (rel_seek_secs*sh_audio->i_bps);
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
306
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
307 if(demuxer->movi_end && pos >= demuxer->movi_end) {
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
308 sh_audio->timer = (stream_tell(s) - demuxer->movi_start)/(float)sh_audio->i_bps;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
309 return;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
310 } else if(pos < demuxer->movi_start)
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
311 pos = demuxer->movi_start;
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
312
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
313 priv->last_pts = (pos-demuxer->movi_start)/(float)sh_audio->i_bps;
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
314 sh_audio->timer = priv->last_pts - (ds_tell_pts(demuxer->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
315
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
316 switch(priv->frmt) {
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
317 case WAV:
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
318 pos -= (pos % (sh_audio->channels * sh_audio->samplesize) );
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
319 // We need to decrease the pts by one step to make it the "last one"
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
320 priv->last_pts -= sh_audio->wf->nAvgBytesPerSec/(float)sh_audio->i_bps;
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
321 break;
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
322 }
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
323
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
324 stream_seek(s,pos);
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
325
4700
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
326 resync_audio_stream(sh_audio);
30131db5dfbb Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents: 4694
diff changeset
327
4694
a21735031d6a Audio file demuxer. Extended version for demuxer info.
albeu
parents:
diff changeset
328 }
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
329
5812
f9d23c2aa6b7 Uninit added
albeu
parents: 5796
diff changeset
330 void demux_close_audio(demuxer_t* demuxer) {
f9d23c2aa6b7 Uninit added
albeu
parents: 5796
diff changeset
331 da_priv_t* priv = demuxer->priv;
f9d23c2aa6b7 Uninit added
albeu
parents: 5796
diff changeset
332
f9d23c2aa6b7 Uninit added
albeu
parents: 5796
diff changeset
333 if(!priv)
f9d23c2aa6b7 Uninit added
albeu
parents: 5796
diff changeset
334 return;
f9d23c2aa6b7 Uninit added
albeu
parents: 5796
diff changeset
335 free(priv);
f9d23c2aa6b7 Uninit added
albeu
parents: 5796
diff changeset
336 }
f9d23c2aa6b7 Uninit added
albeu
parents: 5796
diff changeset
337
4764
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
338 /****************** Options stuff ******************/
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
339
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
340 #include "../cfgparser.h"
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
341
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
342 static config_t demux_audio_opts[] = {
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
343 { "hr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, NULL },
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
344 { "nohr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, NULL},
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
345 {NULL, NULL, 0, 0, 0, 0, NULL}
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
346 };
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
347
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
348 void demux_audio_register_options(m_config_t* cfg) {
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
349 m_config_register_options(cfg,demux_audio_opts);
9579496a91db Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents: 4720
diff changeset
350 }