[svn] / branches / release-1_3-branch / xvidcore / src / bitstream / bitstream.c Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/src/bitstream/bitstream.c

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

revision 1610, Sun Apr 10 00:27:25 2005 UTC revision 1616, Tue May 17 21:03:32 2005 UTC
# Line 20  Line 20 
20   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
21   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   *   *
23   * $Id: bitstream.c,v 1.50 2005-04-10 00:27:25 suxen_drol Exp $   * $Id: bitstream.c,v 1.51 2005-05-17 21:03:32 Skal Exp $
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
# Line 33  Line 33 
33  #include "mbcoding.h"  #include "mbcoding.h"
34    
35    
36  static uint32_t __inline  static const uint8_t log2_tab_16[256] =  { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 };
37  log2bin(uint32_t value)  
38    static uint32_t __inline log2bin(uint32_t value)
39  {  {
40          int n = 0;          int n = 0;
41      if (value & 0xffff0000) {
42          while (value) {      value >>= 16;
43                  value >>= 1;      n += 16;
44                  n++;    }
45      if (value & 0xff00) {
46        value >>= 8;
47        n += 8;
48      }
49      if (value & 0xf0) {
50        value >>= 4;
51        n += 4;
52          }          }
53          return n;   return n + log2_tab_16[value];
54  }  }
55    
   
56  static const uint32_t intra_dc_threshold_table[] = {  static const uint32_t intra_dc_threshold_table[] = {
57          32,                                                     /* never use */          32,                                                     /* never use */
58          13,          13,
# Line 1401  Line 1408 
1408          }          }
1409    
1410  }  }
1411    
1412    /*
1413     * Group of VOP
1414     */
1415    void
1416    BitstreamWriteGroupOfVopHeader(Bitstream * const bs,
1417                                   const MBParam * pParam,
1418                                   uint32_t is_closed_gov)
1419    {
1420      int64_t time = (pParam->m_stamp + (pParam->fbase/2)) / pParam->fbase;
1421      int hours, minutes, seconds;
1422    
1423      /* compute time_code */
1424      seconds = time % 60; time /= 60;
1425      minutes = time % 60; time /= 60;
1426      hours = time % 24; /* don't overflow */
1427    
1428      BitstreamPutBits(bs, GRPOFVOP_START_CODE, 32);
1429      BitstreamPutBits(bs, hours, 5);
1430      BitstreamPutBits(bs, minutes, 6);
1431      BitstreamPutBit(bs, 1);
1432      BitstreamPutBits(bs, seconds, 6);
1433      BitstreamPutBits(bs, is_closed_gov, 1);
1434      BitstreamPutBits(bs, 0, 1); /* broken_link */
1435    }
1436    
1437    /*
1438     * End of Sequence
1439     */
1440    void
1441    BitstreamWriteEndOfSequence(Bitstream * const bs)
1442    {
1443        BitstreamPadAlways(bs);
1444        BitstreamPutBits(bs, VISOBJSEQ_STOP_CODE, 32);
1445    }
1446    
1447    /*
1448     * Video Packet (resync marker)
1449     */
1450    
1451    void write_video_packet_header(Bitstream * const bs,
1452                                   const MBParam * pParam,
1453                                   const FRAMEINFO * const frame,
1454                                   int mbnum)
1455    {
1456        const int mbnum_bits = log2bin(pParam->mb_width *  pParam->mb_height - 1);
1457        uint32_t nbitsresyncmarker;
1458        int addbits=0;
1459        if (frame->coding_type != I_VOP)
1460            addbits = frame->fcode -1;
1461        if (frame->coding_type == B_VOP)
1462            addbits = MAX(frame->fcode, frame->bcode)-1;
1463        BitstreamPadAlways(bs);
1464        nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER + addbits;
1465        BitstreamPutBits(bs, RESYNC_MARKER, nbitsresyncmarker);
1466        BitstreamPutBits(bs, mbnum, mbnum_bits);
1467        BitstreamPutBits(bs, frame->quant, 5);
1468        BitstreamPutBit(bs, 0); /* hec */
1469    }

Legend:
Removed from v.1610  
changed lines
  Added in v.1616

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