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>
14 void avformat_close_input_unique::operator() (AVFormatContext *format_ctx) const
16 avformat_close_input(&format_ctx);
19 AVFormatContextWithCloser avformat_open_input_unique(
20 const char *pathname, AVInputFormat *fmt, AVDictionary **options)
22 AVFormatContext *format_ctx = nullptr;
23 if (avformat_open_input(&format_ctx, pathname, fmt, options) != 0) {
26 return AVFormatContextWithCloser(format_ctx);
32 void avcodec_free_context_unique::operator() (AVCodecContext *codec_ctx) const
34 avcodec_free_context(&codec_ctx);
37 AVCodecContextWithDeleter avcodec_alloc_context3_unique(const AVCodec *codec)
39 return AVCodecContextWithDeleter(avcodec_alloc_context3(codec));
45 void avcodec_parameters_free_unique::operator() (AVCodecParameters *codec_par) const
47 avcodec_parameters_free(&codec_par);
52 void av_frame_free_unique::operator() (AVFrame *frame) const
54 av_frame_free(&frame);
57 AVFrameWithDeleter av_frame_alloc_unique()
59 return AVFrameWithDeleter(av_frame_alloc());