27 #define AVSC_NO_DECLSPEC
41 #define AVISYNTH_LIB "avisynth"
45 #if defined (__APPLE__)
46 #define AVISYNTH_LIB "libavxsynth.dylib"
48 #define AVISYNTH_LIB "libavxsynth.so"
51 #define LoadLibrary(x) dlopen(x, RTLD_NOW | RTLD_GLOBAL)
52 #define GetProcAddress dlsym
53 #define FreeLibrary dlclose
58 #define avs_is_yv24(vi) 0
59 #define avs_is_yv16(vi) 0
60 #define avs_is_yv411(vi) 0
61 #define avs_is_y8(vi) 0
66 #define AVSC_DECLARE_FUNC(name) name##_func name
81 #undef AVSC_DECLARE_FUNC
127 #define LOAD_AVS_FUNC(name, continue_on_fail) \
129 avs_library->name = (void*)GetProcAddress(avs_library->library, #name); \
130 if(!continue_on_fail && !avs_library->name) \
171 avs->
env = avs_library->avs_create_script_environment(3);
172 if (avs_library->avs_get_error) {
173 const char *
error = avs_library->avs_get_error(avs->
env);
194 if (avs == avs_ctx_list) {
195 avs_ctx_list = avs->
next;
198 while (prev->
next != avs)
204 avs_library->avs_release_clip(avs->
clip);
208 avs_library->avs_delete_script_environment(avs->
env);
363 char filename_ansi[MAX_PATH * 4];
364 wchar_t filename_wc[MAX_PATH * 4];
372 MultiByteToWideChar(CP_UTF8, 0, s->
filename, -1, filename_wc, MAX_PATH * 4);
373 WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi, MAX_PATH * 4, NULL, NULL);
378 val = avs_library->avs_invoke(avs->
env,
"Import", arg, 0);
390 avs->
clip = avs_library->avs_take_clip(
val, avs->
env);
391 avs->
vi = avs_library->avs_get_video_info(avs->
clip);
394 avs_library->avs_release_value(
val);
425 unsigned char *dst_p;
426 const unsigned char *src_p;
427 int n, i, plane, rowsize, planeheight, pitch,
bits;
463 frame = avs_library->avs_get_frame(avs->
clip, n);
464 error = avs_library->avs_clip_get_error(avs->
clip);
473 for (i = 0; i < avs->
n_planes; i++) {
479 if (avs_library->avs_get_version(avs->
clip) == 3) {
493 src_p = src_p + (planeheight - 1) * pitch;
497 avs_library->avs_bit_blt(avs->
env, dst_p, rowsize, src_p, pitch, rowsize, planeheight);
498 dst_p += rowsize * planeheight;
501 avs_library->avs_release_video_frame(frame);
556 avs_library->avs_get_audio(avs->
clip, pkt->
data, n, samples);
557 error = avs_library->avs_clip_get_error(avs->
clip);
636 if ((timestamp >= avs->
vi->
num_frames) || (timestamp > INT_MAX) || (timestamp < 0))
const char const char void * val
static int avs_atexit_called
int avpriv_unlock_avformat(void)
static AviSynthLibrary * avs_library
AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame *p, int plane)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
AVCodecContext * codec
Codec context associated with this stream.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame *p, int plane)
static const int avs_planes_yuv[3]
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
packed RGB 8:8:8, 24bpp, BGRBGR...
static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int discard)
attribute_deprecated void(* destruct)(struct AVPacket *)
#define AVSC_DECLARE_FUNC(name)
int id
Format-specific stream ID.
AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo *p)
static av_cold int read_close(AVFormatContext *ctx)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVSC_INLINE const BYTE * avs_get_read_ptr_p(const AVS_VideoFrame *p, int plane)
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static av_cold int avisynth_read_close(AVFormatContext *s)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVSC_INLINE int avs_get_row_size_p_25(const AVS_VideoFrame *p, int plane)
void * priv_data
Format private data.
char filename[1024]
input or output filename
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
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
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
A list of all streams in the file.
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)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame *p, int plane)
static const int avs_planes_grey[1]
AVSC_INLINE int avs_get_height_p_25(const AVS_VideoFrame *p, int plane)
static int read_header(FFV1Context *f)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
attribute_deprecated void av_destruct_packet(AVPacket *pkt)
Default packet destructor.
static av_cold void avisynth_atexit_handler(void)
enum AVMediaType codec_type
int sample_rate
samples per second
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
AVSC_INLINE int avs_is_error(AVS_Value v)
#define LOAD_AVS_FUNC(name, continue_on_fail)
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
rational number numerator/denominator
AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo *p)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
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)
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...
AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo *p)
int64_t nb_frames
number of frames in this stream if known or 0
struct AviSynthContext * next
int channels
number of audio channels
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...
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...
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVSC_INLINE int avs_has_audio(const AVS_VideoInfo *p)
int audio_samples_per_second