[Sumover-dev] [svn commit] r4064 - in vic/branches/mpeg4: video

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Tue Jun 12 15:57:25 BST 2007


Author: piers
Date: Tue Jun 12 15:57:23 2007
New Revision: 4064

Modified:
   vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl
   vic/branches/mpeg4/video/grabber-win32.cpp
   vic/branches/mpeg4/video/grabber-win32DS.cpp
   vic/branches/mpeg4/video/grabber.cpp

Log:
Updates to fix grabbers on windows:
- Old vfw Win32 made more robust to failing grabbers
- Win32DS now attempts to select best resolution to fix the selected capture size. It is also now possible to select PAL or NTSC from Signal.. menu to adjust captured video size.
- Altered code so it chooses the capture size before calling RenderStream on filterGraph - that way the filter graph manager can insert the appropriate colour space converter.
- Uses set_size_cif() in size() - which falls thru to ste_size_411() not handled.  Fixed bug in Grabber.cpp: set_size_cif() where width=176 didn't have a break statement.
- tweaked ui-ctrlmenu.tcl so Signal..(type) is set before decimate on - so win32 grabber can use it.

Modified: vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl
==============================================================================
--- vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl	(original)
+++ vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl	Tue Jun 12 15:57:23 2007
@@ -1598,10 +1598,11 @@
             if { [$portButton cget -state] == "normal" } {
                   $grabber port $inputPort
             }
+        }
             if { [$typeButton cget -state] == "normal" } {
                   $grabber type $inputType
             }
-        }
+        
 	$grabber fps [$fps_slider get]
 	$grabber bps [$bps_slider get]
 	$grabber decimate $inputSize

Modified: vic/branches/mpeg4/video/grabber-win32.cpp
==============================================================================
--- vic/branches/mpeg4/video/grabber-win32.cpp	(original)
+++ vic/branches/mpeg4/video/grabber-win32.cpp	Tue Jun 12 15:57:23 2007
@@ -486,7 +486,7 @@
 }
 
 VfwGrabber::VfwGrabber(const int dev) : dev_(dev), connected_(0),
-	last_frame_(0), devtype_(Generic), useconfig_(0)
+	last_frame_(0), devtype_(Generic), useconfig_(0), converter_(0), fmt_(0), frame_sem_(0), cb_mutex_(0)
 {
 	char deviceName[80] ;
 	char deviceVersion[100] ;
@@ -634,6 +634,8 @@
 	}
 	if (!capDriverConnect(capwin_, dev_)) {
 		debug_msg( "capDriverConnect: dev=%d failed - %lu\n", dev_, GetLastError());
+		stop();
+		return;
 		/*abort();*/
 	}
 
@@ -891,16 +893,18 @@
 void VfwCIFGrabber::start()
 {
 	VfwGrabber::start();
-	switch (fmt_->biCompression) {
-	case BI_RGB:
-		converter(new RGB_Converter_411(fmt_->biBitCount, (u_int8_t *)(fmt_ + 1), fmt_->biClrUsed));
-		break;
-	case mmioFOURCC('Y','U','Y','V'):
-		converter(new YUYV_Converter_411());
-		break;
-	default:
-		converter(new IC_Converter_411(fmt_->biCompression, fmt_->biBitCount, fmt_->biWidth, fmt_->biHeight));
-		break;
+	if (fmt_!=NULL) {
+	    switch (fmt_->biCompression) {
+		case BI_RGB:
+		    converter(new RGB_Converter_411(fmt_->biBitCount, (u_int8_t *)(fmt_ + 1), fmt_->biClrUsed));
+		    break;
+		case mmioFOURCC('Y','U','Y','V'):
+		    converter(new YUYV_Converter_411());
+		    break;
+		default:
+		    converter(new IC_Converter_411(fmt_->biCompression, fmt_->biBitCount, fmt_->biWidth, fmt_->biHeight));
+		    break;
+	    }
 	}
     /* allow video handler callback to progress */
     ReleaseMutex(cb_mutex_);
@@ -909,17 +913,24 @@
 
 void VfwGrabber::stop()
 {
-	debug_msg("VfwWindow::stop() thread=%x\n", GetCurrentThreadId());
+    debug_msg("VfwWindow::stop() thread=%x\n", GetCurrentThreadId());
+
+    if (cb_mutex_!=NULL) {
+	CloseHandle(cb_mutex_);
+	cb_mutex_=0;
+    } else 
+	return;
 
-	if (capturing_)
-		capCaptureStop(capwin_);
+    if (capturing_)
+	capCaptureStop(capwin_);
     /* ensure this won't be called */
     capSetCallbackOnVideoStream(capwin_, NULL);
     capturing_ = 0;
-	capture_=0;
+    capture_=0;
+    if (frame_sem_!=0 ) {
 	ReleaseSemaphore(frame_sem_, 1, NULL);
 	CloseHandle(frame_sem_);
-    CloseHandle(cb_mutex_);
+    }
 #ifdef NDEF
 	if (caps_.fHasOverlay)
 		capOverlay(capwin_, FALSE);
@@ -927,10 +938,11 @@
 		capPreview(capwin_, FALSE);
 #endif
 
-	capDriverDisconnect(capwin_);
+	if (capwin_!=NULL) 
+	    capDriverDisconnect(capwin_);
 	connected_ = 0;
 
-	if (fmt_->biCompression == BI_RGB)
+	if (converter_!=NULL) //if (fmt_->biCompression == BI_RGB)
 		delete converter_;
 	converter_ = 0;
 
@@ -1030,7 +1042,7 @@
 VfwGrabber::capture(VfwGrabber *gw, LPBYTE frame)
 {
 #ifdef DEBUG
-	if (last_frame_ != NULL)
+	if (gw->last_frame_ != NULL)
 		debug_msg("Last frame not grabbed!\n");
 #endif
 	if (capturing_) gw->last_frame_ = frame;

Modified: vic/branches/mpeg4/video/grabber-win32DS.cpp
==============================================================================
--- vic/branches/mpeg4/video/grabber-win32DS.cpp	(original)
+++ vic/branches/mpeg4/video/grabber-win32DS.cpp	Tue Jun 12 15:57:23 2007
@@ -189,14 +189,18 @@
    debug_msg("new DirectShowGrabber()\n");
    svideoPort = -1;
    compositePort = -1;
+   decimate_ =-1;
+   converter_=0;
+   cb_mutex_=0;
+
 
    crossbar = crossbarCursor = NULL;  
 
    pCaptureFilter_ = filt;   
    setport("external");
 
-   basewidth_  = CIF_BASE_WIDTH;
-   baseheight_ = CIF_BASE_HEIGHT;
+   //basewidth_  = CIF_BASE_WIDTH;
+   //baseheight_ = CIF_BASE_HEIGHT;
   
    /*
    ZeroMemory(&mt_, sizeof(AM_MEDIA_TYPE));
@@ -241,7 +245,7 @@
    }
    debug_msg("DirectShowGrabber::DirectShowGrabber():  graph builder interface acquired\n");
 
-   // Tell the capture graph builder about the FGM.
+   // Tell the capture graph builder about the Filter Graph Manager (FGM).
    hr = pBuild_->SetFiltergraph(pGraph_);
    //showErrorMessage(hr);
    if (FAILED(hr)) {
@@ -250,7 +254,7 @@
    }
    debug_msg("DirectShowGrabber::DirectShowGrabber():  graph associated with builder\n");
 
-   // Add the capture filter to the filter graph
+   // Add the capture filter (obtained by the DirectShowDevice Scanner) to the filter graph
    hr = pGraph_->AddFilter(pCaptureFilter_, L"VicCaptureFilter");
    //showErrorMessage(hr);
    debug_msg("DirectShowGrabber::DirectShowGrabber():  capture filter added to graph\n");
@@ -292,7 +296,8 @@
    		Grabber::status_=-1;
 		return;
    }
-   // setCaptureOutputFormat();
+   //Not needed as width & height aren't known yet.
+   //setCaptureOutputFormat();
    
    findCrossbar(pCaptureFilter_);
    routeCrossbar();   
@@ -302,16 +307,19 @@
    ZeroMemory(&mt_, sizeof(AM_MEDIA_TYPE));
    mt_.majortype = MEDIATYPE_Video;
    mt_.subtype   = MEDIASUBTYPE_RGB24;
+   //mt_.subtype   = MEDIASUBTYPE_UYVY;
+   //mt_.formattype == FORMAT_VideoInfo;
    hr            = pSampleGrabber_->SetMediaType(&mt_);
    //showErrorMessage(hr);
 
    // Connect the filters   
-   hr = pBuild_->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
-                              pCaptureFilter_, pGrabberBaseFilter_, pNullBaseFilter_);
+   //hr = pBuild_->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
+   //                           pCaptureFilter_, pGrabberBaseFilter_, pNullBaseFilter_);
    //showErrorMessage(hr);
-   debug_msg("DirectShowGrabber::DirectShowGrabber():  builder render stream\n");
+   //debug_msg("DirectShowGrabber::DirectShowGrabber():  builder render stream\n");
    
    if (FAILED(hr)) {
+          debug_msg("DirectShowGrabber::DirectShowGrabber():  FAILed to build render stream\n");
    		status_=-1;
 		return;
    }
@@ -324,8 +332,9 @@
 
     debug_msg("~DirectShowGrabber()\n");
 
-    capturing_ = !capturing_;
-    hr         = pMediaControl_->Stop();
+    //capturing_ = !capturing_;
+    if (capturing_) 
+	hr  = pMediaControl_->Stop();
     //showErrorMessage(hr);    
 
     // Release COM objects in reverse order of instantiation
@@ -354,7 +363,8 @@
       addCrossbar(pXBar);
       hr = pXBar->QueryInterface(IID_IBaseFilter, (void**)&pFilter);
       if ( SUCCEEDED(hr) ) {
-         findCrossbar(pFilter);
+	debug_msg("DirectShowGrabber::FindCrossbar()...Found and added\n");
+        findCrossbar(pFilter);
          pFilter->Release();
       }
 
@@ -416,8 +426,6 @@
            break;
        }
     }
-
-	
 	if(strcmp(input_port_, "S-Video")==0){
 		port = svideoPort;
 	}else if(strcmp(input_port_, "Composite")==0){
@@ -444,8 +452,18 @@
    HRESULT hr;
 
    setsize();
-
+   setCaptureOutputFormat();
+   hr = pBuild_->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
+	pCaptureFilter_, pGrabberBaseFilter_, pNullBaseFilter_);
    // callback mutex
+   if (SUCCEEDED(hr) )
+       debug_msg("DirectShowGrabber::DirectShowGrabber():  builder render stream\n");
+   else {
+       debug_msg("DirectShowGrabber::DirectShowGrabber():  FAILED to builder render stream: %x\n", hr);
+       stop();
+       return;
+   }
+
    cb_mutex_ = CreateMutex(NULL, FALSE, NULL);
    WaitForSingleObject(cb_mutex_, INFINITE);
    
@@ -456,6 +474,9 @@
 
    // Run the graph...
    hr = pMediaControl_->Run();
+   if (SUCCEEDED(hr) )
+       debug_msg("DirectShowGrabber::DirectShowGrabber():  Graph set to Run\n");
+
    //showErrorMessage(hr);
 
    Grabber::start();
@@ -474,7 +495,7 @@
    //showErrorMessage(hr);
    
    CloseHandle(cb_mutex_);  
-   delete converter_;
+   delete[] converter_;
    capturing_  = 0;   
    converter_  = 0;
    last_frame_ = 0;
@@ -505,12 +526,12 @@
 int DirectShowGrabber::grab() {
    int rval;
 
-   /*
-   debug_msg("DirectShowGrabber::grab: thread=%x w=%d h=%d frame_=%p fsize_=%d in=%dx%d out=%dx%d\n",
+   
+   debug_msg("DirectShowGrabber::grab: thread=%x w=%d h=%d bw=%d bh=%d frame_=%p fsize_=%d in=%dx%d out=%dx%d\n",
              GetCurrentThreadId(),
-             basewidth_, baseheight_, frame_, framesize_,
+             width_, height_, basewidth_, baseheight_, frame_, framesize_,
              inw_, inh_, outw_, outh_);
-   */
+   
 
    WaitForSingleObject(cb_mutex_, INFINITE);
 
@@ -555,6 +576,7 @@
    int                      iSize;
    VIDEO_STREAM_CONFIG_CAPS scc;
    HRESULT                  hr;
+   VIDEOINFOHEADER          *pVih;
 
    pConfig   = NULL;
    hr        = pBuild_->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
@@ -579,7 +601,7 @@
 	 //     for simple firewire cam
          if( SUCCEEDED(hr) ) {
             if ((pmtConfig->majortype  == MEDIATYPE_Video)            &&
-                  (pmtConfig->subtype    == MEDIASUBTYPE_RGB24)       &&
+                  //(pmtConfig->subtype    == MEDIASUBTYPE_RGB24)       &&
                   (pmtConfig->formattype == FORMAT_VideoInfo)         &&
                   (pmtConfig->cbFormat   >= sizeof (VIDEOINFOHEADER)) &&
                   (pmtConfig->pbFormat   != NULL)) {
@@ -587,13 +609,26 @@
 			   if(scc.MaxOutputSize.cx > max_width_){
 			       max_width_  = scc.MaxOutputSize.cx;
 			       max_height_ =  scc.MaxOutputSize.cy;
-			       		return TRUE;
 
 			   }
+			   		    debug_msg("Windows GDI BITMAPINFOHEADER follows:\n");
+    		    pVih                        = (VIDEOINFOHEADER *)pmtConfig->pbFormat;			  
+		    debug_msg("biWidth=        %d\n", pVih->bmiHeader.biWidth);
+		    debug_msg("biHeight=       %d\n", pVih->bmiHeader.biHeight);
+		    debug_msg("biSize=         %d\n", pVih->bmiHeader.biSize);
+		    debug_msg("biPlanes=       %d\n", pVih->bmiHeader.biPlanes);
+		    debug_msg("biBitCount=     %d\n", pVih->bmiHeader.biBitCount);
+		    debug_msg("biCompression=  %d\n", pVih->bmiHeader.biCompression);
+		    debug_msg("biSizeImage=    %d\n", pVih->bmiHeader.biSizeImage);
+		    debug_msg("biXPelsPerMeter=%d\n", pVih->bmiHeader.biXPelsPerMeter);
+		    debug_msg("biYPelsPerMeter=%d\n", pVih->bmiHeader.biYPelsPerMeter);
 			}
 		 }
 	  }
    }
+   if (max_width_>0)		       		
+       return TRUE;
+
    return FALSE;
 }
 
@@ -601,6 +636,9 @@
    IAMStreamConfig          *pConfig;
    int                      iCount;
    int                      iSize;
+   int			    curr_w=0;
+   int			    curr_h=0;
+   int			    temp_w, temp_h;
    VIDEOINFOHEADER          *pVih;
    VIDEO_STREAM_CONFIG_CAPS scc;
    AM_MEDIA_TYPE            *pmtConfig;
@@ -616,8 +654,9 @@
    hr        = pBuild_->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
                                      pCaptureFilter_, IID_IAMStreamConfig, (void**)&pConfig);
    if (FAILED(hr)) {
-   		Grabber::status_=-1;
-		return;
+	debug_msg("Failed to FindInterface\n");
+   	Grabber::status_=-1;
+	return;
    }
 
    debug_msg("DirectShowGrabber::setCaptureOutputFormat(): IAMStreamConfig interface acquired\n");
@@ -634,51 +673,86 @@
 
          if( SUCCEEDED(hr) ) {
             if ((pmtConfig->majortype  == MEDIATYPE_Video)            &&
-                  (pmtConfig->subtype    == MEDIASUBTYPE_RGB24)       &&
+                  //(pmtConfig->subtype    == MEDIASUBTYPE_RGB24)       &&
                   (pmtConfig->formattype == FORMAT_VideoInfo)         &&
                   (pmtConfig->cbFormat   >= sizeof (VIDEOINFOHEADER)) &&
-		  (pmtConfig->pbFormat   != NULL)		      &&
-		  (scc.MaxOutputSize.cx >= width_)		      &&
-		  (scc.MaxOutputSize.cy >= height_)){
-
-               pVih                        = (VIDEOINFOHEADER *)pmtConfig->pbFormat;			  
-               pVih->bmiHeader.biWidth     = width_;
-               pVih->bmiHeader.biHeight    = height_;
-               pVih->bmiHeader.biSizeImage = DIBSIZE(pVih->bmiHeader);
-	       // AvgTimePerFrame value that specifies the video frame'
-	       // average display time, in 100-nanosecond units. 
-	       if (fps_) 
-		 pVih->AvgTimePerFrame	   = 10000000/fps_;
-
-               debug_msg("Windows GDI BITMAPINFOHEADER follows:\n");
-               debug_msg("biWidth=        %d\n", pVih->bmiHeader.biWidth);
-               debug_msg("biHeight=       %d\n", pVih->bmiHeader.biHeight);
-               debug_msg("biSize=         %d\n", pVih->bmiHeader.biSize);
-               debug_msg("biPlanes=       %d\n", pVih->bmiHeader.biPlanes);
-               debug_msg("biBitCount=     %d\n", pVih->bmiHeader.biBitCount);
-               debug_msg("biCompression=  %d\n", pVih->bmiHeader.biCompression);
-               debug_msg("biSizeImage=    %d\n", pVih->bmiHeader.biSizeImage);
-               debug_msg("biXPelsPerMeter=%d\n", pVih->bmiHeader.biXPelsPerMeter);
-               debug_msg("biYPelsPerMeter=%d\n", pVih->bmiHeader.biYPelsPerMeter);
-               debug_msg("biClrUsed=      %d\n", pVih->bmiHeader.biClrUsed);
-               debug_msg("biClrImportant= %d\n", pVih->bmiHeader.biClrImportant);
-
-               hr = pConfig->SetFormat(pmtConfig);
-               //showErrorMessage(hr);
-
+		  (pmtConfig->pbFormat   != NULL) /*		      &&
+		  (scc.MaxOutputSize.cx <= width_)		      &&
+		  (scc.MaxOutputSize.cy <= height_)*/){
+
+	       if ((abs(width_ - scc.MaxOutputSize.cx) + abs(height_ - scc.MaxOutputSize.cy))<
+		   (abs(width_ - curr_w) +abs(height_ - curr_h))) {
+
+		    pVih                        = (VIDEOINFOHEADER *)pmtConfig->pbFormat;			  
+		    //pVih->bmiHeader.biWidth     = width_;
+		    //pVih->bmiHeader.biWidth     = 320;
+		    //pVih->bmiHeader.biHeight    = height_;
+		    //pVih->bmiHeader.biHeight    = 240;
+		    //pVih->bmiHeader.biSizeImage = DIBSIZE(pVih->bmiHeader);
+		    // AvgTimePerFrame value that specifies the video frame'
+		    // average display time, in 100-nanosecond units. 
+		    //if (fps_) 
+			// pVih->AvgTimePerFrame	   = 10000000/fps_;
+
+		    debug_msg("fps_= %d\n", fps_);
+
+		    debug_msg("Windows GDI BITMAPINFOHEADER follows:\n");
+		    debug_msg("biWidth=        %d\n", pVih->bmiHeader.biWidth);
+		    debug_msg("biHeight=       %d\n", pVih->bmiHeader.biHeight);
+		    debug_msg("biSize=         %d\n", pVih->bmiHeader.biSize);
+		    debug_msg("biPlanes=       %d\n", pVih->bmiHeader.biPlanes);
+		    debug_msg("biBitCount=     %d\n", pVih->bmiHeader.biBitCount);
+		    debug_msg("biCompression=  %d\n", pVih->bmiHeader.biCompression);
+		    debug_msg("biSizeImage=    %d\n", pVih->bmiHeader.biSizeImage);
+		    debug_msg("biXPelsPerMeter=%d\n", pVih->bmiHeader.biXPelsPerMeter);
+		    debug_msg("biYPelsPerMeter=%d\n", pVih->bmiHeader.biYPelsPerMeter);
+		    debug_msg("biClrUsed=      %d\n", pVih->bmiHeader.biClrUsed);
+		    debug_msg("biClrImportant= %d\n", pVih->bmiHeader.biClrImportant);
+
+		    //pmtConfig->subtype    = MEDIASUBTYPE_RGB24;
+            	    temp_w = pVih->bmiHeader.biWidth;
+		    temp_h = pVih->bmiHeader.biHeight;
+            	    pVih->bmiHeader.biWidth     = width_;
+		    pVih->bmiHeader.biHeight    = height_;
+		    hr = pConfig->SetFormat(pmtConfig);
+		    if (SUCCEEDED(hr)) {
+			curr_w = width_;
+			curr_h = height_;
+			formatSet = 1;
+			debug_msg("Set(wxh): %dx%d, and Got: %dx%d\n",width_,height_, pVih->bmiHeader.biWidth, pVih->bmiHeader.biHeight);
+			break;
+		    } else {
+			if ((temp_w < width_) && (temp_h < height_)) {
+			    pVih->bmiHeader.biWidth = temp_w;
+			    pVih->bmiHeader.biHeight = temp_h;
+			    hr = pConfig->SetFormat(pmtConfig);
+			    if (SUCCEEDED(hr)) {
+				curr_w = temp_w;
+				curr_h = temp_h;
+				formatSet = 1;
+				debug_msg("Set(wxh): %dx%d, and Got: %dx%d\n",width_,height_, pVih->bmiHeader.biWidth, pVih->bmiHeader.biHeight);
+			    }
+			} else {
+    			    debug_msg("Failed to Set format this time - trying again\n");
+			}
+		    }
+	       }
                // XXX:  leak.  need to deal with this - msp
                //DeleteMediaType(pmtConfig);
-               formatSet = 1;
-//               break;
-
             }
          }
       }
    }
    pConfig->Release();
 
-   if( formatSet )
-      debug_msg("DirectShowGrabber::setCaptureOutputFormat:  format set\n");
+   if ( formatSet ) {
+      if ( (curr_w != width_) || (curr_h != height_ )) {
+	   width_  = curr_w;
+	   height_ = curr_h;
+	   debug_msg("DirectShowGrabber::setCaptureOutputFormat:  format set to near res: %dx%d\n",width_,height_);
+      } else 
+	   debug_msg("DirectShowGrabber::setCaptureOutputFormat:  format set\n");
+   }
    else
       debug_msg("DirectShowGrabber::setCaptureOutputFormat:  format not set\n");
 }
@@ -699,19 +773,39 @@
          if (dec != decimate_) {
             decimate_ = dec;
             if (running_) {
-               stop();
-               setsize();
-			   setCaptureOutputFormat();
-               start();
-			} else{
-               setsize();
-			   setCaptureOutputFormat();
-			}
+		   stop();
+		   setsize();
+		   setCaptureOutputFormat();
+		   start();
+	    } else{
+		   setsize();
+		   setCaptureOutputFormat();
+	    }
          }
          return (TCL_OK);
       } else if (strcmp(argv[1], "port") == 0) {
          setport(argv[2]);
          return (TCL_OK);
+      } else if (strcmp(argv[1], "type") == 0) {
+	 if (strcmp(argv[2], "auto") == 0)
+		   ;
+	 else if (strcmp(argv[2], "pal") == 0) {
+		basewidth_  = CIF_BASE_WIDTH;
+		baseheight_ = CIF_BASE_HEIGHT;
+	 } else if (strcmp(argv[2], "ntsc") == 0) {
+		basewidth_  = NTSC_BASE_WIDTH;
+		baseheight_ = NTSC_BASE_HEIGHT;
+	 }
+         if (running_) {
+		   stop();
+		   setsize();
+		   setCaptureOutputFormat();
+		   start();
+	 } else if (decimate_!=-1) {
+		   setsize();
+		   setCaptureOutputFormat();
+	 }
+         return (TCL_OK);
       } else if (strcmp(argv[1], "useconfig") ==0) {
          if (strcmp(argv[2], "1") == 0)
             useconfig_=1;
@@ -751,20 +845,20 @@
 
    if(max_width_ >= D1_BASE_WIDTH){
 	  max_width_ = D1_BASE_WIDTH;
-      max_height_ = D1_BASE_HEIGHT;
+	  max_height_ = D1_BASE_HEIGHT;
    }
 
    if(decimate_ == 1){
        width_ = max_width_;
        height_ = max_height_;
-   }else{
+   } else {
        width_ = basewidth_  / decimate_;
        height_ = baseheight_ / decimate_;
    }
 
    debug_msg("DirectShowCIFGrabber::setsize: %dx%d\n", width_, height_);
 
-   set_size_411(width_, height_);
+   set_size_cif(width_, height_);
    allocref();
 }
 
@@ -779,10 +873,10 @@
    debug_msg("new DirectShowDevice():  friendlyName=%s\n", friendlyName);
    directShowFilter_  = pCapFilt;           
    //SV: XXX got rid of 422 format since there's no grabber returned for it and vic crashes
-   attributes_        = "format { 422 411 } size { large small cif } port { external-in } ";
+   attributes_        = "format { 411 } size { large small cif } port { external-in } type {pal ntsc} ";
    DirectShowCIFGrabber o(directShowFilter_); 
    
-   strcat(attri, "format { 411 } size { large small cif } port { ");
+   strcat(attri, "format { 411 } size { large small cif } type { pal ntsc } port { ");
    if(o.hasSVideo() || o.hasComposite()){
      if(o.hasSVideo()){
        strcat(attri, "S-Video ");
@@ -796,7 +890,6 @@
 
    strcat(attri, "} "); 
    attributes_ = attri;
-
 }
 
 DirectShowDevice::~DirectShowDevice(){

Modified: vic/branches/mpeg4/video/grabber.cpp
==============================================================================
--- vic/branches/mpeg4/video/grabber.cpp	(original)
+++ vic/branches/mpeg4/video/grabber.cpp	Tue Jun 12 15:57:23 2007
@@ -487,6 +487,7 @@
 		ispal = 1;
 		outw_ = 176;
 		outh_ = 144;
+		break;
 
 	case 384:
 		/* 1/2 PAL */
@@ -504,8 +505,10 @@
 
 	default:
 		/* XXX this shouldn't happen */
-		fprintf(stderr, "vic: CIF grabber: bad geometry\n");
-		abort();
+		fprintf(stderr, "vic: CIF grabber: bad geometry - trying 411\n");
+		set_size_411(w,h);
+		return;
+		//abort();
 	}
 	int s = outw_ * outh_;
 	framesize_ = s;



More information about the Sumover-dev mailing list