summaryrefslogtreecommitdiff
path: root/libavformat/xwma.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/xwma.c')
-rw-r--r--libavformat/xwma.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/libavformat/xwma.c b/libavformat/xwma.c
index b24cde857b..d516b767f7 100644
--- a/libavformat/xwma.c
+++ b/libavformat/xwma.c
@@ -2,20 +2,20 @@
* xWMA demuxer
* Copyright (c) 2011 Max Horn
*
- * 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
*/
@@ -46,7 +46,7 @@ static int xwma_read_header(AVFormatContext *s)
int64_t size;
int ret = 0;
uint32_t dpds_table_size = 0;
- uint32_t *dpds_table = 0;
+ uint32_t *dpds_table = NULL;
unsigned int tag;
AVIOContext *pb = s->pb;
AVStream *st;
@@ -75,7 +75,7 @@ static int xwma_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- ret = ff_get_wav_header(s, pb, st->codec, size);
+ ret = ff_get_wav_header(s, pb, st->codec, size, 0);
if (ret < 0)
return ret;
st->need_parsing = AVSTREAM_PARSE_NONE;
@@ -85,7 +85,8 @@ static int xwma_read_header(AVFormatContext *s)
* extradata for that. Thus, ask the user for feedback, but try to go on
* anyway.
*/
- if (st->codec->codec_id != AV_CODEC_ID_WMAV2) {
+ if (st->codec->codec_id != AV_CODEC_ID_WMAV2 &&
+ st->codec->codec_id != AV_CODEC_ID_WMAPRO) {
avpriv_request_sample(s, "Unexpected codec (tag 0x04%x; id %d)",
st->codec->codec_tag, st->codec->codec_id);
} else {
@@ -103,12 +104,18 @@ static int xwma_read_header(AVFormatContext *s)
*/
avpriv_request_sample(s, "Unexpected extradata (%d bytes)",
st->codec->extradata_size);
+ } else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
+ if (ff_alloc_extradata(st->codec, 18))
+ return AVERROR(ENOMEM);
+
+ memset(st->codec->extradata, 0, st->codec->extradata_size);
+ st->codec->extradata[ 0] = st->codec->bits_per_coded_sample;
+ st->codec->extradata[14] = 224;
} else {
- st->codec->extradata_size = 6;
- st->codec->extradata = av_mallocz(6 + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ if (ff_alloc_extradata(st->codec, 6))
return AVERROR(ENOMEM);
+ memset(st->codec->extradata, 0, st->codec->extradata_size);
/* setup extradata with our experimentally obtained value */
st->codec->extradata[4] = 31;
}
@@ -131,7 +138,7 @@ static int xwma_read_header(AVFormatContext *s)
/* parse the remaining RIFF chunks */
for (;;) {
if (pb->eof_reached) {
- ret = AVERROR_INVALIDDATA;
+ ret = AVERROR_EOF;
goto fail;
}
/* read next chunk tag */
@@ -167,13 +174,13 @@ static int xwma_read_header(AVFormatContext *s)
if (dpds_table_size == 0 || dpds_table_size >= INT_MAX / 4) {
av_log(s, AV_LOG_ERROR,
"dpds chunk size %"PRId64" invalid\n", size);
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* Allocate some temporary storage to keep the dpds data around.
* for processing later on.
*/
- dpds_table = av_malloc(dpds_table_size * sizeof(uint32_t));
+ dpds_table = av_malloc_array(dpds_table_size, sizeof(uint32_t));
if (!dpds_table) {
return AVERROR(ENOMEM);
}