[FFmpeg-cvslog] avfilter/thumbnail_cuda: add cuda thumbnail filter

2017-09-22 Thread Yogender Gupta
ffmpeg | branch: master | Yogender Gupta  | Mon Sep  4 
18:36:16 2017 +0530| [21e077fcb3d968e3ed6772a0309e31f94cd7a2a5] | committer: 
Timo Rothenpieler

avfilter/thumbnail_cuda: add cuda thumbnail filter

Signed-off-by: Timo Rothenpieler 

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

 Changelog|   2 +
 configure|   1 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_thumbnail_cuda.c  | 444 +++
 libavfilter/vf_thumbnail_cuda.cu |  79 +++
 7 files changed, 529 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index ea48e81efe..38b125be39 100644
--- a/Changelog
+++ b/Changelog
@@ -48,6 +48,8 @@ version :
 - convolve video filter
 - VP9 tile threading support
 - KMS screen grabber
+- CUDA thumbnail filter
+
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/configure b/configure
index 2de20a02a4..ff9a64292c 100755
--- a/configure
+++ b/configure
@@ -2759,6 +2759,7 @@ vaapi_encode_deps="vaapi"
 hwupload_cuda_filter_deps="cuda"
 scale_npp_filter_deps="cuda libnpp"
 scale_cuda_filter_deps="cuda_sdk"
+thumbnail_cuda_filter_deps="cuda_sdk"
 
 nvenc_deps="cuda"
 nvenc_deps_any="dlopen LoadLibrary"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 8aa974e115..98acb51bcb 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -315,6 +315,7 @@ OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o 
framesync.o
 OBJS-$(CONFIG_TELECINE_FILTER)   += vf_telecine.o
 OBJS-$(CONFIG_THRESHOLD_FILTER)  += vf_threshold.o framesync.o
 OBJS-$(CONFIG_THUMBNAIL_FILTER)  += vf_thumbnail.o
+OBJS-$(CONFIG_THUMBNAIL_CUDA_FILTER) += vf_thumbnail_cuda.o 
vf_thumbnail_cuda.ptx.o
 OBJS-$(CONFIG_TILE_FILTER)   += vf_tile.o
 OBJS-$(CONFIG_TINTERLACE_FILTER) += vf_tinterlace.o
 OBJS-$(CONFIG_TLUT2_FILTER)  += vf_lut2.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 63e86721cd..baa84a3e72 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -326,6 +326,7 @@ static void register_all(void)
 REGISTER_FILTER(TELECINE,   telecine,   vf);
 REGISTER_FILTER(THRESHOLD,  threshold,  vf);
 REGISTER_FILTER(THUMBNAIL,  thumbnail,  vf);
+REGISTER_FILTER(THUMBNAIL_CUDA, thumbnail_cuda, vf);
 REGISTER_FILTER(TILE,   tile,   vf);
 REGISTER_FILTER(TINTERLACE, tinterlace, vf);
 REGISTER_FILTER(TLUT2,  tlut2,  vf);
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 5d6aa5fc70..fb382d4e25 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   6
-#define LIBAVFILTER_VERSION_MINOR 105
+#define LIBAVFILTER_VERSION_MINOR 106
 #define LIBAVFILTER_VERSION_MICRO 100
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_thumbnail_cuda.c b/libavfilter/vf_thumbnail_cuda.c
new file mode 100644
index 00..4c08a85121
--- /dev/null
+++ b/libavfilter/vf_thumbnail_cuda.c
@@ -0,0 +1,444 @@
+/*
+* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include 
+
+#include "libavutil/hwcontext.h"
+#include "libavutil/hwcontext_cuda_internal.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "internal.h"
+
+#define HIST_SIZE (3*256)
+#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
+#define BLOCKX 32
+#define BLOCKY 16
+
+static const enum AVPixelFormat supported_formats[] = {
+AV_PIX_FMT_NV12,
+AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_YUV444P,
+AV_PIX_FMT_P010,
+  

[FFmpeg-cvslog] avcodec/mips: Remove generic func use in hevc non-uni copy mc msa functions

2017-09-22 Thread Kaustubh Raste
ffmpeg | branch: master | Kaustubh Raste  | Thu Sep 
21 13:03:28 2017 +0530| [f160a63badfc6103ce9fdbfeff7c82111ba81ab8] | committer: 
Michael Niedermayer

avcodec/mips: Remove generic func use in hevc non-uni copy mc msa functions

Signed-off-by: Kaustubh Raste 
Reviewed-by: Manojkumar Bhosale 
Signed-off-by: Michael Niedermayer 

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

 libavcodec/mips/hevcdsp_msa.c | 168 --
 1 file changed, 160 insertions(+), 8 deletions(-)

diff --git a/libavcodec/mips/hevcdsp_msa.c b/libavcodec/mips/hevcdsp_msa.c
index f2bc748e37..1a854b204f 100644
--- a/libavcodec/mips/hevcdsp_msa.c
+++ b/libavcodec/mips/hevcdsp_msa.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Manojkumar Bhosale (manojkumar.bhos...@imgtec.com)
+ * Copyright (c) 2015 - 2017 Manojkumar Bhosale (manojkumar.bhos...@imgtec.com)
  *
  * This file is part of FFmpeg.
  *
@@ -302,8 +302,34 @@ static void hevc_copy_16w_msa(uint8_t *src, int32_t 
src_stride,
 ST_SH4(in0_r, in1_r, in2_r, in3_r, dst, dst_stride);
 ST_SH4(in0_l, in1_l, in2_l, in3_l, (dst + 8), dst_stride);
 } else if (0 == (height % 8)) {
-hevc_copy_16multx8mult_msa(src, src_stride, dst, dst_stride,
-   height, 16);
+uint32_t loop_cnt;
+v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
+v8i16 in0_r, in1_r, in2_r, in3_r, in0_l, in1_l, in2_l, in3_l;
+
+for (loop_cnt = (height >> 3); loop_cnt--;) {
+LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6,
+   src7);
+src += (8 * src_stride);
+ILVR_B4_SH(zero, src0, zero, src1, zero, src2, zero, src3, in0_r,
+   in1_r, in2_r, in3_r);
+ILVL_B4_SH(zero, src0, zero, src1, zero, src2, zero, src3, in0_l,
+   in1_l, in2_l, in3_l);
+SLLI_4V(in0_r, in1_r, in2_r, in3_r, 6);
+SLLI_4V(in0_l, in1_l, in2_l, in3_l, 6);
+ST_SH4(in0_r, in1_r, in2_r, in3_r, dst, dst_stride);
+ST_SH4(in0_l, in1_l, in2_l, in3_l, (dst + 8), dst_stride);
+dst += (4 * dst_stride);
+
+ILVR_B4_SH(zero, src4, zero, src5, zero, src6, zero, src7, in0_r,
+   in1_r, in2_r, in3_r);
+ILVL_B4_SH(zero, src4, zero, src5, zero, src6, zero, src7, in0_l,
+   in1_l, in2_l, in3_l);
+SLLI_4V(in0_r, in1_r, in2_r, in3_r, 6);
+SLLI_4V(in0_l, in1_l, in2_l, in3_l, 6);
+ST_SH4(in0_r, in1_r, in2_r, in3_r, dst, dst_stride);
+ST_SH4(in0_l, in1_l, in2_l, in3_l, (dst + 8), dst_stride);
+dst += (4 * dst_stride);
+}
 }
 }
 
@@ -311,29 +337,155 @@ static void hevc_copy_24w_msa(uint8_t *src, int32_t 
src_stride,
   int16_t *dst, int32_t dst_stride,
   int32_t height)
 {
-hevc_copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16);
-hevc_copy_8w_msa(src + 16, src_stride, dst + 16, dst_stride, height);
+uint32_t loop_cnt;
+v16i8 zero = { 0 };
+v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
+v8i16 in0_r, in1_r, in2_r, in3_r, in0_l, in1_l, in2_l, in3_l;
+
+for (loop_cnt = (height >> 2); loop_cnt--;) {
+LD_SB4(src, src_stride, src0, src1, src2, src3);
+LD_SB4((src + 16), src_stride, src4, src5, src6, src7);
+src += (4 * src_stride);
+ILVR_B4_SH(zero, src0, zero, src1, zero, src2, zero, src3, in0_r, 
in1_r,
+   in2_r, in3_r);
+ILVL_B4_SH(zero, src0, zero, src1, zero, src2, zero, src3, in0_l, 
in1_l,
+   in2_l, in3_l);
+SLLI_4V(in0_r, in1_r, in2_r, in3_r, 6);
+SLLI_4V(in0_l, in1_l, in2_l, in3_l, 6);
+ST_SH4(in0_r, in1_r, in2_r, in3_r, dst, dst_stride);
+ST_SH4(in0_l, in1_l, in2_l, in3_l, (dst + 8), dst_stride);
+ILVR_B4_SH(zero, src4, zero, src5, zero, src6, zero, src7, in0_r, 
in1_r,
+   in2_r, in3_r);
+SLLI_4V(in0_r, in1_r, in2_r, in3_r, 6);
+ST_SH4(in0_r, in1_r, in2_r, in3_r, (dst + 16), dst_stride);
+dst += (4 * dst_stride);
+}
 }
 
 static void hevc_copy_32w_msa(uint8_t *src, int32_t src_stride,
   int16_t *dst, int32_t dst_stride,
   int32_t height)
 {
-hevc_copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 32);
+uint32_t loop_cnt;
+v16i8 zero = { 0 };
+v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
+v8i16 in0_r, in1_r, in2_r, in3_r, in0_l, in1_l, in2_l, in3_l;
+
+for (loop_cnt = (height >> 2); loop_cnt--;) {
+LD_SB4(src, src_stride, src0, src2, src4, src6);
+LD_SB4((src + 16), src_stride, src1, src3, src5, src7);
+src += (4 * src_stride);
+
+ILVR_B4_SH(zero, src0, zero, src1, zero, src2, zero, src3, in0

[FFmpeg-cvslog] avcodec/svq3: Fix overflow in svq3_add_idct_c()

2017-09-22 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Sep 18 17:03:55 2017 +0200| [2c933c51687db958d8045d25ed87848342e869f6] | 
committer: Michael Niedermayer

avcodec/svq3: Fix overflow in svq3_add_idct_c()

Fixes: runtime error: signed integer overflow: 2147392585 + 524288 cannot be 
represented in type 'int'
Fixes: 3348/clusterfuzz-testcase-minimized-4809500517203968

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=2c933c51687db958d8045d25ed87848342e869f6
---

 libavcodec/svq3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index a766fa49ad..5cb5bd45b7 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -285,7 +285,7 @@ static void svq3_add_idct_c(uint8_t *dst, int16_t *block,
 const unsigned z1 = 13 * (block[i + 4 * 0] -  block[i + 4 * 2]);
 const unsigned z2 =  7 *  block[i + 4 * 1] - 17 * block[i + 4 * 3];
 const unsigned z3 = 17 *  block[i + 4 * 1] +  7 * block[i + 4 * 3];
-const int rr = (dc + 0x8);
+const int rr = (dc + 0x8u);
 
 dst[i + stride * 0] = av_clip_uint8(dst[i + stride * 0] + ((int)((z0 + 
z3) * qmul + rr) >> 20));
 dst[i + stride * 1] = av_clip_uint8(dst[i + stride * 1] + ((int)((z1 + 
z2) * qmul + rr) >> 20));

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


[FFmpeg-cvslog] avcodec/mips: preload data in hevc sao edge 90 degree filter msa functions

2017-09-22 Thread Kaustubh Raste
ffmpeg | branch: master | Kaustubh Raste  | Thu Sep 
21 12:35:40 2017 +0530| [2b156269974995c42456586f7218ce22a525a1d9] | committer: 
Michael Niedermayer

avcodec/mips: preload data in hevc sao edge 90 degree filter msa functions

Signed-off-by: Kaustubh Raste 
Reviewed-by: Manojkumar Bhosale 
Signed-off-by: Michael Niedermayer 

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

 libavcodec/mips/hevc_lpf_sao_msa.c | 181 +
 1 file changed, 122 insertions(+), 59 deletions(-)

diff --git a/libavcodec/mips/hevc_lpf_sao_msa.c 
b/libavcodec/mips/hevc_lpf_sao_msa.c
index 3472d32322..39c647ed79 100644
--- a/libavcodec/mips/hevc_lpf_sao_msa.c
+++ b/libavcodec/mips/hevc_lpf_sao_msa.c
@@ -1568,23 +1568,25 @@ static void 
hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst,
  int16_t *sao_offset_val,
  int32_t height)
 {
-int32_t h_cnt;
 uint32_t dst_val0, dst_val1;
-v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 };
+v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 v16u8 const1 = (v16u8) __msa_ldi_b(1);
 v16i8 dst0;
-v16i8 zero = { 0 };
+v16i8 sao_offset = LD_SB(sao_offset_val);
 v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11;
 v16u8 src_minus10, src_minus11, src10, src11;
 v16i8 src_zero0, src_zero1;
-v8i16 sao_offset, src00, src01, offset_mask0, offset_mask1;
+v16i8 offset;
+v8i16 offset_mask0, offset_mask1;
 
-sao_offset = LD_SH(sao_offset_val);
+sao_offset = __msa_pckev_b(sao_offset, sao_offset);
 
+/* load in advance */
 LD_UB2(src - src_stride, src_stride, src_minus10, src_minus11);
+LD_UB2(src + src_stride, src_stride, src10, src11);
 
-for (h_cnt = (height >> 1); h_cnt--;) {
-LD_UB2(src + src_stride, src_stride, src10, src11);
+for (height -= 2; height; height -= 2) {
+src += (src_stride << 1);
 
 src_minus10 = (v16u8) __msa_ilvr_b((v16i8) src10, (v16i8) src_minus10);
 src_zero0 = __msa_ilvr_b((v16i8) src_minus11, (v16i8) src_minus11);
@@ -1604,19 +1606,22 @@ static void 
hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst,
 offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 
2);
 offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 
2);
 
-VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0,
-   offset_mask0, offset_mask0, offset_mask0);
-VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1,
-   offset_mask1, offset_mask1, offset_mask1);
-ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01);
-ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0,
- offset_mask1);
-CLIP_SH2_0_255(offset_mask0, offset_mask1);
-dst0 = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0);
+offset = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0);
+dst0 = __msa_pckev_b((v16i8) src_zero1, (v16i8) src_zero0);
+
+VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset, offset,
+   offset, offset);
+
+dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128);
+dst0 = __msa_adds_s_b(dst0, offset);
+dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128);
 
 src_minus10 = src10;
 src_minus11 = src11;
 
+/* load in advance */
+LD_UB2(src + src_stride, src_stride, src10, src11);
+
 dst_val0 = __msa_copy_u_w((v4i32) dst0, 0);
 dst_val1 = __msa_copy_u_w((v4i32) dst0, 2);
 SW(dst_val0, dst);
