Revision ca402f32

View differences:

libavformat/asfdec.c
288 288

  
289 289
    st->codec->codec_type = type;
290 290
    if (type == AVMEDIA_TYPE_AUDIO) {
291
        ff_get_wav_header(pb, st->codec, type_specific_size);
291
        int ret = ff_get_wav_header(pb, st->codec, type_specific_size);
292
        if (ret < 0)
293
            return ret;
292 294
        if (is_dvr_ms_audio) {
293 295
            // codec_id and codec_tag are unreliable in dvr_ms
294 296
            // files. Set them later by probing stream.
libavformat/avidec.c
345 345
    int avih_width=0, avih_height=0;
346 346
    int amv_file_format=0;
347 347
    uint64_t list_end = 0;
348
    int ret;
348 349

  
349 350
    avi->stream_index= -1;
350 351

  
......
623 624
//                    avio_skip(pb, size - 5 * 4);
624 625
                    break;
625 626
                case AVMEDIA_TYPE_AUDIO:
626
                    ff_get_wav_header(pb, st->codec, size);
627
                    ret = ff_get_wav_header(pb, st->codec, size);
628
                    if (ret < 0)
629
                        return ret;
627 630
                    ast->dshow_block_align= st->codec->block_align;
628 631
                    if(ast->sample_size && st->codec->block_align && ast->sample_size != st->codec->block_align){
629 632
                        av_log(s, AV_LOG_WARNING, "sample size (%d) != block align (%d)\n", ast->sample_size, st->codec->block_align);
libavformat/dxa.c
60 60
    int w, h;
61 61
    int num, den;
62 62
    int flags;
63
    int ret;
63 64

  
64 65
    tag = avio_rl32(pb);
65 66
    if (tag != MKTAG('D', 'E', 'X', 'A'))
......
102 103
        ast = av_new_stream(s, 0);
103 104
        if (!ast)
104 105
            return -1;
105
        ff_get_wav_header(pb, ast->codec, fsize);
106
        ret = ff_get_wav_header(pb, ast->codec, fsize);
107
        if (ret < 0)
108
            return ret;
106 109
        // find 'data' chunk
107 110
        while(avio_tell(pb) < c->vidpos && !pb->eof_reached){
108 111
            tag = avio_rl32(pb);
libavformat/matroskadec.c
1329 1329
        } else if (!strcmp(track->codec_id, "A_MS/ACM")
1330 1330
                   && track->codec_priv.size >= 14
1331 1331
                   && track->codec_priv.data != NULL) {
1332
            int ret;
1332 1333
            ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size,
1333 1334
                          AVIO_RDONLY, NULL, NULL, NULL, NULL);
1334
            ff_get_wav_header(&b, st->codec, track->codec_priv.size);
1335
            ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size);
1336
            if (ret < 0)
1337
                return ret;
1335 1338
            codec_id = st->codec->codec_id;
1336 1339
            extradata_offset = FFMIN(track->codec_priv.size, 18);
1337 1340
        } else if (!strcmp(track->codec_id, "V_QUICKTIME")
libavformat/riff.c
480 480
 * WAVEFORMATEX adds 'WORD  cbSize' and basically makes itself
481 481
 * an openended structure.
482 482
 */
483
void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
483
int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
484 484
{
485 485
    int id;
486 486

  
......
510 510
        codec->extradata_size = cbSize;
511 511
        if (cbSize > 0) {
512 512
            codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
513
            if (!codec->extradata)
514
                return AVERROR(ENOMEM);
513 515
            avio_read(pb, codec->extradata, codec->extradata_size);
514 516
            size -= cbSize;
515 517
        }
......
524 526
        codec->channels    = 0;
525 527
        codec->sample_rate = 0;
526 528
    }
529

  
530
    return 0;
527 531
}
528 532

  
529 533

  
libavformat/riff.h
45 45
void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
46 46
int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc);
47 47
enum CodecID ff_wav_codec_get_id(unsigned int tag, int bps);
48
void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size);
48
int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size);
49 49

  
50 50
extern const AVCodecTag ff_codec_bmp_tags[];
51 51
extern const AVCodecTag ff_codec_wav_tags[];
libavformat/wav.c
196 196
    AVIOContext *pb = s->pb;
197 197
    AVStream *st;
198 198
    WAVContext *wav = s->priv_data;
199
    int ret;
199 200

  
200 201
    /* check RIFF header */
201 202
    tag = avio_rl32(pb);
......
228 229
    if (!st)
229 230
        return AVERROR(ENOMEM);
230 231

  
231
    ff_get_wav_header(pb, st->codec, size);
232
    ret = ff_get_wav_header(pb, st->codec, size);
233
    if (ret < 0)
234
        return ret;
232 235
    st->need_parsing = AVSTREAM_PARSE_FULL;
233 236

  
234 237
    av_set_pts_info(st, 64, 1, st->codec->sample_rate);
......
384 387
    WAVContext    *wav = s->priv_data;
385 388
    AVStream *st;
386 389
    uint8_t guid[16];
390
    int ret;
387 391

  
388 392
    avio_read(pb, guid, 16);
389 393
    if (memcmp(guid, guid_riff, 16))
......
409 413
        return AVERROR(ENOMEM);
410 414

  
411 415
    /* subtract chunk header size - normal wav file doesn't count it */
412
    ff_get_wav_header(pb, st->codec, size - 24);
416
    ret = ff_get_wav_header(pb, st->codec, size - 24);
417
    if (ret < 0)
418
        return ret;
413 419
    avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
414 420

  
415 421
    st->need_parsing = AVSTREAM_PARSE_FULL;
libavformat/wtv.c
675 675
        if (!st)
676 676
            return NULL;
677 677
        if (!ff_guidcmp(formattype, format_waveformatex)) {
678
            ff_get_wav_header(pb, st->codec, size);
678
            int ret = ff_get_wav_header(pb, st->codec, size);
679
            if (ret < 0)
680
                return NULL;
679 681
        } else {
680 682
            if (ff_guidcmp(formattype, format_none))
681 683
                av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
libavformat/xwma.c
40 40
static int xwma_read_header(AVFormatContext *s, AVFormatParameters *ap)
41 41
{
42 42
    int64_t size, av_uninit(data_size);
43
    int ret;
43 44
    uint32_t dpds_table_size = 0;
44 45
    uint32_t *dpds_table = 0;
45 46
    unsigned int tag;
......
70 71
    if (!st)
71 72
        return AVERROR(ENOMEM);
72 73

  
73
    ff_get_wav_header(pb, st->codec, size);
74
    ret = ff_get_wav_header(pb, st->codec, size);
75
    if (ret < 0)
76
        return ret;
74 77
    st->need_parsing = AVSTREAM_PARSE_NONE;
75 78

  
76 79
    /* All xWMA files I have seen contained WMAv2 data. If there are files

Also available in: Unified diff