Audacity  3.0.3
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
FFmpegFunctions Struct Reference

#include <FFmpegFunctions.h>

Inheritance diagram for FFmpegFunctions:
[legend]
Collaboration diagram for FFmpegFunctions:
[legend]

Classes

struct  Private
 

Public Member Functions

 FFmpegFunctions ()
 
 ~FFmpegFunctions ()
 
std::unique_ptr< AVIOContextWrapperCreateAVIOContext () const
 
std::unique_ptr< AVFormatContextWrapperCreateAVFormatContext () const
 
std::unique_ptr< AVStreamWrapperCreateAVStreamWrapper (AVStream *stream) const
 
std::unique_ptr< AVPacketWrapperCreateAVPacketWrapper () const
 
std::unique_ptr< AVFrameWrapperCreateAVFrameWrapper () const
 
std::unique_ptr< AVInputFormatWrapperCreateAVInputFormatWrapper (AVInputFormat *inputFormat) const
 
std::unique_ptr< AVOutputFormatWrapperCreateAVOutputFormatWrapper (AVOutputFormat *outputFormat) const
 
std::unique_ptr< AVCodecWrapperCreateDecoder (AVCodecIDFwd codecID) const
 
std::unique_ptr< AVCodecWrapperCreateEncoder (AVCodecIDFwd codecID) const
 
std::unique_ptr< AVCodecWrapperCreateEncoder (const char *codecName) const
 
std::unique_ptr< AVCodecContextWrapperCreateAVCodecContextWrapper (AVCodecContext *context) const
 
std::unique_ptr< AVCodecContextWrapperCreateAVCodecContextWrapperFromCodec (std::unique_ptr< AVCodecWrapper > codec) const
 
std::unique_ptr< AVOutputFormatWrapperGuessOutputFormat (const char *short_name, const char *filename, const char *mime_type)
 
std::unique_ptr< AVOutputFormatWrapperGetNextOutputFormat (const AVOutputFormatWrapper *fmt) const
 
std::unique_ptr< AVCodecWrapperGetNextCodec (const AVCodecWrapper *codec) const
 
std::unique_ptr< AVFifoBufferWrapperCreateFifoBuffer (int size) const
 
template<typename T >
AVDataBuffer< T > CreateMemoryBuffer (int preallocatedSize) const
 

Static Public Member Functions

static std::shared_ptr< FFmpegFunctionsLoad ()
 
static std::vector< wxString > GetSearchPaths ()
 

Public Attributes

AVCodecIDFwd(* GetAVCodecID )(AudacityAVCodecID) = nullptr
 
AudacityAVCodecID(* GetAudacityCodecID )(AVCodecIDFwd) = nullptr
 
- Public Attributes inherited from AVCodecFunctions
FFMPegVersion AVCodecVersion
 
void(* av_packet_ref )(AVPacket *dst, const AVPacket *src) = nullptr
 
void(* av_packet_unref )(AVPacket *pkt) = nullptr
 
void(* av_init_packet )(AVPacket *pkt) = nullptr
 
AVCodec *(* avcodec_find_encoder )(AVCodecIDFwd id) = nullptr
 
AVCodec *(* avcodec_find_encoder_by_name )(const char *name) = nullptr
 
AVCodec *(* avcodec_find_decoder )(AVCodecIDFwd id) = nullptr
 
const char *(* avcodec_get_name )(AVCodecIDFwd id) = nullptr
 
int(* avcodec_open2 )(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) = nullptr
 
int(* avcodec_is_open )(AVCodecContext *avctx) = nullptr
 
int(* avcodec_close )(AVCodecContext *avctx) = nullptr
 
int(* avcodec_decode_audio4 )(AVCodecContext *avctx, AVFrame *frame, int *got_output, const AVPacket *avpkt) = nullptr
 
int(* avcodec_encode_audio2 )(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_output) = nullptr
 
AVCodecContext *(* avcodec_alloc_context3 )(const AVCodec *codec) = nullptr
 
void(* avcodec_register_all )(void) = nullptr
 
