[FFmpeg-devel] MPEG-2 Acceleration Refactor

Greg Hulands ghulands
Sun Jun 17 03:44:21 CEST 2007


Based on the START/STOP_TIMER stuff showing the patch is actually  
faster I have tidied the patch a little more and removed the function  
prototypes to the _fast functions at the top of the file.

If there are any other problems from stopping this getting committed,  
please let me know.

Thanks,
Greg

Index: mpeg12.c
===================================================================
--- mpeg12.c	(revision 9339)
+++ mpeg12.c	(working copy)
@@ -47,25 +47,25 @@
#ifdef CONFIG_ENCODERS
static void mpeg1_encode_block(MpegEncContext *s,
-                         DCTELEM *block,
-                         int component);
+                               DCTELEM *block,
+                               int component);
static void mpeg1_encode_motion(MpegEncContext *s, int val, int  
f_or_b_code);    // RAL: f_code parameter added
#endif //CONFIG_ENCODERS
static inline int mpeg1_decode_block_inter(MpegEncContext *s,
-                              DCTELEM *block,
-                              int n);
+                                           DCTELEM *block,
+                                           int n,
+                                           int fast);
static inline int mpeg1_decode_block_intra(MpegEncContext *s,
-                              DCTELEM *block,
-                              int n);
-static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s,  
DCTELEM *block, int n);
+                                           DCTELEM *block,
+                                           int n);
static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
-                                        DCTELEM *block,
-                                        int n);
+                                               DCTELEM *block,
+                                               int n,
+                                               int fast);
static inline int mpeg2_decode_block_intra(MpegEncContext *s,
-                                    DCTELEM *block,
-                                    int n);
-static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext  
*s, DCTELEM *block, int n);
-static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s,  
DCTELEM *block, int n);
+                                           DCTELEM *block,
+                                           int n,
+                                           int fast);
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred);
static void exchange_uv(MpegEncContext *s);
@@ -1154,7 +1154,7 @@
              if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv 
[1][0][1])==0)
                  s->mb_skipped = 1;
          }
-
+
          return 0;
      }
@@ -1229,15 +1229,15 @@
              }
          }
#endif
-
+		
          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_decode_block_intra(s, s->pblocks[i], i, 1);
                  }
              }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) < 0)
                          return -1;
                  }
              }
@@ -1440,12 +1440,12 @@
                  }
              }
#endif
-
+			
              if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
                  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_decode_block_non_intra(s, s- 
 >pblocks[i], i, 1);
                          } else {
                              s->block_last_index[i] = -1;
                          }
@@ -1456,7 +1456,7 @@
                      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) < 0)
                                  return -1;
                          } else {
                              s->block_last_index[i] = -1;
@@ -1468,7 +1468,7 @@
                  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_decode_block_inter(s, s->pblocks 
[i], i, 1);
                          } else {
                              s->block_last_index[i] = -1;
                          }
@@ -1477,7 +1477,7 @@
                  }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) < 0)
                                  return -1;
                          } else {
                              s->block_last_index[i] = -1;
@@ -1493,7 +1493,6 @@
      }
      s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=  
mb_type;
-
      return 0;
}
@@ -1550,8 +1549,8 @@
}
static inline int mpeg1_decode_block_intra(MpegEncContext *s,
-                               DCTELEM *block,
-                               int n)
+                                           DCTELEM *block,
+                                           int n)
{
      int level, dc, diff, i, j, run;
      int component;
@@ -1559,7 +1558,7 @@
      uint8_t * const scantable= s->intra_scantable.permutated;
      const uint16_t *quant_matrix= s->intra_matrix;
      const int qscale= s->qscale;
-
+
      /* DC coef */
      component = (n <= 3 ? 0 : n - 4 + 1);
      diff = decode_dc(&s->gb, component);
@@ -1577,7 +1576,7 @@
          for(;;) {
              UPDATE_CACHE(re, &s->gb);
              GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],  
TEX_VLC_BITS, 2, 0);
-
+
              if(level == 127){
                  break;
              } else if(level != 0) {
@@ -1613,107 +1612,38 @@
                  av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at % 
d %d\n", s->mb_x, s->mb_y);
                  return -1;
              }
