FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
avisynth.c
Go to the documentation of this file.
1 /*
2  * AviSynth/AvxSynth support
3  * Copyright (c) 2012 AvxSynth Team
4  *
5  * This file is part of FFmpeg
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/internal.h"
22 #include "libavcodec/internal.h"
23 #include "avformat.h"
24 #include "internal.h"
25 #include "config.h"
26 
27 /* Enable function pointer definitions for runtime loading. */
28 #define AVSC_NO_DECLSPEC
29 
30 /* Platform-specific directives for AviSynth vs AvxSynth. */
31 #ifdef _WIN32
32  #include <windows.h>
33  #undef EXTERN_C
35  #define AVISYNTH_LIB "avisynth"
36  #define USING_AVISYNTH
37 #else
38  #include <dlfcn.h>
40  #define AVISYNTH_NAME "libavxsynth"
41  #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
42 
43  #define LoadLibrary(x) dlopen(x, RTLD_NOW | RTLD_LOCAL)
44  #define GetProcAddress dlsym
45  #define FreeLibrary dlclose
46 #endif
47 
48 typedef struct AviSynthLibrary {
49  void *library;
50 #define AVSC_DECLARE_FUNC(name) name ## _func name
51  AVSC_DECLARE_FUNC(avs_bit_blt);
52  AVSC_DECLARE_FUNC(avs_clip_get_error);
53  AVSC_DECLARE_FUNC(avs_create_script_environment);
54  AVSC_DECLARE_FUNC(avs_delete_script_environment);
55  AVSC_DECLARE_FUNC(avs_get_audio);
56  AVSC_DECLARE_FUNC(avs_get_error);
57  AVSC_DECLARE_FUNC(avs_get_frame);
58  AVSC_DECLARE_FUNC(avs_get_version);
59  AVSC_DECLARE_FUNC(avs_get_video_info);
60  AVSC_DECLARE_FUNC(avs_invoke);
61  AVSC_DECLARE_FUNC(avs_release_clip);
62  AVSC_DECLARE_FUNC(avs_release_value);
63  AVSC_DECLARE_FUNC(avs_release_video_frame);
64  AVSC_DECLARE_FUNC(avs_take_clip);
65 #ifdef USING_AVISYNTH
71  AVSC_DECLARE_FUNC(avs_is_planar_rgb);
72  AVSC_DECLARE_FUNC(avs_is_planar_rgba);
73 #endif
74 #undef AVSC_DECLARE_FUNC
76 
77 typedef struct AviSynthContext {
80  const AVS_VideoInfo *vi;
81 
82  /* avisynth_read_packet_video() iterates over this. */
83  int n_planes;
84  const int *planes;
85 
88  int64_t curr_sample;
89 
90  int error;
91 
92  /* Linked list pointers. */
95 
96 static const int avs_planes_packed[1] = { 0 };
97 static const int avs_planes_grey[1] = { AVS_PLANAR_Y };
98 static const int avs_planes_yuv[3] = { AVS_PLANAR_Y, AVS_PLANAR_U,
99  AVS_PLANAR_V };
100 #ifdef USING_AVISYNTH
101 static const int avs_planes_rgb[3] = { AVS_PLANAR_G, AVS_PLANAR_B,
102  AVS_PLANAR_R };
103 static const int avs_planes_yuva[4] = { AVS_PLANAR_Y, AVS_PLANAR_U,
105 static const int avs_planes_rgba[4] = { AVS_PLANAR_G, AVS_PLANAR_B,
107 #endif
108 
109 /* A conflict between C++ global objects, atexit, and dynamic loading requires
110  * us to register our own atexit handler to prevent double freeing. */
112 static int avs_atexit_called = 0;
113 
114 /* Linked list of AviSynthContexts. An atexit handler destroys this list. */
116 
117 static av_cold void avisynth_atexit_handler(void);
118 
120 {
121  avs_library.library = LoadLibrary(AVISYNTH_LIB);
122  if (!avs_library.library)
123  return AVERROR_UNKNOWN;
124 
125 #define LOAD_AVS_FUNC(name, continue_on_fail) \
126  avs_library.name = \
127  (void *)GetProcAddress(avs_library.library, #name); \
128  if (!continue_on_fail && !avs_library.name) \
129  goto fail;
130 
131  LOAD_AVS_FUNC(avs_bit_blt, 0);
132  LOAD_AVS_FUNC(avs_clip_get_error, 0);
133  LOAD_AVS_FUNC(avs_create_script_environment, 0);
134  LOAD_AVS_FUNC(avs_delete_script_environment, 0);
135  LOAD_AVS_FUNC(avs_get_audio, 0);
136  LOAD_AVS_FUNC(avs_get_error, 1); // New to AviSynth 2.6
137  LOAD_AVS_FUNC(avs_get_frame, 0);
138  LOAD_AVS_FUNC(avs_get_version, 0);
139  LOAD_AVS_FUNC(avs_get_video_info, 0);
140  LOAD_AVS_FUNC(avs_invoke, 0);
141  LOAD_AVS_FUNC(avs_release_clip, 0);
142  LOAD_AVS_FUNC(avs_release_value, 0);
143  LOAD_AVS_FUNC(avs_release_video_frame, 0);
144  LOAD_AVS_FUNC(avs_take_clip, 0);
145 #ifdef USING_AVISYNTH
151  LOAD_AVS_FUNC(avs_is_planar_rgb, 1);
152  LOAD_AVS_FUNC(avs_is_planar_rgba, 1);
153 #endif
154 #undef LOAD_AVS_FUNC
155 
156  atexit(avisynth_atexit_handler);
157  return 0;
158 
159 fail:
160  FreeLibrary(avs_library.library);
161  return AVERROR_UNKNOWN;
162 }
163 
164 /* Note that avisynth_context_create and avisynth_context_destroy
165  * do not allocate or free the actual context! That is taken care of
166  * by libavformat. */
168 {
169  AviSynthContext *avs = s->priv_data;
170  int ret;
171 
172  if (!avs_library.library)
173  if (ret = avisynth_load_library())
174  return ret;
175 
176  avs->env = avs_library.avs_create_script_environment(3);
177  if (avs_library.avs_get_error) {
178  const char *error = avs_library.avs_get_error(avs->env);
179  if (error) {
180  av_log(s, AV_LOG_ERROR, "%s\n", error);
181  return AVERROR_UNKNOWN;
182  }
183  }
184 
185  if (!avs_ctx_list) {
186  avs_ctx_list = avs;
187  } else {
188  avs->next = avs_ctx_list;
189  avs_ctx_list = avs;
190  }
191 
192  return 0;
193 }
194 
196 {
197  if (avs_atexit_called)
198  return;
199 
200  if (avs == avs_ctx_list) {
201  avs_ctx_list = avs->next;
202  } else {
204  while (prev->next != avs)
205  prev = prev->next;
206  prev->next = avs->next;
207  }
208 
209  if (avs->clip) {
210  avs_library.avs_release_clip(avs->clip);
211  avs->clip = NULL;
212  }
213  if (avs->env) {
214  avs_library.avs_delete_script_environment(avs->env);
215  avs->env = NULL;
216  }
217 }
218 
220 {
222 
223  while (avs) {
224  AviSynthContext *next = avs->next;
226  avs = next;
227  }
228  FreeLibrary(avs_library.library);
229 
230  avs_atexit_called = 1;
231 }
232 
233 /* Create AVStream from audio and video data. */
235 {
236  AviSynthContext *avs = s->priv_data;
237  int planar = 0; // 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA
238 
241  st->codecpar->width = avs->vi->width;
242  st->codecpar->height = avs->vi->height;
243 
244  st->avg_frame_rate = (AVRational) { avs->vi->fps_numerator,
245  avs->vi->fps_denominator };
246  st->start_time = 0;
247  st->duration = avs->vi->num_frames;
248  st->nb_frames = avs->vi->num_frames;
249  avpriv_set_pts_info(st, 32, avs->vi->fps_denominator, avs->vi->fps_numerator);
250 
251  switch (avs->vi->pixel_type) {
252 #ifdef USING_AVISYNTH
253 /* 10~16-bit YUV pix_fmts (AviSynth+) */
254  case AVS_CS_YUV444P10:
256  planar = 1;
257  break;
258  case AVS_CS_YUV422P10:
260  planar = 1;
261  break;
262  case AVS_CS_YUV420P10:
264  planar = 1;
265  break;
266  case AVS_CS_YUV444P12:
268  planar = 1;
269  break;
270  case AVS_CS_YUV422P12:
272  planar = 1;
273  break;
274  case AVS_CS_YUV420P12:
276  planar = 1;
277  break;
278  case AVS_CS_YUV444P14:
280  planar = 1;
281  break;
282  case AVS_CS_YUV422P14:
284  planar = 1;
285  break;
286  case AVS_CS_YUV420P14:
288  planar = 1;
289  break;
290  case AVS_CS_YUV444P16:
292  planar = 1;
293  break;
294  case AVS_CS_YUV422P16:
296  planar = 1;
297  break;
298  case AVS_CS_YUV420P16:
300  planar = 1;
301  break;
302 /* 8~16-bit YUV pix_fmts with Alpha (AviSynth+) */
303  case AVS_CS_YUVA444:
305  planar = 4;
306  break;
307  case AVS_CS_YUVA422:
309  planar = 4;
310  break;
311  case AVS_CS_YUVA420:
313  planar = 4;
314  break;
315  case AVS_CS_YUVA444P10:
317  planar = 4;
318  break;
319  case AVS_CS_YUVA422P10:
321  planar = 4;
322  break;
323  case AVS_CS_YUVA420P10:
325  planar = 4;
326  break;
327  case AVS_CS_YUVA444P16:
329  planar = 4;
330  break;
331  case AVS_CS_YUVA422P16:
333  planar = 4;
334  break;
335  case AVS_CS_YUVA420P16:
337  planar = 4;
338  break;
339 /* Planar RGB pix_fmts (AviSynth+) */
340  case AVS_CS_RGBP:
342  planar = 3;
343  break;
344  case AVS_CS_RGBP10:
346  planar = 3;
347  break;
348  case AVS_CS_RGBP12:
350  planar = 3;
351  break;
352  case AVS_CS_RGBP14:
354  planar = 3;
355  break;
356  case AVS_CS_RGBP16:
358  planar = 3;
359  break;
360 /* Planar RGB pix_fmts with Alpha (AviSynth+) */
361  case AVS_CS_RGBAP:
363  planar = 5;
364  break;
365  case AVS_CS_RGBAP10:
367  planar = 5;
368  break;
369  case AVS_CS_RGBAP12:
371  planar = 5;
372  break;
373  case AVS_CS_RGBAP16:
375  planar = 5;
376  break;
377 /* GRAY16 (AviSynth+) */
378  case AVS_CS_Y16:
380  planar = 2;
381  break;
382 /* pix_fmts added in AviSynth 2.6 */
383  case AVS_CS_YV24:
385  planar = 1;
386  break;
387  case AVS_CS_YV16:
389  planar = 1;
390  break;
391  case AVS_CS_YV411:
393  planar = 1;
394  break;
395  case AVS_CS_Y8:
397  planar = 2;
398  break;
399 /* 16-bit packed RGB pix_fmts (AviSynth+) */
400  case AVS_CS_BGR48:
402  break;
403  case AVS_CS_BGR64:
405  break;
406 #endif
407 /* AviSynth 2.5 and AvxSynth pix_fmts */
408  case AVS_CS_BGR24:
410  break;
411  case AVS_CS_BGR32:
413  break;
414  case AVS_CS_YUY2:
416  break;
417  case AVS_CS_YV12:
419  planar = 1;
420  break;
421  case AVS_CS_I420: // Is this even used anywhere?
423  planar = 1;
424  break;
425  default:
426  av_log(s, AV_LOG_ERROR,
427  "unknown AviSynth colorspace %d\n", avs->vi->pixel_type);
428  avs->error = 1;
429  return AVERROR_UNKNOWN;
430  }
431 
432  switch (planar) {
433 #ifdef USING_AVISYNTH
434  case 5: // Planar RGB + Alpha
435  avs->n_planes = 4;
436  avs->planes = avs_planes_rgba;
437  break;
438  case 4: // YUV + Alpha
439  avs->n_planes = 4;
440  avs->planes = avs_planes_yuva;
441  break;
442  case 3: // Planar RGB
443  avs->n_planes = 3;
444  avs->planes = avs_planes_rgb;
445  break;
446 #endif
447  case 2: // Y8
448  avs->n_planes = 1;
449  avs->planes = avs_planes_grey;
450  break;
451  case 1: // YUV
452  avs->n_planes = 3;
453  avs->planes = avs_planes_yuv;
454  break;
455  default:
456  avs->n_planes = 1;
457  avs->planes = avs_planes_packed;
458  }
459  return 0;
460 }
461 
463 {
464  AviSynthContext *avs = s->priv_data;
465 
468  st->codecpar->channels = avs->vi->nchannels;
469  st->duration = avs->vi->num_audio_samples;
471 
472  switch (avs->vi->sample_type) {
473  case AVS_SAMPLE_INT8:
475  break;
476  case AVS_SAMPLE_INT16:
478  break;
479  case AVS_SAMPLE_INT24:
481  break;
482  case AVS_SAMPLE_INT32:
484  break;
485  case AVS_SAMPLE_FLOAT:
487  break;
488  default:
489  av_log(s, AV_LOG_ERROR,
490  "unknown AviSynth sample type %d\n", avs->vi->sample_type);
491  avs->error = 1;
492  return AVERROR_UNKNOWN;
493  }
494  return 0;
495 }
496 
498 {
499  AviSynthContext *avs = s->priv_data;
500  AVStream *st;
501  int ret;
502  int id = 0;
503 
504  if (avs_has_video(avs->vi)) {
505  st = avformat_new_stream(s, NULL);
506  if (!st)
507  return AVERROR_UNKNOWN;
508  st->id = id++;
509  if (ret = avisynth_create_stream_video(s, st))
510  return ret;
511  }
512  if (avs_has_audio(avs->vi)) {
513  st = avformat_new_stream(s, NULL);
514  if (!st)
515  return AVERROR_UNKNOWN;
516  st->id = id++;
517  if (ret = avisynth_create_stream_audio(s, st))
518  return ret;
519  }
520  return 0;
521 }
522 
524 {
525  AviSynthContext *avs = s->priv_data;
526  AVS_Value arg, val;
527  int ret;
528 #ifdef USING_AVISYNTH
529  char filename_ansi[MAX_PATH * 4];
530  wchar_t filename_wc[MAX_PATH * 4];
531 #endif
532 
533  if (ret = avisynth_context_create(s))
534  return ret;
535 
536 #ifdef USING_AVISYNTH
537  /* Convert UTF-8 to ANSI code page */
538  MultiByteToWideChar(CP_UTF8, 0, s->filename, -1, filename_wc, MAX_PATH * 4);
539  WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi,
540  MAX_PATH * 4, NULL, NULL);
541  arg = avs_new_value_string(filename_ansi);
542 #else
543  arg = avs_new_value_string(s->filename);
544 #endif
545  val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
546  if (avs_is_error(val)) {
547  av_log(s, AV_LOG_ERROR, "%s\n", avs_as_error(val));
548  ret = AVERROR_UNKNOWN;
549  goto fail;
550  }
551  if (!avs_is_clip(val)) {
552  av_log(s, AV_LOG_ERROR, "AviSynth script did not return a clip\n");
553  ret = AVERROR_UNKNOWN;
554  goto fail;
555  }
556 
557  avs->clip = avs_library.avs_take_clip(val, avs->env);
558  avs->vi = avs_library.avs_get_video_info(avs->clip);
559 
560 #ifdef USING_AVISYNTH
561  /* On Windows, FFmpeg supports AviSynth interface version 6 or higher.
562  * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher,
563  * and excludes 2.5 and the 2.6 alphas. Since AvxSynth identifies itself
564  * as interface version 3 like 2.5.8, this needs to be special-cased. */
565 
566  if (avs_library.avs_get_version(avs->clip) < 6) {
567  av_log(s, AV_LOG_ERROR,
568  "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
569  ret = AVERROR_UNKNOWN;
570  goto fail;
571  }
572 #endif
573 
574  /* Release the AVS_Value as it will go out of scope. */
575  avs_library.avs_release_value(val);
576 
577  if (ret = avisynth_create_stream(s))
578  goto fail;
579 
580  return 0;
581 
582 fail:
584  return ret;
585 }
586 
588  AVPacket *pkt, int *discard)
589 {
590  AviSynthContext *avs = s->priv_data;
591 
592  avs->curr_stream++;
593  avs->curr_stream %= s->nb_streams;
594 
595  *st = s->streams[avs->curr_stream];
596  if ((*st)->discard == AVDISCARD_ALL)
597  *discard = 1;
598  else
599  *discard = 0;
600 
601  return;
602 }
603 
604 /* Copy AviSynth clip data into an AVPacket. */
606  int discard)
607 {
608  AviSynthContext *avs = s->priv_data;
610  unsigned char *dst_p;
611  const unsigned char *src_p;
612  int n, i, plane, rowsize, planeheight, pitch, bits;
613  const char *error;
614 
615  if (avs->curr_frame >= avs->vi->num_frames)
616  return AVERROR_EOF;
617 
618  /* This must happen even if the stream is discarded to prevent desync. */
619  n = avs->curr_frame++;
620  if (discard)
621  return 0;
622 
623 #ifdef USING_AVISYNTH
624  /* Detect whether we're using AviSynth 2.6 or AviSynth+ by
625  * looking for whether avs_is_planar_rgb exists. */
626 
627  int avsplus;
628 
629  if (GetProcAddress(avs_library.library, "avs_is_planar_rgb") == NULL)
630  avsplus = 0;
631  else
632  avsplus = 1;
633 
634  /* avs_bits_per_pixel changed to AVSC_API with AviSynth 2.6, which
635  * requires going through avs_library, while AvxSynth has it under
636  * the older AVSC_INLINE type, so special-case this. */
637 
638  bits = avs_library.avs_bits_per_pixel(avs->vi);
639 #else
640  bits = avs_bits_per_pixel(avs->vi);
641 #endif
642 
643  /* Without the cast to int64_t, calculation overflows at about 9k x 9k
644  * resolution. */
645  pkt->size = (((int64_t)avs->vi->width *
646  (int64_t)avs->vi->height) * bits) / 8;
647  if (!pkt->size)
648  return AVERROR_UNKNOWN;
649 
650  if (av_new_packet(pkt, pkt->size) < 0)
651  return AVERROR(ENOMEM);
652 
653  pkt->pts = n;
654  pkt->dts = n;
655  pkt->duration = 1;
656  pkt->stream_index = avs->curr_stream;
657 
658  frame = avs_library.avs_get_frame(avs->clip, n);
659  error = avs_library.avs_clip_get_error(avs->clip);
660  if (error) {
661  av_log(s, AV_LOG_ERROR, "%s\n", error);
662  avs->error = 1;
663  av_packet_unref(pkt);
664  return AVERROR_UNKNOWN;
665  }
666 
667  dst_p = pkt->data;
668  for (i = 0; i < avs->n_planes; i++) {
669  plane = avs->planes[i];
670 #ifdef USING_AVISYNTH
671  src_p = avs_library.avs_get_read_ptr_p(frame, plane);
672  pitch = avs_library.avs_get_pitch_p(frame, plane);
673 
674  rowsize = avs_library.avs_get_row_size_p(frame, plane);
675  planeheight = avs_library.avs_get_height_p(frame, plane);
676 #else
677  src_p = avs_get_read_ptr_p(frame, plane);
678  pitch = avs_get_pitch_p(frame, plane);
679 
680  rowsize = avs_get_row_size_p(frame, plane);
681  planeheight = avs_get_height_p(frame, plane);
682 #endif
683 
684  /* Flip RGB video. */
685  if (avs_is_rgb24(avs->vi) || avs_is_rgb(avs->vi)) {
686  src_p = src_p + (planeheight - 1) * pitch;
687  pitch = -pitch;
688  }
689 
690 #ifdef USING_AVISYNTH
691  /* Flip Planar RGB video. */
692  if (avsplus && (avs_library.avs_is_planar_rgb(avs->vi) ||
693  avs_library.avs_is_planar_rgba(avs->vi)))
694  pitch = -pitch;
695 #endif
696 
697  avs_library.avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch,
698  rowsize, planeheight);
699  dst_p += rowsize * planeheight;
700  }
701 
702  avs_library.avs_release_video_frame(frame);
703  return 0;
704 }
705 
707  int discard)
708 {
709  AviSynthContext *avs = s->priv_data;
710  AVRational fps, samplerate;
711  int samples;
712  int64_t n;
713  const char *error;
714 
715  if (avs->curr_sample >= avs->vi->num_audio_samples)
716  return AVERROR_EOF;
717 
718  fps.num = avs->vi->fps_numerator;
719  fps.den = avs->vi->fps_denominator;
720  samplerate.num = avs->vi->audio_samples_per_second;
721  samplerate.den = 1;
722 
723  if (avs_has_video(avs->vi)) {
724  if (avs->curr_frame < avs->vi->num_frames)
725  samples = av_rescale_q(avs->curr_frame, samplerate, fps) -
726  avs->curr_sample;
727  else
728  samples = av_rescale_q(1, samplerate, fps);
729  } else {
730  samples = 1000;
731  }
732 
733  /* After seeking, audio may catch up with video. */
734  if (samples <= 0) {
735  pkt->size = 0;
736  pkt->data = NULL;
737  return 0;
738  }
739 
740  if (avs->curr_sample + samples > avs->vi->num_audio_samples)
741  samples = avs->vi->num_audio_samples - avs->curr_sample;
742 
743  /* This must happen even if the stream is discarded to prevent desync. */
744  n = avs->curr_sample;
745  avs->curr_sample += samples;
746  if (discard)
747  return 0;
748 
749  pkt->size = avs_bytes_per_channel_sample(avs->vi) *
750  samples * avs->vi->nchannels;
751  if (!pkt->size)
752  return AVERROR_UNKNOWN;
753 
754  if (av_new_packet(pkt, pkt->size) < 0)
755  return AVERROR(ENOMEM);
756 
757  pkt->pts = n;
758  pkt->dts = n;
759  pkt->duration = samples;
760  pkt->stream_index = avs->curr_stream;
761 
762  avs_library.avs_get_audio(avs->clip, pkt->data, n, samples);
763  error = avs_library.avs_clip_get_error(avs->clip);
764  if (error) {
765  av_log(s, AV_LOG_ERROR, "%s\n", error);
766  avs->error = 1;
767  av_packet_unref(pkt);
768  return AVERROR_UNKNOWN;
769  }
770  return 0;
771 }
772 
774 {
775  int ret;
776 
777  // Calling library must implement a lock for thread-safe opens.
778  if (ret = avpriv_lock_avformat())
779  return ret;
780 
781  if (ret = avisynth_open_file(s)) {
783  return ret;
784  }
785 
787  return 0;
788 }
789 
791 {
792  AviSynthContext *avs = s->priv_data;
793  AVStream *st;
794  int discard = 0;
795  int ret;
796 
797  if (avs->error)
798  return AVERROR_UNKNOWN;
799 
800  /* If either stream reaches EOF, try to read the other one before
801  * giving up. */
802  avisynth_next_stream(s, &st, pkt, &discard);
803  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
804  ret = avisynth_read_packet_video(s, pkt, discard);
805  if (ret == AVERROR_EOF && avs_has_audio(avs->vi)) {
806  avisynth_next_stream(s, &st, pkt, &discard);
807  return avisynth_read_packet_audio(s, pkt, discard);
808  }
809  } else {
810  ret = avisynth_read_packet_audio(s, pkt, discard);
811  if (ret == AVERROR_EOF && avs_has_video(avs->vi)) {
812  avisynth_next_stream(s, &st, pkt, &discard);
813  return avisynth_read_packet_video(s, pkt, discard);
814  }
815  }
816 
817  return ret;
818 }
819 
821 {
822  if (avpriv_lock_avformat())
823  return AVERROR_UNKNOWN;
824 
827  return 0;
828 }
829 
830 static int avisynth_read_seek(AVFormatContext *s, int stream_index,
831  int64_t timestamp, int flags)
832 {
833  AviSynthContext *avs = s->priv_data;
834  AVStream *st;
835  AVRational fps, samplerate;
836 
837  if (avs->error)
838  return AVERROR_UNKNOWN;
839 
840  fps = (AVRational) { avs->vi->fps_numerator,
841  avs->vi->fps_denominator };
842  samplerate = (AVRational) { avs->vi->audio_samples_per_second, 1 };
843 
844  st = s->streams[stream_index];
845  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
846  /* AviSynth frame counts are signed int. */
847  if ((timestamp >= avs->vi->num_frames) ||
848  (timestamp > INT_MAX) ||
849  (timestamp < 0))
850  return AVERROR_EOF;
851  avs->curr_frame = timestamp;
852  if (avs_has_audio(avs->vi))
853  avs->curr_sample = av_rescale_q(timestamp, samplerate, fps);
854  } else {
855  if ((timestamp >= avs->vi->num_audio_samples) || (timestamp < 0))
856  return AVERROR_EOF;
857  /* Force frame granularity for seeking. */
858  if (avs_has_video(avs->vi)) {
859  avs->curr_frame = av_rescale_q(timestamp, fps, samplerate);
860  avs->curr_sample = av_rescale_q(avs->curr_frame, samplerate, fps);
861  } else {
862  avs->curr_sample = timestamp;
863  }
864  }
865 
866  return 0;
867 }
868 
870  .name = "avisynth",
871  .long_name = NULL_IF_CONFIG_SMALL("AviSynth script"),
872  .priv_data_size = sizeof(AviSynthContext),
877  .extensions = "avs",
878 };
int plane
Definition: avisynth_c.h:422
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:771
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:380
const char * s
Definition: avisynth_c.h:768
static int avs_atexit_called
Definition: avisynth.c:112
int avpriv_unlock_avformat(void)
Definition: utils.c:3851
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:376
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:353
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:363
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:377
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4549
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:3969
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:180
int num
Numerator.
Definition: rational.h:59
int size
Definition: avcodec.h:1601
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:359
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:338
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:347
discard all
Definition: avcodec.h:786
static AVPacket pkt
static const int avs_planes_yuv[3]
Definition: avisynth.c:98
Format I/O context.
Definition: avformat.h:1330
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
uint8_t bits
Definition: crc.c:296
static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int discard)
Definition: avisynth.c:706
#define av_cold
Definition: attributes.h:82
int width
Video only.
Definition: avcodec.h:4035
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1618
int id
Format-specific stream ID.
Definition: avformat.h:888
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4182
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1398
AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo *p)
Definition: avisynth_c.h:341
static AVFrame * frame
uint8_t * data
Definition: avcodec.h:1600
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:334
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:356
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:348
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:379
#define av_log(a,...)
static av_cold int avisynth_read_close(AVFormatContext *s)
Definition: avisynth.c:820
AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:340
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
#define AVISYNTH_LIB
Definition: avisynth.c:41
INT64 num_audio_samples
Definition: avisynth_c.h:326
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:86
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:187
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_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),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){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) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;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)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch const uint8_t **in ch off *out planar
Definition: audioconvert.c:56
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
const int * planes
Definition: avisynth.c:84
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:381
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3965
const char * arg
Definition: jacosubdec.c:66
AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo *p)
Definition: avisynth_c.h:344
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:364
AVSC_INLINE int avs_has_video(const AVS_VideoInfo *p)
Definition: avisynth_c.h:335
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:346
struct AVS_Clip AVS_Clip
Definition: avisynth_c.h:308
static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, int discard)
Definition: avisynth.c:605
AVInputFormat ff_avisynth_demuxer
Definition: avisynth.c:869
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:959
int avpriv_lock_avformat(void)
Definition: utils.c:3842
#define fail()
Definition: checkasm.h:82
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:365
unsigned fps_numerator
Definition: avisynth_c.h:319
AVS_ScriptEnvironment * env
Definition: avisynth.c:78
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
static AviSynthLibrary avs_library
Definition: avisynth.c:111
AVSC_DECLARE_FUNC(avs_bit_blt)
static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: avisynth.c:790
common internal API header
AVSC_INLINE int avs_is_clip(AVS_Value v)
Definition: avisynth_c.h:623
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1386
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:362
char filename[1024]
input or output filename
Definition: avformat.h:1406
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:327
AVSC_INLINE AVS_Value avs_new_value_string(const char *v0)
Definition: avisynth_c.h:657
AVSC_INLINE const char * avs_as_error(AVS_Value v)
Definition: avisynth_c.h:642
AVS_Clip * clip
Definition: avisynth.c:79
static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
Definition: avisynth.c:234
static const int avs_planes_grey[1]
Definition: avisynth.c:97
int n
Definition: avisynth_c.h:684
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:65
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:378
#define LoadLibrary(x)
Definition: avisynth.c:43
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:361
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:514
AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:221
Stream structure.
Definition: avformat.h:881
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:354
static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
Definition: avisynth.c:462
static av_cold void avisynth_atexit_handler(void)
Definition: avisynth.c:219
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:351
AVSC_INLINE const unsigned char * avs_get_read_ptr_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:384
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:188
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:567
AVSC_INLINE int avs_is_error(AVS_Value v)
Definition: avisynth_c.h:629
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:320
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:63
void * library
Definition: avisynth.c:49
#define LOAD_AVS_FUNC(name, continue_on_fail)
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:343
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo *p)
Definition: avisynth_c.h:439
static int avisynth_create_stream(AVFormatContext *s)
Definition: avisynth.c:497
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:352
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:360
const AVS_VideoInfo * vi
Definition: avisynth.c:80
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:344
static int flags
Definition: cpu.c:47
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:350
static int avisynth_open_file(AVFormatContext *s)
Definition: avisynth.c:523
static av_cold int avisynth_load_library(void)
Definition: avisynth.c:119
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:935
int sample_rate
Audio only.
Definition: avcodec.h:4079
Main libavformat public API header.
struct AVS_ScriptEnvironment AVS_ScriptEnvironment
Definition: avisynth_c.h:309
static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: avisynth.c:830
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
common internal api header.
static AviSynthContext * avs_ctx_list
Definition: avisynth.c:115
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:228
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
Definition: avformat.h:928
#define GetProcAddress
Definition: avisynth.c:44
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:937
int den
Denominator.
Definition: rational.h:60
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71
AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:373
struct AviSynthContext * next
Definition: avisynth.c:93
void * priv_data
Format private data.
Definition: avformat.h:1358
unsigned fps_denominator
Definition: avisynth_c.h:319
int channels
Audio only.
Definition: avcodec.h:4075
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1599
static av_cold int avisynth_context_create(AVFormatContext *s)
Definition: avisynth.c:167
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:662
AVCodecParameters * codecpar
Definition: avformat.h:1233
static const int avs_planes_packed[1]
Definition: avisynth.c:96
static av_cold void avisynth_context_destroy(AviSynthContext *avs)
Definition: avisynth.c:195
int stream_index
Definition: avcodec.h:1602
AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:348
#define FreeLibrary
Definition: avisynth.c:45
static av_cold int avisynth_read_header(AVFormatContext *s)
Definition: avisynth.c:773
This structure stores compressed data.
Definition: avcodec.h:1577
static void avisynth_next_stream(AVFormatContext *s, AVStream **st, AVPacket *pkt, int *discard)
Definition: avisynth.c:587
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:355
int64_t curr_sample
Definition: avisynth.c:88
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1593
AVSC_INLINE int avs_has_audio(const AVS_VideoInfo *p)
Definition: avisynth_c.h:338
int audio_samples_per_second
Definition: avisynth_c.h:324