vobsub.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vobsub.h: Vobsub support
00003  *****************************************************************************
00004  * Copyright (C) 2009 the VideoLAN team
00005  * $Id: cabdefb1f396daa568889fee0ef21c6ed66de572 $
00006  *
00007  * Authors: John Stebbins
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 static inline void vobsub_palette_rgb2yuv( uint32_t *pu_palette )
00025 {
00026     int i;
00027     for( i = 0; i < 16; i++ )
00028     {
00029         uint8_t r, g, b, y, u, v;
00030         r = (pu_palette[i] >> 16) & 0xff;
00031         g = (pu_palette[i] >> 8) & 0xff;
00032         b = (pu_palette[i] >> 0) & 0xff;
00033         y = (uint8_t) __MIN(abs(r * 2104 + g * 4130 + b * 802 + 4096 + 131072) >> 13, 235);
00034         u = (uint8_t) __MIN(abs(r * -1214 + g * -2384 + b * 3598 + 4096 + 1048576) >> 13, 240);
00035         v = (uint8_t) __MIN(abs(r * 3598 + g * -3013 + b * -585 + 4096 + 1048576) >> 13, 240);
00036         pu_palette[i] = (y&0xff)<<16 | (v&0xff)<<8 | (u&0xff);
00037     }
00038 }
00039 
00040 static inline int vobsub_palette_parse( const char *psz_buf, uint32_t *pu_palette )
00041 {
00042     if( sscanf( psz_buf, "palette: "
00043                 "%"PRIx32", %"PRIx32", %"PRIx32", %"PRIx32", "
00044                 "%"PRIx32", %"PRIx32", %"PRIx32", %"PRIx32", "
00045                 "%"PRIx32", %"PRIx32", %"PRIx32", %"PRIx32", "
00046                 "%"PRIx32", %"PRIx32", %"PRIx32", %"PRIx32"",
00047                 &pu_palette[0], &pu_palette[1], &pu_palette[2], &pu_palette[3],
00048                 &pu_palette[4], &pu_palette[5], &pu_palette[6], &pu_palette[7],
00049                 &pu_palette[8], &pu_palette[9], &pu_palette[10], &pu_palette[11],
00050                 &pu_palette[12], &pu_palette[13], &pu_palette[14], &pu_palette[15] ) == 16 )
00051     {
00052         vobsub_palette_rgb2yuv( pu_palette );
00053         return VLC_SUCCESS;
00054     }
00055     else
00056     {
00057         return VLC_EGENERIC;
00058     }
00059 }
00060 
00061 static inline int vobsub_size_parse( const char *psz_buf,
00062                                      int *pi_original_frame_width,
00063                                      int *pi_original_frame_height )
00064 {
00065     if( sscanf( psz_buf, "size: %dx%d",
00066                 pi_original_frame_width, pi_original_frame_height ) == 2 )
00067     {
00068         return VLC_SUCCESS;
00069     }
00070     else
00071     {
00072         return VLC_EGENERIC;
00073     }
00074 }
00075 

Generated on Tue May 25 08:04:56 2010 for VLC by  doxygen 1.5.6