FFmpeg
Loading...
Searching...
No Matches
cavsdec.c File Reference

Chinese AVS video (AVS1-P2/P16, JiZhun and Broadcasting profiles) decoder. More...

#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/intmath.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "get_bits.h"
#include "golomb.h"
#include "cavs.h"
#include "codec_internal.h"
#include "profiles.h"
#include "decode.h"
#include "mathops.h"
#include "mpeg12data.h"
#include "put_bits.h"
#include "startcode.h"

Go to the source code of this file.

Macros

#define EOB   0, 0, 0
 
#define AEC_MB_SKIP_RUN   0
 
#define AEC_MB_TYPE   4
 
#define AEC_MB_PART_TYPE   19
 
#define AEC_INTRA_LUMA_PRED_MODE   22
 
#define AEC_INTRA_CHROMA_PRED_MODE   26
 
#define AEC_MB_REFERENCE_INDEX   30
 
#define AEC_MV_DIFF_X   36
 
#define AEC_MV_DIFF_Y   42
 
#define AEC_CBP   48
 
#define AEC_MB_QP_DELTA   54
 
#define AEC_COEFF_FRAME_LUMA   58
 
#define AEC_COEFF_FRAME_CHROMA   124
 
#define AEC_COEFF_FIELD_LUMA   190
 
#define AEC_COEFF_FIELD_CHROMA   256
 
#define CAVS_MAX_ABS_LEVEL   2048
 
#define AEC_COEFF_NUM_CTX   66
 
#define AEC_COEFF_RUN   46
 
#define AEC_COEFF_RUN_NUM_CTX   20
 
#define MV(nP, nC, mode, size, ref)
 
#define REF(dst, list, nP)
 
#define TMP_UNUSED_INX   7
 
#define SET_REF(idx, frame, par, distance)
 

Functions

static void store_mvs (AVSContext *h)
 
static int scale_direct (unsigned den, int mv, int dist)
 Scale one component of the co-located motion vector, den being 16384 / BlockDistanceRef (clause 9.9.1 b) 3)).
 
static int field_parity (AVSContext *h, int distance_index)
 The parity of a field is the parity of its distance index: a first coded field has an even one, a second field an odd one (clause 9.4.6.1).
 
static void mv_pred_direct (AVSContext *h, cavs_vector *pmv_fw, cavs_vector *col_mv)
 Direct mode: scale the co-located motion vector by its own BlockDistance, carried in the mv cache (clause 9.9.1 b)).
 
static void mv_pred_sym (AVSContext *h, cavs_vector *src, enum cavs_block size)
 Symmetric mode: derive the backward mv from the forward one, scaled by the block's own pair of distances (clause 9.9.1 c)).
 
static int get_ue_code (GetBitContext *gb, int order)
 kth-order exponential golomb code
 
static int dequant (AVSContext *h, int16_t *level_buf, uint8_t *run_buf, int16_t *dst, int mul, int shift, int coeff_num)
 
static int decode_residual_block (AVSContext *h, GetBitContext *gb, const struct dec_2dvlc *r, int esc_golomb_order, int qp, uint8_t *dst, ptrdiff_t stride)
 decode coefficients from one 8x8 block, dequantize, inverse transform and add them to sample block
 
static int aec_mb_skip_run (AVSContext *h)
 Decode mb_skip_run, table 44 unary (8.4.4.2 a)).
 
static int aec_mb_type_p (AVSContext *h)
 Decode mb_type, table 44 unary mapped by tables 54 and 55 (9.4.2 a) 2))
 
static int aec_mb_type_b (AVSContext *h)
 Decode mb_type in a B picture (table 45, 8.4.4.2 b)); see table 56.
 
static int aec_mb_part_type (AVSContext *h)
 Decode mb_part_type (tables 46 and 57, 8.4.4.2 c)).
 
static int aec_ref_index (AVSContext *h, int ctx_inc, int max)
 Decode mb_reference_index, table 44 unary (8.4.3 j), 8.4.4.2 f)).
 
static int aec_mv_diff (AVSContext *h, int base, int mvda, int *diff)
 Decode one mv_diff_x or mv_diff_y (table 49, 8.4.4.2 g)); mvda is the magnitude of the same component of the left block's mv_diff.
 
