Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qffmpegavaudioformat.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "qaudioformat.h"
7
8extern "C" {
9#include <libavutil/opt.h>
10}
11
13
14namespace QFFmpeg {
15
17 : sampleFormat(context->sample_fmt), sampleRate(context->sample_rate)
18{
19#if QT_FFMPEG_OLD_CHANNEL_LAYOUT
20 if (context->channel_layout) {
21 channelLayoutMask = context->channel_layout;
22 } else {
23 const auto channelConfig =
26 }
27#else
28 channelLayout = context->ch_layout;
29#endif
30}
31
32AVAudioFormat::AVAudioFormat(const AVCodecParameters *codecPar)
33 : sampleFormat(AVSampleFormat(codecPar->format)), sampleRate(codecPar->sample_rate)
34{
35#if QT_FFMPEG_OLD_CHANNEL_LAYOUT
36 if (codecPar->channel_layout) {
37 channelLayoutMask = codecPar->channel_layout;
38 } else {
39 const auto channelConfig =
42 }
43#else
44 channelLayout = codecPar->ch_layout;
45#endif
46}
47
49 : sampleFormat(QFFmpegMediaFormatInfo::avSampleFormat(audioFormat.sampleFormat())),
50 sampleRate(audioFormat.sampleRate())
51{
54 : audioFormat.channelConfig();
55
57
58#if QT_FFMPEG_OLD_CHANNEL_LAYOUT
59 channelLayoutMask = mask;
60#else
61 av_channel_layout_from_mask(&channelLayout, mask);
62#endif
63}
64
65bool operator==(const AVAudioFormat &lhs, const AVAudioFormat &rhs)
66{
67 return lhs.sampleFormat == rhs.sampleFormat && lhs.sampleRate == rhs.sampleRate &&
68#if QT_FFMPEG_OLD_CHANNEL_LAYOUT
69 lhs.channelLayoutMask == rhs.channelLayoutMask
70#else
72#endif
73 ;
74}
75
76} // namespace QFFmpeg
77
The QAudioFormat class stores audio stream parameter information.
constexpr int channelCount() const noexcept
Returns the current channel count value.
static Q_MULTIMEDIA_EXPORT ChannelConfig defaultChannelConfigForChannelCount(int channelCount)
Returns a default channel configuration for channelCount.
static constexpr ChannelConfig channelConfig(Args... channels)
Returns the current channel configuration for the given channels.
static int64_t avChannelLayout(QAudioFormat::ChannelConfig channelConfig)
bool operator==(const AVAudioFormat &lhs, const AVAudioFormat &rhs)
Combined button and popup list for selecting options.
static void * context
QAudioFormat::ChannelConfig channelConfig
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
AVAudioFormat(const AVCodecContext *context)