H264PictureParameterSet.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*------------------------------------------------------------------------------
  2. -- --
  3. -- This software is confidential and proprietary and may be used --
  4. -- only as expressly authorized by a licensing agreement from --
  5. -- --
  6. -- Hantro Products Oy. --
  7. -- --
  8. -- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
  9. -- ALL RIGHTS RESERVED --
  10. -- --
  11. -- The entire notice above must be reproduced --
  12. -- on all copies and should not be removed. --
  13. -- --
  14. --------------------------------------------------------------------------------
  15. --
  16. -- Abstract : Picture Parameter Set handling
  17. --
  18. ------------------------------------------------------------------------------*/
  19. /*------------------------------------------------------------------------------
  20. 1. Include headers
  21. ------------------------------------------------------------------------------*/
  22. #include "H264PictureParameterSet.h"
  23. #include "H264NalUnit.h"
  24. /*------------------------------------------------------------------------------
  25. 2. External compiler flags
  26. --------------------------------------------------------------------------------
  27. --------------------------------------------------------------------------------
  28. 3. Module defines
  29. ------------------------------------------------------------------------------*/
  30. /*------------------------------------------------------------------------------
  31. 4. Local function prototypes
  32. ------------------------------------------------------------------------------*/
  33. /*------------------------------------------------------------------------------
  34. H264PicParameterInit
  35. ------------------------------------------------------------------------------*/
  36. void H264PicParameterSetInit(pps_s * pps)
  37. {
  38. pps->byteStream = ENCHW_YES;
  39. pps->picParameterSetId = 0;
  40. pps->seqParameterSetId = 0;
  41. pps->entropyCodingMode = ENCHW_NO;
  42. pps->picOrderPresent = ENCHW_NO;
  43. pps->numSliceGroupsMinus1 = 0;
  44. pps->numRefIdxL0ActiveMinus1 = 0;
  45. pps->numRefIdxL1ActiveMinus1 = 0;
  46. pps->weightedPred = ENCHW_NO;
  47. pps->weightedBipredIdc = 0;
  48. pps->picInitQpMinus26 = 0;
  49. pps->picInitQsMinus26 = 0;
  50. pps->chromaQpIndexOffset = 2;
  51. pps->deblockingFilterControlPresent = ENCHW_YES;
  52. pps->constIntraPred = ENCHW_NO;
  53. pps->redundantPicCntPresent = ENCHW_NO;
  54. pps->transform8x8Mode = ENCHW_NO;
  55. return;
  56. }
  57. /*------------------------------------------------------------------------------
  58. H264PicParameterSet
  59. ------------------------------------------------------------------------------*/
  60. void H264PicParameterSet(stream_s * stream, pps_s * pps)
  61. {
  62. /* Nal unit sytax */
  63. H264NalUnitHdr(stream, 1, PPSET, pps->byteStream);
  64. H264ExpGolombUnsigned(stream, pps->picParameterSetId);
  65. COMMENT("pic_parameter_set_id");
  66. H264ExpGolombUnsigned(stream, pps->seqParameterSetId);
  67. COMMENT("seq_parameter_set_id");
  68. H264NalBits(stream, (i32) pps->entropyCodingMode, 1);
  69. COMMENT("entropy_coding_mode_flag");
  70. H264NalBits(stream, (i32) pps->picOrderPresent, 1);
  71. COMMENT("pic_order_present_flag");
  72. H264ExpGolombUnsigned(stream, pps->numSliceGroupsMinus1);
  73. COMMENT("num_slice_groups_minus1");
  74. /* if( num_slice_groups_minus1 > 0 ) etc... not implementet yet */
  75. H264ExpGolombUnsigned(stream, pps->numRefIdxL0ActiveMinus1);
  76. COMMENT("num_ref_idx_l0_active_minus1");
  77. H264ExpGolombUnsigned(stream, pps->numRefIdxL1ActiveMinus1);
  78. COMMENT("num_ref_idx_l1_active_minus1");
  79. H264NalBits(stream, (i32) pps->weightedPred, 1);
  80. COMMENT("weighted_pred_flag");
  81. H264NalBits(stream, pps->weightedBipredIdc, 2);
  82. COMMENT("weighted_bipred_idc");
  83. H264ExpGolombSigned(stream, pps->picInitQpMinus26);
  84. COMMENT("pic_init_qp_minus26");
  85. H264ExpGolombSigned(stream, pps->picInitQsMinus26);
  86. COMMENT("pic_init_qs_minus26");
  87. H264ExpGolombSigned(stream, pps->chromaQpIndexOffset);
  88. COMMENT("chroma_qp_index_offset");
  89. H264NalBits(stream, (i32) pps->deblockingFilterControlPresent, 1);
  90. COMMENT("deblocking_filter_control_present_flag");
  91. H264NalBits(stream, (i32) pps->constIntraPred, 1);
  92. COMMENT("constrained_intra_pred_flag");
  93. H264NalBits(stream, (i32) pps->redundantPicCntPresent, 1);
  94. COMMENT("redundant_pic_cnt_present_flag");
  95. if (pps->transform8x8Mode == ENCHW_YES)
  96. {
  97. H264NalBits(stream, pps->transform8x8Mode, 1);
  98. COMMENT("transform_8x8_mode_flag");
  99. H264NalBits(stream, 0, 1);
  100. COMMENT("pic_scaling_matrix_present_flag");
  101. H264ExpGolombSigned(stream, pps->chromaQpIndexOffset);
  102. COMMENT("second_chroma_qp_index_offset");
  103. }
  104. H264NalUnitTrailinBits(stream, pps->byteStream);
  105. return;
  106. }