logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

40 lines
802 B

#pragma once
#include <vector>
#include <string>
#include <cuda_runtime_api.h>
#include <nvjpeg.h>
#include "jpeg_image.h"
namespace NVJpegDecoder {
typedef std::vector<std::string> OriginJpegImages;
typedef std::vector<JpegImage> 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