mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
fraps: Use av_fast_padded_malloc() instead of av_realloc()
Ensures alignment and avoids using uninitialized data. Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
This commit is contained in:
parent
0880503fbb
commit
f54ae2f8e7
@ -46,6 +46,7 @@ typedef struct FrapsContext{
|
||||
AVCodecContext *avctx;
|
||||
AVFrame frame;
|
||||
uint8_t *tmpbuf;
|
||||
int tmpbuf_size;
|
||||
DSPContext dsp;
|
||||
} FrapsContext;
|
||||
|
||||
@ -276,7 +277,10 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
offs[planes] = buf_size;
|
||||
for(i = 0; i < planes; i++){
|
||||
is_chroma = !!i;
|
||||
s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
av_fast_padded_malloc(&s->tmpbuf, &s->tmpbuf_size,
|
||||
offs[i + 1] - offs[i] - 1024);
|
||||
if (!s->tmpbuf)
|
||||
return AVERROR(ENOMEM);
|
||||
if(fraps2_decode_plane(s, f->data[i], f->linesize[i], avctx->width >> is_chroma,
|
||||
avctx->height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i);
|
||||
@ -318,7 +322,10 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
offs[planes] = buf_size;
|
||||
for(i = 0; i < planes; i++){
|
||||
s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
av_fast_padded_malloc(&s->tmpbuf, &s->tmpbuf_size,
|
||||
offs[i + 1] - offs[i] - 1024);
|
||||
if (!s->tmpbuf)
|
||||
return AVERROR(ENOMEM);
|
||||
if(fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), -f->linesize[0],
|
||||
avctx->width, avctx->height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i);
|
||||
|
Loading…
Reference in New Issue
Block a user