Loading...
Searching...
No Matches
VideoInterface.hpp
1#pragma once
2#include <Media/Libav.hpp>
3#include <Video/VideoEnums.hpp>
4#if SCORE_HAS_LIBAV
5#include <score_plugin_media_export.h>
6extern "C" {
7#include <libavcodec/codec_id.h>
8#include <libavutil/pixfmt.h>
9#include <libavcodec/version.h>
10#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 3, 100)
11#if __has_include(<libavutil/mastering_display_metadata.h>)
12#include <libavutil/mastering_display_metadata.h>
13#endif
14#endif
15struct AVFrame;
16struct AVCodecContext;
17struct AVPacket;
18}
19#include <memory>
20#include <string>
21
22namespace Video
23{
24
25struct SCORE_PLUGIN_MEDIA_EXPORT ImageFormat
26{
27 // From ffmpeg
28 int width{};
29 int height{};
30 AVPixelFormat pixel_format = AVPixelFormat(-1);
31
32 AVColorRange color_range = AVColorRange(-1);
33 AVColorPrimaries color_primaries = AVColorPrimaries(-1);
34 AVColorTransferCharacteristic color_trc = AVColorTransferCharacteristic(-1);
35 AVColorSpace color_space = AVColorSpace(-1);
36 AVChromaLocation chroma_location = AVChromaLocation(-1);
37
38#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 3, 100)
39 AVMasteringDisplayMetadata mastering_display{};
40 std::optional<AVContentLightMetadata> content_light{};
41#endif
42
43 // Set by the user
44 OutputFormat output_format = ::Video::OutputFormat::SDR;
45 Tonemap tonemap = ::Video::Tonemap::BT_2390;
46};
47
48struct SCORE_PLUGIN_MEDIA_EXPORT VideoMetadata : ImageFormat
49{
50 std::string filePath;
51 AVCodecID codec_id = AV_CODEC_ID_NONE;
52 double fps{};
53 bool realTime{};
54 double flicks_per_dts{};
55 double dts_per_flicks{};
56};
57
58struct SCORE_PLUGIN_MEDIA_EXPORT VideoInterface : VideoMetadata
59{
60 virtual ~VideoInterface();
61 virtual AVFrame* dequeue_frame() noexcept = 0;
62 virtual void release_frame(AVFrame* frame) noexcept = 0;
63};
64
65struct SCORE_PLUGIN_MEDIA_EXPORT ReadFrame
66{
67 AVFrame* frame{};
68 int error{};
69};
70struct SCORE_PLUGIN_MEDIA_EXPORT FreeAVFrame
71{
72 void operator()(AVFrame* f) const noexcept;
73};
74
75using AVFramePointer = std::unique_ptr<AVFrame, FreeAVFrame>;
76
77ReadFrame readVideoFrame(
78 AVCodecContext* codecContext, const AVPacket* pkt, AVFrame* frame, bool ignorePts);
79}
80#endif
Definition VideoInterface.hpp:71
Definition VideoInterface.hpp:26
Definition VideoInterface.hpp:66
Definition VideoInterface.hpp:59
Definition VideoInterface.hpp:49