[FFmpeg-cvslog] avcodec/lscr: stop returning error if size of packet is 2 bytes

2020-09-16 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Sep 16 15:20:21 
2020 +0200| [161495a3d026a73bc802c66a94e867ef457320d4] | committer: Paul B Mahol

avcodec/lscr: stop returning error if size of packet is 2 bytes

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

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

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 647e7f0a74..395b86bbe7 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1597,6 +1597,8 @@ static int decode_frame_lscr(AVCodecContext *avctx,
 
 if (avpkt->size < 2)
 return AVERROR_INVALIDDATA;
+if (avpkt->size == 2)
+return 0;
 
 bytestream2_init(gb, avpkt->data, avpkt->size);
 

___
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] [ffmpeg-web] branch master updated. 4717783 web/download: add gyan.dev for Windows builds

2020-09-16 Thread ffmpeg-git
The branch, master has been updated
   via  4717783e0a0454099366a892c573cfd091bfea55 (commit)
   via  fcf9b3b969bd01709a439676195b946683ce1676 (commit)
  from  688e95788b23bc8d4c1f072939692cf93ed4bc78 (commit)


- Log -
commit 4717783e0a0454099366a892c573cfd091bfea55
Author: Gyan Doshi 
AuthorDate: Wed Sep 16 14:53:53 2020 +0530
Commit: Lou Logan 
CommitDate: Wed Sep 16 13:06:18 2020 -0800

web/download: add gyan.dev for Windows builds

diff --git a/src/download b/src/download
index 34fa093..cc427a5 100644
--- a/src/download
+++ b/src/download
@@ -79,6 +79,9 @@
 Windows EXE Files
 
 
+  https://www.gyan.dev/ffmpeg/builds/";>
+Windows builds from gyan.dev
+  
  
 


commit fcf9b3b969bd01709a439676195b946683ce1676
Author: Gyan Doshi 
AuthorDate: Wed Sep 16 14:53:52 2020 +0530
Commit: Lou Logan 
CommitDate: Wed Sep 16 13:06:13 2020 -0800

web/download: remove Zeranoe links

ffmpeg.zeranoe.com will close on Sep 18, 2020

Last published builds are from Aug 31 2020.

diff --git a/src/download b/src/download
index 02e2fe7..34fa093 100644
--- a/src/download
+++ b/src/download
@@ -79,9 +79,6 @@
 Windows EXE Files
 
 
-  https://ffmpeg.zeranoe.com/builds/";>
-Windows builds by Zeranoe
-  
  
 

@@ -93,9 +90,6 @@
   https://evermeet.cx/ffmpeg/";>
 Static builds for macOS 64-bit
   
-  https://ffmpeg.zeranoe.com/builds/";>
-Static and shared builds for macOS 64-bit
-  
  
 


---

Summary of changes:
 src/download | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)


hooks/post-receive
-- 

___
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/wmalosslessdec: Check remaining space before padding and channel residue

2020-09-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sun 
Sep 13 21:12:17 2020 +0200| [c467adf3bf9bb4b7fd28956ec698d884e63f145d] | 
committer: Michael Niedermayer

avcodec/wmalosslessdec: Check remaining space before padding and channel residue

Fixes: Timeout (1101sec -> 0.4sec)
Fixes: 
24491/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-5725337036783616

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

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

diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 725e811070..b8d0f6220d 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -932,6 +932,8 @@ static int decode_subframe(WmallDecodeCtx *s)
 s->do_lpc = 0;
 }
 
+if (get_bits_left(&s->gb) < 1)
+return AVERROR_INVALIDDATA;
 
 if (get_bits1(&s->gb))
 padding_zeroes = get_bits(&s->gb, 5);

___
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/mv30: Check remaining mask in decode_inter()

2020-09-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Sep 14 00:03:36 2020 +0200| [142ae27b1d4d23b72396950ebaaeaca10ba600d9] | 
committer: Michael Niedermayer

avcodec/mv30: Check remaining mask in decode_inter()

Fixes: timeout (too long -> 4sec)
Fixes: 
25129/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5642089713631232

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=142ae27b1d4d23b72396950ebaaeaca10ba600d9
---

 libavcodec/mv30.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index c83ba7ffbd..0dcfef23e0 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -531,8 +531,13 @@ static int decode_inter(AVCodecContext *avctx, 
GetBitContext *gb,
 for (int x = 0; x < avctx->width; x += 16) {
 if (cnt >= 4)
 cnt = 0;
-if (cnt == 0)
+if (cnt == 0) {
+if (get_bits_left(&mask) < 8) {
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
 flags = get_bits(&mask, 8);
+}
 
 dst[0] = frame->data[0] + linesize[0] * y + x;
 dst[1] = frame->data[0] + linesize[0] * y + x + 8;

___
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/ffv1: Simplify cleanup after allocation failure

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Sep 14 05:39:26 2020 +0200| [fe63b3eedcb2b92b3e086676ebed470d9f0ed64d] | 
committer: Andreas Rheinhardt

avcodec/ffv1: Simplify cleanup after allocation failure

Now that ff_ffv1_close() is called upon failure for both the FFV1 encoder
and decoder, the code contained therein can be used to free the partially
allocated slice contexts if allocating the slice contexts failed. One just
has to set the correct number of slice contexts on error. This allows to
remove the code for freeing partially allocated slice contexts in
ff_ffv1_init_slice_contexts().

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/ffv1.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 5b52849400..1c580c3b49 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -119,7 +119,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 
 av_assert0(max_slice_count > 0);
 
-for (i = 0; i < max_slice_count; i++) {
+for (i = 0; i < max_slice_count;) {
 int sx  = i % f->num_h_slices;
 int sy  = i / f->num_h_slices;
 int sxs = f->avctx->width  *  sx  / f->num_h_slices;
@@ -131,7 +131,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 if (!fs)
 goto memfail;
 
-f->slice_context[i] = fs;
+f->slice_context[i++] = fs;
 memcpy(fs, f, sizeof(*fs));
 memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2));
 
@@ -144,22 +144,14 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
   sizeof(*fs->sample_buffer));
 fs->sample_buffer32 = av_malloc_array((fs->width + 6), 3 * MAX_PLANES *
 sizeof(*fs->sample_buffer32));
-if (!fs->sample_buffer || !fs->sample_buffer32) {
-av_freep(&fs->sample_buffer);
-av_freep(&fs->sample_buffer32);
-av_freep(&f->slice_context[i]);
+if (!fs->sample_buffer || !fs->sample_buffer32)
 goto memfail;
-}
 }
 f->max_slice_count = max_slice_count;
 return 0;
 
 memfail:
-while(--i >= 0) {
-av_freep(&f->slice_context[i]->sample_buffer);
-av_freep(&f->slice_context[i]->sample_buffer32);
-av_freep(&f->slice_context[i]);
-}
+f->max_slice_count = i;
 return AVERROR(ENOMEM);
 }
 

