32 |
* |
* |
33 |
* History: |
* History: |
34 |
* |
* |
35 |
|
* 05.10.2002 support for interpolated images in qpel mode - Isibaar |
36 |
* 01.05.2002 BFRAME image-based u,v interpolation |
* 01.05.2002 BFRAME image-based u,v interpolation |
37 |
* 22.04.2002 added some B-frame support |
* 22.04.2002 added some B-frame support |
38 |
* 14.04.2002 added image_dump_yuvpgm(), added image_mad() |
* 14.04.2002 added image_dump_yuvpgm(), added image_mad() |
39 |
* XVID_CSP_USER input support |
* XVID_CSP_USER input support |
40 |
* 09.04.2002 PSNR calculations |
* 09.04.2002 PSNR calculations - Isibaar |
41 |
* 06.04.2002 removed interlaced edging from U,V blocks (as per spec) |
* 06.04.2002 removed interlaced edging from U,V blocks (as per spec) |
42 |
* 26.03.2002 interlacing support (field-based edging in set_edges) |
* 26.03.2002 interlacing support (field-based edging in set_edges) |
43 |
* 26.01.2002 rgb555, rgb565 |
* 26.01.2002 rgb555, rgb565 |
262 |
IMAGE * refhv, |
IMAGE * refhv, |
263 |
uint32_t edged_width, |
uint32_t edged_width, |
264 |
uint32_t edged_height, |
uint32_t edged_height, |
265 |
|
uint32_t quarterpel, |
266 |
uint32_t rounding) |
uint32_t rounding) |
267 |
{ |
{ |
268 |
const uint32_t offset = EDGE_SIZE * (edged_width + 1); |
const uint32_t offset = EDGE_SIZE2 * (edged_width + 1); // we only interpolate half of the edge area |
269 |
const uint32_t stride_add = 7 * edged_width; |
const uint32_t stride_add = 7 * edged_width; |
270 |
|
/* |
271 |
#ifdef BFRAMES |
#ifdef BFRAMES |
272 |
const uint32_t edged_width2 = edged_width / 2; |
const uint32_t edged_width2 = edged_width / 2; |
273 |
const uint32_t edged_height2 = edged_height / 2; |
const uint32_t edged_height2 = edged_height / 2; |
274 |
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
275 |
const uint32_t stride_add2 = 7 * edged_width2; |
const uint32_t stride_add2 = 7 * edged_width2; |
276 |
#endif |
#endif |
277 |
|
*/ |
278 |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
279 |
uint32_t x, y; |
uint32_t x, y; |
280 |
|
|
289 |
v_ptr -= offset; |
v_ptr -= offset; |
290 |
hv_ptr -= offset; |
hv_ptr -= offset; |
291 |
|
|
292 |
for (y = 0; y < edged_height; y += 8) { |
if(quarterpel) { |
293 |
for (x = 0; x < edged_width; x += 8) { |
|
294 |
|
for (y = 0; y < (edged_height - EDGE_SIZE); y += 8) { |
295 |
|
for (x = 0; x < (edged_width - EDGE_SIZE); x += 8) { |
296 |
|
interpolate8x8_6tap_lowpass_h(h_ptr, n_ptr, edged_width, rounding); |
297 |
|
interpolate8x8_6tap_lowpass_v(v_ptr, n_ptr, edged_width, rounding); |
298 |
|
|
299 |
|
n_ptr += 8; |
300 |
|
h_ptr += 8; |
301 |
|
v_ptr += 8; |
302 |
|
} |
303 |
|
|
304 |
|
n_ptr += EDGE_SIZE; |
305 |
|
h_ptr += EDGE_SIZE; |
306 |
|
v_ptr += EDGE_SIZE; |
307 |
|
|
308 |
|
h_ptr += stride_add; |
309 |
|
v_ptr += stride_add; |
310 |
|
n_ptr += stride_add; |
311 |
|
} |
312 |
|
|
313 |
|
h_ptr = refh->y; |
314 |
|
h_ptr -= offset; |
315 |
|
|
316 |
|
for (y = 0; y < (edged_height - EDGE_SIZE); y = y + 8) { |
317 |
|
for (x = 0; x < (edged_width - EDGE_SIZE); x = x + 8) { |
318 |
|
interpolate8x8_6tap_lowpass_v(hv_ptr, h_ptr, edged_width, rounding); |
319 |
|
hv_ptr += 8; |
320 |
|
h_ptr += 8; |
321 |
|
} |
322 |
|
|
323 |
|
hv_ptr += EDGE_SIZE2; |
324 |
|
h_ptr += EDGE_SIZE2; |
325 |
|
|
326 |
|
hv_ptr += stride_add; |
327 |
|
h_ptr += stride_add; |
328 |
|
} |
329 |
|
} |
330 |
|
else { |
331 |
|
|
332 |
|
for (y = 0; y < (edged_height - EDGE_SIZE); y += 8) { |
333 |
|
for (x = 0; x < (edged_width - EDGE_SIZE); x += 8) { |
334 |
interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width, rounding); |
interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width, rounding); |
335 |
interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width, rounding); |
interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width, rounding); |
336 |
interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width, rounding); |
interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width, rounding); |
340 |
v_ptr += 8; |
v_ptr += 8; |
341 |
hv_ptr += 8; |
hv_ptr += 8; |
342 |
} |
} |
343 |
|
|
344 |
|
h_ptr += EDGE_SIZE; |
345 |
|
v_ptr += EDGE_SIZE; |
346 |
|
hv_ptr += EDGE_SIZE; |
347 |
|
n_ptr += EDGE_SIZE; |
348 |
|
|
349 |
h_ptr += stride_add; |
h_ptr += stride_add; |
350 |
v_ptr += stride_add; |
v_ptr += stride_add; |
351 |
hv_ptr += stride_add; |
hv_ptr += stride_add; |
352 |
n_ptr += stride_add; |
n_ptr += stride_add; |
353 |
} |
} |
354 |
|
} |
355 |
/* |
/* |
356 |
#ifdef BFRAMES |
#ifdef BFRAMES |
357 |
n_ptr = refn->u; |
n_ptr = refn->u; |
562 |
height = -height; |
height = -height; |
563 |
} |
} |
564 |
|
|
565 |
|
// --- xvid 2.1 compatiblity patch --- |
566 |
|
// --- remove when xvid_dec_frame->stride equals real stride |
567 |
|
if ((csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB555 || |
568 |
|
(csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB565 || |
569 |
|
(csp & ~XVID_CSP_VFLIP) == XVID_CSP_YUY2 || |
570 |
|
(csp & ~XVID_CSP_VFLIP) == XVID_CSP_YVYU || |
571 |
|
(csp & ~XVID_CSP_VFLIP) == XVID_CSP_UYVY) |
572 |
|
{ |
573 |
|
dst_stride *= 2; |
574 |
|
} |
575 |
|
else if ((csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB24) |
576 |
|
{ |
577 |
|
dst_stride *= 3; |
578 |
|
} |
579 |
|
else if ((csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB32 || |
580 |
|
(csp & ~XVID_CSP_VFLIP) == XVID_CSP_ABGR || |
581 |
|
(csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGBA) |
582 |
|
{ |
583 |
|
dst_stride *= 4; |
584 |
|
} |
585 |
|
// ^--- xvid 2.1 compatiblity fix ---^ |
586 |
|
|
587 |
|
|
588 |
switch (csp & ~XVID_CSP_VFLIP) { |
switch (csp & ~XVID_CSP_VFLIP) { |
589 |
case XVID_CSP_RGB555: |
case XVID_CSP_RGB555: |
590 |
yv12_to_rgb555(dst, dst_stride, image->y, image->u, image->v, |
yv12_to_rgb555(dst, dst_stride, image->y, image->u, image->v, |
606 |
edged_width, edged_width / 2, width, height); |
edged_width, edged_width / 2, width, height); |
607 |
return 0; |
return 0; |
608 |
|
|
609 |
|
case XVID_CSP_ABGR: |
610 |
|
yv12_to_abgr(dst, dst_stride, image->y, image->u, image->v, |
611 |
|
edged_width, edged_width / 2, width, height); |
612 |
|
return 0; |
613 |
|
|
614 |
|
case XVID_CSP_RGBA: |
615 |
|
yv12_to_rgba(dst, dst_stride, image->y, image->u, image->v, |
616 |
|
edged_width, edged_width / 2, width, height); |
617 |
|
return 0; |
618 |
|
|
619 |
case XVID_CSP_I420: |
case XVID_CSP_I420: |
620 |
yv12_to_yuv(dst, dst_stride, image->y, image->u, image->v, edged_width, |
yv12_to_yuv(dst, dst_stride, image->y, image->u, image->v, edged_width, |
621 |
edged_width / 2, width, height); |
edged_width / 2, width, height); |