qml: Create MediaGroupDisplay
[vlc.git] / modules / demux / vobsub.h
blob9cd26ad0e5174dea7f3cb0d75d10154ac9a7d607
1 /*****************************************************************************
2 * vobsub.h: Vobsub support
3 *****************************************************************************
4 * Copyright (C) 2009 VLC authors and VideoLAN
6 * Authors: John Stebbins
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 static inline void vobsub_palette_argb2ayvu( const uint32_t *src, uint32_t *dst )
25 int i;
26 for( i = 0; i < 16; i++ )
28 uint8_t r, g, b, y, u, v;
29 r = (src[i] >> 16) & 0xff;
30 g = (src[i] >> 8) & 0xff;
31 b = (src[i] >> 0) & 0xff;
32 y = (uint8_t) __MIN(abs(r * 2104 + g * 4130 + b * 802 + 4096 + 131072) >> 13, 235);
33 u = (uint8_t) __MIN(abs(r * -1214 + g * -2384 + b * 3598 + 4096 + 1048576) >> 13, 240);
34 v = (uint8_t) __MIN(abs(r * 3598 + g * -3013 + b * -585 + 4096 + 1048576) >> 13, 240);
35 dst[i] = (y&0xff)<<16 | (v&0xff)<<8 | (u&0xff);
39 static inline int vobsub_palette_parse( const char *psz_buf, uint32_t *pu_palette )
41 uint32_t palette[16];
42 if( sscanf( psz_buf, "palette: "
43 "%" SCNx32", %" SCNx32 ", %" SCNx32 ", %" SCNx32 ", "
44 "%" SCNx32", %" SCNx32 ", %" SCNx32 ", %" SCNx32 ", "
45 "%" SCNx32", %" SCNx32 ", %" SCNx32 ", %" SCNx32 ", "
46 "%" SCNx32", %" SCNx32 ", %" SCNx32 ", %" SCNx32 "",
47 &palette[0], &palette[1], &palette[2], &palette[3],
48 &palette[4], &palette[5], &palette[6], &palette[7],
49 &palette[8], &palette[9], &palette[10], &palette[11],
50 &palette[12], &palette[13], &palette[14], &palette[15] ) == 16 )
52 vobsub_palette_argb2ayvu( palette, pu_palette );
53 return VLC_SUCCESS;
55 else
57 return VLC_EGENERIC;
61 static inline int vobsub_size_parse( const char *psz_buf,
62 int *pi_original_frame_width,
63 int *pi_original_frame_height )
65 int w, h;
66 if( sscanf( psz_buf, "size: %dx%d", &w, &h ) == 2 )
68 *pi_original_frame_width = w;
69 *pi_original_frame_height = h;
70 return VLC_SUCCESS;
72 else
74 return VLC_EGENERIC;