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 
22 struct SCORE_PLUGIN_MEDIA_EXPORT VideoMetadata : ImageFormat
23 {
24  double fps{};
25  bool realTime{};
26  double flicks_per_dts{};
27  double dts_per_flicks{};
28 };
29 
30 struct SCORE_PLUGIN_MEDIA_EXPORT VideoInterface : VideoMetadata
31 {
32  virtual ~VideoInterface();
33  virtual AVFrame* dequeue_frame() noexcept = 0;
34  virtual void release_frame(AVFrame* frame) noexcept = 0;
35 };
36 
37 struct SCORE_PLUGIN_MEDIA_EXPORT ReadFrame
38 {
39  AVFrame* frame{};
40  int error{};
41 };
42 struct SCORE_PLUGIN_MEDIA_EXPORT FreeAVFrame
43 {
44  void operator()(AVFrame* f) const noexcept;
45 };
46 
47 using AVFramePointer = std::unique_ptr<AVFrame, FreeAVFrame>;
48 
49 ReadFrame readVideoFrame(
50  AVCodecContext* codecContext, const AVPacket* pkt, AVFrame* frame, bool ignorePts);
51 }
52 #endif
Definition: VideoInterface.hpp:43
Definition: VideoInterface.hpp:16
Definition: VideoInterface.hpp:38
Definition: VideoInterface.hpp:31
Definition: VideoInterface.hpp:23