gavl: /build/gavl/src/gavl-1.4.0/include/gavl/compression.h Source File

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
55 typedef enum
56 {
57 GAVL_CODEC_ID_NONE = 0,
58 /* Audio */
59 GAVL_CODEC_ID_ALAW = 1,
60 GAVL_CODEC_ID_ULAW,
61 GAVL_CODEC_ID_MP2,
62 GAVL_CODEC_ID_MP3,
63 GAVL_CODEC_ID_AC3,
64 GAVL_CODEC_ID_AAC,
65 GAVL_CODEC_ID_VORBIS,
66 GAVL_CODEC_ID_FLAC,
67
68 /* Video */
69 GAVL_CODEC_ID_JPEG = 0x10000,
70 GAVL_CODEC_ID_PNG,
71 GAVL_CODEC_ID_TIFF,
72 GAVL_CODEC_ID_TGA,
73 GAVL_CODEC_ID_MPEG1,
74 GAVL_CODEC_ID_MPEG2,
75 GAVL_CODEC_ID_MPEG4_ASP,
76 GAVL_CODEC_ID_H264,
77 GAVL_CODEC_ID_THEORA,
78 GAVL_CODEC_ID_DIRAC,
79 GAVL_CODEC_ID_DV,
80 } gavl_codec_id_t;
81
92 typedef struct
93 {
94 int flags;
95 gavl_codec_id_t id;
96
97 uint8_t * global_header;
98 int global_header_len;
99
100 int bitrate;
101 int palette_size;
102 } gavl_compression_info_t;
103
108GAVL_PUBLIC
109 void gavl_compression_info_free(gavl_compression_info_t* info);
110
117GAVL_PUBLIC
118 void gavl_compression_info_dump(const gavl_compression_info_t * info);
119
126GAVL_PUBLIC
127 void gavl_compression_info_copy(gavl_compression_info_t * dst,
128 const gavl_compression_info_t * src);
129
130
146GAVL_PUBLIC
147 const char * gavl_compression_get_extension(gavl_codec_id_t id, int * separate);
148
158GAVL_PUBLIC
159 int gavl_compression_need_pixelformat(gavl_codec_id_t id);
160
167GAVL_PUBLIC
168 int gavl_compression_constant_frame_samples(gavl_codec_id_t id);
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
193 typedef struct
194 {
195 uint8_t * data;
196 int data_len;
197 int data_alloc;
198
199 int flags;
200
201 int64_t pts;
202 int64_t duration;
203
204 int field2_offset;
205 int header_size;
206 int sequence_end_pos;
207
208 } gavl_packet_t;
209
218GAVL_PUBLIC
219 void gavl_packet_alloc(gavl_packet_t * p, int len);
220
225GAVL_PUBLIC
226 void gavl_packet_free(gavl_packet_t * p);
227
234GAVL_PUBLIC
235 void gavl_packet_dump(const gavl_packet_t * p);
236
241#ifdef __cplusplus
242}
243#endif
244
245
246#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