annotate wav.c @ 1280:8505bbb024c5 libavformat

scan s->probesize packets instead of MAX_SCAN_PACKETS (that is still the default value)
author nicodvb
date Sun, 27 Aug 2006 12:22:40 +0000
parents 6a5e58d2114b
children 0899bfe4105c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 874
diff changeset
1 /*
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * WAV encoder and decoder
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2001, 2002 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 893
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include "avformat.h"
1142
e3a585883bbd Move initialisations and internal symbols in allformats.h,
gpoirier
parents: 1136
diff changeset
20 #include "allformats.h"
1172
6a5e58d2114b move common stuff from avienc.c and wav.c to new file riff.c
mru
parents: 1169
diff changeset
21 #include "riff.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
23 typedef struct {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24 offset_t data;
1136
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
25 offset_t data_end;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 } WAVContext;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27
1149
02e10bcc0e0d Fix compilation with --disable-muxers.
diego
parents: 1142
diff changeset
28 #ifdef CONFIG_MUXERS
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 static int wav_write_header(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 WAVContext *wav = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
32 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 offset_t fmt;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
35 put_tag(pb, "RIFF");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36 put_le32(pb, 0); /* file length */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 put_tag(pb, "WAVE");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39 /* format header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40 fmt = start_tag(pb, "fmt ");
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
41 if (put_wav_header(pb, s->streams[0]->codec) < 0) {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 av_free(wav);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45 end_tag(pb, fmt);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
47 av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
645
9fc2d2cc4608 wav timestamp truncation fix by (Wolfram Gloger <wmglo dent.med.uni-muenchen de>)
michael
parents: 587
diff changeset
48
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49 /* data header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50 wav->data = start_tag(pb, "data");
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 874
diff changeset
51
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52 put_flush_packet(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 413
diff changeset
57 static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 ByteIOContext *pb = &s->pb;
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 413
diff changeset
60 put_buffer(pb, pkt->data, pkt->size);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
61 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
62 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
63
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
64 static int wav_write_trailer(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
65 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
66 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
67 WAVContext *wav = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68 offset_t file_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 if (!url_is_streamed(&s->pb)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 end_tag(pb, wav->data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
73 /* update file size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
74 file_size = url_ftell(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75 url_fseek(pb, 4, SEEK_SET);
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
76 put_le32(pb, (uint32_t)(file_size - 8));
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
77 url_fseek(pb, file_size, SEEK_SET);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
79 put_flush_packet(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
80 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
82 }
858
66cc656ea404 Replace CONFIG_ENCODERS/CONFIG_DECODERS with CONFIG_MUXERS/CONFIG_DEMUXERS
diego
parents: 846
diff changeset
83 #endif //CONFIG_MUXERS
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85 /* return the size of the found tag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
86 /* XXX: > 2GB ? */
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
87 static int find_tag(ByteIOContext *pb, uint32_t tag1)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 unsigned int tag;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
90 int size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
91
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
92 for(;;) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93 if (url_feof(pb))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 tag = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 size = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 if (tag == tag1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
98 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
99 url_fseek(pb, size, SEEK_CUR);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
100 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
101 if (size < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
102 size = 0x7fffffff;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103 return size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
105
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
106 static int wav_probe(AVProbeData *p)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
107 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
108 /* check file header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
109 if (p->buf_size <= 32)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
110 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
111 if (p->buf[0] == 'R' && p->buf[1] == 'I' &&
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
112 p->buf[2] == 'F' && p->buf[3] == 'F' &&
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
113 p->buf[8] == 'W' && p->buf[9] == 'A' &&
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
114 p->buf[10] == 'V' && p->buf[11] == 'E')
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
115 return AVPROBE_SCORE_MAX;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
116 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
117 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
118 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
119
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
120 /* wav input */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
121 static int wav_read_header(AVFormatContext *s,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
122 AVFormatParameters *ap)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
123 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
124 int size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
125 unsigned int tag;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
126 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
127 AVStream *st;
1136
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
128 WAVContext *wav = s->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
129
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
130 /* check RIFF header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
131 tag = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
132
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
133 if (tag != MKTAG('R', 'I', 'F', 'F'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
134 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
135 get_le32(pb); /* file size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
136 tag = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
137 if (tag != MKTAG('W', 'A', 'V', 'E'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
138 return -1;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 874
diff changeset
139
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
140 /* parse fmt header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
141 size = find_tag(pb, MKTAG('f', 'm', 't', ' '));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
142 if (size < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
143 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
144 st = av_new_stream(s, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
145 if (!st)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
146 return AVERROR_NOMEM;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
147
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
148 get_wav_header(pb, st->codec, size);
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
149 st->need_parsing = 1;
567
23b915bb10f5 set correct timebase
michael
parents: 564
diff changeset
150
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
151 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
567
23b915bb10f5 set correct timebase
michael
parents: 564
diff changeset
152
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
153 size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
154 if (size < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
155 return -1;
1136
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
156 wav->data_end= url_ftell(pb) + size;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
157 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
158 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
159
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
160 #define MAX_SIZE 4096
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
161
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
162 static int wav_read_packet(AVFormatContext *s,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
163 AVPacket *pkt)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
164 {
1136
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
165 int ret, size, left;
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
166 AVStream *st;
1136
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
167 WAVContext *wav = s->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
168
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
169 if (url_feof(&s->pb))
482
0fdc96c2f2fe sweeping change from -EIO -> AVERROR_IO
melanson
parents: 468
diff changeset
170 return AVERROR_IO;
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
171 st = s->streams[0];
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
172
1136
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
173 left= wav->data_end - url_ftell(&s->pb);
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
174 if(left <= 0){
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
175 left = find_tag(&(s->pb), MKTAG('d', 'a', 't', 'a'));
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
176 if (left < 0) {
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
177 return AVERROR_IO;
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
178 }
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
179 wav->data_end= url_ftell(&s->pb) + left;
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
180 }
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
181
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
182 size = MAX_SIZE;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
183 if (st->codec->block_align > 1) {
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
184 if (size < st->codec->block_align)
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
185 size = st->codec->block_align;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
186 size = (size / st->codec->block_align) * st->codec->block_align;
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
187 }
1136
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
188 size= FFMIN(size, left);
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
189 if (av_new_packet(pkt, size))
482
0fdc96c2f2fe sweeping change from -EIO -> AVERROR_IO
melanson
parents: 468
diff changeset
190 return AVERROR_IO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
191 pkt->stream_index = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
192
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
193 ret = get_buffer(&s->pb, pkt->data, pkt->size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
194 if (ret < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
195 av_free_packet(pkt);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
196 /* note: we need to modify the packet size here to handle the last
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
197 packet */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
198 pkt->size = ret;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
199 return ret;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
200 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
201
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
202 static int wav_read_close(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
203 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
204 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
205 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
206
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 874
diff changeset
207 static int wav_read_seek(AVFormatContext *s,
558
89bd76208427 100l (forgoten seeking functions)
michael
parents: 550
diff changeset
208 int stream_index, int64_t timestamp, int flags)
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
209 {
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
210 AVStream *st;
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
211
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
212 st = s->streams[0];
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 817
diff changeset
213 switch(st->codec->codec_id) {
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
214 case CODEC_ID_MP2:
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
215 case CODEC_ID_MP3:
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
216 case CODEC_ID_AC3:
496
112057e05179 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents: 482
diff changeset
217 case CODEC_ID_DTS:
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
218 /* use generic seeking with dynamically generated indexes */
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
219 return -1;
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
220 default:
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
221 break;
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
222 }
558
89bd76208427 100l (forgoten seeking functions)
michael
parents: 550
diff changeset
223 return pcm_read_seek(s, stream_index, timestamp, flags);
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
224 }
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
225
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
226 #ifdef CONFIG_WAV_DEMUXER
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
227 AVInputFormat wav_demuxer = {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
228 "wav",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
229 "wav format",
1136
d65cd7c3573e dont read over the end of a data chunk and at the end search for the next
michael
parents: 1122
diff changeset
230 sizeof(WAVContext),
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
231 wav_probe,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
232 wav_read_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
233 wav_read_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
234 wav_read_close,
309
6c9fddf8458c seeking support - fixed some ADPCM decoding cases
bellard
parents: 277
diff changeset
235 wav_read_seek,
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
236 };
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
237 #endif
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
238 #ifdef CONFIG_WAV_MUXER
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
239 AVOutputFormat wav_muxer = {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
240 "wav",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
241 "wav format",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
242 "audio/x-wav",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
243 "wav",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
244 sizeof(WAVContext),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
245 CODEC_ID_PCM_S16LE,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
246 CODEC_ID_NONE,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
247 wav_write_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
248 wav_write_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
249 wav_write_trailer,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
250 };
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
251 #endif