00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVCODEC_CAVS_H
00023 #define AVCODEC_CAVS_H
00024
00025 #include "dsputil.h"
00026 #include "mpegvideo.h"
00027 #include "cavsdsp.h"
00028
00029 #define SLICE_MAX_START_CODE 0x000001af
00030 #define EXT_START_CODE 0x000001b5
00031 #define USER_START_CODE 0x000001b2
00032 #define CAVS_START_CODE 0x000001b0
00033 #define PIC_I_START_CODE 0x000001b3
00034 #define PIC_PB_START_CODE 0x000001b6
00035
00036 #define A_AVAIL 1
00037 #define B_AVAIL 2
00038 #define C_AVAIL 4
00039 #define D_AVAIL 8
00040 #define NOT_AVAIL -1
00041 #define REF_INTRA -2
00042 #define REF_DIR -3
00043
00044 #define ESCAPE_CODE 59
00045
00046 #define FWD0 0x01
00047 #define FWD1 0x02
00048 #define BWD0 0x04
00049 #define BWD1 0x08
00050 #define SYM0 0x10
00051 #define SYM1 0x20
00052 #define SPLITH 0x40
00053 #define SPLITV 0x80
00054
00055 #define MV_BWD_OFFS 12
00056 #define MV_STRIDE 4
00057
00058 enum cavs_mb {
00059 I_8X8 = 0,
00060 P_SKIP,
00061 P_16X16,
00062 P_16X8,
00063 P_8X16,
00064 P_8X8,
00065 B_SKIP,
00066 B_DIRECT,
00067 B_FWD_16X16,
00068 B_BWD_16X16,
00069 B_SYM_16X16,
00070 B_8X8 = 29
00071 };
00072
00073 enum cavs_sub_mb {
00074 B_SUB_DIRECT,
00075 B_SUB_FWD,
00076 B_SUB_BWD,
00077 B_SUB_SYM
00078 };
00079
00080 enum cavs_intra_luma {
00081 INTRA_L_VERT,
00082 INTRA_L_HORIZ,
00083 INTRA_L_LP,
00084 INTRA_L_DOWN_LEFT,
00085 INTRA_L_DOWN_RIGHT,
00086 INTRA_L_LP_LEFT,
00087 INTRA_L_LP_TOP,
00088 INTRA_L_DC_128
00089 };
00090
00091 enum cavs_intra_chroma {
00092 INTRA_C_LP,
00093 INTRA_C_HORIZ,
00094 INTRA_C_VERT,
00095 INTRA_C_PLANE,
00096 INTRA_C_LP_LEFT,
00097 INTRA_C_LP_TOP,
00098 INTRA_C_DC_128,
00099 };
00100
00101 enum cavs_mv_pred {
00102 MV_PRED_MEDIAN,
00103 MV_PRED_LEFT,
00104 MV_PRED_TOP,
00105 MV_PRED_TOPRIGHT,
00106 MV_PRED_PSKIP,
00107 MV_PRED_BSKIP
00108 };
00109
00110 enum cavs_block {
00111 BLK_16X16,
00112 BLK_16X8,
00113 BLK_8X16,
00114 BLK_8X8
00115 };
00116
00117 enum cavs_mv_loc {
00118 MV_FWD_D3 = 0,
00119 MV_FWD_B2,
00120 MV_FWD_B3,
00121 MV_FWD_C2,
00122 MV_FWD_A1,
00123 MV_FWD_X0,
00124 MV_FWD_X1,
00125 MV_FWD_A3 = 8,
00126 MV_FWD_X2,
00127 MV_FWD_X3,
00128 MV_BWD_D3 = MV_BWD_OFFS,
00129 MV_BWD_B2,
00130 MV_BWD_B3,
00131 MV_BWD_C2,
00132 MV_BWD_A1,
00133 MV_BWD_X0,
00134 MV_BWD_X1,
00135 MV_BWD_A3 = MV_BWD_OFFS+8,
00136 MV_BWD_X2,
00137 MV_BWD_X3
00138 };
00139
00140 DECLARE_ALIGNED(8, typedef, struct) {
00141 int16_t x;
00142 int16_t y;
00143 int16_t dist;
00144 int16_t ref;
00145 } cavs_vector;
00146
00147 struct dec_2dvlc {
00148 int8_t rltab[59][3];
00149 int8_t level_add[27];
00150 int8_t golomb_order;
00151 int inc_limit;
00152 int8_t max_run;
00153 };
00154
00155 typedef struct {
00156 MpegEncContext s;
00157 CAVSDSPContext cdsp;
00158 Picture picture;
00159 Picture DPB[2];
00160 int dist[2];
00161 int profile, level;
00162 int aspect_ratio;
00163 int mb_width, mb_height;
00164 int pic_type;
00165 int stream_revision;
00166 int progressive;
00167 int pic_structure;
00168 int skip_mode_flag;
00169 int loop_filter_disable;
00170 int alpha_offset, beta_offset;
00171 int ref_flag;
00172 int mbx, mby, mbidx;
00173 int flags;
00174 int stc;
00175 uint8_t *cy, *cu, *cv;
00176 int left_qp;
00177 uint8_t *top_qp;
00178
00191 cavs_vector mv[2*4*3];
00192 cavs_vector *top_mv[2];
00193 cavs_vector *col_mv;
00194
00199 int pred_mode_Y[3*3];
00200 int *top_pred_Y;
00201 int l_stride, c_stride;
00202 int luma_scan[4];
00203 int qp;
00204 int qp_fixed;
00205 int cbp;
00206 ScanTable scantable;
00207
00210 uint8_t *top_border_y, *top_border_u, *top_border_v;
00211 uint8_t left_border_y[26], left_border_u[10], left_border_v[10];
00212 uint8_t intern_border_y[26];
00213 uint8_t topleft_border_y, topleft_border_u, topleft_border_v;
00214
00215 void (*intra_pred_l[8])(uint8_t *d,uint8_t *top,uint8_t *left,int stride);
00216 void (*intra_pred_c[7])(uint8_t *d,uint8_t *top,uint8_t *left,int stride);
00217 uint8_t *col_type_base;
00218
00219
00220 int sym_factor;
00221 int direct_den[2];
00222 int scale_den[2];
00223
00224 int got_keyframe;
00225 DCTELEM *block;
00226 } AVSContext;
00227
00228 extern const uint8_t ff_cavs_partition_flags[30];
00229 extern const cavs_vector ff_cavs_intra_mv;
00230 extern const cavs_vector ff_cavs_dir_mv;
00231
00232 static inline void set_mvs(cavs_vector *mv, enum cavs_block size) {
00233 switch(size) {
00234 case BLK_16X16:
00235 mv[MV_STRIDE ] = mv[0];
00236 mv[MV_STRIDE+1] = mv[0];
00237 case BLK_16X8:
00238 mv[1] = mv[0];
00239 break;
00240 case BLK_8X16:
00241 mv[MV_STRIDE] = mv[0];
00242 break;
00243 }
00244 }
00245
00246 void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type);
00247 void ff_cavs_load_intra_pred_luma(AVSContext *h, uint8_t *top, uint8_t **left,
00248 int block);
00249 void ff_cavs_load_intra_pred_chroma(AVSContext *h);
00250 void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv);
00251 void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type);
00252 void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC,
00253 enum cavs_mv_pred mode, enum cavs_block size, int ref);
00254 void ff_cavs_init_mb(AVSContext *h);
00255 int ff_cavs_next_mb(AVSContext *h);
00256 void ff_cavs_init_pic(AVSContext *h);
00257 void ff_cavs_init_top_lines(AVSContext *h);
00258 int ff_cavs_init(AVCodecContext *avctx);
00259 int ff_cavs_end (AVCodecContext *avctx);
00260
00261 #endif