daala  0.0-437-g2cb8134
Experimental Daala video codec API reference.
 All Data Structures Files Functions Variables Typedefs Macros Groups
Modules | Macros
Functions for Encoding

Modules

 Configuration keys for the encoder ctl interface.
 Encoder CTL settings.
 

Macros

#define OD_SET_QUANT   4000
 Set the quantizer scale. More...
 

Functions for encoding

You must link to libdaalabase and libdaalaenc if you use any of the functions in this section.

The functions are listed in the order they are used in a typical encode. The basic steps are:

  • Fill in a daala_info structure with details on the format of the video you wish to encode.
  • Allocate a daala_enc_ctx handle with daala_encode_alloc().
  • Perform any additional encoder configuration required with daala_encode_ctl().
  • Repeatedly call daala_encode_flusheader() to retrieve all the header packets.
  • For each uncompressed frame:
  • Call daala_encode_free() to release all encoder memory.
daala_enc_ctxdaala_encode_create (const daala_info *info)
 Allocates and initializes an encoder instance. More...
 
int daala_encode_ctl (daala_enc_ctx *enc, int req, void *buf, size_t buf_sz)
 Encoder control function. More...
 
int daala_encode_flush_header (daala_enc_ctx *enc, daala_comment *comments, ogg_packet *op)
 Outputs the next header packet. More...
 
int daala_encode_img_in (daala_enc_ctx *enc, od_img *img, int duration)
 Submits an uncompressed frame to the encoder. More...
 
int daala_encode_packet_out (daala_enc_ctx *enc, int last, ogg_packet *op)
 Retrieves encoded video data packets. More...
 
void daala_encode_free (daala_enc_ctx *enc)
 Frees an allocated encoder instance. More...
 

Detailed Description

Macro Definition Documentation

#define OD_SET_QUANT   4000

Set the quantizer scale.

The passed buffer is interpreted as containing a single int. The valid range is 0-511.

Function Documentation

daala_enc_ctx* daala_encode_create ( const daala_info info)

Allocates and initializes an encoder instance.

Parameters
infoA daala_info struct filled with the desired encoding parameters.
Returns
The initialized daala_enc_ctx handle.
Return values
NULLif the encoding parameters were invalid.
int daala_encode_ctl ( daala_enc_ctx enc,
int  req,
void *  buf,
size_t  buf_sz 
)

Encoder control function.

This is used to provide advanced control of the encoding process.

Parameters
encA daala_enc_ctx handle.
reqThe control code to process. See the list of available control codes for details.
bufThe parameters for this control code.
buf_szThe size of the parameter buffer.
int daala_encode_flush_header ( daala_enc_ctx enc,
daala_comment comments,
ogg_packet *  op 
)

Outputs the next header packet.

This should be called repeatedly after encoder initialization until it return 0 to get all of the header packets, in order, before encoding actual video data.

Parameters
encA daala_enc_ctx handle.
commentsThe metadata to place in the comment header, when it is encoded.
opAn ogg_packet structure to fill. All of the elements of this structure will be set, including a pointer to the header data. The memory for the header data is owned by libdaala.
Returns
A positive value indicates that a header packet was successfully produced.
Return values
0No packet was produced, and no more header packets remain.
OD_EFAULTenc, comments or op was NULL.
int daala_encode_img_in ( daala_enc_ctx enc,
od_img img,
int  duration 
)

Submits an uncompressed frame to the encoder.

Parameters
encA daala_enc_ctx handle.
imgA buffer of image data to encode.
durationThe duration to display the frame for, in timebase units. If a non-zero frame duration was specified in the header, then this parameter is ignored.
Return values
0Success.
OD_EFAULTenc or img was NULL.
OD_EINVALThe image size does not match the frame size the encoder was initialized with, or encoding has already completed.
int daala_encode_packet_out ( daala_enc_ctx enc,
int  last,
ogg_packet *  op 
)

Retrieves encoded video data packets.

This should be called repeatedly after each frame is submitted to flush any encoded packets, until it returns 0. The encoder will not buffer these packets as subsequent frames are compressed, so a failure to do so will result in lost video data.

Note
Current the encoder operates in a one-frame-in, one-packet-out manner. However, this may be changed in the future.
Parameters
encA daala_enc_ctx handle.
lastSet this flag to a non-zero value if no more uncompressed frames will be submitted. This ensures that a proper EOS flag is set on the last packet.
opAn ogg_packet structure to fill. All of the elements of this structure will be set, including a pointer to the video data. The memory for the video data is owned by libdaala.
Returns
A positive value indicates that a video data packet was successfully produced.
Return values
0No packet was produced, and no more encoded video data remains.
OD_EFAULTenc or op was NULL.
void daala_encode_free ( daala_enc_ctx enc)

Frees an allocated encoder instance.

Parameters
encA daala_enc_ctx handle.