#include "image.h"
#include "log.h"
-#ifdef DEBUG_HASH
-#include <mhash.h>
-#endif
-
using namespace std;
using namespace boost;
/* 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);
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;
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 << " "
/* 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;
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)
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;
#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>
#include "exceptions.h"
#include "scaler.h"
-#ifdef DEBUG_HASH
-#include <mhash.h>
-#endif
-
using namespace std;
using namespace boost;
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.
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 {
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;
}
#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>
#include "player_manager.h"
#endif
-#ifdef DEBUG_HASH
-#include <mhash.h>
-#endif
-
using namespace std;
using namespace boost;
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) {
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.
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 */
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
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;
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;
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')
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