28 #ifndef OPENSHOT_FFMPEG_UTILITIES_H
29 #define OPENSHOT_FFMPEG_UTILITIES_H
33 #define INT64_C(c) (c ## LL)
34 #define UINT64_C(c) (c ## ULL)
39 #include <libavcodec/avcodec.h>
40 #include <libavformat/avformat.h>
41 #include <libswscale/swscale.h>
42 #include <libavresample/avresample.h>
43 #include <libavutil/mathematics.h>
44 #include <libavutil/pixfmt.h>
45 #include <libavutil/pixdesc.h>
48 #if LIBAVFORMAT_VERSION_MAJOR >= 53
49 #include <libavutil/opt.h>
51 #include <libavcodec/opt.h>
55 #if LIBAVFORMAT_VERSION_MAJOR >= 54
56 #include <libavutil/channel_layout.h>
61 #ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
62 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
64 #ifndef AV_ERROR_MAX_STRING_SIZE
65 #define AV_ERROR_MAX_STRING_SIZE 64
67 #ifndef AUDIO_PACKET_ENCODING_SIZE
68 #define AUDIO_PACKET_ENCODING_SIZE 768000 // 48khz * S16 (2 bytes) * max channels (8)
72 static const std::string av_make_error_string(
int errnum)
76 std::string errstring(errbuf);
82 #define av_err2str(errnum) av_make_error_string(errnum).c_str()
86 #define PixelFormat AVPixelFormat
89 #define PIX_FMT_RGBA AV_PIX_FMT_RGBA
92 #define PIX_FMT_NONE AV_PIX_FMT_NONE
95 #define PIX_FMT_RGB24 AV_PIX_FMT_RGB24
97 #ifndef PIX_FMT_YUV420P
98 #define PIX_FMT_YUV420P AV_PIX_FMT_YUV420P
101 #if LIBAVFORMAT_VERSION_MAJOR >= 55
102 #define AV_ALLOCATE_FRAME() av_frame_alloc()
103 #define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame)
104 #define AV_FREE_FRAME(av_frame) av_frame_free(av_frame)
106 #define AV_ALLOCATE_FRAME() avcodec_alloc_frame()
107 #define AV_RESET_FRAME(av_frame) avcodec_get_frame_defaults(av_frame)
108 #define AV_FREE_FRAME(av_frame) avcodec_free_frame(av_frame)
#define AV_ERROR_MAX_STRING_SIZE