Mercurial > libavcodec.hg
annotate motionpixels_tablegen.h @ 12483:0159a19bfff7 libavcodec
aacdec: Rework channel mapping compatibility hacks.
For a PCE based configuration map the channels solely based on tags.
For an indexed configuration map the channels solely based on position.
This works with all known exotic samples including al17, elem_id0, bad_concat,
and lfe_is_sce.
author | alexc |
---|---|
date | Fri, 10 Sep 2010 18:01:48 +0000 |
parents | 2980d9efc542 |
children |
rev | line source |
---|---|
10581
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
1 /* |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
2 * Header file for hardcoded motionpixels RGB to YUV table |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
3 * |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
4 * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
5 * |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
6 * This file is part of FFmpeg. |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
7 * |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
10 * License as published by the Free Software Foundation; either |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
12 * |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
16 * Lesser General Public License for more details. |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
17 * |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
21 */ |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
22 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
23 #ifndef MOTIONPIXELS_TABLEGEN_H |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
24 #define MOTIONPIXELS_TABLEGEN_H |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
25 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
26 #include <stdint.h> |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
27 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
28 typedef struct YuvPixel { |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
29 int8_t y, v, u; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
30 } YuvPixel; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
31 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
32 static int mp_yuv_to_rgb(int y, int v, int u, int clip_rgb) { |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
33 static const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
34 int r, g, b; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
35 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
36 r = (1000 * y + 701 * v) / 1000; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
37 g = (1000 * y - 357 * v - 172 * u) / 1000; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
38 b = (1000 * y + 886 * u) / 1000; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
39 if (clip_rgb) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
40 return ((cm[r * 8] & 0xF8) << 7) | ((cm[g * 8] & 0xF8) << 2) | (cm[b * 8] >> 3); |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
41 if ((unsigned)r < 32 && (unsigned)g < 32 && (unsigned)b < 32) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
42 return (r << 10) | (g << 5) | b; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
43 return 1 << 15; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
44 } |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
45 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
46 #if CONFIG_HARDCODED_TABLES |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
47 #define motionpixels_tableinit() |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
48 #include "libavcodec/motionpixels_tables.h" |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
49 #else |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
50 static YuvPixel mp_rgb_yuv_table[1 << 15]; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
51 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
52 static void mp_set_zero_yuv(YuvPixel *p) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
53 { |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
54 int i, j; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
55 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
56 for (i = 0; i < 31; ++i) { |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
57 for (j = 31; j > i; --j) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
58 if (!(p[j].u | p[j].v | p[j].y)) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
59 p[j] = p[j - 1]; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
60 for (j = 0; j < 31 - i; ++j) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
61 if (!(p[j].u | p[j].v | p[j].y)) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
62 p[j] = p[j + 1]; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
63 } |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
64 } |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
65 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
66 static void mp_build_rgb_yuv_table(YuvPixel *p) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
67 { |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
68 int y, v, u, i; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
69 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
70 for (y = 0; y <= 31; ++y) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
71 for (v = -31; v <= 31; ++v) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
72 for (u = -31; u <= 31; ++u) { |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
73 i = mp_yuv_to_rgb(y, v, u, 0); |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
74 if (i < (1 << 15) && !(p[i].u | p[i].v | p[i].y)) { |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
75 p[i].y = y; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
76 p[i].v = v; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
77 p[i].u = u; |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
78 } |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
79 } |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
80 for (i = 0; i < 1024; ++i) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
81 mp_set_zero_yuv(p + i * 32); |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
82 } |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
83 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
84 static void motionpixels_tableinit(void) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
85 { |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
86 if (!mp_rgb_yuv_table[0].u) |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
87 mp_build_rgb_yuv_table(mp_rgb_yuv_table); |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
88 } |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
89 #endif /* CONFIG_HARDCODED_TABLES */ |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
90 |
2980d9efc542
Add support for hardcoding the motionpixels rgb to yuv table.
reimar
parents:
diff
changeset
|
91 #endif /* MOTIONPIXELS_TABLEGEN_H */ |