static int aec_mv (AVSContext *h, enum cavs_mv_loc nP)
 Decode a motion vector's mv_diff pair into the cache that ff_cavs_mv() reads and the next block takes its mvda from.
 
static int aec_intra_luma_pred_mode (AVSContext *h, int pred)
 Decode intra_luma_pred_mode (table 47) and derive IntraLumaPredMode from predIntraPredMode per clause 9.4.4.2 a).
 
static int aec_intra_chroma_pred_mode (AVSContext *h)
 Decode intra_chroma_pred_mode (table 48, 8.4.4.2 e)).
 
static int aec_cbp (AVSContext *h)
 Decode cbp (table 50, 8.4.4.2 h), clause 9.4.7).
 
static int aec_mb_qp_delta (AVSContext *h, int *delta)
 Decode mb_qp_delta (table 44 unary, 8.4.4.2 i)) and map the code number to the signed delta of clause 9.4.8.
 
static int decode_residual_block_aec (AVSContext *h, int chroma, int qp, uint8_t *dst, ptrdiff_t stride)
 Decode the trans_coefficient pairs of one 8x8 block (8.4.4.2 j) and k)).
 
static int is_start_code_offset (AVSContext *h, int offset)
 Tell whether the byte aligned 00 00 01 at offset is a start code: in a de-emulated payload it may be a coincidence (annex A).
 
static void aec_end_of_slice (AVSContext *h)
 Position the reader on the start code that ends an AEC slice: the first one at or after the slice's own payload.
 
static int decode_mb_qp_delta (AVSContext *h)
 Read mb_qp_delta when the macroblock has coefficients and the picture's qp is not fixed, and keep PreviousDeltaQP for the AEC contexts (clause 9.4.8).
 
static int decode_residual (AVSContext *h, const struct dec_2dvlc *r, int esc_golomb_order, int chroma, int qp, uint8_t *dst, ptrdiff_t stride)
 Decode one 8x8 block's residual with the picture's entropy coder.
 
static int decode_residual_chroma (AVSContext *h)
 
static int decode_residual_inter (AVSContext *h)
 
static void set_mv_intra (AVSContext *h)
 
static int decode_mb_i (AVSContext *h, int cbp_code)
 
static void set_intra_mode_default (AVSContext *h)
 
static int decode_ref_index (AVSContext *h, int list, enum cavs_mv_loc nP)
 Read one mb_reference_index and turn it into a reference list index (table 26, clauses 7.2.5 and 9.4.5).
 
static int decode_mv (AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC, enum cavs_mv_pred mode, enum cavs_block size, int ref)
 Decode one motion vector: under AEC its mv_diff must be read before ff_cavs_mv() overwrites the cache its context comes from.
 
static void set_inter_mb_ctx (AVSContext *h, enum cavs_mb mb_type, int skip)
 
static int decode_mb_p (AVSContext *h, enum cavs_mb mb_type)
 
static int decode_mb_b (AVSContext *h, enum cavs_mb mb_type)
 
static int decode_mb_pb_layer (AVSContext *h, int *skip_count)
 Decode one macroblock of a P or B coded macroblock layer, table 25.
 
static int decode_slice_header (AVSContext *h, GetBitContext *gb)
 
static int check_for_slice (AVSContext *h)
 
static int set_ref_list (AVSContext *h)
 Build the reference list and the temporal distances of the current frame or field (clause 9.4.5 figures 14 to 20, clause 9.4.6.1).
 
static int decode_pic (AVSContext *h)
 
static int decode_seq_header (AVSContext *h)
 
static int annex_a_applies (int stc)
 annex A applies to picture headers and slices, not to other units
 
static int deemulate_region (PutBitContext *pb, const uint8_t *buf, int size, int deemulated)
 Copy one region of a picture payload, removing the annex A pseudo start codes; the clause 5.8.2.4 stuffing is rewritten to keep the next start code aligned.
 
static int deemulate_picture (AVSContext *h, PutBitContext *pb, const uint8_t *buf, int size)
 Walk the payload region by region, removing the annex A pseudo start codes; on the writing pass, record every start code prefix offset in h->stc_offset.
 
static int remove_pseudo_start_codes (AVSContext *h, const uint8_t *buf, int size)
 Remove the annex A pseudo start codes from a payload: a byte forming 00 00 02 with the two before it loses its two least significant bits.
 
static av_cold void cavs_flush (AVCodecContext *avctx)
 
