shithub: libvpx

Download patch

ref: e2de094c99135cb78d28fe75b9ffa34247f99328
parent: bd9b383db20898424b6ef7deea769dd2b176e9f4
parent: 092b5bef37f87c77a048246d841ba6343c315176
author: Johann <johannkoenig@google.com>
date: Thu Dec 23 01:14:07 EST 2010

Merge "abstract apply_temporal_filter"

--- a/vp8/encoder/generic/csystemdependent.c
+++ b/vp8/encoder/generic/csystemdependent.c
@@ -94,6 +94,8 @@
 
     cpi->rtcd.search.full_search             = vp8_full_search_sad;
     cpi->rtcd.search.diamond_search          = vp8_diamond_search_sad;
+
+    cpi->rtcd.temporal.filter                = vp8_apply_temporal_filter_c;
 #endif
 
     // Pure C:
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -73,6 +73,7 @@
 int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, const vp8_variance_rtcd_vtable_t *rtcd);
 int vp8_calc_low_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, const vp8_variance_rtcd_vtable_t *rtcd);
 
+extern void vp8cx_temp_filter_c(VP8_COMP *cpi);
 
 static void set_default_lf_deltas(VP8_COMP *cpi);
 
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -27,6 +27,7 @@
 #include "vpx_ports/mem.h"
 #include "vpx/internal/vpx_codec_internal.h"
 #include "mcomp.h"
+#include "temporal_filter.h"
 
 //#define SPEEDSTATS 1
 #define MIN_GF_INTERVAL             4
@@ -228,6 +229,7 @@
     vp8_encodemb_rtcd_vtable_t  encodemb;
     vp8_quantize_rtcd_vtable_t  quantize;
     vp8_search_rtcd_vtable_t    search;
+    vp8_temporal_rtcd_vtable_t  temporal;
 } VP8_ENCODER_RTCD;
 
 enum
--- a/vp8/encoder/temporal_filter.c
+++ b/vp8/encoder/temporal_filter.c
@@ -111,7 +111,7 @@
         RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, stride, &pred[320], 8);
     }
 }
-static void apply_temporal_filter
+void vp8_apply_temporal_filter_c
 (
     unsigned char *frame1,
     unsigned int stride,
@@ -440,32 +440,35 @@
                               predictor );
 
                     // Apply the filter (YUV)
-                    apply_temporal_filter ( f->y_buffer + mb_y_offset,
-                                            f->y_stride,
-                                            predictor,
-                                            16,
-                                            strength,
-                                            filter_weight[frame],
-                                            accumulator,
-                                            count );
+                    TEMPORAL_INVOKE(&cpi->rtcd.temporal, filter)
+                        (f->y_buffer + mb_y_offset,
+                         f->y_stride,
+                         predictor,
+                         16,
+                         strength,
+                         filter_weight[frame],
+                         accumulator,
+                         count);
 
-                    apply_temporal_filter ( f->u_buffer + mb_uv_offset,
-                                            f->uv_stride,
-                                            predictor + 256,
-                                            8,
-                                            strength,
-                                            filter_weight[frame],
-                                            accumulator + 256,
-                                            count + 256 );
+                    TEMPORAL_INVOKE(&cpi->rtcd.temporal, filter)
+                        (f->u_buffer + mb_uv_offset,
+                         f->uv_stride,
+                         predictor + 256,
+                         8,
+                         strength,
+                         filter_weight[frame],
+                         accumulator + 256,
+                         count + 256);
 
-                    apply_temporal_filter ( f->v_buffer + mb_uv_offset,
-                                            f->uv_stride,
-                                            predictor + 320,
-                                            8,
-                                            strength,
-                                            filter_weight[frame],
-                                            accumulator + 320,
-                                            count + 320 );
+                    TEMPORAL_INVOKE(&cpi->rtcd.temporal, filter)
+                        (f->v_buffer + mb_uv_offset,
+                         f->uv_stride,
+                         predictor + 320,
+                         8,
+                         strength,
+                         filter_weight[frame],
+                         accumulator + 320,
+                         count + 320);
                 }
             }
 
--- a/vp8/encoder/temporal_filter.h
+++ b/vp8/encoder/temporal_filter.h
@@ -12,8 +12,33 @@
 #ifndef __INC_VP8_TEMPORAL_FILTER_H
 #define __INC_VP8_TEMPORAL_FILTER_H
 
-#include "onyx_int.h"
+#define prototype_filter(sym)\
+    void (sym) \
+    ( \
+     unsigned char *frame1, \
+     unsigned int stride, \
+     unsigned char *frame2, \
+     unsigned int block_size, \
+     int strength, \
+     int filter_weight, \
+     unsigned int *accumulator, \
+     unsigned int *count \
+    )
 
-void vp8cx_temp_filter_c(VP8_COMP *cpi);
+#ifndef vp8_temporal_filter
+#define vp8_temporal_filter vp8_apply_temporal_filter_c
+#endif
+extern prototype_filter(vp8_temporal_filter);
+
+typedef struct
+{
+    prototype_filter(*filter);
+} vp8_temporal_rtcd_vtable_t;
+
+#if CONFIG_RUNTIME_CPU_DETECT
+#define TEMPORAL_INVOKE(ctx,fn) (ctx)->fn
+#else
+#define TEMPORAL_INVOKE(ctx,fn) vp8_temporal_##fn
+#endif
 
 #endif // __INC_VP8_TEMPORAL_FILTER_H