#include "libavcodec/internal.h"
#include "avformat.h"
#include "internal.h"
+#include "config.h"
/* Enable function pointer definitions for runtime loading. */
#define AVSC_NO_DECLSPEC
-/* Platform-specific directives for AviSynth vs AvxSynth.
- *
- * avisynth_c.h needs to be the one provided with x264, as
- * the one in AviSynth's CVS hasn't been updated to support
- * 2.6's extra colorspaces. A temporary source of that header,
- * installable from a GNU-style Makefile is available from
- * github.com/qyot27/avisynth_headers -- AvxSynth doesn't
- * require this kind of special treatment because like any
- * standard *nix application, it installs its headers
- * alongside its libs. */
+/* Platform-specific directives for AviSynth vs AvxSynth. */
#ifdef _WIN32
#include <windows.h>
#undef EXTERN_C
#else
#include <dlfcn.h>
#include <avxsynth/avxsynth_c.h>
- #if defined (__APPLE__)
- #define AVISYNTH_LIB "libavxsynth.dylib"
- #else
- #define AVISYNTH_LIB "libavxsynth.so"
- #endif
+ #define AVISYNTH_NAME "libavxsynth"
+ #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
- #define LoadLibrary(x) dlopen(x, RTLD_NOW | RTLD_GLOBAL)
+ #define LoadLibrary(x) dlopen(x, RTLD_NOW | RTLD_LOCAL)
#define GetProcAddress dlsym
#define FreeLibrary dlclose
#endif
AVSC_DECLARE_FUNC(avs_release_value);
AVSC_DECLARE_FUNC(avs_release_video_frame);
AVSC_DECLARE_FUNC(avs_take_clip);
+#ifdef USING_AVISYNTH
+ AVSC_DECLARE_FUNC(avs_bits_per_pixel);
+ AVSC_DECLARE_FUNC(avs_get_height_p);
+ AVSC_DECLARE_FUNC(avs_get_pitch_p);
+ AVSC_DECLARE_FUNC(avs_get_read_ptr_p);
+ AVSC_DECLARE_FUNC(avs_get_row_size_p);
+ AVSC_DECLARE_FUNC(avs_is_yv24);
+ AVSC_DECLARE_FUNC(avs_is_yv16);
+ AVSC_DECLARE_FUNC(avs_is_yv411);
+ AVSC_DECLARE_FUNC(avs_is_y8);
+#endif
#undef AVSC_DECLARE_FUNC
} AviSynthLibrary;
LOAD_AVS_FUNC(avs_release_value, 0);
LOAD_AVS_FUNC(avs_release_video_frame, 0);
LOAD_AVS_FUNC(avs_take_clip, 0);
+#ifdef USING_AVISYNTH
+ LOAD_AVS_FUNC(avs_bits_per_pixel, 1);
+ LOAD_AVS_FUNC(avs_get_height_p, 1);
+ LOAD_AVS_FUNC(avs_get_pitch_p, 1);
+ LOAD_AVS_FUNC(avs_get_read_ptr_p, 1);
+ LOAD_AVS_FUNC(avs_get_row_size_p, 1);
+ LOAD_AVS_FUNC(avs_is_yv24, 1);
+ LOAD_AVS_FUNC(avs_is_yv16, 1);
+ LOAD_AVS_FUNC(avs_is_yv411, 1);
+ LOAD_AVS_FUNC(avs_is_y8, 1);
+#endif
#undef LOAD_AVS_FUNC
atexit(avisynth_atexit_handler);
st->codec->channels = avs->vi->nchannels;
st->time_base = (AVRational) { 1,
avs->vi->audio_samples_per_second };
+ st->duration = avs->vi->num_audio_samples;
switch (avs->vi->sample_type) {
case AVS_SAMPLE_INT8:
avs->vi = avs_library.avs_get_video_info(avs->clip);
#ifdef USING_AVISYNTH
- /* libav only supports AviSynth 2.6 on Windows. Since AvxSynth
- * identifies itself as interface version 3 like 2.5.8, this
- * needs to be special-cased. */
+ /* On Windows, libav supports AviSynth interface version 6 or higher.
+ * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher,
+ * and excludes 2.5 and the 2.6 alphas. Since AvxSynth identifies itself
+ * as interface version 3 like 2.5.8, this needs to be special-cased. */
- if (avs_library.avs_get_version(avs->clip) == 3) {
+ if (avs_library.avs_get_version(avs->clip) < 6) {
av_log(s, AV_LOG_ERROR,
- "AviSynth 2.5.8 not supported. Please upgrade to 2.6.\n");
+ "AviSynth version is too old. Please upgrade to either AviSynth 2.6 >= RC1 or AviSynth+ >= r1718.\n");
ret = AVERROR_UNKNOWN;
goto fail;
}
{
AviSynthContext *avs = s->priv_data;
- pkt->stream_index = avs->curr_stream++;
+ avs->curr_stream++;
avs->curr_stream %= s->nb_streams;
- *st = s->streams[pkt->stream_index];
+ *st = s->streams[avs->curr_stream];
if ((*st)->discard == AVDISCARD_ALL)
*discard = 1;
else
if (discard)
return 0;
- pkt->pts = n;
- pkt->dts = n;
- pkt->duration = 1;
-
#ifdef USING_AVISYNTH
/* Define the bpp values for the new AviSynth 2.6 colorspaces.
* Since AvxSynth doesn't have these functions, special-case
* it in order to avoid implicit declaration errors. */
- if (avs_is_yv24(avs->vi))
+ if (avs_library.avs_is_yv24(avs->vi))
bits = 24;
- else if (avs_is_yv16(avs->vi))
+ else if (avs_library.avs_is_yv16(avs->vi))
bits = 16;
- else if (avs_is_yv411(avs->vi))
+ else if (avs_library.avs_is_yv411(avs->vi))
bits = 12;
- else if (avs_is_y8(avs->vi))
+ else if (avs_library.avs_is_y8(avs->vi))
bits = 8;
else
+ bits = avs_library.avs_bits_per_pixel(avs->vi);
+#else
+ bits = avs_bits_per_pixel(avs->vi);
#endif
- bits = avs_bits_per_pixel(avs->vi);
/* Without the cast to int64_t, calculation overflows at about 9k x 9k
* resolution. */
if (av_new_packet(pkt, pkt->size) < 0)
return AVERROR(ENOMEM);
+ pkt->pts = n;
+ pkt->dts = n;
+ pkt->duration = 1;
+ pkt->stream_index = avs->curr_stream;
+
frame = avs_library.avs_get_frame(avs->clip, n);
error = avs_library.avs_clip_get_error(avs->clip);
if (error) {
dst_p = pkt->data;
for (i = 0; i < avs->n_planes; i++) {
plane = avs->planes[i];
+#ifdef USING_AVISYNTH
+ src_p = avs_library.avs_get_read_ptr_p(frame, plane);
+ pitch = avs_library.avs_get_pitch_p(frame, plane);
+
+ rowsize = avs_library.avs_get_row_size_p(frame, plane);
+ planeheight = avs_library.avs_get_height_p(frame, plane);
+#else
src_p = avs_get_read_ptr_p(frame, plane);
pitch = avs_get_pitch_p(frame, plane);
rowsize = avs_get_row_size_p(frame, plane);
planeheight = avs_get_height_p(frame, plane);
+#endif
/* Flip RGB video. */
if (avs_is_rgb24(avs->vi) || avs_is_rgb(avs->vi)) {
if (discard)
return 0;
- pkt->pts = n;
- pkt->dts = n;
- pkt->duration = samples;
-
pkt->size = avs_bytes_per_channel_sample(avs->vi) *
samples * avs->vi->nchannels;
if (!pkt->size)
if (av_new_packet(pkt, pkt->size) < 0)
return AVERROR(ENOMEM);
+ pkt->pts = n;
+ pkt->dts = n;
+ pkt->duration = samples;
+ pkt->stream_index = avs->curr_stream;
+
avs_library.avs_get_audio(avs->clip, pkt->data, n, samples);
error = avs_library.avs_clip_get_error(avs->clip);
if (error) {