AOMedia AV1 Codec: Loop Restoration

| AOMedia AV1 Codec

Loop Restoration
Encoder Algorithm

## Functions
void | av1_loop_restoration_filter_unit (const RestorationTileLimits *limits, const RestorationUnitInfo *rui, const RestorationStripeBoundaries *rsb, RestorationLineBuffers *rlbs, int plane_w, int plane_h, int ss_x, int ss_y, int highbd, int bit_depth, uint8_t *data8, int stride, uint8_t *dst8, int dst_stride, int32_t *tmpbuf, int optimized_lr, struct aom_internal_error_info *error_info)
| Function for applying loop restoration filter to a single unit.
void | av1_loop_restoration_filter_frame (YV12_BUFFER_CONFIG *frame, struct AV1Common *cm, int optimized_lr, void *lr_ctxt)
| Function for applying loop restoration filter to a frame.
void | av1_pick_filter_restoration (const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi)
| Algorithm for AV1 loop restoration search and estimation.

## Detailed Description

This module describes the loop restoration search and estimation algorithm in AV1. More details will be added.

## Function Documentation

## ◆ av1_loop_restoration_filter_unit()

void av1_loop_restoration_filter_unit | ( | const RestorationTileLimits * | limits,
|  | const RestorationUnitInfo * | rui,
|  | const RestorationStripeBoundaries * | rsb,
|  | RestorationLineBuffers * | rlbs,
|  | int | plane_w,
|  | int | plane_h,
|  | int | ss_x,
|  | int | ss_y,
|  | int | highbd,
|  | int | bit_depth,
|  | uint8_t * | data8,
|  | int | stride,
|  | uint8_t * | dst8,
|  | int | dst_stride,
|  | int32_t * | tmpbuf,
|  | int | optimized_lr,
|  | struct aom_internal_error_info * | error_info )

Function for applying loop restoration filter to a single unit.

This function applies the loop restoration filter to a single loop restoration unit.

Parameters

  [in] | limits | Limits of the unit
  [in] | rui | The parameters to use for this unit and its coefficients
  [in] | rsb | Deblocked pixels to use for stripe boundaries
  [in] | rlbs | Space to use as a scratch buffer
  [in] | ss_x | Horizontal subsampling for plane
  [in] | ss_y | Vertical subsampling for plane
  [in] | plane_w | Width of the current plane
  [in] | plane_h | Height of the current plane
  [in] | highbd | Whether high bitdepth pipeline is used
  [in] | bit_depth | Bit-depth of the video
  [in] | data8 | Frame data (pointing at the top-left corner of the frame, not the restoration unit).
  [in] | stride | Stride of `data8`
  [out] | dst8 | Buffer where the results will be written. Like `data8`, `dst8` should point at the top-left corner of the frame
  [in] | dst_stride | Stride of `dst8`
  [in] | tmpbuf | Scratch buffer used by the sgrproj filter which should be at least SGRPROJ_TMPBUF_SIZE big.
  [in] | optimized_lr | Whether to use fast optimized Loop Restoration
  [in,out] | error_info | Error info for reporting errors

Remarks
  Nothing is returned. Instead, the filtered unit is output in `dst8` at the proper restoration unit offset.

References av1_loop_restoration_filter_unit().

Referenced by av1_loop_restoration_filter_unit().

## ◆ av1_loop_restoration_filter_frame()

void av1_loop_restoration_filter_frame | ( | YV12_BUFFER_CONFIG * | frame,
|  | struct AV1Common * | cm,
|  | int | optimized_lr,
|  | void * | lr_ctxt )

Function for applying loop restoration filter to a frame.

This function applies the loop restoration filter to a frame.

Parameters

  [in,out] | frame | Compressed frame buffer
  [in,out] | cm | Pointer to top level common structure
  [in] | optimized_lr | Whether to use fast optimized Loop Restoration
  [in] | lr_ctxt | Loop restoration context

Remarks
  Nothing is returned. Instead, the filtered frame is output in `frame`.

References av1_loop_restoration_filter_frame().

Referenced by av1_loop_restoration_filter_frame(), and cdef_restoration_frame().

## ◆ av1_pick_filter_restoration()

void av1_pick_filter_restoration | ( | const YV12_BUFFER_CONFIG * | sd,
|  | AV1_COMP * | cpi )

Algorithm for AV1 loop restoration search and estimation.

This function determines proper restoration filter types and associated parameters for each restoration unit in a frame.

Parameters

  [in] | sd | Source frame buffer
  [in,out] | cpi | Top-level encoder structure

Remarks
  Nothing is returned. Instead, chosen restoration filter types and parameters are stored per plane in the `rst_info` structure of type RestorationInfo inside `cpi->common:`
  - `rst_info`[ `0` ]: Chosen parameters for Y plane
  - `rst_info`[ `1` ]: Chosen parameters for U plane if it exists
  - `rst_info`[ `2` ]: Chosen parameters for V plane if it exists

  The following fields in each `rst_info`[ `p`], `p` = 0, 1, 2 are populated:
  - `rst_info`[ `p` ].`frame_restoration_type`
  - `rst_info`[ `p` ].`unit_info`[ `u` ], for each `u` in 0, 1, ..., `n`( `p` ) - 1, where `n`( `p` ) is the number of restoration units in plane `p`.

  The following fields in each `rst_info`[ `p` ].`unit_info`[ `u` ], `p` = 0, 1, 2 and `u` = 0, 1, ..., `n`( `p` ) - 1, of type RestorationUnitInfo are populated:
  - `rst_info`[ `p` ].`unit_info`[ `u` ].`restoration_type`
  - `rst_info`[ `p` ].`unit_info`[ `u` ].`wiener_info` OR `rst_info`[ `p` ].`unit_info`[ `u` ].`sgrproj_info` OR neither, depending on `rst_info`[ `p` ].`unit_info`[ `u` ].`restoration_type`

References av1_pick_filter_restoration().

Referenced by av1_pick_filter_restoration(), and cdef_restoration_frame().