[FFmpeg-cvslog] avcodec/libsvtav1: only set max_buf_sz if both bitrate and rc_buf_sz is set

2022-11-20 Thread Christopher Degawa
ffmpeg | branch: master | Christopher Degawa  | Sun Nov 20 
13:07:36 2022 -0600| [96748ac54f998ba6fe22802799c16b4eba8d4ccc] | committer: 
James Almer

avcodec/libsvtav1: only set max_buf_sz if both bitrate and rc_buf_sz is set

maximum_buffer_size_ms should only be set if both are specified or if
the user sets it through -svtav1-params buf-sz=val

Signed-off-by: Christopher Degawa 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96748ac54f998ba6fe22802799c16b4eba8d4ccc
---

 libavcodec/libsvtav1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 48cd58a0b3..7605baddfe 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -179,7 +179,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 param->min_qp_allowed   = avctx->qmin;
 }
 param->max_bit_rate = avctx->rc_max_rate;
-param->maximum_buffer_size_ms   = avctx->rc_buffer_size * 1000LL / 
avctx->bit_rate;
+if (avctx->bit_rate && avctx->rc_buffer_size)
+param->maximum_buffer_size_ms = avctx->rc_buffer_size * 1000LL / 
avctx->bit_rate;
 
 if (svt_enc->crf > 0) {
 param->qp   = svt_enc->crf;

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

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


[FFmpeg-cvslog] avcodec/vqcdec: Check for end of input in decode_vectors()

2022-11-20 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov 18 21:08:44 2022 +0100| [0871cb9499242cb323c245599f3e7e763806e85b] | 
committer: Michael Niedermayer

avcodec/vqcdec: Check for end of input in decode_vectors()

Fixes: Timeout
Fixes: 
52695/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQC_fuzzer-4882310386548736

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0871cb9499242cb323c245599f3e7e763806e85b
---

 libavcodec/vqcdec.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vqcdec.c b/libavcodec/vqcdec.c
index 5d1a03158c..18cd99462e 100644
--- a/libavcodec/vqcdec.c
+++ b/libavcodec/vqcdec.c
@@ -137,7 +137,7 @@ static void seed_codebooks(VqcContext * s, const int * seed)
 }
 }
 
-static void decode_vectors(VqcContext * s, const uint8_t * buf, int size, int 
width, int height)
+static int decode_vectors(VqcContext * s, const uint8_t * buf, int size, int 
width, int height)
 {
 GetBitContext gb;
 uint8_t * vectors = s->vectors;
@@ -155,9 +155,11 @@ static void decode_vectors(VqcContext * s, const uint8_t * 
buf, int size, int wi
 *dst++ = get_bits(&gb, 8);
 
 while (show_bits(&gb, 2) != 2) {
-
 if (dst >= vectors_end - 1)
-return;
+return 0;
+
+if (get_bits_left(&gb) < 4)
+return AVERROR_INVALIDDATA;
 
 if (!show_bits(&gb, 4)) {
 *dst++ = 0;
@@ -182,6 +184,8 @@ static void decode_vectors(VqcContext * s, const uint8_t * 
buf, int size, int wi
 skip_bits(&gb, 2);
 vectors += 32;
 }
+
+return 0;
 }
 
 static void load_coeffs(VqcContext * s, const uint8_t * v, int width, int 
coeff_width)
@@ -392,7 +396,9 @@ static int vqc_decode_frame(AVCodecContext *avctx, AVFrame 
* rframe,
 avpriv_request_sample(avctx, "gamma=0x%x, contrast=0x%x\n", gamma, 
contrast);
 
 seed_codebooks(s, seed);
-decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, avctx->height);
+ret = decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, 
avctx->height);
+if (ret < 0)
+return ret;
 decode_frame(s, avctx->width, avctx->height);
 
 if ((ret = av_frame_ref(rframe, s->frame)) < 0)

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

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


[FFmpeg-cvslog] avcodec/apac: reset buffer on error

2022-11-20 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed 
Nov 16 21:53:45 2022 +0100| [6634b6ae5f470bea73d46c606a99b79d21d46c37] | 
committer: Michael Niedermayer

avcodec/apac: reset buffer on error

Fixes: repeatly parsing the same data after each 1 byte packet
Fixes: Timeout
Fixes: 
51943/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APAC_fuzzer-5779018251370496

Reviewed-by: Paul B Mahol 
Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6634b6ae5f470bea73d46c606a99b79d21d46c37
---

 libavcodec/apac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/apac.c b/libavcodec/apac.c
index 6a1f61b842..e9f6a0dd88 100644
--- a/libavcodec/apac.c
+++ b/libavcodec/apac.c
@@ -191,6 +191,8 @@ static int apac_decode(AVCodecContext *avctx, AVFrame 
*frame,
 if (c->bit_length < 0 ||
 c->bit_length > 17) {
 c->bit_length = avctx->bits_per_coded_sample;
+s->bitstream_index = 0;
+s->bitstream_size  = 0;
 return AVERROR_INVALIDDATA;
 }
 

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

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


[FFmpeg-cvslog] swscale/input: Use more unsigned intermediates

2022-11-20 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Nov 15 23:10:02 2022 +0100| [ba209e3d5142fd31bb6c3e05c5b183118a278afc] | 
committer: Michael Niedermayer

swscale/input: Use more unsigned intermediates

Same principle as previous commit, with sufficiently huge rgb2yuv table
values this produces wrong results and undefined behavior.
The unsigned produces the same incorrect results. That is probably
ok as these cases with huge values seem not to occur in any real
use case.

Fixes: signed integer overflow
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba209e3d5142fd31bb6c3e05c5b183118a278afc
---

 libswscale/input.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index d7dbedd82f..d5676062a2 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -84,9 +84,9 @@ rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV,
 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
 av_assert1(src1==src2);
 for (i = 0; i < width; i++) {
-int r_b = (input_pixel(&src1[8 * i + 0]) + input_pixel(&src1[8 * i + 
4]) + 1) >> 1;
-int   g = (input_pixel(&src1[8 * i + 1]) + input_pixel(&src1[8 * i + 
5]) + 1) >> 1;
-int b_r = (input_pixel(&src1[8 * i + 2]) + input_pixel(&src1[8 * i + 
6]) + 1) >> 1;
+unsigned r_b = (input_pixel(&src1[8 * i + 0]) + input_pixel(&src1[8 * 
i + 4]) + 1) >> 1;
+unsigned   g = (input_pixel(&src1[8 * i + 1]) + input_pixel(&src1[8 * 
i + 5]) + 1) >> 1;
+unsigned b_r = (input_pixel(&src1[8 * i + 2]) + input_pixel(&src1[8 * 
i + 6]) + 1) >> 1;
 
 dstU[i]= (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;
 dstV[i]= (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;
@@ -158,9 +158,9 @@ static av_always_inline void rgb48ToUV_c_template(uint16_t 
*dstU,
 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
 av_assert1(src1 == src2);
 for (i = 0; i < width; i++) {
-int r_b = input_pixel(&src1[i * 3 + 0]);
-int g   = input_pixel(&src1[i * 3 + 1]);
-int b_r = input_pixel(&src1[i * 3 + 2]);
+unsigned r_b = input_pixel(&src1[i * 3 + 0]);
+unsigned g   = input_pixel(&src1[i * 3 + 1]);
+unsigned b_r = input_pixel(&src1[i * 3 + 2]);
 
 dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> 
RGB2YUV_SHIFT;
 dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> 
RGB2YUV_SHIFT;
@@ -180,12 +180,12 @@ static av_always_inline void 
rgb48ToUV_half_c_template(uint16_t *dstU,
 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
 av_assert1(src1 == src2);
 for (i = 0; i < width; i++) {
-int r_b = (input_pixel(&src1[6 * i + 0]) +
-   input_pixel(&src1[6 * i + 3]) + 1) >> 1;
-int g   = (input_pixel(&src1[6 * i + 1]) +
-   input_pixel(&src1[6 * i + 4]) + 1) >> 1;
-int b_r = (input_pixel(&src1[6 * i + 2]) +
-   input_pixel(&src1[6 * i + 5]) + 1) >> 1;
+unsigned r_b = (input_pixel(&src1[6 * i + 0]) +
+input_pixel(&src1[6 * i + 3]) + 1) >> 1;
+unsigned g   = (input_pixel(&src1[6 * i + 1]) +
+input_pixel(&src1[6 * i + 4]) + 1) >> 1;
+unsigned b_r = (input_pixel(&src1[6 * i + 2]) +
+input_pixel(&src1[6 * i + 5]) + 1) >> 1;
 
 dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> 
RGB2YUV_SHIFT;
 dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> 
RGB2YUV_SHIFT;

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

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


[FFmpeg-cvslog] swscale/input: Use unsigned intermediates in rgb64ToUV_c_template

2022-11-20 Thread Jeremy Dorfman
ffmpeg | branch: master | Jeremy Dorfman  | Tue Nov 15 
14:30:23 2022 -0500| [ce566281f943227480b5441401e90ee8a843730f] | committer: 
Michael Niedermayer

swscale/input: Use unsigned intermediates in rgb64ToUV_c_template

Large rgb2yuv tables and high pixel values cause the intermediate
int32_t of ru*r + gu*g + bu*b to exceed INT_MAX, which is undefined
behavior. This causes libswscale built with LLVM -fsanitize=undefined to
assert. Using unsigned integers instead has defined behavior and
produces identical results, and makes rgb64ToUV_c_template match
rgb64ToY_c_template.

Fixes: signed integer overflow
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce566281f943227480b5441401e90ee8a843730f
---

 libswscale/input.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index 7ff7bfaa01..d7dbedd82f 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -65,9 +65,9 @@ rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV,
 int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
 av_assert1(src1==src2);
 for (i = 0; i < width; i++) {
-int r_b = input_pixel(&src1[i*4+0]);
-int   g = input_pixel(&src1[i*4+1]);
-int b_r = input_pixel(&src1[i*4+2]);
+unsigned int r_b = input_pixel(&src1[i*4+0]);
+unsigned int   g = input_pixel(&src1[i*4+1]);
+unsigned int b_r = input_pixel(&src1[i*4+2]);
 
 dstU[i] = (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;
 dstV[i] = (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> 
RGB2YUV_SHIFT;

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

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


[FFmpeg-cvslog] libavfilter/x86/vf_convolution: fix sobel swap issue on WIN64

2022-11-20 Thread Wang , Bin
ffmpeg | branch: master | Wang, Bin  | Mon Nov 14 23:20:23 
2022 +0800| [459527108ad409c026da93e9f49f4d3006c0f2f9] | committer: Haihao Xiang

libavfilter/x86/vf_convolution: fix sobel swap issue on WIN64

Reviewed by: James Almer 
Signed-off-by: Wang, Bin 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=459527108ad409c026da93e9f49f4d3006c0f2f9
---

 libavfilter/x86/vf_convolution.asm | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavfilter/x86/vf_convolution.asm 
b/libavfilter/x86/vf_convolution.asm
index c912d56752..9ac9ef5d73 100644
--- a/libavfilter/x86/vf_convolution.asm
+++ b/libavfilter/x86/vf_convolution.asm
@@ -189,15 +189,16 @@ cglobal filter_sobel, 4, 15, 7, dst, width, matrix, ptr, 
c0, c1, c2, c3, c4, c5,
 cglobal filter_sobel, 4, 15, 7, dst, width, rdiv, bias, matrix, ptr, c0, c1, 
c2, c3, c4, c5, c6, c7, c8, r, x
 %endif
 %if WIN64
-SWAP xmm0, xmm2
-SWAP xmm1, xmm3
+VBROADCASTSS m0, xmm2
+VBROADCASTSS m1, xmm3
 mov  r2q, matrixmp
 mov  r3q, ptrmp
 DEFINE_ARGS dst, width, matrix, ptr, c0, c1, c2, c3, c4, c5, c6, c7, c8, 
r, x
-%endif
-movsxdifnidn widthq, widthd
+%else
 VBROADCASTSS m0, xmm0
 VBROADCASTSS m1, xmm1
+%endif
+movsxdifnidn widthq, widthd
 pxor  m6, m6
 mov   c0q, [ptrq + 0*gprsize]
 mov   c1q, [ptrq + 1*gprsize]
@@ -281,7 +282,7 @@ cglobal filter_sobel, 4, 15, 7, dst, width, rdiv, bias, 
matrix, ptr, c0, c1, c2,
 fmaddss xmm4, xmm5, xmm5, xmm4
 
 sqrtpsxmm4, xmm4
-fmaddss   xmm4, xmm4, xmm0, xmm1 ;sum = sum * rdiv + bias
+fmaddss   xmm4, xmm4, xm0, xm1 ;sum = sum * rdiv + bias
 cvttps2dq xmm4, xmm4 ; trunc to integer
 packssdw  xmm4, xmm4
 packuswb  xmm4, xmm4

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

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