FFmpeg
Macros | Functions | Variables
av1dec.c File Reference
#include "config_components.h"
#include "libavutil/hdr_dynamic_metadata.h"
#include "libavutil/film_grain_params.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "av1_parse.h"
#include "av1dec.h"
#include "atsc_a53.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "decode.h"
#include "hwaccel_internal.h"
#include "internal.h"
#include "hwconfig.h"
#include "profiles.h"
#include "refstruct.h"
#include "thread.h"

Go to the source code of this file.

Macros

#define HWACCEL_MAX
 
#define OFFSET(x)   offsetof(AV1DecContext, x)
 
#define VD   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 

Functions

static uint32_t inverse_recenter (int r, uint32_t v)
 
static uint32_t decode_unsigned_subexp_with_ref (uint32_t sub_exp, int mx, int r)
 
static int32_t decode_signed_subexp_with_ref (uint32_t sub_exp, int low, int high, int r)
 
static void read_global_param (AV1DecContext *s, int type, int ref, int idx)
 
static uint64_t round_two (uint64_t x, uint16_t n)
 
static int64_t round_two_signed (int64_t x, uint16_t n)
 
static int16_t resolve_divisor (uint32_t d, uint16_t *shift)
 Resolve divisor process. More...
 
static uint8_t get_shear_params_valid (AV1DecContext *s, int idx)
 check if global motion params is valid. More...
 
static void global_motion_params (AV1DecContext *s)
 update gm type/params, since cbs already implemented part of this function, so we don't need to full implement spec. More...
 
static int get_relative_dist (const AV1RawSequenceHeader *seq, unsigned int a, unsigned int b)
 
static void skip_mode_params (AV1DecContext *s)
 
static void coded_lossless_param (AV1DecContext *s)
 
static void load_grain_params (AV1DecContext *s)
 
static int init_tile_data (AV1DecContext *s)
 
static int get_tiles_info (AVCodecContext *avctx, const AV1RawTileGroup *tile_group)
 
static enum AVPixelFormat get_sw_pixel_format (void *logctx, const AV1RawSequenceHeader *seq)
 
static int get_pixel_format (AVCodecContext *avctx)
 
static void av1_frame_unref (AV1Frame *f)
 
static int av1_frame_ref (AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)
 
static av_cold int av1_decode_free (AVCodecContext *avctx)
 
static int set_context_with_sequence (AVCodecContext *avctx, const AV1RawSequenceHeader *seq)
 
static int update_context_with_frame_header (AVCodecContext *avctx, const AV1RawFrameHeader *header)
 
static av_cold int av1_decode_init (AVCodecContext *avctx)
 
static int av1_frame_alloc (AVCodecContext *avctx, AV1Frame *f)
 
static int export_itut_t35 (AVCodecContext *avctx, AVFrame *frame, const AV1RawMetadataITUTT35 *itut_t35)
 
static int export_metadata (AVCodecContext *avctx, AVFrame *frame)
 
static int export_film_grain (AVCodecContext *avctx, AVFrame *frame)
 
static int set_output_frame (AVCodecContext *avctx, AVFrame *frame)
 
static int update_reference_list (AVCodecContext *avctx)
 
static int get_current_frame (AVCodecContext *avctx)
 
static int av1_receive_frame_internal (AVCodecContext *avctx, AVFrame *frame)
 
static int av1_receive_frame (AVCodecContext *avctx, AVFrame *frame)
 
static void av1_decode_flush (AVCodecContext *avctx)
 

Variables

static const uint16_t div_lut [AV1_DIV_LUT_NUM]
 < same with Div_Lut defined in spec 7.11.3.7 More...
 
static const CodedBitstreamUnitType decompose_unit_types []
 
static const AVOption av1_options []
 
static const AVClass av1_class
 
const FFCodec ff_av1_decoder
 

Macro Definition Documentation

◆ HWACCEL_MAX