AVCodec *(* av_codec_next )(const AVCodec *c) = nullptr
 
int(* av_codec_is_encoder )(const AVCodec *codec) = nullptr
 
int(* avcodec_fill_audio_frame )(AVFrame *frame, int nb_channels, AVSampleFormatFwd sample_fmt, const uint8_t *buf, int buf_size, int align) = nullptr
 
AVPacket *(* av_packet_alloc )() = nullptr
 
void(* av_packet_free )(AVPacket **pkt) = nullptr
 
void(* avcodec_free_context )(AVCodecContext **avctx) = nullptr
 
- Public Attributes inherited from AVFormatFunctions
FFMPegVersion AVFormatVersion
 
int(* avformat_find_stream_info )(AVFormatContext *ic, AVDictionary **options) = nullptr
 
int(* av_read_frame )(AVFormatContext *s, AVPacket *pkt) = nullptr
 
int(* av_seek_frame )(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) = nullptr
 
void(* avformat_close_input )(AVFormatContext **s) = nullptr
 
int(* avformat_write_header )(AVFormatContext *s, AVDictionary **options) = nullptr
 
int(* av_interleaved_write_frame )(AVFormatContext *s, AVPacket *pkt) = nullptr
 
AVOutputFormat *(* av_oformat_next )(const AVOutputFormat *f) = nullptr
 
AVStream *(* avformat_new_stream )(AVFormatContext *s, const AVCodec *c) = nullptr
 
AVFormatContext *(* avformat_alloc_context )(void) = nullptr
 
int(* av_write_trailer )(AVFormatContext *s) = nullptr
 
unsigned int(* av_codec_get_tag )(const struct AVCodecTag *const *tags, AVCodecIDFwd id) = nullptr
 
int(* avformat_open_input )(AVFormatContext **ic_ptr, const char *filename, const AVInputFormat *fmt, AVDictionary **options) = nullptr
 
int64_t(* avio_size )(AVIOContext *s) = nullptr
 
AVIOContext *(* avio_alloc_context )(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, const uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence)) = nullptr
 
AVOutputFormat *(* av_guess_format )(const char *short_name, const char *filename, const char *mime_type) = nullptr
 
void(* avformat_free_context )(AVFormatContext *s) = nullptr
 
void(* av_register_all )(void) = nullptr
 
void(* avio_context_free )(AVIOContext **s) = nullptr
 
- Public Attributes inherited from AVUtilFunctions
FFMPegVersion AVUtilVersion
 
void *(* av_malloc )(size_t size) = nullptr
 
void(* av_free )(void *ptr) = nullptr
 
void(* av_dict_free )(AVDictionary **m) = nullptr
 
AudacityAVDictionaryEntry *(* av_dict_get )(const AVDictionary *m, const char *key, const AudacityAVDictionaryEntry *prev, int flags) = nullptr
 
int(* av_dict_set )(AVDictionary **pm, const char *key, const char *value, int flags) = nullptr
 
void(* av_dict_copy )(AVDictionary **dst, const AVDictionary *src, int flags) = nullptr
 
int(* av_get_bytes_per_sample )(AVSampleFormatFwd sample_fmt) = nullptr
 
void(* av_log_set_callback )(void(*cb)(void *, int, const char *, va_list)) = nullptr
 
void(* av_log_default_callback )(void *ptr, int level, const char *fmt, va_list vl) = nullptr
 
AVFifoBuffer *(* av_fifo_alloc )(unsigned int size) = nullptr
 
int(* av_fifo_generic_read )(AVFifoBuffer *f, void *buf, int buf_size, void(*func)(void *, void *, int)) = nullptr
 
int(* av_fifo_realloc2 )(AVFifoBuffer *f, unsigned int size) = nullptr
 
void(* av_fifo_free )(AVFifoBuffer *f) = nullptr
 
int(* av_fifo_size )(const AVFifoBuffer *f) = nullptr
 
int(* av_fifo_generic_write )(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int)) = nullptr
 
int64_t(* av_rescale_q )(int64_t a, AudacityAVRational bq, AudacityAVRational cq) = nullptr
 
