commit 787ddd974d6f0e3a2f74899579011b691de9c8f2
Author: David Sorber <david.sorber@gmail.com>
Date:   Tue Jul 10 21:45:20 2018 -0400

    WIP for libpackjpg reorganization: moved all jpeg specific functions into the wrapper class

diff --git a/software/packJPG_library/lib_src/packjpg.cpp b/software/packJPG_library/lib_src/packjpg.cpp
index 2418229..ed09e7a 100644
--- a/software/packJPG_library/lib_src/packjpg.cpp
+++ b/software/packJPG_library/lib_src/packjpg.cpp
@@ -330,45 +330,6 @@ static inline void* frealloc(void* ptr, size_t size)
 }
 
 
-
-
-/* -----------------------------------------------
-    function declarations: jpeg-specific
-    ----------------------------------------------- */
-
-bool jpg_setup_imginfo(void);
-bool jpg_parse_jfif(unsigned char type, unsigned int len, unsigned char* segment);
-bool jpg_rebuild_header(void);
-
-int jpg_decode_block_seq(BitReader* huffr, huffTree* dctree, huffTree* actree, short* block);
-int jpg_encode_block_seq(BitWriter* huffw, huffCodes* dctbl, huffCodes* actbl, short* block);
-
-int jpg_decode_dc_prg_fs(BitReader* huffr, huffTree* dctree, short* block);
-int jpg_encode_dc_prg_fs(BitWriter* huffw, huffCodes* dctbl, short* block);
-int jpg_decode_ac_prg_fs(BitReader* huffr, huffTree* actree, short* block,
-                         int* eobrun, int from, int to);
-int jpg_encode_ac_prg_fs(BitWriter* huffw, huffCodes* actbl, short* block,
-                         int* eobrun, int from, int to);
-
-int jpg_decode_dc_prg_sa(BitReader* huffr, short* block);
-int jpg_encode_dc_prg_sa(BitWriter* huffw, short* block);
-int jpg_decode_ac_prg_sa(BitReader* huffr, huffTree* actree, short* block,
-                         int* eobrun, int from, int to);
-int jpg_encode_ac_prg_sa(BitWriter* huffw, std::vector<std::uint8_t>& storw, huffCodes* actbl,
-                         short* block, int* eobrun, int from, int to);
-
-int jpg_decode_eobrun_sa(BitReader* huffr, short* block, int* eobrun, int from, int to);
-int jpg_encode_eobrun(BitWriter* huffw, huffCodes* actbl, int* eobrun);
-int jpg_encode_crbits(BitWriter* huffw, std::vector<std::uint8_t>& storw);
-
-int jpg_next_huffcode(BitReader* huffw, huffTree* ctree);
-int jpg_next_mcupos(int* mcu, int* cmp, int* csc, int* sub, int* dpos, int* rstw);
-int jpg_next_mcuposn(int* cmp, int* dpos, int* rstw);
-int jpg_skip_eobrun(int* cmp, int* dpos, int* rstw, int* eobrun);
-
-void jpg_build_huffcodes(unsigned char* clen, unsigned char* cval,
-                         huffCodes* hc, huffTree* ht);
-
 /* -----------------------------------------------
     function declarations: pjg-specific
     ----------------------------------------------- */
@@ -556,7 +517,6 @@ bool packJPG::pjglib_convert_stream2stream(char* msg)
     return pjglib_convert_stream2mem(nullptr, nullptr, msg);
 }
 
-
 /* -----------------------------------------------
     DLL export converter function
     ----------------------------------------------- */
@@ -569,7 +529,6 @@ bool packJPG::pjglib_convert_file2file(char* in, char* out, char* msg)
     return pjglib_convert_stream2mem(nullptr, nullptr, msg);
 }
 
-
 /* -----------------------------------------------
     DLL export converter function
     ----------------------------------------------- */
@@ -663,7 +622,6 @@ bool packJPG::pjglib_convert_stream2mem(
     return true;
 }
 
-
 /* -----------------------------------------------
     DLL export init input (file/mem)
     ----------------------------------------------- */
@@ -2946,12 +2904,13 @@ bool packJPG::jpg_setup_imginfo(void)
     return true;
 }
 
-#if 0
-
 /* -----------------------------------------------
     Parse routines for JFIF segments
     ----------------------------------------------- */
