You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// if(params.hw_decode_available){
// for(int i = 0; i < params.batch_size; i++){
// // extract bitstream meta data to figure out whether a bit-stream can be decoded
// nvjpegJpegStreamParseHeader(params.nvjpeg_handle, (const unsigned char *)img_data[i].data(), img_len[i], params.jpeg_streams[0]);
// int isSupported = -1;
// nvjpegDecodeBatchedSupported(params.nvjpeg_handle, params.jpeg_streams[0], &isSupported);
GPU硬解码在编解码速度上是比CPU快的,但是处理过程中多了 host to device 和 device to host 内存复制时间。所以在处理小图片的速度不理想。由于GPU核心数远远多于CPU核心数,所以使用多线程也有利于获得更好的结果。
与官方demo 使用的api不一样
pynvjpeg旨在使用nvjpeg的编解码功能,实现兼容opencv的接口。
English Translation
Why the decoding time is similar?
GPU hard decoding is faster than CPU in encoding and decoding process, but there is a process names host to device or device to host memory copying spends time. For the reason, the decoding/encoding time is similar, especially decoding/encoding small pictures . Using multi-threading, The GPU should got the more better score than CPU.
The API is different from the official demo
PyNvjpeg is designed to be compatible with OpenCV.
Activity
hacktmz commentedon Jun 8, 2021
然后官方的解码demo 是这样写的,里面的api为什么跟pynvjpeg完全不一样
int decode_images(const FileData &img_data, const std::vector<size_t> &img_len,
std::vector<nvjpegImage_t> &out, decode_params_t ¶ms,
double &time) {
CHECK_CUDA(cudaStreamSynchronize(params.stream));
cudaEvent_t startEvent = NULL, stopEvent = NULL;
float loopTime = 0;
CHECK_CUDA(cudaEventCreate(&startEvent, cudaEventBlockingSync));
CHECK_CUDA(cudaEventCreate(&stopEvent, cudaEventBlockingSync));
std::vector<const unsigned char*> batched_bitstreams;
std::vector<size_t> batched_bitstreams_size;
std::vector<nvjpegImage_t> batched_output;
// bit-streams that batched decode cannot handle
std::vector<const unsigned char*> otherdecode_bitstreams;
std::vector<size_t> otherdecode_bitstreams_size;
std::vector<nvjpegImage_t> otherdecode_output;
// if(params.hw_decode_available){
// for(int i = 0; i < params.batch_size; i++){
// // extract bitstream meta data to figure out whether a bit-stream can be decoded
// nvjpegJpegStreamParseHeader(params.nvjpeg_handle, (const unsigned char *)img_data[i].data(), img_len[i], params.jpeg_streams[0]);
// int isSupported = -1;
// nvjpegDecodeBatchedSupported(params.nvjpeg_handle, params.jpeg_streams[0], &isSupported);
// if(isSupported == 0){
// batched_bitstreams.push_back((const unsigned char *)img_data[i].data());
// batched_bitstreams_size.push_back(img_len[i]);
// batched_output.push_back(out[i]);
// } else {
// otherdecode_bitstreams.push_back((const unsigned char *)img_data[i].data());
// otherdecode_bitstreams_size.push_back(img_len[i]);
// otherdecode_output.push_back(out[i]);
// }
// }
// } else {
for(int i = 0; i < params.batch_size; i++) {
otherdecode_bitstreams.push_back((const unsigned char *)img_data[i].data());
otherdecode_bitstreams_size.push_back(img_len[i]);
otherdecode_output.push_back(out[i]);
}
// }
CHECK_CUDA(cudaEventRecord(startEvent, params.stream));
CHECK_CUDA(cudaEventRecord(stopEvent, params.stream));
CHECK_CUDA(cudaEventSynchronize(stopEvent));
CHECK_CUDA(cudaEventElapsedTime(&loopTime, startEvent, stopEvent));
time = static_cast(loopTime);
return EXIT_SUCCESS;
}
zeng-qinghui commentedon Jun 8, 2021
为什么测试解码提升很小?
GPU硬解码在编解码速度上是比CPU快的,但是处理过程中多了 host to device 和 device to host 内存复制时间。所以在处理小图片的速度不理想。由于GPU核心数远远多于CPU核心数,所以使用多线程也有利于获得更好的结果。
与官方demo 使用的api不一样
pynvjpeg旨在使用nvjpeg的编解码功能,实现兼容opencv的接口。
Why the decoding time is similar?
GPU hard decoding is faster than CPU in encoding and decoding process, but there is a process names host to device or device to host memory copying spends time. For the reason, the decoding/encoding time is similar, especially decoding/encoding small pictures . Using multi-threading, The GPU should got the more better score than CPU.
The API is different from the official demo
PyNvjpeg is designed to be compatible with OpenCV.