AVFrame *(* av_frame_alloc )(void) = nullptr
 
void(* av_frame_free )(AVFrame **frame) = nullptr
 
int(* av_samples_get_buffer_size )(int *linesize, int nb_channels, int nb_samples, AVSampleFormatFwd sample_fmt, int align) = nullptr
 
int64_t(* av_get_default_channel_layout )(int nb_channels) = nullptr
 
int(* av_strerror )(int errnum, char *errbuf, size_t errbuf_size) = nullptr
 
int(* av_get_channel_layout_nb_channels )(uint64_t channel_layout) = nullptr
 

Private Attributes

std::unique_ptr< PrivatemPrivate
 

Detailed Description

Definition at line 81 of file FFmpegFunctions.h.

Constructor & Destructor Documentation

◆ FFmpegFunctions()

FFmpegFunctions::FFmpegFunctions ( )

Definition at line 253 of file FFmpegFunctions.cpp.

254  : mPrivate(std::make_unique<Private>())
255 {
256 }

◆ ~FFmpegFunctions()

FFmpegFunctions::~FFmpegFunctions ( )

Definition at line 258 of file FFmpegFunctions.cpp.

259 {
260 }

Member Function Documentation

◆ CreateAVCodecContextWrapper()

std::unique_ptr< AVCodecContextWrapper > FFmpegFunctions::CreateAVCodecContextWrapper ( AVCodecContext context) const

Definition at line 409 of file FFmpegFunctions.cpp.

410 {
411  return mPrivate->CodecFactories.CreateAVCodecContextWrapper(
412  *this, context);
413 }

References mPrivate.

◆ CreateAVCodecContextWrapperFromCodec()

std::unique_ptr< AVCodecContextWrapper > FFmpegFunctions::CreateAVCodecContextWrapperFromCodec ( std::unique_ptr< AVCodecWrapper codec) const

Definition at line 416 of file FFmpegFunctions.cpp.

418 {
419  if (codec == nullptr)
420  return {};
421 
422  return mPrivate->CodecFactories.CreateAVCodecContextWrapperFromCodec(
423  *this, std::move(codec));
424 }

References mPrivate.

◆ CreateAVFormatContext()

std::unique_ptr< AVFormatContextWrapper > FFmpegFunctions::CreateAVFormatContext ( ) const

Definition at line 331 of file FFmpegFunctions.cpp.

332 {
333  return mPrivate->FormatFactories.CreateAVFormatContextWrapper(*this);
334 }

References mPrivate.

◆ CreateAVFrameWrapper()

std::unique_ptr< AVFrameWrapper > FFmpegFunctions::CreateAVFrameWrapper ( ) const
Postcondition
return value is not null

Definition at line 347 of file FFmpegFunctions.cpp.

348 {
349  return mPrivate->UtilFactories.CreateAVFrameWrapper(*this);
350 }

References mPrivate.

Referenced by AVCodecContextWrapper::DecodeAudioPacket(), and encode_audio().

Here is the caller graph for this function:

◆ CreateAVInputFormatWrapper()

std::unique_ptr< AVInputFormatWrapper > FFmpegFunctions::CreateAVInputFormatWrapper ( AVInputFormat inputFormat) const

Definition at line 353 of file FFmpegFunctions.cpp.

355 {
356  return mPrivate->FormatFactories.CreateAVInputFormatWrapper(inputFormat);
357 }

References mPrivate.

Referenced by AVFormatContextWrapper::OpenInputContext().

Here is the caller graph for this function:

◆ CreateAVIOContext()

std::unique_ptr< AVIOContextWrapper > FFmpegFunctions::CreateAVIOContext ( ) const

Definition at line 325 of file FFmpegFunctions.cpp.

326 {
327  return mPrivate->FormatFactories.CreateAVIOContextWrapper(*this);
328 }

References mPrivate.

Referenced by AVFormatContextWrapper::OpenInputContext(), and AVFormatContextWrapper::OpenOutputContext().

Here is the caller graph for this function:

◆ CreateAVOutputFormatWrapper()

std::unique_ptr< AVOutputFormatWrapper > FFmpegFunctions::CreateAVOutputFormatWrapper ( AVOutputFormat outputFormat) const

Definition at line 369 of file FFmpegFunctions.cpp.

371 {
372  return mPrivate->FormatFactories.CreateAVOutputFormatWrapper(outputFormat);
373 }

References mPrivate.

◆ CreateAVPacketWrapper()

std::unique_ptr< AVPacketWrapper > FFmpegFunctions::CreateAVPacketWrapper ( ) const
Postcondition
return value is not null

Definition at line 342 of file FFmpegFunctions.cpp.

343 {
344  return mPrivate->CodecFactories.CreateAVPacketWrapper(*this);
345 }

References mPrivate.

Referenced by AVCodecContextWrapper::DecodeAudioPacket(), and AVFormatContextWrapper::ReadNextPacket().

Here is the caller graph for this function:

◆ CreateAVStreamWrapper()

std::unique_ptr< AVStreamWrapper > FFmpegFunctions::CreateAVStreamWrapper ( AVStream stream) const

Definition at line 337 of file FFmpegFunctions.cpp.

338 {
339  return mPrivate->FormatFactories.CreateAVStreamWrapper(*this, stream);
340 }

References mPrivate.

Referenced by AVFormatContextWrapper::CreateStream().

Here is the caller graph for this function:

◆ CreateDecoder()

std::unique_ptr< AVCodecWrapper > FFmpegFunctions::CreateDecoder ( AVCodecIDFwd  codecID) const

Definition at line 376 of file FFmpegFunctions.cpp.

377 {
378  AVCodec* codec = avcodec_find_decoder(codecID);
379 
380  if (codec == nullptr)
381  return {};
382 
383  return mPrivate->CodecFactories.CreateAVCodecWrapper(codec);
384 }

References AVCodecFunctions::avcodec_find_decoder, and mPrivate.

◆ CreateEncoder() [1/2]

std::unique_ptr< AVCodecWrapper > FFmpegFunctions::CreateEncoder ( AVCodecIDFwd  codecID) const

Definition at line 387 of file FFmpegFunctions.cpp.

388 {
389  AVCodec* codec = avcodec_find_encoder(codecID);
390 
391  if (codec == nullptr)
392  return {};
393 
394  return mPrivate->CodecFactories.CreateAVCodecWrapper(codec);
395 }

References AVCodecFunctions::avcodec_find_encoder, and mPrivate.

◆ CreateEncoder() [2/2]

std::unique_ptr< AVCodecWrapper > FFmpegFunctions::CreateEncoder ( const char *  codecName) const

Definition at line 398 of file FFmpegFunctions.cpp.

399 {
401 
402  if (codec == nullptr)
403  return {};
404 
405  return mPrivate->CodecFactories.CreateAVCodecWrapper(codec);
406 }

References AVCodecFunctions::avcodec_find_encoder_by_name, mPrivate, and name.

◆ CreateFifoBuffer()

std::unique_ptr< AVFifoBufferWrapper > FFmpegFunctions::CreateFifoBuffer ( int  size) const

Definition at line 451 of file FFmpegFunctions.cpp.

452 {
453  return std::make_unique<AVFifoBufferWrapper>(*this, size);
454 }

References size.

◆ CreateMemoryBuffer()

template<typename T >
AVDataBuffer<T> FFmpegFunctions::CreateMemoryBuffer ( int  preallocatedSize) const
inline

Definition at line 125 of file FFmpegFunctions.h.

126  {
127  return AVDataBuffer<T>(preallocatedSize, T {}, AVAllocator<T>());
128  }

Referenced by encode_audio().

Here is the caller graph for this function:

◆ GetNextCodec()

std::unique_ptr< AVCodecWrapper > FFmpegFunctions::GetNextCodec ( const AVCodecWrapper codec) const

Definition at line 439 of file FFmpegFunctions.cpp.

