From 42c74d481ea1e75b4727a1863a8411c04e9104d3 Mon Sep 17 00:00:00 2001 From: Ashik Salim Date: Sun, 8 Apr 2018 03:28:02 +0530 Subject: [PATCH 1/5] move attribute_deprecated to before function prototype --- src/frame.h | 2 +- src/packet.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frame.h b/src/frame.h index 785b0d06..50c41fc8 100644 --- a/src/frame.h +++ b/src/frame.h @@ -134,7 +134,7 @@ class Frame : public FFWrapperPtr return {RAW_GET(pts, AV_NOPTS_VALUE), m_timeBase}; } - void setPts(int64_t pts, Rational ptsTimeBase) attribute_deprecated + attribute_deprecated void setPts(int64_t pts, Rational ptsTimeBase) { RAW_SET(pts, ptsTimeBase.rescale(pts, m_timeBase)); } diff --git a/src/packet.h b/src/packet.h index 040b7b0c..aff0ea96 100644 --- a/src/packet.h +++ b/src/packet.h @@ -53,8 +53,8 @@ class Packet : public FFWrapperRef * @param tsTimeBase is a time base of setted timestamp, can be omited or sets to Rational(0,0) * that means that time base equal to packet time base. */ - void setPts(int64_t pts, const Rational &tsTimeBase = Rational(0, 0)) attribute_deprecated; - void setDts(int64_t dts, const Rational &tsTimeBase = Rational(0, 0)) attribute_deprecated; + attribute_deprecated void setPts(int64_t pts, const Rational &tsTimeBase = Rational(0, 0)); + attribute_deprecated void setDts(int64_t dts, const Rational &tsTimeBase = Rational(0, 0)); void setPts(const Timestamp &pts); void setDts(const Timestamp &dts); From b186aa4a769dbdc2ec0b714ab419e6ca8282f679 Mon Sep 17 00:00:00 2001 From: Ashik Salim Date: Sun, 8 Apr 2018 03:28:56 +0530 Subject: [PATCH 2/5] fix a missing header needed for std min, max --- src/timestamp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/timestamp.cpp b/src/timestamp.cpp index 8a9106b4..07c11d52 100644 --- a/src/timestamp.cpp +++ b/src/timestamp.cpp @@ -1,3 +1,4 @@ +#include #include #include "timestamp.h" From adf0da5e97e403982ffff59ebf7bbb9a28f4ff10 Mon Sep 17 00:00:00 2001 From: Ashik Salim Date: Sun, 8 Apr 2018 03:30:51 +0530 Subject: [PATCH 3/5] replace ssize_t with int --- src/codeccontext.cpp | 12 ++++++------ src/codeccontext.h | 8 ++++---- src/formatcontext.cpp | 2 +- src/formatcontext.h | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/codeccontext.cpp b/src/codeccontext.cpp index 0e7f1cf4..78061bd2 100644 --- a/src/codeccontext.cpp +++ b/src/codeccontext.cpp @@ -11,14 +11,14 @@ using namespace std; namespace av { namespace { -std::pair +std::pair make_error_pair(Errors errc) { - return make_pair(static_cast(errc), &avcpp_category()); + return make_pair(static_cast(errc), &avcpp_category()); } -std::pair -make_error_pair(ssize_t status) +std::pair +make_error_pair(int status) { if (status < 0) return make_pair(status, &ffmpeg_category()); @@ -725,7 +725,7 @@ void CodecContext2::open(const Codec &codec, AVDictionary **options, OptionalErr throws_if(ec, stat, ffmpeg_category()); } -std::pair CodecContext2::decodeCommon(AVFrame *outFrame, const Packet &inPacket, size_t offset, int &frameFinished, int (*decodeProc)(AVCodecContext *, AVFrame *, int *, const AVPacket *)) noexcept +std::pair CodecContext2::decodeCommon(AVFrame *outFrame, const Packet &inPacket, size_t offset, int &frameFinished, int (*decodeProc)(AVCodecContext *, AVFrame *, int *, const AVPacket *)) noexcept { if (!isValid()) return make_error_pair(Errors::CodecInvalid); @@ -749,7 +749,7 @@ std::pair CodecContext2::decodeCommon(AVFrame * return make_error_pair(decoded); } -std::pair CodecContext2::encodeCommon(Packet &outPacket, const AVFrame *inFrame, int &gotPacket, int (*encodeProc)(AVCodecContext *, AVPacket *, const AVFrame *, int *)) noexcept +std::pair CodecContext2::encodeCommon(Packet &outPacket, const AVFrame *inFrame, int &gotPacket, int (*encodeProc)(AVCodecContext *, AVPacket *, const AVFrame *, int *)) noexcept { if (!isValid()) { fflog(AV_LOG_ERROR, "Invalid context\n"); diff --git a/src/codeccontext.h b/src/codeccontext.h index 90a690fd..a2fe4752 100644 --- a/src/codeccontext.h +++ b/src/codeccontext.h @@ -132,17 +132,17 @@ class CodecContext2 : public FFWrapperPtr, public noncopyable void open(const Codec &codec, AVDictionary **options, OptionalErrorCode ec); - std::pair + std::pair decodeCommon(AVFrame *outFrame, const Packet &inPacket, size_t offset, int &frameFinished, int (*decodeProc)(AVCodecContext*, AVFrame*,int *, const AVPacket *)) noexcept; - std::pair + std::pair encodeCommon(Packet &outPacket, const AVFrame *inFrame, int &gotPacket, int (*encodeProc)(AVCodecContext*, AVPacket*,const AVFrame*, int*)) noexcept; public: template - std::pair + std::pair decodeCommon(T &outFrame, const Packet &inPacket, size_t offset, @@ -191,7 +191,7 @@ class CodecContext2 : public FFWrapperPtr, public noncopyable } template - std::pair + std::pair encodeCommon(Packet &outPacket, const T &inFrame, int &gotPacket, diff --git a/src/formatcontext.cpp b/src/formatcontext.cpp index a8caa160..6e91a83f 100644 --- a/src/formatcontext.cpp +++ b/src/formatcontext.cpp @@ -931,7 +931,7 @@ void FormatContext::closeCodecContexts() #endif } -ssize_t FormatContext::checkPbError(ssize_t stat) +int FormatContext::checkPbError(int stat) { // WORKAROUND: a lot of format specific writer_packet() functions always return zero code // and av_write_frame() in FFMPEG prio 1.0 does not contain follow wrapper diff --git a/src/formatcontext.h b/src/formatcontext.h index f4fb4533..ed544ebd 100644 --- a/src/formatcontext.h +++ b/src/formatcontext.h @@ -27,13 +27,13 @@ using AvioInterruptCb = std::function; struct CustomIO { virtual ~CustomIO() {} - virtual ssize_t write(const uint8_t *data, size_t size) + virtual int write(const uint8_t *data, size_t size) { static_cast(data); static_cast(size); return -1; } - virtual ssize_t read(uint8_t *data, size_t size) + virtual int read(uint8_t *data, size_t size) { static_cast(data); static_cast(size); @@ -202,7 +202,7 @@ class FormatContext : public FFWrapperPtr, public noncopyable void resetSocketAccess(); void findStreamInfo(AVDictionary **options, size_t optionsCount, OptionalErrorCode ec); void closeCodecContexts(); - ssize_t checkPbError(ssize_t stat); + int checkPbError(int stat); void openCustomIO(CustomIO *io, size_t internalBufferSize, bool isWritable, OptionalErrorCode ec); void openCustomIOInput(CustomIO *io, size_t internalBufferSize, OptionalErrorCode ec); From 492bb51bc41cfbf08185e4fbbbcd5e6b54159399 Mon Sep 17 00:00:00 2001 From: Ashik Salim Date: Sun, 8 Apr 2018 03:31:12 +0530 Subject: [PATCH 4/5] fix an invalid argument type in MSVC --- src/dictionary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dictionary.h b/src/dictionary.h index a83f752f..14fdd399 100644 --- a/src/dictionary.h +++ b/src/dictionary.h @@ -63,7 +63,7 @@ class Dictionary : public FFWrapperPtr */ struct RawStringDeleter { - void operator()(char *&ptr) + void operator()(char *ptr) { av_freep(&ptr); } From cd01f3d089757d3aa13152fd963a16e4232f32bc Mon Sep 17 00:00:00 2001 From: Ashik Salim Date: Sun, 8 Apr 2018 03:31:45 +0530 Subject: [PATCH 5/5] add a cpp style definition for AV_TIME_BASE_Q --- src/formatcontext.cpp | 8 ++++---- src/rational.h | 2 ++ src/timestamp.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/formatcontext.cpp b/src/formatcontext.cpp index 6e91a83f..e453d8a3 100644 --- a/src/formatcontext.cpp +++ b/src/formatcontext.cpp @@ -240,7 +240,7 @@ bool FormatContext::seekable() const noexcept void FormatContext::seek(const Timestamp ×tamp, OptionalErrorCode ec) { - seek(timestamp.timestamp(AV_TIME_BASE_Q), -1, 0, ec); + seek(timestamp.timestamp(AV_TIME_BASE_Q_CPP), -1, 0, ec); } void FormatContext::seek(const Timestamp& timestamp, size_t streamIndex, OptionalErrorCode ec) @@ -252,7 +252,7 @@ void FormatContext::seek(const Timestamp& timestamp, size_t streamIndex, Optiona void FormatContext::seek(const Timestamp& timestamp, bool anyFrame, OptionalErrorCode ec) { - seek(timestamp.timestamp(AV_TIME_BASE_Q), -1, anyFrame ? AVSEEK_FLAG_ANY : 0, ec); + seek(timestamp.timestamp(AV_TIME_BASE_Q_CPP), -1, anyFrame ? AVSEEK_FLAG_ANY : 0, ec); } void FormatContext::seek(const Timestamp ×tamp, size_t streamIndex, bool anyFrame, OptionalErrorCode ec) @@ -278,7 +278,7 @@ Timestamp FormatContext::startTime() const noexcept return {}; } - return {m_raw->start_time, AV_TIME_BASE_Q}; + return {m_raw->start_time, AV_TIME_BASE_Q_CPP}; } int FormatContext::eventFlags() const noexcept @@ -320,7 +320,7 @@ Timestamp FormatContext::duration() const noexcept duration += (m_raw->duration <= INT64_MAX - 5000 ? 5000 : 0); } - return {duration, AV_TIME_BASE_Q}; + return {duration, AV_TIME_BASE_Q_CPP}; }; void FormatContext::openInput(const string &uri, OptionalErrorCode ec) diff --git a/src/rational.h b/src/rational.h index add3c413..bbf417ea 100644 --- a/src/rational.h +++ b/src/rational.h @@ -10,6 +10,8 @@ namespace av { +#define AV_TIME_BASE_Q_CPP AVRational{1, AV_TIME_BASE} + enum { RationalMaxPrecision = 5 diff --git a/src/timestamp.h b/src/timestamp.h index bb8dfb10..2edfb2f3 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -67,7 +67,7 @@ class Timestamp private: int64_t m_timestamp = AV_NOPTS_VALUE; - Rational m_timebase = AV_TIME_BASE_Q; + Rational m_timebase = AV_TIME_BASE_Q_CPP; };