[FFmpeg-cvslog] avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()

2020-05-08 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Thu May  7 
18:52:19 2020 +0800| [14285e4ca298607918a900c04565d4956588f20f] | committer: 
Limin Wang

avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()

Signed-off-by: Limin Wang 

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

 libavcodec/mpegvideo_enc.c | 85 +++---
 1 file changed, 43 insertions(+), 42 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index e1fd92ccae..50ae57e0a6 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -298,7 +298,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 avctx->pix_fmt != AV_PIX_FMT_YUV422P) {
 av_log(avctx, AV_LOG_ERROR,
"only YUV420 and YUV422 are supported\n");
-return -1;
+return AVERROR(EINVAL);
 }
 break;
 case AV_CODEC_ID_MJPEG:
@@ -322,13 +322,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 
 if (!format_supported) {
 av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
-return -1;
+return AVERROR(EINVAL);
 }
 break;
 default:
 if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {
 av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n");
-return -1;
+return AVERROR(EINVAL);
 }
 }
 
@@ -456,7 +456,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) {
 av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or 
neither must be specified\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) {
@@ -466,12 +466,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) {
 av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) {
 av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (avctx->rc_max_rate &&
@@ -485,7 +485,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avctx->bit_rate * (int64_t)avctx->time_base.num >
 avctx->rc_buffer_size * (int64_t)avctx->time_base.den) {
 av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (!s->fixed_qscale &&
@@ -511,18 +511,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
 s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P &&
 s->codec_id != AV_CODEC_ID_FLV1) {
 av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) {
 av_log(avctx, AV_LOG_ERROR,
"OBMC is only supported with simple mb decision\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) {
 av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (s->max_b_frames&&
@@ -530,12 +530,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
 s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
 s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
 av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n");
-return -1;
+return AVERROR(EINVAL);
 }
 if (s->max_b_frames < 0) {
 av_log(avctx, AV_LOG_ERROR,
"max b frames must be 0 or positive for mpegvideo based 
encoders\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if ((s->codec_id == AV_CODEC_ID_MPEG4 ||
@@ -555,28 +555,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
 (avctx->width  > 2048 ||
  avctx->height > 1152 )) {
 av_log(avctx, AV_LOG_ERROR, "H.263 does not support resolutions above 
2048x1152\n");
-return -1;
+return AVERROR(EINVAL);
 }
 if ((s->codec_id == AV_CODEC_ID_H263  ||
  s->codec_id == AV_CODEC_ID_H263P) &&
 ((avctx->width &3) ||
  (avctx->height&3) )) {
 av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO &&
 (avctx->width  > 4095 ||
  avctx->height > 4095 )) {
 av_log(avctx, AV_LOG_ERROR, "MPEG-1 does not support resolutions above 
4095x4095\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
 (avctx->width  > 16383 ||
  

[FFmpeg-cvslog] avcodec/mpegvideo: return more specific error codes for ff_mpv_common_init()

2020-05-08 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Fri May  8 
06:57:58 2020 +0800| [18e2c0e732047e8e636f8b76509ae4f1f947ce5b] | committer: 
Limin Wang

avcodec/mpegvideo: return more specific error codes for ff_mpv_common_init()

Signed-off-by: Limin Wang 

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

 libavcodec/mpegvideo.c | 30 --
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 22cab2854b..d174d1282e 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -907,7 +907,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) {
 av_log(s->avctx, AV_LOG_ERROR,
"decoding to AV_PIX_FMT_NONE is not supported.\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) 
{
@@ -923,7 +923,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 
 if ((s->width || s->height) &&
 av_image_check_size(s->width, s->height, 0, s->avctx))
-return -1;
+return AVERROR(EINVAL);
 
 dct_init(s);
 
@@ -935,27 +935,27 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 return ret;
 
 FF_ALLOCZ_OR_GOTO(s->avctx, s->picture,
-  MAX_PICTURE_COUNT * sizeof(Picture), fail);
+  MAX_PICTURE_COUNT * sizeof(Picture), fail_nomem);
 for (i = 0; i < MAX_PICTURE_COUNT; i++) {
 s->picture[i].f = av_frame_alloc();
 if (!s->picture[i].f)
-goto fail;
+goto fail_nomem;
 }
 s->next_picture.f = av_frame_alloc();
 if (!s->next_picture.f)
-goto fail;
+goto fail_nomem;
 s->last_picture.f = av_frame_alloc();
 if (!s->last_picture.f)
-goto fail;
+goto fail_nomem;
 s->current_picture.f = av_frame_alloc();
 if (!s->current_picture.f)
-goto fail;
+goto fail_nomem;
 s->new_picture.f = av_frame_alloc();
 if (!s->new_picture.f)
-goto fail;
+goto fail_nomem;
 
-if (init_context_frame(s))
-goto fail;
+if ((ret = init_context_frame(s)))
+goto fail_nomem;
 
 s->parse_context.state = -1;
 
@@ -969,9 +969,9 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 if (i) {
 s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext));
 if (!s->thread_context[i])
-goto fail;
+goto fail_nomem;
 }
-if (init_duplicate_context(s->thread_context[i]) < 0)
+if ((ret = init_duplicate_context(s->thread_context[i])) < 0)
 goto fail;
 s->thread_context[i]->start_mb_y =
 (s->mb_height * (i) + nb_slices / 2) / nb_slices;
@@ -979,7 +979,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
 }
 } else {
-if (init_duplicate_context(s) < 0)
+if ((ret = init_duplicate_context(s)) < 0)
 goto fail;
 s->start_mb_y = 0;
 s->end_mb_y   = s->mb_height;
@@ -988,9 +988,11 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 // }
 
 return 0;
+ fail_nomem:
+ret = AVERROR(ENOMEM);
  fail:
 ff_mpv_common_end(s);
-return -1;
+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] avcodec/mpegvideo: return more specific error codes for init_duplicate_context()

2020-05-08 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Fri May  8 
07:00:17 2020 +0800| [de7b690300be8c7423aa9625fa0ee5637ff38673] | committer: 
Limin Wang

avcodec/mpegvideo: return more specific error codes for init_duplicate_context()

Signed-off-by: Limin Wang 

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

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

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index d174d1282e..49fd1c999d 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -408,7 +408,7 @@ static int init_duplicate_context(MpegEncContext *s)
 
 return 0;
 fail:
-return -1; // free() through ff_mpv_common_end()
+return AVERROR(ENOMEM); // free() through ff_mpv_common_end()
 }
 
 static void free_duplicate_context(MpegEncContext *s)

___
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/mpeg12enc: return more specific error codes for encode_init()

2020-05-08 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Thu May  7 
18:55:11 2020 +0800| [0032ca45ff0740cb8f7d70a3283348673a234a5a] | committer: 
Limin Wang

avcodec/mpeg12enc: return more specific error codes for encode_init()

Signed-off-by: Limin Wang 

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

 libavcodec/mpeg12enc.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 643ba8165a..cab7076a58 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -139,16 +139,17 @@ static int find_frame_rate_index(MpegEncContext *s)
 
 static av_cold int encode_init(AVCodecContext *avctx)
 {
+int ret;
 MpegEncContext *s = avctx->priv_data;
 
-if (ff_mpv_encode_init(avctx) < 0)
-return -1;
+if ((ret = ff_mpv_encode_init(avctx)) < 0)
+return ret;
 
 if (find_frame_rate_index(s) < 0) {
 if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
 av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d 
fps\n",
avctx->time_base.den, avctx->time_base.num);
-return -1;
+return AVERROR(EINVAL);
 } else {
 av_log(avctx, AV_LOG_INFO,
"MPEG-1/2 does not support %d/%d fps, there may be AV sync 
issues\n",
@@ -159,7 +160,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 if (avctx->profile == FF_PROFILE_UNKNOWN) {
 if (avctx->level != FF_LEVEL_UNKNOWN) {
 av_log(avctx, AV_LOG_ERROR, "Set profile and level\n");
-return -1;
+return AVERROR(EINVAL);
 }
 /* Main or 4:2:2 */
 avctx->profile = s->chroma_format == CHROMA_420 ? 
FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422;
@@ -175,7 +176,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != 
CHROMA_420) {
 av_log(avctx, AV_LOG_ERROR,
"Only High(1) and 4:2:2(0) profiles support 4:2:2 color 
sampling\n");
-return -1;
+return AVERROR(EINVAL);
 }
 if (avctx->width <= 720 && avctx->height <= 576)
 avctx->level = 8;   /* Main */
@@ -205,7 +206,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 if (s->drop_frame_timecode && s->frame_rate_index != 4) {
 av_log(avctx, AV_LOG_ERROR,
"Drop frame time code only allowed with 1001/3 fps\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 #if FF_API_PRIVATE_OPT

___
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] doc/encoders: remove unsubstantiated ffaacenc > fdk-aac claim

2020-05-08 Thread Lou Logan
ffmpeg | branch: master | Lou Logan  | Thu Apr 30 10:44:04 2020 
-0800| [d163e0ecbcae10745a86a7142d9194d484fdbcce] | committer: Lou Logan

doc/encoders: remove unsubstantiated ffaacenc > fdk-aac claim

After this claim was made in e34e361 kamedo2 did an in-depth ABX
test comparing these encoders:

https://hydrogenaud.io/index.php?topic=111085.0

Result: FFmpeg AAC wasn't as good as libfdk_aac on average.

I know some things have changed since then such as, "use the fast
coder as the default" (fcb681ac) for example, so maybe the situation
is different now.

However, I am unaware of any recent comparison. So without any
substantiation we shouldn't make such a blantant claim.

Signed-off-by: Lou Logan 
Signed-off-by: Gyan Doshi 

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

 doc/encoders.texi | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 18bfe8f2eb..aa3a6eeb66 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -30,11 +30,7 @@ follows.
 
 Advanced Audio Coding (AAC) encoder.
 
-This encoder is the default AAC encoder, natively implemented into FFmpeg. Its
-quality is on par or better than libfdk_aac at the default bitrate of 128kbps.
-This encoder also implements more options, profiles and samplerates than
-other encoders (with only the AAC-HE profile pending to be implemented) so this
-encoder has become the default and is the recommended choice.
+This encoder is the default AAC encoder, natively implemented into FFmpeg.
 
 @subsection Options
 
@@ -651,10 +647,7 @@ configuration. You need to explicitly configure the build 
with
 so if you allow the use of GPL, you should configure with
 @code{--enable-gpl --enable-nonfree --enable-libfdk-aac}.
 
-This encoder is considered to produce output on par or worse at 128kbps to the
-@ref{aacenc,,the native FFmpeg AAC encoder} but can often produce better
-sounding audio at identical or lower bitrates and has support for the
-AAC-HE profiles.
+This encoder has support for the AAC-HE profiles.
 
 VBR encoding, enabled through the @option{vbr} or @option{flags
 +qscale} options, is experimental and only works with some

___
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/bsf: Restrict ff_bsf_get_packet_ref() return values to <= 0

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri May  8 20:37:24 2020 +0200| [47cd3c88c5f3180710494b775634398be1445fbf] | 
committer: Andreas Rheinhardt

avcodec/bsf: Restrict ff_bsf_get_packet_ref() return values to <= 0

Up until now the documentation of ff_bsf_get_packet_ref() allowed return
values >= 0 in case of success, whereas av_bsf_receive_packet() only
allows 0 on success. Given that for some bitstream filters the return
value of ff_bsf_get_packet_ref() is forwarded to the caller of
av_bsf_receive_packet() without any filtering, there would be a problem
if ff_bsf_get_packet_ref() actually returned values > 0. But it
currently doesn't and there is no reason why it should ever do so.
Therefore this commit aligns the return values of these functions by
restricting ff_bsf_get_packet_ref() to always returns 0 on success.

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

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

 libavcodec/bsf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h
index af035eee44..d04f1d3068 100644
--- a/libavcodec/bsf.h
+++ b/libavcodec/bsf.h
@@ -35,7 +35,7 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt);
  * @param ctx pointer to AVBSFContext of filter
  * @param pkt pointer to packet to move reference to
  *
- * @return 0>= on success, negative AVERROR in case of failure
+ * @return 0 on success, negative AVERROR in case of failure
  */
 int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt);
 

___
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/(null|opus_metadata)_bsf: Use ff_bsf_get_packet_ref() directly

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri May  8 12:33:09 2020 +0200| [6db97188d89e70d389e102a6f72555cfee64af30] | 
committer: Andreas Rheinhardt

avcodec/(null|opus_metadata)_bsf: Use ff_bsf_get_packet_ref() directly

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

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

 libavcodec/null_bsf.c  | 7 +--
 libavcodec/opus_metadata_bsf.c | 7 +--
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/libavcodec/null_bsf.c b/libavcodec/null_bsf.c
index 24d26dfb1a..37f4640c87 100644
--- a/libavcodec/null_bsf.c
+++ b/libavcodec/null_bsf.c
@@ -24,12 +24,7 @@
 #include "avcodec.h"
 #include "bsf.h"
 
-static int null_filter(AVBSFContext *ctx, AVPacket *pkt)
-{
-return ff_bsf_get_packet_ref(ctx, pkt);
-}
-
 const AVBitStreamFilter ff_null_bsf = {
 .name   = "null",
-.filter = null_filter,
+.filter = ff_bsf_get_packet_ref,
 };
diff --git a/libavcodec/opus_metadata_bsf.c b/libavcodec/opus_metadata_bsf.c
index 867ad830d3..d22db54f30 100644
--- a/libavcodec/opus_metadata_bsf.c
+++ b/libavcodec/opus_metadata_bsf.c
@@ -25,11 +25,6 @@ typedef struct OpusBSFContext {
 int gain;
 } OpusBSFContext;
 
-static int opus_metadata_filter(AVBSFContext *bsfc, AVPacket *pkt)
-{
-return ff_bsf_get_packet_ref(bsfc, pkt);
-}
-
 static int opus_metadata_init(AVBSFContext *bsfc)
 {
 OpusBSFContext *s = bsfc->priv_data;
@@ -67,6 +62,6 @@ const AVBitStreamFilter ff_opus_metadata_bsf = {
 .priv_data_size = sizeof(OpusBSFContext),
 .priv_class = _metadata_class,
 .init   = _metadata_init,
-.filter = _metadata_filter,
+.filter = _bsf_get_packet_ref,
 .codec_ids  = codec_ids,
 };

___
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] avformat/hlsenc: Cosmetics

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Feb 28 07:59:34 2020 +0100| [345158aea1bac6fc8521474ed0a1f9e6ce8898e8] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Cosmetics

Mainly includes reindentation and returning directly (i.e. without
a goto fail when possible).

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 135 +--
 1 file changed, 55 insertions(+), 80 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 3cc103af85..7b289c060f 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1504,7 +1504,7 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 ff_hls_write_playlist_header(byterange_mode ? hls->m3u8_out : vs->out, 
hls->version, hls->allowcache,
  target_duration, sequence, hls->pl_type, 
hls->flags & HLS_I_FRAMES_ONLY);
 
-if ((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
vs->discontinuity_set==0 ) {
+if ((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
vs->discontinuity_set==0) {
 avio_printf(byterange_mode ? hls->m3u8_out : vs->out, 
"#EXT-X-DISCONTINUITY\n");
 vs->discontinuity_set = 1;
 }
@@ -1664,7 +1664,7 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 }
 ff_format_set_url(oc, filename);
 }
-if ( vs->vtt_basename) {
+if (vs->vtt_basename) {
 char *filename = NULL;
 if (replace_int_data_in_filename(,
 #if FF_API_HLS_WRAP
@@ -1802,10 +1802,8 @@ static int validate_name(int nb_vs, const char *fn)
 char *fn_dup = NULL;
 int ret = 0;
 
-if (!fn) {
-ret = AVERROR(EINVAL);
-goto fail;
-}
+if (!fn)
+return AVERROR(EINVAL);
 
 fn_dup = av_strdup(fn);
 if (!fn_dup)
@@ -1839,14 +1837,12 @@ static int format_name(const char *buf, char **s, int 
index, const char *varname
 int ret = 0;
 
 orig_buf_dup = av_strdup(buf);
-if (!orig_buf_dup) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!orig_buf_dup)
+return AVERROR(ENOMEM);
 
 if (!av_stristr(buf, "%v")) {
 *s = orig_buf_dup;
-return ret;
+return 0;
 }
 
 if (!varname) {
@@ -2164,16 +2160,14 @@ static int update_variant_stream_info(AVFormatContext 
*s)
 hls->var_streams[0].nb_streams = s->nb_streams;
 hls->var_streams[0].streams = av_mallocz(sizeof(AVStream *) *
 hls->var_streams[0].nb_streams);
-if (!hls->var_streams[0].streams) {
+if (!hls->var_streams[0].streams)
 return AVERROR(ENOMEM);
-}
 
 //by default, the first available ccgroup is mapped to the variant 
stream
 if (hls->nb_ccstreams) {
 hls->var_streams[0].ccgroup = 
av_strdup(hls->cc_streams[0].ccgroup);
-if (!hls->var_streams[0].ccgroup) {
+if (!hls->var_streams[0].ccgroup)
 return AVERROR(ENOMEM);
-}
 }
 
 for (i = 0; i < s->nb_streams; i++)
@@ -2315,7 +2309,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 vs = >var_streams[i];
 for (j = 0; j < vs->nb_streams; j++) {
 if (vs->streams[j] == st) {
-if ( st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE ) {
+if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
 oc = vs->vtt_avf;
 stream_index = 0;
 } else {
@@ -2340,7 +2334,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (vs->sequence - vs->nb_entries > hls->start_sequence && hls->init_time 
> 0) {
 /* reset end_pts, hls->recording_time at end of the init hls list */
 int64_t init_list_dur = hls->init_time * vs->nb_entries * AV_TIME_BASE;
-int64_t after_init_list_dur = (vs->sequence - hls->start_sequence - 
vs->nb_entries ) * (hls->time * AV_TIME_BASE);
+int64_t after_init_list_dur = (vs->sequence - hls->start_sequence - 
vs->nb_entries) * (hls->time * AV_TIME_BASE);
 hls->recording_time = hls->time * AV_TIME_BASE;
 end_pts = init_list_dur + after_init_list_dur ;
 }
@@ -2567,12 +2561,10 @@ static void hls_deinit(AVFormatContext *s)
 {
 HLSContext *hls = s->priv_data;
 int i = 0;
-AVFormatContext *vtt_oc = NULL;
 VariantStream *vs = NULL;
 
 for (i = 0; i < hls->nb_varstreams; i++) {
 vs = >var_streams[i];
-vtt_oc = vs->vtt_avf;
 
 av_freep(>basename);
 av_freep(>base_output_dirname);
@@ -2580,7 +2572,7 @@ static void hls_deinit(AVFormatContext *s)
 av_freep(>vtt_basename);
 av_freep(>vtt_m3u8_name);
 
-avformat_free_context(vtt_oc);
+

[FFmpeg-cvslog] avformat/hlsenc: Factor check out of loop

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Dec 15 19:39:16 2019 +0100| [4effcc399a816689e396b64568beb9a90e83408d] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Factor check out of loop

The check will be true at most once anyway.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 3d5b09c963..3cc103af85 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2829,6 +2829,15 @@ static int hls_init(AVFormatContext *s)
 }
 
 hls->recording_time = (hls->init_time ? hls->init_time : hls->time) * 
AV_TIME_BASE;
+
+if (hls->flags & HLS_SPLIT_BY_TIME && hls->flags & 
HLS_INDEPENDENT_SEGMENTS) {
+// Independent segments cannot be guaranteed when splitting by time
+hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
+av_log(s, AV_LOG_WARNING,
+   "'split_by_time' and 'independent_segments' cannot be 
enabled together. "
+   "Disabling 'independent_segments' flag\n");
+}
+
 for (i = 0; i < hls->nb_varstreams; i++) {
 vs = >var_streams[i];
 
@@ -2841,14 +2850,6 @@ static int hls_init(AVFormatContext *s)
 vs->end_pts  = AV_NOPTS_VALUE;
 vs->current_segment_final_filename_fmt[0] = '\0';
 
-if (hls->flags & HLS_SPLIT_BY_TIME && hls->flags & 
HLS_INDEPENDENT_SEGMENTS) {
-// Independent segments cannot be guaranteed when splitting by time
-hls->flags &= ~HLS_INDEPENDENT_SEGMENTS;
-av_log(s, AV_LOG_WARNING,
-   "'split_by_time' and 'independent_segments' cannot be 
enabled together. "
-   "Disabling 'independent_segments' flag\n");
-}
-
 if (hls->flags & HLS_PROGRAM_DATE_TIME) {
 time_t now0;
 time();

___
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] avformat/hlsenc: Localize initialization of subtitle streams

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Dec 15 22:12:53 2019 +0100| [e1dfb5128b90f7a3253465599eeb6d6718359da8] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Localize initialization of subtitle streams

Before this commit, the checks were unnecessarily scattered.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 20f66d52d1..3d5b09c963 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2878,13 +2878,6 @@ static int hls_init(AVFormatContext *s)
 goto fail;
 }
 
-if (vs->has_subtitle) {
-vs->vtt_oformat = av_guess_format("webvtt", NULL, NULL);
-if (!vs->vtt_oformat) {
-ret = AVERROR_MUXER_NOT_FOUND;
-goto fail;
-}
-}
 if (hls->segment_filename) {
 ret = format_name(hls->segment_filename, >basename, i, 
vs->varname);
 if (ret < 0)
@@ -2979,6 +2972,9 @@ static int hls_init(AVFormatContext *s)
 goto fail;
 
 if (vs->has_subtitle) {
+vs->vtt_oformat = av_guess_format("webvtt", NULL, NULL);
+if (!vs->vtt_oformat)
+return AVERROR_MUXER_NOT_FOUND;
 
 if (hls->flags & HLS_SINGLE_FILE)
 vtt_pattern = ".vtt";

___
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] avformat/hlsenc: Unconditionally free some strings

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Dec 15 18:48:28 2019 +0100| [191b51254cf5d37c84af51d434993efe174b0977] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Unconditionally free some strings

hls_init() would at first allocate the vtt_basename string, then
allocate the vtt_m3u8_name string followed by several operations that
may fail and then open the subtitles' output context. Yet upon freeing,
these strings were only freed when the subtitles' output context
existed, ensuring that they leak if something goes wrong between their
allocation and the opening of the subtitles' output context. So drop the
check for whether this output context exists.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0abda8ba30..20f66d52d1 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2577,12 +2577,10 @@ static void hls_deinit(AVFormatContext *s)
 av_freep(>basename);
 av_freep(>base_output_dirname);
 av_freep(>fmp4_init_filename);
-if (vtt_oc) {
-av_freep(>vtt_basename);
-av_freep(>vtt_m3u8_name);
-avformat_free_context(vtt_oc);
-}
+av_freep(>vtt_basename);
+av_freep(>vtt_m3u8_name);
 
+avformat_free_context(vtt_oc);
 avformat_free_context(vs->avf);
 if (hls->resend_init_file)
 av_freep(>init_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] avformat/hlsenc: Check some unchecked allocations

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Dec 15 11:24:32 2019 +0100| [2fcfc16dd21ac493f5297c6ad694e07e5af1c2e6] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Check some unchecked allocations

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index abbf283562..0abda8ba30 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1640,6 +1640,8 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 if (c->use_localtime_mkdir) {
 const char *dir;
 char *fn_copy = av_strdup(oc->url);
+if (!fn_copy)
+return AVERROR(ENOMEM);
 dir = av_dirname(fn_copy);
 if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
 av_log(oc, AV_LOG_ERROR, "Could not create directory %s 
with use_localtime_mkdir\n", dir);
@@ -1806,6 +1808,8 @@ static int validate_name(int nb_vs, const char *fn)
 }
 
 fn_dup = av_strdup(fn);
+if (!fn_dup)
+return AVERROR(ENOMEM);
 filename = av_basename(fn);
 subdir_name = av_dirname(fn_dup);
 
@@ -2186,6 +2190,8 @@ static int update_master_pl_info(AVFormatContext *s)
 int ret = 0;
 
 fn1 = av_strdup(s->url);
+if (!fn1)
+return AVERROR(ENOMEM);
 dir = av_dirname(fn1);
 
 /**
@@ -2194,6 +2200,10 @@ static int update_master_pl_info(AVFormatContext *s)
  */
 if (dir && av_stristr(av_basename(dir), "%v")) {
 fn2 = av_strdup(dir);
+if (!fn2) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 dir = av_dirname(fn2);
 }
 
@@ -2934,7 +2944,8 @@ static int hls_init(AVFormatContext *s)
 if (hls->nb_varstreams > 1) {
 if (av_stristr(vs->fmp4_init_filename, "%v")) {
 av_freep(>fmp4_init_filename);
-format_name(hls->fmp4_init_filename, 
>fmp4_init_filename, i, vs->varname);
+ret = format_name(hls->fmp4_init_filename,
+  >fmp4_init_filename, i, 
vs->varname);
 } else {
 ret = append_postfix(vs->fmp4_init_filename, 
fmp4_init_filename_len, i);
 }

___
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] avformat/hlsenc: Add deinit function

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Dec 15 11:00:02 2019 +0100| [fdb6f55209152b2a9b7e97758c8f26d7cb2dc669] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Add deinit function

This fixes memleaks in instances such as:
a) When an allocation fails at one of the two places in hls_init() where
the error is returned immediately without goto fail first.
b) When an error happens when writing the header.
c) When an allocation fails at one of the three places in
hls_write_trailer() where the error is returned immediately without goto
fail first.
d) When one decides not to write the trailer at all (e.g. because of
errors when writing packets).
Furthermore, it removes code duplication and allows to return
immediately, without goto fail first.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 47 +--
 1 file changed, 17 insertions(+), 30 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 783bcffe57..abbf283562 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2553,8 +2553,9 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 }
 
-static void hls_free_variant_streams(struct HLSContext *hls)
+static void hls_deinit(AVFormatContext *s)
 {
+HLSContext *hls = s->priv_data;
 int i = 0;
 AVFormatContext *vtt_oc = NULL;
 VariantStream *vs = NULL;
@@ -2586,6 +2587,20 @@ static void hls_free_variant_streams(struct HLSContext 
*hls)
 av_freep(>baseurl);
 av_freep(>varname);
 }
+
+for (i = 0; i < hls->nb_ccstreams; i++) {
+ClosedCaptionsStream *ccs = >cc_streams[i];
+av_freep(>ccgroup);
+av_freep(>instreamid);
+av_freep(>language);
+}
+
+ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >sub_m3u8_out);
+av_freep(>key_basename);
+av_freep(>var_streams);
+av_freep(>cc_streams);
+av_freep(>master_m3u8_url);
 }
 
 static int hls_write_trailer(struct AVFormatContext *s)
@@ -2718,21 +2733,6 @@ failed:
 av_free(old_filename);
 }
 
-hls_free_variant_streams(hls);
-
-for (i = 0; i < hls->nb_ccstreams; i++) {
-ClosedCaptionsStream *ccs = >cc_streams[i];
-av_freep(>ccgroup);
-av_freep(>instreamid);
-av_freep(>language);
-}
-
-ff_format_io_close(s, >m3u8_out);
-ff_format_io_close(s, >sub_m3u8_out);
-av_freep(>key_basename);
-av_freep(>var_streams);
-av_freep(>cc_streams);
-av_freep(>master_m3u8_url);
 return 0;
 }
 
@@ -3026,20 +3026,6 @@ static int hls_init(AVFormatContext *s)
 }
 
 fail:
-if (ret < 0) {
-hls_free_variant_streams(hls);
-for (i = 0; i < hls->nb_ccstreams; i++) {
-ClosedCaptionsStream *ccs = >cc_streams[i];
-av_freep(>ccgroup);
-av_freep(>instreamid);
-av_freep(>language);
-}
-av_freep(>key_basename);
-av_freep(>var_streams);
-av_freep(>cc_streams);
-av_freep(>master_m3u8_url);
-}
-
 return ret;
 }
 
@@ -3137,5 +3123,6 @@ AVOutputFormat ff_hls_muxer = {
 .write_header   = hls_write_header,
 .write_packet   = hls_write_packet,
 .write_trailer  = hls_write_trailer,
+.deinit = hls_deinit,
 .priv_class = _class,
 };

___
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/mpegvideo_enc: reindent code

2020-05-08 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Thu May  7 
18:41:17 2020 +0800| [6825f7c0ba0e2021c47ef13440cefc49e50b0b5f] | committer: 
Limin Wang

avcodec/mpegvideo_enc: reindent code

Reviewed-by: Michael Niedermayer 
Signed-off-by: Limin Wang 

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

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

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index b2eb9cf318..e1fd92ccae 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -596,8 +596,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if ((s->codec_id == AV_CODEC_ID_WMV1 ||
  s->codec_id == AV_CODEC_ID_WMV2) &&
  avctx->width & 1) {
- av_log(avctx, AV_LOG_ERROR, "width must be multiple of 2\n");
- return -1;
+av_log(avctx, AV_LOG_ERROR, "width must be multiple of 2\n");
+return -1;
 }
 
 if ((s->avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | 
AV_CODEC_FLAG_INTERLACED_ME)) &&

___
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] avformat/hlsenc: Avoid setting unused variables

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Dec 15 07:42:01 2019 +0100| [de20f6cb701bffc98062d825c339ce30a794ca01] | 
committer: Andreas Rheinhardt

avformat/hlsenc: Avoid setting unused variables

Several variables which are only used when the HLS_SINGLE_FILE flag is
unset have been set even when this flag is set. This has been changed.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/hlsenc.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 11b5c481b0..783bcffe57 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2404,11 +2404,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 }
 
-if (oc->url[0]) {
-proto = avio_find_protocol_name(oc->url);
-use_temp_file = proto && !strcmp(proto, "file") && (hls->flags & 
HLS_TEMP_FILE);
-}
-
 if (hls->flags & HLS_SINGLE_FILE) {
 ret = flush_dynbuf(vs, _length);
 av_freep(>temp_buffer);
@@ -2417,6 +2412,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 vs->size = range_length;
 } else {
+if (oc->url[0]) {
+proto = avio_find_protocol_name(oc->url);
+use_temp_file = proto && !strcmp(proto, "file")
+  && (hls->flags & HLS_TEMP_FILE);
+}
+
 if ((hls->max_seg_size > 0 && (vs->size >= hls->max_seg_size)) || 
!byterange_mode) {
 AVDictionary *options = NULL;
 char *filename = NULL;
@@ -2466,10 +2467,9 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 av_freep(>temp_buffer);
 av_freep();
 }
-}
 
-if (use_temp_file && !(hls->flags & HLS_SINGLE_FILE)) {
-hls_rename_temp_file(s, oc);
+if (use_temp_file)
+hls_rename_temp_file(s, oc);
 }
 
 old_filename = av_strdup(oc->url);

___
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] avformat/matroskadec: Allow multiple Tags elements

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri May  1 00:49:49 2020 +0200| [ff4da60fb8d849f709295bcdcb67726ea189d62b] | 
committer: Andreas Rheinhardt

avformat/matroskadec: Allow multiple Tags elements

The Matroska specification allows multiple (level 1) Tags elements per
file, yet our demuxer didn't: While it parsed any amount of Tags
elements it found in front of the Clusters (albeit with warnings because
of duplicate elements), it would treat any Tags element only referenced
via a SeekHead entry as already parsed if any Tags element has already
been parsed; therefore this Tags element would not be parsed at all.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/matroskadec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 1dc1bd470c..b277c05f9d 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1147,11 +1147,11 @@ static MatroskaLevel1Element 
*matroska_find_level1_elem(MatroskaDemuxContext *ma
 if (id == MATROSKA_ID_CLUSTER)
 return NULL;
 
-// There can be multiple seekheads.
+// There can be multiple SeekHeads and Tags.
 for (i = 0; i < matroska->num_level1_elems; i++) {
 if (matroska->level1_elems[i].id == id) {
 if (matroska->level1_elems[i].pos == pos ||
-id != MATROSKA_ID_SEEKHEAD)
+id != MATROSKA_ID_SEEKHEAD && id != MATROSKA_ID_TAGS)
 return >level1_elems[i];
 }
 }

___
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] avformat/matroskadec: Improve handling of circular SeekHeads

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Apr 30 23:16:44 2020 +0200| [7e9103535ab82b82cb2d440c205a65a7767fa060] | 
committer: Andreas Rheinhardt

avformat/matroskadec: Improve handling of circular SeekHeads

There can be more than one SeekHead in a Matroska file, but most of the
other level 1 elements can only occur once.* Therefore the Matroska
demuxer only allows one entry per ID in its internal list of level 1
elements known to it; the only exception to this are SeekHeads.

The only exception to this are SeekHeads: When one is encountered
(either directly or in the list of entries read from SeekHeads),
a new entry in the list of known level-1 elements is always added,
even when this entry is actually already known.

This leads to lots of seeks in case of circular SeekHeads: Each time a
SeekHead is parsed, a new entry for a SeekHead will be added to the list
of entries read from SeekHeads. The exception for SeekHeads mentioned
above now implies that this SeekHead will always appear new and unparsed
and parsing will be attempted. This continued until the list of known
level-1 elements is full.

Fixing this is pretty simple: Don't add a new entry for a SeekHead if
its position matches the position of an already known SeekHead.

*: Actually, there can be multiple Tags and several other level 1
elements are "identically recurring" which means they may be resent
multiple times, but each instance must be absolutely identical to the
previous.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 90de2e19d3..1dc1bd470c 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1135,7 +1135,7 @@ static int is_ebml_id_valid(uint32_t id)
  * an entry already exists, return the existing entry.
  */
 static MatroskaLevel1Element *matroska_find_level1_elem(MatroskaDemuxContext 
*matroska,
-uint32_t id)
+uint32_t id, int64_t 
pos)
 {
 int i;
 MatroskaLevel1Element *elem;
@@ -1148,18 +1148,17 @@ static MatroskaLevel1Element 
*matroska_find_level1_elem(MatroskaDemuxContext *ma
 return NULL;
 
 // There can be multiple seekheads.
-if (id != MATROSKA_ID_SEEKHEAD) {
-for (i = 0; i < matroska->num_level1_elems; i++) {
-if (matroska->level1_elems[i].id == id)
+for (i = 0; i < matroska->num_level1_elems; i++) {
+if (matroska->level1_elems[i].id == id) {
+if (matroska->level1_elems[i].pos == pos ||
+id != MATROSKA_ID_SEEKHEAD)
 return >level1_elems[i];
 }
 }
 
 // Only a completely broken file would have more elements.
-// It also provides a low-effort way to escape from circular seekheads
-// (every iteration will add a level1 entry).
 if (matroska->num_level1_elems >= FF_ARRAY_ELEMS(matroska->level1_elems)) {
-av_log(matroska->ctx, AV_LOG_ERROR, "Too many level1 elements or 
circular seekheads.\n");
+av_log(matroska->ctx, AV_LOG_ERROR, "Too many level1 elements.\n");
 return NULL;
 }
 
@@ -1408,7 +1407,7 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
 if (id == MATROSKA_ID_CUES)
 matroska->cues_parsing_deferred = 0;
 if (syntax->type == EBML_LEVEL1 &&
-(level1_elem = matroska_find_level1_elem(matroska, syntax->id))) {
+(level1_elem = matroska_find_level1_elem(matroska, syntax->id, 
pos))) {
 if (!level1_elem->pos) {
 // Zero is not a valid position for a level 1 element.
 level1_elem->pos = pos;
@@ -1871,7 +1870,7 @@ static void 
matroska_execute_seekhead(MatroskaDemuxContext *matroska)
 if (id != seekheads[i].id || pos < matroska->segment_start)
 continue;
 
-elem = matroska_find_level1_elem(matroska, id);
+elem = matroska_find_level1_elem(matroska, id, pos);
 if (!elem || elem->parsed)
 continue;
 

___
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] avformat/matroskadec: Sanitize SeekHead entries

2020-05-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Aug 30 13:20:26 2019 +0200| [7c243eece3427bc5a6d54657d488d5c0c2985a8e] | 
committer: Andreas Rheinhardt

avformat/matroskadec: Sanitize SeekHead entries

A Seek element in a Matroska SeekHead should contain a SeekID and a
SeekPosition element and upon reading, they should be sanitized:

Given that IDs are restricted to 32 bit, longer SeekIDs should be treated
as invalid. Instead currently the lower 32 bits have been used.

For SeekPosition, no checks were performed for the element to be
present and if present, whether it was excessively large (i.e. the
absolute file position described by it exceeding INT64_MAX). The
SeekPosition element had a default value of -1 which means that a check
seems to have been intended; but it was not implemented. This commit adds
a check for overflow to the calculation of the absolute file position of
the referenced level 1 elements.
Using -1 (i.e. UINT64_MAX) as default value for SeekPosition implies that
a Seek element without SeekPosition will run afoul of this check.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/matroskadec.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 981fb4bc20..90de2e19d3 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1866,8 +1866,12 @@ static void 
matroska_execute_seekhead(MatroskaDemuxContext *matroska)
 MatroskaSeekhead *seekheads = seekhead_list->elem;
 uint32_t id = seekheads[i].id;
 int64_t pos = seekheads[i].pos + matroska->segment_start;
+MatroskaLevel1Element *elem;
 
-MatroskaLevel1Element *elem = matroska_find_level1_elem(matroska, id);
+if (id != seekheads[i].id || pos < matroska->segment_start)
+continue;
+
+elem = matroska_find_level1_elem(matroska, id);
 if (!elem || elem->parsed)
 continue;
 

___
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] Revert "doc/mailing-list-faq: Mention current problem with GMX"

2020-05-08 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
May  7 12:41:13 2020 +0200| [e38adc197ed1ef3423329035a29292b17d319a79] | 
committer: Michael Niedermayer

Revert "doc/mailing-list-faq: Mention current problem with GMX"

mails to GMX seem working again

This reverts commit cd11fbcfb03994d3ddbc83f0620530d6f6748f68.

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

 doc/mailing-list-faq.texi | 4 
 1 file changed, 4 deletions(-)

diff --git a/doc/mailing-list-faq.texi b/doc/mailing-list-faq.texi
index 15fc8e86c0..439d783956 100644
--- a/doc/mailing-list-faq.texi
+++ b/doc/mailing-list-faq.texi
@@ -358,10 +358,6 @@ often not aware of this and is often out of their control.
 When possible we attempt to notify the provider to be removed from the
 blacklists or filters.
 
-Currently (End April/May 2020) GMX is apparently blocking all mails from 
FFmpeg.
-If you have a gmx account, do not hesitate to complain to them about this. We 
so far
-have had no luck.
-
 @section Why are my sent messages not showing up?
 
 Excluding @ref{Why is my message awaiting moderator approval?, messages that 
are held in the moderation queue}

___
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-layer-mathbinary-test: add unit test for minimum

2020-05-08 Thread Guo , Yejun
ffmpeg | branch: master | Guo, Yejun  | Sun Apr 26 
15:49:39 2020 +0800| [6fd61234d59783d87f917dcac4d7cf2b89a661c5] | committer: 
Guo, Yejun

dnn-layer-mathbinary-test: add unit test for minimum

Signed-off-by: Guo, Yejun 

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

 tests/dnn/dnn-layer-mathbinary-test.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tests/dnn/dnn-layer-mathbinary-test.c 
b/tests/dnn/dnn-layer-mathbinary-test.c
index f67c0f213b..e7f8f8557c 100644
--- a/tests/dnn/dnn-layer-mathbinary-test.c
+++ b/tests/dnn/dnn-layer-mathbinary-test.c
@@ -38,6 +38,8 @@ static float get_expected(float f1, float f2, 
DNNMathBinaryOperation op)
 return f1 * f2;
 case DMBO_REALDIV:
 return f1 / f2;
+case DMBO_MINIMUM:
+return (f1 < f2) ? f1 : f2;
 default:
 av_assert0(!"not supported yet");
 return 0.f;
@@ -200,5 +202,8 @@ int main(int argc, char **argv)
 if (test(DMBO_REALDIV))
 return 1;
 
+if (test(DMBO_MINIMUM))
+return 1;
+
 return 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] dnn/native: add native support for minimum

2020-05-08 Thread Guo , Yejun
ffmpeg | branch: master | Guo, Yejun  | Sun Apr 26 
15:46:38 2020 +0800| [71e28c5422e321640b69ee512eef3e899c746e1e] | committer: 
Guo, Yejun

dnn/native: add native support for minimum

it can be tested with model file generated with below python script:
import tensorflow as tf
import numpy as np
import imageio

in_img = imageio.imread('input.jpg')
in_img = in_img.astype(np.float32)/255.0
in_data = in_img[np.newaxis, :]

x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
x1 = tf.minimum(0.7, x)
x2 = tf.maximum(x1, 0.4)
y = tf.identity(x2, name='dnn_out')

sess=tf.Session()
sess.run(tf.global_variables_initializer())

graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, 
['dnn_out'])
tf.train.write_graph(graph_def, '.', 'image_process.pb', as_text=False)

print("image_process.pb generated, please use \
path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n")

output = sess.run(y, feed_dict={x: in_data})
imageio.imsave("out.jpg", np.squeeze(output))

Signed-off-by: Guo, Yejun 

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

 libavfilter/dnn/dnn_backend_native_layer_mathbinary.c | 13 +
 libavfilter/dnn/dnn_backend_native_layer_mathbinary.h |  1 +
 tools/python/convert_from_tensorflow.py   | 11 +++
 tools/python/convert_header.py|  2 +-
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c 
b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
index c32a042788..edc389d3ba 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
@@ -150,6 +150,19 @@ int dnn_execute_layer_math_binary(DnnOperand *operands, 
const int32_t *input_ope
 }
 }
 return 0;
+case DMBO_MINIMUM:
+if (params->input0_broadcast || params->input1_broadcast) {
+for (int i = 0; i < dims_count; ++i) {
+dst[i] = FFMIN(params->v, src[i]);
+}
+} else {
+const DnnOperand *input1 = [input_operand_indexes[1]];
+const float *src1 = input1->data;
+for (int i = 0; i < dims_count; ++i) {
+dst[i] = FFMIN(src[i], src1[i]);
+}
+}
+return 0;
 default:
 return -1;
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h 
b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
index 2ffbb66eeb..f3dbbeb8c3 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
@@ -35,6 +35,7 @@ typedef enum {
 DMBO_ADD = 1,
 DMBO_MUL = 2,
 DMBO_REALDIV = 3,
+DMBO_MINIMUM = 4,
 DMBO_COUNT
 } DNNMathBinaryOperation;
 
diff --git a/tools/python/convert_from_tensorflow.py 
b/tools/python/convert_from_tensorflow.py
index a0fdad25b7..1c20891fcc 100644
--- a/tools/python/convert_from_tensorflow.py
+++ b/tools/python/convert_from_tensorflow.py
@@ -71,7 +71,7 @@ class TFConverter:
 self.conv2d_scope_names = set()
 self.conv2d_scopename_inputname_dict = {}
 self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 
'Maximum':4, 'MathBinary':5}
-self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3}
+self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 
'Minimum':4}
 self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2}
 self.name_operand_dict = {}
 
@@ -305,15 +305,10 @@ class TFConverter:
 self.dump_mirrorpad_to_file(node, f)
 elif node.op == 'Maximum':
 self.dump_maximum_to_file(node, f)
-elif node.op == 'Sub':
-self.dump_mathbinary_to_file(node, f)
-elif node.op == 'Add':
-self.dump_mathbinary_to_file(node, f)
-elif node.op == 'Mul':
-self.dump_mathbinary_to_file(node, f)
-elif node.op == 'RealDiv':
+elif node.op in self.mathbin2code:
 self.dump_mathbinary_to_file(node, f)
 
+
 def dump_operands_to_file(self, f):
 operands = sorted(self.name_operand_dict.values())
 for operand in operands:
diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py
index 75d1ce803c..e692a5e217 100644
--- a/tools/python/convert_header.py
+++ b/tools/python/convert_header.py
@@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE'
 major = 1
 
 # increase minor when we don't have to re-convert the model file
-minor = 4
+minor = 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".