[xiph-cvs] cvs commit: w3d/tools Makefile makedepend.sh ppmdiff.c makedepend

Holger Waechtler holger at xiph.org
Mon Jul 2 01:28:47 PDT 2001



holger      01/07/02 01:28:47

  Modified:    .        Makefile TODO _test_rle.c bitcoder.h rle.h tarkin.c
                        tarkin_enc.c wavelet.c wavelet_xform.c
  Added:       tools    Makefile makedepend.sh ppmdiff.c
  Removed:     tools    makedepend
  Log:
   - simplified coefficient encoder
   - end-of-bitstream handling is now done in rle.h
   - added ppmdiff.c (very simple hack !)
   - renamed makedepend to makedepend.sh
   - fixed some bugs, discovered others

Revision  Changes    Path
1.7       +1 -1      w3d/Makefile

Index: Makefile
===================================================================
RCS file: /usr/local/cvsroot/w3d/Makefile,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Makefile	2001/06/29 15:15:54	1.6
+++ Makefile	2001/07/02 08:28:45	1.7
@@ -39,6 +39,6 @@
 .depend: $(SRCS) $(TEST_SRCS)
         $(RM) .depend
         touch .depend
-	sh tools/makedepend -f.depend -- $(CFLAGS) -- $(SRCS) $(TEST_SRCS) tarkin_enc.c tarkin_dec.c
+	sh tools/makedepend.sh -f.depend -- $(CFLAGS) -- $(SRCS) $(TEST_SRCS) tarkin_enc.c tarkin_dec.c
 
 -include .depend

1.5       +13 -3     w3d/TODO

Index: TODO
===================================================================
RCS file: /usr/local/cvsroot/w3d/TODO,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TODO	2001/06/29 09:19:25	1.4
+++ TODO	2001/07/02 08:28:45	1.5
@@ -1,7 +1,17 @@
-- segfaults while destroying encoder stream
+Open bugs and stuff required to fix them:
 
-Here only the wavelet-related TODO's:
+ - there is something really wrong in the truncation table code 
+ - segfaults when bitstream limit is very high
+    (we better should check malloc return codes)
+ - there are strange errors accumulating over time ...
+    (probably incomplete initialisation)
+ - add the pnsr tools
+ - use Simon's pnm routines, support grayscale images, ppmdiff->pnmdiff
 
+
+Wavelet-related TODO's:
+
+ - implement truncation table setup
  - arithmetic binary entropy coders may be faster, simpler and more efficient;
     implement the ZP-Coder
  - oggetize the stream format
@@ -13,7 +23,7 @@
  - mmx/3dnow/sse/altivec
 
 
-other TODO's:
+Other:
 
  - think about a multiresolution multidimensional motion detection scheme
  - the wavelet codec could be used for still image compression too

1.2       +3 -3      w3d/_test_rle.c

Index: _test_rle.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/_test_rle.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- _test_rle.c	2001/06/25 07:56:07	1.1
+++ _test_rle.c	2001/07/02 08:28:45	1.2
@@ -17,8 +17,8 @@
 
 
 
-#define MAX_COUNT 650000          /*  write/read up to 650000 bits   */
-#define N_TESTS   100             /*  test 100 times                 */
+#define MAX_COUNT 650000        /*  write/read up to 650000 bits   */
+#define N_TESTS   100           /*  test 100 times                 */
 
 
 int main ()
@@ -54,7 +54,7 @@
          ENTROPY_ENCODER_INIT(&encoder, limit);
 
          for (i=0; i<limit; i++) {
-            bit[i] = (rand() > RAND_MAX/2) ? 0 : 1;
+            bit[i] = (rand() > RAND_MAX/20) ? 0 : 1;
             OUTPUT_BIT(&encoder, bit[i]);
          }
 

1.3       +3 -1      w3d/bitcoder.h

