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 |
30 |
* |
* |
31 |
*************************************************************************/ |
****************************************************************************/ |
|
|
|
|
/************************************************************************** |
|
|
* |
|
|
* 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> |
|
|
* |
|
|
*************************************************************************/ |
|
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 |
|
|
268 |
/* --- u,v-image-based interpolation --- |
#ifdef BFRAMES |
269 |
const uint32_t edged_width2 = edged_width / 2; |
const uint32_t edged_width2 = edged_width / 2; |
270 |
const uint32_t edged_height2 = edged_height / 2; |
const uint32_t edged_height2 = edged_height / 2; |
271 |
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1); |
272 |
const uint32_t stride_add2 = 7 * edged_width2; |
const uint32_t stride_add2 = 7 * edged_width2; |
273 |
*/ |
#endif |
274 |
|
|
275 |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr; |
276 |
uint32_t x, y; |
uint32_t x, y; |
303 |
n_ptr += stride_add; |
n_ptr += stride_add; |
304 |
} |
} |
305 |
|
|
306 |
/* --- u,v-image-based interpolation --- |
#ifdef BFRAMES |
307 |
n_ptr = refn->u; |
n_ptr = refn->u; |
308 |
h_ptr = refh->u; |
h_ptr = refh->u; |
309 |
v_ptr = refv->u; |
v_ptr = refv->u; |
357 |
hv_ptr += stride_add2; |
hv_ptr += stride_add2; |
358 |
n_ptr += stride_add2; |
n_ptr += stride_add2; |
359 |
} |
} |
360 |
|
#endif |
361 |
|
|
362 |
|
/* |
363 |
|
interpolate_halfpel_h( |
364 |
|
refh->y - offset, |
365 |
|
refn->y - offset, |
366 |
|
edged_width, edged_height, |
367 |
|
rounding); |
368 |
|
|
369 |
|
interpolate_halfpel_v( |
370 |
|
refv->y - offset, |
371 |
|
refn->y - offset, |
372 |
|
edged_width, edged_height, |
373 |
|
rounding); |
374 |
|
|
375 |
|
interpolate_halfpel_hv( |
376 |
|
refhv->y - offset, |
377 |
|
refn->y - offset, |
378 |
|
edged_width, edged_height, |
379 |
|
rounding); |
380 |
|
*/ |
381 |
|
|
382 |
|
/* uv-image-based compensation |
383 |
|
offset = EDGE_SIZE2 * (edged_width / 2 + 1); |
384 |
|
|
385 |
|
interpolate_halfpel_h( |
386 |
|
refh->u - offset, |
387 |
|
refn->u - offset, |
388 |
|
edged_width / 2, edged_height / 2, |
389 |
|
rounding); |
390 |
|
|
391 |
|
interpolate_halfpel_v( |
392 |
|
refv->u - offset, |
393 |
|
refn->u - offset, |
394 |
|
edged_width / 2, edged_height / 2, |
395 |
|
rounding); |
396 |
|
|
397 |
|
interpolate_halfpel_hv( |
398 |
|
refhv->u - offset, |
399 |
|
refn->u - offset, |
400 |
|
edged_width / 2, edged_height / 2, |
401 |
|
rounding); |
402 |
|
|
403 |
|
|
404 |
|
interpolate_halfpel_h( |
405 |
|
refh->v - offset, |
406 |
|
refn->v - offset, |
407 |
|
edged_width / 2, edged_height / 2, |
408 |
|
rounding); |
409 |
|
|
410 |
|
interpolate_halfpel_v( |
411 |
|
refv->v - offset, |
412 |
|
refn->v - offset, |
413 |
|
edged_width / 2, edged_height / 2, |
414 |
|
rounding); |
415 |
|
|
416 |
|
interpolate_halfpel_hv( |
417 |
|
refhv->v - offset, |
418 |
|
refn->v - offset, |
419 |
|
edged_width / 2, edged_height / 2, |
420 |
|
rounding); |
421 |
*/ |
*/ |
422 |
} |
} |
423 |
|
|