Skip to content

Commit d570408

Browse files
committed
Address cudacodec build warnings.
1 parent 2ddfbb8 commit d570408

File tree

12 files changed

+144
-101
lines changed

12 files changed

+144
-101
lines changed

modules/cudacodec/include/opencv2/cudacodec.hpp

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ struct CV_EXPORTS_W_SIMPLE FormatInfo
385385
*/
386386
class CV_EXPORTS_W NVSurfaceToColorConverter {
387387
public:
388+
virtual ~NVSurfaceToColorConverter() {}
389+
388390
/** @brief Performs the conversion from the raw YUV Surface output from VideoReader to the requested color format. Use this function when you want to convert the raw YUV Surface output from VideoReader to more than one color format or you want both the raw Surface output in addition to a color frame.
389391
* @param yuv The raw YUV Surface output from VideoReader see @ref SurfaceFormat.
390392
* @param color The converted frame.
@@ -550,8 +552,7 @@ class CV_EXPORTS_W VideoReader
550552
- Out: Value of the property.
551553
@return `true` unless the property is not supported.
552554
*/
553-
virtual bool get(const VideoReaderProps propertyId, double& propertyVal) const = 0;
554-
CV_WRAP virtual bool getVideoReaderProps(const VideoReaderProps propertyId, CV_OUT double& propertyValOut, double propertyValIn = 0) const = 0;
555+
CV_WRAP_AS(getVideoReaderProps) virtual bool get(const VideoReaderProps propertyId, CV_OUT size_t& propertyVal) const = 0;
555556

556557
/** @brief Retrieves the specified property used by the VideoSource.
557558
@@ -562,6 +563,43 @@ class CV_EXPORTS_W VideoReader
562563
@return `true` unless the property is unset set or not supported.
563564
*/
564565
CV_WRAP virtual bool get(const int propertyId, CV_OUT double& propertyVal) const = 0;
566+
567+
/** @brief Determine whether the raw package at \a idx contains encoded data for a key frame.
568+
569+
@param idx Index of the encoded package to check.
570+
571+
@returns `true` if the raw package at \a idx contains encoded data for a key frame and `false` otherwise.
572+
573+
@note A typical use case is deciding to archive live video after streaming has been initialized. In this scenario you would not want to write any encoded frames before a key frame. This is simulated in the example below where VideoReader is initialized without enabling raw mode
574+
```
575+
VideoReaderInitParams params;
576+
params.rawMode = false;
577+
Ptr<VideoReader> reader = createVideoReader(rtspUrl, {}, params);
578+
```
579+
and then at some point in the future raw mode is enabled to enable the footage to be archived
580+
```
581+
reader->set(VideoReaderProps::PROP_RAW_MODE, true);
582+
```
583+
Because raw mode has been enabled mid stream the first raw package retrieved now is not guaranteed to contain a key frame. To locate the next raw package containing a key frame rawPackageHasKeyFrame() can then be used as shown below.
584+
```
585+
double iRawPacketBase = -1;
586+
reader->get(VideoReaderProps::PROP_RAW_PACKAGES_BASE_INDEX, iRawPacketBase);
587+
GpuMat frame;
588+
while (reader->nextFrame(frame)) {
589+
double nRawPackets = -1;
590+
reader->get(VideoReaderProps::PROP_NUMBER_OF_RAW_PACKAGES_SINCE_LAST_GRAB, nRawPackets);
591+
for (int iRawPacketToWrite = static_cast<int>(iRawPacketBase); iRawPacketToWrite < static_cast<int>(iRawPacketBase + nRawPackets); iRawPacketToWrite++) {
592+
if (reader->rawPackageHasKeyFrame(iRawPacketToWrite)) {
593+
Mat packageToWrite;
594+
reader->retrieve(packageToWrite, iRawPacketToWrite);
595+
...
596+
}
597+
}
598+
}
599+
```
600+
\sa retrieve
601+
*/
602+
CV_WRAP virtual bool rawPackageHasKeyFrame(const size_t idx) const = 0;
565603
};
566604

