From 092b5bef37f87c77a048246d841ba6343c315176 Mon Sep 17 00:00:00 2001 From: Johann Date: Mon, 29 Nov 2010 14:21:11 -0500 Subject: [PATCH] abstract apply_temporal_filter 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 | 2 + vp8/encoder/onyx_if.c | 1 + vp8/encoder/onyx_int.h | 2 + vp8/encoder/temporal_filter.c | 53 ++++++++++++++------------ vp8/encoder/temporal_filter.h | 29 +++++++++++++- 5 files changed, 60 insertions(+), 27 deletions(-) diff --git a/vp8/encoder/generic/csystemdependent.c b/vp8/encoder/generic/csystemdependent.c index 824af5e46..898ad76fb 100644 --- a/vp8/encoder/generic/csystemdependent.c +++ b/vp8/encoder/generic/csystemdependent.c @@ -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: diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 279d50d54..b34633393 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -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); diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index 56938bec4..990ae1d9e 100644 --- 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 @@ 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 diff --git a/vp8/encoder/temporal_filter.c b/vp8/encoder/temporal_filter.c index e4d47462f..31be76ec1 100644 --- a/vp8/encoder/temporal_filter.c +++ b/vp8/encoder/temporal_filter.c @@ -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 ); + 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); } } diff --git a/vp8/encoder/temporal_filter.h b/vp8/encoder/temporal_filter.h index f70e8c01e..3271f6e5a 100644 --- 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