Loading...
Searching...
No Matches
Rescale.hpp
1#pragma once
2
3#include <Media/Libav.hpp>
4#if SCORE_HAS_LIBAV
5
6#include <Video/FrameQueue.hpp>
7#include <Video/VideoInterface.hpp>
8
9extern "C" {
10struct SwsContext;
11#include <libavcodec/avcodec.h>
12#include <libavformat/avformat.h>
13}
14
15#include <QDebug>
16
17#include <score_plugin_media_export.h>
18namespace Video
19{
20class SCORE_PLUGIN_MEDIA_EXPORT Rescale
21{
22public:
23 operator bool() const noexcept { return m_rescale; }
24
25 void open(const VideoMetadata& src);
26 void close();
27 void rescale(FrameQueue& m_frames, AVFramePointer& frame, ReadFrame& read);
28
29private:
30 const VideoMetadata* m_src{};
31 SwsContext* m_rescale{};
32 AVPixelFormat m_rescaleFormat{};
33};
34
35struct SCORE_PLUGIN_MEDIA_EXPORT DecoderConfiguration
36{
37 AVPixelFormat hardwareAcceleration{AV_PIX_FMT_NONE};
38 std::string decoder;
39 int threads{};
40 int graphicsApi{}; // score::gfx::GraphicsApi (avoid header dependency)
41 uint32_t gpuVendorId{}; // PCI vendor ID of the render GPU (0 = unknown)
42 bool useAVCodec{true};
43 bool ignorePTS{false};
44};
45
46struct SCORE_PLUGIN_MEDIA_EXPORT LibAVDecoder
47{
48 ReadFrame enqueue_frame(const AVPacket* pkt) noexcept;
49 std::pair<AVBufferRef*, const AVCodec*> open_hwdec(const AVCodec&) noexcept;
50
51 int init_codec_context(
52 const AVCodec* codec, AVBufferRef* hw_dev_ctx, const AVStream* stream,
53 std::function<void(AVCodecContext&)> setup);
54 bool open_codec_context(
55 VideoInterface& self, const AVStream* stream,
56 std::function<void(AVCodecContext&)> setup);
57 void init_scaler(VideoInterface& self) noexcept;
58 void load_packet_in_frame(const AVPacket& packet, AVFrame& frame);
59
60 ReadFrame read_one_frame(AVPacket& packet);
61 ReadFrame read_one_frame_raw(AVPacket& packet);
62 ReadFrame read_one_frame_avcodec(AVPacket& packet);
63
65
66 AVFormatContext* m_formatContext{};
67 AVStream* m_avstream{};
68 const AVCodec* m_codec{};
69 AVCodecContext* m_codecContext{};
70
71 FrameQueue m_frames;
72 Rescale m_rescale;
73 bool m_finished{};
74};
75
76}
77#endif
Definition Rescale.hpp:21
Definition Rescale.hpp:36
Definition FrameQueue.hpp:53
Definition Rescale.hpp:47
Definition VideoInterface.hpp:66
Definition VideoInterface.hpp:59
Definition VideoInterface.hpp:49