Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __X264_ENCODER_H
- #define __X264_ENCODER_H
- #ifdef __cplusplus
- #define __STDINT_MACROS
- #define __STDC_CONSTANT_MACROS
- #endif
- #include <iostream>
- #include <queue>
- #include <stdint.h>
- extern "C" {
- #include <x264.h>
- }
- #define RGB2YUV_SHIFT 15
- #define BY ((int)( 0.098 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define BV ((int)(-0.071 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define BU ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define GY ((int)( 0.504 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define GV ((int)(-0.368 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define GU ((int)(-0.291 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define RY ((int)( 0.257 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define RV ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define RU ((int)(-0.148 * (1 << RGB2YUV_SHIFT) + 0.5))
- #define Y_CONST ((33 << (RGB2YUV_SHIFT - 1)) >> RGB2YUV_SHIFT)
- #define UV_CONST ((257 << (RGB2YUV_SHIFT - 1)) >> RGB2YUV_SHIFT)
- class x264Encoder
- {
- public:
- x264Encoder(void);
- ~x264Encoder(void);
- public:
- void initilize();
- void unInitilize();
- void encodeFrame(char* image);
- void encodeFrame_no_convert(char* image);
- bool isNalsAvailableInOutputQueue();
- x264_nal_t getNalUnit();
- private:
- std::queue<x264_nal_t> outputQueue;
- x264_param_t parameters;
- x264_picture_t picture_in,picture_out;
- x264_t* encoder;
- char* yuvbasef;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment