VideoInterface.hpp
1 #pragma once
2 #include <Media/Libav.hpp>
3 #if SCORE_HAS_LIBAV
4 #include <score_plugin_media_export.h>
5 extern "C" {
6 #include <libavutil/pixfmt.h>
7 struct AVFrame;
8 struct AVCodecContext;
9 struct AVPacket;
10 }
11 #include <memory>
12 
13 namespace Video
14 {
15 struct 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 
28 struct 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 
36 struct 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 
43 struct SCORE_PLUGIN_MEDIA_EXPORT ReadFrame
44 {
45  AVFrame* frame{};
46  int error{};
47 };
48 struct SCORE_PLUGIN_MEDIA_EXPORT FreeAVFrame
49 {
50  void operator()(AVFrame* f) const noexcept;
51 };
52 
53 using AVFramePointer = std::unique_ptr<AVFrame, FreeAVFrame>;
54 
55 ReadFrame 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