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 <libavutil/pixfmt.h>
7struct AVFrame;
8struct AVCodecContext;
9struct AVPacket;
10}
11#include <memory>
12
13namespace Video
14{
15struct SCORE_PLUGIN_MEDIA_EXPORT ImageFormat
16{
17 int width{};
18 int height{};
19 AVPixelFormat pixel_format = AVPixelFormat(-1);
20
21 AVColorRange color_range = AVColorRange(-1);
22 AVColorPrimaries color_primaries = AVColorPrimaries(-1);
23 AVColorTransferCharacteristic color_trc = AVColorTransferCharacteristic(-1);
24 AVColorSpace color_space = AVColorSpace(-1);
25 AVChromaLocation chroma_location = AVChromaLocation(-1);
26};
27
28struct SCORE_PLUGIN_MEDIA_EXPORT VideoMetadata : ImageFormat
29{
30 double fps{};
31 bool realTime{};
32 double flicks_per_dts{};
33 double dts_per_flicks{};
34};
35
36struct SCORE_PLUGIN_MEDIA_EXPORT VideoInterface : VideoMetadata
37{
38 virtual ~VideoInterface();
39 virtual AVFrame* dequeue_frame() noexcept = 0;
40 virtual void release_frame(AVFrame* frame) noexcept = 0;
41};
42
43struct SCORE_PLUGIN_MEDIA_EXPORT ReadFrame
44{
45 AVFrame* frame{};
46 int error{};
47};
48struct SCORE_PLUGIN_MEDIA_EXPORT FreeAVFrame
49{
50 void operator()(AVFrame* f) const noexcept;
51};
52
53using AVFramePointer = std::unique_ptr<AVFrame, FreeAVFrame>;
54
55ReadFrame readVideoFrame(
56 AVCodecContext* codecContext, const AVPacket* pkt, AVFrame* frame, bool ignorePts);
57}
58#endif
Definition VideoInterface.hpp:49
Definition VideoInterface.hpp:16
Definition VideoInterface.hpp:44
Definition VideoInterface.hpp:37
Definition VideoInterface.hpp:29