gavl
compression.h
1/*****************************************************************
2 * gavl - a general purpose audio/video processing library
3 *
4 * Copyright (c) 2001 - 2011 Members of the Gmerlin project
5 * gmerlin-general@lists.sourceforge.net
6 * http://gmerlin.sourceforge.net
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * *****************************************************************/
21
22#ifndef GAVL_COMPRESSION_H_INCLUDED
23#define GAVL_COMPRESSION_H_INCLUDED
24
25#include <gavl/gavldefs.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
45#define GAVL_COMPRESSION_HAS_P_FRAMES (1<<0)
46#define GAVL_COMPRESSION_HAS_B_FRAMES (1<<1)
47#define GAVL_COMPRESSION_HAS_FIELD_PICTURES (1<<2)
48#define GAVL_COMPRESSION_SBR (1<<3)
49
55typedef enum
56 {
58 /* Audio */
67
68 /* Video */
81
92typedef struct
93 {
94 int flags;
96
97 uint8_t * global_header;
99
103
108GAVL_PUBLIC
110
117GAVL_PUBLIC
119
126GAVL_PUBLIC
128 const gavl_compression_info_t * src);
129
130
146GAVL_PUBLIC
147const char * gavl_compression_get_extension(gavl_codec_id_t id, int * separate);
148
158GAVL_PUBLIC
160
167GAVL_PUBLIC
169
170
171
172#define GAVL_PACKET_TYPE_I 'I'
173#define GAVL_PACKET_TYPE_P 'P'
174#define GAVL_PACKET_TYPE_B 'B'
175#define GAVL_PACKET_TYPE_MASK 0xff
176
177#define GAVL_PACKET_KEYFRAME (1<<8)
178#define GAVL_PACKET_LAST (1<<9)
179
193typedef struct
194 {
195 uint8_t * data;
198
199 int flags;
200
201 int64_t pts;
202 int64_t duration;
203
207
209
218GAVL_PUBLIC
220
225GAVL_PUBLIC
227
234GAVL_PUBLIC
236
241#ifdef __cplusplus
242}
243#endif
244
245
246#endif // GAVL_COMPRESSION_H_INCLUDED
GAVL_PUBLIC void gavl_compression_info_dump(const gavl_compression_info_t *info)
Dump a compression info to stderr.
GAVL_PUBLIC void gavl_packet_dump(const gavl_packet_t *p)
Dump a packet to stderr.
GAVL_PUBLIC int gavl_compression_need_pixelformat(gavl_codec_id_t id)
Check if the compression supports multiple pixelformats.
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
Codec ID.
Definition: compression.h:56
GAVL_PUBLIC void gavl_packet_free(gavl_packet_t *p)
Free memory of a packet.
GAVL_PUBLIC void gavl_packet_alloc(gavl_packet_t *p, int len)
Allocate memory for a packet.
GAVL_PUBLIC void gavl_compression_info_copy(gavl_compression_info_t *dst, const gavl_compression_info_t *src)
Copy a compression info.
GAVL_PUBLIC int gavl_compression_constant_frame_samples(gavl_codec_id_t id)
Check if an audio compression constant frame samples.
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
Vorbis (segmented extradata and packets)
Definition: compression.h:65
@ GAVL_CODEC_ID_MPEG1
MPEG-1 video.
Definition: compression.h:73
@ GAVL_CODEC_ID_DV
DV (several variants)
Definition: compression.h:79
@ GAVL_CODEC_ID_AC3
AC3.
Definition: compression.h:63
@ GAVL_CODEC_ID_DIRAC
Complete DIRAC frames, sequence end code appended to last packet.
Definition: compression.h:78
@ GAVL_CODEC_ID_TGA
TGA image.
Definition: compression.h:72
@ GAVL_CODEC_ID_MPEG2
MPEG-2 video.
Definition: compression.h:74
@ GAVL_CODEC_ID_AAC
AAC as stored in quicktime/mp4.
Definition: compression.h:64
@ GAVL_CODEC_ID_MPEG4_ASP
MPEG-4 ASP (a.k.a. Divx4)
Definition: compression.h:75
@ GAVL_CODEC_ID_JPEG
JPEG image.
Definition: compression.h:69
@ GAVL_CODEC_ID_H264
H.264 (Annex B)
Definition: compression.h:76
@ GAVL_CODEC_ID_MP2
MPEG-1 audio layer II.
Definition: compression.h:61
@ GAVL_CODEC_ID_TIFF
TIFF image.
Definition: compression.h:71
@ GAVL_CODEC_ID_FLAC
Flac (extradata contain a file header without comment and seektable)
Definition: compression.h:66
@ GAVL_CODEC_ID_THEORA
Theora (segmented extradata)
Definition: compression.h:77
@ GAVL_CODEC_ID_MP3
MPEG-1/2 audio layer 3 CBR/VBR.
Definition: compression.h:62
@ GAVL_CODEC_ID_PNG
PNG image.
Definition: compression.h:70
@ GAVL_CODEC_ID_ALAW
alaw 2:1
Definition: compression.h:59
@ GAVL_CODEC_ID_NONE
Unknown/unsupported compression format.
Definition: compression.h:57
@ GAVL_CODEC_ID_ULAW
mu-law 2:1
Definition: compression.h:60
Compression format.
Definition: compression.h:93
gavl_codec_id_t id
Codec ID.
Definition: compression.h:95
uint8_t * global_header
Global header.
Definition: compression.h:97
int flags
ORed combination of GAVL_COMPRESSION_* flags.
Definition: compression.h:94
int global_header_len
Length of global header.
Definition: compression.h:98
int bitrate
Needed by some codecs, negative values mean VBR.
Definition: compression.h:100
int palette_size
Size of the embedded palette for image codecs.
Definition: compression.h:101
Packet structure.
Definition: compression.h:194
int data_len
Length of data.
Definition: compression.h:196
int header_size
Size of a repeated global header (or 0)
Definition: compression.h:205
uint8_t * data
Data.
Definition: compression.h:195
int64_t pts
Presentation time.
Definition: compression.h:201
int sequence_end_pos
Position of sequence end code if any.
Definition: compression.h:206
int flags
ORed combination of GAVL_PACKET_* flags.
Definition: compression.h:199
int64_t duration
Duration of the contained frame.
Definition: compression.h:202
int field2_offset
Offset of field 2 for field pictures.
Definition: compression.h:204
int data_alloc
How many bytes got allocated.
Definition: compression.h:197