A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System.Runtime.InteropServices;
5using FFmpeg.AutoGen;
6
7namespace osu.Framework.Graphics.Video
8{
9 // ReSharper disable InconsistentNaming
10 public unsafe class FFmpegFuncs
11 {
12 #region Delegates
13
14 public delegate AVFrame* AvFrameAllocDelegate();
15
16 public delegate void AvFrameFreeDelegate(AVFrame** frame);
17
18 public delegate void AvFrameUnrefDelegate(AVFrame* frame);
19
20 public delegate int AvFrameGetBufferDelegate(AVFrame* frame, int align);
21
22 public delegate byte* AvStrDupDelegate(string s);
23
24 public delegate int AvStrErrorDelegate(int errnum, byte* buffer, ulong bufSize);
25
26 public delegate void* AvMallocDelegate(ulong size);
27
28 public delegate AVPacket* AvPacketAllocDelegate();
29
30 public delegate void AvPacketUnrefDelegate(AVPacket* pkt);
31
32 public delegate void AvPacketFreeDelegate(AVPacket** pkt);
33
34 public delegate int AvReadFrameDelegate(AVFormatContext* s, AVPacket* pkt);
35
36 public delegate int AvSeekFrameDelegate(AVFormatContext* s, int stream_index, long timestamp, int flags);
37
38 public delegate AVCodec* AvcodecFindDecoderDelegate(AVCodecID id);
39
40 public delegate int AvcodecOpen2Delegate(AVCodecContext* avctx, AVCodec* codec, AVDictionary** options);
41
42 public delegate int AvcodecReceiveFrameDelegate(AVCodecContext* avctx, AVFrame* frame);
43
44 public delegate int AvcodecSendPacketDelegate(AVCodecContext* avctx, AVPacket* avpkt);
45
46 public delegate AVFormatContext* AvformatAllocContextDelegate();
47
48 public delegate void AvformatCloseInputDelegate(AVFormatContext** s);
49
50 public delegate int AvformatFindStreamInfoDelegate(AVFormatContext* ic, AVDictionary** options);
51
52 public delegate int AvformatOpenInputDelegate(AVFormatContext** ps, [MarshalAs((UnmanagedType)48)] string url, AVInputFormat* fmt, AVDictionary** options);
53
54 public delegate AVIOContext* AvioAllocContextDelegate(byte* buffer, int buffer_size, int write_flag, void* opaque, avio_alloc_context_read_packet_func read_packet, avio_alloc_context_write_packet_func write_packet, avio_alloc_context_seek_func seek);
55
56 public delegate void SwsFreeContextDelegate(SwsContext* swsContext);
57
58 public delegate SwsContext* SwsGetContextDelegate(int srcW, int srcH, AVPixelFormat srcFormat, int dstW, int dstH, AVPixelFormat dstFormat, int flags, SwsFilter* srcFilter, SwsFilter* dstFilter, double* param);
59
60 public delegate int SwsScaleDelegate(SwsContext* c, byte*[] srcSlice, int[] srcStride, int srcSliceY, int srcSliceH, byte*[] dst, int[] dstStride);
61
62 #endregion
63
64 public AvFrameAllocDelegate av_frame_alloc;
65 public AvFrameFreeDelegate av_frame_free;
66 public AvFrameUnrefDelegate av_frame_unref;
67 public AvFrameGetBufferDelegate av_frame_get_buffer;
68 public AvStrDupDelegate av_strdup;
69 public AvStrErrorDelegate av_strerror;
70 public AvMallocDelegate av_malloc;
71 public AvPacketAllocDelegate av_packet_alloc;
72 public AvPacketUnrefDelegate av_packet_unref;
73 public AvPacketFreeDelegate av_packet_free;
74 public AvReadFrameDelegate av_read_frame;
75 public AvSeekFrameDelegate av_seek_frame;
76 public AvcodecFindDecoderDelegate avcodec_find_decoder;
77 public AvcodecOpen2Delegate avcodec_open2;
78 public AvcodecReceiveFrameDelegate avcodec_receive_frame;
79 public AvcodecSendPacketDelegate avcodec_send_packet;
80 public AvformatAllocContextDelegate avformat_alloc_context;
81 public AvformatCloseInputDelegate avformat_close_input;
82 public AvformatFindStreamInfoDelegate avformat_find_stream_info;
83 public AvformatOpenInputDelegate avformat_open_input;
84 public AvioAllocContextDelegate avio_alloc_context;
85 public SwsFreeContextDelegate sws_freeContext;
86 public SwsGetContextDelegate sws_getContext;
87 public SwsScaleDelegate sws_scale;
88 }
89}