]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/snow.c
avcodec/fft-test: fix memory alloc checks
[ffmpeg] / libavcodec / snow.c
index 711d1a4f080ca4fb3dcc49b366a2a3f71f6b28a9..dc80ce6f3b595adeb2afb8cf5381ea85e3931c6f 100644 (file)
@@ -22,7 +22,7 @@
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
-#include "dsputil.h"
+#include "me_cmp.h"
 #include "snow_dwt.h"
 #include "internal.h"
 #include "snow.h"
@@ -69,19 +69,26 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_
 int ff_snow_get_buffer(SnowContext *s, AVFrame *frame)
 {
     int ret, i;
+    int edges_needed = av_codec_is_encoder(s->avctx->codec);
 
-    frame->width  = s->avctx->width  + 2 * EDGE_WIDTH;
-    frame->height = s->avctx->height + 2 * EDGE_WIDTH;
+    frame->width  = s->avctx->width ;
+    frame->height = s->avctx->height;
+    if (edges_needed) {
+        frame->width  += 2 * EDGE_WIDTH;
+        frame->height += 2 * EDGE_WIDTH;
+    }
     if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
         return ret;
-    for (i = 0; frame->data[i]; i++) {
-        int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) *
-                        frame->linesize[i] +
-                        (EDGE_WIDTH >> (i ? s->chroma_h_shift : 0));
-        frame->data[i] += offset;
+    if (edges_needed) {
+        for (i = 0; frame->data[i]; i++) {
+            int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) *
+                            frame->linesize[i] +
+                            (EDGE_WIDTH >> (i ? s->chroma_h_shift : 0));
+            frame->data[i] += offset;
+        }
+        frame->width  = s->avctx->width;
+        frame->height = s->avctx->height;
     }
-    frame->width  = s->avctx->width;
-    frame->height = s->avctx->height;
 
     return 0;
 }
@@ -428,12 +435,11 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
     s->avctx= avctx;
     s->max_ref_frames=1; //just make sure it's not an invalid value in case of no initial keyframe
 
-    ff_dsputil_init(&s->dsp, avctx);
+    ff_me_cmp_init(&s->mecc, avctx);
     ff_hpeldsp_init(&s->hdsp, avctx->flags);
     ff_videodsp_init(&s->vdsp, 8);
     ff_dwt_init(&s->dwt);
     ff_h264qpel_init(&s->h264qpel, 8);
-    ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
 
 #define mcf(dx,dy)\
     s->qdsp.put_qpel_pixels_tab       [0][dy+dx/4]=\
@@ -639,22 +645,6 @@ void ff_snow_release_buffer(AVCodecContext *avctx)
 int ff_snow_frame_start(SnowContext *s){
    AVFrame *tmp;
    int i, ret;
-   int w= s->avctx->width; //FIXME round up to x16 ?
-   int h= s->avctx->height;
-
-    if (s->current_picture->data[0] && !(s->avctx->flags&CODEC_FLAG_EMU_EDGE)) {
-        s->mpvencdsp.draw_edges(s->current_picture->data[0],
-                                s->current_picture->linesize[0], w   , h   ,
-                                EDGE_WIDTH  , EDGE_WIDTH  , EDGE_TOP | EDGE_BOTTOM);
-        if (s->current_picture->data[2]) {
-            s->mpvencdsp.draw_edges(s->current_picture->data[1],
-                                    s->current_picture->linesize[1], w>>s->chroma_h_shift, h>>s->chroma_v_shift,
-                                    EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);
-            s->mpvencdsp.draw_edges(s->current_picture->data[2],
-                                    s->current_picture->linesize[2], w>>s->chroma_h_shift, h>>s->chroma_v_shift,
-                                    EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);
-        }
-    }
 
     ff_snow_release_buffer(s->avctx);