/* Xvid's default 2-pass doesn't allow us to create data as we need to, so this section spends time replacing the first pass plugin so we can write statistic information as libavcodec requests in. We have another kludge that allows us to pass data to the second pass in Xvid without a custom rate-control plugin. Initializes the two-pass plugin and context. */
static int xvid_ff_2pass_create(xvid_plg_create_t *param, void **handle)
/* Xvid's default 2-pass doesn't allow us to create data as we need to, so this section spends time replacing the first pass plugin so we can write statistic information as libavcodec requests in. We have another kludge that allows us to pass data to the second pass in Xvid without a custom rate-control plugin. Initializes the two-pass plugin and context. */
static int xvid_ff_2pass_create(xvid_plg_create_t *param, void **handle)
{
    struct xvid_ff_pass1 *x = (struct xvid_ff_pass1 *)param->param;
    char *log = x->context->twopassbuffer;
    if( log == NULL )
        return XVID_ERR_FAIL;
    log[0] = 0;
    snprintf(log, BUFFER_REMAINING(log),
        "# ffmpeg 2-pass log file, using xvid codec\n");
    snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log),
        "# Do not modify. libxvidcore version: %d.%d.%d\n\n",
        XVID_VERSION_MAJOR(XVID_VERSION),
        XVID_VERSION_MINOR(XVID_VERSION),
        XVID_VERSION_PATCH(XVID_VERSION));
    *handle = x->context;
    return 0;
}