#pragma once #include "av_base.hpp" extern "C" { #include typedef struct AVDictionary AVDictionary; typedef struct AVFormatContext AVFormatContext; typedef struct AVInputFormat AVInputFormat; typedef struct AVCodecContext AVCodecContext; typedef struct AVCodec AVCodec; typedef struct AVPacket AVPacket; typedef struct AVFrame AVFrame; } #include namespace av { // AVFormatContext related using format_context = av::unique_ptr; format_context format_open_input(std::string const & filename, AVInputFormat* format, AVDictionary** options); format_context format_alloc_context(); // AVCodec related using open_codec = av::unique_ptr; open_codec codec_open(AVCodecContext* ctx, AVCodec* codec, AVDictionary** options); // AVPacket related (this is somewhat strange, but matches the usecase) // I need to rethink this using packet_buffer = AVPacket; using packet = av::unique_ptr; packet read_frame(format_context & ctx, packet_buffer & p); // AVFrame related using frame = av::unique_ptr; frame frame_alloc(); frame frame_clone(frame const & f); // creates a clone with the *same* buffer AVPixelFormat get_format(frame const & f); // Does not copy data, it acts as a view void crop(frame & f, int left, int top, int width, int height); frame crop(frame && f, int left, int top, int width, int height); frame crop(frame const & f, int left, int top, int width, int height); }