|
FFmpeg
|
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 |
Chinese AVS video (AVS1-P2/P16, JiZhun and Broadcasting profiles) decoder.
Clause, table and figure numbers refer to GY/T 257.1-2012.
Definition in file cavsdec.c.
| #define AEC_MB_SKIP_RUN 0 |
Definition at line 673 of file cavsdec.c.
Referenced by aec_mb_skip_run().
| #define AEC_MB_TYPE 4 |
Definition at line 674 of file cavsdec.c.
Referenced by aec_mb_type_b(), and aec_mb_type_p().
| #define AEC_MB_PART_TYPE 19 |
Definition at line 675 of file cavsdec.c.
Referenced by aec_mb_part_type().
| #define AEC_INTRA_LUMA_PRED_MODE 22 |
Definition at line 676 of file cavsdec.c.
Referenced by aec_intra_luma_pred_mode().
| #define AEC_INTRA_CHROMA_PRED_MODE 26 |
Definition at line 677 of file cavsdec.c.
Referenced by aec_intra_chroma_pred_mode().
| #define AEC_MB_REFERENCE_INDEX 30 |
Definition at line 678 of file cavsdec.c.
Referenced by aec_ref_index().
| #define AEC_MB_QP_DELTA 54 |
Definition at line 682 of file cavsdec.c.
Referenced by aec_mb_qp_delta().
| #define AEC_COEFF_FRAME_LUMA 58 |
Definition at line 683 of file cavsdec.c.
Referenced by decode_residual_block_aec().
| #define AEC_COEFF_FRAME_CHROMA 124 |
Definition at line 684 of file cavsdec.c.
Referenced by decode_residual_block_aec().
| #define AEC_COEFF_FIELD_LUMA 190 |
Definition at line 685 of file cavsdec.c.
Referenced by decode_residual_block_aec().
| #define AEC_COEFF_FIELD_CHROMA 256 |
Definition at line 686 of file cavsdec.c.
Referenced by decode_residual_block_aec().
| #define CAVS_MAX_ABS_LEVEL 2048 |
Definition at line 690 of file cavsdec.c.
Referenced by decode_residual_block_aec().
| #define AEC_COEFF_NUM_CTX 66 |
Definition at line 693 of file cavsdec.c.
Referenced by decode_residual_block_aec().
| #define AEC_COEFF_RUN 46 |
Definition at line 694 of file cavsdec.c.
Referenced by decode_residual_block_aec().
| #define AEC_COEFF_RUN_NUM_CTX 20 |
Definition at line 695 of file cavsdec.c.
Referenced by decode_residual_block_aec().
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().
Definition at line 1372 of file cavsdec.c.
Referenced by decode_mb_b(), and decode_mb_p().
| #define TMP_UNUSED_INX 7 |
Referenced by decode_mb_b().
Referenced by set_ref_list().
|
inlinestatic |
Definition at line 466 of file cavsdec.c.
Referenced by decode_mb_p().
|
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().
|
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().
|
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().
|
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().
|
inlinestatic |
kth-order exponential golomb code
Definition at line 574 of file cavsdec.c.
Referenced by decode_residual_block().
|
inlinestatic |
Definition at line 587 of file cavsdec.c.
Referenced by calc_dequant(), decode_block(), decode_residual_block(), decode_residual_block_aec(), dequant(), and lead_decode_frame().
|
static |
decode coefficients from one 8x8 block, dequantize, inverse transform and add them to sample block
| r | pointer to 2D VLC table |
| esc_golomb_order | escape codes are k-golomb with this order k |
| qp | quantizer |
| dst | location of sample block |
| stride | line stride in frame buffer |
Definition at line 617 of file cavsdec.c.
Referenced by decode_residual().
|
static |
Decode mb_skip_run, table 44 unary (8.4.4.2 a)).
Definition at line 701 of file cavsdec.c.
Referenced by decode_mb_pb_layer().
|
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().
|
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().
|
static |
Decode mb_part_type (tables 46 and 57, 8.4.4.2 c)).
Definition at line 755 of file cavsdec.c.
Referenced by decode_mb_b().
|
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().
|
static |
|
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().
|
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().
|
static |
Decode intra_chroma_pred_mode (table 48, 8.4.4.2 e)).
Definition at line 865 of file cavsdec.c.
Referenced by decode_mb_i().
|
static |
Decode cbp (table 50, 8.4.4.2 h), clause 9.4.7).
Definition at line 893 of file cavsdec.c.
Referenced by decode_mb_i(), and decode_residual_inter().
|
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().
|
static |
Decode the trans_coefficient pairs of one 8x8 block (8.4.4.2 j) and k)).
| chroma | selects the chroma half of the context sets of table 51 |
Definition at line 960 of file cavsdec.c.
Referenced by decode_residual().
|
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().
|
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().
|
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().
|
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().
|
inlinestatic |
Definition at line 1137 of file cavsdec.c.
Referenced by decode_mb_i(), and decode_residual_inter().
|
inlinestatic |
Definition at line 1155 of file cavsdec.c.
Referenced by decode_mb_b(), and decode_mb_p().
|
inlinestatic |
Definition at line 1190 of file cavsdec.c.
Referenced by decode_mb_i().
|
static |
Definition at line 1200 of file cavsdec.c.
Referenced by decode_mb_pb_layer(), and decode_pic().
|
inlinestatic |
Definition at line 1289 of file cavsdec.c.
Referenced by decode_mb_b(), and decode_mb_p().
|
static |
|
static |
Decode one motion vector: under AEC its mv_diff must be read before ff_cavs_mv() overwrites the cache its context comes from.
|
static |
Definition at line 1352 of file cavsdec.c.
Referenced by decode_mb_b(), and decode_mb_p().
|
static |
Definition at line 1380 of file cavsdec.c.
Referenced by decode_mb_pb_layer().
|
static |
Definition at line 1435 of file cavsdec.c.
Referenced by decode_mb_pb_layer().
|
static |
Decode one macroblock of a P or B coded macroblock layer, table 25.
| skip_count | what 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().
|
inlinestatic |
Definition at line 1673 of file cavsdec.c.
Referenced by check_for_slice().
|
inlinestatic |
Definition at line 1707 of file cavsdec.c.
Referenced by decode_pic().
|
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().
|
static |
Definition at line 1841 of file cavsdec.c.
Referenced by cavs_decode_frame().
|
static |
Definition at line 2047 of file cavsdec.c.
Referenced by cavs_decode_frame().
|
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().
|
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.
Definition at line 2158 of file cavsdec.c.
Referenced by deemulate_picture().
|
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.
Definition at line 2212 of file cavsdec.c.
Referenced by remove_pseudo_start_codes().
|
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.
Definition at line 2259 of file cavsdec.c.
Referenced by cavs_decode_frame().
|
static |
|
static |
|
static |
|
static |
Definition at line 51 of file cavsdec.c.
Referenced by decode_coeffs(), decode_mb_i(), decode_residual_inter(), and init_static_data().
|
static |
Definition at line 62 of file cavsdec.c.
Referenced by decode_mb_i().
|
static |
Definition at line 64 of file cavsdec.c.
Referenced by decode_residual_block(), and decode_residual_block_aec().
|
static |
Definition at line 75 of file cavsdec.c.
Referenced by decode_residual_block(), and decode_residual_block_aec().
|
static |
Definition at line 88 of file cavsdec.c.
Referenced by decode_mb_i().
|
static |
Definition at line 224 of file cavsdec.c.
Referenced by decode_residual_inter().
|
static |
Definition at line 360 of file cavsdec.c.
Referenced by decode_residual_chroma().
|
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().
| const FFCodec ff_cavs_decoder |