From 0717e1ca56bbf5334d56e45940ebdaba05506986 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 21 Sep 2025 23:29:35 +0200 Subject: Hacks --- hacks/hz.py | 1 + src/lib/ffmpeg_content.cc | 1 + src/lib/film.cc | 1 + src/lib/j2k_encoder.cc | 2 ++ src/lib/player.cc | 16 +++++++++++++++- src/lib/reel_writer.cc | 4 +++- src/lib/writer.cc | 1 + test/72fps_dcp_test.cc | 38 ++++++++++++++++++++++++++++++++++++++ test/wscript | 1 + 9 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 test/72fps_dcp_test.cc diff --git a/hacks/hz.py b/hacks/hz.py index 3d85d86cb..1744537cc 100644 --- a/hacks/hz.py +++ b/hacks/hz.py @@ -15,6 +15,7 @@ factors = ( 48, 50, 60, + 72, 48000, 96000, ) diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 6d70336a5..cb4b6199b 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -412,6 +412,7 @@ FFmpegContent::full_length (shared_ptr film) const { FrameRateChange const frc (film, shared_from_this()); if (video) { + // std::cout << "video is " << video->length_after_3d_combine() << " frames, factor=" << frc.factor() << " out " << film->video_frame_rate() << "\n"; return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } diff --git a/src/lib/film.cc b/src/lib/film.cc index 754c7c850..1d062fb09 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1985,6 +1985,7 @@ Film::reels_for_type(ReelType type) const switch (type) { case ReelType::SINGLE: + std::cout << "reels end " << len.to_string() << "\n"; periods.emplace_back(DCPTime(), len); break; case ReelType::BY_VIDEO_CONTENT: diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 2d7802068..c04336586 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -322,9 +322,11 @@ J2KEncoder::encode (shared_ptr pv, DCPTime time) frame_done (); } else if (_last_player_video[pv->eyes()] && _writer.can_repeat(position) && pv->same(_last_player_video[pv->eyes()])) { LOG_DEBUG_ENCODE("Frame @ {} REPEAT", time.to_string()); + std::cout << "Frame @ " << time.to_string() << " " << time.frames_round(72) << " REPEAT\n"; _writer.repeat(position, pv->eyes()); } else { LOG_DEBUG_ENCODE("Frame @ {} ENCODE", time.to_string()); + std::cout << "Frame @ " << time.to_string() << " " << time.frames_round(72) << " ENCODE\n"; /* Queue this new frame for encoding */ LOG_TIMING ("add-frame-to-queue queue={}", _queue.size ()); auto dcpv = DCPVideo( diff --git a/src/lib/player.cc b/src/lib/player.cc index 77916a5e5..82aadd802 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -889,9 +889,15 @@ Player::pass() if (done) { if (_next_video_time) { LOG_DEBUG_PLAYER("Done: emit video until end of film at {}", film->length().to_string()); + std::cout << "Emit until end of film at " << film->length().to_string() << " " << film->length().frames_round(72) << "\n"; emit_video_until(film->length()); } + std::cout << "done: nat " << _next_audio_time.get_value_or({}).to_string() << " film " << film->length().to_string() << "\n"; + if (_next_audio_time && film->length() > *_next_audio_time) { + fill_audio(DCPTimePeriod(*_next_audio_time, film->length())); + } + if (_shuffler) { _shuffler->flush(); } @@ -965,7 +971,8 @@ void Player::emit_video_until(DCPTime time) { LOG_DEBUG_PLAYER("emit_video_until {}; next video time is {}", time.to_string(), _next_video_time.get_value_or({}).to_string()); - auto frame = [this](shared_ptr pv, DCPTime time) { + static int shite = 0; + auto frame = [this, &shite](shared_ptr pv, DCPTime time) { /* We need a delay to give a little wiggle room to ensure that relevant subtitles arrive at the player before the video that requires them. */ @@ -982,6 +989,7 @@ Player::emit_video_until(DCPTime time) auto to_do = _delay.front(); _delay.pop_front(); emit_video(to_do.first, to_do.second); + std::cout << "EV " << to_do.second.to_string() << " " << ++shite << "\n"; }; auto film = _film.lock(); @@ -995,6 +1003,8 @@ Player::emit_video_until(DCPTime time) } }; + std::cout << "EVU " << _next_video_time.get_value_or({}).to_string() << " " << time.to_string() << "\n"; + while (_next_video_time.get_value_or({}) < time) { auto left = _last_video[Eyes::LEFT]; auto right = _last_video[Eyes::RIGHT]; @@ -1458,6 +1468,7 @@ Player::emit_video(shared_ptr pv, DCPTime time) pv->set_text(texts.get()); } + // std::cout << "emit_video " << time.to_string() << "\n"; Video(pv, time); } @@ -1477,6 +1488,9 @@ Player::emit_audio(shared_ptr data, DCPTime time) /* This audio must follow on from the previous, allowing for half a sample (at 48kHz) leeway */ DCPOMATIC_ASSERT(diff < 2); Audio(data, time, film->audio_frame_rate()); + static int64_t x = 0; + x += data->frames(); + std::cout << "sent " << x << " audio frames.\n"; _next_audio_time = time + DCPTime::from_frames(data->frames(), film->audio_frame_rate()); } diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index d78c6b730..465b84528 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -345,9 +345,11 @@ ReelWriter::repeat_write(Frame frame, Eyes eyes) { if (!_j2k_picture_asset_writer) { /* We're not writing any data */ + std::cout << "don't do it.\n"; return; } + std::cout << "do it.\n"; auto fin = J2KFrameInfo(_j2k_picture_asset_writer->write(_last_written[eyes]->data(), _last_written[eyes]->size())); fin.write(_info_file, frame, eyes); } @@ -580,7 +582,7 @@ ReelWriter::create_reel_sound(shared_ptr reel, listactual_duration() != period_duration) { throw ProgrammingError( __FILE__, __LINE__, - fmt::format("{} vs {}", reel_asset->actual_duration(), period_duration) + fmt::format("sound asset {} vs reel {}", reel_asset->actual_duration(), period_duration) ); } diff --git a/src/lib/writer.cc b/src/lib/writer.cc index dd5223670..2c1da13d1 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -448,6 +448,7 @@ try break; case QueueItem::Type::REPEAT: LOG_DEBUG_ENCODE(N_("Writer REPEAT-writes {}"), qi.frame); + std::cout << "Writer REPEAT-writes " << qi.frame << "\n"; reel.repeat_write(qi.frame, qi.eyes); ++_repeat_written; break; diff --git a/test/72fps_dcp_test.cc b/test/72fps_dcp_test.cc new file mode 100644 index 000000000..3191c7269 --- /dev/null +++ b/test/72fps_dcp_test.cc @@ -0,0 +1,38 @@ +/* + Copyright (C) 2025 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "lib/config.h" +#include "lib/content_factory.h" +#include "lib/film.h" +#include "test.h" +#include + + +BOOST_AUTO_TEST_CASE(unusual_72fps_dcp_test) +{ + auto content = content_factory(TestPaths::private_data() / "arrietty_JP-EN.mkv"); + auto film = new_test_film("unusual_72fps_dcp_test", content); + film->set_video_frame_rate(72); + + Config::instance()->set_log_types(Config::instance()->log_types() | LogEntry::TYPE_DEBUG_PLAYER); + make_and_verify_dcp(film); +} + diff --git a/test/wscript b/test/wscript index 4bd2c8891..cbdb19e74 100644 --- a/test/wscript +++ b/test/wscript @@ -48,6 +48,7 @@ def build(bld): 2986_regression_test.cc 3042_regression_test.cc 4k_test.cc + 72fps_dcp_test.cc analytics_test.cc atmos_test.cc audio_analysis_test.cc -- cgit v1.2.3