Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit bdd62a615a74ba7d29b528263462937da132c62c)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -38,16 +38,15 @@ static av_cold int adx_decode_init(AVCodecContext *avctx) |
38 | 38 |
ADXContext *c = avctx->priv_data; |
39 | 39 |
int ret, header_size; |
40 | 40 |
|
41 |
- if (avctx->extradata_size < 24) |
|
42 |
- return AVERROR_INVALIDDATA; |
|
43 |
- |
|
44 |
- if ((ret = avpriv_adx_decode_header(avctx, avctx->extradata, |
|
45 |
- avctx->extradata_size, &header_size, |
|
46 |
- c->coeff)) < 0) { |
|
47 |
- av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); |
|
48 |
- return AVERROR_INVALIDDATA; |
|
41 |
+ if (avctx->extradata_size >= 24) { |
|
42 |
+ if ((ret = avpriv_adx_decode_header(avctx, avctx->extradata, |
|
43 |
+ avctx->extradata_size, &header_size, |
|
44 |
+ c->coeff)) < 0) { |
|
45 |
+ av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); |
|
46 |
+ return AVERROR_INVALIDDATA; |
|
47 |
+ } |
|
48 |
+ c->channels = avctx->channels; |
|
49 | 49 |
} |
50 |
- c->channels = avctx->channels; |
|
51 | 50 |
|
52 | 51 |
avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
53 | 52 |
|
... | ... |
@@ -107,6 +106,21 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, |
107 | 107 |
return buf_size; |
108 | 108 |
} |
109 | 109 |
|
110 |
+ if(AV_RB16(buf) == 0x8000){ |
|
111 |
+ int header_size; |
|
112 |
+ if ((ret = avpriv_adx_decode_header(avctx, buf, |
|
113 |
+ buf_size, &header_size, |
|
114 |
+ c->coeff)) < 0) { |
|
115 |
+ av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); |
|
116 |
+ return AVERROR_INVALIDDATA; |
|
117 |
+ } |
|
118 |
+ c->channels = avctx->channels; |
|
119 |
+ if(buf_size < header_size) |
|
120 |
+ return AVERROR_INVALIDDATA; |
|
121 |
+ buf += header_size; |
|
122 |
+ buf_size -= header_size; |
|
123 |
+ } |
|
124 |
+ |
|
110 | 125 |
/* calculate number of blocks in the packet */ |
111 | 126 |
num_blocks = buf_size / (BLOCK_SIZE * c->channels); |
112 | 127 |
|