📄 cmodel_yuv420p.c
字号:
/******************************************************************************* cmodel_yuv420p.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2007 Members of the libquicktime project. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*******************************************************************************/ #define HAVE_RGB_16_TO_RGB_24#define HAVE_RGB_TO_YUV#define HAVE_RGB_TO_YUVJ#define HAVE_YUV_TO_RGB#define HAVE_YUVJ_TO_RGB#define HAVE_YUV_8_TO_YUVJ#define HAVE_YUVJ_TO_YUV_8#include "lqt_private.h"#include "cmodel_permutation.h"#define TRANSFER_FRAME_DEFAULT(output, \ y_in_offset, \ u_in_offset, \ v_in_offset, \ input_column) \{ \ register int i, j; \ \ switch(in_colormodel) \ { \ case BC_YUV420P: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_YUV420P_IN_HEAD_16 \ transfer_YUV422P_to_BGR565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_YUV420P_IN_HEAD_16 \ transfer_YUV422P_to_RGB565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_BGR888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_BGR8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i / 2 * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i / 2 * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] / 2 * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] / 2 * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_YUV422((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] / 2 * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] / 2 * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV444P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] / 2 * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] / 2 * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV444P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_RGB888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV420P_IN_HEAD_16 \ transfer_YUV422P_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_YUV420P_IN_HEAD_16 \ transfer_YUV422P_to_RGBA16161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_YUVA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ case BC_YUV411P: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV411P_IN_HEAD \ transfer_YUV411P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_YUVJ444P: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUVJ444P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ444P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV444P_to_YUV444P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ \ case BC_YUVJ422P: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUVJ422P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV420P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i / 2 * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i / 2 * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUVJ422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUVJ422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422: \ TRANSFER_YUV422_IN_HEAD \ transfer_YUVJ422P_to_YUV422((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_YUVJ420P: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUVJ420P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ420P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i / 2 * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i / 2 * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] / 2 * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] / 2 * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ \ case BC_YUV422P: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_YUV422P_IN_HEAD_16 \ transfer_YUV422P_to_BGR565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_YUV422P_IN_HEAD_16 \ transfer_YUV422P_to_RGB565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_BGR888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_BGR8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV422P_IN_HEAD_16 \ transfer_YUV422P_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_YUV422P_IN_HEAD_16 \ transfer_YUV422P_to_RGBA16161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_YUVA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -