StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
watermark.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Multimedia.
5 *
6 * StormByte-Multimedia original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Multimedia source in this
20 * file. Third-party components — including FFmpeg and embedded trained data —
21 * remain under their own licenses and are not covered by the commercial grant.
22 *
23 * Neither license grants any patent rights. Any patent licenses required
24 * to use this software or third-party components must be obtained separately
25 * from the patent holders.
26 *
27 * StormByte-Multimedia is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 *
32 * You should have received a copy of the GNU Lesser General Public License
33 * version 3 along with StormByte-Multimedia. If not, see
34 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
35 *
36 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
37 */
38
39#pragma once
40
41#include <StormByte/buffer/generic.hxx>
42#include <StormByte/logger/log.hxx>
49
50#include <cstdint>
51#include <filesystem>
52#include <memory>
53#include <optional>
54#include <string_view>
55
84
134 public:
148 Watermark(std::shared_ptr<StormByte::Logger::Log> log,
149 const std::filesystem::path& logo, Anchor anchor,
150 unsigned opacity = 100, int margin = 0) noexcept;
151
159 Watermark(std::shared_ptr<StormByte::Logger::Log> log,
160 const std::filesystem::path& logo,
161 StormByte::Multimedia::Property::Point position,
162 unsigned opacity = 100) noexcept;
163
167 Watermark(const Watermark& other) = delete;
168
172 Watermark(Watermark&& other) noexcept = delete;
173
177 ~Watermark() noexcept override;
178
183 Watermark& operator=(const Watermark& other) = delete;
184
189 Watermark& operator=(Watermark&& other) noexcept = delete;
190
204 enum StormByte::Multimedia::Type Media() const noexcept override;
205
210 protected:
219 void Clean() noexcept override;
220
227 void Setup() noexcept override;
228
236 void Process(const Pipeline::Frame& frame) noexcept override;
237
245 void LastChance(const Pipeline::Frame& frame) noexcept override;
246
251 private:
252 static constexpr std::uint8_t ProbeMax = 200;
253
262 void DisableLogo(std::string_view why) noexcept;
263
268 bool LoadFile() noexcept;
269
274 bool DecodeLogo() noexcept;
275
281 const StormByte::Multimedia::FFmpeg::AVFrame* Luma(
282 const StormByte::Multimedia::FFmpeg::AVFrame& src) noexcept;
283
289 bool ProbeBars(const StormByte::Multimedia::FFmpeg::AVFrame& src) noexcept;
290
296 void Paint() noexcept;
297
301 void DropScale() noexcept;
302
303 std::filesystem::path m_path;
304 std::optional<Anchor> m_anchor;
305 std::optional<StormByte::Multimedia::Property::Point> m_point;
306 unsigned m_opacity;
307 int m_margin;
308 StormByte::Buffer::DataType m_bytes;
309 int m_logoWidth;
310 int m_logoHeight;
311 StormByte::Buffer::DataType m_rgba;
312 bool m_loaded;
313 bool m_decoded;
314 bool m_released;
315 int m_barTop;
316 int m_barBottom;
317 int m_barLeft;
318 int m_barRight;
319 int m_stable;
320 int m_lumaW;
321 int m_lumaH;
322 int m_lumaFmt;
323 std::unique_ptr<StormByte::Multimedia::FFmpeg::Sws> m_swsLuma;
324 std::unique_ptr<StormByte::Multimedia::FFmpeg::AVFrame> m_luma;
325 };
326}
Abstract base for every StormByte Multimedia filter.
Definition ffmpeg.hxx:226
Mutates decoded frames.
Definition ffmpeg.hxx:676
Overlays a still image on decoded video.
Definition watermark.hxx:133
Watermark(std::shared_ptr< StormByte::Logger::Log > log, const std::filesystem::path &logo, Anchor anchor, unsigned opacity=100, int margin=0) noexcept
Logo at an anchor on the active picture.
One decoded access unit.
Definition frame.hxx:76
Video leaves (Process and Analytics).
Anchor
Logo placement relative to the active picture.
Definition watermark.hxx:73
Type
Kind of media stream or codec.
Definition type.hxx:55
#define STORMBYTE_MULTIMEDIA_PUBLIC
Imported symbol.
Definition visibility.h:47