00001 /* 00002 * This file is part of MPlayer. 00003 * 00004 * MPlayer is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * MPlayer is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with MPlayer; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #include "config.h" 00020 #include "img_format.h" 00021 #include "stdio.h" 00022 00023 const char *vo_format_name(int format) 00024 { 00025 static char unknown_format[20]; 00026 switch(format) 00027 { 00028 case IMGFMT_RGB1: return "RGB 1-bit"; 00029 case IMGFMT_RGB4: return "RGB 4-bit"; 00030 case IMGFMT_RG4B: return "RGB 4-bit per byte"; 00031 case IMGFMT_RGB8: return "RGB 8-bit"; 00032 case IMGFMT_RGB12: return "RGB 12-bit"; 00033 case IMGFMT_RGB15: return "RGB 15-bit"; 00034 case IMGFMT_RGB16: return "RGB 16-bit"; 00035 case IMGFMT_RGB24: return "RGB 24-bit"; 00036 // case IMGFMT_RGB32: return "RGB 32-bit"; 00037 case IMGFMT_RGB48LE: return "RGB 48-bit LE"; 00038 case IMGFMT_RGB48BE: return "RGB 48-bit BE"; 00039 case IMGFMT_BGR1: return "BGR 1-bit"; 00040 case IMGFMT_BGR4: return "BGR 4-bit"; 00041 case IMGFMT_BG4B: return "BGR 4-bit per byte"; 00042 case IMGFMT_BGR8: return "BGR 8-bit"; 00043 case IMGFMT_BGR12: return "BGR 12-bit"; 00044 case IMGFMT_BGR15: return "BGR 15-bit"; 00045 case IMGFMT_BGR16: return "BGR 16-bit"; 00046 case IMGFMT_BGR24: return "BGR 24-bit"; 00047 // case IMGFMT_BGR32: return "BGR 32-bit"; 00048 case IMGFMT_ABGR: return "ABGR"; 00049 case IMGFMT_BGRA: return "BGRA"; 00050 case IMGFMT_ARGB: return "ARGB"; 00051 case IMGFMT_RGBA: return "RGBA"; 00052 case IMGFMT_YVU9: return "Planar YVU9"; 00053 case IMGFMT_IF09: return "Planar IF09"; 00054 case IMGFMT_YV12: return "Planar YV12"; 00055 case IMGFMT_I420: return "Planar I420"; 00056 case IMGFMT_IYUV: return "Planar IYUV"; 00057 case IMGFMT_CLPL: return "Planar CLPL"; 00058 case IMGFMT_Y800: return "Planar Y800"; 00059 case IMGFMT_Y8: return "Planar Y8"; 00060 case IMGFMT_420P16_LE: return "Planar 420P 16-bit little-endian"; 00061 case IMGFMT_420P16_BE: return "Planar 420P 16-bit big-endian"; 00062 case IMGFMT_422P16_LE: return "Planar 422P 16-bit little-endian"; 00063 case IMGFMT_422P16_BE: return "Planar 422P 16-bit big-endian"; 00064 case IMGFMT_444P16_LE: return "Planar 444P 16-bit little-endian"; 00065 case IMGFMT_444P16_BE: return "Planar 444P 16-bit big-endian"; 00066 case IMGFMT_420A: return "Planar 420P with alpha"; 00067 case IMGFMT_444P: return "Planar 444P"; 00068 case IMGFMT_422P: return "Planar 422P"; 00069 case IMGFMT_411P: return "Planar 411P"; 00070 case IMGFMT_NV12: return "Planar NV12"; 00071 case IMGFMT_NV21: return "Planar NV21"; 00072 case IMGFMT_HM12: return "Planar NV12 Macroblock"; 00073 case IMGFMT_IUYV: return "Packed IUYV"; 00074 case IMGFMT_IY41: return "Packed IY41"; 00075 case IMGFMT_IYU1: return "Packed IYU1"; 00076 case IMGFMT_IYU2: return "Packed IYU2"; 00077 case IMGFMT_UYVY: return "Packed UYVY"; 00078 case IMGFMT_UYNV: return "Packed UYNV"; 00079 case IMGFMT_cyuv: return "Packed CYUV"; 00080 case IMGFMT_Y422: return "Packed Y422"; 00081 case IMGFMT_YUY2: return "Packed YUY2"; 00082 case IMGFMT_YUNV: return "Packed YUNV"; 00083 case IMGFMT_YVYU: return "Packed YVYU"; 00084 case IMGFMT_Y41P: return "Packed Y41P"; 00085 case IMGFMT_Y211: return "Packed Y211"; 00086 case IMGFMT_Y41T: return "Packed Y41T"; 00087 case IMGFMT_Y42T: return "Packed Y42T"; 00088 case IMGFMT_V422: return "Packed V422"; 00089 case IMGFMT_V655: return "Packed V655"; 00090 case IMGFMT_CLJR: return "Packed CLJR"; 00091 case IMGFMT_YUVP: return "Packed YUVP"; 00092 case IMGFMT_UYVP: return "Packed UYVP"; 00093 case IMGFMT_MPEGPES: return "Mpeg PES"; 00094 case IMGFMT_ZRMJPEGNI: return "Zoran MJPEG non-interlaced"; 00095 case IMGFMT_ZRMJPEGIT: return "Zoran MJPEG top field first"; 00096 case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first"; 00097 case IMGFMT_XVMC_MOCO_MPEG2: return "MPEG1/2 Motion Compensation"; 00098 case IMGFMT_XVMC_IDCT_MPEG2: return "MPEG1/2 Motion Compensation and IDCT"; 00099 case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration"; 00100 case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration"; 00101 case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration"; 00102 case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration"; 00103 case IMGFMT_VDPAU_WMV3: return "WMV3 VDPAU acceleration"; 00104 case IMGFMT_VDPAU_VC1: return "VC1 VDPAU acceleration"; 00105 } 00106 snprintf(unknown_format,20,"Unknown 0x%04x",format); 00107 return unknown_format; 00108 } 00109 00110 int mp_get_chroma_shift(int format, int *x_shift, int *y_shift) 00111 { 00112 int xs = 0, ys = 0; 00113 int bpp; 00114 int bpp_factor = 1; 00115 int err = 0; 00116 switch (format) { 00117 case IMGFMT_420P16_LE: 00118 case IMGFMT_420P16_BE: 00119 bpp_factor = 2; 00120 case IMGFMT_420A: 00121 case IMGFMT_I420: 00122 case IMGFMT_IYUV: 00123 case IMGFMT_YV12: 00124 xs = 1; 00125 ys = 1; 00126 break; 00127 case IMGFMT_IF09: 00128 case IMGFMT_YVU9: 00129 xs = 2; 00130 ys = 2; 00131 break; 00132 case IMGFMT_444P16_LE: 00133 case IMGFMT_444P16_BE: 00134 bpp_factor = 2; 00135 case IMGFMT_444P: 00136 xs = 0; 00137 ys = 0; 00138 break; 00139 case IMGFMT_422P16_LE: 00140 case IMGFMT_422P16_BE: 00141 bpp_factor = 2; 00142 case IMGFMT_422P: 00143 xs = 1; 00144 ys = 0; 00145 break; 00146 case IMGFMT_411P: 00147 xs = 2; 00148 ys = 0; 00149 break; 00150 case IMGFMT_440P: 00151 xs = 0; 00152 ys = 1; 00153 break; 00154 case IMGFMT_Y8: 00155 case IMGFMT_Y800: 00156 xs = 31; 00157 ys = 31; 00158 break; 00159 default: 00160 err = 1; 00161 break; 00162 } 00163 if (x_shift) *x_shift = xs; 00164 if (y_shift) *y_shift = ys; 00165 bpp = 8 + ((16 >> xs) >> ys); 00166 if (format == IMGFMT_420A) 00167 bpp += 8; 00168 bpp *= bpp_factor; 00169 return err ? 0 : bpp; 00170 }