Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vlc_es.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_es.h: Elementary stream formats descriptions
00003  *****************************************************************************
00004  * Copyright (C) 1999-2001 the VideoLAN team
00005  * $Id: vlc_es.h 12307 2005-08-20 19:14:58Z dionoea $
00006  *
00007  * Authors: Laurent Aimar <[email protected]>
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef _VLC_ES_H
00025 #define _VLC_ES_H 1
00026 
00037 struct video_palette_t
00038 {
00039     int i_entries;      
00040     uint8_t palette[256][4];                   
00041 };
00042 
00046 struct audio_format_t
00047 {
00048     vlc_fourcc_t i_format;                          
00049     unsigned int i_rate;                              
00051     /* Describes the channels configuration of the samples (ie. number of
00052      * channels which are available in the buffer, and positions). */
00053     uint32_t     i_physical_channels;
00054 
00055     /* Describes from which original channels, before downmixing, the
00056      * buffer is derived. */
00057     uint32_t     i_original_channels;
00058 
00059     /* Optional - for A/52, SPDIF and DTS types : */
00060     /* Bytes used by one compressed frame, depends on bitrate. */
00061     unsigned int i_bytes_per_frame;
00062 
00063     /* Number of sampleframes contained in one compressed frame. */
00064     unsigned int i_frame_length;
00065     /* Please note that it may be completely arbitrary - buffers are not
00066      * obliged to contain a integral number of so-called "frames". It's
00067      * just here for the division :
00068      * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
00069      */
00070 
00071     /* FIXME ? (used by the codecs) */
00072     int i_channels;
00073     int i_blockalign;
00074     int i_bitspersample;
00075 };
00076 
00077 #ifdef WORDS_BIGENDIAN
00078 #   define AUDIO_FMT_S16_NE VLC_FOURCC('s','1','6','b')
00079 #   define AUDIO_FMT_U16_NE VLC_FOURCC('u','1','6','b')
00080 #else
00081 #   define AUDIO_FMT_S16_NE VLC_FOURCC('s','1','6','l')
00082 #   define AUDIO_FMT_U16_NE VLC_FOURCC('u','1','6','l')
00083 #endif
00084 
00088 struct video_format_t
00089 {
00090     vlc_fourcc_t i_chroma;                               
00091     unsigned int i_aspect;                                 
00093     unsigned int i_width;                                 
00094     unsigned int i_height;                               
00095     unsigned int i_x_offset;               
00096     unsigned int i_y_offset;               
00097     unsigned int i_visible_width;                 
00098     unsigned int i_visible_height;               
00100     unsigned int i_bits_per_pixel;             
00102     unsigned int i_sar_num;                   
00103     unsigned int i_sar_den;
00104 
00105     unsigned int i_frame_rate;                     
00106     unsigned int i_frame_rate_base;              
00108     int i_rmask, i_gmask, i_bmask;          
00109     video_palette_t *p_palette;              
00110 };
00111 
00115 struct subs_format_t
00116 {
00117     /* the character encoding of the text of the subtitle.
00118      * all gettext recognized shorts can be used */
00119     char *psz_encoding;
00120 
00121 
00122     int  i_x_origin; 
00123     int  i_y_origin; 
00125     struct
00126     {
00127         /*  */
00128         uint32_t palette[16+1];
00129 
00130         /* the width of the original movie the spu was extracted from */
00131         int i_original_frame_width;
00132         /* the height of the original movie the spu was extracted from */
00133         int i_original_frame_height;
00134     } spu;
00135 
00136     struct
00137     {
00138         int i_id;
00139     } dvb;
00140 };
00141 
00145 struct es_format_t
00146 {
00147     int             i_cat;
00148     vlc_fourcc_t    i_codec;
00149 
00150     int             i_id;       /* -1: let the core mark the right id
00151                                    >=0: valid id */
00152     int             i_group;    /* -1 : standalone
00153                                    >= 0 then a "group" (program) is created
00154                                         for each value */
00155     int             i_priority; /*  -2 : mean not selectable by the users
00156                                     -1 : mean not selected by default even
00157                                         when no other stream
00158                                     >=0: priority */
00159     char            *psz_language;
00160     char            *psz_description;
00161 
00162     audio_format_t audio;
00163     video_format_t video;
00164     subs_format_t  subs;
00165 
00166     unsigned int   i_bitrate;
00167 
00168     vlc_bool_t     b_packetized; /* wether the data is packetized
00169                                     (ie. not truncated) */
00170     int     i_extra;
00171     void    *p_extra;
00172 
00173 };
00174 
00175 /* ES Categories */
00176 #define UNKNOWN_ES      0x00
00177 #define VIDEO_ES        0x01
00178 #define AUDIO_ES        0x02
00179 #define SPU_ES          0x03
00180 #define NAV_ES          0x04
00181 
00182 static inline void es_format_Init( es_format_t *fmt,
00183                                    int i_cat, vlc_fourcc_t i_codec )
00184 {
00185     fmt->i_cat                  = i_cat;
00186     fmt->i_codec                = i_codec;
00187     fmt->i_id                   = -1;
00188     fmt->i_group                = 0;
00189     fmt->i_priority             = 0;
00190     fmt->psz_language           = NULL;
00191     fmt->psz_description        = NULL;
00192 
00193     memset( &fmt->audio, 0, sizeof(audio_format_t) );
00194     memset( &fmt->video, 0, sizeof(video_format_t) );
00195     memset( &fmt->subs, 0, sizeof(subs_format_t) );
00196 
00197     fmt->b_packetized           = VLC_TRUE;
00198     fmt->i_bitrate              = 0;
00199     fmt->i_extra                = 0;
00200     fmt->p_extra                = NULL;
00201 }
00202 
00203 static inline void es_format_Copy( es_format_t *dst, es_format_t *src )
00204 {
00205     memcpy( dst, src, sizeof( es_format_t ) );
00206     if( src->psz_language )
00207          dst->psz_language = strdup( src->psz_language );
00208     if( src->psz_description )
00209         dst->psz_description = strdup( src->psz_description );
00210     if( src->i_extra > 0 )
00211     {
00212         dst->i_extra = src->i_extra;
00213         dst->p_extra = malloc( src->i_extra );
00214         memcpy( dst->p_extra, src->p_extra, src->i_extra );
00215     }
00216     else
00217     {
00218         dst->i_extra = 0;
00219         dst->p_extra = NULL;
00220     }
00221 
00222     if( src->subs.psz_encoding )
00223         dst->subs.psz_encoding = strdup( src->subs.psz_encoding );
00224 
00225     if( src->video.p_palette )
00226     {
00227         dst->video.p_palette =
00228             (video_palette_t*)malloc( sizeof( video_palette_t ) );
00229         memcpy( dst->video.p_palette, src->video.p_palette,
00230                 sizeof( video_palette_t ) );
00231     }
00232 }
00233 
00234 static inline void es_format_Clean( es_format_t *fmt )
00235 {
00236     if( fmt->psz_language ) free( fmt->psz_language );
00237     fmt->psz_language = NULL;
00238 
00239     if( fmt->psz_description ) free( fmt->psz_description );
00240     fmt->psz_description = NULL;
00241 
00242     if( fmt->i_extra > 0 ) free( fmt->p_extra );
00243     fmt->i_extra = 0; fmt->p_extra = NULL;
00244 
00245     if( fmt->video.p_palette ) free( fmt->video.p_palette );
00246     fmt->video.p_palette = NULL;
00247 
00248     if( fmt->subs.psz_encoding ) free( fmt->subs.psz_encoding );
00249     fmt->subs.psz_encoding = NULL;
00250 }
00251 
00252 #endif

Generated on Tue Dec 20 10:14:19 2005 for vlc-0.8.4a by  doxygen 1.4.2