Guest User

Untitled

a guest
Dec 27th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #ifndef __X264_ENCODER_H
  2. #define __X264_ENCODER_H
  3.  
  4. #ifdef __cplusplus
  5. #define __STDINT_MACROS
  6. #define __STDC_CONSTANT_MACROS
  7. #endif
  8.  
  9. #include <iostream>
  10. #include <queue>
  11. #include <stdint.h>
  12.  
  13. extern "C" {
  14. #include <x264.h>
  15. }
  16.  
  17. #define RGB2YUV_SHIFT 15
  18. #define BY ((int)( 0.098 * (1 << RGB2YUV_SHIFT) + 0.5))
  19. #define BV ((int)(-0.071 * (1 << RGB2YUV_SHIFT) + 0.5))
  20. #define BU ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5))
  21. #define GY ((int)( 0.504 * (1 << RGB2YUV_SHIFT) + 0.5))
  22. #define GV ((int)(-0.368 * (1 << RGB2YUV_SHIFT) + 0.5))
  23. #define GU ((int)(-0.291 * (1 << RGB2YUV_SHIFT) + 0.5))
  24. #define RY ((int)( 0.257 * (1 << RGB2YUV_SHIFT) + 0.5))
  25. #define RV ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5))
  26. #define RU ((int)(-0.148 * (1 << RGB2YUV_SHIFT) + 0.5))
  27.  
  28. #define Y_CONST ((33 << (RGB2YUV_SHIFT - 1)) >> RGB2YUV_SHIFT)
  29. #define UV_CONST ((257 << (RGB2YUV_SHIFT - 1)) >> RGB2YUV_SHIFT)
  30.  
  31. class x264Encoder
  32. {
  33. public:
  34. x264Encoder(void);
  35. ~x264Encoder(void);
  36.  
  37. public:
  38. void initilize();
  39. void unInitilize();
  40. void encodeFrame(char* image);
  41. void encodeFrame_no_convert(char* image);
  42. bool isNalsAvailableInOutputQueue();
  43. x264_nal_t getNalUnit();
  44. private:
  45. std::queue<x264_nal_t> outputQueue;
  46. x264_param_t parameters;
  47. x264_picture_t picture_in,picture_out;
  48. x264_t* encoder;
  49. char* yuvbasef;
  50. };
  51.  
  52. #endif
Advertisement
Add Comment
Please, Sign In to add comment