* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdint.h>
+
#include "libavutil/avassert.h"
#include "libavutil/dict.h"
#include "libavutil/log.h"
return avio_rl32(pb);
}
+/* RIFF chunks are always on a even offset. */
+static int64_t wav_seek_tag(AVIOContext *s, int64_t offset, int whence)
+{
+ return avio_seek(s, offset + (offset & 1), whence);
+}
+
/* return the size of the found tag */
static int64_t find_tag(AVIOContext *pb, uint32_t tag1)
{
size = next_tag(pb, &tag);
if (tag == tag1)
break;
- avio_skip(pb, size);
+ wav_seek_tag(pb, size, SEEK_CUR);
}
return size;
}
if (!*st)
return AVERROR(ENOMEM);
- ret = ff_get_wav_header(pb, (*st)->codec, size);
+ ret = ff_get_wav_header(s, pb, (*st)->codecpar, size);
if (ret < 0)
return ret;
(*st)->need_parsing = AVSTREAM_PARSE_FULL;
- avpriv_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate);
+ avpriv_set_pts_info(*st, 64, 1, (*st)->codecpar->sample_rate);
return 0;
}
/* don't look for footer metadata if we can't seek or if we don't
* know where the data tag ends
*/
- if (!pb->seekable || (!rf64 && !size))
+ if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || (!rf64 && !size))
goto break_loop;
break;
case MKTAG('f', 'a', 'c', 't'):
/* seek to next tag unless we know that we'll run into EOF */
if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) ||
- avio_seek(pb, next_tag_ofs, SEEK_SET) < 0) {
+ wav_seek_tag(pb, next_tag_ofs, SEEK_SET) < 0) {
break;
}
}
avio_seek(pb, data_ofs, SEEK_SET);
- if (!sample_count && st->codec->channels &&
- av_get_bits_per_sample(st->codec->codec_id))
+ if (!sample_count && st->codecpar->channels &&
+ av_get_bits_per_sample(st->codecpar->codec_id))
sample_count = (data_size << 3) /
- (st->codec->channels *
- (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
+ (st->codecpar->channels *
+ (uint64_t)av_get_bits_per_sample(st->codecpar->codec_id));
if (sample_count)
st->duration = sample_count;
}
size = MAX_SIZE;
- if (st->codec->block_align > 1) {
- if (size < st->codec->block_align)
- size = st->codec->block_align;
- size = (size / st->codec->block_align) * st->codec->block_align;
+ if (st->codecpar->block_align > 1) {
+ if (size < st->codecpar->block_align)
+ size = st->codecpar->block_align;
+ size = (size / st->codecpar->block_align) * st->codecpar->block_align;
}
size = FFMIN(size, left);
ret = av_get_packet(s->pb, pkt, size);
AVStream *st;
st = s->streams[0];
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
case AV_CODEC_ID_AC3:
return AVERROR(ENOMEM);
/* subtract chunk header size - normal wav file doesn't count it */
- ret = ff_get_wav_header(pb, st->codec, size - 24);
+ ret = ff_get_wav_header(s, pb, st->codecpar, size - 24);
if (ret < 0)
return ret;
avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
st->need_parsing = AVSTREAM_PARSE_FULL;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
size = find_guid(pb, guid_data);
if (size < 0) {