567605
/** @brief Interface for video demultiplexing. :

modules/cudacodec/src/NvEncoder.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,9 @@ void NvEncoder::CreateDefaultEncoderParams(NV_ENC_INITIALIZE_PARAMS* pIntializeP
101101
#endif
102102
pIntializeParams->tuningInfo = tuningInfo;
103103
pIntializeParams->encodeConfig->rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP;
104-
#if ((NVENCAPI_MAJOR_VERSION == 12 && NVENCAPI_MINOR_VERSION >= 2) || NVENCAPI_MAJOR_VERSION > 12)
105-
NV_ENC_PRESET_CONFIG presetConfig = { NV_ENC_PRESET_CONFIG_VER, 0, { NV_ENC_CONFIG_VER } };
106-
#else
107-
NV_ENC_PRESET_CONFIG presetConfig = { NV_ENC_PRESET_CONFIG_VER, { NV_ENC_CONFIG_VER } };
108-
#endif
104+
NV_ENC_PRESET_CONFIG presetConfig = {};
105+
presetConfig.version = NV_ENC_PRESET_CONFIG_VER;
106+
presetConfig.presetCfg.version = NV_ENC_CONFIG_VER;
109107
m_nvenc.nvEncGetEncodePresetConfigEx(m_hEncoder, codecGuid, presetGuid, tuningInfo, &presetConfig);
110108
memcpy(pIntializeParams->encodeConfig, &presetConfig.presetCfg, sizeof(NV_ENC_CONFIG));
111109

@@ -205,11 +203,9 @@ void NvEncoder::CreateEncoder(const NV_ENC_INITIALIZE_PARAMS* pEncoderParams)
205203
}
206204
else
207205
{
208-
#if ((NVENCAPI_MAJOR_VERSION == 12 && NVENCAPI_MINOR_VERSION >= 2) || NVENCAPI_MAJOR_VERSION > 12)
209-
NV_ENC_PRESET_CONFIG presetConfig = { NV_ENC_PRESET_CONFIG_VER, 0, { NV_ENC_CONFIG_VER } };
210-
#else
211-
NV_ENC_PRESET_CONFIG presetConfig = { NV_ENC_PRESET_CONFIG_VER, { NV_ENC_CONFIG_VER } };
212-
#endif
206+
NV_ENC_PRESET_CONFIG presetConfig = {};
207+
presetConfig.version = NV_ENC_PRESET_CONFIG_VER;
208+
presetConfig.presetCfg.version = NV_ENC_CONFIG_VER;
213209
m_nvenc.nvEncGetEncodePresetConfigEx(m_hEncoder, pEncoderParams->encodeGUID, pEncoderParams->presetGUID, pEncoderParams->tuningInfo, &presetConfig);
214210
memcpy(&m_encodeConfig, &presetConfig.presetCfg, sizeof(NV_ENC_CONFIG));
215211
}
@@ -570,6 +566,8 @@ void NvEncoder::WaitForCompletionEvent(int iEvent)
570566
NVENC_THROW_ERROR("Failed to encode frame", NV_ENC_ERR_GENERIC);
571567
}
572568
#endif
569+
#else
570+
CV_UNUSED(iEvent);
573571
#endif
574572
}
575573

modules/cudacodec/src/NvEncoder.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ class NvEncoder
263263
/**
264264
* @brief This function returns the completion event.
265265
*/
266-
void* GetCompletionEvent(uint32_t eventIdx) { return (m_vpCompletionEvent.size() == m_nEncoderBuffer) ? m_vpCompletionEvent[eventIdx] : nullptr; }
266+
void* GetCompletionEvent(uint32_t eventIdx) {
267+
CV_Assert(m_nEncoderBuffer >= 0);
268+
return (m_vpCompletionEvent.size() == static_cast<size_t>(m_nEncoderBuffer)) ? m_vpCompletionEvent[eventIdx] : nullptr;
269+
}
267270

