[FFmpeg-devel] [PATCH] When using ffmpeg to record screen, set the operating system time and set the system time backward. Stop screen recording, unable to save video.

2021-02-19 Thread houlei
From: Hou Lei 

Signed-off-by: Hou Lei 
---
 libavdevice/xcbgrab.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index be5d5ea2cf..7e886064fe 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -208,7 +208,16 @@ static int64_t wait_frame(AVFormatContext *s, AVPacket 
*pkt)
 for (;;) {
 curtime = av_gettime();
 delay   = c->time_frame - curtime;
-if (delay <= 0)
+
+//When the user changes the operating system time, can synchronization 
be forced here?
+/*
+if (delay > 10) {
+   c->time_frame = curtime + c->frame_duration;
+   break;
+}
+*/
+//When the user changes the operating system time, add timeout 
judgment.
+if (delay <= 0 || delay > 10)
 break;
 av_usleep(delay);
 }
-- 
2.20.1



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] [Code format dependent] : [Adjust the format of code blocks]

2021-02-19 Thread houlei
From: Hou Lei 

Signed-off-by: Hou Lei 
---
 fftools/ffmpeg.c |  8 
 libavcodec/h264_loopfilter.c | 22 --
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index add5a3e505..ed20bd3a25 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2672,7 +2672,7 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
 if (!repeating || !pkt || got_output) {
 if (pkt && pkt->duration) {
 duration_dts = av_rescale_q(pkt->duration, 
ist->st->time_base, AV_TIME_BASE_Q);
-} else if(ist->dec_ctx->framerate.num != 0 && 
ist->dec_ctx->framerate.den != 0) {
+} else if (ist->dec_ctx->framerate.num != 0 && 
ist->dec_ctx->framerate.den != 0) {
 int ticks= av_stream_get_parser(ist->st) ? 
av_stream_get_parser(ist->st)->repeat_pict+1 : ist->dec_ctx->ticks_per_frame;
 duration_dts = ((int64_t)AV_TIME_BASE *
 ist->dec_ctx->framerate.den * ticks) /
@@ -2773,7 +2773,7 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
 ist->next_dts = av_rescale_q(next_dts + 1, 
av_inv_q(ist->framerate), time_base_q);
 } else if (pkt->duration) {
 ist->next_dts += av_rescale_q(pkt->duration, 
ist->st->time_base, AV_TIME_BASE_Q);
-} else if(ist->dec_ctx->framerate.num != 0) {
+} else if (ist->dec_ctx->framerate.num != 0) {
 int ticks= av_stream_get_parser(ist->st) ? 
av_stream_get_parser(ist->st)->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;
 ist->next_dts += ((int64_t)AV_TIME_BASE *
   ist->dec_ctx->framerate.den * ticks) /
@@ -3493,7 +3493,7 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 
 // Don't parse the 'forced_keyframes' in case of 
'keep-source-keyframes',
 // parse it only for static kf timings
-} else if(strncmp(ost->forced_keyframes, "source", 6)) {
+} else if (strncmp(ost->forced_keyframes, "source", 6)) {
 parse_forced_key_frames(ost->forced_keyframes, ost, 
ost->enc_ctx);
 }
 }
@@ -3986,7 +3986,7 @@ static int check_keyboard_interaction(int64_t cur_time)
 if (key == 'h'){
 if (do_hex_dump){
 do_hex_dump = do_pkt_dump = 0;
-} else if(do_pkt_dump){
+} else if (do_pkt_dump){
 do_hex_dump = 1;
 } else
 do_pkt_dump = 1;
diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
index 558ec6c02d..28ad82de31 100644
--- a/libavcodec/h264_loopfilter.c
+++ b/libavcodec/h264_loopfilter.c
@@ -324,7 +324,7 @@ static av_always_inline void 
h264_filter_mb_fast_internal(const H264Context *h,
 filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, 
qpc, a, b, h, 0);
 filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, 
qpc, a, b, h, 0);
 }
