From 21effaa4b20bbd34ecc11e5bef1211dcca6fc2bc Mon Sep 17 00:00:00 2001 From: Ivan Kalvachev Date: Sun, 22 Feb 2009 09:02:06 +0000 Subject: [PATCH] Change the type of pblocks from pointers to short array into pointers to array of 64 DCTELEM, similarly to other block fields. This also get rid of some casts and fixes a warning. Originally committed as revision 17517 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/mpeg12.c | 18 ++++++++++-------- libavcodec/mpegvideo.c | 4 ++-- libavcodec/mpegvideo.h | 2 +- libavcodec/mpegvideo_xvmc.c | 14 +++++++------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 6cf03356de..343858289f 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -308,17 +308,17 @@ static int mpeg_decode_mb(MpegEncContext *s, if (s->codec_id == CODEC_ID_MPEG2VIDEO) { if(s->flags2 & CODEC_FLAG2_FAST){ for(i=0;i<6;i++) { - mpeg2_fast_decode_block_intra(s, s->pblocks[i], i); + mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i); } }else{ for(i=0;ipblocks[i], i) < 0) + if (mpeg2_decode_block_intra(s, *s->pblocks[i], i) < 0) return -1; } } } else { for(i=0;i<6;i++) { - if (ff_mpeg1_decode_block_intra(s, s->pblocks[i], i) < 0) + if (ff_mpeg1_decode_block_intra(s, *s->pblocks[i], i) < 0) return -1; } } @@ -520,7 +520,7 @@ static int mpeg_decode_mb(MpegEncContext *s, if(s->flags2 & CODEC_FLAG2_FAST){ for(i=0;i<6;i++) { if(cbp & 32) { - mpeg2_fast_decode_block_non_intra(s, s->pblocks[i], i); + mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i); } else { s->block_last_index[i] = -1; } @@ -531,7 +531,7 @@ static int mpeg_decode_mb(MpegEncContext *s, for(i=0;ipblocks[i], i) < 0) + if (mpeg2_decode_block_non_intra(s, *s->pblocks[i], i) < 0) return -1; } else { s->block_last_index[i] = -1; @@ -543,7 +543,7 @@ static int mpeg_decode_mb(MpegEncContext *s, if(s->flags2 & CODEC_FLAG2_FAST){ for(i=0;i<6;i++) { if (cbp & 32) { - mpeg1_fast_decode_block_inter(s, s->pblocks[i], i); + mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i); } else { s->block_last_index[i] = -1; } @@ -552,7 +552,7 @@ static int mpeg_decode_mb(MpegEncContext *s, }else{ for(i=0;i<6;i++) { if (cbp & 32) { - if (mpeg1_decode_block_inter(s, s->pblocks[i], i) < 0) + if (mpeg1_decode_block_inter(s, *s->pblocks[i], i) < 0) return -1; } else { s->block_last_index[i] = -1; @@ -1595,7 +1595,9 @@ static void mpeg_decode_extension(AVCodecContext *avctx, } static void exchange_uv(MpegEncContext *s){ - short * tmp = s->pblocks[4]; + DCTELEM (*tmp)[64]; + + tmp = s->pblocks[4]; s->pblocks[4] = s->pblocks[5]; s->pblocks[5] = tmp; } diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 2eec211abc..06d842b2d9 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -301,7 +301,7 @@ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){ s->block= s->blocks[0]; for(i=0;i<12;i++){ - s->pblocks[i] = (short *)(&s->block[i]); + s->pblocks[i] = &s->block[i]; } return 0; fail: @@ -357,7 +357,7 @@ void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src){ memcpy(dst, src, sizeof(MpegEncContext)); backup_duplicate_context(dst, &bak); for(i=0;i<12;i++){ - dst->pblocks[i] = (short *)(&dst->block[i]); + dst->pblocks[i] = &dst->block[i]; } //STOP_TIMER("update_duplicate_context") //about 10k cycles / 0.01 sec for 1000frames on 1ghz with 2 threads } diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 8f25ff3dc7..8709deeb02 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -635,7 +635,7 @@ typedef struct MpegEncContext { uint8_t *ptr_lastgob; int swap_uv;//vcr2 codec is mpeg2 varint with UV swaped - short * pblocks[12]; + DCTELEM (*pblocks[12])[64]; DCTELEM (*block)[64]; ///< points to one of the following blocks DCTELEM (*blocks)[8][64]; // for HQ mode we need to keep the best block diff --git a/libavcodec/mpegvideo_xvmc.c b/libavcodec/mpegvideo_xvmc.c index bff9543a0c..b73a399b9e 100644 --- a/libavcodec/mpegvideo_xvmc.c +++ b/libavcodec/mpegvideo_xvmc.c @@ -44,7 +44,7 @@ void ff_xvmc_init_block(MpegEncContext *s) struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.data[2]; assert(render && render->xvmc_id == AV_XVMC_ID); - s->block = (DCTELEM *)(render->data_blocks + render->next_free_data_block_num * 64); + s->block = (DCTELEM (*)[64])(render->data_blocks + render->next_free_data_block_num * 64); } /** @@ -59,7 +59,7 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) cbp <<= 12-mb_block_count; for (i = 0; i < mb_block_count; i++) { if (cbp & (1 << 11)) - s->pblocks[i] = (short *)(&s->block[j++]); + s->pblocks[i] = &s->block[j++]; else s->pblocks[i] = NULL; cbp += cbp; @@ -285,9 +285,9 @@ void ff_xvmc_decode_mb(MpegEncContext *s) if (s->flags & CODEC_FLAG_GRAY) { if (s->mb_intra) { // intra frames are always full chroma blocks for (i = 4; i < blocks_per_mb; i++) { - memset(s->pblocks[i], 0, sizeof(*s->pblocks[i])*64); // so we need to clear them + memset(s->pblocks[i], 0, sizeof(*s->pblocks[i])); // so we need to clear them if (!render->unsigned_intra) - s->pblocks[i][0] = 1 << 10; + *s->pblocks[i][0] = 1 << 10; } } else { cbp &= 0xf << (blocks_per_mb - 4); @@ -302,9 +302,9 @@ void ff_xvmc_decode_mb(MpegEncContext *s) if (s->block_last_index[i] >= 0) { // I do not have unsigned_intra MOCO to test, hope it is OK. if (s->mb_intra && (render->idct || (!render->idct && !render->unsigned_intra))) - s->pblocks[i][0] -= 1 << 10; + *s->pblocks[i][0] -= 1 << 10; if (!render->idct) { - s->dsp.idct(s->pblocks[i]); + s->dsp.idct(*s->pblocks[i]); /* It is unclear if MC hardware requires pixel diff values to be * in the range [-255;255]. TODO: Clipping if such hardware is * ever found. As of now it would only be an unnecessary @@ -313,7 +313,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s) // copy blocks only if the codec doesn't support pblocks reordering if (s->avctx->xvmc_acceleration == 1) { memcpy(&render->data_blocks[render->next_free_data_block_num*64], - s->pblocks[i], sizeof(*s->pblocks[i])*64); + s->pblocks[i], sizeof(*s->pblocks[i])); } render->next_free_data_block_num++; }