static int cavs_decode_frame (AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
 

Variables

static const uint8_t mv_scan [4]
 
static const uint8_t cbp_tab [64][2]
 
static const uint8_t scan3x3 [4] = { 4, 5, 7, 8 }
 
static const uint8_t dequant_shift [64]
 
static const uint16_t dequant_mul [64]
 
static const struct dec_2dvlc intra_dec [7]
 
static const struct dec_2dvlc inter_dec [7]
 
static const struct dec_2dvlc chroma_dec [5]
 
static const uint8_t cavs_aec_pri_idx [6] = { 0, 1, 2, 3, 3, 4 }
 Table 52, priIdx as a function of lMax, which saturates at 5.
 
const FFCodec ff_cavs_decoder
 

Detailed Description

Chinese AVS video (AVS1-P2/P16, JiZhun and Broadcasting profiles) decoder.

Author
Stefan Gehrer stefa.nosp@m.n.ge.nosp@m.hrer@.nosp@m.gmx..nosp@m.de

Clause, table and figure numbers refer to GY/T 257.1-2012.

Definition in file cavsdec.c.

Macro Definition Documentation

◆ EOB

#define EOB   0, 0, 0

Definition at line 86 of file cavsdec.c.

◆ AEC_MB_SKIP_RUN

#define AEC_MB_SKIP_RUN   0

Definition at line 673 of file cavsdec.c.

Referenced by aec_mb_skip_run().

◆ AEC_MB_TYPE

#define AEC_MB_TYPE   4

Definition at line 674 of file cavsdec.c.

Referenced by aec_mb_type_b(), and aec_mb_type_p().

◆ AEC_MB_PART_TYPE

#define AEC_MB_PART_TYPE   19

Definition at line 675 of file cavsdec.c.

Referenced by aec_mb_part_type().

◆ AEC_INTRA_LUMA_PRED_MODE

#define AEC_INTRA_LUMA_PRED_MODE   22

Definition at line 676 of file cavsdec.c.

Referenced by aec_intra_luma_pred_mode().

◆ AEC_INTRA_CHROMA_PRED_MODE

#define AEC_INTRA_CHROMA_PRED_MODE   26

Definition at line 677 of file cavsdec.c.

Referenced by aec_intra_chroma_pred_mode().

◆ AEC_MB_REFERENCE_INDEX

#define AEC_MB_REFERENCE_INDEX   30

Definition at line 678 of file cavsdec.c.

Referenced by aec_ref_index().

◆ AEC_MV_DIFF_X

#define AEC_MV_DIFF_X   36

Definition at line 679 of file cavsdec.c.

Referenced by aec_mv().

◆ AEC_MV_DIFF_Y

#define AEC_MV_DIFF_Y   42

Definition at line 680 of file cavsdec.c.

Referenced by aec_mv().

◆ AEC_CBP

#define AEC_CBP   48

Definition at line 681 of file cavsdec.c.

Referenced by aec_cbp().

◆ AEC_MB_QP_DELTA

#define AEC_MB_QP_DELTA   54

Definition at line 682 of file cavsdec.c.

Referenced by aec_mb_qp_delta().

◆ AEC_COEFF_FRAME_LUMA

#define AEC_COEFF_FRAME_LUMA   58

Definition at line 683 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ AEC_COEFF_FRAME_CHROMA

#define AEC_COEFF_FRAME_CHROMA   124

Definition at line 684 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ AEC_COEFF_FIELD_LUMA

#define AEC_COEFF_FIELD_LUMA   190

Definition at line 685 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ AEC_COEFF_FIELD_CHROMA

#define AEC_COEFF_FIELD_CHROMA   256

Definition at line 686 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ CAVS_MAX_ABS_LEVEL

#define CAVS_MAX_ABS_LEVEL   2048

Definition at line 690 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ AEC_COEFF_NUM_CTX

#define AEC_COEFF_NUM_CTX   66

Definition at line 693 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ AEC_COEFF_RUN

#define AEC_COEFF_RUN   46

Definition at line 694 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ AEC_COEFF_RUN_NUM_CTX

#define AEC_COEFF_RUN_NUM_CTX   20

Definition at line 695 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ MV

#define MV ( nP,
nC,
mode,
size,
ref )
Value:
do { \
ret = decode_mv(h, nP, nC, mode, size, ref); \
if (ret < 0) \
return ret; \
} while (0)
static int decode_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC, enum cavs_mv_pred mode, enum cavs_block size, int ref)
Decode one motion vector: under AEC its mv_diff must be read before ff_cavs_mv() overwrites the cache...
Definition cavsdec.c:1339
int ret
Definition ffplay.c:391
Definition swscale.c:85
static int ref[MAX_W *MAX_W]
int size

