[xiph-cvs] cvs commit: w3d Makefile ppm.c tarkin.c tarkin_enc.c wavelet.c wavelet.h

Holger Waechtler holger at xiph.org
Fri Jun 29 08:13:08 PDT 2001



holger      01/06/29 08:13:08

  Modified:    .        Makefile ppm.c tarkin.c tarkin_enc.c wavelet.c
                        wavelet.h
  Log:
   - added wavelet_3d_buf_dump() for debugging purposes. Use -DDBG_XFORM
      to enable this code ...

Revision  Changes    Path
1.5       +1 -1      w3d/Makefile

Index: Makefile
===================================================================
RCS file: /usr/local/cvsroot/w3d/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Makefile	2001/06/29 09:19:25	1.4
+++ Makefile	2001/06/29 15:13:07	1.5
@@ -1,7 +1,7 @@
 CC = gcc
 RM = rm -rf
 
-CFLAGS = -g -O0 -Wall -DTYPE=int16_t -DRLECODER
+CFLAGS = -g -O0 -Wall -DTYPE=int16_t -DRLECODER -DDBG_XFORM
 LFLAGS = -g
 
 OBJS = ppm.o wavelet.o wavelet_xform.o yuv.o tarkin.o tarkin-io.o

1.2       +14 -4     w3d/ppm.c

Index: ppm.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/ppm.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ppm.c	2001/06/29 09:19:25	1.1
+++ ppm.c	2001/06/29 15:13:07	1.2
@@ -1,8 +1,8 @@
 /**
  *   This code has some serious problems with DOS-style CR/LF linebreaks.
- *   Simon already contributed better code, but there has been no attempt to
- *   use them for now.
- *   If you want do do this, please send me a patch.
+ *   Simon already contributed better routines, but there has been no attempt to
+ *   use them for now (I'm just too lazy lazy). If you want do this job, 
+ *   please send me a patch.
  *
  *     - Holger
  */
@@ -109,6 +109,16 @@
 }
 
 
+static inline
+uint8_t CLAMP(int16_t x)
+{
+   x *= 4;
+   x += 128;
+   return  ((x > 255) ? 255 : (x < 0) ? 0 : x);
+}
+
+
+
 void write_ppm16 (char *fname, int16_t *rgb, int w, int h)
 {
    int i;
@@ -123,7 +133,7 @@
 
    fprintf (outfile, "P6\n%d %d\n%d\n", w, h, 255);
    for (i=0; i<w*h; i++) {
-      uint8_t c [3] = { rgb[i], rgb[i], rgb[i] };
+      uint8_t c [3] = { CLAMP(rgb[i]), CLAMP(rgb[i]), CLAMP(rgb[i]) };
       fwrite (c, 1, 3, outfile);
    }
    fclose (outfile);

1.4       +5 -0      w3d/tarkin.c

Index: tarkin.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/tarkin.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- tarkin.c	2001/06/29 12:21:43	1.3
+++ tarkin.c	2001/06/29 15:13:07	1.4
@@ -131,6 +131,9 @@
          uint32_t bitstream_len;
 
          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]);
+
          bitstream_len = wavelet_3d_buf_encode_coeff (layer->waveletbuf[j],
                                                       s->bitstream,
                                                       layer->bitstream_len);
@@ -265,6 +268,8 @@
 
             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);
          }
       }

1.3       +1 -1      w3d/tarkin_enc.c

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

1.6       +23 -0     w3d/wavelet.c

Index: wavelet.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/wavelet.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- wavelet.c	2001/06/29 12:21:43	1.5
+++ wavelet.c	2001/06/29 15:13:07	1.6
@@ -512,3 +512,26 @@
    }
 }
 
+
+
+#if defined(DBG_XFORM)
+
+#include "ppm.h"
+
+void wavelet_3d_buf_dump (char *fmt,
+                          uint32_t first_frame_in_buf,
+                          uint32_t id,
+                          Wavelet3DBuf* buf)
+{
+   char fname [256];
+   uint32_t f;
+
+   for (f=0; f<buf->frames; f++) {
+      snprintf (fname, 256, fmt, id, first_frame_in_buf + f);
+
+      write_ppm16 (fname, buf->data + f * buf->width * buf->height,
+                   buf->width, buf->height);
+   }
+}
+#endif
+

1.4       +9 -0      w3d/wavelet.h

Index: wavelet.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/wavelet.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- wavelet.h	2001/06/25 07:56:07	1.3
+++ wavelet.h	2001/06/29 15:13:07	1.4
@@ -42,4 +42,13 @@
                                          uint8_t *bitstream,
                                          uint32_t limit);
 
+#if defined(DBG_XFORM)
+extern void wavelet_3d_buf_dump (char *fmt,
+                                 uint32_t first_frame_in_buf,
+                                 uint32_t id,
+                                 Wavelet3DBuf* buf);
+#else
+#define wavelet_3d_buf_dump(x...)
+#endif
+
 #endif

--- >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