#ifndef _JPEG_ENCODE_H__ #define _JPEG_ENCODE_H__ #include #include #include #include "NvJpegEncoder.h" #include "NvVideoConverter.h" typedef struct { NvVideoConverter *conv; NvJPEGEncoder *jpegenc; char *in_file_path; std::ifstream * in_file; uint32_t in_width; uint32_t in_height; uint32_t in_pixfmt; char *out_file_path; std::ofstream * out_file; bool got_error; bool use_fd; bool perf; uint32_t crop_left; uint32_t crop_top; uint32_t crop_width; uint32_t crop_height; int stress_test; bool scaled_encode; uint32_t scale_width; uint32_t scale_height; int quality; } jpeg_encode_context_t; class JpegEncode { public: JpegEncode(); ~JpegEncode(); int JpegEncodeOneFrame(int width, int height, char* frameData, char *path); ///< 输入图片格式必须为yuv420m private: void set_defaults(jpeg_encode_context_t * ctx, int width, int height); int read_video_frame(char* frameData, NvBuffer & buffer); private: jpeg_encode_context_t m_ctx; #define TEST_ERROR(cond, str, label) if(cond) { \ std::cerr << str << std::endl; \ error = 1; \ goto label; } #define PERF_LOOP 300 }; #endif //_JPEG_ENCODE_H__