Index: trunk/ppImage/src/ppImageDetrendReadout.c
===================================================================
--- trunk/ppImage/src/ppImageDetrendReadout.c	(revision 33590)
+++ 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");
-        }
+	  }
+	}
     }
 