___
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/pcm-dvd: Avoid allocation of buffer

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Sep 12 23:47:28 2020 +0200| [7a84ee84ec2b1413f14d81af4b9266de2e83ca2c] | 
committer: Andreas Rheinhardt

avcodec/pcm-dvd: Avoid allocation of buffer

In this case, it also allows to remove the decoder's close function.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/pcm-dvd.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index 0a751a8191..725c2f5b29 100644
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -34,8 +34,9 @@ typedef struct PCMDVDContext {
 int last_block_size; // Size of the last block of samples in bytes
 int samples_per_block;   // Number of samples per channel per block
 int groups_per_block;// Number of 20/24-bit sample groups per block
-uint8_t *extra_samples;  // Pointer to leftover samples from a frame
 int extra_sample_count;  // Number of leftover samples in the buffer
+uint8_t extra_samples[8 * 3 * 4];  // Space for leftover samples from a 
frame
+   // (8 channels, 3B/sample, 4 
samples/block)
 } PCMDVDContext;
 
 static av_cold int pcm_dvd_decode_init(AVCodecContext *avctx)
@@ -44,18 +45,6 @@ static av_cold int pcm_dvd_decode_init(AVCodecContext *avctx)
 
 /* Invalid header to force parsing of the first header */
 s->last_header = -1;
-/* reserve space for 8 channels, 3 bytes/sample, 4 samples/block */
-if (!(s->extra_samples = av_malloc(8 * 3 * 4)))
-return AVERROR(ENOMEM);
-
-return 0;
-}
-
-static av_cold int pcm_dvd_decode_uninit(AVCodecContext *avctx)
-{
-PCMDVDContext *s = avctx->priv_data;
-
-av_freep(&s->extra_samples);
 
 return 0;
 }
@@ -310,7 +299,6 @@ AVCodec ff_pcm_dvd_decoder = {
 .priv_data_size = sizeof(PCMDVDContext),
 .init   = pcm_dvd_decode_init,
 .decode = pcm_dvd_decode_frame,
-.close  = pcm_dvd_decode_uninit,
 .capabilities   = AV_CODEC_CAP_DR1,
 .sample_fmts= (const enum AVSampleFormat[]) {
 AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE

___
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/ffv1enc: Fix memleaks on init failure

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Sep 14 05:30:15 2020 +0200| [f9215d0bb20242299f3654fd4646511665b20c4c] | 
committer: Andreas Rheinhardt

avcodec/ffv1enc: Fix memleaks on init failure

The FFV1 encoder has so far not cleaned up after itself in this case;
but it can be done easily by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/ffv1enc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 97dc15eac9..611b250e96 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1354,4 +1354,5 @@ AVCodec ff_ffv1_encoder = {
 .defaults   = ffv1_defaults,
 #endif
 .priv_class = &ffv1_class,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };

___
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/svq3: Fix memleaks upon allocation error

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 02:45:38 2020 +0200| [64a64d47c0afd2a0517375345fe7df61abfc89c0] | 
committer: Andreas Rheinhardt

avcodec/svq3: Fix memleaks upon allocation error

Commit b2361cfb94738298a6c4037cc348fe5015efb841e made all of the
error paths in svq3_decode_init() call svq3_decode_end(); yet several
new error paths that were added later (in merges from Libav) returned
directly without cleaning up properly. This commit fixes the resulting
potential memleaks by setting the FF_CODEC_CAP_INIT_CLEANUP flag. This
also allows to simplify freeing by returning directly.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/svq3.c | 39 +--
 1 file changed, 13 insertions(+), 26 deletions(-)

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 8a67836827..41a9bf2daa 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -222,8 +222,6 @@ static const uint32_t svq3_dequant_coeff[32] = {
 61694, 68745, 77615, 89113, 100253, 109366, 126635, 141533
 };
 
-static int svq3_decode_end(AVCodecContext *avctx);
-
 static void svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int 
qp)
 {
 const unsigned qmul = svq3_dequant_coeff[qp];
@@ -1185,10 +1183,8 @@ static av_cold int svq3_decode_init(AVCodecContext 
*avctx)
 int w,h;
 
 size = AV_RB32(&extradata[4]);
-if (size > extradata_end - extradata - 8) {
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
+if (size > extradata_end - extradata - 8)
+return AVERROR_INVALIDDATA;
 init_get_bits(&gb, extradata + 8, size * 8);
 
 /* 'frame size code' and optional 'width, height' */
@@ -1229,7 +1225,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
 }
 ret = ff_set_dimensions(avctx, w, h);
 if (ret < 0)
-goto fail;
+return ret;
 
 s->halfpel_flag  = get_bits1(&gb);
 s->thirdpel_flag = get_bits1(&gb);
@@ -1248,10 +1244,8 @@ static av_cold int svq3_decode_init(AVCodecContext 
*avctx)
 av_log(avctx, AV_LOG_DEBUG, "Unknown fields %d %d %d %d %d\n",
unk0, unk1, unk2, unk3, unk4);
 
-if (skip_1stop_8data_bits(&gb) < 0) {
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
+if (skip_1stop_8data_bits(&gb) < 0)
+return AVERROR_INVALIDDATA;
 
 s->has_watermark  = get_bits1(&gb);
 avctx->has_b_frames = !s->low_delay;
@@ -1269,16 +1263,13 @@ static av_cold int svq3_decode_init(AVCodecContext 
*avctx)
 uint8_t *buf;
 
 if (watermark_height <= 0 ||
-(uint64_t)watermark_width * 4 > UINT_MAX / watermark_height) {
-ret = -1;
-goto fail;
-}
+(uint64_t)watermark_width * 4 > UINT_MAX / watermark_height)
+return AVERROR_INVALIDDATA;
 
 buf = av_malloc(buf_len);
-if (!buf) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!buf)
+return AVERROR(ENOMEM);
+
 av_log(avctx, AV_LOG_DEBUG, "watermark size: %ux%u\n",
watermark_width, watermark_height);
 av_log(avctx, AV_LOG_DEBUG,
@@ -1289,8 +1280,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
 av_log(avctx, AV_LOG_ERROR,
"could not uncompress watermark logo\n");
 av_free(buf);
-ret = -1;
-goto fail;
+return -1;
 }
 s->watermark_key = 
av_bswap16(av_crc(av_crc_get_table(AV_CRC_16_CCITT), 0, buf, buf_len));
 
@@ -1301,8 +1291,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
 #else
 av_log(avctx, AV_LOG_ERROR,
"this svq3 file contains watermark which need zlib support 
compiled in\n");
-ret = -1;
-goto fail;
+return AVERROR(ENOSYS);
 #endif
 }
 }