440 {
441  AVCodec* nextCodec =
442  av_codec_next(codec != nullptr ? codec->GetWrappedValue() : nullptr);
443 
444  if (nextCodec == nullptr)
445  return {};
446 
447  return mPrivate->CodecFactories.CreateAVCodecWrapper(nextCodec);
448 }

References AVCodecFunctions::av_codec_next, AVCodecWrapper::GetWrappedValue(), and mPrivate.

Here is the call graph for this function:

◆ GetNextOutputFormat()

std::unique_ptr< AVOutputFormatWrapper > FFmpegFunctions::GetNextOutputFormat ( const AVOutputFormatWrapper fmt) const

Definition at line 427 of file FFmpegFunctions.cpp.

428 {
429  AVOutputFormat* outputFormat =
430  av_oformat_next(fmt != nullptr ? fmt->GetWrappedValue() : nullptr);
431 
432  if (outputFormat == nullptr)
433  return {};
434 
435  return mPrivate->FormatFactories.CreateAVOutputFormatWrapper(outputFormat);
436 }

References AVFormatFunctions::av_oformat_next, AVOutputFormatWrapper::GetWrappedValue(), and mPrivate.

Here is the call graph for this function:

◆ GetSearchPaths()

std::vector< wxString > FFmpegFunctions::GetSearchPaths ( )
static

Definition at line 298 of file FFmpegFunctions.cpp.

299 {
300  std::vector<wxString> paths;
301 
302  const wxString userAVFormatFullPath = AVFormatPath.Read();
303 
304  if (!userAVFormatFullPath.empty())
305  paths.emplace_back(wxPathOnly(userAVFormatFullPath));
306 
307 #if defined(__WXMSW__)
308  wxRegKey reg(wxT("HKEY_LOCAL_MACHINE\\Software\\FFmpeg for Audacity"));
309  wxString path;
310 
311  if (reg.Exists())
312  reg.QueryValue(wxT("InstallPath"), path);
313 
314  if (!path.empty())
315  paths.emplace_back(path);
316 
317 #elif defined(__WXMAC__)
318  paths.emplace_back(wxT("/Library/Application Support/audacity/libs"));
319  paths.emplace_back(wxT("/usr/local/lib/audacity"));
320 #endif
321 
322  return paths;
323 }

References AVFormatPath, Setting< T >::Read(), and anonymous_namespace{CompareAudioCommand.cpp}::reg.

Referenced by EnvSetter::EnvSetter(), FindFFmpegLibs(), and FFmpegFunctions::Private::LoadLibrary().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GuessOutputFormat()

std::unique_ptr< AVOutputFormatWrapper > FFmpegFunctions::GuessOutputFormat ( const char *  short_name,
const char *  filename,
const char *  mime_type 
)

Definition at line 359 of file FFmpegFunctions.cpp.

361 {
362  AVOutputFormat* outputFormat =
363  av_guess_format(short_name, filename, mime_type);
364 
365  return mPrivate->FormatFactories.CreateAVOutputFormatWrapper(outputFormat);
366 }

References AVFormatFunctions::av_guess_format, and mPrivate.

◆ Load()

std::shared_ptr< FFmpegFunctions > FFmpegFunctions::Load ( )
static

Definition at line 262 of file FFmpegFunctions.cpp.

263 {
264  static std::weak_ptr<FFmpegFunctions> weakFunctions;
265 
266  auto functions = weakFunctions.lock();
267 
268  if (functions)
269  return functions;
270 
271  std::shared_ptr<FFmpegFunctions> ffmpeg =
272  std::make_shared<FFmpegFunctions>();
273 
274  const auto supportedVersions =
276 
277 #if !defined(__WXMAC__)
278  EnvSetter envSetter;
279 #endif
280 
281  for (int version : supportedVersions)
282  {
283  for (const wxString& path : BuildAVFormatPaths(version))
284  {
285  if (ffmpeg->mPrivate->Load(*ffmpeg, path))
286  {
287  weakFunctions = ffmpeg;
288  return ffmpeg;
289  }
290  }
291  }
292 
293  return {};
294 }

