annotate fmt-conversion.c @ 29491:99eda963d27a

Fix incorrect channel ordering for lavc audio codecs (specifically ffac3, ffdca, ffflac, ffaac, fftruehd). In the process, adds support for 32-bit samples.
author tack
date Tue, 18 Aug 2009 22:24:36 +0000
parents 3e9db1ac8cf1
children f6d56a15f1d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28526
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
1 /*
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
2 * This file is part of MPlayer.
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
3 *
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
7 * (at your option) any later version.
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
8 *
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
12 * GNU General Public License for more details.
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
13 *
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License along
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
17 */
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
18
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
19 #include "mp_msg.h"
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
20 #include "libavutil/avutil.h"
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
21 #include "libmpcodecs/img_format.h"
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
22 #include "fmt-conversion.h"
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
23
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
24 static const struct {
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
25 int fmt;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
26 enum PixelFormat pix_fmt;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
27 } conversion_map[] = {
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
28 {IMGFMT_BGR32, PIX_FMT_RGB32},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
29 {IMGFMT_BGR24, PIX_FMT_BGR24},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
30 {IMGFMT_BGR16, PIX_FMT_RGB565},
29078
a4210116367f 100l, add forgotten BGR15 format to fmt-conversion.c table
reimar
parents: 28631
diff changeset
31 {IMGFMT_BGR15, PIX_FMT_RGB555},
28526
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
32 {IMGFMT_BGR8, PIX_FMT_RGB8},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
33 {IMGFMT_BGR4, PIX_FMT_RGB4},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
34 {IMGFMT_BGR1, PIX_FMT_MONOBLACK},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
35 {IMGFMT_RGB1, PIX_FMT_MONOBLACK},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
36 {IMGFMT_RG4B, PIX_FMT_BGR4_BYTE},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
37 {IMGFMT_BG4B, PIX_FMT_RGB4_BYTE},
29445
3e9db1ac8cf1 Map IMGFMT_RGB48xE to PIX_FMT_RGB48xE.
cehoyos
parents: 29078
diff changeset
38 {IMGFMT_RGB48LE, PIX_FMT_RGB48LE},
3e9db1ac8cf1 Map IMGFMT_RGB48xE to PIX_FMT_RGB48xE.
cehoyos
parents: 29078
diff changeset
39 {IMGFMT_RGB48BE, PIX_FMT_RGB48BE},
28526
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
40 {IMGFMT_RGB32, PIX_FMT_BGR32},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
41 {IMGFMT_RGB24, PIX_FMT_RGB24},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
42 {IMGFMT_RGB16, PIX_FMT_BGR565},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
43 {IMGFMT_RGB15, PIX_FMT_BGR555},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
44 {IMGFMT_RGB8, PIX_FMT_BGR8},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
45 {IMGFMT_RGB4, PIX_FMT_BGR4},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
46 {IMGFMT_BGR8, PIX_FMT_PAL8},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
47 {IMGFMT_YUY2, PIX_FMT_YUYV422},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
48 {IMGFMT_UYVY, PIX_FMT_UYVY422},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
49 {IMGFMT_NV12, PIX_FMT_NV12},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
50 {IMGFMT_NV21, PIX_FMT_NV21},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
51 {IMGFMT_Y800, PIX_FMT_GRAY8},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
52 {IMGFMT_Y8, PIX_FMT_GRAY8},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
53 {IMGFMT_YVU9, PIX_FMT_YUV410P},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
54 {IMGFMT_IF09, PIX_FMT_YUV410P},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
55 {IMGFMT_YV12, PIX_FMT_YUV420P},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
56 {IMGFMT_I420, PIX_FMT_YUV420P},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
57 {IMGFMT_IYUV, PIX_FMT_YUV420P},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
58 {IMGFMT_411P, PIX_FMT_YUV411P},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
59 {IMGFMT_422P, PIX_FMT_YUV422P},
28631
70a43ec47c61 Re-add accidentally discarded comment about YUVJ format.
reimar
parents: 28526
diff changeset
60 {IMGFMT_444P, PIX_FMT_YUV444P},
70a43ec47c61 Re-add accidentally discarded comment about YUVJ format.
reimar
parents: 28526
diff changeset
61
70a43ec47c61 Re-add accidentally discarded comment about YUVJ format.
reimar
parents: 28526
diff changeset
62 // YUVJ are YUV formats that use the full Y range and not just
70a43ec47c61 Re-add accidentally discarded comment about YUVJ format.
reimar
parents: 28526
diff changeset
63 // 16 - 235 (see colorspaces.txt).
70a43ec47c61 Re-add accidentally discarded comment about YUVJ format.
reimar
parents: 28526
diff changeset
64 // Currently they are all treated the same way.
70a43ec47c61 Re-add accidentally discarded comment about YUVJ format.
reimar
parents: 28526
diff changeset
65 {IMGFMT_YV12, PIX_FMT_YUVJ420P},
28526
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
66 {IMGFMT_422P, PIX_FMT_YUVJ422P},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
67 {IMGFMT_444P, PIX_FMT_YUVJ444P},
28631
70a43ec47c61 Re-add accidentally discarded comment about YUVJ format.
reimar
parents: 28526
diff changeset
68
28526
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
69 {IMGFMT_XVMC_MOCO_MPEG2, PIX_FMT_XVMC_MPEG2_MC},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
70 {IMGFMT_XVMC_IDCT_MPEG2, PIX_FMT_XVMC_MPEG2_IDCT},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
71 {IMGFMT_VDPAU_MPEG1, PIX_FMT_VDPAU_MPEG1},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
72 {IMGFMT_VDPAU_MPEG2, PIX_FMT_VDPAU_MPEG2},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
73 {IMGFMT_VDPAU_H264, PIX_FMT_VDPAU_H264},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
74 {IMGFMT_VDPAU_WMV3, PIX_FMT_VDPAU_WMV3},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
75 {IMGFMT_VDPAU_VC1, PIX_FMT_VDPAU_VC1},
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
76 {0, PIX_FMT_NONE}
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
77 };
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
78
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
79 enum PixelFormat imgfmt2pixfmt(int fmt)
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
80 {
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
81 int i;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
82 enum PixelFormat pix_fmt;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
83 for (i = 0; conversion_map[i].fmt; i++)
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
84 if (conversion_map[i].fmt == fmt)
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
85 break;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
86 pix_fmt = conversion_map[i].pix_fmt;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
87 if (pix_fmt == PIX_FMT_NONE)
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
88 mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported format %s\n", vo_format_name(fmt));
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
89 return pix_fmt;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
90 }
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
91
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
92 int pixfmt2imgfmt(enum PixelFormat pix_fmt)
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
93 {
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
94 int i;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
95 int fmt;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
96 for (i = 0; conversion_map[i].pix_fmt != PIX_FMT_NONE; i++)
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
97 if (conversion_map[i].pix_fmt == pix_fmt)
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
98 break;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
99 fmt = conversion_map[i].fmt;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
100 if (!fmt)
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
101 mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported PixelFormat %i\n", pix_fmt);
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
102 return fmt;
21efa4282730 Create a fmt-conversion.c file so fmt-conversion.h can be included by multiple files.
reimar
parents:
diff changeset
103 }