165 |
src = image->y; |
src = image->y; |
166 |
|
|
167 |
for (i = 0; i < EDGE_SIZE; i++) { |
for (i = 0; i < EDGE_SIZE; i++) { |
168 |
// if interlacing, edges contain top-most data from each field |
/* // if interlacing, edges contain top-most data from each field |
169 |
if (interlacing && (i & 1)) { |
if (interlacing && (i & 1)) { |
170 |
memset(dst, *(src + edged_width), EDGE_SIZE); |
memset(dst, *(src + edged_width), EDGE_SIZE); |
171 |
memcpy(dst + EDGE_SIZE, src + edged_width, width); |
memcpy(dst + EDGE_SIZE, src + edged_width, width); |
172 |
memset(dst + edged_width - EDGE_SIZE, |
memset(dst + edged_width - EDGE_SIZE, |
173 |
*(src + edged_width + width - 1), EDGE_SIZE); |
*(src + edged_width + width - 1), EDGE_SIZE); |
174 |
} else { |
} else {*/ |
175 |
memset(dst, *src, EDGE_SIZE); |
memset(dst, *src, EDGE_SIZE); |
176 |
memcpy(dst + EDGE_SIZE, src, width); |
memcpy(dst + EDGE_SIZE, src, width); |
177 |
memset(dst + edged_width - EDGE_SIZE, *(src + width - 1), |
memset(dst + edged_width - EDGE_SIZE, *(src + width - 1), |
178 |
EDGE_SIZE); |
EDGE_SIZE); |
179 |
} |
/*}*/ |
180 |
dst += edged_width; |
dst += edged_width; |
181 |
} |
} |
182 |
|
|
189 |
|
|
190 |
src -= edged_width; |
src -= edged_width; |
191 |
for (i = 0; i < EDGE_SIZE; i++) { |
for (i = 0; i < EDGE_SIZE; i++) { |
192 |
// if interlacing, edges contain bottom-most data from each field |
/* // if interlacing, edges contain bottom-most data from each field |
193 |
if (interlacing && !(i & 1)) { |
if (interlacing && !(i & 1)) { |
194 |
memset(dst, *(src - edged_width), EDGE_SIZE); |
memset(dst, *(src - edged_width), EDGE_SIZE); |
195 |
memcpy(dst + EDGE_SIZE, src - edged_width, width); |
memcpy(dst + EDGE_SIZE, src - edged_width, width); |
196 |
memset(dst + edged_width - EDGE_SIZE, |
memset(dst + edged_width - EDGE_SIZE, |
197 |
*(src - edged_width + width - 1), EDGE_SIZE); |
*(src - edged_width + width - 1), EDGE_SIZE); |
198 |
} else { |
} else {*/ |
199 |
memset(dst, *src, EDGE_SIZE); |
memset(dst, *src, EDGE_SIZE); |
200 |
memcpy(dst + EDGE_SIZE, src, width); |
memcpy(dst + EDGE_SIZE, src, width); |
201 |
memset(dst + edged_width - EDGE_SIZE, *(src + width - 1), |
memset(dst + edged_width - EDGE_SIZE, *(src + width - 1), |
202 |
EDGE_SIZE); |
EDGE_SIZE); |
203 |
} |
/*}*/ |
204 |
dst += edged_width; |
dst += edged_width; |
205 |
} |
} |
206 |
|
|
261 |
} |
} |
262 |
} |
} |
263 |
|
|
264 |
// bframe encoding requires image-based u,v interpolation |
|
265 |
|
// image-based y,u,v interpolation |
266 |
void |
void |
267 |
image_interpolate(const IMAGE * refn, |
image_interpolate(const IMAGE * refn, |
268 |
IMAGE * refh, |
IMAGE * refh, |
275 |
const uint32_t offset = EDGE_SIZE * (edged_width + 1); |
const uint32_t offset = EDGE_SIZE * (edged_width + 1); |
276 |
const uint32_t stride_add = 7 * edged_width; |
const uint32_t stride_add = 7 * edged_width; |
277 |
|
|
278 |
#ifdef BFRAMES |
/* --- u,v-image-based interpolation --- |
279 |
const uint32_t edged_width2 = edged_width / 2; |
const uint32_t edged_width2 = edged_width / 2; |
280 |
const uint32_t edged_height2 = edged_height / 2; |
const uint32_t edged_height2 = edged_height / 2; |
281 |
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
282 |
const uint32_t stride_add2 = 7 * edged_width2; |
const uint32_t stride_add2 = 7 * edged_width2; |
283 |
#endif |
*/ |
284 |
|
|
285 |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
286 |
uint32_t x, y; |
uint32_t x, y; |
313 |
n_ptr += stride_add; |
n_ptr += stride_add; |
314 |
} |
} |
315 |
|
|
316 |
#ifdef BFRAMES |
/* --- u,v-image-based interpolation --- |
317 |
n_ptr = refn->u; |
n_ptr = refn->u; |
318 |
h_ptr = refh->u; |
h_ptr = refh->u; |
319 |
v_ptr = refv->u; |
v_ptr = refv->u; |
367 |
hv_ptr += stride_add2; |
hv_ptr += stride_add2; |
368 |
n_ptr += stride_add2; |
n_ptr += stride_add2; |
369 |
} |
} |
|
#endif |
|
|
|
|
|
/* |
|
|
interpolate_halfpel_h( |
|
|
refh->y - offset, |
|
|
refn->y - offset, |
|
|
edged_width, edged_height, |
|
|
rounding); |
|
|
|
|
|
interpolate_halfpel_v( |
|
|
refv->y - offset, |
|
|
refn->y - offset, |
|
|
edged_width, edged_height, |
|
|
rounding); |
|
|
|
|
|
interpolate_halfpel_hv( |
|
|
refhv->y - offset, |
|
|
refn->y - offset, |
|
|
edged_width, edged_height, |
|
|
rounding); |
|
|
*/ |
|
|
|
|
|
/* uv-image-based compensation |
|
|
offset = EDGE_SIZE2 * (edged_width / 2 + 1); |
|
|
|
|
|
interpolate_halfpel_h( |
|
|
refh->u - offset, |
|
|
refn->u - offset, |
|
|
edged_width / 2, edged_height / 2, |
|
|
rounding); |
|
|
|
|
|
interpolate_halfpel_v( |
|
|
refv->u - offset, |
|
|
refn->u - offset, |
|
|
edged_width / 2, edged_height / 2, |
|
|
rounding); |
|
|
|
|
|
interpolate_halfpel_hv( |
|
|
refhv->u - offset, |
|
|
refn->u - offset, |
|
|
edged_width / 2, edged_height / 2, |
|
|
rounding); |
|
|
|
|
|
|
|
|
interpolate_halfpel_h( |
|
|
refh->v - offset, |
|
|
refn->v - offset, |
|
|
edged_width / 2, edged_height / 2, |
|
|
rounding); |
|
|
|
|
|
interpolate_halfpel_v( |
|
|
refv->v - offset, |
|
|
refn->v - offset, |
|
|
edged_width / 2, edged_height / 2, |
|
|
rounding); |
|
|
|
|
|
interpolate_halfpel_hv( |
|
|
refhv->v - offset, |
|
|
refn->v - offset, |
|
|
edged_width / 2, edged_height / 2, |
|
|
rounding); |
|
370 |
*/ |
*/ |
371 |
} |
} |
372 |
|
|
691 |
if(w > width) |
if(w > width) |
692 |
w = width; |
w = width; |
693 |
w2 = w >> 1; |
w2 = w >> 1; |
694 |
void __inline |
|
695 |
dY = (uint8_t*)out_frm->y + (mby << 4) * out_frm->stride_y + (mbx << 4); |
dY = (uint8_t*)out_frm->y + (mby << 4) * out_frm->stride_y + (mbx << 4); |
696 |
dU = (uint8_t*)out_frm->u + (mby << 3) * out_frm->stride_u + (mbx << 3); |
dU = (uint8_t*)out_frm->u + (mby << 3) * out_frm->stride_u + (mbx << 3); |
697 |
dV = (uint8_t*)out_frm->v + (mby << 3) * out_frm->stride_v + (mbx << 3); |
dV = (uint8_t*)out_frm->v + (mby << 3) * out_frm->stride_v + (mbx << 3); |
701 |
|
|
702 |
for(i = 0 ; i < 16 ; i++) { |
for(i = 0 ; i < 16 ; i++) { |
703 |
memcpy(dY,sY,w); |
memcpy(dY,sY,w); |
704 |
dY = out_frm->y + (mby << 4) * out_frm->stride_y + (mbx << 4); |
dY += out_frm->stride_y; |
705 |
dU = out_frm->u + (mby << 3) * out_frm->stride_u + (mbx << 3); |
sY += std; |
706 |
dV = out_frm->v + (mby << 3) * out_frm->stride_v + (mbx << 3); |
} |
707 |
for(i = 0 ; i < 8 ; i++) { |
for(i = 0 ; i < 8 ; i++) { |
708 |
memcpy(dU,sU,w2); |
memcpy(dU,sU,w2); |
709 |
dU += out_frm->stride_u; |
dU += out_frm->stride_u; |