StormByte C++ Library: Multimedia module
0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
lib
public
StormByte
multimedia
ffmpeg
convert.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/multimedia/ffmpeg/AVChannelLayout.hxx
>
42
#include <
StormByte/multimedia/ffmpeg/AVRational.hxx
>
43
44
extern
"C"
{
45
#include <libavutil/channel_layout.h>
46
#include <libavutil/mem.h>
47
#include <libavutil/rational.h>
48
}
49
57
namespace
StormByte::Multimedia::FFmpeg
{
61
struct
Convert
{
67
static
const ::AVChannelLayout*
Raw
(
const
AVChannelLayout
& layout)
noexcept
{
68
return
layout.m_raw;
69
}
70
76
static ::AVChannelLayout*
Raw
(
AVChannelLayout
& layout)
noexcept
{
77
return
layout.m_raw;
78
}
79
85
static
AVChannelLayout
From
(const ::AVChannelLayout& src)
noexcept
{
86
AVChannelLayout
out;
87
out.Ensure();
88
if
(!out.m_raw)
89
return
out;
90
if
(av_channel_layout_copy(out.m_raw, &src) < 0)
91
out.Free();
92
return
out;
93
}
94
};
95
101
inline ::AVRational
ToRaw
(
const
AVRational
& rational)
noexcept
{
102
return
{ rational.
num
, rational.den };
103
}
104
110
inline
AVRational
FromRaw
(::AVRational rational)
noexcept
{
111
return
AVRational
(rational.num, rational.den);
112
}
113
119
inline
const ::AVChannelLayout*
ToRaw
(
const
AVChannelLayout
& layout)
noexcept
{
120
return
Convert::Raw
(layout);
121
}
122
128
inline ::AVChannelLayout*
ToRaw
(
AVChannelLayout
& layout)
noexcept
{
129
return
Convert::Raw
(layout);
130
}
131
137
inline
AVChannelLayout
FromRaw
(const ::AVChannelLayout& layout)
noexcept
{
138
return
Convert::From
(layout);
139
}
140
146
inline
AVChannelLayout
FromRaw
(const ::AVChannelLayout* layout)
noexcept
{
147
return
layout ?
Convert::From
(*layout) :
AVChannelLayout
{};
148
}
149
}
AVChannelLayout.hxx
AVRational.hxx
StormByte::Multimedia::FFmpeg::AVChannelLayout
RAII AVChannelLayout (av_channel_layout_copy / uninit).
Definition
AVChannelLayout.hxx:65
StormByte::Multimedia::Property::AVRational
Pair {num, den} matching libavutil AVRational.
Definition
av_rational.hxx:62
StormByte::Multimedia::Property::AVRational::num
int num
Numerator (AVRational.num)
Definition
av_rational.hxx:64
StormByte::Multimedia::FFmpeg
Private RAII wrappers over libav*.
StormByte::Multimedia::FFmpeg::FromRaw
AVRational FromRaw(::AVRational rational) noexcept
C AVRational → public / backend rational.
Definition
convert.hxx:110
StormByte::Multimedia::FFmpeg::ToRaw
inline ::AVRational ToRaw(const AVRational &rational) noexcept
Public / backend rational → C AVRational.
Definition
convert.hxx:101
StormByte::Multimedia::FFmpeg::Convert
Friend of AVChannelLayout.
Definition
convert.hxx:61
StormByte::Multimedia::FFmpeg::Convert::From
static AVChannelLayout From(const ::AVChannelLayout &src) noexcept
Deep-copies a C layout into a wrapper.
Definition
convert.hxx:85
StormByte::Multimedia::FFmpeg::Convert::Raw
::AVChannelLayout * Raw(AVChannelLayout &layout) noexcept
Mutable C layout.
Definition
convert.hxx:76
StormByte::Multimedia::FFmpeg::Convert::Raw
static const ::AVChannelLayout * Raw(const AVChannelLayout &layout) noexcept
Const C layout.
Definition
convert.hxx:67
Generated by
1.9.8