mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
pcmdec: consistently use codec_id, fixes out of array reads
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
eab022d863
commit
7373b3ad04
@ -211,7 +211,7 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
|
|||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (avctx->codec->id) {
|
switch (avctx->codec_id) {
|
||||||
case AV_CODEC_ID_PCM_ALAW:
|
case AV_CODEC_ID_PCM_ALAW:
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
s->table[i] = alaw2linear(i);
|
s->table[i] = alaw2linear(i);
|
||||||
@ -227,7 +227,7 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
|
|||||||
avctx->sample_fmt = avctx->codec->sample_fmts[0];
|
avctx->sample_fmt = avctx->codec->sample_fmts[0];
|
||||||
|
|
||||||
if (avctx->sample_fmt == AV_SAMPLE_FMT_S32)
|
if (avctx->sample_fmt == AV_SAMPLE_FMT_S32)
|
||||||
avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec->id);
|
avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec_id);
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&s->frame);
|
avcodec_get_frame_defaults(&s->frame);
|
||||||
avctx->coded_frame = &s->frame;
|
avctx->coded_frame = &s->frame;
|
||||||
@ -315,7 +315,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
samples = s->frame.data[0];
|
samples = s->frame.data[0];
|
||||||
|
|
||||||
switch (avctx->codec->id) {
|
switch (avctx->codec_id) {
|
||||||
case AV_CODEC_ID_PCM_U32LE:
|
case AV_CODEC_ID_PCM_U32LE:
|
||||||
DECODE(32, le32, src, samples, n, 0, 0x80000000)
|
DECODE(32, le32, src, samples, n, 0, 0x80000000)
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user