[svn] / trunk / xvidcore / src / bitstream / mbcoding.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/bitstream/mbcoding.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 15, Sat Mar 9 15:29:26 2002 UTC revision 69, Tue Mar 26 11:16:08 2002 UTC
# Line 5  Line 5 
5    
6  #include "../utils/mbfunctions.h"  #include "../utils/mbfunctions.h"
7    
8    #include <stdlib.h> /* malloc, free */
9    
10  #define ESCAPE 7167  #define ESCAPE 7167
11  #define ABS(X) (((X)>0)?(X):-(X))  #define ABS(X) (((X)>0)?(X):-(X))
12  #define CLIP(X,A) (X > A) ? (A) : (X)  #define CLIP(X,A) (X > A) ? (A) : (X)
# Line 54  Line 56 
56                          char *max_run_ptr = max_run[last + (intra << 1)];                          char *max_run_ptr = max_run[last + (intra << 1)];
57    
58                          for(l = 0; l < 64; l++) { // run                          for(l = 0; l < 64; l++) { // run
59                                  int32_t level = k, run = l;                                  int32_t level = k;
60                                    uint32_t run = l;
61    
62                                  if(abs(level) <= max_level_ptr[run] && run <= max_run_ptr[abs(level)]) {                                  if(abs(level) <= max_level_ptr[run] && run <= max_run_ptr[abs(level)]) {
63    
# Line 263  Line 266 
266  {  {
267          uint32_t i, mcbpc, cbpy, bits;          uint32_t i, mcbpc, cbpy, bits;
268    
         mcbpc = pMB->cbp & 3;  
269          cbpy = pMB->cbp >> 2;          cbpy = pMB->cbp >> 2;
270    
271      // write mcbpc      // write mcbpc
272          if(pParam->coding_type == I_VOP)          if(pParam->coding_type == I_VOP) {
273                  BitstreamPutBits(bs, mcbpc_I[mcbpc].code, mcbpc_I[mcbpc].len);              mcbpc = ((pMB->mode >> 1) & 3) | ((pMB->cbp & 3) << 2);
274      else                  BitstreamPutBits(bs, mcbpc_intra_tab[mcbpc].code, mcbpc_intra_tab[mcbpc].len);
275                  BitstreamPutBits(bs, mcbpc_P_intra[mcbpc].code, mcbpc_P_intra[mcbpc].len);          }
276            else {
277                mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3);
278                    BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code, mcbpc_inter_tab[mcbpc].len);
279            }
280    
281          // ac prediction flag          // ac prediction flag
282          if(pMB->acpred_directions[0])          if(pMB->acpred_directions[0])
# Line 285  Line 291 
291      if(pMB->mode == MODE_INTRA_Q)      if(pMB->mode == MODE_INTRA_Q)
292                  BitstreamPutBits(bs, pMB->dquant, 2);                  BitstreamPutBits(bs, pMB->dquant, 2);
293    
294            // write interlacing
295            if (pParam->global_flags & XVID_INTERLACING)
296            {
297                    BitstreamPutBit(bs, pMB->field_dct);
298            }
299    
300          // code block coeffs          // code block coeffs
301          for(i = 0; i < 6; i++)          for(i = 0; i < 6; i++)
302          {          {
# Line 314  Line 326 
326          int32_t i;          int32_t i;
327          uint32_t bits, mcbpc, cbpy;          uint32_t bits, mcbpc, cbpy;
328    
329          mcbpc = pMB->cbp & 3;      mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3);
330          cbpy = 15 - (pMB->cbp >> 2);          cbpy = 15 - (pMB->cbp >> 2);
331    
332          // write mcbpc          // write mcbpc
333      if(pMB->mode == MODE_INTER4V)      BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code, mcbpc_inter_tab[mcbpc].len);
                 BitstreamPutBits(bs, mcbpc_P_inter4v[mcbpc].code, mcbpc_P_inter4v[mcbpc].len);  
     else  
                 BitstreamPutBits(bs, mcbpc_P_inter[mcbpc].code, mcbpc_P_inter[mcbpc].len);  
334    
335          // write cbpy          // write cbpy
336          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);
# Line 330  Line 339 
339      if(pMB->mode == MODE_INTER_Q)      if(pMB->mode == MODE_INTER_Q)
340                  BitstreamPutBits(bs, pMB->dquant, 2);                  BitstreamPutBits(bs, pMB->dquant, 2);
341    
342            // interlacing
343            if (pParam->global_flags & XVID_INTERLACING)
344            {
345                    BitstreamPutBit(bs, pMB->field_dct);
346                    DEBUG1("codep: field_dct: ", pMB->field_dct);
347    
348                    // if inter block, write field ME flag
349                    if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)
350                    {
351                            BitstreamPutBit(bs, pMB->field_pred);
352                            DEBUG1("codep: field_pred: ", pMB->field_pred);
353    
354                            // write field prediction references
355                            if (pMB->field_pred)
356                            {
357                                    BitstreamPutBit(bs, pMB->field_for_top);
358                                    BitstreamPutBit(bs, pMB->field_for_bot);
359                            }
360                    }
361            }
362    
363          // code motion vector(s)          // code motion vector(s)
364          for(i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++)          for(i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++)
365          {          {

Legend:
Removed from v.15  
changed lines
  Added in v.69

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4