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 extend_plane_borders
18 unsigned char *s
, /* source */
22 int et
, /* extend top border */
23 int el
, /* extend left border */
24 int eb
, /* extend bottom border */
25 int er
/* extend right border */
30 unsigned char *src_ptr1
, *src_ptr2
;
31 unsigned char *dest_ptr1
, *dest_ptr2
;
34 /* copy the left and right most columns out */
40 for (i
= 0; i
< h
- 0 + 1; i
++)
42 /* Some linkers will complain if we call vpx_memset with el set to a
46 vpx_memset(dest_ptr1
, src_ptr1
[0], el
);
47 vpx_memset(dest_ptr2
, src_ptr2
[0], er
);
54 /* Now copy the top and bottom source lines into each line of the respective borders */
56 src_ptr2
= s
+ sp
* (h
- 1) - el
;
57 dest_ptr1
= s
+ sp
* (-et
) - el
;
58 dest_ptr2
= s
+ sp
* (h
) - el
;
59 linesize
= el
+ er
+ w
+ 1;
61 for (i
= 0; i
< (int)et
; i
++)
63 vpx_memcpy(dest_ptr1
, src_ptr1
, linesize
);
67 for (i
= 0; i
< (int)eb
; i
++)
69 vpx_memcpy(dest_ptr2
, src_ptr2
, linesize
);
75 void vp8_extend_to_multiple_of16(YV12_BUFFER_CONFIG
*ybf
, int width
, int height
)
77 int er
= 0xf & (16 - (width
& 0xf));
78 int eb
= 0xf & (16 - (height
& 0xf));
80 /* check for non multiples of 16 */
81 if (er
!= 0 || eb
!= 0)
83 extend_plane_borders(ybf
->y_buffer
, ybf
->y_stride
, height
, width
, 0, 0, eb
, er
);
86 height
= (height
+ 1) >> 1;
87 width
= (width
+ 1) >> 1;
88 er
= 0x7 & (8 - (width
& 0x7));
89 eb
= 0x7 & (8 - (height
& 0x7));
93 extend_plane_borders(ybf
->u_buffer
, ybf
->uv_stride
, height
, width
, 0, 0, eb
, er
);
94 extend_plane_borders(ybf
->v_buffer
, ybf
->uv_stride
, height
, width
, 0, 0, eb
, er
);
99 /* note the extension is only for the last row, for intra prediction purpose */
100 void vp8_extend_mb_row(YV12_BUFFER_CONFIG
*ybf
, unsigned char *YPtr
, unsigned char *UPtr
, unsigned char *VPtr
)
104 YPtr
+= ybf
->y_stride
* 14;
105 UPtr
+= ybf
->uv_stride
* 6;
106 VPtr
+= ybf
->uv_stride
* 6;
108 for (i
= 0; i
< 4; i
++)
115 YPtr
+= ybf
->y_stride
;
116 UPtr
+= ybf
->uv_stride
;
117 VPtr
+= ybf
->uv_stride
;
119 for (i
= 0; i
< 4; i
++)