1 |
/************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* image stuff |
* - image module - |
5 |
|
* |
6 |
|
* Copyright(C) 2002 Peter Ross <pross@xvid.org> |
7 |
|
* |
8 |
|
* This program is an implementation of a part of one or more MPEG-4 |
9 |
|
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
10 |
|
* to use this software module in hardware or software products are |
11 |
|
* advised that its use may infringe existing patents or copyrights, and |
12 |
|
* any such use would be at such party's own risk. The original |
13 |
|
* developer of this software module and his/her company, and subsequent |
14 |
|
* editors and their companies, will have no liability for use of this |
15 |
|
* software or modifications or derivatives thereof. |
16 |
* |
* |
17 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
18 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
26 |
* |
* |
27 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
28 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
29 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
* |
|
|
*************************************************************************/ |
|
|
|
|
|
/************************************************************************** |
|
|
* |
|
|
* History: |
|
|
* |
|
|
* 01.05.2002 BFRAME image-based u,v interpolation |
|
|
* 22.04.2002 added some B-frame support |
|
|
* 14.04.2002 added image_dump_yuvpgm(), added image_mad() |
|
|
* XVID_CSP_USER input support |
|
|
* 09.04.2002 PSNR calculations |
|
|
* 06.04.2002 removed interlaced edging from U,V blocks (as per spec) |
|
|
* 26.03.2002 interlacing support (field-based edging in set_edges) |
|
|
* 26.01.2002 rgb555, rgb565 |
|
|
* 07.01.2001 commented u,v interpolation (not required for uv-block-based) |
|
|
* 23.12.2001 removed #ifdefs, added function pointers + init_common() |
|
|
* 22.12.2001 cpu #ifdefs |
|
|
* 19.12.2001 image_dump(); useful for debugging |
|
|
* 6.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
30 |
* |
* |
31 |
*************************************************************************/ |
****************************************************************************/ |
32 |
|
|
33 |
#include <stdlib.h> |
#include <stdlib.h> |
34 |
#include <string.h> // memcpy, memset |
#include <string.h> // memcpy, memset |
252 |
} |
} |
253 |
} |
} |
254 |
|
|
255 |
|
// bframe encoding requires image-based u,v interpolation |
|
// image-based y,u,v interpolation |
|
256 |
void |
void |
257 |
image_interpolate(const IMAGE * refn, |
image_interpolate(const IMAGE * refn, |
258 |
IMAGE * refh, |
IMAGE * refh, |
265 |
const uint32_t offset = EDGE_SIZE * (edged_width + 1); |
const uint32_t offset = EDGE_SIZE * (edged_width + 1); |
266 |
const uint32_t stride_add = 7 * edged_width; |
const uint32_t stride_add = 7 * edged_width; |
267 |
|
|
|
/* --- u,v-image-based interpolation --- |
|
|
const uint32_t edged_width2 = edged_width / 2; |
|
|
const uint32_t edged_height2 = edged_height / 2; |
|
|
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
|
|
const uint32_t stride_add2 = 7 * edged_width2; |
|
|
*/ |
|
|
|
|
268 |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
269 |
uint32_t x, y; |
uint32_t x, y; |
270 |
|
|
296 |
n_ptr += stride_add; |
n_ptr += stride_add; |
297 |
} |
} |
298 |
|
|
299 |
/* --- u,v-image-based interpolation --- |
/* |
300 |
n_ptr = refn->u; |
interpolate_halfpel_h( |
301 |
h_ptr = refh->u; |
refh->y - offset, |
302 |
v_ptr = refv->u; |
refn->y - offset, |
303 |
hv_ptr = refhv->u; |
edged_width, edged_height, |
304 |
|
rounding); |
305 |
n_ptr -= offset2; |
|
306 |
h_ptr -= offset2; |
interpolate_halfpel_v( |
307 |
v_ptr -= offset2; |
refv->y - offset, |
308 |
hv_ptr -= offset2; |
refn->y - offset, |
309 |
|
edged_width, edged_height, |
310 |
for (y = 0; y < edged_height2; y = y + 8) { |
rounding); |
311 |
for (x = 0; x < edged_width2; x = x + 8) { |
|
312 |
interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width2, rounding); |
interpolate_halfpel_hv( |
313 |
interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width2, rounding); |
refhv->y - offset, |
314 |
interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width2, rounding); |
refn->y - offset, |
315 |
|
edged_width, edged_height, |
316 |
|
rounding); |
317 |
|
*/ |
318 |
|
|
319 |
n_ptr += 8; |
/* uv-image-based compensation |
320 |
h_ptr += 8; |
offset = EDGE_SIZE2 * (edged_width / 2 + 1); |
|
v_ptr += 8; |
|
|
hv_ptr += 8; |
|
|
} |
|
|
h_ptr += stride_add2; |
|
|
v_ptr += stride_add2; |
|
|
hv_ptr += stride_add2; |
|
|
n_ptr += stride_add2; |
|
|
} |
|
|
|
|
|
n_ptr = refn->v; |
|
|
h_ptr = refh->v; |
|
|
v_ptr = refv->v; |
|
|
hv_ptr = refhv->v; |
|
|
|
|
|
n_ptr -= offset2; |
|
|
h_ptr -= offset2; |
|
|
v_ptr -= offset2; |
|
|
hv_ptr -= offset2; |
|
|
|
|
|
for (y = 0; y < edged_height2; y = y + 8) { |
|
|
for (x = 0; x < edged_width2; x = x + 8) { |
|
|
interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width2, rounding); |
|
|
interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width2, rounding); |
|
|
interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width2, rounding); |
|
321 |
|
|
322 |
n_ptr += 8; |
interpolate_halfpel_h( |
323 |
h_ptr += 8; |
refh->u - offset, |
324 |
v_ptr += 8; |
refn->u - offset, |
325 |
hv_ptr += 8; |
edged_width / 2, edged_height / 2, |
326 |
} |
rounding); |
327 |
h_ptr += stride_add2; |
|
328 |
v_ptr += stride_add2; |
interpolate_halfpel_v( |
329 |
hv_ptr += stride_add2; |
refv->u - offset, |
330 |
n_ptr += stride_add2; |
refn->u - offset, |
331 |
} |
edged_width / 2, edged_height / 2, |
332 |
|
rounding); |
333 |
|
|
334 |
|
interpolate_halfpel_hv( |
335 |
|
refhv->u - offset, |
336 |
|
refn->u - offset, |
337 |
|
edged_width / 2, edged_height / 2, |
338 |
|
rounding); |
339 |
|
|
340 |
|
|
341 |
|
interpolate_halfpel_h( |
342 |
|
refh->v - offset, |
343 |
|
refn->v - offset, |
344 |
|
edged_width / 2, edged_height / 2, |
345 |
|
rounding); |
346 |
|
|
347 |
|
interpolate_halfpel_v( |
348 |
|
refv->v - offset, |
349 |
|
refn->v - offset, |
350 |
|
edged_width / 2, edged_height / 2, |
351 |
|
rounding); |
352 |
|
|
353 |
|
interpolate_halfpel_hv( |
354 |
|
refhv->v - offset, |
355 |
|
refn->v - offset, |
356 |
|
edged_width / 2, edged_height / 2, |
357 |
|
rounding); |
358 |
*/ |
*/ |
359 |
} |
} |
360 |
|
|