allow ffmpeg video to resample curr_pos, add bluray format
[goodguy/history.git] / cinelerra-5.0 / quicktime / cmodel_yuv420p.c
1 /*
2  * This library is free software; you can redistribute it and/or modify it
3  * under the terms of the GNU Lesser General Public License as published
4  * by the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  * 
7  * This library is distributed in the hope that it will be useful, but
8  * WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  * Lesser General Public License for more details.
11  * 
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 
15  * USA
16  */
17
18
19
20 #include "cmodel_permutation.h"
21
22
23
24
25 static inline void transfer_YUV_PLANAR_to_RGB8(unsigned char *(*output), 
26         unsigned char *input_y,
27         unsigned char *input_u,
28         unsigned char *input_v)
29 {
30         int y, u, v, r, g, b;
31         
32         y = (*input_y << 16) | (*input_y << 8) | *input_y;
33         u = *input_u;
34         v = *input_v;
35         YUV_TO_RGB(y, u, v, r, g, b)
36
37         *(*output) = (unsigned char)((r & 0xc0) +
38                                                  ((g & 0xe0) >> 2) +
39                                                  ((b & 0xe0) >> 5));
40         (*output)++;
41 }
42
43 static inline void transfer_YUV_PLANAR_to_BGR565(unsigned char *(*output), 
44         unsigned char *input_y,
45         unsigned char *input_u,
46         unsigned char *input_v)
47 {
48         int y, u, v;
49         int r, g, b;
50         
51         y = (*input_y << 16) | (*input_y << 8) | *input_y;
52         u = *input_u;
53         v = *input_v;
54         YUV_TO_RGB(y, u, v, r, g, b)
55
56         *(uint16_t*)(*output) = ((b & 0xf8) << 8)
57                          + ((g & 0xfc) << 3)
58                          + ((r & 0xf8) >> 3);
59         (*output) += 2;
60 }
61
62 static inline void transfer_YUV_PLANAR_to_RGB565(unsigned char *(*output), 
63         unsigned char *input_y,
64         unsigned char *input_u,
65         unsigned char *input_v)
66 {
67         int y, u, v;
68         int r, g, b;
69         
70         y = (*input_y << 16) | (*input_y << 8) | *input_y;
71         u = *input_u;
72         v = *input_v;
73         YUV_TO_RGB(y, u, v, r, g, b)
74
75         *(uint16_t*)(*output) = ((r & 0xf8) << 8)
76                          + ((g & 0xfc) << 3)
77                          + ((b & 0xf8) >> 3);
78         (*output) += 2;
79 }
80
81 static inline void transfer_YUV_PLANAR_to_BGR888(unsigned char *(*output), 
82         unsigned char *input_y,
83         unsigned char *input_u,
84         unsigned char *input_v)
85 {
86         int y, u, v;
87         int r, g, b;
88         
89         y = (*input_y << 16) | (*input_y << 8) | *input_y;
90         u = *input_u;
91         v = *input_v;
92         YUV_TO_RGB(y, u, v, r, g, b)
93
94         (*output)[0] = b;
95         (*output)[1] = g;
96         (*output)[2] = r;
97         (*output) += 3;
98 }
99
100 static inline void transfer_YUV_PLANAR_to_BGR8888(unsigned char *(*output), 
101         unsigned char *input_y,
102         unsigned char *input_u,
103         unsigned char *input_v)
104 {
105         int y, u, v;
106         int r, g, b;
107
108         y = (*input_y << 16) | (*input_y << 8) | *input_y;
109         u = *input_u;
110         v = *input_v;
111         YUV_TO_RGB(y, u, v, r, g, b)
112
113         (*output)[0] = b;
114         (*output)[1] = g;
115         (*output)[2] = r;
116         (*output) += 4;
117 }
118
119 static inline void transfer_YUV_PLANAR_to_RGB888(unsigned char *(*output), 
120         unsigned char *input_y,
121         unsigned char *input_u,
122         unsigned char *input_v)
123 {
124 // Signedness is important
125         int y, u, v, r, g, b;
126
127         y = (*input_y << 16) | (*input_y << 8) | *input_y;
128         u = *input_u;
129         v = *input_v;
130         YUV_TO_RGB(y, u, v, r, g, b)
131
132         (*output)[0] = r;
133         (*output)[1] = g;
134         (*output)[2] = b;
135         (*output) += 3;
136 }
137
138 static inline void transfer_YUV_PLANAR_to_ARGB8888(unsigned char *(*output), 
139         unsigned char *input_y,
140         unsigned char *input_u,
141         unsigned char *input_v)
142 {
143 // Signedness is important
144         int y, u, v, r, g, b;
145
146         y = (*input_y << 16) | (*input_y << 8) | *input_y;
147         u = *input_u;
148         v = *input_v;
149         YUV_TO_RGB(y, u, v, r, g, b)
150
151         (*output)[0] = 0xff;
152         (*output)[1] = r;
153         (*output)[2] = g;
154         (*output)[3] = b;
155         (*output) += 4;
156 }
157
158 static inline void transfer_YUV_PLANAR_to_ABGR8888(unsigned char *(*output), 
159         unsigned char *input_y,
160         unsigned char *input_u,
161         unsigned char *input_v)
162 {
163 // Signedness is important
164         int y, u, v, r, g, b;
165
166         y = (*input_y << 16) | (*input_y << 8) | *input_y;
167         u = *input_u;
168         v = *input_v;
169         YUV_TO_RGB(y, u, v, r, g, b)
170
171         (*output)[0] = 0xff;
172         (*output)[3] = r;
173         (*output)[2] = g;
174         (*output)[1] = b;
175         (*output) += 4;
176 }
177
178 static inline void transfer_YUV_PLANAR_to_RGBA8888(unsigned char *(*output), 
179         unsigned char *input_y,
180         unsigned char *input_u,
181         unsigned char *input_v)
182 {
183 // Signedness is important
184         int y, u, v;
185         int r, g, b;
186
187         y = (*input_y << 16) | (*input_y << 8) | *input_y;
188         u = *input_u;
189         v = *input_v;
190         YUV_TO_RGB(y, u, v, r, g, b)
191
192         (*output)[0] = r;
193         (*output)[1] = g;
194         (*output)[2] = b;
195         (*output)[3] = 0xff;
196         (*output) += 4;
197 }
198
199 static inline void transfer_YUV_PLANAR_to_RGB161616(uint16_t *(*output), 
200         unsigned char *input_y,
201         unsigned char *input_u,
202         unsigned char *input_v)
203 {
204 // Signedness is important
205         int y, u, v;
206         int r, g, b;
207         y = (*input_y << 16) | (*input_y << 8) | *input_y;
208         u = (*input_u << 8) | *input_u;
209         v = (*input_v << 8) | *input_v;
210         YUV_TO_RGB16(y, u, v, r, g, b)
211         (*output)[0] = r;
212         (*output)[1] = g;
213         (*output)[2] = b;
214
215         (*output) += 3;
216 }
217
218
219 static inline void transfer_YUV_PLANAR_to_RGBA16161616(uint16_t *(*output), 
220         unsigned char *input_y,
221         unsigned char *input_u,
222         unsigned char *input_v)
223 {
224 // Signedness is important
225         int y, u, v;
226         int r, g, b;
227         y = (*input_y << 16) | (*input_y << 8) | *input_y;
228         u = (*input_u << 8) | *input_u;
229         v = (*input_v << 8) | *input_v;
230         YUV_TO_RGB16(y, u, v, r, g, b)
231
232         (*output)[0] = r;
233         (*output)[1] = g;
234         (*output)[2] = b;
235         (*output)[3] = 0xffff;
236
237         (*output) += 4;
238 }
239
240
241 static inline void transfer_YUV_PLANAR_to_RGB_FLOAT(float* *output, 
242         unsigned char *input_y,
243         unsigned char *input_u,
244         unsigned char *input_v)
245 {
246 // Signedness is important
247         float y = (float)*input_y / 0xff;
248         int u, v;
249         float r, g, b;
250         u = *input_u;
251         v = *input_v;
252         YUV_TO_FLOAT(y, u, v, r, g, b)
253 // optimization error here
254
255         (*output)[0] = r;
256         (*output)[1] = g;
257         (*output)[2] = b;
258         (*output) += 3;
259 }
260
261
262 static inline void transfer_YUV_PLANAR_to_RGBA_FLOAT(float* *output, 
263         unsigned char *input_y,
264         unsigned char *input_u,
265         unsigned char *input_v)
266 {
267 // Signedness is important
268         float y = (float)*input_y / 0xff;
269         int u, v;
270         float r, g, b;
271         u = *input_u;
272         v = *input_v;
273         YUV_TO_FLOAT(y, u, v, r, g, b)
274
275 // optimization error here
276         (*output)[0] = r;
277         (*output)[1] = g;
278         (*output)[2] = b;
279         (*output)[3] = 1.0;
280         (*output) += 4;
281 }
282
283
284
285 static inline void transfer_YUV_PLANAR_to_YUV888(unsigned char *(*output), 
286         unsigned char *input_y,
287         unsigned char *input_u,
288         unsigned char *input_v)
289 {
290         (*output)[0] = *input_y;
291         (*output)[1] = *input_u;
292         (*output)[2] = *input_v;
293         (*output) += 3;
294 }
295
296 static inline void transfer_YUV_PLANAR_to_YUV161616(uint16_t *(*output), 
297         unsigned char *input_y,
298         unsigned char *input_u,
299         unsigned char *input_v)
300 {
301         (*output)[0] = (*input_y << 8) | *input_y;
302         (*output)[1] = (*input_u << 8) | *input_u;
303         (*output)[2] = (*input_v << 8) | *input_v;
304         (*output) += 3;
305 }
306
307 static inline void transfer_YUV_PLANAR_to_YUVA8888(unsigned char *(*output), 
308         unsigned char *input_y,
309         unsigned char *input_u,
310         unsigned char *input_v)
311 {
312         (*output)[0] = *input_y;
313         (*output)[1] = *input_u;
314         (*output)[2] = *input_v;
315         (*output)[3] = 0xff;
316         (*output) += 4;
317 }
318
319 static inline void transfer_YUV_PLANAR_to_YUVA16161616(uint16_t *(*output), 
320         unsigned char *input_y,
321         unsigned char *input_u,
322         unsigned char *input_v)
323 {
324         (*output)[0] = (((uint16_t)*input_y) << 8) | *input_y;
325         (*output)[1] = (((uint16_t)*input_u) << 8) | *input_u;
326         (*output)[2] = (((uint16_t)*input_v) << 8) | *input_v;
327
328         (*output)[3] = 0xffff;
329         (*output) += 4;
330 }
331
332 static inline void transfer_YUV_PLANAR_to_YUV420P(unsigned char *input_y,
333         unsigned char *input_u,
334         unsigned char *input_v,
335         unsigned char *output_y,
336         unsigned char *output_u,
337         unsigned char *output_v,
338         int j)
339 {
340         output_y[j] = *input_y;
341         output_u[j / 2] = *input_u;
342         output_v[j / 2] = *input_v;
343 }
344
345 static inline void transfer_YUV_PLANAR_to_YUV444P(unsigned char *input_y,
346         unsigned char *input_u,
347         unsigned char *input_v,
348         unsigned char *output_y,
349         unsigned char *output_u,
350         unsigned char *output_v,
351         int j)
352 {
353         output_y[j] = *input_y;
354         output_u[j] = *input_u;
355         output_v[j] = *input_v;
356 }
357
358 static inline void transfer_YUV_PLANAR_to_YUV422(unsigned char *(*output), 
359         unsigned char *input_y,
360         unsigned char *input_u,
361         unsigned char *input_v,
362         int j)
363 {
364 // Store U and V for even pixels only
365         if(!(j & 1))
366         {
367                 (*output)[1] = *input_u;
368                 (*output)[3] = *input_v;
369                 (*output)[0] = *input_y;
370         }
371         else
372 // Store Y and advance output for odd pixels only
373         {
374                 (*output)[2] = *input_y;
375                 (*output) += 4;
376         }
377 }
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393 // ******************************** YUV444P -> ********************************
394
395 static inline void transfer_YUV444P_to_YUV444P(unsigned char *input_y,
396         unsigned char *input_u,
397         unsigned char *input_v,
398         unsigned char *output_y,
399         unsigned char *output_u,
400         unsigned char *output_v,
401         int j)
402 {
403         output_y[j] = *input_y;
404         output_u[j] = *input_u;
405         output_v[j] = *input_v;
406 }
407
408
409
410
411 #define TRANSFER_FRAME_DEFAULT(output, \
412         input, \
413         y_in_offset, \
414         u_in_offset, \
415         v_in_offset, \
416         input_column) \
417 { \
418         register int i, j; \
419  \
420         switch(in_colormodel) \
421         { \
422                 case BC_YUV420P: \
423                         switch(out_colormodel) \
424                         { \
425                                 case BC_RGB8: \
426                                         TRANSFER_YUV420P_IN_HEAD \
427                                         transfer_YUV_PLANAR_to_RGB8((output), \
428                                                 input_y + (y_in_offset), \
429                                                 input_u + (u_in_offset), \
430                                                 input_v + (v_in_offset)); \
431                                         TRANSFER_FRAME_TAIL \
432                                         break; \
433                                 case BC_BGR565: \
434                                         TRANSFER_YUV420P_IN_HEAD \
435                                         transfer_YUV_PLANAR_to_BGR565((output), \
436                                                 input_y + (y_in_offset), \
437                                                 input_u + (u_in_offset), \
438                                                 input_v + (v_in_offset)); \
439                                         TRANSFER_FRAME_TAIL \
440                                         break; \
441                                 case BC_RGB565: \
442                                         TRANSFER_YUV420P_IN_HEAD \
443                                         transfer_YUV_PLANAR_to_RGB565((output), \
444                                                 input_y + (y_in_offset), \
445                                                 input_u + (u_in_offset), \
446                                                 input_v + (v_in_offset)); \
447                                         TRANSFER_FRAME_TAIL \
448                                         break; \
449                                 case BC_BGR888:      \
450                                         TRANSFER_YUV420P_IN_HEAD \
451                                         transfer_YUV_PLANAR_to_BGR888((output), \
452                                                 input_y + (y_in_offset), \
453                                                 input_u + (u_in_offset), \
454                                                 input_v + (v_in_offset)); \
455                                         TRANSFER_FRAME_TAIL \
456                                         break; \
457                                 case BC_BGR8888: \
458                                         TRANSFER_YUV420P_IN_HEAD \
459                                         transfer_YUV_PLANAR_to_BGR8888((output), \
460                                                 input_y + (y_in_offset), \
461                                                 input_u + (u_in_offset), \
462                                                 input_v + (v_in_offset)); \
463                                         TRANSFER_FRAME_TAIL \
464                                         break; \
465                                 case BC_YUV420P: \
466                                         for(i = 0; i < out_h; i++) \
467                                         { \
468                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
469                                                 unsigned char *output_u = out_u_plane + i / 2 * total_out_w / 2; \
470                                                 unsigned char *output_v = out_v_plane + i / 2 * total_out_w / 2; \
471                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
472                                                 unsigned char *input_u = in_u_plane + row_table[i] / 2 * total_in_w / 2; \
473                                                 unsigned char *input_v = in_v_plane + row_table[i] / 2 * total_in_w / 2; \
474                                                 for(j = 0; j < out_w; j++) \
475                                                 { \
476                                                         transfer_YUV_PLANAR_to_YUV420P(input_y + (y_in_offset), \
477                                                                 input_u + (u_in_offset), \
478                                                                 input_v + (v_in_offset), \
479                                                                 output_y, \
480                                                                 output_u, \
481                                                                 output_v, \
482                                                                 j); \
483                                                 } \
484                                         } \
485                                         break; \
486                                 case BC_YUV422: \
487                                         TRANSFER_YUV420P_IN_HEAD \
488                                         transfer_YUV_PLANAR_to_YUV422((output), \
489                                                 input_y + (y_in_offset), \
490                                                 input_u + (u_in_offset), \
491                                                 input_v + (v_in_offset), \
492                                                 j); \
493                                         TRANSFER_FRAME_TAIL \
494                                         break; \
495                                 case BC_YUV422P: \
496                                         for(i = 0; i < out_h; i++) \
497                                         { \
498                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
499                                                 unsigned char *output_u = out_u_plane + i * total_out_w / 2; \
500                                                 unsigned char *output_v = out_v_plane + i * total_out_w / 2; \
501                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
502                                                 unsigned char *input_u = in_u_plane + row_table[i] / 2 * total_in_w / 2; \
503                                                 unsigned char *input_v = in_v_plane + row_table[i] / 2 * total_in_w / 2; \
504                                                 for(j = 0; j < out_w; j++) \
505                                                 { \
506                                                         transfer_YUV_PLANAR_to_YUV420P(input_y + (y_in_offset), \
507                                                                 input_u + (u_in_offset), \
508                                                                 input_v + (v_in_offset), \
509                                                                 output_y, \
510                                                                 output_u, \
511                                                                 output_v, \
512                                                                 j); \
513                                                 } \
514                                         } \
515                                         break; \
516                                 case BC_YUV444P: \
517                                         for(i = 0; i < out_h; i++) \
518                                         { \
519                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
520                                                 unsigned char *output_u = out_u_plane + i * total_out_w; \
521                                                 unsigned char *output_v = out_v_plane + i * total_out_w; \
522                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
523                                                 unsigned char *input_u = in_u_plane + row_table[i] / 2 * total_in_w / 2; \
524                                                 unsigned char *input_v = in_v_plane + row_table[i] / 2 * total_in_w / 2; \
525                                                 for(j = 0; j < out_w; j++) \
526                                                 { \
527                                                         transfer_YUV_PLANAR_to_YUV444P(input_y + (y_in_offset), \
528                                                                 input_u + (u_in_offset), \
529                                                                 input_v + (v_in_offset), \
530                                                                 output_y, \
531                                                                 output_u, \
532                                                                 output_v, \
533                                                                 j); \
534                                                 } \
535                                         } \
536                                         break; \
537                                 case BC_RGB888:      \
538                                         TRANSFER_YUV420P_IN_HEAD \
539                                         transfer_YUV_PLANAR_to_RGB888((output), \
540                                                 input_y + (y_in_offset), \
541                                                 input_u + (u_in_offset), \
542                                                 input_v + (v_in_offset)); \
543                                         TRANSFER_FRAME_TAIL \
544                                         break; \
545                                 case BC_ARGB8888:      \
546                                         TRANSFER_YUV420P_IN_HEAD \
547                                         transfer_YUV_PLANAR_to_ARGB8888((output), \
548                                                 input_y + (y_in_offset), \
549                                                 input_u + (u_in_offset), \
550                                                 input_v + (v_in_offset)); \
551                                         TRANSFER_FRAME_TAIL \
552                                         break; \
553                                 case BC_ABGR8888:      \
554                                         TRANSFER_YUV420P_IN_HEAD \
555                                         transfer_YUV_PLANAR_to_ABGR8888((output), \
556                                                 input_y + (y_in_offset), \
557                                                 input_u + (u_in_offset), \
558                                                 input_v + (v_in_offset)); \
559                                         TRANSFER_FRAME_TAIL \
560                                         break; \
561                                 case BC_RGBA8888:      \
562                                         TRANSFER_YUV420P_IN_HEAD \
563                                         transfer_YUV_PLANAR_to_RGBA8888((output), \
564                                                 input_y + (y_in_offset), \
565                                                 input_u + (u_in_offset), \
566                                                 input_v + (v_in_offset)); \
567                                         TRANSFER_FRAME_TAIL \
568                                         break; \
569                                 case BC_RGB161616:      \
570                                         TRANSFER_YUV420P_IN_HEAD \
571                                         transfer_YUV_PLANAR_to_RGB161616((uint16_t**)(output), \
572                                                 input_y + (y_in_offset), \
573                                                 input_u + (u_in_offset), \
574                                                 input_v + (v_in_offset)); \
575                                         TRANSFER_FRAME_TAIL \
576                                         break; \
577                                 case BC_RGBA16161616:      \
578                                         TRANSFER_YUV420P_IN_HEAD \
579                                         transfer_YUV_PLANAR_to_RGBA16161616((uint16_t**)(output), \
580                                                 input_y + (y_in_offset), \
581                                                 input_u + (u_in_offset), \
582                                                 input_v + (v_in_offset)); \
583                                         TRANSFER_FRAME_TAIL \
584                                         break; \
585                                 case BC_RGB_FLOAT:      \
586                                         TRANSFER_YUV420P_IN_HEAD \
587                                         transfer_YUV_PLANAR_to_RGB_FLOAT((float**)(output), \
588                                                 input_y + (y_in_offset), \
589                                                 input_u + (u_in_offset), \
590                                                 input_v + (v_in_offset)); \
591                                         TRANSFER_FRAME_TAIL \
592                                         break; \
593                                 case BC_RGBA_FLOAT:      \
594                                         TRANSFER_YUV420P_IN_HEAD \
595                                         transfer_YUV_PLANAR_to_RGBA_FLOAT((float**)(output), \
596                                                 input_y + (y_in_offset), \
597                                                 input_u + (u_in_offset), \
598                                                 input_v + (v_in_offset)); \
599                                         TRANSFER_FRAME_TAIL \
600                                         break; \
601                                 case BC_YUV888: \
602                                         TRANSFER_YUV420P_IN_HEAD \
603                                         transfer_YUV_PLANAR_to_YUV888((output), \
604                                                 input_y + (y_in_offset), \
605                                                 input_u + (u_in_offset), \
606                                                 input_v + (v_in_offset)); \
607                                         TRANSFER_FRAME_TAIL \
608                                         break; \
609                                 case BC_YUVA8888: \
610                                         TRANSFER_YUV420P_IN_HEAD \
611                                         transfer_YUV_PLANAR_to_YUVA8888((output), \
612                                                 input_y + (y_in_offset), \
613                                                 input_u + (u_in_offset), \
614                                                 input_v + (v_in_offset)); \
615                                         TRANSFER_FRAME_TAIL \
616                                         break; \
617                                 case BC_YUV161616: \
618                                         TRANSFER_YUV420P_IN_HEAD \
619                                         transfer_YUV_PLANAR_to_YUV161616((uint16_t**)(output), \
620                                                 input_y + (y_in_offset), \
621                                                 input_u + (u_in_offset), \
622                                                 input_v + (v_in_offset)); \
623                                         TRANSFER_FRAME_TAIL \
624                                         break; \
625                                 case BC_YUVA16161616: \
626                                         TRANSFER_YUV420P_IN_HEAD \
627                                         transfer_YUV_PLANAR_to_YUVA16161616((uint16_t**)(output), \
628                                                 input_y + (y_in_offset), \
629                                                 input_u + (u_in_offset), \
630                                                 input_v + (v_in_offset)); \
631                                         TRANSFER_FRAME_TAIL \
632                                         break; \
633                         } \
634                         break; \
635  \
636                 case BC_YUV9P: \
637                         switch(out_colormodel) \
638                         { \
639                                 case BC_RGB8: \
640                                         TRANSFER_YUV9P_IN_HEAD \
641                                         transfer_YUV_PLANAR_to_RGB8((output), \
642                                                 input_y + (y_in_offset), \
643                                                 input_u + (u_in_offset), \
644                                                 input_v + (v_in_offset)); \
645                                         TRANSFER_FRAME_TAIL \
646                                         break; \
647                                 case BC_BGR565: \
648                                         TRANSFER_YUV9P_IN_HEAD \
649                                         transfer_YUV_PLANAR_to_BGR565((output), \
650                                                 input_y + (y_in_offset), \
651                                                 input_u + (u_in_offset), \
652                                                 input_v + (v_in_offset)); \
653                                         TRANSFER_FRAME_TAIL \
654                                         break; \
655                                 case BC_RGB565: \
656                                         TRANSFER_YUV9P_IN_HEAD \
657                                         transfer_YUV_PLANAR_to_RGB565((output), \
658                                                 input_y + (y_in_offset), \
659                                                 input_u + (u_in_offset), \
660                                                 input_v + (v_in_offset)); \
661                                         TRANSFER_FRAME_TAIL \
662                                         break; \
663                                 case BC_BGR888:      \
664                                         TRANSFER_YUV9P_IN_HEAD \
665                                         transfer_YUV_PLANAR_to_BGR888((output), \
666                                                 input_y + (y_in_offset), \
667                                                 input_u + (u_in_offset), \
668                                                 input_v + (v_in_offset)); \
669                                         TRANSFER_FRAME_TAIL \
670                                         break; \
671                                 case BC_BGR8888: \
672                                         TRANSFER_YUV9P_IN_HEAD \
673                                         transfer_YUV_PLANAR_to_BGR8888((output), \
674                                                 input_y + (y_in_offset), \
675                                                 input_u + (u_in_offset), \
676                                                 input_v + (v_in_offset)); \
677                                         TRANSFER_FRAME_TAIL \
678                                         break; \
679                                 case BC_YUV420P: \
680                                         for(i = 0; i < out_h; i++) \
681                                         { \
682                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
683                                                 unsigned char *output_u = out_u_plane + i / 2 * total_out_w / 2; \
684                                                 unsigned char *output_v = out_v_plane + i / 2 * total_out_w / 2; \
685                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
686                                                 unsigned char *input_u = in_u_plane + row_table[i] / 2 * total_in_w / 2; \
687                                                 unsigned char *input_v = in_v_plane + row_table[i] / 2 * total_in_w / 2; \
688                                                 for(j = 0; j < out_w; j++) \
689                                                 { \
690                                                         transfer_YUV_PLANAR_to_YUV420P(input_y + (y_in_offset), \
691                                                                 input_u + (u_in_offset), \
692                                                                 input_v + (v_in_offset), \
693                                                                 output_y, \
694                                                                 output_u, \
695                                                                 output_v, \
696                                                                 j); \
697                                                 } \
698                                         } \
699                                         break; \
700                                 case BC_YUV422: \
701                                         TRANSFER_YUV9P_IN_HEAD \
702                                         transfer_YUV_PLANAR_to_YUV422((output), \
703                                                 input_y + (y_in_offset), \
704                                                 input_u + (u_in_offset), \
705                                                 input_v + (v_in_offset), \
706                                                 j); \
707                                         TRANSFER_FRAME_TAIL \
708                                         break; \
709                                 case BC_YUV422P: \
710                                         for(i = 0; i < out_h; i++) \
711                                         { \
712                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
713                                                 unsigned char *output_u = out_u_plane + i * total_out_w / 2; \
714                                                 unsigned char *output_v = out_v_plane + i * total_out_w / 2; \
715                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
716                                                 unsigned char *input_u = in_u_plane + row_table[i] / 2 * total_in_w / 2; \
717                                                 unsigned char *input_v = in_v_plane + row_table[i] / 2 * total_in_w / 2; \
718                                                 for(j = 0; j < out_w; j++) \
719                                                 { \
720                                                         transfer_YUV_PLANAR_to_YUV420P(input_y + (y_in_offset), \
721                                                                 input_u + (u_in_offset), \
722                                                                 input_v + (v_in_offset), \
723                                                                 output_y, \
724                                                                 output_u, \
725                                                                 output_v, \
726                                                                 j); \
727                                                 } \
728                                         } \
729                                         break; \
730                                 case BC_YUV444P: \
731                                         for(i = 0; i < out_h; i++) \
732                                         { \
733                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
734                                                 unsigned char *output_u = out_u_plane + i * total_out_w; \
735                                                 unsigned char *output_v = out_v_plane + i * total_out_w; \
736                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
737                                                 unsigned char *input_u = in_u_plane + row_table[i] / 2 * total_in_w / 2; \
738                                                 unsigned char *input_v = in_v_plane + row_table[i] / 2 * total_in_w / 2; \
739                                                 for(j = 0; j < out_w; j++) \
740                                                 { \
741                                                         transfer_YUV_PLANAR_to_YUV444P(input_y + (y_in_offset), \
742                                                                 input_u + (u_in_offset), \
743                                                                 input_v + (v_in_offset), \
744                                                                 output_y, \
745                                                                 output_u, \
746                                                                 output_v, \
747                                                                 j); \
748                                                 } \
749                                         } \
750                                         break; \
751                                 case BC_RGB888:      \
752                                         TRANSFER_YUV9P_IN_HEAD \
753                                         transfer_YUV_PLANAR_to_RGB888((output), \
754                                                 input_y + (y_in_offset), \
755                                                 input_u + (u_in_offset), \
756                                                 input_v + (v_in_offset)); \
757                                         TRANSFER_FRAME_TAIL \
758                                         break; \
759                                 case BC_ARGB8888:      \
760                                         TRANSFER_YUV9P_IN_HEAD \
761                                         transfer_YUV_PLANAR_to_ARGB8888((output), \
762                                                 input_y + (y_in_offset), \
763                                                 input_u + (u_in_offset), \
764                                                 input_v + (v_in_offset)); \
765                                         TRANSFER_FRAME_TAIL \
766                                         break; \
767                                 case BC_ABGR8888:      \
768                                         TRANSFER_YUV9P_IN_HEAD \
769                                         transfer_YUV_PLANAR_to_ABGR8888((output), \
770                                                 input_y + (y_in_offset), \
771                                                 input_u + (u_in_offset), \
772                                                 input_v + (v_in_offset)); \
773                                         TRANSFER_FRAME_TAIL \
774                                         break; \
775                                 case BC_RGBA8888:      \
776                                         TRANSFER_YUV9P_IN_HEAD \
777                                         transfer_YUV_PLANAR_to_RGBA8888((output), \
778                                                 input_y + (y_in_offset), \
779                                                 input_u + (u_in_offset), \
780                                                 input_v + (v_in_offset)); \
781                                         TRANSFER_FRAME_TAIL \
782                                         break; \
783                                 case BC_RGB161616:      \
784                                         TRANSFER_YUV9P_IN_HEAD \
785                                         transfer_YUV_PLANAR_to_RGB161616((uint16_t**)(output), \
786                                                 input_y + (y_in_offset), \
787                                                 input_u + (u_in_offset), \
788                                                 input_v + (v_in_offset)); \
789                                         TRANSFER_FRAME_TAIL \
790                                         break; \
791                                 case BC_RGBA16161616:      \
792                                         TRANSFER_YUV9P_IN_HEAD \
793                                         transfer_YUV_PLANAR_to_RGBA16161616((uint16_t**)(output), \
794                                                 input_y + (y_in_offset), \
795                                                 input_u + (u_in_offset), \
796                                                 input_v + (v_in_offset)); \
797                                         TRANSFER_FRAME_TAIL \
798                                         break; \
799                                 case BC_RGB_FLOAT:      \
800                                         TRANSFER_YUV9P_IN_HEAD \
801                                         transfer_YUV_PLANAR_to_RGB_FLOAT((float**)(output), \
802                                                 input_y + (y_in_offset), \
803                                                 input_u + (u_in_offset), \
804                                                 input_v + (v_in_offset)); \
805                                         TRANSFER_FRAME_TAIL \
806                                         break; \
807                                 case BC_RGBA_FLOAT:      \
808                                         TRANSFER_YUV9P_IN_HEAD \
809                                         transfer_YUV_PLANAR_to_RGBA_FLOAT((float**)(output), \
810                                                 input_y + (y_in_offset), \
811                                                 input_u + (u_in_offset), \
812                                                 input_v + (v_in_offset)); \
813                                         TRANSFER_FRAME_TAIL \
814                                         break; \
815                                 case BC_YUV888: \
816                                         TRANSFER_YUV9P_IN_HEAD \
817                                         transfer_YUV_PLANAR_to_YUV888((output), \
818                                                 input_y + (y_in_offset), \
819                                                 input_u + (u_in_offset), \
820                                                 input_v + (v_in_offset)); \
821                                         TRANSFER_FRAME_TAIL \
822                                         break; \
823                                 case BC_YUVA8888: \
824                                         TRANSFER_YUV9P_IN_HEAD \
825                                         transfer_YUV_PLANAR_to_YUVA8888((output), \
826                                                 input_y + (y_in_offset), \
827                                                 input_u + (u_in_offset), \
828                                                 input_v + (v_in_offset)); \
829                                         TRANSFER_FRAME_TAIL \
830                                         break; \
831                                 case BC_YUV161616: \
832                                         TRANSFER_YUV9P_IN_HEAD \
833                                         transfer_YUV_PLANAR_to_YUV161616((uint16_t**)(output), \
834                                                 input_y + (y_in_offset), \
835                                                 input_u + (u_in_offset), \
836                                                 input_v + (v_in_offset)); \
837                                         TRANSFER_FRAME_TAIL \
838                                         break; \
839                                 case BC_YUVA16161616: \
840                                         TRANSFER_YUV9P_IN_HEAD \
841                                         transfer_YUV_PLANAR_to_YUVA16161616((uint16_t**)(output), \
842                                                 input_y + (y_in_offset), \
843                                                 input_u + (u_in_offset), \
844                                                 input_v + (v_in_offset)); \
845                                         TRANSFER_FRAME_TAIL \
846                                         break; \
847                         } \
848                         break; \
849  \
850                 case BC_YUV422P: \
851                         switch(out_colormodel) \
852                         { \
853                                 case BC_RGB8: \
854                                         TRANSFER_YUV422P_IN_HEAD \
855                                         transfer_YUV_PLANAR_to_RGB8((output), \
856                                                 input_y + (y_in_offset), \
857                                                 input_u + (u_in_offset), \
858                                                 input_v + (v_in_offset)); \
859                                         TRANSFER_FRAME_TAIL \
860                                         break; \
861                                 case BC_BGR565: \
862                                         TRANSFER_YUV422P_IN_HEAD \
863                                         transfer_YUV_PLANAR_to_BGR565((output), \
864                                                 input_y + (y_in_offset), \
865                                                 input_u + (u_in_offset), \
866                                                 input_v + (v_in_offset)); \
867                                         TRANSFER_FRAME_TAIL \
868                                         break; \
869                                 case BC_RGB565: \
870                                         TRANSFER_YUV422P_IN_HEAD \
871                                         transfer_YUV_PLANAR_to_RGB565((output), \
872                                                 input_y + (y_in_offset), \
873                                                 input_u + (u_in_offset), \
874                                                 input_v + (v_in_offset)); \
875                                         TRANSFER_FRAME_TAIL \
876                                         break; \
877                                 case BC_BGR888:      \
878                                         TRANSFER_YUV422P_IN_HEAD \
879                                         transfer_YUV_PLANAR_to_BGR888((output), \
880                                                 input_y + (y_in_offset), \
881                                                 input_u + (u_in_offset), \
882                                                 input_v + (v_in_offset)); \
883                                         TRANSFER_FRAME_TAIL \
884                                         break; \
885                                 case BC_BGR8888: \
886                                         TRANSFER_YUV422P_IN_HEAD \
887                                         transfer_YUV_PLANAR_to_BGR8888((output), \
888                                                 input_y + (y_in_offset), \
889                                                 input_u + (u_in_offset), \
890                                                 input_v + (v_in_offset)); \
891                                         TRANSFER_FRAME_TAIL \
892                                         break; \
893                                 case BC_RGB888:      \
894                                         TRANSFER_YUV422P_IN_HEAD \
895                                         transfer_YUV_PLANAR_to_RGB888((output), \
896                                                 input_y + (y_in_offset), \
897                                                 input_u + (u_in_offset), \
898                                                 input_v + (v_in_offset)); \
899                                         TRANSFER_FRAME_TAIL \
900                                         break; \
901                                 case BC_ARGB8888:      \
902                                         TRANSFER_YUV422P_IN_HEAD \
903                                         transfer_YUV_PLANAR_to_ARGB8888((output), \
904                                                 input_y + (y_in_offset), \
905                                                 input_u + (u_in_offset), \
906                                                 input_v + (v_in_offset)); \
907                                         TRANSFER_FRAME_TAIL \
908                                         break; \
909                                 case BC_ABGR8888:      \
910                                         TRANSFER_YUV422P_IN_HEAD \
911                                         transfer_YUV_PLANAR_to_ABGR8888((output), \
912                                                 input_y + (y_in_offset), \
913                                                 input_u + (u_in_offset), \
914                                                 input_v + (v_in_offset)); \
915                                         TRANSFER_FRAME_TAIL \
916                                         break; \
917                                 case BC_RGBA8888:      \
918                                         TRANSFER_YUV422P_IN_HEAD \
919                                         transfer_YUV_PLANAR_to_RGBA8888((output), \
920                                                 input_y + (y_in_offset), \
921                                                 input_u + (u_in_offset), \
922                                                 input_v + (v_in_offset)); \
923                                         TRANSFER_FRAME_TAIL \
924                                         break; \
925                                 case BC_RGB161616:      \
926                                         TRANSFER_YUV422P_IN_HEAD \
927                                         transfer_YUV_PLANAR_to_RGB161616((uint16_t**)(output), \
928                                                 input_y + (y_in_offset), \
929                                                 input_u + (u_in_offset), \
930                                                 input_v + (v_in_offset)); \
931                                         TRANSFER_FRAME_TAIL \
932                                         break; \
933                                 case BC_RGBA16161616:      \
934                                         TRANSFER_YUV422P_IN_HEAD \
935                                         transfer_YUV_PLANAR_to_RGBA16161616((uint16_t**)(output), \
936                                                 input_y + (y_in_offset), \
937                                                 input_u + (u_in_offset), \
938                                                 input_v + (v_in_offset)); \
939                                         TRANSFER_FRAME_TAIL \
940                                         break; \
941                                 case BC_RGB_FLOAT:      \
942                                         TRANSFER_YUV422P_IN_HEAD \
943                                         transfer_YUV_PLANAR_to_RGB_FLOAT((float**)(output), \
944                                                 input_y + (y_in_offset), \
945                                                 input_u + (u_in_offset), \
946                                                 input_v + (v_in_offset)); \
947                                         TRANSFER_FRAME_TAIL \
948                                         break; \
949                                 case BC_RGBA_FLOAT:      \
950                                         TRANSFER_YUV422P_IN_HEAD \
951                                         transfer_YUV_PLANAR_to_RGBA_FLOAT((float**)(output), \
952                                                 input_y + (y_in_offset), \
953                                                 input_u + (u_in_offset), \
954                                                 input_v + (v_in_offset)); \
955                                         TRANSFER_FRAME_TAIL \
956                                         break; \
957                                 case BC_YUV888: \
958                                         TRANSFER_YUV422P_IN_HEAD \
959                                         transfer_YUV_PLANAR_to_YUV888((output), \
960                                                 input_y + (y_in_offset), \
961                                                 input_u + (u_in_offset), \
962                                                 input_v + (v_in_offset)); \
963                                         TRANSFER_FRAME_TAIL \
964                                         break; \
965                                 case BC_YUVA8888: \
966                                         TRANSFER_YUV422P_IN_HEAD \
967                                         transfer_YUV_PLANAR_to_YUVA8888((output), \
968                                                 input_y + (y_in_offset), \
969                                                 input_u + (u_in_offset), \
970                                                 input_v + (v_in_offset)); \
971                                         TRANSFER_FRAME_TAIL \
972                                         break; \
973                                 case BC_YUV161616: \
974                                         TRANSFER_YUV422P_IN_HEAD \
975                                         transfer_YUV_PLANAR_to_YUV161616((uint16_t**)(output), \
976                                                 input_y + (y_in_offset), \
977                                                 input_u + (u_in_offset), \
978                                                 input_v + (v_in_offset)); \
979                                         TRANSFER_FRAME_TAIL \
980                                         break; \
981                                 case BC_YUVA16161616: \
982                                         TRANSFER_YUV422P_IN_HEAD \
983                                         transfer_YUV_PLANAR_to_YUVA16161616((uint16_t**)(output), \
984                                                 input_y + (y_in_offset), \
985                                                 input_u + (u_in_offset), \
986                                                 input_v + (v_in_offset)); \
987                                         TRANSFER_FRAME_TAIL \
988                                         break; \
989                                 case BC_YUV420P: \
990                                         for(i = 0; i < out_h; i++) \
991                                         { \
992                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
993                                                 unsigned char *output_u = out_u_plane + i / 2 * total_out_w / 2; \
994                                                 unsigned char *output_v = out_v_plane + i / 2 * total_out_w / 2; \
995                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
996                                                 unsigned char *input_u = in_u_plane + row_table[i] * total_in_w / 2; \
997                                                 unsigned char *input_v = in_v_plane + row_table[i] * total_in_w / 2; \
998                                                 for(j = 0; j < out_w; j++) \
999                                                 { \
1000                                                         transfer_YUV_PLANAR_to_YUV420P(input_y + (y_in_offset), \
1001                                                                 input_u + (u_in_offset), \
1002                                                                 input_v + (v_in_offset), \
1003                                                                 output_y, \
1004                                                                 output_u, \
1005                                                                 output_v, \
1006                                                                 j); \
1007                                                 } \
1008                                         } \
1009                                         break; \
1010                                 case BC_YUV422: \
1011                                         TRANSFER_YUV422_IN_HEAD \
1012                                         transfer_YUV_PLANAR_to_YUV422((output), \
1013                                                 input_y + (y_in_offset), \
1014                                                 input_u + (u_in_offset), \
1015                                                 input_v + (v_in_offset), \
1016                                                 j); \
1017                                         TRANSFER_FRAME_TAIL \
1018                                         break; \
1019                                 case BC_YUV422P: \
1020                                         for(i = 0; i < out_h; i++) \
1021                                         { \
1022                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
1023                                                 unsigned char *output_u = out_u_plane + i * total_out_w / 2; \
1024                                                 unsigned char *output_v = out_v_plane + i * total_out_w / 2; \
1025                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
1026                                                 unsigned char *input_u = in_u_plane + row_table[i] * total_in_w / 2; \
1027                                                 unsigned char *input_v = in_v_plane + row_table[i] * total_in_w / 2; \
1028                                                 for(j = 0; j < out_w; j++) \
1029                                                 { \
1030                                                         transfer_YUV_PLANAR_to_YUV420P(input_y + (y_in_offset), \
1031                                                                 input_u + (u_in_offset), \
1032                                                                 input_v + (v_in_offset), \
1033                                                                 output_y, \
1034                                                                 output_u, \
1035                                                                 output_v, \
1036                                                                 j); \
1037                                                 } \
1038                                         } \
1039                                         break; \
1040                                 case BC_YUV444P: \
1041                                         for(i = 0; i < out_h; i++) \
1042                                         { \
1043                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
1044                                                 unsigned char *output_u = out_u_plane + i * total_out_w; \
1045                                                 unsigned char *output_v = out_v_plane + i * total_out_w; \
1046                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
1047                                                 unsigned char *input_u = in_u_plane + row_table[i] * total_in_w / 2; \
1048                                                 unsigned char *input_v = in_v_plane + row_table[i] * total_in_w / 2; \
1049                                                 for(j = 0; j < out_w; j++) \
1050                                                 { \
1051                                                         transfer_YUV_PLANAR_to_YUV444P(input_y + (y_in_offset), \
1052                                                                 input_u + (u_in_offset), \
1053                                                                 input_v + (v_in_offset), \
1054                                                                 output_y, \
1055                                                                 output_u, \
1056                                                                 output_v, \
1057                                                                 j); \
1058                                                 } \
1059                                         } \
1060                                         break; \
1061                         } \
1062                         break; \
1063  \
1064  \
1065                 case BC_YUV444P: \
1066                         switch(out_colormodel) \
1067                         { \
1068                                 case BC_RGB8: \
1069                                         TRANSFER_YUV444P_IN_HEAD \
1070                                         transfer_YUV_PLANAR_to_RGB8((output), \
1071                                                 input_y + (y_in_offset), \
1072                                                 input_u + (u_in_offset), \
1073                                                 input_v + (v_in_offset)); \
1074                                         TRANSFER_FRAME_TAIL \
1075                                         break; \
1076                                 case BC_BGR565: \
1077                                         TRANSFER_YUV444P_IN_HEAD \
1078                                         transfer_YUV_PLANAR_to_BGR565((output), \
1079                                                 input_y + (y_in_offset), \
1080                                                 input_u + (u_in_offset), \
1081                                                 input_v + (v_in_offset)); \
1082                                         TRANSFER_FRAME_TAIL \
1083                                         break; \
1084                                 case BC_RGB565: \
1085                                         TRANSFER_YUV444P_IN_HEAD \
1086                                         transfer_YUV_PLANAR_to_RGB565((output), \
1087                                                 input_y + (y_in_offset), \
1088                                                 input_u + (u_in_offset), \
1089                                                 input_v + (v_in_offset)); \
1090                                         TRANSFER_FRAME_TAIL \
1091                                         break; \
1092                                 case BC_BGR888:      \
1093                                         TRANSFER_YUV444P_IN_HEAD \
1094                                         transfer_YUV_PLANAR_to_BGR888((output), \
1095                                                 input_y + (y_in_offset), \
1096                                                 input_u + (u_in_offset), \
1097                                                 input_v + (v_in_offset)); \
1098                                         TRANSFER_FRAME_TAIL \
1099                                         break; \
1100                                 case BC_BGR8888: \
1101                                         TRANSFER_YUV444P_IN_HEAD \
1102                                         transfer_YUV_PLANAR_to_BGR8888((output), \
1103                                                 input_y + (y_in_offset), \
1104                                                 input_u + (u_in_offset), \
1105                                                 input_v + (v_in_offset)); \
1106                                         TRANSFER_FRAME_TAIL \
1107                                         break; \
1108                                 case BC_RGB888:      \
1109                                         TRANSFER_YUV444P_IN_HEAD \
1110                                         transfer_YUV_PLANAR_to_RGB888((output), \
1111                                                 input_y + (y_in_offset), \
1112                                                 input_u + (u_in_offset), \
1113                                                 input_v + (v_in_offset)); \
1114                                         TRANSFER_FRAME_TAIL \
1115                                         break; \
1116                                 case BC_ARGB8888:      \
1117                                         TRANSFER_YUV444P_IN_HEAD \
1118                                         transfer_YUV_PLANAR_to_ARGB8888((output), \
1119                                                 input_y + (y_in_offset), \
1120                                                 input_u + (u_in_offset), \
1121                                                 input_v + (v_in_offset)); \
1122                                         TRANSFER_FRAME_TAIL \
1123                                         break; \
1124                                 case BC_ABGR8888:      \
1125                                         TRANSFER_YUV444P_IN_HEAD \
1126                                         transfer_YUV_PLANAR_to_ABGR8888((output), \
1127                                                 input_y + (y_in_offset), \
1128                                                 input_u + (u_in_offset), \
1129                                                 input_v + (v_in_offset)); \
1130                                         TRANSFER_FRAME_TAIL \
1131                                         break; \
1132                                 case BC_RGBA8888:      \
1133                                         TRANSFER_YUV444P_IN_HEAD \
1134                                         transfer_YUV_PLANAR_to_RGBA8888((output), \
1135                                                 input_y + (y_in_offset), \
1136                                                 input_u + (u_in_offset), \
1137                                                 input_v + (v_in_offset)); \
1138                                         TRANSFER_FRAME_TAIL \
1139                                         break; \
1140                                 case BC_RGB161616:      \
1141                                         TRANSFER_YUV444P_IN_HEAD \
1142                                         transfer_YUV_PLANAR_to_RGB161616((uint16_t**)(output), \
1143                                                 input_y + (y_in_offset), \
1144                                                 input_u + (u_in_offset), \
1145                                                 input_v + (v_in_offset)); \
1146                                         TRANSFER_FRAME_TAIL \
1147                                         break; \
1148                                 case BC_RGBA16161616:      \
1149                                         TRANSFER_YUV444P_IN_HEAD \
1150                                         transfer_YUV_PLANAR_to_RGBA16161616((uint16_t**)(output), \
1151                                                 input_y + (y_in_offset), \
1152                                                 input_u + (u_in_offset), \
1153                                                 input_v + (v_in_offset)); \
1154                                         TRANSFER_FRAME_TAIL \
1155                                         break; \
1156                                 case BC_RGB_FLOAT:      \
1157                                         TRANSFER_YUV444P_IN_HEAD \
1158                                         transfer_YUV_PLANAR_to_RGB_FLOAT((float**)(output), \
1159                                                 input_y + (y_in_offset), \
1160                                                 input_u + (u_in_offset), \
1161                                                 input_v + (v_in_offset)); \
1162                                         TRANSFER_FRAME_TAIL \
1163                                         break; \
1164                                 case BC_RGBA_FLOAT:      \
1165                                         TRANSFER_YUV444P_IN_HEAD \
1166                                         transfer_YUV_PLANAR_to_RGBA_FLOAT((float**)(output), \
1167                                                 input_y + (y_in_offset), \
1168                                                 input_u + (u_in_offset), \
1169                                                 input_v + (v_in_offset)); \
1170                                         TRANSFER_FRAME_TAIL \
1171                                         break; \
1172                                 case BC_YUV888: \
1173                                         TRANSFER_YUV444P_IN_HEAD \
1174                                         transfer_YUV_PLANAR_to_YUV888((output), \
1175                                                 input_y + (y_in_offset), \
1176                                                 input_u + (u_in_offset), \
1177                                                 input_v + (v_in_offset)); \
1178                                         TRANSFER_FRAME_TAIL \
1179                                         break; \
1180                                 case BC_YUVA8888: \
1181                                         TRANSFER_YUV444P_IN_HEAD \
1182                                         transfer_YUV_PLANAR_to_YUVA8888((output), \
1183                                                 input_y + (y_in_offset), \
1184                                                 input_u + (u_in_offset), \
1185                                                 input_v + (v_in_offset)); \
1186                                         TRANSFER_FRAME_TAIL \
1187                                         break; \
1188                                 case BC_YUV161616: \
1189                                         TRANSFER_YUV444P_IN_HEAD \
1190                                         transfer_YUV_PLANAR_to_YUV161616((uint16_t**)(output), \
1191                                                 input_y + (y_in_offset), \
1192                                                 input_u + (u_in_offset), \
1193                                                 input_v + (v_in_offset)); \
1194                                         TRANSFER_FRAME_TAIL \
1195                                         break; \
1196                                 case BC_YUVA16161616: \
1197                                         TRANSFER_YUV444P_IN_HEAD \
1198                                         transfer_YUV_PLANAR_to_YUVA16161616((uint16_t**)(output), \
1199                                                 input_y + (y_in_offset), \
1200                                                 input_u + (u_in_offset), \
1201                                                 input_v + (v_in_offset)); \
1202                                         TRANSFER_FRAME_TAIL \
1203                                         break; \
1204                                 case BC_YUV420P: \
1205                                         for(i = 0; i < out_h; i++) \
1206                                         { \
1207                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
1208                                                 unsigned char *output_u = out_u_plane + i / 2 * total_out_w / 2; \
1209                                                 unsigned char *output_v = out_v_plane + i / 2 * total_out_w / 2; \
1210                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
1211                                                 unsigned char *input_u = in_u_plane + row_table[i] * total_in_w; \
1212                                                 unsigned char *input_v = in_v_plane + row_table[i] * total_in_w; \
1213                                                 for(j = 0; j < out_w; j++) \
1214                                                 { \
1215                                                         transfer_YUV_PLANAR_to_YUV420P(input_y + (y_in_offset), \
1216                                                                 input_u + (u_in_offset), \
1217                                                                 input_v + (v_in_offset), \
1218                                                                 output_y, \
1219                                                                 output_u, \
1220                                                                 output_v, \
1221                                                                 j); \
1222                                                 } \
1223                                         } \
1224                                         break; \
1225                                 case BC_YUV422: \
1226                                         TRANSFER_YUV444P_IN_HEAD \
1227                                         transfer_YUV_PLANAR_to_YUV422((output), \
1228                                                 input_y + (y_in_offset), \
1229                                                 input_u + (u_in_offset), \
1230                                                 input_v + (v_in_offset), \
1231                                                 j); \
1232                                         TRANSFER_FRAME_TAIL \
1233                                         break; \
1234                                 case BC_YUV422P: \
1235                                         for(i = 0; i < out_h; i++) \
1236                                         { \
1237                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
1238                                                 unsigned char *output_u = out_u_plane + i * total_out_w / 2; \
1239                                                 unsigned char *output_v = out_v_plane + i * total_out_w / 2; \
1240                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
1241                                                 unsigned char *input_u = in_u_plane + row_table[i] * total_in_w; \
1242                                                 unsigned char *input_v = in_v_plane + row_table[i] * total_in_w; \
1243                                                 for(j = 0; j < out_w; j++) \
1244                                                 { \
1245                                                         transfer_YUV_PLANAR_to_YUV420P(input_y + (y_in_offset), \
1246                                                                 input_u + (u_in_offset), \
1247                                                                 input_v + (v_in_offset), \
1248                                                                 output_y, \
1249                                                                 output_u, \
1250                                                                 output_v, \
1251                                                                 j); \
1252                                                 } \
1253                                         } \
1254                                         break; \
1255                                 case BC_YUV444P: \
1256                                         for(i = 0; i < out_h; i++) \
1257                                         { \
1258                                                 unsigned char *output_y = out_y_plane + i * total_out_w; \
1259                                                 unsigned char *output_u = out_u_plane + i * total_out_w; \
1260                                                 unsigned char *output_v = out_v_plane + i * total_out_w; \
1261                                                 unsigned char *input_y = in_y_plane + row_table[i] * total_in_w; \
1262                                                 unsigned char *input_u = in_u_plane + row_table[i] * total_in_w; \
1263                                                 unsigned char *input_v = in_v_plane + row_table[i] * total_in_w; \
1264                                                 for(j = 0; j < out_w; j++) \
1265                                                 { \
1266                                                         transfer_YUV444P_to_YUV444P(input_y + (y_in_offset), \
1267                                                                 input_u + (u_in_offset), \
1268                                                                 input_v + (v_in_offset), \
1269                                                                 output_y, \
1270                                                                 output_u, \
1271                                                                 output_v, \
1272                                                                 j); \
1273                                                 } \
1274                                         } \
1275                                         break; \
1276                         } \
1277                         break; \
1278         } \
1279 }
1280
1281 void cmodel_yuv420p(PERMUTATION_ARGS)
1282 {
1283         if(scale)
1284         {
1285                 TRANSFER_FRAME_DEFAULT(&output_row, 
1286                         input_row + column_table[j] * in_pixelsize,
1287                         column_table[j],
1288                         column_table[j] / 2,
1289                         column_table[j] / 2,
1290                         0);
1291         }
1292         else
1293         {
1294                 TRANSFER_FRAME_DEFAULT(&output_row, 
1295                         input_row + j * in_pixelsize,
1296                         j,
1297                         j / 2,
1298                         j / 2,
1299                         0);
1300         }
1301 }
1302
1303 void cmodel_yuv9p(PERMUTATION_ARGS)
1304 {
1305         if(scale)
1306         {
1307                 TRANSFER_FRAME_DEFAULT(&output_row, 
1308                         input_row + column_table[j] * in_pixelsize,
1309                         column_table[j],
1310                         column_table[j] / 4,
1311                         column_table[j] / 4,
1312                         0);
1313         }
1314         else
1315         {
1316                 TRANSFER_FRAME_DEFAULT(&output_row, 
1317                         input_row + j * in_pixelsize,
1318                         j,
1319                         j / 4,
1320                         j / 4,
1321                         0);
1322         }
1323 }
1324
1325 void cmodel_yuv444p(PERMUTATION_ARGS)
1326 {
1327         if(scale)
1328         {
1329                 TRANSFER_FRAME_DEFAULT(&output_row, 
1330                         input_row + column_table[j] * in_pixelsize,
1331                         column_table[j],
1332                         column_table[j],
1333                         column_table[j],
1334                         0);
1335         }
1336         else
1337         {
1338                 TRANSFER_FRAME_DEFAULT(&output_row, 
1339                         input_row + j * in_pixelsize,
1340                         j,
1341                         j,
1342                         j,
1343                         0);
1344         }
1345 }