#define HWACCEL_MAX
Value:
(CONFIG_AV1_DXVA2_HWACCEL + \
CONFIG_AV1_D3D11VA_HWACCEL * 2 + \
CONFIG_AV1_NVDEC_HWACCEL + \
CONFIG_AV1_VAAPI_HWACCEL + \
CONFIG_AV1_VDPAU_HWACCEL + \
CONFIG_AV1_VULKAN_HWACCEL)

◆ OFFSET

#define OFFSET (   x)    offsetof(AV1DecContext, x)

Definition at line 1471 of file av1dec.c.

◆ VD

Definition at line 1472 of file av1dec.c.

Function Documentation

◆ inverse_recenter()

static uint32_t inverse_recenter ( int  r,
uint32_t  v 
)
static

Definition at line 70 of file av1dec.c.

Referenced by decode_unsigned_subexp_with_ref().

◆ decode_unsigned_subexp_with_ref()

static uint32_t decode_unsigned_subexp_with_ref ( uint32_t  sub_exp,
int  mx,
int  r 
)
static

Definition at line 80 of file av1dec.c.

Referenced by decode_signed_subexp_with_ref().

◆ decode_signed_subexp_with_ref()

static int32_t decode_signed_subexp_with_ref ( uint32_t  sub_exp,
int  low,
int  high,
int  r 
)
static

Definition at line 90 of file av1dec.c.

Referenced by read_global_param().

◆ read_global_param()

static void read_global_param ( AV1DecContext s,
int  type,
int  ref,
int  idx 
)
static

Definition at line 97 of file av1dec.c.

Referenced by global_motion_params().

◆ round_two()

static uint64_t round_two ( uint64_t  x,
uint16_t  n 
)
static

Definition at line 139 of file av1dec.c.

Referenced by resolve_divisor(), and round_two_signed().

◆ round_two_signed()

static int64_t round_two_signed ( int64_t  x,
uint16_t  n 
)
static

Definition at line 146 of file av1dec.c.

Referenced by get_shear_params_valid().

◆ resolve_divisor()

static int16_t resolve_divisor ( uint32_t  d,
uint16_t *  shift 
)
static

Resolve divisor process.

see spec 7.11.3.7

Definition at line 155 of file av1dec.c.

Referenced by get_shear_params_valid().

◆ get_shear_params_valid()

static uint8_t get_shear_params_valid ( AV1DecContext s,
int  idx 
)
static

check if global motion params is valid.

see spec 7.11.3.6

Definition at line 175 of file av1dec.c.

Referenced by global_motion_params().

◆ global_motion_params()

static void global_motion_params ( AV1DecContext s)
static

update gm type/params, since cbs already implemented part of this function, so we don't need to full implement spec.

Definition at line 207 of file av1dec.c.

Referenced by get_current_frame().

◆ get_relative_dist()

static int get_relative_dist ( const AV1RawSequenceHeader seq,
unsigned int  a,
unsigned int  b 
)
static

Definition at line 256 of file av1dec.c.

Referenced by skip_mode_params().

◆ skip_mode_params()

static void skip_mode_params ( AV1DecContext s)
static

Definition at line 264 of file av1dec.c.

Referenced by get_current_frame().

◆ coded_lossless_param()

static void coded_lossless_param ( AV1DecContext s)
static

Definition at line 330 of file av1dec.c.

Referenced by get_current_frame().

◆ load_grain_params()

static void load_grain_params ( AV1DecContext s)
static

Definition at line 360 of file av1dec.c.

Referenced by get_current_frame().

◆ init_tile_data()

static int init_tile_data ( AV1DecContext s)
static

Definition at line 380 of file av1dec.c.

Referenced by get_current_frame().

◆ get_tiles_info()

static int get_tiles_info ( AVCodecContext avctx,
const AV1RawTileGroup tile_group 
)
static

Definition at line 398 of file av1dec.c.

Referenced by av1_receive_frame_internal().

◆ get_sw_pixel_format()

static enum AVPixelFormat get_sw_pixel_format ( void *  logctx,
const AV1RawSequenceHeader seq 
)
static

Definition at line 443 of file av1dec.c.

