123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- #ifndef EASYCODEC_EASY_DECODE_H_
- #define EASYCODEC_EASY_DECODE_H_
- #include <functional>
- #include <memory>
- #include "cxxutil/edk_attribute.h"
- #include "cxxutil/exception.h"
- #include "easycodec/vformat.h"
- namespace edk {
- using DecodeFrameCallback = std::function<void(const CnFrame&)>;
- using DecodeEOSCallback = std::function<void()>;
- class DecodeHandler;
- class EasyDecode {
- public:
-
- struct Attr {
-
- Geometry frame_geometry;
-
- CodecType codec_type;
-
- PixelFmt pixel_format;
-
- ColorStd color_std = ColorStd::ITU_BT_709;
-
- uint32_t input_buffer_num = 2;
-
- uint32_t output_buffer_num = 3;
-
- bool interlaced = false;
-
- DecodeFrameCallback frame_callback = NULL;
-
- DecodeEOSCallback eos_callback = NULL;
-
- bool silent = false;
-
- int dev_id = 0;
-
-
- int stride_align = 1;
- };
-
- enum class Status {
- RUNNING,
- PAUSED,
- STOP,
- EOS
- };
-
- static std::unique_ptr<EasyDecode> New(const Attr& attr) noexcept(false);
-
- Attr GetAttr() const;
-
- Status GetStatus() const;
-
- bool Pause();
-
- bool Resume();
-
- void AbortDecoder();
-
- bool FeedData(const CnPacket& packet, bool integral_frame = true) noexcept(false);
-
- bool FeedEos() noexcept(false);
-
- void ReleaseBuffer(uint64_t buf_id);
-
- static bool CopyFrameD2H(void* dst, const CnFrame& frame);
-
- int GetMinimumOutputBufferCount() const;
-
- ~EasyDecode();
- friend class DecodeHandler;
- private:
- explicit EasyDecode(const Attr& attr);
- EasyDecode(const EasyDecode&) = delete;
- EasyDecode& operator=(const EasyDecode&) = delete;
- EasyDecode(EasyDecode&&) = delete;
- EasyDecode& operator=(EasyDecode&&) = delete;
- DecodeHandler* handler_ = nullptr;
- };
- }
- #endif
|