Index: branches/pap/ppMerge/src/ppMergeReadChunk.c
===================================================================
--- branches/pap/ppMerge/src/ppMergeReadChunk.c	(revision 23948)
+++ branches/pap/ppMerge/src/ppMergeReadChunk.c	(revision 25027)
@@ -50,4 +50,5 @@
             for (int i = 0; i < readouts->n; i++) {
                 pmReadout *inRO = readouts->data[i]; ///< Input readout
+		if (!inRO->process) continue;
 
                 // override the recorded last scan
@@ -56,12 +57,24 @@
                 inRO->thisMaskScan   = fileGroup->firstScan;
                 inRO->forceScan      = true;
+                // inRO->process        = true;
+
+		// char *cellname = psMetadataLookupStr(&mdok, inRO->parent->concepts, "CELL.NAME");
+		// fprintf (stderr, "cell: %s, file %d, process: %d, image, mask, var: %lx, %lx, %lx -> ", 
+		// 	 cellname, i, inRO->process, (long int) inRO->image, (long int) inRO->mask, (long int) inRO->variance);
 
                 // Read a chunk from a file
                 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i);
 
+		int zMax = 0;
                 bool keepReading = false;
-                if (pmReadoutMore(inRO, file->fits, 0, rows, config)) {
+                if (pmReadoutMore(inRO, file->fits, 0, &zMax, rows, config)) {
+		    // skip video cells
+		    if (zMax > 1) {
+			psWarning ("skipping video cell (1: %ld)", (long) pthread_self());
+			inRO->process = false;
+			continue;
+		    }
                     keepReading = true;
-                    if (!pmReadoutReadChunk(inRO, file->fits, 0, rows, 0, config)) {
+                    if (!pmReadoutReadChunk(inRO, file->fits, 0, &zMax, rows, 0, config)) {
                         psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPMERGE.INPUT %d",
                                 numChunk, i);
@@ -69,10 +82,23 @@
                         return NULL;
                     }
+		    // skip video cells
+		    if (zMax > 1) {
+			psWarning ("skipping video cell (2: %ld)", (long) pthread_self());
+			inRO->process = false;
+			continue;
+		    }
                 }
+		// skip video cells
+		// XXX this could be more efficient if we identified the cells to skip before calling the function...
+		if (zMax > 1) {
+		    psWarning ("skipping video cell (3: %ld)", (long) pthread_self());
+		    inRO->process = false;
+		    continue;
+		}
 
-                if (haveMasks && pmReadoutMoreMask(inRO, file->fits, 0, rows, config)) {
+                if (haveMasks && pmReadoutMoreMask(inRO, file->fits, 0, &zMax, rows, config)) {
                     keepReading = true;
                     pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.MASK", i);
-                    if (!pmReadoutReadChunkMask(inRO, file->fits, 0, rows, 0, config)) {
+                    if (!pmReadoutReadChunkMask(inRO, file->fits, 0, &zMax, rows, 0, config)) {
                         psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPMERGE.INPUT.MASK %d",
                                 numChunk, i);
@@ -82,8 +108,8 @@
                 }
 
-                if (haveVariances && pmReadoutMoreVariance(inRO, file->fits, 0, rows, config)) {
+                if (haveVariances && pmReadoutMoreVariance(inRO, file->fits, 0, &zMax, rows, config)) {
                     keepReading = true;
                     pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.VARIANCE", i);
-                    if (!pmReadoutReadChunkVariance(inRO, file->fits, 0, rows, 0, config)) {
+                    if (!pmReadoutReadChunkVariance(inRO, file->fits, 0, &zMax, rows, 0, config)) {
                         psError(PS_ERR_IO, false,
                                 "Unable to read chunk %d for file PPMERGE.INPUT.VARIANCE %d",
@@ -93,4 +119,7 @@
                     }
                 }
+
+		// fprintf (stderr, "%lx, %lx, %lx\n", (long int) inRO->image, (long int) inRO->mask, (long int) inRO->variance);
+
                 if (!keepReading) {
                     return NULL;
