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);
248 #ifdef USING_AVISYNTH
285 "unknown AviSynth colorspace %d\n", avs->
vi->
pixel_type);
372 #ifdef USING_AVISYNTH
373 char filename_ansi[MAX_PATH * 4];
374 wchar_t filename_wc[MAX_PATH * 4];
380 #ifdef USING_AVISYNTH
382 MultiByteToWideChar(CP_UTF8, 0, s->
filename, -1, filename_wc, MAX_PATH * 4);
383 WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi,
389 val = avs_library.avs_invoke(avs->
env,
"Import", arg, 0);
401 avs->
clip = avs_library.avs_take_clip(val, avs->
env);
402 avs->
vi = avs_library.avs_get_video_info(avs->
clip);
404 #ifdef USING_AVISYNTH
410 if (avs_library.avs_get_version(avs->
clip) < 6) {
412 "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
419 avs_library.avs_release_value(val);
454 unsigned char *dst_p;
455 const unsigned char *src_p;
456 int n, i,
plane, rowsize, planeheight, pitch,
bits;
467 #ifdef USING_AVISYNTH
472 if (avs_library.avs_is_yv24(avs->
vi))
474 else if (avs_library.avs_is_yv16(avs->
vi))
476 else if (avs_library.avs_is_yv411(avs->
vi))
478 else if (avs_library.avs_is_y8(avs->
vi))
481 bits = avs_library.avs_bits_per_pixel(avs->
vi);
489 (int64_t)avs->
vi->
height) * bits) / 8;
501 frame = avs_library.avs_get_frame(avs->
clip, n);
502 error = avs_library.avs_clip_get_error(avs->
clip);
511 for (i = 0; i < avs->
n_planes; i++) {
513 #ifdef USING_AVISYNTH
514 src_p = avs_library.avs_get_read_ptr_p(frame, plane);
515 pitch = avs_library.avs_get_pitch_p(frame, plane);
517 rowsize = avs_library.avs_get_row_size_p(frame, plane);
518 planeheight = avs_library.avs_get_height_p(frame, plane);
529 src_p = src_p + (planeheight - 1) * pitch;
533 avs_library.avs_bit_blt(avs->
env, dst_p, rowsize, src_p, pitch,
534 rowsize, planeheight);
535 dst_p += rowsize * planeheight;
538 avs_library.avs_release_video_frame(frame);
598 avs_library.avs_get_audio(avs->
clip, pkt->
data, n, samples);
599 error = avs_library.avs_clip_get_error(avs->
clip);
667 int64_t timestamp,
int flags)
684 (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)
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)
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)
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