Index: bitcoder.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/bitcoder.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bitcoder.h	2001/06/29 09:19:25	1.2
+++ bitcoder.h	2001/07/02 08:28:45	1.3
@@ -19,7 +19,6 @@
 #define ENTROPY_DECODER_INIT(coder,bitstream,limit) \
    bitcoder_decoder_init(coder,bitstream,limit)
 #define ENTROPY_DECODER_DONE(coder)       /* nothing to do ... */
-#define ENTROPY_CODER_IS_EMPTY(coder)     bitcoder_is_empty (coder)
 #define ENTROPY_CODER_BITSTREAM(coder)    (coder)->bitstream
 
 #endif
@@ -80,7 +79,10 @@
 int bitcoder_is_empty (BitCoderState *s)
 {
    if (!s->bitstream || s->byte_count >= s->limit)
+{
+printf ("bitcoder empty !!!\n");
       return 1;
+}
 
    return 0;
 }

1.4       +12 -12    w3d/rle.h

Index: rle.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/rle.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rle.h	2001/06/29 09:19:25	1.3
+++ rle.h	2001/07/02 08:28:45	1.4
@@ -17,7 +17,6 @@
 #define ENTROPY_DECODER_INIT(coder,bitstream,limit) \
    rlecoder_decoder_init(coder,bitstream,limit)
 #define ENTROPY_DECODER_DONE(coder)       /* nothing to do ... */
-#define ENTROPY_CODER_IS_EMPTY(coder)     bitcoder_is_empty(&(coder)->bitcoder)
 #define ENTROPY_CODER_BITSTREAM(coder)    ((coder)->bitcoder.bitstream)
 
 #endif
@@ -153,7 +152,7 @@
       huffmancoder_write (&s->bitcoder, bit ? 1 : 0);
    }
 
-   if ((bit & 1) == s->mps) {
+   if (s->mps == bit) {
       s->count++;
    } else {
 #ifdef RLE_HISTOGRAM
@@ -170,21 +169,18 @@
    }
 }
 
-
 static inline
 int rlecoder_read_bit (RLECoderState *s)
 {
-   if (s->mps == -1) {
-      s->mps = huffmancoder_read (&s->bitcoder);
-      s->count = huffmancoder_read (&s->bitcoder) + 1;
-   }
-
    if (s->count == 0) {
       s->count = huffmancoder_read (&s->bitcoder) + 1;
       s->mps = ~s->mps & 1;
+      if (bitcoder_is_empty(&s->bitcoder)) {
+         s->mps = 0;
+         s->count = ~0;
+      }
    }
    s->count--;
-
    return (s->mps);
 }
 
@@ -193,9 +189,9 @@
 static inline
 void rlecoder_encoder_init (RLECoderState *s, uint32_t limit)
 {
+   bitcoder_encoder_init (&s->bitcoder, limit);
    s->mps = -1;
    s->count = 0;
-   bitcoder_encoder_init (&s->bitcoder, limit);
 }
 
 
@@ -214,9 +210,13 @@
 static inline
 void rlecoder_decoder_init (RLECoderState *s, uint8_t *bitstream, uint32_t limit)
 {
-   s->mps = -1;
-   s->count = 0;
    bitcoder_decoder_init (&s->bitcoder, bitstream, limit);
+   s->mps = huffmancoder_read (&s->bitcoder);
+   s->count = huffmancoder_read (&s->bitcoder) + 1;
+   if (bitcoder_is_empty(&s->bitcoder)) {
+      s->mps = 0;
+      s->count = ~0;
+   }
 }
 
 

1.5       +13 -1     w3d/tarkin.c

