Sorry I'm late to the party. Just a couple comments.
On Wed, 6 Nov 2013 01:02:23 -0500, Stephen Hutchinson <[email protected]> wrote:
> From: d s <[email protected]>
>
> Directly loads AviSynth through LoadLibrary instead of relying on
> Video for Windows, and supports using AvxSynth (via dlopen) to
> open scripts on Linux and OS X.
>
> Error messages from AviSynth/AvxSynth are now reported through
> av_log and exit, rather than the traditional behavior of generating
> an error video that the user would need to watch to diagnose.
>
> The main rewrite was authored by d s <[email protected]>
> from the AvxSynth team, with additional contributions by
>
> Oka Motofumi <[email protected]>
> Stephen Hutchinson <[email protected]>
> ---
> configure | 4 +-
> libavformat/avisynth.c | 800
> +++++++++++++++++++++++++++++++++++++++----------
> 2 files changed, 637 insertions(+), 167 deletions(-)
>
> +
> +/* A conflict between C++ global objects, atexit, and dynamic loading
> requires
> + * us to register our own atexit handler to prevent double freeing. */
> +static AviSynthLibrary *avs_library = NULL;
Is there a reason for avs_library to be dynamically allocated?
>From looking at the code, I don't see why you couldn't store the whole struct
>as
static here.
>
> -static int avisynth_read_close(AVFormatContext *s)
> +/* Copy AviSynth clip data into an AVPacket. */
> +static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
> + int discard)
> {
> AviSynthContext *avs = s->priv_data;
> - int i;
> + AVS_VideoFrame *frame;
> + unsigned char *dst_p;
> + const unsigned char *src_p;
> + int n, i, plane, rowsize, planeheight, pitch, bits;
> + const char *error;
> +
> + if (avs->curr_frame >= avs->vi->num_frames)
> + return AVERROR_EOF;
> +
> + /* This must happen even if the stream is discarded to prevent desync. */
> + n = avs->curr_frame++;
> + 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))
> + bits = 24;
> + else if (avs_is_yv16(avs->vi))
> + bits = 16;
> + else if (avs_is_yv411(avs->vi))
> + bits = 12;
> + else if (avs_is_y8(avs->vi))
> + bits = 8;
> + else
> +#endif
> + bits = avs_bits_per_pixel(avs->vi);
> +
> + /* Without the cast to int64_t, calculation overflows at about 9k x 9k
> + * resolution. */
> + pkt->size = (((int64_t)avs->vi->width *
> + (int64_t)avs->vi->height) * bits) / 8;
> + if (!pkt->size)
> + return AVERROR_UNKNOWN;
> + pkt->data = av_malloc(pkt->size);
Why not allocate with av_new_packet? It's the standard way and it would also
take care of the issues with destruct (which you set below) being deprecated.
--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel