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  *
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 
25 #include "libavcodec/internal.h"
26 
27 #include "avformat.h"
28 #include "internal.h"
29 #include "config.h"
30 
31 /* Enable function pointer definitions for runtime loading. */
32 #define AVSC_NO_DECLSPEC
33 
34 /* Platform-specific directives for AviSynth vs AvxSynth. */
35 #ifdef _WIN32
36  #include "compat/w32dlfcn.h"
37  #undef EXTERN_C
39  #define AVISYNTH_LIB "avisynth"
40  #define USING_AVISYNTH
41 #else
42  #include <dlfcn.h>
44  #define AVISYNTH_NAME "libavxsynth"
45  #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
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 = dlopen(AVISYNTH_LIB, RTLD_NOW | RTLD_LOCAL);
122  if (!avs_library.library)
123  return AVERROR_UNKNOWN;
124 
125 #define LOAD_AVS_FUNC(name, continue_on_fail) \
126  avs_library.name = dlsym(avs_library.library, #name); \
127  if (!continue_on_fail && !avs_library.name) \
128  goto fail;
129 
130  LOAD_AVS_FUNC(avs_bit_blt, 0);
131  LOAD_AVS_FUNC(avs_clip_get_error, 0);
132  LOAD_AVS_FUNC(avs_create_script_environment, 0);
133  LOAD_AVS_FUNC(avs_delete_script_environment, 0);
134  LOAD_AVS_FUNC(avs_get_audio, 0);
135  LOAD_AVS_FUNC(avs_get_error, 1); // New to AviSynth 2.6
136  LOAD_AVS_FUNC(avs_get_frame, 0);
137  LOAD_AVS_FUNC(avs_get_version, 0);
138  LOAD_AVS_FUNC(avs_get_video_info, 0);
139  LOAD_AVS_FUNC(avs_invoke, 0);
140  LOAD_AVS_FUNC(avs_release_clip, 0);
141  LOAD_AVS_FUNC(avs_release_value, 0);
142  LOAD_AVS_FUNC(avs_release_video_frame, 0);
143  LOAD_AVS_FUNC(avs_take_clip, 0);
144 #ifdef USING_AVISYNTH
150  LOAD_AVS_FUNC(avs_is_planar_rgb, 1);
151  LOAD_AVS_FUNC(avs_is_planar_rgba, 1);
152 #endif
153 #undef LOAD_AVS_FUNC
154 
155  atexit(avisynth_atexit_handler);
156  return 0;
157 
158 fail:
159  dlclose(avs_library.library);
160  return AVERROR_UNKNOWN;
161 }
162 
163 /* Note that avisynth_context_create and avisynth_context_destroy
164  * do not allocate or free the actual context! That is taken care of
165  * by libavformat. */
167 {
168  AviSynthContext *avs = s->priv_data;
169  int ret;
170 
171  if (!avs_library.library)
172  if (ret = avisynth_load_library())
173  return ret;
174 
175  avs->env = avs_library.avs_create_script_environment(3);
176  if (avs_library.avs_get_error) {
177  const char *error = avs_library.avs_get_error(avs->env);
178  if (error) {
179  av_log(s, AV_LOG_ERROR, "%s\n", error);
180  return AVERROR_UNKNOWN;
181  }
182  }
183 
184  if (!avs_ctx_list) {
185  avs_ctx_list = avs;
186  } else {
187  avs->next = avs_ctx_list;
188  avs_ctx_list = avs;
189  }
190 
191  return 0;
192 }
193 
195 {
196  if (avs_atexit_called)
197  return;
198 
199  if (avs == avs_ctx_list) {
200  avs_ctx_list = avs->next;
201  } else {
203  while (prev->next != avs)
204  prev = prev->next;
205  prev->next = avs->next;
206  }
207 
208  if (avs->clip) {
209  avs_library.avs_release_clip(avs->clip);
210  avs->clip = NULL;
211  }
212  if (avs->env) {
213  avs_library.avs_delete_script_environment(avs->env);
214  avs->env = NULL;
215  }
216 }
217 
219 {
221 
222  while (avs) {
223  AviSynthContext *next = avs->next;
225  avs = next;
226  }
227  dlclose(avs_library.library);
228 
229  avs_atexit_called = 1;
230 }
231 
232 /* Create AVStream from audio and video data. */
234 {
235  AviSynthContext *avs = s->priv_data;
236  int planar = 0; // 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA
237 
240  st->codecpar->width = avs->vi->width;
241  st->codecpar->height = avs->vi->height;
242 
243  st->avg_frame_rate = (AVRational) { avs->vi->fps_numerator,
244  avs->vi->fps_denominator };
245  st->start_time = 0;
246  st->duration = avs->vi->num_frames;
247  st->nb_frames = avs->vi->num_frames;
248  avpriv_set_pts_info(st, 32, avs->vi->fps_denominator, avs->vi->fps_numerator);
249 
250  switch (avs->vi->pixel_type) {
251 #ifdef USING_AVISYNTH
252  /* 10~16-bit YUV pix_fmts (AviSynth+) */
253  case AVS_CS_YUV444P10:
255  planar = 1;
256  break;
257  case AVS_CS_YUV422P10:
259  planar = 1;
260  break;
261  case AVS_CS_YUV420P10:
263  planar = 1;
264  break;
265  case AVS_CS_YUV444P12:
267  planar = 1;
268  break;
269  case AVS_CS_YUV422P12:
271  planar = 1;
272  break;
273  case AVS_CS_YUV420P12:
275  planar = 1;
276  break;
277  case AVS_CS_YUV444P14:
279  planar = 1;
280  break;
281  case AVS_CS_YUV422P14:
283  planar = 1;
284  break;
285  case AVS_CS_YUV420P14:
287  planar = 1;
288  break;
289  case AVS_CS_YUV444P16:
291  planar = 1;
292  break;
293  case AVS_CS_YUV422P16:
295  planar = 1;
296  break;
297  case AVS_CS_YUV420P16:
299  planar = 1;
300  break;
301  /* 8~16-bit YUV pix_fmts with Alpha (AviSynth+) */
302  case AVS_CS_YUVA444:
304  planar = 4;
305  break;
306  case AVS_CS_YUVA422:
308  planar = 4;
309  break;
310  case AVS_CS_YUVA420:
312  planar = 4;
313  break;
314  case AVS_CS_YUVA444P10:
316  planar = 4;
317  break;
318  case AVS_CS_YUVA422P10:
320  planar = 4;
321  break;
322  case AVS_CS_YUVA420P10:
324  planar = 4;
325  break;
326  case AVS_CS_YUVA444P16:
328  planar = 4;
329  break;
330  case AVS_CS_YUVA422P16:
332  planar = 4;
333  break;
334  case AVS_CS_YUVA420P16:
336  planar = 4;
337  break;
338  /* Planar RGB pix_fmts (AviSynth+) */
339  case AVS_CS_RGBP:
341  planar = 3;
342  break;
343  case AVS_CS_RGBP10:
345  planar = 3;
346  break;
347  case AVS_CS_RGBP12:
349  planar = 3;
350  break;
351  case AVS_CS_RGBP14:
353  planar = 3;
354  break;
355  case AVS_CS_RGBP16:
357  planar = 3;
358  break;
359  /* Planar RGB pix_fmts with Alpha (AviSynth+) */
360  case AVS_CS_RGBAP:
362  planar = 5;
363  break;
364  case AVS_CS_RGBAP10:
366  planar = 5;
367  break;
368  case AVS_CS_RGBAP12:
370  planar = 5;
371  break;
372  case AVS_CS_RGBAP16:
374  planar = 5;
375  break;
376  /* GRAY16 (AviSynth+) */
377  case AVS_CS_Y16:
379  planar = 2;
380  break;
381  /* pix_fmts added in AviSynth 2.6 */
382  case AVS_CS_YV24:
384  planar = 1;
385  break;
386  case AVS_CS_YV16:
388  planar = 1;
389  break;
390  case AVS_CS_YV411:
392  planar = 1;
393  break;
394  case AVS_CS_Y8:
396  planar = 2;
397  break;
398  /* 16-bit packed RGB pix_fmts (AviSynth+) */
399  case AVS_CS_BGR48:
401  break;
402  case AVS_CS_BGR64:
404  break;
405 #endif
406  /* AviSynth 2.5 and AvxSynth pix_fmts */
407  case AVS_CS_BGR24:
409  break;
410  case AVS_CS_BGR32:
412  break;
413  case AVS_CS_YUY2:
415  break;
416  case AVS_CS_YV12:
418  planar = 1;
419  break;
420  case AVS_CS_I420: // Is this even used anywhere?
422  planar = 1;
423  break;
424  default:
425  av_log(s, AV_LOG_ERROR,
426  "unknown AviSynth colorspace %d\n", avs->vi->pixel_type);
427  avs->error = 1;
428  return AVERROR_UNKNOWN;
429  }
430 
431  switch (planar) {
432 #ifdef USING_AVISYNTH
433  case 5: // Planar RGB + Alpha
434  avs->n_planes = 4;
435  avs->planes = avs_planes_rgba;
436  break;
437  case 4: // YUV + Alpha
438  avs->n_planes = 4;
439  avs->planes = avs_planes_yuva;
440  break;
441  case 3: // Planar RGB
442  avs->n_planes = 3;
443  avs->planes = avs_planes_rgb;
444  break;
445 #endif
446  case 2: // Y8
447  avs->n_planes = 1;
448  avs->planes = avs_planes_grey;
449  break;
450  case 1: // YUV
451  avs->n_planes = 3;
452  avs->planes = avs_planes_yuv;
453  break;
454  default:
455  avs->n_planes = 1;
456  avs->planes = avs_planes_packed;
457  }
458  return 0;
459 }
460 
462 {
463  AviSynthContext *avs = s->priv_data;
464 
467  st->codecpar->channels = avs->vi->nchannels;
468  st->duration = avs->vi->num_audio_samples;
470 
471  switch (avs->vi->sample_type) {
472  case AVS_SAMPLE_INT8:
474  break;
475  case AVS_SAMPLE_INT16:
477  break;
478  case AVS_SAMPLE_INT24:
480  break;
481  case AVS_SAMPLE_INT32:
483  break;
484  case AVS_SAMPLE_FLOAT:
486  break;
487  default:
488  av_log(s, AV_LOG_ERROR,
489  "unknown AviSynth sample type %d\n", avs->vi->sample_type);
490  avs->error = 1;
491  return AVERROR_UNKNOWN;
492  }
493  return 0;
494 }
495 
497 {
498  AviSynthContext *avs = s->priv_data;
499  AVStream *st;
500  int ret;
501  int id = 0;
502 
503  if (avs_has_video(avs->vi)) {
504  st = avformat_new_stream(s, NULL);
505  if (!st)
506  return AVERROR_UNKNOWN;
507  st->id = id++;
508  if (ret = avisynth_create_stream_video(s, st))
509  return ret;
510  }
511  if (avs_has_audio(avs->vi)) {
512  st = avformat_new_stream(s, NULL);
513  if (!st)
514  return AVERROR_UNKNOWN;
515  st->id = id++;
516  if (ret = avisynth_create_stream_audio(s, st))
517  return ret;
518  }
519  return 0;
520 }
521 
523 {
524  AviSynthContext *avs = s->priv_data;
525  AVS_Value arg, val;
526  int ret;
527 #ifdef USING_AVISYNTH
528  char filename_ansi[MAX_PATH * 4];
529  wchar_t filename_wc[MAX_PATH * 4];
530 #endif
531 
532  if (ret = avisynth_context_create(s))
533  return ret;
534 
535 #ifdef USING_AVISYNTH
536  /* Convert UTF-8 to ANSI code page */
537  MultiByteToWideChar(CP_UTF8, 0, s->filename, -1, filename_wc, MAX_PATH * 4);
538  WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi,
539  MAX_PATH * 4, NULL, NULL);
540  arg = avs_new_value_string(filename_ansi);
541 #else
542  arg = avs_new_value_string(s->filename);
543 #endif
544  val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
545  if (avs_is_error(val)) {
546  av_log(s, AV_LOG_ERROR, "%s\n", avs_as_error(val));
547  ret = AVERROR_UNKNOWN;
548  goto fail;
549  }
550  if (!avs_is_clip(val)) {
551  av_log(s, AV_LOG_ERROR, "AviSynth script did not return a clip\n");
552  ret = AVERROR_UNKNOWN;
553  goto fail;
554  }
555 
556  avs->clip = avs_library.avs_take_clip(val, avs->env);
557  avs->vi = avs_library.avs_get_video_info(avs->clip);
558 
559 #ifdef USING_AVISYNTH
560  /* On Windows, FFmpeg supports AviSynth interface version 6 or higher.
561  * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher,
562  * and excludes 2.5 and the 2.6 alphas. Since AvxSynth identifies itself
563  * as interface version 3 like 2.5.8, this needs to be special-cased. */
564 
565  if (avs_library.avs_get_version(avs->clip) < 6) {
566  av_log(s, AV_LOG_ERROR,
567  "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
568  ret = AVERROR_UNKNOWN;
569  goto fail;
570  }
571 #endif
572 
573  /* Release the AVS_Value as it will go out of scope. */
574  avs_library.avs_release_value(val);
575 
576  if (ret = avisynth_create_stream(s))
577  goto fail;
578 
579  return 0;
580 
581 fail:
583  return ret;
584 }
585 
587  AVPacket *pkt, int *discard)
588 {
589  AviSynthContext *avs = s->priv_data;
590 
591  avs->curr_stream++;
592  avs->curr_stream %= s->nb_streams;
593 
594  *st = s->streams[avs->curr_stream];
595  if ((*st)->discard == AVDISCARD_ALL)
596  *discard = 1;
597  else
598  *discard = 0;
599 
600  return;
601 }
602 
603 /* Copy AviSynth clip data into an AVPacket. */
605  int discard)
606 {
607  AviSynthContext *avs = s->priv_data;
609  unsigned char *dst_p;
610  const unsigned char *src_p;
611  int n, i, plane, rowsize, planeheight, pitch, bits;
612  const char *error;
613  int avsplus av_unused;
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  if (GetProcAddress(avs_library.library, "avs_is_planar_rgb") == NULL)
627  avsplus = 0;
628  else
629  avsplus = 1;
630 
631  /* avs_bits_per_pixel changed to AVSC_API with AviSynth 2.6, which
632  * requires going through avs_library, while AvxSynth has it under
633  * the older AVSC_INLINE type, so special-case this. */
634 
635  bits = avs_library.avs_bits_per_pixel(avs->vi);
636 #else
637  bits = avs_bits_per_pixel(avs->vi);
638 #endif
639 
640  /* Without the cast to int64_t, calculation overflows at about 9k x 9k
641  * resolution. */
642  pkt->size = (((int64_t)avs->vi->width *
643  (int64_t)avs->vi->height) * bits) / 8;
644  if (!pkt->size)
645  return AVERROR_UNKNOWN;
646 
647  if (av_new_packet(pkt, pkt->size) < 0)
648  return AVERROR(ENOMEM);
649 
650  pkt->pts = n;
651  pkt->dts = n;
652  pkt->duration = 1;
653  pkt->stream_index = avs->curr_stream;
654 
655  frame = avs_library.avs_get_frame(avs->clip, n);
656  error = avs_library.avs_clip_get_error(avs->clip);
657  if (error) {
658  av_log(s, AV_LOG_ERROR, "%s\n", error);
659  avs->error = 1;
660  av_packet_unref(pkt);
661  return AVERROR_UNKNOWN;
662  }
663 
664  dst_p = pkt->data;
665  for (i = 0; i < avs->n_planes; i++) {
666  plane = avs->planes[i];
667 #ifdef USING_AVISYNTH
668  src_p = avs_library.avs_get_read_ptr_p(frame, plane);
669  pitch = avs_library.avs_get_pitch_p(frame, plane);
670 
671  rowsize = avs_library.avs_get_row_size_p(frame, plane);
672  planeheight = avs_library.avs_get_height_p(frame, plane);
673 #else
674  src_p = avs_get_read_ptr_p(frame, plane);
675  pitch = avs_get_pitch_p(frame, plane);
676 
677  rowsize = avs_get_row_size_p(frame, plane);
678  planeheight = avs_get_height_p(frame, plane);
679 #endif
680 
681  /* Flip RGB video. */
682  if (avs_is_rgb24(avs->vi) || avs_is_rgb(avs->vi)) {
683  src_p = src_p + (planeheight - 1) * pitch;
684  pitch = -pitch;
685  }
686 
687 #ifdef USING_AVISYNTH
688  /* Flip Planar RGB video */
689  if (avsplus && (avs_library.avs_is_planar_rgb(avs->vi) ||
690  avs_library.avs_is_planar_rgba(avs->vi))) {
691  src_p = src_p + (planeheight - 1) * pitch;
692  pitch = -pitch;
693  }
694 #endif
695 
696  avs_library.avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch,
697  rowsize, planeheight);
698  dst_p += rowsize * planeheight;
699  }
700 
701  avs_library.avs_release_video_frame(frame);
702  return 0;
703 }
704 
706  int discard)
707 {
708  AviSynthContext *avs = s->priv_data;
709  AVRational fps, samplerate;
710  int samples;
711  int64_t n;
712  const char *error;
713 
714  if (avs->curr_sample >= avs->vi->num_audio_samples)
715  return AVERROR_EOF;
716 
717  fps.num = avs->vi->fps_numerator;
718  fps.den = avs->vi->fps_denominator;
719  samplerate.num = avs->vi->audio_samples_per_second;
720  samplerate.den = 1;
721 
722  if (avs_has_video(avs->vi)) {
723  if (avs->curr_frame < avs->vi->num_frames)
724  samples = av_rescale_q(avs->curr_frame, samplerate, fps) -
725  avs->curr_sample;
726  else
727  samples = av_rescale_q(1, samplerate, fps);
728  } else {
729  samples = 1000;
730  }
731 
732  /* After seeking, audio may catch up with video. */
733  if (samples <= 0) {
734  pkt->size = 0;
735  pkt->data = NULL;
736  return 0;
737  }
738 
739  if (avs->curr_sample + samples > avs->vi->num_audio_samples)
740  samples = avs->vi->num_audio_samples - avs->curr_sample;
741 
742  /* This must happen even if the stream is discarded to prevent desync. */
743  n = avs->curr_sample;
744  avs->curr_sample += samples;
745  if (discard)
746  return 0;
747 
748  pkt->size = avs_bytes_per_channel_sample(avs->vi) *
749  samples * avs->vi->nchannels;
750  if (!pkt->size)
751  return AVERROR_UNKNOWN;
752 
753  if (av_new_packet(pkt, pkt->size) < 0)
754  return AVERROR(ENOMEM);
755 
756  pkt->pts = n;
757  pkt->dts = n;
758  pkt->duration = samples;
759  pkt->stream_index = avs->curr_stream;
760 
761  avs_library.avs_get_audio(avs->clip, pkt->data, n, samples);
762  error = avs_library.avs_clip_get_error(avs->clip);
763  if (error) {
764  av_log(s, AV_LOG_ERROR, "%s\n", error);
765  avs->error = 1;
766  av_packet_unref(pkt);
767  return AVERROR_UNKNOWN;
768  }
769  return 0;
770 }
771 
773 {
774  int ret;
775 
776  // Calling library must implement a lock for thread-safe opens.
777  if (ret = ff_lock_avformat())
778  return ret;
779 
780  if (ret = avisynth_open_file(s)) {
782  return ret;
783  }
784 
786  return 0;
787 }
788 
790 {
791  AviSynthContext *avs = s->priv_data;
792  AVStream *st;
793  int discard = 0;
794  int ret;
795 
796  if (avs->error)
797  return AVERROR_UNKNOWN;
798 
799  /* If either stream reaches EOF, try to read the other one before
800  * giving up. */
801  avisynth_next_stream(s, &st, pkt, &discard);
802  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
803  ret = avisynth_read_packet_video(s, pkt, discard);
804  if (ret == AVERROR_EOF && avs_has_audio(avs->vi)) {
805  avisynth_next_stream(s, &st, pkt, &discard);
806  return avisynth_read_packet_audio(s, pkt, discard);
807  }
808  } else {
809  ret = avisynth_read_packet_audio(s, pkt, discard);
810  if (ret == AVERROR_EOF && avs_has_video(avs->vi)) {
811  avisynth_next_stream(s, &st, pkt, &discard);
812  return avisynth_read_packet_video(s, pkt, discard);
813  }
814  }
815 
816  return ret;
817 }
818 
820 {
821  if (ff_lock_avformat())
822  return AVERROR_UNKNOWN;
823 
826  return 0;
827 }
828 
829 static int avisynth_read_seek(AVFormatContext *s, int stream_index,
830  int64_t timestamp, int flags)
831 {
832  AviSynthContext *avs = s->priv_data;
833  AVStream *st;
834  AVRational fps, samplerate;
835 
836  if (avs->error)
837  return AVERROR_UNKNOWN;
838 
839  fps = (AVRational) { avs->vi->fps_numerator,
840  avs->vi->fps_denominator };
841  samplerate = (AVRational) { avs->vi->audio_samples_per_second, 1 };
842 
843  st = s->streams[stream_index];
844  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
845  /* AviSynth frame counts are signed int. */
846  if ((timestamp >= avs->vi->num_frames) ||
847  (timestamp > INT_MAX) ||
848  (timestamp < 0))
849  return AVERROR_EOF;
850  avs->curr_frame = timestamp;
851  if (avs_has_audio(avs->vi))
852  avs->curr_sample = av_rescale_q(timestamp, samplerate, fps);
853  } else {
854  if ((timestamp >= avs->vi->num_audio_samples) || (timestamp < 0))
855  return AVERROR_EOF;
856  /* Force frame granularity for seeking. */
857  if (avs_has_video(avs->vi)) {
858  avs->curr_frame = av_rescale_q(timestamp, fps, samplerate);
859  avs->curr_sample = av_rescale_q(avs->curr_frame, samplerate, fps);
860  } else {
861  avs->curr_sample = timestamp;
862  }
863  }
864 
865  return 0;
866 }
867 
869  .name = "avisynth",
870  .long_name = NULL_IF_CONFIG_SMALL("AviSynth script"),
871  .priv_data_size = sizeof(AviSynthContext),
876  .extensions = "avs",
877 };
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:407
const char * s
Definition: avisynth_c.h:768
static int avs_atexit_called
Definition: avisynth.c:112
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:403
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:378
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:388
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:404
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:4820
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:3884
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:164
int num
Numerator.
Definition: rational.h:59
int size
Definition: avcodec.h:1431
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:384
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:363
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:372
discard all
Definition: avcodec.h:794
static AVPacket pkt
Macro definitions for various function/variable attributes.
static const int avs_planes_yuv[3]
Definition: avisynth.c:98
Format I/O context.
Definition: avformat.h:1342
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:97
static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int discard)
Definition: avisynth.c:705
#define av_cold
Definition: attributes.h:82
int width
Video only.
Definition: avcodec.h:3950
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1448
int id
Format-specific stream ID.
Definition: avformat.h:880
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4450
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1410
AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo *p)
Definition: avisynth_c.h:341
static AVFrame * frame
uint8_t * data
Definition: avcodec.h:1430
static int flags
Definition: log.c:55
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:359
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:381
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:373
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:406
#define av_log(a,...)
static av_cold int avisynth_read_close(AVFormatContext *s)
Definition: avisynth.c:819
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:45
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:172
#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:186
const int * planes
Definition: avisynth.c:84
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:408
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3880
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:389
AVSC_INLINE int avs_has_video(const AVS_VideoInfo *p)
Definition: avisynth_c.h:335
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:371
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:604
AVInputFormat ff_avisynth_demuxer
Definition: avisynth.c:868
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:946
#define fail()
Definition: checkasm.h:116
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:390
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:789
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:1398
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:387
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:352
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:233
int ff_unlock_avformat(void)
Definition: utils.c:88
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:405
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:386
static void error(const char *err)
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:530
AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo *p)
Definition: avxsynth_c.h:221
Stream structure.
Definition: avformat.h:873
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:379
static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
Definition: avisynth.c:461
static av_cold void avisynth_atexit_handler(void)
Definition: avisynth.c:218
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:376
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:173
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:592
AVSC_INLINE int avs_is_error(AVS_Value v)
Definition: avisynth_c.h:629
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:342
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_X86ASM &&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
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:368
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:496
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:377
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:385
const AVS_VideoInfo * vi
Definition: avisynth.c:80
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:369
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:375
static int avisynth_open_file(AVFormatContext *s)
Definition: avisynth.c:522
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:922
int sample_rate
Audio only.
Definition: avcodec.h:3994
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:829
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:211
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
Definition: avformat.h:912
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:924
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:1370
unsigned fps_denominator
Definition: avisynth_c.h:319
int channels
Audio only.
Definition: avcodec.h:3990
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1429
static av_cold int avisynth_context_create(AVFormatContext *s)
Definition: avisynth.c:166
int ff_lock_avformat(void)
Definition: utils.c:83
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:647
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1020
static const int avs_planes_packed[1]
Definition: avisynth.c:96
static av_cold void avisynth_context_destroy(AviSynthContext *avs)
Definition: avisynth.c:194
int stream_index
Definition: avcodec.h:1432
AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame *p, int plane)
Definition: avxsynth_c.h:348
static av_cold int avisynth_read_header(AVFormatContext *s)
Definition: avisynth.c:772
This structure stores compressed data.
Definition: avcodec.h:1407
static void avisynth_next_stream(AVFormatContext *s, AVStream **st, AVPacket *pkt, int *discard)
Definition: avisynth.c:586
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:380
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:1423
#define av_unused
Definition: attributes.h:125
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