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
,
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 /* 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
)
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
++)
121 YPtr
+= ybf
->y_stride
;
122 UPtr
+= ybf
->uv_stride
;
123 VPtr
+= ybf
->uv_stride
;
125 for (i
= 0; i
< 4; i
++)