If I understand it correctly, it is impossible for application to set a resolution which isn't supported by the device now, since SetFormat() will fail when an invalid is given. Hence we don't need to handle this case anymore.
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/qcap/v4l.c | 80 +++++++++---------------------------------------- 1 file changed, 14 insertions(+), 66 deletions(-)
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index b264203bcc..eab9ecd2e2 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -103,11 +103,9 @@ struct capabilitie
struct _Capture { - UINT outputwidth, outputheight; struct capabilitie *current_cap; struct capabilitie **caps; LONG caps_count; - BOOL swresize;
struct strmbase_source *pin; int fd, mmap; @@ -206,8 +204,6 @@ HRESULT qcap_driver_set_format(Capture *device, AM_MEDIA_TYPE *mt) || format.fmt.pix.height != newheight) ERR("Failed to set pixel format: %s.\n", strerror(errno));
- device->outputwidth = format.fmt.pix.width; - device->outputheight = format.fmt.pix.height; return S_OK; }
@@ -297,61 +293,22 @@ HRESULT qcap_driver_set_prop(Capture *device, VideoProcAmpProperty property,
static void Resize(const Capture * capBox, LPBYTE output, const BYTE *input) { - UINT width, height, bitdepth, depth; + int inoffset, outoffset, ow; + struct capabilitie *cap;
- width = capBox->current_cap->width; - height = capBox->current_cap->height; - bitdepth = capBox->current_cap->depth; - depth = bitdepth / 8; + cap = capBox->current_cap; + outoffset = cap->width * cap->height * cap->depth / 8; + ow = cap->width * cap->depth / 8; + inoffset = 0; /* the whole image needs to be reversed, because the dibs are messed up in windows */ - if (!capBox->swresize) + while (outoffset > 0) { - int inoffset = 0, outoffset = height * width * depth; - int ow = width * depth; - while (outoffset > 0) - { - int x; - outoffset -= ow; - for (x = 0; x < ow; x++) - output[outoffset + x] = input[inoffset + x]; - inoffset += ow; - } - } - else - { - HDC dc_s, dc_d; - HBITMAP bmp_s, bmp_d; - int inoffset = 0, outoffset = (capBox->outputheight) * capBox->outputwidth * depth; - int ow = capBox->outputwidth * depth; - LPBYTE myarray; - - /* FIXME: Improve software resizing: add error checks and optimize */ - - myarray = CoTaskMemAlloc(capBox->outputwidth * capBox->outputheight * depth); - dc_s = CreateCompatibleDC(NULL); - dc_d = CreateCompatibleDC(NULL); - bmp_s = CreateBitmap(width, height, 1, bitdepth, input); - bmp_d = CreateBitmap(capBox->outputwidth, capBox->outputheight, 1, bitdepth, NULL); - SelectObject(dc_s, bmp_s); - SelectObject(dc_d, bmp_d); - StretchBlt(dc_d, 0, 0, capBox->outputwidth, capBox->outputheight, - dc_s, 0, 0, width, height, SRCCOPY); - GetBitmapBits(bmp_d, capBox->outputwidth * capBox->outputheight * depth, myarray); - while (outoffset > 0) - { - int i; - - outoffset -= ow; - for (i = 0; i < ow; i++) - output[outoffset + i] = myarray[inoffset + i]; - inoffset += ow; - } - CoTaskMemFree(myarray); - DeleteObject(dc_s); - DeleteObject(dc_d); - DeleteObject(bmp_s); - DeleteObject(bmp_d); + int x; + outoffset -= ow; + for (x = 0; x < ow; x++) + output[outoffset + x] = input[inoffset + x]; + inoffset += ow; } }
@@ -385,10 +342,7 @@ static DWORD WINAPI ReadThread(LPVOID lParam) { int len;
- if (!capBox->swresize) - len = height * width * depth; - else - len = capBox->outputheight * capBox->outputwidth * depth; + len = height * width * depth; IMediaSample_SetActualDataLength(pSample, len);
len = IMediaSample_GetActualDataLength(pSample); @@ -427,10 +381,7 @@ void qcap_driver_init_stream(Capture *device) HRESULT hr;
req_props.cBuffers = 3; - if (!device->swresize) - req_props.cbBuffer = device->current_cap->width * device->current_cap->height; - else - req_props.cbBuffer = device->outputwidth * device->outputheight; + req_props.cbBuffer = device->current_cap->width * device->current_cap->height; req_props.cbBuffer = (req_props.cbBuffer * device->current_cap->depth) / 8; req_props.cbAlign = 1; req_props.cbPrefix = 0; @@ -685,9 +636,6 @@ Capture *qcap_driver_init(struct strmbase_source *pin, USHORT card) goto error; }
- device->outputwidth = format.fmt.pix.width; - device->outputheight = format.fmt.pix.height; - device->swresize = FALSE; device->pin = pin; device->state = State_Stopped; device->run_event = CreateEventW(NULL, TRUE, FALSE, NULL);
On 4/23/20 12:29 AM, Jactry Zeng wrote:
If I understand it correctly, it is impossible for application to set a resolution which isn't supported by the device now, since SetFormat() will fail when an invalid is given. Hence we don't need to handle this case anymore.
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
dlls/qcap/v4l.c | 80 +++++++++---------------------------------------- 1 file changed, 14 insertions(+), 66 deletions(-)
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index b264203bcc..eab9ecd2e2 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -103,11 +103,9 @@ struct capabilitie
struct _Capture {
UINT outputwidth, outputheight; struct capabilitie *current_cap; struct capabilitie **caps; LONG caps_count;
BOOL swresize;
struct strmbase_source *pin; int fd, mmap;
@@ -206,8 +204,6 @@ HRESULT qcap_driver_set_format(Capture *device, AM_MEDIA_TYPE *mt) || format.fmt.pix.height != newheight) ERR("Failed to set pixel format: %s.\n", strerror(errno));
- device->outputwidth = format.fmt.pix.width;
- device->outputheight = format.fmt.pix.height; return S_OK;
}
@@ -297,61 +293,22 @@ HRESULT qcap_driver_set_prop(Capture *device, VideoProcAmpProperty property,
static void Resize(const Capture * capBox, LPBYTE output, const BYTE *input)
I guess this function shouldn't be called Resize() anymore, then?
{
- UINT width, height, bitdepth, depth;
- int inoffset, outoffset, ow;
- struct capabilitie *cap;
- width = capBox->current_cap->width;
- height = capBox->current_cap->height;
- bitdepth = capBox->current_cap->depth;
- depth = bitdepth / 8;
- cap = capBox->current_cap;
- outoffset = cap->width * cap->height * cap->depth / 8;
- ow = cap->width * cap->depth / 8;
- inoffset = 0; /* the whole image needs to be reversed, because the dibs are messed up in windows */
- if (!capBox->swresize)
- while (outoffset > 0) {
int inoffset = 0, outoffset = height * width * depth;
int ow = width * depth;
while (outoffset > 0)
{
int x;
outoffset -= ow;
for (x = 0; x < ow; x++)
output[outoffset + x] = input[inoffset + x];
inoffset += ow;
}
- }
- else
- {
HDC dc_s, dc_d;
HBITMAP bmp_s, bmp_d;
int inoffset = 0, outoffset = (capBox->outputheight) * capBox->outputwidth * depth;
int ow = capBox->outputwidth * depth;
LPBYTE myarray;
/* FIXME: Improve software resizing: add error checks and optimize */
myarray = CoTaskMemAlloc(capBox->outputwidth * capBox->outputheight * depth);
dc_s = CreateCompatibleDC(NULL);
dc_d = CreateCompatibleDC(NULL);
bmp_s = CreateBitmap(width, height, 1, bitdepth, input);
bmp_d = CreateBitmap(capBox->outputwidth, capBox->outputheight, 1, bitdepth, NULL);
SelectObject(dc_s, bmp_s);
SelectObject(dc_d, bmp_d);
StretchBlt(dc_d, 0, 0, capBox->outputwidth, capBox->outputheight,
dc_s, 0, 0, width, height, SRCCOPY);
GetBitmapBits(bmp_d, capBox->outputwidth * capBox->outputheight * depth, myarray);
while (outoffset > 0)
{
int i;
outoffset -= ow;
for (i = 0; i < ow; i++)
output[outoffset + i] = myarray[inoffset + i];
inoffset += ow;
}
CoTaskMemFree(myarray);
DeleteObject(dc_s);
DeleteObject(dc_d);
DeleteObject(bmp_s);
DeleteObject(bmp_d);
int x;
outoffset -= ow;
for (x = 0; x < ow; x++)
output[outoffset + x] = input[inoffset + x];
}inoffset += ow;
}
@@ -385,10 +342,7 @@ static DWORD WINAPI ReadThread(LPVOID lParam) { int len;
if (!capBox->swresize)
len = height * width * depth;
else
len = capBox->outputheight * capBox->outputwidth * depth;
len = height * width * depth; IMediaSample_SetActualDataLength(pSample, len); len = IMediaSample_GetActualDataLength(pSample);
@@ -427,10 +381,7 @@ void qcap_driver_init_stream(Capture *device) HRESULT hr;
req_props.cBuffers = 3;
- if (!device->swresize)
req_props.cbBuffer = device->current_cap->width * device->current_cap->height;
- else
req_props.cbBuffer = device->outputwidth * device->outputheight;
- req_props.cbBuffer = device->current_cap->width * device->current_cap->height; req_props.cbBuffer = (req_props.cbBuffer * device->current_cap->depth) / 8; req_props.cbAlign = 1; req_props.cbPrefix = 0;
@@ -685,9 +636,6 @@ Capture *qcap_driver_init(struct strmbase_source *pin, USHORT card) goto error; }
- device->outputwidth = format.fmt.pix.width;
- device->outputheight = format.fmt.pix.height;
- device->swresize = FALSE; device->pin = pin; device->state = State_Stopped; device->run_event = CreateEventW(NULL, TRUE, FALSE, NULL);