@@ -1334,9 +1323,6 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
 init_dequant4_coeff_table(s);
 
 return 0;
-fail:
-svq3_decode_end(avctx);
-return ret;
 }
 
 static void free_picture(AVCodecContext *avctx, SVQ3Frame *pic)
@@ -1654,4 +1640,5 @@ AVCodec ff_svq3_decoder = {
   AV_CODEC_CAP_DELAY,
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P,
  AV_PIX_FMT_NONE},
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };

___
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/c93: Cleanup generically after init failure

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 22:42:26 2020 +0200| [8de4a132ff5cf9efa1c35c78c881dc22ba255c10] | 
committer: Andreas Rheinhardt

avcodec/c93: Cleanup generically after init failure

Reviewed-by: Paul B Mahol 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/c93.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/c93.c b/libavcodec/c93.c
index e1808150b8..7e3bfdbc72 100644
--- a/libavcodec/c93.c
+++ b/libavcodec/c93.c
@@ -63,10 +63,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
 s->pictures[0] = av_frame_alloc();
 s->pictures[1] = av_frame_alloc();
-if (!s->pictures[0] || !s->pictures[1]) {
-decode_end(avctx);
+if (!s->pictures[0] || !s->pictures[1])
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -269,5 +267,5 @@ AVCodec ff_c93_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };

___
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/pcm: Avoid indirection when calling float dsp function

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 00:13:43 2020 +0200| [771f91532c5cb65666820f1156b3a0e1661a3102] | 
committer: Andreas Rheinhardt

avcodec/pcm: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from the
AVFloatDSPContext that is needed lateron. This also allows to remove the
decoders' close function.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/pcm.c | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 96a68f7fe8..12d1b3a2c3 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -235,13 +235,15 @@ static int pcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 
 typedef struct PCMDecode {
 short   table[256];
-AVFloatDSPContext *fdsp;
+void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
+   int len);
 float   scale;
 } PCMDecode;
 
 static av_cold int pcm_decode_init(AVCodecContext *avctx)
 {
 PCMDecode *s = avctx->priv_data;
+AVFloatDSPContext *fdsp;
 int i;
 
 if (avctx->channels <= 0) {
@@ -268,9 +270,11 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
 return AVERROR_INVALIDDATA;
 
 s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1));
-s->fdsp = avpriv_float_dsp_alloc(0);
-if (!s->fdsp)
+fdsp = avpriv_float_dsp_alloc(0);
+if (!fdsp)
 return AVERROR(ENOMEM);
+s->vector_fmul_scalar = fdsp->vector_fmul_scalar;
+av_free(fdsp);
 break;
 default:
 break;
@@ -284,15 +288,6 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
 return 0;
 }
 
