Change the type of pblocks from pointers to short array into
authorIvan Kalvachev <ikalvachev@gmail.com>
Sun, 22 Feb 2009 09:02:06 +0000 (09:02 +0000)
committerIvan Kalvachev <ikalvachev@gmail.com>
Sun, 22 Feb 2009 09:02:06 +0000 (09:02 +0000)
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
libavcodec/mpegvideo.c
libavcodec/mpegvideo.h
libavcodec/mpegvideo_xvmc.c

index 6cf0335..3438582 100644 (file)
@@ -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;i<mb_block_count;i++) {
-                    if (mpeg2_decode_block_intra(s, s->pblocks[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;i<mb_block_count;i++) {
                         if ( cbp & (1<<11) ) {
-                            if (mpeg2_decode_block_non_intra(s, s->pblocks[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;
 }
index 2eec211..06d842b 100644 (file)
@@ -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
 }
index 8f25ff3..8709dee 100644 (file)
@@ -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
index bff9543..b73a399 100644 (file)
@@ -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++;
         }