| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * WAV demuxer | ||
| 3 | * Copyright (c) 2001, 2002 Fabrice Bellard | ||
| 4 | * | ||
| 5 | * Sony Wave64 demuxer | ||
| 6 | * RF64 demuxer | ||
| 7 | * Copyright (c) 2009 Daniel Verkamp | ||
| 8 | * | ||
| 9 | * BW64 demuxer | ||
| 10 | * | ||
| 11 | * This file is part of FFmpeg. | ||
| 12 | * | ||
| 13 | * FFmpeg is free software; you can redistribute it and/or | ||
| 14 | * modify it under the terms of the GNU Lesser General Public | ||
| 15 | * License as published by the Free Software Foundation; either | ||
| 16 | * version 2.1 of the License, or (at your option) any later version. | ||
| 17 | * | ||
| 18 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 21 | * Lesser General Public License for more details. | ||
| 22 | * | ||
| 23 | * You should have received a copy of the GNU Lesser General Public | ||
| 24 | * License along with FFmpeg; if not, write to the Free Software | ||
| 25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 26 | */ | ||
| 27 | |||
| 28 | #include <stdint.h> | ||
| 29 | |||
| 30 | #include "config_components.h" | ||
| 31 | #include "libavutil/avassert.h" | ||
| 32 | #include "libavutil/dict.h" | ||
| 33 | #include "libavutil/intreadwrite.h" | ||
| 34 | #include "libavutil/log.h" | ||
| 35 | #include "libavutil/mathematics.h" | ||
| 36 | #include "libavutil/mem.h" | ||
| 37 | #include "libavutil/opt.h" | ||
| 38 | #include "libavcodec/internal.h" | ||
| 39 | #include "avformat.h" | ||
| 40 | #include "avio.h" | ||
| 41 | #include "avio_internal.h" | ||
| 42 | #include "demux.h" | ||
| 43 | #include "id3v2.h" | ||
| 44 | #include "internal.h" | ||
| 45 | #include "metadata.h" | ||
| 46 | #include "pcm.h" | ||
| 47 | #include "riff.h" | ||
| 48 | #include "w64.h" | ||
| 49 | #include "spdif.h" | ||
| 50 | |||
| 51 | typedef struct WAVDemuxContext { | ||
| 52 | const AVClass *class; | ||
| 53 | int64_t data_end; | ||
| 54 | int w64; | ||
| 55 | AVStream *vst; | ||
| 56 | int64_t smv_data_ofs; | ||
| 57 | int smv_block_size; | ||
| 58 | int smv_frames_per_jpeg; | ||
| 59 | int smv_block; | ||
| 60 | int smv_last_stream; | ||
| 61 | int smv_eof; | ||
| 62 | int audio_eof; | ||
| 63 | int ignore_length; | ||
| 64 | int max_size; | ||
| 65 | int spdif; | ||
| 66 | int smv_given_first; | ||
| 67 | int unaligned; // e.g. if an odd number of bytes ID3 tag was prepended | ||
| 68 | int rifx; // RIFX: integer byte order for parameters is big endian | ||
| 69 | } WAVDemuxContext; | ||
| 70 | |||
| 71 | #define OFFSET(x) offsetof(WAVDemuxContext, x) | ||
| 72 | #define DEC AV_OPT_FLAG_DECODING_PARAM | ||
| 73 | static const AVOption demux_options[] = { | ||
| 74 | #define W64_DEMUXER_OPTIONS_OFFSET (1 * CONFIG_WAV_DEMUXER) | ||
| 75 | #if CONFIG_WAV_DEMUXER | ||
| 76 | { "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC }, | ||
| 77 | #endif | ||
| 78 | { "max_size", "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1 << 22, DEC }, | ||
| 79 | { NULL }, | ||
| 80 | }; | ||
| 81 | |||
| 82 | 578 | static void set_max_size(AVStream *st, WAVDemuxContext *wav) | |
| 83 | { | ||
| 84 |
2/2✓ Branch 0 taken 571 times.
✓ Branch 1 taken 7 times.
|
578 | if (wav->max_size <= 0) { |
| 85 | 571 | int max_size = ff_pcm_default_packet_size(st->codecpar); | |
| 86 |
1/2✓ Branch 0 taken 571 times.
✗ Branch 1 not taken.
|
571 | wav->max_size = max_size < 0 ? 4096 : max_size; |
| 87 | } | ||
| 88 | 578 | } | |
| 89 | |||
| 90 | 578 | static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav) | |
| 91 | { | ||
| 92 |
2/2✓ Branch 0 taken 538 times.
✓ Branch 1 taken 40 times.
|
578 | if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codecpar->codec_tag == 1) { |
| 93 | enum AVCodecID codec; | ||
| 94 | 538 | int len = 1<<16; | |
| 95 | 538 | int ret = ffio_ensure_seekback(s->pb, len); | |
| 96 | |||
| 97 |
1/2✓ Branch 0 taken 538 times.
✗ Branch 1 not taken.
|
538 | if (ret >= 0) { |
| 98 | 538 | uint8_t *buf = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE); | |
| 99 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 538 times.
|
538 | if (!buf) { |
| 100 | ✗ | ret = AVERROR(ENOMEM); | |
| 101 | } else { | ||
| 102 | 538 | int64_t pos = avio_tell(s->pb); | |
| 103 | 538 | len = ret = avio_read(s->pb, buf, len); | |
| 104 |
1/2✓ Branch 0 taken 538 times.
✗ Branch 1 not taken.
|
538 | if (len >= 0) { |
| 105 | 538 | ret = ff_spdif_probe(buf, len, &codec); | |
| 106 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 537 times.
|
538 | if (ret > AVPROBE_SCORE_EXTENSION) { |
| 107 | 1 | s->streams[0]->codecpar->codec_id = codec; | |
| 108 | 1 | wav->spdif = 1; | |
| 109 | } | ||
| 110 | } | ||
| 111 | 538 | avio_seek(s->pb, pos, SEEK_SET); | |
| 112 | 538 | av_free(buf); | |
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 538 times.
|
538 | if (ret < 0) |
| 117 | ✗ | av_log(s, AV_LOG_WARNING, "Cannot check for SPDIF\n"); | |
| 118 | } | ||
| 119 | 578 | } | |
| 120 | |||
| 121 | #if CONFIG_WAV_DEMUXER | ||
| 122 | |||
| 123 | 1451 | static int64_t next_tag(AVIOContext *pb, uint32_t *tag, int big_endian) | |
| 124 | { | ||
| 125 | 1451 | *tag = avio_rl32(pb); | |
| 126 |
1/2✓ Branch 0 taken 1451 times.
✗ Branch 1 not taken.
|
1451 | if (!big_endian) { |
| 127 | 1451 | return avio_rl32(pb); | |
| 128 | } else { | ||
| 129 | ✗ | return avio_rb32(pb); | |
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | /* RIFF chunks are always at even offsets relative to where they start. */ | ||
| 134 | 875 | static int64_t wav_seek_tag(WAVDemuxContext * wav, AVIOContext *s, int64_t offset, int whence) | |
| 135 | { | ||
| 136 |
3/4✓ Branch 0 taken 875 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 873 times.
|
875 | offset += offset < INT64_MAX && offset + wav->unaligned & 1; |
| 137 | |||
| 138 | 875 | return avio_seek(s, offset, whence); | |
| 139 | } | ||
| 140 | |||
| 141 | /* return the size of the found tag */ | ||
| 142 | 240 | static int64_t find_tag(WAVDemuxContext * wav, AVIOContext *pb, uint32_t tag1) | |
| 143 | { | ||
| 144 | unsigned int tag; | ||
| 145 | int64_t size; | ||
| 146 | |||
| 147 | for (;;) { | ||
| 148 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 2 taken 224 times.
|
464 | if (avio_feof(pb)) |
| 149 | 240 | return AVERROR_EOF; | |
| 150 | 224 | size = next_tag(pb, &tag, wav->rifx); | |
| 151 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
|
224 | if (tag == tag1) |
| 152 | ✗ | break; | |
| 153 | 224 | wav_seek_tag(wav, pb, size, SEEK_CUR); | |
| 154 | } | ||
| 155 | ✗ | return size; | |
| 156 | } | ||
| 157 | |||
| 158 | 7480 | static int wav_probe(const AVProbeData *p) | |
| 159 | { | ||
| 160 | /* check file header */ | ||
| 161 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7479 times.
|
7480 | if (p->buf_size <= 32) |
| 162 | 1 | return 0; | |
| 163 |
2/2✓ Branch 0 taken 493 times.
✓ Branch 1 taken 6986 times.
|
7479 | if (!memcmp(p->buf + 8, "WAVE", 4)) { |
| 164 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 493 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
493 | if (!memcmp(p->buf, "RIFF", 4) || !memcmp(p->buf, "RIFX", 4)) |
| 165 | /* Since the ACT demuxer has a standard WAV header at the top of | ||
| 166 | * its own, the returned score is decreased to avoid a probe | ||
| 167 | * conflict between ACT and WAV. */ | ||
| 168 | 493 | return AVPROBE_SCORE_MAX - 1; | |
| 169 | ✗ | else if ((!memcmp(p->buf, "RF64", 4) || | |
| 170 | ✗ | !memcmp(p->buf, "BW64", 4)) && | |
| 171 | ✗ | !memcmp(p->buf + 12, "ds64", 4)) | |
| 172 | ✗ | return AVPROBE_SCORE_MAX; | |
| 173 | } | ||
| 174 | 6986 | return 0; | |
| 175 | } | ||
| 176 | |||
| 177 | 578 | static void handle_stream_probing(AVStream *st) | |
| 178 | { | ||
| 179 |
2/2✓ Branch 0 taken 521 times.
✓ Branch 1 taken 57 times.
|
578 | if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) { |
| 180 | 521 | FFStream *const sti = ffstream(st); | |
| 181 | 521 | sti->request_probe = AVPROBE_SCORE_EXTENSION + 1; | |
| 182 | 521 | sti->probe_packets = FFMIN(sti->probe_packets, 32); | |
| 183 | } | ||
| 184 | 578 | } | |
| 185 | |||
| 186 | 576 | static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream *st) | |
| 187 | { | ||
| 188 | 576 | AVIOContext *pb = s->pb; | |
| 189 | 576 | WAVDemuxContext *wav = s->priv_data; | |
| 190 | int ret; | ||
| 191 | |||
| 192 | /* parse fmt header */ | ||
| 193 | 576 | ret = ff_get_wav_header(s, pb, st->codecpar, size, wav->rifx); | |
| 194 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
|
576 | if (ret < 0) |
| 195 | ✗ | return ret; | |
| 196 | 576 | handle_stream_probing(st); | |
| 197 | |||
| 198 | 576 | ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL_RAW; | |
| 199 | |||
| 200 | 576 | avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); | |
| 201 | |||
| 202 | 576 | return 0; | |
| 203 | } | ||
| 204 | |||
| 205 | ✗ | static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream *st) | |
| 206 | { | ||
| 207 | ✗ | AVIOContext *pb = s->pb; | |
| 208 | ✗ | int version, num_streams, i, channels = 0, ret; | |
| 209 | |||
| 210 | ✗ | if (size < 36) | |
| 211 | ✗ | return AVERROR_INVALIDDATA; | |
| 212 | |||
| 213 | ✗ | st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; | |
| 214 | ✗ | st->codecpar->codec_id = AV_CODEC_ID_XMA2; | |
| 215 | ✗ | ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL_RAW; | |
| 216 | |||
| 217 | ✗ | version = avio_r8(pb); | |
| 218 | ✗ | if (version != 3 && version != 4) | |
| 219 | ✗ | return AVERROR_INVALIDDATA; | |
| 220 | ✗ | num_streams = avio_r8(pb); | |
| 221 | ✗ | if (size != (32 + ((version==3)?0:8) + 4*num_streams)) | |
| 222 | ✗ | return AVERROR_INVALIDDATA; | |
| 223 | ✗ | avio_skip(pb, 10); | |
| 224 | ✗ | st->codecpar->sample_rate = avio_rb32(pb); | |
| 225 | ✗ | if (version == 4) | |
| 226 | ✗ | avio_skip(pb, 8); | |
| 227 | ✗ | avio_skip(pb, 4); | |
| 228 | ✗ | st->duration = avio_rb32(pb); | |
| 229 | ✗ | avio_skip(pb, 8); | |
| 230 | |||
| 231 | ✗ | for (i = 0; i < num_streams; i++) { | |
| 232 | ✗ | channels += avio_r8(pb); | |
| 233 | ✗ | avio_skip(pb, 3); | |
| 234 | } | ||
| 235 | ✗ | av_channel_layout_uninit(&st->codecpar->ch_layout); | |
| 236 | ✗ | st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; | |
| 237 | ✗ | st->codecpar->ch_layout.nb_channels = channels; | |
| 238 | |||
| 239 | ✗ | if (st->codecpar->ch_layout.nb_channels <= 0 || st->codecpar->sample_rate <= 0) | |
| 240 | ✗ | return AVERROR_INVALIDDATA; | |
| 241 | |||
| 242 | ✗ | avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); | |
| 243 | |||
| 244 | ✗ | avio_seek(pb, -size, SEEK_CUR); | |
| 245 | ✗ | if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0) | |
| 246 | ✗ | return ret; | |
| 247 | |||
| 248 | ✗ | return 0; | |
| 249 | } | ||
| 250 | |||
| 251 | 15 | static inline int wav_parse_bext_string(AVFormatContext *s, const char *key, | |
| 252 | int length) | ||
| 253 | { | ||
| 254 | char temp[257]; | ||
| 255 | int ret; | ||
| 256 | |||
| 257 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | av_assert0(length < sizeof(temp)); |
| 258 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | if ((ret = ffio_read_size(s->pb, temp, length)) < 0) |
| 259 | ✗ | return ret; | |
| 260 | |||
| 261 | 15 | temp[length] = 0; | |
| 262 | |||
| 263 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6 times.
|
15 | if (strlen(temp)) |
| 264 | 9 | return av_dict_set(&s->metadata, key, temp, 0); | |
| 265 | |||
| 266 | 6 | return 0; | |
| 267 | } | ||
| 268 | |||
| 269 | 3 | static int wav_parse_bext_tag(AVFormatContext *s, int64_t size) | |
| 270 | { | ||
| 271 | char temp[131], *coding_history; | ||
| 272 | int ret, x; | ||
| 273 | uint64_t time_reference; | ||
| 274 | 3 | int64_t umid_parts[8], umid_mask = 0; | |
| 275 | |||
| 276 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if ((ret = wav_parse_bext_string(s, "description", 256)) < 0 || |
| 277 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | (ret = wav_parse_bext_string(s, "originator", 32)) < 0 || |
| 278 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | (ret = wav_parse_bext_string(s, "originator_reference", 32)) < 0 || |
| 279 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
6 | (ret = wav_parse_bext_string(s, "origination_date", 10)) < 0 || |
| 280 | 3 | (ret = wav_parse_bext_string(s, "origination_time", 8)) < 0) | |
| 281 | ✗ | return ret; | |
| 282 | |||
| 283 | 3 | time_reference = avio_rl64(s->pb); | |
| 284 | 3 | snprintf(temp, sizeof(temp), "%"PRIu64, time_reference); | |
| 285 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if ((ret = av_dict_set(&s->metadata, "time_reference", temp, 0)) < 0) |
| 286 | ✗ | return ret; | |
| 287 | |||
| 288 | /* check if version is >= 1, in which case an UMID may be present */ | ||
| 289 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (avio_rl16(s->pb) >= 1) { |
| 290 | ✗ | for (x = 0; x < 8; x++) | |
| 291 | ✗ | umid_mask |= umid_parts[x] = avio_rb64(s->pb); | |
| 292 | |||
| 293 | ✗ | if (umid_mask) { | |
| 294 | /* the string formatting below is per SMPTE 330M-2004 Annex C */ | ||
| 295 | ✗ | if (umid_parts[4] == 0 && umid_parts[5] == 0 && | |
| 296 | ✗ | umid_parts[6] == 0 && umid_parts[7] == 0) { | |
| 297 | /* basic UMID */ | ||
| 298 | ✗ | snprintf(temp, sizeof(temp), | |
| 299 | "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64, | ||
| 300 | umid_parts[0], umid_parts[1], | ||
| 301 | umid_parts[2], umid_parts[3]); | ||
| 302 | } else { | ||
| 303 | /* extended UMID */ | ||
| 304 | ✗ | snprintf(temp, sizeof(temp), | |
| 305 | "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64 | ||
| 306 | "%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64, | ||
| 307 | umid_parts[0], umid_parts[1], | ||
| 308 | umid_parts[2], umid_parts[3], | ||
| 309 | umid_parts[4], umid_parts[5], | ||
| 310 | umid_parts[6], umid_parts[7]); | ||
| 311 | } | ||
| 312 | |||
| 313 | ✗ | if ((ret = av_dict_set(&s->metadata, "umid", temp, 0)) < 0) | |
| 314 | ✗ | return ret; | |
| 315 | } | ||
| 316 | |||
| 317 | ✗ | avio_skip(s->pb, 190); | |
| 318 | } else | ||
| 319 | 3 | avio_skip(s->pb, 254); | |
| 320 | |||
| 321 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (size > 602) { |
| 322 | /* CodingHistory present */ | ||
| 323 | 3 | size -= 602; | |
| 324 | |||
| 325 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!(coding_history = av_malloc(size + 1))) |
| 326 | ✗ | return AVERROR(ENOMEM); | |
| 327 | |||
| 328 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if ((ret = ffio_read_size(s->pb, coding_history, size)) < 0) { |
| 329 | ✗ | av_free(coding_history); | |
| 330 | ✗ | return ret; | |
| 331 | } | ||
| 332 | |||
| 333 | 3 | coding_history[size] = 0; | |
| 334 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if ((ret = av_dict_set(&s->metadata, "coding_history", coding_history, |
| 335 | AV_DICT_DONT_STRDUP_VAL)) < 0) | ||
| 336 | ✗ | return ret; | |
| 337 | } | ||
| 338 | |||
| 339 | 3 | return 0; | |
| 340 | } | ||
| 341 | |||
| 342 | static const AVMetadataConv wav_metadata_conv[] = { | ||
| 343 | { "description", "comment" }, | ||
| 344 | { "originator", "encoded_by" }, | ||
| 345 | { "origination_date", "date" }, | ||
| 346 | { "origination_time", "creation_time" }, | ||
| 347 | { 0 }, | ||
| 348 | }; | ||
| 349 | |||
| 350 | /* wav input */ | ||
| 351 | 576 | static int wav_read_header(AVFormatContext *s) | |
| 352 | { | ||
| 353 | 576 | int64_t size, av_uninit(data_size); | |
| 354 | 576 | int64_t sample_count = 0; | |
| 355 | 576 | int rf64 = 0, bw64 = 0; | |
| 356 | uint32_t tag; | ||
| 357 | 576 | AVIOContext *pb = s->pb; | |
| 358 | 576 | AVStream *st = NULL; | |
| 359 | 576 | WAVDemuxContext *wav = s->priv_data; | |
| 360 | 576 | int ret, got_fmt = 0, got_xma2 = 0; | |
| 361 | 576 | int64_t next_tag_ofs, data_ofs = -1; | |
| 362 | |||
| 363 | 576 | wav->unaligned = avio_tell(s->pb) & 1; | |
| 364 | |||
| 365 | 576 | wav->smv_data_ofs = -1; | |
| 366 | |||
| 367 | /* read chunk ID */ | ||
| 368 | 576 | tag = avio_rl32(pb); | |
| 369 |
1/5✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
576 | switch (tag) { |
| 370 | 576 | case MKTAG('R', 'I', 'F', 'F'): | |
| 371 | 576 | break; | |
| 372 | ✗ | case MKTAG('R', 'I', 'F', 'X'): | |
| 373 | ✗ | wav->rifx = 1; | |
| 374 | ✗ | break; | |
| 375 | ✗ | case MKTAG('R', 'F', '6', '4'): | |
| 376 | ✗ | rf64 = 1; | |
| 377 | ✗ | break; | |
| 378 | ✗ | case MKTAG('B', 'W', '6', '4'): | |
| 379 | ✗ | bw64 = 1; | |
| 380 | ✗ | break; | |
| 381 | ✗ | default: | |
| 382 | ✗ | av_log(s, AV_LOG_ERROR, "invalid start code %s in RIFF header\n", | |
| 383 | ✗ | av_fourcc2str(tag)); | |
| 384 | ✗ | return AVERROR_INVALIDDATA; | |
| 385 | } | ||
| 386 | |||
| 387 | /* read chunk size */ | ||
| 388 | 576 | avio_rl32(pb); | |
| 389 | |||
| 390 | /* read format */ | ||
| 391 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
|
576 | if (avio_rl32(pb) != MKTAG('W', 'A', 'V', 'E')) { |
| 392 | ✗ | av_log(s, AV_LOG_ERROR, "invalid format in RIFF header\n"); | |
| 393 | ✗ | return AVERROR_INVALIDDATA; | |
| 394 | } | ||
| 395 | |||
| 396 |
2/4✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 576 times.
|
576 | if (rf64 || bw64) { |
| 397 | ✗ | if (avio_rl32(pb) != MKTAG('d', 's', '6', '4')) | |
| 398 | ✗ | return AVERROR_INVALIDDATA; | |
| 399 | ✗ | size = avio_rl32(pb); | |
| 400 | ✗ | if (size < 24) | |
| 401 | ✗ | return AVERROR_INVALIDDATA; | |
| 402 | ✗ | avio_rl64(pb); /* RIFF size */ | |
| 403 | |||
| 404 | ✗ | data_size = avio_rl64(pb); | |
| 405 | ✗ | sample_count = avio_rl64(pb); | |
| 406 | |||
| 407 | ✗ | if (data_size < 0 || sample_count < 0) { | |
| 408 | ✗ | av_log(s, AV_LOG_ERROR, "negative data_size and/or sample_count in " | |
| 409 | "ds64: data_size = %"PRId64", sample_count = %"PRId64"\n", | ||
| 410 | data_size, sample_count); | ||
| 411 | ✗ | return AVERROR_INVALIDDATA; | |
| 412 | } | ||
| 413 | ✗ | avio_skip(pb, size - 24); /* skip rest of ds64 chunk */ | |
| 414 | |||
| 415 | } | ||
| 416 | |||
| 417 | /* Create the audio stream now so that its index is always zero */ | ||
| 418 | 576 | st = avformat_new_stream(s, NULL); | |
| 419 |
1/2✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 | if (!st) |
| 420 | ✗ | return AVERROR(ENOMEM); | |
| 421 | |||
| 422 | 651 | for (;;) { | |
| 423 | AVStream *vst; | ||
| 424 | 1227 | size = next_tag(pb, &tag, wav->rifx); | |
| 425 | 1227 | next_tag_ofs = avio_tell(pb) + size; | |
| 426 | |||
| 427 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1225 times.
|
1227 | if (avio_feof(pb)) |
| 428 | 2 | break; | |
| 429 | |||
| 430 |
8/10✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 1 times.
|
1225 | switch (tag) { |
| 431 | 576 | case MKTAG('f', 'm', 't', ' '): | |
| 432 | /* only parse the first 'fmt ' tag found */ | ||
| 433 |
3/6✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 576 times.
|
576 | if (!got_xma2 && !got_fmt && (ret = wav_parse_fmt_tag(s, size, st)) < 0) { |
| 434 | ✗ | return ret; | |
| 435 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
|
576 | } else if (got_fmt) |
| 436 | ✗ | av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n"); | |
| 437 | |||
| 438 | 576 | got_fmt = 1; | |
| 439 | 576 | break; | |
| 440 | ✗ | case MKTAG('X', 'M', 'A', '2'): | |
| 441 | /* only parse the first 'XMA2' tag found */ | ||
| 442 | ✗ | if (!got_fmt && !got_xma2 && (ret = wav_parse_xma2_tag(s, size, st)) < 0) { | |
| 443 | ✗ | return ret; | |
| 444 | ✗ | } else if (got_xma2) | |
| 445 | ✗ | av_log(s, AV_LOG_WARNING, "found more than one 'XMA2' tag\n"); | |
| 446 | |||
| 447 | ✗ | got_xma2 = 1; | |
| 448 | ✗ | break; | |
| 449 | 576 | case MKTAG('d', 'a', 't', 'a'): | |
| 450 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
576 | if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) && !got_fmt && !got_xma2) { |
| 451 | ✗ | av_log(s, AV_LOG_ERROR, | |
| 452 | "found no 'fmt ' tag before the 'data' tag\n"); | ||
| 453 | ✗ | return AVERROR_INVALIDDATA; | |
| 454 | } | ||
| 455 | |||
| 456 |
2/4✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 576 times.
|
576 | if (rf64 || bw64) { |
| 457 | ✗ | next_tag_ofs = wav->data_end = av_sat_add64(avio_tell(pb), data_size); | |
| 458 |
1/2✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 | } else if (size != 0xFFFFFFFF) { |
| 459 | 576 | data_size = size; | |
| 460 |
1/2✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 | next_tag_ofs = wav->data_end = size ? next_tag_ofs : INT64_MAX; |
| 461 | } else { | ||
| 462 | ✗ | av_log(s, AV_LOG_WARNING, "Ignoring maximum wav data size, " | |
| 463 | "file may be invalid\n"); | ||
| 464 | ✗ | data_size = 0; | |
| 465 | ✗ | next_tag_ofs = wav->data_end = INT64_MAX; | |
| 466 | } | ||
| 467 | |||
| 468 | 576 | data_ofs = avio_tell(pb); | |
| 469 | |||
| 470 | /* don't look for footer metadata if we can't seek or if we don't | ||
| 471 | * know where the data tag ends | ||
| 472 | */ | ||
| 473 |
3/8✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 576 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 576 times.
|
576 | if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || (!(rf64 && !bw64) && !size)) |
| 474 | ✗ | goto break_loop; | |
| 475 | 576 | break; | |
| 476 | 43 | case MKTAG('f', 'a', 'c', 't'): | |
| 477 |
1/2✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
|
43 | if (!sample_count) |
| 478 |
1/2✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
|
43 | sample_count = (!wav->rifx ? avio_rl32(pb) : avio_rb32(pb)); |
| 479 | 43 | break; | |
| 480 | 3 | case MKTAG('b', 'e', 'x', 't'): | |
| 481 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if ((ret = wav_parse_bext_tag(s, size)) < 0) |
| 482 | ✗ | return ret; | |
| 483 | 3 | break; | |
| 484 | 1 | case MKTAG('S','M','V','0'): | |
| 485 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (!got_fmt) { |
| 486 | ✗ | av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'SMV0' tag\n"); | |
| 487 | ✗ | return AVERROR_INVALIDDATA; | |
| 488 | } | ||
| 489 | // SMV file, a wav file with video appended. | ||
| 490 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (size != MKTAG('0','2','0','0')) { |
| 491 | ✗ | av_log(s, AV_LOG_ERROR, "Unknown SMV version found\n"); | |
| 492 | ✗ | goto break_loop; | |
| 493 | } | ||
| 494 | 1 | av_log(s, AV_LOG_DEBUG, "Found SMV data\n"); | |
| 495 | 1 | wav->smv_given_first = 0; | |
| 496 | 1 | vst = avformat_new_stream(s, NULL); | |
| 497 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (!vst) |
| 498 | ✗ | return AVERROR(ENOMEM); | |
| 499 | 1 | wav->vst = vst; | |
| 500 | 1 | avio_r8(pb); | |
| 501 | 1 | vst->id = 1; | |
| 502 | 1 | vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; | |
| 503 | 1 | vst->codecpar->codec_id = AV_CODEC_ID_SMVJPEG; | |
| 504 | 1 | vst->codecpar->width = avio_rl24(pb); | |
| 505 | 1 | vst->codecpar->height = avio_rl24(pb); | |
| 506 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if ((ret = ff_alloc_extradata(vst->codecpar, 4)) < 0) { |
| 507 | ✗ | av_log(s, AV_LOG_ERROR, "Could not allocate extradata.\n"); | |
| 508 | ✗ | return ret; | |
| 509 | } | ||
| 510 | 1 | size = avio_rl24(pb); | |
| 511 | 1 | wav->smv_data_ofs = avio_tell(pb) + (size - 5) * 3; | |
| 512 | 1 | avio_rl24(pb); | |
| 513 | 1 | wav->smv_block_size = avio_rl24(pb); | |
| 514 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (!wav->smv_block_size) |
| 515 | ✗ | return AVERROR_INVALIDDATA; | |
| 516 | 1 | avpriv_set_pts_info(vst, 32, 1, avio_rl24(pb)); | |
| 517 | 1 | vst->duration = avio_rl24(pb); | |
| 518 | 1 | avio_rl24(pb); | |
| 519 | 1 | avio_rl24(pb); | |
| 520 | 1 | wav->smv_frames_per_jpeg = avio_rl24(pb); | |
| 521 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (wav->smv_frames_per_jpeg > 65536) { |
| 522 | ✗ | av_log(s, AV_LOG_ERROR, "too many frames per jpeg\n"); | |
| 523 | ✗ | return AVERROR_INVALIDDATA; | |
| 524 | } | ||
| 525 | 1 | AV_WL32(vst->codecpar->extradata, wav->smv_frames_per_jpeg); | |
| 526 | 1 | goto break_loop; | |
| 527 | 22 | case MKTAG('L', 'I', 'S', 'T'): | |
| 528 | case MKTAG('l', 'i', 's', 't'): | ||
| 529 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
|
22 | if (size < 4) { |
| 530 | ✗ | av_log(s, AV_LOG_ERROR, "too short LIST tag\n"); | |
| 531 | ✗ | return AVERROR_INVALIDDATA; | |
| 532 | } | ||
| 533 |
2/3✓ Branch 1 taken 19 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
22 | switch (avio_rl32(pb)) { |
| 534 | 19 | case MKTAG('I', 'N', 'F', 'O'): | |
| 535 | 19 | ff_read_riff_info(s, size - 4); | |
| 536 | 19 | break; | |
| 537 | 3 | case MKTAG('a', 'd', 't', 'l'): | |
| 538 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (s->nb_chapters > 0) { |
| 539 |
3/4✓ Branch 1 taken 15 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
|
33 | while (avio_tell(pb) < next_tag_ofs && |
| 540 | 15 | !avio_feof(pb)) { | |
| 541 | char cue_label[512]; | ||
| 542 | unsigned id, sub_size; | ||
| 543 | |||
| 544 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | if (avio_rl32(pb) != MKTAG('l', 'a', 'b', 'l')) |
| 545 | ✗ | break; | |
| 546 | |||
| 547 | 15 | sub_size = avio_rl32(pb); | |
| 548 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | if (sub_size < 5) |
| 549 | ✗ | break; | |
| 550 | 15 | id = avio_rl32(pb); | |
| 551 | 15 | avio_get_str(pb, sub_size - 4, cue_label, sizeof(cue_label)); | |
| 552 | 15 | avio_skip(pb, avio_tell(pb) & 1); | |
| 553 | |||
| 554 |
1/2✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
|
45 | for (int i = 0; i < s->nb_chapters; i++) { |
| 555 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 30 times.
|
45 | if (s->chapters[i]->id == id) { |
| 556 | 15 | av_dict_set(&s->chapters[i]->metadata, "title", cue_label, 0); | |
| 557 | 15 | break; | |
| 558 | } | ||
| 559 | } | ||
| 560 | } | ||
| 561 | } | ||
| 562 | 3 | break; | |
| 563 | } | ||
| 564 | 22 | break; | |
| 565 | ✗ | case MKTAG('I', 'D', '3', ' '): | |
| 566 | case MKTAG('i', 'd', '3', ' '): { | ||
| 567 | ID3v2ExtraMeta *id3v2_extra_meta; | ||
| 568 | ✗ | ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, 0); | |
| 569 | ✗ | if (id3v2_extra_meta) { | |
| 570 | ✗ | ff_id3v2_parse_apic(s, id3v2_extra_meta); | |
| 571 | ✗ | ff_id3v2_parse_chapters(s, id3v2_extra_meta); | |
| 572 | ✗ | ff_id3v2_parse_priv(s, id3v2_extra_meta); | |
| 573 | } | ||
| 574 | ✗ | ff_id3v2_free_extra_meta(&id3v2_extra_meta); | |
| 575 | } | ||
| 576 | ✗ | break; | |
| 577 | 3 | case MKTAG('c', 'u', 'e', ' '): | |
| 578 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | if (size >= 4 && got_fmt && st->codecpar->sample_rate > 0) { |
| 579 | 3 | AVRational tb = {1, st->codecpar->sample_rate}; | |
| 580 | 3 | unsigned nb_cues = avio_rl32(pb); | |
| 581 | |||
| 582 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (size >= nb_cues * 24LL + 4LL) { |
| 583 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 3 times.
|
18 | for (int i = 0; i < nb_cues; i++) { |
| 584 | 15 | unsigned offset, id = avio_rl32(pb); | |
| 585 | |||
| 586 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | if (avio_feof(pb)) |
| 587 | ✗ | return AVERROR_INVALIDDATA; | |
| 588 | |||
| 589 | 15 | avio_skip(pb, 16); | |
| 590 | 15 | offset = avio_rl32(pb); | |
| 591 | |||
| 592 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | if (!avpriv_new_chapter(s, id, tb, offset, AV_NOPTS_VALUE, NULL)) |
| 593 | ✗ | return AVERROR(ENOMEM); | |
| 594 | } | ||
| 595 | } | ||
| 596 | } | ||
| 597 | 3 | break; | |
| 598 | } | ||
| 599 | |||
| 600 | /* seek to next tag unless we know that we'll run into EOF */ | ||
| 601 |
4/6✓ Branch 1 taken 1224 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 651 times.
✓ Branch 5 taken 573 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 651 times.
|
1875 | if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) || |
| 602 | 651 | wav_seek_tag(wav, pb, next_tag_ofs, SEEK_SET) < 0) { | |
| 603 | break; | ||
| 604 | } | ||
| 605 | } | ||
| 606 | |||
| 607 | 573 | break_loop: | |
| 608 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
576 | if (!got_fmt && !got_xma2) { |
| 609 | ✗ | av_log(s, AV_LOG_ERROR, "no 'fmt ' or 'XMA2' tag found\n"); | |
| 610 | ✗ | return AVERROR_INVALIDDATA; | |
| 611 | } | ||
| 612 | |||
| 613 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
|
576 | if (data_ofs < 0) { |
| 614 | ✗ | av_log(s, AV_LOG_ERROR, "no 'data' tag found\n"); | |
| 615 | ✗ | return AVERROR_INVALIDDATA; | |
| 616 | } | ||
| 617 | |||
| 618 | 576 | avio_seek(pb, data_ofs, SEEK_SET); | |
| 619 | |||
| 620 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
|
576 | if (data_size > (INT64_MAX>>3)) { |
| 621 | ✗ | av_log(s, AV_LOG_WARNING, "Data size %"PRId64" is too large\n", data_size); | |
| 622 | ✗ | data_size = 0; | |
| 623 | } | ||
| 624 | |||
| 625 |
2/4✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
✗ Branch 3 not taken.
|
576 | if ( st->codecpar->bit_rate > 0 && data_size > 0 |
| 626 |
1/2✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 | && st->codecpar->sample_rate > 0 |
| 627 |
4/4✓ Branch 0 taken 42 times.
✓ Branch 1 taken 534 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 12 times.
|
576 | && sample_count > 0 && st->codecpar->ch_layout.nb_channels > 1 |
| 628 |
1/2✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
|
30 | && sample_count % st->codecpar->ch_layout.nb_channels == 0) { |
| 629 | 30 | if (fabs(8.0 * data_size * st->codecpar->ch_layout.nb_channels * st->codecpar->sample_rate / | |
| 630 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
|
30 | sample_count /st->codecpar->bit_rate - 1.0) < 0.3) |
| 631 | ✗ | sample_count /= st->codecpar->ch_layout.nb_channels; | |
| 632 | } | ||
| 633 | |||
| 634 |
4/6✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 534 times.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
|
576 | if (data_size > 0 && sample_count && st->codecpar->ch_layout.nb_channels && |
| 635 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
|
42 | (data_size << 3) / sample_count / st->codecpar->ch_layout.nb_channels > st->codecpar->bits_per_coded_sample + 1) { |
| 636 | ✗ | av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count); | |
| 637 | ✗ | sample_count = 0; | |
| 638 | } | ||
| 639 | |||
| 640 | /* G.729 hack (for Ticket4577) | ||
| 641 | * FIXME: Come up with cleaner, more general solution */ | ||
| 642 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
576 | if (st->codecpar->codec_id == AV_CODEC_ID_G729 && sample_count && (data_size << 3) > sample_count) { |
| 643 | ✗ | av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count); | |
| 644 | ✗ | sample_count = 0; | |
| 645 | } | ||
| 646 | |||
| 647 |
4/4✓ Branch 0 taken 42 times.
✓ Branch 1 taken 534 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 19 times.
|
576 | if (!sample_count || av_get_exact_bits_per_sample(st->codecpar->codec_id) > 0) |
| 648 |
1/2✓ Branch 0 taken 557 times.
✗ Branch 1 not taken.
|
557 | if ( st->codecpar->ch_layout.nb_channels |
| 649 |
1/2✓ Branch 0 taken 557 times.
✗ Branch 1 not taken.
|
557 | && data_size |
| 650 |
2/2✓ Branch 1 taken 551 times.
✓ Branch 2 taken 6 times.
|
557 | && av_get_bits_per_sample(st->codecpar->codec_id) |
| 651 |
2/2✓ Branch 1 taken 548 times.
✓ Branch 2 taken 3 times.
|
551 | && wav->data_end <= avio_size(pb)) |
| 652 | 1096 | sample_count = (data_size << 3) | |
| 653 | 548 | / | |
| 654 | 548 | (st->codecpar->ch_layout.nb_channels * (uint64_t)av_get_bits_per_sample(st->codecpar->codec_id)); | |
| 655 | |||
| 656 |
2/2✓ Branch 0 taken 567 times.
✓ Branch 1 taken 9 times.
|
576 | if (sample_count) |
| 657 | 567 | st->duration = sample_count; | |
| 658 | |||
| 659 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 573 times.
|
576 | if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S32LE && |
| 660 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | st->codecpar->block_align == st->codecpar->ch_layout.nb_channels * 4 && |
| 661 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | st->codecpar->bits_per_coded_sample == 32 && |
| 662 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | st->codecpar->extradata_size == 2 && |
| 663 | ✗ | AV_RL16(st->codecpar->extradata) == 1) { | |
| 664 | ✗ | st->codecpar->codec_id = AV_CODEC_ID_PCM_F16LE; | |
| 665 | ✗ | st->codecpar->bits_per_coded_sample = 16; | |
| 666 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 565 times.
|
576 | } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE && |
| 667 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | st->codecpar->block_align == st->codecpar->ch_layout.nb_channels * 4 && |
| 668 | ✗ | st->codecpar->bits_per_coded_sample == 24) { | |
| 669 | ✗ | st->codecpar->codec_id = AV_CODEC_ID_PCM_F24LE; | |
| 670 |
1/2✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 | } else if (st->codecpar->codec_id == AV_CODEC_ID_XMA1 || |
| 671 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
|
576 | st->codecpar->codec_id == AV_CODEC_ID_XMA2) { |
| 672 | ✗ | st->codecpar->block_align = 2048; | |
| 673 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 572 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
|
576 | } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->ch_layout.nb_channels > 2 && |
| 674 | ✗ | st->codecpar->block_align < INT_MAX / st->codecpar->ch_layout.nb_channels) { | |
| 675 | ✗ | st->codecpar->block_align *= st->codecpar->ch_layout.nb_channels; | |
| 676 | } | ||
| 677 | |||
| 678 | 576 | ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); | |
| 679 | 576 | ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv); | |
| 680 | |||
| 681 | 576 | set_spdif(s, wav); | |
| 682 | 576 | set_max_size(st, wav); | |
| 683 | |||
| 684 | 576 | return 0; | |
| 685 | } | ||
| 686 | |||
| 687 | /** | ||
| 688 | * Find chunk with w64 GUID by skipping over other chunks. | ||
| 689 | * @return the size of the found chunk | ||
| 690 | */ | ||
| 691 | 6 | static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16]) | |
| 692 | { | ||
| 693 | uint8_t guid[16]; | ||
| 694 | int64_t size; | ||
| 695 | |||
| 696 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
|
6 | while (!avio_feof(pb)) { |
| 697 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | if (avio_read(pb, guid, 16) != 16) |
| 698 | 2 | break; | |
| 699 | ✗ | size = avio_rl64(pb); | |
| 700 | ✗ | if (size <= 24 || size > INT64_MAX - 8) | |
| 701 | ✗ | return AVERROR_INVALIDDATA; | |
| 702 | ✗ | if (!memcmp(guid, guid1, 16)) | |
| 703 | ✗ | return size; | |
| 704 | ✗ | avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24); | |
| 705 | } | ||
| 706 | 6 | return AVERROR_EOF; | |
| 707 | } | ||
| 708 | |||
| 709 | 35921 | static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) | |
| 710 | { | ||
| 711 | int ret, size; | ||
| 712 | int64_t left; | ||
| 713 | 35921 | WAVDemuxContext *wav = s->priv_data; | |
| 714 | 35921 | AVStream *st = s->streams[0]; | |
| 715 | |||
| 716 |
2/2✓ Branch 0 taken 45 times.
✓ Branch 1 taken 35876 times.
|
35921 | if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) |
| 717 | 45 | return ff_spdif_read_packet(s, pkt); | |
| 718 | |||
| 719 |
2/2✓ Branch 0 taken 68 times.
✓ Branch 1 taken 35808 times.
|
35876 | if (wav->smv_data_ofs > 0) { |
| 720 | int64_t audio_dts, video_dts; | ||
| 721 | 68 | AVStream *vst = wav->vst; | |
| 722 | 68 | smv_retry: | |
| 723 | 69 | audio_dts = (int32_t)ffstream( st)->cur_dts; | |
| 724 | 69 | video_dts = (int32_t)ffstream(vst)->cur_dts; | |
| 725 | |||
| 726 |
2/4✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
|
69 | if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { |
| 727 | /*We always return a video frame first to get the pixel format first*/ | ||
| 728 | 138 | wav->smv_last_stream = wav->smv_given_first ? | |
| 729 | 68 | av_compare_ts(video_dts, vst->time_base, | |
| 730 |
4/4✓ Branch 0 taken 68 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 3 times.
|
137 | audio_dts, st->time_base) > 0 : 0; |
| 731 | 69 | wav->smv_given_first = 1; | |
| 732 | } | ||
| 733 | 69 | wav->smv_last_stream = !wav->smv_last_stream; | |
| 734 | 69 | wav->smv_last_stream |= wav->audio_eof; | |
| 735 | 69 | wav->smv_last_stream &= !wav->smv_eof; | |
| 736 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 66 times.
|
69 | if (wav->smv_last_stream) { |
| 737 | 3 | uint64_t old_pos = avio_tell(s->pb); | |
| 738 | 3 | uint64_t new_pos = wav->smv_data_ofs + | |
| 739 | 3 | wav->smv_block * (int64_t)wav->smv_block_size; | |
| 740 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) { |
| 741 | ✗ | ret = AVERROR_EOF; | |
| 742 | ✗ | goto smv_out; | |
| 743 | } | ||
| 744 | 3 | size = avio_rl24(s->pb); | |
| 745 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (size > wav->smv_block_size) { |
| 746 | ✗ | ret = AVERROR_EOF; | |
| 747 | ✗ | goto smv_out; | |
| 748 | } | ||
| 749 | 3 | ret = av_get_packet(s->pb, pkt, size); | |
| 750 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | if (ret < 0) |
| 751 | 1 | goto smv_out; | |
| 752 | 2 | pkt->pos -= 3; | |
| 753 | 2 | pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg; | |
| 754 | 2 | pkt->duration = wav->smv_frames_per_jpeg; | |
| 755 | 2 | wav->smv_block++; | |
| 756 | |||
| 757 | 2 | pkt->stream_index = vst->index; | |
| 758 | 3 | smv_out: | |
| 759 | 3 | avio_seek(s->pb, old_pos, SEEK_SET); | |
| 760 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | if (ret == AVERROR_EOF) { |
| 761 | 1 | wav->smv_eof = 1; | |
| 762 | 1 | goto smv_retry; | |
| 763 | } | ||
| 764 | 2 | return ret; | |
| 765 | } | ||
| 766 | } | ||
| 767 | |||
| 768 | 35874 | left = wav->data_end - avio_tell(s->pb); | |
| 769 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 35874 times.
|
35874 | if (wav->ignore_length) |
| 770 | ✗ | left = INT_MAX; | |
| 771 |
2/2✓ Branch 0 taken 246 times.
✓ Branch 1 taken 35628 times.
|
35874 | if (left <= 0) { |
| 772 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 240 times.
|
246 | if (CONFIG_W64_DEMUXER && wav->w64) |
| 773 | 6 | left = find_guid(s->pb, ff_w64_guid_data) - 24; | |
| 774 | else | ||
| 775 | 240 | left = find_tag(wav, s->pb, MKTAG('d', 'a', 't', 'a')); | |
| 776 |
1/2✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
|
246 | if (left < 0) { |
| 777 | 246 | wav->audio_eof = 1; | |
| 778 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 245 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
246 | if (wav->smv_data_ofs > 0 && !wav->smv_eof) |
| 779 | ✗ | goto smv_retry; | |
| 780 | 246 | return AVERROR_EOF; | |
| 781 | } | ||
| 782 | ✗ | if (INT64_MAX - left < avio_tell(s->pb)) | |
| 783 | ✗ | return AVERROR_INVALIDDATA; | |
| 784 | ✗ | wav->data_end = avio_tell(s->pb) + left; | |
| 785 | } | ||
| 786 | |||
| 787 | 35628 | size = wav->max_size; | |
| 788 |
2/2✓ Branch 0 taken 35144 times.
✓ Branch 1 taken 484 times.
|
35628 | if (st->codecpar->block_align > 1) { |
| 789 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 35144 times.
|
35144 | if (size < st->codecpar->block_align) |
| 790 | ✗ | size = st->codecpar->block_align; | |
| 791 | 35144 | size = (size / st->codecpar->block_align) * st->codecpar->block_align; | |
| 792 | } | ||
| 793 | 35628 | size = FFMIN(size, left); | |
| 794 | 35628 | ret = av_get_packet(s->pb, pkt, size); | |
| 795 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 35617 times.
|
35628 | if (ret < 0) |
| 796 | 11 | return ret; | |
| 797 | 35617 | pkt->stream_index = 0; | |
| 798 | |||
| 799 | 35617 | return ret; | |
| 800 | } | ||
| 801 | |||
| 802 | 409 | static int wav_read_seek(AVFormatContext *s, | |
| 803 | int stream_index, int64_t timestamp, int flags) | ||
| 804 | { | ||
| 805 | 409 | WAVDemuxContext *wav = s->priv_data; | |
| 806 | 409 | AVStream *ast = s->streams[0], *vst = wav->vst; | |
| 807 | 409 | wav->smv_eof = 0; | |
| 808 | 409 | wav->audio_eof = 0; | |
| 809 | |||
| 810 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
409 | if (stream_index != 0 && (!vst || stream_index != vst->index)) |
| 811 | ✗ | return AVERROR(EINVAL); | |
| 812 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
|
409 | if (wav->smv_data_ofs > 0) { |
| 813 | ✗ | int64_t smv_timestamp = timestamp; | |
| 814 | ✗ | if (stream_index == 0) | |
| 815 | ✗ | smv_timestamp = av_rescale_q(timestamp, ast->time_base, vst->time_base); | |
| 816 | else | ||
| 817 | ✗ | timestamp = av_rescale_q(smv_timestamp, vst->time_base, ast->time_base); | |
| 818 | ✗ | if (wav->smv_frames_per_jpeg > 0) { | |
| 819 | ✗ | wav->smv_block = smv_timestamp / wav->smv_frames_per_jpeg; | |
| 820 | } | ||
| 821 | } | ||
| 822 | |||
| 823 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
|
409 | switch (ast->codecpar->codec_id) { |
| 824 | ✗ | case AV_CODEC_ID_MP2: | |
| 825 | case AV_CODEC_ID_MP3: | ||
| 826 | case AV_CODEC_ID_AC3: | ||
| 827 | case AV_CODEC_ID_DTS: | ||
| 828 | case AV_CODEC_ID_XMA2: | ||
| 829 | /* use generic seeking with dynamically generated indexes */ | ||
| 830 | ✗ | return -1; | |
| 831 | 409 | default: | |
| 832 | 409 | break; | |
| 833 | } | ||
| 834 | 409 | return ff_pcm_read_seek(s, 0, timestamp, flags); | |
| 835 | } | ||
| 836 | |||
| 837 | static const AVClass wav_demuxer_class = { | ||
| 838 | .class_name = "WAV demuxer", | ||
| 839 | .item_name = av_default_item_name, | ||
| 840 | .option = demux_options, | ||
| 841 | .version = LIBAVUTIL_VERSION_INT, | ||
| 842 | }; | ||
| 843 | const FFInputFormat ff_wav_demuxer = { | ||
| 844 | .p.name = "wav", | ||
| 845 | .p.long_name = NULL_IF_CONFIG_SMALL("WAV / WAVE (Waveform Audio)"), | ||
| 846 | .p.flags = AVFMT_GENERIC_INDEX, | ||
| 847 | .p.codec_tag = ff_wav_codec_tags_list, | ||
| 848 | .p.priv_class = &wav_demuxer_class, | ||
| 849 | .priv_data_size = sizeof(WAVDemuxContext), | ||
| 850 | .read_probe = wav_probe, | ||
| 851 | .read_header = wav_read_header, | ||
| 852 | .read_packet = wav_read_packet, | ||
| 853 | .read_seek = wav_read_seek, | ||
| 854 | }; | ||
| 855 | #endif /* CONFIG_WAV_DEMUXER */ | ||
| 856 | |||
| 857 | #if CONFIG_W64_DEMUXER | ||
| 858 | 7480 | static int w64_probe(const AVProbeData *p) | |
| 859 | { | ||
| 860 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7477 times.
|
7480 | if (p->buf_size <= 40) |
| 861 | 3 | return 0; | |
| 862 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7475 times.
|
7477 | if (!memcmp(p->buf, ff_w64_guid_riff, 16) && |
| 863 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | !memcmp(p->buf + 24, ff_w64_guid_wave, 16)) |
| 864 | 2 | return AVPROBE_SCORE_MAX; | |
| 865 | else | ||
| 866 | 7475 | return 0; | |
| 867 | } | ||
| 868 | |||
| 869 | 2 | static int w64_read_header(AVFormatContext *s) | |
| 870 | { | ||
| 871 | 2 | int64_t size, data_ofs = 0; | |
| 872 | 2 | AVIOContext *pb = s->pb; | |
| 873 | 2 | WAVDemuxContext *wav = s->priv_data; | |
| 874 | AVStream *st; | ||
| 875 | uint8_t guid[16]; | ||
| 876 | 2 | int ret = ffio_read_size(pb, guid, 16); | |
| 877 | |||
| 878 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (ret < 0) |
| 879 | ✗ | return ret; | |
| 880 | |||
| 881 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (memcmp(guid, ff_w64_guid_riff, 16)) |
| 882 | ✗ | return AVERROR_INVALIDDATA; | |
| 883 | |||
| 884 | /* riff + wave + fmt + sizes */ | ||
| 885 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) |
| 886 | ✗ | return AVERROR_INVALIDDATA; | |
| 887 | |||
| 888 | 2 | ret = ffio_read_size(pb, guid, 16); | |
| 889 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (ret < 0) |
| 890 | ✗ | return ret; | |
| 891 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (memcmp(guid, ff_w64_guid_wave, 16)) { |
| 892 | ✗ | av_log(s, AV_LOG_ERROR, "could not find wave guid\n"); | |
| 893 | ✗ | return AVERROR_INVALIDDATA; | |
| 894 | } | ||
| 895 | |||
| 896 | 2 | wav->w64 = 1; | |
| 897 | |||
| 898 | 2 | st = avformat_new_stream(s, NULL); | |
| 899 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (!st) |
| 900 | ✗ | return AVERROR(ENOMEM); | |
| 901 | |||
| 902 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | while (!avio_feof(pb)) { |
| 903 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
|
6 | if (avio_read(pb, guid, 16) != 16) |
| 904 | 2 | break; | |
| 905 | 4 | size = avio_rl64(pb); | |
| 906 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
|
4 | if (size <= 24 || INT64_MAX - size < avio_tell(pb)) { |
| 907 | ✗ | if (data_ofs) | |
| 908 | ✗ | break; | |
| 909 | ✗ | return AVERROR_INVALIDDATA; | |
| 910 | } | ||
| 911 | |||
| 912 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | if (!memcmp(guid, ff_w64_guid_fmt, 16)) { |
| 913 | /* subtract chunk header size - normal wav file doesn't count it */ | ||
| 914 | 2 | ret = ff_get_wav_header(s, pb, st->codecpar, size - 24, 0); | |
| 915 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (ret < 0) |
| 916 | ✗ | return ret; | |
| 917 | 2 | avio_skip(pb, FFALIGN(size, INT64_C(8)) - size); | |
| 918 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (st->codecpar->block_align && |
| 919 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | st->codecpar->ch_layout.nb_channels < FF_SANE_NB_CHANNELS && |
| 920 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | st->codecpar->bits_per_coded_sample < 128) { |
| 921 | 2 | int64_t block_align = st->codecpar->block_align; | |
| 922 | |||
| 923 | 2 | block_align = FFMAX(block_align, | |
| 924 | ((st->codecpar->bits_per_coded_sample + 7LL) / 8) * | ||
| 925 | st->codecpar->ch_layout.nb_channels); | ||
| 926 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (block_align > st->codecpar->block_align) { |
| 927 | ✗ | av_log(s, AV_LOG_WARNING, "invalid block_align: %d, broken file.\n", | |
| 928 | ✗ | st->codecpar->block_align); | |
| 929 | ✗ | st->codecpar->block_align = block_align; | |
| 930 | } | ||
| 931 | } | ||
| 932 | 2 | avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); | |
| 933 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | } else if (!memcmp(guid, ff_w64_guid_fact, 16)) { |
| 934 | int64_t samples; | ||
| 935 | |||
| 936 | ✗ | samples = avio_rl64(pb); | |
| 937 | ✗ | if (samples > 0) | |
| 938 | ✗ | st->duration = samples; | |
| 939 | ✗ | avio_skip(pb, FFALIGN(size, INT64_C(8)) - 32); | |
| 940 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | } else if (!memcmp(guid, ff_w64_guid_data, 16)) { |
| 941 | 2 | wav->data_end = avio_tell(pb) + size - 24; | |
| 942 | |||
| 943 | 2 | data_ofs = avio_tell(pb); | |
| 944 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) |
| 945 | ✗ | break; | |
| 946 | |||
| 947 | 2 | avio_skip(pb, size - 24); | |
| 948 | ✗ | } else if (!memcmp(guid, ff_w64_guid_summarylist, 16)) { | |
| 949 | int64_t start, end, cur; | ||
| 950 | uint32_t count, chunk_size, i; | ||
| 951 | ✗ | int64_t filesize = avio_size(s->pb); | |
| 952 | |||
| 953 | ✗ | start = avio_tell(pb); | |
| 954 | ✗ | end = start + FFALIGN(size, INT64_C(8)) - 24; | |
| 955 | ✗ | count = avio_rl32(pb); | |
| 956 | |||
| 957 | ✗ | for (i = 0; i < count; i++) { | |
| 958 | char chunk_key[5], *value; | ||
| 959 | |||
| 960 | ✗ | if (avio_feof(pb) || (cur = avio_tell(pb)) < 0 || cur > end - 8 /* = tag + size */) | |
| 961 | break; | ||
| 962 | |||
| 963 | ✗ | chunk_key[4] = 0; | |
| 964 | ✗ | avio_read(pb, chunk_key, 4); | |
| 965 | ✗ | chunk_size = avio_rl32(pb); | |
| 966 | ✗ | if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize)) | |
| 967 | ✗ | return AVERROR_INVALIDDATA; | |
| 968 | |||
| 969 | ✗ | value = av_malloc(chunk_size + 1); | |
| 970 | ✗ | if (!value) | |
| 971 | ✗ | return AVERROR(ENOMEM); | |
| 972 | |||
| 973 | ✗ | ret = avio_get_str16le(pb, chunk_size, value, chunk_size); | |
| 974 | ✗ | if (ret < 0) { | |
| 975 | ✗ | av_free(value); | |
| 976 | ✗ | return ret; | |
| 977 | } | ||
| 978 | ✗ | avio_skip(pb, chunk_size - ret); | |
| 979 | |||
| 980 | ✗ | av_dict_set(&s->metadata, chunk_key, value, AV_DICT_DONT_STRDUP_VAL); | |
| 981 | } | ||
| 982 | |||
| 983 | ✗ | avio_skip(pb, end - avio_tell(pb)); | |
| 984 | } else { | ||
| 985 | ✗ | av_log(s, AV_LOG_DEBUG, "unknown guid: "FF_PRI_GUID"\n", FF_ARG_GUID(guid)); | |
| 986 | ✗ | avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24); | |
| 987 | } | ||
| 988 | } | ||
| 989 | |||
| 990 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (!data_ofs) |
| 991 | ✗ | return AVERROR_EOF; | |
| 992 | |||
| 993 | 2 | ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); | |
| 994 | 2 | ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv); | |
| 995 | |||
| 996 | 2 | handle_stream_probing(st); | |
| 997 | 2 | ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL_RAW; | |
| 998 | |||
| 999 | 2 | avio_seek(pb, data_ofs, SEEK_SET); | |
| 1000 | |||
| 1001 | 2 | set_spdif(s, wav); | |
| 1002 | 2 | set_max_size(st, wav); | |
| 1003 | |||
| 1004 | 2 | return 0; | |
| 1005 | } | ||
| 1006 | |||
| 1007 | static const AVClass w64_demuxer_class = { | ||
| 1008 | .class_name = "W64 demuxer", | ||
| 1009 | .item_name = av_default_item_name, | ||
| 1010 | .option = &demux_options[W64_DEMUXER_OPTIONS_OFFSET], | ||
| 1011 | .version = LIBAVUTIL_VERSION_INT, | ||
| 1012 | }; | ||
| 1013 | |||
| 1014 | const FFInputFormat ff_w64_demuxer = { | ||
| 1015 | .p.name = "w64", | ||
| 1016 | .p.long_name = NULL_IF_CONFIG_SMALL("Sony Wave64"), | ||
| 1017 | .p.flags = AVFMT_GENERIC_INDEX, | ||
| 1018 | .p.codec_tag = ff_wav_codec_tags_list, | ||
| 1019 | .p.priv_class = &w64_demuxer_class, | ||
| 1020 | .priv_data_size = sizeof(WAVDemuxContext), | ||
| 1021 | .flags_internal = FF_INFMT_FLAG_ID3V2_AUTO, | ||
| 1022 | .read_probe = w64_probe, | ||
| 1023 | .read_header = w64_read_header, | ||
| 1024 | .read_packet = wav_read_packet, | ||
| 1025 | .read_seek = wav_read_seek, | ||
| 1026 | }; | ||
| 1027 | #endif /* CONFIG_W64_DEMUXER */ | ||
| 1028 |