]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vp6.c
Alpha: move dsputil prototypes to a header file
[ffmpeg] / libavcodec / vp6.c
index 6ffde072f7b7d3281db45ea6b90097c08060b6b7..b3dd80ffbf35f2d30e9abb7a42667e855493a3e6 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * @file vp6.c
+ * @file libavcodec/vp6.c
  * VP6 compatible video decoder
  *
  * Copyright (C) 2006  Aurelien Jacobs <aurel@gnuage.org>
@@ -29,7 +29,7 @@
 
 #include "avcodec.h"
 #include "dsputil.h"
-#include "bitstream.h"
+#include "get_bits.h"
 #include "huffman.h"
 
 #include "vp56.h"
@@ -227,6 +227,7 @@ static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
         nodes[map[2*i+1]].count = b + !b;
     }
 
+    free_vlc(vlc);
     /* then build the huffman tree accodring to probabilities */
     ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
                        FF_HUFFMAN_FLAG_HNODE_FIRST);
@@ -372,6 +373,8 @@ static void vp6_parse_coeff_huffman(VP56Context *s)
                 if (coeff_idx)
                     break;
             } else {
+                if (get_bits_count(&s->gb) >= s->gb.size_in_bits)
+                    return;
                 coeff = get_vlc2(&s->gb, vlc_coeff->table, 9, 3);
                 if (coeff == 0) {
                     if (coeff_idx) {
@@ -531,39 +534,6 @@ static void vp6_filter_diag2(VP56Context *s, uint8_t *dst, uint8_t *src,
     s->dsp.put_h264_chroma_pixels_tab[0](dst, tmp, stride, 8, 0, v_weight);
 }
 
-static void vp6_filter_diag4(uint8_t *dst, uint8_t *src, int stride,
-                             const int16_t *h_weights,const int16_t *v_weights)
-{
-    int x, y;
-    int tmp[8*11];
-    int *t = tmp;
-
-    src -= stride;
-
-    for (y=0; y<11; y++) {
-        for (x=0; x<8; x++) {
-            t[x] = av_clip_uint8((  src[x-1] * h_weights[0]
-                               + src[x  ] * h_weights[1]
-                               + src[x+1] * h_weights[2]
-                               + src[x+2] * h_weights[3] + 64) >> 7);
-        }
-        src += stride;
-        t += 8;
-    }
-
-    t = tmp + 8;
-    for (y=0; y<8; y++) {
-        for (x=0; x<8; x++) {
-            dst[x] = av_clip_uint8((  t[x-8 ] * v_weights[0]
-                                 + t[x   ] * v_weights[1]
-                                 + t[x+8 ] * v_weights[2]
-                                 + t[x+16] * v_weights[3] + 64) >> 7);
-        }
-        dst += stride;
-        t += 8;
-    }
-}
-
 static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src,
                        int offset1, int offset2, int stride,
                        VP56mv mv, int mask, int select, int luma)
@@ -601,7 +571,7 @@ static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src,
             vp6_filter_hv4(dst, src+offset1, stride, stride,
                            vp6_block_copy_filter[select][y8]);
         } else {
-            vp6_filter_diag4(dst, src+offset1 + ((mv.x^mv.y)>>31), stride,
+            s->dsp.vp6_filter_diag4(dst, src+offset1+((mv.x^mv.y)>>31), stride,
                              vp6_block_copy_filter[select][x8],
                              vp6_block_copy_filter[select][y8]);
         }
@@ -632,6 +602,23 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx)
     return 0;
 }
 
+static av_cold int vp6_decode_free(AVCodecContext *avctx)
+{
+    VP56Context *s = avctx->priv_data;
+    int pt, ct, cg;
+
+    vp56_free(avctx);
+
+    for (pt=0; pt<2; pt++) {
+        free_vlc(&s->dccv_vlc[pt]);
+        free_vlc(&s->runv_vlc[pt]);
+        for (ct=0; ct<3; ct++)
+            for (cg=0; cg<6; cg++)
+                free_vlc(&s->ract_vlc[pt][ct][cg]);
+    }
+    return 0;
+}
+
 AVCodec vp6_decoder = {
     "vp6",
     CODEC_TYPE_VIDEO,
@@ -639,7 +626,7 @@ AVCodec vp6_decoder = {
     sizeof(VP56Context),
     vp6_decode_init,
     NULL,
-    vp56_free,
+    vp6_decode_free,
     vp56_decode_frame,
     CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("On2 VP6"),
@@ -653,7 +640,7 @@ AVCodec vp6f_decoder = {
     sizeof(VP56Context),
     vp6_decode_init,
     NULL,
-    vp56_free,
+    vp6_decode_free,
     vp56_decode_frame,
     CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version)"),
@@ -667,7 +654,7 @@ AVCodec vp6a_decoder = {
     sizeof(VP56Context),
     vp6_decode_init,
     NULL,
-    vp56_free,
+    vp6_decode_free,
     vp56_decode_frame,
     CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"),