Formatting, variable name tidying and some const correctness.
authorCarl Hetherington <cth@carlh.net>
Fri, 7 Jul 2023 22:20:15 +0000 (00:20 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 16 Dec 2023 01:07:37 +0000 (02:07 +0100)
src/lib/dcp_encoder.cc
src/lib/dcp_encoder.h
src/lib/dcp_video.cc
src/lib/dcp_video.h
src/lib/encoder.h
src/lib/j2k_encoder.cc
src/lib/j2k_encoder.h
src/lib/transcode_job.cc

index 7088225cd09a5a85f3f81a7ede8f4475d9ecc5b7..a03f689b03b757ea5802309bc94b732962efd701 100644 (file)
@@ -118,13 +118,20 @@ DCPEncoder::go ()
        _writer.finish(_film->dir(_film->dcp_name()));
 }
 
-void DCPEncoder::pause(void) {
+
+void
+DCPEncoder::pause()
+{
        _j2k_encoder.pause();
 }
 
-void DCPEncoder::resume(void) {
+
+void
+DCPEncoder::resume()
+{
        _j2k_encoder.resume();
 }
+
 void
 DCPEncoder::video (shared_ptr<PlayerVideo> data, DCPTime time)
 {
index a8043887eb6d8e1f2e8601a8dc12249225496485..771679a98de2c20027af855803e52df10c34b830 100644 (file)
@@ -52,8 +52,9 @@ public:
        bool finishing () const override {
                return _finishing;
        }
-       void pause(void) override;
-       void resume(void) override;
+
+       void pause() override;
+       void resume() override;
 
 private:
 
index 204c390ee73285f0622dabab17d286ec0658feaa..3769a3285e552b9e40400e2513e79e920a499eb1 100644 (file)
@@ -118,15 +118,17 @@ DCPVideo::convert_to_xyz (shared_ptr<const PlayerVideo> frame)
 }
 
 dcp::Size
-DCPVideo::get_size(void) {
-       auto image = _frame->image (bind(&PlayerVideo::keep_xyz_or_rgb, _1), VideoRange::FULL, false);
+DCPVideo::get_size() const
+{
+       auto image = _frame->image(bind(&PlayerVideo::keep_xyz_or_rgb, _1), VideoRange::FULL, false);
        return image->size();
 }
 
-void
-DCPVideo::convert_to_xyz (uint16_t *dst) {
 
-       auto image = _frame->image (bind(&PlayerVideo::keep_xyz_or_rgb, _1), VideoRange::FULL, false);
+void
+DCPVideo::convert_to_xyz(uint16_t* dst) const
+{
+       auto image = _frame->image(bind(&PlayerVideo::keep_xyz_or_rgb, _1), VideoRange::FULL, false);
        if (_frame->colour_conversion()) {
                dcp::rgb_to_xyz (
                        image->data()[0],
@@ -138,6 +140,7 @@ DCPVideo::convert_to_xyz (uint16_t *dst) {
        }
 }
 
+
 /** J2K-encode this frame on the local host.
  *  @return Encoded data.
  */
index 23c920ede6fdcf5e8aa624763a503d1436cc2678..67a2c9f4412e8b06dc5932a73ee66b574e9f8150 100644 (file)
@@ -49,7 +49,7 @@ class PlayerVideo;
 class DCPVideo
 {
 public:
-       DCPVideo (void) : DCPVideo(nullptr,0,0,0,Resolution::TWO_K){}
+       DCPVideo() : DCPVideo(nullptr, 0, 0, 0, Resolution::TWO_K) {}
        DCPVideo (std::shared_ptr<const PlayerVideo>, int index, int dcp_fps, int bandwidth, Resolution r);
        DCPVideo (std::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr);
 
@@ -69,8 +69,9 @@ public:
 
        static std::shared_ptr<dcp::OpenJPEGImage> convert_to_xyz(std::shared_ptr<const PlayerVideo> frame);
 
-       void convert_to_xyz (uint16_t *dst);
-       dcp::Size get_size(void);
+       void convert_to_xyz(uint16_t* dst) const;
+       dcp::Size get_size() const;
+
 private:
 
        void add_metadata (xmlpp::Element *) const;
index f921fcb515962fb9f92af12d2189af77778c2274..aeaf7f6204a9cb10c12a3c4ce3ee9e7a4ba2e7ee 100644 (file)
@@ -58,8 +58,8 @@ public:
        /** @return the number of frames that are done */
        virtual Frame frames_done () const = 0;
        virtual bool finishing () const = 0;
-       virtual void pause(void) {}
-       virtual void resume(void) {}
+       virtual void pause() {}
+       virtual void resume() {}
 
 protected:
        std::shared_ptr<const Film> _film;
index e2fca09b11112e37b80a1e0cdfb4fa3bf4f4db20..defde2227a5fee5af985b36c0ce230d130d61236 100644 (file)
@@ -61,9 +61,9 @@ static grk_plugin::GrokInitializer grokInitializer;
 J2KEncoder::J2KEncoder(shared_ptr<const Film> film, Writer& writer)
        : _film (film)
        , _history (200)
-       , _writer (writer) ,
-       dcpomaticContext_(film,writer,_history, Config::instance()->gpu_binary_location ()),
-       context_(Config::instance()->enable_gpu () ? new grk_plugin::GrokContext(dcpomaticContext_) : nullptr)
+       , _writer (writer)
+       , _dcpomatic_context(film, writer, _history, Config::instance()->gpu_binary_location())
+       , _context(Config::instance()->enable_gpu() ? new grk_plugin::GrokContext(_dcpomatic_context) : nullptr)
 {
 }
 
@@ -77,7 +77,7 @@ J2KEncoder::~J2KEncoder ()
        terminate_threads ();
        }
 
-       delete context_;
+       delete _context;
 }
 
 void
@@ -89,18 +89,25 @@ J2KEncoder::begin ()
        servers_list_changed ();
 }
 
-void J2KEncoder::pause(void){
-       if (Config::instance()->enable_gpu ())
+
+void
+J2KEncoder::pause()
+{
+       if (Config::instance()->enable_gpu()) {
                end(false);
+       }
 }
 
-void J2KEncoder::resume(void){
-       if (Config::instance()->enable_gpu ()) {
-               context_ = new grk_plugin::GrokContext(dcpomaticContext_);
-               servers_list_changed ();
+
+void J2KEncoder::resume()
+{
+       if (Config::instance()->enable_gpu()) {
+               _context = new grk_plugin::GrokContext(_dcpomatic_context);
+               servers_list_changed();
        }
 }
 
+
 void
 J2KEncoder::end (bool isFinal)
 {
@@ -141,7 +148,7 @@ J2KEncoder::end (bool isFinal)
        if (isFinal) {
                for (auto & i: _queue) {
                        if (Config::instance()->enable_gpu ()) {
-                               if (!context_->scheduleCompress(i)){
+                               if (!_context->scheduleCompress(i)){
                                        LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), i.index());
                                        // handle error
                                }
@@ -161,8 +168,8 @@ J2KEncoder::end (bool isFinal)
                        }
                }
        }
-       delete context_;
-       context_ = nullptr;
+       delete _context;
+       _context = nullptr;
 }
 
 
@@ -367,8 +374,8 @@ try
                                }
 
                        } else {
-                               if (context_) {
-                                       if (!context_->launch(vf, config->selected_gpu()) || !context_->scheduleCompress(vf)) {
+                               if (_context) {
+                                       if (!_context->launch(vf, config->selected_gpu()) || !_context->scheduleCompress(vf)) {
                                                LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), vf.index());
                                                _queue.push_front (vf);
                                        }
index a3ea9f3e8684bd52c46a65c5b39024b74b206fca..1d31274b3f545741f323ada3c37152a7fa4af951 100644 (file)
@@ -70,8 +70,8 @@ public:
        /** Called to pass a bit of video to be encoded as the next DCP frame */
        void encode (std::shared_ptr<PlayerVideo> pv, dcpomatic::DCPTime time);
 
-       void pause(void);
-       void resume(void);
+       void pause();
+       void resume();
 
        /** Called when a processing run has finished */
        void end (bool isFinal);
@@ -111,8 +111,8 @@ private:
 
        boost::signals2::scoped_connection _server_found_connection;
 
-       grk_plugin::DcpomaticContext dcpomaticContext_;
-       grk_plugin::GrokContext *context_;
+       grk_plugin::DcpomaticContext _dcpomatic_context;
+       grk_plugin::GrokContext *_context;
 };
 
 
index e907cbe03277af21bf84f7b2d5c29d07905c0b8e..b260bc44b1d852c5c23ce0870a7a3c2594a2318f 100644 (file)
@@ -147,15 +147,21 @@ TranscodeJob::run ()
        }
 }
 
-void TranscodeJob::pause() {
+
+void
+TranscodeJob::pause()
+{
        _encoder->pause();
 }
 
-void TranscodeJob::resume() {
+
+void TranscodeJob::resume()
+{
        _encoder->resume();
        Job::resume();
 }
 
+
 string
 TranscodeJob::status () const
 {