Making mosaic images with ffmpeg
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB

#pragma once
#include "av_base.hpp"
extern "C" {
#include <libavutil/pixfmt.h>
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 <memory>
namespace av {
// AVFormatContext related
using format_context = av::unique_ptr<AVFormatContext>;
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<AVCodecContext>;
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<AVPacket>;
packet read_frame(format_context & ctx, packet_buffer & p);
// AVFrame related
using frame = av::unique_ptr<AVFrame>;
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);
}