FFmpeg
qtpalette.c
Go to the documentation of this file.
1 /*
2  * QuickTime palette handling
3  * Copyright (c) 2001 Fabrice Bellard
4  * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
5  * Copyright (c) 2015 Mats Peterson
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include <stdio.h>
25 #include <stdint.h>
26 
27 #include "libavcodec/codec_id.h"
28 #include "avio.h"
29 #include "qtpalette.h"
30 
31 static const uint8_t qt_default_palette_2[2 * 3] = {
32  0xFF, 0xFF, 0xFF,
33  0x00, 0x00, 0x00
34 };
35 
36 /* From a screenshot of the "Monitors & Sound" control panel in Mac OS 7.5.5 */
37 static const uint8_t qt_default_palette_4[4 * 3] = {
38  0xFF, 0xFF, 0xFF,
39  0xAC, 0xAC, 0xAC,
40  0x55, 0x55, 0x55,
41  0x00, 0x00, 0x00
42 };
43 
44 /* From a screenshot of the "Monitors & Sound" control panel in Mac OS 7.5.5 */
45 static const uint8_t qt_default_palette_16[16 * 3] = {
46  0xFF, 0xFF, 0xFF,
47  0xFC, 0xF3, 0x05,
48  0xFF, 0x64, 0x02,
49  0xDD, 0x08, 0x06,
50  0xF2, 0x08, 0x84,
51  0x46, 0x00, 0xA5,
52  0x00, 0x00, 0xD4,
53  0x02, 0xAB, 0xEA,
54  0x1F, 0xB7, 0x14,
55  0x00, 0x64, 0x11,
56  0x56, 0x2C, 0x05,
57  0x90, 0x71, 0x3A,
58  0xC0, 0xC0, 0xC0,
59  0x80, 0x80, 0x80,
60  0x40, 0x40, 0x40,
61  0x00, 0x00, 0x00
62 };
63 
64 static const uint8_t qt_default_palette_256[256 * 3] = {
65  /* 0, 0x00 */ 0xFF, 0xFF, 0xFF,
66  /* 1, 0x01 */ 0xFF, 0xFF, 0xCC,
67  /* 2, 0x02 */ 0xFF, 0xFF, 0x99,
68  /* 3, 0x03 */ 0xFF, 0xFF, 0x66,
69  /* 4, 0x04 */ 0xFF, 0xFF, 0x33,
70  /* 5, 0x05 */ 0xFF, 0xFF, 0x00,
71  /* 6, 0x06 */ 0xFF, 0xCC, 0xFF,
72  /* 7, 0x07 */ 0xFF, 0xCC, 0xCC,
73  /* 8, 0x08 */ 0xFF, 0xCC, 0x99,
74  /* 9, 0x09 */ 0xFF, 0xCC, 0x66,
75  /* 10, 0x0A */ 0xFF, 0xCC, 0x33,
76  /* 11, 0x0B */ 0xFF, 0xCC, 0x00,
77  /* 12, 0x0C */ 0xFF, 0x99, 0xFF,
78  /* 13, 0x0D */ 0xFF, 0x99, 0xCC,
79  /* 14, 0x0E */ 0xFF, 0x99, 0x99,
80  /* 15, 0x0F */ 0xFF, 0x99, 0x66,
81  /* 16, 0x10 */ 0xFF, 0x99, 0x33,
82  /* 17, 0x11 */ 0xFF, 0x99, 0x00,
83  /* 18, 0x12 */ 0xFF, 0x66, 0xFF,
84  /* 19, 0x13 */ 0xFF, 0x66, 0xCC,
85  /* 20, 0x14 */ 0xFF, 0x66, 0x99,
86  /* 21, 0x15 */ 0xFF, 0x66, 0x66,
87  /* 22, 0x16 */ 0xFF, 0x66, 0x33,
88  /* 23, 0x17 */ 0xFF, 0x66, 0x00,
89  /* 24, 0x18 */ 0xFF, 0x33, 0xFF,
90  /* 25, 0x19 */ 0xFF, 0x33, 0xCC,
91  /* 26, 0x1A */ 0xFF, 0x33, 0x99,
92  /* 27, 0x1B */ 0xFF, 0x33, 0x66,
93  /* 28, 0x1C */ 0xFF, 0x33, 0x33,
94  /* 29, 0x1D */ 0xFF, 0x33, 0x00,
95  /* 30, 0x1E */ 0xFF, 0x00, 0xFF,
96  /* 31, 0x1F */ 0xFF, 0x00, 0xCC,
97  /* 32, 0x20 */ 0xFF, 0x00, 0x99,
98  /* 33, 0x21 */ 0xFF, 0x00, 0x66,
99  /* 34, 0x22 */ 0xFF, 0x00, 0x33,
100  /* 35, 0x23 */ 0xFF, 0x00, 0x00,
101  /* 36, 0x24 */ 0xCC, 0xFF, 0xFF,
102  /* 37, 0x25 */ 0xCC, 0xFF, 0xCC,
103  /* 38, 0x26 */ 0xCC, 0xFF, 0x99,
104  /* 39, 0x27 */ 0xCC, 0xFF, 0x66,
105  /* 40, 0x28 */ 0xCC, 0xFF, 0x33,
106  /* 41, 0x29 */ 0xCC, 0xFF, 0x00,
107  /* 42, 0x2A */ 0xCC, 0xCC, 0xFF,
108  /* 43, 0x2B */ 0xCC, 0xCC, 0xCC,
109  /* 44, 0x2C */ 0xCC, 0xCC, 0x99,
110  /* 45, 0x2D */ 0xCC, 0xCC, 0x66,
111  /* 46, 0x2E */ 0xCC, 0xCC, 0x33,
112  /* 47, 0x2F */ 0xCC, 0xCC, 0x00,
113  /* 48, 0x30 */ 0xCC, 0x99, 0xFF,
114  /* 49, 0x31 */ 0xCC, 0x99, 0xCC,
115  /* 50, 0x32 */ 0xCC, 0x99, 0x99,
116  /* 51, 0x33 */ 0xCC, 0x99, 0x66,
117  /* 52, 0x34 */ 0xCC, 0x99, 0x33,
118  /* 53, 0x35 */ 0xCC, 0x99, 0x00,
119  /* 54, 0x36 */ 0xCC, 0x66, 0xFF,
120  /* 55, 0x37 */ 0xCC, 0x66, 0xCC,
121  /* 56, 0x38 */ 0xCC, 0x66, 0x99,
122  /* 57, 0x39 */ 0xCC, 0x66, 0x66,
123  /* 58, 0x3A */ 0xCC, 0x66, 0x33,
124  /* 59, 0x3B */ 0xCC, 0x66, 0x00,
125  /* 60, 0x3C */ 0xCC, 0x33, 0xFF,
126  /* 61, 0x3D */ 0xCC, 0x33, 0xCC,
127  /* 62, 0x3E */ 0xCC, 0x33, 0x99,
128  /* 63, 0x3F */ 0xCC, 0x33, 0x66,
129  /* 64, 0x40 */ 0xCC, 0x33, 0x33,
130  /* 65, 0x41 */ 0xCC, 0x33, 0x00,
131  /* 66, 0x42 */ 0xCC, 0x00, 0xFF,
132  /* 67, 0x43 */ 0xCC, 0x00, 0xCC,
133  /* 68, 0x44 */ 0xCC, 0x00, 0x99,
134  /* 69, 0x45 */ 0xCC, 0x00, 0x66,
135  /* 70, 0x46 */ 0xCC, 0x00, 0x33,
136  /* 71, 0x47 */ 0xCC, 0x00, 0x00,
137  /* 72, 0x48 */ 0x99, 0xFF, 0xFF,
138  /* 73, 0x49 */ 0x99, 0xFF, 0xCC,
139  /* 74, 0x4A */ 0x99, 0xFF, 0x99,
140  /* 75, 0x4B */ 0x99, 0xFF, 0x66,
141  /* 76, 0x4C */ 0x99, 0xFF, 0x33,
142  /* 77, 0x4D */ 0x99, 0xFF, 0x00,
143  /* 78, 0x4E */ 0x99, 0xCC, 0xFF,
144  /* 79, 0x4F */ 0x99, 0xCC, 0xCC,
145  /* 80, 0x50 */ 0x99, 0xCC, 0x99,
146  /* 81, 0x51 */ 0x99, 0xCC, 0x66,
147  /* 82, 0x52 */ 0x99, 0xCC, 0x33,
148  /* 83, 0x53 */ 0x99, 0xCC, 0x00,
149  /* 84, 0x54 */ 0x99, 0x99, 0xFF,
150  /* 85, 0x55 */ 0x99, 0x99, 0xCC,
151  /* 86, 0x56 */ 0x99, 0x99, 0x99,
152  /* 87, 0x57 */ 0x99, 0x99, 0x66,
153  /* 88, 0x58 */ 0x99, 0x99, 0x33,
154  /* 89, 0x59 */ 0x99, 0x99, 0x00,
155  /* 90, 0x5A */ 0x99, 0x66, 0xFF,
156  /* 91, 0x5B */ 0x99, 0x66, 0xCC,
157  /* 92, 0x5C */ 0x99, 0x66, 0x99,
158  /* 93, 0x5D */ 0x99, 0x66, 0x66,
159  /* 94, 0x5E */ 0x99, 0x66, 0x33,
160  /* 95, 0x5F */ 0x99, 0x66, 0x00,
161  /* 96, 0x60 */ 0x99, 0x33, 0xFF,
162  /* 97, 0x61 */ 0x99, 0x33, 0xCC,
163  /* 98, 0x62 */ 0x99, 0x33, 0x99,
164  /* 99, 0x63 */ 0x99, 0x33, 0x66,
165  /* 100, 0x64 */ 0x99, 0x33, 0x33,
166  /* 101, 0x65 */ 0x99, 0x33, 0x00,
167  /* 102, 0x66 */ 0x99, 0x00, 0xFF,
168  /* 103, 0x67 */ 0x99, 0x00, 0xCC,
169  /* 104, 0x68 */ 0x99, 0x00, 0x99,
170  /* 105, 0x69 */ 0x99, 0x00, 0x66,
171  /* 106, 0x6A */ 0x99, 0x00, 0x33,
172  /* 107, 0x6B */ 0x99, 0x00, 0x00,
173  /* 108, 0x6C */ 0x66, 0xFF, 0xFF,
174  /* 109, 0x6D */ 0x66, 0xFF, 0xCC,
175  /* 110, 0x6E */ 0x66, 0xFF, 0x99,
176  /* 111, 0x6F */ 0x66, 0xFF, 0x66,
177  /* 112, 0x70 */ 0x66, 0xFF, 0x33,
178  /* 113, 0x71 */ 0x66, 0xFF, 0x00,
179  /* 114, 0x72 */ 0x66, 0xCC, 0xFF,
180  /* 115, 0x73 */ 0x66, 0xCC, 0xCC,
181  /* 116, 0x74 */ 0x66, 0xCC, 0x99,
182  /* 117, 0x75 */ 0x66, 0xCC, 0x66,
183  /* 118, 0x76 */ 0x66, 0xCC, 0x33,
184  /* 119, 0x77 */ 0x66, 0xCC, 0x00,
185  /* 120, 0x78 */ 0x66, 0x99, 0xFF,
186  /* 121, 0x79 */ 0x66, 0x99, 0xCC,
187  /* 122, 0x7A */ 0x66, 0x99, 0x99,
188  /* 123, 0x7B */ 0x66, 0x99, 0x66,
189  /* 124, 0x7C */ 0x66, 0x99, 0x33,
190  /* 125, 0x7D */ 0x66, 0x99, 0x00,
191  /* 126, 0x7E */ 0x66, 0x66, 0xFF,
192  /* 127, 0x7F */ 0x66, 0x66, 0xCC,
193  /* 128, 0x80 */ 0x66, 0x66, 0x99,
194  /* 129, 0x81 */ 0x66, 0x66, 0x66,
195  /* 130, 0x82 */ 0x66, 0x66, 0x33,
196  /* 131, 0x83 */ 0x66, 0x66, 0x00,
197  /* 132, 0x84 */ 0x66, 0x33, 0xFF,
198  /* 133, 0x85 */ 0x66, 0x33, 0xCC,
199  /* 134, 0x86 */ 0x66, 0x33, 0x99,
200  /* 135, 0x87 */ 0x66, 0x33, 0x66,
201  /* 136, 0x88 */ 0x66, 0x33, 0x33,
202  /* 137, 0x89 */ 0x66, 0x33, 0x00,
203  /* 138, 0x8A */ 0x66, 0x00, 0xFF,
204  /* 139, 0x8B */ 0x66, 0x00, 0xCC,
205  /* 140, 0x8C */ 0x66, 0x00, 0x99,
206  /* 141, 0x8D */ 0x66, 0x00, 0x66,
207  /* 142, 0x8E */ 0x66, 0x00, 0x33,
208  /* 143, 0x8F */ 0x66, 0x00, 0x00,
209  /* 144, 0x90 */ 0x33, 0xFF, 0xFF,
210  /* 145, 0x91 */ 0x33, 0xFF, 0xCC,
211  /* 146, 0x92 */ 0x33, 0xFF, 0x99,
212  /* 147, 0x93 */ 0x33, 0xFF, 0x66,
213  /* 148, 0x94 */ 0x33, 0xFF, 0x33,
214  /* 149, 0x95 */ 0x33, 0xFF, 0x00,
215  /* 150, 0x96 */ 0x33, 0xCC, 0xFF,
216  /* 151, 0x97 */ 0x33, 0xCC, 0xCC,
217  /* 152, 0x98 */ 0x33, 0xCC, 0x99,
218  /* 153, 0x99 */ 0x33, 0xCC, 0x66,
219  /* 154, 0x9A */ 0x33, 0xCC, 0x33,
220  /* 155, 0x9B */ 0x33, 0xCC, 0x00,
221  /* 156, 0x9C */ 0x33, 0x99, 0xFF,
222  /* 157, 0x9D */ 0x33, 0x99, 0xCC,
223  /* 158, 0x9E */ 0x33, 0x99, 0x99,
224  /* 159, 0x9F */ 0x33, 0x99, 0x66,
225  /* 160, 0xA0 */ 0x33, 0x99, 0x33,
226  /* 161, 0xA1 */ 0x33, 0x99, 0x00,
227  /* 162, 0xA2 */ 0x33, 0x66, 0xFF,
228  /* 163, 0xA3 */ 0x33, 0x66, 0xCC,
229  /* 164, 0xA4 */ 0x33, 0x66, 0x99,
230  /* 165, 0xA5 */ 0x33, 0x66, 0x66,
231  /* 166, 0xA6 */ 0x33, 0x66, 0x33,
232  /* 167, 0xA7 */ 0x33, 0x66, 0x00,
233  /* 168, 0xA8 */ 0x33, 0x33, 0xFF,
234  /* 169, 0xA9 */ 0x33, 0x33, 0xCC,
235  /* 170, 0xAA */ 0x33, 0x33, 0x99,
236  /* 171, 0xAB */ 0x33, 0x33, 0x66,
237  /* 172, 0xAC */ 0x33, 0x33, 0x33,
238  /* 173, 0xAD */ 0x33, 0x33, 0x00,
239  /* 174, 0xAE */ 0x33, 0x00, 0xFF,
240  /* 175, 0xAF */ 0x33, 0x00, 0xCC,
241  /* 176, 0xB0 */ 0x33, 0x00, 0x99,
242  /* 177, 0xB1 */ 0x33, 0x00, 0x66,
243  /* 178, 0xB2 */ 0x33, 0x00, 0x33,
244  /* 179, 0xB3 */ 0x33, 0x00, 0x00,
245  /* 180, 0xB4 */ 0x00, 0xFF, 0xFF,
246  /* 181, 0xB5 */ 0x00, 0xFF, 0xCC,
247  /* 182, 0xB6 */ 0x00, 0xFF, 0x99,
248  /* 183, 0xB7 */ 0x00, 0xFF, 0x66,
249  /* 184, 0xB8 */ 0x00, 0xFF, 0x33,
250  /* 185, 0xB9 */ 0x00, 0xFF, 0x00,
251  /* 186, 0xBA */ 0x00, 0xCC, 0xFF,
252  /* 187, 0xBB */ 0x00, 0xCC, 0xCC,
253  /* 188, 0xBC */ 0x00, 0xCC, 0x99,
254  /* 189, 0xBD */ 0x00, 0xCC, 0x66,
255  /* 190, 0xBE */ 0x00, 0xCC, 0x33,
256  /* 191, 0xBF */ 0x00, 0xCC, 0x00,
257  /* 192, 0xC0 */ 0x00, 0x99, 0xFF,
258  /* 193, 0xC1 */ 0x00, 0x99, 0xCC,
259  /* 194, 0xC2 */ 0x00, 0x99, 0x99,
260  /* 195, 0xC3 */ 0x00, 0x99, 0x66,
261  /* 196, 0xC4 */ 0x00, 0x99, 0x33,
262  /* 197, 0xC5 */ 0x00, 0x99, 0x00,
263  /* 198, 0xC6 */ 0x00, 0x66, 0xFF,
264  /* 199, 0xC7 */ 0x00, 0x66, 0xCC,
265  /* 200, 0xC8 */ 0x00, 0x66, 0x99,
266  /* 201, 0xC9 */ 0x00, 0x66, 0x66,
267  /* 202, 0xCA */ 0x00, 0x66, 0x33,
268  /* 203, 0xCB */ 0x00, 0x66, 0x00,
269  /* 204, 0xCC */ 0x00, 0x33, 0xFF,
270  /* 205, 0xCD */ 0x00, 0x33, 0xCC,
271  /* 206, 0xCE */ 0x00, 0x33, 0x99,
272  /* 207, 0xCF */ 0x00, 0x33, 0x66,
273  /* 208, 0xD0 */ 0x00, 0x33, 0x33,
274  /* 209, 0xD1 */ 0x00, 0x33, 0x00,
275  /* 210, 0xD2 */ 0x00, 0x00, 0xFF,
276  /* 211, 0xD3 */ 0x00, 0x00, 0xCC,
277  /* 212, 0xD4 */ 0x00, 0x00, 0x99,
278  /* 213, 0xD5 */ 0x00, 0x00, 0x66,
279  /* 214, 0xD6 */ 0x00, 0x00, 0x33,
280  /* 215, 0xD7 */ 0xEE, 0x00, 0x00,
281  /* 216, 0xD8 */ 0xDD, 0x00, 0x00,
282  /* 217, 0xD9 */ 0xBB, 0x00, 0x00,
283  /* 218, 0xDA */ 0xAA, 0x00, 0x00,
284  /* 219, 0xDB */ 0x88, 0x00, 0x00,
285  /* 220, 0xDC */ 0x77, 0x00, 0x00,
286  /* 221, 0xDD */ 0x55, 0x00, 0x00,
287  /* 222, 0xDE */ 0x44, 0x00, 0x00,
288  /* 223, 0xDF */ 0x22, 0x00, 0x00,
289  /* 224, 0xE0 */ 0x11, 0x00, 0x00,
290  /* 225, 0xE1 */ 0x00, 0xEE, 0x00,
291  /* 226, 0xE2 */ 0x00, 0xDD, 0x00,
292  /* 227, 0xE3 */ 0x00, 0xBB, 0x00,
293  /* 228, 0xE4 */ 0x00, 0xAA, 0x00,
294  /* 229, 0xE5 */ 0x00, 0x88, 0x00,
295  /* 230, 0xE6 */ 0x00, 0x77, 0x00,
296  /* 231, 0xE7 */ 0x00, 0x55, 0x00,
297  /* 232, 0xE8 */ 0x00, 0x44, 0x00,
298  /* 233, 0xE9 */ 0x00, 0x22, 0x00,
299  /* 234, 0xEA */ 0x00, 0x11, 0x00,
300  /* 235, 0xEB */ 0x00, 0x00, 0xEE,
301  /* 236, 0xEC */ 0x00, 0x00, 0xDD,
302  /* 237, 0xED */ 0x00, 0x00, 0xBB,
303  /* 238, 0xEE */ 0x00, 0x00, 0xAA,
304  /* 239, 0xEF */ 0x00, 0x00, 0x88,
305  /* 240, 0xF0 */ 0x00, 0x00, 0x77,
306  /* 241, 0xF1 */ 0x00, 0x00, 0x55,
307  /* 242, 0xF2 */ 0x00, 0x00, 0x44,
308  /* 243, 0xF3 */ 0x00, 0x00, 0x22,
309  /* 244, 0xF4 */ 0x00, 0x00, 0x11,
310  /* 245, 0xF5 */ 0xEE, 0xEE, 0xEE,
311  /* 246, 0xF6 */ 0xDD, 0xDD, 0xDD,
312  /* 247, 0xF7 */ 0xBB, 0xBB, 0xBB,
313  /* 248, 0xF8 */ 0xAA, 0xAA, 0xAA,
314  /* 249, 0xF9 */ 0x88, 0x88, 0x88,
315  /* 250, 0xFA */ 0x77, 0x77, 0x77,
316  /* 251, 0xFB */ 0x55, 0x55, 0x55,
317  /* 252, 0xFC */ 0x44, 0x44, 0x44,
318  /* 253, 0xFD */ 0x22, 0x22, 0x22,
319  /* 254, 0xFE */ 0x11, 0x11, 0x11,
320  /* 255, 0xFF */ 0x00, 0x00, 0x00
321 };
322 
323 int ff_get_qtpalette(int codec_id, AVIOContext *pb, uint32_t *palette)
324 {
325  int tmp, bit_depth, color_table_id, greyscale, i;
326 
327  avio_seek(pb, 82, SEEK_CUR);
328 
329  /* Get the bit depth and greyscale state */
330  tmp = avio_rb16(pb);
331  bit_depth = tmp & 0x1F;
332  greyscale = tmp & 0x20;
333 
334  /* Get the color table ID */
335  color_table_id = avio_rb16(pb);
336 
337  /* Do not create a greyscale palette for Cinepak */
338  if (greyscale && codec_id == AV_CODEC_ID_CINEPAK)
339  return 0;
340 
341  /* If the depth is 1, 2, 4, or 8 bpp, file is palettized. */
342  if ((bit_depth == 1 || bit_depth == 2 || bit_depth == 4 || bit_depth == 8)) {
343  uint32_t color_count, color_start, color_end;
344  uint32_t r, g, b;
345 
346  /* Ignore the greyscale bit for 1-bit video and sample
347  * descriptions containing a color table. */
348  if (greyscale && bit_depth > 1 && color_table_id) {
349  int color_index, color_dec;
350  /* compute the greyscale palette */
351  color_count = 1 << bit_depth;
352  color_index = 255;
353  color_dec = 256 / (color_count - 1);
354  for (i = 0; i < color_count; i++) {
355  r = g = b = color_index;
356  palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | (b);
357  color_index -= color_dec;
358  if (color_index < 0)
359  color_index = 0;
360  }
361  } else if (color_table_id) {
362  /* The color table ID is non-zero. Interpret this as
363  * being -1, which means use the default Macintosh
364  * color table */
365  const uint8_t *color_table;
366  color_count = 1 << bit_depth;
367  if (bit_depth == 1)
369  else if (bit_depth == 2)
371  else if (bit_depth == 4)
373  else
375  for (i = 0; i < color_count; i++) {
376  r = color_table[i * 3 + 0];
377  g = color_table[i * 3 + 1];
378  b = color_table[i * 3 + 2];
379  palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | (b);
380  }
381  } else {
382  /* The color table ID is 0; the color table is in the sample
383  * description */
384  color_start = avio_rb32(pb);
385  avio_rb16(pb); /* color table flags */
386  color_end = avio_rb16(pb);
387  if ((color_start <= 255) && (color_end <= 255)) {
388  for (i = color_start; i <= color_end; i++) {
389  /* Each color is made of four unsigned 16 bit integers. The
390  * first integer is 0, the remaining integers are the red,
391  * the green and the blue values. We only use the top 8 bit. */
392  avio_skip(pb, 2);
393  r = avio_r8(pb);
394  avio_r8(pb);
395  g = avio_r8(pb);
396  avio_r8(pb);
397  b = avio_r8(pb);
398  avio_r8(pb);
399  palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | (b);
400  }
401  }
402  }
403 
404  return 1;
405  }
406 
407  return 0;
408 }
qt_default_palette_2
static const uint8_t qt_default_palette_2[2 *3]
Definition: qtpalette.c:31
r
const char * r
Definition: vf_curves.c:127
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
b
#define b
Definition: input.c:41
qt_default_palette_4
static const uint8_t qt_default_palette_4[4 *3]
Definition: qtpalette.c:37
bit_depth
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition: af_astats.c:246
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:761
codec_id.h
qt_default_palette_16
static const uint8_t qt_default_palette_16[16 *3]
Definition: qtpalette.c:45
g
const char * g
Definition: vf_curves.c:128
codec_id
enum AVCodecID codec_id
Definition: vaapi_decode.c:394
AV_CODEC_ID_CINEPAK
@ AV_CODEC_ID_CINEPAK
Definition: codec_id.h:95
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
qtpalette.h
qt_default_palette_256
static const uint8_t qt_default_palette_256[256 *3]
Definition: qtpalette.c:64
avio.h
ff_get_qtpalette
int ff_get_qtpalette(int codec_id, AVIOContext *pb, uint32_t *palette)
Retrieve the palette (or "color table" in QuickTime terms), either from the video sample description,...
Definition: qtpalette.c:323
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:603
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:231
avio_rb16
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:746
U
#define U(x)
Definition: vpx_arith.h:37
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:318
color_table
static const ColorEntry color_table[]
Definition: xpmdec.c:51