Referenced by av1_decode_init(), and get_pixel_format().

◆ get_pixel_format()

static int get_pixel_format ( AVCodecContext avctx)
static

check if the HW accel is inited correctly. If not, return un-implemented. Since now the av1 decoder doesn't support native decode, if it will be implemented in the future, need remove this check.

Definition at line 506 of file av1dec.c.

Referenced by av1_receive_frame_internal().

◆ av1_frame_unref()

static void av1_frame_unref ( AV1Frame f)
static

◆ av1_frame_ref()

static int av1_frame_ref ( AVCodecContext avctx,
AV1Frame dst,
const AV1Frame src 
)
static

Definition at line 652 of file av1dec.c.

Referenced by av1_receive_frame_internal(), and update_reference_list().

◆ av1_decode_free()

static av_cold int av1_decode_free ( AVCodecContext avctx)
static

Definition at line 696 of file av1dec.c.

◆ set_context_with_sequence()

static int set_context_with_sequence ( AVCodecContext avctx,
const AV1RawSequenceHeader seq 
)
static

Definition at line 727 of file av1dec.c.

Referenced by av1_decode_init(), and av1_receive_frame_internal().

◆ update_context_with_frame_header()

static int update_context_with_frame_header ( AVCodecContext avctx,
const AV1RawFrameHeader header 
)
static

Definition at line 770 of file av1dec.c.

Referenced by av1_frame_alloc().

◆ av1_decode_init()

static av_cold int av1_decode_init ( AVCodecContext avctx)
static

Definition at line 810 of file av1dec.c.

◆ av1_frame_alloc()

static int av1_frame_alloc ( AVCodecContext avctx,
AV1Frame f 
)
static

Definition at line 874 of file av1dec.c.

Referenced by get_current_frame().

◆ export_itut_t35()

static int export_itut_t35 ( AVCodecContext avctx,
AVFrame frame,
const AV1RawMetadataITUTT35 itut_t35 
)
static

Definition at line 920 of file av1dec.c.

Referenced by export_metadata().

◆ export_metadata()

static int export_metadata ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 979 of file av1dec.c.

Referenced by set_output_frame().

◆ export_film_grain()

static int export_film_grain ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 1022 of file av1dec.c.

Referenced by set_output_frame().

◆ set_output_frame()

static int set_output_frame ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 1082 of file av1dec.c.

Referenced by av1_receive_frame_internal().

◆ update_reference_list()

static int update_reference_list ( AVCodecContext avctx)
static

Definition at line 1126 of file av1dec.c.

Referenced by av1_receive_frame_internal().

◆ get_current_frame()

static int get_current_frame ( AVCodecContext avctx)
static

Definition at line 1145 of file av1dec.c.

Referenced by av1_receive_frame_internal().

◆ av1_receive_frame_internal()

static int av1_receive_frame_internal ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 1185 of file av1dec.c.

Referenced by av1_receive_frame().

◆ av1_receive_frame()

static int av1_receive_frame ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 1416 of file av1dec.c.

◆ av1_decode_flush()

static void av1_decode_flush ( AVCodecContext avctx)
static

Definition at line 1446 of file av1dec.c.

Variable Documentation

◆ div_lut

