1
0

vlc.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*!
  2. ************************************************************************
  3. * \file vlc.h
  4. *
  5. * \brief
  6. * header for (CA)VLC coding functions
  7. *
  8. * \author
  9. * Karsten Suehring
  10. *
  11. ************************************************************************
  12. */
  13. #ifndef _VLC_H_
  14. #define _VLC_H_
  15. #include <bfc/platform/types.h>
  16. //! gives CBP value from codeword number, both for intra and inter
  17. static const byte NCBP[2][48][2]=
  18. {
  19. { // 0 1 2 3 4 5 6 7 8 9 10 11
  20. {15, 0},{ 0, 1},{ 7, 2},{11, 4},{13, 8},{14, 3},{ 3, 5},{ 5,10},{10,12},{12,15},{ 1, 7},{ 2,11},
  21. { 4,13},{ 8,14},{ 6, 6},{ 9, 9},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
  22. { 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
  23. { 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0}
  24. },
  25. {
  26. {47, 0},{31,16},{15, 1},{ 0, 2},{23, 4},{27, 8},{29,32},{30, 3},{ 7, 5},{11,10},{13,12},{14,15},
  27. {39,47},{43, 7},{45,11},{46,13},{16,14},{ 3, 6},{ 5, 9},{10,31},{12,35},{19,37},{21,42},{26,44},
  28. {28,33},{35,34},{37,36},{42,40},{44,39},{ 1,43},{ 2,45},{ 4,46},{ 8,17},{17,18},{18,20},{20,24},
  29. {24,19},{ 6,21},{ 9,26},{22,28},{25,23},{32,27},{33,29},{34,30},{36,22},{40,25},{38,38},{41,41}
  30. }
  31. };
  32. //! for the linfo_levrun_inter routine
  33. static const byte NTAB1[4][8][2] =
  34. {
  35. {{1,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
  36. {{1,1},{1,2},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
  37. {{2,0},{1,3},{1,4},{1,5},{0,0},{0,0},{0,0},{0,0}},
  38. {{3,0},{2,1},{2,2},{1,6},{1,7},{1,8},{1,9},{4,0}},
  39. };
  40. static const byte LEVRUN1[16]=
  41. {
  42. 4,2,2,1,1,1,1,1,1,1,0,0,0,0,0,0,
  43. };
  44. static const byte NTAB2[4][8][2] =
  45. {
  46. {{1,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
  47. {{1,1},{2,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
  48. {{1,2},{3,0},{4,0},{5,0},{0,0},{0,0},{0,0},{0,0}},
  49. {{1,3},{1,4},{2,1},{3,1},{6,0},{7,0},{8,0},{9,0}},
  50. };
  51. //! for the linfo_levrun__c2x2 routine
  52. static const byte LEVRUN3[4] =
  53. {
  54. 2,1,0,0
  55. };
  56. static const byte NTAB3[2][2][2] =
  57. {
  58. {{1,0},{0,0}},
  59. {{2,0},{1,1}},
  60. };
  61. extern int se_v (const char *tracestring, Bitstream *bitstream);
  62. extern int ue_v (const char *tracestring, Bitstream *bitstream);
  63. extern Boolean u_1 (const char *tracestring, Bitstream *bitstream);
  64. extern int u_v (int LenInBits, const char *tracestring, Bitstream *bitstream);
  65. extern int i_v (int LenInBits, const char *tracestring, Bitstream *bitstream);
  66. // CAVLC mapping
  67. extern void linfo_ue(int len, int info, int *value1, int *dummy);
  68. extern void linfo_se(int len, int info, int *value1, int *dummy);
  69. extern void linfo_cbp_intra_normal(int len,int info,int *cbp, int *dummy);
  70. extern void linfo_cbp_inter_normal(int len,int info,int *cbp, int *dummy);
  71. extern void linfo_cbp_intra_other(int len,int info,int *cbp, int *dummy);
  72. extern void linfo_cbp_inter_other(int len,int info,int *cbp, int *dummy);
  73. extern void linfo_levrun_inter(int len,int info,int *level,int *irun);
  74. extern void linfo_levrun_c2x2(int len,int info,int *level,int *irun);
  75. extern int uvlc_startcode_follows(Slice *currSlice, int dummy);
  76. extern int readSyntaxElement_VLC (SyntaxElement *sym, Bitstream *currStream);
  77. extern int readSyntaxElement_UVLC(SyntaxElement *, struct datapartition *);
  78. extern int readSyntaxElement_Intra4x4PredictionMode(SyntaxElement *sym, Bitstream *currStream);
  79. extern int GetVLCSymbol (const uint8_t buffer[],int totbitoffset,int *info, int bytecount);
  80. extern int GetVLCSymbol_IntraMode (const uint8_t buffer[],int totbitoffset,int *info, int bytecount);
  81. extern int readSyntaxElement_FLC (Bitstream *currStream, int numbits);
  82. extern int readSyntaxElement_NumCoeffTrailingOnes (SyntaxElement *sym, Bitstream *currStream, int vlcnum);
  83. extern int readSyntaxElement_NumCoeffTrailingOnesChromaDC(VideoParameters *p_Vid, SyntaxElement *sym, Bitstream *currStream);
  84. extern int readSyntaxElement_Level_VLC0 (Bitstream *currStream);
  85. extern int readSyntaxElement_Level_VLCN (int vlc, Bitstream *currStream);
  86. extern int readSyntaxElement_TotalZeros (Bitstream *currStream, int vlcnum);
  87. extern int readSyntaxElement_TotalZerosChromaDC (VideoParameters *p_Vid, Bitstream *currStream, int vlcnum);
  88. extern int readSyntaxElement_Run (Bitstream *currStream, int vlcnum);
  89. extern int GetBits (const uint8_t buffer[],int totbitoffset,int *info, int bitcount, int numbits);
  90. extern int more_rbsp_data (const uint8_t buffer[],int totbitoffset,int bytecount);
  91. int code_from_bitstream_2d_17_4_c(SyntaxElement *sym, Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
  92. int code_from_bitstream_2d_17_4_sse2(SyntaxElement *sym, Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
  93. int code_from_bitstream_2d_5_4_c(SyntaxElement *sym, Bitstream *currStream, const uint8_t *lentab, const uint8_t *codtab, const uint8_t *masktab);
  94. int code_from_bitstream_2d_5_4_sse2(SyntaxElement *sym, Bitstream *currStream, const uint8_t *lentab, const uint8_t *codtab, const uint8_t *masktab);
  95. int code_from_bitstream_2d_16_1_c(Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
  96. int code_from_bitstream_2d_16_1_sse2(Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
  97. #endif