Index: trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvo.h	(revision 28837)
+++ trunk/Ohana/src/libdvo/include/dvo.h	(revision 28855)
@@ -318,4 +318,7 @@
 
 PhotCodeData *GetPhotcodeTable (void);
+void SetPhotcodeTable (PhotCodeData *);
+
+int *GetSecFiltMap(PhotCodeData *ouput, PhotCodeData* input);
 
 int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite);
Index: trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 28837)
+++ trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 28855)
@@ -21,10 +21,16 @@
 PhotCodeData *GetPhotcodeTable () {
 
-  /* allocate space to photcode table, free existing data */
   if (photcodes == NULL) {
+    /* allocate space to photcode table */
     ALLOCATE (photcodes, PhotCodeData, 1);
     photcodes[0].code = NULL;
   }
   return photcodes;
+}
+
+// set the photcode table. This is used to switch between serveral previously
+// allocated tables
+void SetPhotcodeTable (PhotCodeData *new) {
+  photcodes = new;  
 }
 
@@ -531,4 +537,26 @@
 }
 
+// Create a map between the secfilt values from one photcode table to another
+int *GetSecFiltMap(PhotCodeData *output, PhotCodeData *input) {
+  int i;
+  int NsecfiltIn  = input[0].Nsecfilt;
+  int *map;
+  ALLOCATE(map, int, NsecfiltIn);
+
+  // loop over entries 
+  for (i = 0; i < NsecfiltIn; i++) {
+    int code  = input[0].codeNsec[i];
+    int entry = output[0].hashcode[code];
+    if (entry == -1) {
+      // entry is missing
+      free(map);
+      return(FALSE);
+    }
+    map[i] = entry;
+  }
+
+  return map;
+}
+
 /* photcode table should have the following format: 
 