Index: tarkin.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/tarkin.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- tarkin.c	2001/06/29 15:13:07	1.4
+++ tarkin.c	2001/07/02 08:28:45	1.5
@@ -130,9 +130,15 @@
       for (j=0; j<layer->n_comp; j++) {
          uint32_t bitstream_len;
 
+         wavelet_3d_buf_dump ("color-%d-%03d.ppm",
+                              s->current_frame - s->current_frame_in_buf, j,
+                              layer->waveletbuf[j]);
+
          wavelet_3d_buf_fwd_xform (layer->waveletbuf[j], 2, 2);
+
          wavelet_3d_buf_dump ("coeff-%d-%03d.ppm",
-                              s->current_frame, j, layer->waveletbuf[j]);
+                              s->current_frame - s->current_frame_in_buf, j,
+                              layer->waveletbuf[j]);
 
          bitstream_len = wavelet_3d_buf_encode_coeff (layer->waveletbuf[j],
                                                       s->bitstream,
@@ -268,9 +274,15 @@
 
             wavelet_3d_buf_decode_coeff (layer->waveletbuf[j], s->bitstream,
                                          bitstream_len);
+
             wavelet_3d_buf_dump ("rcoeff-%d-%03d.ppm",
                                  s->current_frame, j, layer->waveletbuf[j]);
+
             wavelet_3d_buf_inv_xform (layer->waveletbuf[j], 2, 2);
+
+            wavelet_3d_buf_dump ("rcolor-%d-%03d.ppm",
+                                 s->current_frame - s->current_frame_in_buf, j,
+                                 layer->waveletbuf[j]);
          }
       }
    }

1.4       +1 -1      w3d/tarkin_enc.c

Index: tarkin_enc.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/tarkin_enc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- tarkin_enc.c	2001/06/29 15:13:07	1.3
+++ tarkin_enc.c	2001/07/02 08:28:45	1.4
@@ -80,7 +80,7 @@
 
       tarkin_stream_write_frame (tarkin_stream, &rgb);
       frame++;
-   } while (0);
+   } while (1);
 
    free (rgb);
    tarkin_stream_destroy (tarkin_stream);

1.7       +83 -89    w3d/wavelet.c

Index: wavelet.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/wavelet.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- wavelet.c	2001/06/29 15:13:07	1.6
+++ wavelet.c	2001/07/02 08:28:45	1.7
@@ -107,84 +107,49 @@
                    ENTROPY_CODER insignificand_bitstream [],
                    TYPE coeff)
 {
+   TYPE mask [2] = { 0, ~0 };
    int sign = (coeff >> SIGN_SHIFT) & 1;
-   int i = 8;
+   TYPE significance = coeff ^ mask[sign];
+   int i = 10;
 
    do {
-      int this_bit = (coeff >> i) & 1;
-      int bit_is_significand = sign ^ this_bit;
+      i--;
+      OUTPUT_BIT(&significand_bitstream[i], (significance >> i) & 1);
+   } while (!((significance >> i) & 1) && i > 0);
 
-      if (bit_is_significand) {
-         OUTPUT_BIT(&significand_bitstream[i], 1);
-         OUTPUT_BIT(&significand_bitstream[i], sign);
-         break;
-      } else {
-         OUTPUT_BIT(&significand_bitstream[i], 0);
-         if (i == 0)
-            OUTPUT_BIT(&significand_bitstream[i], sign);
-      }
-   } while (--i >= 0);
+   OUTPUT_BIT(&significand_bitstream[i], sign);
 
    while (--i >= 0)
-      OUTPUT_BIT(&insignificand_bitstream[i], ((coeff >> i) ^ sign) & 1);
+      OUTPUT_BIT(&insignificand_bitstream[i], (significance >> i) & 1);
 }
 
