Skip to content

Commit

Permalink
d2vsource: Always set the frame properties
Browse files Browse the repository at this point in the history
Not just when the dimensions are different from the aligned dimensions.
  • Loading branch information
cantabile committed Feb 2, 2016
1 parent 8656273 commit 973cc29
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/vs/d2vsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ const VSFrameRef *VS_CC d2vGetFrame(int n, int activationReason, void **instance
VSFrameContext *frameCtx, VSCore *core, const VSAPI *vsapi)
{
d2vData *d = (d2vData *) *instanceData;
VSFrameRef *s, *f;
const VSFrameRef *s;
VSFrameRef *f;
VSMap *props;
string msg;
int ret;
int plane;

/* Unreference the previously decoded frame. */
av_frame_unref(d->frame);
Expand All @@ -58,28 +60,31 @@ const VSFrameRef *VS_CC d2vGetFrame(int n, int activationReason, void **instance
}

/* Grab our direct-rendered frame. */
s = (VSFrameRef *) d->frame->opaque;
s = (const VSFrameRef *) d->frame->opaque;
if (!s) {
vsapi->setFilterError("Seek pattern broke d2vsource! Please send a sample.", frameCtx);
return NULL;
}

/* If our width and height are the same, just return it. */
if (d->vi.width == d->aligned_width && d->vi.height == d->aligned_height) {
f = (VSFrameRef *) vsapi->cloneFrameRef(s);
return f;
f = vsapi->copyFrame(s, core);
} else {
f = vsapi->newVideoFrame(d->vi.format, d->vi.width, d->vi.height, NULL, core);

/* Copy into VS's buffers. */
for (plane = 0; plane < d->vi.format->numPlanes; plane++) {
uint8_t *dstp = vsapi->getWritePtr(f, plane);
const uint8_t *srcp = vsapi->getReadPtr(s, plane);
int dst_stride = vsapi->getStride(f, plane);
int src_stride = vsapi->getStride(s, plane);
int width = vsapi->getFrameWidth(f, plane);
int height = vsapi->getFrameHeight(f, plane);

vs_bitblt(dstp, dst_stride, srcp, src_stride, width * d->vi.format->bytesPerSample, height);
}
}

f = vsapi->newVideoFrame(d->vi.format, d->vi.width, d->vi.height, NULL, core);

/* Copy into VS's buffers. */
vs_bitblt(vsapi->getWritePtr(f, 0), vsapi->getStride(f, 0), vsapi->getWritePtr(s, 0), vsapi->getStride(s, 0),
d->vi.width, d->vi.height);
vs_bitblt(vsapi->getWritePtr(f, 1), vsapi->getStride(f, 1), vsapi->getWritePtr(s, 1), vsapi->getStride(s, 1),
d->vi.width >> d->vi.format->subSamplingW, d->vi.height >> d->vi.format->subSamplingH);
vs_bitblt(vsapi->getWritePtr(f, 2), vsapi->getStride(f, 2), vsapi->getWritePtr(s, 2), vsapi->getStride(s, 2),
d->vi.width >> d->vi.format->subSamplingW, d->vi.height >> d->vi.format->subSamplingH);

props = vsapi->getFramePropsRW(f);

/*
Expand Down

0 comments on commit 973cc29

Please sign in to comment.