daala: daala/codec.h Source File

daala 0.0-1733-g24f889a-dirty Experimental Daala video codec API reference.

Loading...
Searching...
No Matches
codec.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/*Daala video codec
3Copyright (c) 2006-2013 Daala project contributors. All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7
8- Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
10
11- Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14
15THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
16AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
19FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
25
45
48#if !defined(_daala_codec_H)
49# define _daala_codec_H (1)
50
51# if defined(__cplusplus)
52extern "C" {
53# endif
54
55#include "daala_integer.h"
56
57/*Enable special features for gcc and compatible compilers.*/
58# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
59# define OD_GNUC_PREREQ(maj, min, pat) \
60 ((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__ >= ((maj) << 16) + ((min) << 8) + pat)
61# else
62# define OD_GNUC_PREREQ(maj, min, pat) (0)
63# endif
64
65#if OD_GNUC_PREREQ(4, 0, 0)
66# pragma GCC visibility push(default)
67#endif
68
69#if OD_GNUC_PREREQ(3, 4, 0)
70# define OD_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
71#else
72# define OD_WARN_UNUSED_RESULT
73#endif
74
75#if OD_GNUC_PREREQ(3, 4, 0)
76# define OD_ARG_NONNULL(x) __attribute__((__nonnull__(x)))
77#else
78# define OD_ARG_NONNULL(x)
79#endif
80
81/*TODO: remove this ugliness*/
82# if defined(_MSC_VER)
83# pragma warning(disable:4100 4115 4125 4127 4152 4505 4554 4711)
84# endif
85
89#define OD_SUCCESS (0)
91# define OD_EFAULT (-1)
93# define OD_EINVAL (-10)
95# define OD_EBADHEADER (-20)
97# define OD_ENOTFORMAT (-21)
99# define OD_EVERSION (-22)
101# define OD_EIMPL (-23)
103# define OD_EBADPACKET (-24)
105
111# define OD_CS_UNSPECIFIED (0)
113# define OD_CS_ITU_REC_470M (1)
115# define OD_CS_ITU_REC_470BG (2)
117# define OD_CS_ITU_REC_790 (3)
119# define OD_CS_YCgCo (4)
121# define OD_CS_NSPACES (5)
123
125# define OD_NPLANES_MAX (4)
126
127typedef struct daala_image_plane daala_image_plane;
128typedef struct daala_image daala_image;
129typedef struct daala_plane_info daala_plane_info;
130typedef struct daala_info daala_info;
131typedef struct daala_comment daala_comment;
132
133const char *daala_version_string(void);
134
143 int daala_log_init(void);
144
146 struct daala_image_plane {
149 unsigned char *data;
154 unsigned char xdec;
155 unsigned char ydec;
162 int xstride;
165 int ystride;
171 int bitdepth;
172};
173
175 struct daala_image {
177 daala_image_plane planes[OD_NPLANES_MAX];
179 int nplanes;
181 int32_t width;
182 int32_t height;
183};
184
187 struct daala_plane_info {
188 unsigned char xdec;
189 unsigned char ydec;
190};
191
196#define OD_BITDEPTH_MODE_8 (1)
198#define OD_BITDEPTH_MODE_10 (2)
200#define OD_BITDEPTH_MODE_12 (3)
202
204 struct daala_info {
205 unsigned char version_major;
206 unsigned char version_minor;
207 unsigned char version_sub;
209 int32_t pic_width;
210 int32_t pic_height;
211 uint32_t pixel_aspect_numerator;
212 uint32_t pixel_aspect_denominator;
213 uint32_t timebase_numerator;
214 uint32_t timebase_denominator;
215 uint32_t frame_duration;
218 int keyframe_granule_shift;
221 int bitdepth_mode;
229 int full_precision_references;
230 int nplanes;
231 daala_plane_info plane_info[OD_NPLANES_MAX];
234 int keyframe_rate;
235};
236
237 typedef struct {
238 unsigned char *packet;
239 long bytes;
240 long b_o_s;
241 long e_o_s;
242
243 int64_t granulepos;
244 int64_t packetno;
245} daala_packet;
246
247void daala_info_init(daala_info *info);
248void daala_info_clear(daala_info *info);
249
272 struct daala_comment {
274 char **user_comments;
276 int *comment_lengths;
278 int comments;
281 char *vendor;
282};
283
287 void daala_comment_init(daala_comment *dc);
290 void daala_comment_clear(daala_comment *dc);
291
292int64_t daala_granule_basetime(void *encdec, int64_t granpos);
304 double daala_granule_time(void *encdec, int64_t granpos);
312 int daala_packet_isheader(daala_packet *dpkt);
320 int daala_packet_iskeyframe(daala_packet *dpkt);
321
322# if OD_GNUC_PREREQ(4, 0, 0)
323# pragma GCC visibility pop
324# endif
325# if defined(__cplusplus)
326}
327# endif
328
329#endif
OD_NPLANES_MAX
#define OD_NPLANES_MAX
The maximum number of color planes allowed in a single frame.
Definition codec.h:125
daala_comment_clear
void daala_comment_clear(daala_comment *dc)
Free resources allocated for metadata.
daala_granule_time
double daala_granule_time(void *encdec, int64_t granpos)
Converts a granule position to an absolute time in seconds.
daala_packet_iskeyframe
int daala_packet_iskeyframe(daala_packet *dpkt)
Determines whether a Daala packet is a key frame or not.
daala_comment_init
void daala_comment_init(daala_comment *dc)
Initializes a daala_comment section.
daala_packet_isheader
int daala_packet_isheader(daala_packet *dpkt)
Determines whether a Daala packet is a header or not.
daala_log_init
int daala_log_init(void)
Initialize the logging module.
daala_comment
The comment information.
Definition codec.h:272
daala_comment::comment_lengths
int * comment_lengths
An array of the corresponding lengths of each vector, in bytes.
Definition codec.h:276
daala_comment::vendor
char * vendor
The null-terminated vendor string.
Definition codec.h:281
daala_comment::user_comments
char ** user_comments
The array of comment string vectors.
Definition codec.h:274
daala_comment::comments
int comments
The total number of comment strings.
Definition codec.h:278
daala_image_plane
Representation of a single component within an image or frame.
Definition codec.h:146
daala_image_plane::xdec
unsigned char xdec
The decimation factor in the x and y direction.
Definition codec.h:154
daala_image_plane::ystride
int ystride
Distance in memory between two pixels vertically next to each other.
Definition codec.h:165
daala_image_plane::xstride
int xstride
Distance in memory between two pixels horizontally next to each other.
Definition codec.h:162
daala_image_plane::bitdepth
int bitdepth
8 for 'normal' video precision; data is unsigned bytes centered on 128.
Definition codec.h:171
daala_image_plane::data
unsigned char * data
Image data is stored as an unsigned octet type whether it's actually 8 bit or a multi-byte depth.
Definition codec.h:149
daala_image
Representation of an image or video frame.
Definition codec.h:175
daala_image::planes
daala_image_plane planes[OD_NPLANES_MAX]
Typical 3 planes for Y, Cb, and Cr.
Definition codec.h:177
daala_image::nplanes
int nplanes
Number of planes (1 for greyscale, 3 for YCbCr, 4 for YCbCr+Alpha ).
Definition codec.h:179
daala_image::width
int32_t width
Width and height in pixels.
Definition codec.h:181
daala_info
Configuration parameters for a codec instance.
Definition codec.h:204
daala_info::keyframe_granule_shift
int keyframe_granule_shift
The amount to shift to extract the last keyframe number from the granule position.
Definition codec.h:218
daala_info::bitdepth_mode
int bitdepth_mode
bitdepth_mode is one of the three OD_BITDEPTH_MODE_X choices allowed above.
Definition codec.h:221
daala_info::pic_width
int32_t pic_width
pic_width,_height form a region of interest to encode
Definition codec.h:209
daala_info::keyframe_rate
int keyframe_rate
key frame rate defined how often a key frame is emitted by encoder in number of frames.
Definition codec.h:234
daala_info::full_precision_references
int full_precision_references
FPR must be on for high-depth, including lossless high-depth.
Definition codec.h:229
daala_packet
Definition codec.h:237
daala_plane_info
Subsampling factors for a plane as a power of 2.
Definition codec.h:187