summaryrefslogtreecommitdiff
path: root/libavformat/au.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/au.c')
-rw-r--r--libavformat/au.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/libavformat/au.c b/libavformat/au.c
index e09d7ac5cd..b7654a417a 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -2,20 +2,20 @@
* AU muxer and demuxer
* Copyright (c) 2001 Fabrice Bellard
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -120,7 +120,7 @@ static int au_probe(AVProbeData *p)
/* au input */
static int au_read_header(AVFormatContext *s)
{
- int size;
+ int size, bps, data_size = 0;
unsigned int tag;
AVIOContext *pb = s->pb;
unsigned int id, channels, rate;
@@ -132,7 +132,12 @@ static int au_read_header(AVFormatContext *s)
if (tag != MKTAG('.', 's', 'n', 'd'))
return -1;
size = avio_rb32(pb); /* header size */
- avio_rb32(pb); /* data size */
+ data_size = avio_rb32(pb); /* data size in bytes */
+
+ if (data_size < 0 && data_size != AU_UNKNOWN_SIZE) {
+ av_log(s, AV_LOG_ERROR, "Invalid negative data size '%d' found\n", data_size);
+ return AVERROR_INVALIDDATA;
+ }
id = avio_rb32(pb);
rate = avio_rb32(pb);
@@ -140,7 +145,7 @@ static int au_read_header(AVFormatContext *s)
codec = ff_codec_get_id(codec_au_tags, id);
- if (!av_get_bits_per_sample(codec)) {
+ if (!(bps = av_get_bits_per_sample(codec))) {
av_log_ask_for_sample(s, "could not determine bits per sample\n");
return AVERROR_INVALIDDATA;
}
@@ -164,6 +169,8 @@ static int au_read_header(AVFormatContext *s)
st->codec->codec_id = codec;
st->codec->channels = channels;
st->codec->sample_rate = rate;
+ if (data_size != AU_UNKNOWN_SIZE)
+ st->duration = (((int64_t)data_size)<<3) / (st->codec->channels * (int64_t)bps);
avpriv_set_pts_info(st, 64, 1, rate);
return 0;
}
@@ -180,11 +187,8 @@ static int au_read_packet(AVFormatContext *s,
av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);
if (ret < 0)
return ret;
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
-
- /* note: we need to modify the packet size here to handle the last
- packet */
- pkt->size = ret;
return 0;
}