-
+
              block[j] = level;
          }
          CLOSE_READER(re, &s->gb);
      }
      s->block_last_index[n] = i;
-   return 0;
-}
-
-static inline int mpeg1_decode_block_inter(MpegEncContext *s,
-                               DCTELEM *block,
-                               int n)
-{
-    int level, i, j, run;
-    RLTable *rl = &rl_mpeg1;
-    uint8_t * const scantable= s->intra_scantable.permutated;
-    const uint16_t *quant_matrix= s->inter_matrix;
-    const int qscale= s->qscale;
-
-    {
-        OPEN_READER(re, &s->gb);
-        i = -1;
-        /* special case for the first coef. no need to add a second  
vlc table */
-        UPDATE_CACHE(re, &s->gb);
-        if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
-            level= (3*qscale*quant_matrix[0])>>5;
-            level= (level-1)|1;
-            if(GET_CACHE(re, &s->gb)&0x40000000)
-                level= -level;
-            block[0] = level;
-            i++;
-            SKIP_BITS(re, &s->gb, 2);
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                goto end;
-        }
-
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],  
TEX_VLC_BITS, 2, 0);
-
-            if(level != 0) {
-                i += run;
-                j = scantable[i];
-                level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                level= (level-1)|1;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -  
SHOW_SBITS(re, &s->gb, 1);
-                SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS 
(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s- 
 >gb, 8);
-                if (level == -128) {
-                    level = SHOW_UBITS(re, &s->gb, 8) - 256;  
SKIP_BITS(re, &s->gb, 8);
-                } else if (level == 0) {
-                    level = SHOW_UBITS(re, &s->gb, 8)      ;  
SKIP_BITS(re, &s->gb, 8);
-                }
-                i += run;
-                j = scantable[i];
-                if(level<0){
-                    level= -level;
-                    level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                    level= (level-1)|1;
-                    level= -level;
-                }else{
-                    level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                    level= (level-1)|1;
-                }
-            }
-            if (i > 63){
-                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d  
%d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-
-            block[j] = level;
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                break;
-            UPDATE_CACHE(re, &s->gb);
-        }
-end:
-        LAST_SKIP_BITS(re, &s->gb, 2);
-        CLOSE_READER(re, &s->gb);
-    }
-    s->block_last_index[n] = i;
      return 0;
}
-static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s,  
DCTELEM *block, int n)
+static inline int mpeg1_decode_block_inter(MpegEncContext *s,
+                                           DCTELEM *block,
+                                           int n,
+                                           int fast)
{
      int level, i, j, run;
      RLTable *rl = &rl_mpeg1;
      uint8_t * const scantable= s->intra_scantable.permutated;
      const int qscale= s->qscale;
-
+	const uint16_t *quant_matrix;
+	
+	if (!fast) quant_matrix= s->inter_matrix;
+	
      {
          OPEN_READER(re, &s->gb);
          i = -1;
          /* special case for the first coef. no need to add a second  
vlc table */
          UPDATE_CACHE(re, &s->gb);
          if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
-            level= (3*qscale)>>1;
+            if (fast)
+				level= (3*qscale)>>1;
+			else
+				level= (3*qscale*quant_matrix[0])>>5;
              level= (level-1)|1;
              if(GET_CACHE(re, &s->gb)&0x40000000)
                  level= -level;
@@ -1723,15 +1653,18 @@
              if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t) 
0xBFFFFFFF)
                  goto end;
          }
-
+
          /* now quantify & encode AC coefs */
          for(;;) {
              GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],  
