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
28 extern "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 
50 typedef enum
51  {
53  /* Audio */
61 
62  /* Video */
63  GAVL_CODEC_ID_JPEG = 0x10000,
75 
86 typedef struct
87  {
88  int flags;
90 
91  uint8_t * global_header;
93 
94  int bitrate;
97 
102 GAVL_PUBLIC
104 
111 GAVL_PUBLIC
113 
129 GAVL_PUBLIC
130 const char * gavl_compression_get_extension(gavl_codec_id_t id, int * separate);
131 
141 GAVL_PUBLIC
143 
144 
145 #define GAVL_PACKET_TYPE_I 'I'
146 #define GAVL_PACKET_TYPE_P 'P'
147 #define GAVL_PACKET_TYPE_B 'B'
148 #define GAVL_PACKET_TYPE_MASK 0xff
149 
150 #define GAVL_PACKET_KEYFRAME (1<<8)
151 #define GAVL_PACKET_LAST (1<<9)
152 
153 
166 typedef struct
167  {
168  uint8_t * data;
169  int data_len;
171 
172  int flags;
173 
174  int64_t pts;
175  int64_t duration;
176 
180 
181  } gavl_packet_t;
182 
191 GAVL_PUBLIC
192 void gavl_packet_alloc(gavl_packet_t * p, int len);
193 
198 GAVL_PUBLIC
200 
207 GAVL_PUBLIC
208 void gavl_packet_dump(const gavl_packet_t * p);
209 
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 
215 
216 #endif // GAVL_COMPRESSION_H_INCLUDED
int data_len
Length of data.
Definition: compression.h:169
Complete DIRAC frames, sequence end code appended to last packet.
Definition: compression.h:72
int64_t pts
Presentation time.
Definition: compression.h:174
MPEG-1 video.
Definition: compression.h:67
GAVL_PUBLIC void gavl_compression_info_dump(const gavl_compression_info_t *info)
Dump a compression info to stderr.
AAC as stored in quicktime/mp4.
Definition: compression.h:59
MPEG-1 audio layer II.
Definition: compression.h:56
int data_alloc
How many bytes got allocated.
Definition: compression.h:170
GAVL_PUBLIC void gavl_packet_free(gavl_packet_t *p)
Free memory of a packet.
uint8_t * global_header
Global header.
Definition: compression.h:91
int64_t duration
Duration of the contained frame.
Definition: compression.h:175
MPEG-4 ASP (a.k.a. Divx4)
Definition: compression.h:69
int header_size
Size of a repeated global header (or 0)
Definition: compression.h:178
GAVL_PUBLIC void gavl_compression_info_free(gavl_compression_info_t *info)
Free all dynamically allocated memory of a compression info.
Compression format.
Definition: compression.h:86
uint8_t * data
Data.
Definition: compression.h:168
int palette_size
Size of the embedded palette for image codecs.
Definition: compression.h:95
H.264 (Annex B)
Definition: compression.h:70
GAVL_PUBLIC void gavl_packet_dump(const gavl_packet_t *p)
Dump a packet to stderr.
int global_header_len
Length of global header.
Definition: compression.h:92
Vorbis (segmented extradata and packets)
Definition: compression.h:60
int field2_offset
Offset of field 2 for field pictures.
Definition: compression.h:177
gavl_codec_id_t id
Codec ID.
Definition: compression.h:89
TIFF image.
Definition: compression.h:65
alaw 2:1
Definition: compression.h:54
JPEG image.
Definition: compression.h:63
GAVL_PUBLIC const char * gavl_compression_get_extension(gavl_codec_id_t id, int *separate)
Get the file extension of the corresponding raw format.
Unknown/unsupported compression format.
Definition: compression.h:52
MPEG-1/2 audio layer 3 CBR/VBR.
Definition: compression.h:57
MPEG-2 video.
Definition: compression.h:68
TGA image.
Definition: compression.h:66
gavl_codec_id_t
Definition: compression.h:50
DV (several variants)
Definition: compression.h:73
int flags
ORed combination of GAVL_PACKET_* flags.
Definition: compression.h:172
int sequence_end_pos
Position of sequence end code if any.
Definition: compression.h:179
Theora (segmented extradata.
Definition: compression.h:71
PNG image.
Definition: compression.h:64
GAVL_PUBLIC int gavl_compression_need_pixelformat(gavl_codec_id_t id)
Check if the compression supports multiple pixelformats.
mu-law 2:1
Definition: compression.h:55
int bitrate
Needed by some codecs, negative values mean VBR.
Definition: compression.h:94
GAVL_PUBLIC void gavl_packet_alloc(gavl_packet_t *p, int len)
Allocate memory for a packet.
Packet structure.
Definition: compression.h:166
AC3.
Definition: compression.h:58
int flags
ORed combination of GAVL_COMPRESSION_* flags.
Definition: compression.h:88