Definition at line 1365 of file cavsdec.c.

Referenced by clv_decode_frame(), decode_mb_b(), decode_mb_p(), decode_tile(), ff_vc1_pred_b_mv(), ff_vc1_pred_mv(), mc(), mv_pred(), mvi_predict(), mvi_reset(), mvi_update_prediction(), predict_mv(), and read_mv().

◆ REF

#define REF ( dst,
list,
nP )
Value:
do { \
if (ret < 0) \
return ret; \
dst = ret; \
} while (0)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
static int decode_ref_index(AVSContext *h, int list, enum cavs_mv_loc nP)
Read one mb_reference_index and turn it into a reference list index (table 26, clauses 7....
Definition cavsdec.c:1306
static ListView * list
Definition ffplay.c:377

Definition at line 1372 of file cavsdec.c.

Referenced by decode_mb_b(), and decode_mb_p().

◆ TMP_UNUSED_INX

#define TMP_UNUSED_INX   7

Referenced by decode_mb_b().

◆ SET_REF

#define SET_REF ( idx,
frame,
par,
distance )
Value:
do { \
h->ref[idx].f = (frame); \
h->ref[idx].parity = (par); \
h->dist[idx] = (distance) & 511; \
} while (0)
static AVFrame * frame
static float distance(float x, float y, int band)

Referenced by set_ref_list().

Function Documentation

◆ store_mvs()

static void store_mvs ( AVSContext * h)
inlinestatic

Definition at line 466 of file cavsdec.c.

Referenced by decode_mb_p().

◆ scale_direct()

static int scale_direct ( unsigned den,
int mv,
int dist )
inlinestatic

Scale one component of the co-located motion vector, den being 16384 / BlockDistanceRef (clause 9.9.1 b) 3)).

The intermediate products stay unsigned, they can overflow an int.

Definition at line 479 of file cavsdec.c.

Referenced by mv_pred_direct().

◆ field_parity()

static int field_parity ( AVSContext * h,
int distance_index )
inlinestatic

The parity of a field is the parity of its distance index: a first coded field has an even one, a second field an odd one (clause 9.4.6.1).

Definition at line 490 of file cavsdec.c.

Referenced by mv_pred_direct(), and slice_to_vbi_lines().

◆ mv_pred_direct()

static void mv_pred_direct ( AVSContext * h,
cavs_vector * pmv_fw,
cavs_vector * col_mv )
inlinestatic

Direct mode: scale the co-located motion vector by its own BlockDistance, carried in the mv cache (clause 9.9.1 b)).

Annex B fixes PictureStructure over a sequence, so the frame and field conversion of step 2 cannot arise.

Definition at line 501 of file cavsdec.c.

Referenced by decode_mb_b().

◆ mv_pred_sym()

static void mv_pred_sym ( AVSContext * h,
cavs_vector * src,
enum cavs_block size )
inlinestatic

Symmetric mode: derive the backward mv from the forward one, scaled by the block's own pair of distances (clause 9.9.1 c)).

Definition at line 548 of file cavsdec.c.

Referenced by decode_mb_b().

◆ get_ue_code()

static int get_ue_code ( GetBitContext * gb,
int order )
inlinestatic

kth-order exponential golomb code

Definition at line 574 of file cavsdec.c.

Referenced by decode_residual_block().

◆ dequant()

static int dequant ( AVSContext * h,
int16_t * level_buf,
uint8_t * run_buf,
int16_t * dst,
int mul,
int shift,
int coeff_num )
inlinestatic

◆ decode_residual_block()

static int decode_residual_block ( AVSContext * h,
GetBitContext * gb,
const struct dec_2dvlc * r,
int esc_golomb_order,
int qp,
uint8_t * dst,
ptrdiff_t stride )
static

decode coefficients from one 8x8 block, dequantize, inverse transform and add them to sample block