-static TYPE coefficient_table [][2] = {
-   { 1, ~1 },       //  000000001
-   { 2, ~2 },       //  000000010
-   { 4, ~4 },       //  000000100
-   { 8, ~8 },       //  000001000
-   { 16, ~16 },     //  000010000
-   { 32, ~32 },     //  000100000
-   { 64, ~64 },     //  001000000
-   { 128, ~128 },   //  010000000
-   { 256, ~256 }    //  100000000
-};
-
-
 
 static inline
 TYPE decode_coeff (ENTROPY_CODER significand_bitstream [],
                    ENTROPY_CODER insignificand_bitstream [])
 {
-   int i = 8;
-   TYPE coeff = 0;
+   TYPE mask [2] = { 0, ~0 };
+   TYPE significance;
+   int sign;
+   int i = 10;
 
    do {
-      if (ENTROPY_CODER_IS_EMPTY(&significand_bitstream[i]))
-         continue;
+      i--;
+      significance = INPUT_BIT(&significand_bitstream[i]) << i;
+   } while (!significance && i > 0);
 
-      if (INPUT_BIT(&significand_bitstream[i])) {
-         int sign;
-
-         if (ENTROPY_CODER_IS_EMPTY(&significand_bitstream[i]))
-            continue;
-
-         sign = INPUT_BIT(&significand_bitstream[i]);
-         coeff = coefficient_table [i][sign];
-         break;
-      } else if (i == 0) {
-         if (ENTROPY_CODER_IS_EMPTY(&significand_bitstream[i]))
-            continue;
-
-         if (INPUT_BIT(&significand_bitstream[i]))
-            coeff = ~0;
-      }
-   } while (--i >= 0);
+   sign = INPUT_BIT(&significand_bitstream[i]);
 
    while (--i >= 0) {
-      if (ENTROPY_CODER_IS_EMPTY(&insignificand_bitstream[i]))
-         continue;
+      significance |= INPUT_BIT(&insignificand_bitstream[i]) << i;
+   };
 
-      coeff ^= INPUT_BIT(&insignificand_bitstream[i]) << i;
-   }
-
-   return coeff;
+   return (significance ^ mask[sign]);
 }
 
 
 
-
+#if 0
 static inline
 void encode_quadrant (const Wavelet3DBuf* buf,
                       int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
@@ -291,16 +256,43 @@
          decode_quadrant (buf,level,7,w1,h1,f1,s_stream,i_stream);
    }
 }
+#endif
 
+static
+void encode_coefficients (const Wavelet3DBuf* buf,
+                          ENTROPY_CODER s_stream [],
+                          ENTROPY_CODER i_stream [])
+{
+   uint32_t i;
 
+   for (i=0; i<buf->width*buf->height*buf->frames; i++)
+      encode_coeff(s_stream, i_stream, buf->data[i]);
+}
+
 static
