1 #include "ffmpeg_raii.h"
4 #include <libavcodec/avcodec.h>
5 #include <libavformat/avformat.h>
6 #include <libavutil/dict.h>
7 #include <libavutil/frame.h>
8 #include <libswscale/swscale.h>
15 void avformat_close_input_unique::operator() (AVFormatContext *format_ctx) const
17 avformat_close_input(&format_ctx);
20 AVFormatContextWithCloser avformat_open_input_unique(
21 const char *pathname, AVInputFormat *fmt, AVDictionary **options)
23 AVFormatContext *format_ctx = nullptr;
24 if (avformat_open_input(&format_ctx, pathname, fmt, options) != 0) {
27 return AVFormatContextWithCloser(format_ctx);
33 void avcodec_free_context_unique::operator() (AVCodecContext *codec_ctx) const
35 avcodec_free_context(&codec_ctx);
38 AVCodecContextWithDeleter avcodec_alloc_context3_unique(const AVCodec *codec)
40 return AVCodecContextWithDeleter(avcodec_alloc_context3(codec));
46 void avcodec_parameters_free_unique::operator() (AVCodecParameters *codec_par) const
48 avcodec_parameters_free(&codec_par);
53 void av_frame_free_unique::operator() (AVFrame *frame) const
55 av_frame_free(&frame);
58 AVFrameWithDeleter av_frame_alloc_unique()
60 return AVFrameWithDeleter(av_frame_alloc());
65 void sws_free_context_unique::operator() (SwsContext *context) const
67 sws_freeContext(context);