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

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

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

revision 1.25.2.2, Thu Sep 26 01:54:54 2002 UTC revision 1.25.2.3, Sat Nov 2 15:52:30 2002 UTC
# Line 41  Line 41 
41    *                                                                                                                                                        *    *                                                                                                                                                        *
42    *  Revision history:                                                         *    *  Revision history:                                                         *
43    *                                                                            *    *                                                                            *
44      *  28.10.2002 GMC support - gruel                                                                                        *
45    *  28.06.2002 added check_resync_marker()                                    *    *  28.06.2002 added check_resync_marker()                                    *
46    *  14.04.2002 bframe encoding                                                                                            *    *  14.04.2002 bframe encoding                                                                                            *
47    *  08.03.2002 initial version; isibaar                                                           *    *  08.03.2002 initial version; isibaar                                                           *
# Line 67  Line 68 
68  VLC DCT3Dintra[4096];  VLC DCT3Dintra[4096];
69  VLC DCT3Dinter[4096];  VLC DCT3Dinter[4096];
70    
71    /* not really MB related, but VLCs are only available here */
72    void inline bs_put_spritetrajectory(Bitstream * bs,
73                              const int val)
74    {
75            const int code = sprite_trajectory_code[val+16384].code;
76            const int len = sprite_trajectory_code[val+16384].len;
77            const int code2 = sprite_trajectory_len[len].code;
78            const int len2 = sprite_trajectory_len[len].len;
79    
80    //      printf("GMC=%d Code/Len  = %d / %d ",val, code,len);
81    //      printf("Code2 / Len2 = %d / %d \n",code2,len2);
82    
83            BitstreamPutBits(bs, code2, len2);
84            if (len) BitstreamPutBits(bs, code, len);
85    }
86    
87    
88  void  void
89  init_vlc_tables(void)  init_vlc_tables(void)
90  {  {
# Line 183  Line 201 
201          DCT3D[0] = DCT3Dinter;          DCT3D[0] = DCT3Dinter;
202          DCT3D[1] = DCT3Dintra;          DCT3D[1] = DCT3Dintra;
203    
204    
205    /* init sprite_trajectory tables */
206    /* even if GMC is not specified (it might be used later...) */
207    
208            sprite_trajectory_code[0+16384].code = 0;
209            sprite_trajectory_code[0+16384].len = 0;
210            for (k=0;k<14;k++)
211            {
212                    int limit = (1<<k);
213    
214                    for (i=-(2*limit-1); i<= -limit; i++)
215                    {
216                            sprite_trajectory_code[i+16384].code = (2*limit-1)+i;
217                            sprite_trajectory_code[i+16384].len = k+1;
218                    }
219    
220                    for (i=limit; i<= 2*limit-1; i++)
221                    {
222                            sprite_trajectory_code[i+16384].code = i;
223                            sprite_trajectory_code[i+16384].len = k+1;
224                    }
225            }
226  }  }
227    
228  static __inline void  static __inline void
# Line 281  Line 321 
321    
322    
323  static __inline void  static __inline void
324  CodeBlockIntra(const FRAMEINFO * frame,  CodeBlockIntra(const FRAMEINFO * const frame,
325                             const MACROBLOCK * pMB,                             const MACROBLOCK * pMB,
326                             int16_t qcoeff[6 * 64],                             int16_t qcoeff[6 * 64],
327                             Bitstream * bs,                             Bitstream * bs,
# Line 347  Line 387 
387    
388    
389  static void  static void
390  CodeBlockInter(const FRAMEINFO * frame,  CodeBlockInter(const FRAMEINFO * const frame,
391                             const MACROBLOCK * pMB,                             const MACROBLOCK * pMB,
392                             int16_t qcoeff[6 * 64],                             int16_t qcoeff[6 * 64],
393                             Bitstream * bs,                             Bitstream * bs,
# Line 356  Line 396 
396    
397          int32_t i;          int32_t i;
398          uint32_t bits, mcbpc, cbpy;          uint32_t bits, mcbpc, cbpy;
399            int mcsel=0;
400    
401          mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3);          mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3);
402          cbpy = 15 - (pMB->cbp >> 2);          cbpy = 15 - (pMB->cbp >> 2);
# Line 364  Line 405 
405          BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code,          BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code,
406                                           mcbpc_inter_tab[mcbpc].len);                                           mcbpc_inter_tab[mcbpc].len);
407    
408            if ( (frame->coding_type == S_VOP) && (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) )
409            {
410                    if (frame->quarterpel) {
411                            if ( (pMB->qmvs[0].x == frame->GMC_MV.x) && (pMB->qmvs[0].y == frame->GMC_MV.y) )
412                                    mcsel=1;
413                    } else {
414                            if ( (pMB->mvs[0].x == frame->GMC_MV.x) && (pMB->mvs[0].y == frame->GMC_MV.y) )
415                                    mcsel=1;
416                    }
417                    BitstreamPutBit(bs, mcsel);             // mcsel: '0'=local motion, '1'=GMC
418            }
419    
420          // write cbpy          // write cbpy
421          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);
422    
# Line 390  Line 443 
443                          }                          }
444                  }                  }
445          }          }
446          // code motion vector(s)          // code motion vector(s) if motion is local
447            if (mcsel==0)
448          for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) {          for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) {
449                  CodeVector(bs, pMB->pmvs[i].x, frame->fcode, pStat);                  CodeVector(bs, pMB->pmvs[i].x, frame->fcode, pStat);
450                  CodeVector(bs, pMB->pmvs[i].y, frame->fcode, pStat);                  CodeVector(bs, pMB->pmvs[i].y, frame->fcode, pStat);
# Line 411  Line 465 
465    
466          bits = BitstreamPos(bs) - bits;          bits = BitstreamPos(bs) - bits;
467          pStat->iTextBits += bits;          pStat->iTextBits += bits;
   
468  }  }
469    
470    
471  void  void
472  MBCoding(const FRAMEINFO * frame,  MBCoding(const FRAMEINFO * const frame,
473                   MACROBLOCK * pMB,                   MACROBLOCK * pMB,
474                   int16_t qcoeff[6 * 64],                   int16_t qcoeff[6 * 64],
475                   Bitstream * bs,                   Bitstream * bs,
476                   Statistics * pStat)                   Statistics * pStat)
477  {  {
478            if (frame->coding_type != I_VOP)
479          if (frame->coding_type == P_VOP) {                          BitstreamPutBit(bs, 0); // not_coded
                         BitstreamPutBit(bs, 0); // coded  
         }  
480    
481          if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q)          if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q)
482                  CodeBlockIntra(frame, pMB, qcoeff, bs, pStat);                  CodeBlockIntra(frame, pMB, qcoeff, bs, pStat);

Legend:
Removed from v.1.25.2.2  
changed lines
  Added in v.1.25.2.3

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