@@ -1624,8 +1629,41 @@ static void 
hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst,
 SW(dst_val1, dst);
 
 dst += dst_stride;
-src += (src_stride << 1);
 }
+
+src_minus10 = (v16u8) __msa_ilvr_b((v16i8) src10, (v16i8) src_minus10);
+src_zero0 = __msa_ilvr_b((v16i8) src_minus11, (v16i8) src_minus11);
+src_minus11 = (v16u8) __msa_ilvr_b((v16i8) src11, (v16i8) src_minus11);
+src_zero1 = __msa_ilvr_b((v16i8) src10, (v16i8) src10);
+
+cmp_minus10 = ((v16u8) src_zero0 == src_minus10);
+diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10);
+cmp_minus10 = (src_minus10 < (v16u8) src_zero0);
+diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10);
+
+cmp_minus11 = ((v16u8) src_zero1 == src_minus11);
+diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11);
+cmp_minus11 = (src_minus11 < (v16u8) src_zero1);
+diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11);
+
+offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2);
+offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2);
+
+offset = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0);
+dst0 = __msa_pckev_b((v16i8) src_zero1

[FFmpeg-cvslog] avcodec/ffv1dec: Fix integer overflow in read_quant_table()

2017-09-22 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Sep 18 17:26:09 2017 +0200| [d00fc952b6c261dd8eb0f7552b9ccf985dbc2b20] | 
committer: Michael Niedermayer

avcodec/ffv1dec: Fix integer overflow in read_quant_table()

Fixes: runtime error: signed integer overflow: 2147483647 + 1 cannot be 
represented in type 'int'
Fixes: 3361/clusterfuzz-testcase-minimized-5065842955911168

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=d00fc952b6c261dd8eb0f7552b9ccf985dbc2b20
---

 libavcodec/ffv1dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index b13ecd3eab..d2bfee784f 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -372,7 +372,7 @@ static int read_quant_table(RangeCoder *c, int16_t 
*quant_table, int scale)
 memset(state, 128, sizeof(state));
 
 for (v = 0; i < 128; v++) {
-unsigned len = get_symbol(c, state, 0) + 1;
+unsigned len = get_symbol(c, state, 0) + 1U;
 
 if (len > 128 - i || !len)
 return AVERROR_INVALIDDATA;

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


[FFmpeg-cvslog] avcodec/dirac_dwt: Fix integer overflow in COMPOSE_FIDELITYi*()

2017-09-22 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Sep 18 02:53:25 2017 +0200| [67da2685e03805230207daab83ab43a390fbb887] | 
committer: Michael Niedermayer

avcodec/dirac_dwt: Fix integer overflow in COMPOSE_FIDELITYi*()

Fixes: runtime error: signed integer overflow: 161 * 13872281 cannot be 
represented in type 'int'

Fixes: 3295/clusterfuzz-testcase-minimized-4738998142500864

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=67da2685e03805230207daab83ab43a390fbb887
---

 libavcodec/dirac_dwt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dirac_dwt.h b/libavcodec/dirac_dwt.h
index adf5178714..755d5e5d2d 100644
--- a/libavcodec/dirac_dwt.h
+++ b/libavcodec/dirac_dwt.h
@@ -111,10 +111,10 @@ void ff_spatial_idwt_slice2(DWTContext *d, int y);
 (b0 + b1)
 
 #define COMPOSE_FIDELITYiL0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
-(b4 - ((-8*(b0+b8) + 21*(b1+b7) - 46*(b2+b6) + 161*(b3+b5) + 128) >> 8))
+(b4 - ((int)(-8*(b0+(unsigned)b8) + 21*(b1+(unsigned)b7) - 
46*(b2+(unsigned)b6) + 161*(b3+(unsigned)b5) + 128) >> 8))
 
 #define COMPOSE_FIDELITYiH0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
-(b4 + ((-2*(b0+b8) + 10*(b1+b7) - 25*(b2+b6) + 81*(b3+b5) + 128) >> 8))
+(b4 + ((int)(-2*(b0+(unsigned)b8) + 10*(b1+(unsigned)b7) - 
25*(b2+(unsigned)b6) +  81*(b3+(unsigned)b5) + 128) >> 8))
 
 #define COMPOSE_DAUB97iL1(b0, b1, b2)\
 (b1 - ((int)(1817*(b0 + (unsigned)b2) + 2048) >> 12))

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


[FFmpeg-cvslog] avformat/gif: use av_packet_alloc()

2017-09-22 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Sep 23 02:18:47 
2017 -0300| [afe674734bbe71ef6c32f96a98f5f84d007eea1c] | committer: James Almer

avformat/gif: use av_packet_alloc()

Signed-off-by: James Almer 

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

 libavformat/gif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/gif.c b/libavformat/gif.c
index 91cd40db5c..d6113dbc85 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -186,7 +186,7 @@ static int gif_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 AVStream *video_st = s->streams[0];
 
 if (!gif->prev_pkt) {
-gif->prev_pkt = av_malloc(sizeof(*gif->prev_pkt));
+gif->prev_pkt = av_packet_alloc();
 if (!gif->prev_pkt)
 return AVERROR(ENOMEM);
 

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


[FFmpeg-cvslog] avformat/apngenc: use av_packet_alloc()

2017-09-22 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Sep 23 02:15:16 
2017 -0300| [bb4b7624d9dd17dcda44703d5d69292a85fe2d4d] | committer: James Almer

avformat/apngenc: use av_packet_alloc()

Signed-off-by: James Almer 

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

 libavformat/apngenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c
index 378a9b3b36..d4191c02cc 100644
--- a/libavformat/apngenc.c
+++ b/libavformat/apngenc.c
@@ -228,7 +228,7 @@ static int apng_write_packet(AVFormatContext 
*format_context, AVPacket *packet)
 int ret;
 
 if (!apng->prev_packet) {
-apng->prev_packet = av_malloc(sizeof(*apng->prev_packet));
+apng->prev_packet = av_packet_alloc();
 if (!apng->prev_packet)
 return AVERROR(ENOMEM);
 

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


[FFmpeg-cvslog] libavcodec: v4l2: add support for v4l2 mem2mem codecs

2017-09-22 Thread Jorge Ramirez-Ortiz
ffmpeg | branch: master | Jorge Ramirez-Ortiz  
| Wed Sep 20 18:55:40 2017 -0700| [1ef7752d64cbe9af2f27cc65aba3a2ca3831c128] | 
committer: wm4

libavcodec: v4l2: add support for v4l2 mem2mem codecs

This patchset enhances Alexis Ballier's original patch and validates
it using Qualcomm's Venus hardware (driver recently landed upstream
[1]).

This has been tested on Qualcomm's DragonBoard 410c and 820c
Configure/make scripts have been validated on Ubuntu 10.04 and
16.04.

Tested decoders:
   - h264
   - h263
   - mpeg4
   - vp8
   - vp9
   - hevc

Tested encoders:
   - h264
   - h263
   - mpeg4

Tested transcoding (concurrent encoding/decoding)

Some of the changes introduced:
- v4l2: code cleanup and abstractions added
- v4l2: follow the new encode/decode api.
- v4l2: fix display size for NV12 output pool.
- v4l2: handle EOS (EPIPE and draining)
- v4l2: vp8 and mpeg4 decoding and encoding.
- v4l2: hevc and vp9 support.
- v4l2: generate EOF on dequeue errors.
- v4l2: h264_mp4toannexb filtering.
- v4l2: fixed make install and fate issues.
- v4l2: codecs enabled/disabled depending on pixfmt defined
- v4l2: pass timebase/framerate to the context
- v4l2: runtime decoder reconfiguration.
- v4l2: add more frame information
- v4l2: free hardware resources on last reference being released
- v4l2: encoding: disable b-frames for upstreaming (patch required)

[1] https://lwn.net/Articles/697956/

System Level view:
v42l_m2m_enc/dec --> v4l2_m2m --> v4l2_context --> v4l2_buffers

Reviewed-by: Jorge Ramirez 
Reviewed-by: Alexis Ballier 
Tested-by: Jorge Ramirez 

Signed-off-by: wm4 

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

 Changelog |   1 +
 configure |  28 ++
 libavcodec/Makefile   |  15 ++
 libavcodec/allcodecs.c|   9 +
 libavcodec/v4l2_buffers.c | 453 +++
 libavcodec/v4l2_buffers.h | 121 +
 libavcodec/v4l2_context.c | 667 ++
 libavcodec/v4l2_context.h | 181 +
 libavcodec/v4l2_fmt.c | 182 +
 libavcodec/v4l2_fmt.h |  34 +++
 libavcodec/v4l2_m2m.c | 383 ++
 libavcodec/v4l2_m2m.h | 103 +++
 libavcodec/v4l2_m2m_dec.c | 228 
 libavcodec/v4l2_m2m_enc.c | 352 
 14 files changed, 2757 insertions(+)

diff --git a/Changelog b/Changelog
index 38b125be39..678dcdadc7 100644
--- a/Changelog
+++ b/Changelog
@@ -49,6 +49,7 @@ version :
 - VP9 tile threading support
 - KMS screen grabber
 - CUDA thumbnail filter
+- V4L2 mem2mem HW assisted codecs
 
 
 version 3.3:
diff --git a/configure b/configure
index ff9a64292c..16fc2bd074 100755
--- a/configure
+++ b/configure
@@ -185,6 +185,7 @@ Individual component options:
   --enable-filter=NAME enable filter NAME
   --disable-filter=NAMEdisable filter NAME
   --disable-filtersdisable all filters
+  --disable-v4l2_m2m   disable V4L2 mem2mem code [autodetect]
 
 External library support:
 
@@ -1628,6 +1629,7 @@ HWACCEL_AUTODETECT_LIBRARY_LIST="
 vda
 vdpau
 videotoolbox
+v4l2_m2m
 xvmc
 "
 
@@ -2755,6 +2757,7 @@ omx_rpi_select="omx"
 qsvdec_select="qsv"
 qsvenc_select="qsv"
 vaapi_encode_deps="vaapi"
+v4l2_m2m_deps_any="linux_videodev2_h"
 
 hwupload_cuda_filter_deps="cuda"
 scale_npp_filter_deps="cuda libnpp"
@@ -2765,6 +2768,8 @@ nvenc_deps="cuda"
 nvenc_deps_any="dlopen LoadLibrary"
 nvenc_encoder_deps="nvenc"
 
+h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m"
+h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m"
 h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
 h264_cuvid_decoder_deps="cuda cuvid"
 h264_cuvid_decoder_select="h264_mp4toannexb_bsf"
@@ -2783,6 +2788,8 @@ h264_vda_decoder_deps="vda"
 h264_vda_decoder_select="h264_decoder"
 h264_vdpau_decoder_deps="vdpau"
 h264_vdpau_decoder_select="h264_decoder"
+h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
+h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m"
 hevc_cuvid_decoder_deps="cuda cuvid"
 hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf"
 hevc_mediacodec_decoder_deps="mediacodec"
@@ -2794,12 +2801,15 @@ hevc_qsv_encoder_deps="libmfx"
 hevc_qsv_encoder_select="hevcparse qsvenc"
 hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
 hevc_vaapi_encoder_select="vaapi_encode golomb"
+hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
+hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
 mjpeg_cuvid_decoder_deps="cuda cuvid"
 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
 mjpeg_vaapi_encoder_select="vaapi_encode jpegtables"
 mpeg1_cuvid_decoder_deps="cuda cuvid"
 mpeg1_vdpau_decoder_deps="vdpau"
 mpeg1_vdpau_d