TEX_VLC_BITS, 2, 0);
-
+
              if(level != 0) {
                  i += run;
                  j = scantable[i];
-                level= ((level*2+1)*qscale)>>1;
+                if (fast)
+					level= ((level*2+1)*qscale)>>1;
+				else
+					level= ((level*2+1)*qscale*quant_matrix[j])>>5;
                  level= (level-1)|1;
                  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -  
SHOW_SBITS(re, &s->gb, 1);
                  SKIP_BITS(re, &s->gb, 1);
@@ -1749,142 +1682,94 @@
                  j = scantable[i];
                  if(level<0){
                      level= -level;
-                    level= ((level*2+1)*qscale)>>1;
+                    if (fast)
+						level= ((level*2+1)*qscale)>>1;
+					else
+						level= ((level*2+1)*qscale*quant_matrix[j])>>5;
                      level= (level-1)|1;
                      level= -level;
                  }else{
-                    level= ((level*2+1)*qscale)>>1;
+                    if (fast)
+						level= ((level*2+1)*qscale)>>1;
+					else
+						level= ((level*2+1)*qscale*quant_matrix[j])>>5;
                      level= (level-1)|1;
                  }
              }
-
+			if (!fast) {
+				if (i > 63){
+					av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s- 
 >mb_x, s->mb_y);
+					return -1;
+				}
+			}
+			
              block[j] = level;
              if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t) 
0xBFFFFFFF)
                  break;
              UPDATE_CACHE(re, &s->gb);
          }
end:
-        LAST_SKIP_BITS(re, &s->gb, 2);
+            LAST_SKIP_BITS(re, &s->gb, 2);
          CLOSE_READER(re, &s->gb);
      }
      s->block_last_index[n] = i;
      return 0;
}
-
static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
-                               DCTELEM *block,
-                               int n)
+                                               DCTELEM *block,
+                                               int n,
+                                               int fast)
{
      int level, i, j, run;
      RLTable *rl = &rl_mpeg1;
      uint8_t * const scantable= s->intra_scantable.permutated;
-    const uint16_t *quant_matrix;
      const int qscale= s->qscale;
-    int mismatch;
-
-    mismatch = 1;
-
-    {
-        OPEN_READER(re, &s->gb);
-        i = -1;
-        if (n < 4)
-            quant_matrix = s->inter_matrix;
-        else
-            quant_matrix = s->chroma_inter_matrix;
-
-        /* special case for the first coef. no need to add a second  
vlc table */
-        UPDATE_CACHE(re, &s->gb);
-        if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
-            level= (3*qscale*quant_matrix[0])>>5;
-            if(GET_CACHE(re, &s->gb)&0x40000000)
-                level= -level;
-            block[0] = level;
-            mismatch ^= level;
-            i++;
-            SKIP_BITS(re, &s->gb, 2);
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                goto end;
-        }
-
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],  
TEX_VLC_BITS, 2, 0);
-
-            if(level != 0) {
-                i += run;
-                j = scantable[i];
-                level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -  
SHOW_SBITS(re, &s->gb, 1);
-                SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS 
(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s- 
 >gb, 12);
-
-                i += run;
-                j = scantable[i];
-                if(level<0){
-                    level= ((-level*2+1)*qscale*quant_matrix[j])>>5;
-                    level= -level;
-                }else{
-                    level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                }
-            }
-            if (i > 63){
-                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d  
%d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-
-            mismatch ^= level;
-            block[j] = level;
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                break;
-            UPDATE_CACHE(re, &s->gb);
-        }
-end:
-        LAST_SKIP_BITS(re, &s->gb, 2);
-        CLOSE_READER(re, &s->gb);
-    }
-    block[63] ^= (mismatch & 1);
-
-    s->block_last_index[n] = i;
-    return 0;
-}
-
-static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
-                               DCTELEM *block,
-                               int n)
-{
-    int level, i, j, run;
-    RLTable *rl = &rl_mpeg1;
-    uint8_t * const scantable= s->intra_scantable.permutated;
-    const int qscale= s->qscale;
+	const uint16_t *quant_matrix; // !fast
+	int mismatch;
+	
      OPEN_READER(re, &s->gb);
      i = -1;
-
+	
+	
+	if (!fast)
+	{
+		mismatch = 1;
+
+		if (n < 4)
+			quant_matrix = s->inter_matrix;
+		else
+			quant_matrix = s->chroma_inter_matrix;
+	}
+	
      /* special case for the first coef. no need to add a second vlc  
table */
      UPDATE_CACHE(re, &s->gb);
      if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
-        level= (3*qscale)>>1;
+        if (fast)
+			level= (3*qscale)>>1;
+		else
+			level= (3*qscale*quant_matrix[0])>>5;
          if(GET_CACHE(re, &s->gb)&0x40000000)
              level= -level;
          block[0] = level;
+		if (!fast) mismatch ^= level;
          i++;
          SKIP_BITS(re, &s->gb, 2);
          if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
              goto end;
      }
