[FFmpeg-cvslog] avfilter/f_interleave: add duration option

2020-04-25 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Apr 25 12:35:22 
2020 +0200| [b29b934e4fd3de69dc45a23bb779a22b2fecd194] | committer: Paul B Mahol

avfilter/f_interleave: add duration option

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

 doc/filters.texi   | 15 +++
 libavfilter/f_interleave.c | 43 +++
 2 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 80c33f5edb..71a6787289 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -23316,6 +23316,21 @@ These filters accept the following options:
 @table @option
 @item nb_inputs, n
 Set the number of different inputs, it is 2 by default.
+
+@item duration
+How to determine the end-of-stream.
+
+@table @option
+@item longest
+The duration of the longest input. (default)
+
+@item shortest
+The duration of the shortest input.
+
+@item first
+The duration of the first input.
+@end table
+
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_interleave.c b/libavfilter/f_interleave.c
index 06f4cda798..368ce6e678 100644
--- a/libavfilter/f_interleave.c
+++ b/libavfilter/f_interleave.c
@@ -37,15 +37,25 @@
 typedef struct InterleaveContext {
 const AVClass *class;
 int nb_inputs;
+int duration_mode;
 int64_t pts;
 } InterleaveContext;
 
+#define DURATION_LONGEST  0
+#define DURATION_SHORTEST 1
+#define DURATION_FIRST2
+
 #define OFFSET(x) offsetof(InterleaveContext, x)
 
 #define DEFINE_OPTIONS(filt_name, flags_)   \
 static const AVOption filt_name##_options[] = { \
{ "nb_inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, 
{.i64 = 2}, 1, INT_MAX, .flags = flags_ }, \
{ "n", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, 
{.i64 = 2}, 1, INT_MAX, .flags = flags_ }, \
+   { "duration", "how to determine the end-of-stream",  \
+   OFFSET(duration_mode), AV_OPT_TYPE_INT, { .i64 = DURATION_LONGEST }, 0, 
 2, flags_, "duration" }, \
+   { "longest",  "Duration of longest input",  0, AV_OPT_TYPE_CONST, { 
.i64 = DURATION_LONGEST  }, 0, 0, flags_, "duration" }, \
+   { "shortest", "Duration of shortest input", 0, AV_OPT_TYPE_CONST, { 
.i64 = DURATION_SHORTEST }, 0, 0, flags_, "duration" }, \
+   { "first","Duration of first input",0, AV_OPT_TYPE_CONST, { 
.i64 = DURATION_FIRST}, 0, 0, flags_, "duration" }, \
{ NULL } \
 }
 
@@ -54,21 +64,26 @@ static int activate(AVFilterContext *ctx)
 AVFilterLink *outlink = ctx->outputs[0];
 InterleaveContext *s = ctx->priv;
 int64_t q_pts, pts = INT64_MAX;
-int i, nb_eofs = 0, input_idx = -1;
+int i, nb_eofs = 0, input_idx = -1, nb_active_inputs = 0;
+int nb_inputs_with_frames = 0;
 
 FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
 
 for (i = 0; i < ctx->nb_inputs; i++) {
-if (!ff_outlink_get_status(ctx->inputs[i]) &&
-!ff_inlink_queued_frames(ctx->inputs[i]))
-break;
+if (!ff_outlink_get_status(ctx->inputs[i])) {
+nb_active_inputs++;
+if (!ff_inlink_queued_frames(ctx->inputs[i]))
+break;
+nb_inputs_with_frames++;
+}
 }
 
-if (i == ctx->nb_inputs) {
+if (nb_active_inputs > 0 && nb_active_inputs == nb_inputs_with_frames) {
 for (i = 0; i < ctx->nb_inputs; i++) {
 AVFrame *frame;
 
-if (ff_outlink_get_status(ctx->inputs[i]))
+if (ff_outlink_get_status(ctx->inputs[i]) ||
+ff_inlink_queued_frames(ctx->inputs[i]) == 0)
 continue;
 
 frame = ff_inlink_peek_frame(ctx->inputs[i], 0);
@@ -104,6 +119,16 @@ static int activate(AVFilterContext *ctx)
 }
 }
 
+for (i = 0; i < ctx->nb_inputs; i++)
+nb_eofs += !!ff_outlink_get_status(ctx->inputs[i]);
+
+if ((nb_eofs > 0 && s->duration_mode == DURATION_SHORTEST) ||
+(nb_eofs == ctx->nb_inputs && s->duration_mode == DURATION_LONGEST) ||
+(ff_outlink_get_status(ctx->inputs[0]) && s->duration_mode == 
DURATION_FIRST)) {
+ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
+return 0;
+}
+
 for (i = 0; i < ctx->nb_inputs; i++) {
 if (ff_inlink_queued_frames(ctx->inputs[i]))
 continue;
@@ -112,12 +137,6 @@ static int activate(AVFilterContext *ctx)
 ff_inlink_request_frame(ctx->inputs[i]);
 return 0;
 }
-nb_eofs++;
-}
-
-if (nb_eofs == ctx->nb_inputs) {
-ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
-return 0;
 }
 
 return FFERROR_NOT_READY;

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

To unsubscribe, visit link above, or ema

[FFmpeg-cvslog] avfilter/f_interleave: make sure that all frames in inlink queue are used

2020-04-25 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Apr 25 13:07:13 
2020 +0200| [ec3b5deab43b00c9ed50b512c7ef52dd9f0887c6] | committer: Paul B Mahol

