You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.0KB

  1. #ifndef _mpeg4_avc_h_
  2. #define _mpeg4_avc_h_
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #if defined(__cplusplus)
  6. extern "C" {
  7. #endif
  8. struct mpeg4_avc_t
  9. {
  10. // uint8_t version; // 1-only
  11. uint8_t profile;
  12. uint8_t compatibility; // constraint_set[0-5]_flag
  13. uint8_t level;
  14. uint8_t nalu; // NALUnitLength = (lengthSizeMinusOne + 1), default 4(0x03+1)
  15. uint8_t nb_sps;
  16. uint8_t nb_pps;
  17. struct mpeg4_avc_sps_t
  18. {
  19. uint16_t bytes;
  20. uint8_t* data;
  21. } sps[32]; // [0-31]
  22. struct mpeg4_avc_pps_t
  23. {
  24. uint16_t bytes;
  25. uint8_t* data;
  26. } pps[256];
  27. // extension
  28. uint8_t chroma_format_idc;
  29. uint8_t bit_depth_luma_minus8;
  30. uint8_t bit_depth_chroma_minus8;
  31. uint8_t data[4 * 1024];
  32. size_t off;
  33. };
  34. int mpeg4_avc_decoder_configuration_record_load(const uint8_t* data, size_t bytes, struct mpeg4_avc_t* avc);
  35. int mpeg4_avc_decoder_configuration_record_save(const struct mpeg4_avc_t* avc, uint8_t* data, size_t bytes);
  36. int mpeg4_avc_to_nalu(const struct mpeg4_avc_t* avc, uint8_t* data, size_t bytes);
  37. int mpeg4_avc_codecs(const struct mpeg4_avc_t* avc, char* codecs, size_t bytes);
  38. /// @param[out] vcl 0-non VCL, 1-IDR, 2-P/B
  39. /// @return <=0-error, >0-output bytes
  40. int h264_annexbtomp4(struct mpeg4_avc_t* avc, const void* data, size_t bytes, void* out, size_t size, int* vcl, int* update);
  41. /// @return <=0-error, >0-output bytes
  42. int h264_mp4toannexb(const struct mpeg4_avc_t* avc, const void* data, size_t bytes, void* out, size_t size);
  43. /// h264_is_new_access_unit H.264 new access unit(frame)
  44. /// @return 1-new access, 0-not a new access
  45. int h264_is_new_access_unit(const uint8_t* nalu, size_t bytes);
  46. /// H.264 nal unit split
  47. int mpeg4_h264_annexb_nalu(const void* h264, size_t bytes, void (*handler)(void* param, const uint8_t* nalu, size_t bytes), void* param);
  48. /// Detect H.264 bitstrem type: H.264 Annexb or MP4-AVCC
  49. /// @return 0-annexb, >0-avcc length, <0-error
  50. int mpeg4_h264_bitstream_format(const uint8_t* h264, size_t bytes);
  51. #if defined(__cplusplus)
  52. }
  53. #endif
  54. #endif /* !_mpeg4_avc_h_ */