-
+
      /* now quantify & encode AC coefs */
      for(;;) {
          GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],  
TEX_VLC_BITS, 2, 0);
-
+
          if(level != 0) {
              i += run;
              j = scantable[i];
-            level= ((level*2+1)*qscale)>>1;
+            if (fast)
+				level= ((level*2+1)*qscale)>>1;
+			else
+				level= ((level*2+1)*qscale*quant_matrix[j])>>5;
              level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS 
(re, &s->gb, 1);
              SKIP_BITS(re, &s->gb, 1);
          } else {
@@ -1892,42 +1777,59 @@
              run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re,  
&s->gb, 6);
              UPDATE_CACHE(re, &s->gb);
              level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s- 
 >gb, 12);
-
+
              i += run;
              j = scantable[i];
              if(level<0){
-                level= ((-level*2+1)*qscale)>>1;
+                if (fast)
+					level= ((-level*2+1)*qscale)>>1;
+				else
+					level= ((-level*2+1)*qscale*quant_matrix[j])>>5;
                  level= -level;
              }else{
-                level= ((level*2+1)*qscale)>>1;
+                if (fast)
+					level= ((level*2+1)*qscale)>>1;
+				else
+					level= ((level*2+1)*qscale*quant_matrix[j])>>5;
              }
          }
-
+		
+		if (!fast) {
+			if (i > 63){
+				av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s- 
 >mb_x, s->mb_y);
+				return -1;
+			}
+			
+			mismatch ^= level;
+		}
+		
          block[j] = level;
+		
          if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
              break;
          UPDATE_CACHE(re, &s->gb);
      }
end:
-    LAST_SKIP_BITS(re, &s->gb, 2);
+        LAST_SKIP_BITS(re, &s->gb, 2);
      CLOSE_READER(re, &s->gb);
+	if (!fast) block[63] ^= (mismatch & 1);
      s->block_last_index[n] = i;
      return 0;
}
-
static inline int mpeg2_decode_block_intra(MpegEncContext *s,
-                               DCTELEM *block,
-                               int n)
+                                           DCTELEM *block,
+                                           int n,
+                                           int fast)
{
      int level, dc, diff, i, j, run;
      int component;
      RLTable *rl;
-    uint8_t * const scantable= s->intra_scantable.permutated;
+    uint8_t * scantable= s->intra_scantable.permutated; // could be  
const if (!fast)
      const uint16_t *quant_matrix;
      const int qscale= s->qscale;
-    int mismatch;
-
+	int mismatch;
+	
      /* DC coef */
      if (n < 4){
          quant_matrix = s->intra_matrix;
@@ -1943,26 +1845,33 @@
      dc += diff;
      s->last_dc[component] = dc;
      block[0] = dc << (3 - s->intra_dc_precision);
-    dprintf(s->avctx, "dc=%d\n", block[0]);
-    mismatch = block[0] ^ 1;
-    i = 0;
+	if (!fast) {
+		dprintf("dc=%d\n", block[0]);
+		mismatch = block[0] ^ 1;
+		i = 0;
+	}
      if (s->intra_vlc_format)
          rl = &rl_mpeg2;
      else
          rl = &rl_mpeg1;
-
+
      {
          OPEN_READER(re, &s->gb);
          /* now quantify & encode AC coefs */
          for(;;) {
              UPDATE_CACHE(re, &s->gb);
              GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],  
TEX_VLC_BITS, 2, 0);
-
+
              if(level == 127){
                  break;
              } else if(level != 0) {
-                i += run;
-                j = scantable[i];
+                if (fast) {
+					scantable += run;
+					j = *scantable;
+				} else {
+					i += run;
+					j = scantable[i];
+				}
                  level= (level*qscale*quant_matrix[j])>>4;
                  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -  
SHOW_SBITS(re, &s->gb, 1);
                  LAST_SKIP_BITS(re, &s->gb, 1);
@@ -1971,8 +1880,13 @@
                  run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS 
(re, &s->gb, 6);
                  UPDATE_CACHE(re, &s->gb);
                  level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re,  
&s->gb, 12);
-                i += run;
-                j = scantable[i];
+                if (fast) {
+					scantable += run;
+					j = *scantable;
+				} else {
+					i += run;
+					j = scantable[i];
+				}
                  if(level<0){
                      level= (-level*qscale*quant_matrix[j])>>4;
                      level= -level;
@@ -1980,92 +1894,23 @@
                      level= (level*qscale*quant_matrix[j])>>4;
                  }
              }
-            if (i > 63){
-                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d  
%d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-
-            mismatch^= level;
+			if (!fast) {
+				if (i > 63){
+					av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s- 
 >mb_x, s->mb_y);
+					return -1;
+				}
+				mismatch^= level;
+			}
              block[j] = level;
          }
          CLOSE_READER(re, &s->gb);
      }
