Begin to refactor vpx_scale usage in VP9
Only declare the functions in vpx_scale RTCD and include the relevant header. Remove unused files and functions in vpx_scale to avoid wasting time renaming. vpx_scale/win32/scaleopt.c contains functions which have not been called in a long time but are potentially optimized. The 'vp8' functions have not been renamed yet. That is for after the cleanup. Change-Id: I2c325a101d60fa9d27e7dfcd5b52a864b4a1e09c
This commit is contained in:
parent
34591b54dd
commit
c6bd29e2f5
@ -16,6 +16,7 @@
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
#include "vp9/common/vp9_systemdependent.h"
|
||||
#include "./vp9_rtcd.h"
|
||||
#include "./vpx_scale_rtcd.h"
|
||||
|
||||
|
||||
#include <math.h>
|
||||
|
@ -677,39 +677,3 @@ specialize vp9_yv12_copy_partial_frame
|
||||
|
||||
fi
|
||||
# end encoder functions
|
||||
|
||||
# Scaler functions
|
||||
if [ "$CONFIG_SPATIAL_RESAMPLING" = "yes" ]; then
|
||||
prototype void vp8_horizontal_line_4_5_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_4_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_4_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_2_3_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_2_3_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_2_3_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_3_5_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_3_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_3_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_3_4_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_3_4_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_3_4_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_1_2_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_1_2_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_1_2_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_5_4_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_5_4_scale "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_5_3_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_5_3_scale "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_2_1_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_2_1_scale "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_2_1_scale_i "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
fi
|
||||
|
||||
prototype void vp8_yv12_extend_frame_borders "struct yv12_buffer_config *ybf"
|
||||
specialize vp8_yv12_extend_frame_borders
|
||||
|
||||
prototype void vp8_yv12_copy_frame "struct yv12_buffer_config *src_ybc, struct yv12_buffer_config *dst_ybc"
|
||||
specialize vp8_yv12_copy_frame
|
||||
|
||||
prototype void vp8_yv12_copy_y "struct yv12_buffer_config *src_ybc, struct yv12_buffer_config *dst_ybc"
|
||||
specialize vp8_yv12_copy_y
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "vpx_ports/vpx_timer.h"
|
||||
#include "vp9/decoder/vp9_decodframe.h"
|
||||
#include "vp9/decoder/vp9_detokenize.h"
|
||||
#include "./vpx_scale_rtcd.h"
|
||||
|
||||
static int get_free_fb(VP9_COMMON *cm);
|
||||
static void ref_cnt_fb(int *buf, int *idx, int new_idx);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "vp9/common/vp9_quant_common.h"
|
||||
#include "vp9/common/vp9_entropymv.h"
|
||||
#include "vp9/encoder/vp9_encodemv.h"
|
||||
#include "./vpx_scale_rtcd.h"
|
||||
|
||||
#define OUTPUT_FPF 0
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "vp9/common/vp9_quant_common.h"
|
||||
#include "vp9/encoder/vp9_segmentation.h"
|
||||
#include "./vp9_rtcd.h"
|
||||
#include "./vpx_scale_rtcd.h"
|
||||
#if CONFIG_POSTPROC
|
||||
#include "vp9/common/vp9_postproc.h"
|
||||
#endif
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
#include "vp9/common/vp9_alloccommon.h"
|
||||
#include "vp9/common/vp9_loopfilter.h"
|
||||
#include "./vpx_scale_rtcd.h"
|
||||
|
||||
void vp9_yv12_copy_partial_frame_c(YV12_BUFFER_CONFIG *src_ybc,
|
||||
YV12_BUFFER_CONFIG *dst_ybc, int Fraction) {
|
||||
|
@ -1,569 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
#include "vpxscale_arbitrary.h"
|
||||
|
||||
#define FIXED_POINT
|
||||
|
||||
#define MAX_IN_WIDTH 800
|
||||
#define MAX_IN_HEIGHT 600
|
||||
#define MAX_OUT_WIDTH 800
|
||||
#define MAX_OUT_HEIGHT 600
|
||||
#define MAX_OUT_DIMENSION ((MAX_OUT_WIDTH > MAX_OUT_HEIGHT) ? \
|
||||
MAX_OUT_WIDTH : MAX_OUT_HEIGHT)
|
||||
|
||||
BICUBIC_SCALER_STRUCT g_b_scaler;
|
||||
static int g_first_time = 1;
|
||||
|
||||
#pragma DATA_SECTION(g_hbuf, "VP6_HEAP")
|
||||
#pragma DATA_ALIGN (g_hbuf, 32);
|
||||
unsigned char g_hbuf[MAX_OUT_DIMENSION];
|
||||
|
||||
#pragma DATA_SECTION(g_hbuf_uv, "VP6_HEAP")
|
||||
#pragma DATA_ALIGN (g_hbuf_uv, 32);
|
||||
unsigned char g_hbuf_uv[MAX_OUT_DIMENSION];
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
static int a_i = 0.6 * 65536;
|
||||
#else
|
||||
static float a = -0.6;
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
// 3 2
|
||||
// C0 = a*t - a*t
|
||||
//
|
||||
static short c0_fixed(unsigned int t) {
|
||||
// put t in Q16 notation
|
||||
unsigned short v1, v2;
|
||||
|
||||
// Q16
|
||||
v1 = (a_i * t) >> 16;
|
||||
v1 = (v1 * t) >> 16;
|
||||
|
||||
// Q16
|
||||
v2 = (a_i * t) >> 16;
|
||||
v2 = (v2 * t) >> 16;
|
||||
v2 = (v2 * t) >> 16;
|
||||
|
||||
// Q12
|
||||
return -((v1 - v2) >> 4);
|
||||
}
|
||||
|
||||
// 2 3
|
||||
// C1 = a*t + (3-2*a)*t - (2-a)*t
|
||||
//
|
||||
static short c1_fixed(unsigned int t) {
|
||||
unsigned short v1, v2, v3;
|
||||
unsigned short two, three;
|
||||
|
||||
// Q16
|
||||
v1 = (a_i * t) >> 16;
|
||||
|
||||
// Q13
|
||||
two = 2 << 13;
|
||||
v2 = two - (a_i >> 3);
|
||||
v2 = (v2 * t) >> 16;
|
||||
v2 = (v2 * t) >> 16;
|
||||
v2 = (v2 * t) >> 16;
|
||||
|
||||
// Q13
|
||||
three = 3 << 13;
|
||||
v3 = three - (2 * (a_i >> 3));
|
||||
v3 = (v3 * t) >> 16;
|
||||
v3 = (v3 * t) >> 16;
|
||||
|
||||
// Q12
|
||||
return (((v1 >> 3) - v2 + v3) >> 1);
|
||||
|
||||
}
|
||||
|
||||
// 2 3
|
||||
// C2 = 1 - (3-a)*t + (2-a)*t
|
||||
//
|
||||
static short c2_fixed(unsigned int t) {
|
||||
unsigned short v1, v2, v3;
|
||||
unsigned short two, three;
|
||||
|
||||
// Q13
|
||||
v1 = 1 << 13;
|
||||
|
||||
// Q13
|
||||
three = 3 << 13;
|
||||
v2 = three - (a_i >> 3);
|
||||
v2 = (v2 * t) >> 16;
|
||||
v2 = (v2 * t) >> 16;
|
||||
|
||||
// Q13
|
||||
two = 2 << 13;
|
||||
v3 = two - (a_i >> 3);
|
||||
v3 = (v3 * t) >> 16;
|
||||
v3 = (v3 * t) >> 16;
|
||||
v3 = (v3 * t) >> 16;
|
||||
|
||||
// Q12
|
||||
return (v1 - v2 + v3) >> 1;
|
||||
}
|
||||
|
||||
// 2 3
|
||||
// C3 = a*t - 2*a*t + a*t
|
||||
//
|
||||
static short c3_fixed(unsigned int t) {
|
||||
int v1, v2, v3;
|
||||
|
||||
// Q16
|
||||
v1 = (a_i * t) >> 16;
|
||||
|
||||
// Q15
|
||||
v2 = 2 * (a_i >> 1);
|
||||
v2 = (v2 * t) >> 16;
|
||||
v2 = (v2 * t) >> 16;
|
||||
|
||||
// Q16
|
||||
v3 = (a_i * t) >> 16;
|
||||
v3 = (v3 * t) >> 16;
|
||||
v3 = (v3 * t) >> 16;
|
||||
|
||||
// Q12
|
||||
return ((v2 - (v1 >> 1) - (v3 >> 1)) >> 3);
|
||||
}
|
||||
#else
|
||||
// 3 2
|
||||
// C0 = -a*t + a*t
|
||||
//
|
||||
float C0(float t) {
|
||||
return -a * t * t * t + a * t * t;
|
||||
}
|
||||
|
||||
// 2 3
|
||||
// C1 = -a*t + (2*a+3)*t - (a+2)*t
|
||||
//
|
||||
float C1(float t) {
|
||||
return -(a + 2.0f) * t * t * t + (2.0f * a + 3.0f) * t * t - a * t;
|
||||
}
|
||||
|
||||
// 2 3
|
||||
// C2 = 1 - (a+3)*t + (a+2)*t
|
||||
//
|
||||
float C2(float t) {
|
||||
return (a + 2.0f) * t * t * t - (a + 3.0f) * t * t + 1.0f;
|
||||
}
|
||||
|
||||
// 2 3
|
||||
// C3 = a*t - 2*a*t + a*t
|
||||
//
|
||||
float C3(float t) {
|
||||
return a * t * t * t - 2.0f * a * t * t + a * t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
int compare_real_fixed() {
|
||||
int i, errors = 0;
|
||||
float mult = 1.0 / 10000.0;
|
||||
unsigned int fixed_mult = mult * 4294967296;// 65536;
|
||||
unsigned int phase_offset_int;
|
||||
float phase_offset_real;
|
||||
|
||||
for (i = 0; i < 10000; i++) {
|
||||
int fixed0, fixed1, fixed2, fixed3, fixed_total;
|
||||
int real0, real1, real2, real3, real_total;
|
||||
|
||||
phase_offset_real = (float)i * mult;
|
||||
phase_offset_int = (fixed_mult * i) >> 16;
|
||||
// phase_offset_int = phase_offset_real * 65536;
|
||||
|
||||
fixed0 = c0_fixed(phase_offset_int);
|
||||
real0 = C0(phase_offset_real) * 4096.0;
|
||||
|
||||
if ((abs(fixed0) > (abs(real0) + 1)) || (abs(fixed0) < (abs(real0) - 1)))
|
||||
errors++;
|
||||
|
||||
fixed1 = c1_fixed(phase_offset_int);
|
||||
real1 = C1(phase_offset_real) * 4096.0;
|
||||
|
||||
if ((abs(fixed1) > (abs(real1) + 1)) || (abs(fixed1) < (abs(real1) - 1)))
|
||||
errors++;
|
||||
|
||||
fixed2 = c2_fixed(phase_offset_int);
|
||||
real2 = C2(phase_offset_real) * 4096.0;
|
||||
|
||||
if ((abs(fixed2) > (abs(real2) + 1)) || (abs(fixed2) < (abs(real2) - 1)))
|
||||
errors++;
|
||||
|
||||
fixed3 = c3_fixed(phase_offset_int);
|
||||
real3 = C3(phase_offset_real) * 4096.0;
|
||||
|
||||
if ((abs(fixed3) > (abs(real3) + 1)) || (abs(fixed3) < (abs(real3) - 1)))
|
||||
errors++;
|
||||
|
||||
fixed_total = fixed0 + fixed1 + fixed2 + fixed3;
|
||||
real_total = real0 + real1 + real2 + real3;
|
||||
|
||||
if ((fixed_total > 4097) || (fixed_total < 4094))
|
||||
errors++;
|
||||
|
||||
if ((real_total > 4097) || (real_total < 4095))
|
||||
errors++;
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Find greatest common denominator between two integers. Method used here is
|
||||
// slow compared to Euclid's algorithm, but does not require any division.
|
||||
int gcd(int a, int b) {
|
||||
// Problem with this algorithm is that if a or b = 0 this function
|
||||
// will never exit. Don't want to return 0 because any computation
|
||||
// that was based on a common denoninator and tried to reduce by
|
||||
// dividing by 0 would fail. Best solution that could be thought of
|
||||
// would to be fail by returing a 1;
|
||||
if (a <= 0 || b <= 0)
|
||||
return 1;
|
||||
|
||||
while (a != b) {
|
||||
if (b > a)
|
||||
b = b - a;
|
||||
else {
|
||||
int tmp = a;// swap large and
|
||||
a = b; // small
|
||||
b = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void bicubic_coefficient_init() {
|
||||
vpx_memset(&g_b_scaler, 0, sizeof(BICUBIC_SCALER_STRUCT));
|
||||
g_first_time = 0;
|
||||
}
|
||||
|
||||
void bicubic_coefficient_destroy() {
|
||||
if (!g_first_time) {
|
||||
vpx_free(g_b_scaler.l_w);
|
||||
|
||||
vpx_free(g_b_scaler.l_h);
|
||||
|
||||
vpx_free(g_b_scaler.l_h_uv);
|
||||
|
||||
vpx_free(g_b_scaler.c_w);
|
||||
|
||||
vpx_free(g_b_scaler.c_h);
|
||||
|
||||
vpx_free(g_b_scaler.c_h_uv);
|
||||
|
||||
vpx_memset(&g_b_scaler, 0, sizeof(BICUBIC_SCALER_STRUCT));
|
||||
}
|
||||
}
|
||||
|
||||
// Create the coeffients that will be used for the cubic interpolation.
|
||||
// Because scaling does not have to be equal in the vertical and horizontal
|
||||
// regimes the phase offsets will be different. There are 4 coefficents
|
||||
// for each point, two on each side. The layout is that there are the
|
||||
// 4 coefficents for each phase in the array and then the next phase.
|
||||
int bicubic_coefficient_setup(int in_width, int in_height, int out_width, int out_height) {
|
||||
int i;
|
||||
#ifdef FIXED_POINT
|
||||
int phase_offset_int;
|
||||
unsigned int fixed_mult;
|
||||
int product_val = 0;
|
||||
#else
|
||||
float phase_offset;
|
||||
#endif
|
||||
int gcd_w, gcd_h, gcd_h_uv, d_w, d_h, d_h_uv;
|
||||
|
||||
if (g_first_time)
|
||||
bicubic_coefficient_init();
|
||||
|
||||
|
||||
// check to see if the coefficents have already been set up correctly
|
||||
if ((in_width == g_b_scaler.in_width) && (in_height == g_b_scaler.in_height)
|
||||
&& (out_width == g_b_scaler.out_width) && (out_height == g_b_scaler.out_height))
|
||||
return 0;
|
||||
|
||||
g_b_scaler.in_width = in_width;
|
||||
g_b_scaler.in_height = in_height;
|
||||
g_b_scaler.out_width = out_width;
|
||||
g_b_scaler.out_height = out_height;
|
||||
|
||||
// Don't want to allow crazy scaling, just try and prevent a catastrophic
|
||||
// failure here. Want to fail after setting the member functions so if
|
||||
// if the scaler is called the member functions will not scale.
|
||||
if (out_width <= 0 || out_height <= 0)
|
||||
return -1;
|
||||
|
||||
// reduce in/out width and height ratios using the gcd
|
||||
gcd_w = gcd(out_width, in_width);
|
||||
gcd_h = gcd(out_height, in_height);
|
||||
gcd_h_uv = gcd(out_height, in_height / 2);
|
||||
|
||||
// the numerator width and height are to be saved in
|
||||
// globals so they can be used during the scaling process
|
||||
// without having to be recalculated.
|
||||
g_b_scaler.nw = out_width / gcd_w;
|
||||
d_w = in_width / gcd_w;
|
||||
|
||||
g_b_scaler.nh = out_height / gcd_h;
|
||||
d_h = in_height / gcd_h;
|
||||
|
||||
g_b_scaler.nh_uv = out_height / gcd_h_uv;
|
||||
d_h_uv = (in_height / 2) / gcd_h_uv;
|
||||
|
||||
// allocate memory for the coefficents
|
||||
vpx_free(g_b_scaler.l_w);
|
||||
|
||||
vpx_free(g_b_scaler.l_h);
|
||||
|
||||
vpx_free(g_b_scaler.l_h_uv);
|
||||
|
||||
g_b_scaler.l_w = (short *)vpx_memalign(32, out_width * 2);
|
||||
g_b_scaler.l_h = (short *)vpx_memalign(32, out_height * 2);
|
||||
g_b_scaler.l_h_uv = (short *)vpx_memalign(32, out_height * 2);
|
||||
|
||||
vpx_free(g_b_scaler.c_w);
|
||||
|
||||
vpx_free(g_b_scaler.c_h);
|
||||
|
||||
vpx_free(g_b_scaler.c_h_uv);
|
||||
|
||||
g_b_scaler.c_w = (short *)vpx_memalign(32, g_b_scaler.nw * 4 * 2);
|
||||
g_b_scaler.c_h = (short *)vpx_memalign(32, g_b_scaler.nh * 4 * 2);
|
||||
g_b_scaler.c_h_uv = (short *)vpx_memalign(32, g_b_scaler.nh_uv * 4 * 2);
|
||||
|
||||
g_b_scaler.hbuf = g_hbuf;
|
||||
g_b_scaler.hbuf_uv = g_hbuf_uv;
|
||||
|
||||
// Set up polyphase filter taps. This needs to be done before
|
||||
// the scaling because of the floating point math required. The
|
||||
// coefficients are multiplied by 2^12 so that fixed point math
|
||||
// can be used in the main scaling loop.
|
||||
#ifdef FIXED_POINT
|
||||
fixed_mult = (1.0 / (float)g_b_scaler.nw) * 4294967296;
|
||||
|
||||
product_val = 0;
|
||||
|
||||
for (i = 0; i < g_b_scaler.nw; i++) {
|
||||
if (product_val > g_b_scaler.nw)
|
||||
product_val -= g_b_scaler.nw;
|
||||
|
||||
phase_offset_int = (fixed_mult * product_val) >> 16;
|
||||
|
||||
g_b_scaler.c_w[i * 4] = c3_fixed(phase_offset_int);
|
||||
g_b_scaler.c_w[i * 4 + 1] = c2_fixed(phase_offset_int);
|
||||
g_b_scaler.c_w[i * 4 + 2] = c1_fixed(phase_offset_int);
|
||||
g_b_scaler.c_w[i * 4 + 3] = c0_fixed(phase_offset_int);
|
||||
|
||||
product_val += d_w;
|
||||
}
|
||||
|
||||
|
||||
fixed_mult = (1.0 / (float)g_b_scaler.nh) * 4294967296;
|
||||
|
||||
product_val = 0;
|
||||
|
||||
for (i = 0; i < g_b_scaler.nh; i++) {
|
||||
if (product_val > g_b_scaler.nh)
|
||||
product_val -= g_b_scaler.nh;
|
||||
|
||||
phase_offset_int = (fixed_mult * product_val) >> 16;
|
||||
|
||||
g_b_scaler.c_h[i * 4] = c0_fixed(phase_offset_int);
|
||||
g_b_scaler.c_h[i * 4 + 1] = c1_fixed(phase_offset_int);
|
||||
g_b_scaler.c_h[i * 4 + 2] = c2_fixed(phase_offset_int);
|
||||
g_b_scaler.c_h[i * 4 + 3] = c3_fixed(phase_offset_int);
|
||||
|
||||
product_val += d_h;
|
||||
}
|
||||
|
||||
fixed_mult = (1.0 / (float)g_b_scaler.nh_uv) * 4294967296;
|
||||
|
||||
product_val = 0;
|
||||
|
||||
for (i = 0; i < g_b_scaler.nh_uv; i++) {
|
||||
if (product_val > g_b_scaler.nh_uv)
|
||||
product_val -= g_b_scaler.nh_uv;
|
||||
|
||||
phase_offset_int = (fixed_mult * product_val) >> 16;
|
||||
|
||||
g_b_scaler.c_h_uv[i * 4] = c0_fixed(phase_offset_int);
|
||||
g_b_scaler.c_h_uv[i * 4 + 1] = c1_fixed(phase_offset_int);
|
||||
g_b_scaler.c_h_uv[i * 4 + 2] = c2_fixed(phase_offset_int);
|
||||
g_b_scaler.c_h_uv[i * 4 + 3] = c3_fixed(phase_offset_int);
|
||||
|
||||
product_val += d_h_uv;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
for (i = 0; i < g_nw; i++) {
|
||||
phase_offset = (float)((i * d_w) % g_nw) / (float)g_nw;
|
||||
g_c_w[i * 4] = (C3(phase_offset) * 4096.0);
|
||||
g_c_w[i * 4 + 1] = (C2(phase_offset) * 4096.0);
|
||||
g_c_w[i * 4 + 2] = (C1(phase_offset) * 4096.0);
|
||||
g_c_w[i * 4 + 3] = (C0(phase_offset) * 4096.0);
|
||||
}
|
||||
|
||||
for (i = 0; i < g_nh; i++) {
|
||||
phase_offset = (float)((i * d_h) % g_nh) / (float)g_nh;
|
||||
g_c_h[i * 4] = (C0(phase_offset) * 4096.0);
|
||||
g_c_h[i * 4 + 1] = (C1(phase_offset) * 4096.0);
|
||||
g_c_h[i * 4 + 2] = (C2(phase_offset) * 4096.0);
|
||||
g_c_h[i * 4 + 3] = (C3(phase_offset) * 4096.0);
|
||||
}
|
||||
|
||||
for (i = 0; i < g_nh_uv; i++) {
|
||||
phase_offset = (float)((i * d_h_uv) % g_nh_uv) / (float)g_nh_uv;
|
||||
g_c_h_uv[i * 4] = (C0(phase_offset) * 4096.0);
|
||||
g_c_h_uv[i * 4 + 1] = (C1(phase_offset) * 4096.0);
|
||||
g_c_h_uv[i * 4 + 2] = (C2(phase_offset) * 4096.0);
|
||||
g_c_h_uv[i * 4 + 3] = (C3(phase_offset) * 4096.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Create an array that corresponds input lines to output lines.
|
||||
// This doesn't require floating point math, but it does require
|
||||
// a division and because hardware division is not present that
|
||||
// is a call.
|
||||
for (i = 0; i < out_width; i++) {
|
||||
g_b_scaler.l_w[i] = (i * d_w) / g_b_scaler.nw;
|
||||
|
||||
if ((g_b_scaler.l_w[i] + 2) <= in_width)
|
||||
g_b_scaler.max_usable_out_width = i;
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < out_height + 1; i++) {
|
||||
g_b_scaler.l_h[i] = (i * d_h) / g_b_scaler.nh;
|
||||
g_b_scaler.l_h_uv[i] = (i * d_h_uv) / g_b_scaler.nh_uv;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bicubic_scale(int in_width, int in_height, int in_stride,
|
||||
int out_width, int out_height, int out_stride,
|
||||
unsigned char *input_image, unsigned char *output_image) {
|
||||
short *RESTRICT l_w, * RESTRICT l_h;
|
||||
short *RESTRICT c_w, * RESTRICT c_h;
|
||||
unsigned char *RESTRICT ip, * RESTRICT op;
|
||||
unsigned char *RESTRICT hbuf;
|
||||
int h, w, lw, lh;
|
||||
int temp_sum;
|
||||
int phase_offset_w, phase_offset_h;
|
||||
|
||||
c_w = g_b_scaler.c_w;
|
||||
c_h = g_b_scaler.c_h;
|
||||
|
||||
op = output_image;
|
||||
|
||||
l_w = g_b_scaler.l_w;
|
||||
l_h = g_b_scaler.l_h;
|
||||
|
||||
phase_offset_h = 0;
|
||||
|
||||
for (h = 0; h < out_height; h++) {
|
||||
// select the row to work on
|
||||
lh = l_h[h];
|
||||
ip = input_image + (in_stride * lh);
|
||||
|
||||
// vp8_filter the row vertically into an temporary buffer.
|
||||
// If the phase offset == 0 then all the multiplication
|
||||
// is going to result in the output equalling the input.
|
||||
// So instead point the temporary buffer to the input.
|
||||
// Also handle the boundry condition of not being able to
|
||||
// filter that last lines.
|
||||
if (phase_offset_h && (lh < in_height - 2)) {
|
||||
hbuf = g_b_scaler.hbuf;
|
||||
|
||||
for (w = 0; w < in_width; w++) {
|
||||
temp_sum = c_h[phase_offset_h * 4 + 3] * ip[w - in_stride];
|
||||
temp_sum += c_h[phase_offset_h * 4 + 2] * ip[w];
|
||||
temp_sum += c_h[phase_offset_h * 4 + 1] * ip[w + in_stride];
|
||||
temp_sum += c_h[phase_offset_h * 4] * ip[w + 2 * in_stride];
|
||||
|
||||
hbuf[w] = temp_sum >> 12;
|
||||
}
|
||||
} else
|
||||
hbuf = ip;
|
||||
|
||||
// increase the phase offset for the next time around.
|
||||
if (++phase_offset_h >= g_b_scaler.nh)
|
||||
phase_offset_h = 0;
|
||||
|
||||
// now filter and expand it horizontally into the final
|
||||
// output buffer
|
||||
phase_offset_w = 0;
|
||||
|
||||
for (w = 0; w < out_width; w++) {
|
||||
// get the index to use to expand the image
|
||||
lw = l_w[w];
|
||||
|
||||
temp_sum = c_w[phase_offset_w * 4] * hbuf[lw - 1];
|
||||
temp_sum += c_w[phase_offset_w * 4 + 1] * hbuf[lw];
|
||||
temp_sum += c_w[phase_offset_w * 4 + 2] * hbuf[lw + 1];
|
||||
temp_sum += c_w[phase_offset_w * 4 + 3] * hbuf[lw + 2];
|
||||
temp_sum = temp_sum >> 12;
|
||||
|
||||
if (++phase_offset_w >= g_b_scaler.nw)
|
||||
phase_offset_w = 0;
|
||||
|
||||
// boundry conditions
|
||||
if ((lw + 2) >= in_width)
|
||||
temp_sum = hbuf[lw];
|
||||
|
||||
if (lw == 0)
|
||||
temp_sum = hbuf[0];
|
||||
|
||||
op[w] = temp_sum;
|
||||
}
|
||||
|
||||
op += out_stride;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bicubic_scale_frame_reset() {
|
||||
g_b_scaler.out_width = 0;
|
||||
g_b_scaler.out_height = 0;
|
||||
}
|
||||
|
||||
void bicubic_scale_frame(YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst,
|
||||
int new_width, int new_height) {
|
||||
|
||||
dst->y_width = new_width;
|
||||
dst->y_height = new_height;
|
||||
dst->uv_width = new_width / 2;
|
||||
dst->uv_height = new_height / 2;
|
||||
|
||||
dst->y_stride = dst->y_width;
|
||||
dst->uv_stride = dst->uv_width;
|
||||
|
||||
bicubic_scale(src->y_width, src->y_height, src->y_stride,
|
||||
new_width, new_height, dst->y_stride,
|
||||
src->y_buffer, dst->y_buffer);
|
||||
|
||||
bicubic_scale(src->uv_width, src->uv_height, src->uv_stride,
|
||||
new_width / 2, new_height / 2, dst->uv_stride,
|
||||
src->u_buffer, dst->u_buffer);
|
||||
|
||||
bicubic_scale(src->uv_width, src->uv_height, src->uv_stride,
|
||||
new_width / 2, new_height / 2, dst->uv_stride,
|
||||
src->v_buffer, dst->v_buffer);
|
||||
}
|
@ -17,688 +17,6 @@
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_horizontal_line_4_5_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 4 to 5.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_horizontal_line_4_5_scale_c(const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width) {
|
||||
unsigned i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
const unsigned char *src = source;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
for (i = 0; i < source_width - 4; i += 4) {
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char) a;
|
||||
des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
|
||||
c = src[2] * 154;
|
||||
a = src[3];
|
||||
des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
|
||||
des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
|
||||
b = src[4];
|
||||
des [4] = (unsigned char)((a * 205 + 51 * b + 128) >> 8);
|
||||
|
||||
src += 4;
|
||||
des += 5;
|
||||
}
|
||||
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
|
||||
c = src[2] * 154;
|
||||
a = src[3];
|
||||
des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
|
||||
des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
|
||||
des [4] = (unsigned char)(a);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_vertical_band_4_5_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 4 to 5. The
|
||||
* height of the band scaled is 4-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_vertical_band_4_5_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c, d;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; i++) {
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
|
||||
des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch * 2] * 154;
|
||||
d = des[dest_pitch * 3];
|
||||
|
||||
des [dest_pitch * 2] = (unsigned char)((b * 102 + c + 128) >> 8);
|
||||
des [dest_pitch * 3] = (unsigned char)((c + 102 * d + 128) >> 8);
|
||||
|
||||
/* First line in next band */
|
||||
a = des [dest_pitch * 5];
|
||||
des [dest_pitch * 4] = (unsigned char)((d * 205 + 51 * a + 128) >> 8);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_last_vertical_band_4_5_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 4 to 5. The
|
||||
* height of the band scaled is 4-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_last_vertical_band_4_5_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c, d;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; ++i) {
|
||||
a = des[0];
|
||||
b = des[dest_pitch];
|
||||
|
||||
des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch * 2] * 154;
|
||||
d = des[dest_pitch * 3];
|
||||
|
||||
des [dest_pitch * 2] = (unsigned char)((b * 102 + c + 128) >> 8);
|
||||
des [dest_pitch * 3] = (unsigned char)((c + 102 * d + 128) >> 8);
|
||||
|
||||
/* No other line for interplation of this line, so .. */
|
||||
des[dest_pitch * 4] = (unsigned char) d;
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_horizontal_line_2_3_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 2 to 3.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_horizontal_line_2_3_scale_c(const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
const unsigned char *src = source;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
for (i = 0; i < source_width - 2; i += 2) {
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
c = src[2];
|
||||
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
|
||||
des [2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8);
|
||||
|
||||
src += 2;
|
||||
des += 3;
|
||||
}
|
||||
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
|
||||
des [2] = (unsigned char)(b);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_vertical_band_2_3_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 2 to 3. The
|
||||
* height of the band scaled is 2-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_vertical_band_2_3_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; i++) {
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
c = des[dest_pitch * 3];
|
||||
des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
|
||||
des [dest_pitch * 2] = (unsigned char)((b * 171 + 85 * c + 128) >> 8);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_last_vertical_band_2_3_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 2 to 3. The
|
||||
* height of the band scaled is 2-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_last_vertical_band_2_3_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; ++i) {
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
|
||||
des [dest_pitch ] = (unsigned char)((a * 85 + 171 * b + 128) >> 8);
|
||||
des [dest_pitch * 2] = (unsigned char)(b);
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_horizontal_line_3_5_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 3 to 5.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_horizontal_line_3_5_scale_c(const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
const unsigned char *src = source;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
for (i = 0; i < source_width - 3; i += 3) {
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
|
||||
|
||||
c = src[2];
|
||||
des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
|
||||
des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
|
||||
|
||||
a = src[3];
|
||||
des [4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
|
||||
|
||||
src += 3;
|
||||
des += 5;
|
||||
}
|
||||
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
|
||||
des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
|
||||
c = src[2];
|
||||
des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
|
||||
des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
|
||||
|
||||
des [4] = (unsigned char)(c);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_vertical_band_3_5_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 3 to 5. The
|
||||
* height of the band scaled is 3-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_vertical_band_3_5_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; i++) {
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
des [dest_pitch] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch * 2];
|
||||
des [dest_pitch * 2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
|
||||
des [dest_pitch * 3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
|
||||
|
||||
/* First line in next band... */
|
||||
a = des [dest_pitch * 5];
|
||||
des [dest_pitch * 4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_last_vertical_band_3_5_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 3 to 5. The
|
||||
* height of the band scaled is 3-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_last_vertical_band_3_5_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; ++i) {
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
|
||||
des [ dest_pitch ] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch * 2];
|
||||
des [dest_pitch * 2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
|
||||
des [dest_pitch * 3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
|
||||
|
||||
/* No other line for interplation of this line, so .. */
|
||||
des [ dest_pitch * 4 ] = (unsigned char)(c);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_horizontal_line_3_4_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 3 to 4.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_horizontal_line_3_4_scale_c(const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
const unsigned char *src = source;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
for (i = 0; i < source_width - 3; i += 3) {
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
|
||||
|
||||
c = src[2];
|
||||
des [2] = (unsigned char)((b + c + 1) >> 1);
|
||||
|
||||
a = src[3];
|
||||
des [3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8);
|
||||
|
||||
src += 3;
|
||||
des += 4;
|
||||
}
|
||||
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
|
||||
|
||||
c = src[2];
|
||||
des [2] = (unsigned char)((b + c + 1) >> 1);
|
||||
des [3] = (unsigned char)(c);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_vertical_band_3_4_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 3 to 4. The
|
||||
* height of the band scaled is 3-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_vertical_band_3_4_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; i++) {
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch * 2];
|
||||
des [dest_pitch * 2] = (unsigned char)((b + c + 1) >> 1);
|
||||
|
||||
/* First line in next band... */
|
||||
a = des [dest_pitch * 4];
|
||||
des [dest_pitch * 3] = (unsigned char)((c * 192 + a * 64 + 128) >> 8);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_last_vertical_band_3_4_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 3 to 4. The
|
||||
* height of the band scaled is 3-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_last_vertical_band_3_4_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; ++i) {
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
|
||||
des [dest_pitch] = (unsigned char)((a * 64 + b * 192 + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch * 2];
|
||||
des [dest_pitch * 2] = (unsigned char)((b + c + 1) >> 1);
|
||||
|
||||
/* No other line for interplation of this line, so .. */
|
||||
des [dest_pitch * 3] = (unsigned char)(c);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_horizontal_line_1_2_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 1 to 2.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_horizontal_line_1_2_scale_c(const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b;
|
||||
unsigned char *des = dest;
|
||||
const unsigned char *src = source;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
for (i = 0; i < source_width - 1; i += 1) {
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a + b + 1) >> 1);
|
||||
src += 1;
|
||||
des += 2;
|
||||
}
|
||||
|
||||
a = src[0];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)(a);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_vertical_band_1_2_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 1 to 2. The
|
||||
* height of the band scaled is 1-pixel.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_vertical_band_1_2_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned int a, b;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; i++) {
|
||||
a = des [0];
|
||||
b = des [dest_pitch * 2];
|
||||
|
||||
des[dest_pitch] = (unsigned char)((a + b + 1) >> 1);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_last_vertical_band_1_2_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 1 to 2. The
|
||||
* height of the band scaled is 1-pixel.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_last_vertical_band_1_2_scale_c(unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width) {
|
||||
unsigned int i;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; ++i) {
|
||||
des[dest_pitch] = des[0];
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_horizontal_line_4_5_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "./vpx_scale_rtcd.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
#include "vpx_scale/yv12config.h"
|
||||
#include "vpx_scale/scale_mode.h"
|
||||
|
||||
typedef struct {
|
||||
int expanded_frame_width;
|
||||
@ -39,66 +38,6 @@ typedef struct {
|
||||
|
||||
} SCALE_VARS;
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : horizontal_line_copy
|
||||
*
|
||||
* INPUTS : None
|
||||
*
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : None
|
||||
*
|
||||
* FUNCTION : 1 to 1 scaling up for a horizontal line of pixles
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void horizontal_line_copy(
|
||||
const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width
|
||||
) {
|
||||
(void) dest_width;
|
||||
|
||||
duck_memcpy(dest, source, source_width);
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : null_scale
|
||||
*
|
||||
* INPUTS : None
|
||||
*
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : None
|
||||
*
|
||||
* FUNCTION : 1 to 1 scaling up for a vertical band
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void null_scale(
|
||||
unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width
|
||||
) {
|
||||
(void) dest;
|
||||
(void) dest_pitch;
|
||||
(void) dest_width;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : scale1d_2t1_i
|
||||
@ -589,422 +528,3 @@ void vp8_scale_frame
|
||||
for (i = dh / 2 - 1; i < (int)dst->y_height / 2; i++)
|
||||
duck_memcpy(dst->v_buffer + i * dst->uv_stride, dst->v_buffer + (dh / 2 - 2)*dst->uv_stride, dst->uv_width);
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : any_ratio_2d_scale
|
||||
*
|
||||
* INPUTS : SCALE_INSTANCE *si : Pointer to post-processor instance (NOT USED).
|
||||
* const unsigned char *source : Pointer to source image.
|
||||
* unsigned int source_pitch : Stride of source image.
|
||||
* unsigned int source_width : Width of source image.
|
||||
* unsigned int source_height : Height of source image (NOT USED).
|
||||
* unsigned char *dest : Pointer to destination image.
|
||||
* unsigned int dest_pitch : Stride of destination image.
|
||||
* unsigned int dest_width : Width of destination image.
|
||||
* unsigned int dest_height : Height of destination image.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : int: 1 if image scaled, 0 if image could not be scaled.
|
||||
*
|
||||
* FUNCTION : Scale the image with changing apect ratio.
|
||||
*
|
||||
* SPECIAL NOTES : This scaling is a bi-linear scaling. Need to re-work the
|
||||
* whole function for new scaling algorithm.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
int any_ratio_2d_scale
|
||||
(
|
||||
SCALE_VARS *si,
|
||||
const unsigned char *source,
|
||||
int source_pitch,
|
||||
unsigned int source_width,
|
||||
unsigned int source_height,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width,
|
||||
unsigned int dest_height
|
||||
) {
|
||||
unsigned int i, k;
|
||||
unsigned int src_band_height = 0;
|
||||
unsigned int dest_band_height = 0;
|
||||
|
||||
/* suggested scale factors */
|
||||
int hs = si->HScale;
|
||||
int hr = si->HRatio;
|
||||
int vs = si->VScale;
|
||||
int vr = si->VRatio;
|
||||
|
||||
/* assume the ratios are scalable instead of should be centered */
|
||||
int ratio_scalable = 1;
|
||||
|
||||
const unsigned char *source_base = ((source_pitch >= 0) ? source : (source + ((source_height - 1) * source_pitch)));
|
||||
const unsigned char *line_src;
|
||||
|
||||
void (*horiz_line_scale)(const unsigned char *, unsigned int, unsigned char *, unsigned int) = NULL;
|
||||
void (*vert_band_scale)(unsigned char *, unsigned int, unsigned int) = NULL;
|
||||
void (*last_vert_band_scale)(unsigned char *, unsigned int, unsigned int) = NULL;
|
||||
|
||||
(void) si;
|
||||
|
||||
/* find out the ratio for each direction */
|
||||
switch (hr * 30 / hs) {
|
||||
case 24:
|
||||
/* 4-5 Scale in Width direction */
|
||||
horiz_line_scale = vp8_horizontal_line_4_5_scale;
|
||||
break;
|
||||
case 22:
|
||||
/* 3-4 Scale in Width direction */
|
||||
horiz_line_scale = vp8_horizontal_line_3_4_scale;
|
||||
break;
|
||||
|
||||
case 20:
|
||||
/* 4-5 Scale in Width direction */
|
||||
horiz_line_scale = vp8_horizontal_line_2_3_scale;
|
||||
break;
|
||||
case 18:
|
||||
/* 3-5 Scale in Width direction */
|
||||
horiz_line_scale = vp8_horizontal_line_3_5_scale;
|
||||
break;
|
||||
case 15:
|
||||
/* 1-2 Scale in Width direction */
|
||||
horiz_line_scale = vp8_horizontal_line_1_2_scale;
|
||||
break;
|
||||
case 30:
|
||||
/* no scale in Width direction */
|
||||
horiz_line_scale = horizontal_line_copy;
|
||||
break;
|
||||
default:
|
||||
/* The ratio is not acceptable now */
|
||||
/* throw("The ratio is not acceptable for now!"); */
|
||||
ratio_scalable = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (vr * 30 / vs) {
|
||||
case 24:
|
||||
/* 4-5 Scale in vertical direction */
|
||||
vert_band_scale = vp8_vertical_band_4_5_scale;
|
||||
last_vert_band_scale = vp8_last_vertical_band_4_5_scale;
|
||||
src_band_height = 4;
|
||||
dest_band_height = 5;
|
||||
break;
|
||||
case 22:
|
||||
/* 3-4 Scale in vertical direction */
|
||||
vert_band_scale = vp8_vertical_band_3_4_scale;
|
||||
last_vert_band_scale = vp8_last_vertical_band_3_4_scale;
|
||||
src_band_height = 3;
|
||||
dest_band_height = 4;
|
||||
break;
|
||||
case 20:
|
||||
/* 2-3 Scale in vertical direction */
|
||||
vert_band_scale = vp8_vertical_band_2_3_scale;
|
||||
last_vert_band_scale = vp8_last_vertical_band_2_3_scale;
|
||||
src_band_height = 2;
|
||||
dest_band_height = 3;
|
||||
break;
|
||||
case 18:
|
||||
/* 3-5 Scale in vertical direction */
|
||||
vert_band_scale = vp8_vertical_band_3_5_scale;
|
||||
last_vert_band_scale = vp8_last_vertical_band_3_5_scale;
|
||||
src_band_height = 3;
|
||||
dest_band_height = 5;
|
||||
break;
|
||||
case 15:
|
||||
/* 1-2 Scale in vertical direction */
|
||||
vert_band_scale = vp8_vertical_band_1_2_scale;
|
||||
last_vert_band_scale = vp8_last_vertical_band_1_2_scale;
|
||||
src_band_height = 1;
|
||||
dest_band_height = 2;
|
||||
break;
|
||||
case 30:
|
||||
/* no scale in Width direction */
|
||||
vert_band_scale = null_scale;
|
||||
last_vert_band_scale = null_scale;
|
||||
src_band_height = 4;
|
||||
dest_band_height = 4;
|
||||
break;
|
||||
default:
|
||||
/* The ratio is not acceptable now */
|
||||
/* throw("The ratio is not acceptable for now!"); */
|
||||
ratio_scalable = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ratio_scalable == 0)
|
||||
return ratio_scalable;
|
||||
|
||||
horiz_line_scale(source, source_width, dest, dest_width);
|
||||
|
||||
/* except last band */
|
||||
for (k = 0; k < (dest_height + dest_band_height - 1) / dest_band_height - 1; k++) {
|
||||
/* scale one band horizontally */
|
||||
for (i = 1; i < src_band_height; i++) {
|
||||
/* Trap case where we could read off the base of the source buffer */
|
||||
line_src = source + i * source_pitch;
|
||||
|
||||
if (line_src < source_base)
|
||||
line_src = source_base;
|
||||
|
||||
horiz_line_scale(line_src, source_width,
|
||||
dest + i * dest_pitch, dest_width);
|
||||
}
|
||||
|
||||
/* first line of next band */
|
||||
/* Trap case where we could read off the base of the source buffer */
|
||||
line_src = source + src_band_height * source_pitch;
|
||||
|
||||
if (line_src < source_base)
|
||||
line_src = source_base;
|
||||
|
||||
horiz_line_scale(line_src, source_width,
|
||||
dest + dest_band_height * dest_pitch,
|
||||
dest_width);
|
||||
|
||||
/* Vertical scaling is in place */
|
||||
vert_band_scale(dest, dest_pitch, dest_width);
|
||||
|
||||
/* Next band... */
|
||||
source += src_band_height * source_pitch;
|
||||
dest += dest_band_height * dest_pitch;
|
||||
}
|
||||
|
||||
/* scale one band horizontally */
|
||||
for (i = 1; i < src_band_height; i++) {
|
||||
/* Trap case where we could read off the base of the source buffer */
|
||||
line_src = source + i * source_pitch;
|
||||
|
||||
if (line_src < source_base)
|
||||
line_src = source_base;
|
||||
|
||||
horiz_line_scale(line_src, source_width,
|
||||
dest + i * dest_pitch,
|
||||
dest_width);
|
||||
}
|
||||
|
||||
/* Vertical scaling is in place */
|
||||
last_vert_band_scale(dest, dest_pitch, dest_width);
|
||||
|
||||
return ratio_scalable;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : any_ratio_frame_scale
|
||||
*
|
||||
* INPUTS : SCALE_INSTANCE *si : Pointer to post-processor instance (NOT USED).
|
||||
* unsigned char *frame_buffer : Pointer to source image.
|
||||
* int YOffset : Offset from start of buffer to Y samples.
|
||||
* int UVOffset : Offset from start of buffer to UV samples.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : int: 1 if image scaled, 0 if image could not be scaled.
|
||||
*
|
||||
* FUNCTION : Scale the image with changing apect ratio.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
int any_ratio_frame_scale(SCALE_VARS *scale_vars, int YOffset, int UVOffset) {
|
||||
int i;
|
||||
int ew;
|
||||
int eh;
|
||||
|
||||
/* suggested scale factors */
|
||||
int hs = scale_vars->HScale;
|
||||
int hr = scale_vars->HRatio;
|
||||
int vs = scale_vars->VScale;
|
||||
int vr = scale_vars->VRatio;
|
||||
|
||||
int ratio_scalable = 1;
|
||||
|
||||
int sw = (scale_vars->expanded_frame_width * hr + hs - 1) / hs;
|
||||
int sh = (scale_vars->expanded_frame_height * vr + vs - 1) / vs;
|
||||
int dw = scale_vars->expanded_frame_width;
|
||||
int dh = scale_vars->expanded_frame_height;
|
||||
YV12_BUFFER_CONFIG *src_yuv_config = scale_vars->src_yuv_config;
|
||||
YV12_BUFFER_CONFIG *dst_yuv_config = scale_vars->dst_yuv_config;
|
||||
|
||||
if (hr == 3)
|
||||
ew = (sw + 2) / 3 * 3 * hs / hr;
|
||||
else
|
||||
ew = (sw + 7) / 8 * 8 * hs / hr;
|
||||
|
||||
if (vr == 3)
|
||||
eh = (sh + 2) / 3 * 3 * vs / vr;
|
||||
else
|
||||
eh = (sh + 7) / 8 * 8 * vs / vr;
|
||||
|
||||
ratio_scalable = any_ratio_2d_scale(scale_vars,
|
||||
(const unsigned char *)src_yuv_config->y_buffer,
|
||||
src_yuv_config->y_stride, sw, sh,
|
||||
(unsigned char *) dst_yuv_config->y_buffer + YOffset,
|
||||
dst_yuv_config->y_stride, dw, dh);
|
||||
|
||||
for (i = 0; i < eh; i++)
|
||||
duck_memset(dst_yuv_config->y_buffer + YOffset + i * dst_yuv_config->y_stride + dw, 0, ew - dw);
|
||||
|
||||
for (i = dh; i < eh; i++)
|
||||
duck_memset(dst_yuv_config->y_buffer + YOffset + i * dst_yuv_config->y_stride, 0, ew);
|
||||
|
||||
if (ratio_scalable == 0)
|
||||
return ratio_scalable;
|
||||
|
||||
sw = (sw + 1) >> 1;
|
||||
sh = (sh + 1) >> 1;
|
||||
dw = (dw + 1) >> 1;
|
||||
dh = (dh + 1) >> 1;
|
||||
|
||||
any_ratio_2d_scale(scale_vars,
|
||||
(const unsigned char *)src_yuv_config->u_buffer,
|
||||
src_yuv_config->y_stride / 2, sw, sh,
|
||||
(unsigned char *)dst_yuv_config->u_buffer + UVOffset,
|
||||
dst_yuv_config->uv_stride, dw, dh);
|
||||
|
||||
any_ratio_2d_scale(scale_vars,
|
||||
(const unsigned char *)src_yuv_config->v_buffer,
|
||||
src_yuv_config->y_stride / 2, sw, sh,
|
||||
(unsigned char *)dst_yuv_config->v_buffer + UVOffset,
|
||||
dst_yuv_config->uv_stride, dw, dh);
|
||||
|
||||
return ratio_scalable;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : center_image
|
||||
*
|
||||
* INPUTS : SCALE_INSTANCE *si : Pointer to post-processor instance.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Centers the image without scaling in the output buffer.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static void
|
||||
center_image(YV12_BUFFER_CONFIG *src_yuv_config, YV12_BUFFER_CONFIG *dst_yuv_config) {
|
||||
int i;
|
||||
int row_offset, col_offset;
|
||||
unsigned char *src_data_pointer;
|
||||
unsigned char *dst_data_pointer;
|
||||
|
||||
/* center values */
|
||||
row_offset = (dst_yuv_config->y_height - src_yuv_config->y_height) / 2;
|
||||
col_offset = (dst_yuv_config->y_width - src_yuv_config->y_width) / 2;
|
||||
|
||||
/* Y's */
|
||||
src_data_pointer = src_yuv_config->y_buffer;
|
||||
dst_data_pointer = (unsigned char *)dst_yuv_config->y_buffer + (row_offset * dst_yuv_config->y_stride) + col_offset;
|
||||
|
||||
for (i = 0; i < src_yuv_config->y_height; i++) {
|
||||
duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->y_width);
|
||||
dst_data_pointer += dst_yuv_config->y_stride;
|
||||
src_data_pointer += src_yuv_config->y_stride;
|
||||
}
|
||||
|
||||
row_offset /= 2;
|
||||
col_offset /= 2;
|
||||
|
||||
/* U's */
|
||||
src_data_pointer = src_yuv_config->u_buffer;
|
||||
dst_data_pointer = (unsigned char *)dst_yuv_config->u_buffer + (row_offset * dst_yuv_config->uv_stride) + col_offset;
|
||||
|
||||
for (i = 0; i < src_yuv_config->uv_height; i++) {
|
||||
duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->uv_width);
|
||||
dst_data_pointer += dst_yuv_config->uv_stride;
|
||||
src_data_pointer += src_yuv_config->uv_stride;
|
||||
}
|
||||
|
||||
/* V's */
|
||||
src_data_pointer = src_yuv_config->v_buffer;
|
||||
dst_data_pointer = (unsigned char *)dst_yuv_config->v_buffer + (row_offset * dst_yuv_config->uv_stride) + col_offset;
|
||||
|
||||
for (i = 0; i < src_yuv_config->uv_height; i++) {
|
||||
duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->uv_width);
|
||||
dst_data_pointer += dst_yuv_config->uv_stride;
|
||||
src_data_pointer += src_yuv_config->uv_stride;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : scale_or_center
|
||||
*
|
||||
* INPUTS : SCALE_INSTANCE *si : Pointer to post-processor instance.
|
||||
*
|
||||
*
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Decides to scale or center image in scale buffer for blit
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_yv12_scale_or_center
|
||||
(
|
||||
YV12_BUFFER_CONFIG *src_yuv_config,
|
||||
YV12_BUFFER_CONFIG *dst_yuv_config,
|
||||
int expanded_frame_width,
|
||||
int expanded_frame_height,
|
||||
int scaling_mode,
|
||||
int HScale,
|
||||
int HRatio,
|
||||
int VScale,
|
||||
int VRatio
|
||||
) {
|
||||
/*if ( ppi->post_processing_level )
|
||||
update_umvborder ( ppi, frame_buffer );*/
|
||||
|
||||
|
||||
switch (scaling_mode) {
|
||||
case SCALE_TO_FIT:
|
||||
case MAINTAIN_ASPECT_RATIO: {
|
||||
SCALE_VARS scale_vars;
|
||||
/* center values */
|
||||
#if 1
|
||||
int row = (dst_yuv_config->y_height - expanded_frame_height) / 2;
|
||||
int col = (dst_yuv_config->y_width - expanded_frame_width) / 2;
|
||||
/*int YOffset = row * dst_yuv_config->y_width + col;
|
||||
int UVOffset = (row>>1) * dst_yuv_config->uv_width + (col>>1);*/
|
||||
int YOffset = row * dst_yuv_config->y_stride + col;
|
||||
int UVOffset = (row >> 1) * dst_yuv_config->uv_stride + (col >> 1);
|
||||
#else
|
||||
int row = (src_yuv_config->y_height - expanded_frame_height) / 2;
|
||||
int col = (src_yuv_config->y_width - expanded_frame_width) / 2;
|
||||
int YOffset = row * src_yuv_config->y_width + col;
|
||||
int UVOffset = (row >> 1) * src_yuv_config->uv_width + (col >> 1);
|
||||
#endif
|
||||
|
||||
scale_vars.dst_yuv_config = dst_yuv_config;
|
||||
scale_vars.src_yuv_config = src_yuv_config;
|
||||
scale_vars.HScale = HScale;
|
||||
scale_vars.HRatio = HRatio;
|
||||
scale_vars.VScale = VScale;
|
||||
scale_vars.VRatio = VRatio;
|
||||
scale_vars.expanded_frame_width = expanded_frame_width;
|
||||
scale_vars.expanded_frame_height = expanded_frame_height;
|
||||
|
||||
/* perform center and scale */
|
||||
any_ratio_frame_scale(&scale_vars, YOffset, UVOffset);
|
||||
|
||||
break;
|
||||
}
|
||||
case CENTER:
|
||||
center_image(src_yuv_config, dst_yuv_config);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __VPX_SCALE_ARBITRARY_H__
|
||||
#define __VPX_SCALE_ARBITRARY_H__
|
||||
|
||||
#include "vpx_scale/yv12config.h"
|
||||
|
||||
typedef struct {
|
||||
int in_width;
|
||||
int in_height;
|
||||
|
||||
int out_width;
|
||||
int out_height;
|
||||
int max_usable_out_width;
|
||||
|
||||
// numerator for the width and height
|
||||
int nw;
|
||||
int nh;
|
||||
int nh_uv;
|
||||
|
||||
// output to input correspondance array
|
||||
short *l_w;
|
||||
short *l_h;
|
||||
short *l_h_uv;
|
||||
|
||||
// polyphase coefficients
|
||||
short *c_w;
|
||||
short *c_h;
|
||||
short *c_h_uv;
|
||||
|
||||
// buffer for horizontal filtering.
|
||||
unsigned char *hbuf;
|
||||
unsigned char *hbuf_uv;
|
||||
} BICUBIC_SCALER_STRUCT;
|
||||
|
||||
int bicubic_coefficient_setup(int in_width, int in_height, int out_width, int out_height);
|
||||
int bicubic_scale(int in_width, int in_height, int in_stride,
|
||||
int out_width, int out_height, int out_stride,
|
||||
unsigned char *input_image, unsigned char *output_image);
|
||||
void bicubic_scale_frame_reset();
|
||||
void bicubic_scale_frame(YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst,
|
||||
int new_width, int new_height);
|
||||
void bicubic_coefficient_init();
|
||||
void bicubic_coefficient_destroy();
|
||||
|
||||
#endif /* __VPX_SCALE_ARBITRARY_H__ */
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : postp.h
|
||||
*
|
||||
* Description : Post processor interface
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef VPXSCALE_H
|
||||
#define VPXSCALE_H
|
||||
|
||||
extern void (*vp8_vertical_band_4_5_scale)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
extern void (*vp8_last_vertical_band_4_5_scale)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
extern void (*vp8_vertical_band_3_5_scale)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
extern void (*vp8_last_vertical_band_3_5_scale)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
extern void (*vp8_horizontal_line_1_2_scale)(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
|
||||
extern void (*vp8_horizontal_line_3_5_scale)(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
|
||||
extern void (*vp8_horizontal_line_4_5_scale)(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
|
||||
extern void (*vp8_vertical_band_1_2_scale)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
extern void (*vp8_last_vertical_band_1_2_scale)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
|
||||
extern void dmachine_specific_config(int mmx_enabled, int xmm_enabled, int wmt_enabled);
|
||||
|
||||
#endif
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef SCALE_MODE_H
|
||||
#define SCALE_MODE_H
|
||||
|
||||
typedef enum {
|
||||
MAINTAIN_ASPECT_RATIO = 0x0,
|
||||
SCALE_TO_FIT = 0x1,
|
||||
CENTER = 0x2,
|
||||
OTHER = 0x3
|
||||
} SCALE_MODE;
|
||||
|
||||
|
||||
#endif
|
@ -1,5 +1,4 @@
|
||||
SCALE_SRCS-yes += vpx_scale.mk
|
||||
SCALE_SRCS-yes += scale_mode.h
|
||||
SCALE_SRCS-yes += yv12config.h
|
||||
SCALE_SRCS-yes += vpxscale.h
|
||||
SCALE_SRCS-yes += generic/vpxscale.c
|
||||
|
@ -7,21 +7,6 @@ forward_decls vpx_scale_forward_decls
|
||||
|
||||
# Scaler functions
|
||||
if [ "CONFIG_SPATIAL_RESAMPLING" != "yes" ]; then
|
||||
prototype void vp8_horizontal_line_4_5_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_4_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_4_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_2_3_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_2_3_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_2_3_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_3_5_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_3_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_3_5_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_3_4_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_3_4_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_3_4_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_1_2_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_1_2_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_last_vertical_band_1_2_scale "unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_5_4_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
prototype void vp8_vertical_band_5_4_scale "unsigned char *source, unsigned int src_pitch, unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width"
|
||||
prototype void vp8_horizontal_line_5_3_scale "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"
|
||||
|
@ -14,16 +14,6 @@
|
||||
|
||||
#include "vpx_scale/yv12config.h"
|
||||
|
||||
extern void vp8_yv12_scale_or_center(YV12_BUFFER_CONFIG *src_yuv_config,
|
||||
YV12_BUFFER_CONFIG *dst_yuv_config,
|
||||
int expanded_frame_width,
|
||||
int expanded_frame_height,
|
||||
int scaling_mode,
|
||||
int HScale,
|
||||
int HRatio,
|
||||
int VScale,
|
||||
int VRatio);
|
||||
|
||||
extern void vp8_scale_frame(YV12_BUFFER_CONFIG *src,
|
||||
YV12_BUFFER_CONFIG *dst,
|
||||
unsigned char *temp_area,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : system_dependent.c
|
||||
*
|
||||
* Description : Miscellaneous system dependent functions
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
#include "cpuidlib.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Imports
|
||||
*****************************************************************************/
|
||||
extern void register_generic_scalers(void);
|
||||
extern void register_mmxscalers(void);
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : post_proc_machine_specific_config
|
||||
*
|
||||
* INPUTS : UINT32 Version : Codec version number.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Checks for machine specifc features such as MMX support
|
||||
* sets appropriate flags and function pointers.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_scale_machine_specific_config(void) {
|
||||
// If MMX supported then set to use MMX versions of functions else
|
||||
// use original 'C' versions.
|
||||
int mmx_enabled;
|
||||
int xmm_enabled;
|
||||
int wmt_enabled;
|
||||
|
||||
vpx_get_processor_flags(&mmx_enabled, &xmm_enabled, &wmt_enabled);
|
||||
|
||||
if (mmx_enabled || xmm_enabled || wmt_enabled) {
|
||||
register_mmxscalers();
|
||||
} else {
|
||||
vp8_horizontal_line_1_2_scale = vp8cx_horizontal_line_1_2_scale_c;
|
||||
vp8_vertical_band_1_2_scale = vp8cx_vertical_band_1_2_scale_c;
|
||||
vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
|
||||
vp8_horizontal_line_3_5_scale = vp8cx_horizontal_line_3_5_scale_c;
|
||||
vp8_vertical_band_3_5_scale = vp8cx_vertical_band_3_5_scale_c;
|
||||
vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
|
||||
vp8_horizontal_line_3_4_scale = vp8cx_horizontal_line_3_4_scale_c;
|
||||
vp8_vertical_band_3_4_scale = vp8cx_vertical_band_3_4_scale_c;
|
||||
vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
|
||||
vp8_horizontal_line_2_3_scale = vp8cx_horizontal_line_2_3_scale_c;
|
||||
vp8_vertical_band_2_3_scale = vp8cx_vertical_band_2_3_scale_c;
|
||||
vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
|
||||
vp8_horizontal_line_4_5_scale = vp8cx_horizontal_line_4_5_scale_c;
|
||||
vp8_vertical_band_4_5_scale = vp8cx_vertical_band_4_5_scale_c;
|
||||
vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
|
||||
|
||||
|
||||
vp8_vertical_band_5_4_scale = vp8cx_vertical_band_5_4_scale_c;
|
||||
vp8_vertical_band_5_3_scale = vp8cx_vertical_band_5_3_scale_c;
|
||||
vp8_vertical_band_2_1_scale = vp8cx_vertical_band_2_1_scale_c;
|
||||
vp8_vertical_band_2_1_scale_i = vp8cx_vertical_band_2_1_scale_i_c;
|
||||
vp8_horizontal_line_2_1_scale = vp8cx_horizontal_line_2_1_scale_c;
|
||||
vp8_horizontal_line_5_3_scale = vp8cx_horizontal_line_5_3_scale_c;
|
||||
vp8_horizontal_line_5_4_scale = vp8cx_horizontal_line_5_4_scale_c;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user