Loading...
Searching...
No Matches
VideoInterface.hpp
1#pragma once
2#include <Media/Libav.hpp>
3#if SCORE_HAS_LIBAV
4#include <score_plugin_media_export.h>
5extern "C" {
6#include <libavcodec/codec_id.h>
7#include <libavutil/pixfmt.h>
8struct AVFrame;
9struct AVCodecContext;
10struct AVPacket;
11}
12#include <memory>
13#include <string>
14
15namespace Video
16{
17struct SCORE_PLUGIN_MEDIA_EXPORT ImageFormat
18{
19 int width{};
20 int height{};
21 AVPixelFormat pixel_format = AVPixelFormat(-1);
22
23 AVColorRange color_range = AVColorRange(-1);
24 AVColorPrimaries color_primaries = AVColorPrimaries(-1);
25 AVColorTransferCharacteristic color_trc = AVColorTransferCharacteristic(-1);
26 AVColorSpace color_space = AVColorSpace(-1);
27 AVChromaLocation chroma_location = AVChromaLocation(-1);
28};
29
30struct SCORE_PLUGIN_MEDIA_EXPORT VideoMetadata : ImageFormat
31{
32 std::string filePath;
33 AVCodecID codec_id = AV_CODEC_ID_NONE;
34 double fps{};
35 bool realTime{};
36 double flicks_per_dts{};
37 double dts_per_flicks{};
38};
39
40struct SCORE_PLUGIN_MEDIA_EXPORT VideoInterface : VideoMetadata
41{
42 virtual ~VideoInterface();
43 virtual AVFrame* dequeue_frame() noexcept = 0;
44 virtual void release_frame(AVFrame* frame) noexcept = 0;
45};
46
47struct SCORE_PLUGIN_MEDIA_EXPORT ReadFrame
48{
49 AVFrame* frame{};
50 int error{};
51};
52struct SCORE_PLUGIN_MEDIA_EXPORT FreeAVFrame
53{
54 void operator()(AVFrame* f) const noexcept;
55};
56
57using AVFramePointer = std::unique_ptr<AVFrame, FreeAVFrame>;
58
59ReadFrame readVideoFrame(
60 AVCodecContext* codecContext, const AVPacket* pkt, AVFrame* frame, bool ignorePts);
61}
62#endif
Definition VideoInterface.hpp:53
Definition VideoInterface.hpp:18
Definition VideoInterface.hpp:48
Definition VideoInterface.hpp:41
Definition VideoInterface.hpp:31