compression.h
/*****************************************************************
* gavl - a general purpose audio/video processing library
*
* Copyright (c) 2001 - 2011 Members of the Gmerlin project
* gmerlin-general@lists.sourceforge.net
* http://gmerlin.sourceforge.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *****************************************************************/
#ifndef GAVL_COMPRESSION_H_INCLUDED
#define GAVL_COMPRESSION_H_INCLUDED
#include <gavl/gavldefs.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GAVL_COMPRESSION_HAS_P_FRAMES (1<<0)
#define GAVL_COMPRESSION_HAS_B_FRAMES (1<<1)
#define GAVL_COMPRESSION_HAS_FIELD_PICTURES (1<<2)
#define GAVL_COMPRESSION_SBR (1<<3)
typedef enum
{
GAVL_CODEC_ID_NONE = 0,
/* Audio */
GAVL_CODEC_ID_ALAW = 1,
GAVL_CODEC_ID_ULAW,
GAVL_CODEC_ID_MP2,
GAVL_CODEC_ID_MP3,
GAVL_CODEC_ID_AC3,
GAVL_CODEC_ID_AAC,
GAVL_CODEC_ID_VORBIS,
GAVL_CODEC_ID_FLAC,
/* Video */
GAVL_CODEC_ID_JPEG = 0x10000,
GAVL_CODEC_ID_PNG,
GAVL_CODEC_ID_TIFF,
GAVL_CODEC_ID_TGA,
GAVL_CODEC_ID_MPEG1,
GAVL_CODEC_ID_MPEG2,
GAVL_CODEC_ID_MPEG4_ASP,
GAVL_CODEC_ID_H264,
GAVL_CODEC_ID_THEORA,
GAVL_CODEC_ID_DIRAC,
GAVL_CODEC_ID_DV,
} gavl_codec_id_t;
typedef struct
{
int flags;
gavl_codec_id_t id;
uint8_t * global_header;
int global_header_len;
int bitrate;
int palette_size;
} gavl_compression_info_t;
GAVL_PUBLIC
void gavl_compression_info_free(gavl_compression_info_t* info);
GAVL_PUBLIC
void gavl_compression_info_dump(const gavl_compression_info_t * info);
GAVL_PUBLIC
void gavl_compression_info_copy(gavl_compression_info_t * dst,
const gavl_compression_info_t * src);
GAVL_PUBLIC
const char * gavl_compression_get_extension(gavl_codec_id_t id, int * separate);
GAVL_PUBLIC
int gavl_compression_need_pixelformat(gavl_codec_id_t id);
GAVL_PUBLIC
int gavl_compression_constant_frame_samples(gavl_codec_id_t id);
#define GAVL_PACKET_TYPE_I 'I'
#define GAVL_PACKET_TYPE_P 'P'
#define GAVL_PACKET_TYPE_B 'B'
#define GAVL_PACKET_TYPE_MASK 0xff
#define GAVL_PACKET_KEYFRAME (1<<8)
#define GAVL_PACKET_LAST (1<<9)
typedef struct
{
uint8_t * data;
int data_len;
int data_alloc;
int flags;
int64_t pts;
int64_t duration;
int field2_offset;
int header_size;
int sequence_end_pos;
} gavl_packet_t;
GAVL_PUBLIC
void gavl_packet_alloc(gavl_packet_t * p, int len);
GAVL_PUBLIC
void gavl_packet_free(gavl_packet_t * p);
GAVL_PUBLIC
void gavl_packet_dump(const gavl_packet_t * p);
#ifdef __cplusplus
}
#endif
#endif // GAVL_COMPRESSION_H_INCLUDED
gavl_compression_info_dump
GAVL_PUBLIC void gavl_compression_info_dump(const gavl_compression_info_t *info)
Dump a compression info to stderr.
gavl_packet_dump
GAVL_PUBLIC void gavl_packet_dump(const gavl_packet_t *p)
Dump a packet to stderr.
gavl_compression_need_pixelformat
GAVL_PUBLIC int gavl_compression_need_pixelformat(gavl_codec_id_t id)
Check if the compression supports multiple pixelformats.
gavl_compression_get_extension
GAVL_PUBLIC const char * gavl_compression_get_extension(gavl_codec_id_t id, int *separate)
Get the file extension of the corresponding raw format.
gavl_codec_id_t
gavl_codec_id_t
Codec ID.
Definition: compression.h:56
gavl_packet_free
GAVL_PUBLIC void gavl_packet_free(gavl_packet_t *p)
Free memory of a packet.
gavl_packet_alloc
GAVL_PUBLIC void gavl_packet_alloc(gavl_packet_t *p, int len)
Allocate memory for a packet.
gavl_compression_info_copy
GAVL_PUBLIC void gavl_compression_info_copy(gavl_compression_info_t *dst, const gavl_compression_info_t *src)
Copy a compression info.
gavl_compression_constant_frame_samples
GAVL_PUBLIC int gavl_compression_constant_frame_samples(gavl_codec_id_t id)
Check if an audio compression constant frame samples.
gavl_compression_info_free
GAVL_PUBLIC void gavl_compression_info_free(gavl_compression_info_t *info)
Free all dynamically allocated memory of a compression info.
GAVL_CODEC_ID_VORBIS
@ GAVL_CODEC_ID_VORBIS
Vorbis (segmented extradata and packets)
Definition: compression.h:65
GAVL_CODEC_ID_MPEG1
@ GAVL_CODEC_ID_MPEG1
MPEG-1 video.
Definition: compression.h:73
GAVL_CODEC_ID_DV
@ GAVL_CODEC_ID_DV
DV (several variants)
Definition: compression.h:79
GAVL_CODEC_ID_AC3
@ GAVL_CODEC_ID_AC3
AC3.
Definition: compression.h:63
GAVL_CODEC_ID_DIRAC
@ GAVL_CODEC_ID_DIRAC
Complete DIRAC frames, sequence end code appended to last packet.
Definition: compression.h:78
GAVL_CODEC_ID_TGA
@ GAVL_CODEC_ID_TGA
TGA image.
Definition: compression.h:72
GAVL_CODEC_ID_MPEG2
@ GAVL_CODEC_ID_MPEG2
MPEG-2 video.
Definition: compression.h:74
GAVL_CODEC_ID_AAC
@ GAVL_CODEC_ID_AAC
AAC as stored in quicktime/mp4.
Definition: compression.h:64
GAVL_CODEC_ID_MPEG4_ASP
@ GAVL_CODEC_ID_MPEG4_ASP
MPEG-4 ASP (a.k.a. Divx4)
Definition: compression.h:75
GAVL_CODEC_ID_JPEG
@ GAVL_CODEC_ID_JPEG
JPEG image.
Definition: compression.h:69
GAVL_CODEC_ID_H264
@ GAVL_CODEC_ID_H264
H.264 (Annex B)
Definition: compression.h:76
GAVL_CODEC_ID_MP2
@ GAVL_CODEC_ID_MP2
MPEG-1 audio layer II.
Definition: compression.h:61
GAVL_CODEC_ID_TIFF
@ GAVL_CODEC_ID_TIFF
TIFF image.
Definition: compression.h:71
GAVL_CODEC_ID_FLAC
@ GAVL_CODEC_ID_FLAC
Flac (extradata contain a file header without comment and seektable)
Definition: compression.h:66
GAVL_CODEC_ID_THEORA
@ GAVL_CODEC_ID_THEORA
Theora (segmented extradata)
Definition: compression.h:77
GAVL_CODEC_ID_MP3
@ GAVL_CODEC_ID_MP3
MPEG-1/2 audio layer 3 CBR/VBR.
Definition: compression.h:62
GAVL_CODEC_ID_PNG
@ GAVL_CODEC_ID_PNG
PNG image.
Definition: compression.h:70
GAVL_CODEC_ID_ALAW
@ GAVL_CODEC_ID_ALAW
alaw 2:1
Definition: compression.h:59
GAVL_CODEC_ID_NONE
@ GAVL_CODEC_ID_NONE
Unknown/unsupported compression format.
Definition: compression.h:57
GAVL_CODEC_ID_ULAW
@ GAVL_CODEC_ID_ULAW
mu-law 2:1
Definition: compression.h:60
gavl_compression_info_t
Compression format.
Definition: compression.h:93
gavl_compression_info_t::id
gavl_codec_id_t id
Codec ID.
Definition: compression.h:95
gavl_compression_info_t::global_header
uint8_t * global_header
Global header.
Definition: compression.h:97
gavl_compression_info_t::flags
int flags
ORed combination of GAVL_COMPRESSION_* flags.
Definition: compression.h:94
gavl_compression_info_t::global_header_len
int global_header_len
Length of global header.
Definition: compression.h:98
gavl_compression_info_t::bitrate
int bitrate
Needed by some codecs, negative values mean VBR.
Definition: compression.h:100
gavl_compression_info_t::palette_size
int palette_size
Size of the embedded palette for image codecs.
Definition: compression.h:101
gavl_packet_t
Packet structure.
Definition: compression.h:194
gavl_packet_t::data_len
int data_len
Length of data.
Definition: compression.h:196
gavl_packet_t::header_size
int header_size
Size of a repeated global header (or 0)
Definition: compression.h:205
gavl_packet_t::data
uint8_t * data
Data.
Definition: compression.h:195
gavl_packet_t::pts
int64_t pts
Presentation time.
Definition: compression.h:201
gavl_packet_t::sequence_end_pos
int sequence_end_pos
Position of sequence end code if any.
Definition: compression.h:206
gavl_packet_t::flags
int flags
ORed combination of GAVL_PACKET_* flags.
Definition: compression.h:199
gavl_packet_t::duration
int64_t duration
Duration of the contained frame.
Definition: compression.h:202
gavl_packet_t::field2_offset
int field2_offset
Offset of field 2 for field pictures.
Definition: compression.h:204
gavl_packet_t::data_alloc
int data_alloc
How many bytes got allocated.
Definition: compression.h:197