AOMedia AV1 Codec
High-level Algorithm
Collaboration diagram for High-level Algorithm:

Modules

 Speed vs Quality Trade Off
 
 Source Frame Processing
 
 Rate Control
 
 Temporal Dependency Modelling
 
 Two Pass Mode
 
 The Look-Ahead Buffer
 
 Golden Frame Group
 

Functions

int av1_pack_bitstream (struct AV1_COMP *const cpi, uint8_t *dst, size_t *size, int *const largest_tile_id)
 Pack the bitstream for one frame.
 
int av1_encode_strategy (AV1_COMP *const cpi, size_t *const size, uint8_t *const dest, unsigned int *frame_flags, int64_t *const time_stamp, int64_t *const time_end, const aom_rational64_t *const timestamp_ratio, int *const pop_lookahead, int flush)
 Implement high-level encode strategy. More...
 
static void encode_frame_internal (AV1_COMP *cpi)
 Encoder setup(only for the current frame), encoding, and recontruction for a single frame.
 
void av1_encode_frame (AV1_COMP *cpi)
 Setup reference frame buffers and encode a frame. More...
 
static void cdef_restoration_frame (AV1_COMP *cpi, AV1_COMMON *cm, MACROBLOCKD *xd, int use_restoration, int use_cdef)
 Select and apply cdef filters and switchable restoration filters.
 
static void loopfilter_frame (AV1_COMP *cpi, AV1_COMMON *cm)
 Select and apply in-loop deblocking filters, cdef filters, and restoration filters.
 
static int encode_without_recode (AV1_COMP *cpi)
 Encode a frame without the recode loop, usually used in one-pass encoding and realtime coding. More...
 
static int encode_with_recode_loop (AV1_COMP *cpi, size_t *size, uint8_t *dest)
 Recode loop for encoding one frame. the purpose of encoding one frame for multiple times can be approaching a target bitrate or adjusting the usage of global motions. More...
 
static int encode_with_recode_loop_and_filter (AV1_COMP *cpi, size_t *size, uint8_t *dest, int64_t *sse, int64_t *rate, int *largest_tile_id)
 Recode loop or a single loop for encoding one frame, followed by in-loop deblocking filters, CDEF filters, and restoration filters. More...
 
static int encode_frame_to_data_rate (AV1_COMP *cpi, size_t *size, uint8_t *dest)
 Run the final pass encoding for 1-pass/2-pass encoding mode, and pack the bitstream. More...
 

Detailed Description

This module describes sequence level/frame level algorithm in AV1. More details will be added.

Function Documentation

◆ av1_encode_strategy()

int av1_encode_strategy ( AV1_COMP *const  cpi,
size_t *const  size,
uint8_t *const  dest,
unsigned int *  frame_flags,
int64_t *const  time_stamp,
int64_t *const  time_end,
const aom_rational64_t *const  timestamp_ratio,
int *const  pop_lookahead,
int  flush 
)

Implement high-level encode strategy.

This function will implement high-level encode strategy, choosing frame type, frame placement, etc. It populates an EncodeFrameParams struct with the results of these decisions and then encodes the frame. The caller should use the output parameters *time_stamp and *time_end only when this function returns AOM_CODEC_OK.

Parameters
[in]cpiTop-level encoder structure
[in]sizeBitstream size
[in]destBitstream output
[in]frame_flagsFlags to decide how to encoding the frame
[out]time_stampTime stamp of the frame
[out]time_endTime end
[in]timestamp_ratioTime base
[in]pop_lookaheadDecide to pop the source frame from queue
[in]flushDecide to encode one frame or the rest of frames
Returns
Returns a value to indicate if the encoding is done successfully.
Return values
AOM_CODEC_OK
-1
AOM_CODEC_ERROR

◆ av1_encode_frame()

◆ encode_without_recode()

static int encode_without_recode ( AV1_COMP *  cpi)
static

