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.
12 #include "vpx_mem/vpx_mem.h"
15 static void extend_plane_borders
17 unsigned char *s
, // source
21 int et
, // extend top border
22 int el
, // extend left border
23 int eb
, // extend bottom border
24 int er
// extend right border
29 unsigned char *src_ptr1
, *src_ptr2
;
30 unsigned char *dest_ptr1
, *dest_ptr2
;
33 // copy the left and right most columns out
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
);
49 // Now copy the top and bottom source lines into each line of the respective borders
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
);
62 for (i
= 0; i
< (int)eb
; i
++)
64 vpx_memcpy(dest_ptr2
, src_ptr2
, linesize
);
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
);
81 height
= (height
+ 1) >> 1;
82 width
= (width
+ 1) >> 1;
83 er
= 0x7 & (8 - (width
& 0x7));
84 eb
= 0x7 & (8 - (height
& 0x7));
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
)
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
++)
110 YPtr
+= ybf
->y_stride
;
111 UPtr
+= ybf
->uv_stride
;
112 VPtr
+= ybf
->uv_stride
;
114 for (i
= 0; i
< 4; i
++)