Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLibavEncoderContext Class Reference

#include <KisLibavEncoderContext.h>

+ Inheritance diagram for KisLibavEncoderContext:

Public Member Functions

bool convertFrame (QImage &inOutImage, AVPixelFormat &outPixelFormat) const
 
SwsContext * getSwsContextFor (int inputWidth, int inputHeight, AVPixelFormat inputFormat, int outputWidth, int outputHeight, AVPixelFormat outputFormat, int flags)
 
int getSwsFlags (const QString &scaleFilter) const
 
 KisLibavEncoderContext (QString *outErrorMessage=nullptr)
 
void setErrorMessage (const QString &errorMessage)
 
void setInternalErrorMessage (const QString &detail)
 
virtual ~KisLibavEncoderContext ()
 

Private Attributes

QString * m_outErrorMessage
 
SwsContext * m_swsContext = nullptr
 

Detailed Description

Definition at line 20 of file KisLibavEncoderContext.h.

Constructor & Destructor Documentation

◆ KisLibavEncoderContext()

KisLibavEncoderContext::KisLibavEncoderContext ( QString * outErrorMessage = nullptr)
inlineexplicit

Definition at line 24 of file KisLibavEncoderContext.h.

25 : m_outErrorMessage(outErrorMessage)
26 {
27 }

◆ ~KisLibavEncoderContext()

virtual KisLibavEncoderContext::~KisLibavEncoderContext ( )
inlinevirtual

Definition at line 29 of file KisLibavEncoderContext.h.

30 {
31 sws_freeContext(m_swsContext);
32 };

References m_swsContext.

Member Function Documentation

◆ convertFrame()

bool KisLibavEncoderContext::convertFrame ( QImage & inOutImage,
AVPixelFormat & outPixelFormat ) const
inline

Definition at line 34 of file KisLibavEncoderContext.h.

35 {
36 switch (inOutImage.format()) {
37 case QImage::Format_RGB32:
38 outPixelFormat = AV_PIX_FMT_BGR0;
39 break;
40 case QImage::Format_ARGB32:
41 outPixelFormat = AV_PIX_FMT_BGRA;
42 break;
43 default:
44 // The above are the only formats I can get the the recorder to
45 // produce, so I'm not gonna get experimental with this.
46 outPixelFormat = AV_PIX_FMT_BGRA;
47 inOutImage = inOutImage.convertToFormat(QImage::Format_ARGB32);
48 if (inOutImage.isNull()) {
49 warnFile << "Frame conversion from" << inOutImage.format() << "failed";
50 return false;
51 }
52 break;
53 }
54 return true;
55 }
#define warnFile
Definition kis_debug.h:99

References warnFile.

◆ getSwsContextFor()

SwsContext * KisLibavEncoderContext::getSwsContextFor ( int inputWidth,
int inputHeight,
AVPixelFormat inputFormat,
int outputWidth,
int outputHeight,
AVPixelFormat outputFormat,
int flags )
inline

Definition at line 76 of file KisLibavEncoderContext.h.

83 {
84 return sws_getCachedContext(m_swsContext,
85 inputWidth,
86 inputHeight,
87 inputFormat,
88 outputWidth,
89 outputHeight,
90 outputFormat,
91 flags,
92 nullptr,
93 nullptr,
94 nullptr);
95 }

References m_swsContext.

◆ getSwsFlags()

int KisLibavEncoderContext::getSwsFlags ( const QString & scaleFilter) const
inline

Definition at line 57 of file KisLibavEncoderContext.h.

58 {
59 // These are the values provided by KisDlgAnimationRenderer.
60 if (scaleFilter.isEmpty() || scaleFilter == QStringLiteral("bilinear")) {
61 return SWS_FAST_BILINEAR;
62 } else if (scaleFilter == QStringLiteral("bicubic")) {
63 return SWS_BICUBIC;
64 } else if (scaleFilter == QStringLiteral("lanczos")) {
65 return SWS_LANCZOS;
66 } else if (scaleFilter == QStringLiteral("neighbor")) {
67 return 0;
68 } else if (scaleFilter == QStringLiteral("spline")) {
69 return SWS_SPLINE;
70 } else {
71 warnFile.nospace() << "Unhandled scale filter '" << scaleFilter << "'";
72 return SWS_FAST_BILINEAR;
73 }
74 }

References warnFile.

◆ setErrorMessage()

void KisLibavEncoderContext::setErrorMessage ( const QString & errorMessage)
inline

Definition at line 105 of file KisLibavEncoderContext.h.

106 {
107 if (m_outErrorMessage) {
108 *m_outErrorMessage = errorMessage;
109 }
110 }

References m_outErrorMessage.

◆ setInternalErrorMessage()

void KisLibavEncoderContext::setInternalErrorMessage ( const QString & detail)
inline

Definition at line 97 of file KisLibavEncoderContext.h.

98 {
99 warnFile << "Media encoder error:" << detail;
100 // Internal encoder errors are only really useful for developers,
101 // so there's no point in translating them.
102 setErrorMessage(i18n("Internal error (%1)", detail));
103 }
void setErrorMessage(const QString &errorMessage)

References setErrorMessage(), and warnFile.

Member Data Documentation

◆ m_outErrorMessage

QString* KisLibavEncoderContext::m_outErrorMessage
private

Definition at line 113 of file KisLibavEncoderContext.h.

◆ m_swsContext

SwsContext* KisLibavEncoderContext::m_swsContext = nullptr
private

Definition at line 114 of file KisLibavEncoderContext.h.


The documentation for this class was generated from the following file: