[FFmpeg-devel] 回复: [PATCH 1/1] add without_captureblt option for libavdevice/gdigrab.c, when useing the bitblt function with CAPTUREBLT it caused the mouse cursor flicker. most time we dont need this flag to capture window
Commit Message
did someone review the patch?
________________________________
发件人: _ FgoDt <fgodtdev@hotmail.com>
发送时间: 2019年11月15日 15:03
收件人: ffmpeg-devel@ffmpeg.org <ffmpeg-devel@ffmpeg.org>
抄送: _ FgoDt <fgodtdev@hotmail.com>
主题: [PATCH 1/1] add without_captureblt option for libavdevice/gdigrab.c, when useing the bitblt function with CAPTUREBLT it caused the mouse cursor flicker. most time we dont need this flag to capture window
From: fgodt <fgodtdev@hotmail.com>
Signed-off-by: fgodt <fgodtdev@hotmail.com>
---
libavdevice/gdigrab.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--
2.23.0
Comments
On Wed, 11. Dec 09:01, _ FgoDt wrote:
> did someone review the patch?
>
> ________________________________
> 发件人: _ FgoDt <fgodtdev@hotmail.com>
> 发送时间: 2019年11月15日 15:03
> 收件人: ffmpeg-devel@ffmpeg.org <ffmpeg-devel@ffmpeg.org>
> 抄送: _ FgoDt <fgodtdev@hotmail.com>
> 主题: [PATCH 1/1] add without_captureblt option for libavdevice/gdigrab.c, when useing the bitblt function with CAPTUREBLT it caused the mouse cursor flicker. most time we dont need this flag to capture window
>
> From: fgodt <fgodtdev@hotmail.com>
This would be in commit, you should use your name.
>
> Signed-off-by: fgodt <fgodtdev@hotmail.com>
> ---
> libavdevice/gdigrab.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
> index f4444406fa..0ab0cfed01 100644
> --- a/libavdevice/gdigrab.c
> +++ b/libavdevice/gdigrab.c
> @@ -53,6 +53,8 @@ struct gdigrab {
> int offset_x; /**< Capture x offset (private option) */
> int offset_y; /**< Capture y offset (private option) */
>
> + int without_captureblt; /**< capture without captureblt */
> +
> HWND hwnd; /**< Handle of the window for the grab */
> HDC source_hdc; /**< Source device context */
> HDC dest_hdc; /**< Destination, source-compatible DC */
> @@ -542,6 +544,8 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
>
> int64_t curtime, delay;
>
> + unsigned long flag;
> +
> /* Calculate the time of the next frame */
> time_frame += INT64_C(1000000);
>
> @@ -570,12 +574,16 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
> return AVERROR(ENOMEM);
> pkt->pts = curtime;
>
> + flag = SRCCOPY;
> + if(!gdigrab->without_captureblt)
> + flag |= CAPTUREBLT;
> +
> /* Blit screen grab */
> if (!BitBlt(dest_hdc, 0, 0,
> clip_rect.right - clip_rect.left,
> clip_rect.bottom - clip_rect.top,
> source_hdc,
> - clip_rect.left, clip_rect.top, SRCCOPY | CAPTUREBLT)) {
> + clip_rect.left, clip_rect.top, flag)) {
> WIN32_API_ERROR("Failed to capture image");
> return AVERROR(EIO);
> }
> @@ -639,6 +647,7 @@ static const AVOption options[] = {
> { "video_size", "set video frame size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, DEC },
> { "offset_x", "capture area x offset", OFFSET(offset_x), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
> { "offset_y", "capture area y offset", OFFSET(offset_y), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
> + { "without_captureblt", "capture without captureblt", OFFSET(without_captureblt), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC },
> { NULL },
> };
IMO a not negated option would be better. i.e. use_captureblt that's enabled by
default.
You also need to update the docs.
I don't have windows so can't test on my machine.
On 2019/12/11 下午10:19, Andriy Gelman wrote:
> On Wed, 11. Dec 09:01, _ FgoDt wrote:
>> did someone review the patch?
>>
>> ________________________________
>> 发件人: _ FgoDt <fgodtdev@hotmail.com>
>> 发送时间: 2019年11月15日 15:03
>> 收件人: ffmpeg-devel@ffmpeg.org <ffmpeg-devel@ffmpeg.org>
>> 抄送: _ FgoDt <fgodtdev@hotmail.com>
>> 主题: [PATCH 1/1] add without_captureblt option for libavdevice/gdigrab.c, when useing the bitblt function with CAPTUREBLT it caused the mouse cursor flicker. most time we dont need this flag to capture window
>> From: fgodt <fgodtdev@hotmail.com>
> This would be in commit, you should use your name.
>
>> Signed-off-by: fgodt <fgodtdev@hotmail.com>
>> ---
>> libavdevice/gdigrab.c | 11 ++++++++++-
>> 1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
>> index f4444406fa..0ab0cfed01 100644
>> --- a/libavdevice/gdigrab.c
>> +++ b/libavdevice/gdigrab.c
>> @@ -53,6 +53,8 @@ struct gdigrab {
>> int offset_x; /**< Capture x offset (private option) */
>> int offset_y; /**< Capture y offset (private option) */
>>
>> + int without_captureblt; /**< capture without captureblt */
>> +
>> HWND hwnd; /**< Handle of the window for the grab */
>> HDC source_hdc; /**< Source device context */
>> HDC dest_hdc; /**< Destination, source-compatible DC */
>> @@ -542,6 +544,8 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
>>
>> int64_t curtime, delay;
>>
>> + unsigned long flag;
>> +
>> /* Calculate the time of the next frame */
>> time_frame += INT64_C(1000000);
>>
>> @@ -570,12 +574,16 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
>> return AVERROR(ENOMEM);
>> pkt->pts = curtime;
>>
>> + flag = SRCCOPY;
>> + if(!gdigrab->without_captureblt)
>> + flag |= CAPTUREBLT;
>> +
>> /* Blit screen grab */
>> if (!BitBlt(dest_hdc, 0, 0,
>> clip_rect.right - clip_rect.left,
>> clip_rect.bottom - clip_rect.top,
>> source_hdc,
>> - clip_rect.left, clip_rect.top, SRCCOPY | CAPTUREBLT)) {
>> + clip_rect.left, clip_rect.top, flag)) {
>> WIN32_API_ERROR("Failed to capture image");
>> return AVERROR(EIO);
>> }
>> @@ -639,6 +647,7 @@ static const AVOption options[] = {
>> { "video_size", "set video frame size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, DEC },
>> { "offset_x", "capture area x offset", OFFSET(offset_x), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
>> { "offset_y", "capture area y offset", OFFSET(offset_y), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
>> + { "without_captureblt", "capture without captureblt", OFFSET(without_captureblt), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC },
>> { NULL },
>> };
> IMO a not negated option would be better. i.e. use_captureblt that's enabled by
> default.
>
> You also need to update the docs.
>
> I don't have windows so can't test on my machine.
>
Thanks
I will send an other patch, change without_captureblt to use_captureblt
and update the docs, also test on my pc
@@ -53,6 +53,8 @@ struct gdigrab {
int offset_x; /**< Capture x offset (private option) */
int offset_y; /**< Capture y offset (private option) */
+ int without_captureblt; /**< capture without captureblt */
+
HWND hwnd; /**< Handle of the window for the grab */
HDC source_hdc; /**< Source device context */
HDC dest_hdc; /**< Destination, source-compatible DC */
@@ -542,6 +544,8 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
int64_t curtime, delay;
+ unsigned long flag;
+
/* Calculate the time of the next frame */
time_frame += INT64_C(1000000);
@@ -570,12 +574,16 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
return AVERROR(ENOMEM);
pkt->pts = curtime;
+ flag = SRCCOPY;
+ if(!gdigrab->without_captureblt)
+ flag |= CAPTUREBLT;
+
/* Blit screen grab */
if (!BitBlt(dest_hdc, 0, 0,
clip_rect.right - clip_rect.left,
clip_rect.bottom - clip_rect.top,
source_hdc,
- clip_rect.left, clip_rect.top, SRCCOPY | CAPTUREBLT)) {
+ clip_rect.left, clip_rect.top, flag)) {
WIN32_API_ERROR("Failed to capture image");
return AVERROR(EIO);
}
@@ -639,6 +647,7 @@ static const AVOption options[] = {
{ "video_size", "set video frame size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, DEC },
{ "offset_x", "capture area x offset", OFFSET(offset_x), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
{ "offset_y", "capture area y offset", OFFSET(offset_y), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
+ { "without_captureblt", "capture without captureblt", OFFSET(without_captureblt), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC },
{ NULL },
};