Skip to content
Snippets Groups Projects
Commit 0845736b authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Minor tidy

parent 4ec17b79
No related branches found
No related tags found
1 merge request!311Resolves #296 removal of NvPipe
......@@ -88,6 +88,10 @@ bool NvPipeEncoder::supports(ftl::codecs::codec_t codec) {
}
}
/*
* Create encoder params structure from packet and surface. Changes to these
* require a recreation of the encoder.
*/
static ftl::codecs::NvPipeEncoder::Parameters generateParams(const cv::cuda::GpuMat &in, const ftl::codecs::Packet &pkt) {
ftl::codecs::NvPipeEncoder::Parameters params;
params.bitrate = pkt.bitrate;
......@@ -116,6 +120,9 @@ static uint64_t calculateBitrate(definition_t def, float ratescale) {
return uint64_t((bitrate - minrate)*ratescale + minrate);
}
/*
* Check that codec configuration and surface data are all valid.
*/
static bool validate(const cv::cuda::GpuMat &in, ftl::codecs::Packet &pkt) {
if (in.type() == CV_32F) pkt.flags |= kFlagFloat;
else pkt.flags |= ftl::codecs::kFlagFlipRGB;
......@@ -213,7 +220,6 @@ bool NvPipeEncoder::_createEncoder(const cv::cuda::GpuMat &in, const ftl::codecs
if (nvenc_ && (params == params_)) return true;
uint64_t bitrate = calculateBitrate(pkt.definition, float(pkt.bitrate)/255.0f) * pkt.frame_count;
//if (is_float_channel_) bitrate *= 2.0f;
LOG(INFO) << "Calculated bitrate " << ((params.is_float) ? "(float)" : "(rgb)") << ": " << bitrate;
params_ = params;
......@@ -229,7 +235,7 @@ bool NvPipeEncoder::_createEncoder(const cv::cuda::GpuMat &in, const ftl::codecs
cuCtxGetCurrent(&cudaContext);
if (nvenc_) {
LOG(INFO) << "Destroying NVENC encoder : " << (uint64_t)nvenc_;
LOG(INFO) << "Destroying old NVENC encoder";
std::vector<std::vector<uint8_t>> tmp;
nvenc_->EndEncode(tmp);
nvenc_->DestroyEncoder();
......@@ -299,10 +305,10 @@ bool NvPipeEncoder::_createEncoder(const cv::cuda::GpuMat &in, const ftl::codecs
}
if (!nvenc_) {
LOG(ERROR) << "Could not create video encoder: "; // << NvPipe_GetError(NULL);
//LOG(ERROR) << "Could not create video encoder";
return false;
} else {
LOG(INFO) << "NvPipe encoder created : " << (uint64_t)nvenc_;
LOG(INFO) << "NVENC encoder created";
//nvenc_->SetIOCudaStreams(cv::cuda::StreamAccessor::getStream(stream_), cv::cuda::StreamAccessor::getStream(stream_));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment