Commit 5724b7e2 authored by James Zern's avatar James Zern
Browse files

yv12extend: name variables consistently

- s|source -> src
- dest -> dst
- use verbose names in extend_plane dropping the redundant comments

+ light cosmetics:
- join a few lines / assignments
- drop some unnecessary comments & includes

Change-Id: I6d979a85a0223a0a79a22f79a6d9c7512fd04532
Showing with 64 additions and 99 deletions
...@@ -10,67 +10,52 @@ ...@@ -10,67 +10,52 @@
#include <assert.h> #include <assert.h>
#include "./vpx_config.h" #include "./vpx_config.h"
#include "vpx_scale/yv12config.h" #include "vpx/vpx_integer.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vpx_scale/vpx_scale.h" #include "vpx_scale/yv12config.h"
/****************************************************************************
* Exports
****************************************************************************/
/**************************************************************************** static void extend_plane(uint8_t *src, int src_stride,
* int width, int height,
****************************************************************************/ int extend_top, int extend_left,
static void extend_plane(uint8_t *s, /* source */ int extend_bottom, int extend_right) {
int sp, /* source pitch */
int w, /* width */
int h, /* height */
int et, /* extend top border */
int el, /* extend left border */
int eb, /* extend bottom border */
int er) { /* extend right border */
int i; int i;
uint8_t *src_ptr1, *src_ptr2; const int linesize = extend_left + extend_right + width;
uint8_t *dest_ptr1, *dest_ptr2;
int linesize;
/* copy the left and right most columns out */ /* copy the left and right most columns out */
src_ptr1 = s; uint8_t *src_ptr1 = src;
src_ptr2 = s + w - 1; uint8_t *src_ptr2 = src + width - 1;
dest_ptr1 = s - el; uint8_t *dst_ptr1 = src - extend_left;
dest_ptr2 = s + w; uint8_t *dst_ptr2 = src + width;
for (i = 0; i < h; i++) { for (i = 0; i < height; ++i) {
vpx_memset(dest_ptr1, src_ptr1[0], el); vpx_memset(dst_ptr1, src_ptr1[0], extend_left);
vpx_memset(dest_ptr2, src_ptr2[0], er); vpx_memset(dst_ptr2, src_ptr2[0], extend_right);
src_ptr1 += sp; src_ptr1 += src_stride;
src_ptr2 += sp; src_ptr2 += src_stride;
dest_ptr1 += sp; dst_ptr1 += src_stride;
dest_ptr2 += sp; dst_ptr2 += src_stride;
} }
/* Now copy the top and bottom lines into each line of the respective /* Now copy the top and bottom lines into each line of the respective
* borders * borders
*/ */
src_ptr1 = s - el; src_ptr1 = src - extend_left;
src_ptr2 = s + sp * (h - 1) - el; src_ptr2 = src + src_stride * (height - 1) - extend_left;
dest_ptr1 = s + sp * (-et) - el; dst_ptr1 = src + src_stride * -extend_top - extend_left;
dest_ptr2 = s + sp * (h) - el; dst_ptr2 = src + src_stride * height - extend_left;
linesize = el + er + w;
for (i = 0; i < extend_top; ++i) {
for (i = 0; i < et; i++) { vpx_memcpy(dst_ptr1, src_ptr1, linesize);
vpx_memcpy(dest_ptr1, src_ptr1, linesize); dst_ptr1 += src_stride;
dest_ptr1 += sp;
} }
for (i = 0; i < eb; i++) { for (i = 0; i < extend_bottom; ++i) {
vpx_memcpy(dest_ptr2, src_ptr2, linesize); vpx_memcpy(dst_ptr2, src_ptr2, linesize);
dest_ptr2 += sp; dst_ptr2 += src_stride;
} }
} }
void void vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
assert(ybf->y_height - ybf->y_crop_height < 16); assert(ybf->y_height - ybf->y_crop_height < 16);
assert(ybf->y_width - ybf->y_crop_width < 16); assert(ybf->y_width - ybf->y_crop_width < 16);
assert(ybf->y_height - ybf->y_crop_height >= 0); assert(ybf->y_height - ybf->y_crop_height >= 0);
...@@ -96,9 +81,9 @@ vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) { ...@@ -96,9 +81,9 @@ vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
} }
#if CONFIG_VP9 #if CONFIG_VP9
static void extend_frame(YV12_BUFFER_CONFIG *ybf, static void extend_frame(YV12_BUFFER_CONFIG *const ybf,
int subsampling_x, int subsampling_y, int subsampling_x, int subsampling_y,
int ext_size) { int ext_size) {
const int c_w = (ybf->y_crop_width + subsampling_x) >> subsampling_x; const int c_w = (ybf->y_crop_width + subsampling_x) >> subsampling_x;
const int c_h = (ybf->y_crop_height + subsampling_y) >> subsampling_y; const int c_h = (ybf->y_crop_height + subsampling_y) >> subsampling_y;
const int c_et = ext_size >> subsampling_y; const int c_et = ext_size >> subsampling_y;
...@@ -126,7 +111,6 @@ static void extend_frame(YV12_BUFFER_CONFIG *ybf, ...@@ -126,7 +111,6 @@ static void extend_frame(YV12_BUFFER_CONFIG *ybf,
c_w, c_h, c_et, c_el, c_eb, c_er); c_w, c_h, c_et, c_el, c_eb, c_er);
} }
void vp9_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, void vp9_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf,
int subsampling_x, int subsampling_y) { int subsampling_x, int subsampling_y) {
extend_frame(ybf, subsampling_x, subsampling_y, ybf->border); extend_frame(ybf, subsampling_x, subsampling_y, ybf->border);
...@@ -138,29 +122,16 @@ void vp9_extend_frame_inner_borders_c(YV12_BUFFER_CONFIG *ybf, ...@@ -138,29 +122,16 @@ void vp9_extend_frame_inner_borders_c(YV12_BUFFER_CONFIG *ybf,
VP9INNERBORDERINPIXELS : ybf->border; VP9INNERBORDERINPIXELS : ybf->border;
extend_frame(ybf, subsampling_x, subsampling_y, inner_bw); extend_frame(ybf, subsampling_x, subsampling_y, inner_bw);
} }
#endif #endif // CONFIG_VP9
/**************************************************************************** // Copies the source image into the destination image and updates the
* // destination's UMV borders.
* ROUTINE : vp8_yv12_copy_frame // Note: The frames are assumed to be identical in size.
* void vp8_yv12_copy_frame_c(YV12_BUFFER_CONFIG *src_ybc,
* INPUTS : YV12_BUFFER_CONFIG *dst_ybc) {
*
* OUTPUTS : None.
*
* RETURNS : void
*
* FUNCTION : Copies the source image into the destination image and
* updates the destination's UMV borders.
*
* SPECIAL NOTES : The frames are assumed to be identical in size.
*
****************************************************************************/
void
vp8_yv12_copy_frame_c(YV12_BUFFER_CONFIG *src_ybc,
YV12_BUFFER_CONFIG *dst_ybc) {
int row; int row;
unsigned char *source, *dest; const uint8_t *src = src_ybc->y_buffer;
uint8_t *dst = dst_ybc->y_buffer;
#if 0 #if 0
/* These assertions are valid in the codec, but the libvpx-tester uses /* These assertions are valid in the codec, but the libvpx-tester uses
...@@ -170,31 +141,28 @@ vp8_yv12_copy_frame_c(YV12_BUFFER_CONFIG *src_ybc, ...@@ -170,31 +141,28 @@ vp8_yv12_copy_frame_c(YV12_BUFFER_CONFIG *src_ybc,
assert(src_ybc->y_height == dst_ybc->y_height); assert(src_ybc->y_height == dst_ybc->y_height);
#endif #endif
source = src_ybc->y_buffer; for (row = 0; row < src_ybc->y_height; ++row) {
dest = dst_ybc->y_buffer; vpx_memcpy(dst, src, src_ybc->y_width);
src += src_ybc->y_stride;
for (row = 0; row < src_ybc->y_height; row++) { dst += dst_ybc->y_stride;
vpx_memcpy(dest, source, src_ybc->y_width);
source += src_ybc->y_stride;
dest += dst_ybc->y_stride;
} }
source = src_ybc->u_buffer; src = src_ybc->u_buffer;
dest = dst_ybc->u_buffer; dst = dst_ybc->u_buffer;
for (row = 0; row < src_ybc->uv_height; row++) { for (row = 0; row < src_ybc->uv_height; ++row) {
vpx_memcpy(dest, source, src_ybc->uv_width); vpx_memcpy(dst, src, src_ybc->uv_width);
source += src_ybc->uv_stride; src += src_ybc->uv_stride;
dest += dst_ybc->uv_stride; dst += dst_ybc->uv_stride;
} }
source = src_ybc->v_buffer; src = src_ybc->v_buffer;
dest = dst_ybc->v_buffer; dst = dst_ybc->v_buffer;
for (row = 0; row < src_ybc->uv_height; row++) { for (row = 0; row < src_ybc->uv_height; ++row) {
vpx_memcpy(dest, source, src_ybc->uv_width); vpx_memcpy(dst, src, src_ybc->uv_width);
source += src_ybc->uv_stride; src += src_ybc->uv_stride;
dest += dst_ybc->uv_stride; dst += dst_ybc->uv_stride;
} }
vp8_yv12_extend_frame_borders_c(dst_ybc); vp8_yv12_extend_frame_borders_c(dst_ybc);
...@@ -203,15 +171,12 @@ vp8_yv12_copy_frame_c(YV12_BUFFER_CONFIG *src_ybc, ...@@ -203,15 +171,12 @@ vp8_yv12_copy_frame_c(YV12_BUFFER_CONFIG *src_ybc,
void vpx_yv12_copy_y_c(YV12_BUFFER_CONFIG *src_ybc, void vpx_yv12_copy_y_c(YV12_BUFFER_CONFIG *src_ybc,
YV12_BUFFER_CONFIG *dst_ybc) { YV12_BUFFER_CONFIG *dst_ybc) {
int row; int row;
unsigned char *source, *dest; const uint8_t *src = src_ybc->y_buffer;
uint8_t *dst = dst_ybc->y_buffer;
source = src_ybc->y_buffer;
dest = dst_ybc->y_buffer;
for (row = 0; row < src_ybc->y_height; row++) { for (row = 0; row < src_ybc->y_height; ++row) {
vpx_memcpy(dest, source, src_ybc->y_width); vpx_memcpy(dst, src, src_ybc->y_width);
source += src_ybc->y_stride; src += src_ybc->y_stride;
dest += dst_ybc->y_stride; dst += dst_ybc->y_stride;
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment