1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <assert.h>
13*77c1e3ccSAndroid Build Coastguard Worker
14*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
15*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_scale_rtcd.h"
16*77c1e3ccSAndroid Build Coastguard Worker
17*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_integer.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "aom_mem/aom_mem.h"
19*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/mem.h"
20*77c1e3ccSAndroid Build Coastguard Worker #include "aom_scale/yv12config.h"
21*77c1e3ccSAndroid Build Coastguard Worker
extend_plane(uint8_t * const src,int src_stride,int width,int height,int extend_top,int extend_left,int extend_bottom,int extend_right,int v_start,int v_end)22*77c1e3ccSAndroid Build Coastguard Worker static void extend_plane(uint8_t *const src, int src_stride, int width,
23*77c1e3ccSAndroid Build Coastguard Worker int height, int extend_top, int extend_left,
24*77c1e3ccSAndroid Build Coastguard Worker int extend_bottom, int extend_right, int v_start,
25*77c1e3ccSAndroid Build Coastguard Worker int v_end) {
26*77c1e3ccSAndroid Build Coastguard Worker assert(src != NULL);
27*77c1e3ccSAndroid Build Coastguard Worker int i;
28*77c1e3ccSAndroid Build Coastguard Worker const int linesize = extend_left + extend_right + width;
29*77c1e3ccSAndroid Build Coastguard Worker assert(linesize <= src_stride);
30*77c1e3ccSAndroid Build Coastguard Worker
31*77c1e3ccSAndroid Build Coastguard Worker /* copy the left and right most columns out */
32*77c1e3ccSAndroid Build Coastguard Worker uint8_t *src_ptr1 = src + v_start * src_stride;
33*77c1e3ccSAndroid Build Coastguard Worker uint8_t *src_ptr2 = src + v_start * src_stride + width - 1;
34*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst_ptr1 = src + v_start * src_stride - extend_left;
35*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst_ptr2 = src_ptr2 + 1;
36*77c1e3ccSAndroid Build Coastguard Worker
37*77c1e3ccSAndroid Build Coastguard Worker for (i = v_start; i < v_end; ++i) {
38*77c1e3ccSAndroid Build Coastguard Worker memset(dst_ptr1, src_ptr1[0], extend_left);
39*77c1e3ccSAndroid Build Coastguard Worker memset(dst_ptr2, src_ptr2[0], extend_right);
40*77c1e3ccSAndroid Build Coastguard Worker src_ptr1 += src_stride;
41*77c1e3ccSAndroid Build Coastguard Worker src_ptr2 += src_stride;
42*77c1e3ccSAndroid Build Coastguard Worker dst_ptr1 += src_stride;
43*77c1e3ccSAndroid Build Coastguard Worker dst_ptr2 += src_stride;
44*77c1e3ccSAndroid Build Coastguard Worker }
45*77c1e3ccSAndroid Build Coastguard Worker
46*77c1e3ccSAndroid Build Coastguard Worker /* Now copy the top and bottom lines into each line of the respective
47*77c1e3ccSAndroid Build Coastguard Worker * borders
48*77c1e3ccSAndroid Build Coastguard Worker */
49*77c1e3ccSAndroid Build Coastguard Worker src_ptr1 = src - extend_left;
50*77c1e3ccSAndroid Build Coastguard Worker dst_ptr1 = src_ptr1 + src_stride * -extend_top;
51*77c1e3ccSAndroid Build Coastguard Worker
52*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < extend_top; ++i) {
53*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst_ptr1, src_ptr1, linesize);
54*77c1e3ccSAndroid Build Coastguard Worker dst_ptr1 += src_stride;
55*77c1e3ccSAndroid Build Coastguard Worker }
56*77c1e3ccSAndroid Build Coastguard Worker
57*77c1e3ccSAndroid Build Coastguard Worker src_ptr2 = src_ptr1 + src_stride * (height - 1);
58*77c1e3ccSAndroid Build Coastguard Worker dst_ptr2 = src_ptr2;
59*77c1e3ccSAndroid Build Coastguard Worker
60*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < extend_bottom; ++i) {
61*77c1e3ccSAndroid Build Coastguard Worker dst_ptr2 += src_stride;
62*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst_ptr2, src_ptr2, linesize);
63*77c1e3ccSAndroid Build Coastguard Worker }
64*77c1e3ccSAndroid Build Coastguard Worker }
65*77c1e3ccSAndroid Build Coastguard Worker
66*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
extend_plane_high(uint8_t * const src8,int src_stride,int width,int height,int extend_top,int extend_left,int extend_bottom,int extend_right,int v_start,int v_end)67*77c1e3ccSAndroid Build Coastguard Worker static void extend_plane_high(uint8_t *const src8, int src_stride, int width,
68*77c1e3ccSAndroid Build Coastguard Worker int height, int extend_top, int extend_left,
69*77c1e3ccSAndroid Build Coastguard Worker int extend_bottom, int extend_right, int v_start,
70*77c1e3ccSAndroid Build Coastguard Worker int v_end) {
71*77c1e3ccSAndroid Build Coastguard Worker int i;
72*77c1e3ccSAndroid Build Coastguard Worker const int linesize = extend_left + extend_right + width;
73*77c1e3ccSAndroid Build Coastguard Worker assert(linesize <= src_stride);
74*77c1e3ccSAndroid Build Coastguard Worker uint16_t *src = CONVERT_TO_SHORTPTR(src8);
75*77c1e3ccSAndroid Build Coastguard Worker
76*77c1e3ccSAndroid Build Coastguard Worker /* copy the left and right most columns out */
77*77c1e3ccSAndroid Build Coastguard Worker uint16_t *src_ptr1 = src + v_start * src_stride;
78*77c1e3ccSAndroid Build Coastguard Worker uint16_t *src_ptr2 = src + v_start * src_stride + width - 1;
79*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst_ptr1 = src + v_start * src_stride - extend_left;
80*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst_ptr2 = src_ptr2 + 1;
81*77c1e3ccSAndroid Build Coastguard Worker
82*77c1e3ccSAndroid Build Coastguard Worker for (i = v_start; i < v_end; ++i) {
83*77c1e3ccSAndroid Build Coastguard Worker aom_memset16(dst_ptr1, src_ptr1[0], extend_left);
84*77c1e3ccSAndroid Build Coastguard Worker aom_memset16(dst_ptr2, src_ptr2[0], extend_right);
85*77c1e3ccSAndroid Build Coastguard Worker src_ptr1 += src_stride;
86*77c1e3ccSAndroid Build Coastguard Worker src_ptr2 += src_stride;
87*77c1e3ccSAndroid Build Coastguard Worker dst_ptr1 += src_stride;
88*77c1e3ccSAndroid Build Coastguard Worker dst_ptr2 += src_stride;
89*77c1e3ccSAndroid Build Coastguard Worker }
90*77c1e3ccSAndroid Build Coastguard Worker
91*77c1e3ccSAndroid Build Coastguard Worker /* Now copy the top and bottom lines into each line of the respective
92*77c1e3ccSAndroid Build Coastguard Worker * borders
93*77c1e3ccSAndroid Build Coastguard Worker */
94*77c1e3ccSAndroid Build Coastguard Worker src_ptr1 = src - extend_left;
95*77c1e3ccSAndroid Build Coastguard Worker dst_ptr1 = src_ptr1 + src_stride * -extend_top;
96*77c1e3ccSAndroid Build Coastguard Worker
97*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < extend_top; ++i) {
98*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst_ptr1, src_ptr1, linesize * sizeof(uint16_t));
99*77c1e3ccSAndroid Build Coastguard Worker dst_ptr1 += src_stride;
100*77c1e3ccSAndroid Build Coastguard Worker }
101*77c1e3ccSAndroid Build Coastguard Worker
102*77c1e3ccSAndroid Build Coastguard Worker src_ptr2 = src_ptr1 + src_stride * (height - 1);
103*77c1e3ccSAndroid Build Coastguard Worker dst_ptr2 = src_ptr2;
104*77c1e3ccSAndroid Build Coastguard Worker
105*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < extend_bottom; ++i) {
106*77c1e3ccSAndroid Build Coastguard Worker dst_ptr2 += src_stride;
107*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst_ptr2, src_ptr2, linesize * sizeof(uint16_t));
108*77c1e3ccSAndroid Build Coastguard Worker }
109*77c1e3ccSAndroid Build Coastguard Worker }
110*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_HIGHBITDEPTH
111*77c1e3ccSAndroid Build Coastguard Worker
aom_extend_frame_borders_plane_row_c(const YV12_BUFFER_CONFIG * ybf,int plane,int v_start,int v_end)112*77c1e3ccSAndroid Build Coastguard Worker void aom_extend_frame_borders_plane_row_c(const YV12_BUFFER_CONFIG *ybf,
113*77c1e3ccSAndroid Build Coastguard Worker int plane, int v_start, int v_end) {
114*77c1e3ccSAndroid Build Coastguard Worker const int ext_size = ybf->border;
115*77c1e3ccSAndroid Build Coastguard Worker const int ss_x = ybf->subsampling_x;
116*77c1e3ccSAndroid Build Coastguard Worker const int ss_y = ybf->subsampling_y;
117*77c1e3ccSAndroid Build Coastguard Worker
118*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_height - ybf->y_crop_height < 16);
119*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_width - ybf->y_crop_width < 16);
120*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_height - ybf->y_crop_height >= 0);
121*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_width - ybf->y_crop_width >= 0);
122*77c1e3ccSAndroid Build Coastguard Worker
123*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = plane > 0;
124*77c1e3ccSAndroid Build Coastguard Worker const int top = ext_size >> (is_uv ? ss_y : 0);
125*77c1e3ccSAndroid Build Coastguard Worker const int left = ext_size >> (is_uv ? ss_x : 0);
126*77c1e3ccSAndroid Build Coastguard Worker const int bottom = top + ybf->heights[is_uv] - ybf->crop_heights[is_uv];
127*77c1e3ccSAndroid Build Coastguard Worker const int right = left + ybf->widths[is_uv] - ybf->crop_widths[is_uv];
128*77c1e3ccSAndroid Build Coastguard Worker const int extend_top_border = (v_start == 0);
129*77c1e3ccSAndroid Build Coastguard Worker const int extend_bottom_border = (v_end == ybf->crop_heights[is_uv]);
130*77c1e3ccSAndroid Build Coastguard Worker
131*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
132*77c1e3ccSAndroid Build Coastguard Worker if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) {
133*77c1e3ccSAndroid Build Coastguard Worker extend_plane_high(ybf->buffers[plane], ybf->strides[is_uv],
134*77c1e3ccSAndroid Build Coastguard Worker ybf->crop_widths[is_uv], ybf->crop_heights[is_uv],
135*77c1e3ccSAndroid Build Coastguard Worker extend_top_border ? top : 0, left,
136*77c1e3ccSAndroid Build Coastguard Worker extend_bottom_border ? bottom : 0, right, v_start, v_end);
137*77c1e3ccSAndroid Build Coastguard Worker return;
138*77c1e3ccSAndroid Build Coastguard Worker }
139*77c1e3ccSAndroid Build Coastguard Worker #endif
140*77c1e3ccSAndroid Build Coastguard Worker
141*77c1e3ccSAndroid Build Coastguard Worker extend_plane(ybf->buffers[plane], ybf->strides[is_uv],
142*77c1e3ccSAndroid Build Coastguard Worker ybf->crop_widths[is_uv], ybf->crop_heights[is_uv],
143*77c1e3ccSAndroid Build Coastguard Worker extend_top_border ? top : 0, left,
144*77c1e3ccSAndroid Build Coastguard Worker extend_bottom_border ? bottom : 0, right, v_start, v_end);
145*77c1e3ccSAndroid Build Coastguard Worker }
146*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG * ybf,const int num_planes)147*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf,
148*77c1e3ccSAndroid Build Coastguard Worker const int num_planes) {
149*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->border % 2 == 0);
150*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_height - ybf->y_crop_height < 16);
151*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_width - ybf->y_crop_width < 16);
152*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_height - ybf->y_crop_height >= 0);
153*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_width - ybf->y_crop_width >= 0);
154*77c1e3ccSAndroid Build Coastguard Worker
155*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
156*77c1e3ccSAndroid Build Coastguard Worker if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) {
157*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
158*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = plane > 0;
159*77c1e3ccSAndroid Build Coastguard Worker const int plane_border = ybf->border >> is_uv;
160*77c1e3ccSAndroid Build Coastguard Worker extend_plane_high(
161*77c1e3ccSAndroid Build Coastguard Worker ybf->buffers[plane], ybf->strides[is_uv], ybf->crop_widths[is_uv],
162*77c1e3ccSAndroid Build Coastguard Worker ybf->crop_heights[is_uv], plane_border, plane_border,
163*77c1e3ccSAndroid Build Coastguard Worker plane_border + ybf->heights[is_uv] - ybf->crop_heights[is_uv],
164*77c1e3ccSAndroid Build Coastguard Worker plane_border + ybf->widths[is_uv] - ybf->crop_widths[is_uv], 0,
165*77c1e3ccSAndroid Build Coastguard Worker ybf->crop_heights[is_uv]);
166*77c1e3ccSAndroid Build Coastguard Worker }
167*77c1e3ccSAndroid Build Coastguard Worker return;
168*77c1e3ccSAndroid Build Coastguard Worker }
169*77c1e3ccSAndroid Build Coastguard Worker #endif
170*77c1e3ccSAndroid Build Coastguard Worker
171*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
172*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = plane > 0;
173*77c1e3ccSAndroid Build Coastguard Worker const int plane_border = ybf->border >> is_uv;
174*77c1e3ccSAndroid Build Coastguard Worker extend_plane(ybf->buffers[plane], ybf->strides[is_uv],
175*77c1e3ccSAndroid Build Coastguard Worker ybf->crop_widths[is_uv], ybf->crop_heights[is_uv],
176*77c1e3ccSAndroid Build Coastguard Worker plane_border, plane_border,
177*77c1e3ccSAndroid Build Coastguard Worker plane_border + ybf->heights[is_uv] - ybf->crop_heights[is_uv],
178*77c1e3ccSAndroid Build Coastguard Worker plane_border + ybf->widths[is_uv] - ybf->crop_widths[is_uv], 0,
179*77c1e3ccSAndroid Build Coastguard Worker ybf->crop_heights[is_uv]);
180*77c1e3ccSAndroid Build Coastguard Worker }
181*77c1e3ccSAndroid Build Coastguard Worker }
182*77c1e3ccSAndroid Build Coastguard Worker
extend_frame(YV12_BUFFER_CONFIG * const ybf,int ext_size,const int num_planes)183*77c1e3ccSAndroid Build Coastguard Worker static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size,
184*77c1e3ccSAndroid Build Coastguard Worker const int num_planes) {
185*77c1e3ccSAndroid Build Coastguard Worker const int ss_x = ybf->subsampling_x;
186*77c1e3ccSAndroid Build Coastguard Worker const int ss_y = ybf->subsampling_y;
187*77c1e3ccSAndroid Build Coastguard Worker
188*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_height - ybf->y_crop_height < 16);
189*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_width - ybf->y_crop_width < 16);
190*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_height - ybf->y_crop_height >= 0);
191*77c1e3ccSAndroid Build Coastguard Worker assert(ybf->y_width - ybf->y_crop_width >= 0);
192*77c1e3ccSAndroid Build Coastguard Worker
193*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
194*77c1e3ccSAndroid Build Coastguard Worker if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) {
195*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
196*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = plane > 0;
197*77c1e3ccSAndroid Build Coastguard Worker const int top = ext_size >> (is_uv ? ss_y : 0);
198*77c1e3ccSAndroid Build Coastguard Worker const int left = ext_size >> (is_uv ? ss_x : 0);
199*77c1e3ccSAndroid Build Coastguard Worker const int bottom = top + ybf->heights[is_uv] - ybf->crop_heights[is_uv];
200*77c1e3ccSAndroid Build Coastguard Worker const int right = left + ybf->widths[is_uv] - ybf->crop_widths[is_uv];
201*77c1e3ccSAndroid Build Coastguard Worker extend_plane_high(ybf->buffers[plane], ybf->strides[is_uv],
202*77c1e3ccSAndroid Build Coastguard Worker ybf->crop_widths[is_uv], ybf->crop_heights[is_uv], top,
203*77c1e3ccSAndroid Build Coastguard Worker left, bottom, right, 0, ybf->crop_heights[is_uv]);
204*77c1e3ccSAndroid Build Coastguard Worker }
205*77c1e3ccSAndroid Build Coastguard Worker return;
206*77c1e3ccSAndroid Build Coastguard Worker }
207*77c1e3ccSAndroid Build Coastguard Worker #endif
208*77c1e3ccSAndroid Build Coastguard Worker
209*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
210*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = plane > 0;
211*77c1e3ccSAndroid Build Coastguard Worker const int top = ext_size >> (is_uv ? ss_y : 0);
212*77c1e3ccSAndroid Build Coastguard Worker const int left = ext_size >> (is_uv ? ss_x : 0);
213*77c1e3ccSAndroid Build Coastguard Worker const int bottom = top + ybf->heights[is_uv] - ybf->crop_heights[is_uv];
214*77c1e3ccSAndroid Build Coastguard Worker const int right = left + ybf->widths[is_uv] - ybf->crop_widths[is_uv];
215*77c1e3ccSAndroid Build Coastguard Worker extend_plane(ybf->buffers[plane], ybf->strides[is_uv],
216*77c1e3ccSAndroid Build Coastguard Worker ybf->crop_widths[is_uv], ybf->crop_heights[is_uv], top, left,
217*77c1e3ccSAndroid Build Coastguard Worker bottom, right, 0, ybf->crop_heights[is_uv]);
218*77c1e3ccSAndroid Build Coastguard Worker }
219*77c1e3ccSAndroid Build Coastguard Worker }
220*77c1e3ccSAndroid Build Coastguard Worker
aom_extend_frame_borders_c(YV12_BUFFER_CONFIG * ybf,const int num_planes)221*77c1e3ccSAndroid Build Coastguard Worker void aom_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, const int num_planes) {
222*77c1e3ccSAndroid Build Coastguard Worker extend_frame(ybf, ybf->border, num_planes);
223*77c1e3ccSAndroid Build Coastguard Worker }
224*77c1e3ccSAndroid Build Coastguard Worker
225*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
memcpy_short_addr(uint8_t * dst8,const uint8_t * src8,int num)226*77c1e3ccSAndroid Build Coastguard Worker static void memcpy_short_addr(uint8_t *dst8, const uint8_t *src8, int num) {
227*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
228*77c1e3ccSAndroid Build Coastguard Worker uint16_t *src = CONVERT_TO_SHORTPTR(src8);
229*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst, src, num * sizeof(uint16_t));
230*77c1e3ccSAndroid Build Coastguard Worker }
231*77c1e3ccSAndroid Build Coastguard Worker #endif
232*77c1e3ccSAndroid Build Coastguard Worker
233*77c1e3ccSAndroid Build Coastguard Worker // Copies the source image into the destination image and updates the
234*77c1e3ccSAndroid Build Coastguard Worker // destination's UMV borders.
235*77c1e3ccSAndroid Build Coastguard Worker // Note: The frames are assumed to be identical in size.
aom_yv12_copy_frame_c(const YV12_BUFFER_CONFIG * src_bc,YV12_BUFFER_CONFIG * dst_bc,const int num_planes)236*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_bc,
237*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_bc, const int num_planes) {
238*77c1e3ccSAndroid Build Coastguard Worker assert(src_bc->y_width == dst_bc->y_width);
239*77c1e3ccSAndroid Build Coastguard Worker assert(src_bc->y_height == dst_bc->y_height);
240*77c1e3ccSAndroid Build Coastguard Worker
241*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
242*77c1e3ccSAndroid Build Coastguard Worker assert((src_bc->flags & YV12_FLAG_HIGHBITDEPTH) ==
243*77c1e3ccSAndroid Build Coastguard Worker (dst_bc->flags & YV12_FLAG_HIGHBITDEPTH));
244*77c1e3ccSAndroid Build Coastguard Worker
245*77c1e3ccSAndroid Build Coastguard Worker if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
246*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
247*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *plane_src = src_bc->buffers[plane];
248*77c1e3ccSAndroid Build Coastguard Worker uint8_t *plane_dst = dst_bc->buffers[plane];
249*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = plane > 0;
250*77c1e3ccSAndroid Build Coastguard Worker
251*77c1e3ccSAndroid Build Coastguard Worker for (int row = 0; row < src_bc->heights[is_uv]; ++row) {
252*77c1e3ccSAndroid Build Coastguard Worker memcpy_short_addr(plane_dst, plane_src, src_bc->widths[is_uv]);
253*77c1e3ccSAndroid Build Coastguard Worker plane_src += src_bc->strides[is_uv];
254*77c1e3ccSAndroid Build Coastguard Worker plane_dst += dst_bc->strides[is_uv];
255*77c1e3ccSAndroid Build Coastguard Worker }
256*77c1e3ccSAndroid Build Coastguard Worker }
257*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_extend_frame_borders_c(dst_bc, num_planes);
258*77c1e3ccSAndroid Build Coastguard Worker return;
259*77c1e3ccSAndroid Build Coastguard Worker }
260*77c1e3ccSAndroid Build Coastguard Worker #endif
261*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
262*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *plane_src = src_bc->buffers[plane];
263*77c1e3ccSAndroid Build Coastguard Worker uint8_t *plane_dst = dst_bc->buffers[plane];
264*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = plane > 0;
265*77c1e3ccSAndroid Build Coastguard Worker
266*77c1e3ccSAndroid Build Coastguard Worker for (int row = 0; row < src_bc->heights[is_uv]; ++row) {
267*77c1e3ccSAndroid Build Coastguard Worker memcpy(plane_dst, plane_src, src_bc->widths[is_uv]);
268*77c1e3ccSAndroid Build Coastguard Worker plane_src += src_bc->strides[is_uv];
269*77c1e3ccSAndroid Build Coastguard Worker plane_dst += dst_bc->strides[is_uv];
270*77c1e3ccSAndroid Build Coastguard Worker }
271*77c1e3ccSAndroid Build Coastguard Worker }
272*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_extend_frame_borders_c(dst_bc, num_planes);
273*77c1e3ccSAndroid Build Coastguard Worker }
274*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_copy_y_c(const YV12_BUFFER_CONFIG * src_ybc,YV12_BUFFER_CONFIG * dst_ybc,int use_crop)275*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc,
276*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_ybc, int use_crop) {
277*77c1e3ccSAndroid Build Coastguard Worker int row;
278*77c1e3ccSAndroid Build Coastguard Worker int width = use_crop ? src_ybc->y_crop_width : src_ybc->y_width;
279*77c1e3ccSAndroid Build Coastguard Worker int height = use_crop ? src_ybc->y_crop_height : src_ybc->y_height;
280*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src = src_ybc->y_buffer;
281*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst = dst_ybc->y_buffer;
282*77c1e3ccSAndroid Build Coastguard Worker
283*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
284*77c1e3ccSAndroid Build Coastguard Worker if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) {
285*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
286*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
287*77c1e3ccSAndroid Build Coastguard Worker for (row = 0; row < height; ++row) {
288*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst16, src16, width * sizeof(uint16_t));
289*77c1e3ccSAndroid Build Coastguard Worker src16 += src_ybc->y_stride;
290*77c1e3ccSAndroid Build Coastguard Worker dst16 += dst_ybc->y_stride;
291*77c1e3ccSAndroid Build Coastguard Worker }
292*77c1e3ccSAndroid Build Coastguard Worker return;
293*77c1e3ccSAndroid Build Coastguard Worker }
294*77c1e3ccSAndroid Build Coastguard Worker #endif
295*77c1e3ccSAndroid Build Coastguard Worker
296*77c1e3ccSAndroid Build Coastguard Worker for (row = 0; row < height; ++row) {
297*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst, src, width);
298*77c1e3ccSAndroid Build Coastguard Worker src += src_ybc->y_stride;
299*77c1e3ccSAndroid Build Coastguard Worker dst += dst_ybc->y_stride;
300*77c1e3ccSAndroid Build Coastguard Worker }
301*77c1e3ccSAndroid Build Coastguard Worker }
302*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_copy_u_c(const YV12_BUFFER_CONFIG * src_bc,YV12_BUFFER_CONFIG * dst_bc,int use_crop)303*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_copy_u_c(const YV12_BUFFER_CONFIG *src_bc,
304*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_bc, int use_crop) {
305*77c1e3ccSAndroid Build Coastguard Worker int row;
306*77c1e3ccSAndroid Build Coastguard Worker int width = use_crop ? src_bc->uv_crop_width : src_bc->uv_width;
307*77c1e3ccSAndroid Build Coastguard Worker int height = use_crop ? src_bc->uv_crop_height : src_bc->uv_height;
308*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src = src_bc->u_buffer;
309*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst = dst_bc->u_buffer;
310*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
311*77c1e3ccSAndroid Build Coastguard Worker if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
312*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
313*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
314*77c1e3ccSAndroid Build Coastguard Worker for (row = 0; row < height; ++row) {
315*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst16, src16, width * sizeof(uint16_t));
316*77c1e3ccSAndroid Build Coastguard Worker src16 += src_bc->uv_stride;
317*77c1e3ccSAndroid Build Coastguard Worker dst16 += dst_bc->uv_stride;
318*77c1e3ccSAndroid Build Coastguard Worker }
319*77c1e3ccSAndroid Build Coastguard Worker return;
320*77c1e3ccSAndroid Build Coastguard Worker }
321*77c1e3ccSAndroid Build Coastguard Worker #endif
322*77c1e3ccSAndroid Build Coastguard Worker for (row = 0; row < height; ++row) {
323*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst, src, width);
324*77c1e3ccSAndroid Build Coastguard Worker src += src_bc->uv_stride;
325*77c1e3ccSAndroid Build Coastguard Worker dst += dst_bc->uv_stride;
326*77c1e3ccSAndroid Build Coastguard Worker }
327*77c1e3ccSAndroid Build Coastguard Worker }
328*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_copy_v_c(const YV12_BUFFER_CONFIG * src_bc,YV12_BUFFER_CONFIG * dst_bc,int use_crop)329*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_copy_v_c(const YV12_BUFFER_CONFIG *src_bc,
330*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_bc, int use_crop) {
331*77c1e3ccSAndroid Build Coastguard Worker int row;
332*77c1e3ccSAndroid Build Coastguard Worker int width = use_crop ? src_bc->uv_crop_width : src_bc->uv_width;
333*77c1e3ccSAndroid Build Coastguard Worker int height = use_crop ? src_bc->uv_crop_height : src_bc->uv_height;
334*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src = src_bc->v_buffer;
335*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst = dst_bc->v_buffer;
336*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
337*77c1e3ccSAndroid Build Coastguard Worker if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
338*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
339*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
340*77c1e3ccSAndroid Build Coastguard Worker for (row = 0; row < height; ++row) {
341*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst16, src16, width * sizeof(uint16_t));
342*77c1e3ccSAndroid Build Coastguard Worker src16 += src_bc->uv_stride;
343*77c1e3ccSAndroid Build Coastguard Worker dst16 += dst_bc->uv_stride;
344*77c1e3ccSAndroid Build Coastguard Worker }
345*77c1e3ccSAndroid Build Coastguard Worker return;
346*77c1e3ccSAndroid Build Coastguard Worker }
347*77c1e3ccSAndroid Build Coastguard Worker #endif
348*77c1e3ccSAndroid Build Coastguard Worker for (row = 0; row < height; ++row) {
349*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst, src, width);
350*77c1e3ccSAndroid Build Coastguard Worker src += src_bc->uv_stride;
351*77c1e3ccSAndroid Build Coastguard Worker dst += dst_bc->uv_stride;
352*77c1e3ccSAndroid Build Coastguard Worker }
353*77c1e3ccSAndroid Build Coastguard Worker }
354*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_partial_copy_y_c(const YV12_BUFFER_CONFIG * src_ybc,int hstart1,int hend1,int vstart1,int vend1,YV12_BUFFER_CONFIG * dst_ybc,int hstart2,int vstart2)355*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_partial_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc, int hstart1,
356*77c1e3ccSAndroid Build Coastguard Worker int hend1, int vstart1, int vend1,
357*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_ybc, int hstart2,
358*77c1e3ccSAndroid Build Coastguard Worker int vstart2) {
359*77c1e3ccSAndroid Build Coastguard Worker int row;
360*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src = src_ybc->y_buffer;
361*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst = dst_ybc->y_buffer;
362*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
363*77c1e3ccSAndroid Build Coastguard Worker if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) {
364*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 =
365*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(src + vstart1 * src_ybc->y_stride + hstart1);
366*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst16 =
367*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(dst + vstart2 * dst_ybc->y_stride + hstart2);
368*77c1e3ccSAndroid Build Coastguard Worker
369*77c1e3ccSAndroid Build Coastguard Worker for (row = vstart1; row < vend1; ++row) {
370*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst16, src16, (hend1 - hstart1) * sizeof(uint16_t));
371*77c1e3ccSAndroid Build Coastguard Worker src16 += src_ybc->y_stride;
372*77c1e3ccSAndroid Build Coastguard Worker dst16 += dst_ybc->y_stride;
373*77c1e3ccSAndroid Build Coastguard Worker }
374*77c1e3ccSAndroid Build Coastguard Worker return;
375*77c1e3ccSAndroid Build Coastguard Worker }
376*77c1e3ccSAndroid Build Coastguard Worker #endif
377*77c1e3ccSAndroid Build Coastguard Worker src = (src + vstart1 * src_ybc->y_stride + hstart1);
378*77c1e3ccSAndroid Build Coastguard Worker dst = (dst + vstart2 * dst_ybc->y_stride + hstart2);
379*77c1e3ccSAndroid Build Coastguard Worker
380*77c1e3ccSAndroid Build Coastguard Worker for (row = vstart1; row < vend1; ++row) {
381*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst, src, (hend1 - hstart1));
382*77c1e3ccSAndroid Build Coastguard Worker src += src_ybc->y_stride;
383*77c1e3ccSAndroid Build Coastguard Worker dst += dst_ybc->y_stride;
384*77c1e3ccSAndroid Build Coastguard Worker }
385*77c1e3ccSAndroid Build Coastguard Worker }
386*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_partial_coloc_copy_y_c(const YV12_BUFFER_CONFIG * src_ybc,YV12_BUFFER_CONFIG * dst_ybc,int hstart,int hend,int vstart,int vend)387*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_partial_coloc_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc,
388*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_ybc, int hstart,
389*77c1e3ccSAndroid Build Coastguard Worker int hend, int vstart, int vend) {
390*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_partial_copy_y_c(src_ybc, hstart, hend, vstart, vend, dst_ybc,
391*77c1e3ccSAndroid Build Coastguard Worker hstart, vstart);
392*77c1e3ccSAndroid Build Coastguard Worker }
393*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_partial_copy_u_c(const YV12_BUFFER_CONFIG * src_bc,int hstart1,int hend1,int vstart1,int vend1,YV12_BUFFER_CONFIG * dst_bc,int hstart2,int vstart2)394*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_partial_copy_u_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1,
395*77c1e3ccSAndroid Build Coastguard Worker int hend1, int vstart1, int vend1,
396*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_bc, int hstart2,
397*77c1e3ccSAndroid Build Coastguard Worker int vstart2) {
398*77c1e3ccSAndroid Build Coastguard Worker int row;
399*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src = src_bc->u_buffer;
400*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst = dst_bc->u_buffer;
401*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
402*77c1e3ccSAndroid Build Coastguard Worker if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
403*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 =
404*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(src + vstart1 * src_bc->uv_stride + hstart1);
405*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst16 =
406*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(dst + vstart2 * dst_bc->uv_stride + hstart2);
407*77c1e3ccSAndroid Build Coastguard Worker for (row = vstart1; row < vend1; ++row) {
408*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst16, src16, (hend1 - hstart1) * sizeof(uint16_t));
409*77c1e3ccSAndroid Build Coastguard Worker src16 += src_bc->uv_stride;
410*77c1e3ccSAndroid Build Coastguard Worker dst16 += dst_bc->uv_stride;
411*77c1e3ccSAndroid Build Coastguard Worker }
412*77c1e3ccSAndroid Build Coastguard Worker return;
413*77c1e3ccSAndroid Build Coastguard Worker }
414*77c1e3ccSAndroid Build Coastguard Worker #endif
415*77c1e3ccSAndroid Build Coastguard Worker src = (src + vstart1 * src_bc->uv_stride + hstart1);
416*77c1e3ccSAndroid Build Coastguard Worker dst = (dst + vstart2 * dst_bc->uv_stride + hstart2);
417*77c1e3ccSAndroid Build Coastguard Worker
418*77c1e3ccSAndroid Build Coastguard Worker for (row = vstart1; row < vend1; ++row) {
419*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst, src, (hend1 - hstart1));
420*77c1e3ccSAndroid Build Coastguard Worker src += src_bc->uv_stride;
421*77c1e3ccSAndroid Build Coastguard Worker dst += dst_bc->uv_stride;
422*77c1e3ccSAndroid Build Coastguard Worker }
423*77c1e3ccSAndroid Build Coastguard Worker }
424*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_partial_coloc_copy_u_c(const YV12_BUFFER_CONFIG * src_bc,YV12_BUFFER_CONFIG * dst_bc,int hstart,int hend,int vstart,int vend)425*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_partial_coloc_copy_u_c(const YV12_BUFFER_CONFIG *src_bc,
426*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_bc, int hstart,
427*77c1e3ccSAndroid Build Coastguard Worker int hend, int vstart, int vend) {
428*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_partial_copy_u_c(src_bc, hstart, hend, vstart, vend, dst_bc, hstart,
429*77c1e3ccSAndroid Build Coastguard Worker vstart);
430*77c1e3ccSAndroid Build Coastguard Worker }
431*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_partial_copy_v_c(const YV12_BUFFER_CONFIG * src_bc,int hstart1,int hend1,int vstart1,int vend1,YV12_BUFFER_CONFIG * dst_bc,int hstart2,int vstart2)432*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_partial_copy_v_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1,
433*77c1e3ccSAndroid Build Coastguard Worker int hend1, int vstart1, int vend1,
434*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_bc, int hstart2,
435*77c1e3ccSAndroid Build Coastguard Worker int vstart2) {
436*77c1e3ccSAndroid Build Coastguard Worker int row;
437*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src = src_bc->v_buffer;
438*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst = dst_bc->v_buffer;
439*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
440*77c1e3ccSAndroid Build Coastguard Worker if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) {
441*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 =
442*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(src + vstart1 * src_bc->uv_stride + hstart1);
443*77c1e3ccSAndroid Build Coastguard Worker uint16_t *dst16 =
444*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(dst + vstart2 * dst_bc->uv_stride + hstart2);
445*77c1e3ccSAndroid Build Coastguard Worker for (row = vstart1; row < vend1; ++row) {
446*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst16, src16, (hend1 - hstart1) * sizeof(uint16_t));
447*77c1e3ccSAndroid Build Coastguard Worker src16 += src_bc->uv_stride;
448*77c1e3ccSAndroid Build Coastguard Worker dst16 += dst_bc->uv_stride;
449*77c1e3ccSAndroid Build Coastguard Worker }
450*77c1e3ccSAndroid Build Coastguard Worker return;
451*77c1e3ccSAndroid Build Coastguard Worker }
452*77c1e3ccSAndroid Build Coastguard Worker #endif
453*77c1e3ccSAndroid Build Coastguard Worker src = (src + vstart1 * src_bc->uv_stride + hstart1);
454*77c1e3ccSAndroid Build Coastguard Worker dst = (dst + vstart2 * dst_bc->uv_stride + hstart2);
455*77c1e3ccSAndroid Build Coastguard Worker
456*77c1e3ccSAndroid Build Coastguard Worker for (row = vstart1; row < vend1; ++row) {
457*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst, src, (hend1 - hstart1));
458*77c1e3ccSAndroid Build Coastguard Worker src += src_bc->uv_stride;
459*77c1e3ccSAndroid Build Coastguard Worker dst += dst_bc->uv_stride;
460*77c1e3ccSAndroid Build Coastguard Worker }
461*77c1e3ccSAndroid Build Coastguard Worker }
462*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_partial_coloc_copy_v_c(const YV12_BUFFER_CONFIG * src_bc,YV12_BUFFER_CONFIG * dst_bc,int hstart,int hend,int vstart,int vend)463*77c1e3ccSAndroid Build Coastguard Worker void aom_yv12_partial_coloc_copy_v_c(const YV12_BUFFER_CONFIG *src_bc,
464*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *dst_bc, int hstart,
465*77c1e3ccSAndroid Build Coastguard Worker int hend, int vstart, int vend) {
466*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_partial_copy_v_c(src_bc, hstart, hend, vstart, vend, dst_bc, hstart,
467*77c1e3ccSAndroid Build Coastguard Worker vstart);
468*77c1e3ccSAndroid Build Coastguard Worker }
469*77c1e3ccSAndroid Build Coastguard Worker
aom_yv12_realloc_with_new_border_c(YV12_BUFFER_CONFIG * ybf,int new_border,int byte_alignment,bool alloc_pyramid,int num_planes)470*77c1e3ccSAndroid Build Coastguard Worker int aom_yv12_realloc_with_new_border_c(YV12_BUFFER_CONFIG *ybf, int new_border,
471*77c1e3ccSAndroid Build Coastguard Worker int byte_alignment, bool alloc_pyramid,
472*77c1e3ccSAndroid Build Coastguard Worker int num_planes) {
473*77c1e3ccSAndroid Build Coastguard Worker if (ybf) {
474*77c1e3ccSAndroid Build Coastguard Worker if (new_border == ybf->border) return 0;
475*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG new_buf;
476*77c1e3ccSAndroid Build Coastguard Worker memset(&new_buf, 0, sizeof(new_buf));
477*77c1e3ccSAndroid Build Coastguard Worker const int error = aom_alloc_frame_buffer(
478*77c1e3ccSAndroid Build Coastguard Worker &new_buf, ybf->y_crop_width, ybf->y_crop_height, ybf->subsampling_x,
479*77c1e3ccSAndroid Build Coastguard Worker ybf->subsampling_y, ybf->flags & YV12_FLAG_HIGHBITDEPTH, new_border,
480*77c1e3ccSAndroid Build Coastguard Worker byte_alignment, alloc_pyramid, 0);
481*77c1e3ccSAndroid Build Coastguard Worker if (error) return error;
482*77c1e3ccSAndroid Build Coastguard Worker // Copy image buffer
483*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_copy_frame(ybf, &new_buf, num_planes);
484*77c1e3ccSAndroid Build Coastguard Worker
485*77c1e3ccSAndroid Build Coastguard Worker // Extend up to new border
486*77c1e3ccSAndroid Build Coastguard Worker aom_extend_frame_borders(&new_buf, num_planes);
487*77c1e3ccSAndroid Build Coastguard Worker
488*77c1e3ccSAndroid Build Coastguard Worker // Now free the old buffer and replace with the new
489*77c1e3ccSAndroid Build Coastguard Worker aom_free_frame_buffer(ybf);
490*77c1e3ccSAndroid Build Coastguard Worker memcpy(ybf, &new_buf, sizeof(new_buf));
491*77c1e3ccSAndroid Build Coastguard Worker return 0;
492*77c1e3ccSAndroid Build Coastguard Worker }
493*77c1e3ccSAndroid Build Coastguard Worker return -2;
494*77c1e3ccSAndroid Build Coastguard Worker }
495