Use EnumIndexedVector in J2KEncoder.
authorCarl Hetherington <cth@carlh.net>
Mon, 26 Sep 2022 22:56:15 +0000 (00:56 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 27 Sep 2022 11:46:16 +0000 (13:46 +0200)
src/lib/j2k_encoder.cc
src/lib/j2k_encoder.h

index e6dab582801fd7177ecea144d294510261c9f41a..daba87c5986ee6a62240ac78ecb1ec609df1da3a 100644 (file)
@@ -229,7 +229,7 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time)
                /* This frame already has J2K data, so just write it */
                _writer->write (pv->j2k(), position, pv->eyes ());
                frame_done ();
-       } else if (_last_player_video[static_cast<int>(pv->eyes())] && _writer->can_repeat(position) && pv->same (_last_player_video[static_cast<int>(pv->eyes())])) {
+       } else if (_last_player_video[pv->eyes()] && _writer->can_repeat(position) && pv->same(_last_player_video[pv->eyes()])) {
                LOG_DEBUG_ENCODE("Frame @ %1 REPEAT", to_string(time));
                _writer->repeat (position, pv->eyes ());
        } else {
@@ -250,7 +250,7 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time)
                _empty_condition.notify_all ();
        }
 
-       _last_player_video[static_cast<int>(pv->eyes())] = pv;
+       _last_player_video[pv->eyes()] = pv;
        _last_player_video_time = time;
 }
 
index a52cf0d1fc44f264bc614b33877d32a1d79b981a..4bdedb0604d17ae40cd2f1437c15a407c3e31500 100644 (file)
@@ -29,6 +29,7 @@
 
 
 #include "cross.h"
+#include "enum_indexed_vector.h"
 #include "event_history.h"
 #include "exception_store.h"
 #include "util.h"
@@ -105,7 +106,7 @@ private:
        std::shared_ptr<Writer> _writer;
        Waker _waker;
 
-       std::shared_ptr<PlayerVideo> _last_player_video[static_cast<int>(Eyes::COUNT)];
+       EnumIndexedVector<std::shared_ptr<PlayerVideo>, Eyes> _last_player_video;
        boost::optional<dcpomatic::DCPTime> _last_player_video_time;
 
        boost::signals2::scoped_connection _server_found_connection;