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 "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 
134 /* A conflict between C++ global objects, atexit, and dynamic loading requires
135  * us to register our own atexit handler to prevent double freeing. */
137 static int avs_atexit_called = 0;
138 
139 /* Linked list of AviSynthContexts. An atexit handler destroys this list. */
141 
142 static av_cold void avisynth_atexit_handler(void);
143 
145 {
146  avs_library.library = dlopen(AVISYNTH_LIB, RTLD_NOW | RTLD_LOCAL);
147  if (!avs_library.library)
148  return AVERROR_UNKNOWN;
149 
150 #define LOAD_AVS_FUNC(name, continue_on_fail) \
151  avs_library.name = (name ## _func) \
152  dlsym(avs_library.library, #name); \
153  if (!continue_on_fail && !avs_library.name) \
154  goto fail;
155 
156  LOAD_AVS_FUNC(avs_bit_blt, 0);
157  LOAD_AVS_FUNC(avs_clip_get_error, 0);
158  LOAD_AVS_FUNC(avs_check_version, 0);
159  LOAD_AVS_FUNC(avs_create_script_environment, 0);
160  LOAD_AVS_FUNC(avs_delete_script_environment, 0);
161  LOAD_AVS_FUNC(avs_get_audio, 0);
162  LOAD_AVS_FUNC(avs_get_channel_mask, 1);
163  LOAD_AVS_FUNC(avs_get_error, 1); // New to AviSynth 2.6
164  LOAD_AVS_FUNC(avs_get_frame, 0);
165  LOAD_AVS_FUNC(avs_get_version, 0);
166  LOAD_AVS_FUNC(avs_get_video_info, 0);
167  LOAD_AVS_FUNC(avs_invoke, 0);
168  LOAD_AVS_FUNC(avs_is_color_space, 1);
169  LOAD_AVS_FUNC(avs_release_clip, 0);
170  LOAD_AVS_FUNC(avs_release_value, 0);
171  LOAD_AVS_FUNC(avs_release_video_frame, 0);
172  LOAD_AVS_FUNC(avs_take_clip, 0);
173  LOAD_AVS_FUNC(avs_bits_per_pixel, 1);
174  LOAD_AVS_FUNC(avs_get_height_p, 1);
175  LOAD_AVS_FUNC(avs_get_pitch_p, 1);
176  LOAD_AVS_FUNC(avs_get_read_ptr_p, 1);
177  LOAD_AVS_FUNC(avs_get_row_size_p, 1);
178  LOAD_AVS_FUNC(avs_is_planar_rgb, 1);
179  LOAD_AVS_FUNC(avs_is_planar_rgba, 1);
180  LOAD_AVS_FUNC(avs_get_frame_props_ro, 1);
181  LOAD_AVS_FUNC(avs_prop_get_int, 1);
182  LOAD_AVS_FUNC(avs_prop_get_type, 1);
183  LOAD_AVS_FUNC(avs_get_env_property, 1);
184 #undef LOAD_AVS_FUNC
185 
186  atexit(avisynth_atexit_handler);
187  return 0;
188 
189 fail:
190  dlclose(avs_library.library);
191  return AVERROR_UNKNOWN;
192 }
193 
194 /* Note that avisynth_context_create and avisynth_context_destroy
195  * do not allocate or free the actual context! That is taken care of
196  * by libavformat. */
198 {
199  AviSynthContext *avs = s->priv_data;
200  int ret;
201 
202  if (!avs_library.library)
203  if (ret = avisynth_load_library())
204  return ret;
205 
206  avs->env = avs_library.avs_create_script_environment(3);
207  if (avs_library.avs_get_error) {
208  const char *error = avs_library.avs_get_error(avs->env);
209  if (error) {
210  av_log(s, AV_LOG_ERROR, "%s\n", error);
211  return AVERROR_UNKNOWN;
212  }
213  }
214 
215  if (!avs_ctx_list) {
216  avs_ctx_list = avs;
217  } else {
218  avs->next = avs_ctx_list;
219  avs_ctx_list = avs;
220  }
221 
222  return 0;
223 }
224 
226 {
227  if (avs_atexit_called)
228  return;
229 
230  if (avs == avs_ctx_list) {
231  avs_ctx_list = avs->next;
232  } else {
234  while (prev->next != avs)
235  prev = prev->next;
236  prev->next = avs->next;
237  }
238 
239  if (avs->clip) {
240  avs_library.avs_release_clip(avs->clip);
241  avs->clip = NULL;
242  }
243  if (avs->env) {
244  avs_library.avs_delete_script_environment(avs->env);
245  avs->env = NULL;
246  }
247 }
248 
250 {
252 
253  while (avs) {
254  AviSynthContext *next = avs->next;
256  avs = next;
257  }
258  dlclose(avs_library.library);
259 
260  avs_atexit_called = 1;
261 }
262 
263 /* Create AVStream from audio and video data. */
265 {
266  AviSynthContext *avs = s->priv_data;
267  const AVS_Map *avsmap;
268  AVS_VideoFrame *frame;
269  int error;
270  int planar = 0; // 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA
271  int sar_num = 1;
272  int sar_den = 1;
273 
276  st->codecpar->width = avs->vi->width;
277  st->codecpar->height = avs->vi->height;
278 
279  st->avg_frame_rate = (AVRational) { avs->vi->fps_numerator,
280  avs->vi->fps_denominator };
281  st->start_time = 0;
282  st->duration = avs->vi->num_frames;
283  st->nb_frames = avs->vi->num_frames;
284  avpriv_set_pts_info(st, 32, avs->vi->fps_denominator, avs->vi->fps_numerator);
285 
286 
287  switch (avs->vi->pixel_type) {
288  /* 10~16-bit YUV pix_fmts (AviSynth+) */
289  case AVS_CS_YUV444P10:
291  planar = 1;
292  break;
293  case AVS_CS_YUV422P10:
295  planar = 1;
296  break;
297  case AVS_CS_YUV420P10:
299  planar = 1;
300  break;
301  case AVS_CS_YUV444P12:
303  planar = 1;
304  break;
305  case AVS_CS_YUV422P12:
307  planar = 1;
308  break;
309  case AVS_CS_YUV420P12:
311  planar = 1;
312  break;
313  case AVS_CS_YUV444P14:
315  planar = 1;
316  break;
317  case AVS_CS_YUV422P14:
319  planar = 1;
320  break;
321  case AVS_CS_YUV420P14:
323  planar = 1;
324  break;
325  case AVS_CS_YUV444P16:
327  planar = 1;
328  break;
329  case AVS_CS_YUV422P16:
331  planar = 1;
332  break;
333  case AVS_CS_YUV420P16:
335  planar = 1;
336  break;
337  /* 8~16-bit YUV pix_fmts with Alpha (AviSynth+) */
338  case AVS_CS_YUVA444:
340  planar = 4;
341  break;
342  case AVS_CS_YUVA422:
344  planar = 4;
345  break;
346  case AVS_CS_YUVA420:
348  planar = 4;
349  break;
350  case AVS_CS_YUVA444P10:
352  planar = 4;
353  break;
354  case AVS_CS_YUVA422P10:
356  planar = 4;
357  break;
358  case AVS_CS_YUVA420P10:
360  planar = 4;
361  break;
362  case AVS_CS_YUVA422P12:
364  planar = 4;
365  break;
366  case AVS_CS_YUVA444P16:
368  planar = 4;
369  break;
370  case AVS_CS_YUVA422P16:
372  planar = 4;
373  break;
374  case AVS_CS_YUVA420P16:
376  planar = 4;
377  break;
378  /* Planar RGB pix_fmts (AviSynth+) */
379  case AVS_CS_RGBP:
381  planar = 3;
382  break;
383  case AVS_CS_RGBP10:
385  planar = 3;
386  break;
387  case AVS_CS_RGBP12:
389  planar = 3;
390  break;
391  case AVS_CS_RGBP14:
393  planar = 3;
394  break;
395  case AVS_CS_RGBP16:
397  planar = 3;
398  break;
399  /* Single precision floating point Planar RGB (AviSynth+) */
400  case AVS_CS_RGBPS:
402  planar = 3;
403  break;
404  /* Planar RGB pix_fmts with Alpha (AviSynth+) */
405  case AVS_CS_RGBAP:
407  planar = 5;
408  break;
409  case AVS_CS_RGBAP10:
411  planar = 5;
412  break;
413  case AVS_CS_RGBAP12:
415  planar = 5;
416  break;
417  case AVS_CS_RGBAP16:
419  planar = 5;
420  break;
421  /* Single precision floating point Planar RGB with Alpha (AviSynth+) */
422  case AVS_CS_RGBAPS:
424  planar = 5;
425  break;
426  /* 10~16-bit gray pix_fmts (AviSynth+) */
427  case AVS_CS_Y10:
429  planar = 2;
430  break;
431  case AVS_CS_Y12:
433  planar = 2;
434  break;
435  case AVS_CS_Y14:
437  planar = 2;
438  break;
439  case AVS_CS_Y16:
441  planar = 2;
442  break;
443  /* Single precision floating point gray (AviSynth+) */
444  case AVS_CS_Y32:
446  planar = 2;
447  break;
448  /* pix_fmts added in AviSynth 2.6 */
449  case AVS_CS_YV24:
451  planar = 1;
452  break;
453  case AVS_CS_YV16:
455  planar = 1;
456  break;
457  case AVS_CS_YV411:
459  planar = 1;
460  break;
461  case AVS_CS_Y8:
463  planar = 2;
464  break;
465  /* 16-bit packed RGB pix_fmts (AviSynth+) */
466  case AVS_CS_BGR48:
468  break;
469  case AVS_CS_BGR64:
471  break;
472  /* AviSynth 2.5 pix_fmts */
473  case AVS_CS_BGR24:
475  break;
476  case AVS_CS_BGR32:
478  break;
479  case AVS_CS_YUY2:
481  break;
482  case AVS_CS_YV12:
484  planar = 1;
485  break;
486  case AVS_CS_I420: // Is this even used anywhere?
488  planar = 1;
489  break;
490  default:
492  "unknown AviSynth colorspace %d\n", avs->vi->pixel_type);
493  avs->error = 1;
494  return AVERROR_UNKNOWN;
495  }
496 
497  switch (planar) {
498  case 5: // Planar RGB + Alpha
499  avs->n_planes = 4;
500  avs->planes = avs_planes_rgba;
501  break;
502  case 4: // YUV + Alpha
503  avs->n_planes = 4;
504  avs->planes = avs_planes_yuva;
505  break;
506  case 3: // Planar RGB
507  avs->n_planes = 3;
508  avs->planes = avs_planes_rgb;
509  break;
510  case 2: // Y8
511  avs->n_planes = 1;
512  avs->planes = avs_planes_grey;
513  break;
514  case 1: // YUV
515  avs->n_planes = 3;
516  avs->planes = avs_planes_yuv;
517  break;
518  default:
519  avs->n_planes = 1;
520  avs->planes = avs_planes_packed;
521  }
522 
523  /* Read AviSynth+'s frame properties to set additional info.
524  *
525  * Due to a bug preventing the C interface from accessing frame
526  * properties in earlier versions of interface version 8, and
527  * previous attempts at being clever resulting in pre-8 versions
528  * of AviSynth+ segfaulting, only enable this if we detect
529  * version 9 at the minimum. Technically, 8.1 works, but the time
530  * distance between 8.1 and 9 is very small, so just restrict it to 9. */
531 
532  if (avs_library.avs_get_version(avs->clip) >= 9) {
533 
534  frame = avs_library.avs_get_frame(avs->clip, 0);
535  avsmap = avs_library.avs_get_frame_props_ro(avs->env, frame);
536 
537  /* Field order */
539  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_FieldBased") == AVS_PROPTYPE_UNSET) {
541  } else {
542  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_FieldBased", 0, &error)) {
543  case 0:
545  break;
546  case 1:
548  break;
549  case 2:
551  break;
552  default:
554  }
555  }
556  }
557 
558  /* Color Range */
559  if(avs->flags & AVISYNTH_FRAMEPROP_RANGE) {
560  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ColorRange") == AVS_PROPTYPE_UNSET) {
562  } else {
563  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ColorRange", 0, &error)) {
564  case 0:
566  break;
567  case 1:
569  break;
570  default:
572  }
573  }
574  }
575 
576  /* Color Primaries */
578  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Primaries", 0, &error)) {
579  case 1:
581  break;
582  case 2:
584  break;
585  case 4:
587  break;
588  case 5:
590  break;
591  case 6:
593  break;
594  case 7:
596  break;
597  case 8:
599  break;
600  case 9:
602  break;
603  case 10:
605  break;
606  case 11:
608  break;
609  case 12:
611  break;
612  case 22:
614  break;
615  default:
617  }
618  }
619 
620  /* Color Transfer Characteristics */
622  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Transfer", 0, &error)) {
623  case 1:
625  break;
626  case 2:
628  break;
629  case 4:
631  break;
632  case 5:
634  break;
635  case 6:
637  break;
638  case 7:
640  break;
641  case 8:
643  break;
644  case 9:
646  break;
647  case 10:
649  break;
650  case 11:
652  break;
653  case 12:
655  break;
656  case 13:
658  break;
659  case 14:
661  break;
662  case 15:
664  break;
665  case 16:
667  break;
668  case 17:
670  break;
671  case 18:
673  break;
674  default:
676  }
677  }
678 
679  /* Matrix coefficients */
680  if(avs->flags & AVISYNTH_FRAMEPROP_MATRIX) {
681  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_Matrix") == AVS_PROPTYPE_UNSET) {
683  } else {
684  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Matrix", 0, &error)) {
685  case 0:
687  break;
688  case 1:
690  break;
691  case 2:
693  break;
694  case 4:
696  break;
697  case 5:
699  break;
700  case 6:
702  break;
703  case 7:
705  break;
706  case 8:
708  break;
709  case 9:
711  break;
712  case 10:
714  break;
715  case 11:
717  break;
718  case 12:
720  break;
721  case 13:
723  break;
724  case 14:
726  break;
727  default:
729  }
730  }
731  }
732 
733  /* Chroma Location */
735  if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ChromaLocation") == AVS_PROPTYPE_UNSET) {
737  } else {
738  switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ChromaLocation", 0, &error)) {
739  case 0:
741  break;
742  case 1:
744  break;
745  case 2:
747  break;
748  case 3:
750  break;
751  case 4:
753  break;
754  case 5:
756  break;
757  default:
759  }
760  }
761  }
762 
763  /* Sample aspect ratio */
764  if(avs->flags & AVISYNTH_FRAMEPROP_SAR) {
765  sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error);
766  sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error);
767  st->sample_aspect_ratio = (AVRational){ sar_num, sar_den };
768  }
769 
770  avs_library.avs_release_video_frame(frame);
771  } else {
773  /* AviSynth works with frame-based video, detecting field order can
774  * only work when avs_is_field_based returns 'false'. */
775  av_log(s, AV_LOG_TRACE, "avs_is_field_based: %d\n", avs_is_field_based(avs->vi));
776  if (avs_is_field_based(avs->vi) == 0) {
777  if (avs_is_tff(avs->vi)) {
779  }
780  else if (avs_is_bff(avs->vi)) {
782  }
783  }
784  }
785 
786  return 0;
787 }
788 
790 {
791  AviSynthContext *avs = s->priv_data;
792 
794  st->codecpar->sample_rate = avs->vi->audio_samples_per_second;
795  st->codecpar->ch_layout.nb_channels = avs->vi->nchannels;
796  st->duration = avs->vi->num_audio_samples;
797  avpriv_set_pts_info(st, 64, 1, avs->vi->audio_samples_per_second);
798 
799  if (avs_library.avs_get_version(avs->clip) >= 10)
801  avs_library.avs_get_channel_mask(avs->vi));
802 
803  switch (avs->vi->sample_type) {
804  case AVS_SAMPLE_INT8:
806  break;
807  case AVS_SAMPLE_INT16:
808  st->codecpar->codec_id = PCM(S16);
809  break;
810  case AVS_SAMPLE_INT24:
811  st->codecpar->codec_id = PCM(S24);
812  break;
813  case AVS_SAMPLE_INT32:
814  st->codecpar->codec_id = PCM(S32);
815  break;
816  case AVS_SAMPLE_FLOAT:
817  st->codecpar->codec_id = PCM(F32);
818  break;
819  default:
821  "unknown AviSynth sample type %d\n", avs->vi->sample_type);
822  avs->error = 1;
823  return AVERROR_UNKNOWN;
824  }
825  return 0;
826 }
827 
829 {
830  AviSynthContext *avs = s->priv_data;
831  AVStream *st;
832  int ret;
833  int id = 0;
834 
835  if (avs_has_video(avs->vi)) {
836  st = avformat_new_stream(s, NULL);
837  if (!st)
838  return AVERROR_UNKNOWN;
839  st->id = id++;
841  return ret;
842  }
843  if (avs_has_audio(avs->vi)) {
844  st = avformat_new_stream(s, NULL);
845  if (!st)
846  return AVERROR_UNKNOWN;
847  st->id = id++;
849  return ret;
850  }
851  return 0;
852 }
853 
855 {
856  AviSynthContext *avs = s->priv_data;
857  AVS_Value val;
858  int ret;
859 
861  return ret;
862 
863  if (!avs_library.avs_check_version(avs->env, 7)) {
864  AVS_Value args[] = {
865  avs_new_value_string(s->url),
866  avs_new_value_bool(1) // filename is in UTF-8
867  };
868  val = avs_library.avs_invoke(avs->env, "Import",
869  avs_new_value_array(args, 2), 0);
870  } else {
871  AVS_Value arg;
872 #ifdef _WIN32
873  char *filename_ansi;
874  /* Convert UTF-8 to ANSI code page */
875  if (utf8toansi(s->url, &filename_ansi)) {
877  goto fail;
878  }
879  arg = avs_new_value_string(filename_ansi);
880 #else
881  arg = avs_new_value_string(s->url);
882 #endif
883  val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
884 #ifdef _WIN32
885  av_free(filename_ansi);
886 #endif
887  }
888 
889  if (avs_is_error(val)) {
890  av_log(s, AV_LOG_ERROR, "%s\n", avs_as_error(val));
892  goto fail;
893  }
894  if (!avs_is_clip(val)) {
895  av_log(s, AV_LOG_ERROR, "AviSynth script did not return a clip\n");
897  goto fail;
898  }
899 
900  avs->clip = avs_library.avs_take_clip(val, avs->env);
901  avs->vi = avs_library.avs_get_video_info(avs->clip);
902 
903  /* On Windows, FFmpeg supports AviSynth interface version 6 or higher.
904  * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher,
905  * and excludes 2.5 and the 2.6 alphas. */
906 
907  if (avs_library.avs_get_version(avs->clip) < 6) {
909  "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
911  goto fail;
912  }
913 
914  /* Release the AVS_Value as it will go out of scope. */
915  avs_library.avs_release_value(val);
916 
918  goto fail;
919 
920  return 0;
921 
922 fail:
924  return ret;
925 }
926 
928  AVPacket *pkt, int *discard)
929 {
930  AviSynthContext *avs = s->priv_data;
931 
932  avs->curr_stream++;
933  avs->curr_stream %= s->nb_streams;
934 
935  *st = s->streams[avs->curr_stream];
936  if ((*st)->discard == AVDISCARD_ALL)
937  *discard = 1;
938  else
939  *discard = 0;
940 
941  return;
942 }
943 
944 /* Copy AviSynth clip data into an AVPacket. */
946  int discard)
947 {
948  AviSynthContext *avs = s->priv_data;
949  AVS_VideoFrame *frame;
950  unsigned char *dst_p;
951  const unsigned char *src_p;
952  int n, i, plane, rowsize, planeheight, pitch, bits, ret;
953  const char *error;
954 
955  if (avs->curr_frame >= avs->vi->num_frames)
956  return AVERROR_EOF;
957 
958  /* This must happen even if the stream is discarded to prevent desync. */
959  n = avs->curr_frame++;
960  if (discard)
961  return 0;
962 
963  bits = avs_library.avs_bits_per_pixel(avs->vi);
964 
965  /* Without the cast to int64_t, calculation overflows at about 9k x 9k
966  * resolution. */
967  pkt->size = (((int64_t)avs->vi->width *
968  (int64_t)avs->vi->height) * bits) / 8;
969  if (!pkt->size)
970  return AVERROR_UNKNOWN;
971 
972  if ((ret = av_new_packet(pkt, pkt->size)) < 0)
973  return ret;
974 
975  pkt->pts = n;
976  pkt->dts = n;
977  pkt->duration = 1;
978  pkt->stream_index = avs->curr_stream;
979 
980  frame = avs_library.avs_get_frame(avs->clip, n);
981  error = avs_library.avs_clip_get_error(avs->clip);
982  if (error) {
983  av_log(s, AV_LOG_ERROR, "%s\n", error);
984  avs->error = 1;
986  return AVERROR_UNKNOWN;
987  }
988 
989  dst_p = pkt->data;
990  for (i = 0; i < avs->n_planes; i++) {
991  plane = avs->planes[i];
992  src_p = avs_library.avs_get_read_ptr_p(frame, plane);
993  pitch = avs_library.avs_get_pitch_p(frame, plane);
994 
995  rowsize = avs_library.avs_get_row_size_p(frame, plane);
996  planeheight = avs_library.avs_get_height_p(frame, plane);
997 
998  /* Flip RGB video. */
999  if (avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR) ||
1000  avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR48) ||
1001  avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR64)) {
1002  src_p = src_p + (planeheight - 1) * pitch;
1003  pitch = -pitch;
1004  }
1005 
1006  avs_library.avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch,
1007  rowsize, planeheight);
1008  dst_p += rowsize * planeheight;
1009  }
1010 
1011  avs_library.avs_release_video_frame(frame);
1012  return 0;
1013 }
1014 
1016  int discard)
1017 {
1018  AviSynthContext *avs = s->priv_data;
1019  AVRational fps, samplerate;
1020  int samples, ret;
1021  int64_t n;
1022  const char *error;
1023 
1024  if (avs->curr_sample >= avs->vi->num_audio_samples)
1025  return AVERROR_EOF;
1026 
1027  fps.num = avs->vi->fps_numerator;
1028  fps.den = avs->vi->fps_denominator;
1029  samplerate.num = avs->vi->audio_samples_per_second;
1030  samplerate.den = 1;
1031 
1032  if (avs_has_video(avs->vi)) {
1033  if (avs->curr_frame < avs->vi->num_frames)
1034  samples = av_rescale_q(avs->curr_frame, samplerate, fps) -
1035  avs->curr_sample;
1036  else
1037  samples = av_rescale_q(1, samplerate, fps);
1038  } else {
1039  samples = 1000;
1040  }
1041 
1042  /* After seeking, audio may catch up with video. */
1043  if (samples <= 0) {
1044  pkt->size = 0;
1045  pkt->data = NULL;
1046  return 0;
1047  }
1048 
1049  if (avs->curr_sample + samples > avs->vi->num_audio_samples)
1050  samples = avs->vi->num_audio_samples - avs->curr_sample;
1051 
1052  /* This must happen even if the stream is discarded to prevent desync. */
1053  n = avs->curr_sample;
1054  avs->curr_sample += samples;
1055  if (discard)
1056  return 0;
1057 
1058  pkt->size = avs_bytes_per_channel_sample(avs->vi) *
1059  samples * avs->vi->nchannels;
1060  if (!pkt->size)
1061  return AVERROR_UNKNOWN;
1062 
1063  if ((ret = av_new_packet(pkt, pkt->size)) < 0)
1064  return ret;
1065 
1066  pkt->pts = n;
1067  pkt->dts = n;
1068  pkt->duration = samples;
1069  pkt->stream_index = avs->curr_stream;
1070 
1071  avs_library.avs_get_audio(avs->clip, pkt->data, n, samples);
1072  error = avs_library.avs_clip_get_error(avs->clip);
1073  if (error) {
1074  av_log(s, AV_LOG_ERROR, "%s\n", error);
1075  avs->error = 1;
1077  return AVERROR_UNKNOWN;
1078  }
1079  return 0;
1080 }
1081 
1083 {
1084  int ret;
1085 
1086  // Calling library must implement a lock for thread-safe opens.
1087  if (ret = ff_lock_avformat())
1088  return ret;
1089 
1090  if (ret = avisynth_open_file(s)) {
1092  return ret;
1093  }
1094 
1096  return 0;
1097 }
1098 
1100 {
1101  AviSynthContext *avs = s->priv_data;
1102  AVStream *st;
1103  int discard = 0;
1104  int ret;
1105 
1106  if (avs->error)
1107  return AVERROR_UNKNOWN;
1108 
1109  /* If either stream reaches EOF, try to read the other one before
1110  * giving up. */
1111  avisynth_next_stream(s, &st, pkt, &discard);
1112  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
1113  ret = avisynth_read_packet_video(s, pkt, discard);
1114  if (ret == AVERROR_EOF && avs_has_audio(avs->vi)) {
1115  avisynth_next_stream(s, &st, pkt, &discard);
1116  return avisynth_read_packet_audio(s, pkt, discard);
1117  }
1118  } else {
1119  ret = avisynth_read_packet_audio(s, pkt, discard);
1120  if (ret == AVERROR_EOF && avs_has_video(avs->vi)) {
1121  avisynth_next_stream(s, &st, pkt, &discard);
1122  return avisynth_read_packet_video(s, pkt, discard);
1123  }
1124  }
1125 
1126  return ret;
1127 }
1128 
1130 {
1131  if (ff_lock_avformat())
1132  return AVERROR_UNKNOWN;
1133 
1134  avisynth_context_destroy(s->priv_data);
1136  return 0;
1137 }
1138 
1139 static int avisynth_read_seek(AVFormatContext *s, int stream_index,
1140  int64_t timestamp, int flags)
1141 {
1142  AviSynthContext *avs = s->priv_data;
1143  AVStream *st;
1144  AVRational fps, samplerate;
1145 
1146  if (avs->error)
1147  return AVERROR_UNKNOWN;
1148 
1149  fps = (AVRational) { avs->vi->fps_numerator,
1150  avs->vi->fps_denominator };
1151  samplerate = (AVRational) { avs->vi->audio_samples_per_second, 1 };
1152 
1153  st = s->streams[stream_index];
1154  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
1155  /* AviSynth frame counts are signed int. */
1156  if ((timestamp >= avs->vi->num_frames) ||
1157  (timestamp > INT_MAX) ||
1158  (timestamp < 0))
1159  return AVERROR_EOF;
1160  avs->curr_frame = timestamp;
1161  if (avs_has_audio(avs->vi))
1162  avs->curr_sample = av_rescale_q(timestamp, samplerate, fps);
1163  } else {
1164  if ((timestamp >= avs->vi->num_audio_samples) || (timestamp < 0))
1165  return AVERROR_EOF;
1166  /* Force frame granularity for seeking. */
1167  if (avs_has_video(avs->vi)) {
1168  avs->curr_frame = av_rescale_q(timestamp, fps, samplerate);
1169  avs->curr_sample = av_rescale_q(avs->curr_frame, samplerate, fps);
1170  } else {
1171  avs->curr_sample = timestamp;
1172  }
1173  }
1174 
1175  return 0;
1176 }
1177 
1178 #define AVISYNTH_FRAMEPROP_DEFAULT AVISYNTH_FRAMEPROP_FIELD_ORDER | AVISYNTH_FRAMEPROP_RANGE | \
1179  AVISYNTH_FRAMEPROP_PRIMARIES | AVISYNTH_FRAMEPROP_TRANSFER | \
1180  AVISYNTH_FRAMEPROP_MATRIX | AVISYNTH_FRAMEPROP_CHROMA_LOCATION
1181 #define OFFSET(x) offsetof(AviSynthContext, x)
1182 static const AVOption avisynth_options[] = {
1183  { "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" },
1184  { "field_order", "read field order", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_FIELD_ORDER}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1185  { "range", "read color range", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_RANGE}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1186  { "primaries", "read color primaries", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_PRIMARIES}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1187  { "transfer", "read color transfer characteristics", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_TRANSFER}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1188  { "matrix", "read matrix coefficients", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_MATRIX}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1189  { "chroma_location", "read chroma location", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_CHROMA_LOCATION}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1190  { "sar", "read sample aspect ratio", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_SAR}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, .unit = "flags" },
1191  { NULL },
1192 };
1193 
1195  .class_name = "AviSynth demuxer",
1196  .item_name = av_default_item_name,
1197  .option = avisynth_options,
1198  .version = LIBAVUTIL_VERSION_INT,
1199 };
1200 
1202  .p.name = "avisynth",
1203  .p.long_name = NULL_IF_CONFIG_SMALL("AviSynth script"),
1204  .p.extensions = "avs",
1205  .p.priv_class = &avisynth_demuxer_class,
1206  .priv_data_size = sizeof(AviSynthContext),
1211 };
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:522
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: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:1194
avisynth_atexit_handler
static av_cold void avisynth_atexit_handler(void)
Definition: avisynth.c:249
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:1181
avisynth_load_library
static av_cold int avisynth_load_library(void)
Definition: avisynth.c:144
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.
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:589
AVCHROMA_LOC_BOTTOM
@ AVCHROMA_LOC_BOTTOM
Definition: pixfmt.h:709
avisynth_read_seek
static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: avisynth.c:1139
avisynth_read_packet
static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: avisynth.c:1099
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:683
avs_atexit_called
static int avs_atexit_called
Definition: avisynth.c:137
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:522
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:346
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: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:313
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_unlock_avformat
int ff_unlock_avformat(void)
Definition: utils.c:54
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: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: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:179
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:264
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:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
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:41
AV_FIELD_UNKNOWN
@ AV_FIELD_UNKNOWN
Definition: defs.h:199
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:707
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: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:1129
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:242
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:140
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:927
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
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:563
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:459
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:219
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
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:225
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:704
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:706
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:1015
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:1082
avs_library
static AviSynthLibrary avs_library
Definition: avisynth.c:136
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:649
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:1182
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: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:588
avisynth_read_packet_video
static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, int discard)
Definition: avisynth.c:945
avisynth_create_stream
static int avisynth_create_stream(AVFormatContext *s)
Definition: avisynth.c:828
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
ff_lock_avformat
int ff_lock_avformat(void)
Definition: utils.c:49
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:703
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:35
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:521
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
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:255
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:515
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:1178
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:202
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:666
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:789
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
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:1201
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:705
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: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
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:273
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: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:499
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:31
AviSynthContext::next
struct AviSynthContext * next
Definition: avisynth.c:120
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:234
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:197
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:854
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:244
avs_planes_packed
static const int avs_planes_packed[1]
Definition: avisynth.c:123
AVCHROMA_LOC_BOTTOMLEFT
@ AVCHROMA_LOC_BOTTOMLEFT
Definition: pixfmt.h:708
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