2 Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "verify_dcp_dialog.h"
24 #include "lib/verify_dcp_job.h"
25 #include "lib/warnings.h"
26 #include <dcp/verify.h>
27 #include <dcp/raw_convert.h>
28 #include <boost/algorithm/string.hpp>
29 DCPOMATIC_DISABLE_WARNINGS
30 #include <wx/richtext/richtextctrl.h>
31 #include <wx/notebook.h>
32 DCPOMATIC_ENABLE_WARNINGS
37 using std::shared_ptr;
42 VerifyDCPDialog::VerifyDCPDialog (wxWindow* parent, shared_ptr<VerifyDCPJob> job)
43 : wxDialog (parent, wxID_ANY, _("DCP verification"), wxDefaultPosition, {600, 400})
45 auto sizer = new wxBoxSizer (wxVERTICAL);
46 auto notebook = new wxNotebook (this, wxID_ANY);
47 sizer->Add (notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
49 map<dcp::VerificationNote::Type, wxRichTextCtrl*> pages;
50 pages[dcp::VerificationNote::Type::ERROR] = new wxRichTextCtrl (notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
51 notebook->AddPage (pages[dcp::VerificationNote::Type::ERROR], _("Errors"));
52 pages[dcp::VerificationNote::Type::BV21_ERROR] = new wxRichTextCtrl (notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
53 notebook->AddPage (pages[dcp::VerificationNote::Type::BV21_ERROR], _("SMPTE Bv2.1 errors"));
54 pages[dcp::VerificationNote::Type::WARNING] = new wxRichTextCtrl (notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
55 notebook->AddPage (pages[dcp::VerificationNote::Type::WARNING], _("Warnings"));
57 auto summary = new wxStaticText (this, wxID_ANY, wxT(""));
58 sizer->Add (summary, 0, wxALL, DCPOMATIC_DIALOG_BORDER);
60 auto buttons = CreateStdDialogButtonSizer (0);
61 sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
62 buttons->SetAffirmativeButton (new wxButton (this, wxID_OK));
67 sizer->SetSizeHints (this);
69 for (auto const& i: pages) {
70 i.second->GetCaret()->Hide();
73 if (job->finished_ok() && job->notes().empty()) {
74 summary->SetLabel (_("DCP validates OK."));
78 map<dcp::VerificationNote::Type, int> counts;
79 counts[dcp::VerificationNote::Type::WARNING] = 0;
80 counts[dcp::VerificationNote::Type::BV21_ERROR] = 0;
81 counts[dcp::VerificationNote::Type::ERROR] = 0;
83 auto add_bullet = [&pages](dcp::VerificationNote::Type type, wxString message) {
84 pages[type]->BeginStandardBullet(N_("standard/diamond"), 1, 50);
85 pages[type]->WriteText (message);
86 pages[type]->Newline ();
87 pages[type]->EndStandardBullet ();
90 auto add = [&counts, &add_bullet](dcp::VerificationNote note, wxString message) {
92 message.Replace("%n", std_to_wx(note.note().get()));
95 message.Replace("%f", std_to_wx(note.file()->filename().string()));
98 message.Replace("%l", std_to_wx(dcp::raw_convert<string>(note.line().get())));
100 add_bullet (note.type(), message);
101 counts[note.type()]++;
104 if (job->finished_in_error() && job->error_summary() != "") {
105 /* We have an error that did not come from dcp::verify */
106 add_bullet (dcp::VerificationNote::Type::ERROR, std_to_wx(job->error_summary()));
109 for (auto i: job->notes()) {
111 case dcp::VerificationNote::Code::FAILED_READ:
112 add (i, std_to_wx(*i.note()));
114 case dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES:
115 add(i, _("The hash of the CPL %n in the PKL does not agree with the CPL file. This probably means that the CPL file is corrupt."));
117 case dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE:
118 add(i, _("The picture in a reel has a frame rate of %n, which is not valid."));
120 case dcp::VerificationNote::Code::INCORRECT_PICTURE_HASH:
121 add(i, _("The hash of the picture asset %f does not agree with the PKL file. This probably means that the asset file is corrupt."));
123 case dcp::VerificationNote::Code::MISMATCHED_PICTURE_HASHES:
124 add(i, _("The PKL and CPL hashes disagree for picture asset %f."));
126 case dcp::VerificationNote::Code::INCORRECT_SOUND_HASH:
127 add(i, _("The hash of the sound asset %f does not agree with the PKL file. This probably means that the asset file is corrupt."));
129 case dcp::VerificationNote::Code::MISMATCHED_SOUND_HASHES:
130 add(i, _("The PKL and CPL hashes disagree for sound asset %f."));
132 case dcp::VerificationNote::Code::EMPTY_ASSET_PATH:
133 add(i, _("An asset has an empty path in the ASSETMAP."));
135 case dcp::VerificationNote::Code::MISSING_ASSET:
136 add(i, _("The asset %f is missing."));
138 case dcp::VerificationNote::Code::MISMATCHED_STANDARD:
139 add(i, _("Parts of the DCP are written according to the Interop standard and parts according to SMPTE."));
141 case dcp::VerificationNote::Code::INVALID_XML:
143 add(i, _("The XML in %f is malformed on line %l (%n)."));
145 add(i, _("The XML in %f is malformed (%n)."));
148 case dcp::VerificationNote::Code::MISSING_ASSETMAP:
149 add(i, _("No ASSETMAP or ASSETMAP.xml file was found."));
151 case dcp::VerificationNote::Code::INVALID_INTRINSIC_DURATION:
152 add(i, _("The asset %n has an intrinsic duration of less than 1 second, which is invalid."));
154 case dcp::VerificationNote::Code::INVALID_DURATION:
155 add(i, _("The asset %n has a duration of less than 1 second, which is invalid."));
157 case dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_SIZE_IN_BYTES:
158 add(i, _("At least one frame of the video asset %f is over the limit of 250Mbit/s."));
160 case dcp::VerificationNote::Code::NEARLY_INVALID_PICTURE_FRAME_SIZE_IN_BYTES:
161 add(i, _("At least one frame of the video asset %f is close to the limit of 250MBit/s."));
163 case dcp::VerificationNote::Code::EXTERNAL_ASSET:
164 add(i, _("This DCP refers to at the asset %n in another DCP (and perhaps others), so it is a \"version file\" (VF)"));
166 case dcp::VerificationNote::Code::THREED_ASSET_MARKED_AS_TWOD:
167 add(i, _("The asset %f is 3D but its MXF is marked as 2D."));
169 case dcp::VerificationNote::Code::INVALID_STANDARD:
170 add(i, _("This DCP uses the Interop standard, but it should be made with SMPTE."));
172 case dcp::VerificationNote::Code::INVALID_LANGUAGE:
173 add(i, _("The invalid language tag %n is used."));
175 case dcp::VerificationNote::Code::INVALID_PICTURE_SIZE_IN_PIXELS:
176 add(i, _("The video asset %f uses the invalid image size %n."));
178 case dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K:
179 add(i, _("The video asset %f uses the invalid frame rate %n."));
181 case dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_4K:
182 add(i, _("The video asset %f uses the frame rate %n which is invalid for 4K video."));
184 case dcp::VerificationNote::Code::INVALID_PICTURE_ASSET_RESOLUTION_FOR_3D:
185 add(i, _("The video asset %f uses the frame rate %n which is invalid for 3D video."));
187 case dcp::VerificationNote::Code::INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES:
188 add(i, _("The XML in the closed caption asset %f takes up %n bytes which is over the 256KB limit."));
190 case dcp::VerificationNote::Code::INVALID_TIMED_TEXT_SIZE_IN_BYTES:
191 add(i, _("The timed text asset %f takes up %n bytes which is over the 115MB limit."));
193 case dcp::VerificationNote::Code::INVALID_TIMED_TEXT_FONT_SIZE_IN_BYTES:
194 add(i, _("The fonts in the timed text asset %f take up %n bytes which is over the 10MB limit."));
196 case dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE:
197 add(i, _("The subtitle asset %f contains no <Language> tag."));
199 case dcp::VerificationNote::Code::MISMATCHED_SUBTITLE_LANGUAGES:
200 add(i, _("Not all subtitle assets specify the same <Language> tag."));
202 case dcp::VerificationNote::Code::MISSING_SUBTITLE_START_TIME:
203 add(i, _("The subtitle asset %f contains no <StartTime> tag."));
205 case dcp::VerificationNote::Code::INVALID_SUBTITLE_START_TIME:
206 add(i, _("The subtitle asset %f has a <StartTime> which is not zero."));
208 case dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME:
209 add(i, _("The first subtitle or closed caption happens before 4s into the first reel."));
211 case dcp::VerificationNote::Code::INVALID_SUBTITLE_DURATION:
212 add(i, _("At least one subtitle lasts less than 15 frames."));
214 case dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING:
215 add(i, _("At least one pair of subtitles is separated by less than 2 frames."));
217 case dcp::VerificationNote::Code::INVALID_SUBTITLE_LINE_COUNT:
218 add(i, _("There are more than 3 subtitle lines in at least one place."));
220 case dcp::VerificationNote::Code::NEARLY_INVALID_SUBTITLE_LINE_LENGTH:
221 add(i, _("There are more than 52 characters in at least one subtitle line."));
223 case dcp::VerificationNote::Code::INVALID_SUBTITLE_LINE_LENGTH:
224 add(i, _("There are more than 79 characters in at least one subtitle line."));
226 case dcp::VerificationNote::Code::INVALID_CLOSED_CAPTION_LINE_COUNT:
227 add(i, _("There are more than 3 closed caption lines in at least one place."));
229 case dcp::VerificationNote::Code::INVALID_CLOSED_CAPTION_LINE_LENGTH:
230 add(i, _("There are more than 32 characters in at least one closed caption line."));
232 case dcp::VerificationNote::Code::INVALID_SOUND_FRAME_RATE:
233 add(i, _("The sound asset %f has an invalid frame rate of %n."));
235 case dcp::VerificationNote::Code::MISSING_CPL_ANNOTATION_TEXT:
236 add(i, _("The CPL %n has no <AnnotationText> tag."));
238 case dcp::VerificationNote::Code::MISMATCHED_CPL_ANNOTATION_TEXT:
239 add(i, _("The CPL %n has an <AnnotationText> which is not the same as its <ContentTitleText>."));
241 case dcp::VerificationNote::Code::MISMATCHED_ASSET_DURATION:
242 add(i, _("At least one asset in a reel does not have the same duration as the others."));
244 case dcp::VerificationNote::Code::MISSING_MAIN_SUBTITLE_FROM_SOME_REELS:
245 add(i, _("The DCP has subtitles but at least one reel has no subtitle asset."));
247 case dcp::VerificationNote::Code::MISMATCHED_CLOSED_CAPTION_ASSET_COUNTS:
248 add(i, _("The DCP has closed captions but not every reel has the same number of closed caption assets."));
250 case dcp::VerificationNote::Code::MISSING_SUBTITLE_ENTRY_POINT:
251 add(i, _("The subtitle asset %n has no <EntryPoint> tag."));
253 case dcp::VerificationNote::Code::INCORRECT_SUBTITLE_ENTRY_POINT:
254 add(i, _("Subtitle asset %n has a non-zero <EntryPoint>."));
256 case dcp::VerificationNote::Code::MISSING_CLOSED_CAPTION_ENTRY_POINT:
257 add(i, _("The closed caption asset %n has no <EntryPoint> tag."));
259 case dcp::VerificationNote::Code::INCORRECT_CLOSED_CAPTION_ENTRY_POINT:
260 add(i, _("Closed caption asset %n has a non-zero <EntryPoint>."));
262 case dcp::VerificationNote::Code::MISSING_HASH:
263 add(i, _("The asset %n has no <Hash> in the CPL."));
265 case dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE:
266 add(i, _("The DCP is a feature but has no FFEC (first frame of end credits) marker."));
268 case dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE:
269 add(i, _("The DCP is a feature but has no FFMC (first frame of moving credits) marker."));
271 case dcp::VerificationNote::Code::MISSING_FFOC:
272 add(i, _("The DCP has no FFOC (first frame of content) marker."));
274 case dcp::VerificationNote::Code::MISSING_LFOC:
275 add(i, _("The DCP has no LFOC (last frame of content) marker."));
277 case dcp::VerificationNote::Code::INCORRECT_FFOC:
278 add(i, _("The DCP has a FFOC of %n instead of 1."));
280 case dcp::VerificationNote::Code::INCORRECT_LFOC:
281 add(i, _("The DCP has a LFOC of %n instead of the reel duration minus one."));
283 case dcp::VerificationNote::Code::MISSING_CPL_METADATA:
284 add(i, _("The CPL %n has no CPL metadata tag."));
286 case dcp::VerificationNote::Code::MISSING_CPL_METADATA_VERSION_NUMBER:
287 add(i, _("The CPL %n has no CPL metadata version number tag."));
289 case dcp::VerificationNote::Code::MISSING_EXTENSION_METADATA:
290 add(i, _("The CPL %n has no CPL extension metadata tag."));
292 case dcp::VerificationNote::Code::INVALID_EXTENSION_METADATA:
293 add(i, _("The CPL %f has an invalid CPL extension metadata tag (%n)"));
295 case dcp::VerificationNote::Code::UNSIGNED_CPL_WITH_ENCRYPTED_CONTENT:
296 add(i, _("The CPL %n has encrypted content but is not signed."));
298 case dcp::VerificationNote::Code::UNSIGNED_PKL_WITH_ENCRYPTED_CONTENT:
299 add(i, _("The PKL %n has encrypted content but is not signed."));
301 case dcp::VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL:
302 add(i, _("The PKL %n has an <AnnotationText> which does not match its CPL's <ContentTitleText>."));
304 case dcp::VerificationNote::Code::PARTIALLY_ENCRYPTED:
305 add(i, _("The DCP has encrypted content, but not all its assets are encrypted."));
307 case dcp::VerificationNote::Code::INVALID_JPEG2000_CODESTREAM:
308 add(i, _("A picture frame has an invalid JPEG2000 codestream (%n)"));
310 case dcp::VerificationNote::Code::INVALID_JPEG2000_GUARD_BITS_FOR_2K:
311 add(i, _("A 2K JPEG2000 frame has %n guard bits instead of 1."));
313 case dcp::VerificationNote::Code::INVALID_JPEG2000_GUARD_BITS_FOR_4K:
314 add(i, _("A 4K JPEG2000 frame has %n guard bits instead of 2."));
316 case dcp::VerificationNote::Code::INVALID_JPEG2000_TILE_SIZE:
317 add(i, _("A JPEG2000 tile size does not match the image size."));
319 case dcp::VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_WIDTH:
320 add(i, _("A JPEG2000 frame has a code-block width of %n instead of 32."));
322 case dcp::VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_HEIGHT:
323 add(i, _("A JPEG2000 frame has a code-block height of %n instead of 32."));
325 case dcp::VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_2K:
326 add(i, _("A 2K JPEG2000 frame has %n POC marker(s) instead of 0."));
328 case dcp::VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_4K:
329 add(i, _("A 4K JPEG2000 frame has %n POC marker(s) instead of 1."));
331 case dcp::VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER:
332 add(i, _("A JPEG2000 frame contains an invalid POC marker (%n)."));
334 case dcp::VerificationNote::Code::INVALID_JPEG2000_POC_MARKER_LOCATION:
335 add(i, _("A JPEG2000 frame contains POC marker in an invalid location."));
337 case dcp::VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_2K:
338 add(i, _("A 2K JPEG2000 frame contains %n tile parts instead of 3."));
340 case dcp::VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_4K:
341 add(i, _("A 2K JPEG2000 frame contains %n tile parts instead of 6."));
343 case dcp::VerificationNote::Code::MISSING_JPEG200_TLM_MARKER:
344 add(i, _("A JPEG2000 frame has no TLM marker."));
346 case dcp::VerificationNote::Code::SUBTITLE_OVERLAPS_REEL_BOUNDARY:
347 add(i, _("A subtitle lasts longer than the reel it is in."));
349 case dcp::VerificationNote::Code::MISMATCHED_TIMED_TEXT_RESOURCE_ID:
350 add(i, _("The Resource ID in a timed text MXF did not match the ID of the contained XML."));
352 case dcp::VerificationNote::Code::INCORRECT_TIMED_TEXT_ASSET_ID:
353 add(i, _("The Asset ID in a timed text MXF is the same as the Resource ID or that of the contained XML."));
355 case dcp::VerificationNote::Code::MISMATCHED_TIMED_TEXT_DURATION:
357 vector<string> parts;
358 boost::split (parts, i.note().get(), boost::is_any_of(" "));
359 add(i, wxString::Format(_("The reel duration (%s) of some timed text is not the same as the ContainerDuration (%s) of its MXF."), std_to_wx(parts[0]), std_to_wx(parts[1])));
362 case dcp::VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED:
363 add(i, _("Part of the DCP could not be checked because no KDM was available."));
365 case dcp::VerificationNote::Code::EMPTY_TEXT:
366 add(i, _("At least one <Text> node in a subtitle or closed caption is empty."));
368 case dcp::VerificationNote::Code::MISMATCHED_CLOSED_CAPTION_VALIGN:
369 add(i, _("Some closed <Text> or <Image> nodes have different vertical alignments within a <Subtitle>."));
371 case dcp::VerificationNote::Code::INCORRECT_CLOSED_CAPTION_ORDERING:
372 add(i, _("Some closed captions are not listed in the order of their vertical position."));
374 case dcp::VerificationNote::Code::UNEXPECTED_ENTRY_POINT:
375 add(i, _("There is a <EntryPoint> tag inside a <MainMarkers>."));
377 case dcp::VerificationNote::Code::UNEXPECTED_DURATION:
378 add(i, _("There is a <Duration> tag inside a <MainMarkers>."));
383 wxString summary_text;
385 if (counts[dcp::VerificationNote::Type::ERROR] == 1) {
386 /// TRANSLATORS: this will be used at the start of a string like "1 error, 2 Bv2.1 errors and 3 warnings."
387 summary_text = _("1 error, ");
389 /// TRANSLATORS: this will be used at the start of a string like "1 error, 2 Bv2.1 errors and 3 warnings."
390 summary_text = wxString::Format("%d errors, ", counts[dcp::VerificationNote::Type::ERROR]);
393 if (counts[dcp::VerificationNote::Type::BV21_ERROR] == 1) {
394 /// TRANSLATORS: this will be used in the middle of a string like "1 error, 2 Bv2.1 errors and 3 warnings."
395 summary_text += _("1 Bv2.1 error, ");
397 /// TRANSLATORS: this will be used in the middle of a string like "1 error, 2 Bv2.1 errors and 3 warnings."
398 summary_text += wxString::Format("%d Bv2.1 errors, ", counts[dcp::VerificationNote::Type::BV21_ERROR]);
401 if (counts[dcp::VerificationNote::Type::WARNING] == 1) {
402 /// TRANSLATORS: this will be used at the end of a string like "1 error, 2 Bv2.1 errors and 3 warnings."
403 summary_text += _("and 1 warning.");
405 /// TRANSLATORS: this will be used at the end of a string like "1 error, 2 Bv2.1 errors and 3 warnings."
406 summary_text += wxString::Format("and %d warnings.", counts[dcp::VerificationNote::Type::WARNING]);
409 summary->SetLabel(summary_text);
411 if (counts[dcp::VerificationNote::Type::ERROR] == 0) {
412 add_bullet (dcp::VerificationNote::Type::ERROR, _("No errors found."));
415 if (counts[dcp::VerificationNote::Type::BV21_ERROR] == 0) {
416 add_bullet (dcp::VerificationNote::Type::BV21_ERROR, _("No SMPTE Bv2.1 errors found."));
419 if (counts[dcp::VerificationNote::Type::WARNING] == 0) {
420 add_bullet (dcp::VerificationNote::Type::WARNING, _("No warnings found."));