-uint32_t insignificand_truncation_table [9] = {
-   2, 4, 8, 16, 32, 64, 128, 256, 512
+void decode_coefficients (Wavelet3DBuf* buf,
+                          ENTROPY_CODER s_stream [],
+                          ENTROPY_CODER i_stream [])
+{
+   uint32_t i;
+
+   for (i=0; i<buf->width*buf->height*buf->frames; i++)
+      buf->data[i] = decode_coeff(s_stream, i_stream);
+}
+
+
+
+static
+uint32_t insignificand_truncation_table [10] = {
+//   1, 2, 4, 8, 16, 32, 64, 128, 256, 512
+   100, 100, 100, 100, 100, 100, 100, 100, 100, 100
 };
 
 
 static
-uint32_t significand_truncation_table [8] = { 2, 4, 8, 16, 32, 64, 128, 256 };
+uint32_t significand_truncation_table [9] = { //1, 2, 4, 8, 16, 32, 64, 128, 256 };
+   100, 100, 100, 100, 100, 100, 100, 100, 100
+};
 
 
 static
@@ -313,11 +305,11 @@
    uint32_t byte_count = 0;
    int i;
 
-//printf ("%s: limit == %u\n", __FUNCTION__, limit);
-   limit -= 2 * 9 * sizeof(uint32_t);  /* 2 limittabs, coded binary */
-//printf ("%s: rem. limit == %u\n", __FUNCTION__, limit);
+printf ("%s: limit == %u\n", __FUNCTION__, limit);
+   limit -= 2 * 10 * sizeof(uint32_t);  /* 2 limittabs, coded binary */
+printf ("%s: rem. limit == %u\n", __FUNCTION__, limit);
 
-   for (i=0; i<9; i++) {
+   for (i=0; i<10; i++) {
       uint32_t bytes = ENTROPY_ENCODER_FLUSH(&insignificand_bitstream[i]);
 
       insignificand_limittab[i] =
@@ -325,26 +317,26 @@
 
       if (bytes < insignificand_limittab[i])
          insignificand_limittab[i] = bytes;
-//printf ("insignificand_limittab[%i]  == %u\n", i, insignificand_limittab[i]);
+printf ("insignificand_limittab[%i]  == %u\n", i, insignificand_limittab[i]);
       byte_count += insignificand_limittab[i];
    }
 
-   for (i=8; i>0; i--) {
+   for (i=9; i>0; i--) {
       uint32_t bytes = ENTROPY_ENCODER_FLUSH(&significand_bitstream[i]);
 
-      significand_limittab[i] = limit * significand_truncation_table[8-i] / 2048;
+      significand_limittab[i] = limit * significand_truncation_table[9-i] / 2048;
 
       if (bytes < significand_limittab[i])
          significand_limittab[i] = bytes;
-//printf ("significand_limittab[%i]  == %u\n", i, significand_limittab[i]);
+printf ("significand_limittab[%i]  == %u\n", i, significand_limittab[i]);
       byte_count += significand_limittab[i];
    }
 
-   significand_limittab[i] = limit - byte_count;
-   byte_count += significand_limittab[i];
+   significand_limittab[0] = limit - byte_count;
+   byte_count += significand_limittab[0];
 
-//printf ("significand_limittab[%i]  == %u\n", i, significand_limittab[i]);
-//printf ("byte_count == %u\n", byte_count);
+printf ("significand_limittab[%i]  == %u\n", 0, significand_limittab[0]);
+printf ("byte_count == %u\n", byte_count);
    return byte_count;
 }
 
@@ -359,12 +351,12 @@
 {
    int i;
 
-   for (i=0; i<9; i++) {
+   for (i=0; i<10; i++) {
       *(uint32_t*) bitstream = significand_limittab[i];
       bitstream += 4;
    }
 
-   for (i=0; i<9; i++) {
+   for (i=0; i<10; i++) {
       *(uint32_t*) bitstream = insignificand_limittab[i];
       bitstream += 4;
    }
@@ -380,13 +372,15 @@
 {
    int i;
 
-   for (i=0; i<9; i++) {
+   for (i=0; i<10; i++) {
       significand_limittab[i] = *(uint32_t*) bitstream;
+printf ("significand_limittab[%i]  == %u\n", i, significand_limittab[i]);
       bitstream += 4;
    }
 
-   for (i=0; i<9; i++) {
+   for (i=0; i<10; i++) {
       insignificand_limittab[i] = *(uint32_t*) bitstream;
+printf ("insignificand_limittab[%i]  == %u\n", i, insignificand_limittab[i]);
       bitstream += 4;
    }
  
@@ -406,7 +400,7 @@
 {
    int i;
 
-   for (i=8; i>=0; i--) {
+   for (i=9; i>=0; i--) {
       memcpy (bitstream,
               ENTROPY_CODER_BITSTREAM(&significand_bitstream[i]),
               significand_limittab[i]);
@@ -414,7 +408,7 @@
       bitstream += significand_limittab[i];
    }
 
-   for (i=8; i>=0; i--) {
+   for (i=9; i>=0; i--) {
       memcpy (bitstream,
               ENTROPY_CODER_BITSTREAM(&insignificand_bitstream[i]),
               insignificand_limittab[i]);
@@ -434,13 +428,13 @@
    uint32_t byte_count;
    int i;
 
-   for (i=8; i>=0; i--) {
+   for (i=9; i>=0; i--) {
       byte_count = significand_limittab[i];
       ENTROPY_DECODER_INIT(&significand_bitstream[i], bitstream, byte_count);
       bitstream += byte_count;
    }
 
-   for (i=8; i>=0; i--) {
+   for (i=9; i>=0; i--) {
       byte_count = insignificand_limittab[i];
       ENTROPY_DECODER_INIT(&insignificand_bitstream[i], bitstream, byte_count);
       bitstream += byte_count;
@@ -452,14 +446,14 @@
                                  uint8_t *bitstream,
                                  uint32_t limit)
 {
-   ENTROPY_CODER significand_bitstream [9];
-   ENTROPY_CODER insignificand_bitstream [9];
-   uint32_t significand_limittab [9];
-   uint32_t insignificand_limittab [9];
+   ENTROPY_CODER significand_bitstream [10];
+   ENTROPY_CODER insignificand_bitstream [10];
+   uint32_t significand_limittab [10];
+   uint32_t insignificand_limittab [10];
    uint32_t byte_count;
    int i;
 
-   for (i=0; i<9; i++) {
+   for (i=0; i<10; i++) {
       ENTROPY_ENCODER_INIT(&significand_bitstream[i], limit);
       ENTROPY_ENCODER_INIT(&insignificand_bitstream[i], limit);
    }
@@ -476,7 +470,7 @@
    merge_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
                      significand_limittab, insignificand_limittab);
 
-   for (i=0; i<9; i++) {
+   for (i=0; i<10; i++) {
       ENTROPY_ENCODER_DONE(&significand_bitstream[i]);
       ENTROPY_ENCODER_DONE(&insignificand_bitstream[i]);
    }
@@ -489,10 +483,10 @@
                                   uint8_t *bitstream,
                                   uint32_t byte_count)
 {
-   ENTROPY_CODER significand_bitstream [9];
-   ENTROPY_CODER insignificand_bitstream [9];
-   uint32_t significand_limittab [9];
-   uint32_t insignificand_limittab [9];
+   ENTROPY_CODER significand_bitstream [10];
+   ENTROPY_CODER insignificand_bitstream [10];
+   uint32_t significand_limittab [10];
+   uint32_t insignificand_limittab [10];
    int i;
 
    for (i=0; i<buf->width*buf->height*buf->frames; i++)
@@ -506,7 +500,7 @@
 
    decode_coefficients (buf, significand_bitstream, insignificand_bitstream);
 
-   for (i=0; i<9; i++) {
+   for (i=0; i<10; i++) {
       ENTROPY_DECODER_DONE(&significand_bitstream[i]);
       ENTROPY_DECODER_DONE(&insignificand_bitstream[i]);
    }

1.2       +3 -3      w3d/wavelet_xform.c

Index: wavelet_xform.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/wavelet_xform.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- wavelet_xform.c	2001/06/25 07:56:07	1.1
+++ wavelet_xform.c	2001/07/02 08:28:45	1.2
@@ -204,10 +204,10 @@
 static inline
 void copyback_d (TYPE *x, const TYPE *d, int stride, int n)
 {
-   int i, k=n/2;
+   int i, j, k=n/2;
 
-   for (i=0; i<k; i++)
-      x [(n-k+i)*stride] = d[i];
+   for (i=n-k, j=0; i<n; i++, j++)
+      x [i*stride] = d[j];
 }
 
 

1.1                  w3d/tools/Makefile

Index: Makefile
===================================================================
CC = gcc
RM = rm -rf

CFLAGS = -g -O0 -Wall -I.. -DTYPE=uint16_t
LFLAGS = -g

TARGETS = ppmdiff

OBJS = $(TARGETS:=.o) ../ppm.o
SRCS = $(OBJS:.o=.c)

all: ppmdiff

ppmdiff: $(OBJS)
        $(CC) $(LFLAGS) $(OBJS) -o $@

.c.o: .depend
        $(CC) $(CFLAGS) -c $< -o $@

clean:
        $(RM) $(OBJS) $(TARGETS) gmon.out core .depend .depend.bak

.depend: $(SRCS)
        $(RM) .depend
        touch .depend
        sh ../tools/makedepend.sh -f.depend -- $(CFLAGS) -- $(SRCS)

-include .depend

1.1                  w3d/tools/makedepend.sh

Index: makedepend.sh
===================================================================
#!/bin/sh
#
# $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $
#
#       Do the equivalent of the 'makedepend' program, but do it right.
#
#       Usage:
#
#       makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]
#         [-o object-suffix]
#
#       Notes:
#
#       The C compiler used can be overridden with the environment
#       variable "CC".
#
#       The "-v" switch of the "makedepend" program is not supported.
#
#
#       This script should
#       work on both USG and BSD systems.  However, when System V.4 comes out,
#       USG users will probably have to change "silent" to "-s" instead of
#       "-" (at least, that is what the documentation implies).
#
# $XFree86: xc/config/util/mdepend.cpp,v 3.3.2.3 2001/03/15 21:16:08 tsi Exp $
#

CC="gcc -E -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE  -D_GNU_SOURCE  "

ilent='-'

TMP=`pwd`/.mdep$$
CPPCMD=${TMP}a
DEPENDLINES=${TMP}b
TMPMAKEFILE=${TMP}c
MAGICLINE=${TMP}d
ARGS=${TMP}e

trap "rm -f ${TMP}*; exit 1" 1 2 15
trap "rm -f ${TMP}*; exit 0" 1 2 13

echo " \c" > $CPPCMD
if [ `wc -c < $CPPCMD` -eq 1 ]
then
    c="\c"
    n=
else
    c=
    n="-n"
fi

echo $n "$c" >$ARGS

files=
makefile=
magic_string='# DO NOT DELETE'
objsuffix='.o'
width=78
endmarker=""
verbose=n
append=n

while [ $# != 0 ]
do
    if [ "$endmarker"x != x ] && [ "$endmarker" = "$1" ]; then
        endmarker=""
    else
        case "$1" in
            -D*|-I*|-U*)
                echo $n " '$1'$c" >> $ARGS
                ;;

            -g|-O)      # ignore so we can just pass $(CFLAGS) in
                ;;

            *)
                if [ "$endmarker"x = x ]; then
                    case "$1" in        
                        -w)
                            width="$2"
                            shift
                            ;;
                        -s)
                            magic_string="$2"
                            shift
                            ;;
                        -f*)
                            if [ "$1" = "-f-" ]; then
                                makefile="-"
                            elif [ "$1" = "-f" ]; then
                                makefile="$2"
                                shift
                            else
                                echo "$1" | sed 's/^\-f//' >${TMP}arg
                                makefile="`cat ${TMP}arg`"
                                rm -f ${TMP}arg
                            fi
                            ;;
                        -o)
                            objsuffix="$2"
                            shift
                            ;;
                        
                        --*)
                            echo "$1" | sed 's/^\-\-//' >${TMP}end
                            endmarker="`cat ${TMP}end`"
                            rm -f ${TMP}end
                            if [ "$endmarker"x = x ]; then
                                endmarker="--"
                            fi
                            ;;
                        -v)
                            verbose="y"
                            ;;

                        -a)
                            append="y"
                            ;;

                        -cc)
                            CC="$2"
                            shift
                            ;;

                        -*)
                            echo "Unknown option '$1' ignored" 1>&2
                            ;;
                        *)
                            files="$files $1"
                            ;;
                    esac
                fi
                ;;
        esac
    fi
    shift
done
echo ' $*' >> $ARGS

echo "#!/bin/sh" > $CPPCMD
echo "exec $CC `cat $ARGS`" >> $CPPCMD
chmod +x $CPPCMD
rm $ARGS

case "$makefile" in
    '')
        if [ -r makefile ]
        then
            makefile=makefile
        elif [ -r Makefile ]
        then
            makefile=Makefile
        else
            echo 'no makefile or Makefile found' 1>&2
            exit 1
        fi
        ;;
    -)
        makefile=$TMPMAKEFILE
        ;;
esac

if [ "$verbose"x = "y"x ]; then 
    cat $CPPCMD
fi

echo '' > $DEPENDLINES
for i in $files
do
    $CPPCMD $i       | sed -n "/^#/s;^;$i ;p"

done   | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g'     -e 's|"||g' -e 's| \./| |'   | awk '{
        if ($1 != $4  &&  $2 != "#ident" && $2 != "#pragma")

            {
            ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
            print ofile, $4
            }
        }'   | sort -u   | awk '

            {
            newrec = rec " " $2
            if ($1 != old1)
                {
                old1 = $1
                if (rec != "")
                    print rec
                rec = $1 ": " $2
                }
            else if (length (newrec) > '"$width"')
                {
                print rec
                rec = $1 ": " $2
                }
            else
                rec = newrec
            }
        END         {

            if (rec != "")
                print rec
            }'   | egrep -v '^[^:]*:[   ]*$' >> $DEPENDLINES

trap "" 1 2 13 15       # Now we are committed
case "$makefile" in
    $TMPMAKEFILE)
        ;;
    *)
        rm -f $makefile.bak
        cp $makefile $makefile.bak
        echo "Appending dependencies to $makefile"
        ;;
