adjusted_format_desc.field_mode = field_mode::progressive;
adjusted_format_desc.fps *= adjusted_format_desc.field_count;
- adjusted_format_desc.duration /= adjusted_format_desc.field_count;
+ adjusted_format_desc.time_scale *= adjusted_format_desc.field_count;
+ adjusted_format_desc.framerate *= adjusted_format_desc.field_count;
adjusted_format_desc.field_count = 1;
+ adjusted_format_desc.audio_cadence = core::find_audio_cadence(adjusted_format_desc.framerate);
return dependencies.producer_registry->create_producer(adjusted_dependencies, producer_string);
}();
return out;
}
+std::vector<int> find_audio_cadence(const boost::rational<int>& framerate, bool log_quiet)
+{
+ static std::map<boost::rational<int>, std::vector<int>> CADENCES_BY_FRAMERATE = []
+ {
+ std::map<boost::rational<int>, std::vector<int>> result;
+
+ for (core::video_format format : enum_constants<core::video_format>())
+ {
+ core::video_format_desc desc(format);
+ boost::rational<int> format_rate(desc.time_scale, desc.duration);
+
+ result.insert(std::make_pair(format_rate, desc.audio_cadence));
+ }
+
+ return result;
+ }();
+
+ auto exact_match = CADENCES_BY_FRAMERATE.find(framerate);
+
+ if (exact_match != CADENCES_BY_FRAMERATE.end())
+ return exact_match->second;
+
+ boost::rational<int> closest_framerate_diff = std::numeric_limits<int>::max();
+ boost::rational<int> closest_framerate = 0;
+
+ for (auto format_framerate : CADENCES_BY_FRAMERATE | boost::adaptors::map_keys)
+ {
+ auto diff = boost::abs(framerate - format_framerate);
+
+ if (diff < closest_framerate_diff)
+ {
+ closest_framerate_diff = diff;
+ closest_framerate = format_framerate;
+ }
+ }
+
+ if (log_quiet)
+ CASPAR_LOG(debug) << "No exact audio cadence match found for framerate " << to_string(framerate)
+ << "\nClosest match is " << to_string(closest_framerate)
+ << "\nwhich is a " << to_string(closest_framerate_diff) << " difference.";
+ else
+ CASPAR_LOG(warning) << "No exact audio cadence match found for framerate " << to_string(framerate)
+ << "\nClosest match is " << to_string(closest_framerate)
+ << "\nwhich is a " << to_string(closest_framerate_diff) << " difference.";
+
+ return CADENCES_BY_FRAMERATE[closest_framerate];
+}
+
}}
#include <boost/rational.hpp>
namespace caspar { namespace core {
-
+
enum class video_format
-{
- pal,
- ntsc,
- x576p2500,
- x720p2500,
+{
+ pal,
+ ntsc,
+ x576p2500,
+ x720p2500,
x720p5000,
x720p2398,
x720p2400,
x720p3000,
x720p6000,
x1080p2398,
- x1080p2400,
- x1080i5000,
- x1080i5994,
- x1080i6000,
- x1080p2500,
- x1080p2997,
- x1080p3000,
+ x1080p2400,
+ x1080i5000,
+ x1080i5994,
+ x1080i6000,
+ x1080p2500,
+ x1080p2997,
+ x1080p3000,
x1080p5000,
x1080p5994,
x1080p6000,
struct video_format_desc final
{
- video_format format;
+ video_format format;
- int width;
- int height;
+ int width;
+ int height;
int square_width;
int square_height;
core::field_mode field_mode; // progressive, interlaced upper field first, interlaced lower field first
int time_scale;
int duration;
int field_count;
- std::size_t size; // frame size in bytes
+ std::size_t size; // frame size in bytes
std::wstring name; // name of output format
int audio_sample_rate;
int duration,
const std::wstring& name,
const std::vector<int>& audio_cadence);
-
+
video_format_desc(video_format format = video_format::invalid);
video_format_desc(const std::wstring& name);
};
std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc);
+std::vector<int> find_audio_cadence(const boost::rational<int>& framerate, bool log_quiet = false);
+
}}
std::vector<int> find_audio_cadence(const boost::rational<int>& framerate)
{
- static std::map<boost::rational<int>, std::vector<int>> CADENCES_BY_FRAMERATE = []
- {
- std::map<boost::rational<int>, std::vector<int>> result;
-
- for (core::video_format format : enum_constants<core::video_format>())
- {
- core::video_format_desc desc(format);
- boost::rational<int> format_rate(desc.time_scale, desc.duration);
-
- result.insert(std::make_pair(format_rate, desc.audio_cadence));
- }
-
- return result;
- }();
-
- auto exact_match = CADENCES_BY_FRAMERATE.find(framerate);
-
- if (exact_match != CADENCES_BY_FRAMERATE.end())
- return exact_match->second;
-
- boost::rational<int> closest_framerate_diff = std::numeric_limits<int>::max();
- boost::rational<int> closest_framerate = 0;
-
- for (auto format_framerate : CADENCES_BY_FRAMERATE | boost::adaptors::map_keys)
- {
- auto diff = boost::abs(framerate - format_framerate);
-
- if (diff < closest_framerate_diff)
- {
- closest_framerate_diff = diff;
- closest_framerate = format_framerate;
- }
- }
-
- if (is_logging_quiet_for_thread())
- CASPAR_LOG(debug) << "No exact audio cadence match found for framerate " << to_string(framerate)
- << "\nClosest match is " << to_string(closest_framerate)
- << "\nwhich is a " << to_string(closest_framerate_diff) << " difference.";
- else
- CASPAR_LOG(warning) << "No exact audio cadence match found for framerate " << to_string(framerate)
- << "\nClosest match is " << to_string(closest_framerate)
- << "\nwhich is a " << to_string(closest_framerate_diff) << " difference.";
-
- return CADENCES_BY_FRAMERATE[closest_framerate];
+ return core::find_audio_cadence(framerate, is_logging_quiet_for_thread());
}
//
dependencies.format_desc.time_scale*2,
dependencies.format_desc.duration,
dependencies.format_desc.name,
- dependencies.format_desc.audio_cadence };
+ core::find_audio_cadence(dependencies.format_desc.framerate * 2) };
auto group = spl::make_shared<core::scene::scene_producer>(psd_layer->name(), L"layer group in " + params.at(0), doc.width(), doc.height(), format_desc);