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
24
26
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
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
50 #define AVSC_DECLARE_FUNC(name) name ## _func name
65 #ifdef USING_AVISYNTH
73 #endif
74 #undef AVSC_DECLARE_FUNC
76
81
82 /* avisynth_read_packet_video() iterates over this. */
85
89
91
92 /* Linked list pointers. */
95
100 #ifdef USING_AVISYNTH
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. */
113
114 /* Linked list of AviSynthContexts. An atexit handler destroys this list. */
116
118
120 {
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
144 #ifdef USING_AVISYNTH
152 #endif
153 #undef LOAD_AVS_FUNC
154
156 return 0;
157
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 {
169 int ret;
170
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) {
181 }
182 }
183
184 if (!avs_ctx_list) {
185 avs_ctx_list = avs;
186 } else {
188 avs_ctx_list = avs;
189 }
190
191 return 0;
192 }
193
195 {
197 return;
198
199 if (avs == avs_ctx_list) {
200 avs_ctx_list = avs->
next;
201 } else {
203 while (prev->
next != avs)
206 }
207
209 avs_library.avs_release_clip(avs->
clip);
211 }
213 avs_library.avs_delete_script_environment(avs->
env);
215 }
216 }
217
219 {
221
222 while (avs) {
226 }
228
230 }
231
232 /* Create AVStream from audio and video data. */
234 {
236 int planar = 0;
// 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA
237
242
249
251 #ifdef USING_AVISYNTH
252 /* 10~16-bit YUV pix_fmts (AviSynth+) */
255 planar = 1;
256 break;
259 planar = 1;
260 break;
263 planar = 1;
264 break;
267 planar = 1;
268 break;
271 planar = 1;
272 break;
275 planar = 1;
276 break;
279 planar = 1;
280 break;
283 planar = 1;
284 break;
287 planar = 1;
288 break;
291 planar = 1;
292 break;
295 planar = 1;
296 break;
299 planar = 1;
300 break;
301 /* 8~16-bit YUV pix_fmts with Alpha (AviSynth+) */
304 planar = 4;
305 break;
308 planar = 4;
309 break;
312 planar = 4;
313 break;
316 planar = 4;
317 break;
320 planar = 4;
321 break;
324 planar = 4;
325 break;
328 planar = 4;
329 break;
332 planar = 4;
333 break;
336 planar = 4;
337 break;
338 /* Planar RGB pix_fmts (AviSynth+) */
341 planar = 3;
342 break;
345 planar = 3;
346 break;
349 planar = 3;
350 break;
353 planar = 3;
354 break;
357 planar = 3;
358 break;
359 /* Planar RGB pix_fmts with Alpha (AviSynth+) */
362 planar = 5;
363 break;
366 planar = 5;
367 break;
370 planar = 5;
371 break;
374 planar = 5;
375 break;
376 /* GRAY16 (AviSynth+) */
379 planar = 2;
380 break;
381 /* pix_fmts added in AviSynth 2.6 */
384 planar = 1;
385 break;
388 planar = 1;
389 break;
392 planar = 1;
393 break;
396 planar = 2;
397 break;
398 /* 16-bit packed RGB pix_fmts (AviSynth+) */
401 break;
404 break;
405 #endif
406 /* AviSynth 2.5 and AvxSynth pix_fmts */
409 break;
412 break;
415 break;
418 planar = 1;
419 break;
422 planar = 1;
423 break;
424 default:
426 "unknown AviSynth colorspace %d\n", avs->
vi->
pixel_type);
429 }
430
431 switch (planar) {
432 #ifdef USING_AVISYNTH
433 case 5: // Planar RGB + Alpha
435 avs->
planes = avs_planes_rgba;
436 break;
437 case 4: // YUV + Alpha
439 avs->
planes = avs_planes_yuva;
440 break;
441 case 3: // Planar RGB
443 avs->
planes = avs_planes_rgb;
444 break;
445 #endif
446 case 2: // Y8
449 break;
450 case 1: // YUV
453 break;
454 default:
457 }
458 return 0;
459 }
460
462 {
464
470
474 break;
477 break;
480 break;
483 break;
486 break;
487 default:
492 }
493 return 0;
494 }
495
497 {
500 int ret;
501 int id = 0;
502
505 if (!st)
509 return ret;
510 }
513 if (!st)
517 return ret;
518 }
519 return 0;
520 }
521
523 {
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
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,
541 #else
543 #endif
544 val = avs_library.avs_invoke(avs->
env,
"Import", arg, 0);
549 }
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) {
567 "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
570 }
571 #endif
572
573 /* Release the AVS_Value as it will go out of scope. */
574 avs_library.avs_release_value(val);
575
578
579 return 0;
580
583 return ret;
584 }
585
588 {
590
593
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 {
609 unsigned char *dst_p;
610 const unsigned char *src_p;
611 int n, i,
plane, rowsize, planeheight, pitch,
bits;
614
617
618 /* This must happen even if the stream is discarded to prevent desync. */
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
638 #endif
639
640 /* Without the cast to int64_t, calculation overflows at about 9k x 9k
641 * resolution. */
643 (int64_t)avs->
vi->
height) * bits) / 8;
646
649
654
655 frame = avs_library.avs_get_frame(avs->
clip, n);
656 error = avs_library.avs_clip_get_error(avs->
clip);
657 if (error) {
662 }
663
665 for (i = 0; i < avs->
n_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
676
679 #endif
680
681 /* Flip RGB video. */
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 {
710 int samples;
713
716
721
726 else
728 } else {
729 samples = 1000;
730 }
731
732 /* After seeking, audio may catch up with video. */
733 if (samples <= 0) {
736 return 0;
737 }
738
741
742 /* This must happen even if the stream is discarded to prevent desync. */
745 if (discard)
746 return 0;
747
752
755
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) {
768 }
769 return 0;
770 }
771
773 {
774 int ret;
775
776 // Calling library must implement a lock for thread-safe opens.
778 return ret;
779
782 return ret;
783 }
784
786 return 0;
787 }
788
790 {
793 int discard = 0;
794 int ret;
795
798
799 /* If either stream reaches EOF, try to read the other one before
800 * giving up. */
807 }
808 } else {
813 }
814 }
815
816 return ret;
817 }
818
820 {
823
826 return 0;
827 }
828
830 int64_t timestamp,
int flags)
831 {
835
838
842
845 /* AviSynth frame counts are signed int. */
847 (timestamp > INT_MAX) ||
848 (timestamp < 0))
853 } else {
856 /* Force frame granularity for seeking. */
860 } else {
862 }
863 }
864
865 return 0;
866 }
867
876 .extensions = "avs",
877 };
const char const char void * val
#define AV_PIX_FMT_YUVA422P16
static int avs_atexit_called
int avpriv_unlock_avformat(void)
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_YUVA422P10
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_YUV420P12
Macro definitions for various function/variable attributes.
static const int avs_planes_yuv[3]
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int discard)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int id
Format-specific stream ID.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo *p)
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUVA420P16
static av_cold int avisynth_read_close(AVFormatContext *s)
AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame *p, int plane)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
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
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_PIX_FMT_YUVA444P16
enum AVMediaType codec_type
General type of the encoded data.
AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo *p)
#define AV_PIX_FMT_GBRAP12
AVSC_INLINE int avs_has_video(const AVS_VideoInfo *p)
#define AV_PIX_FMT_YUV444P10
static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, int discard)
AVInputFormat ff_avisynth_demuxer
AVRational avg_frame_rate
Average framerate.
int avpriv_lock_avformat(void)
#define AV_PIX_FMT_GBRAP16
AVS_ScriptEnvironment * env
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static AviSynthLibrary avs_library
AVSC_DECLARE_FUNC(avs_bit_blt)
static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
common internal API header
AVSC_INLINE int avs_is_clip(AVS_Value v)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
#define AV_PIX_FMT_GBRP16
char filename[1024]
input or output filename
#define AV_PIX_FMT_GRAY16
AVSC_INLINE AVS_Value avs_new_value_string(const char *v0)
AVSC_INLINE const char * avs_as_error(AVS_Value v)
static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
static const int avs_planes_grey[1]
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_GBRP14
static void error(const char *err)
static int read_header(FFV1Context *f)
AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo *p)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AV_PIX_FMT_YUV420P16
static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
static av_cold void avisynth_atexit_handler(void)
#define AV_PIX_FMT_YUV420P14
AVSC_INLINE const unsigned char * avs_get_read_ptr_p(const AVS_VideoFrame *p, int plane)
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVSC_INLINE int avs_is_error(AVS_Value v)
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
#define LOAD_AVS_FUNC(name, continue_on_fail)
#define AV_PIX_FMT_YUV420P10
Rational number (pair of numerator and denominator).
AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo *p)
static int avisynth_create_stream(AVFormatContext *s)
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
static int avisynth_open_file(AVFormatContext *s)
static av_cold int avisynth_load_library(void)
int64_t duration
Decoding: duration of the stream, in stream time base.
int sample_rate
Audio only.
struct AVS_ScriptEnvironment AVS_ScriptEnvironment
static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
static AviSynthContext * avs_ctx_list
planar GBRA 4:4:4:4 32bpp
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int64_t nb_frames
number of frames in this stream if known or 0
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame *p, int plane)
struct AviSynthContext * next
void * priv_data
Format private data.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static av_cold int avisynth_context_create(AVFormatContext *s)
AVCodecParameters * codecpar
static const int avs_planes_packed[1]
static av_cold void avisynth_context_destroy(AviSynthContext *avs)
AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame *p, int plane)
static av_cold int avisynth_read_header(AVFormatContext *s)
This structure stores compressed data.
static void avisynth_next_stream(AVFormatContext *s, AVStream **st, AVPacket *pkt, int *discard)
#define AV_PIX_FMT_YUV422P16
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVSC_INLINE int avs_has_audio(const AVS_VideoInfo *p)
int audio_samples_per_second