avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
videorescaler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <memory>
5 
6 #include "ffmpeg.h"
7 #include "frame.h"
8 #include "avutils.h"
9 #include "pixelformat.h"
10 #include "averror.h"
11 
12 namespace av
13 {
14 
16 {
18  SwsFlagFastBilinear = SWS_FAST_BILINEAR,
19  SwsFlagBilinear = SWS_BILINEAR,
20  SwsFlagBicubic = SWS_BICUBIC,
22  SwsFlagNeighbor = SWS_POINT,
23  SwsFlagArea = SWS_AREA,
24  SwsFlagBicublin = SWS_BICUBLIN,
25  SwsFlagGauss = SWS_GAUSS,
26  SwsFlagSinc = SWS_SINC,
27  SwsFlagLanczos = SWS_LANCZOS,
28  SwsFlagSpline = SWS_SPLINE,
29  SwsFlagPrintInfo = SWS_PRINT_INFO,
30  SwsFlagAccurateRnd = SWS_ACCURATE_RND,
31  SwsFlagFullChromaInt = SWS_FULL_CHR_H_INT,
32  SwsFlagFullChromaInp = SWS_FULL_CHR_H_INP,
33  SwsFlagBitexact = SWS_BITEXACT,
34  SwsFlagErrorDiffusion = SWS_ERROR_DIFFUSION,
35 };
36 
37 class VideoRescaler : public FFWrapperPtr<SwsContext>, public noncopyable
38 {
39 public:
40  VideoRescaler();
41 
44  int32_t flags = SwsFlagAuto);
45 
46  VideoRescaler(int m_dstWidth, int m_dstHeight, PixelFormat m_dstPixelFormat, int32_t flags = SwsFlagAuto);
47 
48  VideoRescaler(const VideoRescaler &other);
50 
52 
55 
56  int dstWidth() const { return m_dstWidth; }
57  int dstHeight() const { return m_dstHeight; }
58  PixelFormat dstPixelFormat() { return m_dstPixelFormat; }
59 
60  int srcWidth() const { return m_srcWidth; }
61  int srcHeight() const { return m_srcHeight; }
62  PixelFormat srcPixelFormat() { return m_srcPixelFormat; }
63 
64  int32_t flags() const { return m_flags; }
65 
66  void rescale(VideoFrame &dst, const VideoFrame &src, OptionalErrorCode ec = throws());
67  VideoFrame rescale(const VideoFrame &src, OptionalErrorCode ec = throws());
68 
69  bool isValid() const;
70 
71 private:
72  void swap(VideoRescaler &other) noexcept;
73 
74  void getContext(int32_t flags = 0);
75 
76  static
77  bool validate(int width, int height, PixelFormat pixelFormat);
78 
79 private:
80  int m_dstWidth = -1;
81  int m_dstHeight = -1;
82  PixelFormat m_dstPixelFormat = AV_PIX_FMT_NONE;
83 
84  int m_srcWidth = -1;
85  int m_srcHeight = -1;
86  PixelFormat m_srcPixelFormat = AV_PIX_FMT_NONE;
87 
88  int32_t m_flags = SwsFlagAuto;
89 };
90 
91 } // ::av
92 
av::SwsFlagAuto
@ SwsFlagAuto
Definition: videorescaler.h:17
av::VideoRescaler::dstWidth
int dstWidth() const
Definition: videorescaler.h:56
av::VideoRescaler::dstHeight
int dstHeight() const
Definition: videorescaler.h:57
av::SwsFlagFastBilinear
@ SwsFlagFastBilinear
Definition: videorescaler.h:18
averror.h
av::SwsFlagSinc
@ SwsFlagSinc
Definition: videorescaler.h:26
ffmpeg.h
pixelformat.h
av::VideoRescaler::srcWidth
int srcWidth() const
Definition: videorescaler.h:60
FFWrapperPtr
Definition: ffmpeg.h:68
av::SwsFlagNeighbor
@ SwsFlagNeighbor
Definition: videorescaler.h:22
av::SwsFlagPrintInfo
@ SwsFlagPrintInfo
Definition: videorescaler.h:29
av::SwsFlagAccurateRnd
@ SwsFlagAccurateRnd
Definition: videorescaler.h:30
av::SwsFlagBitexact
@ SwsFlagBitexact
Definition: videorescaler.h:33
av::VideoRescaler::srcHeight
int srcHeight() const
Definition: videorescaler.h:61
av::SwsFlagFullChromaInp
@ SwsFlagFullChromaInp
Definition: videorescaler.h:32
av::OptionalErrorCode
Definition: averror.h:63
av::SwsFlagSpline
@ SwsFlagSpline
Definition: videorescaler.h:28
av::SwsFlagBicubic
@ SwsFlagBicubic
Definition: videorescaler.h:20
avutils.h
av::SwsFlagBilinear
@ SwsFlagBilinear
Definition: videorescaler.h:19
av::VideoRescaler::rescale
void rescale(VideoFrame &dst, const VideoFrame &src, OptionalErrorCode ec=throws())
Definition: videorescaler.cpp:119
av::VideoRescaler::VideoRescaler
VideoRescaler()
Definition: videorescaler.cpp:10
frame.h
av::VideoRescaler::operator=
VideoRescaler & operator=(const VideoRescaler &rhs)
Definition: videorescaler.cpp:104
av::SwsFlagFullChromaInt
@ SwsFlagFullChromaInt
Definition: videorescaler.h:31
av::SwsFlagBicublin
@ SwsFlagBicublin
Definition: videorescaler.h:24
av::PixelFormat
The PixelFormat class is a simple wrapper for AVPixelFormat that allow to acces it it properties.
Definition: pixelformat.h:26
av::SwsFlagArea
@ SwsFlagArea
Definition: videorescaler.h:23
av::SwsFlagExprerimental
@ SwsFlagExprerimental
Definition: videorescaler.h:21
av::VideoFrame
Definition: frame.h:354
av
Definition: audioresampler.cpp:8
av::noncopyable
Definition: avutils.h:69
av::SwsFlagGauss
@ SwsFlagGauss
Definition: videorescaler.h:25
av::SwsFlagErrorDiffusion
@ SwsFlagErrorDiffusion
Definition: videorescaler.h:34
av::SwsFlagLanczos
@ SwsFlagLanczos
Definition: videorescaler.h:27
av::VideoRescaler::~VideoRescaler
~VideoRescaler()
Definition: videorescaler.cpp:53
av::VideoRescaler::dstPixelFormat
PixelFormat dstPixelFormat()
Definition: videorescaler.h:58
av::SwsFlags
SwsFlags
Definition: videorescaler.h:15
av::VideoRescaler
Definition: videorescaler.h:37
av::VideoRescaler::isValid
bool isValid() const
Definition: videorescaler.cpp:183
av::VideoRescaler::srcPixelFormat
PixelFormat srcPixelFormat()
Definition: videorescaler.h:62
av::VideoRescaler::flags
int32_t flags() const
Definition: videorescaler.h:64