-}else if(chroma422){
+} else if (chroma422){
 if(left_type){
 filter_mb_edgecv(&img_cb[2*0<> dir ) {
+} else if ( mask_par0 && ((mbm_type & (MB_TYPE_16x16 | 
(MB_TYPE_8x16 >> dir ) {
 int b_idx= 8 + 4;
 int bn_idx= b_idx - (dir ? 8:1);
 
@@ -580,9 +579,7 @@ static av_always_inline void filter_mb_dir(const 
H264Context *h, H264SliceContex
 if (sl->non_zero_count_cache[b_idx] |
 sl->non_zero_count_cache[bn_idx]) {
 bS[i] = 2;
-}
-else if(!mv_done)
-{
+} else if (!mv_done) {
 bS[i] = check_mv(sl, b_idx, bn_idx, mvy_limit);
 }
 }
@@ -643,8 +640,7 @@ static av_always_inline void filter_mb_dir(const 
H264Context *h, H264SliceContex
 if( edge & mask_edge ) {
 AV_ZERO64(bS);
 mv_done = 1;
-}
-else if( mask_par0 ) {
+} else if ( mask_par0 ) {
 int b_idx= 8 + 4 + edge * (dir ? 8:1);
 int bn_idx= b_idx - (dir ? 8:1);
 
@@ -663,9 +659,7 @@ static av_always_inline void filter_mb_dir(const 
H264Context *h, H264SliceContex
 if (sl->non_zero_count_cache[b_idx] |
 sl->non_zero_count_cache[bn_idx]) {
 bS[i] = 2;
-}
-else if(!mv_done)
-{
+} else if (!mv_done) {
 bS[i] = check_mv(sl, b_idx, bn_idx, mvy_limit);
 }
 }
@@ -687,7 +681,7 @@ static av_always_inline void filter_mb_dir(const 
H264Context *h, H264SliceContex

Re: [FFmpeg-devel] [PATCH] avcodec/msp2dec: Check available space in RLE decoder

2021-05-10 Thread HouLei


在 2021/4/11 上午5:21, Michael Niedermayer 写道:

On Fri, Apr 09, 2021 at 10:59:44PM -0300, James Almer wrote:

On 4/7/2021 11:59 AM, Michael Niedermayer wrote:

On Wed, Apr 07, 2021 at 12:42:50AM +0200, Andreas Rheinhardt wrote:

Michael Niedermayer:

Fixes: out of array read
Fixes: 
32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
   libavcodec/msp2dec.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c
index cc548d218a..87057fb5e2 100644
--- a/libavcodec/msp2dec.c
+++ b/libavcodec/msp2dec.c
@@ -68,9 +68,10 @@ static int msp2_decode_frame(AVCodecContext *avctx,
   bytestream2_init(&gb, buf, pkt_size);
   x = 0;
-while (bytestream2_get_bytes_left(&gb) && x < width) {
+while (bytestream2_get_bytes_left(&gb) > 0 && x < width) {

This decoder uses the checked bytestream2 API, so != 0 and > 0 should be
equivalent for bytestream2_get_bytes_left(&gb).

I changed it to "> 0" because it felt clearer&more robust
i will drop that as its not needed for the bugfix



   int size = bytestream2_get_byte(&gb);
   if (size) {
+size = FFMIN(size, bytestream2_get_bytes_left(&gb));
   memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, 
FFMIN(size, width - x));

width can include seven bytes of the packet's padding, but it stays
within the padding, so I wonder where the out of array read comes from.
The only fishy thing in this decoder I see is that 2 * avctx->height
might overflow.

size is a value read from the bytestream, theres no guarntee that
the amount that byte calls for is not beyond the end of the bytestream
and its not checked by memcpy

bytestream2_get_buffer() would check it and it can maybe be used instead

If you knew about it, why didn't you use it? This code here basically
duplicates the three lines in bytestream2_get_buffer().

why i didnt use it, well ultimatly probable because i had a bugfix that
i tested and that solved the issue and that was easy to backport. And
noone asked me to include the simplification.
Of course no question when looking at it now, its prettier to replace
these 3 lines by bytestream2_get_buffer().
Thats what review is for, to spot these things. Which it now did.
Feel free to replace it or ill do it tomorrow if i dont forget

thx

[...]

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 17/20] avcodec/twinvqdec: Mark decoder as init-threadsafe

2021-05-10 Thread HouLei

?

在 2021/5/7 下午2:46, Andreas Rheinhardt 写道:

Signed-off-by: Andreas Rheinhardt 
---
  libavcodec/twinvqdec.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/libavcodec/twinvqdec.c b/libavcodec/twinvqdec.c
index b972facfdd..1fbe0bc32e 100644
--- a/libavcodec/twinvqdec.c
+++ b/libavcodec/twinvqdec.c
@@ -426,4 +426,5 @@ const AVCodec ff_twinvq_decoder = {
  .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
  .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
  };



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] Fix memory allocation problem. Related to ticket #9264.

2021-06-08 Thread houlei
From: houlei 

Signed-off-by: houlei 
---
 libavdevice/xv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavdevice/xv.c b/libavdevice/xv.c
index 24ba3179f6..7e15c178b6 100644
--- a/libavdevice/xv.c
+++ b/libavdevice/xv.c
@@ -296,10 +296,11 @@ static int write_picture(AVFormatContext *s, uint8_t 
*input_data[4],
 {
 XVContext *xv = s->priv_data;
 XvImage *img = xv->yuv_image;
-uint8_t *data[3] = {
+uint8_t *data[4] = {
 img->data + img->offsets[0],
 img->data + img->offsets[1],
-img->data + img->offsets[2]
+img->data + img->offsets[2],
+img->data + img->offsets[3]
 };
 
 /* Check messages. Window might get closed. */
-- 
2.20.1



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] Fix memory allocation problem. Related to ticket #9264.

2021-06-08 Thread houlei
From: houlei 

Signed-off-by: houlei 
---
 libavdevice/xv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavdevice/xv.c b/libavdevice/xv.c
index 24ba3179f6..7e15c178b6 100644
--- a/libavdevice/xv.c
+++ b/libavdevice/xv.c
@@ -296,10 +296,11 @@ static int write_picture(AVFormatContext *s, uint8_t 
*input_data[4],
 {
 XVContext *xv = s->priv_data;
 XvImage *img = xv->yuv_image;
-uint8_t *data[3] = {
+uint8_t *data[4] = {
 img->data + img->offsets[0],
 img->data + img->offsets[1],
-img->data + img->offsets[2]
+img->data + img->offsets[2],
+img->data + img->offsets[3]
 };
 
 /* Check messages. Window might get closed. */
-- 
2.20.1



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] Fix memory allocation problem. Related to ticket #9264.

2021-06-08 Thread houlei
From: houlei 

Signed-off-by: houlei 
---
 libavdevice/xv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/xv.c b/libavdevice/xv.c
index 7e15c178b6..8f9a2cb5c0 100644
--- a/libavdevice/xv.c
+++ b/libavdevice/xv.c
@@ -300,7 +300,7 @@ static int write_picture(AVFormatContext *s, uint8_t 
*input_data[4],
 img->data + img->offsets[0],
 img->data + img->offsets[1],
 img->data + img->offsets[2],
-img->data + img->offsets[3]
+0
 };
 
 /* Check messages. Window might get closed. */
-- 
2.20.1



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".