Skip to content

Commit

Permalink
ffmpeg: updated for 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Feb 17, 2022
1 parent 7d52dc1 commit 03f0ec9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/codec/ffmpeg/ffmpegdecoder.cpp
Expand Up @@ -268,7 +268,7 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, const QAtomicIn
AVStream* avstream = fmt_ctx->streams[i];

// Find decoder for this stream, if it exists we can proceed
AVCodec* decoder = avcodec_find_decoder(avstream->codecpar->codec_id);
const AVCodec* decoder = avcodec_find_decoder(avstream->codecpar->codec_id);

if (decoder
&& (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
Expand Down Expand Up @@ -1010,7 +1010,7 @@ bool FFmpegDecoder::Instance::Open(const char *filename, int stream_index)
avstream_ = fmt_ctx_->streams[stream_index];

// Find decoder
AVCodec* codec = avcodec_find_decoder(avstream_->codecpar->codec_id);
const AVCodec* codec = avcodec_find_decoder(avstream_->codecpar->codec_id);

// Handle failure to find decoder
if (codec == nullptr) {
Expand Down
10 changes: 5 additions & 5 deletions app/codec/ffmpeg/ffmpegencoder.cpp
Expand Up @@ -50,7 +50,7 @@ QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const
{
QStringList pix_fmts;

AVCodec* codec_info = GetEncoder(c);
const AVCodec* codec_info = GetEncoder(c);

if (codec_info) {
for (int i=0; codec_info->pix_fmts[i]!=-1; i++) {
Expand Down Expand Up @@ -570,7 +570,7 @@ bool FFmpegEncoder::InitializeStream(AVMediaType type, AVStream** stream_ptr, AV
}

// Find encoder
AVCodec* encoder = GetEncoder(codec);
const AVCodec* encoder = GetEncoder(codec);
if (!encoder) {
SetError(tr("Failed to find codec for 0x%1").arg(codec, 16));
return false;
Expand Down Expand Up @@ -669,7 +669,7 @@ bool FFmpegEncoder::InitializeStream(AVMediaType type, AVStream** stream_ptr, AV
return true;
}

bool FFmpegEncoder::InitializeCodecContext(AVStream **stream, AVCodecContext **codec_ctx, AVCodec* codec)
bool FFmpegEncoder::InitializeCodecContext(AVStream **stream, AVCodecContext **codec_ctx, const AVCodec* codec)
{
*stream = avformat_new_stream(fmt_ctx_, nullptr);
if (!(*stream)) {
Expand All @@ -687,7 +687,7 @@ bool FFmpegEncoder::InitializeCodecContext(AVStream **stream, AVCodecContext **c
return true;
}

bool FFmpegEncoder::SetupCodecContext(AVStream* stream, AVCodecContext* codec_ctx, AVCodec* codec)
bool FFmpegEncoder::SetupCodecContext(AVStream* stream, AVCodecContext* codec_ctx, const AVCodec* codec)
{
int error_code;

Expand Down Expand Up @@ -833,7 +833,7 @@ bool FFmpegEncoder::InitializeResampleContext(SampleBufferPtr audio)
return true;
}

AVCodec *FFmpegEncoder::GetEncoder(ExportCodec::Codec c)
const AVCodec *FFmpegEncoder::GetEncoder(ExportCodec::Codec c)
{
switch (c) {
case ExportCodec::kCodecH264:
Expand Down
7 changes: 4 additions & 3 deletions app/codec/ffmpeg/ffmpegencoder.h
Expand Up @@ -22,6 +22,7 @@
#define FFMPEGENCODER_H

extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>
Expand Down Expand Up @@ -69,15 +70,15 @@ class FFmpegEncoder : public Encoder
bool WriteAVFrame(AVFrame* frame, AVCodecContext *codec_ctx, AVStream *stream);

bool InitializeStream(enum AVMediaType type, AVStream** stream, AVCodecContext** codec_ctx, const ExportCodec::Codec &codec);
bool InitializeCodecContext(AVStream** stream, AVCodecContext** codec_ctx, AVCodec* codec);
bool SetupCodecContext(AVStream *stream, AVCodecContext *codec_ctx, AVCodec *codec);
bool InitializeCodecContext(AVStream** stream, AVCodecContext** codec_ctx, const AVCodec* codec);
bool SetupCodecContext(AVStream *stream, AVCodecContext *codec_ctx, const AVCodec *codec);

void FlushEncoders();
void FlushCodecCtx(AVCodecContext* codec_ctx, AVStream *stream);

bool InitializeResampleContext(SampleBufferPtr audio);

static AVCodec *GetEncoder(ExportCodec::Codec c);
static const AVCodec *GetEncoder(ExportCodec::Codec c);

AVFormatContext* fmt_ctx_;

Expand Down
1 change: 1 addition & 0 deletions app/common/ffmpegutils.h
Expand Up @@ -22,6 +22,7 @@
#define FFMPEGABSTRACTION_H

extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}

Expand Down
4 changes: 4 additions & 0 deletions app/render/audioparams.h
Expand Up @@ -21,6 +21,10 @@
#ifndef AUDIOPARAMS_H
#define AUDIOPARAMS_H

extern "C" {
#include <libavutil/channel_layout.h>
}

#include <QtMath>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
Expand Down

0 comments on commit 03f0ec9

Please sign in to comment.