FFmpeg
avisynth.c
Go to the documentation of this file.
1 /*
2  * AviSynth(+) support
3  * Copyright (c) 2012 AvxSynth Team
4  *
5  * This file is part of FFmpeg
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/attributes.h"
23 #include "libavutil/internal.h"
24 #include "libavutil/mem.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/thread.h"
27 
28 #include "avformat.h"
29 #include "demux.h"
30 #include "internal.h"
31 #include "config.h"
32 
33 /* Enable function pointer definitions for runtime loading. */
34 #define AVSC_NO_DECLSPEC
35 
36 /* Platform-specific directives. */
37 #ifdef _WIN32
38  #include "compat/w32dlfcn.h"
40  #undef EXTERN_C
41  #define AVISYNTH_LIB "avisynth"
42 #else
43  #include <dlfcn.h>
44  #define AVISYNTH_NAME "libavisynth"
45  #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
46 #endif
47 
48 /* Endianness guards for audio */
49 #if HAVE_BIGENDIAN
50  #define PCM(format) (AV_CODEC_ID_PCM_ ## format ## BE)
51 #else
52  #define PCM(format) (AV_CODEC_ID_PCM_ ## format ## LE)
53 #endif
54 
55 #include <avisynth/avisynth_c.h>
56 
57 typedef struct AviSynthLibrary {
58  void *library;
59 #define AVSC_DECLARE_FUNC(name) name ## _func name
60  AVSC_DECLARE_FUNC(avs_bit_blt);
61  AVSC_DECLARE_FUNC(avs_clip_get_error);
62  AVSC_DECLARE_FUNC(avs_check_version);
63  AVSC_DECLARE_FUNC(avs_create_script_environment);
64  AVSC_DECLARE_FUNC(avs_delete_script_environment);
65  AVSC_DECLARE_FUNC(avs_get_audio);
66  AVSC_DECLARE_FUNC(avs_get_channel_mask);
67  AVSC_DECLARE_FUNC(avs_get_error);
68  AVSC_DECLARE_FUNC(avs_get_frame);
69  AVSC_DECLARE_FUNC(avs_get_version);
70  AVSC_DECLARE_FUNC(avs_get_video_info);
71  AVSC_DECLARE_FUNC(avs_invoke);
72  AVSC_DECLARE_FUNC(avs_is_color_space);
73  AVSC_DECLARE_FUNC(avs_release_clip);
74  AVSC_DECLARE_FUNC(avs_release_value);
75  AVSC_DECLARE_FUNC(avs_release_video_frame);
76  AVSC_DECLARE_FUNC(avs_take_clip);
77  AVSC_DECLARE_FUNC(avs_bits_per_pixel);
78  AVSC_DECLARE_FUNC(avs_get_height_p);
79  AVSC_DECLARE_FUNC(avs_get_pitch_p);
80  AVSC_DECLARE_FUNC(avs_get_read_ptr_p);
81  AVSC_DECLARE_FUNC(avs_get_row_size_p);
82  AVSC_DECLARE_FUNC(avs_is_planar_rgb);
83  AVSC_DECLARE_FUNC(avs_is_planar_rgba);
84  AVSC_DECLARE_FUNC(avs_get_frame_props_ro);
85  AVSC_DECLARE_FUNC(avs_prop_get_int);
86  AVSC_DECLARE_FUNC(avs_prop_get_type);
87  AVSC_DECLARE_FUNC(avs_get_env_property);
88 #undef AVSC_DECLARE_FUNC
90 
91 typedef enum AviSynthFlags {
100 
101 typedef struct AviSynthContext {
102  const AVClass *class;
103  AVS_ScriptEnvironment *env;
104  AVS_Clip *clip;
105  const AVS_VideoInfo *vi;
106 
107  /* avisynth_read_packet_video() iterates over this. */
108  int n_planes;
109  const int *planes;
110 
113  int64_t curr_sample;
114 
115  int error;
116 
117  uint32_t flags;
118 
119  /* Linked list pointers. */
122 
123 static const int avs_planes_packed[1] = { 0 };
124 static const int avs_planes_grey[1] = { AVS_PLANAR_Y };
125 static const int avs_planes_yuv[3] = { AVS_PLANAR_Y, AVS_PLANAR_U,
126  AVS_PLANAR_V };
127 static const int avs_planes_rgb[3] = { AVS_PLANAR_G, AVS_PLANAR_B,
128  AVS_PLANAR_R };
129 static const int avs_planes_yuva[4] = { AVS_PLANAR_Y, AVS_PLANAR_U,
130  AVS_PLANAR_V, AVS_PLANAR_A };
131 static const int avs_planes_rgba[4] = { AVS_PLANAR_G, AVS_PLANAR_B,
132  AVS_PLANAR_R, AVS_PLANAR_A };
133 
135 
136 /* A conflict between C++ global objects, atexit, and dynamic loading requires
137  * us to register our own atexit handler to prevent double freeing. */
139 static int avs_atexit_called = 0;
140 
141 /* Linked list of AviSynthContexts. An atexit handler destroys this list. */
143 
144 static av_cold void avisynth_atexit_handler(void);
145 
147 {
148  avs_library.library = dlopen(AVISYNTH_LIB, RTLD_NOW | RTLD_LOCAL);
149  if (!avs_library.library)
150  return AVERROR_UNKNOWN;
151 
152 #define LOAD_AVS_FUNC(name, continue_on_fail) \
153  avs_library.name = (name ## _func) \
154  dlsym(avs_library.library, #name); \
155  if (!continue_on_fail && !avs_library.name) \
156  goto fail;
157 
158  LOAD_AVS_FUNC(avs_bit_blt, 0);
159  LOAD_AVS_FUNC(avs_clip_get_error, 0);
160  LOAD_AVS_FUNC(avs_check_version, 0);
161  LOAD_AVS_FUNC(avs_create_script_environment, 0);
162  LOAD_AVS_FUNC(avs_delete_script_environment, 0);
163  LOAD_AVS_FUNC(avs_get_audio, 0);
164  LOAD_AVS_FUNC(avs_get_channel_mask, 1);
165  LOAD_AVS_FUNC(avs_get_error, 1); // New to AviSynth 2.6
166  LOAD_AVS_FUNC(avs_get_frame, 0);
167  LOAD_AVS_FUNC(avs_get_version, 0);
168  LOAD_AVS_FUNC(avs_get_video_info, 0);
169  LOAD_AVS_FUNC(avs_invoke, 0);
170  LOAD_AVS_FUNC(avs_is_color_space, 1);
171  LOAD_AVS_FUNC(avs_release_clip, 0);
172  LOAD_AVS_FUNC(avs_release_value, 0);
173  LOAD_AVS_FUNC(avs_release_video_frame, 0);
174  LOAD_AVS_FUNC(avs_take_clip, 0);
175  LOAD_AVS_FUNC(avs_bits_per_pixel, 1);
176  LOAD_AVS_FUNC(avs_get_height_p, 1);
177  LOAD_AVS_FUNC(avs_get_pitch_p, 1);
178  LOAD_AVS_FUNC(avs_get_read_ptr_p, 1);
179  LOAD_AVS_FUNC(avs_get_row_size_p, 1);
180  LOAD_AVS_FUNC(avs_is_planar_rgb, 1);
181  LOAD_AVS_FUNC(avs_is_planar_rgba, 1);
182  LOAD_AVS_FUNC(avs_get_frame_props_ro, 1);
183  LOAD_AVS_FUNC(avs_prop_get_int, 1);
184  LOAD_AVS_FUNC(avs_prop_get_type, 1);
185  LOAD_AVS_FUNC(avs_get_env_property, 1);
186 #undef LOAD_AVS_FUNC
187 
188  atexit(avisynth_atexit_handler);
189  return 0;
190 
191 fail:
192  dlclose(avs_library.library);
193  return AVERROR_UNKNOWN;
194 }
195 
196 /* Note that avisynth_context_create and avisynth_context_destroy
197  * do not allocate or free the actual context! That is taken care of
198  * by libavformat. */
200 {
201  AviSynthContext *avs = s->priv_data;
202  int ret;
203 
204  if (!avs_library.library)
205  if (ret = avisynth_load_library())
206  return ret;
207 
208  avs->env = avs_library.avs_create_script_environment(3);
209  if (avs_library.avs_get_error) {
210  const char *error = avs_library.avs_get_error(avs->env);
211  if (error) {
212  av_log(s, AV_LOG_ERROR, "%s\n", error);
213  return AVERROR_UNKNOWN;
214  }
215  }
216 
217  if (!avs_ctx_list) {
218  avs_ctx_list = avs;
219  } else {
220  avs->next = avs_ctx_list;
221  avs_ctx_list = avs;
222  }
223 
224  return 0;
225 }
226 
228 {
229  if (avs_atexit_called)
230  return;
231 
232  if (avs == avs_ctx_list) {
233  avs_ctx_list = avs->next;
234  } else {
236  while (prev->next != avs)
237  prev = prev->next;
238  prev->next = avs->next;
239  }
240 
241  if (avs->clip) {
242  avs_library.avs_release_clip(avs->clip);
243  avs->clip = NULL;
244  }
245  if (avs->env) {
246  avs_library.avs_delete_script_environment(avs->env);
247  avs->env = NULL;
248  }
249 }
250 
252 {
254 
255  while (avs) {
256  AviSynthContext *next = avs->next;
258  avs = next;
259  }
260  dlclose(avs_library.library);
261 
262  avs_atexit_called = 1;
263 }
264 
265 /* Create AVStream from audio and video data. */
267 {
268  AviSynthContext *avs = s->priv_data;
269  const AVS_Map *avsmap;
270  AVS_VideoFrame *frame;
271  int error;
272  int planar = 0; // 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA
273  int sar_num = 1;
274  int sar_den = 1;
275 
278  st->codecpar->width = avs->vi->width;
279  st->codecpar->height = avs->vi->height;
280 
281  st->avg_frame_rate = (AVRational) { avs->vi->fps_numerator,
282  avs->vi->fps_denominator };
283  st->start_time = 0;
284  st->duration = avs->vi->num_frames;
285  st->nb_frames = avs->vi->num_frames;
286  avpriv_set_pts_info(st, 32, avs->vi->fps_denominator, avs->vi->fps_numerator);
287 
288 
289  switch (avs->vi->pixel_type) {
290  /* 10~16-bit YUV pix_fmts (AviSynth+) */
291  case AVS_CS_YUV444P10:
293  planar = 1;
294  break;
295  case AVS_CS_YUV422P10:
297  planar = 1;
298  break;
299  case AVS_CS_YUV420P10:
301  planar = 1;
302  break;
303  case AVS_CS_YUV444P12:
305  planar = 1;
306  break;
307  case AVS_CS_YUV422P12:
309  planar = 1;
310  break;
311  case AVS_CS_YUV420P12:
313  planar = 1;
314  break;
315  case AVS_CS_YUV444P14:
317  planar = 1;
318  break;
319  case AVS_CS_YUV422P14:
321  planar = 1;
322  break;
323  case AVS_CS_YUV420P14:
325  planar = 1;
326  break;
327  case AVS_CS_YUV444P16:
329  planar = 1;
330  break;
331  case AVS_CS_YUV422P16:
333  planar = 1;
334  break;
335  case AVS_CS_YUV420P16:
337  planar = 1;
338  break;
339  /* 8~16-bit YUV pix_fmts with Alpha (AviSynth+) */
340  case AVS_CS_YUVA444:
342  planar = 4;
343  break;
344  case AVS_CS_YUVA422:
346  planar = 4;
347  break;
348  case AVS_CS_YUVA420:
350  planar = 4;
351  break;
352  case AVS_CS_YUVA444P10:
354  planar = 4;
355  break;
356  case AVS_CS_YUVA422P10:
358  planar = 4;
359  break;
360  case AVS_CS_YUVA420P10:
362  planar = 4;
363  break;
364  case AVS_CS_YUVA422P12:
366  planar = 4;
367  break;
368  case AVS_CS_YUVA444P16:
370  planar = 4;
371  break;
372  case AVS_CS_YUVA422P16:
374  planar = 4;
375  break;
376  case AVS_CS_YUVA420P16:
378  planar = 4;
379  break;
380  /* Planar RGB pix_fmts (AviSynth+) */
381  case AVS_CS_RGBP:
383  planar = 3;
384  break;
385  case AVS_CS_RGBP10:
387  planar = 3;
388  break;
389  case AVS_CS_RGBP12:
391  planar = 3;
392  break;
393  case AVS_CS_RGBP14:
395  planar = 3;
396  break;
397  case AVS_CS_RGBP16:
399  planar = 3;
400  break;
401  /* Single precision floating point Planar RGB (AviSynth+) */
402  case AVS_CS_RGBPS:
404  planar = 3;
405  break;
406  /* Planar RGB pix_fmts with Alpha (AviSynth+) */
407  case AVS_CS_RGBAP:
409  planar = 5;
410  break;
411  case AVS_CS_RGBAP10:
413  planar = 5;
414  break;
415  case AVS_CS_RGBAP12:
417  planar = 5;
418  break;
419  case AVS_CS_RGBAP16:
421  planar = 5;
422  break;
423  /* Single precision floating point Planar RGB with Alpha (AviSynth+) */
424  case AVS_CS_RGBAPS:
426  planar = 5;
427  break;
428  /* 10~16-bit gray pix_fmts (AviSynth+) */
429  case AVS_CS_Y10:
431  planar = 2;
432  break;
433  case AVS_CS_Y12:
435  planar = 2;
436  break;
437  case AVS_CS_Y14:
439  planar = 2;
440  break;
441  case AVS_CS_Y16:
443  planar = 2;
444  break;
445  /* Single precision floating point gray (AviSynth+) */
446  case AVS_CS_Y32:
448  planar = 2;
449  break;
450  /* pix_fmts added in AviSynth 2.6 */
451  case AVS_CS_YV24:
453  planar = 1;
454  break;
455  case AVS_CS_YV16:
457  planar = 1;
458  break;
459  case AVS_CS_YV411:
461  planar = 1;
462  break;
463  case AVS_CS_Y8:
465  planar = 2;
466  break;
467  /* 16-bit packed RGB pix_fmts (AviSynth+) */
468  case AVS_CS_BGR48:
470  break;
471  case AVS_CS_BGR64:
473  break;
474  /* AviSynth 2.5 pix_fmts */
475  case AVS_CS_BGR24:
477  break;
478  case AVS_CS_BGR32:
480  break;
481  case AVS_CS_YUY2:
483  break;
484  case AVS_CS_YV12:
486  planar = 1;
487  break;
488  case AVS_CS_I420: // Is this even used anywhere?
490  planar = 1;
491  break;
492  default:
494  "unknown AviSynth colorspace %d\n", avs->vi->pixel_type);
495  avs->error = 1;
496  return AVERROR_UNKNOWN;
497  }
498 
499  switch (planar) {
500  case 5: // Planar RGB + Alpha
501  avs->n_planes = 4;
502  avs->planes = avs_planes_rgba;
503  break;
504  case 4: // YUV + Alpha
505  avs->n_planes = 4;
506  avs->planes = avs_planes_yuva;
507  break;
508  case 3: // Planar RGB
509  avs->n_planes = 3;
510  avs->planes = avs_planes_rgb;
511  break;
512  case 2: // Y8
513  avs->n_planes = 1;
514  avs->planes = avs_planes_grey;
515  break;
516  case 1: // YUV
517  avs->n_planes = 3;
518  avs->planes = avs_planes_yuv;
519  break;
520  default:
521  avs->n_planes = 1;
522  avs->planes = avs_planes_packed;
523  }
524 
525  /* Read AviSynth+'s frame properties to set additional info.
526  *
527  * Due to a bug preventing the C interface from accessing frame
528  * properties in earlier versions of interface version 8, and
529  * previous attempts at being clever resulting in pre-8 versions
530  * of AviSynth+ segfaulting, only enable this if we detect
531  * version 9 at the minimum. Technically, 8.1 works, but the time
532  * distance between 8.1 and 9 is very small, so just restrict it to 9. */
533 
534  if (avs_library.avs_get_version(avs->clip) >= 9) {
535 
536  frame = avs_library.avs_get_frame(avs->clip, 0);
537  avsmap = avs_library.avs_get_frame_props_ro(avs->env, frame);
538 
539  /* Field order */
541  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_FieldBased") == AVS_PROPTYPE_UNSET) {
543  } else {
544  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_FieldBased", 0, &error)) {
545  case 0:
547  break;
548  case 1:
550  break;
551  case 2:
553  break;
554  default:
556  }
557  }
558  }
559 
560  /* Color Range */
561  if(avs->flags & AVISYNTH_FRAMEPROP_RANGE) {
562  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ColorRange") == AVS_PROPTYPE_UNSET) {
564  } else {
565  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ColorRange", 0, &error)) {
566  case 0:
568  break;
569  case 1:
571  break;
572  default:
574  }
575  }
576  }
577 
578  /* Color Primaries */
580  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Primaries", 0, &error)) {
581  case 1:
583  break;
584  case 2:
586  break;
587  case 4:
589  break;
590  case 5:
592  break;
593  case 6:
595  break;
596  case 7:
598  break;
599  case 8:
601  break;
602  case 9:
604  break;
605  case 10:
607  break;
608  case 11:
610  break;
611  case 12:
613  break;
614  case 22:
616  break;
617  default:
619  }
620  }
621 
622  /* Color Transfer Characteristics */
624  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Transfer", 0, &error)) {
625  case 1:
627  break;
628  case 2:
630  break;
631  case 4:
633  break;
634  case 5:
636  break;
637  case 6:
639  break;
640  case 7:
642  break;
643  case 8:
645  break;
646  case 9:
648  break;
649  case 10:
651  break;
652  case 11:
654  break;
655  case 12:
657  break;
658  case 13:
660  break;
661  case 14:
663  break;
664  case 15:
666  break;
667  case 16:
669  break;
670  case 17:
672  break;
673  case 18:
675  break;
676  default:
678  }
679  }
680 
681  /* Matrix coefficients */
682  if(avs->flags & AVISYNTH_FRAMEPROP_MATRIX) {
683  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_Matrix") == AVS_PROPTYPE_UNSET) {
685  } else {
686  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Matrix", 0, &error)) {
687  case 0:
689  break;
690  case 1:
692  break;
693  case 2:
695  break;
696  case 4:
698  break;
699  case 5:
701  break;
702  case 6:
704  break;
705  case 7:
707  break;
708  case 8:
710  break;
711  case 9:
713  break;
714  case 10:
716  break;
717  case 11:
719  break;
720  case 12:
722  break;
723  case 13:
725  break;
726  case 14:
728  break;
729  default:
731  }
732  }
733  }
734 
735  /* Chroma Location */
737  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ChromaLocation") == AVS_PROPTYPE_UNSET) {
739  } else {
740  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ChromaLocation", 0, &error)) {
741  case 0:
743  break;
744  case 1:
746  break;
747  case 2:
749  break;
750  case 3:
752  break;
753  case 4:
755  break;
756  case 5:
758  break;
759  default:
761  }
762  }
763  }
764 
765  /* Sample aspect ratio */
766  if(avs->flags & AVISYNTH_FRAMEPROP_SAR) {
767  sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error);
768  sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error);
769  st->sample_aspect_ratio = (AVRational){ sar_num, sar_den };
770  }
771 
772  avs_library.avs_release_video_frame(frame);
773  } else {
775  /* AviSynth works with frame-based video, detecting field order can
776  * only work when avs_is_field_based returns 'false'. */
777  av_log(s, AV_LOG_TRACE, "avs_is_field_based: %d\n", avs_is_field_based(avs->vi));
778  if (avs_is_field_based(avs->vi) == 0) {
779  if (avs_is_tff(avs->vi)) {
781  }
782  else if (avs_is_bff(avs->vi)) {
784  }
785  }
786  }
787 
788  return 0;
789 }
790 
792 {
793  AviSynthContext *avs = s->priv_data;
794 
796  st->codecpar->sample_rate = avs->vi->audio_samples_per_second;
797  st->codecpar->ch_layout.nb_channels = avs->vi->nchannels;
798  st->duration = avs->vi->num_audio_samples;
799  avpriv_set_pts_info(st, 64, 1, avs->vi->audio_samples_per_second);
800 
801  if (avs_library.avs_get_version(avs->clip) >= 10)
803  avs_library.avs_get_channel_mask(avs->vi));
804 
805  switch (avs->vi->sample_type) {
806  case AVS_SAMPLE_INT8:
808  break;
809  case AVS_SAMPLE_INT16:
810  st->codecpar->codec_id = PCM(S16);
811  break;
812  case AVS_SAMPLE_INT24:
813  st->codecpar->codec_id = PCM(S24);
814  break;
815  case AVS_SAMPLE_INT32:
816  st->codecpar->codec_id = PCM(S32);
817  break;
818  case AVS_SAMPLE_FLOAT:
819  st->codecpar->codec_id = PCM(F32);
820  break;
821  default:
823  "unknown AviSynth sample type %d\n", avs->vi->sample_type);
824  avs->error = 1;
825  return AVERROR_UNKNOWN;
826  }
827  return 0;
828 }
829 
831 {
832  AviSynthContext *avs = s->priv_data;
833  AVStream *st;
834  int ret;
835  int id = 0;
836 
837  if (avs_has_video(avs->vi)) {
838  st = avformat_new_stream(s, NULL);
839  if (!st)
840  return AVERROR_UNKNOWN;
841  st->id = id++;
843  return ret;
844  }
845  if (avs_has_audio(avs->vi)) {
846  st = avformat_new_stream(s, NULL);
847  if (!st)
848  return AVERROR_UNKNOWN;
849  st->id = id++;
851  return ret;
852  }
853  return 0;
854 }
855 
857 {
858  AviSynthContext *avs = s->priv_data;
859  AVS_Value val;
860  int ret;
861 
863  return ret;
864 
865  if (!avs_library.avs_check_version(avs->env, 7)) {
866  AVS_Value args[] = {
867  avs_new_value_string(s->url),
868  avs_new_value_bool(1) // filename is in UTF-8
869  };
870  val = avs_library.avs_invoke(avs->env, "Import",
871  avs_new_value_array(args, 2), 0);
872  } else {
873  AVS_Value arg;
874 #ifdef _WIN32
875  char *filename_ansi;
876  /* Convert UTF-8 to ANSI code page */
877  if (utf8toansi(s->url, &filename_ansi)) {
879  goto fail;
880  }
881  arg = avs_new_value_string(filename_ansi);
882 #else
883  arg = avs_new_value_string(s->url);
884 #endif
885  val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
886 #ifdef _WIN32
887  av_free(filename_ansi);
888 #endif
889  }
890 
891  if (avs_is_error(val)) {
892  av_log(s, AV_LOG_ERROR, "%s\n", avs_as_error(val));
894  goto fail;
895  }
896  if (!avs_is_clip(val)) {
897  av_log(s, AV_LOG_ERROR, "AviSynth script did not return a clip\n");
899  goto fail;
900  }
901 
902  avs->clip = avs_library.avs_take_clip(val, avs->env);
903  avs->vi = avs_library.avs_get_video_info(avs->clip);
904 
905  /* On Windows, FFmpeg supports AviSynth interface version 6 or higher.
906  * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher,
907  * and excludes 2.5 and the 2.6 alphas. */
908 
909  if (avs_library.avs_get_version(avs->clip) < 6) {
911  "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
913  goto fail;
914  }
915 
916  /* Release the AVS_Value as it will go out of scope. */
917  avs_library.avs_release_value(val);
918 
920  goto fail;
921 
922  return 0;
923 
924 fail:
926  return ret;
927 }
928 
930  AVPacket *pkt, int *discard)
931 {
932  AviSynthContext *avs = s->priv_data;
933 
934  avs->curr_stream++;
935  avs->curr_stream %= s->nb_streams;
936 
937  *st = s->streams[avs->curr_stream];
938  if ((*st)->discard == AVDISCARD_ALL)
939  *discard = 1;
940  else
941  *discard = 0;
942 
943  return;
944 }
945 
946 /* Copy AviSynth clip data into an AVPacket. */
948  int discard)
949 {
950  AviSynthContext *avs = s->priv_data;
951  AVS_VideoFrame *frame;
952  unsigned char *dst_p;
953  const unsigned char *src_p;
954  int n, i, plane, rowsize, planeheight, pitch, bits, ret;
955  const char *error;
956 
957  if (avs->curr_frame >= avs->vi->num_frames)
958  return AVERROR_EOF;
959 
960  /* This must happen even if the stream is discarded to prevent desync. */
961  n = avs->curr_frame++;
962  if (discard)
963  return 0;
964 
965  bits = avs_library.avs_bits_per_pixel(avs->vi);
966 
967  /* Without the cast to int64_t, calculation overflows at about 9k x 9k
968  * resolution. */
969  pkt->size = (((int64_t)avs->vi->width *
970  (int64_t)avs->vi->height) * bits) / 8;
971  if (!pkt->size)
972  return AVERROR_UNKNOWN;
973 
974  if ((ret = av_new_packet(pkt, pkt->size)) < 0)
975  return ret;
976 
977  pkt->pts = n;
978  pkt->dts = n;
979  pkt->duration = 1;
980  pkt->stream_index = avs->curr_stream;
981 
982  frame = avs_library.avs_get_frame(avs->clip, n);
983  error = avs_library.avs_clip_get_error(avs->clip);
984  if (error) {
985  av_log(s, AV_LOG_ERROR, "%s\n", error);
986  avs->error = 1;
988  return AVERROR_UNKNOWN;
989  }
990 
991  dst_p = pkt->data;
992  for (i = 0; i < avs->n_planes; i++) {
993  plane = avs->planes[i];
994  src_p = avs_library.avs_get_read_ptr_p(frame, plane);
995  pitch = avs_library.avs_get_pitch_p(frame, plane);
996 
997  rowsize = avs_library.avs_get_row_size_p(frame, plane);
998  planeheight = avs_library.avs_get_height_p(frame, plane);
999 
1000  /* Flip RGB video. */
1001  if (avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR) ||
1002  avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR48) ||
1003  avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR64)) {
1004  src_p = src_p + (planeheight - 1) * pitch;
1005  pitch = -pitch;
1006  }
1007 
1008  avs_library.avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch,
1009  rowsize, planeheight);
1010  dst_p += rowsize * planeheight;
1011  }
1012 
1013  avs_library.avs_release_video_frame(frame);
1014  return 0;
1015 }
1016 
1018  int discard)
1019 {
1020  AviSynthContext *avs = s->priv_data;
1021  AVRational fps, samplerate;
1022  int samples, ret;
1023  int64_t n;
1024  const char *error;
1025 
1026  if (avs->curr_sample >= avs->vi->num_audio_samples)
1027  return AVERROR_EOF;
1028 
1029  fps.num = avs->vi->fps_numerator;
1030  fps.den = avs->vi->fps_denominator;
1031  samplerate.num = avs->vi->audio_samples_per_second;
1032  samplerate.den = 1;
1033 
1034  if (avs_has_video(avs->vi)) {
1035  if (avs->curr_frame < avs->vi->num_frames)
1036  samples = av_rescale_q(avs->curr_frame, samplerate, fps) -
1037  avs->curr_sample;
1038  else
1039  samples = av_rescale_q(1, samplerate, fps);
1040  } else {
1041  samples = 1000;
1042  }
1043 
1044  /* After seeking, audio may catch up with video. */
1045  if (samples <= 0) {
1046  pkt->size = 0;
1047  pkt->data = NULL;
1048  return 0;
1049  }
1050 
1051  if (avs->curr_sample + samples > avs->vi->num_audio_samples)
1052  samples = avs->vi->num_audio_samples - avs->curr_sample;
1053 
1054  /* This must happen even if the stream is discarded to prevent desync. */
1055  n = avs->curr_sample;
1056  avs->curr_sample += samples;
1057  if (discard)
1058  return 0;
1059 
1060  pkt->size = avs_bytes_per_channel_sample(avs->vi) *
1061  samples * avs->vi->nchannels;
1062  if (!pkt->size)
1063  return AVERROR_UNKNOWN;
1064 
1065  if ((ret = av_new_packet(pkt, pkt->size)) < 0)
1066  return ret;
1067 
1068  pkt->pts = n;
1069  pkt->dts = n;
1070  pkt->duration = samples;
1071  pkt->stream_index = avs->curr_stream;
1072 
1073  avs_library.avs_get_audio(avs->clip, pkt->data, n, samples);
1074  error = avs_library.avs_clip_get_error(avs->clip);
1075  if (error) {
1076  av_log(s, AV_LOG_ERROR, "%s\n", error);
1077  avs->error = 1;
1079  return AVERROR_UNKNOWN;
1080  }
1081  return 0;
1082 }
1083 
1085 {
1086  int ret;
1087 
1088  // Calling library must implement a lock for thread-safe opens.
1090  return AVERROR_UNKNOWN;
1091 
1092  if (ret = avisynth_open_file(s)) {
1094  return ret;
1095  }
1096 
1098  return 0;
1099 }
1100 
1102 {
1103  AviSynthContext *avs = s->priv_data;
1104  AVStream *st;
1105  int discard = 0;
1106  int ret;
1107 
1108  if (avs->error)
1109  return AVERROR_UNKNOWN;
1110 
1111  /* If either stream reaches EOF, try to read the other one before
1112  * giving up. */
1113  avisynth_next_stream(s, &st, pkt, &discard);
1114  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
1115  ret = avisynth_read_packet_video(s, pkt, discard);
1116  if (ret == AVERROR_EOF && avs_has_audio(avs->vi)) {
1117  avisynth_next_stream(s, &st, pkt, &discard);
1118  return avisynth_read_packet_audio(s, pkt, discard);
1119  }
1120  } else {
1121  ret = avisynth_read_packet_audio(s, pkt, discard);
1122  if (ret == AVERROR_EOF && avs_has_video(avs->vi)) {
1123  avisynth_next_stream(s, &st, pkt, &discard);
1124  return avisynth_read_packet_video(s, pkt, discard);
1125  }
1126  }
1127 
1128  return ret;
1129 }
1130 
1132 {
1134  return AVERROR_UNKNOWN;
1135 
1136  avisynth_context_destroy(s->priv_data);
1138  return 0;
1139 }
1140 
1141 static int avisynth_read_seek(AVFormatContext *s, int stream_index,
1142  int64_t timestamp, int flags)
1143 {
1144  AviSynthContext *avs = s->priv_data;
1145  AVStream *st;
1146  AVRational fps, samplerate;
1147 
1148  if (avs->error)
1149  return AVERROR_UNKNOWN;
1150 
1151  fps = (AVRational) { avs->vi->fps_numerator,
1152  avs->vi->fps_denominator };
1153  samplerate = (AVRational) { avs->vi->audio_samples_per_second, 1 };
1154 
1155  st = s->streams[stream_index];
1156  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
1157  /* AviSynth frame counts are signed int. */
1158  if ((timestamp >= avs->vi->num_frames) ||
1159  (timestamp > INT_MAX) ||
1160  (timestamp < 0))
1161  return AVERROR_EOF;
1162  avs->curr_frame = timestamp;
1163  if (avs_has_audio(avs->vi))
1164  avs->curr_sample = av_rescale_q(timestamp, samplerate, fps);
1165  } else {
1166  if ((timestamp >= avs->vi->num_audio_samples) || (timestamp < 0))
1167  return AVERROR_EOF;
1168  /* Force frame granularity for seeking. */
1169  if (avs_has_video(avs->vi)) {
1170  avs->curr_frame = av_rescale_q(timestamp, fps, samplerate);
1171  avs->curr_sample = av_rescale_q(avs->curr_frame, samplerate, fps);
1172  } else {
1173  avs->curr_sample = timestamp;
1174  }
1175  }
1176 
1177  return 0;
1178 }
1179 
1180 #define AVISYNTH_FRAMEPROP_DEFAULT AVISYNTH_FRAMEPROP_FIELD_ORDER | AVISYNTH_FRAMEPROP_RANGE | \
1181  AVISYNTH_FRAMEPROP_PRIMARIES | AVISYNTH_FRAMEPROP_TRANSFER | \
1182  AVISYNTH_FRAMEPROP_MATRIX | AVISYNTH_FRAMEPROP_CHROMA_LOCATION
1183 #define OFFSET(x) offsetof(AviSynthContext, x)
1184 static const AVOption avisynth_options[] = {
1185  { "avisynth_flags", "set flags related to reading frame properties from script (AviSynth+ v3.7.1 or higher)", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = AVISYNTH_FRAMEPROP_DEFAULT}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1186  { "field_order", "read field order", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_FIELD_ORDER}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1187  { "range", "read color range", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_RANGE}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1188  { "primaries", "read color primaries", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_PRIMARIES}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1189  { "transfer", "read color transfer characteristics", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_TRANSFER}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1190  { "matrix", "read matrix coefficients", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_MATRIX}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1191  { "chroma_location", "read chroma location", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_CHROMA_LOCATION}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1192  { "sar", "read sample aspect ratio", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_SAR}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1193  { NULL },
1194 };
1195 
1197  .class_name = "AviSynth demuxer",
1198  .item_name = av_default_item_name,
1199  .option = avisynth_options,
1200  .version = LIBAVUTIL_VERSION_INT,
1201 };
1202 
1204  .p.name = "avisynth",
1205  .p.long_name = NULL_IF_CONFIG_SMALL("AviSynth script"),
1206  .p.extensions = "avs",
1207  .p.priv_class = &avisynth_demuxer_class,
1208  .priv_data_size = sizeof(AviSynthContext),
1213 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:522
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: packet.c:427
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:501
wchar_filename.h
AVCOL_PRI_EBU3213
@ AVCOL_PRI_EBU3213
EBU Tech. 3213-E (nothing there) / one of JEDEC P22 group phosphors.
Definition: pixfmt.h:571
opt.h
avisynth_demuxer_class
static const AVClass avisynth_demuxer_class
Definition: avisynth.c:1196
avisynth_atexit_handler
static av_cold void avisynth_atexit_handler(void)
Definition: avisynth.c:251
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
OFFSET
#define OFFSET(x)
Definition: avisynth.c:1183
avisynth_load_library
static av_cold int avisynth_load_library(void)
Definition: avisynth.c:146
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.
thread.h
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AV_FIELD_PROGRESSIVE
@ AV_FIELD_PROGRESSIVE
Definition: defs.h:201
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:589
AVCHROMA_LOC_BOTTOM
@ AVCHROMA_LOC_BOTTOM
Definition: pixfmt.h:712
avisynth_read_seek
static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: avisynth.c:1141
avisynth_read_packet
static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: avisynth.c:1101
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:65
AviSynthContext::curr_sample
int64_t curr_sample
Definition: avisynth.c:113
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:521
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:686
avs_atexit_called
static int avs_atexit_called
Definition: avisynth.c:139
AVPacket::data
uint8_t * data
Definition: packet.h:520
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:516
AviSynthLibrary::library
void * library
Definition: avisynth.c:58
avs_planes_yuv
static const int avs_planes_yuv[3]
Definition: avisynth.c:125
AVOption
AVOption.
Definition: opt.h:357
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:583
AVISYNTH_FRAMEPROP_MATRIX
@ AVISYNTH_FRAMEPROP_MATRIX
Definition: avisynth.c:96
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:832
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:610
AVCOL_TRC_BT2020_12
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
Definition: pixfmt.h:596
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:538
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:321
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:517
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:621
AviSynthContext::curr_stream
int curr_stream
Definition: avisynth.c:111
ff_mutex_unlock
static int ff_mutex_unlock(AVMutex *mutex)
Definition: thread.h:189
AVCodecParameters::color_primaries
enum AVColorPrimaries color_primaries
Definition: codec_par.h:167
AviSynthLibrary
Definition: avisynth.c:57
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:615
AV_FIELD_TT
@ AV_FIELD_TT
Top coded_first, top displayed first.
Definition: defs.h:202
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
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:496
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:594
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
fail
#define fail()
Definition: checkasm.h:185
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:494
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:151
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:523
AVISYNTH_FRAMEPROP_SAR
@ AVISYNTH_FRAMEPROP_SAR
Definition: avisynth.c:98
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:586
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:143
val
static double val(void *priv, double ch)
Definition: aeval.c:78
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:462
AVCOL_TRC_LOG_SQRT
@ AVCOL_TRC_LOG_SQRT
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
Definition: pixfmt.h:591
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:802
AVISYNTH_LIB
#define AVISYNTH_LIB
Definition: avisynth.c:45
planar
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1<< 16)) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out->ch+ch,(const uint8_t **) in->ch+ch, off *(out-> planar
Definition: audioconvert.c:56
AVRational::num
int num
Numerator.
Definition: rational.h:59
avisynth_create_stream_video
static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
Definition: avisynth.c:266
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:585
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
AVCodecParameters::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: codec_par.h:168
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:206
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
avisynth_mutex
static AVMutex avisynth_mutex
Definition: avisynth.c:134
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:490
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_read_callback.c:42
AV_FIELD_UNKNOWN
@ AV_FIELD_UNKNOWN
Definition: defs.h:200
AVMutex
#define AVMutex
Definition: thread.h:184
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:498
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVCHROMA_LOC_TOP
@ AVCHROMA_LOC_TOP
Definition: pixfmt.h:710
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: packet.c:98
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:499
LOAD_AVS_FUNC
#define LOAD_AVS_FUNC(name, continue_on_fail)
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
AVCOL_TRC_BT1361_ECG
@ AVCOL_TRC_BT1361_ECG
ITU-R BT1361 Extended Colour Gamut.
Definition: pixfmt.h:593
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:491
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:553
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:616
avisynth_read_close
static av_cold int avisynth_read_close(AVFormatContext *s)
Definition: avisynth.c:1131
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:134
av_channel_layout_from_mask
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
Definition: channel_layout.c:247
PCM
#define PCM(format)
Definition: avisynth.c:52
bits
uint8_t bits
Definition: vp3data.h:128
avs_ctx_list
static AviSynthContext * avs_ctx_list
Definition: avisynth.c:142
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:489
avs_planes_rgba
static const int avs_planes_rgba[4]
Definition: avisynth.c:131
AVCOL_PRI_SMPTE428
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:567
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:461
AviSynthContext::error
int error
Definition: avisynth.c:115
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
avisynth_next_stream
static void avisynth_next_stream(AVFormatContext *s, AVStream **st, AVPacket *pkt, int *discard)
Definition: avisynth.c:929
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
AVCOL_PRI_SMPTE240M
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
Definition: pixfmt.h:564
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:511
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:558
AVCOL_SPC_CHROMA_DERIVED_CL
@ AVCOL_SPC_CHROMA_DERIVED_CL
Chromaticity-derived constant luminance system.
Definition: pixfmt.h:624
AVCOL_PRI_BT470BG
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:562
arg
const char * arg
Definition: jacosubdec.c:67
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:563
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:459
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:220
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
internal.h
AviSynthContext::env
AVS_ScriptEnvironment * env
Definition: avisynth.c:103
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:497
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
AviSynthContext::planes
const int * planes
Definition: avisynth.c:109
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:469
NULL
#define NULL
Definition: coverity.c:32
avisynth_context_destroy
static av_cold void avisynth_context_destroy(AviSynthContext *avs)
Definition: avisynth.c:227
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:707
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCHROMA_LOC_TOPLEFT
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:709
AVCOL_TRC_IEC61966_2_4
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
Definition: pixfmt.h:592
avisynth_read_packet_audio
static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int discard)
Definition: avisynth.c:1017
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:557
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AviSynthContext::flags
uint32_t flags
Definition: avisynth.c:117
avisynth_read_header
static av_cold int avisynth_read_header(AVFormatContext *s)
Definition: avisynth.c:1084
avs_library
static AviSynthLibrary avs_library
Definition: avisynth.c:138
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:595
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:618
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:479
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:180
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:652
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:184
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:804
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:566
avisynth_options
static const AVOption avisynth_options[]
Definition: avisynth.c:1184
AviSynthContext::clip
AVS_Clip * clip
Definition: avisynth.c:104
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:597
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:569
AVPacket::size
int size
Definition: packet.h:521
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:94
AVCOL_TRC_SMPTE240M
@ AVCOL_TRC_SMPTE240M
Definition: pixfmt.h:588
avisynth_read_packet_video
static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, int discard)
Definition: avisynth.c:947
avisynth_create_stream
static int avisynth_create_stream(AVFormatContext *s)
Definition: avisynth.c:830
AVCOL_PRI_FILM
@ AVCOL_PRI_FILM
colour filters using Illuminant C
Definition: pixfmt.h:565
AVISYNTH_FRAMEPROP_PRIMARIES
@ AVISYNTH_FRAMEPROP_PRIMARIES
Definition: avisynth.c:94
AVCOL_TRC_LOG
@ AVCOL_TRC_LOG
"Logarithmic transfer characteristic (100:1 range)"
Definition: pixfmt.h:590
AviSynthContext
Definition: avisynth.c:101
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:508
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:483
AV_MUTEX_INITIALIZER
#define AV_MUTEX_INITIALIZER
Definition: thread.h:185
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:706
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:821
FFInputFormat::p
AVInputFormat p
The public AVInputFormat.
Definition: demux.h:41
AVISYNTH_FRAMEPROP_TRANSFER
@ AVISYNTH_FRAMEPROP_TRANSFER
Definition: avisynth.c:95
AviSynthFlags
AviSynthFlags
Definition: avisynth.c:91
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:519
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:451
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:518
attributes.h
ff_mutex_lock
static int ff_mutex_lock(AVMutex *mutex)
Definition: thread.h:188
AVCOL_SPC_CHROMA_DERIVED_NCL
@ AVCOL_SPC_CHROMA_DERIVED_NCL
Chromaticity-derived non-constant luminance system.
Definition: pixfmt.h:623
AviSynthContext::curr_frame
int curr_frame
Definition: avisynth.c:112
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:582
AVISYNTH_FRAMEPROP_CHROMA_LOCATION
@ AVISYNTH_FRAMEPROP_CHROMA_LOCATION
Definition: avisynth.c:97
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
Definition: pixfmt.h:617
avs_planes_grey
static const int avs_planes_grey[1]
Definition: avisynth.c:124
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:473
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:513
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:620
internal.h
AVCodecParameters::height
int height
Definition: codec_par.h:135
AVISYNTH_FRAMEPROP_DEFAULT
#define AVISYNTH_FRAMEPROP_DEFAULT
Definition: avisynth.c:1180
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:495
AV_FIELD_BB
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
Definition: defs.h:203
demux.h
AVCodecParameters::color_range
enum AVColorRange color_range
Video only.
Definition: codec_par.h:166
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:612
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:669
AVCodecParameters::field_order
enum AVFieldOrder field_order
Video only.
Definition: codec_par.h:161
avisynth_create_stream_audio
static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
Definition: avisynth.c:791
AVCOL_PRI_BT470M
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:560
AVStream::id
int id
Format-specific stream ID.
Definition: avformat.h:755
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:743
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
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVISYNTH_FRAMEPROP_RANGE
@ AVISYNTH_FRAMEPROP_RANGE
Definition: avisynth.c:93
avformat.h
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:482
AVCodecParameters::chroma_location
enum AVChromaLocation chroma_location
Definition: codec_par.h:170
ff_avisynth_demuxer
const FFInputFormat ff_avisynth_demuxer
Definition: avisynth.c:1203
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:487
AVISYNTH_FRAMEPROP_FIELD_ORDER
@ AVISYNTH_FRAMEPROP_FIELD_ORDER
Definition: avisynth.c:92
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:601
AVCHROMA_LOC_CENTER
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
Definition: pixfmt.h:708
AVRational::den
int den
Denominator.
Definition: rational.h:60
AVCOL_SPC_FCC
@ AVCOL_SPC_FCC
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:614
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:519
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:509
avs_planes_rgb
static const int avs_planes_rgb[3]
Definition: avisynth.c:127
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AVCOL_TRC_SMPTE170M
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Definition: pixfmt.h:587
AVPacket::stream_index
int stream_index
Definition: packet.h:522
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition: opt.h:284
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
mem.h
avs_planes_yuva
static const int avs_planes_yuva[4]
Definition: avisynth.c:129
AV_CODEC_ID_PCM_U8
@ AV_CODEC_ID_PCM_U8
Definition: codec_id.h:333
AVCodecParameters::format
int format
Definition: codec_par.h:92
AVCOL_PRI_SMPTE432
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:570
AviSynthContext::n_planes
int n_planes
Definition: avisynth.c:108
AviSynthContext::vi
const AVS_VideoInfo * vi
Definition: avisynth.c:105
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:497
AVCOL_SPC_SMPTE2085
@ AVCOL_SPC_SMPTE2085
SMPTE 2085, Y'D'zD'x.
Definition: pixfmt.h:622
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
FFInputFormat
Definition: demux.h:37
AviSynthContext::next
struct AviSynthContext * next
Definition: avisynth.c:120
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:244
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
AviSynthLibrary::AVSC_DECLARE_FUNC
AVSC_DECLARE_FUNC(avs_bit_blt)
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVCOL_TRC_SMPTE428
@ AVCOL_TRC_SMPTE428
SMPTE ST 428-1.
Definition: pixfmt.h:599
avisynth_context_create
static av_cold int avisynth_context_create(AVFormatContext *s)
Definition: avisynth.c:199
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:488
avisynth_open_file
static int avisynth_open_file(AVFormatContext *s)
Definition: avisynth.c:856
AVStream::start_time
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition: avformat.h:792
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:460
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:611
AVCOL_SPC_ICTCP
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:625
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:254
avs_planes_packed
static const int avs_planes_packed[1]
Definition: avisynth.c:123
AVCHROMA_LOC_BOTTOMLEFT
@ AVCHROMA_LOC_BOTTOMLEFT
Definition: pixfmt.h:711
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:486
w32dlfcn.h