Parameters
rpointer to 2D VLC table
esc_golomb_orderescape codes are k-golomb with this order k
qpquantizer
dstlocation of sample block
strideline stride in frame buffer

Definition at line 617 of file cavsdec.c.

Referenced by decode_residual().

◆ aec_mb_skip_run()

static int aec_mb_skip_run ( AVSContext * h)
static

Decode mb_skip_run, table 44 unary (8.4.4.2 a)).

Returns
SkipMbCount

Definition at line 701 of file cavsdec.c.

Referenced by decode_mb_pb_layer().

◆ aec_mb_type_p()

static int aec_mb_type_p ( AVSContext * h)
static

Decode mb_type, table 44 unary mapped by tables 54 and 55 (9.4.2 a) 2))

Definition at line 716 of file cavsdec.c.

Referenced by decode_mb_pb_layer().

◆ aec_mb_type_b()

static int aec_mb_type_b ( AVSContext * h)
static

Decode mb_type in a B picture (table 45, 8.4.4.2 b)); see table 56.

Definition at line 730 of file cavsdec.c.

Referenced by decode_mb_pb_layer().

◆ aec_mb_part_type()

static int aec_mb_part_type ( AVSContext * h)
static

Decode mb_part_type (tables 46 and 57, 8.4.4.2 c)).

Returns
MbPartType, 0 to 3

Definition at line 755 of file cavsdec.c.

Referenced by decode_mb_b().

◆ aec_ref_index()

static int aec_ref_index ( AVSContext * h,
int ctx_inc,
int max )
static

Decode mb_reference_index, table 44 unary (8.4.3 j), 8.4.4.2 f)).

Definition at line 765 of file cavsdec.c.

Referenced by decode_ref_index().

◆ aec_mv_diff()

static int aec_mv_diff ( AVSContext * h,
int base,
int mvda,
int * diff )
static

Decode one mv_diff_x or mv_diff_y (table 49, 8.4.4.2 g)); mvda is the magnitude of the same component of the left block's mv_diff.

Definition at line 785 of file cavsdec.c.

Referenced by aec_mv().

◆ aec_mv()

static int aec_mv ( AVSContext * h,
enum cavs_mv_loc nP )
static

Decode a motion vector's mv_diff pair into the cache that ff_cavs_mv() reads and the next block takes its mvda from.

Definition at line 828 of file cavsdec.c.

Referenced by decode_mv().

◆ aec_intra_luma_pred_mode()

static int aec_intra_luma_pred_mode ( AVSContext * h,
int pred )
static

Decode intra_luma_pred_mode (table 47) and derive IntraLumaPredMode from predIntraPredMode per clause 9.4.4.2 a).

Definition at line 846 of file cavsdec.c.

Referenced by decode_mb_i().

◆ aec_intra_chroma_pred_mode()

static int aec_intra_chroma_pred_mode ( AVSContext * h)
static

Decode intra_chroma_pred_mode (table 48, 8.4.4.2 e)).

Returns
IntraChromaPredMode, 0 to 3 (table 60)

Definition at line 865 of file cavsdec.c.

Referenced by decode_mb_i().

◆ aec_cbp()

static int aec_cbp ( AVSContext * h)
static

Decode cbp (table 50, 8.4.4.2 h), clause 9.4.7).

Returns
MbCBP, a six bit mask over the block order numbers

Definition at line 893 of file cavsdec.c.

Referenced by decode_mb_i(), and decode_residual_inter().

◆ aec_mb_qp_delta()

static int aec_mb_qp_delta ( AVSContext * h,
int * delta )
static

Decode mb_qp_delta (table 44 unary, 8.4.4.2 i)) and map the code number to the signed delta of clause 9.4.8.

Definition at line 932 of file cavsdec.c.

Referenced by decode_mb_qp_delta().

◆ decode_residual_block_aec()

static int decode_residual_block_aec ( AVSContext * h,
int chroma,
int qp,
uint8_t * dst,
ptrdiff_t stride )
static

Decode the trans_coefficient pairs of one 8x8 block (8.4.4.2 j) and k)).

Parameters
chromaselects the chroma half of the context sets of table 51

Definition at line 960 of file cavsdec.c.

Referenced by decode_residual().

◆ is_start_code_offset()

static int is_start_code_offset ( AVSContext * h,
int offset )
static

Tell whether the byte aligned 00 00 01 at offset is a start code: in a de-emulated payload it may be a coincidence (annex A).