268271
/**
269272
* @brief This function returns the current pixel format.

modules/cudacodec/src/cuda/ColorSpace.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
namespace cv { namespace cuda { namespace device {
1010

11+
void Y8ToGray8(uint8_t* dpY8, int nY8Pitch, uint8_t* dpGray, int nGrayPitch, int nWidth, int nHeight, ColorMatrix matYuv2Color, bool videoFullRangeFlag, const cudaStream_t stream);
12+
void Y8ToGray16(uint8_t* dpY8, int nY8Pitch, uint8_t* dpGray, int nGrayPitch, int nWidth, int nHeight, ColorMatrix matYuv2Color, bool videoFullRangeFlag, const cudaStream_t stream);
13+
void Y16ToGray8(uint8_t* dpY16, int nY16Pitch, uint8_t* dpGray, int nGrayPitch, int nWidth, int nHeight, ColorMatrix matYuv2Color, bool videoFullRangeFlag, const cudaStream_t stream);
14+
void Y16ToGray16(uint8_t* dpY16, int nY16Pitch, uint8_t* dpGray, int nGrayPitch, int nWidth, int nHeight, ColorMatrix matYuv2Color, bool videoFullRangeFlag, const cudaStream_t stream);
15+
1116
template<class T>
1217
__device__ static T Clamp(T x, T lower, T upper) {
1318
return x < lower ? lower : (x > upper ? upper : x);

modules/cudacodec/src/cuvid_video_source.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource(const String& fname)
6868
CUVIDEOFORMAT vidfmt;
6969
cuSafeCall( cuvidGetSourceVideoFormat(videoSource_, &vidfmt, 0) );
7070

71-
CV_Assert(Codec::NumCodecs == cudaVideoCodec::cudaVideoCodec_NumCodecs);
71+
CV_Assert(static_cast<int>(Codec::NumCodecs) == static_cast<int>(cudaVideoCodec::cudaVideoCodec_NumCodecs));
7272
format_.codec = static_cast<Codec>(vidfmt.codec);
7373
format_.chromaFormat = static_cast<ChromaFormat>(vidfmt.chroma_format);
7474
format_.nBitDepthMinus8 = vidfmt.bit_depth_luma_minus8;

modules/cudacodec/src/cuvid_video_source.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class CuvidVideoSource : public VideoSource
5656

5757
FormatInfo format() const CV_OVERRIDE;
5858
void updateFormat(const FormatInfo& videoFormat) CV_OVERRIDE;
59+
bool get(const int, double&) const { return false; }
5960
void start() CV_OVERRIDE;
6061
void stop() CV_OVERRIDE;
6162
bool isStarted() const CV_OVERRIDE;

modules/cudacodec/src/ffmpeg_video_source.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Codec FourccToCodec(int codec)
9090
}
9191

9292
static
93-
int StartCodeLen(unsigned char* data, const int sz) {
93+
int StartCodeLen(unsigned char* data, const size_t sz) {
9494
if (sz >= 3 && data[0] == 0 && data[1] == 0 && data[2] == 1)
9595
return 3;
9696
else if (sz >= 4 && data[0] == 0 && data[1] == 0 && data[2] == 0 && data[3] == 1)
@@ -99,7 +99,8 @@ int StartCodeLen(unsigned char* data, const int sz) {
9999
return 0;
100100
}
101101

102-
bool ParamSetsExist(unsigned char* parameterSets, const int szParameterSets, unsigned char* data, const int szData) {
102+
static
103+
bool ParamSetsExist(unsigned char* parameterSets, const size_t szParameterSets, unsigned char* data, const size_t szData) {
103104
const int paramSetStartCodeLen = StartCodeLen(parameterSets, szParameterSets);
104105
const int packetStartCodeLen = StartCodeLen(data, szData);
105106
// weak test to see if the parameter set has already been included in the RTP stream
@@ -129,8 +130,8 @@ cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname,
129130

130131
int codec = (int)cap.get(CAP_PROP_FOURCC);
131132
format_.codec = FourccToCodec(codec);
132-
format_.height = cap.get(CAP_PROP_FRAME_HEIGHT);
133-
format_.width = cap.get(CAP_PROP_FRAME_WIDTH);
133+
format_.height = static_cast<int>(cap.get(CAP_PROP_FRAME_HEIGHT));
134+
format_.width = static_cast<int>(cap.get(CAP_PROP_FRAME_WIDTH));
134135
format_.displayArea = Rect(0, 0, format_.width, format_.height);
135136
format_.valid = false;
136137
format_.fps = cap.get(CAP_PROP_FPS);
@@ -181,7 +182,8 @@ bool cv::cudacodec::detail::FFmpegVideoSource::getNextPacket(unsigned char** dat
181182
{
182183
const size_t nBytesToTrimFromData = format_.codec == Codec::MPEG4 ? 3 : 0;
183184
const size_t newSz = extraData.total() + *size - nBytesToTrimFromData;
184-
dataWithHeader = Mat(1, newSz, CV_8UC1);
185+
CV_Assert(newSz <= std::numeric_limits<int>::max());
186+
dataWithHeader = Mat(1, static_cast<int>(newSz), CV_8UC1);
185187
memcpy(dataWithHeader.data, extraData.data, extraData.total());
186188
memcpy(dataWithHeader.data + extraData.total(), (*data) + nBytesToTrimFromData, *size - nBytesToTrimFromData);
187189
*data = dataWithHeader.data;

modules/cudacodec/src/video_decoder.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void cv::cudacodec::detail::VideoDecoder::create(const FormatInfo& videoFormat)
158158
codecSupported |= cudaVideoCodec_VP8 == _codec || cudaVideoCodec_VP9 == _codec;
159159
#endif
160160
#if (CUDART_VERSION >= 9000)
161-
codecSupported |= cudaVideoCodec_AV1;
161+
codecSupported |= cudaVideoCodec_AV1 == _codec;
162162
#endif
163163
CV_Assert(codecSupported);
164164
CV_Assert( cudaVideoChromaFormat_Monochrome == _chromaFormat ||
@@ -211,12 +211,12 @@ void cv::cudacodec::detail::VideoDecoder::create(const FormatInfo& videoFormat)
211211
}
212212
}
213213

214-
CV_Assert(videoFormat.ulWidth >= decodeCaps.nMinWidth &&
215-
videoFormat.ulHeight >= decodeCaps.nMinHeight &&
216-
videoFormat.ulWidth <= decodeCaps.nMaxWidth &&
217-
videoFormat.ulHeight <= decodeCaps.nMaxHeight);
214+
CV_Assert(videoFormat.ulWidth >= static_cast<int>(decodeCaps.nMinWidth) &&
215+
videoFormat.ulHeight >= static_cast<int>(decodeCaps.nMinHeight) &&
216+
videoFormat.ulWidth <= static_cast<int>(decodeCaps.nMaxWidth) &&
217+
videoFormat.ulHeight <= static_cast<int>(decodeCaps.nMaxHeight));
218218

219-
CV_Assert((videoFormat.width >> 4) * (videoFormat.height >> 4) <= decodeCaps.nMaxMBCount);
219+
CV_Assert((static_cast<unsigned int>(videoFormat.width) >> 4) * (static_cast<unsigned int>(videoFormat.height) >> 4) <= decodeCaps.nMaxMBCount);
220220
#else
221221
if (videoFormat.enableHistogram) {
222222
CV_Error(Error::StsBadArg, "Luma histogram output is not supported when CUDA Toolkit version <= 9.0.");
@@ -240,14 +240,14 @@ void cv::cudacodec::detail::VideoDecoder::create(const FormatInfo& videoFormat)
240240
createInfo_.DeinterlaceMode = static_cast<cudaVideoDeinterlaceMode>(videoFormat.deinterlaceMode);
241241
createInfo_.ulTargetWidth = videoFormat.width;
242242
createInfo_.ulTargetHeight = videoFormat.height;
243-
createInfo_.display_area.left = videoFormat.displayArea.x;
244-
createInfo_.display_area.right = videoFormat.displayArea.x + videoFormat.displayArea.width;
245-
createInfo_.display_area.top = videoFormat.displayArea.y;
246-
createInfo_.display_area.bottom = videoFormat.displayArea.y + videoFormat.displayArea.height;
247-
createInfo_.target_rect.left = videoFormat.targetRoi.x;
248-
createInfo_.target_rect.right = videoFormat.targetRoi.x + videoFormat.targetRoi.width;
249-
createInfo_.target_rect.top = videoFormat.targetRoi.y;
250-
createInfo_.target_rect.bottom = videoFormat.targetRoi.y + videoFormat.targetRoi.height;
243+
createInfo_.display_area.left = static_cast<short>(videoFormat.displayArea.x);
244+
createInfo_.display_area.right = static_cast<short>(videoFormat.displayArea.x + videoFormat.displayArea.width);
245+
createInfo_.display_area.top = static_cast<short>(videoFormat.displayArea.y);
246+
createInfo_.display_area.bottom = static_cast<short>(videoFormat.displayArea.y + videoFormat.displayArea.height);
247+
createInfo_.target_rect.left = static_cast<short>(videoFormat.targetRoi.x);
248+
createInfo_.target_rect.right = static_cast<short>(videoFormat.targetRoi.x + videoFormat.targetRoi.width);
249+
createInfo_.target_rect.top = static_cast<short>(videoFormat.targetRoi.y);
250+
createInfo_.target_rect.bottom = static_cast<short>(videoFormat.targetRoi.y + videoFormat.targetRoi.height);
251251
createInfo_.ulNumOutputSurfaces = 2;
252252
createInfo_.ulCreationFlags = videoCreateFlags;
253253
createInfo_.vidLock = lock_;
@@ -288,19 +288,19 @@ int cv::cudacodec::detail::VideoDecoder::reconfigure(const FormatInfo& videoForm
288288
videoFormat_.targetRoi = videoFormat.targetRoi;
289289
}
290290

291-
CUVIDRECONFIGUREDECODERINFO reconfigParams = { 0 };
291+
CUVIDRECONFIGUREDECODERINFO reconfigParams = {};
292292
reconfigParams.ulWidth = videoFormat_.ulWidth;
293293
reconfigParams.ulHeight = videoFormat_.ulHeight;
294-
reconfigParams.display_area.left = videoFormat_.displayArea.x;
295-
reconfigParams.display_area.right = videoFormat_.displayArea.x + videoFormat_.displayArea.width;
296-
reconfigParams.display_area.top = videoFormat_.displayArea.y;
297-
reconfigParams.display_area.bottom = videoFormat_.displayArea.y + videoFormat_.displayArea.height;
294+
reconfigParams.display_area.left = static_cast<short>(videoFormat_.displayArea.x);
295+
reconfigParams.display_area.right = static_cast<short>(videoFormat_.displayArea.x + videoFormat_.displayArea.width);
296+
reconfigParams.display_area.top = static_cast<short>(videoFormat_.displayArea.y);
297+
reconfigParams.display_area.bottom = static_cast<short>(videoFormat_.displayArea.y + videoFormat_.displayArea.height);
298298
reconfigParams.ulTargetWidth = videoFormat_.width;
299299
reconfigParams.ulTargetHeight = videoFormat_.height;
300-
reconfigParams.target_rect.left = videoFormat_.targetRoi.x;
301-
reconfigParams.target_rect.right = videoFormat_.targetRoi.x + videoFormat_.targetRoi.width;
302-
reconfigParams.target_rect.top = videoFormat_.targetRoi.y;
303-
reconfigParams.target_rect.bottom = videoFormat_.targetRoi.y + videoFormat_.targetRoi.height;
300+
reconfigParams.target_rect.left = static_cast<short>(videoFormat_.targetRoi.x);
301+
reconfigParams.target_rect.right = static_cast<short>(videoFormat_.targetRoi.x + videoFormat_.targetRoi.width);
302+
reconfigParams.target_rect.top = static_cast<short>(videoFormat_.targetRoi.y);
303+
reconfigParams.target_rect.bottom = static_cast<short>(videoFormat_.targetRoi.y + videoFormat_.targetRoi.height);
304304
reconfigParams.ulNumDecodeSurfaces = videoFormat_.ulNumDecodeSurfaces;
305305

306306
cuSafeCall(cuCtxPushCurrent(ctx_));

modules/cudacodec/src/video_reader.cpp

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ void cv::cudacodec::MapHist(const GpuMat&, Mat&) { throw_no_cuda(); }
5454

5555
#else // HAVE_NVCUVID
5656

57-
void nv12ToBgra(const GpuMat& decodedFrame, GpuMat& outFrame, int width, int height, const bool videoFullRangeFlag, cudaStream_t stream);
58-
5957
using namespace cv::cudacodec::detail;
6058

6159
namespace
@@ -81,11 +79,12 @@ namespace
8179

8280
bool set(const ColorFormat colorFormat, const BitDepth bitDepth = BitDepth::UNCHANGED, const bool planar = false) CV_OVERRIDE;
8381

84-
bool get(const VideoReaderProps propertyId, double& propertyVal) const CV_OVERRIDE;
85-
bool getVideoReaderProps(const VideoReaderProps propertyId, double& propertyValOut, double propertyValIn) const CV_OVERRIDE;
82+
bool get(const VideoReaderProps propertyId, size_t& propertyVal) const CV_OVERRIDE;
8683

8784
bool get(const int propertyId, double& propertyVal) const CV_OVERRIDE;
8885

86+
bool rawPackageHasKeyFrame(const size_t idx) const CV_OVERRIDE;
87+
8988
private:
9089
bool skipFrame();
9190
bool aquireFrameInfo(std::pair<CUVIDPARSERDISPINFO, CUVIDPROCPARAMS>& frameInfo, Stream& stream = Stream::Null());
@@ -298,8 +297,9 @@ namespace
298297
if (idx >= rawPacketsBaseIdx && idx < rawPacketsBaseIdx + rawPackets.size()) {
299298
if (!frame.isMat())
300299
CV_Error(Error::StsUnsupportedFormat, "Raw data is stored on the host and must be retrieved using a cv::Mat");
301-
const size_t i = idx - rawPacketsBaseIdx;
302-
Mat tmp(1, rawPackets.at(i).Size(), CV_8UC1, const_cast<unsigned char*>(rawPackets.at(i).Data()), rawPackets.at(i).Size());
300+
const size_t i = idx - static_cast<size_t>(rawPacketsBaseIdx);
301+
CV_Assert(rawPackets.at(i).Size() <= std::numeric_limits<int>::max());
302+
Mat tmp(1, static_cast<int>(rawPackets.at(i).Size()), CV_8UC1, const_cast<unsigned char*>(rawPackets.at(i).Data()), rawPackets.at(i).Size());
303303
frame.getMatRef() = tmp;
304304
}
305305
}
@@ -311,6 +311,8 @@ namespace
311311
case VideoReaderProps::PROP_RAW_MODE :
312312
videoSource_->SetRawMode(static_cast<bool>(propertyVal));
313313
return true;
314+
default:
315+
break;
314316
}
315317
return false;
316318
}
@@ -334,7 +336,7 @@ namespace
334336
return true;
335337
}
336338

337-
bool VideoReaderImpl::get(const VideoReaderProps propertyId, double& propertyVal) const {
339+
bool VideoReaderImpl::get(const VideoReaderProps propertyId, size_t& propertyVal) const {
338340
switch (propertyId)
339341
{
340342
case VideoReaderProps::PROP_DECODED_FRAME_IDX:
@@ -356,41 +358,34 @@ namespace
356358
case VideoReaderProps::PROP_RAW_MODE:
357359
propertyVal = videoSource_->RawModeEnabled();
358360
return true;
359-
case VideoReaderProps::PROP_LRF_HAS_KEY_FRAME: {
360-
const int iPacket = propertyVal - rawPacketsBaseIdx;
361-
if (videoSource_->RawModeEnabled() && iPacket >= 0 && iPacket < rawPackets.size()) {
362-
propertyVal = rawPackets.at(iPacket).ContainsKeyFrame();
363-
return true;
364-
}
365-
else
366-
break;
367-
}
368361
case VideoReaderProps::PROP_ALLOW_FRAME_DROP:
369362
propertyVal = videoParser_->allowFrameDrops();
370363
return true;
371364
case VideoReaderProps::PROP_UDP_SOURCE:
372365
propertyVal = videoParser_->udpSource();
373366
return true;
374367
case VideoReaderProps::PROP_COLOR_FORMAT:
375-
propertyVal = static_cast<double>(colorFormat);
368+
propertyVal = static_cast<size_t>(colorFormat);
376369
return true;
377370
case VideoReaderProps::PROP_BIT_DEPTH:
378-
propertyVal = static_cast<double>(bitDepth);
371+
propertyVal = static_cast<size_t>(bitDepth);
379372
return true;
380373
case VideoReaderProps::PROP_PLANAR:
381-
propertyVal = static_cast<double>(planar);
374+
propertyVal = static_cast<size_t>(planar);
382375
return true;
383376
default:
384377
break;
385378
}
386379
return false;
387380
}
388381

389-
bool VideoReaderImpl::getVideoReaderProps(const VideoReaderProps propertyId, double& propertyValOut, double propertyValIn) const {
390-
double propertyValInOut = propertyValIn;
391-
const bool ret = get(propertyId, propertyValInOut);
392-
propertyValOut = propertyValInOut;
393-
return ret;
382+
bool VideoReaderImpl::rawPackageHasKeyFrame(const size_t idx) const {
383+
if (idx < rawPacketsBaseIdx) return false;
384+
const size_t iPacket = idx - rawPacketsBaseIdx;
385+
if (videoSource_->RawModeEnabled() && iPacket < rawPackets.size())
386+
return rawPackets.at(iPacket).ContainsKeyFrame();
387+
else
388+
return false;
394389
}
395390

396391
bool VideoReaderImpl::get(const int propertyId, double& propertyVal) const {

0 commit comments

Comments
 (0)