img_format.c
Go to the documentation of this file.
1 /*
2  * This file is part of MPlayer.
3  *
4  * MPlayer is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * MPlayer is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #include "config.h"
20 #include "img_format.h"
21 #include "stdio.h"
22 #include "libavutil/bswap.h"
23 
24 const char *ff_vo_format_name(int format)
25 {
26  static char unknown_format[20];
27  switch(format)
28  {
29  case IMGFMT_RGB1: return "RGB 1-bit";
30  case IMGFMT_RGB4: return "RGB 4-bit";
31  case IMGFMT_RG4B: return "RGB 4-bit per byte";
32  case IMGFMT_RGB8: return "RGB 8-bit";
33  case IMGFMT_RGB12: return "RGB 12-bit";
34  case IMGFMT_RGB15: return "RGB 15-bit";
35  case IMGFMT_RGB16: return "RGB 16-bit";
36  case IMGFMT_RGB24: return "RGB 24-bit";
37 // case IMGFMT_RGB32: return "RGB 32-bit";
38  case IMGFMT_RGB48LE: return "RGB 48-bit LE";
39  case IMGFMT_RGB48BE: return "RGB 48-bit BE";
40  case IMGFMT_RGB64LE: return "RGB 64-bit LE";
41  case IMGFMT_RGB64BE: return "RGB 64-bit BE";
42  case IMGFMT_BGR1: return "BGR 1-bit";
43  case IMGFMT_BGR4: return "BGR 4-bit";
44  case IMGFMT_BG4B: return "BGR 4-bit per byte";
45  case IMGFMT_BGR8: return "BGR 8-bit";
46  case IMGFMT_BGR12: return "BGR 12-bit";
47  case IMGFMT_BGR15: return "BGR 15-bit";
48  case IMGFMT_BGR16: return "BGR 16-bit";
49  case IMGFMT_BGR24: return "BGR 24-bit";
50 // case IMGFMT_BGR32: return "BGR 32-bit";
51  case IMGFMT_ABGR: return "ABGR";
52  case IMGFMT_BGRA: return "BGRA";
53  case IMGFMT_ARGB: return "ARGB";
54  case IMGFMT_RGBA: return "RGBA";
55  case IMGFMT_GBR24P: return "Planar GBR 24-bit";
56  case IMGFMT_GBR12P: return "Planar GBR 36-bit";
57  case IMGFMT_GBR14P: return "Planar GBR 42-bit";
58  case IMGFMT_YVU9: return "Planar YVU9";
59  case IMGFMT_IF09: return "Planar IF09";
60  case IMGFMT_YV12: return "Planar YV12";
61  case IMGFMT_I420: return "Planar I420";
62  case IMGFMT_IYUV: return "Planar IYUV";
63  case IMGFMT_CLPL: return "Planar CLPL";
64  case IMGFMT_Y800: return "Planar Y800";
65  case IMGFMT_Y8: return "Planar Y8";
66  case IMGFMT_Y8A: return "Planar Y8 with alpha";
67  case IMGFMT_Y16_LE: return "Planar Y16 little-endian";
68  case IMGFMT_Y16_BE: return "Planar Y16 big-endian";
69  case IMGFMT_420P16_LE: return "Planar 420P 16-bit little-endian";
70  case IMGFMT_420P16_BE: return "Planar 420P 16-bit big-endian";
71  case IMGFMT_420P14_LE: return "Planar 420P 14-bit little-endian";
72  case IMGFMT_420P14_BE: return "Planar 420P 14-bit big-endian";
73  case IMGFMT_420P12_LE: return "Planar 420P 12-bit little-endian";
74  case IMGFMT_420P12_BE: return "Planar 420P 12-bit big-endian";
75  case IMGFMT_420P10_LE: return "Planar 420P 10-bit little-endian";
76  case IMGFMT_420P10_BE: return "Planar 420P 10-bit big-endian";
77  case IMGFMT_420P9_LE: return "Planar 420P 9-bit little-endian";
78  case IMGFMT_420P9_BE: return "Planar 420P 9-bit big-endian";
79  case IMGFMT_422P16_LE: return "Planar 422P 16-bit little-endian";
80  case IMGFMT_422P16_BE: return "Planar 422P 16-bit big-endian";
81  case IMGFMT_422P14_LE: return "Planar 422P 14-bit little-endian";
82  case IMGFMT_422P14_BE: return "Planar 422P 14-bit big-endian";
83  case IMGFMT_422P12_LE: return "Planar 422P 12-bit little-endian";
84  case IMGFMT_422P12_BE: return "Planar 422P 12-bit big-endian";
85  case IMGFMT_422P10_LE: return "Planar 422P 10-bit little-endian";
86  case IMGFMT_422P10_BE: return "Planar 422P 10-bit big-endian";
87  case IMGFMT_422P9_LE: return "Planar 422P 9-bit little-endian";
88  case IMGFMT_422P9_BE: return "Planar 422P 9-bit big-endian";
89  case IMGFMT_444P16_LE: return "Planar 444P 16-bit little-endian";
90  case IMGFMT_444P16_BE: return "Planar 444P 16-bit big-endian";
91  case IMGFMT_444P14_LE: return "Planar 444P 14-bit little-endian";
92  case IMGFMT_444P14_BE: return "Planar 444P 14-bit big-endian";
93  case IMGFMT_444P12_LE: return "Planar 444P 12-bit little-endian";
94  case IMGFMT_444P12_BE: return "Planar 444P 12-bit big-endian";
95  case IMGFMT_444P10_LE: return "Planar 444P 10-bit little-endian";
96  case IMGFMT_444P10_BE: return "Planar 444P 10-bit big-endian";
97  case IMGFMT_444P9_LE: return "Planar 444P 9-bit little-endian";
98  case IMGFMT_444P9_BE: return "Planar 444P 9-bit big-endian";
99  case IMGFMT_420A: return "Planar 420P with alpha";
100  case IMGFMT_444P: return "Planar 444P";
101  case IMGFMT_444A: return "Planar 444P with alpha";
102  case IMGFMT_422P: return "Planar 422P";
103  case IMGFMT_422A: return "Planar 422P with alpha";
104  case IMGFMT_411P: return "Planar 411P";
105  case IMGFMT_NV12: return "Planar NV12";
106  case IMGFMT_NV21: return "Planar NV21";
107  case IMGFMT_HM12: return "Planar NV12 Macroblock";
108  case IMGFMT_IUYV: return "Packed IUYV";
109  case IMGFMT_IY41: return "Packed IY41";
110  case IMGFMT_IYU1: return "Packed IYU1";
111  case IMGFMT_IYU2: return "Packed IYU2";
112  case IMGFMT_UYVY: return "Packed UYVY";
113  case IMGFMT_UYNV: return "Packed UYNV";
114  case IMGFMT_cyuv: return "Packed CYUV";
115  case IMGFMT_Y422: return "Packed Y422";
116  case IMGFMT_YUY2: return "Packed YUY2";
117  case IMGFMT_YUNV: return "Packed YUNV";
118  case IMGFMT_YVYU: return "Packed YVYU";
119  case IMGFMT_Y41P: return "Packed Y41P";
120  case IMGFMT_Y211: return "Packed Y211";
121  case IMGFMT_Y41T: return "Packed Y41T";
122  case IMGFMT_Y42T: return "Packed Y42T";
123  case IMGFMT_V422: return "Packed V422";
124  case IMGFMT_V655: return "Packed V655";
125  case IMGFMT_CLJR: return "Packed CLJR";
126  case IMGFMT_YUVP: return "Packed YUVP";
127  case IMGFMT_UYVP: return "Packed UYVP";
128  case IMGFMT_MPEGPES: return "Mpeg PES";
129  case IMGFMT_ZRMJPEGNI: return "Zoran MJPEG non-interlaced";
130  case IMGFMT_ZRMJPEGIT: return "Zoran MJPEG top field first";
131  case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first";
132  case IMGFMT_XVMC_MOCO_MPEG2: return "MPEG1/2 Motion Compensation";
133  case IMGFMT_XVMC_IDCT_MPEG2: return "MPEG1/2 Motion Compensation and IDCT";
134  case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration";
135  case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration";
136  case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration";
137  case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration";
138  case IMGFMT_VDPAU_WMV3: return "WMV3 VDPAU acceleration";
139  case IMGFMT_VDPAU_VC1: return "VC1 VDPAU acceleration";
140  }
141  snprintf(unknown_format,20,"Unknown 0x%04x",format);
142  return unknown_format;
143 }
144 
145 int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift, int *component_bits)
146 {
147  int xs = 0, ys = 0;
148  int bpp;
149  int err = 0;
150  int bits = 8;
151  if ((format & 0xff0000f0) == 0x34000050)
152  format = av_bswap32(format);
153  if ((format & 0xf00000ff) == 0x50000034) {
154  switch (format >> 24) {
155  case 0x50:
156  break;
157  case 0x51:
158  bits = 16;
159  break;
160  case 0x52:
161  bits = 10;
162  break;
163  case 0x53:
164  bits = 9;
165  break;
166  default:
167  err = 1;
168  break;
169  }
170  switch (format & 0x00ffffff) {
171  case 0x00343434: // 444
172  xs = 0;
173  ys = 0;
174  break;
175  case 0x00323234: // 422
176  xs = 1;
177  ys = 0;
178  break;
179  case 0x00303234: // 420
180  xs = 1;
181  ys = 1;
182  break;
183  case 0x00313134: // 411
184  xs = 2;
185  ys = 0;
186  break;
187  case 0x00303434: // 440
188  xs = 0;
189  ys = 1;
190  break;
191  default:
192  err = 1;
193  break;
194  }
195  } else switch (format) {
196  case IMGFMT_444A:
197  xs = 0;
198  ys = 0;
199  break;
200  case IMGFMT_422A:
201  xs = 1;
202  ys = 0;
203  break;
204  case IMGFMT_420A:
205  case IMGFMT_I420:
206  case IMGFMT_IYUV:
207  case IMGFMT_YV12:
208  xs = 1;
209  ys = 1;
210  break;
211  case IMGFMT_IF09:
212  case IMGFMT_YVU9:
213  xs = 2;
214  ys = 2;
215  break;
216  case IMGFMT_Y8:
217  case IMGFMT_Y800:
218  xs = 31;
219  ys = 31;
220  break;
221  default:
222  err = 1;
223  break;
224  }
225  if (x_shift) *x_shift = xs;
226  if (y_shift) *y_shift = ys;
227  if (component_bits) *component_bits = bits;
228  bpp = 8 + ((16 >> xs) >> ys);
229  if (format == IMGFMT_420A || format == IMGFMT_422A || format == IMGFMT_444A)
230  bpp += 8;
231  bpp *= (bits + 7) >> 3;
232  return err ? 0 : bpp;
233 }
#define IMGFMT_YUY2
Definition: img_format.h:240
output sine component ys
#define IMGFMT_444P16_LE
Definition: img_format.h:146
#define IMGFMT_444P14_LE
Definition: img_format.h:148
#define IMGFMT_XVMC_MOCO_MPEG2
Definition: img_format.h:267
#define IMGFMT_Y16_BE
Definition: img_format.h:135
#define IMGFMT_RGB4
Definition: img_format.h:29
#define IMGFMT_Y42T
Definition: img_format.h:246
#define IMGFMT_Y8A
Definition: img_format.h:138
#define IMGFMT_422P16_LE
Definition: img_format.h:156
#define IMGFMT_UYNV
Definition: img_format.h:237
#define IMGFMT_V655
Definition: img_format.h:248
#define IMGFMT_RGB48LE
Definition: img_format.h:37
#define IMGFMT_GBR12P
Definition: img_format.h:100
#define IMGFMT_444P12_LE
Definition: img_format.h:150
#define IMGFMT_RGBA
Definition: img_format.h:85
#define IMGFMT_NV12
Definition: img_format.h:125
#define IMGFMT_420P9_BE
Definition: img_format.h:175
#define IMGFMT_BGR24
Definition: img_format.h:51
#define IMGFMT_YVU9
Definition: img_format.h:117
#define IMGFMT_420P14_LE
Definition: img_format.h:168
#define IMGFMT_UYVY
Definition: img_format.h:236
#define IMGFMT_RGB12
Definition: img_format.h:32
#define IMGFMT_YV12
Definition: img_format.h:119
#define IMGFMT_BGR15
Definition: img_format.h:49
#define IMGFMT_Y8
Definition: img_format.h:124
#define IMGFMT_420P10_LE
Definition: img_format.h:172
#define IMGFMT_GBR14P
Definition: img_format.h:101
#define IMGFMT_Y422
Definition: img_format.h:239
uint8_t bits
Definition: crc.c:216
#define IMGFMT_CLPL
Definition: img_format.h:122
#define IMGFMT_444P9_LE
Definition: img_format.h:154
#define IMGFMT_XVMC_IDCT_MPEG2
Definition: img_format.h:268
#define IMGFMT_IY41
Definition: img_format.h:233
#define IMGFMT_IYU2
Definition: img_format.h:235
#define IMGFMT_444P16_BE
Definition: img_format.h:147
const char * ff_vo_format_name(int format)
Definition: img_format.c:24
#define IMGFMT_422P9_BE
Definition: img_format.h:165
#define IMGFMT_444P9_BE
Definition: img_format.h:155
#define IMGFMT_ZRMJPEGNI
Definition: img_format.h:258
#define IMGFMT_ARGB
Definition: img_format.h:84
#define IMGFMT_444A
Definition: img_format.h:144
#define IMGFMT_BG4B
Definition: img_format.h:106
#define IMGFMT_YVYU
Definition: img_format.h:242
#define IMGFMT_444P10_BE
Definition: img_format.h:153
#define IMGFMT_GBR24P
Definition: img_format.h:54
#define IMGFMT_IF09
Definition: img_format.h:118
#define IMGFMT_422P12_LE
Definition: img_format.h:160
#define IMGFMT_422P14_LE
Definition: img_format.h:158
#define IMGFMT_RGB48BE
Definition: img_format.h:38
#define IMGFMT_422P10_BE
Definition: img_format.h:163
#define IMGFMT_BGR16
Definition: img_format.h:50
#define IMGFMT_422P12_BE
Definition: img_format.h:161
#define IMGFMT_422P16_BE
Definition: img_format.h:157
#define IMGFMT_IYUV
Definition: img_format.h:121
#define IMGFMT_NV21
Definition: img_format.h:126
#define IMGFMT_Y41P
Definition: img_format.h:243
#define IMGFMT_IYU1
Definition: img_format.h:234
#define IMGFMT_YUNV
Definition: img_format.h:241
#define IMGFMT_422A
Definition: img_format.h:142
#define IMGFMT_444P12_BE
Definition: img_format.h:151
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate.The lists are not just lists
#define IMGFMT_RGB15
Definition: img_format.h:33
#define IMGFMT_VDPAU_MPEG1
Definition: img_format.h:274
#define IMGFMT_Y211
Definition: img_format.h:244
#define IMGFMT_BGR12
Definition: img_format.h:48
#define IMGFMT_Y41T
Definition: img_format.h:245
#define IMGFMT_444P10_LE
Definition: img_format.h:152
#define IMGFMT_RGB16
Definition: img_format.h:34
#define av_bswap32
Definition: bfin/bswap.h:33
#define IMGFMT_RGB64BE
Definition: img_format.h:40
#define IMGFMT_YUVP
Definition: img_format.h:250
#define IMGFMT_420P16_LE
Definition: img_format.h:166
#define IMGFMT_VDPAU_H264
Definition: img_format.h:276
#define IMGFMT_444P14_BE
Definition: img_format.h:149
#define IMGFMT_RG4B
Definition: img_format.h:105
#define IMGFMT_V422
Definition: img_format.h:247
byte swapping routines
#define IMGFMT_HM12
Definition: img_format.h:134
#define IMGFMT_Y800
Definition: img_format.h:123
#define IMGFMT_RGB1
Definition: img_format.h:28
#define IMGFMT_422P
Definition: img_format.h:131
#define IMGFMT_422P10_LE
Definition: img_format.h:162
#define snprintf
Definition: snprintf.h:34
#define IMGFMT_MPEGPES
Definition: img_format.h:254
#define IMGFMT_ZRMJPEGIT
Definition: img_format.h:259
#define IMGFMT_422P9_LE
Definition: img_format.h:164
#define IMGFMT_420P10_BE
Definition: img_format.h:173
#define IMGFMT_420P16_BE
Definition: img_format.h:167
#define IMGFMT_ABGR
Definition: img_format.h:82
#define IMGFMT_RGB64LE
Definition: img_format.h:39
#define IMGFMT_BGR4
Definition: img_format.h:45
#define IMGFMT_420P14_BE
Definition: img_format.h:169
#define IMGFMT_BGR8
Definition: img_format.h:47
#define IMGFMT_444P
Definition: img_format.h:130
#define IMGFMT_Y16_LE
Definition: img_format.h:127
#define IMGFMT_RGB24
Definition: img_format.h:35
#define IMGFMT_BGRA
Definition: img_format.h:83
#define IMGFMT_420P12_LE
Definition: img_format.h:170
int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift, int *component_bits)
Calculates the scale shifts for the chroma planes for planar YUV.
Definition: img_format.c:145
#define IMGFMT_IUYV
Definition: img_format.h:232
#define IMGFMT_VDPAU_VC1
Definition: img_format.h:278
#define IMGFMT_BGR1
Definition: img_format.h:44
#define IMGFMT_cyuv
Definition: img_format.h:238
#define IMGFMT_420P9_LE
Definition: img_format.h:174
#define IMGFMT_422P14_BE
Definition: img_format.h:159
#define IMGFMT_VDPAU_WMV3
Definition: img_format.h:277
#define IMGFMT_ZRMJPEGIB
Definition: img_format.h:260
#define IMGFMT_UYVP
Definition: img_format.h:251
#define IMGFMT_RGB8
Definition: img_format.h:31
#define IMGFMT_420A
Definition: img_format.h:140
#define IMGFMT_VDPAU_MPEG2
Definition: img_format.h:275
#define IMGFMT_VDPAU_MPEG4
Definition: img_format.h:279
#define IMGFMT_I420
Definition: img_format.h:120
#define IMGFMT_420P12_BE
Definition: img_format.h:171
#define IMGFMT_CLJR
Definition: img_format.h:249
#define IMGFMT_411P
Definition: img_format.h:132