1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-08 13:22:53 +02:00

prepare splitting decoder-only parts into own file:

make commonly used functions global

Originally committed as revision 9519 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Stefan Gehrer 2007-07-07 07:35:18 +00:00
parent 218b3ae970
commit ceb48b46f8
2 changed files with 54 additions and 45 deletions

View File

@ -71,7 +71,7 @@ static inline int get_bs(vector_t *mvP, vector_t *mvQ, int b) {
* --------- * ---------
* *
*/ */
static void filter_mb(AVSContext *h, enum mb_t mb_type) { void ff_cavs_filter(AVSContext *h, enum mb_t mb_type) {
DECLARE_ALIGNED_8(uint8_t, bs[8]); DECLARE_ALIGNED_8(uint8_t, bs[8]);
int qp_avg, alpha, beta, tc; int qp_avg, alpha, beta, tc;
int i; int i;
@ -323,7 +323,7 @@ static inline void mc_part_std(AVSContext *h,int square,int chroma_height,int de
} }
} }
static void inter_pred(AVSContext *h, enum mb_t mb_type) { void ff_cavs_inter(AVSContext *h, enum mb_t mb_type) {
if(partition_flags[mb_type] == 0){ // 16x16 if(partition_flags[mb_type] == 0){ // 16x16
mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0, mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0,
h->s.dsp.put_cavs_qpel_pixels_tab[0], h->s.dsp.put_cavs_qpel_pixels_tab[0],
@ -428,8 +428,8 @@ static inline void mv_pred_sym(AVSContext *h, vector_t *src, enum block_t size)
set_mvs(dst, size); set_mvs(dst, size);
} }
static void mv_pred(AVSContext *h, enum mv_loc_t nP, enum mv_loc_t nC, void ff_cavs_mv(AVSContext *h, enum mv_loc_t nP, enum mv_loc_t nC,
enum mv_pred_t mode, enum block_t size, int ref) { enum mv_pred_t mode, enum block_t size, int ref) {
vector_t *mvP = &h->mv[nP]; vector_t *mvP = &h->mv[nP];
vector_t *mvA = &h->mv[nP-1]; vector_t *mvA = &h->mv[nP-1];
vector_t *mvB = &h->mv[nP-4]; vector_t *mvB = &h->mv[nP-4];
@ -631,7 +631,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code) {
h->left_border_v, h->c_stride); h->left_border_v, h->c_stride);
decode_residual_chroma(h); decode_residual_chroma(h);
filter_mb(h,I_8X8); ff_cavs_filter(h,I_8X8);
set_mv_intra(h); set_mv_intra(h);
return 0; return 0;
} }
@ -643,40 +643,40 @@ static void decode_mb_p(AVSContext *h, enum mb_t mb_type) {
init_mb(h); init_mb(h);
switch(mb_type) { switch(mb_type) {
case P_SKIP: case P_SKIP:
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_PSKIP, BLK_16X16, 0); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_PSKIP, BLK_16X16, 0);
break; break;
case P_16X16: case P_16X16:
ref[0] = h->ref_flag ? 0 : get_bits1(gb); ref[0] = h->ref_flag ? 0 : get_bits1(gb);
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16,ref[0]); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16,ref[0]);
break; break;
case P_16X8: case P_16X8:
ref[0] = h->ref_flag ? 0 : get_bits1(gb); ref[0] = h->ref_flag ? 0 : get_bits1(gb);
ref[2] = h->ref_flag ? 0 : get_bits1(gb); ref[2] = h->ref_flag ? 0 : get_bits1(gb);
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, ref[0]); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, ref[0]);
mv_pred(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, ref[2]); ff_cavs_mv(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, ref[2]);
break; break;
case P_8X16: case P_8X16:
ref[0] = h->ref_flag ? 0 : get_bits1(gb); ref[0] = h->ref_flag ? 0 : get_bits1(gb);
ref[1] = h->ref_flag ? 0 : get_bits1(gb); ref[1] = h->ref_flag ? 0 : get_bits1(gb);
mv_pred(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, ref[0]); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, ref[0]);
mv_pred(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT, BLK_8X16, ref[1]); ff_cavs_mv(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, ref[1]);
break; break;
case P_8X8: case P_8X8:
ref[0] = h->ref_flag ? 0 : get_bits1(gb); ref[0] = h->ref_flag ? 0 : get_bits1(gb);
ref[1] = h->ref_flag ? 0 : get_bits1(gb); ref[1] = h->ref_flag ? 0 : get_bits1(gb);
ref[2] = h->ref_flag ? 0 : get_bits1(gb); ref[2] = h->ref_flag ? 0 : get_bits1(gb);
ref[3] = h->ref_flag ? 0 : get_bits1(gb); ref[3] = h->ref_flag ? 0 : get_bits1(gb);
mv_pred(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_MEDIAN, BLK_8X8, ref[0]); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_MEDIAN, BLK_8X8, ref[0]);
mv_pred(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_MEDIAN, BLK_8X8, ref[1]); ff_cavs_mv(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_MEDIAN, BLK_8X8, ref[1]);
mv_pred(h, MV_FWD_X2, MV_FWD_X1, MV_PRED_MEDIAN, BLK_8X8, ref[2]); ff_cavs_mv(h, MV_FWD_X2, MV_FWD_X1, MV_PRED_MEDIAN, BLK_8X8, ref[2]);
mv_pred(h, MV_FWD_X3, MV_FWD_X0, MV_PRED_MEDIAN, BLK_8X8, ref[3]); ff_cavs_mv(h, MV_FWD_X3, MV_FWD_X0, MV_PRED_MEDIAN, BLK_8X8, ref[3]);
} }
inter_pred(h, mb_type); ff_cavs_inter(h, mb_type);
set_intra_mode_default(h); set_intra_mode_default(h);
store_mvs(h); store_mvs(h);
if(mb_type != P_SKIP) if(mb_type != P_SKIP)
decode_residual_inter(h); decode_residual_inter(h);
filter_mb(h,mb_type); ff_cavs_filter(h,mb_type);
*h->col_type = mb_type; *h->col_type = mb_type;
} }
@ -697,8 +697,8 @@ static void decode_mb_b(AVSContext *h, enum mb_t mb_type) {
case B_DIRECT: case B_DIRECT:
if(!(*h->col_type)) { if(!(*h->col_type)) {
/* intra MB at co-location, do in-plane prediction */ /* intra MB at co-location, do in-plane prediction */
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1);
mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0); ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0);
} else } else
/* direct prediction from co-located P MB, block-wise */ /* direct prediction from co-located P MB, block-wise */
for(block=0;block<4;block++) for(block=0;block<4;block++)
@ -706,14 +706,14 @@ static void decode_mb_b(AVSContext *h, enum mb_t mb_type) {
&h->col_mv[(h->mby*h->mb_width+h->mbx)*4 + block]); &h->col_mv[(h->mby*h->mb_width+h->mbx)*4 + block]);
break; break;
case B_FWD_16X16: case B_FWD_16X16:
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1);
break; break;
case B_SYM_16X16: case B_SYM_16X16:
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1);
mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X16); mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X16);
break; break;
case B_BWD_16X16: case B_BWD_16X16:
mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_MEDIAN, BLK_16X16, 0); ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_MEDIAN, BLK_16X16, 0);
break; break;
case B_8X8: case B_8X8:
for(block=0;block<4;block++) for(block=0;block<4;block++)
@ -723,9 +723,9 @@ static void decode_mb_b(AVSContext *h, enum mb_t mb_type) {
case B_SUB_DIRECT: case B_SUB_DIRECT:
if(!(*h->col_type)) { if(!(*h->col_type)) {
/* intra MB at co-location, do in-plane prediction */ /* intra MB at co-location, do in-plane prediction */
mv_pred(h, mv_scan[block], mv_scan[block]-3, ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3,
MV_PRED_BSKIP, BLK_8X8, 1); MV_PRED_BSKIP, BLK_8X8, 1);
mv_pred(h, mv_scan[block]+MV_BWD_OFFS, ff_cavs_mv(h, mv_scan[block]+MV_BWD_OFFS,
mv_scan[block]-3+MV_BWD_OFFS, mv_scan[block]-3+MV_BWD_OFFS,
MV_PRED_BSKIP, BLK_8X8, 0); MV_PRED_BSKIP, BLK_8X8, 0);
} else } else
@ -733,11 +733,11 @@ static void decode_mb_b(AVSContext *h, enum mb_t mb_type) {
&h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + block]); &h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + block]);
break; break;
case B_SUB_FWD: case B_SUB_FWD:
mv_pred(h, mv_scan[block], mv_scan[block]-3, ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3,
MV_PRED_MEDIAN, BLK_8X8, 1); MV_PRED_MEDIAN, BLK_8X8, 1);
break; break;
case B_SUB_SYM: case B_SUB_SYM:
mv_pred(h, mv_scan[block], mv_scan[block]-3, ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3,
MV_PRED_MEDIAN, BLK_8X8, 1); MV_PRED_MEDIAN, BLK_8X8, 1);
mv_pred_sym(h, &h->mv[mv_scan[block]], BLK_8X8); mv_pred_sym(h, &h->mv[mv_scan[block]], BLK_8X8);
break; break;
@ -745,7 +745,7 @@ static void decode_mb_b(AVSContext *h, enum mb_t mb_type) {
} }
for(block=0;block<4;block++) { for(block=0;block<4;block++) {
if(sub_type[block] == B_SUB_BWD) if(sub_type[block] == B_SUB_BWD)
mv_pred(h, mv_scan[block]+MV_BWD_OFFS, ff_cavs_mv(h, mv_scan[block]+MV_BWD_OFFS,
mv_scan[block]+MV_BWD_OFFS-3, mv_scan[block]+MV_BWD_OFFS-3,
MV_PRED_MEDIAN, BLK_8X8, 0); MV_PRED_MEDIAN, BLK_8X8, 0);
} }
@ -755,37 +755,37 @@ static void decode_mb_b(AVSContext *h, enum mb_t mb_type) {
flags = partition_flags[mb_type]; flags = partition_flags[mb_type];
if(mb_type & 1) { /* 16x8 macroblock types */ if(mb_type & 1) { /* 16x8 macroblock types */
if(flags & FWD0) if(flags & FWD0)
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, 1); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, 1);
if(flags & SYM0) if(flags & SYM0)
mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X8); mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X8);
if(flags & FWD1) if(flags & FWD1)
mv_pred(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, 1); ff_cavs_mv(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, 1);
if(flags & SYM1) if(flags & SYM1)
mv_pred_sym(h, &h->mv[MV_FWD_X2], BLK_16X8); mv_pred_sym(h, &h->mv[MV_FWD_X2], BLK_16X8);
if(flags & BWD0) if(flags & BWD0)
mv_pred(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_TOP, BLK_16X8, 0); ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_TOP, BLK_16X8, 0);
if(flags & BWD1) if(flags & BWD1)
mv_pred(h, MV_BWD_X2, MV_BWD_A1, MV_PRED_LEFT, BLK_16X8, 0); ff_cavs_mv(h, MV_BWD_X2, MV_BWD_A1, MV_PRED_LEFT, BLK_16X8, 0);
} else { /* 8x16 macroblock types */ } else { /* 8x16 macroblock types */
if(flags & FWD0) if(flags & FWD0)
mv_pred(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, 1); ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, 1);
if(flags & SYM0) if(flags & SYM0)
mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_8X16); mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_8X16);
if(flags & FWD1) if(flags & FWD1)
mv_pred(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, 1); ff_cavs_mv(h,MV_FWD_X1,MV_FWD_C2,MV_PRED_TOPRIGHT,BLK_8X16,1);
if(flags & SYM1) if(flags & SYM1)
mv_pred_sym(h, &h->mv[MV_FWD_X1], BLK_8X16); mv_pred_sym(h, &h->mv[MV_FWD_X1], BLK_8X16);
if(flags & BWD0) if(flags & BWD0)
mv_pred(h, MV_BWD_X0, MV_BWD_B3, MV_PRED_LEFT, BLK_8X16, 0); ff_cavs_mv(h, MV_BWD_X0, MV_BWD_B3, MV_PRED_LEFT, BLK_8X16, 0);
if(flags & BWD1) if(flags & BWD1)
mv_pred(h, MV_BWD_X1, MV_BWD_C2, MV_PRED_TOPRIGHT,BLK_8X16, 0); ff_cavs_mv(h,MV_BWD_X1,MV_BWD_C2,MV_PRED_TOPRIGHT,BLK_8X16,0);
} }
} }
inter_pred(h, mb_type); ff_cavs_inter(h, mb_type);
set_intra_mode_default(h); set_intra_mode_default(h);
if(mb_type != B_SKIP) if(mb_type != B_SKIP)
decode_residual_inter(h); decode_residual_inter(h);
filter_mb(h,mb_type); ff_cavs_filter(h,mb_type);
} }
/***************************************************************************** /*****************************************************************************
@ -828,7 +828,7 @@ static inline void check_for_slice(AVSContext *h) {
* *
****************************************************************************/ ****************************************************************************/
static void init_pic(AVSContext *h) { void ff_cavs_init_pic(AVSContext *h) {
int i; int i;
/* clear some predictors */ /* clear some predictors */
@ -882,7 +882,7 @@ static int decode_pic(AVSContext *h) {
s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture); s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture);
s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture); s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture);
init_pic(h); ff_cavs_init_pic(h);
h->picture.poc = get_bits(&s->gb,8)*2; h->picture.poc = get_bits(&s->gb,8)*2;
/* get temporal distances and MV scaling factors */ /* get temporal distances and MV scaling factors */
@ -991,7 +991,7 @@ static int decode_pic(AVSContext *h) {
* this data has to be stored for one complete row of macroblocks * this data has to be stored for one complete row of macroblocks
* and this storage space is allocated here * and this storage space is allocated here
*/ */
static void init_top_lines(AVSContext *h) { void ff_cavs_init_top_lines(AVSContext *h) {
/* alloc top line of predictors */ /* alloc top line of predictors */
h->top_qp = av_malloc( h->mb_width); h->top_qp = av_malloc( h->mb_width);
h->top_mv[0] = av_malloc((h->mb_width*2+1)*sizeof(vector_t)); h->top_mv[0] = av_malloc((h->mb_width*2+1)*sizeof(vector_t));
@ -1031,7 +1031,7 @@ static int decode_seq_header(AVSContext *h) {
h->s.avctx->width = s->width; h->s.avctx->width = s->width;
h->s.avctx->height = s->height; h->s.avctx->height = s->height;
if(!h->top_qp) if(!h->top_qp)
init_top_lines(h); ff_cavs_init_top_lines(h);
return 0; return 0;
} }
@ -1115,7 +1115,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
} }
} }
static int cavs_decode_init(AVCodecContext * avctx) { int ff_cavs_init(AVCodecContext *avctx) {
AVSContext *h = avctx->priv_data; AVSContext *h = avctx->priv_data;
MpegEncContext * const s = &h->s; MpegEncContext * const s = &h->s;
@ -1146,7 +1146,7 @@ static int cavs_decode_init(AVCodecContext * avctx) {
return 0; return 0;
} }
static int cavs_decode_end(AVCodecContext * avctx) { int ff_cavs_end(AVCodecContext *avctx) {
AVSContext *h = avctx->priv_data; AVSContext *h = avctx->priv_data;
av_free(h->top_qp); av_free(h->top_qp);
@ -1167,9 +1167,9 @@ AVCodec cavs_decoder = {
CODEC_TYPE_VIDEO, CODEC_TYPE_VIDEO,
CODEC_ID_CAVS, CODEC_ID_CAVS,
sizeof(AVSContext), sizeof(AVSContext),
cavs_decode_init, ff_cavs_init,
NULL, NULL,
cavs_decode_end, ff_cavs_end,
cavs_decode_frame, cavs_decode_frame,
CODEC_CAP_DR1 | CODEC_CAP_DELAY, CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.flush= cavs_flush, .flush= cavs_flush,

View File

@ -461,4 +461,13 @@ static inline int dequant(AVSContext *h, DCTELEM *level_buf, uint8_t *run_buf,
return 0; return 0;
} }
void ff_cavs_filter(AVSContext *h, enum mb_t mb_type);
void ff_cavs_inter(AVSContext *h, enum mb_t mb_type);
void ff_cavs_mv(AVSContext *h, enum mv_loc_t nP, enum mv_loc_t nC,
enum mv_pred_t mode, enum block_t size, int ref);
void ff_cavs_init_pic(AVSContext *h);
void ff_cavs_init_top_lines(AVSContext *h);
int ff_cavs_init(AVCodecContext *avctx);
int ff_cavs_end (AVCodecContext *avctx);
#endif /* CAVS_H */ #endif /* CAVS_H */