h264_decoder.h 796 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * video_decoder.h
  3. *
  4. * Created on: 2022年1月15日
  5. * Author: pengzc
  6. */
  7. #ifndef JNI_CALL_VIDEO_DECODER_H_
  8. #define JNI_CALL_VIDEO_DECODER_H_
  9. #include <stdint.h>
  10. namespace voip {
  11. class H264Decoder {
  12. public:
  13. struct ImageData {
  14. int width;
  15. int height;
  16. uint8_t* data[3];
  17. };
  18. public:
  19. H264Decoder();
  20. virtual ~H264Decoder();
  21. int Initialize();
  22. /**
  23. * 解码H264流
  24. * 如果成功解出一帧图像,则返回0,图像数据保存到img
  25. *
  26. * 每次调用必须传入完整的一个nal
  27. */
  28. int DecodeFrame(uint8_t* nalu, int nalu_len, ImageData* img);
  29. /**
  30. * 将图像转为NV21格式
  31. */
  32. int ToNV21(const ImageData& img, uint8_t* nv21);
  33. private:
  34. class Impl;
  35. Impl* impl_;
  36. };
  37. } /* namespace base */
  38. #endif /* JNI_CALL_VIDEO_DECODER_H_ */