Revision f61cbc22

View differences:

libavformat/vocdec.c
68 68
    AVCodecContext *dec = st->codec;
69 69
    ByteIOContext *pb = s->pb;
70 70
    VocType type;
71
    int size, tmp_codec;
71
    int size, tmp_codec=-1;
72 72
    int sample_rate = 0;
73 73
    int channels = 1;
74 74

  
......
90 90
            if (sample_rate)
91 91
                dec->sample_rate = sample_rate;
92 92
            dec->channels = channels;
93
            tmp_codec = ff_codec_get_id(ff_voc_codec_tags, get_byte(pb));
94
            if (dec->codec_id == CODEC_ID_NONE)
95
                dec->codec_id = tmp_codec;
96
            else if (dec->codec_id != tmp_codec)
97
                av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
93
            tmp_codec = get_byte(pb);
98 94
            dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
99 95
            voc->remaining_size -= 2;
100 96
            max_size -= 2;
......
117 113
            dec->sample_rate = get_le32(pb);
118 114
            dec->bits_per_coded_sample = get_byte(pb);
119 115
            dec->channels = get_byte(pb);
120
            tmp_codec = ff_codec_get_id(ff_voc_codec_tags, get_le16(pb));
121
            if (dec->codec_id == CODEC_ID_NONE)
122
                dec->codec_id = tmp_codec;
123
            else if (dec->codec_id != tmp_codec)
124
                av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
116
            tmp_codec = get_le16(pb);
125 117
            url_fskip(pb, 4);
126 118
            voc->remaining_size -= 12;
127 119
            max_size -= 12;
......
133 125
            voc->remaining_size = 0;
134 126
            break;
135 127
        }
128
    }
129

  
130
    if (tmp_codec >= 0) {
131
        tmp_codec = ff_codec_get_id(ff_voc_codec_tags, tmp_codec);
132
        if (dec->codec_id == CODEC_ID_NONE)
133
            dec->codec_id = tmp_codec;
134
        else if (dec->codec_id != tmp_codec)
135
            av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
136 136
        if (dec->codec_id == CODEC_ID_NONE) {
137
            av_log(s, AV_LOG_ERROR, "Invalid codec_id\n");
138
            if (s->audio_codec_id == CODEC_ID_NONE) return AVERROR(EINVAL);
137
            if (s->audio_codec_id == CODEC_ID_NONE) {
138
                av_log(s, AV_LOG_ERROR, "unknown codec tag\n");
139
                return AVERROR(EINVAL);
140
            }
141
            av_log(s, AV_LOG_WARNING, "unknown codec tag\n");
139 142
        }
140 143
    }
141 144

  

Also available in: Unified diff