1 |
/************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* colorspace conversions |
* - colorspace conversion module - |
5 |
* |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
* Copyright(C) 2002 Peter Ross <pross@xvid.org> |
7 |
* it under the terms of the GNU General Public License as published by |
* 2002 Michael Militzer <isibaar@xvid.org> |
8 |
|
* |
9 |
|
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
10 |
|
* |
11 |
|
* XviD is free software; you can redistribute it and/or modify it |
12 |
|
* under the terms of the GNU General Public License as published by |
13 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
14 |
* (at your option) any later version. |
* (at your option) any later version. |
15 |
* |
* |
20 |
* |
* |
21 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
22 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
23 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
* |
* |
25 |
*************************************************************************/ |
* Under section 8 of the GNU General Public License, the copyright |
26 |
|
* holders of XVID explicitly forbid distribution in the following |
27 |
/************************************************************************** |
* countries: |
28 |
|
* |
29 |
|
* - Japan |
30 |
|
* - United States of America |
31 |
|
* |
32 |
|
* Linking XviD statically or dynamically with other modules is making a |
33 |
|
* combined work based on XviD. Thus, the terms and conditions of the |
34 |
|
* GNU General Public License cover the whole combination. |
35 |
|
* |
36 |
|
* As a special exception, the copyright holders of XviD give you |
37 |
|
* permission to link XviD with independent modules that communicate with |
38 |
|
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
39 |
|
* license terms of these independent modules, and to copy and distribute |
40 |
|
* the resulting combined work under terms of your choice, provided that |
41 |
|
* every copy of the combined work is accompanied by a complete copy of |
42 |
|
* the source code of XviD (the version of XviD used to produce the |
43 |
|
* combined work), being distributed under the terms of the GNU General |
44 |
|
* Public License plus this exception. An independent module is a module |
45 |
|
* which is not derived from or based on XviD. |
46 |
* |
* |
47 |
* History: |
* Note that people who make modified versions of XviD are not obligated |
48 |
|
* to grant this special exception for their modified versions; it is |
49 |
|
* their choice whether to do so. The GNU General Public License gives |
50 |
|
* permission to release a modified version without this exception; this |
51 |
|
* exception also makes it possible to release a modified version which |
52 |
|
* carries forward this exception. |
53 |
* |
* |
54 |
* 14.04.2002 added user_to_yuv_c() |
* $Id$ |
|
* 30.02.2002 out_yuv dst_stride2 fix |
|
|
* 26.02.2002 rgb555, rgb565 |
|
|
* 24.11.2001 accuracy improvement to yuyv/vyuy conversion |
|
|
* 28.10.2001 total rewrite <pross@cs.rmit.edu.au> |
|
55 |
* |
* |
56 |
**************************************************************************/ |
****************************************************************************/ |
57 |
|
|
58 |
#include <string.h> // memcpy |
#include <string.h> /* memcpy */ |
59 |
|
|
60 |
#include "colorspace.h" |
#include "colorspace.h" |
61 |
#include "../divx4.h" // DEC_PICTURE |
#include "../divx4.h" /* DEC_PICTURE */ |
62 |
|
|
63 |
// function pointers |
/* function pointers */ |
64 |
|
|
65 |
/* input */ |
/* input */ |
66 |
color_inputFuncPtr rgb555_to_yv12; |
color_inputFuncPtr rgb555_to_yv12; |
142 |
|
|
143 |
|
|
144 |
for (y = height / 2; y; y--) { |
for (y = height / 2; y; y--) { |
145 |
// process one 2x2 block per iteration |
/* process one 2x2 block per iteration */ |
146 |
for (x = 0; x < (uint32_t) width; x += 2) { |
for (x = 0; x < (uint32_t) width; x += 2) { |
147 |
int rgb, r, g, b, r4, g4, b4; |
int rgb, r, g, b, r4, g4, b4; |
148 |
|
|
227 |
|
|
228 |
|
|
229 |
for (y = height / 2; y; y--) { |
for (y = height / 2; y; y--) { |
230 |
// process one 2x2 block per iteration |
/* process one 2x2 block per iteration */ |
231 |
for (x = 0; x < (uint32_t) width; x += 2) { |
for (x = 0; x < (uint32_t) width; x += 2) { |
232 |
int rgb, r, g, b, r4, g4, b4; |
int rgb, r, g, b, r4, g4, b4; |
233 |
|
|
499 |
|
|
500 |
for (x = width >> 1; x; x--) { |
for (x = width >> 1; x; x--) { |
501 |
*y_out++ = *src++; |
*y_out++ = *src++; |
502 |
//*u_out++ = *src++; |
/**u_out++ = *src++; */ |
503 |
*u_out++ = (*(src + width2) + *src) >> 1; |
*u_out++ = (*(src + width2) + *src) >> 1; |
504 |
src++; |
src++; |
505 |
*y_out++ = *src++; |
*y_out++ = *src++; |
506 |
//*v_out++ = *src++; |
/**v_out++ = *src++; */ |
507 |
*v_out++ = (*(src + width2) + *src) >> 1; |
*v_out++ = (*(src + width2) + *src) >> 1; |
508 |
src++; |
src++; |
509 |
|
|
551 |
|
|
552 |
for (x = width >> 1; x; x--) { |
for (x = width >> 1; x; x--) { |
553 |
*u_out++ = *src++; |
*u_out++ = *src++; |
554 |
// *u_out++ = (*(src+width2) + *src++) >> 1; |
/* *u_out++ = (*(src+width2) + *src++) >> 1; */ |
555 |
*y_out++ = *src++; |
*y_out++ = *src++; |
556 |
//*v_out++ = *src++; |
/**v_out++ = *src++; */ |
557 |
*v_out++ = (*(src + width2) + *src) >> 1; |
*v_out++ = (*(src + width2) + *src) >> 1; |
558 |
src++; |
src++; |
559 |
*y_out++ = *src++; |
*y_out++ = *src++; |
652 |
r = g = b = 0; |
r = g = b = 0; |
653 |
r2 = g2 = b2 = 0; |
r2 = g2 = b2 = 0; |
654 |
|
|
655 |
// process one 2x2 block per iteration |
/* process one 2x2 block per iteration */ |
656 |
for (x = 0; x < (uint32_t) width / 2; x++) { |
for (x = 0; x < (uint32_t) width / 2; x++) { |
657 |
int u, v; |
int u, v; |
658 |
int b_u, g_uv, r_v, rgb_y; |
int b_u, g_uv, r_v, rgb_y; |
734 |
uint8_t *y_src2 = y_src + y_stride; |
uint8_t *y_src2 = y_src + y_stride; |
735 |
uint32_t x, y; |
uint32_t x, y; |
736 |
|
|
737 |
if (height < 0) { // flip image? |
if (height < 0) { /* flip image? */ |
738 |
height = -height; |
height = -height; |
739 |
y_src += (height - 1) * y_stride; |
y_src += (height - 1) * y_stride; |
740 |
y_src2 = y_src - y_stride; |
y_src2 = y_src - y_stride; |
751 |
r = g = b = 0; |
r = g = b = 0; |
752 |
r2 = g2 = b2 = 0; |
r2 = g2 = b2 = 0; |
753 |
|
|
754 |
// process one 2x2 block per iteration |
/* process one 2x2 block per iteration */ |
755 |
for (x = 0; x < (uint32_t) width / 2; x++) { |
for (x = 0; x < (uint32_t) width / 2; x++) { |
756 |
int u, v; |
int u, v; |
757 |
int b_u, g_uv, r_v, rgb_y; |
int b_u, g_uv, r_v, rgb_y; |
828 |
uint8_t *y_src2 = y_src + y_stride; |
uint8_t *y_src2 = y_src + y_stride; |
829 |
uint32_t x, y; |
uint32_t x, y; |
830 |
|
|
831 |
if (height < 0) { // flip image? |
if (height < 0) { /* flip image? */ |
832 |
height = -height; |
height = -height; |
833 |
y_src += (height - 1) * y_stride; |
y_src += (height - 1) * y_stride; |
834 |
y_src2 = y_src - y_stride; |
y_src2 = y_src - y_stride; |
839 |
} |
} |
840 |
|
|
841 |
for (y = height / 2; y; y--) { |
for (y = height / 2; y; y--) { |
842 |
// process one 2x2 block per iteration |
/* process one 2x2 block per iteration */ |
843 |
for (x = 0; x < (uint32_t) width / 2; x++) { |
for (x = 0; x < (uint32_t) width / 2; x++) { |
844 |
int u, v; |
int u, v; |
845 |
int b_u, g_uv, r_v, rgb_y; |
int b_u, g_uv, r_v, rgb_y; |
925 |
uint8_t *y_src2 = y_src + y_stride; |
uint8_t *y_src2 = y_src + y_stride; |
926 |
uint32_t x, y; |
uint32_t x, y; |
927 |
|
|
928 |
if (height < 0) { // flip image? |
if (height < 0) { /* flip image? */ |
929 |
height = -height; |
height = -height; |
930 |
y_src += (height - 1) * y_stride; |
y_src += (height - 1) * y_stride; |
931 |
y_src2 = y_src - y_stride; |
y_src2 = y_src - y_stride; |
936 |
} |
} |
937 |
|
|
938 |
for (y = height / 2; y; y--) { |
for (y = height / 2; y; y--) { |
939 |
// process one 2x2 block per iteration |
/* process one 2x2 block per iteration */ |
940 |
for (x = 0; x < (uint32_t) width / 2; x++) { |
for (x = 0; x < (uint32_t) width / 2; x++) { |
941 |
int u, v; |
int u, v; |
942 |
int b_u, g_uv, r_v, rgb_y; |
int b_u, g_uv, r_v, rgb_y; |