compression.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00052
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
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
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
00102 GAVL_CODEC_ID_DVDSUB = 0x20000,
00103
00104 } gavl_codec_id_t;
00105
00106 #define GAVL_BITRATE_VBR -1
00107 #define GAVL_BITRATE_LOSSLESS -2
00108
00109
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
00314 #define GAVL_PACKET_TYPE_P 0x02
00315 #define GAVL_PACKET_TYPE_B 0x03
00316 #define GAVL_PACKET_TYPE_MASK 0x03
00317
00318 #define GAVL_PACKET_KEYFRAME (1<<2)
00319 #define GAVL_PACKET_LAST (1<<3)
00320 #define GAVL_PACKET_EXT (1<<4)
00321 #define GAVL_PACKET_REF (1<<5)
00322 #define GAVL_PACKET_NOOUTPUT (1<<6)
00323
00324 #define GAVL_PACKET_PADDING 32
00325
00326
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