Skip to content

Commit

Permalink
Add 'nocrop' parameter
Browse files Browse the repository at this point in the history
If this is set to true, direct rendering will always be used,
and no memcpy will take place, but it will retrurn the frame
with the aligned width and height, which may need cropping,
which constitutes a memcpy in vapoursynth.

If the image has to be cropped anyway, this function can provide
a speedup in the form of less memcpys.

Signed-off-by: Derek Buitenhuis <[email protected]>
  • Loading branch information
dwbuiten committed Nov 19, 2012
1 parent 8511214 commit 1c989a2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion vs/d2vsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ static void VS_CC d2vCreate(const VSMap *in, VSMap *out, void *userData, VSCore
d2vData d;
d2vData *data;
string msg;
bool no_crop;
int err;

d.d2v = d2vparse((char *)vsapi->propGetData(in, "input", 0, 0), msg);
if (!d.d2v) {
Expand Down Expand Up @@ -128,6 +130,16 @@ static void VS_CC d2vCreate(const VSMap *in, VSMap *out, void *userData, VSCore
data->aligned_width = FFALIGN(data->vi.width, 16);
data->aligned_height = FFALIGN(data->vi.height, 32);

/* See if nocrop is enabled, and set the width/height accordingly. */
no_crop = !!vsapi->propGetInt(in, "nocrop", 0, &err);
if (err)
no_crop = false;

if (no_crop) {
data->vi.width = data->aligned_width;
data->vi.height = data->aligned_height;
}

/*
* Make our private data available to libavcodec, and
* set our custom get/release_buffer funcs.
Expand All @@ -148,5 +160,5 @@ static void VS_CC d2vCreate(const VSMap *in, VSMap *out, void *userData, VSCore

VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin configFunc, VSRegisterFunction registerFunc, VSPlugin *plugin) {
configFunc("com.sources.d2vsource", "d2v", "D2V Source", VAPOURSYNTH_API_VERSION, 1, plugin);
registerFunc("Source", "input:data;", d2vCreate, 0, plugin);
registerFunc("Source", "input:data;nocrop:int:opt;", d2vCreate, 0, plugin);
}

0 comments on commit 1c989a2

Please sign in to comment.