]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vp56.h
Free encoder extradata in avcodec_close(). Should fix several small memory
[ffmpeg] / libavcodec / vp56.h
index 2870f2a396e20e95fcc196f56e215e9f69707ddb..fab9d1d9d13f0cf211c4fe5b5dd220d822fca177 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * @file vp56.h
+ * @file libavcodec/vp56.h
  * VP5 and VP6 compatible video decoder (common features)
  *
  * Copyright (C) 2006  Aurelien Jacobs <aurel@gnuage.org>
@@ -26,7 +26,7 @@
 
 #include "vp56data.h"
 #include "dsputil.h"
-#include "bitstream.h"
+#include "get_bits.h"
 #include "bytestream.h"
 
 
@@ -50,6 +50,7 @@ typedef struct {
     int high;
     int bits;
     const uint8_t *buffer;
+    const uint8_t *end;
     unsigned long code_word;
 } VP56RangeCoder;
 
@@ -84,7 +85,7 @@ typedef struct {
     uint8_t coeff_runv[2][14];       /* run value (vp6 only) */
     uint8_t mb_type[3][10][10];      /* model for decoding MB type */
     uint8_t mb_types_stats[3][10][2];/* contextual, next MB type stats */
-} Vp56Model;
+} VP56Model;
 
 struct vp56_context {
     AVCodecContext *avctx;
@@ -109,6 +110,7 @@ struct vp56_context {
     int quantizer;
     uint16_t dequant_dc;
     uint16_t dequant_ac;
+    int8_t *qscale_table;
 
     /* DC predictors management */
     VP56RefDc *above_blocks;
@@ -119,7 +121,7 @@ struct vp56_context {
     /* blocks / macroblock */
     VP56mb mb_type;
     VP56Macroblock *macroblocks;
-    DECLARE_ALIGNED_16(DCTELEM, block_coeff[6][64]);
+    DECLARE_ALIGNED_16(DCTELEM, block_coeff)[6][64];
 
     /* motion vectors */
     VP56mv mv[6];  /* vectors for each block in MB */
@@ -155,8 +157,8 @@ struct vp56_context {
     VP56ParseCoeffModels parse_coeff_models;
     VP56ParseHeader parse_header;
 
-    Vp56Model *modelp;
-    Vp56Model models[2];
+    VP56Model *modelp;
+    VP56Model models[2];
 
     /* huffman decoding */
     int use_huffman;
@@ -172,7 +174,7 @@ void vp56_init(AVCodecContext *avctx, int flip, int has_alpha);
 int vp56_free(AVCodecContext *avctx);
 void vp56_init_dequant(VP56Context *s, int quantizer);
 int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
-                      const uint8_t *buf, int buf_size);
+                      AVPacket *avpkt);
 
 
 /**
@@ -185,6 +187,7 @@ static inline void vp56_init_range_decoder(VP56RangeCoder *c,
     c->high = 255;
     c->bits = 8;
     c->buffer = buf;
+    c->end = buf + buf_size;
     c->code_word = bytestream_get_be16(&c->buffer);
 }
 
@@ -205,7 +208,7 @@ static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
     while (c->high < 128) {
         c->high <<= 1;
         c->code_word <<= 1;
-        if (--c->bits == 0) {
+        if (--c->bits == 0 && c->buffer < c->end) {
             c->bits = 8;
             c->code_word |= *c->buffer++;
         }
@@ -228,7 +231,7 @@ static inline int vp56_rac_get(VP56RangeCoder *c)
 
     /* normalize */
     c->code_word <<= 1;
-    if (--c->bits == 0) {
+    if (--c->bits == 0 && c->buffer < c->end) {
         c->bits = 8;
         c->code_word |= *c->buffer++;
     }