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.
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 */
24
int et, /* extend top border */
25
int el, /* extend left border */
26
int eb, /* extend bottom border */
27
int er /* extend right border */
31
unsigned char *src_ptr1, *src_ptr2;
32
unsigned char *dest_ptr1, *dest_ptr2;
35
/* copy the left and right most columns out */
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);
52
/* Now copy the top and bottom lines into each line of the respective
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);
67
for (i = 0; i < eb; i++)
69
vpx_memcpy(dest_ptr2, src_ptr2, linesize);
75
void vp8_copy_and_extend_frame(YV12_BUFFER_CONFIG *src,
76
YV12_BUFFER_CONFIG *dst)
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,
88
et = dst->border >> 1;
89
el = dst->border >> 1;
90
eb = (dst->border >> 1) + dst->uv_height - src->uv_height;
91
er = (dst->border >> 1) + dst->uv_width - src->uv_width;
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,
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,
105
void vp8_copy_and_extend_frame_with_rect(YV12_BUFFER_CONFIG *src,
106
YV12_BUFFER_CONFIG *dst,
110
int et = dst->border;
111
int el = dst->border;
112
int eb = dst->border + dst->y_height - src->y_height;
113
int er = dst->border + dst->y_width - src->y_width;
114
int src_y_offset = srcy * src->y_stride + srcx;
115
int dst_y_offset = srcy * dst->y_stride + srcx;
116
int src_uv_offset = ((srcy * src->uv_stride) >> 1) + (srcx >> 1);
117
int dst_uv_offset = ((srcy * dst->uv_stride) >> 1) + (srcx >> 1);
119
/* If the side is not touching the bounder then don't extend. */
124
if (srcy + srch != src->y_height)
126
if (srcx + srcw != src->y_width)
129
copy_and_extend_plane(src->y_buffer + src_y_offset,
131
dst->y_buffer + dst_y_offset,
140
srch = (srch + 1) >> 1;
141
srcw = (srcw + 1) >> 1;
143
copy_and_extend_plane(src->u_buffer + src_uv_offset,
145
dst->u_buffer + dst_uv_offset,
150
copy_and_extend_plane(src->v_buffer + src_uv_offset,
152
dst->v_buffer + dst_uv_offset,
159
/* note the extension is only for the last row, for intra prediction purpose */
160
void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf,
167
YPtr += ybf->y_stride * 14;
168
UPtr += ybf->uv_stride * 6;
169
VPtr += ybf->uv_stride * 6;
171
for (i = 0; i < 4; i++)
178
YPtr += ybf->y_stride;
179
UPtr += ybf->uv_stride;
180
VPtr += ybf->uv_stride;
182
for (i = 0; i < 4; i++)