Beispiel #1
0
CSRIAviSynth::CSRIAviSynth(PClip _child, IScriptEnvironment *env,
	const char *file, const char *rendname, const char *rendver)
	: GenericVideoFilter(_child)
{
	csri_rend *r = csri_renderer_byname(rendname, rendver);
	if (!r) {
		if (rendver)
			env->ThrowError("Failed to load renderer \"%s\""
				" version \"%s\"", rendname, rendver);
		else if (rendname)
			env->ThrowError("Failed to load renderer \"%s\"",
				rendname);
		else
			env->ThrowError("Failed to load default renderer");
	}

	struct csri_fmt fmt;
	fmt.pixfmt = GetPixfmt();
	if (fmt.pixfmt == -1)
		env->ThrowError("Pixel format not supported by "
			"AviSynth interface");

	inst = csri_open_file(r, file, NULL);
	if (!inst)
		env->ThrowError("Failed to load \"%s\"", file);

	fmt.width = vi.width;
	fmt.height = vi.height;
	if (csri_request_fmt(inst, &fmt)) {
		csri_close(inst);
		env->ThrowError("Selected pixel format or size not supported "
			"by selected subtitle renderer", file);
	}
	spf = (double)vi.fps_denominator / (double)vi.fps_numerator;
}
Beispiel #2
0
int kCSRI::Draw(videoframe& dst)
{
    // Check if CSRI loaded properly
    if(!kInstance) return 1;  // no CSRI loaded

    // Load data into frame
    csri_frame frame;
    frame.pixfmt = CSRI_F_BGR_;
    for(size_t i = 0; i < 4; i++)
    {
        frame.planes[i] = NULL;
        frame.strides[0] = 0;
    }
    frame.planes[0] = dst.data;
    frame.strides[0] = 4 * dst.width;

    // Set format
    csri_fmt format;
    format.width = dst.width;
    format.height = dst.height;
    format.pixfmt = frame.pixfmt;
    int error = csri_request_fmt(kInstance, &format);
    if(error) return 2;  // incompatible format

    // Render
    csri_render(kInstance, &frame, 0);
    return 0;
}
void CSRISubtitlesProvider::DrawSubtitles(VideoFrame &dst,double time) {
    if (!instance) return;

    csri_frame frame;
    if (dst.flipped) {
        frame.planes[0] = dst.data.data() + (dst.height-1) * dst.width * 4;
        frame.strides[0] = -(signed)dst.width * 4;
    }
    else {
        frame.planes[0] = dst.data.data();
        frame.strides[0] = dst.width * 4;
    }
    frame.pixfmt = CSRI_F_BGR_;

    csri_fmt format = { frame.pixfmt, dst.width, dst.height };

    std::lock_guard<std::mutex> lock(csri_mutex);
    if (!csri_request_fmt(instance, &format))
        csri_render(instance, &frame, time);
}