FFmpeg
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.h>
29 #include <VSScript.h>
30 
31 #include "libavutil/avassert.h"
32 #include "libavutil/avstring.h"
33 #include "libavutil/eval.h"
34 #include "libavutil/frame.h"
35 #include "libavutil/imgutils.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 struct VSState {
43  VSScript *vss;
44 };
45 
46 typedef struct VSContext {
47  const AVClass *class;
48 
50 
51  const VSAPI *vsapi;
52  VSCore *vscore;
53 
54  VSNodeRef *outnode;
55  int is_cfr;
57 
58  int c_order[4];
59 
60  /* options */
61  int64_t max_script_size;
62 } VSContext;
63 
64 #define OFFSET(x) offsetof(VSContext, x)
65 #define A AV_OPT_FLAG_AUDIO_PARAM
66 #define D AV_OPT_FLAG_DECODING_PARAM
67 static const AVOption options[] = {
68  {"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},
69  {NULL}
70 };
71 
72 static void free_vss_state(void *opaque, uint8_t *data)
73 {
74  struct VSState *vss = opaque;
75 
76  if (vss->vss) {
77  vsscript_freeScript(vss->vss);
78  vsscript_finalize();
79  }
80 }
81 
83 {
84  VSContext *vs = s->priv_data;
85 
86  if (vs->outnode)
87  vs->vsapi->freeNode(vs->outnode);
88 
90 
91  vs->vsapi = NULL;
92  vs->vscore = NULL;
93  vs->outnode = NULL;
94 
95  return 0;
96 }
97 
99 {
101  const AVPixFmtDescriptor *pd;
102  if (other == AV_PIX_FMT_NONE || other == pixfmt)
103  return 1; // not affected by byte order
105  return pd && (!!HAVE_BIGENDIAN == !!(pd->flags & AV_PIX_FMT_FLAG_BE));
106 }
107 
108 static av_cold enum AVPixelFormat match_pixfmt(const VSFormat *vsf, int c_order[4])
109 {
110  static const int yuv_order[4] = {0, 1, 2, 0};
111  static const int rgb_order[4] = {1, 2, 0, 0};
112  const AVPixFmtDescriptor *pd;
113 
114  for (pd = av_pix_fmt_desc_next(NULL); pd; pd = av_pix_fmt_desc_next(pd)) {
115  int is_rgb, is_yuv, i;
116  const int *order;
117  enum AVPixelFormat pixfmt;
118 
120 
124  continue;
125 
126  if (pd->log2_chroma_w != vsf->subSamplingW ||
127  pd->log2_chroma_h != vsf->subSamplingH)
128  continue;
129 
130  is_rgb = vsf->colorFamily == cmRGB;
131  if (is_rgb != !!(pd->flags & AV_PIX_FMT_FLAG_RGB))
132  continue;
133 
134  is_yuv = vsf->colorFamily == cmYUV ||
135  vsf->colorFamily == cmYCoCg ||
136  vsf->colorFamily == cmGray;
137  if (!is_rgb && !is_yuv)
138  continue;
139 
140  if (vsf->sampleType != ((pd->flags & AV_PIX_FMT_FLAG_FLOAT) ? stFloat : stInteger))
141  continue;
142 
143  if (av_pix_fmt_count_planes(pixfmt) != vsf->numPlanes)
144  continue;
145 
146  if (!is_native_endian(pixfmt))
147  continue;
148 
149  order = is_yuv ? yuv_order : rgb_order;
150 
151  for (i = 0; i < pd->nb_components; i++) {
152  const AVComponentDescriptor *c = &pd->comp[i];
153  if (order[c->plane] != i ||
154  c->offset != 0 || c->shift != 0 ||
155  c->step != vsf->bytesPerSample ||
156  c->depth != vsf->bitsPerSample)
157  goto cont;
158  }
159 
160  // Use it.
161  memcpy(c_order, order, sizeof(int[4]));
162  return pixfmt;
163 
164  cont: ;
165  }
166 
167  return AV_PIX_FMT_NONE;
168 }
169 
171 {
172  AVStream *st;
173  AVIOContext *pb = s->pb;
174  VSContext *vs = s->priv_data;
175  int64_t sz = avio_size(pb);
176  char *buf = NULL;
177  char dummy;
178  const VSVideoInfo *info;
179  struct VSState *vss_state;
180  int err = 0;
181 
182  vss_state = av_mallocz(sizeof(*vss_state));
183  if (!vss_state) {
184  err = AVERROR(ENOMEM);
185  goto done;
186  }
187 
188  vs->vss_state = av_buffer_create(NULL, 0, free_vss_state, vss_state, 0);
189  if (!vs->vss_state) {
190  err = AVERROR(ENOMEM);
191  av_free(vss_state);
192  goto done;
193  }
194 
195  if (!vsscript_init()) {
196  av_log(s, AV_LOG_ERROR, "Failed to initialize VSScript (possibly PYTHONPATH not set).\n");
197  err = AVERROR_EXTERNAL;
198  goto done;
199  }
200 
201  if (vsscript_createScript(&vss_state->vss)) {
202  av_log(s, AV_LOG_ERROR, "Failed to create script instance.\n");
203  err = AVERROR_EXTERNAL;
204  vsscript_finalize();
205  goto done;
206  }
207 
208  if (sz < 0 || sz > vs->max_script_size) {
209  if (sz < 0)
210  av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
211  sz = vs->max_script_size;
212  }
213 
214  buf = av_malloc(sz + 1);
215  if (!buf) {
216  err = AVERROR(ENOMEM);
217  goto done;
218  }
219  sz = avio_read(pb, buf, sz);
220 
221  if (sz < 0) {
222  av_log(s, AV_LOG_ERROR, "Could not read script.\n");
223  err = sz;
224  goto done;
225  }
226 
227  // Data left means our buffer (the max_script_size option) is too small
228  if (avio_read(pb, &dummy, 1) == 1) {
229  av_log(s, AV_LOG_ERROR, "File size is larger than max_script_size option "
230  "value %"PRIi64", consider increasing the max_script_size option\n",
231  vs->max_script_size);
233  goto done;
234  }
235 
236  buf[sz] = '\0';
237  if (vsscript_evaluateScript(&vss_state->vss, buf, s->url, 0)) {
238  const char *msg = vsscript_getError(vss_state->vss);
239  av_log(s, AV_LOG_ERROR, "Failed to parse script: %s\n", msg ? msg : "(unknown)");
240  err = AVERROR_EXTERNAL;
241  goto done;
242  }
243 
244  vs->vsapi = vsscript_getVSApi();
245  vs->vscore = vsscript_getCore(vss_state->vss);
246 
247  vs->outnode = vsscript_getOutput(vss_state->vss, 0);
248  if (!vs->outnode) {
249  av_log(s, AV_LOG_ERROR, "Could not get script output node.\n");
250  err = AVERROR_EXTERNAL;
251  goto done;
252  }
253 
254  st = avformat_new_stream(s, NULL);
255  if (!st) {
256  err = AVERROR(ENOMEM);
257  goto done;
258  }
259 
260  info = vs->vsapi->getVideoInfo(vs->outnode);
261 
262  if (!info->format || !info->width || !info->height) {
263  av_log(s, AV_LOG_ERROR, "Non-constant input format not supported.\n");
264  err = AVERROR_PATCHWELCOME;
265  goto done;
266  }
267 
268  if (info->fpsDen) {
269  vs->is_cfr = 1;
270  avpriv_set_pts_info(st, 64, info->fpsDen, info->fpsNum);
271  st->duration = info->numFrames;
272  } else {
273  // VFR. Just set "something".
274  avpriv_set_pts_info(st, 64, 1, AV_TIME_BASE);
275  s->ctx_flags |= AVFMTCTX_UNSEEKABLE;
276  }
277 
280  st->codecpar->width = info->width;
281  st->codecpar->height = info->height;
282  st->codecpar->format = match_pixfmt(info->format, vs->c_order);
283 
284  if (st->codecpar->format == AV_PIX_FMT_NONE) {
285  av_log(s, AV_LOG_ERROR, "Unsupported VS pixel format %s\n", info->format->name);
286  err = AVERROR_EXTERNAL;
287  goto done;
288  }
289  av_log(s, AV_LOG_VERBOSE, "VS format %s -> pixfmt %s\n", info->format->name,
291 
292  if (info->format->colorFamily == cmYCoCg)
294 
295 done:
296  av_free(buf);
297  return err;
298 }
299 
300 static void free_frame(void *opaque, uint8_t *data)
301 {
302  AVFrame *frame = (AVFrame *)data;
303 
305 }
306 
307 static int get_vs_prop_int(AVFormatContext *s, const VSMap *map, const char *name, int def)
308 {
309  VSContext *vs = s->priv_data;
310  int64_t res;
311  int err = 1;
312 
313  res = vs->vsapi->propGetInt(map, name, 0, &err);
314  return err || res < INT_MIN || res > INT_MAX ? def : res;
315 }
316 
318  const VSAPI *vsapi;
319  const VSFrameRef *frame;
321 };
322 
323 static void free_vsframe_ref(void *opaque, uint8_t *data)
324 {
325  struct vsframe_ref_data *d = opaque;
326 
327  if (d->frame)
328  d->vsapi->freeFrame(d->frame);
329 
330  av_buffer_unref(&d->vss_state);
331 
332  av_free(d);
333 }
334 
336 {
337  VSContext *vs = s->priv_data;
338  AVStream *st = s->streams[0];
339  AVFrame *frame = NULL;
340  char vserr[80];
341  const VSFrameRef *vsframe;
342  const VSVideoInfo *info = vs->vsapi->getVideoInfo(vs->outnode);
343  const VSMap *props;
344  const AVPixFmtDescriptor *desc;
345  AVBufferRef *vsframe_ref = NULL;
346  struct vsframe_ref_data *ref_data;
347  int err = 0;
348  int i;
349 
350  if (vs->current_frame >= info->numFrames)
351  return AVERROR_EOF;
352 
353  ref_data = av_mallocz(sizeof(*ref_data));
354  if (!ref_data) {
355  err = AVERROR(ENOMEM);
356  goto end;
357  }
358 
359  // (the READONLY flag is important because the ref is reused for plane data)
360  vsframe_ref = av_buffer_create(NULL, 0, free_vsframe_ref, ref_data, AV_BUFFER_FLAG_READONLY);
361  if (!vsframe_ref) {
362  err = AVERROR(ENOMEM);
363  av_free(ref_data);
364  goto end;
365  }
366 
367  vsframe = vs->vsapi->getFrame(vs->current_frame, vs->outnode, vserr, sizeof(vserr));
368  if (!vsframe) {
369  av_log(s, AV_LOG_ERROR, "Error getting frame: %s\n", vserr);
370  err = AVERROR_EXTERNAL;
371  goto end;
372  }
373 
374  ref_data->vsapi = vs->vsapi;
375  ref_data->frame = vsframe;
376 
377  ref_data->vss_state = av_buffer_ref(vs->vss_state);
378  if (!ref_data->vss_state) {
379  err = AVERROR(ENOMEM);
380  goto end;
381  }
382 
383  props = vs->vsapi->getFramePropsRO(vsframe);
384 
385  frame = av_frame_alloc();
386  if (!frame) {
387  err = AVERROR(ENOMEM);
388  goto end;
389  }
390 
391  frame->format = st->codecpar->format;
392  frame->width = st->codecpar->width;
393  frame->height = st->codecpar->height;
395 
396  // Values according to ISO/IEC 14496-10.
397  frame->colorspace = get_vs_prop_int(s, props, "_Matrix", frame->colorspace);
398  frame->color_primaries = get_vs_prop_int(s, props, "_Primaries", frame->color_primaries);
399  frame->color_trc = get_vs_prop_int(s, props, "_Transfer", frame->color_trc);
400 
401  if (get_vs_prop_int(s, props, "_ColorRange", 1) == 0)
403 
404  frame->sample_aspect_ratio.num = get_vs_prop_int(s, props, "_SARNum", 0);
405  frame->sample_aspect_ratio.den = get_vs_prop_int(s, props, "_SARDen", 1);
406 
407  av_assert0(vs->vsapi->getFrameWidth(vsframe, 0) == frame->width);
408  av_assert0(vs->vsapi->getFrameHeight(vsframe, 0) == frame->height);
409 
411 
412  for (i = 0; i < info->format->numPlanes; i++) {
413  int p = vs->c_order[i];
414  ptrdiff_t plane_h = frame->height;
415 
416  frame->data[i] = (void *)vs->vsapi->getReadPtr(vsframe, p);
417  frame->linesize[i] = vs->vsapi->getStride(vsframe, p);
418 
419  frame->buf[i] = av_buffer_ref(vsframe_ref);
420  if (!frame->buf[i]) {
421  err = AVERROR(ENOMEM);
422  goto end;
423  }
424 
425  // Each plane needs an AVBufferRef that indicates the correct plane
426  // memory range. VapourSynth doesn't even give us the memory range,
427  // so make up a bad guess to make FFmpeg happy (even if almost nothing
428  // checks the memory range).
429  if (i == 1 || i == 2)
430  plane_h = AV_CEIL_RSHIFT(plane_h, desc->log2_chroma_h);
431  frame->buf[i]->data = frame->data[i];
432  frame->buf[i]->size = frame->linesize[i] * plane_h;
433  }
434 
435  pkt->buf = av_buffer_create((uint8_t*)frame, sizeof(*frame),
436  free_frame, NULL, 0);
437  if (!pkt->buf) {
438  err = AVERROR(ENOMEM);
439  goto end;
440  }
441 
442  frame = NULL; // pkt owns it now
443 
444  pkt->data = pkt->buf->data;
445  pkt->size = pkt->buf->size;
447 
448  if (vs->is_cfr)
449  pkt->pts = vs->current_frame;
450 
451  vs->current_frame++;
452 
453 end:
455  av_buffer_unref(&vsframe_ref);
456  return err;
457 }
458 
459 static int read_seek_vs(AVFormatContext *s, int stream_idx, int64_t ts, int flags)
460 {
461  VSContext *vs = s->priv_data;
462 
463  if (!vs->is_cfr)
464  return AVERROR(ENOSYS);
465 
466  vs->current_frame = FFMIN(FFMAX(0, ts), s->streams[0]->duration);
467  return 0;
468 }
469 
470 static av_cold int probe_vs(const AVProbeData *p)
471 {
472  // Explicitly do not support this. VS scripts are written in Python, and
473  // can run arbitrary code on the user's system.
474  return 0;
475 }
476 
477 static const AVClass class_vs = {
478  .class_name = "VapourSynth demuxer",
479  .item_name = av_default_item_name,
480  .option = options,
481  .version = LIBAVUTIL_VERSION_INT,
482 };
483 
485  .p.name = "vapoursynth",
486  .p.long_name = NULL_IF_CONFIG_SMALL("VapourSynth demuxer"),
487  .p.priv_class = &class_vs,
488  .priv_data_size = sizeof(VSContext),
489  .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
490  .read_probe = probe_vs,
495 };
AVFrame::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:658
av_pix_fmt_swap_endianness
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
Utility function to swap the endianness of a pixel format.
Definition: pixdesc.c:3017
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:654
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
AVCodecParameters::color_space
enum AVColorSpace color_space
Definition: codec_par.h:169
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
VSContext::current_frame
int current_frame
Definition: vapoursynth.c:56
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2962
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
ff_vapoursynth_demuxer
const FFInputFormat ff_vapoursynth_demuxer
Definition: vapoursynth.c:484
AV_PIX_FMT_FLAG_FLOAT
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:158
AVFrame::color_primaries
enum AVColorPrimaries color_primaries
Definition: frame.h:656
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:665
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:375
pixdesc.h
AVFrame::width
int width
Definition: frame.h:447
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:683
AVPacket::data
uint8_t * data
Definition: packet.h:522
AVOption
AVOption.
Definition: opt.h:346
vsframe_ref_data::vss_state
AVBufferRef * vss_state
Definition: vapoursynth.c:320
data
const char data[16]
Definition: mxf.c:148
av_pix_fmt_desc_next
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
Definition: pixdesc.c:2969
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
OFFSET
#define OFFSET(x)
Definition: vapoursynth.c:64
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
get_vs_prop_int
static int get_vs_prop_int(AVFormatContext *s, const VSMap *map, const char *name, int def)
Definition: vapoursynth.c:307
AVFrame::buf
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:588
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:322
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:396
free_vss_state
static void free_vss_state(void *opaque, uint8_t *data)
Definition: vapoursynth.c:72
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3002
VSContext::outnode
VSNodeRef * outnode
Definition: vapoursynth.c:54
avpriv_set_pts_info
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:853
class_vs
static const AVClass class_vs
Definition: vapoursynth.c:477
VSContext::vscore
VSCore * vscore
Definition: vapoursynth.c:52
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:151
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
dummy
int dummy
Definition: motion.c:66
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:143
AVERROR_BUFFER_TOO_SMALL
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
Definition: error.h:53
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:802
AVRational::num
int num
Numerator.
Definition: rational.h:59
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:148
avassert.h
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_read_callback.c:41
options
static const AVOption options[]
Definition: vapoursynth.c:67
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
AV_BUFFER_FLAG_READONLY
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
Definition: buffer.h:114
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:553
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:134
info
MIPS optimizations info
Definition: mips.txt:2
vsframe_ref_data::vsapi
const VSAPI * vsapi
Definition: vapoursynth.c:318
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:236
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
VSContext::max_script_size
int64_t max_script_size
Definition: vapoursynth.c:61
read_header_vs
static av_cold int read_header_vs(AVFormatContext *s)
Definition: vapoursynth.c:170
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
limits.h
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
AV_CODEC_ID_WRAPPED_AVFRAME
@ AV_CODEC_ID_WRAPPED_AVFRAME
Passthrough codec, AVFrames wrapped in AVPacket.
Definition: codec_id.h:600
frame
static AVFrame * frame
Definition: demux_decode.c:54
FF_INFMT_FLAG_INIT_CLEANUP
#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
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
internal.h
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: packet.h:505
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:766
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:550
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
VSContext::c_order
int c_order[4]
Definition: vapoursynth.c:58
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
av_buffer_unref
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
AVComponentDescriptor
Definition: pixdesc.h:30
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
AVFMTCTX_UNSEEKABLE
#define AVFMTCTX_UNSEEKABLE
signal that the stream is definitely not seekable, and attempts to call the seek function will fail.
Definition: avformat.h:1208
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:451
VSContext::vsapi
const VSAPI * vsapi
Definition: vapoursynth.c:51
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:618
read_seek_vs
static int read_seek_vs(AVFormatContext *s, int stream_idx, int64_t ts, int flags)
Definition: vapoursynth.c:459
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
is_native_endian
static av_cold int is_native_endian(enum AVPixelFormat pixfmt)
Definition: vapoursynth.c:98
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
av_buffer_create
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
VSState::vss
VSScript * vss
Definition: vapoursynth.c:43
eval.h
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
AVPacket::size
int size
Definition: packet.h:523
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
AV_PIX_FMT_FLAG_BITSTREAM
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:124
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:462
VSContext::vss_state
AVBufferRef * vss_state
Definition: vapoursynth.c:49
frame.h
FFInputFormat::p
AVInputFormat p
The public AVInputFormat.
Definition: demux.h:41
read_close_vs
static av_cold int read_close_vs(AVFormatContext *s)
Definition: vapoursynth.c:82
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
av_pix_fmt_desc_get_id
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition: pixdesc.c:2981
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:528
AVBufferRef::size
size_t size
Size of data in bytes.
Definition: buffer.h:94
AV_PIX_FMT_FLAG_BAYER
#define AV_PIX_FMT_FLAG_BAYER
The pixel format is following a Bayer pattern.
Definition: pixdesc.h:152
free_frame
static void free_frame(void *opaque, uint8_t *data)
Definition: vapoursynth.c:300
VSContext::is_cfr
int is_cfr
Definition: vapoursynth.c:55
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:515
read_packet_vs
static int read_packet_vs(AVFormatContext *s, AVPacket *pkt)
Definition: vapoursynth.c:335
AVCodecParameters::height
int height
Definition: codec_par.h:135
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_FLAG_BE
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:116
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
VSContext
Definition: vapoursynth.c:46
demux.h
match_pixfmt
static av_cold enum AVPixelFormat match_pixfmt(const VSFormat *vsf, int c_order[4])
Definition: vapoursynth.c:108
AVStream
Stream structure.
Definition: avformat.h:743
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:366
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
avformat.h
AVFrame::sample_aspect_ratio
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:482
A
#define A
Definition: vapoursynth.c:65
AVFrame::height
int height
Definition: frame.h:447
probe_vs
static av_cold int probe_vs(const AVProbeData *p)
Definition: vapoursynth.c:470
AV_PIX_FMT_FLAG_XYZ
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
Definition: pixdesc.h:163
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:611
vsframe_ref_data
Definition: vapoursynth.c:317
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
desc
const char * desc
Definition: libsvtav1.c:75
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
read_probe
static int read_probe(const AVProbeData *p)
Definition: cdg.c:30
D
#define D
Definition: vapoursynth.c:66
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
AVCodecParameters::format
int format
Definition: codec_par.h:92
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:499
vsframe_ref_data::frame
const VSFrameRef * frame
Definition: vapoursynth.c:319
FFInputFormat
Definition: demux.h:37
d
d
Definition: ffmpeg_filter.c:409
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:420
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
avstring.h
AV_PKT_FLAG_TRUSTED
#define AV_PKT_FLAG_TRUSTED
The packet comes from a trusted source.
Definition: packet.h:591
VSState
Definition: vapoursynth.c:42
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
free_vsframe_ref
static void free_vsframe_ref(void *opaque, uint8_t *data)
Definition: vapoursynth.c:323
av_get_pix_fmt_name
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:2882