Remove long-since disused hash debugging.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Sep 2012 22:49:53 +0000 (23:49 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 24 Sep 2012 22:49:53 +0000 (23:49 +0100)
src/lib/dcp_video_frame.cc
src/lib/dcp_video_frame.h
src/lib/image.cc
src/lib/image.h
src/lib/server.cc
src/lib/util.cc
src/lib/util.h
src/lib/wscript
src/tools/servomatictest.cc
wscript

index d8af3462d681b477bbd7859c5c618395e4a133e7..96c40358a46176385ae67624cccd38e41c014808 100644 (file)
 #include "image.h"
 #include "log.h"
 
-#ifdef DEBUG_HASH
-#include <mhash.h>
-#endif
-
 using namespace std;
 using namespace boost;
 
@@ -255,12 +251,6 @@ DCPVideoFrame::encode_locally ()
        /* Set event manager to null (openjpeg 1.3 bug) */
        _cinfo->event_mgr = 0;
 
-#ifdef DEBUG_HASH
-       md5_data ("J2K in X frame " + lexical_cast<string> (_frame), _image->comps[0].data, size * sizeof (int));
-       md5_data ("J2K in Y frame " + lexical_cast<string> (_frame), _image->comps[1].data, size * sizeof (int));
-       md5_data ("J2K in Z frame " + lexical_cast<string> (_frame), _image->comps[2].data, size * sizeof (int));
-#endif 
-       
        /* Setup the encoder parameters using the current image and user parameters */
        opj_setup_encoder (_cinfo, _parameters, _image);
 
@@ -271,10 +261,6 @@ DCPVideoFrame::encode_locally ()
                throw EncodeError ("jpeg2000 encoding failed");
        }
 
