FFmpeg
Macros | Functions | Variables
cavsdec.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/emms.h"
#include "avcodec.h"
#include "get_bits.h"
#include "golomb.h"
#include "cavs.h"
#include "codec_internal.h"
#include "decode.h"
#include "mathops.h"
#include "mpeg12data.h"
#include "startcode.h"

Go to the source code of this file.

Macros

#define EOB   0, 0, 0
 
#define TMP_UNUSED_INX   7
 

Functions

static void store_mvs (AVSContext *h)
 
static void mv_pred_direct (AVSContext *h, cavs_vector *pmv_fw, cavs_vector *col_mv)
 
static void mv_pred_sym (AVSContext *h, cavs_vector *src, enum cavs_block size)
 
static int get_ue_code (GetBitContext *gb, int order)
 kth-order exponential golomb code More...
 
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 More...
 
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 void 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_slice_header (AVSContext *h, GetBitContext *gb)
 
static int check_for_slice (AVSContext *h)
 
static int decode_pic (AVSContext *h)
 
static int decode_seq_header (AVSContext *h)
 
static 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]
 
const FFCodec ff_cavs_decoder
 

Detailed Description

Chinese AVS video (AVS1-P2, JiZhun profile) decoder

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

Definition in file cavsdec.c.

Macro Definition Documentation

◆ EOB

#define EOB   0, 0, 0

Definition at line 80 of file cavsdec.c.

◆ TMP_UNUSED_INX

#define TMP_UNUSED_INX   7

Function Documentation

◆ store_mvs()

static void store_mvs ( AVSContext h)
inlinestatic

Definition at line 460 of file cavsdec.c.

Referenced by decode_mb_p().

◆ mv_pred_direct()

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

Definition at line 468 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

Definition at line 487 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 507 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

Definition at line 520 of file cavsdec.c.

Referenced by calc_dequant(), decode_block(), decode_residual_block(), and lead_decode_frame().

◆ 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 550 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 598 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 615 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 645 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 655 of file cavsdec.c.

Referenced by decode_pic().

◆ set_intra_mode_default()

static void set_intra_mode_default ( AVSContext h)
inlinestatic

Definition at line 729 of file cavsdec.c.

Referenced by decode_mb_b(), and decode_mb_p().

◆ decode_mb_p()

static void decode_mb_p ( AVSContext h,
enum cavs_mb  mb_type 
)
static

Definition at line 740 of file cavsdec.c.

Referenced by decode_pic().

◆ decode_mb_b()

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

Definition at line 785 of file cavsdec.c.

Referenced by decode_pic().

◆ decode_slice_header()

static int decode_slice_header ( AVSContext h,
GetBitContext gb 
)
inlinestatic

Definition at line 928 of file cavsdec.c.

Referenced by cavs_decode_frame(), and check_for_slice().

◆ check_for_slice()

static int check_for_slice ( AVSContext h)
inlinestatic

Definition at line 957 of file cavsdec.c.

Referenced by decode_pic().

◆ decode_pic()

static int decode_pic ( AVSContext h)
static

Definition at line 985 of file cavsdec.c.

Referenced by cavs_decode_frame().

◆ decode_seq_header()

static int decode_seq_header ( AVSContext h)
static

Definition at line 1177 of file cavsdec.c.

Referenced by cavs_decode_frame().

◆ cavs_flush()

static void cavs_flush ( AVCodecContext avctx)
static

Definition at line 1232 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 1238 of file cavsdec.c.

Variable Documentation

◆ mv_scan

const uint8_t mv_scan[4]
static
Initial value:

Definition at line 40 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 45 of file cavsdec.c.

Referenced by decode_mb_i(), and decode_residual_inter().

◆ scan3x3

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

Definition at line 56 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 58 of file cavsdec.c.

Referenced by decode_residual_block().

◆ 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 69 of file cavsdec.c.

Referenced by decode_residual_block().

◆ intra_dec

const struct dec_2dvlc intra_dec[7]
static

Definition at line 82 of file cavsdec.c.

Referenced by decode_mb_i().

◆ inter_dec

const struct dec_2dvlc inter_dec[7]
static

Definition at line 218 of file cavsdec.c.

Referenced by decode_residual_inter().

◆ chroma_dec

const struct dec_2dvlc chroma_dec[5]
static

Definition at line 354 of file cavsdec.c.

Referenced by decode_residual_chroma().

◆ ff_cavs_decoder

const FFCodec ff_cavs_decoder
Initial value:
= {
.p.name = "cavs",
CODEC_LONG_NAME("Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile)"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(AVSContext),
.close = ff_cavs_end,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
.flush = cavs_flush,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 1322 of file cavsdec.c.

FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
MV_FWD_X0
@ MV_FWD_X0
Definition: cavs.h:132
ff_cavs_init
av_cold int ff_cavs_init(AVCodecContext *avctx)
Definition: cavs.c:792
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
cavs_flush
static void cavs_flush(AVCodecContext *avctx)
Definition: cavsdec.c:1232
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
ff_cavs_end
av_cold int ff_cavs_end(AVCodecContext *avctx)
Definition: cavs.c:835
MV_FWD_X3
@ MV_FWD_X3
Definition: cavs.h:136
AV_CODEC_ID_CAVS
@ AV_CODEC_ID_CAVS
Definition: codec_id.h:139
MV_FWD_X2
@ MV_FWD_X2
Definition: cavs.h:135
cavs_decode_frame
static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
Definition: cavsdec.c:1238
AV_CODEC_CAP_DELAY
#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:76
AVSContext
Definition: cavs.h:169
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
MV_FWD_X1
@ MV_FWD_X1
Definition: cavs.h:133