const uint16_t div_lut[AV1_DIV_LUT_NUM]
static
Initial value:
= {
16384, 16320, 16257, 16194, 16132, 16070, 16009, 15948, 15888, 15828, 15768,
15709, 15650, 15592, 15534, 15477, 15420, 15364, 15308, 15252, 15197, 15142,
15087, 15033, 14980, 14926, 14873, 14821, 14769, 14717, 14665, 14614, 14564,
14513, 14463, 14413, 14364, 14315, 14266, 14218, 14170, 14122, 14075, 14028,
13981, 13935, 13888, 13843, 13797, 13752, 13707, 13662, 13618, 13574, 13530,
13487, 13443, 13400, 13358, 13315, 13273, 13231, 13190, 13148, 13107, 13066,
13026, 12985, 12945, 12906, 12866, 12827, 12788, 12749, 12710, 12672, 12633,
12596, 12558, 12520, 12483, 12446, 12409, 12373, 12336, 12300, 12264, 12228,
12193, 12157, 12122, 12087, 12053, 12018, 11984, 11950, 11916, 11882, 11848,
11815, 11782, 11749, 11716, 11683, 11651, 11619, 11586, 11555, 11523, 11491,
11460, 11429, 11398, 11367, 11336, 11305, 11275, 11245, 11215, 11185, 11155,
11125, 11096, 11067, 11038, 11009, 10980, 10951, 10923, 10894, 10866, 10838,
10810, 10782, 10755, 10727, 10700, 10673, 10645, 10618, 10592, 10565, 10538,
10512, 10486, 10460, 10434, 10408, 10382, 10356, 10331, 10305, 10280, 10255,
10230, 10205, 10180, 10156, 10131, 10107, 10082, 10058, 10034, 10010, 9986,
9963, 9939, 9916, 9892, 9869, 9846, 9823, 9800, 9777, 9754, 9732,
9709, 9687, 9664, 9642, 9620, 9598, 9576, 9554, 9533, 9511, 9489,
9468, 9447, 9425, 9404, 9383, 9362, 9341, 9321, 9300, 9279, 9259,
9239, 9218, 9198, 9178, 9158, 9138, 9118, 9098, 9079, 9059, 9039,
9020, 9001, 8981, 8962, 8943, 8924, 8905, 8886, 8867, 8849, 8830,
8812, 8793, 8775, 8756, 8738, 8720, 8702, 8684, 8666, 8648, 8630,
8613, 8595, 8577, 8560, 8542, 8525, 8508, 8490, 8473, 8456, 8439,
8422, 8405, 8389, 8372, 8355, 8339, 8322, 8306, 8289, 8273, 8257,
8240, 8224, 8208, 8192
}

< same with Div_Lut defined in spec 7.11.3.7

Definition at line 43 of file av1dec.c.

Referenced by resolve_divisor().

◆ decompose_unit_types

const CodedBitstreamUnitType decompose_unit_types[]
static

◆ av1_options

const AVOption av1_options[]
static
Initial value:
= {
{ "operating_point", "Select an operating point of the scalable bitstream",
OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, AV1_MAX_OPERATING_POINTS - 1, VD },
{ NULL }
}

Definition at line 1473 of file av1dec.c.

◆ av1_class

const AVClass av1_class
static
Initial value:
= {
.class_name = "AV1 decoder",
.item_name = av_default_item_name,
.option = av1_options,
}

Definition at line 1479 of file av1dec.c.

◆ ff_av1_decoder

const FFCodec ff_av1_decoder

Definition at line 1486 of file av1dec.c.

AV1_OBU_REDUNDANT_FRAME_HEADER
@ AV1_OBU_REDUNDANT_FRAME_HEADER
Definition: av1.h:36
AV1_OBU_TEMPORAL_DELIMITER
@ AV1_OBU_TEMPORAL_DELIMITER
Definition: av1.h:31
av1_options
static const AVOption av1_options[]
Definition: av1dec.c:1473
AV1_OBU_FRAME_HEADER
@ AV1_OBU_FRAME_HEADER
Definition: av1.h:32
AV1_MAX_OPERATING_POINTS
@ AV1_MAX_OPERATING_POINTS
Definition: av1.h:73
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV1_OBU_TILE_GROUP
@ AV1_OBU_TILE_GROUP
Definition: av1.h:33
AV1_OBU_FRAME
@ AV1_OBU_FRAME
Definition: av1.h:35
AV1_OBU_SEQUENCE_HEADER
@ AV1_OBU_SEQUENCE_HEADER
Definition: av1.h:30
VD
#define VD
Definition: av1dec.c:1472
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
OFFSET
#define OFFSET(x)
Definition: av1dec.c:1471
AV1_OBU_METADATA
@ AV1_OBU_METADATA
Definition: av1.h:34