avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
codeccontext.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ffmpeg.h"
4 #include "stream.h"
5 #include "avutils.h"
6 #include "averror.h"
7 #include "pixelformat.h"
8 #include "sampleformat.h"
9 #include "avlog.h"
10 #include "frame.h"
11 #include "codec.h"
12 #include "channellayout.h"
13 
14 extern "C" {
15 #include <libavcodec/avcodec.h>
16 #include <libavformat/version.h>
17 }
18 
19 namespace av {
20 
21 namespace codec_context::audio {
22 void set_channels(AVCodecContext *obj, int channels);
23 void set_channel_layout_mask(AVCodecContext *obj, uint64_t mask);
24 int get_channels(const AVCodecContext *obj);
25 uint64_t get_channel_layout_mask(const AVCodecContext *obj);
26 }
27 
28 namespace codec_context::internal {
29 const int *get_supported_samplerates(const struct AVCodec *codec);
30 }
31 
32 class CodecContext2 : public FFWrapperPtr<AVCodecContext>, public noncopyable
33 {
34 protected:
35  void swap(CodecContext2 &other);
36 
37  //
38  // No directly created
39  //
40 
42  using BaseWrapper::BaseWrapper;
43 
44  CodecContext2();
45 
46  // Stream decoding/encoding
47  CodecContext2(const class Stream &st,
48  const class Codec& codec,
49  Direction direction,
50  AVMediaType type);
51 
52  // Stream independ decoding/encoding
53  CodecContext2(const class Codec &codec, Direction direction, AVMediaType type);
54 
56 
57  void setCodec(const class Codec &codec, bool resetDefaults, Direction direction, AVMediaType type, OptionalErrorCode ec = throws());
58 
59  AVMediaType codecType(AVMediaType contextType) const noexcept;
60 
61 public:
62 
63  using BaseWrapper::_log;
64 
65  //
66  // Common
67  //
68 
69  void open(OptionalErrorCode ec = throws());
70  void open(const Codec &codec, OptionalErrorCode ec = throws());
71  void open(class Dictionary &options, OptionalErrorCode ec = throws());
72  void open(class Dictionary &&options, OptionalErrorCode ec = throws());
73  void open(class Dictionary &options, const Codec &codec, OptionalErrorCode ec = throws());
74  void open(class Dictionary &&options, const Codec &codec, OptionalErrorCode ec = throws());
75 
76  [[deprecated("Start from FFmpeg 4.0 it is recommended to destroy and recreate codec context insted of close")]]
77  void close(OptionalErrorCode ec = throws());
78 
79  bool isOpened() const noexcept;
80  bool isValid() const noexcept;
81 
89  void copyContextFrom(const CodecContext2 &other, OptionalErrorCode ec = throws());
92 
93  Rational timeBase() const noexcept;
94  void setTimeBase(const Rational &value) noexcept;
95 
96  const Stream& stream() const noexcept;
97  Codec codec() const noexcept;
98 
99  void setOption(const std::string &key, const std::string &val, OptionalErrorCode ec = throws());
100  void setOption(const std::string &key, const std::string &val, int flags, OptionalErrorCode ec = throws());
101 
102  int frameSize() const noexcept;
103  int64_t frameNumber() const noexcept;
104 
105  // Note, set ref counted to enable for multithreaded processing
106  bool isRefCountedFrames() const noexcept;
107  void setRefCountedFrames(bool refcounted) const noexcept;
108 
109  int strict() const noexcept;
110  void setStrict(int strict) noexcept;
111 
112  int64_t bitRate() const noexcept;
113  std::pair<int64_t, int64_t> bitRateRange() const noexcept;
114  void setBitRate(int64_t bitRate) noexcept;
115  void setBitRateRange(const std::pair<int64_t, int64_t> &bitRateRange) noexcept;
116 
117  // Flags
120  void setFlags(int flags) noexcept;
121  void addFlags(int flags) noexcept;
122  void clearFlags(int flags) noexcept;
123  int flags() noexcept;
124  bool isFlags(int flags) noexcept;
126 
127  // Flags 2
130  void setFlags2(int flags) noexcept;
131  void addFlags2(int flags) noexcept;
132  void clearFlags2(int flags) noexcept;
133  int flags2() noexcept;
134  bool isFlags2(int flags) noexcept;
136 
137 
138 protected:
139 
140  bool isValidForEncode(Direction direction, AVMediaType type) const noexcept;
141 
142  bool checkCodec(const Codec& codec, Direction direction, AVMediaType type, OptionalErrorCode ec);
143 
144  void open(const Codec &codec, AVDictionary **options, OptionalErrorCode ec);
145 
146 
147  std::pair<int, const std::error_category*>
148  decodeCommon(AVFrame *outFrame, const class Packet &inPacket, size_t offset, int &frameFinished,
149  int (*decodeProc)(AVCodecContext*, AVFrame*,int *, const AVPacket *)) noexcept;
150 
151  std::pair<int, const std::error_category*>
152  encodeCommon(class Packet &outPacket, const AVFrame *inFrame, int &gotPacket,
153  int (*encodeProc)(AVCodecContext*, AVPacket*,const AVFrame*, int*)) noexcept;
154 
155 public:
156  template<typename T>
157  std::pair<int, const std::error_category*>
158  decodeCommon(T &outFrame,
159  const class Packet &inPacket,
160  size_t offset,
161  int &frameFinished,
162  int (*decodeProc)(AVCodecContext *, AVFrame *, int *, const AVPacket *));
163 
164  template<typename T>
165  std::pair<int, const std::error_category*>
166  encodeCommon(class Packet &outPacket,
167  const T &inFrame,
168  int &gotPacket,
169  int (*encodeProc)(AVCodecContext *, AVPacket *, const AVFrame *, int *));
170 
171 private:
172  Stream m_stream;
173 };
174 
175 
184 {
185 protected:
187 
188 public:
189  GenericCodecContext() = default;
190 
192 
194 
196 
197  AVMediaType codecType() const noexcept;
198 };
199 
200 
201 template<typename Clazz, Direction _direction, AVMediaType _type>
203 {
204 protected:
205  Clazz& moveOperator(Clazz &&rhs)
206  {
207  if (this == &rhs)
208  return static_cast<Clazz&>(*this);
209  Clazz(std::forward<Clazz>(rhs)).swap(static_cast<Clazz&>(*this));
210  return static_cast<Clazz&>(*this);
211  }
212 
214 
215 public:
216 
217  using CodecContext2::_log;
218 
220  : CodecContext2()
221  {
222  }
223 
224  // Stream decoding/encoding
225  explicit CodecContextBase(const class Stream &st, const class Codec& codec = Codec())
226  : CodecContext2(st, codec, _direction, _type)
227  {
228  }
229 
230  // Stream independ decoding/encoding
231  explicit CodecContextBase(const Codec &codec)
232  : CodecContext2(codec, _direction, _type)
233  {
234  }
235 
236  //
237  // Disable copy/Activate move
238  //
240  : CodecContextBase()
241  {
242  swap(other);
243  }
244  //
245 
246 
247  void setCodec(const Codec &codec, OptionalErrorCode ec = throws())
248  {
249  setCodec(codec, false, _direction, _type, ec);
250  }
251 
252  void setCodec(const Codec &codec, bool resetDefaults, OptionalErrorCode ec = throws())
253  {
254  setCodec(codec, resetDefaults, _direction, _type, ec);
255  }
256 
257  AVMediaType codecType() const noexcept
258  {
259  return CodecContext2::codecType(_type);
260  }
261 };
262 
263 
264 template<typename Clazz, Direction _direction>
265 class VideoCodecContext : public CodecContextBase<Clazz, _direction, AVMEDIA_TYPE_VIDEO>
266 {
267 public:
269  using Parent::Parent;
270  using Parent::isValid;
271  using Parent::isOpened;
272 
273  int width() const
274  {
275  return RAW_GET2(isValid(), width, 0);
276  }
277 
278  int height() const
279  {
280  return RAW_GET2(isValid(), height, 0);
281  }
282 
283  int codedWidth() const
284  {
285  return RAW_GET2(isValid(), coded_width, 0);
286  }
287 
288  int codedHeight() const
289  {
290  return RAW_GET2(isValid(), coded_height, 0);
291  }
292 
294  {
295  return RAW_GET2(isValid(), pix_fmt, AV_PIX_FMT_NONE);
296  }
297 
298  int32_t globalQuality() const
299  {
300  return RAW_GET2(isValid(), global_quality, FF_LAMBDA_MAX);
301  }
302 
303  int32_t gopSize() const
304  {
305  return RAW_GET2(isValid(), gop_size, 0);
306  }
307 
308  int bitRateTolerance() const
309  {
310  return RAW_GET2(isValid(), bit_rate_tolerance, 0);
311  }
312 
313  int maxBFrames() const
314  {
315  return RAW_GET2(isValid(), max_b_frames, 0);
316  }
317 
319  {
320  return RAW_GET(sample_aspect_ratio, AVRational());
321  }
322 
323  void setWidth(int w) // Note, it also sets coded_width
324  {
325  if (isValid() & !isOpened())
326  {
327  m_raw->width = w;
328  m_raw->coded_width = w;
329  }
330  }
331 
332  void setHeight(int h) // Note, it also sets coded_height
333  {
334  if (isValid() && !isOpened())
335  {
336  m_raw->height = h;
337  m_raw->coded_height = h;
338  }
339  }
340 
341  void setCodedWidth(int w)
342  {
343  RAW_SET2(isValid() && !isOpened(), coded_width, w);
344  }
345 
346  void setCodedHeight(int h)
347  {
348  RAW_SET2(isValid() && !isOpened(), coded_height, h);
349  }
350 
351  void setPixelFormat(PixelFormat pixelFormat)
352  {
353  RAW_SET2(isValid(), pix_fmt, pixelFormat);
354  }
355 
356  void setGlobalQuality(int32_t quality)
357  {
358  if (quality < 0 || quality > FF_LAMBDA_MAX)
359  quality = FF_LAMBDA_MAX;
360 
361  RAW_SET2(isValid(), global_quality, quality);
362  }
363 
364  void setGopSize(int32_t size)
365  {
366  RAW_SET2(isValid(), gop_size, size);
367  }
368 
369  void setBitRateTolerance(int bitRateTolerance)
370  {
371  RAW_SET2(isValid(), bit_rate_tolerance, bitRateTolerance);
372  }
373 
374  void setMaxBFrames(int maxBFrames)
375  {
376  RAW_SET2(isValid(), max_b_frames, maxBFrames);
377  }
378 
379  void setSampleAspectRatio(const Rational& sampleAspectRatio)
380  {
381  RAW_SET(sample_aspect_ratio, sampleAspectRatio);
382  }
383 
384 protected:
385  using Parent::moveOperator;
386  using Parent::m_raw;
387 };
388 
389 
390 class VideoDecoderContext : public VideoCodecContext<VideoDecoderContext, Direction::Decoding>
391 {
392 public:
394  using Parent::Parent;
395 
396  VideoDecoderContext() = default;
398 
400 
412  VideoFrame decode(const Packet &packet,
413  OptionalErrorCode ec = throws(),
414  bool autoAllocateFrame = true);
415 
429  VideoFrame decode(const Packet &packet,
430  size_t offset,
431  size_t &decodedBytes,
432  OptionalErrorCode ec = throws(),
433  bool autoAllocateFrame = true);
434 
435 
436 private:
437  VideoFrame decodeVideo(OptionalErrorCode ec,
438  const Packet &packet,
439  size_t offset,
440  size_t *decodedBytes,
441  bool autoAllocateFrame);
442 
443 };
444 
445 
446 class VideoEncoderContext : public VideoCodecContext<VideoEncoderContext, Direction::Encoding>
447 {
448 public:
450  using Parent::Parent;
451 
452  VideoEncoderContext() = default;
454 
456 
466  Packet encode(OptionalErrorCode ec = throws());
467 
479  Packet encode(const VideoFrame &inFrame, OptionalErrorCode ec = throws());
480 
481 };
482 
483 
484 template<typename Clazz, Direction _direction>
485 class AudioCodecContext : public CodecContextBase<Clazz, _direction, AVMEDIA_TYPE_AUDIO>
486 {
487 public:
489  using Parent::Parent;
490  using Parent::isValid;
491  using Parent::isOpened;
492  using Parent::_log;
493 
494  int sampleRate() const noexcept
495  {
496  return RAW_GET2(isValid(), sample_rate, 0);
497  }
498 
499  int channels() const noexcept
500  {
501  if (!isValid())
502  return 0;
504  }
505 
506  SampleFormat sampleFormat() const noexcept
507  {
508  return RAW_GET2(isValid(), sample_fmt, AV_SAMPLE_FMT_NONE);
509  }
510 
511  uint64_t channelLayout() const noexcept
512  {
513  if (!isValid())
514  return 0;
516  }
517 
518 #if API_NEW_CHANNEL_LAYOUT
519  ChannelLayoutView channelLayout2() const noexcept
520  {
521  if (!isValid())
522  return ChannelLayoutView{};
523  return ChannelLayoutView{m_raw->ch_layout};
524  }
525 #endif
526 
527  void setSampleRate(int sampleRate) noexcept
528  {
529  if (!isValid())
530  return;
532  if (sr != sampleRate)
533  {
534  fflog(AV_LOG_INFO, "Guess sample rate %d instead unsupported %d\n", sr, sampleRate);
535  }
536  if (sr > 0)
537  m_raw->sample_rate = sr;
538  }
539 
540  void setChannels(int channels) noexcept
541  {
542  if (!isValid() || channels <= 0)
543  return;
545  }
546 
547  void setSampleFormat(SampleFormat sampleFormat) noexcept
548  {
549  RAW_SET2(isValid(), sample_fmt, sampleFormat);
550  }
551 
552  void setChannelLayout(uint64_t layout) noexcept
553  {
554  if (!isValid() || layout == 0)
555  return;
557  }
558 
559 #if API_NEW_CHANNEL_LAYOUT
560  void setChannelLayout(ChannelLayout layout) noexcept
561  {
562  if (!isValid() || !layout.isValid())
563  return;
564  m_raw->ch_layout = *layout.raw();
565  layout.release(); // is controlled by the CodecContext
566  }
567 #endif
568 
569 protected:
570  using Parent::moveOperator;
571  using Parent::m_raw;
572 };
573 
574 
575 class AudioDecoderContext : public AudioCodecContext<AudioDecoderContext, Direction::Decoding>
576 {
577 public:
579  using Parent::Parent;
580 
581  AudioDecoderContext() = default;
583 
585 
586  AudioSamples decode(const Packet &inPacket, OptionalErrorCode ec = throws());
587  AudioSamples decode(const Packet &inPacket, size_t offset, OptionalErrorCode ec = throws());
588 
589 };
590 
591 
592 class AudioEncoderContext : public AudioCodecContext<AudioEncoderContext, Direction::Encoding>
593 {
594 public:
596  using Parent::Parent;
597 
598  AudioEncoderContext() = default;
600 
602 
603  Packet encode(OptionalErrorCode ec = throws());
604  Packet encode(const AudioSamples &inSamples, OptionalErrorCode ec = throws());
605 
606 };
607 
608 
609 } // namespace av
av::VideoCodecContext::setGlobalQuality
void setGlobalQuality(int32_t quality)
Definition: codeccontext.h:356
av::VideoCodecContext::setGopSize
void setGopSize(int32_t size)
Definition: codeccontext.h:364
av::CodecContext2::clearFlags
void clearFlags(int flags) noexcept
Definition: codeccontext.cpp:736
av::CodecContext2::bitRate
int64_t bitRate() const noexcept
Definition: codeccontext.cpp:698
fflog
#define fflog(level, format,...)
Default in-class logger.
Definition: avlog.h:27
av::CodecContext2::copyContextFrom
void copyContextFrom(const CodecContext2 &other, OptionalErrorCode ec=throws())
Copy codec context from codec context associated with given stream or other codec context.
Definition: codeccontext.cpp:563
av::Rational
Definition: rational.h:25
av::VideoCodecContext::gopSize
int32_t gopSize() const
Definition: codeccontext.h:303
av::Dictionary
Implements interface to access to the AVDictionary entity.
Definition: dictionary.h:30
av::CodecContextBase::moveOperator
Clazz & moveOperator(Clazz &&rhs)
Definition: codeccontext.h:205
averror.h
av::CodecContext2::setRefCountedFrames
void setRefCountedFrames(bool refcounted) const noexcept
Definition: codeccontext.cpp:676
ffmpeg.h
av::CodecContextBase::codecType
AVMediaType codecType() const noexcept
Definition: codeccontext.h:257
pixelformat.h
FFWrapperPtr
Definition: ffmpeg.h:66
av::CodecContext2::timeBase
Rational timeBase() const noexcept
Definition: codeccontext.cpp:609
av::AudioCodecContext::setSampleRate
void setSampleRate(int sampleRate) noexcept
Definition: codeccontext.h:527
av::CodecContext2::CodecContext2
CodecContext2()
Definition: codeccontext.cpp:292
av::VideoCodecContext::setWidth
void setWidth(int w)
Definition: codeccontext.h:323
av::CodecContext2::bitRateRange
std::pair< int64_t, int64_t > bitRateRange() const noexcept
Definition: codeccontext.cpp:703
av::AudioCodecContext::sampleFormat
SampleFormat sampleFormat() const noexcept
Definition: codeccontext.h:506
av::CodecContext2::frameSize
int frameSize() const noexcept
Definition: codeccontext.cpp:653
av::VideoCodecContext::pixelFormat
PixelFormat pixelFormat() const
Definition: codeccontext.h:293
av::CodecContextBase::CodecContextBase
CodecContextBase()
Definition: codeccontext.h:219
av::CodecContext2::setCodec
void setCodec(const class Codec &codec, bool resetDefaults, Direction direction, AVMediaType type, OptionalErrorCode ec=throws())
Definition: codeccontext.cpp:368
av::CodecContext2::codec
Codec codec() const noexcept
Definition: codeccontext.cpp:624
av::VideoCodecContext::codedHeight
int codedHeight() const
Definition: codeccontext.h:288
av::CodecContext2::setOption
void setOption(const std::string &key, const std::string &val, OptionalErrorCode ec=throws())
av::CodecContext2::isValidForEncode
bool isValidForEncode(Direction direction, AVMediaType type) const noexcept
Definition: codeccontext.cpp:783
codec.h
av::CodecContextBase::setCodec
void setCodec(const Codec &codec, OptionalErrorCode ec=throws())
Definition: codeccontext.h:247
av::VideoCodecContext::height
int height() const
Definition: codeccontext.h:278
av::CodecContext2::isValid
bool isValid() const noexcept
Definition: codeccontext.cpp:557
av::CodecContext2::isFlags2
bool isFlags2(int flags) noexcept
Definition: codeccontext.cpp:776
av::CodecContext2::open
void open(OptionalErrorCode ec=throws())
Definition: codeccontext.cpp:450
av::CodecContextBase
Definition: codeccontext.h:202
av::CodecContext2::flags2
int flags2() noexcept
Definition: codeccontext.cpp:771
av::OptionalErrorCode
Definition: averror.h:63
av::CodecContext2::codecType
AVMediaType codecType(AVMediaType contextType) const noexcept
Definition: codeccontext.cpp:438
av::CodecContext2::strict
int strict() const noexcept
Definition: codeccontext.cpp:683
av::codec_context::audio::get_channel_layout_mask
uint64_t get_channel_layout_mask(const AVCodecContext *obj)
Definition: codeccontext.cpp:1138
av::CodecContext2::flags
int flags() noexcept
Definition: codeccontext.cpp:742
av::codec_context::audio::get_channels
int get_channels(const AVCodecContext *obj)
Definition: codeccontext.cpp:1122
av::VideoCodecContext::setSampleAspectRatio
void setSampleAspectRatio(const Rational &sampleAspectRatio)
Definition: codeccontext.h:379
av::VideoCodecContext::setMaxBFrames
void setMaxBFrames(int maxBFrames)
Definition: codeccontext.h:374
av::VideoCodecContext::codedWidth
int codedWidth() const
Definition: codeccontext.h:283
av::CodecContext2::encodeCommon
std::pair< int, const std::error_category * > encodeCommon(class Packet &outPacket, const AVFrame *inFrame, int &gotPacket, int(*encodeProc)(AVCodecContext *, AVPacket *, const AVFrame *, int *)) noexcept
Definition: codeccontext.cpp:881
av::CodecContext2::setBitRate
void setBitRate(int64_t bitRate) noexcept
Definition: codeccontext.cpp:711
av::AudioCodecContext::setChannels
void setChannels(int channels) noexcept
Definition: codeccontext.h:540
av::CodecContext2::isRefCountedFrames
bool isRefCountedFrames() const noexcept
Definition: codeccontext.cpp:667
avutils.h
RAW_GET
#define RAW_GET(field, def)
Definition: ffmpeg.h:92
av::CodecContext2::setStrict
void setStrict(int strict) noexcept
Definition: codeccontext.cpp:688
av::codec_context::audio::set_channel_layout_mask
void set_channel_layout_mask(AVCodecContext *obj, uint64_t mask)
Definition: codeccontext.cpp:1101
av::VideoCodecContext::sampleAspectRatio
Rational sampleAspectRatio() const
Definition: codeccontext.h:318
av::VideoCodecContext::width
int width() const
Definition: codeccontext.h:273
av::AudioCodecContext::setSampleFormat
void setSampleFormat(SampleFormat sampleFormat) noexcept
Definition: codeccontext.h:547
av::EqualComparator
Definition: avutils.h:318
av::CodecContext2::clearFlags2
void clearFlags2(int flags) noexcept
Definition: codeccontext.cpp:765
av::AudioCodecContext::channels
int channels() const noexcept
Definition: codeccontext.h:499
av::VideoCodecContext::globalQuality
int32_t globalQuality() const
Definition: codeccontext.h:298
avlog.h
stream.h
av::VideoCodecContext::maxBFrames
int maxBFrames() const
Definition: codeccontext.h:313
av::VideoCodecContext::setCodedWidth
void setCodedWidth(int w)
Definition: codeccontext.h:341
av::VideoDecoderContext
Definition: codeccontext.h:390
FFWrapperPtr< AVCodecContext >::_log
void _log(int level, const char *fmt) const
Definition: ffmpeg.h:77
av::CodecContext2::checkCodec
bool checkCodec(const Codec &codec, Direction direction, AVMediaType type, OptionalErrorCode ec)
Definition: codeccontext.cpp:817
av::CodecContext2::~CodecContext2
~CodecContext2()
Definition: codeccontext.cpp:345
av::CodecContextBase::CodecContextBase
CodecContextBase(CodecContextBase &&other)
Definition: codeccontext.h:239
av::AudioCodecContext::setChannelLayout
void setChannelLayout(uint64_t layout) noexcept
Definition: codeccontext.h:552
av::CodecContext2::addFlags
void addFlags(int flags) noexcept
Definition: codeccontext.cpp:730
av::codec_context::audio::set_channels
void set_channels(AVCodecContext *obj, int channels)
Definition: codeccontext.cpp:1086
av::CodecContextBase::CodecContextBase
CodecContextBase(const class Stream &st, const class Codec &codec=Codec())
Definition: codeccontext.h:225
av::noncopyable::operator=
void operator=(const noncopyable &)=delete
frame.h
av::CodecContext2::stream
const Stream & stream() const noexcept
Definition: codeccontext.cpp:619
sampleformat.h
av::CodecContext2
Definition: codeccontext.h:32
av::AudioSamples
Definition: frame.h:391
av::VideoEncoderContext
Definition: codeccontext.h:446
av::CodecContext2::close
void close(OptionalErrorCode ec=throws())
Definition: codeccontext.cpp:539
av::CodecContext2::addFlags2
void addFlags2(int flags) noexcept
Definition: codeccontext.cpp:759
av::PixelFormat
The PixelFormat class is a simple wrapper for AVPixelFormat that allow to acces it it properties.
Definition: pixelformat.h:26
av::GenericCodecContext
The GenericCodecContext class to copy contexts from input streams to output one.
Definition: codeccontext.h:183
av::AudioCodecContext::channelLayout
uint64_t channelLayout() const noexcept
Definition: codeccontext.h:511
av::CodecContext2::setFlags
void setFlags(int flags) noexcept
Access to CODEC_FLAG_* flags.
Definition: codeccontext.cpp:725
av::Packet
Definition: packet.h:18
av::CodecContext2::isFlags
bool isFlags(int flags) noexcept
Definition: codeccontext.cpp:747
av::VideoFrame
Definition: frame.h:354
av::codec_context::internal::get_supported_samplerates
const int * get_supported_samplerates(const struct AVCodec *codec)
Definition: codeccontext.cpp:172
av
Definition: audioresampler.cpp:8
av::AudioEncoderContext
Definition: codeccontext.h:592
std
Definition: averror.h:228
av::AudioCodecContext::sampleRate
int sampleRate() const noexcept
Definition: codeccontext.h:494
av::VideoCodecContext::setHeight
void setHeight(int h)
Definition: codeccontext.h:332
av::noncopyable
Definition: avutils.h:84
av::VideoCodecContext::setPixelFormat
void setPixelFormat(PixelFormat pixelFormat)
Definition: codeccontext.h:351
channellayout.h
av::AudioCodecContext
Definition: codeccontext.h:485
av::VideoCodecContext::bitRateTolerance
int bitRateTolerance() const
Definition: codeccontext.h:308
FFWrapperPtr< AVCodecContext >::m_raw
AVCodecContext * m_raw
Definition: ffmpeg.h:89
av::Direction
Direction
Definition: stream.h:14
av::CodecContext2::setFlags2
void setFlags2(int flags) noexcept
Access to CODEC_FLAG2_* flags.
Definition: codeccontext.cpp:754
av::throws
OptionalErrorCode throws()
Helper to construct null OptionalErrorCode object.
Definition: averror.h:179
av::CodecContext2::decodeCommon
std::pair< int, const std::error_category * > decodeCommon(AVFrame *outFrame, const class Packet &inPacket, size_t offset, int &frameFinished, int(*decodeProc)(AVCodecContext *, AVFrame *, int *, const AVPacket *)) noexcept
av::AudioDecoderContext
Definition: codeccontext.h:575
av::Codec
Definition: codec.h:17
av::CodecContext2::frameNumber
int64_t frameNumber() const noexcept
Definition: codeccontext.cpp:658
av::VideoCodecContext
Definition: codeccontext.h:265
av::CodecContext2::swap
void swap(CodecContext2 &other)
Definition: codeccontext.cpp:285
av::VideoCodecContext::setCodedHeight
void setCodedHeight(int h)
Definition: codeccontext.h:346
av::CodecContextBase::CodecContextBase
CodecContextBase(const Codec &codec)
Definition: codeccontext.h:231
RAW_SET
#define RAW_SET(field, val)
Definition: ffmpeg.h:93
av::CodecContext2::isOpened
bool isOpened() const noexcept
Definition: codeccontext.cpp:552
av::VideoCodecContext::setBitRateTolerance
void setBitRateTolerance(int bitRateTolerance)
Definition: codeccontext.h:369
av::guessValue
T guessValue(const T &value, const L *list, C endListComparator)
Select more approptiate value from given value list.
Definition: avutils.h:351
RAW_GET2
#define RAW_GET2(cond, field, def)
Definition: ffmpeg.h:95
av::Stream
Definition: stream.h:22
RAW_SET2
#define RAW_SET2(cond, field, val)
Definition: ffmpeg.h:96
av::CodecContext2::setTimeBase
void setTimeBase(const Rational &value) noexcept
Definition: codeccontext.cpp:614
av::SampleFormat
The SampleFormat class is a simple proxy class for AVSampleFormat.
Definition: sampleformat.h:21
av::CodecContext2::setBitRateRange
void setBitRateRange(const std::pair< int64_t, int64_t > &bitRateRange) noexcept
Definition: codeccontext.cpp:716
av::CodecContextBase::setCodec
void setCodec(const Codec &codec, bool resetDefaults, OptionalErrorCode ec=throws())
Definition: codeccontext.h:252