gavl
compression.h
00001 /*****************************************************************
00002  * gavl - a general purpose audio/video processing library
00003  *
00004  * Copyright (c) 2001 - 2011 Members of the Gmerlin project
00005  * gmerlin-general@lists.sourceforge.net
00006  * http://gmerlin.sourceforge.net
00007  *
00008  * This program is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  * *****************************************************************/
00021 
00022 #ifndef GAVL_COMPRESSION_H_INCLUDED
00023 #define GAVL_COMPRESSION_H_INCLUDED
00024 
00025 #include <gavl/gavldefs.h>
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00045 #define GAVL_COMPRESSION_HAS_P_FRAMES (1<<0) //!< Not all frames are keyframes
00046 #define GAVL_COMPRESSION_HAS_B_FRAMES (1<<1) //!< Frames don't appear in presentation order 
00047 #define GAVL_COMPRESSION_HAS_FIELD_PICTURES (1<<2) //!< Packets can consist of 2 consecutive fields
00048 #define GAVL_COMPRESSION_SBR                (1<<3) //!< Samplerate got doubled by decoder, format and sample counts are for the upsampled rate
00049 
00050 typedef enum
00051   {
00052     GAVL_CODEC_ID_NONE  = 0, 
00053     /* Audio */
00054     GAVL_CODEC_ID_ALAW  = 1, 
00055     GAVL_CODEC_ID_ULAW,      
00056     GAVL_CODEC_ID_MP2,       
00057     GAVL_CODEC_ID_MP3,       
00058     GAVL_CODEC_ID_AC3,       
00059     GAVL_CODEC_ID_AAC,       
00060     GAVL_CODEC_ID_VORBIS,    
00061     
00062     /* Video */
00063     GAVL_CODEC_ID_JPEG = 0x10000, 
00064     GAVL_CODEC_ID_PNG,            
00065     GAVL_CODEC_ID_TIFF,           
00066     GAVL_CODEC_ID_TGA,            
00067     GAVL_CODEC_ID_MPEG1,          
00068     GAVL_CODEC_ID_MPEG2,          
00069     GAVL_CODEC_ID_MPEG4_ASP,      
00070     GAVL_CODEC_ID_H264,           
00071     GAVL_CODEC_ID_THEORA,         
00072     GAVL_CODEC_ID_DIRAC,          
00073     GAVL_CODEC_ID_DV,             
00074   } gavl_codec_id_t;
00075 
00086 typedef struct
00087   {
00088   int flags; 
00089   gavl_codec_id_t id; 
00090   
00091   uint8_t * global_header; 
00092   int global_header_len;   
00093   
00094   int bitrate;             
00095   int palette_size;        
00096   } gavl_compression_info_t;
00097 
00102 GAVL_PUBLIC
00103 void gavl_compression_info_free(gavl_compression_info_t* info);
00104 
00111 GAVL_PUBLIC
00112 void gavl_compression_info_dump(const gavl_compression_info_t * info);
00113 
00129 GAVL_PUBLIC
00130 const char * gavl_compression_get_extension(gavl_codec_id_t id, int * separate);
00131 
00141 GAVL_PUBLIC
00142 int gavl_compression_need_pixelformat(gavl_codec_id_t id);
00143 
00144   
00145 #define GAVL_PACKET_TYPE_I 'I'      //!< Packet is an I-frame
00146 #define GAVL_PACKET_TYPE_P 'P'      //!< Packet is a P-frame
00147 #define GAVL_PACKET_TYPE_B 'B'      //!< Packet is a B-frame
00148 #define GAVL_PACKET_TYPE_MASK 0xff  //!< Mask for frame type
00149 
00150 #define GAVL_PACKET_KEYFRAME (1<<8) //!< Packet is a keyframe
00151 #define GAVL_PACKET_LAST     (1<<9) //!< Packet is the last in the stream (only Xiph codecs need this flag)
00152 
00166 typedef struct
00167   {
00168   uint8_t * data; 
00169   int data_len;   
00170   int data_alloc; 
00171 
00172   int flags;      
00173 
00174   int64_t pts;      
00175   int64_t duration; 
00176 
00177   int field2_offset; 
00178   int header_size;   
00179   int sequence_end_pos;    
00180 
00181   } gavl_packet_t;
00182 
00191 GAVL_PUBLIC
00192 void gavl_packet_alloc(gavl_packet_t * p, int len);
00193 
00198 GAVL_PUBLIC
00199 void gavl_packet_free(gavl_packet_t * p);
00200 
00207 GAVL_PUBLIC
00208 void gavl_packet_dump(const gavl_packet_t * p);
00209 
00210   
00211 #ifdef __cplusplus
00212 }
00213 #endif
00214  
00215 
00216 #endif // GAVL_COMPRESSION_H_INCLUDED