Skip to content

Commit e6fcc58

Browse files
decklink: better name for format strategies
1 parent 91831c1 commit e6fcc58

File tree

7 files changed

+62
-62
lines changed

7 files changed

+62
-62
lines changed

src/modules/decklink/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ project (decklink)
33

44
set(SOURCES
55
consumer/decklink_consumer.cpp
6-
consumer/frame_factory_hdr_v210.cpp
7-
consumer/frame_factory_sdr_bgra.cpp
6+
consumer/hdr_v210_strategy.cpp
7+
consumer/sdr_bgra_strategy.cpp
88
consumer/config.cpp
99
consumer/monitor.cpp
1010

@@ -14,9 +14,9 @@ set(SOURCES
1414
)
1515
set(HEADERS
1616
consumer/decklink_consumer.h
17-
consumer/frame_factory_hdr_v210.h
18-
consumer/frame_factory_sdr_bgra.h
19-
consumer/frame_factory.h
17+
consumer/hdr_v210_strategy.h
18+
consumer/sdr_bgra_strategy.h
19+
consumer/format_strategy.h
2020
consumer/config.h
2121
consumer/monitor.h
2222

src/modules/decklink/consumer/decklink_consumer.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#include "common/os/thread.h"
2626
#include "config.h"
2727
#include "decklink_consumer.h"
28-
#include "frame_factory_hdr_v210.h"
29-
#include "frame_factory_sdr_bgra.h"
28+
#include "hdr_v210_strategy.h"
29+
#include "sdr_bgra_strategy.h"
3030
#include "monitor.h"
3131

3232
#include "../decklink.h"
@@ -194,10 +194,10 @@ core::video_format_desc get_decklink_format(const port_configuration& confi
194194
return fallback_format_desc;
195195
}
196196

197-
spl::shared_ptr<frame_factory> create_frame_factory(bool hdr)
197+
spl::shared_ptr<format_strategy> create_format_strategy(bool hdr)
198198
{
199-
return hdr ? spl::make_shared<frame_factory, frame_factory_hdr_v210>()
200-
: spl::make_shared<frame_factory, frame_factory_sdr_bgra>();
199+
return hdr ? spl::make_shared<format_strategy, hdr_v210_strategy>()
200+
: spl::make_shared<format_strategy, sdr_bgra_strategy>();
201201
}
202202

203203
enum EOTF
@@ -437,7 +437,7 @@ struct decklink_secondary_port final : public IDeckLinkVideoOutputCallback
437437
{
438438
const configuration config_;
439439
const port_configuration output_config_;
440-
spl::shared_ptr<frame_factory> frame_factory_;
440+
spl::shared_ptr<format_strategy> format_strategy_;
441441
com_ptr<IDeckLink> decklink_ = get_device(output_config_.device_index);
442442
com_iface_ptr<IDeckLinkOutput> output_ = iface_cast<IDeckLinkOutput>(decklink_);
443443
com_iface_ptr<IDeckLinkKeyer> keyer_ = iface_cast<IDeckLinkKeyer>(decklink_, true);
@@ -454,7 +454,7 @@ struct decklink_secondary_port final : public IDeckLinkVideoOutputCallback
454454
const core::video_format_desc decklink_format_desc_;
455455
com_ptr<IDeckLinkDisplayMode> mode_ = get_display_mode(output_,
456456
decklink_format_desc_.format,
457-
frame_factory_->get_pixel_format(),
457+
format_strategy_->get_pixel_format(),
458458
bmdSupportedVideoModeDefault);
459459

460460
decklink_secondary_port(const configuration& config,
@@ -465,7 +465,7 @@ struct decklink_secondary_port final : public IDeckLinkVideoOutputCallback
465465
int device_sync_group)
466466
: config_(config)
467467
, output_config_(std::move(output_config))
468-
, frame_factory_(new frame_factory_sdr_bgra())
468+
, format_strategy_(new sdr_bgra_strategy())
469469
, device_sync_group_(device_sync_group)
470470
, channel_format_desc_(std::move(channel_format_desc))
471471
, decklink_format_desc_(get_decklink_format(output_config_, main_decklink_format_desc))
@@ -557,7 +557,7 @@ struct decklink_secondary_port final : public IDeckLinkVideoOutputCallback
557557
frame1 = frame;
558558
}
559559

560-
auto image_data = frame_factory_->convert_frame_for_port(
560+
auto image_data = format_strategy_->convert_frame_for_port(
561561
channel_format_desc_, decklink_format_desc_, output_config_, frame1, frame2, mode_->GetFieldDominance());
562562

563563
schedule_next_video(image_data, 0, display_time);
@@ -569,8 +569,8 @@ struct decklink_secondary_port final : public IDeckLinkVideoOutputCallback
569569
decklink_format_desc_,
570570
nb_samples,
571571
config_.hdr,
572-
frame_factory_->get_pixel_format(),
573-
frame_factory_->get_row_bytes(decklink_format_desc_.width),
572+
format_strategy_->get_pixel_format(),
573+
format_strategy_->get_row_bytes(decklink_format_desc_.width),
574574
core::color_space::bt709,
575575
config_.hdr_meta));
576576
if (FAILED(output_->ScheduleVideoFrame(get_raw(packed_frame),
@@ -600,9 +600,9 @@ struct decklink_secondary_port final : public IDeckLinkVideoOutputCallback
600600

601601
struct decklink_consumer final : public IDeckLinkVideoOutputCallback
602602
{
603-
const int channel_index_;
604-
const configuration config_;
605-
spl::shared_ptr<frame_factory> frame_factory_;
603+
const int channel_index_;
604+
const configuration config_;
605+
spl::shared_ptr<format_strategy> format_strategy_;
606606

607607
com_ptr<IDeckLink> decklink_ = get_device(config_.primary.device_index);
608608
com_iface_ptr<IDeckLinkOutput> output_ = iface_cast<IDeckLinkOutput>(decklink_);
@@ -638,7 +638,7 @@ struct decklink_consumer final : public IDeckLinkVideoOutputCallback
638638

639639
com_ptr<IDeckLinkDisplayMode> mode_ = get_display_mode(output_,
640640
decklink_format_desc_.format,
641-
frame_factory_->get_pixel_format(),
641+
format_strategy_->get_pixel_format(),
642642
bmdSupportedVideoModeDefault);
643643

644644
std::atomic<bool> abort_request_{false};
@@ -647,7 +647,7 @@ struct decklink_consumer final : public IDeckLinkVideoOutputCallback
647647
decklink_consumer(const configuration& config, core::video_format_desc channel_format_desc, int channel_index)
648648
: channel_index_(channel_index)
649649
, config_(config)
650-
, frame_factory_(create_frame_factory(config.hdr))
650+
, format_strategy_(create_format_strategy(config.hdr))
651651
, channel_format_desc_(std::move(channel_format_desc))
652652
, decklink_format_desc_(get_decklink_format(config.primary, channel_format_desc_))
653653
{
@@ -726,7 +726,7 @@ struct decklink_consumer final : public IDeckLinkVideoOutputCallback
726726
nb_samples);
727727
}
728728

729-
std::shared_ptr<void> image_data = frame_factory_->allocate_frame_data(decklink_format_desc_);
729+
std::shared_ptr<void> image_data = format_strategy_->allocate_frame_data(decklink_format_desc_);
730730

731731
schedule_next_video(image_data, nb_samples, video_scheduled_, config_.hdr_meta.default_color_space);
732732
for (auto& context : secondary_port_contexts_) {
@@ -943,7 +943,7 @@ struct decklink_consumer final : public IDeckLinkVideoOutputCallback
943943
if (i == -1) {
944944
// Primary port
945945
std::shared_ptr<void> image_data =
946-
frame_factory_->convert_frame_for_port(channel_format_desc_,
946+
format_strategy_->convert_frame_for_port(channel_format_desc_,
947947
decklink_format_desc_,
948948
config_.primary,
949949
frame1,
@@ -1016,8 +1016,8 @@ struct decklink_consumer final : public IDeckLinkVideoOutputCallback
10161016
BMDTimeValue display_time,
10171017
core::color_space color_space)
10181018
{
1019-
auto fmt = frame_factory_->get_pixel_format();
1020-
auto row_bytes = frame_factory_->get_row_bytes(decklink_format_desc_.width);
1019+
auto fmt = format_strategy_->get_pixel_format();
1020+
auto row_bytes = format_strategy_->get_row_bytes(decklink_format_desc_.width);
10211021
auto fill_frame = wrap_raw<com_ptr, IDeckLinkVideoFrame>(new decklink_frame(
10221022
std::move(image_data), decklink_format_desc_, nb_samples, config_.hdr, fmt, row_bytes, color_space, config_.hdr_meta));
10231023
if (FAILED(output_->ScheduleVideoFrame(

src/modules/decklink/consumer/frame_factory.h renamed to src/modules/decklink/consumer/format_strategy.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@
3434

3535
namespace caspar { namespace decklink {
3636

37-
class frame_factory
37+
class format_strategy
3838
{
3939
protected:
40-
frame_factory() = default;
40+
format_strategy() = default;
4141

4242
public:
43-
frame_factory& operator=(const frame_factory&) = delete;
44-
virtual ~frame_factory() = default;
43+
format_strategy& operator=(const format_strategy&) = delete;
44+
virtual ~format_strategy() = default;
4545

46-
frame_factory(const frame_factory&) = delete;
46+
format_strategy(const format_strategy&) = delete;
4747

4848
virtual BMDPixelFormat get_pixel_format() = 0;
4949
virtual int get_row_bytes(int width) = 0;

src/modules/decklink/consumer/frame_factory_hdr_v210.cpp renamed to src/modules/decklink/consumer/hdr_v210_strategy.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "../StdAfx.h"
2323

24-
#include "frame_factory_hdr_v210.h"
24+
#include "hdr_v210_strategy.h"
2525

2626
#include <common/memshfl.h>
2727

@@ -198,7 +198,7 @@ void pack_v210(const ARGBPixel* src, const std::vector<int32_t>& color_matrix, u
198198
}
199199

200200

201-
struct frame_factory_hdr_v210::impl final
201+
struct hdr_v210_strategy::impl final
202202
{
203203
std::vector<float> bt709{0.2126, 0.7152, 0.0722, -0.1146, -0.3854, 0.5, 0.5, -0.4542, -0.0458};
204204

@@ -338,22 +338,22 @@ struct frame_factory_hdr_v210::impl final
338338
}
339339
};
340340

341-
frame_factory_hdr_v210::frame_factory_hdr_v210()
341+
hdr_v210_strategy::hdr_v210_strategy()
342342
: impl_(new impl())
343343
{
344344
}
345345

346-
frame_factory_hdr_v210::~frame_factory_hdr_v210() {}
346+
hdr_v210_strategy::~hdr_v210_strategy() {}
347347

348-
BMDPixelFormat frame_factory_hdr_v210::get_pixel_format() { return impl_->get_pixel_format(); }
349-
int frame_factory_hdr_v210::get_row_bytes(int width) { return impl_->get_row_bytes(width); }
348+
BMDPixelFormat hdr_v210_strategy::get_pixel_format() { return impl_->get_pixel_format(); }
349+
int hdr_v210_strategy::get_row_bytes(int width) { return impl_->get_row_bytes(width); }
350350

351-
std::shared_ptr<void> frame_factory_hdr_v210::allocate_frame_data(const core::video_format_desc& format_desc)
351+
std::shared_ptr<void> hdr_v210_strategy::allocate_frame_data(const core::video_format_desc& format_desc)
352352
{
353353
return impl_->allocate_frame_data(format_desc);
354354
}
355355
std::shared_ptr<void>
356-
frame_factory_hdr_v210::convert_frame_for_port(const core::video_format_desc& channel_format_desc,
356+
hdr_v210_strategy::convert_frame_for_port(const core::video_format_desc& channel_format_desc,
357357
const core::video_format_desc& decklink_format_desc,
358358
const port_configuration& config,
359359
const core::const_frame& frame1,

src/modules/decklink/consumer/frame_factory_sdr_bgra.h renamed to src/modules/decklink/consumer/hdr_v210_strategy.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "../StdAfx.h"
2525

2626
#include "config.h"
27-
#include "frame_factory.h"
27+
#include "format_strategy.h"
2828

2929
#include "../decklink_api.h"
3030

@@ -35,13 +35,13 @@
3535

3636
namespace caspar { namespace decklink {
3737

38-
class frame_factory_sdr_bgra
39-
: public frame_factory
40-
, std::enable_shared_from_this<frame_factory_sdr_bgra>
38+
class hdr_v210_strategy
39+
: public format_strategy
40+
, std::enable_shared_from_this<hdr_v210_strategy>
4141
{
4242
public:
43-
explicit frame_factory_sdr_bgra();
44-
virtual ~frame_factory_sdr_bgra();
43+
explicit hdr_v210_strategy();
44+
virtual ~hdr_v210_strategy();
4545

4646
virtual BMDPixelFormat get_pixel_format();
4747
virtual int get_row_bytes(int width);
@@ -56,8 +56,8 @@ class frame_factory_sdr_bgra
5656
private:
5757
struct impl;
5858
std::unique_ptr<impl> impl_;
59-
frame_factory_sdr_bgra(const frame_factory_sdr_bgra&) = delete;
60-
frame_factory_sdr_bgra& operator=(const frame_factory_sdr_bgra&) = delete;
59+
hdr_v210_strategy(const hdr_v210_strategy&) = delete;
60+
hdr_v210_strategy& operator=(const hdr_v210_strategy&) = delete;
6161
};
6262

6363
}} // namespace caspar::decklink

src/modules/decklink/consumer/frame_factory_sdr_bgra.cpp renamed to src/modules/decklink/consumer/sdr_bgra_strategy.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "../StdAfx.h"
2424

25-
#include "frame_factory_sdr_bgra.h"
25+
#include "sdr_bgra_strategy.h"
2626

2727
#include <common/memshfl.h>
2828

@@ -40,7 +40,7 @@ std::shared_ptr<void> convert_to_key_only(const std::shared_ptr<void>& image_dat
4040
return key_data;
4141
}
4242

43-
struct frame_factory_sdr_bgra::impl final
43+
struct sdr_bgra_strategy::impl final
4444
{
4545
public:
4646
impl() = default;
@@ -181,22 +181,22 @@ struct frame_factory_sdr_bgra::impl final
181181
}
182182
};
183183

184-
frame_factory_sdr_bgra::frame_factory_sdr_bgra()
184+
sdr_bgra_strategy::sdr_bgra_strategy()
185185
: impl_(new impl())
186186
{
187187
}
188188

189-
frame_factory_sdr_bgra::~frame_factory_sdr_bgra() {}
189+
sdr_bgra_strategy::~sdr_bgra_strategy() {}
190190

191-
BMDPixelFormat frame_factory_sdr_bgra::get_pixel_format() { return impl_->get_pixel_format(); }
192-
int frame_factory_sdr_bgra::get_row_bytes(int width) { return impl_->get_row_bytes(width); }
191+
BMDPixelFormat sdr_bgra_strategy::get_pixel_format() { return impl_->get_pixel_format(); }
192+
int sdr_bgra_strategy::get_row_bytes(int width) { return impl_->get_row_bytes(width); }
193193

194-
std::shared_ptr<void> frame_factory_sdr_bgra::allocate_frame_data(const core::video_format_desc& format_desc)
194+
std::shared_ptr<void> sdr_bgra_strategy::allocate_frame_data(const core::video_format_desc& format_desc)
195195
{
196196
return impl_->allocate_frame_data(format_desc);
197197
}
198198
std::shared_ptr<void>
199-
frame_factory_sdr_bgra::convert_frame_for_port(const core::video_format_desc& channel_format_desc,
199+
sdr_bgra_strategy::convert_frame_for_port(const core::video_format_desc& channel_format_desc,
200200
const core::video_format_desc& decklink_format_desc,
201201
const port_configuration& config,
202202
const core::const_frame& frame1,

src/modules/decklink/consumer/frame_factory_hdr_v210.h renamed to src/modules/decklink/consumer/sdr_bgra_strategy.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "../StdAfx.h"
2525

2626
#include "config.h"
27-
#include "frame_factory.h"
27+
#include "format_strategy.h"
2828

2929
#include "../decklink_api.h"
3030

@@ -35,13 +35,13 @@
3535

3636
namespace caspar { namespace decklink {
3737

38-
class frame_factory_hdr_v210
39-
: public frame_factory
40-
, std::enable_shared_from_this<frame_factory_hdr_v210>
38+
class sdr_bgra_strategy
39+
: public format_strategy
40+
, std::enable_shared_from_this<sdr_bgra_strategy>
4141
{
4242
public:
43-
explicit frame_factory_hdr_v210();
44-
virtual ~frame_factory_hdr_v210();
43+
explicit sdr_bgra_strategy();
44+
virtual ~sdr_bgra_strategy();
4545

4646
virtual BMDPixelFormat get_pixel_format();
4747
virtual int get_row_bytes(int width);
@@ -56,8 +56,8 @@ class frame_factory_hdr_v210
5656
private:
5757
struct impl;
5858
std::unique_ptr<impl> impl_;
59-
frame_factory_hdr_v210(const frame_factory_hdr_v210&) = delete;
60-
frame_factory_hdr_v210& operator=(const frame_factory_hdr_v210&) = delete;
59+
sdr_bgra_strategy(const sdr_bgra_strategy&) = delete;
60+
sdr_bgra_strategy& operator=(const sdr_bgra_strategy&) = delete;
6161
};
6262

6363
}} // namespace caspar::decklink

0 commit comments

Comments
 (0)