Definition at line 1061 of file cavsdec.c.

Referenced by aec_end_of_slice(), and check_for_slice().

◆ aec_end_of_slice()

static void aec_end_of_slice ( AVSContext * h)
static

Position the reader on the start code that ends an AEC slice: the first one at or after the slice's own payload.

The reader position is not reliable: the arithmetic decoder's look ahead has run past it.

Definition at line 1086 of file cavsdec.c.

Referenced by decode_mb_pb_layer(), and decode_pic().

◆ decode_mb_qp_delta()

static int decode_mb_qp_delta ( AVSContext * h)
static

Read mb_qp_delta when the macroblock has coefficients and the picture's qp is not fixed, and keep PreviousDeltaQP for the AEC contexts (clause 9.4.8).

Definition at line 1108 of file cavsdec.c.

Referenced by decode_mb_i(), and decode_residual_inter().

◆ decode_residual()

static int decode_residual ( AVSContext * h,
const struct dec_2dvlc * r,
int esc_golomb_order,
int chroma,
int qp,
uint8_t * dst,
ptrdiff_t stride )
static

Decode one 8x8 block's residual with the picture's entropy coder.

Definition at line 1127 of file cavsdec.c.

Referenced by decode_mb_i(), decode_residual_chroma(), and decode_residual_inter().

◆ decode_residual_chroma()

static int decode_residual_chroma ( AVSContext * h)
inlinestatic

Definition at line 1137 of file cavsdec.c.

Referenced by decode_mb_i(), and decode_residual_inter().

◆ decode_residual_inter()

static int decode_residual_inter ( AVSContext * h)
inlinestatic

Definition at line 1155 of file cavsdec.c.

Referenced by decode_mb_b(), and decode_mb_p().

◆ set_mv_intra()

static void set_mv_intra ( AVSContext * h)
inlinestatic

Definition at line 1190 of file cavsdec.c.

Referenced by decode_mb_i().

◆ decode_mb_i()

static int decode_mb_i ( AVSContext * h,
int cbp_code )
static

Definition at line 1200 of file cavsdec.c.

Referenced by decode_mb_pb_layer(), and decode_pic().

◆ set_intra_mode_default()

static void set_intra_mode_default ( AVSContext * h)
inlinestatic

Definition at line 1289 of file cavsdec.c.

Referenced by decode_mb_b(), and decode_mb_p().

◆ decode_ref_index()

static int decode_ref_index ( AVSContext * h,
int list,
enum cavs_mv_loc nP )
static

Read one mb_reference_index and turn it into a reference list index (table 26, clauses 7.2.5 and 9.4.5).

Table 26 misprints the presence predicate's brackets; GB/T 20090.2-2013 table 27 and IEEE 1857-2023 clause 7.1.5 both print it as implemented here.

Definition at line 1306 of file cavsdec.c.

◆ decode_mv()

static int decode_mv ( AVSContext * h,
enum cavs_mv_loc nP,
enum cavs_mv_loc nC,
enum cavs_mv_pred mode,
enum cavs_block size,
int ref )
static

Decode one motion vector: under AEC its mv_diff must be read before ff_cavs_mv() overwrites the cache its context comes from.

Definition at line 1339 of file cavsdec.c.

◆ set_inter_mb_ctx()

static void set_inter_mb_ctx ( AVSContext * h,
enum cavs_mb mb_type,
int skip )
static

Definition at line 1352 of file cavsdec.c.

Referenced by decode_mb_b(), and decode_mb_p().

◆ decode_mb_p()

static int decode_mb_p ( AVSContext * h,
enum cavs_mb mb_type )
static

Definition at line 1380 of file cavsdec.c.

Referenced by decode_mb_pb_layer().

◆ decode_mb_b()

static int decode_mb_b ( AVSContext * h,
enum cavs_mb mb_type )
static

Definition at line 1435 of file cavsdec.c.

Referenced by decode_mb_pb_layer().

◆ decode_mb_pb_layer()

static int decode_mb_pb_layer ( AVSContext * h,
int * skip_count )
static

Decode one macroblock of a P or B coded macroblock layer, table 25.

Parameters
skip_countwhat is left of the current mb_skip_run, or -1 when the next macroblock position starts a new one

Definition at line 1622 of file cavsdec.c.

