diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-02 21:55:37 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-02 21:55:37 +0100 |
| commit | 19133069634100e119a1196c2f203af464145517 (patch) | |
| tree | e238c8986fd2e2d9ee8095b98eca0b70e5563231 /src | |
| parent | 8fca5499789ae1deb2dbcad8d3501a8f42fb95f0 (diff) | |
Remove bitwise DCP comparison, which I think is fairly useless (just use diff, no?)
Diffstat (limited to 'src')
| -rw-r--r-- | src/mxf_asset.cc | 37 | ||||
| -rw-r--r-- | src/picture_asset.cc | 146 | ||||
| -rw-r--r-- | src/sound_asset.cc | 100 | ||||
| -rw-r--r-- | src/types.h | 5 |
4 files changed, 120 insertions, 168 deletions
diff --git a/src/mxf_asset.cc b/src/mxf_asset.cc index d0e02c8b..ead97b9e 100644 --- a/src/mxf_asset.cc +++ b/src/mxf_asset.cc @@ -58,7 +58,7 @@ MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info) const } bool -MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<string>& notes) const +MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions, list<string>& notes) const { shared_ptr<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (other); if (!other_mxf) { @@ -80,41 +80,6 @@ MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<strin notes.push_back ("MXF lengths differ"); return false; } - - if (opt.bitwise) { - - if (digest() != other_mxf->digest()) { - notes.push_back ("MXF digests differ"); - return false; - } - - if (filesystem::file_size (path()) != filesystem::file_size (other_mxf->path())) { - notes.push_back (path().string() + " and " + other_mxf->path().string() + " sizes differ"); - return false; - } - - ifstream a (path().string().c_str(), ios::binary); - ifstream b (other_mxf->path().string().c_str(), ios::binary); - - int buffer_size = 65536; - char abuffer[buffer_size]; - char bbuffer[buffer_size]; - - int n = filesystem::file_size (path ()); - - while (n) { - int const t = min (n, buffer_size); - a.read (abuffer, t); - b.read (bbuffer, t); - - if (memcmp (abuffer, bbuffer, t) != 0) { - notes.push_back (path().string() + " and " + other_mxf->path().string() + " content differs"); - return false; - } - - n -= t; - } - } return true; } diff --git a/src/picture_asset.cc b/src/picture_asset.cc index 898fe75b..12dfd1aa 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -70,56 +70,55 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<s return false; } - if (!opt.bitwise) { - ASDCP::JP2K::MXFReader reader_A; - if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { - throw MXFFileError ("could not open MXF file for reading", path().string()); - } - - ASDCP::JP2K::MXFReader reader_B; - if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { - throw MXFFileError ("could not open MXF file for reading", path().string()); - } - - ASDCP::JP2K::PictureDescriptor desc_A; - if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) { - throw DCPReadError ("could not read video MXF information"); - } - ASDCP::JP2K::PictureDescriptor desc_B; - if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) { - throw DCPReadError ("could not read video MXF information"); - } - - if ( - desc_A.EditRate != desc_B.EditRate || - desc_A.ContainerDuration != desc_B.ContainerDuration || - desc_A.SampleRate != desc_B.SampleRate || - desc_A.StoredWidth != desc_B.StoredWidth || - desc_A.StoredHeight != desc_B.StoredHeight || - desc_A.AspectRatio != desc_B.AspectRatio || - desc_A.Rsize != desc_B.Rsize || - desc_A.Xsize != desc_B.Xsize || - desc_A.Ysize != desc_B.Ysize || - desc_A.XOsize != desc_B.XOsize || - desc_A.YOsize != desc_B.YOsize || - desc_A.XTsize != desc_B.XTsize || - desc_A.YTsize != desc_B.YTsize || - desc_A.XTOsize != desc_B.XTOsize || - desc_A.YTOsize != desc_B.YTOsize || - desc_A.Csize != desc_B.Csize -// desc_A.CodingStyleDefault != desc_B.CodingStyleDefault || -// desc_A.QuantizationDefault != desc_B.QuantizationDefault - ) { + ASDCP::JP2K::MXFReader reader_A; + if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { + throw MXFFileError ("could not open MXF file for reading", path().string()); + } + + ASDCP::JP2K::MXFReader reader_B; + if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { + throw MXFFileError ("could not open MXF file for reading", path().string()); + } + + ASDCP::JP2K::PictureDescriptor desc_A; + if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) { + throw DCPReadError ("could not read video MXF information"); + } + ASDCP::JP2K::PictureDescriptor desc_B; + if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) { + throw DCPReadError ("could not read video MXF information"); + } + + if ( + desc_A.EditRate != desc_B.EditRate || + desc_A.ContainerDuration != desc_B.ContainerDuration || + desc_A.SampleRate != desc_B.SampleRate || + desc_A.StoredWidth != desc_B.StoredWidth || + desc_A.StoredHeight != desc_B.StoredHeight || + desc_A.AspectRatio != desc_B.AspectRatio || + desc_A.Rsize != desc_B.Rsize || + desc_A.Xsize != desc_B.Xsize || + desc_A.Ysize != desc_B.Ysize || + desc_A.XOsize != desc_B.XOsize || + desc_A.YOsize != desc_B.YOsize || + desc_A.XTsize != desc_B.XTsize || + desc_A.YTsize != desc_B.YTsize || + desc_A.XTOsize != desc_B.XTOsize || + desc_A.YTOsize != desc_B.YTOsize || + desc_A.Csize != desc_B.Csize +// desc_A.CodingStyleDefault != desc_B.CodingStyleDefault || +// desc_A.QuantizationDefault != desc_B.QuantizationDefault + ) { - notes.push_back ("video MXF picture descriptors differ"); - } + notes.push_back ("video MXF picture descriptors differ"); + return false; + } // for (unsigned int j = 0; j < ASDCP::JP2K::MaxComponents; ++j) { // if (desc_A.ImageComponents[j] != desc_B.ImageComponents[j]) { // notes.pack_start ("video MXF picture descriptors differ"); // } // } - } return true; } @@ -241,18 +240,16 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, li shared_ptr<const MonoPictureAsset> other_picture = dynamic_pointer_cast<const MonoPictureAsset> (other); assert (other_picture); - if (!opt.bitwise) { - for (int i = 0; i < _length; ++i) { - shared_ptr<const MonoPictureFrame> frame_A = get_frame (i); - shared_ptr<const MonoPictureFrame> frame_B = other_picture->get_frame (i); - - if (!frame_buffer_equals ( - i, opt, notes, - frame_A->j2k_frame()->RoData(), frame_A->j2k_frame()->Size(), - frame_B->j2k_frame()->RoData(), frame_B->j2k_frame()->Size() - )) { - return false; - } + for (int i = 0; i < _length; ++i) { + shared_ptr<const MonoPictureFrame> frame_A = get_frame (i); + shared_ptr<const MonoPictureFrame> frame_B = other_picture->get_frame (i); + + if (!frame_buffer_equals ( + i, opt, notes, + frame_A->j2k_frame()->RoData(), frame_A->j2k_frame()->Size(), + frame_B->j2k_frame()->RoData(), frame_B->j2k_frame()->Size() + )) { + return false; } } @@ -269,27 +266,24 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, shared_ptr<const StereoPictureAsset> other_picture = dynamic_pointer_cast<const StereoPictureAsset> (other); assert (other_picture); - if (!opt.bitwise) { - - for (int i = 0; i < _length; ++i) { - shared_ptr<const StereoPictureFrame> frame_A = get_frame (i); - shared_ptr<const StereoPictureFrame> frame_B = other_picture->get_frame (i); - - if (!frame_buffer_equals ( - i, opt, notes, - frame_A->j2k_frame()->Left.RoData(), frame_A->j2k_frame()->Left.Size(), - frame_B->j2k_frame()->Left.RoData(), frame_B->j2k_frame()->Left.Size() - )) { - return false; - } - - if (!frame_buffer_equals ( - i, opt, notes, - frame_A->j2k_frame()->Right.RoData(), frame_A->j2k_frame()->Right.Size(), - frame_B->j2k_frame()->Right.RoData(), frame_B->j2k_frame()->Right.Size() - )) { - return false; - } + for (int i = 0; i < _length; ++i) { + shared_ptr<const StereoPictureFrame> frame_A = get_frame (i); + shared_ptr<const StereoPictureFrame> frame_B = other_picture->get_frame (i); + + if (!frame_buffer_equals ( + i, opt, notes, + frame_A->j2k_frame()->Left.RoData(), frame_A->j2k_frame()->Left.Size(), + frame_B->j2k_frame()->Left.RoData(), frame_B->j2k_frame()->Left.Size() + )) { + return false; + } + + if (!frame_buffer_equals ( + i, opt, notes, + frame_A->j2k_frame()->Right.RoData(), frame_A->j2k_frame()->Right.Size(), + frame_B->j2k_frame()->Right.RoData(), frame_B->j2k_frame()->Right.Size() + )) { + return false; } } diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 9395a487..7a3d4415 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -200,64 +200,62 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<str return false; } - if (!opt.bitwise) { - ASDCP::PCM::MXFReader reader_A; - if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { - throw MXFFileError ("could not open MXF file for reading", path().string()); - } + ASDCP::PCM::MXFReader reader_A; + if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) { + throw MXFFileError ("could not open MXF file for reading", path().string()); + } - ASDCP::PCM::MXFReader reader_B; - if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { - throw MXFFileError ("could not open MXF file for reading", path().string()); - } + ASDCP::PCM::MXFReader reader_B; + if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) { + throw MXFFileError ("could not open MXF file for reading", path().string()); + } - ASDCP::PCM::AudioDescriptor desc_A; - if (ASDCP_FAILURE (reader_A.FillAudioDescriptor (desc_A))) { - throw DCPReadError ("could not read audio MXF information"); + ASDCP::PCM::AudioDescriptor desc_A; + if (ASDCP_FAILURE (reader_A.FillAudioDescriptor (desc_A))) { + throw DCPReadError ("could not read audio MXF information"); + } + ASDCP::PCM::AudioDescriptor desc_B; + if (ASDCP_FAILURE (reader_B.FillAudioDescriptor (desc_B))) { + throw DCPReadError ("could not read audio MXF information"); + } + + if ( + desc_A.EditRate != desc_B.EditRate || + desc_A.AudioSamplingRate != desc_B.AudioSamplingRate || + desc_A.Locked != desc_B.Locked || + desc_A.ChannelCount != desc_B.ChannelCount || + desc_A.QuantizationBits != desc_B.QuantizationBits || + desc_A.BlockAlign != desc_B.BlockAlign || + desc_A.AvgBps != desc_B.AvgBps || + desc_A.LinkedTrackID != desc_B.LinkedTrackID || + desc_A.ContainerDuration != desc_B.ContainerDuration +// desc_A.ChannelFormat != desc_B.ChannelFormat || + ) { + + notes.push_back ("audio MXF picture descriptors differ"); + return false; + } + + ASDCP::PCM::FrameBuffer buffer_A (1 * Kumu::Megabyte); + ASDCP::PCM::FrameBuffer buffer_B (1 * Kumu::Megabyte); + + for (int i = 0; i < _length; ++i) { + if (ASDCP_FAILURE (reader_A.ReadFrame (i, buffer_A))) { + throw DCPReadError ("could not read audio frame"); } - ASDCP::PCM::AudioDescriptor desc_B; - if (ASDCP_FAILURE (reader_B.FillAudioDescriptor (desc_B))) { - throw DCPReadError ("could not read audio MXF information"); + + if (ASDCP_FAILURE (reader_B.ReadFrame (i, buffer_B))) { + throw DCPReadError ("could not read audio frame"); } - - if ( - desc_A.EditRate != desc_B.EditRate || - desc_A.AudioSamplingRate != desc_B.AudioSamplingRate || - desc_A.Locked != desc_B.Locked || - desc_A.ChannelCount != desc_B.ChannelCount || - desc_A.QuantizationBits != desc_B.QuantizationBits || - desc_A.BlockAlign != desc_B.BlockAlign || - desc_A.AvgBps != desc_B.AvgBps || - desc_A.LinkedTrackID != desc_B.LinkedTrackID || - desc_A.ContainerDuration != desc_B.ContainerDuration -// desc_A.ChannelFormat != desc_B.ChannelFormat || - ) { - notes.push_back ("audio MXF picture descriptors differ"); + if (buffer_A.Size() != buffer_B.Size()) { + notes.push_back ("sizes of audio data for frame " + lexical_cast<string>(i) + " differ"); return false; } - - ASDCP::PCM::FrameBuffer buffer_A (1 * Kumu::Megabyte); - ASDCP::PCM::FrameBuffer buffer_B (1 * Kumu::Megabyte); - - for (int i = 0; i < _length; ++i) { - if (ASDCP_FAILURE (reader_A.ReadFrame (i, buffer_A))) { - throw DCPReadError ("could not read audio frame"); - } - - if (ASDCP_FAILURE (reader_B.ReadFrame (i, buffer_B))) { - throw DCPReadError ("could not read audio frame"); - } - - if (buffer_A.Size() != buffer_B.Size()) { - notes.push_back ("sizes of audio data for frame " + lexical_cast<string>(i) + " differ"); - return false; - } - - if (memcmp (buffer_A.RoData(), buffer_B.RoData(), buffer_A.Size()) != 0) { - notes.push_back ("PCM data for MXF frame " + lexical_cast<string>(i) + " differ"); - return false; - } + + if (memcmp (buffer_A.RoData(), buffer_B.RoData(), buffer_A.Size()) != 0) { + notes.push_back ("PCM data for MXF frame " + lexical_cast<string>(i) + " differ"); + return false; } } diff --git a/src/types.h b/src/types.h index 7c98a3b3..71ab797b 100644 --- a/src/types.h +++ b/src/types.h @@ -86,11 +86,6 @@ extern bool operator== (Fraction const & a, Fraction const & b); extern bool operator!= (Fraction const & a, Fraction const & b); struct EqualityOptions { - /** true to do a bitwise comparison. - * false to compare PCM and image data, possibly allowing - * some variation in values. - */ - bool bitwise; double max_mean_pixel_error; double max_std_dev_pixel_error; }; |
