Hi Alexey,

On Sunday 06 March 2011 11:57:14 Alexey Fisher wrote:
> Some webcams report wired dwMaxVideoFrameBufferSize size,
> some times too big, some times too smole.
> 
> I tested two webcams:
> 046d:0809 Logitech, Inc. Webcam Pro 9000
> 046d:0991 Logitech, Inc. QuickCam Pro for Notebooks
> with fallowing results.
> 
> The dwMaxVideoFrameBufferSize is not always the same. Reported
> range is about betwene 4 and 10 bpp calculated with this formula:
> bpp = (dwMaxVideoFrameBufferSize * 8) / (frame->wWidth * frame->wHeight)
> 
> I tested also a real comression on this cameras. Comression
> with noremal conditions (video chat) was about 1 bpp.
> Worst compression was by captureing moving text on monitore
> (lots of light, high fps) is about 3bpp.
> So we can calculate predictable buffer size in driver, insted of
> getting some random numers from the cam.
> 
> Setting bpp to 4 for mjpeg should be safe.

Can you but sure that it will be safe for *all* cameras ? I can't.

The uvcvideo driver doesn't use the dwMaxVideoFrameBufferSize field but 
queries the device at runtime for the maximum frame size value (there's one 
exception to this though, the driver uses dwMaxVideoFrameBufferSize for 
pre-1.10 UVC devices that report a 0 frame size at runtime).

The field is also totally unrelated to USB bandwidth management, the maximum 
frame size value is only used to allocate the V4L2 buffers.

> Signed-off-by: Alexey Fisher <bug-tr...@fisher-privat.net>
> ---
>  drivers/media/video/uvc/uvc_driver.c |    5 +++--
>  drivers/media/video/uvc/uvc_video.c  |    3 ++-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/video/uvc/uvc_driver.c
> b/drivers/media/video/uvc/uvc_driver.c index e41285a..5a74de0 100644
> --- a/drivers/media/video/uvc/uvc_driver.c
> +++ b/drivers/media/video/uvc/uvc_driver.c
> @@ -347,7 +347,7 @@ static int uvc_parse_format(struct uvc_device *dev,
>               strlcpy(format->name, "MJPEG", sizeof format->name);
>               format->fcc = V4L2_PIX_FMT_MJPEG;
>               format->flags = UVC_FMT_FLAG_COMPRESSED;
> -             format->bpp = 0;
> +             format->bpp = 4;
>               ftype = UVC_VS_FRAME_MJPEG;
>               break;
> 
> @@ -460,7 +460,8 @@ static int uvc_parse_format(struct uvc_device *dev,
>                * uncompressed formats this can be fixed by computing the
>                * value from the frame size.
>                */
> -             if (!(format->flags & UVC_FMT_FLAG_COMPRESSED))
> +             if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) ||
> +                             (format->fcc == V4L2_PIX_FMT_MJPEG))
>                       frame->dwMaxVideoFrameBufferSize = format->bpp
>                               * frame->wWidth * frame->wHeight / 8;
> 
> diff --git a/drivers/media/video/uvc/uvc_video.c
> b/drivers/media/video/uvc/uvc_video.c index 9a95a62..64bd1d6 100644
> --- a/drivers/media/video/uvc/uvc_video.c
> +++ b/drivers/media/video/uvc/uvc_video.c
> @@ -114,7 +114,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming
> *stream,
> 
>       if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) ||
>            (ctrl->dwMaxVideoFrameSize == 0 &&
> -           stream->dev->uvc_version < 0x0110)) {
> +           stream->dev->uvc_version < 0x0110) ||
> +          (format->fcc == V4L2_PIX_FMT_MJPEG)) {
>               pr_debug("%s: rewrite dwMaxVideoFrameSize=%u to %u.",
>                        __func__, ctrl->dwMaxVideoFrameSize,
>                       frame->dwMaxVideoFrameBufferSize);

-- 
Regards,

Laurent Pinchart
_______________________________________________
Linux-uvc-devel mailing list
Linux-uvc-devel@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to