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 class CodecContext2 : public FFWrapperPtr<AVCodecContext>, public noncopyable
29 {
30 protected:
31  void swap(CodecContext2 &other);
32 
33  //
34  // No directly created
35  //
36 
38  using BaseWrapper::BaseWrapper;
39 
40  CodecContext2();
41 
42  // Stream decoding/encoding
43  CodecContext2(const class Stream &st,
44  const class Codec& codec,
45  Direction direction,
46  AVMediaType type);
47 
48  // Stream independ decoding/encoding
49  CodecContext2(const class Codec &codec, Direction direction, AVMediaType type);
50 
52 
53  void setCodec(const class Codec &codec, bool resetDefaults, Direction direction, AVMediaType type, OptionalErrorCode ec = throws());
54 
55  AVMediaType codecType(AVMediaType contextType) const noexcept;
56 
57 public:
58 
59  using BaseWrapper::_log;
60 
61  //
62  // Common
63  //
64 
65  void open(OptionalErrorCode ec = throws());
66  void open(const Codec &codec, OptionalErrorCode ec = throws());
67  void open(class Dictionary &options, OptionalErrorCode ec = throws());
68  void open(class Dictionary &&options, OptionalErrorCode ec = throws());
69  void open(class Dictionary &options, const Codec &codec, OptionalErrorCode ec = throws());
70  void open(class Dictionary &&options, const Codec &codec, OptionalErrorCode ec = throws());
71 
72  [[deprecated("Start from FFmpeg 4.0 it is recommended to destroy and recreate codec context insted of close")]]
73  void close(OptionalErrorCode ec = throws());
74 
75  bool isOpened() const noexcept;
76  bool isValid() const noexcept;
77 
85  void copyContextFrom(const CodecContext2 &other, OptionalErrorCode ec = throws());
88 
89  Rational timeBase() const noexcept;
90  void setTimeBase(const Rational &value) noexcept;
91 
92  const Stream& stream() const noexcept;
93  Codec codec() const noexcept;
94 
95  void setOption(const std::string &key, const std::string &val, OptionalErrorCode ec = throws());
96  void setOption(const std::string &key, const std::string &val, int flags, OptionalErrorCode ec = throws());
97 
98  int frameSize() const noexcept;
99  int64_t frameNumber() const noexcept;
100 
101  // Note, set ref counted to enable for multithreaded processing
102  bool isRefCountedFrames() const noexcept;
103  void setRefCountedFrames(bool refcounted) const noexcept;
104 
105  int strict() const noexcept;
106  void setStrict(int strict) noexcept;
107 
108  int64_t bitRate() const noexcept;
109  std::pair<int64_t, int64_t> bitRateRange() const noexcept;
110  void setBitRate(int64_t bitRate) noexcept;
111  void setBitRateRange(const std::pair<int64_t, int64_t> &bitRateRange) noexcept;
112 
113  // Flags
116  void setFlags(int flags) noexcept;
117  void addFlags(int flags) noexcept;
118  void clearFlags(int flags) noexcept;
119  int flags() noexcept;
120  bool isFlags(int flags) noexcept;
122 
123  // Flags 2
126  void setFlags2(int flags) noexcept;
127  void addFlags2(int flags) noexcept;
128  void clearFlags2(int flags) noexcept;
129  int flags2() noexcept;
130  bool isFlags2(int flags) noexcept;
132 
133 
134 protected:
135 
136  bool isValidForEncode(Direction direction, AVMediaType type) const noexcept;
137 
138  bool checkCodec(const Codec& codec, Direction direction, AVMediaType type, OptionalErrorCode ec);
139 
140  void open(const Codec &codec, AVDictionary **options, OptionalErrorCode ec);
141 
142 
143  std::pair<int, const std::error_category*>
144  decodeCommon(AVFrame *outFrame, const class Packet &inPacket, size_t offset, int &frameFinished,
145  int (*decodeProc)(AVCodecContext*, AVFrame*,int *, const AVPacket *)) noexcept;
146 
147  std::pair<int, const std::error_category*>
148  encodeCommon(class Packet &outPacket, const AVFrame *inFrame, int &gotPacket,
149  int (*encodeProc)(AVCodecContext*, AVPacket*,const AVFrame*, int*)) noexcept;
150 
151 public:
152  template<typename T>
153  std::pair<int, const std::error_category*>
154  decodeCommon(T &outFrame,
155  const class Packet &inPacket,
156  size_t offset,
157  int &frameFinished,
158  int (*decodeProc)(AVCodecContext *, AVFrame *, int *, const AVPacket *));
159 
160  template<typename T>
161  std::pair<int, const std::error_category*>
162  encodeCommon(class Packet &outPacket,
163  const T &inFrame,
164  int &gotPacket,
165  int (*encodeProc)(AVCodecContext *, AVPacket *, const AVFrame *, int *));
166 
167 private:
168  Stream m_stream;
169 };
170 
171 
180 {
181 protected:
183 
184 public:
185  GenericCodecContext() = default;
186 
188 
190 
192 
193  AVMediaType codecType() const noexcept;
194 };
195 
196 
197 template<typename Clazz, Direction _direction, AVMediaType _type>
199 {
200 protected:
201  Clazz& moveOperator(Clazz &&rhs)
202  {
203  if (this == &rhs)
204  return static_cast<Clazz&>(*this);
205  Clazz(std::forward<Clazz>(rhs)).swap(static_cast<Clazz&>(*this));
206  return static_cast<Clazz&>(*this);
207  }
208 
210 
211 public:
212 
213  using CodecContext2::_log;
214 
216  : CodecContext2()
217  {
218  }
219 
220  // Stream decoding/encoding
221  explicit CodecContextBase(const class Stream &st, const class Codec& codec = Codec())
222  : CodecContext2(st, codec, _direction, _type)
223  {
224  }
225 
226  // Stream independ decoding/encoding
227  explicit CodecContextBase(const Codec &codec)
228  : CodecContext2(codec, _direction, _type)
229  {
230  }
231 
232  //
233  // Disable copy/Activate move
234  //
236  : CodecContextBase()
237  {
238  swap(other);
239  }
240  //
241 
242 
243  void setCodec(const Codec &codec, OptionalErrorCode ec = throws())
244  {
245  setCodec(codec, false, _direction, _type, ec);
246  }
247 
248  void setCodec(const Codec &codec, bool resetDefaults, OptionalErrorCode ec = throws())
249  {
250  setCodec(codec, resetDefaults, _direction, _type, ec);
251  }
252 
253  AVMediaType codecType() const noexcept
254  {
255  return CodecContext2::codecType(_type);
256  }
257 };
258 
259 
260 template<typename Clazz, Direction _direction>
261 class VideoCodecContext : public CodecContextBase<Clazz, _direction, AVMEDIA_TYPE_VIDEO>
262 {
263 public:
265  using Parent::Parent;
266  using Parent::isValid;
267  using Parent::isOpened;
268 
269  int width() const
270  {
271  return RAW_GET2(isValid(), width, 0);
272  }
273 
274  int height() const
275  {
276  return RAW_GET2(isValid(), height, 0);
277  }
278 
279  int codedWidth() const
280  {
281  return RAW_GET2(isValid(), coded_width, 0);
282  }
283 
284  int codedHeight() const
285  {
286  return RAW_GET2(isValid(), coded_height, 0);
287  }
288 
290  {
291  return RAW_GET2(isValid(), pix_fmt, AV_PIX_FMT_NONE);
292  }
293 
294  int32_t globalQuality() const
295  {
296  return RAW_GET2(isValid(), global_quality, FF_LAMBDA_MAX);
297  }
298 
299  int32_t gopSize() const
300  {
301  return RAW_GET2(isValid(), gop_size, 0);
302  }
303 
304  int bitRateTolerance() const
305  {
306  return RAW_GET2(isValid(), bit_rate_tolerance, 0);
307  }
308 
309  int maxBFrames() const
310  {
311  return RAW_GET2(isValid(), max_b_frames, 0);
312  }
313 
315  {
316  return RAW_GET(sample_aspect_ratio, AVRational());
317  }
318 
319  void setWidth(int w) // Note, it also sets coded_width
320  {
321  if (isValid() & !isOpened())
322  {
323  m_raw->width = w;
324  m_raw->coded_width = w;
325  }
326  }
327 
328  void setHeight(int h) // Note, it also sets coded_height
329  {
330  if (isValid() && !isOpened())
331  {
332  m_raw->height = h;
333  m_raw->coded_height = h;
334  }
335  }
336 
337  void setCodedWidth(int w)
338  {
339  RAW_SET2(isValid() && !isOpened(), coded_width, w);
340  }
341 
342  void setCodedHeight(int h)
343  {
344  RAW_SET2(isValid() && !isOpened(), coded_height, h);
345  }
346 
347  void setPixelFormat(PixelFormat pixelFormat)
348  {
349  RAW_SET2(isValid(), pix_fmt, pixelFormat);
350  }
351 
352  void setGlobalQuality(int32_t quality)
353  {
354  if (quality < 0 || quality > FF_LAMBDA_MAX)
355  quality = FF_LAMBDA_MAX;
356 
357  RAW_SET2(isValid(), global_quality, quality);
358  }
359 
360  void setGopSize(int32_t size)
361  {
362  RAW_SET2(isValid(), gop_size, size);
363  }
364 
365  void setBitRateTolerance(int bitRateTolerance)
366  {
367  RAW_SET2(isValid(), bit_rate_tolerance, bitRateTolerance);
368  }
369 
370  void setMaxBFrames(int maxBFrames)
371  {
372  RAW_SET2(isValid(), max_b_frames, maxBFrames);
373  }
374 
375  void setSampleAspectRatio(const Rational& sampleAspectRatio)
376  {
377  RAW_SET(sample_aspect_ratio, sampleAspectRatio);
378  }
379 
380 protected:
381  using Parent::moveOperator;
382  using Parent::m_raw;
383 };
384 
385 
386 class VideoDecoderContext : public VideoCodecContext<VideoDecoderContext, Direction::Decoding>
387 {
388 public:
390  using Parent::Parent;
391 
392  VideoDecoderContext() = default;
394 
396 
408  VideoFrame decode(const Packet &packet,
409  OptionalErrorCode ec = throws(),
410  bool autoAllocateFrame = true);
411 
425  VideoFrame decode(const Packet &packet,
426  size_t offset,
427  size_t &decodedBytes,
428  OptionalErrorCode ec = throws(),
429  bool autoAllocateFrame = true);
430 
431 
432 private:
433  VideoFrame decodeVideo(OptionalErrorCode ec,
434  const Packet &packet,
435  size_t offset,
436  size_t *decodedBytes,
437  bool autoAllocateFrame);
438 
439 };
440 
441 
442 class VideoEncoderContext : public VideoCodecContext<VideoEncoderContext, Direction::Encoding>
443 {
444 public:
446  using Parent::Parent;
447 
448  VideoEncoderContext() = default;
450 
452 
462  Packet encode(OptionalErrorCode ec = throws());
463 
475  Packet encode(const VideoFrame &inFrame, OptionalErrorCode ec = throws());
476 
477 };
478 
479 
480 template<typename Clazz, Direction _direction>
481 class AudioCodecContext : public CodecContextBase<Clazz, _direction, AVMEDIA_TYPE_AUDIO>
482 {
483 public:
485  using Parent::Parent;
486  using Parent::isValid;
487  using Parent::isOpened;
488  using Parent::_log;
489 
490  int sampleRate() const noexcept
491  {
492  return RAW_GET2(isValid(), sample_rate, 0);
493  }
494 
495  int channels() const noexcept
496  {
497  if (!isValid())
498  return 0;
500  }
501 
502  SampleFormat sampleFormat() const noexcept
503  {
504  return RAW_GET2(isValid(), sample_fmt, AV_SAMPLE_FMT_NONE);
505  }
506 
507  uint64_t channelLayout() const noexcept
508  {
509  if (!isValid())
510  return 0;
512  }
513 
514 #if API_NEW_CHANNEL_LAYOUT
515  ChannelLayoutView channelLayout2() const noexcept
516  {
517  if (!isValid())
518  return ChannelLayoutView{};
519  return ChannelLayoutView{m_raw->ch_layout};
520  }
521 #endif
522 
523  void setSampleRate(int sampleRate) noexcept
524  {
525  if (!isValid())
526  return;
527  int sr = guessValue(sampleRate, m_raw->codec->supported_samplerates, EqualComparator<int>(0));
528  if (sr != sampleRate)
529  {
530  fflog(AV_LOG_INFO, "Guess sample rate %d instead unsupported %d\n", sr, sampleRate);
531  }
532  if (sr > 0)
533  m_raw->sample_rate = sr;
534  }
535 
536  void setChannels(int channels) noexcept
537  {
538  if (!isValid() || channels <= 0)
539  return;
541  }
542 
543  void setSampleFormat(SampleFormat sampleFormat) noexcept
544  {
545  RAW_SET2(isValid(), sample_fmt, sampleFormat);
546  }
547 
548  void setChannelLayout(uint64_t layout) noexcept
549  {
550  if (!isValid() || layout == 0)
551  return;
553  }
554 
555 #if API_NEW_CHANNEL_LAYOUT
556  void setChannelLayout(ChannelLayout layout) noexcept
557  {
558  if (!isValid() || !layout.isValid())
559  return;
560  m_raw->ch_layout = *layout.raw();
561  layout.release(); // is controlled by the CodecContext
562  }
563 #endif
564 
565 protected:
566  using Parent::moveOperator;
567  using Parent::m_raw;
568 };
569 
570 
571 class AudioDecoderContext : public AudioCodecContext<AudioDecoderContext, Direction::Decoding>
572 {
573 public:
575  using Parent::Parent;
576 
577  AudioDecoderContext() = default;
579 
581 
582  AudioSamples decode(const Packet &inPacket, OptionalErrorCode ec = throws());
583  AudioSamples decode(const Packet &inPacket, size_t offset, OptionalErrorCode ec = throws());
584 
585 };
586 
587 
588 class AudioEncoderContext : public AudioCodecContext<AudioEncoderContext, Direction::Encoding>
589 {
590 public:
592  using Parent::Parent;
593 
594  AudioEncoderContext() = default;
596 
598 
599  Packet encode(OptionalErrorCode ec = throws());
600  Packet encode(const AudioSamples &inSamples, OptionalErrorCode ec = throws());
601 
602 };
603 
604 
605 } // namespace av
av::VideoCodecContext::setGlobalQuality
void setGlobalQuality(int32_t quality)
Definition: codeccontext.h:352
av::VideoCodecContext::setGopSize
void setGopSize(int32_t size)
Definition: codeccontext.h:360
av::CodecContext2::clearFlags
void clearFlags(int flags) noexcept
Definition: codeccontext.cpp:705
av::CodecContext2::bitRate
int64_t bitRate() const noexcept
Definition: codeccontext.cpp:667
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:532
av::Rational
Definition: rational.h:24
av::VideoCodecContext::gopSize
int32_t gopSize() const
Definition: codeccontext.h:299
av::Dictionary
Implements interface to access to the AVDictionary entity.
Definition: dictionary.h:30
av::CodecContextBase::moveOperator
Clazz & moveOperator(Clazz &&rhs)
Definition: codeccontext.h:201
averror.h
av::CodecContext2::setRefCountedFrames
void setRefCountedFrames(bool refcounted) const noexcept
Definition: codeccontext.cpp:645
ffmpeg.h
av::CodecContextBase::codecType
AVMediaType codecType() const noexcept
Definition: codeccontext.h:253
pixelformat.h
FFWrapperPtr
Definition: ffmpeg.h:68
av::CodecContext2::timeBase
Rational timeBase() const noexcept
Definition: codeccontext.cpp:578
av::AudioCodecContext::setSampleRate
void setSampleRate(int sampleRate) noexcept
Definition: codeccontext.h:523
av::CodecContext2::CodecContext2
CodecContext2()
Definition: codeccontext.cpp:275
av::VideoCodecContext::setWidth
void setWidth(int w)
Definition: codeccontext.h:319
av::CodecContext2::bitRateRange
std::pair< int64_t, int64_t > bitRateRange() const noexcept
Definition: codeccontext.cpp:672
av::AudioCodecContext::sampleFormat
SampleFormat sampleFormat() const noexcept
Definition: codeccontext.h:502
av::CodecContext2::frameSize
int frameSize() const noexcept
Definition: codeccontext.cpp:622
av::VideoCodecContext::pixelFormat
PixelFormat pixelFormat() const
Definition: codeccontext.h:289
av::CodecContextBase::CodecContextBase
CodecContextBase()
Definition: codeccontext.h:215
av::CodecContext2::setCodec
void setCodec(const class Codec &codec, bool resetDefaults, Direction direction, AVMediaType type, OptionalErrorCode ec=throws())
Definition: codeccontext.cpp:351
av::CodecContext2::codec
Codec codec() const noexcept
Definition: codeccontext.cpp:593
av::VideoCodecContext::codedHeight
int codedHeight() const
Definition: codeccontext.h:284
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:752
codec.h
av::CodecContextBase::setCodec
void setCodec(const Codec &codec, OptionalErrorCode ec=throws())
Definition: codeccontext.h:243
av::VideoCodecContext::height
int height() const
Definition: codeccontext.h:274
av::CodecContext2::isValid
bool isValid() const noexcept
Definition: codeccontext.cpp:526
av::CodecContext2::isFlags2
bool isFlags2(int flags) noexcept
Definition: codeccontext.cpp:745
av::CodecContext2::open
void open(OptionalErrorCode ec=throws())
Definition: codeccontext.cpp:419
av::CodecContextBase
Definition: codeccontext.h:198
av::CodecContext2::flags2
int flags2() noexcept
Definition: codeccontext.cpp:740
av::OptionalErrorCode
Definition: averror.h:63
av::CodecContext2::codecType
AVMediaType codecType(AVMediaType contextType) const noexcept
Definition: codeccontext.cpp:407
av::CodecContext2::strict
int strict() const noexcept
Definition: codeccontext.cpp:652
av::codec_context::audio::get_channel_layout_mask
uint64_t get_channel_layout_mask(const AVCodecContext *obj)
Definition: codeccontext.cpp:1100
av::CodecContext2::flags
int flags() noexcept
Definition: codeccontext.cpp:711
av::codec_context::audio::get_channels
int get_channels(const AVCodecContext *obj)
Definition: codeccontext.cpp:1084
av::VideoCodecContext::setSampleAspectRatio
void setSampleAspectRatio(const Rational &sampleAspectRatio)
Definition: codeccontext.h:375
av::VideoCodecContext::setMaxBFrames
void setMaxBFrames(int maxBFrames)
Definition: codeccontext.h:370
av::VideoCodecContext::codedWidth
int codedWidth() const
Definition: codeccontext.h:279
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:850
av::CodecContext2::setBitRate
void setBitRate(int64_t bitRate) noexcept
Definition: codeccontext.cpp:680
av::AudioCodecContext::setChannels
void setChannels(int channels) noexcept
Definition: codeccontext.h:536
av::CodecContext2::isRefCountedFrames
bool isRefCountedFrames() const noexcept
Definition: codeccontext.cpp:636
avutils.h
RAW_GET
#define RAW_GET(field, def)
Definition: ffmpeg.h:94
av::CodecContext2::setStrict
void setStrict(int strict) noexcept
Definition: codeccontext.cpp:657
av::codec_context::audio::set_channel_layout_mask
void set_channel_layout_mask(AVCodecContext *obj, uint64_t mask)
Definition: codeccontext.cpp:1063
av::VideoCodecContext::sampleAspectRatio
Rational sampleAspectRatio() const
Definition: codeccontext.h:314
av::VideoCodecContext::width
int width() const
Definition: codeccontext.h:269
av::AudioCodecContext::setSampleFormat
void setSampleFormat(SampleFormat sampleFormat) noexcept
Definition: codeccontext.h:543
av::EqualComparator
Definition: avutils.h:303
av::CodecContext2::clearFlags2
void clearFlags2(int flags) noexcept
Definition: codeccontext.cpp:734
av::AudioCodecContext::channels
int channels() const noexcept
Definition: codeccontext.h:495
av::VideoCodecContext::globalQuality
int32_t globalQuality() const
Definition: codeccontext.h:294
avlog.h
stream.h
av::VideoCodecContext::maxBFrames
int maxBFrames() const
Definition: codeccontext.h:309
av::VideoCodecContext::setCodedWidth
void setCodedWidth(int w)
Definition: codeccontext.h:337
av::VideoDecoderContext
Definition: codeccontext.h:386
FFWrapperPtr< AVCodecContext >::_log
void _log(int level, const char *fmt) const
Definition: ffmpeg.h:79
av::CodecContext2::checkCodec
bool checkCodec(const Codec &codec, Direction direction, AVMediaType type, OptionalErrorCode ec)
Definition: codeccontext.cpp:786
av::CodecContext2::~CodecContext2
~CodecContext2()
Definition: codeccontext.cpp:328
av::CodecContextBase::CodecContextBase
CodecContextBase(CodecContextBase &&other)
Definition: codeccontext.h:235
av::AudioCodecContext::setChannelLayout
void setChannelLayout(uint64_t layout) noexcept
Definition: codeccontext.h:548
av::CodecContext2::addFlags
void addFlags(int flags) noexcept
Definition: codeccontext.cpp:699
av::codec_context::audio::set_channels
void set_channels(AVCodecContext *obj, int channels)
Definition: codeccontext.cpp:1048
av::CodecContextBase::CodecContextBase
CodecContextBase(const class Stream &st, const class Codec &codec=Codec())
Definition: codeccontext.h:221
av::noncopyable::operator=
void operator=(const noncopyable &)=delete
frame.h
av::CodecContext2::stream
const Stream & stream() const noexcept
Definition: codeccontext.cpp:588
sampleformat.h
av::CodecContext2
Definition: codeccontext.h:28
av::AudioSamples
Definition: frame.h:391
av::VideoEncoderContext
Definition: codeccontext.h:442
av::CodecContext2::close
void close(OptionalErrorCode ec=throws())
Definition: codeccontext.cpp:508
av::CodecContext2::addFlags2
void addFlags2(int flags) noexcept
Definition: codeccontext.cpp:728
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:179
av::AudioCodecContext::channelLayout
uint64_t channelLayout() const noexcept
Definition: codeccontext.h:507
av::CodecContext2::setFlags
void setFlags(int flags) noexcept
Access to CODEC_FLAG_* flags.
Definition: codeccontext.cpp:694
av::Packet
Definition: packet.h:18
av::CodecContext2::isFlags
bool isFlags(int flags) noexcept
Definition: codeccontext.cpp:716
av::VideoFrame
Definition: frame.h:354
av
Definition: audioresampler.cpp:8
av::AudioEncoderContext
Definition: codeccontext.h:588
std
Definition: averror.h:228
av::AudioCodecContext::sampleRate
int sampleRate() const noexcept
Definition: codeccontext.h:490
av::VideoCodecContext::setHeight
void setHeight(int h)
Definition: codeccontext.h:328
av::noncopyable
Definition: avutils.h:69
av::VideoCodecContext::setPixelFormat
void setPixelFormat(PixelFormat pixelFormat)
Definition: codeccontext.h:347
channellayout.h
av::AudioCodecContext
Definition: codeccontext.h:481
av::VideoCodecContext::bitRateTolerance
int bitRateTolerance() const
Definition: codeccontext.h:304
FFWrapperPtr< AVCodecContext >::m_raw
AVCodecContext * m_raw
Definition: ffmpeg.h:91
av::Direction
Direction
Definition: stream.h:14
av::CodecContext2::setFlags2
void setFlags2(int flags) noexcept
Access to CODEC_FLAG2_* flags.
Definition: codeccontext.cpp:723
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:571
av::Codec
Definition: codec.h:17
av::CodecContext2::frameNumber
int64_t frameNumber() const noexcept
Definition: codeccontext.cpp:627
av::VideoCodecContext
Definition: codeccontext.h:261
av::CodecContext2::swap
void swap(CodecContext2 &other)
Definition: codeccontext.cpp:268
av::VideoCodecContext::setCodedHeight
void setCodedHeight(int h)
Definition: codeccontext.h:342
av::CodecContextBase::CodecContextBase
CodecContextBase(const Codec &codec)
Definition: codeccontext.h:227
RAW_SET
#define RAW_SET(field, val)
Definition: ffmpeg.h:95
av::CodecContext2::isOpened
bool isOpened() const noexcept
Definition: codeccontext.cpp:521
av::VideoCodecContext::setBitRateTolerance
void setBitRateTolerance(int bitRateTolerance)
Definition: codeccontext.h:365
av::guessValue
T guessValue(const T &value, const L *list, C endListComparator)
Select more approptiate value from given value list.
Definition: avutils.h:336
RAW_GET2
#define RAW_GET2(cond, field, def)
Definition: ffmpeg.h:97
av::Stream
Definition: stream.h:22
RAW_SET2
#define RAW_SET2(cond, field, val)
Definition: ffmpeg.h:98
av::CodecContext2::setTimeBase
void setTimeBase(const Rational &value) noexcept
Definition: codeccontext.cpp:583
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:685
av::CodecContextBase::setCodec
void setCodec(const Codec &codec, bool resetDefaults, OptionalErrorCode ec=throws())
Definition: codeccontext.h:248