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.

43 lines
1.2 KiB

#pragma once
#include <av/av.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
// Basic image representation
// 3 bytes per pixel (rgb), so size of data is width*height*3
struct raw_rgb_image {
std::vector<uint8_t, av::allocator<uint8_t>> data;
av::frame frame;
raw_rgb_image();
raw_rgb_image(int W, int H);
int width() const;
int height() const;
AVPixelFormat format() const;
};
// opens an image in its own format
av::frame open_image(std::string const & filename);
// crops to the bottom right square (cheap operation)
void crop_to_square(av::frame & frame);
av::frame crop_to_square(av::frame const & frame);
av::frame crop_to_square(av::frame && frame);
// converts and resizes
raw_rgb_image to_raw_rgb_image(av::frame const & frame, int new_width, int new_height);
// apply function to every tile, fun :: Column, Row, Image -> Void
void apply_to_tiles(std::string const & filename, int h_tiles, int v_tiles, std::function<void(int, int, av::frame const &)> fun);
// does what you think it does
void save_as_jpg(av::frame const & frame, std::string const & filename);
// encodes an av::frame with yuv pixelformat (is used by save_as_jpg()).
void encode_as_jpg(av::frame const & frame, std::string const & filename);