summaryrefslogtreecommitdiffstats
path: root/libavcodec/truemotion2.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/truemotion2.c')
-rw-r--r--libavcodec/truemotion2.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 9e45045..01d9f1e 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -2,20 +2,20 @@
* Duck/ON2 TrueMotion 2 Decoder
* Copyright (c) 2005 Konstantin Shishkov
*
- * 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
*/
@@ -44,6 +44,9 @@ typedef struct TM2Context{
GetBitContext gb;
DSPContext dsp;
+ uint8_t *buffer;
+ int buffer_size;
+
/* TM2 streams */
int *tokens[TM2_NUM_STREAMS];
int tok_lens[TM2_NUM_STREAMS];
@@ -64,7 +67,7 @@ typedef struct TM2Context{
* Huffman codes for each of streams
*/
typedef struct TM2Codes{
- VLC vlc; ///< table for Libav bitstream reader
+ VLC vlc; ///< table for FFmpeg bitstream reader
int bits;
int *recode; ///< table for converting from code indexes to values
int length;
@@ -766,33 +769,29 @@ static int decode_frame(AVCodecContext *avctx,
TM2Context * const l = avctx->priv_data;
AVFrame * const p= (AVFrame*)&l->pic;
int i, skip, t;
- uint8_t *swbuf;
- swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if(!swbuf){
+ av_fast_padded_malloc(&l->buffer, &l->buffer_size, buf_size);
+ if(!l->buffer){
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
return -1;
}
- p->reference = 1;
+ p->reference = 3;
p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if(avctx->reget_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- av_free(swbuf);
return -1;
}
- l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)buf, buf_size >> 2);
- skip = tm2_read_header(l, swbuf);
+ l->dsp.bswap_buf((uint32_t*)l->buffer, (const uint32_t*)buf, buf_size >> 2);
+ skip = tm2_read_header(l, l->buffer);
if(skip == -1){
- av_free(swbuf);
return -1;
}
for(i = 0; i < TM2_NUM_STREAMS; i++){
- t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i], buf_size);
+ t = tm2_read_stream(l, l->buffer + skip, tm2_stream_order[i], buf_size);
if(t == -1){
- av_free(swbuf);
return -1;
}
skip += t;
@@ -806,7 +805,6 @@ static int decode_frame(AVCodecContext *avctx,
l->cur = !l->cur;
*data_size = sizeof(AVFrame);
*(AVFrame*)data = l->pic;
- av_free(swbuf);
return buf_size;
}
@@ -823,6 +821,7 @@ static av_cold int decode_init(AVCodecContext *avctx){
l->avctx = avctx;
l->pic.data[0]=NULL;
avctx->pix_fmt = PIX_FMT_BGR24;
+ avcodec_get_frame_defaults(&l->pic);
ff_dsputil_init(&l->dsp, avctx);
@@ -862,6 +861,8 @@ static av_cold int decode_end(AVCodecContext *avctx){
av_free(l->U2);
av_free(l->V2);
}
+ av_freep(&l->buffer);
+ l->buffer_size = 0;
if (pic->data[0])
avctx->release_buffer(avctx, pic);
OpenPOWER on IntegriCloud