28 #define AVSC_NO_DECLSPEC
35 #define AVISYNTH_LIB "avisynth"
36 #define USING_AVISYNTH
40 #define AVISYNTH_NAME "libavxsynth"
41 #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
43 #define LoadLibrary(x) dlopen(x, RTLD_NOW | RTLD_LOCAL)
44 #define GetProcAddress dlsym
45 #define FreeLibrary dlclose
50 #define AVSC_DECLARE_FUNC(name) name ## _func name
76 #undef AVSC_DECLARE_FUNC
119 #define LOAD_AVS_FUNC(name, continue_on_fail) \
121 (void *)GetProcAddress(avs_library.library, #name); \
122 if (!continue_on_fail && !avs_library.name) \
139 #ifdef USING_AVISYNTH
172 avs->
env = avs_library.avs_create_script_environment(3);
173 if (avs_library.avs_get_error) {
174 const char *
error = avs_library.avs_get_error(avs->
env);
196 if (avs == avs_ctx_list) {
197 avs_ctx_list = avs->
next;
200 while (prev->
next != avs)
206 avs_library.avs_release_clip(avs->
clip);
210 avs_library.avs_delete_script_environment(avs->
env);
249 #ifdef USING_AVISYNTH
286 "unknown AviSynth colorspace %d\n", avs->
vi->
pixel_type);
374 #ifdef USING_AVISYNTH
375 char filename_ansi[MAX_PATH * 4];
376 wchar_t filename_wc[MAX_PATH * 4];
382 #ifdef USING_AVISYNTH
384 MultiByteToWideChar(CP_UTF8, 0, s->
filename, -1, filename_wc, MAX_PATH * 4);
385 WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi,
391 val = avs_library.avs_invoke(avs->
env,
"Import", arg, 0);
403 avs->
clip = avs_library.avs_take_clip(val, avs->
env);
404 avs->
vi = avs_library.avs_get_video_info(avs->
clip);
406 #ifdef USING_AVISYNTH
412 if (avs_library.avs_get_version(avs->
clip) < 6) {
414 "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
421 avs_library.avs_release_value(val);
456 unsigned char *dst_p;
457 const unsigned char *src_p;
458 int n, i,
plane, rowsize, planeheight, pitch,
bits;
469 #ifdef USING_AVISYNTH
474 if (avs_library.avs_is_yv24(avs->
vi))
476 else if (avs_library.avs_is_yv16(avs->
vi))
478 else if (avs_library.avs_is_yv411(avs->
vi))
480 else if (avs_library.avs_is_y8(avs->
vi))
483 bits = avs_library.avs_bits_per_pixel(avs->
vi);
491 (int64_t)avs->
vi->
height) * bits) / 8;
503 frame = avs_library.avs_get_frame(avs->
clip, n);
504 error = avs_library.avs_clip_get_error(avs->
clip);
513 for (i = 0; i < avs->
n_planes; i++) {
515 #ifdef USING_AVISYNTH
516 src_p = avs_library.avs_get_read_ptr_p(frame, plane);
517 pitch = avs_library.avs_get_pitch_p(frame, plane);
519 rowsize = avs_library.avs_get_row_size_p(frame, plane);
520 planeheight = avs_library.avs_get_height_p(frame, plane);
531 src_p = src_p + (planeheight - 1) * pitch;
535 avs_library.avs_bit_blt(avs->
env, dst_p, rowsize, src_p, pitch,
536 rowsize, planeheight);
537 dst_p += rowsize * planeheight;
540 avs_library.avs_release_video_frame(frame);
600 avs_library.avs_get_audio(avs->
clip, pkt->
data, n, samples);
601 error = avs_library.avs_clip_get_error(avs->
clip);
669 int64_t timestamp,
int flags)
686 (timestamp > INT_MAX) ||
const char const char void * val
static int avs_atexit_called
int avpriv_unlock_avformat(void)
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 AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const int avs_planes_yuv[3]
static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int discard)
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)
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
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.
#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. ...
AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo *p)
AVSC_INLINE int avs_has_video(const AVS_VideoInfo *p)
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)
AVS_ScriptEnvironment * env
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static AviSynthLibrary avs_library
AVCodecContext * codec
Codec context associated with this stream.
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.
char filename[1024]
input or output filename
AVSC_INLINE AVS_Value avs_new_value_string(const char *v0)
AVSC_INLINE const char * avs_as_error(AVS_Value v)
int width
picture width / height.
static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
static const int avs_planes_grey[1]
packed RGB 8:8:8, 24bpp, BGRBGR...
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)
static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
static av_cold void avisynth_atexit_handler(void)
AVSC_INLINE const unsigned char * avs_get_read_ptr_p(const AVS_VideoFrame *p, int plane)
enum AVMediaType codec_type
int sample_rate
samples per second
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)
rational number numerator/denominator
AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo *p)
static int avisynth_create_stream(AVFormatContext *s)
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.
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
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
int channels
number of audio channels
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)
static const int avs_planes_packed[1]
static av_cold void avisynth_context_destroy(AviSynthContext *avs)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
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)
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