-static av_cold int pcm_decode_close(AVCodecContext *avctx)
-{
-PCMDecode *s = avctx->priv_data;
-
-av_freep(&s->fdsp);
-
-return 0;
-}
-
 /**
  * Read PCM samples macro
  * @param size   Data size of native machine format
@@ -529,9 +524,9 @@ static int pcm_decode_frame(AVCodecContext *avctx, void 
*data,
 
 if (avctx->codec_id == AV_CODEC_ID_PCM_F16LE ||
 avctx->codec_id == AV_CODEC_ID_PCM_F24LE) {
-s->fdsp->vector_fmul_scalar((float *)frame->extended_data[0],
-(const float *)frame->extended_data[0],
-s->scale, FFALIGN(frame->nb_samples * 
avctx->channels, 4));
+s->vector_fmul_scalar((float *)frame->extended_data[0],
+  (const float *)frame->extended_data[0],
+  s->scale, FFALIGN(frame->nb_samples * 
avctx->channels, 4));
 emms_c();
 }
 
@@ -570,7 +565,6 @@ AVCodec ff_ ## name_ ## _decoder = {
\
 .id = AV_CODEC_ID_ ## id_,  \
 .priv_data_size = sizeof(PCMDecode),\
 .init   = pcm_decode_init,  \
-.close  = pcm_decode_close, \
 .decode = pcm_decode_frame, \
 .capabilities   = AV_CODEC_CAP_DR1, \
 .sample_fmts= (const enum AVSampleFormat[]){ sample_fmt_,   \

___
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/svq3: Remove unused buffer

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 02:55:25 2020 +0200| [30620956ff7d1cf0f42846847d44e739bf094540] | 
committer: Andreas Rheinhardt

avcodec/svq3: Remove unused buffer

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/svq3.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 41a9bf2daa..0ac81364bd 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -75,10 +75,6 @@ typedef struct SVQ3Frame {
 
 AVBufferRef *mb_type_buf;
 uint32_t *mb_type;
-
-
-AVBufferRef *ref_index_buf[2];
-int8_t *ref_index[2];
 } SVQ3Frame;
 
 typedef struct SVQ3Context {
@@ -1330,7 +1326,6 @@ static void free_picture(AVCodecContext *avctx, SVQ3Frame 
*pic)
 int i;
 for (i = 0; i < 2; i++) {
 av_buffer_unref(&pic->motion_val_buf[i]);
-av_buffer_unref(&pic->ref_index_buf[i]);
 }
 av_buffer_unref(&pic->mb_type_buf);
 
@@ -1341,7 +1336,6 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame 
*pic)
 {
 SVQ3Context *s = avctx->priv_data;
 const int big_mb_num= s->mb_stride * (s->mb_height + 1) + 1;
-const int mb_array_size = s->mb_stride * s->mb_height;
 const int b4_stride = s->mb_width * 4 + 1;
 const int b4_array_size = b4_stride * s->mb_height * 4;
 int ret;
@@ -1356,14 +1350,12 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame 
*pic)
 
 for (i = 0; i < 2; i++) {
 pic->motion_val_buf[i] = av_buffer_allocz(2 * (b4_array_size + 4) 
* sizeof(int16_t));
-pic->ref_index_buf[i]  = av_buffer_allocz(4 * mb_array_size);
-if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i]) {
+if (!pic->motion_val_buf[i]) {
 ret = AVERROR(ENOMEM);
 goto fail;
 }
 
 pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data 
+ 4;
-pic->ref_index[i]  = pic->ref_index_buf[i]->data;
 }
 }
 

___
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/svq3: Avoid overhead of AVBuffer API

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 03:15:29 2020 +0200| [ef6c52f3c56ffdefb6c1f108b583b60657ff0bfc] | 
committer: Andreas Rheinhardt

avcodec/svq3: Avoid overhead of AVBuffer API

Up until now, the SVQ3 decoder allocated several refcounted buffers,
despite no sharing/refcounting happening at all: Their refcount never
exceeds one and they are treated like ordinary buffers (with the
exception that the pointer used to access them is in the middle of the
allocated buffer, but this does not warrant using the AVBuffer API at
all). Given that using the AVBuffer API incurs overhead, it is no longer
used at all.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/svq3.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 0ac81364bd..fb7b992496 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -70,11 +70,10 @@
 typedef struct SVQ3Frame {
 AVFrame *f;
 
-AVBufferRef *motion_val_buf[2];
+int16_t (*motion_val_buf[2])[2];
 int16_t (*motion_val[2])[2];
 
-AVBufferRef *mb_type_buf;
-uint32_t *mb_type;
+uint32_t *mb_type_buf, *mb_type;
 } SVQ3Frame;
 
 typedef struct SVQ3Context {
@@ -1325,9 +1324,9 @@ static void free_picture(AVCodecContext *avctx, SVQ3Frame 
*pic)
 {
 int i;
 for (i = 0; i < 2; i++) {
-av_buffer_unref(&pic->motion_val_buf[i]);
+av_freep(&pic->motion_val_buf[i]);
 }
-av_buffer_unref(&pic->mb_type_buf);
+av_freep(&pic->mb_type_buf);
 
 av_frame_unref(pic->f);
 }
@@ -1343,19 +1342,19 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame 
*pic)
 if (!pic->motion_val_buf[0]) {
 int i;
 
-pic->mb_type_buf = av_buffer_allocz((big_mb_num + s->mb_stride) * 
sizeof(uint32_t));
+pic->mb_type_buf = av_calloc(big_mb_num + s->mb_stride, 
sizeof(uint32_t));
 if (!pic->mb_type_buf)
 return AVERROR(ENOMEM);
-pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * s->mb_stride + 
1;
+pic->mb_type = pic->mb_type_buf + 2 * s->mb_stride + 1;
 
 for (i = 0; i < 2; i++) {
-pic->motion_val_buf[i] = av_buffer_allocz(2 * (b4_array_size + 4) 
* sizeof(int16_t));
+pic->motion_val_buf[i] = av_calloc(b4_array_size + 4, 2 * 
sizeof(int16_t));
 if (!pic->motion_val_buf[i]) {
 ret = AVERROR(ENOMEM);
 goto fail;
 }
 
-pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data 
+ 4;
+pic->motion_val[i] = pic->motion_val_buf[i] + 4;
 }
 }
 

___
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/roqaudioenc: Avoid redundant free of unallocated buffer

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 00:22:28 2020 +0200| [0b45ac571713cc8fda7aa5381c68ad671d21504b] | 
committer: Andreas Rheinhardt

avcodec/roqaudioenc: Avoid redundant free of unallocated buffer

If allocating a buffer in RoQ DPCM encoder's init function failed,
the close function would be called manually; all this function does is
freeing said buffer, but given that it has not been allocated at all,
this is unnecessary.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/roqaudioenc.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c
index 5154604be8..c09212d3d1 100644
--- a/libavcodec/roqaudioenc.c
+++ b/libavcodec/roqaudioenc.c
@@ -53,7 +53,6 @@ static av_cold int roq_dpcm_encode_close(AVCodecContext 
*avctx)
 static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx)
 {
 ROQDPCMContext *context = avctx->priv_data;
-int ret;
 
 if (avctx->channels > 2) {
 av_log(avctx, AV_LOG_ERROR, "Audio must be mono or stereo\n");
@@ -70,17 +69,12 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext 
*avctx)
 
 context->frame_buffer = av_malloc(8 * ROQ_FRAME_SIZE * avctx->channels *
   sizeof(*context->frame_buffer));
-if (!context->frame_buffer) {
-ret = AVERROR(ENOMEM);
-goto error;
-}
+if (!context->frame_buffer)
+return AVERROR(ENOMEM);
 
 context->lastSample[0] = context->lastSample[1] = 0;
 
 return 0;
-error:
-roq_dpcm_encode_close(avctx);
-return ret;
 }
 
 static unsigned char dpcm_predict(short *previous, short current)

___
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/tscc2: Cleanup generically after init failure

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 03:34:19 2020 +0200| [657756c353526e8807a214770c54a5bcb903bcad] | 
committer: Andreas Rheinhardt

avcodec/tscc2: Cleanup generically after init failure

Do this by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c
index 65fbb010f6..6aadb51ad4 100644
--- a/libavcodec/tscc2.c
+++ b/libavcodec/tscc2.c
@@ -74,18 +74,14 @@ static av_cold int init_vlcs(TSCC2Context *c)
  tscc2_nc_vlc_bits[i],  1, 1,
  tscc2_nc_vlc_codes[i], 2, 2,
  tscc2_nc_vlc_syms, 1, 1, INIT_VLC_LE);
-if (ret) {
-free_vlcs(c);
+if (ret)
 return ret;
-}
 ret = ff_init_vlc_sparse(c->ac_vlc + i, 9, tscc2_ac_vlc_sizes[i],
  tscc2_ac_vlc_bits[i],  1, 1,
  tscc2_ac_vlc_codes[i], 2, 2,
  tscc2_ac_vlc_syms[i],  2, 2, INIT_VLC_LE);
-if (ret) {
-free_vlcs(c);
+if (ret)
 return ret;
-}
 }
 
 return 0;
@@ -360,15 +356,12 @@ static av_cold int tscc2_decode_init(AVCodecContext 
*avctx)
 c->slice_quants = av_malloc(c->mb_width * c->mb_height);
 if (!c->slice_quants) {
 av_log(avctx, AV_LOG_ERROR, "Cannot allocate slice information\n");
-free_vlcs(c);
 return AVERROR(ENOMEM);
 }
 
 c->pic = av_frame_alloc();
-if (!c->pic) {
-tscc2_decode_end(avctx);
+if (!c->pic)
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -383,4 +376,5 @@ AVCodec ff_tscc2_decoder = {
 .close  = tscc2_decode_end,
 .decode = tscc2_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };

___
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/vble: Don't free buffer known to be NULL

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 03:52:39 2020 +0200| [a265e6604eb411316ec7ec91ba1bfaa37c71ef2d] | 
committer: Andreas Rheinhardt

avcodec/vble: Don't free buffer known to be NULL

Freeing a buffer allocated in the VBLE decoder's init function
is the only thing the decoder's close function does and this implies
that it is unnecessary to call it in case said allocation fails. Yet
this is what has been done.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/vble.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/vble.c b/libavcodec/vble.c
index c48c13127a..2cddd550b1 100644
--- a/libavcodec/vble.c
+++ b/libavcodec/vble.c
@@ -197,7 +197,6 @@ static av_cold int vble_decode_init(AVCodecContext *avctx)
 
 if (!ctx->val) {
 av_log(avctx, AV_LOG_ERROR, "Could not allocate values buffer.\n");
-vble_decode_close(avctx);
 return AVERROR(ENOMEM);
 }
 

___
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/vb: Cleanup generically after init failure

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 03:51:23 2020 +0200| [b128344dfcfcf167cd7f6b12b82fddc7efddc98d] | 
committer: Andreas Rheinhardt

avcodec/vb: Cleanup generically after init failure

In other words: Set the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/vb.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vb.c b/libavcodec/vb.c
index d9c6b93a73..fe419c7663 100644
--- a/libavcodec/vb.c
+++ b/libavcodec/vb.c
@@ -262,11 +262,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
 c->frame  = av_mallocz(avctx->width * avctx->height);
 c->prev_frame = av_mallocz(avctx->width * avctx->height);
 
-if (!c->frame || !c->prev_frame) {
-av_freep(&c->frame);
-av_freep(&c->prev_frame);
+if (!c->frame || !c->prev_frame)
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -291,4 +288,5 @@ AVCodec ff_vb_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };

___
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/pcm-dvdenc: Remove empty function

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Sep 12 23:48:32 2020 +0200| [4db4e69512a933f38d99b10df58431b9fed3e584] | 
committer: Andreas Rheinhardt

avcodec/pcm-dvdenc: Remove empty function

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/pcm-dvdenc.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c
index d26eaf071c..63f6e5d81b 100644
--- a/libavcodec/pcm-dvdenc.c
+++ b/libavcodec/pcm-dvdenc.c
@@ -170,11 +170,6 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 return 0;
 }
 
-static av_cold int pcm_dvd_encode_close(AVCodecContext *avctx)
-{
-return 0;
-}
-
 AVCodec ff_pcm_dvd_encoder = {
 .name   = "pcm_dvd",
 .long_name  = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian 
for DVD media"),
@@ -182,7 +177,6 @@ AVCodec ff_pcm_dvd_encoder = {
 .id = AV_CODEC_ID_PCM_DVD,
 .priv_data_size = sizeof(PCMDVDContext),
 .init   = pcm_dvd_encode_init,
-.close  = pcm_dvd_encode_close,
 .encode2= pcm_dvd_encode_frame,
 .capabilities   = AV_CODEC_CAP_SMALL_LAST_FRAME,
 .supported_samplerates = (const int[]) { 48000, 96000, 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/ffv1: Fix segfaults on allocation error

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Sep 14 04:58:34 2020 +0200| [a0750f412ade5a969b1f90e038d707d531c97342] | 
committer: Andreas Rheinhardt

avcodec/ffv1: Fix segfaults on allocation error

When allocating FFV1 slice contexts fails, ff_ffv1_init_slice_contexts()
frees everything that it has allocated, yet it does not reset the
counter for the number of allocated slice contexts. This inconsistent
state leads to segfaults lateron in ff_ffv1_close(), because said
function presumes that the slice contexts have been allocated.
Fix this by making sure that the number of slice contexts on error is
consistent (namely zero).

(This issue only affected the FFV1 decoder, because the encoder does not
clean up after itself on init failure.)

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/ffv1.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 93cec14244..5b52849400 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -115,12 +115,11 @@ av_cold int ff_ffv1_init_slices_state(FFV1Context *f)
 
 av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 {
-int i;
+int i, max_slice_count = f->num_h_slices * f->num_v_slices;
 
-f->max_slice_count = f->num_h_slices * f->num_v_slices;
-av_assert0(f->max_slice_count > 0);
+av_assert0(max_slice_count > 0);
 
-for (i = 0; i < f->max_slice_count; i++) {
+for (i = 0; i < max_slice_count; i++) {
 int sx  = i % f->num_h_slices;
 int sy  = i / f->num_h_slices;
 int sxs = f->avctx->width  *  sx  / f->num_h_slices;
@@ -152,6 +151,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 goto memfail;
 }
 }
+f->max_slice_count = max_slice_count;
 return 0;
 
 memfail:

___
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/qtrleenc: Fix memleak upon allocation failure

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Sep 12 23:52:36 2020 +0200| [2a71cbeb019fabd70f04ca9d2ec5d0bff3b3e3d2] | 
committer: Andreas Rheinhardt

avcodec/qtrleenc: Fix memleak upon allocation failure

The qtrle encoder allocates several buffers and an AVFrame in its init
function. If one of these allocations fails, but others succeed, the
successfully allocated objects leak. This is fixed by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/qtrleenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 6669c1302f..8b0edf7b3d 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -413,4 +413,5 @@ AVCodec ff_qtrle_encoder = {
 .pix_fmts   = (const enum AVPixelFormat[]){
 AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB555BE, AV_PIX_FMT_ARGB, 
AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
 },
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };

___
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/ra288: Avoid indirection when calling float dsp function

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 00:09:18 2020 +0200| [d3737bde639998f5a021e6fc00547ca2a7b28798] | 
committer: Andreas Rheinhardt

avcodec/ra288: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from the
AVFloatDSPContext that is needed lateron. This also allows to remove the
decoder's close function.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/ra288.c | 24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index aa4bd5d90f..8df17891b1 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -39,7 +39,8 @@
 #define RA288_BLOCKS_PER_FRAME 32
 
 typedef struct RA288Context {
-AVFloatDSPContext *fdsp;
+void (*vector_fmul)(float *dst, const float *src0, const float *src1,
+int len);
 DECLARE_ALIGNED(32, float,   sp_lpc)[FFALIGN(36, 16)];   ///< LPC 
coefficients for speech data (spec: A)
 DECLARE_ALIGNED(32, float, gain_lpc)[FFALIGN(10, 16)];   ///< LPC 
coefficients for gain(spec: GB)
 
@@ -60,18 +61,10 @@ typedef struct RA288Context {
 float gain_rec[11];
 } RA288Context;
 
-static av_cold int ra288_decode_close(AVCodecContext *avctx)
-{
-RA288Context *ractx = avctx->priv_data;
-
-av_freep(&ractx->fdsp);
-
-return 0;
-}
-
 static av_cold int ra288_decode_init(AVCodecContext *avctx)
 {
 RA288Context *ractx = avctx->priv_data;
+AVFloatDSPContext *fdsp;
 
 avctx->channels   = 1;
 avctx->channel_layout = AV_CH_LAYOUT_MONO;
@@ -82,9 +75,11 @@ static av_cold int ra288_decode_init(AVCodecContext *avctx)
 return AVERROR_PATCHWELCOME;
 }
 
-ractx->fdsp = avpriv_float_dsp_alloc(avctx->flags & 
AV_CODEC_FLAG_BITEXACT);
-if (!ractx->fdsp)
+fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+if (!fdsp)
 return AVERROR(ENOMEM);
+ractx->vector_fmul = fdsp->vector_fmul;
+av_free(fdsp);
 
 return 0;
 }
@@ -158,7 +153,7 @@ static void do_hybrid_window(RA288Context *ractx,
 
 av_assert2(order>=0);
 
-ractx->fdsp->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 
16));
+ractx->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16));
 
 convolve(buffer1, work + order, n  , order);
 convolve(buffer2, work + order + n, non_rec, order);
@@ -185,7 +180,7 @@ static void backward_filter(RA288Context *ractx,
 do_hybrid_window(ractx, order, n, non_rec, temp, hist, rec, window);
 
 if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1))
-ractx->fdsp->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16));
+ractx->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16));
 
 memmove(hist, hist + n, move_size*sizeof(*hist));
 }
@@ -249,6 +244,5 @@ AVCodec ff_ra_288_decoder = {
 .priv_data_size = sizeof(RA288Context),
 .init   = ra288_decode_init,
 .decode = ra288_decode_frame,
-.close  = ra288_decode_close,
 .capabilities   = AV_CODEC_CAP_DR1,
 };

___
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/sonic: Fix leaks upon allocation errors

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 01:10:40 2020 +0200| [7d91f9271ee336da93b6871bf3306348ac1595a7] | 
committer: Andreas Rheinhardt

avcodec/sonic: Fix leaks upon allocation errors

The Sonic decoder and encoders allocate several buffers in their init
function and return immediately if one of these allocations fails; this
will lead to leaks if there was an earlier successfull allocation. Fix
this by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/sonic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index ea6ef10c9e..fa4ecc3a7a 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -1095,6 +1095,7 @@ AVCodec ff_sonic_decoder = {
 .close  = sonic_decode_close,
 .decode = sonic_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif /* CONFIG_SONIC_DECODER */
 
