]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vp8.c
svq3: rip out the svq3-relevant parts of pred_motion() out of h264
[ffmpeg] / libavcodec / vp8.c
index 4ea6d562b3ec6e990cbca917b60797c103a94434..d5f8fbb66694ec948abc1b9decd65524261a86e9 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "avcodec.h"
 #include "internal.h"
+#include "mathops.h"
 #include "rectangle.h"
 #include "thread.h"
 #include "vp8.h"
@@ -480,6 +481,10 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
     int width  = s->avctx->width;
     int height = s->avctx->height;
 
+    if (buf_size < 4) {
+        return AVERROR_INVALIDDATA;
+    }
+
     s->profile = (buf[0] >> 1) & 7;
     if (s->profile > 1) {
         avpriv_request_sample(s->avctx, "Unknown profile %d", s->profile);
@@ -493,6 +498,10 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
     buf      += 4 - s->profile;
     buf_size -= 4 - s->profile;
 
+    if (buf_size < part1_size) {
+        return AVERROR_INVALIDDATA;
+    }
+
     memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab));
 
     ff_vp56_init_range_decoder(c, buf, part1_size);
@@ -519,7 +528,7 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
                    sizeof(vp7_mv_default_prob[i]));
         memset(&s->segmentation, 0, sizeof(s->segmentation));
         memset(&s->lf_delta, 0, sizeof(s->lf_delta));
-        memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan));
+        memcpy(s->prob[0].scan, ff_zigzag_scan, sizeof(s->prob[0].scan));
     }
 
     if (s->keyframe || s->profile > 0)
@@ -591,7 +600,7 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
     /* G. DCT coefficient ordering specification */
     if (vp8_rac_get(c))
         for (i = 1; i < 16; i++)
-            s->prob[0].scan[i] = zigzag_scan[vp8_rac_get_uint(c, 4)];
+            s->prob[0].scan[i] = ff_zigzag_scan[vp8_rac_get_uint(c, 4)];
 
     /* H. Loop filter levels  */
     if (s->profile > 0)
@@ -1309,7 +1318,7 @@ static int vp8_decode_block_coeffs_internal(VP56RangeCoder *r,
                                             int16_t qmul[2])
 {
     return decode_block_coeffs_internal(r, block, probs, i,
-                                        token_prob, qmul, zigzag_scan, IS_VP8);
+                                        token_prob, qmul, ff_zigzag_scan, IS_VP8);
 }
 #endif
 
@@ -1356,7 +1365,7 @@ void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c,
         // decode DC values and do hadamard
         nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0,
                                   nnz_pred, s->qmat[segment].luma_dc_qmul,
-                                  zigzag_scan, is_vp7);
+                                  ff_zigzag_scan, is_vp7);
         l_nnz[8] = t_nnz[8] = !!nnz;
 
         if (is_vp7 && mb->mode > MODE_I4x4) {
@@ -2671,7 +2680,7 @@ int vp78_decode_init(AVCodecContext *avctx, int is_vp7)
     }
 
     /* does not change for VP8 */
-    memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan));
+    memcpy(s->prob[0].scan, ff_zigzag_scan, sizeof(s->prob[0].scan));
 
     if ((ret = vp8_init_frames(s)) < 0) {
         ff_vp8_decode_free(avctx);
@@ -2756,7 +2765,7 @@ AVCodec ff_vp7_decoder = {
     .init                  = vp7_decode_init,
     .close                 = ff_vp8_decode_free,
     .decode                = vp7_decode_frame,
-    .capabilities          = CODEC_CAP_DR1,
+    .capabilities          = AV_CODEC_CAP_DR1,
     .flush                 = vp8_decode_flush,
 };
 #endif /* CONFIG_VP7_DECODER */
@@ -2771,7 +2780,8 @@ AVCodec ff_vp8_decoder = {
     .init                  = ff_vp8_decode_init,
     .close                 = ff_vp8_decode_free,
     .decode                = ff_vp8_decode_frame,
-    .capabilities          = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS,
+    .capabilities          = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
+                             AV_CODEC_CAP_SLICE_THREADS,
     .flush                 = vp8_decode_flush,
     .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy),
     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context),