esac

#
# If not -a, append the magic string and a blank line so that
# /^$magic_string/+1,\$d can be used to delete everything from after
# the magic string to the end of the file.  Then, append a blank
# line again and then the dependencies.
#
if [ "$append" = "n" ]
then
    cat >> $makefile << END_OF_APPEND

$magic_string

END_OF_APPEND
    ed $silent $makefile << END_OF_ED_SCRIPT
/^$magic_string/+1,\$d
w
q
END_OF_ED_SCRIPT
    echo '' >>$makefile
fi

cat $DEPENDLINES >>$makefile

case "$makefile" in
    $TMPMAKEFILE)
        cat $TMPMAKEFILE
        ;;

esac

rm -f ${TMP}*
exit 0

1.1                  w3d/tools/ppmdiff.c

Index: ppmdiff.c
===================================================================

/**
 *   Ugly Hack.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "ppm.h"
#include "bitcoder.h"

static
void usage (const char *program_name)
{
   printf ("\n"
     " usage: %s <file1.ppm> <file2.ppm>\n"
     "\n", program_name);
   exit (-1);
}

int main (int argc, char **argv)
{
   uint8_t *rgb1, *rgb2, *diff;
   uint32_t width, height, width1, height1;
   uint32_t i;

   if (argc != 3)
      usage (argv[0]);

   if (read_ppm_info (argv[1], &width1, &height1) < 0)
      exit (-1);

   if (read_ppm_info (argv[2], &width, &height) < 0)
      exit (-1);

   if (!(width1 == width && height1 == height)) {
      printf ("image sizes differ !!\n");
      exit (-1);
   }

   rgb1  = malloc (width * height * 3);
   rgb2  = malloc (width * height * 3);
   diff  = malloc (width * height * 3);

   if (read_ppm (argv[1], rgb1, width, height) < 0)
   {
      printf ("error opening '%s' !\n", argv[1]);
      exit(-1);
   }

   if (read_ppm (argv[2], rgb2, width, height) < 0)
   {
      printf ("error opening '%s' !\n", argv[2]);
      exit(-1);
   }

   for (i=0; i<width*height*3; i++) {
      diff[i] = (rgb1[i] == rgb2[i]) ? 0 : 255;
      if (diff[i]) {
         printf("%i: %i <-> %i\n", i, rgb1[i], rgb2[i]);
         bit_print(rgb1[i]);
         bit_print(rgb2[i]);
      }
   }

   write_ppm ("diff.ppm", diff, width, height);

   free (rgb1);
   free (rgb2);
   free (diff);

   return 0;
}

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list