Skip to content

Commit

Permalink
整理滤镜部分代码;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed Nov 23, 2023
1 parent 8c03273 commit dc2fc4b
Show file tree
Hide file tree
Showing 31 changed files with 347 additions and 198 deletions.
27 changes: 2 additions & 25 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
---
Checks: '-*,clang-analyzer-*,readability-*,performance-*,modernize-*,bugprone-*,cert-,cppcoreguidelines-,portability-*,llvm-*,google-*'
Checks: 'clang-analyzer-*,readability-*,performance-*,modernize-*,bugprone-*,cert-*,portability-*,llvm-*,google-*'
WarningsAsErrors: ''
HeaderFilterRegex: '.'
AnalyzeTemporaryDtors: false
FormatStyle: file
FormatStyle: none
User: user
CheckOptions:
# 类名改为大驼峰
- key: readability-identifier-naming.ClassCase
value: CamelCase
# 函数名改为小驼峰
- key: readability-identifier-naming.FunctionCase
value: camelBack
# 变量名改为小驼峰
- key: readability-identifier-naming.VariableCase
value: camelBack
# 关闭一些过于严苛或者不适合的检查
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
- key: readability-magic-numbers.IgnorePowersOf2IntegerLiterals
value: '1'
- key: modernize-use-trailing-return-type.UseEastWestConst
value: '1'
- key: readability-identifier-naming.ClassMemberPrefix
value: 'm_'
- key: readability-identifier-naming.ConstexprVariablePrefix
value: 'k'
- key: readability-identifier-naming.GlobalVariablePrefix
value: 'g_'
10 changes: 5 additions & 5 deletions examples/player/colorspacedialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ColorSpaceDialog::ColorSpaceDialogPrivate
explicit ColorSpaceDialogPrivate(ColorSpaceDialog *q)
: q_ptr(q)
{
Ffmpeg::ColorSpaceTrc colorTrc;
Ffmpeg::ColorUtils::ColorSpaceTrc colorTrc;

contrastSlider = new Slider(q_ptr);
contrastSlider->setRange(colorTrc.contrast_min * multiple, colorTrc.contrast_max * multiple);
Expand Down Expand Up @@ -96,7 +96,7 @@ ColorSpaceDialog::ColorSpaceDialog(QWidget *parent)

ColorSpaceDialog::~ColorSpaceDialog() = default;

void ColorSpaceDialog::setColorSpace(const Ffmpeg::ColorSpaceTrc &colorTrc)
void ColorSpaceDialog::setColorSpace(const Ffmpeg::ColorUtils::ColorSpaceTrc &colorTrc)
{
setBlockValue(d_ptr->contrastSpinBox, colorTrc.contrast * d_ptr->multiple);
setBlockValue(d_ptr->saturationSpinBox, colorTrc.saturation * d_ptr->multiple);
Expand All @@ -106,9 +106,9 @@ void ColorSpaceDialog::setColorSpace(const Ffmpeg::ColorSpaceTrc &colorTrc)
setBlockValue(d_ptr->brightnessSlider, colorTrc.brightness * d_ptr->multiple);
}

Ffmpeg::ColorSpaceTrc ColorSpaceDialog::colorSpace() const
Ffmpeg::ColorUtils::ColorSpaceTrc ColorSpaceDialog::colorSpace() const
{
Ffmpeg::ColorSpaceTrc colorTrc;
Ffmpeg::ColorUtils::ColorSpaceTrc colorTrc;
colorTrc.contrast = d_ptr->contrastSlider->value() / d_ptr->multiple;
colorTrc.saturation = d_ptr->saturationSlider->value() / d_ptr->multiple;
colorTrc.brightness = d_ptr->brightnessSlider->value() / d_ptr->multiple;
Expand Down Expand Up @@ -153,7 +153,7 @@ void ColorSpaceDialog::onBrightnessSpinBoxChanged(int value)

void ColorSpaceDialog::onReset()
{
Ffmpeg::ColorSpaceTrc colorTrc;
Ffmpeg::ColorUtils::ColorSpaceTrc colorTrc;
setBlockValue(d_ptr->contrastSlider, colorTrc.contrast_default * d_ptr->multiple);
setBlockValue(d_ptr->saturationSlider, colorTrc.saturation_default * d_ptr->multiple);
setBlockValue(d_ptr->brightnessSlider, colorTrc.brightness_default * d_ptr->multiple);
Expand Down
4 changes: 2 additions & 2 deletions examples/player/colorspacedialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class ColorSpaceDialog : public QDialog
explicit ColorSpaceDialog(QWidget *parent = nullptr);
~ColorSpaceDialog() override;

void setColorSpace(const Ffmpeg::ColorSpaceTrc &colorTrc);
[[nodiscard]] auto colorSpace() const -> Ffmpeg::ColorSpaceTrc;
void setColorSpace(const Ffmpeg::ColorUtils::ColorSpaceTrc &colorTrc);
[[nodiscard]] auto colorSpace() const -> Ffmpeg::ColorUtils::ColorSpaceTrc;

signals:
void colorSpaceChanged();
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/audiodecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AudioDecoder::AudioDecoderPrivate
switch (eventPtr->type()) {
case Event::EventType::Pause: decoderAudioFrame->addEvent(eventPtr); break;
case Event::EventType::Seek: {
auto seekEvent = static_cast<SeekEvent *>(eventPtr.data());
auto *seekEvent = static_cast<SeekEvent *>(eventPtr.data());
seekEvent->countDown();
q_ptr->clear();
decoderAudioFrame->addEvent(eventPtr);
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/audioframeconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ AudioFrameConverter::~AudioFrameConverter()

auto AudioFrameConverter::convert(Frame *frame) -> QByteArray
{
auto avFrame = frame->avFrame();
auto *avFrame = frame->avFrame();
auto nb_samples = avFrame->nb_samples;
auto out_count = (int64_t) nb_samples * d_ptr->format.sampleRate() / avFrame->sample_rate
+ 256; // 256 copy from ffplay
Expand Down
19 changes: 10 additions & 9 deletions ffmpeg/avcontextinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ namespace Ffmpeg {
class AVContextInfo::AVContextInfoPrivate
{
public:
AVContextInfoPrivate(AVContextInfo *q)
explicit AVContextInfoPrivate(AVContextInfo *q)
: q_ptr(q)
{}

void printCodecpar()
{
auto codecpar = stream->codecpar;
auto *codecpar = stream->codecpar;
qInfo() << "start_time: " << stream->start_time;
qInfo() << "duration: " << stream->duration;
qInfo() << "nb_frames: " << stream->nb_frames;
Expand Down Expand Up @@ -123,16 +123,16 @@ auto AVContextInfo::initDecoder(const AVRational &frameRate) -> bool
{
Q_ASSERT(d_ptr->stream != nullptr);
const char *typeStr = av_get_media_type_string(d_ptr->stream->codecpar->codec_type);
auto codec = avcodec_find_decoder(d_ptr->stream->codecpar->codec_id);
if (!codec) {
const auto *codec = avcodec_find_decoder(d_ptr->stream->codecpar->codec_id);
if (codec == nullptr) {
qWarning() << tr("%1 Codec not found.").arg(typeStr);
return false;
}
d_ptr->codecCtx.reset(new CodecContext(codec));
if (!d_ptr->codecCtx->setParameters(d_ptr->stream->codecpar)) {
return false;
}
auto avCodecCtx = d_ptr->codecCtx->avCodecCtx();
auto *avCodecCtx = d_ptr->codecCtx->avCodecCtx();
avCodecCtx->pkt_timebase = d_ptr->stream->time_base;
d_ptr->codecCtx->setThreadCount(4);
if (d_ptr->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
Expand All @@ -146,8 +146,8 @@ auto AVContextInfo::initDecoder(const AVRational &frameRate) -> bool

auto AVContextInfo::initEncoder(AVCodecID codecId) -> bool
{
auto encodec = avcodec_find_encoder(codecId);
if (!encodec) {
const auto *encodec = avcodec_find_encoder(codecId);
if (encodec == nullptr) {
qWarning() << tr("%1 Encoder not found.").arg(avcodec_get_name(codecId));
return false;
}
Expand All @@ -157,8 +157,8 @@ auto AVContextInfo::initEncoder(AVCodecID codecId) -> bool

auto AVContextInfo::initEncoder(const QString &name) -> bool
{
auto encodec = avcodec_find_encoder_by_name(name.toLocal8Bit().constData());
if (!encodec) {
const auto *encodec = avcodec_find_encoder_by_name(name.toLocal8Bit().constData());
if (encodec == nullptr) {
qWarning() << tr("%1 Encoder not found.").arg(name);
return false;
}
Expand Down Expand Up @@ -207,6 +207,7 @@ auto AVContextInfo::decodeFrame(const QSharedPointer<Packet> &packetPtr)
}
FramePtr framePtr(new Frame);
while (d_ptr->codecCtx->receiveFrame(framePtr.data())) {
framePtr->avFrame()->time_base = stream()->time_base;
if (d_ptr->gpuType == GpuDecode && mediaType() == AVMEDIA_TYPE_VIDEO) {
bool ok = false;
framePtr = d_ptr->hardWareDecodePtr->transFromGpu(framePtr, ok);
Expand Down
Loading

0 comments on commit dc2fc4b

Please sign in to comment.