References BuildAVFormatPaths(), FFmpegAPIResolver::Get(), FFmpegAPIResolver::GetSuportedAVFormatVersions(), and mPrivate.

Referenced by CheckFFmpegPresence(), ExportFFmpeg::CheckFileName(), ExportFFmpeg::ExportFFmpeg(), ExportFFmpegOptions::ExportFFmpegOptions(), GetFFmpegVersion(), Importer::Import(), LoadFFmpeg(), ExportFFmpegCustomOptions::OnOpen(), and FFmpegImportPlugin::Open().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ GetAudacityCodecID

AudacityAVCodecID(* FFmpegFunctions::GetAudacityCodecID) (AVCodecIDFwd) = nullptr

Definition at line 92 of file FFmpegFunctions.h.

Referenced by FFmpegFunctions::Private::Load().

◆ GetAVCodecID

AVCodecIDFwd(* FFmpegFunctions::GetAVCodecID) (AudacityAVCodecID) = nullptr

Definition at line 91 of file FFmpegFunctions.h.

Referenced by FFmpegFunctions::Private::Load().

◆ mPrivate

std::unique_ptr<Private> FFmpegFunctions::mPrivate
private

The documentation for this struct was generated from the following files:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
FFmpegAPIResolver::Get
static FFmpegAPIResolver & Get()
Definition: FFmpegAPIResolver.cpp:13
AVOutputFormatWrapper::GetWrappedValue
AVOutputFormat * GetWrappedValue() noexcept
Definition: AVOutputFormatWrapper.cpp:20
AVCodecFunctions::av_codec_next
AVCodec *(* av_codec_next)(const AVCodec *c)
Definition: AVCodecFunctions.h:35
AVCodecFunctions::avcodec_find_encoder
AVCodec *(* avcodec_find_encoder)(AVCodecIDFwd id)
Definition: AVCodecFunctions.h:24
AVCodecWrapper::GetWrappedValue
AVCodec * GetWrappedValue() noexcept
Definition: AVCodecWrapper.cpp:20
Setting::Read
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:128
FFmpegAPIResolver::GetSuportedAVFormatVersions
std::vector< int > GetSuportedAVFormatVersions() const
Definition: FFmpegAPIResolver.cpp:87
name
const TranslatableString name
Definition: Distortion.cpp:98
AVCodecFunctions::avcodec_find_decoder
AVCodec *(* avcodec_find_decoder)(AVCodecIDFwd id)
Definition: AVCodecFunctions.h:26
AVFormatFunctions::av_oformat_next
AVOutputFormat *(* av_oformat_next)(const AVOutputFormat *f)
Definition: AVFormatFunctions.h:27
AVDataBuffer
std::vector< T, AVAllocator< T > > AVDataBuffer
Definition: FFmpegFunctions.h:79
FFmpegFunctions::mPrivate
std::unique_ptr< Private > mPrivate
Definition: FFmpegFunctions.h:131
AVFormatPath
StringSetting AVFormatPath
Definition: FFmpegFunctions.cpp:296
AVFormatFunctions::av_guess_format
AVOutputFormat *(* av_guess_format)(const char *short_name, const char *filename, const char *mime_type)
Definition: AVFormatFunctions.h:35
EnvSetter
Definition: FFmpegFunctions.cpp:81
AVAllocator
Definition: FFmpegFunctions.h:42
AVCodec
Definition: ffmpeg-2.3.6-single-header.h:3466
anonymous_namespace{CompareAudioCommand.cpp}::reg
BuiltinCommandsModule::Registration< CompareAudioCommand > reg
Definition: CompareAudioCommand.cpp:41
AVCodecFunctions::avcodec_find_encoder_by_name
AVCodec *(* avcodec_find_encoder_by_name)(const char *name)
Definition: AVCodecFunctions.h:25
AVOutputFormat
Definition: ffmpeg-2.3.6-single-header.h:4236
BuildAVFormatPaths
std::vector< wxString > BuildAVFormatPaths(int version)
Definition: FFmpegFunctions.cpp:125