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/opt.h"
25 
26 #include "libavcodec/internal.h"
27 
28 #include "avformat.h"
29 #include "internal.h"
30 #include "config.h"
31 
32 /* Enable function pointer definitions for runtime loading. */
33 #define AVSC_NO_DECLSPEC
34 
35 /* Platform-specific directives. */
36 #ifdef _WIN32
37  #include "compat/w32dlfcn.h"
39  #undef EXTERN_C
40  #define AVISYNTH_LIB "avisynth"
41 #else
42  #include <dlfcn.h>
43  #define AVISYNTH_NAME "libavisynth"
44  #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
45 #endif
46 
47 /* Endianness guards for audio */
48 #if HAVE_BIGENDIAN
49  #define PCM(format) (AV_CODEC_ID_PCM_ ## format ## BE)
50 #else
51  #define PCM(format) (AV_CODEC_ID_PCM_ ## format ## LE)
52 #endif
53 
54 #include <avisynth/avisynth_c.h>
55 
56 typedef struct AviSynthLibrary {
57  void *library;
58 #define AVSC_DECLARE_FUNC(name) name ## _func name
59  AVSC_DECLARE_FUNC(avs_bit_blt);
60  AVSC_DECLARE_FUNC(avs_clip_get_error);
61  AVSC_DECLARE_FUNC(avs_check_version);
62  AVSC_DECLARE_FUNC(avs_create_script_environment);
63  AVSC_DECLARE_FUNC(avs_delete_script_environment);
64  AVSC_DECLARE_FUNC(avs_get_audio);
65  AVSC_DECLARE_FUNC(avs_get_channel_mask);
66  AVSC_DECLARE_FUNC(avs_get_error);
67  AVSC_DECLARE_FUNC(avs_get_frame);
68  AVSC_DECLARE_FUNC(avs_get_version);
69  AVSC_DECLARE_FUNC(avs_get_video_info);
70  AVSC_DECLARE_FUNC(avs_invoke);
71  AVSC_DECLARE_FUNC(avs_is_color_space);
72  AVSC_DECLARE_FUNC(avs_release_clip);
73  AVSC_DECLARE_FUNC(avs_release_value);
74  AVSC_DECLARE_FUNC(avs_release_video_frame);
75  AVSC_DECLARE_FUNC(avs_take_clip);
76  AVSC_DECLARE_FUNC(avs_bits_per_pixel);
77  AVSC_DECLARE_FUNC(avs_get_height_p);
78  AVSC_DECLARE_FUNC(avs_get_pitch_p);
79  AVSC_DECLARE_FUNC(avs_get_read_ptr_p);
80  AVSC_DECLARE_FUNC(avs_get_row_size_p);
81  AVSC_DECLARE_FUNC(avs_is_planar_rgb);
82  AVSC_DECLARE_FUNC(avs_is_planar_rgba);
83  AVSC_DECLARE_FUNC(avs_get_frame_props_ro);
84  AVSC_DECLARE_FUNC(avs_prop_get_int);
85  AVSC_DECLARE_FUNC(avs_prop_get_type);
86  AVSC_DECLARE_FUNC(avs_get_env_property);
87 #undef AVSC_DECLARE_FUNC
89 
90 typedef enum AviSynthFlags {
99 
100 typedef struct AviSynthContext {
101  const AVClass *class;
102  AVS_ScriptEnvironment *env;
103  AVS_Clip *clip;
104  const AVS_VideoInfo *vi;
105 
106  /* avisynth_read_packet_video() iterates over this. */
107  int n_planes;
108  const int *planes;
109 
112  int64_t curr_sample;
113 
114  int error;
115 
116  uint32_t flags;
117 
118  /* Linked list pointers. */
121 
122 static const int avs_planes_packed[1] = { 0 };
123 static const int avs_planes_grey[1] = { AVS_PLANAR_Y };
124 static const int avs_planes_yuv[3] = { AVS_PLANAR_Y, AVS_PLANAR_U,
125  AVS_PLANAR_V };
126 static const int avs_planes_rgb[3] = { AVS_PLANAR_G, AVS_PLANAR_B,
127  AVS_PLANAR_R };
128 static const int avs_planes_yuva[4] = { AVS_PLANAR_Y, AVS_PLANAR_U,
129  AVS_PLANAR_V, AVS_PLANAR_A };
130 static const int avs_planes_rgba[4] = { AVS_PLANAR_G, AVS_PLANAR_B,
131  AVS_PLANAR_R, AVS_PLANAR_A };
132 
133 /* A conflict between C++ global objects, atexit, and dynamic loading requires
134  * us to register our own atexit handler to prevent double freeing. */
136 static int avs_atexit_called = 0;
137 
138 /* Linked list of AviSynthContexts. An atexit handler destroys this list. */
140 
141 static av_cold void avisynth_atexit_handler(void);
142 
144 {
145  avs_library.library = dlopen(AVISYNTH_LIB, RTLD_NOW | RTLD_LOCAL);
146  if (!avs_library.library)
147  return AVERROR_UNKNOWN;
148 
149 #define LOAD_AVS_FUNC(name, continue_on_fail) \
150  avs_library.name = (name ## _func) \
151  dlsym(avs_library.library, #name); \
152  if (!continue_on_fail && !avs_library.name) \
153  goto fail;
154 
155  LOAD_AVS_FUNC(avs_bit_blt, 0);
156  LOAD_AVS_FUNC(avs_clip_get_error, 0);
157  LOAD_AVS_FUNC(avs_check_version, 0);
158  LOAD_AVS_FUNC(avs_create_script_environment, 0);
159  LOAD_AVS_FUNC(avs_delete_script_environment, 0);
160  LOAD_AVS_FUNC(avs_get_audio, 0);
161  LOAD_AVS_FUNC(avs_get_channel_mask, 1);
162  LOAD_AVS_FUNC(avs_get_error, 1); // New to AviSynth 2.6
163  LOAD_AVS_FUNC(avs_get_frame, 0);
164  LOAD_AVS_FUNC(avs_get_version, 0);
165  LOAD_AVS_FUNC(avs_get_video_info, 0);
166  LOAD_AVS_FUNC(avs_invoke, 0);
167  LOAD_AVS_FUNC(avs_is_color_space, 1);
168  LOAD_AVS_FUNC(avs_release_clip, 0);
169  LOAD_AVS_FUNC(avs_release_value, 0);
170  LOAD_AVS_FUNC(avs_release_video_frame, 0);
171  LOAD_AVS_FUNC(avs_take_clip, 0);
172  LOAD_AVS_FUNC(avs_bits_per_pixel, 1);
173  LOAD_AVS_FUNC(avs_get_height_p, 1);
174  LOAD_AVS_FUNC(avs_get_pitch_p, 1);
175  LOAD_AVS_FUNC(avs_get_read_ptr_p, 1);
176  LOAD_AVS_FUNC(avs_get_row_size_p, 1);
177  LOAD_AVS_FUNC(avs_is_planar_rgb, 1);
178  LOAD_AVS_FUNC(avs_is_planar_rgba, 1);
179  LOAD_AVS_FUNC(avs_get_frame_props_ro, 1);
180  LOAD_AVS_FUNC(avs_prop_get_int, 1);
181  LOAD_AVS_FUNC(avs_prop_get_type, 1);
182  LOAD_AVS_FUNC(avs_get_env_property, 1);
183 #undef LOAD_AVS_FUNC
184 
185  atexit(avisynth_atexit_handler);
186  return 0;
187 
188 fail:
189  dlclose(avs_library.library);
190  return AVERROR_UNKNOWN;
191 }
192 
193 /* Note that avisynth_context_create and avisynth_context_destroy
194  * do not allocate or free the actual context! That is taken care of
195  * by libavformat. */
197 {
198  AviSynthContext *avs = s->priv_data;
199  int ret;
200 
201  if (!avs_library.library)
202  if (ret = avisynth_load_library())
203  return ret;
204 
205  avs->env = avs_library.avs_create_script_environment(3);
206  if (avs_library.avs_get_error) {
207  const char *error = avs_library.avs_get_error(avs->env);
208  if (error) {
209  av_log(s, AV_LOG_ERROR, "%s\n", error);
210  return AVERROR_UNKNOWN;
211  }
212  }
213 
214  if (!avs_ctx_list) {
215  avs_ctx_list = avs;
216  } else {
217  avs->next = avs_ctx_list;
218  avs_ctx_list = avs;
219  }
220 
221  return 0;
222 }
223 
225 {
226  if (avs_atexit_called)
227  return;
228 
229  if (avs == avs_ctx_list) {
230  avs_ctx_list = avs->next;
231  } else {
233  while (prev->next != avs)
234  prev = prev->next;
235  prev->next = avs->next;
236  }
237 
238  if (avs->clip) {
239  avs_library.avs_release_clip(avs->clip);
240  avs->clip = NULL;
241  }
242  if (avs->env) {
243  avs_library.avs_delete_script_environment(avs->env);
244  avs->env = NULL;
245  }
246 }
247 
249 {
251 
252  while (avs) {
253  AviSynthContext *next = avs->next;
255  avs = next;
256  }
257  dlclose(avs_library.library);
258 
259  avs_atexit_called = 1;
260 }
261 
262 /* Create AVStream from audio and video data. */
264 {
265  AviSynthContext *avs = s->priv_data;
266  const AVS_Map *avsmap;
267  AVS_VideoFrame *frame;
268  int error;
269  int planar = 0; // 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA
270  int sar_num = 1;
271  int sar_den = 1;
272 
275  st->codecpar->width = avs->vi->width;
276  st->codecpar->height = avs->vi->height;
277 
278  st->avg_frame_rate = (AVRational) { avs->vi->fps_numerator,
279  avs->vi->fps_denominator };
280  st->start_time = 0;
281  st->duration = avs->vi->num_frames;
282  st->nb_frames = avs->vi->num_frames;
283  avpriv_set_pts_info(st, 32, avs->vi->fps_denominator, avs->vi->fps_numerator);
284 
285 
286  switch (avs->vi->pixel_type) {
287  /* 10~16-bit YUV pix_fmts (AviSynth+) */
288  case AVS_CS_YUV444P10:
290  planar = 1;
291  break;
292  case AVS_CS_YUV422P10:
294  planar = 1;
295  break;
296  case AVS_CS_YUV420P10:
298  planar = 1;
299  break;
300  case AVS_CS_YUV444P12:
302  planar = 1;
303  break;
304  case AVS_CS_YUV422P12:
306  planar = 1;
307  break;
308  case AVS_CS_YUV420P12:
310  planar = 1;
311  break;
312  case AVS_CS_YUV444P14:
314  planar = 1;
315  break;
316  case AVS_CS_YUV422P14:
318  planar = 1;
319  break;
320  case AVS_CS_YUV420P14:
322  planar = 1;
323  break;
324  case AVS_CS_YUV444P16:
326  planar = 1;
327  break;
328  case AVS_CS_YUV422P16:
330  planar = 1;
331  break;
332  case AVS_CS_YUV420P16:
334  planar = 1;
335  break;
336  /* 8~16-bit YUV pix_fmts with Alpha (AviSynth+) */
337  case AVS_CS_YUVA444:
339  planar = 4;
340  break;
341  case AVS_CS_YUVA422:
343  planar = 4;
344  break;
345  case AVS_CS_YUVA420:
347  planar = 4;
348  break;
349  case AVS_CS_YUVA444P10:
351  planar = 4;
352  break;
353  case AVS_CS_YUVA422P10:
355  planar = 4;
356  break;
357  case AVS_CS_YUVA420P10:
359  planar = 4;
360  break;
361  case AVS_CS_YUVA422P12:
363  planar = 4;
364  break;
365  case AVS_CS_YUVA444P16:
367  planar = 4;
368  break;
369  case AVS_CS_YUVA422P16:
371  planar = 4;
372  break;
373  case AVS_CS_YUVA420P16:
375  planar = 4;
376  break;
377  /* Planar RGB pix_fmts (AviSynth+) */
378  case AVS_CS_RGBP:
380  planar = 3;
381  break;
382  case AVS_CS_RGBP10:
384  planar = 3;
385  break;
386  case AVS_CS_RGBP12:
388  planar = 3;
389  break;
390  case AVS_CS_RGBP14:
392  planar = 3;
393  break;
394  case AVS_CS_RGBP16:
396  planar = 3;
397  break;
398  /* Single precision floating point Planar RGB (AviSynth+) */
399  case AVS_CS_RGBPS:
401  planar = 3;
402  break;
403  /* Planar RGB pix_fmts with Alpha (AviSynth+) */
404  case AVS_CS_RGBAP:
406  planar = 5;
407  break;
408  case AVS_CS_RGBAP10:
410  planar = 5;
411  break;
412  case AVS_CS_RGBAP12:
414  planar = 5;
415  break;
416  case AVS_CS_RGBAP16:
418  planar = 5;
419  break;
420  /* Single precision floating point Planar RGB with Alpha (AviSynth+) */
421  case AVS_CS_RGBAPS:
423  planar = 5;
424  break;
425  /* 10~16-bit gray pix_fmts (AviSynth+) */
426  case AVS_CS_Y10:
428  planar = 2;
429  break;
430  case AVS_CS_Y12:
432  planar = 2;
433  break;
434  case AVS_CS_Y14:
436  planar = 2;
437  break;
438  case AVS_CS_Y16:
440  planar = 2;
441  break;
442  /* Single precision floating point gray (AviSynth+) */
443  case AVS_CS_Y32:
445  planar = 2;
446  break;
447  /* pix_fmts added in AviSynth 2.6 */
448  case AVS_CS_YV24:
450  planar = 1;
451  break;
452  case AVS_CS_YV16:
454  planar = 1;
455  break;
456  case AVS_CS_YV411:
458  planar = 1;
459  break;
460  case AVS_CS_Y8:
462  planar = 2;
463  break;
464  /* 16-bit packed RGB pix_fmts (AviSynth+) */
465  case AVS_CS_BGR48:
467  break;
468  case AVS_CS_BGR64:
470  break;
471  /* AviSynth 2.5 pix_fmts */
472  case AVS_CS_BGR24:
474  break;
475  case AVS_CS_BGR32:
477  break;
478  case AVS_CS_YUY2:
480  break;
481  case AVS_CS_YV12:
483  planar = 1;
484  break;
485  case AVS_CS_I420: // Is this even used anywhere?
487  planar = 1;
488  break;
489  default:
491  "unknown AviSynth colorspace %d\n", avs->vi->pixel_type);
492  avs->error = 1;
493  return AVERROR_UNKNOWN;
494  }
495 
496  switch (planar) {
497  case 5: // Planar RGB + Alpha
498  avs->n_planes = 4;
499  avs->planes = avs_planes_rgba;
500  break;
501  case 4: // YUV + Alpha
502  avs->n_planes = 4;
503  avs->planes = avs_planes_yuva;
504  break;
505  case 3: // Planar RGB
506  avs->n_planes = 3;
507  avs->planes = avs_planes_rgb;
508  break;
509  case 2: // Y8
510  avs->n_planes = 1;
511  avs->planes = avs_planes_grey;
512  break;
513  case 1: // YUV
514  avs->n_planes = 3;
515  avs->planes = avs_planes_yuv;
516  break;
517  default:
518  avs->n_planes = 1;
519  avs->planes = avs_planes_packed;
520  }
521 
522  /* Read AviSynth+'s frame properties to set additional info.
523  *
524  * Due to a bug preventing the C interface from accessing frame
525  * properties in earlier versions of interface version 8, and
526  * previous attempts at being clever resulting in pre-8 versions
527  * of AviSynth+ segfaulting, only enable this if we detect
528  * version 9 at the minimum. Technically, 8.1 works, but the time
529  * distance between 8.1 and 9 is very small, so just restrict it to 9. */
530 
531  if (avs_library.avs_get_version(avs->clip) >= 9) {
532 
533  frame = avs_library.avs_get_frame(avs->clip, 0);
534  avsmap = avs_library.avs_get_frame_props_ro(avs->env, frame);
535 
536  /* Field order */
538  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_FieldBased") == AVS_PROPTYPE_UNSET) {
540  } else {
541  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_FieldBased", 0, &error)) {
542  case 0:
544  break;
545  case 1:
547  break;
548  case 2:
550  break;
551  default:
553  }
554  }
555  }
556 
557  /* Color Range */
558  if(avs->flags & AVISYNTH_FRAMEPROP_RANGE) {
559  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ColorRange") == AVS_PROPTYPE_UNSET) {
561  } else {
562  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ColorRange", 0, &error)) {
563  case 0:
565  break;
566  case 1:
568  break;
569  default:
571  }
572  }
573  }
574 
575  /* Color Primaries */
577  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Primaries", 0, &error)) {
578  case 1:
580  break;
581  case 2:
583  break;
584  case 4:
586  break;
587  case 5:
589  break;
590  case 6:
592  break;
593  case 7:
595  break;
596  case 8:
598  break;
599  case 9:
601  break;
602  case 10:
604  break;
605  case 11:
607  break;
608  case 12:
610  break;
611  case 22:
613  break;
614  default:
616  }
617  }
618 
619  /* Color Transfer Characteristics */
621  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Transfer", 0, &error)) {
622  case 1:
624  break;
625  case 2:
627  break;
628  case 4:
630  break;
631  case 5:
633  break;
634  case 6:
636  break;
637  case 7:
639  break;
640  case 8:
642  break;
643  case 9:
645  break;
646  case 10:
648  break;
649  case 11:
651  break;
652  case 12:
654  break;
655  case 13:
657  break;
658  case 14:
660  break;
661  case 15:
663  break;
664  case 16:
666  break;
667  case 17:
669  break;
670  case 18:
672  break;
673  default:
675  }
676  }
677 
678  /* Matrix coefficients */
679  if(avs->flags & AVISYNTH_FRAMEPROP_MATRIX) {
680  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_Matrix") == AVS_PROPTYPE_UNSET) {
682  } else {
683  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Matrix", 0, &error)) {
684  case 0:
686  break;
687  case 1:
689  break;
690  case 2:
692  break;
693  case 4:
695  break;
696  case 5:
698  break;
699  case 6:
701  break;
702  case 7:
704  break;
705  case 8:
707  break;
708  case 9:
710  break;
711  case 10:
713  break;
714  case 11:
716  break;
717  case 12:
719  break;
720  case 13:
722  break;
723  case 14:
725  break;
726  default:
728  }
729  }
730  }
731 
732  /* Chroma Location */
734  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ChromaLocation") == AVS_PROPTYPE_UNSET) {
736  } else {
737  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ChromaLocation", 0, &error)) {
738  case 0:
740  break;
741  case 1:
743  break;
744  case 2:
746  break;
747  case 3:
749  break;
750  case 4:
752  break;
753  case 5:
755  break;
756  default:
758  }
759  }
760  }
761 
762  /* Sample aspect ratio */
763  if(avs->flags & AVISYNTH_FRAMEPROP_SAR) {
764  sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error);
765  sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error);
766  st->sample_aspect_ratio = (AVRational){ sar_num, sar_den };
767  }
768 
769  avs_library.avs_release_video_frame(frame);
770  } else {
772  /* AviSynth works with frame-based video, detecting field order can
773  * only work when avs_is_field_based returns 'false'. */
774  av_log(s, AV_LOG_TRACE, "avs_is_field_based: %d\n", avs_is_field_based(avs->vi));
775  if (avs_is_field_based(avs->vi) == 0) {
776  if (avs_is_tff(avs->vi)) {
778  }
779  else if (avs_is_bff(avs->vi)) {
781  }
782  }
783  }
784 
785  return 0;
786 }
787 
789 {
790  AviSynthContext *avs = s->priv_data;
791 
793  st->codecpar->sample_rate = avs->vi->audio_samples_per_second;
794  st->codecpar->ch_layout.nb_channels = avs->vi->nchannels;
795  st->duration = avs->vi->num_audio_samples;
796  avpriv_set_pts_info(st, 64, 1, avs->vi->audio_samples_per_second);
797 
798  if (avs_library.avs_get_version(avs->clip) >= 10)
800  avs_library.avs_get_channel_mask(avs->vi));
801 
802  switch (avs->vi->sample_type) {
803  case AVS_SAMPLE_INT8:
805  break;
806  case AVS_SAMPLE_INT16:
807  st->codecpar->codec_id = PCM(S16);
808  break;
809  case AVS_SAMPLE_INT24:
810  st->codecpar->codec_id = PCM(S24);
811  break;
812  case AVS_SAMPLE_INT32:
813  st->codecpar->codec_id = PCM(S32);
814  break;
815  case AVS_SAMPLE_FLOAT:
816  st->codecpar->codec_id = PCM(F32);
817  break;
818  default:
820  "unknown AviSynth sample type %d\n", avs->vi->sample_type);
821  avs->error = 1;
822  return AVERROR_UNKNOWN;
823  }
824  return 0;
825 }
826 
828 {
829  AviSynthContext *avs = s->priv_data;
830  AVStream *st;
831  int ret;
832  int id = 0;
833 
834  if (avs_has_video(avs->vi)) {
835  st = avformat_new_stream(s, NULL);
836  if (!st)
837  return AVERROR_UNKNOWN;
838  st->id = id++;
840  return ret;
841  }
842  if (avs_has_audio(avs->vi)) {
843  st = avformat_new_stream(s, NULL);
844  if (!st)
845  return AVERROR_UNKNOWN;
846  st->id = id++;
848  return ret;
849  }
850  return 0;
851 }
852 
854 {
855  AviSynthContext *avs = s->priv_data;
856  AVS_Value val;
857  int ret;
858 
860  return ret;
861 
862  if (!avs_library.avs_check_version(avs->env, 7)) {
863  AVS_Value args[] = {
864  avs_new_value_string(s->url),
865  avs_new_value_bool(1) // filename is in UTF-8
866  };
867  val = avs_library.avs_invoke(avs->env, "Import",
868  avs_new_value_array(args, 2), 0);
869  } else {
870  AVS_Value arg;
871 #ifdef _WIN32
872  char *filename_ansi;
873  /* Convert UTF-8 to ANSI code page */
874  if (utf8toansi(s->url, &filename_ansi)) {
876  goto fail;
877  }
878  arg = avs_new_value_string(filename_ansi);
879 #else
880  arg = avs_new_value_string(s->url);
881 #endif
882  val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
883 #ifdef _WIN32
884  av_free(filename_ansi);
885 #endif
886  }
887 
888  if (avs_is_error(val)) {
889  av_log(s, AV_LOG_ERROR, "%s\n", avs_as_error(val));
891  goto fail;
892  }
893  if (!avs_is_clip(val)) {
894  av_log(s, AV_LOG_ERROR, "AviSynth script did not return a clip\n");
896  goto fail;
897  }
898 
899  avs->clip = avs_library.avs_take_clip(val, avs->env);
900  avs->vi = avs_library.avs_get_video_info(avs->clip);
901 
902  /* On Windows, FFmpeg supports AviSynth interface version 6 or higher.
903  * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher,
904  * and excludes 2.5 and the 2.6 alphas. */
905 
906  if (avs_library.avs_get_version(avs->clip) < 6) {
908  "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
910  goto fail;
911  }
912 
913  /* Release the AVS_Value as it will go out of scope. */
914  avs_library.avs_release_value(val);
915 
917  goto fail;
918 
919  return 0;
920 
921 fail:
923  return ret;
924 }
925 
927  AVPacket *pkt, int *discard)
928 {
929  AviSynthContext *avs = s->priv_data;
930 
931  avs->curr_stream++;
932  avs->curr_stream %= s->nb_streams;
933 
934  *st = s->streams[avs->curr_stream];
935  if ((*st)->discard == AVDISCARD_ALL)
936  *discard = 1;
937  else
938  *discard = 0;
939 
940  return;
941 }
942 
943 /* Copy AviSynth clip data into an AVPacket. */
945  int discard)
946 {
947  AviSynthContext *avs = s->priv_data;
948  AVS_VideoFrame *frame;
949  unsigned char *dst_p;
950  const unsigned char *src_p;
951  int n, i, plane, rowsize, planeheight, pitch, bits, ret;
952  const char *error;
953 
954  if (avs->curr_frame >= avs->vi->num_frames)
955  return AVERROR_EOF;
956 
957  /* This must happen even if the stream is discarded to prevent desync. */
958  n = avs->curr_frame++;
959  if (discard)
960  return 0;
961 
962  bits = avs_library.avs_bits_per_pixel(avs->vi);
963 
964  /* Without the cast to int64_t, calculation overflows at about 9k x 9k
965  * resolution. */
966  pkt->size = (((int64_t)avs->vi->width *
967  (int64_t)avs->vi->height) * bits) / 8;
968  if (!pkt->size)
969  return AVERROR_UNKNOWN;
970 
971  if ((ret = av_new_packet(pkt, pkt->size)) < 0)
972  return ret;
973 
974  pkt->pts = n;
975  pkt->dts = n;
976  pkt->duration = 1;
977  pkt->stream_index = avs->curr_stream;
978 
979  frame = avs_library.avs_get_frame(avs->clip, n);
980  error = avs_library.avs_clip_get_error(avs->clip);
981  if (error) {
982  av_log(s, AV_LOG_ERROR, "%s\n", error);
983  avs->error = 1;
985  return AVERROR_UNKNOWN;
986  }
987 
988  dst_p = pkt->data;
989  for (i = 0; i < avs->n_planes; i++) {
990  plane = avs->planes[i];
991  src_p = avs_library.avs_get_read_ptr_p(frame, plane);
992  pitch = avs_library.avs_get_pitch_p(frame, plane);
993 
994  rowsize = avs_library.avs_get_row_size_p(frame, plane);
995  planeheight = avs_library.avs_get_height_p(frame, plane);
996 
997  /* Flip RGB video. */
998  if (avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR) ||
999  avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR48) ||
1000  avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR64)) {
1001  src_p = src_p + (planeheight - 1) * pitch;
1002  pitch = -pitch;
1003  }
1004 
1005  avs_library.avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch,
1006  rowsize, planeheight);
1007  dst_p += rowsize * planeheight;
1008  }
1009 
1010  avs_library.avs_release_video_frame(frame);
1011  return 0;
1012 }
1013 
1015  int discard)
1016 {
1017  AviSynthContext *avs = s->priv_data;
1018  AVRational fps, samplerate;
1019  int samples, ret;
1020  int64_t n;
1021  const char *error;
1022 
1023  if (avs->curr_sample >= avs->vi->num_audio_samples)
1024  return AVERROR_EOF;
1025 
1026  fps.num = avs->vi->fps_numerator;
1027  fps.den = avs->vi->fps_denominator;
1028  samplerate.num = avs->vi->audio_samples_per_second;
1029  samplerate.den = 1;
1030 
1031  if (avs_has_video(avs->vi)) {
1032  if (avs->curr_frame < avs->vi->num_frames)
1033  samples = av_rescale_q(avs->curr_frame, samplerate, fps) -
1034  avs->curr_sample;
1035  else
1036  samples = av_rescale_q(1, samplerate, fps);
1037  } else {
1038  samples = 1000;
1039  }
1040 
1041  /* After seeking, audio may catch up with video. */
1042  if (samples <= 0) {
1043  pkt->size = 0;
1044  pkt->data = NULL;
1045  return 0;
1046  }
1047 
1048  if (avs->curr_sample + samples > avs->vi->num_audio_samples)
1049  samples = avs->vi->num_audio_samples - avs->curr_sample;
1050 
1051  /* This must happen even if the stream is discarded to prevent desync. */
1052  n = avs->curr_sample;
1053  avs->curr_sample += samples;
1054  if (discard)
1055  return 0;
1056 
1057  pkt->size = avs_bytes_per_channel_sample(avs->vi) *
1058  samples * avs->vi->nchannels;
1059  if (!pkt->size)
1060  return AVERROR_UNKNOWN;
1061 
1062  if ((ret = av_new_packet(pkt, pkt->size)) < 0)
1063  return ret;
1064 
1065  pkt->pts = n;
1066  pkt->dts = n;
1067  pkt->duration = samples;
1068  pkt->stream_index = avs->curr_stream;
1069 
1070  avs_library.avs_get_audio(avs->clip, pkt->data, n, samples);
1071  error = avs_library.avs_clip_get_error(avs->clip);
1072  if (error) {
1073  av_log(s, AV_LOG_ERROR, "%s\n", error);
1074  avs->error = 1;
1076  return AVERROR_UNKNOWN;
1077  }
1078  return 0;
1079 }
1080 
1082 {
1083  int ret;
1084 
1085  // Calling library must implement a lock for thread-safe opens.
1086  if (ret = ff_lock_avformat())
1087  return ret;
1088 
1089  if (ret = avisynth_open_file(s)) {
1091  return ret;
1092  }
1093 
1095  return 0;
1096 }
1097 
1099 {
1100  AviSynthContext *avs = s->priv_data;
1101  AVStream *st;
1102  int discard = 0;
1103  int ret;
1104 
1105  if (avs->error)
1106  return AVERROR_UNKNOWN;
1107 
1108  /* If either stream reaches EOF, try to read the other one before
1109  * giving up. */
1110  avisynth_next_stream(s, &st, pkt, &discard);
1111  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
1112  ret = avisynth_read_packet_video(s, pkt, discard);
1113  if (ret == AVERROR_EOF && avs_has_audio(avs->vi)) {
1114  avisynth_next_stream(s, &st, pkt, &discard);
1115  return avisynth_read_packet_audio(s, pkt, discard);
1116  }
1117  } else {
1118  ret = avisynth_read_packet_audio(s, pkt, discard);
1119  if (ret == AVERROR_EOF && avs_has_video(avs->vi)) {
1120  avisynth_next_stream(s, &st, pkt, &discard);
1121  return avisynth_read_packet_video(s, pkt, discard);
1122  }
1123  }
1124 
1125  return ret;
1126 }
1127 
1129 {
1130  if (ff_lock_avformat())
1131  return AVERROR_UNKNOWN;
1132 
1133  avisynth_context_destroy(s->priv_data);
1135  return 0;
1136 }
1137 
1138 static int avisynth_read_seek(AVFormatContext *s, int stream_index,
1139  int64_t timestamp, int flags)
1140 {
1141  AviSynthContext *avs = s->priv_data;
1142  AVStream *st;
1143  AVRational fps, samplerate;
1144 
1145  if (avs->error)
1146  return AVERROR_UNKNOWN;
1147 
1148  fps = (AVRational) { avs->vi->fps_numerator,
1149  avs->vi->fps_denominator };
1150  samplerate = (AVRational) { avs->vi->audio_samples_per_second, 1 };
1151 
1152  st = s->streams[stream_index];
1153  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
1154  /* AviSynth frame counts are signed int. */
1155  if ((timestamp >= avs->vi->num_frames) ||
1156  (timestamp > INT_MAX) ||
1157  (timestamp < 0))
1158  return AVERROR_EOF;
1159  avs->curr_frame = timestamp;
1160  if (avs_has_audio(avs->vi))
1161  avs->curr_sample = av_rescale_q(timestamp, samplerate, fps);
1162  } else {
1163  if ((timestamp >= avs->vi->num_audio_samples) || (timestamp < 0))
1164  return AVERROR_EOF;
1165  /* Force frame granularity for seeking. */
1166  if (avs_has_video(avs->vi)) {
1167  avs->curr_frame = av_rescale_q(timestamp, fps, samplerate);
1168  avs->curr_sample = av_rescale_q(avs->curr_frame, samplerate, fps);
1169  } else {
1170  avs->curr_sample = timestamp;
1171  }
1172  }
1173 
1174  return 0;
1175 }
1176 
1177 #define AVISYNTH_FRAMEPROP_DEFAULT AVISYNTH_FRAMEPROP_FIELD_ORDER | AVISYNTH_FRAMEPROP_RANGE | \
1178  AVISYNTH_FRAMEPROP_PRIMARIES | AVISYNTH_FRAMEPROP_TRANSFER | \
1179  AVISYNTH_FRAMEPROP_MATRIX | AVISYNTH_FRAMEPROP_CHROMA_LOCATION
1180 #define OFFSET(x) offsetof(AviSynthContext, x)
1181 static const AVOption avisynth_options[] = {
1182  { "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" },
1183  { "field_order", "read field order", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_FIELD_ORDER}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1184  { "range", "read color range", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_RANGE}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1185  { "primaries", "read color primaries", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_PRIMARIES}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1186  { "transfer", "read color transfer characteristics", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_TRANSFER}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1187  { "matrix", "read matrix coefficients", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_MATRIX}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1188  { "chroma_location", "read chroma location", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_CHROMA_LOCATION}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1189  { "sar", "read sample aspect ratio", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_SAR}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1190  { NULL },
1191 };
1192 
1194  .class_name = "AviSynth demuxer",
1195  .item_name = av_default_item_name,
1196  .option = avisynth_options,
1197  .version = LIBAVUTIL_VERSION_INT,
1198 };
1199 
1201  .name = "avisynth",
1202  .long_name = NULL_IF_CONFIG_SMALL("AviSynth script"),
1203  .priv_data_size = sizeof(AviSynthContext),
1208  .extensions = "avs",
1209  .priv_class = &avisynth_demuxer_class,
1210 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:526
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:427
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:505
wchar_filename.h
AVCOL_PRI_EBU3213
@ AVCOL_PRI_EBU3213
EBU Tech. 3213-E (nothing there) / one of JEDEC P22 group phosphors.
Definition: pixfmt.h:575
opt.h
avisynth_demuxer_class
static const AVClass avisynth_demuxer_class
Definition: avisynth.c:1193
avisynth_atexit_handler
static av_cold void avisynth_atexit_handler(void)
Definition: avisynth.c:248
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:1180
avisynth_load_library
static av_cold int avisynth_load_library(void)
Definition: avisynth.c:143
AVCodecParameters::color_space
enum AVColorSpace color_space
Definition: codec_par.h:144
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AV_FIELD_PROGRESSIVE
@ AV_FIELD_PROGRESSIVE
Definition: defs.h:200
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:593
AVCHROMA_LOC_BOTTOM
@ AVCHROMA_LOC_BOTTOM
Definition: pixfmt.h:713
avisynth_read_seek
static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: avisynth.c:1138
avisynth_read_packet
static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: avisynth.c:1098
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:65
AviSynthContext::curr_sample
int64_t curr_sample
Definition: avisynth.c:112
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:525
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:687
avs_atexit_called
static int avs_atexit_called
Definition: avisynth.c:136
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:522
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:520
AviSynthLibrary::library
void * library
Definition: avisynth.c:57
avs_planes_yuv
static const int avs_planes_yuv[3]
Definition: avisynth.c:124
AVOption
AVOption.
Definition: opt.h:251
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:587
AVISYNTH_FRAMEPROP_MATRIX
@ AVISYNTH_FRAMEPROP_MATRIX
Definition: avisynth.c:95
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:930
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:482
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:614
AVCOL_TRC_BT2020_12
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
Definition: pixfmt.h:600
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:540
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:323
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:521
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:625
AviSynthContext::curr_stream
int curr_stream
Definition: avisynth.c:110
ff_unlock_avformat
int ff_unlock_avformat(void)
Definition: utils.c:54
AVCodecParameters::color_primaries
enum AVColorPrimaries color_primaries
Definition: codec_par.h:142
AviSynthLibrary
Definition: avisynth.c:56
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:619
AV_FIELD_TT
@ AV_FIELD_TT
Top coded_first, top displayed first.
Definition: defs.h:201
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:830
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:500
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:598
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:179
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:498
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:527
AVISYNTH_FRAMEPROP_SAR
@ AVISYNTH_FRAMEPROP_SAR
Definition: avisynth.c:97
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:590
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:466
AVCOL_TRC_LOG_SQRT
@ AVCOL_TRC_LOG_SQRT
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
Definition: pixfmt.h:595
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:900
AVISYNTH_LIB
#define AVISYNTH_LIB
Definition: avisynth.c:44
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:263
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:589
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:485
AVCodecParameters::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: codec_par.h:143
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:206
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
AVInputFormat
Definition: avformat.h:549
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:494
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_read_callback.c:41
AV_FIELD_UNKNOWN
@ AV_FIELD_UNKNOWN
Definition: defs.h:199
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:502
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVCHROMA_LOC_TOP
@ AVCHROMA_LOC_TOP
Definition: pixfmt.h:711
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: avpacket.c:98
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:503
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:597
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:495
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:554
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:620
avisynth_read_close
static av_cold int avisynth_read_close(AVFormatContext *s)
Definition: avisynth.c:1128
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:121
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:421
PCM
#define PCM(format)
Definition: avisynth.c:51
bits
uint8_t bits
Definition: vp3data.h:128
avs_ctx_list
static AviSynthContext * avs_ctx_list
Definition: avisynth.c:139
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:493
avs_planes_rgba
static const int avs_planes_rgba[4]
Definition: avisynth.c:130
AVCOL_PRI_SMPTE428
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:571
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:465
AviSynthContext::error
int error
Definition: avisynth.c:114
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:926
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:568
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:515
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:562
AVCOL_SPC_CHROMA_DERIVED_CL
@ AVCOL_SPC_CHROMA_DERIVED_CL
Chromaticity-derived constant luminance system.
Definition: pixfmt.h:628
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:566
frame
static AVFrame * frame
Definition: demux_decode.c:54
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:567
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:463
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:219
AVFormatContext
Format I/O context.
Definition: avformat.h:1202
AviSynthContext::env
AVS_ScriptEnvironment * env
Definition: avisynth.c:102
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:501
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:864
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:108
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:473
NULL
#define NULL
Definition: coverity.c:32
avisynth_context_destroy
static av_cold void avisynth_context_destroy(AviSynthContext *avs)
Definition: avisynth.c:224
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:708
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:710
AVCOL_TRC_IEC61966_2_4
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
Definition: pixfmt.h:596
avisynth_read_packet_audio
static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int discard)
Definition: avisynth.c:1014
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:561
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:116
avisynth_read_header
static av_cold int avisynth_read_header(AVFormatContext *s)
Definition: avisynth.c:1081
avs_library
static AviSynthLibrary avs_library
Definition: avisynth.c:135
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:599
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:622
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:483
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:206
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:653
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:171
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:902
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:570
avisynth_options
static const AVOption avisynth_options[]
Definition: avisynth.c:1181
AviSynthContext::clip
AVS_Clip * clip
Definition: avisynth.c:103
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:601
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:573
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
AVCOL_TRC_SMPTE240M
@ AVCOL_TRC_SMPTE240M
Definition: pixfmt.h:592
avisynth_read_packet_video
static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, int discard)
Definition: avisynth.c:944
avisynth_create_stream
static int avisynth_create_stream(AVFormatContext *s)
Definition: avisynth.c:827
AVCOL_PRI_FILM
@ AVCOL_PRI_FILM
colour filters using Illuminant C
Definition: pixfmt.h:569
AVISYNTH_FRAMEPROP_PRIMARIES
@ AVISYNTH_FRAMEPROP_PRIMARIES
Definition: avisynth.c:93
AVCOL_TRC_LOG
@ AVCOL_TRC_LOG
"Logarithmic transfer characteristic (100:1 range)"
Definition: pixfmt.h:594
AviSynthContext
Definition: avisynth.c:100
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:512
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:487
ff_lock_avformat
int ff_lock_avformat(void)
Definition: utils.c:49
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:489
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:707
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:919
AVISYNTH_FRAMEPROP_TRANSFER
@ AVISYNTH_FRAMEPROP_TRANSFER
Definition: avisynth.c:94
AviSynthFlags
AviSynthFlags
Definition: avisynth.c:90
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:521
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:455
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:522
attributes.h
AVCOL_SPC_CHROMA_DERIVED_NCL
@ AVCOL_SPC_CHROMA_DERIVED_NCL
Chromaticity-derived non-constant luminance system.
Definition: pixfmt.h:627
AviSynthContext::curr_frame
int curr_frame
Definition: avisynth.c:111
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:586
AVISYNTH_FRAMEPROP_CHROMA_LOCATION
@ AVISYNTH_FRAMEPROP_CHROMA_LOCATION
Definition: avisynth.c:96
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:621
avs_planes_grey
static const int avs_planes_grey[1]
Definition: avisynth.c:123
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:477
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:245
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
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:624
internal.h
AVCodecParameters::height
int height
Definition: codec_par.h:122
AVISYNTH_FRAMEPROP_DEFAULT
#define AVISYNTH_FRAMEPROP_DEFAULT
Definition: avisynth.c:1177
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:499
AV_FIELD_BB
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
Definition: defs.h:202
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:282
AVCodecParameters::color_range
enum AVColorRange color_range
Video only.
Definition: codec_par.h:141
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:616
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:670
AVCodecParameters::field_order
enum AVFieldOrder field_order
Video only.
Definition: codec_par.h:136
avisynth_create_stream_audio
static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
Definition: avisynth.c:788
AVCOL_PRI_BT470M
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:564
AVStream::id
int id
Format-specific stream ID.
Definition: avformat.h:853
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:841
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
AVISYNTH_FRAMEPROP_RANGE
@ AVISYNTH_FRAMEPROP_RANGE
Definition: avisynth.c:92
avformat.h
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:486
AVCodecParameters::chroma_location
enum AVChromaLocation chroma_location
Definition: codec_par.h:145
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:491
AVISYNTH_FRAMEPROP_FIELD_ORDER
@ AVISYNTH_FRAMEPROP_FIELD_ORDER
Definition: avisynth.c:91
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:605
AVCHROMA_LOC_CENTER
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
Definition: pixfmt.h:709
ff_avisynth_demuxer
const AVInputFormat ff_avisynth_demuxer
Definition: avisynth.c:1200
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:618
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:523
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:513
avs_planes_rgb
static const int avs_planes_rgb[3]
Definition: avisynth.c:126
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:591
AVPacket::stream_index
int stream_index
Definition: packet.h:524
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
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
avs_planes_yuva
static const int avs_planes_yuva[4]
Definition: avisynth.c:128
AV_CODEC_ID_PCM_U8
@ AV_CODEC_ID_PCM_U8
Definition: codec_id.h:336
AVCodecParameters::format
int format
Definition: codec_par.h:79
AVCOL_PRI_SMPTE432
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:574
AviSynthContext::n_planes
int n_planes
Definition: avisynth.c:107
AviSynthContext::vi
const AVS_VideoInfo * vi
Definition: avisynth.c:104
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
AVCOL_SPC_SMPTE2085
@ AVCOL_SPC_SMPTE2085
SMPTE 2085, Y'D'zD'x.
Definition: pixfmt.h:626
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
AviSynthContext::next
struct AviSynthContext * next
Definition: avisynth.c:119
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
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:603
avisynth_context_create
static av_cold int avisynth_context_create(AVFormatContext *s)
Definition: avisynth.c:196
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:492
avisynth_open_file
static int avisynth_open_file(AVFormatContext *s)
Definition: avisynth.c:853
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:890
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:464
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:615
AVCOL_SPC_ICTCP
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:629
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
avs_planes_packed
static const int avs_planes_packed[1]
Definition: avisynth.c:122
AVCHROMA_LOC_BOTTOMLEFT
@ AVCHROMA_LOC_BOTTOMLEFT
Definition: pixfmt.h:712
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:490
w32dlfcn.h