-#ifdef DEBUG_HASH
-       md5_data ("J2K out frame " + lexical_cast<string> (_frame), _cio->buffer, cio_tell (_cio));
-#endif 
-
        {
                stringstream s;
                s << "Finished locally-encoded frame " << _frame;
@@ -300,10 +286,6 @@ DCPVideoFrame::encode_remotely (ServerDescription const * serv)
 
        socket.connect (*endpoint_iterator, 30);
 
-#ifdef DEBUG_HASH
-       _input->hash ("Input for remote encoding (before sending)");
-#endif
-
        stringstream s;
        s << "encode "
          << _input->size().width << " " << _input->size().height << " "
@@ -335,10 +317,6 @@ DCPVideoFrame::encode_remotely (ServerDescription const * serv)
        /* now read the rest */
        socket.read_definite_and_consume (e->data(), e->size(), 30);
 
-#ifdef DEBUG_HASH
-       e->hash ("Encoded image (after receiving)");
-#endif
-
        {
                stringstream s;
                s << "Finished remotely-encoded frame " << _frame;
@@ -382,14 +360,6 @@ EncodedData::send (shared_ptr<Socket> socket)
        socket->write (_data, _size, 30);
 }
 
-#ifdef DEBUG_HASH
-void
-EncodedData::hash (string n) const
-{
-       md5_data (n, _data, _size);
-}
-#endif         
-
 /** @param s Size of data in bytes */
 RemotelyEncodedData::RemotelyEncodedData (int s)
        : EncodedData (new uint8_t[s], s)
index da4e0c30168da272dbab043abc76655ed147fb86..72f885e45e6e0804f675d0f61abf62814314b3bd 100644 (file)
@@ -51,10 +51,6 @@ public:
        void send (boost::shared_ptr<Socket> socket);
        void write (boost::shared_ptr<const Options>, int);
 
-#ifdef DEBUG_HASH
-       void hash (std::string) const;
-#endif 
-
        /** @return data */
        uint8_t* data () const {
                return _data;
index f16bb9f7791a3a7220a079717d590046ce3aefd8..89536da33127726daa2d0fab841786eff063bb7f 100644 (file)
@@ -27,6 +27,7 @@
 #include <sys/time.h>
 #include <boost/algorithm/string.hpp>
 #include <openjpeg.h>
+#include <mhash.h>
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
@@ -39,10 +40,6 @@ extern "C" {
 #include "exceptions.h"
 #include "scaler.h"
 
-#ifdef DEBUG_HASH
-#include <mhash.h>
-#endif
-
 using namespace std;
 using namespace boost;
 
@@ -85,33 +82,6 @@ Image::components () const
        return 0;
 }
 
-#ifdef DEBUG_HASH
-/** Write a MD5 hash of the image's data to stdout.
- *  @param n Title to give the output.
- */
-void
-Image::hash (string n) const
-{
-       MHASH ht = mhash_init (MHASH_MD5);
-       if (ht == MHASH_FAILED) {
-               throw EncodeError ("could not create hash thread");
-       }
-       
-       for (int i = 0; i < components(); ++i) {
-               mhash (ht, data()[i], line_size()[i] * lines(i));
-       }
-       
-       uint8_t hash[16];
-       mhash_deinit (ht, hash);
-       
-       printf ("%s: ", n.c_str ());
-       for (int i = 0; i < int (mhash_get_block_size (MHASH_MD5)); ++i) {
-               printf ("%.2x", hash[i]);
-       }
-       printf ("\n");
-}
-#endif
-
 /** Scale this image to a given size and convert it to RGB.
  *  @param out_size Output image size in pixels.
  *  @param scaler Scaler to use.
index 97ab1d5ff8c2868a9d24550e3876131681b3d4f2..0161d2b01f9850b28f4deb47fc9a184e21f6b10f 100644 (file)
@@ -68,10 +68,6 @@ public:
        boost::shared_ptr<RGBFrameImage> scale_and_convert_to_rgb (Size, int, Scaler const *) const;
        boost::shared_ptr<PostProcessImage> post_process (std::string) const;
        
-#ifdef DEBUG_HASH      
-       void hash (std::string) const;
-#endif
-
        void make_black ();
        
        PixelFormat pixel_format () const {
index 8ca4260490aad273794390e76629dcc4de80ffef..f8c4425d991f42b4a538e2593b198514ddcd491c 100644 (file)
@@ -124,17 +124,9 @@ Server::process (shared_ptr<Socket> socket)
                socket->read_definite_and_consume (image->data()[i], image->line_size()[i] * image->lines(i), 30);
        }
        
-#ifdef DEBUG_HASH
-       image->hash ("Image for encoding (as received by server)");
-#endif         
-       
        DCPVideoFrame dcp_video_frame (image, out_size, padding, scaler, frame, frames_per_second, post_process, colour_lut_index, j2k_bandwidth, _log);
        shared_ptr<EncodedData> encoded = dcp_video_frame.encode_locally ();
        encoded->send (socket);
-
-#ifdef DEBUG_HASH
-       encoded->hash ("Encoded image (as made by server and as sent back)");
-#endif         
        
        return frame;
 }
index 73222083a81c5ee5adf18d2f67c613c2bd938449..c779268e2b338423c3454969c682b0df4ac39fff 100644 (file)
@@ -40,6 +40,7 @@
 #include <magick/MagickCore.h>
 #include <magick/version.h>
 #include <libdcp/version.h>
+#include <mhash.h>
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
@@ -61,10 +62,6 @@ extern "C" {
 #include "player_manager.h"
 #endif
 
-#ifdef DEBUG_HASH
-#include <mhash.h>
-#endif
-
 using namespace std;
 using namespace boost;
 
@@ -347,9 +344,8 @@ split_at_spaces_considering_quotes (string s)
        return out;
 }
 
-#ifdef DEBUG_HASH
-void
-md5_data (string title, void const * data, int size)
+string
+md5_hash (void const * data, int size)
 {
        MHASH ht = mhash_init (MHASH_MD5);
        if (ht == MHASH_FAILED) {
@@ -360,14 +356,16 @@ md5_data (string title, void const * data, int size)
        
        uint8_t hash[16];
        mhash_deinit (ht, hash);
-       
-       printf ("%s [%d]: ", title.c_str (), size);
-       for (int i = 0; i < int (mhash_get_block_size (MHASH_MD5)); ++i) {
-               printf ("%.2x", hash[i]);
+
+       int const N = mhash_get_block_size (MHASH_MD5);
+       stringstream s;
+       s << hex << setfill('0') << setw(2);
+       for (int i = 0; i < N; ++i) {
+               s << ((int) hash[i]);
        }
-       printf ("\n");
+
+       return s.str ();
 }
-#endif
 
 /** @param file File name.
  *  @return MD5 digest of file's contents.
index 63d492e60ab762dd5f75bd7f2158dfb53e80d338..03d04b852c3a859edc611d05bf4847aab2bb72ef 100644 (file)
@@ -52,9 +52,7 @@ enum ContentType {
        VIDEO
 };
 
-#ifdef DEBUG_HASH
-extern void md5_data (std::string, void const *, int);
-#endif
+extern std::string md5_hash (void const *, int);
 
 /** @class Size
  *  @brief Representation of the size of something */
index 71a2b23f41be508c893b0c250ee1137e389b93f2..26740a7e9164570c5c4893704999c37a64069009 100644 (file)
@@ -1,17 +1,13 @@
 def configure(conf):
-    if conf.options.debug_hash:
-        conf.env.append_value('CXXFLAGS', '-DDEBUG_HASH')
-        conf.check_cc(msg = 'Checking for library libmhash', function_name = 'mhash_init', header_name = 'mhash.h', lib = 'mhash', uselib_store = 'MHASH')
+    conf.check_cc(msg = 'Checking for library libmhash', function_name = 'mhash_init', header_name = 'mhash.h', lib = 'mhash', uselib_store = 'MHASH')
 
 def build(bld):
     obj = bld(features = 'cxx cxxshlib')
     obj.name = 'libdvdomatic'
     obj.export_includes = ['.']
-    obj.uselib = 'AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE SNDFILE BOOST_FILESYSTEM BOOST_THREAD OPENJPEG POSTPROC TIFF SIGC++ MAGICK SSH DCP GLIB'
+    obj.uselib = 'AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE SNDFILE BOOST_FILESYSTEM BOOST_THREAD OPENJPEG POSTPROC TIFF SIGC++ MAGICK SSH DCP GLIB MHASH'
     if bld.env.TARGET_WINDOWS:
         obj.uselib += ' WINSOCK2'
-    if bld.env.DEBUG_HASH:
-        obj.uselib += ' MHASH'
     obj.source = """
                 ab_transcode_job.cc
                 ab_transcoder.cc
index 0f37e73a5f9f9880e242f9e93ea78858fde7bfbf..d6804c981bac2fd2a130888650e5d842badd6e47 100644 (file)
@@ -47,12 +47,8 @@ process_video (shared_ptr<Image> image, int frame)
        shared_ptr<DCPVideoFrame> local (new DCPVideoFrame (image, Size (1024, 1024), 0, Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, &log_));
        shared_ptr<DCPVideoFrame> remote (new DCPVideoFrame (image, Size (1024, 1024), 0, Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, &log_));
 
-#if defined(DEBUG_HASH)
-       cout << "Frame " << frame << ":\n";
-#else
        cout << "Frame " << frame << ": ";
        cout.flush ();
-#endif 
 
        shared_ptr<EncodedData> local_encoded = local->encode_locally ();
        shared_ptr<EncodedData> remote_encoded;
@@ -64,11 +60,6 @@ process_video (shared_ptr<Image> image, int frame)
                remote_error = e.what ();
        }
 
-#if defined(DEBUG_HASH)
-       cout << "Frame " << frame << ": ";
-       cout.flush ();
-#endif 
-
        if (!remote_error.empty ()) {
                cout << "\033[0;31mnetwork problem: " << remote_error << "\033[0m\n";
                return;
diff --git a/wscript b/wscript
index 71a89dfd3260ef8fab56889ee705eb7c6be1e121..69d68a35ce6ef73d36db89b0ea68561166a74e2f 100644 (file)
--- a/wscript
+++ b/wscript
@@ -9,7 +9,6 @@ def options(opt):
     opt.load('compiler_cxx')
     opt.load('winres')
 
-    opt.add_option('--debug-hash', action='store_true', default = False, help = 'print hashes of data at various points')
     opt.add_option('--enable-debug', action='store_true', default = False, help = 'build with debugging information and without optimisation')
     opt.add_option('--disable-gui', action='store_true', default = False, help = 'disable building of GUI tools')
     opt.add_option('--disable-player', action='store_true', default = False, help = 'disable building of the player components')
@@ -37,7 +36,6 @@ def configure(conf):
         boost_lib_suffix = ''
         boost_thread = 'boost_thread'
 
-    conf.env.DEBUG_HASH = conf.options.debug_hash
     conf.env.TARGET_WINDOWS = conf.options.target_windows
     conf.env.DISABLE_GUI = conf.options.disable_gui
     conf.env.DISABLE_PLAYER = conf.options.disable_player