diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-08-17 12:56:20 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-08-17 12:56:20 +0200 |
| commit | e65d17fa04c411295496968f6ecee9b3a6c21fae (patch) | |
| tree | c763a48ebd57268a1b83f9767fada295a30a219d /src/lib | |
| parent | 0b4bffff846efe967110477797218c170ffb3166 (diff) | |
| parent | e96f917d51f9606a550902dbc16e0971a8967039 (diff) | |
Merge remote-tracking branch 'origin/main' into v2.17.x
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/analyse_subtitles_job.cc | 6 | ||||
| -rw-r--r-- | src/lib/analyse_subtitles_job.h | 1 | ||||
| -rw-r--r-- | src/lib/guess_crop.cc | 3 | ||||
| -rw-r--r-- | src/lib/image.cc | 6 | ||||
| -rw-r--r-- | src/lib/image.h | 2 |
5 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/analyse_subtitles_job.cc b/src/lib/analyse_subtitles_job.cc index b41990db5..b2346d4d9 100644 --- a/src/lib/analyse_subtitles_job.cc +++ b/src/lib/analyse_subtitles_job.cc @@ -50,6 +50,12 @@ AnalyseSubtitlesJob::AnalyseSubtitlesJob (shared_ptr<const Film> film, shared_pt } +AnalyseSubtitlesJob::~AnalyseSubtitlesJob() +{ + stop_thread(); +} + + string AnalyseSubtitlesJob::name () const { diff --git a/src/lib/analyse_subtitles_job.h b/src/lib/analyse_subtitles_job.h index c47117c57..ea425763f 100644 --- a/src/lib/analyse_subtitles_job.h +++ b/src/lib/analyse_subtitles_job.h @@ -32,6 +32,7 @@ class AnalyseSubtitlesJob : public Job { public: AnalyseSubtitlesJob (std::shared_ptr<const Film> film, std::shared_ptr<Content> content); + ~AnalyseSubtitlesJob(); std::string name () const override; std::string json_name () const override; diff --git a/src/lib/guess_crop.cc b/src/lib/guess_crop.cc index 3538f14de..5eb7e66e8 100644 --- a/src/lib/guess_crop.cc +++ b/src/lib/guess_crop.cc @@ -42,8 +42,9 @@ guess_crop (shared_ptr<const Image> image, double threshold) switch (image->pixel_format()) { case AV_PIX_FMT_RGB24: + case AV_PIX_FMT_RGBA: { - uint8_t const* data = image->data()[0] + start_x * 3 + start_y * image->stride()[0]; + uint8_t const* data = image->data()[0] + start_x * std::lround(image->bytes_per_pixel(0)) + start_y * image->stride()[0]; for (int p = 0; p < pixels; ++p) { /* Averaging R, G and B */ brightest = std::max(brightest, static_cast<double>(data[0] + data[1] + data[2]) / (3 * 256)); diff --git a/src/lib/image.cc b/src/lib/image.cc index 2167918f8..7181c4546 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -1171,14 +1171,14 @@ Image::write_to_socket (shared_ptr<Socket> socket) const float -Image::bytes_per_pixel (int c) const +Image::bytes_per_pixel(int component) const { auto d = av_pix_fmt_desc_get(_pixel_format); if (!d) { throw PixelFormatError ("bytes_per_pixel()", _pixel_format); } - if (c >= planes()) { + if (component >= planes()) { return 0; } @@ -1213,7 +1213,7 @@ Image::bytes_per_pixel (int c) const return bpp[0] + bpp[1] + bpp[2] + bpp[3]; } - return bpp[c]; + return bpp[component]; } diff --git a/src/lib/image.h b/src/lib/image.h index 0237b3d1b..dd9f8b840 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -68,7 +68,7 @@ public: int vertical_factor (int) const; int horizontal_factor (int) const; dcp::Size sample_size (int) const; - float bytes_per_pixel (int) const; + float bytes_per_pixel(int component) const; std::shared_ptr<Image> convert_pixel_format (dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, Alignment alignment, bool fast) const; std::shared_ptr<Image> scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, Alignment alignment, bool fast) const; |
