daala/daalaenc.h(3)
π daala/daalaenc.h β Library Functions Manual π
okay bestie, gather round, because this is the manual page for daala/daalaenc.h, filed under section 3 of the library functions manuals. it's the libdaala C encoding API and it is long, so this is part 1 of 2. hydrate, stretch, we're doing this. π«Ά
β¨ NAME β¨
daala/daalaenc.h β the libdaala C encoding API. that's the whole name section, no notes, iconic behavior. π
π¦ SYNOPSIS π¦
#include 'codec.h'
πΈ Macros
#define _daala_daalaenc_H (1)
π OD_SET_RATE_FLAGS flags
these are the flags you can use with OD_SET_RATE_FLAGS. little menu of behaviors, pick your faves:
#define OD_RATECTL_DROP_FRAMES (0x1)β Drop frames to keep within bitrate buffer constraints.#define OD_RATECTL_CAP_OVERFLOW (0x2)β Ignore bitrate buffer overflows.#define OD_RATECTL_CAP_UNDERFLOW (0x4)β Ignore bitrate buffer underflows.
π¦ Typedefs
Encoder state
so here's the tea: this data structure is opaque, meaning its contents are not publicly defined by this API.
Referring to its internals directly is unsupported, and may break without warning. π like, do not poke the bear, bestie.
typedef struct daala_enc_ctx daala_enc_ctx
- The encoder context. that's the name, that's the game.
π Functions for encoding
if you're using any of the functions in this section you must link to libdaalabase and libdaalaenc. no skipping, it's giving mandatory. π
these functions are listed in the order you'd actually use them in a typical encode. the basic steps are:
- Fill in a
daala_infostructure with details on the format of the video you wish to encode. - Allocate a
daala_enc_ctxhandle withdaala_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:
- Submit the compressed frame via
daala_encode_img_in(). - Repeatedly call
daala_encode_packet_out()to retrieve any video data packets that are ready.
- Submit the compressed frame via
- Call
daala_comment_clear()to release all comments allocated. - Call
daala_encode_free()to release all encoder memory.
now the macros themselves, all cute and numbered:
#define OD_SET_QUANT 4000β Set the quantizer scale.#define OD_SET_COMPLEXITY 4002β Configure the encoder's computational complexity level.#define OD_GET_COMPLEXITY 4004β Get the encoder's computational complexity level.#define OD_SET_ACTIVITY_MASKING 4006β Whether activity masking should be used or not.#define OD_SET_QM 4008β Which quantization matrix to use.#define OD_SET_DERING 4010β Whether the bilinear postprocessing filter should be used or not.#define OD_SET_MC_CHROMA 4100β Whether the motion compensation search should use the chroma planes in addition to the luma plane.#define OD_SET_MV_RES_MIN 4102β Minimum motion vectors resolution for the motion compensation search.#define OD_SET_MV_LEVEL_MIN 4104β Minimum motion vectors level for the motion compensation search.#define OD_SET_MV_LEVEL_MAX 4106β Maximum motion vectors level for the motion compensation search.#define OD_SET_MC_SATD 4108β Whether the SATD metric should be used in motion compensation or not.#define OD_SET_B_FRAMES 4110β Number of B frames used by encoder.#define OD_SET_BITRATE 4112β Sets the current encoding bitrate.#define OD_SET_RATE_FLAGS 4114β Modifies the default bitrate management behavior.#define OD_SET_RATE_BUFFER 4116β Sets the size of the bitrate management bit reservoir as a function of number of frames.#define OD_2PASS_OUT 4118β Enable pass 1 of two-pass encoding mode and retrieve the first pass metrics.#define OD_2PASS_IN 4120β Submits two-pass encoding metric data collected the first encoding pass to the second pass.
and the functions, with their signatures, exact as ever:
daala_enc_ctx * daala_encode_create (const daala_info *info)
Allocates and initializes an encoder instance.
int daala_encode_ctl (daala_enc_ctx *enc, int req, void *buf, size_t
buf_sz)
Encoder control function.
int daala_encode_flush_header (daala_enc_ctx *enc, daala_comment
*comments, daala_packet *dp)
Outputs the next header packet.
int daala_encode_img_in (daala_enc_ctx *enc, daala_image *img, int
duration)
Submits an uncompressed frame to the encoder.
int daala_encode_packet_out (daala_enc_ctx *enc, int last, daala_packet
*dp)
Retrieves encoded video data packets.
void daala_encode_free (daala_enc_ctx *enc)
Frees an allocated encoder instance.
π Detailed Description π
the libdaala C encoding API. short, sweet, to the point. main character energy but make it minimal. β¨
π Macro Definition Documentation π
#define OD_SET_QUANT 4000
Set the quantizer scale. the passed buffer gets interpreted as containing a single int. valid range is 0-511. that's the window, stay in it. π
#define OD_SET_COMPLEXITY 4002
Configure the encoder's computational complexity level.
See also
OD_GET_COMPLEXITY
Parameters
_bufint: The new encoder complexity level. Values must lie in the range 0...10, inclusive, with higher values requiring more CPU but generally producing better quality at a given bitrate.
#define OD_GET_COMPLEXITY 4004
Get the encoder's computational complexity level.
See also
OD_SET_COMPLEXITY
Parameters
_bufint: Returns a value in the range 0...10, inclusive. Higher values indicate higher CPU requirements, but generally producing better quality at a given bitrate.
#define OD_SET_ACTIVITY_MASKING 4006
Whether activity masking should be used or not.
Parameters
_bufint: 0 to disable the use of activity masking, a non-zero value otherwise (the default).
#define OD_SET_QM 4008
Which quantization matrix to use.
Parameters
_bufint: 0 => flat quantization matrix, 1 => HVS (the default).
#define OD_SET_DERING 4010
Whether the bilinear postprocessing filter should be used or not.
Parameters
_bufint: 0 to disable the bilinear postprocessing filter, a non-zero value otherwise (the default).
#define OD_SET_MC_CHROMA 4100
Whether the motion compensation search should use the chroma planes in addition to the luma plane.
Parameters
_bufint: 0 to disable the use of the chroma planes, a non-zero value otherwise (the default).
#define OD_SET_MV_RES_MIN 4102
Minimum motion vectors resolution for the motion compensation search.
Parameters
_bufint: 0 => 1/8 pel (default), 1 => 1/4 pel, 2 => 1/2 pel
#define OD_SET_MV_LEVEL_MIN 4104
Minimum motion vectors level for the motion compensation search. if this level is greater than the maximum level, the maximum level will be used instead. lowkey the min gets overruled by the max, that's just how it is.
Parameters
_bufint: level between 0 and 4 Default: 0
#define OD_SET_MV_LEVEL_MAX 4106
Maximum motion vectors level for the motion compensation search.
Parameters
_bufint: level between 0 and 4 Default: 4
#define OD_SET_MC_SATD 4108
Whether the SATD metric should be used in motion compensation or not.
Parameters
_bufint: 0 to disable the use of SATD (the default), a non-zero value otherwise.
#define OD_SET_B_FRAMES 4110
Number of B frames used by encoder.
Parameters
_bufint: The number of B frames. Values must lie in the range 0...OD_MAX_B_FRAMES, inclusive.
#define OD_SET_BITRATE 4112
Sets the current encoding bitrate. once a bitrate is set, the encoder must use a rate-controlled mode for all future frames (this restriction may be relaxed in a future version). due to the buffer delay, the exact bitrate of each section of the encode is not guaranteed. the encoder may have already used more bits than allowed for the frames it has encoded, expecting to make them up in future frames, or it may have used fewer, holding the excess in reserve. the exact transition between two bitrates is not well-defined by this API, but may be affected by flags set with OD_SET_RATE_FLAGS. after a number of frames equal to the buffer delay, one may expect further output to average at the target bitrate. fr fr, the vibes even out eventually. π¦
Parameters
buflong: The new target bitrate, in bits per second.
Return values
OD_SUCCESSSuccess.OD_EFAULTencorbufis NULL.OD_EINVALThe target bitrate was not positive. A future version of this library may allow passing 0 to disabled rate-controlled mode and return to a quality-based mode, in which case this function will not return an error for that value.OD_EIMPLNot supported by this implementation.
#define OD_SET_RATE_FLAGS 4114
Modifies the default bitrate management behavior. use it to allow or disallow frame dropping, and to enable or disable capping bit reservoir overflows and underflows. see the list of available flags. the flags are set by default to OD_RATECTL_DROP_FRAMES|OD_RATECTL_CAP_OVERFLOW. that's the out-of-the-box vibe. π
Parameters
bufint: Any combination of the available flags:OD_RATECTL_DROP_FRAMES: Enable frame dropping.OD_RATECTL_CAP_OVERFLOW: Don't bank excess bits for later use.OD_RATECTL_CAP_UNDERFLOW: Don't try to make up shortfalls later.
Return values
OD_SUCCESSSuccess.OD_EFAULTencorbufis NULL.OD_EINVALbuf_szis notsizeof(int)or rate control is not enabled.OD_EIMPLNot supported by this implementation in the current encoding mode.
#define OD_SET_RATE_BUFFER 4116
Sets the size of the bitrate management bit reservoir as a function of number of frames. the reservoir size affects how quickly bitrate management reacts to instantaneous changes in the video complexity. larger reservoirs react more slowly, and provide better overall quality, but require more buffering by a client, adding more latency to live streams. by default, libdaala sets the reservoir to the maximum distance between keyframes, subject to a minimum and maximum limit. this call may be used to increase or decrease the reservoir, increasing or decreasing the allowed temporary variance in bitrate. an implementation may impose some limits on the size of a reservoir it can handle, in which case the actual reservoir size may not be exactly what was requested. the actual value set will be returned. so like, you ask, it answers with what actually happened. π
Parameters
bufint: Requested size of the reservoir measured in frames.bufint: The actual size of the reservoir set.
Return values
OD_EFAULTencorbufis NULL.OD_EINVALbuf_szis notsizeof(int), or rate control is not enabled. The buffer has an implementation defined minimum and maximum size and the value inbufwill be adjusted to match the actual value set.OD_EIMPLNot supported by this implementation in the current encoding mode.
and that's where part 1 wraps... except no it doesn't, because there's more coming. stay tuned bestie, we're not done yet. πΈ
#define OD_2PASS_OUT 4118
Enable pass 1 of two-pass encoding mode and retrieve the first pass metrics. Pass 1 mode must be enabled before the first frame is encoded, and a target bitrate must have already been specified to the encoder. Although this does not have to be the exact rate that will be used in the second pass, closer values may produce better results. The first call returns the size of the two-pass header data, along with some placeholder content, and sets the encoder into pass 1 mode implicitly. This call sets the encoder to pass 1 mode implicitly. Then, a subsequent call must be made after each call to daala_encode_img_in() to retrieve the metrics for that frame. An additional, final call must be made to retrieve the summary data, containing such information as the total number of frames, etc. This must be stored in place of the placeholder data that was returned in the first call, before the frame metrics data. All of this data must be presented back to the encoder during pass 2 using OD_2PASS_IN.
Parameters
char *buf:Returns a pointer to internal storage containing the two pass metrics data. This storage is only valid until the next call, or until the encoder context is freed, and must be copied by the application.
Return values
>=0The number of bytes of metric data available in the returned buffer.OD_EFAULTenc or buf is NULL.OD_EINVALbuf_sz is notsizeof(char *), no target bitrate has been set, or the first call was made after the first frame was submitted for encoding.OD_EIMPLNot supported by this implementation.
#define OD_2PASS_IN 4120
Submits two-pass encoding metric data collected the first encoding pass to the second pass. The first call must be made before the first frame is encoded, and a target bitrate must have already been specified to the encoder. It sets the encoder to pass 2 mode implicitly; this cannot be disabled. The encoder may require reading data from some or all of the frames in advance, depending on, e.g., the reservoir size used in the second pass. You must call this function repeatedly before each frame to provide data until either a) it fails to consume all of the data presented or b) all of the pass 1 data has been consumed. In the first case, you must save the remaining data to be presented after the next frame. You can call this function with a NULL argument to get an upper bound on the number of bytes that will be required before the next frame.
When pass 2 is first enabled, the default bit reservoir is set to the entire file; this gives maximum flexibility but can lead to very high peak rates. You can subsequently set it to another value with OD_SET_RATE_BUFFER (e.g., to set it to the keyframe interval for non-live streaming), however, you may then need to provide more data before the next frame.
Parameters
buf char[]:A buffer containing the data returned byOD_2PASS_OUTin pass 1. You may pass NULL for buf to return an upper bound on the number of additional bytes needed before the next frame. The summary data returned at the end of pass 1 must be at the head of the buffer on the first call with a non-NULL buf, and the placeholder data returned at the start of pass 1 should be omitted. After each call you should advance this buffer by the number of bytes consumed.
Return values
>0The number of bytes of metric data required/consumed.0No more data is required before the next frame.OD_EFAULTenc is NULL.OD_EINVALNo target bitrate has been set, or the first call was made after the first frame was submitted for encoding.OD_ENOTFORMATThe data did not appear to be pass 1 from a compatible implementation of this library.OD_EBADHEADERThe data was invalid; this may be returned when attempting to read an aborted pass 1 file that still has the placeholder data in place of the summary data.OD_EIMPLNot supported by this implementation.
#define OD_RATECTL_DROP_FRAMES (0x1)
Drop frames to keep within bitrate buffer constraints. This can have a severe impact on quality, but is the only way to ensure that bitrate targets are met at low rates during sudden bursts of activity. It is enabled by default.
#define OD_RATECTL_CAP_OVERFLOW (0x2)
Ignore bitrate buffer overflows. If the encoder uses so few bits that the reservoir of available bits overflows, ignore the excess. The encoder will not try to use these extra bits in future frames. At high rates this may cause the result to be undersized, but allows a client to play the stream using a finite buffer; it should normally be enabled, which is the default.
#define OD_RATECTL_CAP_UNDERFLOW (0x4)
Ignore bitrate buffer underflows. If the encoder uses so many bits that the reservoir of available bits underflows, ignore the deficit. The encoder will not try to make up these extra bits in future frames. At low rates this may cause the result to be oversized; it should normally be disabled, which is the default.
β¨ Function Documentation β¨
daala_enc_ctx * daala_encode_create (const daala_info * info)
Allocates and initializes an encoder instance.
Parameters
infoAdaala_infostruct 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
encAdaala_enc_ctxhandle.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, daala_packet * dp)
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
encAdaala_enc_ctxhandle.commentsThe metadata to place in the comment header, when it is encoded. Users should free the returned data withdaala_comment_clear().dpAdaala_packetstructure 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, daala_image * img, int duration)
Submits an uncompressed frame to the encoder.
Parameters
encAdaala_enc_ctxhandle.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, daala_packet * dp)
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
encAdaala_enc_ctxhandle. This ensures that a proper EOS flag is set on the last packet.dpAdaala_packetstructure 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
encAdaala_enc_ctxhandle.
β¨ Author β¨
Generated automatically by Doxygen for daala from the source code.
daala β Version unknown β daala/daalaenc.h(3) π that's the whole vibe, bestie, now go encode something iconic π β¨
π¦ where this page comes from
- epel 10: daala-devel 0^20250205git24f889a-1.el10_3 Β· BSD-2-Clause AND BSD-3-Clause AND Apache-2.0 AND GPL-1.0-or-later
- fedora 43: daala-devel 0-36.20200724git694d4ce.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: daala-devel 0-36.20200724git694d4ce.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: daala-devel 0^20250205git24f889a-1.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND Apache-2.0 AND GPL-1.0-or-later
- fedora 43: daala-devel 0^20250205git24f889a-1.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND Apache-2.0 AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms