Index: trunk/ppImage/src/ppImage.h
===================================================================
--- trunk/ppImage/src/ppImage.h	(revision 33667)
+++ trunk/ppImage/src/ppImage.h	(revision 33848)
@@ -57,4 +57,8 @@
     bool addNoise;                      // Add noise to degrade MD image to 3pi
 
+  bool hasVideo;                      // Determine if this OTA has a video cell
+  bool useVideoDark;                  // Should we use a video dark if we can?
+  bool useVideoMask;                  // Should we use a video mask if we can?
+  
     // output files requested
     bool BaseFITS;
Index: trunk/ppImage/src/ppImageDetrendReadout.c
===================================================================
--- trunk/ppImage/src/ppImageDetrendReadout.c	(revision 33667)
+++ trunk/ppImage/src/ppImageDetrendReadout.c	(revision 33848)
@@ -35,5 +35,18 @@
       }
     }
-
+    // Check to see if we're in a chip that contains video
+    bool hasVideo = false;
+    {
+      if (psMetadataLookupStr(NULL,input->parent->parent->hdu->header,"CELLMODE")) {
+	psWarning("VIDEO: %d %d %d\n",(int) options->hasVideo,(int) options->useVideoDark, (int) options->useVideoMask);
+	char *Vptr = strchr(psMetadataLookupStr(NULL,input->parent->parent->hdu->header,"CELLMODE"),'V');
+	if (Vptr) {
+	  hasVideo = true;
+	  psWarning("VIDEO: %d %d %d\n",(int) options->hasVideo,(int) options->useVideoDark, (int) options->useVideoMask);
+	}
+      }
+    }
+
+    
     // Masking on the basis of pixel value needs to be done before anything else, so the values are pristine.
     if (options->doMaskBuild) {
@@ -44,6 +57,12 @@
     // apply the externally supplied mask to the input->mask pixels
     if (options->doMask) {
-        pmReadout *mask = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.MASK");
-        pmMaskBadPixels(input, mask, options->maskValue);
+      pmReadout *mask;
+      if ((options->useVideoMask)&&(hasVideo)) {
+        mask = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.VIDEOMASK");
+      }
+      else {
+	mask = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.MASK");
+      }
+      pmMaskBadPixels(input, mask, options->maskValue);
     }
     if (options->doMaskBurntool) {
@@ -80,9 +99,19 @@
         psMetadata *recipe = psMetadataLookupPtr (&mdok, config->recipes, RECIPE_NAME);
         assert(mdok && recipe);
-        if (psMetadataLookupBool(&mdok, recipe, "OLDDARK")) {
+
+	if ((options->useVideoDark)&&(hasVideo)) {
+	  if (psMetadataLookupBool(&mdok, recipe, "OLDDARK")) {
+            oldDark = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.VIDEODARK");
+	  } else {
+            dark = pmFPAfileThisCell(config->files, detview, "PPIMAGE.VIDEODARK");
+	  }
+	}
+	else {
+	  if (psMetadataLookupBool(&mdok, recipe, "OLDDARK")) {
             oldDark = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.DARK");
-        } else {
+	  } else {
             dark = pmFPAfileThisCell(config->files, detview, "PPIMAGE.DARK");
-        }
+	  }
+	}
     }
 
Index: trunk/ppImage/src/ppImageOptions.c
===================================================================
--- trunk/ppImage/src/ppImageOptions.c	(revision 33667)
+++ trunk/ppImage/src/ppImageOptions.c	(revision 33848)
@@ -45,5 +45,7 @@
     options->doMaskStats     = false;   // Calculate mask fractions
     options->addNoise        = false;  //Degrade an MD image to a 3pi image
-
+    options->hasVideo        = false;   // Determine if this OTA has a video cell
+    options->useVideoDark    = false;   // Use video dark if we can?
+    options->useVideoMask    = false;   // Use video mask if we can?
     // output files requested
     options->BaseFITS        = false;   // create output image
@@ -362,4 +364,12 @@
     options->fringeKeep = psMetadataLookupF32(NULL, recipe, "FRINGE.KEEP");
 
+    // Video cell options
+    if (psMetadataLookup(recipe, "USE.VIDEO.DARK")) {
+      options->useVideoDark = psMetadataLookupBool(NULL,recipe,"USE.VIDEO.DARK");
+    }
+    if (psMetadataLookup(recipe, "USE.VIDEO.MASK")) {
+      options->useVideoMask = psMetadataLookupBool(NULL,recipe,"USE.VIDEO.MASK");
+    }
+
     // Pattern correction
     if (psMetadataLookup(format, "PATTERN.ROW.ORDER")) {
@@ -418,5 +428,5 @@
       options->patternContinuityEdgeWidth = psMetadataLookupS32(NULL, recipe, "PATTERN.CONTINUITY.WIDTH");
     }
-    
+
 
     // Remnance options
Index: trunk/ppImage/src/ppImageParseCamera.c
===================================================================
--- trunk/ppImage/src/ppImageParseCamera.c	(revision 33667)
+++ trunk/ppImage/src/ppImageParseCamera.c	(revision 33848)
@@ -22,4 +22,28 @@
     ppImageOptions *options = ppImageOptionsParse(config);
 
+    // parse the header to extract out whether this OTA has video cells.
+    // CZW: 2012-05-01 I'm somewhat ashamed of what needs to be done to get to the header. There has to be a simpler way, right?
+/*     pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest */
+/*     pmChip *chip;                       // Chip from FPA */
+/*     while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) { */
+/*       if (!chip->process || !chip->file_exists) { */
+/* 	continue; */
+/*       } */
+/* /\*       if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { *\/ */
+/* /\* 	continue; *\/ */
+/* /\*       } *\/ */
+/*       psWarning("VIDEO: %d %d %d\n",(int) options->hasVideo,(int) options->useVideoDark, (int) options->useVideoMask); */
+/*       if (psMetadataLookupStr(NULL,chip->hdu->header,"CELLMODE")) { */
+/* 	psWarning("VIDEO: %d %d %d\n",(int) options->hasVideo,(int) options->useVideoDark, (int) options->useVideoMask); */
+/* 	char *Vptr = strchr(psMetadataLookupStr(NULL,chip->hdu->header,"CELLMODE"),'V'); */
+/* 	if (Vptr) { */
+/* 	  options->hasVideo = true; */
+/* 	  psWarning("VIDEO: %d %d %d\n",(int) options->hasVideo,(int) options->useVideoDark, (int) options->useVideoMask); */
+/* 	} */
+/*       } */
+/*     } */
+/*     pmFPAviewReset(view); */
+/*     psFree(view); */
+    
     // the following are defined from the argument list, if given,
     // otherwise they revert to the config information
@@ -42,18 +66,38 @@
     }
     if (options->doDark) {
-        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.DARK", "DARK",
-                               PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) {
+      // Always load the regular Dark
+      if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.DARK", "DARK",
+			     PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) {
+	psError(PS_ERR_IO, false, "Can't find a dark image source");
+	psFree(options);
+	return NULL;
+      }
+      // Sometimes load the video dark if we need it.
+      if (options->useVideoDark) {
+        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.VIDEODARK", "DARK",
+                               PM_FPA_FILE_DARK, PM_DETREND_TYPE_VIDEODARK)) {
             psError(PS_ERR_IO, false, "Can't find a dark image source");
             psFree(options);
             return NULL;
         }
+      }
     }
     if (options->doMask) {
-        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.MASK", "MASK",
-                               PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) {
+      // Always load the regular mask
+      if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.MASK", "MASK",
+			     PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) {
+	psError(PS_ERR_IO, false, "Can't find a mask image source");
+	psFree(options);
+	return NULL;
+      }
+
+      if (options->useVideoMask) {
+	if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.VIDEOMASK", "MASK",
+                               PM_FPA_FILE_MASK, PM_DETREND_TYPE_VIDEOMASK)) {
             psError(PS_ERR_IO, false, "Can't find a mask image source");
             psFree(options);
             return NULL;
         }
+      }
     }
     if (options->doShutter) {