Referenced by decode_pic().

◆ decode_slice_header()

static int decode_slice_header ( AVSContext * h,
GetBitContext * gb )
inlinestatic

Definition at line 1673 of file cavsdec.c.

Referenced by check_for_slice().

◆ check_for_slice()

static int check_for_slice ( AVSContext * h)
inlinestatic

Definition at line 1707 of file cavsdec.c.

Referenced by decode_pic().

◆ set_ref_list()

static int set_ref_list ( AVSContext * h)
static

Build the reference list and the temporal distances of the current frame or field (clause 9.4.5 figures 14 to 20, clause 9.4.6.1).

Definition at line 1763 of file cavsdec.c.

Referenced by decode_pic().

◆ decode_pic()

static int decode_pic ( AVSContext * h)
static

Definition at line 1841 of file cavsdec.c.

Referenced by cavs_decode_frame().

◆ decode_seq_header()

static int decode_seq_header ( AVSContext * h)
static

Definition at line 2047 of file cavsdec.c.

Referenced by cavs_decode_frame().

◆ annex_a_applies()

static int annex_a_applies ( int stc)
static

annex A applies to picture headers and slices, not to other units

Definition at line 2145 of file cavsdec.c.

Referenced by deemulate_picture().

◆ deemulate_region()

static int deemulate_region ( PutBitContext * pb,
const uint8_t * buf,
int size,
int deemulated )
static

Copy one region of a picture payload, removing the annex A pseudo start codes; the clause 5.8.2.4 stuffing is rewritten to keep the next start code aligned.

With pb NULL they are only counted.

Returns
the number of pseudo start codes found

Definition at line 2158 of file cavsdec.c.

Referenced by deemulate_picture().

◆ deemulate_picture()

static int deemulate_picture ( AVSContext * h,
PutBitContext * pb,
const uint8_t * buf,
int size )
static

Walk the payload region by region, removing the annex A pseudo start codes; on the writing pass, record every start code prefix offset in h->stc_offset.

Returns
the number of pseudo start codes found

Definition at line 2212 of file cavsdec.c.

Referenced by remove_pseudo_start_codes().

◆ remove_pseudo_start_codes()

static int remove_pseudo_start_codes ( AVSContext * h,
const uint8_t * buf,
int size )
static

Remove the annex A pseudo start codes from a payload: a byte forming 00 00 02 with the two before it loses its two least significant bits.

buf runs from just after a picture start code to the packet end.

Returns
the size of h->deemulated_buf, 0 if buf needs no copy, or < 0

Definition at line 2259 of file cavsdec.c.

Referenced by cavs_decode_frame().

◆ cavs_flush()

static av_cold void cavs_flush ( AVCodecContext * avctx)
static

Definition at line 2288 of file cavsdec.c.

◆ cavs_decode_frame()

static int cavs_decode_frame ( AVCodecContext * avctx,
AVFrame * rframe,
int * got_frame,
AVPacket * avpkt )
static

Definition at line 2294 of file cavsdec.c.

Variable Documentation

◆ mv_scan

const uint8_t mv_scan[4]
static
Initial value:
= {
}
@ MV_FWD_X3
Definition cavs.h:139
@ MV_FWD_X1
Definition cavs.h:136
@ MV_FWD_X0
Definition cavs.h:135
@ MV_FWD_X2
Definition cavs.h:138

Definition at line 46 of file cavsdec.c.

Referenced by decode_mb_b().

◆ cbp_tab

const uint8_t cbp_tab[64][2]
static
Initial value:
= {
{ 63, 0 }, { 15, 15 }, { 31, 63 }, { 47, 31 }, { 0, 16 }, { 14, 32 }, { 13, 47 }, { 11, 13 },
{ 7, 14 }, { 5, 11 }, { 10, 12 }, { 8, 5 }, { 12, 10 }, { 61, 7 }, { 4, 48 }, { 55, 3 },
{ 1, 2 }, { 2, 8 }, { 59, 4 }, { 3, 1 }, { 62, 61 }, { 9, 55 }, { 6, 59 }, { 29, 62 },
{ 45, 29 }, { 51, 27 }, { 23, 23 }, { 39, 19 }, { 27, 30 }, { 46, 28 }, { 53, 9 }, { 30, 6 },
{ 43, 60 }, { 37, 21 }, { 60, 44 }, { 16, 26 }, { 21, 51 }, { 28, 35 }, { 19, 18 }, { 35, 20 },
{ 42, 24 }, { 26, 53 }, { 44, 17 }, { 32, 37 }, { 58, 39 }, { 24, 45 }, { 20, 58 }, { 17, 43 },
{ 18, 42 }, { 48, 46 }, { 22, 36 }, { 33, 33 }, { 25, 34 }, { 49, 40 }, { 40, 52 }, { 36, 49 },
{ 34, 50 }, { 50, 56 }, { 52, 25 }, { 54, 22 }, { 41, 54 }, { 56, 57 }, { 38, 41 }, { 57, 38 }
}

