FFmpeg
Loading...
Searching...
No Matches
vapoursynth.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/**
20* @file
21* VapourSynth demuxer
22*
23* Synthesizes vapour (?)
24*/
25
26#include <limits.h>
27
28#include <vapoursynth/VSScript4.h>
29
30#include "libavutil/avassert.h"
31#include "libavutil/avstring.h"
32#include "libavutil/eval.h"
33#include "libavutil/frame.h"
34#include "libavutil/imgutils.h"
35#include "libavutil/mem.h"
36#include "libavutil/opt.h"
37#include "libavutil/pixdesc.h"
38#include "avformat.h"
39#include "demux.h"
40#include "internal.h"
41
42/* Platform-specific directives. */
43#ifdef _WIN32
44 #include <windows.h>
45 #include "compat/w32dlfcn.h"
47 #undef EXTERN_C
48 #define VSSCRIPT_LIB "VSScript.dll"
49#else
50 #include <dlfcn.h>
51 #define VSSCRIPT_NAME "libvapoursynth-script"
52 #define VSSCRIPT_LIB VSSCRIPT_NAME SLIBSUF
53#endif
54
55struct VSState {
56 const VSSCRIPTAPI *vssapi;
57 VSScript *vss;
58};
59
60typedef const VSSCRIPTAPI *(*VSScriptGetAPIFunc)(int version);
61
62typedef struct VSContext {
63 const AVClass *class;
64
66
67 const VSSCRIPTAPI *vssapi;
68 const VSAPI *vsapi;
69 void *vslibrary;
70
71 VSNode *outnode;
72 int is_cfr;
74
75 int c_order[4];
76
77 /* options */
79} VSContext;
80
81#define OFFSET(x) offsetof(VSContext, x)
82#define A AV_OPT_FLAG_AUDIO_PARAM
83#define D AV_OPT_FLAG_DECODING_PARAM
84static const AVOption options[] = {
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},
86 {NULL}
87};
88
90{
91 void *vslibrary = NULL;
92#ifdef _WIN32
93 const HKEY hkeys[] = {HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE};
94 LONG r;
95 WCHAR vss_path[512];
96 DWORD buf_size = sizeof(vss_path) - 2;
97 char *vss_path_utf8;
98 int i;
99
100 for (i = 0; i < FF_ARRAY_ELEMS(hkeys); i++) {
101 if ((r = RegGetValueW(hkeys[i], L"SOFTWARE\\VapourSynth",
102 L"VSScriptDLL", RRF_RT_REG_SZ, NULL,
103 &vss_path, &buf_size)) == ERROR_SUCCESS)
104 break;
105 }
106 if (r == ERROR_SUCCESS && wchartoutf8(vss_path, &vss_path_utf8) == 0) {
107 vslibrary = dlopen(vss_path_utf8, RTLD_NOW | RTLD_GLOBAL);
108 av_free(vss_path_utf8);
109 }
110 else
111#endif
112 vslibrary = dlopen(VSSCRIPT_LIB, RTLD_NOW | RTLD_GLOBAL);
113
114 if (vslibrary != NULL) {
115 if (!(*get_vssapi = (VSScriptGetAPIFunc)dlsym(vslibrary, "getVSScriptAPI"))) {
116 dlclose(vslibrary);
117 return NULL;
118 }
119 }
120 return vslibrary;
121}
122
123static void free_vss_state(void *opaque, uint8_t *data)
124{
125 struct VSState *vss = opaque;
126
127 if (vss->vss) {
128 vss->vssapi->freeScript(vss->vss);
129 }
130}
131
133{
134 VSContext *vs = s->priv_data;
135
136 if (vs->outnode)
137 vs->vsapi->freeNode(vs->outnode);
138
140
141 vs->vsapi = NULL;
142 vs->outnode = NULL;
143
144 if (vs->vslibrary)
145 dlclose(vs->vslibrary);
146
147 return 0;
148}
149
151{
153 const AVPixFmtDescriptor *pd;
154 if (other == AV_PIX_FMT_NONE || other == pixfmt)
155 return 1; // not affected by byte order
157 return pd && (!!HAVE_BIGENDIAN == !!(pd->flags & AV_PIX_FMT_FLAG_BE));
158}
159
160static av_cold enum AVPixelFormat match_pixfmt(const VSVideoFormat *vsf, int c_order[4])
161{
162 static const int yuv_order[4] = {0, 1, 2, 0};
163 static const int rgb_order[4] = {1, 2, 0, 0};
164 const AVPixFmtDescriptor *pd;
165
166 for (pd = av_pix_fmt_desc_next(NULL); pd; pd = av_pix_fmt_desc_next(pd)) {
167 int is_rgb, is_yuv, i;
168 const int *order;
170
172
176 continue;
177
178 if (pd->log2_chroma_w != vsf->subSamplingW ||
179 pd->log2_chroma_h != vsf->subSamplingH)
180 continue;
181
182 is_rgb = vsf->colorFamily == cfRGB;
183 if (is_rgb != !!(pd->flags & AV_PIX_FMT_FLAG_RGB))
184 continue;
185
186 is_yuv = vsf->colorFamily == cfYUV ||
187 vsf->colorFamily == cfGray;
188 if (!is_rgb && !is_yuv)
189 continue;
190
191 if (vsf->sampleType != ((pd->flags & AV_PIX_FMT_FLAG_FLOAT) ? stFloat : stInteger))
192 continue;
193
194 if (av_pix_fmt_count_planes(pixfmt) != vsf->numPlanes)
195 continue;
196
198 continue;
199
200 order = is_yuv ? yuv_order : rgb_order;
201
202 for (i = 0; i < pd->nb_components; i++) {
203 const AVComponentDescriptor *c = &pd->comp[i];
204 if (order[c->plane] != i ||
205 c->offset != 0 || c->shift != 0 ||
206 c->step != vsf->bytesPerSample ||
207 c->depth != vsf->bitsPerSample)
208 goto cont;
209 }
210
211 // Use it.
212 memcpy(c_order, order, sizeof(int[4]));
213 return pixfmt;
214
215 cont: ;
216 }
217
218 return AV_PIX_FMT_NONE;
219}
220
222{
223 AVStream *st;
224 AVIOContext *pb = s->pb;
225 VSContext *vs = s->priv_data;
226 VSScriptGetAPIFunc get_vssapi;
227 int64_t sz = avio_size(pb);
228 char *buf = NULL;
229 char dummy;
230 char vsfmt[32];
231 const VSVideoInfo *info;
232 struct VSState *vss_state;
233 int err = 0;
234
235 if (!(vs->vslibrary = vs_load_library(&get_vssapi))) {
236 av_log(s, AV_LOG_ERROR, "Could not open " VSSCRIPT_LIB ". "
237 "Check VapourSynth installation.\n");
238 err = AVERROR_EXTERNAL;
239 goto done;
240 }
241
242 if (!(vs->vssapi = get_vssapi(VSSCRIPT_API_VERSION))) {
243 av_log(s, AV_LOG_ERROR, "Failed to initialize VSScript (possibly PYTHONPATH not set).\n");
244 err = AVERROR_EXTERNAL;
245 goto done;
246 }
247
248 if (!(vs->vsapi = vs->vssapi->getVSAPI(VAPOURSYNTH_API_VERSION))) {
249 av_log(s, AV_LOG_ERROR, "Could not get VSAPI. "
250 "Check VapourSynth installation.\n");
251 err = AVERROR_EXTERNAL;
252 goto done;
253 }
254
255 vss_state = av_mallocz(sizeof(*vss_state));
256 if (!vss_state) {
257 err = AVERROR(ENOMEM);
258 goto done;
259 }
260 vss_state->vssapi = vs->vssapi;
261
262 vs->vss_state = av_buffer_create(NULL, 0, free_vss_state, vss_state, 0);
263 if (!vs->vss_state) {
264 err = AVERROR(ENOMEM);
265 av_free(vss_state);
266 goto done;
267 }
268
269 if (!(vss_state->vss = vs->vssapi->createScript(NULL))) {
270 av_log(s, AV_LOG_ERROR, "Failed to create script instance.\n");
271 err = AVERROR_EXTERNAL;
272 goto done;
273 }
274
275 if (sz < 0 || sz > vs->max_script_size) {
276 if (sz < 0)
277 av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
278 sz = vs->max_script_size;
279 }
280
281 buf = av_malloc(sz + 1);
282 if (!buf) {
283 err = AVERROR(ENOMEM);
284 goto done;
285 }
286 sz = avio_read(pb, buf, sz);
287
288 if (sz < 0) {
289 av_log(s, AV_LOG_ERROR, "Could not read script.\n");
290 err = sz;
291 goto done;
292 }
293
294 // Data left means our buffer (the max_script_size option) is too small
295 if (avio_read(pb, &dummy, 1) == 1) {
296 av_log(s, AV_LOG_ERROR, "File size is larger than max_script_size option "
297 "value %"PRIi64", consider increasing the max_script_size option\n",
298 vs->max_script_size);
300 goto done;
301 }
302
303 buf[sz] = '\0';
304 if (vs->vssapi->evaluateBuffer(vss_state->vss, buf, s->url)) {
305 const char *msg = vs->vssapi->getError(vss_state->vss);
306 av_log(s, AV_LOG_ERROR, "Failed to parse script: %s\n", msg ? msg : "(unknown)");
307 err = AVERROR_EXTERNAL;
308 goto done;
309 }
310
311 vs->outnode = vs->vssapi->getOutputNode(vss_state->vss, 0);
312 if (!vs->outnode) {
313 av_log(s, AV_LOG_ERROR, "Could not get script output node.\n");
314 err = AVERROR_EXTERNAL;
315 goto done;
316 }
317
319 if (!st) {
320 err = AVERROR(ENOMEM);
321 goto done;
322 }
323
324 info = vs->vsapi->getVideoInfo(vs->outnode);
325
326 if (!info->format.colorFamily || !info->width || !info->height) {
327 av_log(s, AV_LOG_ERROR, "Non-constant input format not supported.\n");
329 goto done;
330 }
331
332 if (info->fpsDen) {
333 vs->is_cfr = 1;
334 avpriv_set_pts_info(st, 64, info->fpsDen, info->fpsNum);
335 st->duration = info->numFrames;
336 } else {
337 // VFR. Just set "something".
339 s->ctx_flags |= AVFMTCTX_UNSEEKABLE;
340 }
341
344 st->codecpar->width = info->width;
345 st->codecpar->height = info->height;
346 st->codecpar->format = match_pixfmt(&info->format, vs->c_order);
347
348 if (st->codecpar->format == AV_PIX_FMT_NONE) {
349 av_log(s, AV_LOG_ERROR, "Unsupported VS pixel format %s\n",
350 vs->vsapi->getVideoFormatName(&info->format, vsfmt) ? vsfmt : "(unknown)");
351 err = AVERROR_EXTERNAL;
352 goto done;
353 }
354 av_log(s, AV_LOG_VERBOSE, "VS format %s -> pixfmt %s\n",
355 vs->vsapi->getVideoFormatName(&info->format, vsfmt) ? vsfmt : "(unknown)",
357
358done:
359 av_free(buf);
360 return err;
361}
362
363static void free_frame(void *opaque, uint8_t *data)
364{
366
368}
369
370static int get_vs_prop_int(AVFormatContext *s, const VSMap *map, const char *name, int def)
371{
372 VSContext *vs = s->priv_data;
373 int64_t res;
374 int err = 1;
375
376 res = vs->vsapi->mapGetInt(map, name, 0, &err);
377 return err || res < INT_MIN || res > INT_MAX ? def : res;
378}
379
381 const VSAPI *vsapi;
382 const VSFrame *frame;
384};
385
386static void free_vsframe_ref(void *opaque, uint8_t *data)
387{
388 struct vsframe_ref_data *d = opaque;
389
390 if (d->frame)
391 d->vsapi->freeFrame(d->frame);
392
394
395 av_free(d);
396}
397
399{
400 VSContext *vs = s->priv_data;
401 AVStream *st = s->streams[0];
402 AVFrame *frame = NULL;
403 char vserr[80];
404 const VSFrame *vsframe;
405 const VSVideoInfo *info = vs->vsapi->getVideoInfo(vs->outnode);
406 const VSMap *props;
408 AVBufferRef *vsframe_ref = NULL;
409 struct vsframe_ref_data *ref_data;
410 int err = 0;
411 int i;
412
413 if (vs->current_frame >= info->numFrames)
414 return AVERROR_EOF;
415
416 ref_data = av_mallocz(sizeof(*ref_data));
417 if (!ref_data) {
418 err = AVERROR(ENOMEM);
419 goto end;
420 }
421
422 // (the READONLY flag is important because the ref is reused for plane data)
424 if (!vsframe_ref) {
425 err = AVERROR(ENOMEM);
426 av_free(ref_data);
427 goto end;
428 }
429
430 vsframe = vs->vsapi->getFrame(vs->current_frame, vs->outnode, vserr, sizeof(vserr));
431 if (!vsframe) {
432 av_log(s, AV_LOG_ERROR, "Error getting frame: %s\n", vserr);
433 err = AVERROR_EXTERNAL;
434 goto end;
435 }
436
437 ref_data->vsapi = vs->vsapi;
438 ref_data->frame = vsframe;
439
440 ref_data->vss_state = av_buffer_ref(vs->vss_state);
441 if (!ref_data->vss_state) {
442 err = AVERROR(ENOMEM);
443 goto end;
444 }
445
446 props = vs->vsapi->getFramePropertiesRO(vsframe);
447
449 if (!frame) {
450 err = AVERROR(ENOMEM);
451 goto end;
452 }
453
454 frame->format = st->codecpar->format;
455 frame->width = st->codecpar->width;
456 frame->height = st->codecpar->height;
457 frame->colorspace = st->codecpar->color_space;
458
459 // Values according to ISO/IEC 14496-10.
460 frame->colorspace = get_vs_prop_int(s, props, "_Matrix", frame->colorspace);
461 frame->color_primaries = get_vs_prop_int(s, props, "_Primaries", frame->color_primaries);
462 frame->color_trc = get_vs_prop_int(s, props, "_Transfer", frame->color_trc);
463
464 if (get_vs_prop_int(s, props, "_ColorRange", 1) == 0)
465 frame->color_range = AVCOL_RANGE_JPEG;
466
467 frame->sample_aspect_ratio.num = get_vs_prop_int(s, props, "_SARNum", 0);
468 frame->sample_aspect_ratio.den = get_vs_prop_int(s, props, "_SARDen", 1);
469
470 av_assert0(vs->vsapi->getFrameWidth(vsframe, 0) == frame->width);
471 av_assert0(vs->vsapi->getFrameHeight(vsframe, 0) == frame->height);
472
473 desc = av_pix_fmt_desc_get(frame->format);
474
475 for (i = 0; i < info->format.numPlanes; i++) {
476 int p = vs->c_order[i];
477 ptrdiff_t plane_h = frame->height;
478
479 frame->data[i] = (void *)vs->vsapi->getReadPtr(vsframe, p);
480 frame->linesize[i] = vs->vsapi->getStride(vsframe, p);
481
482 frame->buf[i] = av_buffer_ref(vsframe_ref);
483 if (!frame->buf[i]) {
484 err = AVERROR(ENOMEM);
485 goto end;
486 }
487
488 // Each plane needs an AVBufferRef that indicates the correct plane
489 // memory range. VapourSynth doesn't even give us the memory range,
490 // so make up a bad guess to make FFmpeg happy (even if almost nothing
491 // checks the memory range).
492 if (i == 1 || i == 2)
493 plane_h = AV_CEIL_RSHIFT(plane_h, desc->log2_chroma_h);
494 frame->buf[i]->data = frame->data[i];
495 frame->buf[i]->size = frame->linesize[i] * plane_h;
496 }
497
498 pkt->buf = av_buffer_create((uint8_t*)frame, sizeof(*frame),
499 free_frame, NULL, 0);
500 if (!pkt->buf) {
501 err = AVERROR(ENOMEM);
502 goto end;
503 }
504
505 frame = NULL; // pkt owns it now
506
507 pkt->data = pkt->buf->data;
508 pkt->size = pkt->buf->size;
509 pkt->flags |= AV_PKT_FLAG_TRUSTED;
510
511 if (vs->is_cfr)
512 pkt->pts = vs->current_frame;
513
514 vs->current_frame++;
515
516end:
518 av_buffer_unref(&vsframe_ref);
519 return err;
520}
521
522static int read_seek_vs(AVFormatContext *s, int stream_idx, int64_t ts, int flags)
523{
524 VSContext *vs = s->priv_data;
525
526 if (!vs->is_cfr)
527 return AVERROR(ENOSYS);
528
529 vs->current_frame = FFMIN(FFMAX(0, ts), s->streams[0]->duration);
530 return 0;
531}
532
533static av_cold int probe_vs(const AVProbeData *p)
534{
535 // Explicitly do not support this. VS scripts are written in Python, and
536 // can run arbitrary code on the user's system.
537 return 0;
538}
539
540static const AVClass class_vs = {
541 .class_name = "VapourSynth demuxer",
542 .item_name = av_default_item_name,
543 .option = options,
544 .version = LIBAVUTIL_VERSION_INT,
545};
546
548 .p.name = "vapoursynth",
549 .p.long_name = NULL_IF_CONFIG_SMALL("VapourSynth demuxer"),
550 .p.priv_class = &class_vs,
551 .priv_data_size = sizeof(VSContext),
552 .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
558};
const FFInputFormat ff_vapoursynth_demuxer
#define A(x)
Definition vpx_arith.h:28
#define L(x)
Definition vpx_arith.h:36
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
#define D
Definition avdct.c:35
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition avformat.c:834
Main libavformat public API header.
#define AVFMTCTX_UNSEEKABLE
signal that the stream is definitely not seekable, and attempts to call the seek function will fail.
Definition avformat.h:1286
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition aviobuf.c:326
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:615
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
#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...
Definition demux.h:35
static AVPacket * pkt
static AVFrame * frame
simple arithmetic expression evaluator
static int dummy
Definition ffplay.c:3754
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
reference-counted frame API
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition opt.h:262
@ AV_CODEC_ID_WRAPPED_AVFRAME
Passthrough codec, AVFrames wrapped in AVPacket.
Definition codec_id.h:621
#define AV_PKT_FLAG_TRUSTED
The packet comes from a trusted source.
Definition packet.h:664
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.
Definition buffer.c:139
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition buffer.c:103
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
Definition buffer.h:114
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.
Definition buffer.c:55
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
Definition error.h:53
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition error.h:59
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:52
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define AV_TIME_BASE
Internal time base represented as integer.
Definition avutil.h:253
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
const VDPAUPixFmtMap * map
misc image utilities
#define r
Definition input.c:42
enum AVPixelFormat pixfmt
Definition kmsgrab.c:367
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
version
Definition libkvazaar.c:313
const char * desc
Definition libsvtav1.c:83
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
Memory handling functions.
const char data[16]
Definition mxf.c:149
#define av_malloc(s)
Definition ops_static.c:52
AVOptions.
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition pixdesc.c:3479
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3500
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
Definition pixdesc.c:3467
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.
Definition pixdesc.c:3380
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
Utility function to swap the endianness of a pixel format.
Definition pixdesc.c:3515
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition pixdesc.h:147
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition pixdesc.h:124
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition pixdesc.h:136
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition pixdesc.h:158
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition pixdesc.h:128
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition pixdesc.h:116
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
Definition pixdesc.h:163
#define AV_PIX_FMT_FLAG_BAYER
The pixel format is following a Bayer pattern.
Definition pixdesc.h:152
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:783
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
const char * name
Definition qsvenc.c:142
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
Definition buffer.h:82
Describe the class of an AVClass context structure.
Definition log.h:76
enum AVColorSpace color_space
Definition codec_par.h:192
int height
The height of the video frame in pixels.
Definition codec_par.h:150
int width
The width of the video frame in pixels.
Definition codec_par.h:143
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
Format I/O context.
Definition avformat.h:1333
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
Bytestream IO Context.
Definition avio.h:160
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:580
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition pixdesc.h:105
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition pixdesc.h:80
uint64_t flags
Combination of AV_PIX_FMT_FLAG_... flags.
Definition pixdesc.h:94
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition pixdesc.h:89
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition pixdesc.h:71
This structure contains the data a format has to probe a file.
Definition avformat.h:471
Stream structure.
Definition avformat.h:766
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:789
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition avformat.h:825
AVBufferRef * vss_state
Definition vapoursynth.c:65
int64_t max_script_size
Definition vapoursynth.c:78
VSNode * outnode
Definition vapoursynth.c:71
int current_frame
Definition vapoursynth.c:73
const VSSCRIPTAPI * vssapi
Definition vapoursynth.c:67
void * vslibrary
Definition vapoursynth.c:69
int c_order[4]
Definition vapoursynth.c:75
const VSAPI * vsapi
Definition vapoursynth.c:68
const VSSCRIPTAPI * vssapi
Definition vapoursynth.c:56
VSScript * vss
Definition vapoursynth.c:57
AVBufferRef * vss_state
const VSFrame * frame
const VSAPI * vsapi
#define av_free(p)
#define av_mallocz(s)
#define av_log(a,...)
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)
Definition vapoursynth.c:60
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)
Definition vapoursynth.c:89
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
#define OFFSET(x)
Definition vapoursynth.c:81
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)
#define VSSCRIPT_LIB
Definition vapoursynth.c:52
static void free_vsframe_ref(void *opaque, uint8_t *data)
static double c[64]