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 
00055 typedef enum
00056   {
00057     GAVL_CODEC_ID_NONE  = 0, 
00058     /* Audio */
00059     GAVL_CODEC_ID_ALAW  = 1, 
00060     GAVL_CODEC_ID_ULAW,      
00061     GAVL_CODEC_ID_MP2,       
00062     GAVL_CODEC_ID_MP3,       
00063     GAVL_CODEC_ID_AC3,       
00064     GAVL_CODEC_ID_AAC,       
00065     GAVL_CODEC_ID_VORBIS,    
00066     GAVL_CODEC_ID_FLAC,      
00067     
00068     /* Video */
00069     GAVL_CODEC_ID_JPEG = 0x10000, 
00070     GAVL_CODEC_ID_PNG,            
00071     GAVL_CODEC_ID_TIFF,           
00072     GAVL_CODEC_ID_TGA,            
00073     GAVL_CODEC_ID_MPEG1,          
00074     GAVL_CODEC_ID_MPEG2,          
00075     GAVL_CODEC_ID_MPEG4_ASP,      
00076     GAVL_CODEC_ID_H264,           
00077     GAVL_CODEC_ID_THEORA,         
00078     GAVL_CODEC_ID_DIRAC,          
00079     GAVL_CODEC_ID_DV,             
00080   } gavl_codec_id_t;
00081 
00092 typedef struct
00093   {
00094   int flags; 
00095   gavl_codec_id_t id; 
00096   
00097   uint8_t * global_header; 
00098   int global_header_len;   
00099   
00100   int bitrate;             
00101   int palette_size;        
00102   } gavl_compression_info_t;
00103 
00108 GAVL_PUBLIC
00109 void gavl_compression_info_free(gavl_compression_info_t* info);
00110 
00117 GAVL_PUBLIC
00118 void gavl_compression_info_dump(const gavl_compression_info_t * info);
00119 
00126 GAVL_PUBLIC
00127 void gavl_compression_info_copy(gavl_compression_info_t * dst,
00128                                 const gavl_compression_info_t * src);
00129 
00130   
00146 GAVL_PUBLIC
00147 const char * gavl_compression_get_extension(gavl_codec_id_t id, int * separate);
00148 
00158 GAVL_PUBLIC
00159 int gavl_compression_need_pixelformat(gavl_codec_id_t id);
00160 
00167 GAVL_PUBLIC
00168 int gavl_compression_constant_frame_samples(gavl_codec_id_t id);
00169 
00170   
00171   
00172 #define GAVL_PACKET_TYPE_I 'I'      //!< Packet is an I-frame
00173 #define GAVL_PACKET_TYPE_P 'P'      //!< Packet is a P-frame
00174 #define GAVL_PACKET_TYPE_B 'B'      //!< Packet is a B-frame
00175 #define GAVL_PACKET_TYPE_MASK 0xff  //!< Mask for frame type
00176 
00177 #define GAVL_PACKET_KEYFRAME (1<<8) //!< Packet is a keyframe
00178 #define GAVL_PACKET_LAST     (1<<9) //!< Packet is the last in the stream (only Xiph codecs need this flag)
00179 
00193 typedef struct
00194   {
00195   uint8_t * data; 
00196   int data_len;   
00197   int data_alloc; 
00198 
00199   int flags;      
00200 
00201   int64_t pts;      
00202   int64_t duration; 
00203 
00204   int field2_offset; 
00205   int header_size;   
00206   int sequence_end_pos;    
00207 
00208   } gavl_packet_t;
00209 
00218 GAVL_PUBLIC
00219 void gavl_packet_alloc(gavl_packet_t * p, int len);
00220 
00225 GAVL_PUBLIC
00226 void gavl_packet_free(gavl_packet_t * p);
00227 
00234 GAVL_PUBLIC
00235 void gavl_packet_dump(const gavl_packet_t * p);
00236 
00241 #ifdef __cplusplus
00242 }
00243 #endif
00244  
00245 
00246 #endif // GAVL_COMPRESSION_H_INCLUDED
Generated on Fri Jun 8 17:27:53 2012 for gavl by  doxygen 1.6.3