Fix truncation of fourcc value in dshow capture property setter (bug #2535)

Added test checking that all valid fourcc values are converted properly
This commit is contained in:
Andrey Kamaev
2013-01-31 02:12:54 +04:00
parent e0426148ba
commit 2d6253609c
2 changed files with 119 additions and 4 deletions

View File

@@ -1203,7 +1203,7 @@ bool videoInput::setupDevice(int deviceNumber, int w, int h){
bool videoInput::setupDeviceFourcc(int deviceNumber, int w, int h,int fourcc){
if(deviceNumber >= VI_MAX_CAMERAS || VDList[deviceNumber]->readyToCapture) return false;
if ( fourcc > 0 ) {
if ( fourcc != -1 ) {
GUID *mediaType = getMediaSubtypeFromFourcc(fourcc);
if ( mediaType ) {
setAttemptCaptureSize(deviceNumber,w,h,*mediaType);
@@ -2193,7 +2193,7 @@ int videoInput::getFourccFromMediaSubtype(GUID type) {
GUID *videoInput::getMediaSubtypeFromFourcc(int fourcc){
for (int i=0;i<VI_NUM_TYPES;i++) {
if ( (unsigned long)fourcc == mediaSubtypes[i].Data1 ) {
if ( (unsigned long)(unsigned)fourcc == mediaSubtypes[i].Data1 ) {
return &mediaSubtypes[i];
}
}
@@ -3268,8 +3268,8 @@ bool CvCaptureCAM_DShow::setProperty( int property_id, double value )
break;
case CV_CAP_PROP_FOURCC:
fourcc = cvRound(value);
if ( fourcc < 0 ) {
fourcc = (int)(unsigned long)(value);
if ( fourcc == -1 ) {
// following cvCreateVideo usage will pop up caprturepindialog here if fourcc=-1
// TODO - how to create a capture pin dialog
}