#pragma once #include #include #include #include #include "jpeg_image.h" namespace NVJpegDecoder { typedef std::vector OriginJpegImages; typedef std::vector JpegImages; class Decoder { public: Decoder():mDeviceId(-1) {} virtual ~Decoder(); Decoder(Decoder&) = delete; Decoder& operator=(Decoder&) = delete; bool BindDevice(int device_id=0); bool Read(const char* filename, JpegImage& image); bool Decode(std::string& imagedata , JpegImage& image); private: bool PrepareJpegImage(const std::string& image, JpegImage& output); void Destroy(); private: nvjpegHandle_t mHandle; nvjpegJpegState_t mState; int mDeviceId; cudaStream_t mStream; }; } // namespace NVJpegDecoder