]> granicus.if.org Git - libvpx/commitdiff
abstract apply_temporal_filter
authorJohann <johannkoenig@google.com>
Mon, 29 Nov 2010 19:21:11 +0000 (14:21 -0500)
committerJohann <johannkoenig@google.com>
Wed, 22 Dec 2010 16:31:54 +0000 (11:31 -0500)
allow for optimized versions of apply_temporal_filter
(now vp8_apply_temporal_filter_c)

the function was previously declared as static and appears to have been
inlined. with this change, that's no longer possible. performance takes
a small hit.

the declaration for vp8_cx_temp_filter_c was moved to onyx_if.c because
of a circular dependency. for rtcd, temporal_filter.h holds the
definition for the rtcd table, so it needs to be included by onyx_int.h.
however, onyx_int.h holds the definition for VP8_COMP which is needed
for the function prototype. blah.

Change-Id: I499c055fdc652ac4659c21c5a55fe10ceb7e95e3

vp8/encoder/generic/csystemdependent.c
vp8/encoder/onyx_if.c
vp8/encoder/onyx_int.h
vp8/encoder/temporal_filter.c
vp8/encoder/temporal_filter.h

index 824af5e46ad546bb82fd0ffba77ea5a33b1f1d61..898ad76fbb732c9e07ee198d20f9ecaa9cd7ee41 100644 (file)
@@ -94,6 +94,8 @@ void vp8_cmachine_specific_config(VP8_COMP *cpi)
 
     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:
index 279d50d547ebf5a186719370ed3a70c263cd55c6..b346333933384cbc464a1081fefb7a4cda7ee3e8 100644 (file)
@@ -73,6 +73,7 @@ int vp8_estimate_entropy_savings(VP8_COMP *cpi);
 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);
 
index 56938bec409e87e114aa9b76cb3426fa47c7aa3c..990ae1d9e427276854edb1f5f51156c44449975d 100644 (file)
@@ -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 @@ typedef struct VP8_ENCODER_RTCD
     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
index e4d47462f9570729f37ad666a0618df04f78552c..31be76ec126e1d5949214b68c0346af49b06e542 100644 (file)
@@ -111,7 +111,7 @@ static void build_predictors_mb
         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 @@ static void vp8cx_temp_blur1_c
                               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 );
-
-                    apply_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->y_buffer + mb_y_offset,
+                         f->y_stride,
+                         predictor,
+                         16,
+                         strength,
+                         filter_weight[frame],
+                         accumulator,
+                         count);
+
+                    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);
+
+                    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);
                 }
             }
 
index f70e8c01e8f2d78c79e14ae1f0b23c710c0c5033..3271f6e5ab36fe43d55632674d2837196707f108 100644 (file)
 #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