From deef359d9b6add8101035104b41768c38037bced Mon Sep 17 00:00:00 2001 From: "Alexander S. Drozdov" Date: Mon, 18 Apr 2016 17:33:25 +1000 Subject: [PATCH] Rename Stream2, Frame2, VideoFrame2 and AudioSamples2 Remove 2 from the end and provide alias types. --- example/api2-samples/api2-decode-audio.cpp | 4 +- .../api2-samples/api2-decode-encode-audio.cpp | 10 +-- .../api2-samples/api2-decode-encode-video.cpp | 4 +- .../api2-decode-rasample-audio.cpp | 10 +-- example/api2-samples/api2-decode.cpp | 6 +- example/api2-samples/api2-scale-video.cpp | 6 +- src/audioresampler.cpp | 18 ++--- src/audioresampler.h | 6 +- src/codeccontext.cpp | 34 ++++----- src/codeccontext.h | 20 +++--- src/filters/buffersink.cpp | 10 +-- src/filters/buffersink.h | 10 +-- src/filters/buffersrc.cpp | 12 ++-- src/filters/buffersrc.h | 12 ++-- src/formatcontext.cpp | 30 ++++---- src/formatcontext.h | 16 ++--- src/frame.cpp | 70 +++++++++---------- src/frame.h | 57 ++++++++------- src/packet.cpp | 2 +- src/packet.h | 4 +- src/stream.cpp | 38 +++++----- src/stream.h | 8 ++- src/videorescaler.cpp | 6 +- src/videorescaler.h | 4 +- 24 files changed, 201 insertions(+), 196 deletions(-) diff --git a/example/api2-samples/api2-decode-audio.cpp b/example/api2-samples/api2-decode-audio.cpp index 62092bb5..eba8e799 100644 --- a/example/api2-samples/api2-decode-audio.cpp +++ b/example/api2-samples/api2-decode-audio.cpp @@ -33,7 +33,7 @@ int main(int argc, char **argv) ssize_t audioStream = -1; CodecContext adec; - Stream2 ast; + Stream ast; error_code ec; string format; @@ -120,7 +120,7 @@ int main(int argc, char **argv) clog << "Read packet: " << pkt.pts() << " / " << pkt.pts().seconds() << " / " << pkt.timeBase() << " / st: " << pkt.streamIndex() << endl; - AudioSamples2 samples = adec.decodeAudio(pkt, ec); + AudioSamples samples = adec.decodeAudio(pkt, ec); if (ec) { cerr << "Error: " << ec << endl; diff --git a/example/api2-samples/api2-decode-encode-audio.cpp b/example/api2-samples/api2-decode-encode-audio.cpp index b749b4e0..9bbfaa9e 100644 --- a/example/api2-samples/api2-decode-encode-audio.cpp +++ b/example/api2-samples/api2-decode-encode-audio.cpp @@ -34,7 +34,7 @@ int main(int argc, char **argv) ssize_t audioStream = -1; CodecContext adec; - Stream2 ast; + Stream ast; error_code ec; int count = 0; @@ -98,7 +98,7 @@ int main(int argc, char **argv) octx.setFormat(ofmt); Codec ocodec = av::findEncodingCodec(ofmt, false); - Stream2 ost = octx.addStream(ocodec); + Stream ost = octx.addStream(ocodec); CodecContext enc (ost); clog << ocodec.name() << " / " << ocodec.longName() << ", audio: " << (ocodec.type()==AVMEDIA_TYPE_AUDIO) << '\n'; @@ -202,7 +202,7 @@ int main(int argc, char **argv) } #endif - AudioSamples2 samples = adec.decodeAudio(pkt, ec); + AudioSamples samples = adec.decodeAudio(pkt, ec); count++; //if (count > 200) // break; @@ -241,7 +241,7 @@ int main(int argc, char **argv) // Pop resampler data bool getAll = !samples; while (true) { - AudioSamples2 ouSamples(enc.sampleFormat(), + AudioSamples ouSamples(enc.sampleFormat(), enc.frameSize(), enc.channelLayout(), enc.sampleRate()); @@ -301,7 +301,7 @@ int main(int argc, char **argv) // clog << "Flush encoder:\n"; while (true) { - AudioSamples2 null(nullptr); + AudioSamples null(nullptr); Packet opkt = enc.encodeAudio(null, ec); if (ec || !opkt) break; diff --git a/example/api2-samples/api2-decode-encode-video.cpp b/example/api2-samples/api2-decode-encode-video.cpp index 3901cb72..0020b190 100644 --- a/example/api2-samples/api2-decode-encode-video.cpp +++ b/example/api2-samples/api2-decode-encode-video.cpp @@ -40,7 +40,7 @@ int main(int argc, char **argv) FormatContext ictx; ssize_t videoStream = -1; CodecContext vdec; - Stream2 vst; + Stream vst; int count = 0; @@ -88,7 +88,7 @@ int main(int argc, char **argv) octx.setFormat(ofrmt); Codec ocodec = findEncodingCodec(ofrmt); - Stream2 ost = octx.addStream(ocodec); + Stream ost = octx.addStream(ocodec); CodecContext encoder {ost}; // Settings diff --git a/example/api2-samples/api2-decode-rasample-audio.cpp b/example/api2-samples/api2-decode-rasample-audio.cpp index 16a55390..979d4c08 100644 --- a/example/api2-samples/api2-decode-rasample-audio.cpp +++ b/example/api2-samples/api2-decode-rasample-audio.cpp @@ -33,7 +33,7 @@ int main(int argc, char **argv) ssize_t audioStream = -1; CodecContext adec; - Stream2 ast; + Stream ast; error_code ec; int count = 0; @@ -114,7 +114,7 @@ int main(int argc, char **argv) clog << "Read packet: " << pkt.pts() << " / " << pkt.pts().seconds() << " / " << pkt.timeBase() << " / st: " << pkt.streamIndex() << endl; - AudioSamples2 samples = adec.decodeAudio(pkt, ec); + AudioSamples samples = adec.decodeAudio(pkt, ec); count++; if (count > 100) @@ -145,7 +145,7 @@ int main(int argc, char **argv) // Pop resampler data #if 0 while (true) { - AudioSamples2 ouSamples(adec.sampleFormat(), samples.samplesCount()/2, adec.channelLayout(), 48000); + AudioSamples ouSamples(adec.sampleFormat(), samples.samplesCount()/2, adec.channelLayout(), 48000); // Resample: //st = resampler.resample(ouSamples, samples); @@ -165,7 +165,7 @@ int main(int argc, char **argv) << endl; } #else - auto ouSamples = AudioSamples2::null(); + auto ouSamples = AudioSamples::null(); while (ouSamples = resampler.pop(samples.samplesCount()/2, ec)) { clog << " Samples [ou]: " << ouSamples.samplesCount() << ", ch: " << ouSamples.channelsCount() @@ -186,7 +186,7 @@ int main(int argc, char **argv) { clog << "Flush resampler:\n"; while (true) { - AudioSamples2 ouSamples(adec.sampleFormat(), 576, adec.channelLayout(), 48000); + AudioSamples ouSamples(adec.sampleFormat(), 576, adec.channelLayout(), 48000); auto hasFrame = resampler.pop(ouSamples, false, ec); if (!ec && !hasFrame) hasFrame = resampler.pop(ouSamples, true, ec); diff --git a/example/api2-samples/api2-decode.cpp b/example/api2-samples/api2-decode.cpp index 8ae068a1..3d0c871c 100644 --- a/example/api2-samples/api2-decode.cpp +++ b/example/api2-samples/api2-decode.cpp @@ -33,7 +33,7 @@ int main(int argc, char **argv) ssize_t videoStream = -1; CodecContext vdec; - Stream2 vst; + Stream vst; error_code ec; int count = 0; @@ -103,7 +103,7 @@ int main(int argc, char **argv) auto ts = pkt.ts(); clog << "Read packet: " << ts << " / " << ts.seconds() << " / " << pkt.timeBase() << " / st: " << pkt.streamIndex() << endl; - VideoFrame2 frame = vdec.decodeVideo(pkt, ec); + VideoFrame frame = vdec.decodeVideo(pkt, ec); count++; //if (count > 100) @@ -125,7 +125,7 @@ int main(int argc, char **argv) clog << "Flush frames;\n"; while (true) { - VideoFrame2 frame = vdec.decodeVideo(Packet(), ec); + VideoFrame frame = vdec.decodeVideo(Packet(), ec); if (ec) { cerr << "Error: " << ec << ", " << ec.message() << endl; return 1; diff --git a/example/api2-samples/api2-scale-video.cpp b/example/api2-samples/api2-scale-video.cpp index 7e693b54..42d1ce53 100644 --- a/example/api2-samples/api2-scale-video.cpp +++ b/example/api2-samples/api2-scale-video.cpp @@ -43,7 +43,7 @@ int main(int argc, char **argv) FormatContext ictx; ssize_t videoStream = -1; CodecContext vdec; - Stream2 vst; + Stream vst; int count = 0; @@ -97,7 +97,7 @@ int main(int argc, char **argv) octx.setFormat(ofrmt); Codec ocodec = findEncodingCodec(ofrmt); - Stream2 ost = octx.addStream(ocodec); + Stream ost = octx.addStream(ocodec); CodecContext encoder {ost}; // Settings @@ -182,7 +182,7 @@ int main(int argc, char **argv) clog << "inpFrame: pts=" << inpFrame.pts() << " / " << inpFrame.pts().seconds() << " / " << inpFrame.timeBase() << ", " << inpFrame.width() << "x" << inpFrame.height() << ", size=" << inpFrame.size() << ", ref=" << inpFrame.isReferenced() << ":" << inpFrame.refCount() << " / type: " << inpFrame.pictureType() << endl; // SCALE - //VideoFrame2 outFrame {encoder.pixelFormat(), encoder.width(), encoder.height()}; + //VideoFrame outFrame {encoder.pixelFormat(), encoder.width(), encoder.height()}; //rescaler.rescale(outFrame, inpFrame, ec); auto outFrame = rescaler.rescale(inpFrame, ec); if (ec) { diff --git a/src/audioresampler.cpp b/src/audioresampler.cpp index 1b77269d..9fc18f9b 100644 --- a/src/audioresampler.cpp +++ b/src/audioresampler.cpp @@ -117,7 +117,7 @@ SampleFormat AudioResampler::srcSampleFormat() const return m_srcFormat; } -bool AudioResampler::pop(AudioSamples2 &dst, bool getall, error_code &ec) +bool AudioResampler::pop(AudioSamples &dst, bool getall, error_code &ec) { clear_if(ec); @@ -170,7 +170,7 @@ bool AudioResampler::pop(AudioSamples2 &dst, bool getall, error_code &ec) return dst.samplesCount() ? true : false; } -AudioSamples2 AudioResampler::pop(size_t samplesCount, error_code &ec) +AudioSamples AudioResampler::pop(size_t samplesCount, error_code &ec) { clear_if(ec); @@ -178,7 +178,7 @@ AudioSamples2 AudioResampler::pop(size_t samplesCount, error_code &ec) { fflog(AV_LOG_ERROR, "SwrContext does not inited\n"); throws_if(ec, Errors::ResamplerNotInited); - return AudioSamples2(nullptr); + return AudioSamples(nullptr); } auto delay = swr_get_delay(m_raw, m_dstRate); @@ -186,24 +186,24 @@ AudioSamples2 AudioResampler::pop(size_t samplesCount, error_code &ec) // Need more data if ((size_t)delay < samplesCount && samplesCount) { - return AudioSamples2(nullptr); + return AudioSamples(nullptr); } if (!samplesCount) samplesCount = delay; // Request all samples - AudioSamples2 dst(dstSampleFormat(), samplesCount, dstChannelLayout(), dstSampleRate()); + AudioSamples dst(dstSampleFormat(), samplesCount, dstChannelLayout(), dstSampleRate()); if (!dst.isValid()) { throws_if(ec, Errors::CantAllocateFrame); - return AudioSamples2(nullptr); + return AudioSamples(nullptr); } auto sts = swr_convert_frame(m_raw, dst.raw(), nullptr); if (sts < 0) { throws_if(ec, sts, ffmpeg_category()); - return AudioSamples2(nullptr); + return AudioSamples(nullptr); } dst.setTimeBase(Rational(1, m_dstRate)); @@ -217,10 +217,10 @@ AudioSamples2 AudioResampler::pop(size_t samplesCount, error_code &ec) dst.setPts(m_nextPts); m_nextPts = dst.pts() + Timestamp(dst.samplesCount(), dst.timeBase()); - return dst.samplesCount() ? std::move(dst) : AudioSamples2::null(); + return dst.samplesCount() ? std::move(dst) : AudioSamples::null(); } -void AudioResampler::push(const AudioSamples2 &src, error_code &ec) +void AudioResampler::push(const AudioSamples &src, error_code &ec) { if (!m_raw) { diff --git a/src/audioresampler.h b/src/audioresampler.h index ab3f8907..557b21e0 100644 --- a/src/audioresampler.h +++ b/src/audioresampler.h @@ -55,7 +55,7 @@ class AudioResampler : public FFWrapperPtr, public noncopyable * @param[in,out] ec this represents the error status on exit, if this is pre-initialized to * av#throws the function will throw on error instead */ - void push(const AudioSamples2 &src, std::error_code &ec = throws()); + void push(const AudioSamples &src, std::error_code &ec = throws()); /** * @brief Pop frame from the rescaler context. @@ -71,7 +71,7 @@ class AudioResampler : public FFWrapperPtr, public noncopyable * av#throws the function will throw on error instead * @return false if no samples avail, true otherwise. On error false. */ - bool pop(AudioSamples2 &dst, bool getall, std::error_code &ec = throws()); + bool pop(AudioSamples &dst, bool getall, std::error_code &ec = throws()); /** * @brief Pop frame from the rescaler context. @@ -86,7 +86,7 @@ class AudioResampler : public FFWrapperPtr, public noncopyable * av#throws the function will throw on error instead * @return resampled samples or null-frame when no requested samples avail. On error null-frame. */ - AudioSamples2 pop(size_t samplesCount, std::error_code &ec = throws()); + AudioSamples pop(size_t samplesCount, std::error_code &ec = throws()); bool isValid() const; operator bool() const { return isValid(); } diff --git a/src/codeccontext.cpp b/src/codeccontext.cpp index 7782b7f3..2ea6ccb4 100644 --- a/src/codeccontext.cpp +++ b/src/codeccontext.cpp @@ -19,7 +19,7 @@ CodecContext::CodecContext() m_raw = avcodec_alloc_context3(nullptr); } -CodecContext::CodecContext(const Stream2 &st, const Codec &codec) +CodecContext::CodecContext(const Stream &st, const Codec &codec) : m_stream(st) { m_raw = st.raw()->codec; @@ -253,7 +253,7 @@ void CodecContext::setTimeBase(const Rational &value) RAW_SET2(isValid(), time_base, value.getValue()); } -const Stream2 &CodecContext::stream() const +const Stream &CodecContext::stream() const { return m_stream; } @@ -626,26 +626,26 @@ bool CodecContext::isFlags2(int flags) return false; } -VideoFrame2 CodecContext::decodeVideo(const Packet &packet, error_code &ec, bool autoAllocateFrame) +VideoFrame CodecContext::decodeVideo(const Packet &packet, error_code &ec, bool autoAllocateFrame) { return decodeVideo(ec, packet, 0, nullptr, autoAllocateFrame); } -VideoFrame2 CodecContext::decodeVideo(const Packet &packet, size_t offset, size_t &decodedBytes, error_code &ec, bool autoAllocateFrame) +VideoFrame CodecContext::decodeVideo(const Packet &packet, size_t offset, size_t &decodedBytes, error_code &ec, bool autoAllocateFrame) { return decodeVideo(ec, packet, offset, &decodedBytes, autoAllocateFrame); } Packet CodecContext::encodeVideo(error_code &ec) { - return encodeVideo(VideoFrame2(nullptr), ec); + return encodeVideo(VideoFrame(nullptr), ec); } -VideoFrame2 CodecContext::decodeVideo(error_code &ec, const Packet &packet, size_t offset, size_t *decodedBytes, bool autoAllocateFrame) +VideoFrame CodecContext::decodeVideo(error_code &ec, const Packet &packet, size_t offset, size_t *decodedBytes, bool autoAllocateFrame) { clear_if(ec); - VideoFrame2 outFrame; + VideoFrame outFrame; if (!autoAllocateFrame) { outFrame = {pixelFormat(), width(), height(), 32}; @@ -653,7 +653,7 @@ VideoFrame2 CodecContext::decodeVideo(error_code &ec, const Packet &packet, size if (!outFrame.isValid()) { throws_if(ec, Errors::FrameInvalid); - return VideoFrame2(); + return VideoFrame(); } } @@ -662,11 +662,11 @@ VideoFrame2 CodecContext::decodeVideo(error_code &ec, const Packet &packet, size if (get<1>(st)) { throws_if(ec, get<0>(st), *get<1>(st)); - return VideoFrame2(); + return VideoFrame(); } if (!gotFrame) - return VideoFrame2(); + return VideoFrame(); outFrame.setPictureType(AV_PICTURE_TYPE_I); @@ -677,7 +677,7 @@ VideoFrame2 CodecContext::decodeVideo(error_code &ec, const Packet &packet, size } -Packet CodecContext::encodeVideo(const VideoFrame2 &inFrame, error_code &ec) +Packet CodecContext::encodeVideo(const VideoFrame &inFrame, error_code &ec) { clear_if(ec); @@ -703,23 +703,23 @@ Packet CodecContext::encodeVideo(const VideoFrame2 &inFrame, error_code &ec) return packet; } -AudioSamples2 CodecContext::decodeAudio(const Packet &inPacket, error_code &ec) +AudioSamples CodecContext::decodeAudio(const Packet &inPacket, error_code &ec) { return decodeAudio(inPacket, 0, ec); } -AudioSamples2 CodecContext::decodeAudio(const Packet &inPacket, size_t offset, error_code &ec) +AudioSamples CodecContext::decodeAudio(const Packet &inPacket, size_t offset, error_code &ec) { clear_if(ec); - AudioSamples2 outSamples; + AudioSamples outSamples; int gotFrame = 0; auto st = decodeCommon(outSamples, inPacket, offset, gotFrame, avcodec_decode_audio4); if (get<1>(st)) { throws_if(ec, get<0>(st), *get<1>(st)); - return AudioSamples2(); + return AudioSamples(); } if (!gotFrame) @@ -737,10 +737,10 @@ AudioSamples2 CodecContext::decodeAudio(const Packet &inPacket, size_t offset, e Packet CodecContext::encodeAudio(error_code &ec) { - return encodeAudio(AudioSamples2(nullptr), ec); + return encodeAudio(AudioSamples(nullptr), ec); } -Packet CodecContext::encodeAudio(const AudioSamples2 &inSamples, error_code &ec) +Packet CodecContext::encodeAudio(const AudioSamples &inSamples, error_code &ec) { clear_if(ec); diff --git a/src/codeccontext.h b/src/codeccontext.h index fd349b38..c67ff908 100644 --- a/src/codeccontext.h +++ b/src/codeccontext.h @@ -25,7 +25,7 @@ class CodecContext : public FFWrapperPtr, public noncopyable public: CodecContext(); // Stream decoding/encoding - explicit CodecContext(const Stream2 &st, const Codec& codec = Codec()); + explicit CodecContext(const Stream &st, const Codec& codec = Codec()); // Stream independ decoding/encoding explicit CodecContext(const Codec &codec); ~CodecContext(); @@ -66,7 +66,7 @@ class CodecContext : public FFWrapperPtr, public noncopyable Rational timeBase() const; void setTimeBase(const Rational &value); - const Stream2& stream() const; + const Stream& stream() const; Codec codec() const; AVMediaType codecType() const; @@ -158,7 +158,7 @@ class CodecContext : public FFWrapperPtr, public noncopyable * @return encoded video frame, if error: exception thrown or error code returns, in both cases * output undefined. */ - VideoFrame2 decodeVideo(const Packet &packet, + VideoFrame decodeVideo(const Packet &packet, std::error_code &ec = throws(), bool autoAllocateFrame = true); @@ -175,7 +175,7 @@ class CodecContext : public FFWrapperPtr, public noncopyable * @return encoded video frame, if error: exception thrown or error code returns, in both cases * output undefined. */ - VideoFrame2 decodeVideo(const Packet &packet, + VideoFrame decodeVideo(const Packet &packet, size_t offset, size_t &decodedBytes, std::error_code &ec = throws(), @@ -203,23 +203,23 @@ class CodecContext : public FFWrapperPtr, public noncopyable * av#throws the function will throw on error instead * @return */ - Packet encodeVideo(const VideoFrame2 &inFrame, std::error_code &ec = throws()); + Packet encodeVideo(const VideoFrame &inFrame, std::error_code &ec = throws()); // // Audio // - AudioSamples2 decodeAudio(const Packet &inPacket, std::error_code &ec = throws()); - AudioSamples2 decodeAudio(const Packet &inPacket, size_t offset, std::error_code &ec = throws()); + AudioSamples decodeAudio(const Packet &inPacket, std::error_code &ec = throws()); + AudioSamples decodeAudio(const Packet &inPacket, size_t offset, std::error_code &ec = throws()); Packet encodeAudio(std::error_code &ec = throws()); - Packet encodeAudio(const AudioSamples2 &inSamples, std::error_code &ec = throws()); + Packet encodeAudio(const AudioSamples &inSamples, std::error_code &ec = throws()); bool isValidForEncode(); private: void open(const Codec &codec, AVDictionary **options, std::error_code &ec); - VideoFrame2 decodeVideo(std::error_code &ec, + VideoFrame decodeVideo(std::error_code &ec, const Packet &packet, size_t offset, size_t *decodedBytes, @@ -254,7 +254,7 @@ class CodecContext : public FFWrapperPtr, public noncopyable //Timestamp m_fakeNextPts; //Timestamp m_fakeCurrPts; - Stream2 m_stream; + Stream m_stream; bool m_isOpened = false; }; diff --git a/src/filters/buffersink.cpp b/src/filters/buffersink.cpp index a06b1b55..ecf47a73 100644 --- a/src/filters/buffersink.cpp +++ b/src/filters/buffersink.cpp @@ -29,7 +29,7 @@ BufferSinkFilterContext &BufferSinkFilterContext::operator=(const FilterContext return *this; } -bool BufferSinkFilterContext::getVideoFrame(VideoFrame2 &frame, int flags, error_code &ec) +bool BufferSinkFilterContext::getVideoFrame(VideoFrame &frame, int flags, error_code &ec) { if (m_type != FilterMediaType::Video) { throws_if(ec, Errors::IncorrectBufferSinkMediaType); @@ -39,12 +39,12 @@ bool BufferSinkFilterContext::getVideoFrame(VideoFrame2 &frame, int flags, error return getFrame(frame.raw(), flags, ec); } -bool BufferSinkFilterContext::getVideoFrame(VideoFrame2 &frame, error_code &ec) +bool BufferSinkFilterContext::getVideoFrame(VideoFrame &frame, error_code &ec) { return getVideoFrame(frame, 0, ec); } -bool BufferSinkFilterContext::getAudioFrame(AudioSamples2 &samples, int flags, error_code &ec) +bool BufferSinkFilterContext::getAudioFrame(AudioSamples &samples, int flags, error_code &ec) { if (m_type != FilterMediaType::Audio) { throws_if(ec, Errors::IncorrectBufferSinkMediaType); @@ -53,12 +53,12 @@ bool BufferSinkFilterContext::getAudioFrame(AudioSamples2 &samples, int flags, e return getFrame(samples.raw(), flags, ec); } -bool BufferSinkFilterContext::getAudioFrame(AudioSamples2 &samples, error_code &ec) +bool BufferSinkFilterContext::getAudioFrame(AudioSamples &samples, error_code &ec) { return getAudioFrame(samples, 0, ec); } -bool BufferSinkFilterContext::getAudioSamples(AudioSamples2 &samples, size_t samplesCount, error_code &ec) +bool BufferSinkFilterContext::getAudioSamples(AudioSamples &samples, size_t samplesCount, error_code &ec) { if (m_type != FilterMediaType::Audio) { throws_if(ec, Errors::IncorrectBufferSinkMediaType); diff --git a/src/filters/buffersink.h b/src/filters/buffersink.h index 0f1529e1..d138047d 100644 --- a/src/filters/buffersink.h +++ b/src/filters/buffersink.h @@ -29,12 +29,12 @@ class BufferSinkFilterContext BufferSinkFilterContext& operator=(const FilterContext &ctx); - bool getVideoFrame(VideoFrame2 &frame, int flags, std::error_code &ec = throws()); - bool getVideoFrame(VideoFrame2 &frame, std::error_code &ec = throws()); + bool getVideoFrame(VideoFrame &frame, int flags, std::error_code &ec = throws()); + bool getVideoFrame(VideoFrame &frame, std::error_code &ec = throws()); - bool getAudioFrame(AudioSamples2 &samples, int flags, std::error_code &ec = throws()); - bool getAudioFrame(AudioSamples2 &samples, std::error_code &ec = throws()); - bool getAudioSamples(AudioSamples2 &samples, size_t samplesCount, std::error_code &ec = throws()); + bool getAudioFrame(AudioSamples &samples, int flags, std::error_code &ec = throws()); + bool getAudioFrame(AudioSamples &samples, std::error_code &ec = throws()); + bool getAudioSamples(AudioSamples &samples, size_t samplesCount, std::error_code &ec = throws()); void setFrameSize(unsigned size, std::error_code &ec = throws()); Rational frameRate(std::error_code &ec = throws()); diff --git a/src/filters/buffersrc.cpp b/src/filters/buffersrc.cpp index 6408fd6d..671e0e2d 100644 --- a/src/filters/buffersrc.cpp +++ b/src/filters/buffersrc.cpp @@ -28,7 +28,7 @@ BufferSrcFilterContext &BufferSrcFilterContext::operator=(const FilterContext &c return *this; } -void BufferSrcFilterContext::addVideoFrame(VideoFrame2 &frame, int flags, error_code &ec) +void BufferSrcFilterContext::addVideoFrame(VideoFrame &frame, int flags, error_code &ec) { if (m_type == FilterMediaType::Video) { addFrame(frame.raw(), flags, ec); @@ -37,12 +37,12 @@ void BufferSrcFilterContext::addVideoFrame(VideoFrame2 &frame, int flags, error_ } } -void BufferSrcFilterContext::addVideoFrame(VideoFrame2 &frame, error_code &ec) +void BufferSrcFilterContext::addVideoFrame(VideoFrame &frame, error_code &ec) { addVideoFrame(frame, 0, ec); } -void BufferSrcFilterContext::writeVideoFrame(const VideoFrame2 &frame, error_code &ec) +void BufferSrcFilterContext::writeVideoFrame(const VideoFrame &frame, error_code &ec) { if (m_type == FilterMediaType::Video) { writeFrame(frame.raw(), ec); @@ -51,7 +51,7 @@ void BufferSrcFilterContext::writeVideoFrame(const VideoFrame2 &frame, error_cod } } -void BufferSrcFilterContext::addAudioSamples(AudioSamples2 &samples, int flags, error_code &ec) +void BufferSrcFilterContext::addAudioSamples(AudioSamples &samples, int flags, error_code &ec) { if (m_type == FilterMediaType::Audio) { addFrame(samples.raw(), flags, ec); @@ -60,12 +60,12 @@ void BufferSrcFilterContext::addAudioSamples(AudioSamples2 &samples, int flags, } } -void BufferSrcFilterContext::addAudioSamples(AudioSamples2 &samples, error_code &ec) +void BufferSrcFilterContext::addAudioSamples(AudioSamples &samples, error_code &ec) { addAudioSamples(samples, 0, ec); } -void BufferSrcFilterContext::writeAudioSamples(const AudioSamples2 &samples, error_code &ec) +void BufferSrcFilterContext::writeAudioSamples(const AudioSamples &samples, error_code &ec) { if (m_type == FilterMediaType::Audio) { writeFrame(samples.raw(), ec); diff --git a/src/filters/buffersrc.h b/src/filters/buffersrc.h index 8d991403..5e5fa55f 100644 --- a/src/filters/buffersrc.h +++ b/src/filters/buffersrc.h @@ -19,13 +19,13 @@ class BufferSrcFilterContext void assign(const FilterContext &ctx, std::error_code &ec = throws()); BufferSrcFilterContext& operator=(const FilterContext &ctx); - void writeVideoFrame(const VideoFrame2 &frame, std::error_code &ec = throws()); - void addVideoFrame(VideoFrame2 &frame, int flags, std::error_code &ec = throws()); - void addVideoFrame(VideoFrame2 &frame, std::error_code &ec = throws()); + void writeVideoFrame(const VideoFrame &frame, std::error_code &ec = throws()); + void addVideoFrame(VideoFrame &frame, int flags, std::error_code &ec = throws()); + void addVideoFrame(VideoFrame &frame, std::error_code &ec = throws()); - void writeAudioSamples(const AudioSamples2 &samples, std::error_code &ec = throws()); - void addAudioSamples(AudioSamples2 &samples, int flags, std::error_code &ec = throws()); - void addAudioSamples(AudioSamples2 &samples, std::error_code &ec = throws()); + void writeAudioSamples(const AudioSamples &samples, std::error_code &ec = throws()); + void addAudioSamples(AudioSamples &samples, int flags, std::error_code &ec = throws()); + void addAudioSamples(AudioSamples &samples, std::error_code &ec = throws()); size_t failedRequestsCount(); diff --git a/src/formatcontext.cpp b/src/formatcontext.cpp index 1c9092ee..a7af04ca 100644 --- a/src/formatcontext.cpp +++ b/src/formatcontext.cpp @@ -173,41 +173,41 @@ size_t FormatContext::streamsCount() const return RAW_GET(nb_streams, 0); } -Stream2 FormatContext::stream(size_t idx) +Stream FormatContext::stream(size_t idx) { if (!m_raw || idx >= m_raw->nb_streams) - return Stream2(m_monitor); + return Stream(m_monitor); - return Stream2(m_monitor, m_raw->streams[idx], isOutput() ? Direction::ENCODING : Direction::DECODING); + return Stream(m_monitor, m_raw->streams[idx], isOutput() ? Direction::ENCODING : Direction::DECODING); } -Stream2 FormatContext::stream(size_t idx, error_code &ec) +Stream FormatContext::stream(size_t idx, error_code &ec) { if (!m_raw) { throws_if(ec, Errors::Unallocated); - return Stream2(m_monitor); + return Stream(m_monitor); } if (idx >= m_raw->nb_streams) { throws_if(ec, Errors::FormatInvalidStreamIndex); - return Stream2(m_monitor); + return Stream(m_monitor); } return stream(idx); } -Stream2 FormatContext::addStream(const Codec &codec, error_code &ec) +Stream FormatContext::addStream(const Codec &codec, error_code &ec) { clear_if(ec); if (!m_raw) { throws_if(ec, Errors::Unallocated); - return Stream2(); + return Stream(); } if (!outputFormat().codecSupported(codec)) { throws_if(ec, Errors::FormatCodecUnsupported); - return Stream2(); + return Stream(); } auto rawcodec = codec.raw(); @@ -217,10 +217,10 @@ Stream2 FormatContext::addStream(const Codec &codec, error_code &ec) if (!st) { throws_if(ec, Errors::FormatCantAddStream); - return Stream2(); + return Stream(); } - auto stream = Stream2(m_monitor, st, Direction::ENCODING); + auto stream = Stream(m_monitor, st, Direction::ENCODING); if (st->codec) { if (outputFormat().isFlags(AVFMT_GLOBALHEADER)) { @@ -705,22 +705,22 @@ bool FormatContext::checkUncodedFrameWriting(size_t streamIndex) noexcept return checkUncodedFrameWriting(streamIndex, ec); } -void FormatContext::writeUncodedFrame(VideoFrame2 &frame, size_t streamIndex, error_code &ec) +void FormatContext::writeUncodedFrame(VideoFrame &frame, size_t streamIndex, error_code &ec) { writeFrame(frame.raw(), streamIndex, ec, av_interleaved_write_uncoded_frame); } -void FormatContext::writeUncodedFrameDirect(VideoFrame2 &frame, size_t streamIndex, error_code &ec) +void FormatContext::writeUncodedFrameDirect(VideoFrame &frame, size_t streamIndex, error_code &ec) { writeFrame(frame.raw(), streamIndex, ec, av_write_uncoded_frame); } -void FormatContext::writeUncodedFrame(AudioSamples2 &frame, size_t streamIndex, error_code &ec) +void FormatContext::writeUncodedFrame(AudioSamples &frame, size_t streamIndex, error_code &ec) { writeFrame(frame.raw(), streamIndex, ec, av_interleaved_write_uncoded_frame); } -void FormatContext::writeUncodedFrameDirect(AudioSamples2 &frame, size_t streamIndex, error_code &ec) +void FormatContext::writeUncodedFrameDirect(AudioSamples &frame, size_t streamIndex, error_code &ec) { writeFrame(frame.raw(), streamIndex, ec, av_write_uncoded_frame); } diff --git a/src/formatcontext.h b/src/formatcontext.h index 0698c32e..abf4c0ac 100644 --- a/src/formatcontext.h +++ b/src/formatcontext.h @@ -76,10 +76,10 @@ class FormatContext : public FFWrapperPtr, public noncopyable // // Streams // - size_t streamsCount() const; - Stream2 stream(size_t idx); - Stream2 stream(size_t idx, std::error_code &ec); - Stream2 addStream(const Codec &codec, std::error_code &ec = throws()); + size_t streamsCount() const; + Stream stream(size_t idx); + Stream stream(size_t idx, std::error_code &ec); + Stream addStream(const Codec &codec, std::error_code &ec = throws()); // // Seeking @@ -172,10 +172,10 @@ class FormatContext : public FFWrapperPtr, public noncopyable bool checkUncodedFrameWriting(size_t streamIndex, std::error_code &ec) noexcept; bool checkUncodedFrameWriting(size_t streamIndex) noexcept; - void writeUncodedFrame(VideoFrame2 &frame, size_t streamIndex, std::error_code &ec = throws()); - void writeUncodedFrameDirect(VideoFrame2 &frame, size_t streamIndex, std::error_code &ec = throws()); - void writeUncodedFrame(AudioSamples2 &frame, size_t streamIndex, std::error_code &ec = throws()); - void writeUncodedFrameDirect(AudioSamples2 &frame, size_t streamIndex, std::error_code &ec = throws()); + void writeUncodedFrame(VideoFrame &frame, size_t streamIndex, std::error_code &ec = throws()); + void writeUncodedFrameDirect(VideoFrame &frame, size_t streamIndex, std::error_code &ec = throws()); + void writeUncodedFrame(AudioSamples &frame, size_t streamIndex, std::error_code &ec = throws()); + void writeUncodedFrameDirect(AudioSamples &frame, size_t streamIndex, std::error_code &ec = throws()); void writeTrailer(std::error_code &ec = throws()); diff --git a/src/frame.cpp b/src/frame.cpp index 9526c47c..a9440ed4 100644 --- a/src/frame.cpp +++ b/src/frame.cpp @@ -86,7 +86,7 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src) namespace av { -VideoFrame2::VideoFrame2(PixelFormat pixelFormat, int width, int height, int align) +VideoFrame::VideoFrame(PixelFormat pixelFormat, int width, int height, int align) { m_raw->format = pixelFormat; m_raw->width = width; @@ -94,8 +94,8 @@ VideoFrame2::VideoFrame2(PixelFormat pixelFormat, int width, int height, int ali av_frame_get_buffer(m_raw, align); } -VideoFrame2::VideoFrame2(const uint8_t *data, size_t size, PixelFormat pixelFormat, int width, int height, int align) - : VideoFrame2(pixelFormat, width, height, align) +VideoFrame::VideoFrame(const uint8_t *data, size_t size, PixelFormat pixelFormat, int width, int height, int align) + : VideoFrame(pixelFormat, width, height, align) { size_t calcSize = av_image_get_buffer_size(pixelFormat, width, height, align); if (calcSize != size) @@ -111,78 +111,78 @@ VideoFrame2::VideoFrame2(const uint8_t *data, size_t size, PixelFormat pixelForm } } -VideoFrame2::VideoFrame2(const VideoFrame2 &other) - : Frame2(other) +VideoFrame::VideoFrame(const VideoFrame &other) + : Frame(other) { } -VideoFrame2::VideoFrame2(VideoFrame2 &&other) - : Frame2(move(other)) +VideoFrame::VideoFrame(VideoFrame &&other) + : Frame(move(other)) { } -VideoFrame2 &VideoFrame2::operator=(const VideoFrame2 &rhs) +VideoFrame &VideoFrame::operator=(const VideoFrame &rhs) { return assignOperator(rhs); } -VideoFrame2 &VideoFrame2::operator=(VideoFrame2 &&rhs) +VideoFrame &VideoFrame::operator=(VideoFrame &&rhs) { return moveOperator(move(rhs)); } -PixelFormat VideoFrame2::pixelFormat() const +PixelFormat VideoFrame::pixelFormat() const { return static_cast(RAW_GET(format, AV_PIX_FMT_NONE)); } -int VideoFrame2::width() const +int VideoFrame::width() const { return RAW_GET(width, 0); } -int VideoFrame2::height() const +int VideoFrame::height() const { return RAW_GET(height, 0); } -bool VideoFrame2::isKeyFrame() const +bool VideoFrame::isKeyFrame() const { return RAW_GET(key_frame, false); } -void VideoFrame2::setKeyFrame(bool isKey) +void VideoFrame::setKeyFrame(bool isKey) { RAW_SET(key_frame, isKey); } -int VideoFrame2::quality() const +int VideoFrame::quality() const { return RAW_GET(quality, 0); } -void VideoFrame2::setQuality(int quality) +void VideoFrame::setQuality(int quality) { RAW_SET(quality, quality); } -AVPictureType VideoFrame2::pictureType() const +AVPictureType VideoFrame::pictureType() const { return RAW_GET(pict_type, AV_PICTURE_TYPE_NONE); } -void VideoFrame2::setPictureType(AVPictureType type) +void VideoFrame::setPictureType(AVPictureType type) { RAW_SET(pict_type, type); } -AudioSamples2::AudioSamples2(SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align) +AudioSamples::AudioSamples(SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align) { init(sampleFormat, samplesCount, channelLayout, sampleRate, align); } -int AudioSamples2::init(SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align) +int AudioSamples::init(SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align) { if (!m_raw) { m_raw = av_frame_alloc(); @@ -203,8 +203,8 @@ int AudioSamples2::init(SampleFormat sampleFormat, int samplesCount, uint64_t ch return 0; } -AudioSamples2::AudioSamples2(const uint8_t *data, size_t size, SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align) - : AudioSamples2(sampleFormat, samplesCount, channelLayout, sampleRate, align) +AudioSamples::AudioSamples(const uint8_t *data, size_t size, SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align) + : AudioSamples(sampleFormat, samplesCount, channelLayout, sampleRate, align) { const auto channels = av_get_channel_layout_nb_channels(channelLayout); auto calcSize = sampleFormat.requiredBufferSize(channels, samplesCount, align); @@ -222,59 +222,59 @@ AudioSamples2::AudioSamples2(const uint8_t *data, size_t size, SampleFormat samp } } -AudioSamples2::AudioSamples2(const AudioSamples2 &other) - : Frame2(other) +AudioSamples::AudioSamples(const AudioSamples &other) + : Frame(other) { } -AudioSamples2::AudioSamples2(AudioSamples2 &&other) - : Frame2(move(other)) +AudioSamples::AudioSamples(AudioSamples &&other) + : Frame(move(other)) { } -AudioSamples2 &AudioSamples2::operator=(const AudioSamples2 &rhs) +AudioSamples &AudioSamples::operator=(const AudioSamples &rhs) { return assignOperator(rhs); } -AudioSamples2 &AudioSamples2::operator=(AudioSamples2 &&rhs) +AudioSamples &AudioSamples::operator=(AudioSamples &&rhs) { return moveOperator(move(rhs)); } -SampleFormat AudioSamples2::sampleFormat() const +SampleFormat AudioSamples::sampleFormat() const { return static_cast(RAW_GET(format, AV_SAMPLE_FMT_NONE)); } -int AudioSamples2::samplesCount() const +int AudioSamples::samplesCount() const { return RAW_GET(nb_samples, 0); } -int AudioSamples2::channelsCount() const +int AudioSamples::channelsCount() const { return m_raw ? av_frame_get_channels(m_raw) : 0; } -int64_t AudioSamples2::channelsLayout() const +int64_t AudioSamples::channelsLayout() const { return m_raw ? av_frame_get_channel_layout(m_raw) : 0; } -int AudioSamples2::sampleRate() const +int AudioSamples::sampleRate() const { return m_raw ? av_frame_get_sample_rate(m_raw) : 0; } -size_t AudioSamples2::sampleBitDepth(error_code &ec) const +size_t AudioSamples::sampleBitDepth(error_code &ec) const { return m_raw ? SampleFormat(static_cast(m_raw->format)).bitsPerSample(ec) : 0; } -string AudioSamples2::channelsLayoutString() const +string AudioSamples::channelsLayoutString() const { if (!m_raw) return ""; diff --git a/src/frame.h b/src/frame.h index fc8fe0c3..4ec0cac7 100644 --- a/src/frame.h +++ b/src/frame.h @@ -20,7 +20,7 @@ namespace av { template -class Frame2 : public FFWrapperPtr +class Frame : public FFWrapperPtr { protected: T& assignOperator(const T &rhs) { @@ -38,16 +38,16 @@ class Frame2 : public FFWrapperPtr } public: - Frame2() { + Frame() { m_raw = av_frame_alloc(); m_raw->opaque = this; } - ~Frame2() { + ~Frame() { av_frame_free(&m_raw); } - Frame2(const AVFrame *frame) { + Frame(const AVFrame *frame) { if (frame) { m_raw = av_frame_alloc(); m_raw->opaque = this; @@ -56,12 +56,12 @@ class Frame2 : public FFWrapperPtr } // Helper ctors to implement move/copy ctors - Frame2(const T& other) : Frame2(other.m_raw) { + Frame(const T& other) : Frame(other.m_raw) { if (m_raw) copyInfoFrom(other); } - Frame2(T&& other) : FFWrapperPtr(nullptr) { + Frame(T&& other) : FFWrapperPtr(nullptr) { if (other.m_raw) { m_raw = av_frame_alloc(); m_raw->opaque = this; @@ -75,9 +75,9 @@ class Frame2 : public FFWrapperPtr } // You must implement operators in deveritive classes using assignOperator() and moveOperator() - void operator=(const Frame2&) = delete; + void operator=(const Frame&) = delete; - void swap(Frame2 &other) { + void swap(Frame &other) { using std::swap; #define FRAME_SWAP(x) swap(x, other.x) FRAME_SWAP(m_raw); @@ -265,20 +265,20 @@ class Frame2 : public FFWrapperPtr }; -class VideoFrame2 : public Frame2 +class VideoFrame : public Frame { public: - using Frame2::Frame2; + using Frame::Frame; - VideoFrame2() = default; - VideoFrame2(PixelFormat pixelFormat, int width, int height, int align = 1); - VideoFrame2(const uint8_t *data, size_t size, PixelFormat pixelFormat, int width, int height, int align = 1); + VideoFrame() = default; + VideoFrame(PixelFormat pixelFormat, int width, int height, int align = 1); + VideoFrame(const uint8_t *data, size_t size, PixelFormat pixelFormat, int width, int height, int align = 1); - VideoFrame2(const VideoFrame2 &other); - VideoFrame2(VideoFrame2 &&other); + VideoFrame(const VideoFrame &other); + VideoFrame(VideoFrame &&other); - VideoFrame2& operator=(const VideoFrame2 &rhs); - VideoFrame2& operator=(VideoFrame2 &&rhs); + VideoFrame& operator=(const VideoFrame &rhs); + VideoFrame& operator=(VideoFrame &&rhs); PixelFormat pixelFormat() const; int width() const; @@ -294,22 +294,24 @@ class VideoFrame2 : public Frame2 void setPictureType(AVPictureType type = AV_PICTURE_TYPE_NONE); }; +// Be a little back compat +using VideoFrame2 attribute_deprecated2("Use `VideoFrame` class (drop-in replacement)") = VideoFrame; -class AudioSamples2 : public Frame2 +class AudioSamples : public Frame { public: - using Frame2::Frame2; + using Frame::Frame; - AudioSamples2() = default; - AudioSamples2(SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align = SampleFormat::AlignDefault); - AudioSamples2(const uint8_t *data, size_t size, + AudioSamples() = default; + AudioSamples(SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align = SampleFormat::AlignDefault); + AudioSamples(const uint8_t *data, size_t size, SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align = SampleFormat::AlignDefault); - AudioSamples2(const AudioSamples2 &other); - AudioSamples2(AudioSamples2 &&other); + AudioSamples(const AudioSamples &other); + AudioSamples(AudioSamples &&other); - AudioSamples2& operator=(const AudioSamples2 &rhs); - AudioSamples2& operator=(AudioSamples2 &&rhs); + AudioSamples& operator=(const AudioSamples &rhs); + AudioSamples& operator=(AudioSamples &&rhs); int init(SampleFormat sampleFormat, int samplesCount, uint64_t channelLayout, int sampleRate, int align = SampleFormat::AlignDefault); @@ -323,6 +325,9 @@ class AudioSamples2 : public Frame2 std::string channelsLayoutString() const; }; +// Be a little back compat +using AudioSamples2 attribute_deprecated2("Use `AudioSamples` class (drop-in replacement)") = AudioSamples; + } // ::av diff --git a/src/packet.cpp b/src/packet.cpp index 69a28e8a..b7a3879e 100644 --- a/src/packet.cpp +++ b/src/packet.cpp @@ -247,7 +247,7 @@ void Packet::clearFlags(int flags) m_raw.flags &= ~flags; } -void Packet::dump(const Stream2 &st, bool dumpPayload) const +void Packet::dump(const Stream &st, bool dumpPayload) const { if (!st.isNull()) { diff --git a/src/packet.h b/src/packet.h index caa7d7be..f1a9a048 100644 --- a/src/packet.h +++ b/src/packet.h @@ -55,11 +55,9 @@ class Packet : public FFWrapperRef */ 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; - //void setFakePts(int64_t pts, const Rational &tsTimeBase = Rational(0, 0)) attribute_deprecated; void setPts(const Timestamp &pts); void setDts(const Timestamp &dts); - //void setFakePts(const Timestamp &pts); int streamIndex() const; bool isKeyPacket() const; @@ -78,7 +76,7 @@ class Packet : public FFWrapperRef void addFlags(int flags); void clearFlags(int flags); - void dump(const Stream2 & st, bool dumpPayload = false) const; + void dump(const Stream & st, bool dumpPayload = false) const; const Rational& timeBase() const { return m_timeBase; } void setTimeBase(const Rational &value); diff --git a/src/stream.cpp b/src/stream.cpp index d0b9ca77..8d38444a 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -4,99 +4,99 @@ namespace av { -Stream2::Stream2(const std::shared_ptr &monitor, AVStream *st, Direction direction) +Stream::Stream(const std::shared_ptr &monitor, AVStream *st, Direction direction) : FFWrapperPtr(st), m_parentMonitor(monitor), m_direction(direction) { } -bool Stream2::isValid() const +bool Stream::isValid() const { return (!m_parentMonitor.expired() && !isNull()); } -int Stream2::index() const +int Stream::index() const { return RAW_GET2(isValid(), index, -1); } -int Stream2::id() const +int Stream::id() const { return RAW_GET2(isValid(), id, -1); } -Rational Stream2::frameRate() const +Rational Stream::frameRate() const { return RAW_GET2(isValid(), r_frame_rate, AVRational{}); } -Rational Stream2::timeBase() const +Rational Stream::timeBase() const { return RAW_GET2(isValid(), time_base, AVRational{}); } -Rational Stream2::sampleAspectRatio() const +Rational Stream::sampleAspectRatio() const { return RAW_GET2(isValid(), sample_aspect_ratio, AVRational{}); } -Timestamp Stream2::startTime() const +Timestamp Stream::startTime() const { return {RAW_GET2(isValid(), start_time, AV_NOPTS_VALUE), timeBase()}; } -Timestamp Stream2::duration() const +Timestamp Stream::duration() const { return {RAW_GET2(isValid(), duration, AV_NOPTS_VALUE), timeBase()}; } -Timestamp Stream2::currentDts() const +Timestamp Stream::currentDts() const { return {RAW_GET2(isValid(), cur_dts, AV_NOPTS_VALUE), timeBase()}; } -AVMediaType Stream2::mediaType() const +AVMediaType Stream::mediaType() const { return RAW_GET2(isValid() && m_raw->codec, codec->codec_type, AVMEDIA_TYPE_UNKNOWN); } -bool Stream2::isAudio() const +bool Stream::isAudio() const { return (mediaType() == AVMEDIA_TYPE_AUDIO); } -bool Stream2::isVideo() const +bool Stream::isVideo() const { return (mediaType() == AVMEDIA_TYPE_VIDEO); } -bool Stream2::isData() const +bool Stream::isData() const { return (mediaType() == AVMEDIA_TYPE_DATA); } -bool Stream2::isSubtitle() const +bool Stream::isSubtitle() const { return (mediaType() == AVMEDIA_TYPE_SUBTITLE); } -bool Stream2::isAttachment() const +bool Stream::isAttachment() const { return (mediaType() == AVMEDIA_TYPE_ATTACHMENT); } -void Stream2::setTimeBase(const Rational &timeBase) +void Stream::setTimeBase(const Rational &timeBase) { RAW_SET2(isValid(), time_base, timeBase.getValue()); } -void Stream2::setFrameRate(const Rational &frameRate) +void Stream::setFrameRate(const Rational &frameRate) { RAW_SET2(isValid(), r_frame_rate, frameRate.getValue()); } -void Stream2::setSampleAspectRatio(const Rational &aspectRatio) +void Stream::setSampleAspectRatio(const Rational &aspectRatio) { RAW_SET2(isValid(), sample_aspect_ratio, aspectRatio.getValue()); } diff --git a/src/stream.h b/src/stream.h index 95d1dd79..913bfe4d 100644 --- a/src/stream.h +++ b/src/stream.h @@ -18,14 +18,14 @@ enum class Direction }; -class Stream2 : public FFWrapperPtr +class Stream : public FFWrapperPtr { private: friend class FormatContext; - Stream2(const std::shared_ptr &monitor, AVStream *st = nullptr, Direction direction = Direction::INVALID); + Stream(const std::shared_ptr &monitor, AVStream *st = nullptr, Direction direction = Direction::INVALID); public: - Stream2() = default; + Stream() = default; bool isValid() const; @@ -57,6 +57,8 @@ class Stream2 : public FFWrapperPtr Direction m_direction = Direction::INVALID; }; +// Back compat alias +using Stream2 attribute_deprecated2("Use `Stream` class (drop-in replacement)") = Stream; } // ::av diff --git a/src/videorescaler.cpp b/src/videorescaler.cpp index 221c2536..3fa21c4e 100644 --- a/src/videorescaler.cpp +++ b/src/videorescaler.cpp @@ -116,7 +116,7 @@ VideoRescaler& VideoRescaler::operator=(VideoRescaler &&rhs) return *this; } -void VideoRescaler::rescale(VideoFrame2 &dst, const VideoFrame2 &src, error_code &ec) +void VideoRescaler::rescale(VideoFrame &dst, const VideoFrame &src, error_code &ec) { m_srcWidth = src.width(); m_srcHeight = src.height(); @@ -173,9 +173,9 @@ void VideoRescaler::rescale(VideoFrame2 &dst, const VideoFrame2 &src, error_code dst.setComplete(true); } -VideoFrame2 VideoRescaler::rescale(const VideoFrame2 &src, error_code &ec) +VideoFrame VideoRescaler::rescale(const VideoFrame &src, error_code &ec) { - VideoFrame2 dst{m_dstPixelFormat, m_dstWidth, m_dstHeight}; + VideoFrame dst{m_dstPixelFormat, m_dstWidth, m_dstHeight}; rescale(dst, src, ec); return dst; } diff --git a/src/videorescaler.h b/src/videorescaler.h index bc8da8a1..0d0b94b5 100644 --- a/src/videorescaler.h +++ b/src/videorescaler.h @@ -64,8 +64,8 @@ class VideoRescaler : public FFWrapperPtr, public noncopyable int32_t flags() const { return m_flags; } - void rescale(VideoFrame2 &dst, const VideoFrame2 &src, std::error_code &ec = throws()); - VideoFrame2 rescale(const VideoFrame2 &src, std::error_code &ec); + void rescale(VideoFrame &dst, const VideoFrame &src, std::error_code &ec = throws()); + VideoFrame rescale(const VideoFrame &src, std::error_code &ec); bool isValid() const;