[FFmpeg-cvslog] r17138 - in trunk/libavcodec: cavs.c cavs.h cavsdec.c
stefang
subversion
Tue Feb 10 23:38:02 CET 2009
Author: stefang
Date: Tue Feb 10 23:38:02 2009
New Revision: 17138
Log:
introduce a macroblock index to avoid a few x*width+y calculations
Modified:
trunk/libavcodec/cavs.c
trunk/libavcodec/cavs.h
trunk/libavcodec/cavsdec.c
Modified: trunk/libavcodec/cavs.c
==============================================================================
--- trunk/libavcodec/cavs.c Tue Feb 10 21:51:35 2009 (r17137)
+++ trunk/libavcodec/cavs.c Tue Feb 10 23:38:02 2009 (r17138)
@@ -567,8 +567,6 @@ void ff_cavs_init_mb(AVSContext *h) {
h->mv[MV_FWD_D3] = ff_cavs_un_mv;
h->mv[MV_BWD_D3] = ff_cavs_un_mv;
}
- /* set pointer for co-located macroblock type */
- h->col_type = &h->col_type_base[h->mby*h->mb_width + h->mbx];
}
/**
@@ -592,6 +590,7 @@ int ff_cavs_next_mb(AVSContext *h) {
h->top_mv[1][h->mbx*2+0] = h->mv[MV_BWD_X2];
h->top_mv[1][h->mbx*2+1] = h->mv[MV_BWD_X3];
/* next MB address */
+ h->mbidx++;
h->mbx++;
if(h->mbx == h->mb_width) { //new mb line
h->flags = B_AVAIL|C_AVAIL;
@@ -637,7 +636,7 @@ void ff_cavs_init_pic(AVSContext *h) {
h->c_stride = h->picture.linesize[1];
h->luma_scan[2] = 8*h->l_stride;
h->luma_scan[3] = 8*h->l_stride+8;
- h->mbx = h->mby = 0;
+ h->mbx = h->mby = h->mbidx = 0;
h->flags = 0;
}
Modified: trunk/libavcodec/cavs.h
==============================================================================
--- trunk/libavcodec/cavs.h Tue Feb 10 21:51:35 2009 (r17137)
+++ trunk/libavcodec/cavs.h Tue Feb 10 23:38:02 2009 (r17138)
@@ -166,7 +166,7 @@ typedef struct {
int loop_filter_disable;
int alpha_offset, beta_offset;
int ref_flag;
- int mbx, mby; ///< macroblock coordinates
+ int mbx, mby, mbidx; ///< macroblock coordinates
int flags; ///< availability flags of neighbouring macroblocks
int stc; ///< last start code
uint8_t *cy, *cu, *cv; ///< current MB sample pointers
@@ -212,7 +212,6 @@ typedef struct {
void (*intra_pred_l[8])(uint8_t *d,uint8_t *top,uint8_t *left,int stride);
void (*intra_pred_c[7])(uint8_t *d,uint8_t *top,uint8_t *left,int stride);
uint8_t *col_type_base;
- uint8_t *col_type;
/* scaling factors for MV prediction */
int sym_factor; ///< for scaling in symmetrical B block
@@ -272,7 +271,7 @@ static inline void set_mv_intra(AVSConte
h->mv[MV_BWD_X0] = ff_cavs_intra_mv;
set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
if(h->pic_type != FF_B_TYPE)
- *h->col_type = I_8X8;
+ h->col_type_base[h->mbidx] = I_8X8;
}
static inline int dequant(AVSContext *h, DCTELEM *level_buf, uint8_t *run_buf,
Modified: trunk/libavcodec/cavsdec.c
==============================================================================
--- trunk/libavcodec/cavsdec.c Tue Feb 10 21:51:35 2009 (r17137)
+++ trunk/libavcodec/cavsdec.c Tue Feb 10 23:38:02 2009 (r17138)
@@ -53,10 +53,10 @@ static const uint8_t cbp_tab[64][2] = {
****************************************************************************/
static inline void store_mvs(AVSContext *h) {
- h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 0] = h->mv[MV_FWD_X0];
- h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 1] = h->mv[MV_FWD_X1];
- h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 2] = h->mv[MV_FWD_X2];
- h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + 3] = h->mv[MV_FWD_X3];
+ h->col_mv[h->mbidx*4 + 0] = h->mv[MV_FWD_X0];
+ h->col_mv[h->mbidx*4 + 1] = h->mv[MV_FWD_X1];
+ h->col_mv[h->mbidx*4 + 2] = h->mv[MV_FWD_X2];
+ h->col_mv[h->mbidx*4 + 3] = h->mv[MV_FWD_X3];
}
static inline void mv_pred_direct(AVSContext *h, cavs_vector *pmv_fw,
@@ -294,7 +294,7 @@ static void decode_mb_p(AVSContext *h, e
if(mb_type != P_SKIP)
decode_residual_inter(h);
ff_cavs_filter(h,mb_type);
- *h->col_type = mb_type;
+ h->col_type_base[h->mbidx] = mb_type;
}
static void decode_mb_b(AVSContext *h, enum cavs_mb mb_type) {
@@ -312,7 +312,7 @@ static void decode_mb_b(AVSContext *h, e
switch(mb_type) {
case B_SKIP:
case B_DIRECT:
- if(!(*h->col_type)) {
+ if(!h->col_type_base[h->mbidx]) {
/* intra MB at co-location, do in-plane prediction */
ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1);
ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0);
@@ -320,7 +320,7 @@ static void decode_mb_b(AVSContext *h, e
/* direct prediction from co-located P MB, block-wise */
for(block=0;block<4;block++)
mv_pred_direct(h,&h->mv[mv_scan[block]],
- &h->col_mv[(h->mby*h->mb_width+h->mbx)*4 + block]);
+ &h->col_mv[h->mbidx*4 + block]);
break;
case B_FWD_16X16:
ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1);
@@ -338,7 +338,7 @@ static void decode_mb_b(AVSContext *h, e
for(block=0;block<4;block++) {
switch(sub_type[block]) {
case B_SUB_DIRECT:
- if(!(*h->col_type)) {
+ if(!h->col_type_base[h->mbidx]) {
/* intra MB at co-location, do in-plane prediction */
ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3,
MV_PRED_BSKIP, BLK_8X8, 1);
@@ -347,7 +347,7 @@ static void decode_mb_b(AVSContext *h, e
MV_PRED_BSKIP, BLK_8X8, 0);
} else
mv_pred_direct(h,&h->mv[mv_scan[block]],
- &h->col_mv[(h->mby*h->mb_width + h->mbx)*4 + block]);
+ &h->col_mv[h->mbidx*4 + block]);
break;
case B_SUB_FWD:
ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3,
@@ -415,6 +415,7 @@ static inline int decode_slice_header(AV
if(h->stc > 0xAF)
av_log(h->s.avctx, AV_LOG_ERROR, "unexpected start code 0x%02x\n", h->stc);
h->mby = h->stc;
+ h->mbidx = h->mby*h->mb_width;
/* mark top macroblocks as unavailable */
h->flags &= ~(B_AVAIL|C_AVAIL);
More information about the ffmpeg-cvslog
mailing list