28#include <vapoursynth/VSScript4.h>
48 #define VSSCRIPT_LIB "VSScript.dll"
51 #define VSSCRIPT_NAME "libvapoursynth-script"
52 #define VSSCRIPT_LIB VSSCRIPT_NAME SLIBSUF
60typedef const VSSCRIPTAPI *(*VSScriptGetAPIFunc)(
int version);
81#define OFFSET(x) offsetof(VSContext, x)
82#define A AV_OPT_FLAG_AUDIO_PARAM
83#define D AV_OPT_FLAG_DECODING_PARAM
85 {
"max_script_size",
"set max file size supported (in bytes)",
OFFSET(max_script_size),
AV_OPT_TYPE_INT64, {.i64 = 1 * 1024 * 1024}, 0, SIZE_MAX - 1,
A|
D},
91 void *vslibrary =
NULL;
93 const HKEY hkeys[] = {HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE};
96 DWORD buf_size =
sizeof(vss_path) - 2;
101 if ((
r = RegGetValueW(hkeys[
i],
L"SOFTWARE\\VapourSynth",
102 L"VSScriptDLL", RRF_RT_REG_SZ,
NULL,
103 &vss_path, &buf_size)) == ERROR_SUCCESS)
106 if (
r == ERROR_SUCCESS && wchartoutf8(vss_path, &vss_path_utf8) == 0) {
107 vslibrary = dlopen(vss_path_utf8, RTLD_NOW | RTLD_GLOBAL);
112 vslibrary = dlopen(
VSSCRIPT_LIB, RTLD_NOW | RTLD_GLOBAL);
114 if (vslibrary !=
NULL) {
128 vss->vssapi->freeScript(
vss->vss);
162 static const int yuv_order[4] = {0, 1, 2, 0};
163 static const int rgb_order[4] = {1, 2, 0, 0};
167 int is_rgb, is_yuv,
i;
182 is_rgb = vsf->colorFamily == cfRGB;
186 is_yuv = vsf->colorFamily == cfYUV ||
187 vsf->colorFamily == cfGray;
188 if (!is_rgb && !is_yuv)
200 order = is_yuv ? yuv_order : rgb_order;
204 if (order[
c->plane] !=
i ||
205 c->offset != 0 ||
c->shift != 0 ||
206 c->step != vsf->bytesPerSample ||
207 c->depth != vsf->bitsPerSample)
212 memcpy(c_order, order,
sizeof(
int[4]));
231 const VSVideoInfo *info;
237 "Check VapourSynth installation.\n");
242 if (!(vs->
vssapi = get_vssapi(VSSCRIPT_API_VERSION))) {
248 if (!(vs->
vsapi = vs->
vssapi->getVSAPI(VAPOURSYNTH_API_VERSION))) {
250 "Check VapourSynth installation.\n");
297 "value %"PRIi64
", consider increasing the max_script_size option\n",
304 if (vs->
vssapi->evaluateBuffer(vss_state->
vss, buf,
s->url)) {
305 const char *msg = vs->
vssapi->getError(vss_state->
vss);
326 if (!info->format.colorFamily || !info->width || !info->height) {
350 vs->
vsapi->getVideoFormatName(&info->format, vsfmt) ? vsfmt :
"(unknown)");
355 vs->
vsapi->getVideoFormatName(&info->format, vsfmt) ? vsfmt :
"(unknown)",
377 return err || res < INT_MIN || res > INT_MAX ? def : res;
404 const VSFrame *vsframe;
405 const VSVideoInfo *info = vs->
vsapi->getVideoInfo(vs->
outnode);
438 ref_data->
frame = vsframe;
446 props = vs->
vsapi->getFramePropertiesRO(vsframe);
475 for (
i = 0;
i < info->format.numPlanes;
i++) {
477 ptrdiff_t plane_h =
frame->height;
479 frame->data[
i] = (
void *)vs->
vsapi->getReadPtr(vsframe, p);
480 frame->linesize[
i] = vs->
vsapi->getStride(vsframe, p);
492 if (
i == 1 ||
i == 2)
507 pkt->data =
pkt->buf->data;
508 pkt->size =
pkt->buf->size;
541 .class_name =
"VapourSynth demuxer",
548 .p.name =
"vapoursynth",
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int64_t avio_size(AVIOContext *s)
Get the filesize.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
#define AV_CEIL_RSHIFT(a, b)
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
simple arithmetic expression evaluator
static int read_header(FFV1Context *f, RangeCoder *c)
reference-counted frame API
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
@ AV_CODEC_ID_WRAPPED_AVFRAME
Passthrough codec, AVFrames wrapped in AVPacket.
#define AV_PKT_FLAG_TRUSTED
The packet comes from a trusted source.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define AV_TIME_BASE
Internal time base represented as integer.
#define LIBAVUTIL_VERSION_INT
const VDPAUPixFmtMap * map
enum AVPixelFormat pixfmt
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Memory handling functions.
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
Utility function to swap the endianness of a pixel format.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
#define AV_PIX_FMT_FLAG_BAYER
The pixel format is following a Bayer pattern.
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
Describe the class of an AVClass context structure.
enum AVColorSpace color_space
int height
The height of the video frame in pixels.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_... flags.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
uint8_t nb_components
The number of components each pixel has, (1-4)
This structure contains the data a format has to probe a file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t duration
Decoding: duration of the stream, in stream time base.
const VSSCRIPTAPI * vssapi
const VSSCRIPTAPI * vssapi
static av_cold int is_native_endian(enum AVPixelFormat pixfmt)
static av_cold int read_close_vs(AVFormatContext *s)
static av_cold int probe_vs(const AVProbeData *p)
const VSSCRIPTAPI *(* VSScriptGetAPIFunc)(int version)
static av_cold enum AVPixelFormat match_pixfmt(const VSVideoFormat *vsf, int c_order[4])
static void free_frame(void *opaque, uint8_t *data)
static av_cold void * vs_load_library(VSScriptGetAPIFunc *get_vssapi)
static av_cold int read_header_vs(AVFormatContext *s)
static int read_packet_vs(AVFormatContext *s, AVPacket *pkt)
static int read_seek_vs(AVFormatContext *s, int stream_idx, int64_t ts, int flags)
static const AVClass class_vs
static void free_vss_state(void *opaque, uint8_t *data)
static int get_vs_prop_int(AVFormatContext *s, const VSMap *map, const char *name, int def)
static void free_vsframe_ref(void *opaque, uint8_t *data)