Merge "keep values in registers during quantization"
[libvpx.git] / vp8 / common / extend.c
blob036bafc5d02c59a5a920e422425b94a8e91d8e23
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
12 #include "extend.h"
13 #include "vpx_mem/vpx_mem.h"
16 static void copy_and_extend_plane
18 unsigned char *s, /* source */
19 int sp, /* source pitch */
20 unsigned char *d, /* destination */
21 int dp, /* destination pitch */
22 int h, /* height */
23 int w, /* width */
24 int et, /* extend top border */
25 int el, /* extend left border */
26 int eb, /* extend bottom border */
27 int er /* extend right border */
30 int i;
31 unsigned char *src_ptr1, *src_ptr2;
32 unsigned char *dest_ptr1, *dest_ptr2;
33 int linesize;
35 /* copy the left and right most columns out */
36 src_ptr1 = s;
37 src_ptr2 = s + w - 1;
38 dest_ptr1 = d - el;
39 dest_ptr2 = d + w;
41 for (i = 0; i < h; i++)
43 vpx_memset(dest_ptr1, src_ptr1[0], el);
44 vpx_memcpy(dest_ptr1 + el, src_ptr1, w);
45 vpx_memset(dest_ptr2, src_ptr2[0], er);
46 src_ptr1 += sp;
47 src_ptr2 += sp;
48 dest_ptr1 += dp;
49 dest_ptr2 += dp;
52 /* Now copy the top and bottom lines into each line of the respective
53 * borders
55 src_ptr1 = d - el;
56 src_ptr2 = d + dp * (h - 1) - el;
57 dest_ptr1 = d + dp * (-et) - el;
58 dest_ptr2 = d + dp * (h) - el;
59 linesize = el + er + w;
61 for (i = 0; i < et; i++)
63 vpx_memcpy(dest_ptr1, src_ptr1, linesize);
64 dest_ptr1 += dp;
67 for (i = 0; i < eb; i++)
69 vpx_memcpy(dest_ptr2, src_ptr2, linesize);
70 dest_ptr2 += dp;
75 void vp8_copy_and_extend_frame(YV12_BUFFER_CONFIG *src,
76 YV12_BUFFER_CONFIG *dst)
78 int et = dst->border;
79 int el = dst->border;
80 int eb = dst->border + dst->y_height - src->y_height;
81 int er = dst->border + dst->y_width - src->y_width;
83 copy_and_extend_plane(src->y_buffer, src->y_stride,
84 dst->y_buffer, dst->y_stride,
85 src->y_height, src->y_width,
86 et, el, eb, er);
88 et = (et + 1) >> 1;
89 el = (el + 1) >> 1;
90 eb = (eb + 1) >> 1;
91 er = (er + 1) >> 1;
93 copy_and_extend_plane(src->u_buffer, src->uv_stride,
94 dst->u_buffer, dst->uv_stride,
95 src->uv_height, src->uv_width,
96 et, el, eb, er);
98 copy_and_extend_plane(src->v_buffer, src->uv_stride,
99 dst->v_buffer, dst->uv_stride,
100 src->uv_height, src->uv_width,
101 et, el, eb, er);
105 /* note the extension is only for the last row, for intra prediction purpose */
106 void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf, unsigned char *YPtr, unsigned char *UPtr, unsigned char *VPtr)
108 int i;
110 YPtr += ybf->y_stride * 14;
111 UPtr += ybf->uv_stride * 6;
112 VPtr += ybf->uv_stride * 6;
114 for (i = 0; i < 4; i++)
116 YPtr[i] = YPtr[-1];
117 UPtr[i] = UPtr[-1];
118 VPtr[i] = VPtr[-1];
121 YPtr += ybf->y_stride;
122 UPtr += ybf->uv_stride;
123 VPtr += ybf->uv_stride;
125 for (i = 0; i < 4; i++)
127 YPtr[i] = YPtr[-1];
128 UPtr[i] = UPtr[-1];
129 VPtr[i] = VPtr[-1];