Merge "makefile: fix error message due to missing quotes"
[libvpx.git] / vp8 / common / extend.c
blob74079527cce5be037da983881d74a10fd5cc12cc
1 /*
2 * Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license and patent
5 * grant that can be found in the LICENSE file in the root of the source
6 * tree. All contributing project authors may be found in the AUTHORS
7 * file in the root of the source tree.
8 */
11 #include "extend.h"
12 #include "vpx_mem/vpx_mem.h"
15 static void extend_plane_borders
17 unsigned char *s, // source
18 int sp, // pitch
19 int h, // height
20 int w, // width
21 int et, // extend top border
22 int el, // extend left border
23 int eb, // extend bottom border
24 int er // extend right border
28 int i;
29 unsigned char *src_ptr1, *src_ptr2;
30 unsigned char *dest_ptr1, *dest_ptr2;
31 int linesize;
33 // copy the left and right most columns out
34 src_ptr1 = s;
35 src_ptr2 = s + w - 1;
36 dest_ptr1 = s - el;
37 dest_ptr2 = s + w;
39 for (i = 0; i < h - 0 + 1; i++)
41 vpx_memset(dest_ptr1, src_ptr1[0], el);
42 vpx_memset(dest_ptr2, src_ptr2[0], er);
43 src_ptr1 += sp;
44 src_ptr2 += sp;
45 dest_ptr1 += sp;
46 dest_ptr2 += sp;
49 // Now copy the top and bottom source lines into each line of the respective borders
50 src_ptr1 = s - el;
51 src_ptr2 = s + sp * (h - 1) - el;
52 dest_ptr1 = s + sp * (-et) - el;
53 dest_ptr2 = s + sp * (h) - el;
54 linesize = el + er + w + 1;
56 for (i = 0; i < (int)et; i++)
58 vpx_memcpy(dest_ptr1, src_ptr1, linesize);
59 dest_ptr1 += sp;
62 for (i = 0; i < (int)eb; i++)
64 vpx_memcpy(dest_ptr2, src_ptr2, linesize);
65 dest_ptr2 += sp;
70 void vp8_extend_to_multiple_of16(YV12_BUFFER_CONFIG *ybf, int width, int height)
72 int er = 0xf & (16 - (width & 0xf));
73 int eb = 0xf & (16 - (height & 0xf));
75 // check for non multiples of 16
76 if (er != 0 || eb != 0)
78 extend_plane_borders(ybf->y_buffer, ybf->y_stride, height, width, 0, 0, eb, er);
80 //adjust for uv
81 height = (height + 1) >> 1;
82 width = (width + 1) >> 1;
83 er = 0x7 & (8 - (width & 0x7));
84 eb = 0x7 & (8 - (height & 0x7));
86 if (er || eb)
88 extend_plane_borders(ybf->u_buffer, ybf->uv_stride, height, width, 0, 0, eb, er);
89 extend_plane_borders(ybf->v_buffer, ybf->uv_stride, height, width, 0, 0, eb, er);
94 // note the extension is only for the last row, for intra prediction purpose
95 void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf, unsigned char *YPtr, unsigned char *UPtr, unsigned char *VPtr)
97 int i;
99 YPtr += ybf->y_stride * 14;
100 UPtr += ybf->uv_stride * 6;
101 VPtr += ybf->uv_stride * 6;
103 for (i = 0; i < 4; i++)
105 YPtr[i] = YPtr[-1];
106 UPtr[i] = UPtr[-1];
107 VPtr[i] = VPtr[-1];
110 YPtr += ybf->y_stride;
111 UPtr += ybf->uv_stride;
112 VPtr += ybf->uv_stride;
114 for (i = 0; i < 4; i++)
116 YPtr[i] = YPtr[-1];
117 UPtr[i] = UPtr[-1];
118 VPtr[i] = VPtr[-1];