Statistics
| Branch: | Revision:

ffmpeg / libavfilter / libmpcodecs / img_format.c @ e4852fb3

History | View | Annotate | Download (5.89 KB)

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

    
23
const char *vo_format_name(int format)
24
{
25
    static char unknown_format[20];
26
    switch(format)
27
    {
28
    case IMGFMT_RGB1: return "RGB 1-bit";
29
    case IMGFMT_RGB4: return "RGB 4-bit";
30
    case IMGFMT_RG4B: return "RGB 4-bit per byte";
31
    case IMGFMT_RGB8: return "RGB 8-bit";
32
    case IMGFMT_RGB12: return "RGB 12-bit";
33
    case IMGFMT_RGB15: return "RGB 15-bit";
34
    case IMGFMT_RGB16: return "RGB 16-bit";
35
    case IMGFMT_RGB24: return "RGB 24-bit";
36
//  case IMGFMT_RGB32: return "RGB 32-bit";
37
    case IMGFMT_RGB48LE: return "RGB 48-bit LE";
38
    case IMGFMT_RGB48BE: return "RGB 48-bit BE";
39
    case IMGFMT_BGR1: return "BGR 1-bit";
40
    case IMGFMT_BGR4: return "BGR 4-bit";
41
    case IMGFMT_BG4B: return "BGR 4-bit per byte";
42
    case IMGFMT_BGR8: return "BGR 8-bit";
43
    case IMGFMT_BGR12: return "BGR 12-bit";
44
    case IMGFMT_BGR15: return "BGR 15-bit";
45
    case IMGFMT_BGR16: return "BGR 16-bit";
46
    case IMGFMT_BGR24: return "BGR 24-bit";
47
//  case IMGFMT_BGR32: return "BGR 32-bit";
48
    case IMGFMT_ABGR: return "ABGR";
49
    case IMGFMT_BGRA: return "BGRA";
50
    case IMGFMT_ARGB: return "ARGB";
51
    case IMGFMT_RGBA: return "RGBA";
52
    case IMGFMT_YVU9: return "Planar YVU9";
53
    case IMGFMT_IF09: return "Planar IF09";
54
    case IMGFMT_YV12: return "Planar YV12";
55
    case IMGFMT_I420: return "Planar I420";
56
    case IMGFMT_IYUV: return "Planar IYUV";
57
    case IMGFMT_CLPL: return "Planar CLPL";
58
    case IMGFMT_Y800: return "Planar Y800";
59
    case IMGFMT_Y8: return "Planar Y8";
60
    case IMGFMT_420P16_LE: return "Planar 420P 16-bit little-endian";
61
    case IMGFMT_420P16_BE: return "Planar 420P 16-bit big-endian";
62
    case IMGFMT_422P16_LE: return "Planar 422P 16-bit little-endian";
63
    case IMGFMT_422P16_BE: return "Planar 422P 16-bit big-endian";
64
    case IMGFMT_444P16_LE: return "Planar 444P 16-bit little-endian";
65
    case IMGFMT_444P16_BE: return "Planar 444P 16-bit big-endian";
66
    case IMGFMT_420A: return "Planar 420P with alpha";
67
    case IMGFMT_444P: return "Planar 444P";
68
    case IMGFMT_422P: return "Planar 422P";
69
    case IMGFMT_411P: return "Planar 411P";
70
    case IMGFMT_NV12: return "Planar NV12";
71
    case IMGFMT_NV21: return "Planar NV21";
72
    case IMGFMT_HM12: return "Planar NV12 Macroblock";
73
    case IMGFMT_IUYV: return "Packed IUYV";
74
    case IMGFMT_IY41: return "Packed IY41";
75
    case IMGFMT_IYU1: return "Packed IYU1";
76
    case IMGFMT_IYU2: return "Packed IYU2";
77
    case IMGFMT_UYVY: return "Packed UYVY";
78
    case IMGFMT_UYNV: return "Packed UYNV";
79
    case IMGFMT_cyuv: return "Packed CYUV";
80
    case IMGFMT_Y422: return "Packed Y422";
81
    case IMGFMT_YUY2: return "Packed YUY2";
82
    case IMGFMT_YUNV: return "Packed YUNV";
83
    case IMGFMT_YVYU: return "Packed YVYU";
84
    case IMGFMT_Y41P: return "Packed Y41P";
85
    case IMGFMT_Y211: return "Packed Y211";
86
    case IMGFMT_Y41T: return "Packed Y41T";
87
    case IMGFMT_Y42T: return "Packed Y42T";
88
    case IMGFMT_V422: return "Packed V422";
89
    case IMGFMT_V655: return "Packed V655";
90
    case IMGFMT_CLJR: return "Packed CLJR";
91
    case IMGFMT_YUVP: return "Packed YUVP";
92
    case IMGFMT_UYVP: return "Packed UYVP";
93
    case IMGFMT_MPEGPES: return "Mpeg PES";
94
    case IMGFMT_ZRMJPEGNI: return "Zoran MJPEG non-interlaced";
95
    case IMGFMT_ZRMJPEGIT: return "Zoran MJPEG top field first";
96
    case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first";
97
    case IMGFMT_XVMC_MOCO_MPEG2: return "MPEG1/2 Motion Compensation";
98
    case IMGFMT_XVMC_IDCT_MPEG2: return "MPEG1/2 Motion Compensation and IDCT";
99
    case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration";
100
    case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration";
101
    case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration";
102
    case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration";
103
    case IMGFMT_VDPAU_WMV3: return "WMV3 VDPAU acceleration";
104
    case IMGFMT_VDPAU_VC1: return "VC1 VDPAU acceleration";
105
    }
106
    snprintf(unknown_format,20,"Unknown 0x%04x",format);
107
    return unknown_format;
108
}
109

    
110
int mp_get_chroma_shift(int format, int *x_shift, int *y_shift)
111
{
112
    int xs = 0, ys = 0;
113
    int bpp;
114
    int bpp_factor = 1;
115
    int err = 0;
116
    switch (format) {
117
    case IMGFMT_420P16_LE:
118
    case IMGFMT_420P16_BE:
119
        bpp_factor = 2;
120
    case IMGFMT_420A:
121
    case IMGFMT_I420:
122
    case IMGFMT_IYUV:
123
    case IMGFMT_YV12:
124
        xs = 1;
125
        ys = 1;
126
        break;
127
    case IMGFMT_IF09:
128
    case IMGFMT_YVU9:
129
        xs = 2;
130
        ys = 2;
131
        break;
132
    case IMGFMT_444P16_LE:
133
    case IMGFMT_444P16_BE:
134
        bpp_factor = 2;
135
    case IMGFMT_444P:
136
        xs = 0;
137
        ys = 0;
138
        break;
139
    case IMGFMT_422P16_LE:
140
    case IMGFMT_422P16_BE:
141
        bpp_factor = 2;
142
    case IMGFMT_422P:
143
        xs = 1;
144
        ys = 0;
145
        break;
146
    case IMGFMT_411P:
147
        xs = 2;
148
        ys = 0;
149
        break;
150
    case IMGFMT_440P:
151
        xs = 0;
152
        ys = 1;
153
        break;
154
    case IMGFMT_Y8:
155
    case IMGFMT_Y800:
156
        xs = 31;
157
        ys = 31;
158
        break;
159
    default:
160
        err = 1;
161
        break;
162
    }
163
    if (x_shift) *x_shift = xs;
164
    if (y_shift) *y_shift = ys;
165
    bpp = 8 + ((16 >> xs) >> ys);
166
    if (format == IMGFMT_420A)
167
        bpp += 8;
168
    bpp *= bpp_factor;
169
    return err ? 0 : bpp;
170
}