2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
2015-05-15 04:50:56 +02:00
|
|
|
#include "./vpx_scale_rtcd.h"
|
2012-12-03 23:19:49 +01:00
|
|
|
#include "vpx_scale/vpx_scale.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
|
|
|
/****************************************************************************
|
|
|
|
* Imports
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* INPUTS : const unsigned char *source : Pointer to source data.
|
2016-07-25 23:32:36 +02:00
|
|
|
* unsigned int source_width : Stride of source.
|
2010-05-18 17:58:33 +02:00
|
|
|
* unsigned char *dest : Pointer to destination data.
|
2016-07-25 23:32:36 +02:00
|
|
|
* unsigned int dest_width : Stride of dest (UNUSED).
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
|
|
|
* OUTPUTS : None.
|
|
|
|
*
|
|
|
|
* RETURNS : void
|
|
|
|
*
|
|
|
|
* FUNCTION : Copies horizontal line of pixels from source to
|
|
|
|
* destination scaling up by 4 to 5.
|
|
|
|
*
|
|
|
|
* SPECIAL NOTES : None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2012-11-02 01:53:44 +01:00
|
|
|
void vp8_horizontal_line_5_4_scale_c(const unsigned char *source,
|
|
|
|
unsigned int source_width,
|
|
|
|
unsigned char *dest,
|
|
|
|
unsigned int dest_width) {
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned i;
|
|
|
|
unsigned int a, b, c, d, e;
|
|
|
|
unsigned char *des = dest;
|
|
|
|
const unsigned char *src = source;
|
|
|
|
|
2016-07-25 23:32:36 +02:00
|
|
|
(void)dest_width;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < source_width; i += 5) {
|
|
|
|
a = src[0];
|
|
|
|
b = src[1];
|
|
|
|
c = src[2];
|
|
|
|
d = src[3];
|
|
|
|
e = src[4];
|
|
|
|
|
2016-07-25 23:32:36 +02:00
|
|
|
des[0] = (unsigned char)a;
|
2012-07-14 00:21:29 +02:00
|
|
|
des[1] = (unsigned char)((b * 192 + c * 64 + 128) >> 8);
|
|
|
|
des[2] = (unsigned char)((c * 128 + d * 128 + 128) >> 8);
|
|
|
|
des[3] = (unsigned char)((d * 64 + e * 192 + 128) >> 8);
|
|
|
|
|
|
|
|
src += 5;
|
|
|
|
des += 4;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-11-02 01:53:44 +01:00
|
|
|
void vp8_vertical_band_5_4_scale_c(unsigned char *source,
|
2016-07-25 23:32:36 +02:00
|
|
|
unsigned int src_pitch, unsigned char *dest,
|
2012-11-02 01:53:44 +01:00
|
|
|
unsigned int dest_pitch,
|
|
|
|
unsigned int dest_width) {
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int a, b, c, d, e;
|
|
|
|
unsigned char *des = dest;
|
|
|
|
unsigned char *src = source;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 0; i < dest_width; i++) {
|
|
|
|
a = src[0 * src_pitch];
|
|
|
|
b = src[1 * src_pitch];
|
|
|
|
c = src[2 * src_pitch];
|
|
|
|
d = src[3 * src_pitch];
|
|
|
|
e = src[4 * src_pitch];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2016-07-25 23:32:36 +02:00
|
|
|
des[0 * dest_pitch] = (unsigned char)a;
|
2012-07-14 00:21:29 +02:00
|
|
|
des[1 * dest_pitch] = (unsigned char)((b * 192 + c * 64 + 128) >> 8);
|
|
|
|
des[2 * dest_pitch] = (unsigned char)((c * 128 + d * 128 + 128) >> 8);
|
|
|
|
des[3 * dest_pitch] = (unsigned char)((d * 64 + e * 192 + 128) >> 8);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
src++;
|
|
|
|
des++;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*7***************************************************************************
|
|
|
|
*
|
2012-11-02 01:53:44 +01:00
|
|
|
* ROUTINE : vp8_horizontal_line_3_5_scale_c
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
|
|
|
* INPUTS : const unsigned char *source : Pointer to source data.
|
2016-07-25 23:32:36 +02:00
|
|
|
* unsigned int source_width : Stride of source.
|
2010-05-18 17:58:33 +02:00
|
|
|
* unsigned char *dest : Pointer to destination data.
|
2016-07-25 23:32:36 +02:00
|
|
|
* unsigned int dest_width : Stride of dest (UNUSED).
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
|
|
|
* OUTPUTS : None.
|
|
|
|
*
|
|
|
|
* RETURNS : void
|
|
|
|
*
|
|
|
|
* FUNCTION : Copies horizontal line of pixels from source to
|
|
|
|
* destination scaling up by 3 to 5.
|
|
|
|
*
|
|
|
|
* SPECIAL NOTES : None.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2012-11-02 01:53:44 +01:00
|
|
|
void vp8_horizontal_line_5_3_scale_c(const unsigned char *source,
|
|
|
|
unsigned int source_width,
|
|
|
|
unsigned char *dest,
|
|
|
|
unsigned int dest_width) {
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int a, b, c, d, e;
|
|
|
|
unsigned char *des = dest;
|
|
|
|
const unsigned char *src = source;
|
|
|
|
|
2016-07-25 23:32:36 +02:00
|
|
|
(void)dest_width;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < source_width; i += 5) {
|
|
|
|
a = src[0];
|
|
|
|
b = src[1];
|
|
|
|
c = src[2];
|
|
|
|
d = src[3];
|
|
|
|
e = src[4];
|
|
|
|
|
2016-07-25 23:32:36 +02:00
|
|
|
des[0] = (unsigned char)a;
|
|
|
|
des[1] = (unsigned char)((b * 85 + c * 171 + 128) >> 8);
|
2012-07-14 00:21:29 +02:00
|
|
|
des[2] = (unsigned char)((d * 171 + e * 85 + 128) >> 8);
|
|
|
|
|
|
|
|
src += 5;
|
|
|
|
des += 3;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-11-02 01:53:44 +01:00
|
|
|
void vp8_vertical_band_5_3_scale_c(unsigned char *source,
|
2016-07-25 23:32:36 +02:00
|
|
|
unsigned int src_pitch, unsigned char *dest,
|
2012-11-02 01:53:44 +01:00
|
|
|
unsigned int dest_pitch,
|
|
|
|
unsigned int dest_width) {
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int a, b, c, d, e;
|
|
|
|
unsigned char *des = dest;
|
|
|
|
unsigned char *src = source;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 0; i < dest_width; i++) {
|
|
|
|
a = src[0 * src_pitch];
|
|
|
|
b = src[1 * src_pitch];
|
|
|
|
c = src[2 * src_pitch];
|
|
|
|
d = src[3 * src_pitch];
|
|
|
|
e = src[4 * src_pitch];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2016-07-25 23:32:36 +02:00
|
|
|
des[0 * dest_pitch] = (unsigned char)a;
|
2012-07-14 00:21:29 +02:00
|
|
|
des[1 * dest_pitch] = (unsigned char)((b * 85 + c * 171 + 128) >> 8);
|
|
|
|
des[2 * dest_pitch] = (unsigned char)((d * 171 + e * 85 + 128) >> 8);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
src++;
|
|
|
|
des++;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
2012-11-02 01:53:44 +01:00
|
|
|
* ROUTINE : vp8_horizontal_line_1_2_scale_c
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
|
|
|
* INPUTS : const unsigned char *source : Pointer to source data.
|
2016-07-25 23:32:36 +02:00
|
|
|
* unsigned int source_width : Stride of source.
|
2010-05-18 17:58:33 +02:00
|
|
|
* unsigned char *dest : Pointer to destination data.
|
2016-07-25 23:32:36 +02:00
|
|
|
* unsigned int dest_width : Stride of dest (UNUSED).
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
|
|
|
* OUTPUTS : None.
|
|
|
|
*
|
|
|
|
* RETURNS : void
|
|
|
|
*
|
|
|
|
* FUNCTION : Copies horizontal line of pixels from source to
|
|
|
|
* destination scaling up by 1 to 2.
|
|
|
|
*
|
|
|
|
* SPECIAL NOTES : None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2012-11-02 01:53:44 +01:00
|
|
|
void vp8_horizontal_line_2_1_scale_c(const unsigned char *source,
|
|
|
|
unsigned int source_width,
|
|
|
|
unsigned char *dest,
|
|
|
|
unsigned int dest_width) {
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int a;
|
|
|
|
unsigned char *des = dest;
|
|
|
|
const unsigned char *src = source;
|
|
|
|
|
2016-07-25 23:32:36 +02:00
|
|
|
(void)dest_width;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < source_width; i += 2) {
|
|
|
|
a = src[0];
|
2016-07-25 23:32:36 +02:00
|
|
|
des[0] = (unsigned char)(a);
|
2012-07-14 00:21:29 +02:00
|
|
|
src += 2;
|
|
|
|
des += 1;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2012-11-02 01:53:44 +01:00
|
|
|
|
|
|
|
void vp8_vertical_band_2_1_scale_c(unsigned char *source,
|
2016-07-25 23:32:36 +02:00
|
|
|
unsigned int src_pitch, unsigned char *dest,
|
2012-11-02 01:53:44 +01:00
|
|
|
unsigned int dest_pitch,
|
|
|
|
unsigned int dest_width) {
|
2016-07-25 23:32:36 +02:00
|
|
|
(void)dest_pitch;
|
|
|
|
(void)src_pitch;
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(dest, source, dest_width);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-11-02 01:53:44 +01:00
|
|
|
void vp8_vertical_band_2_1_scale_i_c(unsigned char *source,
|
|
|
|
unsigned int src_pitch,
|
|
|
|
unsigned char *dest,
|
|
|
|
unsigned int dest_pitch,
|
|
|
|
unsigned int dest_width) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
|
|
|
int temp;
|
|
|
|
int width = dest_width;
|
|
|
|
|
2016-07-25 23:32:36 +02:00
|
|
|
(void)dest_pitch;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
temp = 8;
|
|
|
|
temp += source[i - (int)src_pitch] * 3;
|
|
|
|
temp += source[i] * 10;
|
|
|
|
temp += source[i + src_pitch] * 3;
|
|
|
|
temp >>= 4;
|
|
|
|
dest[i] = (unsigned char)(temp);
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|