-bool jpg_parse_jfif(unsigned char type, unsigned int len, unsigned char* segment)
+bool packJPG::jpg_parse_jfif(
+    unsigned char type, 
+    unsigned int len, 
+    unsigned char* segment)
 {
     unsigned int hpos = 4; // current position in segment, start after segment header
     int lval, rval; // temporary variables
@@ -2959,7 +2918,6 @@ bool jpg_parse_jfif(unsigned char type, unsigned int len, unsigned char* segment
     int cmp;
     int i;
 
-
     switch (type)
     {
         case 0xC4: // DHT segment
@@ -3274,21 +3232,17 @@ bool jpg_parse_jfif(unsigned char type, unsigned int len, unsigned char* segment
     }
 }
 
-
 /* -----------------------------------------------
     JFIF header rebuilding routine
     ----------------------------------------------- */
-bool jpg_rebuild_header(void)
+bool packJPG::jpg_rebuild_header(void)
 {
-    MemoryWriter* hdrw; // new header writer
-
     unsigned char  type = 0x00; // type of current marker segment
     unsigned int   len  = 0; // length of current marker segment
     unsigned int   hpos = 0; // position in header
 
-
     // start headerwriter
-    hdrw = new MemoryWriter();
+    MemoryWriter* hdrw = new MemoryWriter(); // new header writer
 
     // header parser loop
     while ((int) hpos < hdrs)
@@ -3309,17 +3263,19 @@ bool jpg_rebuild_header(void)
     free(hdrdata);
     hdrdata = hdrw->get_c_data();
     hdrs    = hdrw->num_bytes_written();
-    delete (hdrw);
-
+    delete hdrw;
 
     return true;
 }
 
-
 /* -----------------------------------------------
     sequential block decoding routine
     ----------------------------------------------- */
-int jpg_decode_block_seq(BitReader* huffr, huffTree* dctree, huffTree* actree, short* block)
+int packJPG::jpg_decode_block_seq(
+    BitReader* huffr, 
+    huffTree* dctree, 
+    huffTree* actree, 
+    short* block)
 {
     unsigned short n;
     unsigned char  s;
@@ -3328,7 +3284,6 @@ int jpg_decode_block_seq(BitReader* huffr, huffTree* dctree, huffTree* actree, s
     int bpos;
     int hc;
 
-
     // decode dc
     hc = jpg_next_huffcode(huffr, dctree);
     if (hc < 0)
@@ -3377,16 +3332,18 @@ int jpg_decode_block_seq(BitReader* huffr, huffTree* dctree, huffTree* actree, s
         }
     }
 
-
     // return position of eob
     return eob;
 }
 
-
 /* -----------------------------------------------
     sequential block encoding routine
     ----------------------------------------------- */
-int jpg_encode_block_seq(BitWriter* huffw, huffCodes* dctbl, huffCodes* actbl, short* block)
+int packJPG::jpg_encode_block_seq(
+    BitWriter* huffw, 
+    huffCodes* dctbl, 
+    huffCodes* actbl, 
+    short* block)
 {
     unsigned short n;
     unsigned char  s;
@@ -3394,7 +3351,6 @@ int jpg_encode_block_seq(BitWriter* huffw, huffCodes* dctbl, huffCodes* actbl, s
     int bpos;
     int hc;
 
-
     // encode DC
     s = BITLEN2048N(block[0]);
     n = ENVLI(s, block[0]);
@@ -3435,21 +3391,21 @@ int jpg_encode_block_seq(BitWriter* huffw, huffCodes* dctbl, huffCodes* actbl, s
         huffw->write_u16(actbl->cval[0x00], actbl->clen[0x00]);
     }
 
-
     return 64 - z;
 }
 
-
 /* -----------------------------------------------
     progressive DC decoding routine
     ----------------------------------------------- */
-int jpg_decode_dc_prg_fs(BitReader* huffr, huffTree* dctree, short* block)
+int packJPG::jpg_decode_dc_prg_fs(
+    BitReader* huffr, 
+    huffTree* dctree, 
+    short* block)
 {
     unsigned short n;
     unsigned char  s;
     int hc;
 
-
     // decode dc
     hc = jpg_next_huffcode(huffr, dctree);
     if (hc < 0)
@@ -3463,37 +3419,41 @@ int jpg_decode_dc_prg_fs(BitReader* huffr, huffTree* dctree, short* block)
     n = huffr->read(s);
     block[0] = DEVLI(s, n);
 
-
     // return 0 if everything is ok
     return 0;
 }
 
-
 /* -----------------------------------------------
     progressive DC encoding routine
     ----------------------------------------------- */
-int jpg_encode_dc_prg_fs(BitWriter* huffw, huffCodes* dctbl, short* block)
+int packJPG::jpg_encode_dc_prg_fs(
+    BitWriter* huffw, 
+    huffCodes* dctbl, 
+    short* block)
 {
     unsigned short n;
     unsigned char  s;
 
-
     // encode DC
     s = BITLEN2048N(block[0]);
     n = ENVLI(s, block[0]);
     huffw->write_u16(dctbl->cval[s], dctbl->clen[s]);
     huffw->write_u16(n, s);
 
-
     // return 0 if everything is ok
     return 0;
 }
 
-
 /* -----------------------------------------------
     progressive AC decoding routine
     ----------------------------------------------- */
-int jpg_decode_ac_prg_fs(BitReader* huffr, huffTree* actree, short* block, int* eobrun, int from, int to)
+int packJPG::jpg_decode_ac_prg_fs(
+    BitReader* huffr, 
+    huffTree* actree, 
+    short* block, 
+    int* eobrun, 
+    int from, 
+    int to)
 {
     unsigned short n;
     unsigned char  s;
@@ -3504,7 +3464,6 @@ int jpg_decode_ac_prg_fs(BitReader* huffr, huffTree* actree, short* block, int*
     int l;
     int r;
 
-
     // decode ac
     for (bpos = from; bpos <= to;)
     {
@@ -3545,16 +3504,20 @@ int jpg_decode_ac_prg_fs(BitReader* huffr, huffTree* actree, short* block, int*
         }
     }
 
-
     // return position of eob
     return eob;
 }
 
-
 /* -----------------------------------------------
     progressive AC encoding routine
     ----------------------------------------------- */
-int jpg_encode_ac_prg_fs(BitWriter* huffw, huffCodes* actbl, short* block, int* eobrun, int from, int to)
+int packJPG::jpg_encode_ac_prg_fs(
+    BitWriter* huffw, 
+    huffCodes* actbl, 
+    short* block, 
+    int* eobrun, 
+    int from, 
+    int to)
 {
     unsigned short n;
     unsigned char  s;
@@ -3610,11 +3573,10 @@ int jpg_encode_ac_prg_fs(BitWriter* huffw, huffCodes* actbl, short* block, int*
     }
 }
 
-
 /* -----------------------------------------------
     progressive DC SA decoding routine
     ----------------------------------------------- */
-int jpg_decode_dc_prg_sa(BitReader* huffr, short* block)
+int packJPG::jpg_decode_dc_prg_sa(BitReader* huffr, short* block)
 {
     // decode next bit of dc coefficient
     block[0] = huffr->read(1);
@@ -3623,11 +3585,10 @@ int jpg_decode_dc_prg_sa(BitReader* huffr, short* block)
     return 0;
 }
 
-
 /* -----------------------------------------------
     progressive DC SA encoding routine
     ----------------------------------------------- */
-int jpg_encode_dc_prg_sa(BitWriter* huffw, short* block)
+int packJPG::jpg_encode_dc_prg_sa(BitWriter* huffw, short* block)
 {
     // enocode next bit of dc coefficient
     huffw->write_u16(block[0], 1);
@@ -3636,11 +3597,16 @@ int jpg_encode_dc_prg_sa(BitWriter* huffw, short* block)
     return 0;
 }
 
-
 /* -----------------------------------------------
     progressive AC SA decoding routine
     ----------------------------------------------- */
-int jpg_decode_ac_prg_sa(BitReader* huffr, huffTree* actree, short* block, int* eobrun, int from, int to)
+int packJPG::jpg_decode_ac_prg_sa(
+    BitReader* huffr, 
+    huffTree* actree, 
+    short* block, 
+    int* eobrun, 
+    int from, 
+    int to)
 {
     unsigned short n;
     unsigned char  s;
@@ -3652,71 +3618,70 @@ int jpg_decode_ac_prg_sa(BitReader* huffr, huffTree* actree, short* block, int*
     int l;
     int r;
 
-
     // decode AC succesive approximation bits
     if ((*eobrun) == 0) while (bpos <= to)
+    {
+        // decode next
+        hc = jpg_next_huffcode(huffr, actree);
+        if (hc < 0)
+        {
+            return -1;
+        }
+        l = LBITS(hc, 4);
+        r = RBITS(hc, 4);
+        // analyse code
+        if ((l == 15) || (r > 0))         // decode run/level combination
         {
-            // decode next
-            hc = jpg_next_huffcode(huffr, actree);
-            if (hc < 0)
+            z = l;
+            s = r;
+            if (s == 0)
             {
-                return -1;
+                v = 0;
+            }
+            else if (s == 1)
+            {
+                n = huffr->read(1);
+                v = (n == 0) ? -1 : 1;   // fast decode vli
+            }
+            else
+            {
+                return -1;    // decoding error
             }
-            l = LBITS(hc, 4);
-            r = RBITS(hc, 4);
-            // analyse code
-            if ((l == 15) || (r > 0))         // decode run/level combination
+            // write zeroes / write correction bits
+            while (true)
             {
-                z = l;
-                s = r;
-                if (s == 0)
+                if (block[bpos] == 0)     // skip zeroes / write value
                 {
-                    v = 0;
+                    if (z > 0)
+                    {
+                        z--;
+                    }
+                    else
+                    {
+                        block[bpos++] = v;
+                        break;
+                    }
                 }
-                else if (s == 1)
+                else   // read correction bit
                 {
                     n = huffr->read(1);
-                    v = (n == 0) ? -1 : 1;   // fast decode vli
-                }
-                else
-                {
-                    return -1;    // decoding error
+                    block[bpos] = (block[bpos] > 0) ? n : -n;
                 }
-                // write zeroes / write correction bits
-                while (true)
+                if (bpos++ >= to)
                 {
-                    if (block[bpos] == 0)     // skip zeroes / write value
-                    {
-                        if (z > 0)
-                        {
-                            z--;
-                        }
-                        else
-                        {
-                            block[bpos++] = v;
-                            break;
-                        }
-                    }
-                    else   // read correction bit
-                    {
-                        n = huffr->read(1);
-                        block[bpos] = (block[bpos] > 0) ? n : -n;
-                    }
-                    if (bpos++ >= to)
-                    {
-                        return -1;    // error check
-                    }
+                    return -1;    // error check
                 }
             }
-            else   // decode eobrun
-            {
-                eob = bpos;
-                s = l;
-                n = huffr->read(s);
-                (*eobrun) = E_DEVLI(s, n);
-                break;
-            }
         }
+        else   // decode eobrun
+        {
+            eob = bpos;
+            s = l;
+            n = huffr->read(s);
+            (*eobrun) = E_DEVLI(s, n);
+            break;
+        }
+    }
 
     // read after eob correction bits
     if ((*eobrun) > 0)
@@ -3735,11 +3700,17 @@ int jpg_decode_ac_prg_sa(BitReader* huffr, huffTree* actree, short* block, int*
     return eob;
 }
 
-
 /* -----------------------------------------------
     progressive AC SA encoding routine
     ----------------------------------------------- */
-int jpg_encode_ac_prg_sa(BitWriter* huffw, std::vector<std::uint8_t>& storw, huffCodes* actbl, short* block, int* eobrun, int from, int to)
+int packJPG::jpg_encode_ac_prg_sa(
+    BitWriter* huffw, 
+    std::vector<std::uint8_t>& storw, 
+    huffCodes* actbl, 
+    short* block, 
+    int* eobrun, 
+    int from, 
+    int to)
 {
     unsigned short n;
     unsigned char  s;
@@ -3828,16 +3799,19 @@ int jpg_encode_ac_prg_sa(BitWriter* huffw, std::vector<std::uint8_t>& storw, huf
     return eob;
 }
 
-
 /* -----------------------------------------------
     run of EOB SA decoding routine
     ----------------------------------------------- */
-int jpg_decode_eobrun_sa(BitReader* huffr, short* block, int* eobrun, int from, int to)
+int packJPG::jpg_decode_eobrun_sa(
+    BitReader* huffr, 
+    short* block, 
+    int* eobrun, 
+    int from, 
+    int to)
 {
     unsigned short n;
     int bpos;
 
-
     // fast eobrun decoding routine for succesive approximation
     for (bpos = from; bpos <= to; bpos++)
     {
@@ -3848,21 +3822,21 @@ int jpg_decode_eobrun_sa(BitReader* huffr, short* block, int* eobrun, int from,
         }
     }
 
-
     return 0;
 }
 
-
 /* -----------------------------------------------
     run of EOB encoding routine
     ----------------------------------------------- */
-int jpg_encode_eobrun(BitWriter* huffw, huffCodes* actbl, int* eobrun)
+int packJPG::jpg_encode_eobrun(
+    BitWriter* huffw, 
+    huffCodes* actbl, 
+    int* eobrun)
 {
     unsigned short n;
     unsigned char  s;
     int hc;
 
-
     if ((*eobrun) > 0)
     {
         while ((*eobrun) > actbl->max_eobrun)
@@ -3880,15 +3854,15 @@ int jpg_encode_eobrun(BitWriter* huffw, huffCodes* actbl, int* eobrun)
         (*eobrun) = 0;
     }
 
-
     return 0;
 }
 
-
 /* -----------------------------------------------
     correction bits encoding routine
     ----------------------------------------------- */
-int jpg_encode_crbits(BitWriter* huffw, std::vector<std::uint8_t>& storw)
+int packJPG::jpg_encode_crbits(
+    BitWriter* huffw, 
+    std::vector<std::uint8_t>& storw)
 {
     for (const std::uint8_t bit : storw)
     {
@@ -3898,19 +3872,16 @@ int jpg_encode_crbits(BitWriter* huffw, std::vector<std::uint8_t>& storw)
     return 0;
 }
 
-
 /* -----------------------------------------------
     returns next code (from huffman-tree & -data)
     ----------------------------------------------- */
-int jpg_next_huffcode(BitReader* huffw, huffTree* ctree)
+int packJPG::jpg_next_huffcode(BitReader* huffw, huffTree* ctree)
 {
     int node = 0;
 
-
     while (node < 256)
     {
-        node = (huffw->read(1) == 1) ?
-               ctree->r[node] : ctree->l[node];
+        node = (huffw->read(1) == 1) ? ctree->r[node] : ctree->l[node];
         if (node == 0)
         {
             break;
@@ -3920,15 +3891,19 @@ int jpg_next_huffcode(BitReader* huffw, huffTree* ctree)
     return (node - 256);
 }
 
-
 /* -----------------------------------------------
     calculates next position for MCU
     ----------------------------------------------- */
-int jpg_next_mcupos(int* mcu, int* cmp, int* csc, int* sub, int* dpos, int* rstw)
+int packJPG::jpg_next_mcupos(
+    int* mcu, 
+    int* cmp, 
+    int* csc, 
+    int* sub, 
+    int* dpos, 
+    int* rstw)
 {
     int sta = 0; // status
 
-
     // increment all counts where needed
     if ((++(*sub)) >= cmpnfo[(*cmp)].mbs)
     {
@@ -3973,15 +3948,13 @@ int jpg_next_mcupos(int* mcu, int* cmp, int* csc, int* sub, int* dpos, int* rstw
         (*dpos) = (*mcu);
     }
 
-
     return sta;
 }
 
-
 /* -----------------------------------------------
     calculates next position (non interleaved)
     ----------------------------------------------- */
-int jpg_next_mcuposn(int* cmp, int* dpos, int* rstw)
+int packJPG::jpg_next_mcuposn(int* cmp, int* dpos, int* rstw)
 {
     // increment position
     (*dpos)++;
@@ -4015,15 +3988,13 @@ int jpg_next_mcuposn(int* cmp, int* dpos, int* rstw)
             return 1;
         }
 
-
     return 0;
 }
 
-
 /* -----------------------------------------------
     skips the eobrun, calculates next position
     ----------------------------------------------- */
-int jpg_skip_eobrun(int* cmp, int* dpos, int* rstw, int* eobrun)
+int packJPG::jpg_skip_eobrun(int* cmp, int* dpos, int* rstw, int* eobrun)
 {
     if ((*eobrun) > 0)   // error check for eobrun
     {
@@ -4080,18 +4051,20 @@ int jpg_skip_eobrun(int* cmp, int* dpos, int* rstw, int* eobrun)
     return 0;
 }
 
-
 /* -----------------------------------------------
     creates huffman-codes & -trees from dht-data
     ----------------------------------------------- */
-void jpg_build_huffcodes(unsigned char* clen, unsigned char* cval,  huffCodes* hc, huffTree* ht)
+void packJPG::jpg_build_huffcodes(
+    unsigned char* clen, 
+    unsigned char* cval, 
+    huffCodes* hc, 
+    huffTree* ht)
 {
     int nextfree;
     int code;
     int node;
     int i, j, k;
 
-
     // fill with zeroes
     memset(hc->clen, 0, 256 * sizeof(short));
     memset(hc->cval, 0, 256 * sizeof(short));
@@ -4174,11 +4147,12 @@ void jpg_build_huffcodes(unsigned char* clen, unsigned char* cval,  huffCodes* h
     }
 }
 
-/* ----------------------- End of JPEG specific functions -------------------------- */
+/* ------------------- End of JPEG specific functions ---------------------- */
 
-/* ----------------------- End of PJG specific functions -------------------------- */
 
+/* ------------------- End of PJG specific functions ----------------------- */
 
+#if 0
 /* -----------------------------------------------
     encodes frequency scanorder to pjg
     ----------------------------------------------- */
diff --git a/software/packJPG_library/lib_src/packjpg.h b/software/packJPG_library/lib_src/packjpg.h
index 5c08d1f..4c2877b 100644
--- a/software/packJPG_library/lib_src/packjpg.h
+++ b/software/packJPG_library/lib_src/packjpg.h
@@ -136,8 +136,114 @@ private:
      *************************************************************************/ 
      
     bool jpg_setup_imginfo(void);
+    
+    bool jpg_parse_jfif(
+        unsigned char type, 
+        unsigned int len, 
+        unsigned char* segment);
+        
+    bool jpg_rebuild_header(void);
+    
+    int jpg_decode_block_seq(
+        BitReader* huffr, 
+        huffTree* dctree, 
+        huffTree* actree, 
+        short* block);
+        
+    int jpg_encode_block_seq(
+        BitWriter* huffw, 
+        huffCodes* dctbl, 
+        huffCodes* actbl, 
+        short* block);
 
+    int jpg_decode_dc_prg_fs(
+        BitReader* huffr, 
+        huffTree* dctree, 
+        short* block);
+        
+    int jpg_encode_dc_prg_fs(
+        BitWriter* huffw, 
+        huffCodes* dctbl, 
+        short* block);
+        
+    int jpg_decode_ac_prg_fs(
+        BitReader* huffr, 
+        huffTree* actree, 
+        short* block, 
+        int* eobrun, 
+        int from, 
+        int to);
+        
+    int jpg_encode_ac_prg_fs(
+        BitWriter* huffw, 
+        huffCodes* actbl, 
+        short* block, 
+        int* eobrun, 
+        int from, 
+        int to);
 
+    int jpg_decode_dc_prg_sa(BitReader* huffr, short* block);
+    
+    int jpg_encode_dc_prg_sa(BitWriter* huffw, short* block);
+    
+    int jpg_decode_ac_prg_sa(
+        BitReader* huffr, 
+        huffTree* actree, 
+        short* block, 
+        int* eobrun, 
+        int from, 
+        int to);
+        
+    int jpg_encode_ac_prg_sa(
+        BitWriter* huffw, 
+        std::vector<std::uint8_t>& storw, 
+        huffCodes* actbl, 
+        short* block, 
+        int* eobrun, 
+        int from, 
+        int to);
+        
+    int jpg_decode_eobrun_sa(
+        BitReader* huffr, 
+        short* block, 
+        int* eobrun, 
+        int from, 
+        int to);
+        
+    int jpg_encode_eobrun(
+        BitWriter* huffw, 
+        huffCodes* actbl, 
+        int* eobrun);
+        
+    int jpg_encode_crbits(
+        BitWriter* huffw, 
+        std::vector<std::uint8_t>& storw);
+        
+    int jpg_next_huffcode(BitReader* huffw, huffTree* ctree);
+    
+    int jpg_next_mcupos(
+        int* mcu, 
+        int* cmp, 
+        int* csc, 
+        int* sub, 
+        int* dpos, 
+        int* rstw);
+        
+    int jpg_next_mcuposn(int* cmp, int* dpos, int* rstw);
+    
+    int jpg_skip_eobrun(int* cmp, int* dpos, int* rstw, int* eobrun);
+    
+    void jpg_build_huffcodes(
+        unsigned char* clen, 
+        unsigned char* cval, 
+        huffCodes* hc, 
+        huffTree* ht);
+        
+    /**************************************************************************
+     * PJG specific functions
+     *************************************************************************/ 
+     
+     
 
     /**************************************************************************
      * Member variables