-    block[63]^= mismatch&1;
-
-    s->block_last_index[n] = i;
+	if (!fast) block[63]^= mismatch&1;
+
+    s->block_last_index[n] = (fast ? scantable - s- 
 >intra_scantable.permutated : i);
      return 0;
}
-static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s,
-                               DCTELEM *block,
-                               int n)
-{
-    int level, dc, diff, j, run;
-    int component;
-    RLTable *rl;
-    uint8_t * scantable= s->intra_scantable.permutated;
-    const uint16_t *quant_matrix;
-    const int qscale= s->qscale;
-
-    /* DC coef */
-    if (n < 4){
-        quant_matrix = s->intra_matrix;
-        component = 0;
-    }else{
-        quant_matrix = s->chroma_intra_matrix;
-        component = (n&1) + 1;
-    }
-    diff = decode_dc(&s->gb, component);
-    if (diff >= 0xffff)
-        return -1;
-    dc = s->last_dc[component];
-    dc += diff;
-    s->last_dc[component] = dc;
-    block[0] = dc << (3 - s->intra_dc_precision);
-    if (s->intra_vlc_format)
-        rl = &rl_mpeg2;
-    else
-        rl = &rl_mpeg1;
-
-    {
-        OPEN_READER(re, &s->gb);
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            UPDATE_CACHE(re, &s->gb);
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],  
TEX_VLC_BITS, 2, 0);
-
-            if(level == 127){
-                break;
-            } else if(level != 0) {
-                scantable += run;
-                j = *scantable;
-                level= (level*qscale*quant_matrix[j])>>4;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -  
SHOW_SBITS(re, &s->gb, 1);
-                LAST_SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS 
(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s- 
 >gb, 12);
-                scantable += run;
-                j = *scantable;
-                if(level<0){
-                    level= (-level*qscale*quant_matrix[j])>>4;
-                    level= -level;
-                }else{
-                    level= (level*qscale*quant_matrix[j])>>4;
-                }
-            }
-
-            block[j] = level;
-        }
-        CLOSE_READER(re, &s->gb);
-    }
-
-    s->block_last_index[n] = scantable - s->intra_scantable.permutated;
-    return 0;
-}
-
typedef struct Mpeg1Context {
      MpegEncContext mpeg_enc_ctx;
      int mpeg_enc_ctx_allocated; /* true if decoding context  
allocated */
@@ -2625,7 +2470,6 @@
          if(s->avctx->xvmc_acceleration > 1)
              XVMC_init_block(s);//set s->block
#endif
-
          ret = mpeg_decode_mb(s, s->block);
          s->chroma_qscale= s->qscale;
@@ -3124,7 +2968,7 @@
          /* find start next code */
          start_code = -1;
          buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code);
-        if (start_code > 0x1ff){
+        if ((unsigned int)start_code > 0x1ff){
              if(s2->pict_type != B_TYPE || avctx->skip_frame <=  
AVDISCARD_DEFAULT){
                  if(avctx->thread_count > 1){
                      int i;





More information about the ffmpeg-devel mailing list