diff options
Diffstat (limited to 'libavcodec/escape124.c')
-rw-r--r-- | libavcodec/escape124.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index b304dd8b39..0879b3e034 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -2,20 +2,20 @@ * Escape 124 Video Decoder * Copyright (C) 2008 Eli Friedman (eli.friedman@gmail.com) * - * 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 */ @@ -49,7 +49,7 @@ typedef struct Escape124Context { CodeBook codebooks[3]; } Escape124Context; -static int can_safely_read(GetBitContext* gb, int bits) { +static int can_safely_read(GetBitContext* gb, uint64_t bits) { return get_bits_left(gb) >= bits; } @@ -62,6 +62,7 @@ static av_cold int escape124_decode_init(AVCodecContext *avctx) { Escape124Context *s = avctx->priv_data; + avcodec_get_frame_defaults(&s->frame); avctx->pix_fmt = AV_PIX_FMT_RGB555; s->num_superblocks = ((unsigned)avctx->width / 8) * @@ -89,7 +90,7 @@ static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth, unsigned i, j; CodeBook cb = { 0 }; - if (!can_safely_read(gb, size * 34)) + if (!can_safely_read(gb, (uint64_t)size * 34)) return cb; if (size >= INT_MAX / sizeof(MacroBlock)) @@ -199,7 +200,6 @@ static int escape124_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; Escape124Context *s = avctx->priv_data; AVFrame *frame = data; @@ -214,9 +214,11 @@ static int escape124_decode_frame(AVCodecContext *avctx, uint16_t* old_frame_data, *new_frame_data; unsigned old_stride, new_stride; + int ret; - init_get_bits(&gb, buf, buf_size * 8); + if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0) + return ret; // This call also guards the potential depth reads for the // codebook unpacking. @@ -232,7 +234,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, if (!s->frame.data[0]) return AVERROR_INVALIDDATA; - av_log(NULL, AV_LOG_DEBUG, "Skipping frame\n"); + av_log(avctx, AV_LOG_DEBUG, "Skipping frame\n"); *got_frame = 1; if ((ret = av_frame_ref(frame, &s->frame)) < 0) @@ -269,10 +271,8 @@ static int escape124_decode_frame(AVCodecContext *avctx, } } - if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; - } new_frame_data = (uint16_t*)frame->data[0]; new_stride = frame->linesize[0] / 2; @@ -352,7 +352,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, skip--; } - av_log(NULL, AV_LOG_DEBUG, + av_log(avctx, AV_LOG_DEBUG, "Escape sizes: %i, %i, %i\n", frame_size, buf_size, get_bits_count(&gb) / 8); |