1 /*******************************************************************************
2  cmodel_yuv422.c
3 
4  libquicktime - A library for reading and writing quicktime/avi/mp4 files.
5  http://libquicktime.sourceforge.net
6 
7  Copyright (C) 2002 Heroine Virtual Ltd.
8  Copyright (C) 2002-2011 Members of the libquicktime project.
9 
10  This library is free software; you can redistribute it and/or modify it under
11  the terms of the GNU Lesser General Public License as published by the Free
12  Software Foundation; either version 2.1 of the License, or (at your option)
13  any later version.
14 
15  This library is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18  details.
19 
20  You should have received a copy of the GNU Lesser General Public License along
21  with this library; if not, write to the Free Software Foundation, Inc., 51
22  Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *******************************************************************************/
24 
25 #define HAVE_RGB_16_TO_RGB_24
26 #define HAVE_RGB_TO_YUV
27 #define HAVE_RGB_TO_YUVJ
28 #define HAVE_YUV_TO_RGB
29 #define HAVE_YUVJ_TO_RGB
30 #define HAVE_YUV_8_TO_YUVJ
31 #define HAVE_YUVJ_TO_YUV_8
32 
33 #include "lqt_private.h"
34 #include "cmodel_permutation.h"
35 
36 #define TRANSFER_FRAME_DEFAULT(output, \
37 	input, \
38 	y_in_offset, \
39 	u_in_offset, \
40 	v_in_offset, \
41 	input_column) \
42 { \
43 	register int i, j; \
44  \
45 	switch(out_colormodel) \
46 	{ \
47 		case BC_BGR565: \
48 			TRANSFER_FRAME_HEAD_16 \
49                           transfer_YUV422_to_BGR565((output), (input), (input_column)); \
50 			TRANSFER_FRAME_TAIL \
51 			break; \
52 		case BC_RGB565: \
53 			TRANSFER_FRAME_HEAD_16 \
54                           transfer_YUV422_to_RGB565((output), (input), (input_column)); \
55 			TRANSFER_FRAME_TAIL \
56 			break; \
57 		case BC_RGB888:      \
58 			TRANSFER_FRAME_HEAD \
59 			transfer_YUV422_to_RGB888((output), (input), (input_column)); \
60 			TRANSFER_FRAME_TAIL \
61 			break; \
62 		case BC_RGBA8888:      \
63 			TRANSFER_FRAME_HEAD \
64 			transfer_YUV422_to_RGBA8888((output), (input), (input_column)); \
65 			TRANSFER_FRAME_TAIL \
66 			break; \
67 		case BC_YUVA8888:      \
68 			TRANSFER_FRAME_HEAD \
69 			transfer_YUV422_to_YUVA8888((output), (input), (input_column)); \
70 			TRANSFER_FRAME_TAIL \
71 			break; \
72 		case BC_RGB161616:      \
73 			TRANSFER_FRAME_HEAD_16 \
74 			transfer_YUV422_to_RGB161616((output), (input), (input_column)); \
75 			TRANSFER_FRAME_TAIL \
76 			break; \
77 		case BC_RGBA16161616:      \
78 			TRANSFER_FRAME_HEAD_16 \
79 			transfer_YUV422_to_RGBA16161616((output), (input), (input_column)); \
80 			TRANSFER_FRAME_TAIL \
81 			break; \
82 		case BC_BGR888:      \
83 			TRANSFER_FRAME_HEAD \
84 			transfer_YUV422_to_BGR888((output), (input), (input_column)); \
85 			TRANSFER_FRAME_TAIL \
86 			break; \
87 		case BC_BGR8888: \
88 			TRANSFER_FRAME_HEAD \
89 			transfer_YUV422_to_BGR8888((output), (input), (input_column)); \
90 			TRANSFER_FRAME_TAIL \
91 			break; \
92 		case BC_YUV422P: \
93 			TRANSFER_YUV422P_OUT_HEAD \
94 			transfer_YUV422_to_YUV422P(output_y, \
95 				output_u, \
96 				output_v, \
97 				(input), \
98 				j); \
99 			TRANSFER_FRAME_TAIL \
100 			break; \
101 		case BC_YUVJ422P: \
102 			TRANSFER_YUV422P_OUT_HEAD \
103 			transfer_YUV422_to_YUVJ422P(output_y, \
104 				output_u, \
105 				output_v, \
106 				(input), \
107 				j); \
108 			TRANSFER_FRAME_TAIL \
109 			break; \
110 		case BC_YUV422: \
111 			TRANSFER_FRAME_HEAD \
112 			transfer_YUV422_to_YUV422((output), \
113 				(input), \
114 				j); \
115 			TRANSFER_FRAME_TAIL \
116 			break; \
117 		case BC_YUV420P: \
118 			TRANSFER_YUV420P_OUT_HEAD \
119 			transfer_YUV422_to_YUV420P(output_y, \
120 				output_u, \
121 				output_v, \
122 				(input), \
123 				j, \
124 				i); \
125 			TRANSFER_FRAME_TAIL \
126 			break; \
127 	} \
128 }
129 
cmodel_yuv422(PERMUTATION_ARGS)130 void cmodel_yuv422(PERMUTATION_ARGS)
131 {
132 	if(scale)
133 	{
134 		TRANSFER_FRAME_DEFAULT(&output_row,
135 			input_row + ((column_table[j] * in_pixelsize) & 0xfffffffc),
136 			0,
137 			0,
138 			0,
139 			column_table[j]);
140 	}
141 	else
142 	{
143 		TRANSFER_FRAME_DEFAULT(&output_row,
144 			input_row + ((j * in_pixelsize) & 0xfffffffc),
145 			0,
146 			0,
147 			0,
148 			j);
149 	}
150 }
151