avfilter/f_interleave: make sure that all frames in inlink queue are used

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

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

diff --git a/libavfilter/f_interleave.c b/libavfilter/f_interleave.c
index 368ce6e678..c231b307c1 100644
--- a/libavfilter/f_interleave.c
+++ b/libavfilter/f_interleave.c
@@ -64,26 +64,24 @@ static int activate(AVFilterContext *ctx)
 AVFilterLink *outlink = ctx->outputs[0];
 InterleaveContext *s = ctx->priv;
 int64_t q_pts, pts = INT64_MAX;
-int i, nb_eofs = 0, input_idx = -1, nb_active_inputs = 0;
+int i, nb_eofs = 0, input_idx = -1;
 int nb_inputs_with_frames = 0;
 
 FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
 
 for (i = 0; i < ctx->nb_inputs; i++) {
 if (!ff_outlink_get_status(ctx->inputs[i])) {
-nb_active_inputs++;
 if (!ff_inlink_queued_frames(ctx->inputs[i]))
 break;
 nb_inputs_with_frames++;
 }
 }
 
-if (nb_active_inputs > 0 && nb_active_inputs == nb_inputs_with_frames) {
+if (nb_inputs_with_frames > 0) {
 for (i = 0; i < ctx->nb_inputs; i++) {
 AVFrame *frame;
 
-if (ff_outlink_get_status(ctx->inputs[i]) ||
-ff_inlink_queued_frames(ctx->inputs[i]) == 0)
+if (ff_inlink_queued_frames(ctx->inputs[i]) == 0)
 continue;
 
 frame = ff_inlink_peek_frame(ctx->inputs[i], 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] avfilter/f_interleave: no need to check for inlink eof if non-empty queue

2020-04-25 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Apr 25 13:35:22 
2020 +0200| [35bcbfd6da59ecb5288a6a823be731b4db30b365] | committer: Paul B Mahol

avfilter/f_interleave: no need to check for inlink eof if non-empty queue

Also set state to ready if there is any inlink with queued frame.

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

 libavfilter/f_interleave.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavfilter/f_interleave.c b/libavfilter/f_interleave.c
index c231b307c1..a18bbe79b3 100644
--- a/libavfilter/f_interleave.c
+++ b/libavfilter/f_interleave.c
@@ -70,11 +70,9 @@ static int activate(AVFilterContext *ctx)
 FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
 
 for (i = 0; i < ctx->nb_inputs; i++) {
-if (!ff_outlink_get_status(ctx->inputs[i])) {
-if (!ff_inlink_queued_frames(ctx->inputs[i]))
-break;
-nb_inputs_with_frames++;
-}
+if (!ff_inlink_queued_frames(ctx->inputs[i]))
+continue;
+nb_inputs_with_frames++;
 }
 
 if (nb_inputs_with_frames > 0) {
@@ -137,6 +135,11 @@ static int activate(AVFilterContext *ctx)
 }
 }
 
+if (i) {
+ff_filter_set_ready(ctx, 100);
+return 0;
+}
+
 return FFERROR_NOT_READY;
 }
 

___
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: simplify the code

2020-04-25 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Sat Apr 18 
12:17:16 2020 +0800| [56b9130fff1ab71f166995bda7583a83e86d2467] | committer: 
Marton Balint

avcodec/bsf: simplify the code

Signed-off-by: Limin Wang 
Signed-off-by: Marton Balint 

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

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

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 68fee82e0d..d3a9db57f7 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -533,11 +533,7 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext 
**bsf_lst)
 goto end;
 }
 
-while (1) {
-bsf_str = av_strtok(buf, ",", &saveptr);
-if (!bsf_str)
-break;
-
+while (bsf_str = av_strtok(buf, ",", &saveptr)) {
 ret = bsf_parse_single(bsf_str, lst);
 if (ret < 0)
 goto end;

___
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/dirac_vlc: Fix integer overflow in ff_dirac_golomb_read_32/16bit()

2020-04-25 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Apr 24 22:55:55 2020 +0200| [cca0436efc4ea662087690f5d1b0834fd39b1559] | 
committer: Michael Niedermayer

avcodec/dirac_vlc: Fix integer overflow in ff_dirac_golomb_read_32/16bit()

Fixes: left shift of 1073741824 by 1 places cannot be represented in type 
'int32_t' (aka 'int')
Fixes: 
21245/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5683334274613248

Change to int16_t suggested by Lynne

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

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

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

diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c
index fbe28017bc..2e2fa7ea63 100644
--- a/libavcodec/dirac_vlc.c
+++ b/libavcodec/dirac_vlc.c
@@ -1095,7 +1095,7 @@ int ff_dirac_golomb_read_16bit(const uint8_t *buf, int 
bytes,
 {
 LUTState lut = ff_dirac_golomb_lut[*buf++];
 int16_t *dst = (int16_t *)_dst, *last = dst + coeffs;
-int16_t val = 0;
+uint16_t val = 0;
 
 for (int i = 1; i < bytes; i++)
 PROCESS_VALS;
@@ -1115,7 +1115,7 @@ int ff_dirac_golomb_read_32bit(const uint8_t *buf, int 
bytes,
 {
 LUTState lut = ff_dirac_golomb_lut[*buf++];
 int32_t *dst = (int32_t *)_dst, *last = dst + coeffs;
-int32_t val = 0;
+uint32_t val = 0;
 
 for (int i = 1; i < bytes; i++)
 PROCESS_VALS;

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