gavl
|
00001 /***************************************************************** 00002 * gavl - a general purpose audio/video processing library 00003 * 00004 * Copyright (c) 2001 - 2012 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 00047 #define GAVL_COMPRESSION_HAS_P_FRAMES (1<<0) 00048 00050 #define GAVL_COMPRESSION_HAS_B_FRAMES (1<<1) //!< 00051 00053 #define GAVL_COMPRESSION_HAS_FIELD_PICTURES (1<<2) 00054 00056 #define GAVL_COMPRESSION_SBR (1<<3) 00057 00059 #define GAVL_COMPRESSION_BIG_ENDIAN (1<<4) 00060 00066 typedef enum 00067 { 00068 00072 GAVL_CODEC_ID_NONE = 0, 00073 /* Audio */ 00074 GAVL_CODEC_ID_ALAW = 1, 00075 GAVL_CODEC_ID_ULAW, 00076 GAVL_CODEC_ID_MP2, 00077 GAVL_CODEC_ID_MP3, 00078 GAVL_CODEC_ID_AC3, 00079 GAVL_CODEC_ID_AAC, 00080 GAVL_CODEC_ID_VORBIS, 00081 GAVL_CODEC_ID_FLAC, 00082 GAVL_CODEC_ID_OPUS, 00083 GAVL_CODEC_ID_SPEEX, 00084 GAVL_CODEC_ID_DTS, 00085 00086 /* Video */ 00087 GAVL_CODEC_ID_JPEG = 0x10000, 00088 GAVL_CODEC_ID_PNG, 00089 GAVL_CODEC_ID_TIFF, 00090 GAVL_CODEC_ID_TGA, 00091 GAVL_CODEC_ID_MPEG1, 00092 GAVL_CODEC_ID_MPEG2, 00093 GAVL_CODEC_ID_MPEG4_ASP, 00094 GAVL_CODEC_ID_H264, 00095 GAVL_CODEC_ID_THEORA, 00096 GAVL_CODEC_ID_DIRAC, 00097 GAVL_CODEC_ID_DV, 00098 GAVL_CODEC_ID_VP8, 00099 GAVL_CODEC_ID_DIV3, 00100 00101 /* Subtitle (some video codecs can handle subtitles also */ 00102 GAVL_CODEC_ID_DVDSUB = 0x20000, 00103 00104 } gavl_codec_id_t; 00105 00106 #define GAVL_BITRATE_VBR -1 //!< Use this to specify a VBR stream 00107 #define GAVL_BITRATE_LOSSLESS -2 //!< Use this to specify a losslessly compressed stream 00108 00119 typedef struct 00120 { 00121 uint32_t flags; 00122 gavl_codec_id_t id; 00123 00124 uint8_t * global_header; 00125 uint32_t global_header_len; 00126 00127 int32_t bitrate; 00128 int palette_size; 00129 uint32_t pre_skip; 00130 00131 uint32_t video_buffer_size; 00132 00133 uint32_t max_packet_size; 00134 00135 uint32_t max_ref_frames; 00136 00137 } gavl_compression_info_t; 00138 00146 void gavl_compression_info_init(gavl_compression_info_t * info); 00147 00152 GAVL_PUBLIC 00153 void gavl_compression_info_free(gavl_compression_info_t* info); 00154 00161 GAVL_PUBLIC 00162 void gavl_compression_info_dump(const gavl_compression_info_t * info); 00163 00172 GAVL_PUBLIC 00173 void gavl_compression_info_dumpi(const gavl_compression_info_t * info, int num); 00174 00181 GAVL_PUBLIC 00182 void gavl_compression_info_copy(gavl_compression_info_t * dst, 00183 const gavl_compression_info_t * src); 00184 00192 GAVL_PUBLIC 00193 void gavl_append_xiph_header(uint8_t ** global_header, 00194 int * global_header_len, 00195 uint8_t * header, 00196 int header_len); 00197 00206 GAVL_PUBLIC 00207 uint8_t * gavl_extract_xiph_header(uint8_t * global_header, 00208 int global_header_len, 00209 int idx, 00210 int * header_len); 00211 00212 00228 GAVL_PUBLIC 00229 const char * gavl_compression_get_extension(gavl_codec_id_t id, int * separate); 00230 00240 GAVL_PUBLIC 00241 int gavl_compression_need_pixelformat(gavl_codec_id_t id); 00242 00248 const char * gavl_compression_get_mimetype(const gavl_compression_info_t * ci); 00249 00256 GAVL_PUBLIC 00257 int gavl_compression_constant_frame_samples(gavl_codec_id_t id); 00258 00264 GAVL_PUBLIC 00265 int gavl_compression_get_sample_size(gavl_codec_id_t id); 00266 00272 GAVL_PUBLIC const char * 00273 gavl_compression_get_long_name(gavl_codec_id_t id); 00274 00280 GAVL_PUBLIC const char * 00281 gavl_compression_get_short_name(gavl_codec_id_t id); 00282 00288 GAVL_PUBLIC gavl_codec_id_t 00289 gavl_compression_from_short_name(const char * name); 00290 00298 GAVL_PUBLIC 00299 int gavl_num_compressions(); 00300 00309 GAVL_PUBLIC 00310 gavl_codec_id_t gavl_get_compression(int index); 00311 00312 00313 #define GAVL_PACKET_TYPE_I 0x01 //!< Packet is an I-frame 00314 #define GAVL_PACKET_TYPE_P 0x02 //!< Packet is a P-frame 00315 #define GAVL_PACKET_TYPE_B 0x03 //!< Packet is a B-frame 00316 #define GAVL_PACKET_TYPE_MASK 0x03 //!< Mask for frame type 00317 00318 #define GAVL_PACKET_KEYFRAME (1<<2) //!< Packet is a keyframe 00319 #define GAVL_PACKET_LAST (1<<3) //!< Packet is the last in the stream (only Xiph codecs need this flag) 00320 #define GAVL_PACKET_EXT (1<<4) //!< Packet has extensions (used only in gavf files) 00321 #define GAVL_PACKET_REF (1<<5) //!< B-frame used as reference (can't savely be skipped) 00322 #define GAVL_PACKET_NOOUTPUT (1<<6) //!< Packet will produce no decoder output (e.g. VP8 alternate reference) 00323 00324 #define GAVL_PACKET_PADDING 32 //!< Packets are padded with this many zero bytes 00325 00339 typedef struct 00340 { 00341 uint8_t * data; 00342 int data_len; 00343 int data_alloc; 00344 00345 uint32_t flags; 00346 00347 int64_t pts; 00348 int64_t duration; 00349 00350 uint32_t field2_offset; 00351 uint32_t header_size; 00352 uint32_t sequence_end_pos; 00353 00354 gavl_interlace_mode_t interlace_mode; 00355 gavl_timecode_t timecode; 00356 00357 gavl_rectangle_i_t src_rect; 00358 int32_t dst_x; 00359 int32_t dst_y; 00360 00361 uint32_t id; 00362 00363 } gavl_packet_t; 00364 00370 GAVL_PUBLIC 00371 void gavl_packet_init(gavl_packet_t * p); 00372 00373 00382 GAVL_PUBLIC 00383 void gavl_packet_alloc(gavl_packet_t * p, int len); 00384 00389 GAVL_PUBLIC 00390 void gavl_packet_free(gavl_packet_t * p); 00391 00397 GAVL_PUBLIC 00398 void gavl_packet_copy(gavl_packet_t * dst, 00399 const gavl_packet_t * src); 00400 00411 GAVL_PUBLIC 00412 void gavl_packet_copy_metadata(gavl_packet_t * dst, 00413 const gavl_packet_t * src); 00414 00415 00422 GAVL_PUBLIC 00423 void gavl_packet_reset(gavl_packet_t * p); 00424 00425 00432 GAVL_PUBLIC 00433 void gavl_packet_dump(const gavl_packet_t * p); 00434 00442 GAVL_PUBLIC 00443 void gavl_packet_save(const gavl_packet_t * p, 00444 const char * filename); 00445 00450 #ifdef __cplusplus 00451 } 00452 #endif 00453 00454 00455 #endif // GAVL_COMPRESSION_H_INCLUDED