Definition at line 51 of file cavsdec.c.

Referenced by decode_coeffs(), decode_mb_i(), decode_residual_inter(), and init_static_data().

◆ scan3x3

const uint8_t scan3x3[4] = { 4, 5, 7, 8 }
static

Definition at line 62 of file cavsdec.c.

Referenced by decode_mb_i().

◆ dequant_shift

const uint8_t dequant_shift[64]
static
Initial value:
= {
14, 14, 14, 14, 14, 14, 14, 14,
13, 13, 13, 13, 13, 13, 13, 13,
13, 12, 12, 12, 12, 12, 12, 12,
11, 11, 11, 11, 11, 11, 11, 11,
11, 10, 10, 10, 10, 10, 10, 10,
10, 9, 9, 9, 9, 9, 9, 9,
9, 8, 8, 8, 8, 8, 8, 8,
7, 7, 7, 7, 7, 7, 7, 7
}

Definition at line 64 of file cavsdec.c.

Referenced by decode_residual_block(), and decode_residual_block_aec().

◆ dequant_mul

const uint16_t dequant_mul[64]
static
Initial value:
= {
32768, 36061, 38968, 42495, 46341, 50535, 55437, 60424,
32932, 35734, 38968, 42495, 46177, 50535, 55109, 59933,
65535, 35734, 38968, 42577, 46341, 50617, 55027, 60097,
32809, 35734, 38968, 42454, 46382, 50576, 55109, 60056,
65535, 35734, 38968, 42495, 46320, 50515, 55109, 60076,
65535, 35744, 38968, 42495, 46341, 50535, 55099, 60087,
65535, 35734, 38973, 42500, 46341, 50535, 55109, 60097,
32771, 35734, 38965, 42497, 46341, 50535, 55109, 60099
}

Definition at line 75 of file cavsdec.c.

Referenced by decode_residual_block(), and decode_residual_block_aec().

◆ intra_dec

const struct dec_2dvlc intra_dec[7]
static

Definition at line 88 of file cavsdec.c.

Referenced by decode_mb_i().

◆ inter_dec

const struct dec_2dvlc inter_dec[7]
static

Definition at line 224 of file cavsdec.c.

Referenced by decode_residual_inter().

◆ chroma_dec

const struct dec_2dvlc chroma_dec[5]
static

Definition at line 360 of file cavsdec.c.

Referenced by decode_residual_chroma().

◆ cavs_aec_pri_idx

const uint8_t cavs_aec_pri_idx[6] = { 0, 1, 2, 3, 3, 4 }
static

Table 52, priIdx as a function of lMax, which saturates at 5.

Definition at line 698 of file cavsdec.c.

Referenced by decode_residual_block_aec().

◆ ff_cavs_decoder

const FFCodec ff_cavs_decoder
Initial value:
= {
.p.name = "cavs",
CODEC_LONG_NAME("Chinese AVS (Audio Video Standard) (AVS1-P2/P16)"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(AVSContext),
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
.flush = cavs_flush,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
av_cold int ff_cavs_end(AVCodecContext *avctx)
Definition cavs.c:915
av_cold int ff_cavs_init(AVCodecContext *avctx)
Definition cavs.c:867
static av_cold void cavs_flush(AVCodecContext *avctx)
Definition cavsdec.c:2288
static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
Definition cavsdec.c:2294
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:613
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition codec.h:79
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
@ AV_CODEC_ID_CAVS
Definition codec_id.h:137
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
av_cold void CBS_FUNC close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition cbs.c:118
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
const AVProfile ff_cavs_profiles[]
Definition profiles.c:70

Definition at line 2386 of file cavsdec.c.