summaryrefslogtreecommitdiff
path: root/vpx_scale
diff options
context:
space:
mode:
authorJohann <johannkoenig@google.com>2012-12-03 12:26:51 -0800
committerJohn Koleszar <jkoleszar@google.com>2012-12-05 08:59:40 -0800
commit52d350febfc19ec5a1783789c183af2397bf5b20 (patch)
tree848acb68dea8305b82cdbebf349eaaee1d7bb17e /vpx_scale
parenta905672906716b2be9e741d81213177ebb4720d2 (diff)
downloadlibvpx-52d350febfc19ec5a1783789c183af2397bf5b20.tar.gz
libvpx-52d350febfc19ec5a1783789c183af2397bf5b20.tar.bz2
libvpx-52d350febfc19ec5a1783789c183af2397bf5b20.zip
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
Diffstat (limited to 'vpx_scale')
-rw-r--r--vpx_scale/generic/bicubic_scaler.c569
-rw-r--r--vpx_scale/generic/gen_scalers.c682
-rw-r--r--vpx_scale/generic/vpxscale.c480
-rw-r--r--vpx_scale/include/generic/vpxscale_arbitrary.h55
-rw-r--r--vpx_scale/include/generic/vpxscale_depricated.h34
-rw-r--r--vpx_scale/scale_mode.h28
-rw-r--r--vpx_scale/vpx_scale.mk1
-rw-r--r--vpx_scale/vpx_scale_rtcd.sh15
-rw-r--r--vpx_scale/vpxscale.h10
-rw-r--r--vpx_scale/win32/scaleopt.c1193
-rw-r--r--vpx_scale/win32/scalesystemdependent.c87
11 files changed, 0 insertions, 3154 deletions
diff --git a/vpx_scale/generic/bicubic_scaler.c b/vpx_scale/generic/bicubic_scaler.c
deleted file mode 100644
index c116740da..000000000
--- a/vpx_scale/generic/bicubic_scaler.c
+++ /dev/null
@@ -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);
-}
diff --git a/vpx_scale/generic/gen_scalers.c b/vpx_scale/generic/gen_scalers.c
index 60c21fb3a..febe97d94 100644
--- a/vpx_scale/generic/gen_scalers.c
+++ b/vpx_scale/generic/gen_scalers.c
@@ -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.
diff --git a/vpx_scale/generic/vpxscale.c b/vpx_scale/generic/vpxscale.c
index 584ad4b31..49cdb7bc7 100644
--- a/vpx_scale/generic/vpxscale.c
+++ b/vpx_scale/generic/vpxscale.c
@@ -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;
@@ -41,66 +40,6 @@ typedef struct {
/****************************************************************************
*
- * 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
*
* INPUTS : const unsigned char *source : Pointer to data to be scaled.
@@ -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;
- }
-}
diff --git a/vpx_scale/include/generic/vpxscale_arbitrary.h b/vpx_scale/include/generic/vpxscale_arbitrary.h
deleted file mode 100644
index c53525271..000000000
--- a/vpx_scale/include/generic/vpxscale_arbitrary.h
+++ /dev/null
@@ -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__ */
diff --git a/vpx_scale/include/generic/vpxscale_depricated.h b/vpx_scale/include/generic/vpxscale_depricated.h
deleted file mode 100644
index 3f7fe0f04..000000000
--- a/vpx_scale/include/generic/vpxscale_depricated.h
+++ /dev/null
@@ -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
diff --git a/vpx_scale/scale_mode.h b/vpx_scale/scale_mode.h
deleted file mode 100644
index 5581385b6..000000000
--- a/vpx_scale/scale_mode.h
+++ /dev/null
@@ -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
diff --git a/vpx_scale/vpx_scale.mk b/vpx_scale/vpx_scale.mk
index ce998c360..3d759327a 100644
--- a/vpx_scale/vpx_scale.mk
+++ b/vpx_scale/vpx_scale.mk
@@ -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
diff --git a/vpx_scale/vpx_scale_rtcd.sh b/vpx_scale/vpx_scale_rtcd.sh
index f709aa61c..e2bade077 100644
--- a/vpx_scale/vpx_scale_rtcd.sh
+++ b/vpx_scale/vpx_scale_rtcd.sh
@@ -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"
diff --git a/vpx_scale/vpxscale.h b/vpx_scale/vpxscale.h
index 3c2194d65..308b6aab6 100644
--- a/vpx_scale/vpxscale.h
+++ b/vpx_scale/vpxscale.h
@@ -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,
diff --git a/vpx_scale/win32/scaleopt.c b/vpx_scale/win32/scaleopt.c
index 2d96cc7c1..54f9ac069 100644
--- a/vpx_scale/win32/scaleopt.c
+++ b/vpx_scale/win32/scaleopt.c
@@ -18,1184 +18,14 @@
****************************************************************************/
#include "pragmas.h"
-
-
/****************************************************************************
* Module Statics
****************************************************************************/
-__declspec(align(16)) const static unsigned short one_fifth[] = { 51, 51, 51, 51 };
-__declspec(align(16)) const static unsigned short two_fifths[] = { 102, 102, 102, 102 };
-__declspec(align(16)) const static unsigned short three_fifths[] = { 154, 154, 154, 154 };
-__declspec(align(16)) const static unsigned short four_fifths[] = { 205, 205, 205, 205 };
__declspec(align(16)) const static unsigned short round_values[] = { 128, 128, 128, 128 };
-__declspec(align(16)) const static unsigned short four_ones[] = { 1, 1, 1, 1};
-__declspec(align(16)) const static unsigned short const45_2[] = {205, 154, 102, 51 };
-__declspec(align(16)) const static unsigned short const45_1[] = { 51, 102, 154, 205 };
-__declspec(align(16)) const static unsigned char mask45[] = { 0, 0, 0, 0, 0, 0, 255, 0};
-__declspec(align(16)) const static unsigned short const35_2[] = { 154, 51, 205, 102 };
-__declspec(align(16)) const static unsigned short const35_1[] = { 102, 205, 51, 154 };
-
-
#include "vpx_scale/vpxscale.h"
#include "vpx_mem/vpx_mem.h"
-/****************************************************************************
- *
- * ROUTINE : horizontal_line_3_5_scale_mmx
- *
- * INPUTS : const unsigned char *source :
- * unsigned int source_width :
- * unsigned char *dest :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : 3 to 5 up-scaling of a horizontal line of pixels.
- *
- * SPECIAL NOTES : None.
- *
- ****************************************************************************/
-static
-void horizontal_line_3_5_scale_mmx
-(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-) {
- (void) dest_width;
-
- __asm {
-
- push ebx
-
- mov esi, source
- mov edi, dest
-
- mov ecx, source_width
- lea edx, [esi+ecx-3];
-
- movq mm5, const35_1 // mm5 = 66 xx cd xx 33 xx 9a xx
- movq mm6, const35_2 // mm6 = 9a xx 33 xx cd xx 66 xx
-
- movq mm4, round_values // mm4 = 80 xx 80 xx 80 xx 80 xx
- pxor mm7, mm7 // clear mm7
-
- horiz_line_3_5_loop:
-
- mov eax, DWORD PTR [esi] // eax = 00 01 02 03
- mov ebx, eax
-
- and ebx, 0xffff00 // ebx = xx 01 02 xx
- mov ecx, eax // ecx = 00 01 02 03
-
- and eax, 0xffff0000 // eax = xx xx 02 03
- xor ecx, eax // ecx = 00 01 xx xx
-
- shr ebx, 8 // ebx = 01 02 xx xx
- or eax, ebx // eax = 01 02 02 03
-
- shl ebx, 16 // ebx = xx xx 01 02
- movd mm1, eax // mm1 = 01 02 02 03 xx xx xx xx
-
- or ebx, ecx // ebx = 00 01 01 02
- punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 02 xx 03 xx
-
- movd mm0, ebx // mm0 = 00 01 01 02
- pmullw mm1, mm6 //
-
- punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 01 xx 02 xx
- pmullw mm0, mm5 //
-
- mov [edi], ebx // writeoutput 00 xx xx xx
- add esi, 3
-
- add edi, 5
- paddw mm0, mm1
-
- paddw mm0, mm4
- psrlw mm0, 8
-
- cmp esi, edx
- packuswb mm0, mm7
-
- movd DWORD Ptr [edi-4], mm0
- jl horiz_line_3_5_loop
-
-// Exit:
- mov eax, DWORD PTR [esi] // eax = 00 01 02 03
- mov ebx, eax
-
- and ebx, 0xffff00 // ebx = xx 01 02 xx
- mov ecx, eax // ecx = 00 01 02 03
-
- and eax, 0xffff0000 // eax = xx xx 02 03
- xor ecx, eax // ecx = 00 01 xx xx
-
- shr ebx, 8 // ebx = 01 02 xx xx
- or eax, ebx // eax = 01 02 02 03
-
- shl eax, 8 // eax = xx 01 02 02
- and eax, 0xffff0000 // eax = xx xx 02 02
-
- or eax, ebx // eax = 01 02 02 02
-
- shl ebx, 16 // ebx = xx xx 01 02
- movd mm1, eax // mm1 = 01 02 02 02 xx xx xx xx
-
- or ebx, ecx // ebx = 00 01 01 02
- punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 02 xx 02 xx
-
- movd mm0, ebx // mm0 = 00 01 01 02
- pmullw mm1, mm6 //
-
- punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 01 xx 02 xx
- pmullw mm0, mm5 //
-
- mov [edi], ebx // writeoutput 00 xx xx xx
- paddw mm0, mm1
-
- paddw mm0, mm4
- psrlw mm0, 8
-
- packuswb mm0, mm7
- movd DWORD Ptr [edi+1], mm0
-
- pop ebx
-
- }
-
-}
-
-
-/****************************************************************************
- *
- * ROUTINE : horizontal_line_4_5_scale_mmx
- *
- * INPUTS : const unsigned char *source :
- * unsigned int source_width :
- * unsigned char *dest :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : 4 to 5 up-scaling of a horizontal line of pixels.
- *
- * SPECIAL NOTES : None.
- *
- ****************************************************************************/
-static
-void horizontal_line_4_5_scale_mmx
-(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-) {
- (void)dest_width;
-
- __asm {
-
- mov esi, source
- mov edi, dest
-
- mov ecx, source_width
- lea edx, [esi+ecx-8];
-
- movq mm5, const45_1 // mm5 = 33 xx 66 xx 9a xx cd xx
- movq mm6, const45_2 // mm6 = cd xx 9a xx 66 xx 33 xx
-
- movq mm4, round_values // mm4 = 80 xx 80 xx 80 xx 80 xx
- pxor mm7, mm7 // clear mm7
-
- horiz_line_4_5_loop:
-
- movq mm0, QWORD PTR [esi] // mm0 = 00 01 02 03 04 05 06 07
- movq mm1, QWORD PTR [esi+1]; // mm1 = 01 02 03 04 05 06 07 08
-
- movq mm2, mm0 // mm2 = 00 01 02 03 04 05 06 07
- movq mm3, mm1 // mm3 = 01 02 03 04 05 06 07 08
-
- movd DWORD PTR [edi], mm0 // write output 00 xx xx xx
- punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 02 xx 03 xx
-
- punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 03 xx 04 xx
- pmullw mm0, mm5 // 00* 51 01*102 02*154 03*205
-
- pmullw mm1, mm6 // 01*205 02*154 03*102 04* 51
- punpckhbw mm2, mm7 // mm2 = 04 xx 05 xx 06 xx 07 xx
-
- movd DWORD PTR [edi+5], mm2 // write ouput 05 xx xx xx
- pmullw mm2, mm5 // 04* 51 05*102 06*154 07*205
-
- punpckhbw mm3, mm7 // mm3 = 05 xx 06 xx 07 xx 08 xx
- pmullw mm3, mm6 // 05*205 06*154 07*102 08* 51
-
- paddw mm0, mm1 // added round values
- paddw mm0, mm4
-
- psrlw mm0, 8 // output: 01 xx 02 xx 03 xx 04 xx
- packuswb mm0, mm7
-
- movd DWORD PTR [edi+1], mm0 // write output 01 02 03 04
- add edi, 10
-
- add esi, 8
- paddw mm2, mm3 //
-
- paddw mm2, mm4 // added round values
- cmp esi, edx
-
- psrlw mm2, 8
- packuswb mm2, mm7
-
- movd DWORD PTR [edi-4], mm2 // writeoutput 06 07 08 09
- jl horiz_line_4_5_loop
-
-// Exit:
- movq mm0, [esi] // mm0 = 00 01 02 03 04 05 06 07
- movq mm1, mm0 // mm1 = 00 01 02 03 04 05 06 07
-
- movq mm2, mm0 // mm2 = 00 01 02 03 04 05 06 07
- psrlq mm1, 8 // mm1 = 01 02 03 04 05 06 07 00
-
- movq mm3, mask45 // mm3 = 00 00 00 00 00 00 ff 00
- pand mm3, mm1 // mm3 = 00 00 00 00 00 00 07 00
-
- psllq mm3, 8 // mm3 = 00 00 00 00 00 00 00 07
- por mm1, mm3 // mm1 = 01 02 03 04 05 06 07 07
-
- movq mm3, mm1
-
- movd DWORD PTR [edi], mm0 // write output 00 xx xx xx
- punpcklbw mm0, mm7 // mm0 = 00 xx 01 xx 02 xx 03 xx
-
- punpcklbw mm1, mm7 // mm1 = 01 xx 02 xx 03 xx 04 xx
- pmullw mm0, mm5 // 00* 51 01*102 02*154 03*205
-
- pmullw mm1, mm6 // 01*205 02*154 03*102 04* 51
- punpckhbw mm2, mm7 // mm2 = 04 xx 05 xx 06 xx 07 xx
-
- movd DWORD PTR [edi+5], mm2 // write ouput 05 xx xx xx
- pmullw mm2, mm5 // 04* 51 05*102 06*154 07*205
-
- punpckhbw mm3, mm7 // mm3 = 05 xx 06 xx 07 xx 08 xx
- pmullw mm3, mm6 // 05*205 06*154 07*102 07* 51
-
- paddw mm0, mm1 // added round values
- paddw mm0, mm4
-
- psrlw mm0, 8 // output: 01 xx 02 xx 03 xx 04 xx
- packuswb mm0, mm7 // 01 02 03 04 xx xx xx xx
-
- movd DWORD PTR [edi+1], mm0 // write output 01 02 03 04
- paddw mm2, mm3 //
-
- paddw mm2, mm4 // added round values
- psrlw mm2, 8
-
- packuswb mm2, mm7
- movd DWORD PTR [edi+6], mm2 // writeoutput 06 07 08 09
-
-
- }
-}
-
-/****************************************************************************
- *
- * ROUTINE : vertical_band_4_5_scale_mmx
- *
- * INPUTS : unsigned char *dest :
- * unsigned int dest_pitch :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : 4 to 5 up-scaling of a 4 pixel high band of pixels.
- *
- * SPECIAL NOTES : The routine uses the first line of the band below
- * the current band. The function also has a "C" only
- * version.
- *
- ****************************************************************************/
-static
-void vertical_band_4_5_scale_mmx
-(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-) {
- __asm {
-
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
-
- lea edi, [esi+ecx*2] // tow lines below
- add edi, ecx // three lines below
-
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
-
- vs_4_5_loop:
-
- movq mm0, QWORD ptr [esi] // src[0];
- movq mm1, QWORD ptr [esi+ecx] // src[1];
-
- movq mm2, mm0 // Make a copy
- punpcklbw mm0, mm7 // unpack low to word
-
- movq mm5, one_fifth
- punpckhbw mm2, mm7 // unpack high to word
-
- pmullw mm0, mm5 // a * 1/5
-
- movq mm3, mm1 // make a copy
- punpcklbw mm1, mm7 // unpack low to word
-
- pmullw mm2, mm5 // a * 1/5
- movq mm6, four_fifths // constan
-
- movq mm4, mm1 // copy of low b
- pmullw mm4, mm6 // b * 4/5
-
- punpckhbw mm3, mm7 // unpack high to word
- movq mm5, mm3 // copy of high b
-
- pmullw mm5, mm6 // b * 4/5
- paddw mm0, mm4 // a * 1/5 + b * 4/5
-
- paddw mm2, mm5 // a * 1/5 + b * 4/5
- paddw mm0, round_values // + 128
-
- paddw mm2, round_values // + 128
- psrlw mm0, 8
-
- psrlw mm2, 8
- packuswb mm0, mm2 // des [1]
-
- movq QWORD ptr [esi+ecx], mm0 // write des[1]
- movq mm0, [esi+ecx*2] // mm0 = src[2]
-
- // mm1, mm3 --- Src[1]
- // mm0 --- Src[2]
- // mm7 for unpacking
-
- movq mm5, two_fifths
- movq mm2, mm0 // make a copy
-
- pmullw mm1, mm5 // b * 2/5
- movq mm6, three_fifths
-
-
- punpcklbw mm0, mm7 // unpack low to word
- pmullw mm3, mm5 // b * 2/5
-
- movq mm4, mm0 // make copy of c
- punpckhbw mm2, mm7 // unpack high to word
-
- pmullw mm4, mm6 // c * 3/5
- movq mm5, mm2
-
- pmullw mm5, mm6 // c * 3/5
- paddw mm1, mm4 // b * 2/5 + c * 3/5
-
- paddw mm3, mm5 // b * 2/5 + c * 3/5
- paddw mm1, round_values // + 128
-
- paddw mm3, round_values // + 128
- psrlw mm1, 8
-
- psrlw mm3, 8
- packuswb mm1, mm3 // des[2]
-
- movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
- movq mm1, [edi] // mm1=Src[3];
-
- // mm0, mm2 --- Src[2]
- // mm1 --- Src[3]
- // mm6 --- 3/5
- // mm7 for unpacking
-
- pmullw mm0, mm6 // c * 3/5
- movq mm5, two_fifths // mm5 = 2/5
-
- movq mm3, mm1 // make a copy
- pmullw mm2, mm6 // c * 3/5
-
- punpcklbw mm1, mm7 // unpack low
- movq mm4, mm1 // make a copy
-
- punpckhbw mm3, mm7 // unpack high
- pmullw mm4, mm5 // d * 2/5
-
- movq mm6, mm3 // make a copy
- pmullw mm6, mm5 // d * 2/5
-
- paddw mm0, mm4 // c * 3/5 + d * 2/5
- paddw mm2, mm6 // c * 3/5 + d * 2/5
-
- paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
-
- psrlw mm0, 8
- psrlw mm2, 8
-
- packuswb mm0, mm2 // des[3]
- movq QWORD ptr [edi], mm0 // write des[3]
-
- // mm1, mm3 --- Src[3]
- // mm7 -- cleared for unpacking
-
- movq mm0, [edi+ecx*2] // mm0, Src[0] of the next group
-
- movq mm5, four_fifths // mm5 = 4/5
- pmullw mm1, mm5 // d * 4/5
-
- movq mm6, one_fifth // mm6 = 1/5
- movq mm2, mm0 // make a copy
-
- pmullw mm3, mm5 // d * 4/5
- punpcklbw mm0, mm7 // unpack low
-
- pmullw mm0, mm6 // an * 1/5
- punpckhbw mm2, mm7 // unpack high
-
- paddw mm1, mm0 // d * 4/5 + an * 1/5
- pmullw mm2, mm6 // an * 1/5
-
- paddw mm3, mm2 // d * 4/5 + an * 1/5
- paddw mm1, round_values // + 128
-
- paddw mm3, round_values // + 128
- psrlw mm1, 8
-
- psrlw mm3, 8
- packuswb mm1, mm3 // des[4]
-
- movq QWORD ptr [edi+ecx], mm1 // write des[4]
-
- add edi, 8
- add esi, 8
-
- sub edx, 8
- jg vs_4_5_loop
- }
-}
-
-/****************************************************************************
- *
- * ROUTINE : last_vertical_band_4_5_scale_mmx
- *
- * INPUTS : unsigned char *dest :
- * unsigned int dest_pitch :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : None
- *
- * FUNCTION : 4 to 5 up-scaling of the last 4-pixel high band in an image.
- *
- * SPECIAL NOTES : The routine uses the first line of the band below
- * the current band. The function also has an "C" only
- * version.
- *
- ****************************************************************************/
-static
-void last_vertical_band_4_5_scale_mmx
-(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-) {
- __asm {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
-
- lea edi, [esi+ecx*2] // tow lines below
- add edi, ecx // three lines below
-
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
-
- last_vs_4_5_loop:
-
- movq mm0, QWORD ptr [esi] // src[0];
- movq mm1, QWORD ptr [esi+ecx] // src[1];
-
- movq mm2, mm0 // Make a copy
- punpcklbw mm0, mm7 // unpack low to word
-
- movq mm5, one_fifth
- punpckhbw mm2, mm7 // unpack high to word
-
- pmullw mm0, mm5 // a * 1/5
-
- movq mm3, mm1 // make a copy
- punpcklbw mm1, mm7 // unpack low to word
-
- pmullw mm2, mm5 // a * 1/5
- movq mm6, four_fifths // constan
-
- movq mm4, mm1 // copy of low b
- pmullw mm4, mm6 // b * 4/5
-
- punpckhbw mm3, mm7 // unpack high to word
- movq mm5, mm3 // copy of high b
-
- pmullw mm5, mm6 // b * 4/5
- paddw mm0, mm4 // a * 1/5 + b * 4/5
-
- paddw mm2, mm5 // a * 1/5 + b * 4/5
- paddw mm0, round_values // + 128
-
- paddw mm2, round_values // + 128
- psrlw mm0, 8
-
- psrlw mm2, 8
- packuswb mm0, mm2 // des [1]
-
- movq QWORD ptr [esi+ecx], mm0 // write des[1]
- movq mm0, [esi+ecx*2] // mm0 = src[2]
-
- // mm1, mm3 --- Src[1]
- // mm0 --- Src[2]
- // mm7 for unpacking
-
- movq mm5, two_fifths
- movq mm2, mm0 // make a copy
-
- pmullw mm1, mm5 // b * 2/5
- movq mm6, three_fifths
-
-
- punpcklbw mm0, mm7 // unpack low to word
- pmullw mm3, mm5 // b * 2/5
-
- movq mm4, mm0 // make copy of c
- punpckhbw mm2, mm7 // unpack high to word
-
- pmullw mm4, mm6 // c * 3/5
- movq mm5, mm2
-
- pmullw mm5, mm6 // c * 3/5
- paddw mm1, mm4 // b * 2/5 + c * 3/5
-
- paddw mm3, mm5 // b * 2/5 + c * 3/5
- paddw mm1, round_values // + 128
-
- paddw mm3, round_values // + 128
- psrlw mm1, 8
-
- psrlw mm3, 8
- packuswb mm1, mm3 // des[2]
-
- movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
- movq mm1, [edi] // mm1=Src[3];
-
- movq QWORD ptr [edi+ecx], mm1 // write des[4];
-
- // mm0, mm2 --- Src[2]
- // mm1 --- Src[3]
- // mm6 --- 3/5
- // mm7 for unpacking
-
- pmullw mm0, mm6 // c * 3/5
- movq mm5, two_fifths // mm5 = 2/5
-
- movq mm3, mm1 // make a copy
- pmullw mm2, mm6 // c * 3/5
-
- punpcklbw mm1, mm7 // unpack low
- movq mm4, mm1 // make a copy
-
- punpckhbw mm3, mm7 // unpack high
- pmullw mm4, mm5 // d * 2/5
-
- movq mm6, mm3 // make a copy
- pmullw mm6, mm5 // d * 2/5
-
- paddw mm0, mm4 // c * 3/5 + d * 2/5
- paddw mm2, mm6 // c * 3/5 + d * 2/5
-
- paddw mm0, round_values // + 128
- paddw mm2, round_values // + 128
-
- psrlw mm0, 8
- psrlw mm2, 8
-
- packuswb mm0, mm2 // des[3]
- movq QWORD ptr [edi], mm0 // write des[3]
-
- // mm1, mm3 --- Src[3]
- // mm7 -- cleared for unpacking
- add edi, 8
- add esi, 8
-
- sub edx, 8
- jg last_vs_4_5_loop
- }
-}
-
-/****************************************************************************
- *
- * ROUTINE : vertical_band_3_5_scale_mmx
- *
- * INPUTS : unsigned char *dest :
- * unsigned int dest_pitch :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : 3 to 5 up-scaling of a 3-pixel high band of pixels.
- *
- * SPECIAL NOTES : The routine uses the first line of the band below
- * the current band. The function also has an "C" only
- * version.
- *
- ****************************************************************************/
-static
-void vertical_band_3_5_scale_mmx
-(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-) {
- __asm {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
-
- lea edi, [esi+ecx*2] // tow lines below
- add edi, ecx // three lines below
-
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
-
- vs_3_5_loop:
-
- movq mm0, QWORD ptr [esi] // src[0];
- movq mm1, QWORD ptr [esi+ecx] // src[1];
-
- movq mm2, mm0 // Make a copy
- punpcklbw mm0, mm7 // unpack low to word
-
- movq mm5, two_fifths // mm5 = 2/5
- punpckhbw mm2, mm7 // unpack high to word
-
- pmullw mm0, mm5 // a * 2/5
-
- movq mm3, mm1 // make a copy
- punpcklbw mm1, mm7 // unpack low to word
-
- pmullw mm2, mm5 // a * 2/5
- movq mm6, three_fifths // mm6 = 3/5
-
- movq mm4, mm1 // copy of low b
- pmullw mm4, mm6 // b * 3/5
-
- punpckhbw mm3, mm7 // unpack high to word
- movq mm5, mm3 // copy of high b
-
- pmullw mm5, mm6 // b * 3/5
- paddw mm0, mm4 // a * 2/5 + b * 3/5
-
- paddw mm2, mm5 // a * 2/5 + b * 3/5
- paddw mm0, round_values // + 128
-
- paddw mm2, round_values // + 128
- psrlw mm0, 8
-
- psrlw mm2, 8
- packuswb mm0, mm2 // des [1]
-
- movq QWORD ptr [esi+ecx], mm0 // write des[1]
- movq mm0, [esi+ecx*2] // mm0 = src[2]
-
- // mm1, mm3 --- Src[1]
- // mm0 --- Src[2]
- // mm7 for unpacking
-
- movq mm4, mm1 // b low
- pmullw mm1, four_fifths // b * 4/5 low
-
- movq mm5, mm3 // b high
- pmullw mm3, four_fifths // b * 4/5 high
-
- movq mm2, mm0 // c
- pmullw mm4, one_fifth // b * 1/5
-
- punpcklbw mm0, mm7 // c low
- pmullw mm5, one_fifth // b * 1/5
-
- movq mm6, mm0 // make copy of c low
- punpckhbw mm2, mm7 // c high
-
- pmullw mm6, one_fifth // c * 1/5 low
- movq mm7, mm2 // make copy of c high
-
- pmullw mm7, one_fifth // c * 1/5 high
- paddw mm1, mm6 // b * 4/5 + c * 1/5 low
-
- paddw mm3, mm7 // b * 4/5 + c * 1/5 high
- movq mm6, mm0 // make copy of c low
-
- pmullw mm6, four_fifths // c * 4/5 low
- movq mm7, mm2 // make copy of c high
-
- pmullw mm7, four_fifths // c * 4/5 high
-
- paddw mm4, mm6 // b * 1/5 + c * 4/5 low
- paddw mm5, mm7 // b * 1/5 + c * 4/5 high
-
- paddw mm1, round_values // + 128
- paddw mm3, round_values // + 128
-
- psrlw mm1, 8
- psrlw mm3, 8
-
- packuswb mm1, mm3 // des[2]
- movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
-
- paddw mm4, round_values // + 128
- paddw mm5, round_values // + 128
-
- psrlw mm4, 8
- psrlw mm5, 8
-
- packuswb mm4, mm5 // des[3]
- movq QWORD ptr [edi], mm4 // write des[3]
-
- // mm0, mm2 --- Src[3]
-
- pxor mm7, mm7 // clear mm7 for unpacking
- movq mm1, [edi+ecx*2] // mm1 = Src[0] of the next group
-
- movq mm5, three_fifths // mm5 = 3/5
- pmullw mm0, mm5 // d * 3/5
-
- movq mm6, two_fifths // mm6 = 2/5
- movq mm3, mm1 // make a copy
-
- pmullw mm2, mm5 // d * 3/5
- punpcklbw mm1, mm7 // unpack low
-
- pmullw mm1, mm6 // an * 2/5
- punpckhbw mm3, mm7 // unpack high
-
- paddw mm0, mm1 // d * 3/5 + an * 2/5
- pmullw mm3, mm6 // an * 2/5
-
- paddw mm2, mm3 // d * 3/5 + an * 2/5
- paddw mm0, round_values // + 128
-
- paddw mm2, round_values // + 128
- psrlw mm0, 8
-
- psrlw mm2, 8
- packuswb mm0, mm2 // des[4]
-
- movq QWORD ptr [edi+ecx], mm0 // write des[4]
-
- add edi, 8
- add esi, 8
-
- sub edx, 8
- jg vs_3_5_loop
- }
-}
-
-/****************************************************************************
- *
- * ROUTINE : last_vertical_band_3_5_scale_mmx
- *
- * INPUTS : unsigned char *dest :
- * unsigned int dest_pitch :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : 3 to 5 up-scaling of a 3-pixel high band of pixels.
- *
- * SPECIAL NOTES : The routine uses the first line of the band below
- * the current band. The function also has an "C" only
- * version.
- *
- ****************************************************************************/
-static
-void last_vertical_band_3_5_scale_mmx
-(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-) {
- __asm {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
-
- lea edi, [esi+ecx*2] // tow lines below
- add edi, ecx // three lines below
-
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
-
-
- last_vs_3_5_loop:
-
- movq mm0, QWORD ptr [esi] // src[0];
- movq mm1, QWORD ptr [esi+ecx] // src[1];
-
- movq mm2, mm0 // Make a copy
- punpcklbw mm0, mm7 // unpack low to word
-
- movq mm5, two_fifths // mm5 = 2/5
- punpckhbw mm2, mm7 // unpack high to word
-
- pmullw mm0, mm5 // a * 2/5
-
- movq mm3, mm1 // make a copy
- punpcklbw mm1, mm7 // unpack low to word
-
- pmullw mm2, mm5 // a * 2/5
- movq mm6, three_fifths // mm6 = 3/5
-
- movq mm4, mm1 // copy of low b
- pmullw mm4, mm6 // b * 3/5
-
- punpckhbw mm3, mm7 // unpack high to word
- movq mm5, mm3 // copy of high b
-
- pmullw mm5, mm6 // b * 3/5
- paddw mm0, mm4 // a * 2/5 + b * 3/5
-
- paddw mm2, mm5 // a * 2/5 + b * 3/5
- paddw mm0, round_values // + 128
-
- paddw mm2, round_values // + 128
- psrlw mm0, 8
-
- psrlw mm2, 8
- packuswb mm0, mm2 // des [1]
-
- movq QWORD ptr [esi+ecx], mm0 // write des[1]
- movq mm0, [esi+ecx*2] // mm0 = src[2]
-
-
-
- // mm1, mm3 --- Src[1]
- // mm0 --- Src[2]
- // mm7 for unpacking
-
- movq mm4, mm1 // b low
- pmullw mm1, four_fifths // b * 4/5 low
-
- movq QWORD ptr [edi+ecx], mm0 // write des[4]
-
- movq mm5, mm3 // b high
- pmullw mm3, four_fifths // b * 4/5 high
-
- movq mm2, mm0 // c
- pmullw mm4, one_fifth // b * 1/5
-
- punpcklbw mm0, mm7 // c low
- pmullw mm5, one_fifth // b * 1/5
-
- movq mm6, mm0 // make copy of c low
- punpckhbw mm2, mm7 // c high
-
- pmullw mm6, one_fifth // c * 1/5 low
- movq mm7, mm2 // make copy of c high
-
- pmullw mm7, one_fifth // c * 1/5 high
- paddw mm1, mm6 // b * 4/5 + c * 1/5 low
-
- paddw mm3, mm7 // b * 4/5 + c * 1/5 high
- movq mm6, mm0 // make copy of c low
-
- pmullw mm6, four_fifths // c * 4/5 low
- movq mm7, mm2 // make copy of c high
-
- pmullw mm7, four_fifths // c * 4/5 high
-
- paddw mm4, mm6 // b * 1/5 + c * 4/5 low
- paddw mm5, mm7 // b * 1/5 + c * 4/5 high
-
- paddw mm1, round_values // + 128
- paddw mm3, round_values // + 128
-
- psrlw mm1, 8
- psrlw mm3, 8
-
- packuswb mm1, mm3 // des[2]
- movq QWORD ptr [esi+ecx*2], mm1 // write des[2]
-
- paddw mm4, round_values // + 128
- paddw mm5, round_values // + 128
-
- psrlw mm4, 8
- psrlw mm5, 8
-
- packuswb mm4, mm5 // des[3]
- movq QWORD ptr [edi], mm4 // write des[3]
-
- // mm0, mm2 --- Src[3]
-
- add edi, 8
- add esi, 8
-
- sub edx, 8
- jg last_vs_3_5_loop
- }
-}
-
-/****************************************************************************
- *
- * ROUTINE : vertical_band_1_2_scale_mmx
- *
- * INPUTS : unsigned char *dest :
- * unsigned int dest_pitch :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : 1 to 2 up-scaling of a band of pixels.
- *
- * SPECIAL NOTES : The routine uses the first line of the band below
- * the current band. The function also has an "C" only
- * version.
- *
- ****************************************************************************/
-static
-void vertical_band_1_2_scale_mmx
-(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-) {
- __asm {
-
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
-
- pxor mm7, mm7 // clear out mm7
- mov edx, dest_width // Loop counter
-
- vs_1_2_loop:
-
- movq mm0, [esi] // get Src[0]
- movq mm1, [esi + ecx * 2] // get Src[1]
-
- movq mm2, mm0 // make copy before unpack
- movq mm3, mm1 // make copy before unpack
-
- punpcklbw mm0, mm7 // low Src[0]
- movq mm6, four_ones // mm6= 1, 1, 1, 1
-
- punpcklbw mm1, mm7 // low Src[1]
- paddw mm0, mm1 // low (a + b)
-
- punpckhbw mm2, mm7 // high Src[0]
- paddw mm0, mm6 // low (a + b + 1)
-
- punpckhbw mm3, mm7
- paddw mm2, mm3 // high (a + b )
-
- psraw mm0, 1 // low (a + b +1 )/2
- paddw mm2, mm6 // high (a + b + 1)
-
- psraw mm2, 1 // high (a + b + 1)/2
- packuswb mm0, mm2 // pack results
-
- movq [esi+ecx], mm0 // write out eight bytes
- add esi, 8
-
- sub edx, 8
- jg vs_1_2_loop
- }
-
-}
-
-/****************************************************************************
- *
- * ROUTINE : last_vertical_band_1_2_scale_mmx
- *
- * INPUTS : unsigned char *dest :
- * unsigned int dest_pitch :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : 1 to 2 up-scaling of band of pixels.
- *
- * SPECIAL NOTES : The routine uses the first line of the band below
- * the current band. The function also has an "C" only
- * version.
- *
- ****************************************************************************/
-static
-void last_vertical_band_1_2_scale_mmx
-(
- unsigned char *dest,
- unsigned int dest_pitch,
- unsigned int dest_width
-) {
- __asm {
- mov esi, dest // Get the source and destination pointer
- mov ecx, dest_pitch // Get the pitch size
-
- mov edx, dest_width // Loop counter
-
- last_vs_1_2_loop:
-
- movq mm0, [esi] // get Src[0]
- movq [esi+ecx], mm0 // write out eight bytes
-
- add esi, 8
- sub edx, 8
-
- jg last_vs_1_2_loop
- }
-}
-
-/****************************************************************************
- *
- * ROUTINE : horizontal_line_1_2_scale
- *
- * INPUTS : const unsigned char *source :
- * unsigned int source_width :
- * unsigned char *dest :
- * unsigned int dest_width :
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : 1 to 2 up-scaling of a horizontal line of pixels.
- *
- * SPECIAL NOTES : None.
- *
- ****************************************************************************/
-static
-void horizontal_line_1_2_scale_mmx
-(
- const unsigned char *source,
- unsigned int source_width,
- unsigned char *dest,
- unsigned int dest_width
-) {
- (void) dest_width;
-
- __asm {
- mov esi, source
- mov edi, dest
-
- pxor mm7, mm7
- movq mm6, four_ones
-
- mov ecx, source_width
-
- hs_1_2_loop:
-
- movq mm0, [esi]
- movq mm1, [esi+1]
-
- movq mm2, mm0
- movq mm3, mm1
-
- movq mm4, mm0
- punpcklbw mm0, mm7
-
- punpcklbw mm1, mm7
- paddw mm0, mm1
-
- paddw mm0, mm6
- punpckhbw mm2, mm7
-
- punpckhbw mm3, mm7
- paddw mm2, mm3
-
- paddw mm2, mm6
- psraw mm0, 1
-
- psraw mm2, 1
- packuswb mm0, mm2
-
- movq mm2, mm4
- punpcklbw mm2, mm0
-
- movq [edi], mm2
- punpckhbw mm4, mm0
-
- movq [edi+8], mm4
- add esi, 8
-
- add edi, 16
- sub ecx, 8
-
- cmp ecx, 8
- jg hs_1_2_loop
-
-// last eight pixel
-
- movq mm0, [esi]
- movq mm1, mm0
-
- movq mm2, mm0
- movq mm3, mm1
-
- psrlq mm1, 8
- psrlq mm3, 56
-
- psllq mm3, 56
- por mm1, mm3
-
- movq mm3, mm1
- movq mm4, mm0
-
- punpcklbw mm0, mm7
- punpcklbw mm1, mm7
-
- paddw mm0, mm1
- paddw mm0, mm6
-
- punpckhbw mm2, mm7
- punpckhbw mm3, mm7
-
- paddw mm2, mm3
- paddw mm2, mm6
-
- psraw mm0, 1
- psraw mm2, 1
-
- packuswb mm0, mm2
- movq mm2, mm4
-
- punpcklbw mm2, mm0
- movq [edi], mm2
-
- punpckhbw mm4, mm0
- movq [edi+8], mm4
- }
-}
-
-
-
-
-
__declspec(align(16)) const static unsigned short const54_2[] = { 0, 64, 128, 192 };
__declspec(align(16)) const static unsigned short const54_1[] = {256, 192, 128, 64 };
@@ -1685,25 +515,6 @@ void vertical_band_2_1_scale_i_mmx(unsigned char *source, unsigned int src_pitch
void
register_mmxscalers(void) {
- vp8_horizontal_line_1_2_scale = horizontal_line_1_2_scale_mmx;
- vp8_vertical_band_1_2_scale = vertical_band_1_2_scale_mmx;
- vp8_last_vertical_band_1_2_scale = last_vertical_band_1_2_scale_mmx;
- vp8_horizontal_line_3_5_scale = horizontal_line_3_5_scale_mmx;
- vp8_vertical_band_3_5_scale = vertical_band_3_5_scale_mmx;
- vp8_last_vertical_band_3_5_scale = last_vertical_band_3_5_scale_mmx;
- vp8_horizontal_line_4_5_scale = horizontal_line_4_5_scale_mmx;
- vp8_vertical_band_4_5_scale = vertical_band_4_5_scale_mmx;
- vp8_last_vertical_band_4_5_scale = last_vertical_band_4_5_scale_mmx;
-
- 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_vertical_band_5_4_scale = vertical_band_5_4_scale_mmx;
vp8_vertical_band_5_3_scale = vertical_band_5_3_scale_mmx;
vp8_vertical_band_2_1_scale = vertical_band_2_1_scale_mmx;
@@ -1711,8 +522,4 @@ register_mmxscalers(void) {
vp8_horizontal_line_2_1_scale = horizontal_line_2_1_scale_mmx;
vp8_horizontal_line_5_3_scale = horizontal_line_5_3_scale_mmx;
vp8_horizontal_line_5_4_scale = horizontal_line_5_4_scale_mmx;
-
-
-
-
}
diff --git a/vpx_scale/win32/scalesystemdependent.c b/vpx_scale/win32/scalesystemdependent.c
deleted file mode 100644
index 98913d19a..000000000
--- a/vpx_scale/win32/scalesystemdependent.c
+++ /dev/null
@@ -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;
-
- }
-}