diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-09-24 23:49:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-09-24 23:49:53 +0100 |
| commit | 4fd257106009b2db170dafddece06ee3c190fceb (patch) | |
| tree | 7c76eb39f2981e4d492404dcc0966de10eb83eb3 /src/lib | |
| parent | 45698c6bc5cd3a596e7f0c963733d502c11dd854 (diff) | |
Remove long-since disused hash debugging.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dcp_video_frame.cc | 30 | ||||
| -rw-r--r-- | src/lib/dcp_video_frame.h | 4 | ||||
| -rw-r--r-- | src/lib/image.cc | 32 | ||||
| -rw-r--r-- | src/lib/image.h | 4 | ||||
| -rw-r--r-- | src/lib/server.cc | 8 | ||||
| -rw-r--r-- | src/lib/util.cc | 24 | ||||
| -rw-r--r-- | src/lib/util.h | 4 | ||||
| -rw-r--r-- | src/lib/wscript | 8 |
8 files changed, 15 insertions, 99 deletions
diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index d8af3462d..96c40358a 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -55,10 +55,6 @@ #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) diff --git a/src/lib/dcp_video_frame.h b/src/lib/dcp_video_frame.h index da4e0c301..72f885e45 100644 --- a/src/lib/dcp_video_frame.h +++ b/src/lib/dcp_video_frame.h @@ -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; diff --git a/src/lib/image.cc b/src/lib/image.cc index f16bb9f77..89536da33 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -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. diff --git a/src/lib/image.h b/src/lib/image.h index 97ab1d5ff..0161d2b01 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -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 { diff --git a/src/lib/server.cc b/src/lib/server.cc index 8ca426049..f8c4425d9 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -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; } diff --git a/src/lib/util.cc b/src/lib/util.cc index 73222083a..c779268e2 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -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. diff --git a/src/lib/util.h b/src/lib/util.h index 63d492e60..03d04b852 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -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 */ diff --git a/src/lib/wscript b/src/lib/wscript index 71a2b23f4..26740a7e9 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -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 |