@@ -1109,6 +1110,7 @@ AVCodec ff_sonic_encoder = {
 .encode2= sonic_encode_frame,
 .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, 
AV_SAMPLE_FMT_NONE },
 .capabilities   = AV_CODEC_CAP_EXPERIMENTAL,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .close  = sonic_encode_close,
 };
 #endif
@@ -1124,6 +1126,7 @@ AVCodec ff_sonic_ls_encoder = {
 .encode2= sonic_encode_frame,
 .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, 
AV_SAMPLE_FMT_NONE },
 .capabilities   = AV_CODEC_CAP_EXPERIMENTAL,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .close  = sonic_encode_close,
 };
 #endif

___
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/svq3: Fix segfault on allocation error, avoid allocations

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 02:25:16 2020 +0200| [96061c5a4f690c3ab49e4458701bb013fd3dd57f] | 
committer: Andreas Rheinhardt

avcodec/svq3: Fix segfault on allocation error, avoid allocations

The very first thing the SVQ3 decoder currently does is allocating several
SVQ3Frames, a structure which contains members that need to be freed on
their own. If one of these allocations fails, the decoder calls its own
close function to not leak the already allocated SVQ3Frames. Yet said
function presumes that the SVQ3Frames have been successfully allocated
as there is no check before freeing the members that need to be freed.

This commit fixes this by making these frames part of the SVQ3Context,
thereby avoiding the allocations altogether. Notice that the pointers
to the frames have been retained in order to allow to just swap them as
the code already does.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index c8db08a32f..8a67836827 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -147,6 +147,7 @@ typedef struct SVQ3Context {
 DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8];
 uint32_t dequant4_coeff[QP_MAX_NUM + 1][16];
 int block_offset[2 * (16 * 3)];
+SVQ3Frame frames[3];
 } SVQ3Context;
 
 #define FULLPEL_MODE  1
@@ -1135,13 +1136,9 @@ static av_cold int svq3_decode_init(AVCodecContext 
*avctx)
 int marker_found = 0;
 int ret;
 
-s->cur_pic  = av_mallocz(sizeof(*s->cur_pic));
-s->last_pic = av_mallocz(sizeof(*s->last_pic));
-s->next_pic = av_mallocz(sizeof(*s->next_pic));
-if (!s->next_pic || !s->last_pic || !s->cur_pic) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+s->cur_pic  = &s->frames[0];
+s->last_pic = &s->frames[1];
+s->next_pic = &s->frames[2];
 
 s->cur_pic->f  = av_frame_alloc();
 s->last_pic->f = av_frame_alloc();
@@ -1631,9 +1628,6 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx)
 av_frame_free(&s->cur_pic->f);
 av_frame_free(&s->next_pic->f);
 av_frame_free(&s->last_pic->f);
-av_freep(&s->cur_pic);
-av_freep(&s->next_pic);
-av_freep(&s->last_pic);
 av_freep(&s->slice_buf);
 av_freep(&s->intra4x4_pred_mode);
 av_freep(&s->edge_emu_buffer);

___
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/ra144enc: Don't free unnecessarily

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Sep 12 23:56:50 2020 +0200| [8bbd97109c993b50a00a88f2b773252ed1b83fc0] | 
committer: Andreas Rheinhardt

avcodec/ra144enc: Don't free unnecessarily

The init function of the real_144 encoder calls its own close function
if a call to ff_lpc_init() fails; yet nothing has been allocated before
that point and ff_lpc_init() can be expected to clean up after itself on
error (the documentation does not say anything to the contrary and the
current implementation can only fail if the only allocation fails, so
there is nothing to clean up on error anyway), so this is unnecessary.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/ra144enc.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c
index 059f582334..c6965c5c47 100644
--- a/libavcodec/ra144enc.c
+++ b/libavcodec/ra144enc.c
@@ -65,14 +65,11 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx)
 ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,
   FF_LPC_TYPE_LEVINSON);
 if (ret < 0)
-goto error;
+return ret;
 
 ff_af_queue_init(avctx, &ractx->afq);
 
 return 0;
-error:
-ra144_encode_close(avctx);
-return ret;
 }
 
 

___
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] dnn_backend_native_layer_conv2d.c: refine code.

2020-09-16 Thread Xu Jun
ffmpeg | branch: master | Xu Jun  | Wed Sep 16 18:07:19 
2020 +0800| [7d3cd9f9566ef5fb0cf64be90473152c68dc] | committer: Guo, Yejun

dnn_backend_native_layer_conv2d.c: refine code.

Move thread area allocate out of thread function into
main thread.

Signed-off-by: Xu Jun 

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

 libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 30 +++
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index 5c313454f7..2aaa4162df 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -33,12 +33,11 @@ typedef struct thread_common_param{
 const void *parameters;
 NativeContext *ctx;
 float *output_data;
-int thread_num;
 } thread_common_param;
 
 typedef struct thread_param{
 thread_common_param *thread_common_param;
-int thread_index;
+int thread_start, thread_end;
 } thread_param;
 
 int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
@@ -125,16 +124,12 @@ static void * dnn_execute_layer_conv2d_thread(void 
*threadarg)
 int filter_size = conv_params->kernel_size * filter_linesize;
 int pad_size = (conv_params->padding_method == VALID) ? 
(conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
 
-int thread_stride = (height - pad_size * 2) / 
thread_common_param->thread_num;
-int thread_start = thread_stride * thread_param->thread_index + pad_size;
-int thread_end = (thread_param->thread_index == 
thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + 
thread_stride);
-
 float *output = thread_common_param->output_data;
-output += (conv_params->output_num) * (width - 2 * pad_size) * 
(thread_start - pad_size);
+output += (conv_params->output_num) * (width - 2 * pad_size) * 
(thread_param->thread_start - pad_size);
 
 av_assert0(channel == conv_params->input_num);
 
-for (int y = thread_start; y < thread_end; ++y) {
+for (int y = thread_param->thread_start; y < thread_param->thread_end; 
++y) {
 for (int x = pad_size; x < width - pad_size; ++x) {
 for (int n_filter = 0; n_filter < conv_params->output_num; 
++n_filter) {
 if (conv_params->has_bias)
@@ -193,16 +188,19 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads);
 #if HAVE_PTHREAD_CANCEL
 pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t));
+int thread_stride;
 #endif
 thread_param **thread_param = av_malloc(thread_num * 
sizeof(*thread_param));
 thread_common_param thread_common_param;
 const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(parameters);
+int height = operands[input_operand_indexes[0]].dims[1];
+int width = operands[input_operand_indexes[0]].dims[2];
 int pad_size = (conv_params->padding_method == VALID) ? 
(conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
 DnnOperand *output_operand = &operands[output_operand_index];
 
 output_operand->dims[0] = operands[input_operand_indexes[0]].dims[0];
-output_operand->dims[1] = operands[input_operand_indexes[0]].dims[1] - 
pad_size * 2;
-output_operand->dims[2] = operands[input_operand_indexes[0]].dims[2] - 
pad_size * 2;
+output_operand->dims[1] = height - pad_size * 2;
+output_operand->dims[2] = width - pad_size * 2;
 output_operand->dims[3] = conv_params->output_num;
 output_operand->data_type = operands[input_operand_indexes[0]].data_type;
 output_operand->length = calculate_operand_data_length(output_operand);
@@ -223,13 +221,13 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 thread_common_param.ctx = ctx;
 
 #if HAVE_PTHREAD_CANCEL
-thread_common_param.thread_num = thread_num;
-
+thread_stride = (height - pad_size * 2) / thread_num;
 //create threads
 for (int i = 0; i < thread_num; i++){
 thread_param[i] = av_malloc(sizeof(**thread_param));
 thread_param[i]->thread_common_param = &thread_common_param;
-thread_param[i]->thread_index = i;
+thread_param[i]->thread_start = thread_stride * i + pad_size;
+thread_param[i]->thread_end = (i == thread_num - 1) ? (height - 
pad_size) : (thread_param[i]->thread_start + thread_stride);
 pthread_create(&thread_id[i], NULL, dnn_execute_layer_conv2d_thread, 
(void *)thread_param[i]);
 }
 
@@ -245,10 +243,10 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 av_free(thread_param[i]);
 }
 #else
-thread_common_param.thread_num = 1;
-thread_param[0] = av_malloc(sizeof(thread_param));
+thread_param[0] = av_malloc(

[FFmpeg-cvslog] dnn_backend_native_layer_conv2d.c: fix memory allocation bug in multithread function.

2020-09-16 Thread Xu Jun
ffmpeg | branch: master | Xu Jun  | Wed Sep 16 18:07:17 
2020 +0800| [8e67ae2cb4cb6785bbaa6a5d4bbbacd035cfd027] | committer: Guo, Yejun

dnn_backend_native_layer_conv2d.c: fix memory allocation bug in multithread 
function.

Before patch, memory was allocated in each thread functions,
which may cause more than one time of memory allocation and
cause crash.

After patch, memory is allocated in the main thread once,
an index was parsed into thread functions. Bug fixed.

Signed-off-by: Xu Jun 

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

 libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 57 +++
 1 file changed, 26 insertions(+), 31 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index c52725aa2b..5c313454f7 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -32,6 +32,7 @@ typedef struct thread_common_param{
 int32_t output_operand_index;
 const void *parameters;
 NativeContext *ctx;
+float *output_data;
 int thread_num;
 } thread_common_param;
 
@@ -111,9 +112,7 @@ static void * dnn_execute_layer_conv2d_thread(void 
*threadarg)
 thread_param *thread_param = (struct thread_param *)threadarg;
 thread_common_param *thread_common_param = 
thread_param->thread_common_param;
 DnnOperand *operands = thread_common_param->operands;
-float *output;
 int32_t input_operand_index = 
thread_common_param->input_operand_indexes[0];
-int number = operands[input_operand_index].dims[0];
 int height = operands[input_operand_index].dims[1];
 int width = operands[input_operand_index].dims[2];
 int channel = operands[input_operand_index].dims[3];
@@ -130,24 +129,7 @@ static void * dnn_execute_layer_conv2d_thread(void 
*threadarg)
 int thread_start = thread_stride * thread_param->thread_index + pad_size;
 int thread_end = (thread_param->thread_index == 
thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + 
thread_stride);
 
-DnnOperand *output_operand = 
&operands[thread_common_param->output_operand_index];
-output_operand->dims[0] = number;
-output_operand->dims[1] = height - pad_size * 2;
-output_operand->dims[2] = width - pad_size * 2;
-output_operand->dims[3] = conv_params->output_num;
-output_operand->data_type = operands[input_operand_index].data_type;
-output_operand->length = calculate_operand_data_length(output_operand);
-if (output_operand->length <= 0) {
-av_log(thread_common_param->ctx, AV_LOG_ERROR, "The output data length 
overflow\n");
-return (void *)DNN_ERROR;
-}
-output_operand->data = av_realloc(output_operand->data, 
output_operand->length);
-if (!output_operand->data) {
-av_log(thread_common_param->ctx, AV_LOG_ERROR, "Failed to reallocate 
memory for output\n");
-return (void *)DNN_ERROR;
-}
-
-output = output_operand->data;
+float *output = thread_common_param->output_data;
 output += (conv_params->output_num) * (width - 2 * pad_size) * 
(thread_start - pad_size);
 
 av_assert0(channel == conv_params->input_num);
@@ -213,16 +195,33 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t));
 #endif
 thread_param **thread_param = av_malloc(thread_num * 
sizeof(*thread_param));
-void *res;
-int error_flag = DNN_SUCCESS;
-
-//struct used to pass parameters
 thread_common_param thread_common_param;
+const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(parameters);
+int pad_size = (conv_params->padding_method == VALID) ? 
(conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
+DnnOperand *output_operand = &operands[output_operand_index];
+
+output_operand->dims[0] = operands[input_operand_indexes[0]].dims[0];
+output_operand->dims[1] = operands[input_operand_indexes[0]].dims[1] - 
pad_size * 2;
+output_operand->dims[2] = operands[input_operand_indexes[0]].dims[2] - 
pad_size * 2;
+output_operand->dims[3] = conv_params->output_num;
+output_operand->data_type = operands[input_operand_indexes[0]].data_type;
+output_operand->length = calculate_operand_data_length(output_operand);
+if (output_operand->length <= 0) {
+av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
+return DNN_ERROR;
+}
+output_operand->data = av_realloc(output_operand->data, 
output_operand->length);
+if (!output_operand->data) {
+av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n");
+return DNN_ERROR;
+}
+thread_common_param.output_data = output_operand->data;
 thread_common_param.operands = operands;
 thread_common_param.input_operand_indexes = input_operand_indexes;

[FFmpeg-cvslog] avcodec/av1dec: Remove redundant second free

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 13 21:35:12 2020 +0200| [3e057dd8b1ae7c455f0a8a761962349a06d592a7] | 
committer: Andreas Rheinhardt

avcodec/av1dec: Remove redundant second free

The AV1 decoder has the FF_CODEC_CAP_INIT_CLEANUP flag set and yet
the decoder's close function is called manually on some error paths.
This is unnecessary and has been removed in this commit.

Reviewed-by: James Almer 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/av1dec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 871db76b4d..cb46801202 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -480,7 +480,6 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) {
 s->ref[i].tf.f = av_frame_alloc();
 if (!s->ref[i].tf.f) {
-av1_decode_free(avctx);
 av_log(avctx, AV_LOG_ERROR,
"Failed to allocate reference frame buffer %d.\n", i);
 return AVERROR(ENOMEM);
@@ -489,7 +488,6 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 
 s->cur_frame.tf.f = av_frame_alloc();
 if (!s->cur_frame.tf.f) {
-av1_decode_free(avctx);
 av_log(avctx, AV_LOG_ERROR,
"Failed to allocate current frame buffer.\n");
 return AVERROR(ENOMEM);
@@ -504,7 +502,7 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
   avctx->extradata_size);
 if (ret < 0) {
 av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n");
-goto end;
+return ret;
 }
 
 seq = ((CodedBitstreamAV1Context 
*)(s->cbc->priv_data))->sequence_header;

___
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/av1dec: Fix segfault upon allocation error

2020-09-16 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Sep 14 06:37:24 2020 +0200| [92b578e1d62adf933cfacd36c02aabc448ed214d] | 
committer: Andreas Rheinhardt

avcodec/av1dec: Fix segfault upon allocation error

Up until now, the AV1 decoder always checks before calling its wrapper
around ff_thread_release_buffer() whether the ThreadFrame was used at
all, i.e. it checked whether the first data buffer of the AVFrame
contained therein is NULL or not. Yet this presumes that the AVFrame has
been successfully allocated, even though this can of course fail; and if
it did, one would encounter a segfault.
Fix this by removing the checks altogether: ff_thread_release_buffer()
can handle both unallocated as well as empty frames (since commit
f6774f905fb3cfdc319523ac640be30b14c1bc55).

Reviewed-by: James Almer 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/av1dec.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index bd8acdaafe..871db76b4d 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -388,12 +388,10 @@ static av_cold int av1_decode_free(AVCodecContext *avctx)
 AV1DecContext *s = avctx->priv_data;
 
 for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) {
-if (s->ref[i].tf.f->buf[0])
-av1_frame_unref(avctx, &s->ref[i]);
+av1_frame_unref(avctx, &s->ref[i]);
 av_frame_free(&s->ref[i].tf.f);
 }
-if (s->cur_frame.tf.f->buf[0])
-av1_frame_unref(avctx, &s->cur_frame);
+av1_frame_unref(avctx, &s->cur_frame);
 av_frame_free(&s->cur_frame.tf.f);
 
 av_buffer_unref(&s->seq_ref);

___
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".