What error codes does libaom decoder return?
When integrating the Alliance for Open Media (AOM) libaom decoder
into a video application, developers must properly handle
library-specific error codes to ensure playback stability and graceful
degradation. This article details the primary error codes returned by
the libaom decoding API, specifically focusing on the
aom_codec_err_t enum type. We will examine critical error
types, including memory allocation failures, corrupt bitstream errors,
and initialization misconfigurations, providing context on when they
occur and how developers should respond to them.
The
aom_codec_err_t Enumeration
The libaom API communicates the success or failure of its operations
using the aom_codec_err_t status code type. Functions like
aom_codec_decode and aom_codec_control return
these values to indicate whether the frame was processed successfully or
if an anomaly occurred.
Critical Decoding Errors to Watch For
While a successful operation returns AOM_CODEC_OK (0),
developers must implement robust error handling for the following
negative or non-zero statuses:
AOM_CODEC_CORRUPT_FRAMEWhat it means: The decoder encountered invalid, malformed, or missing data while parsing the compressed AV1 bitstream.
When it happens: This is common during network streaming packet loss, file corruption, or when dealing with an uncompliant encoder.
Developer Action: Depending on application requirements, you can choose to drop the frame, request a keyframe from the source, or conceal the error. If the
AOM_CODEC_CAP_ERROR_CONCEALMENTcapability is enabled, the decoder may still produce a viewable, albeit degraded, frame.AOM_CODEC_MEM_ERRORWhat it means: The library failed to allocate necessary memory dynamically.
When it happens: This typically occurs during decoder initialization or when a sudden resolution change in the video stream forces the allocator to request a larger frame buffer than the system can provide.
Developer Action: Safely tear down the decoder instance using
aom_codec_destroy, release associated resources, and alert the application layer of an out-of-memory state.AOM_CODEC_INVALID_PARAMWhat it means: An invalid parameter or argument was passed to an API function.
When it happens: This is frequently encountered when using the
aom_codec_control()interface with an unsupported control ID, or when passing out-of-bounds configuration values toaom_codec_dec_cfg_t.Developer Action: Audit the initialization parameters and control IDs. Ensure that the control macros being used are explicitly designed for the decoder interface rather than the encoder interface.
AOM_CODEC_UNSUP_BITSTREAMWhat it means: The bitstream uses features, profiles, or bit-depths that the current build or version of libaom does not support.
When it happens: This occurs if a high-profile AV1 video (such as 12-bit HDR) is fed into a libaom binary that was compiled with restricted profile support or older legacy versions.
Developer Action: Reject the stream early and inform the user or media pipeline that the specific video profile is unsupported.
AOM_CODEC_ERRORWhat it means: A generic, unspecified error occurred during execution.
When it happens: This functions as a fallback error code when an operation fails due to internal library states that do not fall neatly into predefined categories.
Developer Action: Use
aom_codec_error()oraom_codec_error_detail()immediately after the failure to extract a human-readable string containing specific debugging information.
Best Practices for Handling libaom Errors
To prevent application crashes and memory leaks, always evaluate the
return value of aom_codec_decode(). If the returned value
is not AOM_CODEC_OK, logging the output of
aom_codec_error_detail() is vital for diagnostics, as it
provides a precise textual description of exactly where the AV1
bitstream parsing or internal state machine failed.