Encode a frame without the recode loop, usually used in one-pass encoding and realtime coding.

Parameters
[in]cpiTop-level encoder structure
Returns
Returns a value to indicate if the encoding is done successfully.
Return values
AOM_CODEC_OK
AOM_CODEC_ERROR

References AV1Common::current_frame, SVC::downsample_filter_phase, SVC::downsample_filter_type, AV1Common::height, SPEED_FEATURES::inter_sf, SPEED_FEATURES::part_sf, and AV1Common::width.

Referenced by encode_with_recode_loop_and_filter().

◆ encode_with_recode_loop()

static int encode_with_recode_loop ( AV1_COMP *  cpi,
size_t *  size,
uint8_t *  dest 
)
static

Recode loop for encoding one frame. the purpose of encoding one frame for multiple times can be approaching a target bitrate or adjusting the usage of global motions.

Parameters
[in]cpiTop-level encoder structure
[in]sizeBitstream size
[in]destBitstream output
Returns
Returns a value to indicate if the encoding is done successfully.
Return values
AOM_CODEC_OK
-1
AOM_CODEC_ERROR

References AOM_SUPERRES_NONE, AV1Common::current_frame, and AV1Common::superres_scale_denominator.

Referenced by encode_with_recode_loop_and_filter().

◆ encode_with_recode_loop_and_filter()

static int encode_with_recode_loop_and_filter ( AV1_COMP *  cpi,
size_t *  size,
uint8_t *  dest,
int64_t *  sse,
int64_t *  rate,
int *  largest_tile_id 
)
static

Recode loop or a single loop for encoding one frame, followed by in-loop deblocking filters, CDEF filters, and restoration filters.

Parameters
[in]cpiTop-level encoder structure
[in]sizeBitstream size
[in]destBitstream output
[in]sseTotal distortion of the frame
[in]rateTotal rate of the frame
[in]largest_tile_idTile id of the last tile
Returns
Returns a value to indicate if the encoding is done successfully.
Return values
AOM_CODEC_OK
AOM_CODEC_ERROR

References FeatureFlags::allow_intrabc, AOM_CODEC_OK, CdefInfo::cdef_bits, AV1Common::cdef_info, CdefInfo::cdef_strengths, CdefInfo::cdef_uv_strengths, AV1Common::cur_frame, encode_with_recode_loop(), encode_without_recode(), AV1Common::features, RestorationInfo::frame_restoration_type, AV1Common::lf, loopfilter_frame(), CdefInfo::nb_cdef_strengths, AV1Common::render_height, AV1Common::render_width, RESTORE_NONE, AV1Common::rst_info, and AV1Common::seq_params.

Here is the call graph for this function:

◆ encode_frame_to_data_rate()

static int encode_frame_to_data_rate ( AV1_COMP *  cpi,
size_t *  size,
uint8_t *  dest 
)
static

Run the final pass encoding for 1-pass/2-pass encoding mode, and pack the bitstream.

Parameters
[in]cpiTop-level encoder structure
[in]sizeBitstream size
[in]destBitstream output
Returns
Returns a value to indicate if the encoding is done successfully.
Return values
AOM_CODEC_OK
AOM_CODEC_ERROR

References FeatureFlags::allow_ref_frame_mvs, FeatureFlags::allow_warped_motion, AOM_CBR, AOM_CODEC_ERROR, AOM_CODEC_OK, AOM_RC_THIRD_PASS, av1_pack_bitstream(), AV1Common::cur_frame, FeatureFlags::cur_frame_force_integer_mv, AV1Common::current_frame, AV1Common::features, AV1Common::height, CommonTileParams::large_scale, AV1Common::lf, AV1Common::ref_frame_id, AV1Common::seg, AV1Common::seq_params, AV1Common::show_frame, CommonTileParams::single_tile_decoding, AV1Common::tiles, and AV1Common::width.

Here is the call graph for this function: