[FFmpeg-cvslog] Update for FFmpeg 3.4.10

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Wed Apr 13 23:41:11 2022 +0200| [148314955b9cedc9ad229f03b0ac8ddc43904925] | 
committer: Michael Niedermayer

Update for FFmpeg 3.4.10

Signed-off-by: Michael Niedermayer 

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

 Changelog| 55 +++
 RELEASE  |  2 +-
 doc/Doxyfile |  2 +-
 3 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index aaab81f211..3ffaac29c7 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,61 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version 3.4.10:
+ avfilter/vf_lenscorrection: make width/height int
+ avcodec/diracdec: avoid signed integer overflow in global mv
+ avcodec/takdsp: Fix integer overflow in decorrelate_sf()
+ avcodec/apedec: fix a integer overflow in long_filter_high_3800()
+ avfilter/vf_subtitles: pass storage size to libass
+ avformat/aqtitledec: Skip unrepresentable durations
+ avformat/cafdec: Do not store empty keys in read_info_chunk()
+ avformat/hls: Check target_duration
+ avcodec/pixlet: Avoid signed integer overflow in scaling in filterfn()
+ avformat/matroskadec: Check pre_ns
+ avcodec/sonic: Use unsigned for predictor_k to avoid undefined behavior
+ avformat/matroskadec: Use rounded down duration in get_cue_desc() check
+ avformat/avidec: Check height
+ avformat/rmdec: Better duplicate tags check
+ avformat/mov: Disallow empty sidx
+ avformat/matroskadec: Check duration
+ avcodec/jpeglsdec: Fix if( code style
+ avcodec/jpeglsdec: Check get_ur_golomb_jpegls() for error
+ avcodec/motion_est: fix indention of ff_get_best_fcode()
+ avcodec/motion_est: Fix xy indexing on range violation in ff_get_best_fcode()
+ avcodec/jpeglsdec: Increase range for N in ls_get_code_runterm() by using 
unsigned
+ avformat/matroskadec: Check desc_bytes
+ avformat/utils: Fix invalid NULL pointer operation in ff_parse_key_value()
+ avformat/matroskadec: Fix infinite loop with bz decompression
+ avformat/mov: Check size before subtraction
+ avcodec/apedec: Fix integer overflows in predictor_update_3930()
+ avcodec/apedec: fix integer overflow in 8bit samples
+ avformat/flvdec: timestamps cannot use the full int64 range
+ avcodec/vqavideo: reset accounting on error
+ avcodec/alacdsp: fix integer overflow in decorrelate_stereo()
+ avformat/4xm: Check for duplicate track ids
+ avformat/4xm: Consider max_streams on reallocating tracks array
+ avformat/mov: Check next offset in mov_read_dref()
+ avformat/mxfdec: Check for duplicate mxf_read_index_entry_array()
+ avcodec/apedec: Change avg to uint32_t
+ avformat/mov: Disallow duplicate smdm
+ avformat/mov: Check for EOF in mov_read_glbl()
+ avformat/mov: Check channels for mov_parse_stsd_audio()
+ avformat/avidec: Check read_odml_index() for failure
+ avformat/aiffdec: Use av_rescale() for bitrate
+ avformat/aiffdec: sanity check block_align
+ avformat/aiffdec: Check sample_rate
+ avfilter/vf_gblur: fix heap-buffer overflow
+ avfilter/vf_lenscorrection: fix division by zero
+ avformat/latmenc: abort if no extradata is available
+ avcodec/g729dec: Avoid computing invalid temporary pointers for 
ff_acelp_weighted_vector_sum()
+ avformat/movenc: Fix segfault when remuxing rtp hint stream
+ avformat/tty: add probe function
+ avcodec/flac_parser: Consider AV_INPUT_BUFFER_PADDING_SIZE
+ avcodec/ttadsp: Fix integer overflows in tta_filter_process_c()
+ avutil/mathematics: Document av_rescale_rnd() behavior on non int64 results
+ configure: Add missing libshine->mpegaudioheader dependency
+
+
 version 3.4.9:
  avformat/wavdec: Check smv_block_size
  avformat/rmdec: Check for multiple audio_stream_info
diff --git a/RELEASE b/RELEASE
index 7bcbb3808b..84d6c67654 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1 +1 @@
-3.4.9
+3.4.10
diff --git a/doc/Doxyfile b/doc/Doxyfile
index 2a3ef445ae..b3823eac11 100644
--- a/doc/Doxyfile
+++ b/doc/Doxyfile
@@ -38,7 +38,7 @@ PROJECT_NAME   = FFmpeg
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER = 3.4.9
+PROJECT_NUMBER = 3.4.10
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer a

___
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/vf_lenscorrection: make width/height int

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: release/3.4 | Paul B Mahol  | Mon Oct 14 
20:14:03 2019 +0200| [07cb2c8863b1bf9ec697641eda3829776c7191ba] | committer: 
Michael Niedermayer

avfilter/vf_lenscorrection: make width/height int

Somehow previous correct fix broke usage.

(cherry picked from commit 79522411fa53b68743302d16d28156db95466a21)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c
index 43f3c1b7d0..754b8f5ada 100644
--- a/libavfilter/vf_lenscorrection.c
+++ b/libavfilter/vf_lenscorrection.c
@@ -36,8 +36,8 @@
 
 typedef struct LenscorrectionCtx {
 const AVClass *av_class;
-unsigned int width;
-unsigned int height;
+int width;
+int height;
 int hsub, vsub;
 int nb_planes;
 double cx, cy, k1, k2;

___
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/diracdec: avoid signed integer overflow in global mv

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Mon Mar 21 20:51:47 2022 +0100| [73c593b0ce70faa79e2bd1527362b6d08bec4a9e] | 
committer: Michael Niedermayer

avcodec/diracdec: avoid signed integer overflow in global mv

Fixes: signed integer overflow: -128275513086 * -76056576 cannot be represented 
in type 'long'
Fixes: 
45818/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5129799149944832

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 7f1279684e8e1e33c78577b7f0265c062e4e6232)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 69828c4589..112d7ecfd5 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -1411,8 +1411,8 @@ static void global_mv(DiracContext *s, DiracBlock *block, 
int x, int y, int ref)
 int *c  = s->globalmc[ref].perspective;
 
 int64_t m   = (1> (ez+ep);
 block->u.mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep);

___
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/takdsp: Fix integer overflow in decorrelate_sf()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Mon Mar 28 00:26:06 2022 +0200| [8ed50e18388f3d5470d4a89d99a17439245b3173] | 
committer: Michael Niedermayer

avcodec/takdsp: Fix integer overflow in decorrelate_sf()

Fixes: signed integer overflow: -101 * 71041254 cannot be represented in type 
'int'
Fixes: 
45938/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-4687974320701440

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 01d8c887f63bcb1f870034ed441504b3daffc645)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/takdsp.c b/libavcodec/takdsp.c
index 9cb8052596..a8f9dba342 100644
--- a/libavcodec/takdsp.c
+++ b/libavcodec/takdsp.c
@@ -65,7 +65,7 @@ static void decorrelate_sf(int32_t *p1, int32_t *p2, int 
length, int dshift, int
 for (i = 0; i < length; i++) {
 int32_t a = p1[i];
 int32_t b = p2[i];
-b = (unsigned)(dfactor * (b >> dshift) + 128 >> 8) << dshift;
+b = (unsigned)((int)(dfactor * (unsigned)(b >> dshift) + 128) 
>> 8) << dshift;
 p1[i] = b - a;
 }
 }

___
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/apedec: fix a integer overflow in long_filter_high_3800()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Mon Mar 28 00:12:17 2022 +0200| [7ea021e7bf974256e5b215e3a328855db9d41b5f] | 
committer: Michael Niedermayer

avcodec/apedec: fix a integer overflow in long_filter_high_3800()

Fixes: signed integer overflow: -2146549696 - 3923884 cannot be represented in 
type 'int'
Fixes: 
45907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5992380584558592

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit b085b400becb93ccc68d786ab738b1fc50408b89)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 87d704e600..035fa9a434 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -905,7 +905,7 @@ static void long_filter_high_3800(int32_t *buffer, int 
order, int shift, int len
 dotprod += delay[j] * (unsigned)coeffs[j];
 coeffs[j] += ((delay[j] >> 31) | 1) * sign;
 }
-buffer[i] -= dotprod >> shift;
+buffer[i] -= (unsigned)(dotprod >> shift);
 for (j = 0; j < order - 1; j++)
 delay[j] = delay[j + 1];
 delay[order - 1] = buffer[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] avfilter/vf_subtitles: pass storage size to libass

2022-04-13 Thread Oneric
ffmpeg | branch: release/3.4 | Oneric  | Wed Mar 23 20:43:54 
2022 +0100| [1c73b96c21a2484f144648996578e325cc1bc62e] | committer: Michael 
Niedermayer

avfilter/vf_subtitles: pass storage size to libass

Due to a quirk of the ASS format some tags depend on the exact storage
resolution of the video, so tell libass via ass_set_storage_size.

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

 libavfilter/vf_subtitles.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index 66a564699a..39c40bf458 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -145,9 +145,16 @@ static int config_input(AVFilterLink *inlink)
 ff_draw_init(>draw, inlink->format, ass->alpha ? 
FF_DRAW_PROCESS_ALPHA : 0);
 
 ass_set_frame_size  (ass->renderer, inlink->w, inlink->h);
-if (ass->original_w && ass->original_h)
+if (ass->original_w && ass->original_h) {
 ass_set_aspect_ratio(ass->renderer, (double)inlink->w / inlink->h,
  (double)ass->original_w / ass->original_h);
+#if LIBASS_VERSION > 0x0101
+ass_set_storage_size(ass->renderer, ass->original_w, ass->original_h);
+} else {
+ass_set_storage_size(ass->renderer, inlink->w, inlink->h);
+#endif
+}
+
 if (ass->shaping != -1)
 ass_set_shaper(ass->renderer, ass->shaping);
 

___
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/aqtitledec: Skip unrepresentable durations

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Mar 20 00:07:50 2022 +0100| [86c204addfa0369d45322b9f8392ef3387cf82ee] | 
committer: Michael Niedermayer

avformat/aqtitledec: Skip unrepresentable durations

Fixes: signed integer overflow: -5 - 9223372036854775807 cannot be represented 
in type 'long'
Fixes: 
45665/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-475618463934054

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit c2d1597a8a6470045a8da241d4f65c81f26c3107)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/aqtitledec.c b/libavformat/aqtitledec.c
index 317547c4f4..01b4fd7b93 100644
--- a/libavformat/aqtitledec.c
+++ b/libavformat/aqtitledec.c
@@ -74,7 +74,8 @@ static int aqt_read_header(AVFormatContext *s)
 new_event = 1;
 pos = avio_tell(s->pb);
 if (sub) {
-sub->duration = frame - sub->pts;
+if (frame >= sub->pts && (uint64_t)frame - sub->pts < 
INT64_MAX)
+sub->duration = frame - sub->pts;
 sub = NULL;
 }
 } else if (*line) {

___
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/cafdec: Do not store empty keys in read_info_chunk()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sat Mar 19 23:36:22 2022 +0100| [adcacd0d744795b14a90b72ce5b9ba820b5074d1] | 
committer: Michael Niedermayer

avformat/cafdec: Do not store empty keys in read_info_chunk()

Fixes: Timeout
Fixes: 
45543/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5684953164152832

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 7ec28e1d4cef723485f50f7a08859752b79b570c)
Signed-off-by: Michael Niedermayer 

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

 libavformat/cafdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 4817b90b0b..b9e70ea2fb 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -243,6 +243,8 @@ static void read_info_chunk(AVFormatContext *s, int64_t 
size)
 char value[1024];
 avio_get_str(pb, INT_MAX, key, sizeof(key));
 avio_get_str(pb, INT_MAX, value, sizeof(value));
+if (!*key)
+continue;
 av_dict_set(>metadata, key, value, 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] avformat/hls: Check target_duration

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Mar 20 22:54:31 2022 +0100| [ea391e65ef771e5516a9244f52396e48d3eb4531] | 
committer: Michael Niedermayer

avformat/hls: Check target_duration

Fixes: signed integer overflow: 77 * 100 cannot be represented 
in type 'long long'
Fixes: 
45545/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-6438101247983616

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Steven Liu 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit a8fd3f7fab83e1beea1c441e1a2e538e7aa431a5)
Signed-off-by: Michael Niedermayer 

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

 libavformat/hls.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 332d10f2ee..73a5d22b39 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -750,10 +750,16 @@ static int parse_playlist(HLSContext *c, const char *url,
);
 new_rendition(c, , url);
 } else if (av_strstart(line, "#EXT-X-TARGETDURATION:", )) {
+int64_t t;
 ret = ensure_playlist(c, , url);
 if (ret < 0)
 goto fail;
-pls->target_duration = strtoll(ptr, NULL, 10) * AV_TIME_BASE;
+t = strtoll(ptr, NULL, 10);
+if (t < 0 || t >= INT64_MAX / AV_TIME_BASE) {
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
+pls->target_duration = t * AV_TIME_BASE;
 } else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", )) {
 ret = ensure_playlist(c, , url);
 if (ret < 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/pixlet: Avoid signed integer overflow in scaling in filterfn()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Mon Oct 26 21:30:19 2020 +0100| [14eea4ade4cc02074ca22e13979ea8234dba6332] | 
committer: Michael Niedermayer

avcodec/pixlet: Avoid signed integer overflow in scaling in filterfn()

Fixes: signed integer overflow: 11494 * 107374182400 cannot be represented 
in type 'long'
Fixes: 
26586/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PIXLET_fuzzer-5752633970917376

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 0c1f20c6c858b753effda274b58ef635d1924915)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
index aa7ef55b7d..611a5cd200 100644
--- a/libavcodec/pixlet.c
+++ b/libavcodec/pixlet.c
@@ -396,7 +396,7 @@ static void filterfn(int16_t *dest, int16_t *tmp, unsigned 
size, int64_t scale)
 (int64_t) low [i - 1] * -INT64_C(325392907)  +
 (int64_t) high[i + 0] *  INT64_C(1518500249) +
 (int64_t) high[i - 1] *  INT64_C(1518500249);
-dest[i * 2] = av_clip_int16(((value >> 32) * scale) >> 32);
+dest[i * 2] = av_clip_int16(((value >> 32) * (uint64_t)scale) >> 32);
 }
 
 for (i = 0; i < hsize; i++) {
@@ -407,7 +407,7 @@ static void filterfn(int16_t *dest, int16_t *tmp, unsigned 
size, int64_t scale)
 (int64_t) high[i + 1] *  INT64_C(303700064)  +
 (int64_t) high[i + 0] * -INT64_C(3644400640) +
 (int64_t) high[i - 1] *  INT64_C(303700064);
-dest[i * 2 + 1] = av_clip_int16(((value >> 32) * scale) >> 32);
+dest[i * 2 + 1] = av_clip_int16(((value >> 32) * (uint64_t)scale) >> 
32);
 }
 }
 

___
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: Check pre_ns

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Feb 13 15:20:02 2022 +0100| [92521686ce4b0c607d5d8a57a2f7dadfc08f40f5] | 
committer: Michael Niedermayer

avformat/matroskadec: Check pre_ns

Fixes: division by 0
Fixes: 
44615/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6681108677263360

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 710e51677a6f3a5c2b37dc31a597957a22a5e531)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 37f6d55e75..5def4e311a 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3811,6 +3811,8 @@ static int64_t 
webm_dash_manifest_compute_bandwidth(AVFormatContext *s, int64_t
 // prebuffered.
 pre_bytes = desc_end.end_offset - desc_end.start_offset;
 pre_ns = desc_end.end_time_ns - desc_end.start_time_ns;
+if (pre_ns <= 0)
+return -1;
 pre_sec = pre_ns / nano_seconds_per_second;
 prebuffer_bytes +=
 pre_bytes * ((temp_prebuffer_ns / nano_seconds_per_second) / 
pre_sec);

___
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/rmdec: Better duplicate tags check

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Thu Feb 24 00:26:08 2022 +0100| [680f821af320cb5955f0acbfea43d9a1350bccea] | 
committer: Michael Niedermayer

avformat/rmdec: Better duplicate tags check

Fixes: memleaks
Fixes: 
44810/clusterfuzz-testcase-minimized-ffmpeg_dem_IVR_fuzzer-5619494647627776

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 15a646e5018078a0954918f510f819a5599f0445)
Signed-off-by: Michael Niedermayer 

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

 libavformat/rmdec.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 031590b109..42f76491e2 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -131,10 +131,6 @@ static int rm_read_audio_stream_info(AVFormatContext *s, 
AVIOContext *pb,
 uint32_t version;
 int ret;
 
-// Duplicate tags
-if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
-return AVERROR_INVALIDDATA;
-
 /* ra type header */
 version = avio_rb16(pb); /* version */
 if (version == 3) {
@@ -334,6 +330,11 @@ int ff_rm_read_mdpr_codecdata(AVFormatContext *s, 
AVIOContext *pb,
 if (codec_data_size == 0)
 return 0;
 
+// Duplicate tags
+if (   st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN
+&& st->codecpar->codec_type != AVMEDIA_TYPE_DATA)
+return AVERROR_INVALIDDATA;
+
 avpriv_set_pts_info(st, 64, 1, 1000);
 codec_pos = avio_tell(pb);
 v = avio_rb32(pb);

___
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: Use unsigned for predictor_k to avoid undefined behavior

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Tue Feb  8 00:43:56 2022 +0100| [4b298c87213a481777e9512cc8a16c2b27670655] | 
committer: Michael Niedermayer

avcodec/sonic: Use unsigned for predictor_k to avoid undefined behavior

Fixes: signed integer overflow: -1094995529 * 24 cannot be represented in type 
'int'
Fixes: 
44436/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-4874459459223552

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 28008bf95ed9b2ab5945ae6658358ad7c7f1df35)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index 9498919d2f..d902beb501 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -1018,7 +1018,7 @@ static int sonic_decode_frame(AVCodecContext *avctx,
 
 // dequantize
 for (i = 0; i < s->num_taps; i++)
-s->predictor_k[i] *= s->tap_quant[i];
+s->predictor_k[i] *= (unsigned) s->tap_quant[i];
 
 if (s->lossless)
 quant = 1;

___
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: Use rounded down duration in get_cue_desc() check

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Thu Mar 10 23:24:49 2022 +0100| [4e305299d993868490fb25ebffcc34ea6549a3ef] | 
committer: Michael Niedermayer

avformat/matroskadec: Use rounded down duration in get_cue_desc() check

Floating point is evil, it would be better if duration was not a double

Fixes: Infinite loop
Fixes: 
45123/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6725052291219456

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit bd3a03db9aef72ee36a7cc964171e9f52967f4bc)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 8eb382744f..37f6d55e75 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3627,7 +3627,9 @@ static CueDesc get_cue_desc(AVFormatContext *s, int64_t 
ts, int64_t cues_start)
 int i;
 int nb_index_entries = s->streams[0]->nb_index_entries;
 AVIndexEntry *index_entries = s->streams[0]->index_entries;
-if (ts >= matroska->duration * matroska->time_scale) return (CueDesc) {-1, 
-1, -1, -1};
+
+if (ts >= (int64_t)(matroska->duration * matroska->time_scale))
+return (CueDesc) {-1, -1, -1, -1};
 for (i = 1; i < nb_index_entries; i++) {
 if (index_entries[i - 1].timestamp * matroska->time_scale <= ts &&
 index_entries[i].timestamp * matroska->time_scale > ts) {

___
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/mov: Disallow empty sidx

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Wed Mar  2 13:01:53 2022 +0100| [b70429e33c7c33eda2f0cbcf8d9fa0752bcd3c22] | 
committer: Michael Niedermayer

avformat/mov: Disallow empty sidx

It appears this is not allowed "Each Segment Index box documents how a 
(sub)segment is divided into one or more subsegments
(which may themselves be further subdivided using Segment Index boxes)."
Fixes: Null pointer dereference
Fixes: Ticket9517

Reviewed-by: Paul B Mahol 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 4419433d77278cb742944c4514be5f72a04103c0)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 78ec7e8f45..5bbc54493e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4586,7 +4586,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 index->track_id = track_id;
 
 index->item_count = avio_rb16(pb);
-index->items = av_mallocz_array(index->item_count, 
sizeof(MOVFragmentIndexItem));
+index->items = index->item_count ? av_mallocz_array(index->item_count, 
sizeof(MOVFragmentIndexItem)) : NULL;
 
 if (!index->items) {
 av_freep();

___
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/avidec: Check height

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Feb 27 21:44:29 2022 +0100| [b545c250783bcc82f07372a6808d9745615d9b1a] | 
committer: Michael Niedermayer

avformat/avidec: Check height

Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an 
unsigned type to negate this value to itself
Fixes: Ticket8486

Signed-off-by: Michael Niedermayer 
(cherry picked from commit ec8ff659f57786c4cb089b07dfeab7e5cbab8d52)
Signed-off-by: Michael Niedermayer 

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

 libavformat/avidec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 0cb97dec3d..b9b0e6bb6c 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -843,6 +843,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 memcpy(st->codecpar->extradata + 
st->codecpar->extradata_size - 9,
"BottomUp", 9);
 }
+if (st->codecpar->height == INT_MIN)
+return AVERROR_INVALIDDATA;
 st->codecpar->height = FFABS(st->codecpar->height);
 
 //avio_skip(pb, size - 5 * 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] avformat/matroskadec: Check duration

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Mon Feb 14 20:01:35 2022 +0100| [77f3f2aaf9bbd58aad74b373ce2ace57fd9c18a8] | 
committer: Michael Niedermayer

avformat/matroskadec: Check duration

Fixes: -nan is outside the range of representable values of type 'long'
Fixes: 
44614/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6216204841254912

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 36680078ca3302496d9b0b8a8d7168ce9eabb2bc)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 36674195a1..8eb382744f 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2628,6 +2628,8 @@ static int matroska_read_header(AVFormatContext *s)
 
 if (!matroska->time_scale)
 matroska->time_scale = 100;
+if (isnan(matroska->duration))
+matroska->duration = 0;
 if (matroska->duration)
 matroska->ctx->duration = matroska->duration * matroska->time_scale *
   1000 / AV_TIME_BASE;

___
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/jpeglsdec: Fix if( code style

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Tue Feb 15 21:01:06 2022 +0100| [83d5b57074f55c838231d2f499042ddcb1423b30] | 
committer: Michael Niedermayer

avcodec/jpeglsdec: Fix if( code style

Signed-off-by: Michael Niedermayer 
(cherry picked from commit f306b8e80ab04cfd8f6cd577a4484cb791d6e765)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index 11b2ff71a8..615c9e5068 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -67,7 +67,7 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s)
 s->t3 = get_bits(>gb, 16);
 s->reset  = get_bits(>gb, 16);
 
-if(s->avctx->debug & FF_DEBUG_PICT_INFO) {
+if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
 av_log(s->avctx, AV_LOG_DEBUG, "Coding parameters maxval:%d T1:%d 
T2:%d T3:%d reset:%d\n",
s->maxval, s->t1, s->t2, s->t3, s->reset);
 }
@@ -96,7 +96,7 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s)
 else
 maxtab = 65530/wt - 1;
 
-if(s->avctx->debug & FF_DEBUG_PICT_INFO) {
+if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
 av_log(s->avctx, AV_LOG_DEBUG, "LSE palette %d tid:%d wt:%d 
maxtab:%d\n", id, tid, wt, maxtab);
 }
 if (maxtab >= 256) {
@@ -211,7 +211,7 @@ static inline int ls_get_code_runterm(GetBitContext *gb, 
JLSState *state,
 ret = ret >> 1;
 }
 
-if(FFABS(ret) > 0x)
+if (FFABS(ret) > 0x)
 return -0x1;
 /* update state */
 state->A[Q] += FFABS(ret) - RItype;

___
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/jpeglsdec: Check get_ur_golomb_jpegls() for error

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sat Feb 12 22:02:13 2022 +0100| [fa91d68bf4716b9b20c5fc8b5fe14e6f7d2fd3b5] | 
committer: Michael Niedermayer

avcodec/jpeglsdec: Check get_ur_golomb_jpegls() for error

Fixes: Timeout
Fixes: Invalid shift
Fixes: 
44548/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-556487680891289
Fixes: 
44569/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_fuzzer-6302543246917632
Fixes: 
44570/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-4550196556595200
Fixes: 
44592/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-5651610385121280
Fixes: 
44571/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5094698987945984
Fixes: 
44607/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5341352013987840

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 151f83584eeb1912c8bdcd0c1ab1296e8664a0de)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index 0cb40cc0f1..11b2ff71a8 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -195,6 +195,8 @@ static inline int ls_get_code_runterm(GetBitContext *gb, 
JLSState *state,
 #endif
 ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1,
state->qbpp);
+if (ret < 0)
+return -0x1;
 
 /* decode mapped error */
 map = 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/motion_est: fix indention of ff_get_best_fcode()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Wed Feb  9 10:31:34 2022 +0100| [00f9a2bfd5fc59cbb2aab99a3a8c6572b7e85b81] | 
committer: Michael Niedermayer

avcodec/motion_est: fix indention of ff_get_best_fcode()

Signed-off-by: Michael Niedermayer 
(cherry picked from commit ce43e1c581b4ed539ab366cc3df458779e8a44b8)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 310925c2da..ec3b6cfbba 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -1642,9 +1642,9 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t 
(*mv_table)[2], int type)
  fcode_tab[my + MAX_MV]);
 int j;
 
-if(mx >= range || mx < -range ||
-   my >= range || my < -range)
-continue;
+if (mx >= range || mx < -range ||
+my >= range || my < -range)
+continue;
 
 for(j=0; jpict_type==AV_PICTURE_TYPE_B || 
s->current_picture.mc_mb_var[xy] < s->current_picture.mb_var[xy])

___
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/motion_est: Fix xy indexing on range violation in ff_get_best_fcode()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Tue Feb  8 21:38:50 2022 +0100| [5ead85030294e18131dc1f675ea7547babf50b8f] | 
committer: Michael Niedermayer

avcodec/motion_est: Fix xy indexing on range violation in ff_get_best_fcode()

This codepath seems untested, no testcases change

Found-by: 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 634312a70f4d5afd40058c52b4d8eade1da07a70)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 316d16a77b..310925c2da 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -1634,7 +1634,7 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t 
(*mv_table)[2], int type)
 for(y=0; ymb_height; y++){
 int x;
 int xy= y*s->mb_stride;
-for(x=0; xmb_width; x++){
+for(x=0; xmb_width; x++, xy++){
 if(s->mb_type[xy] & type){
 int mx= mv_table[xy][0];
 int my= mv_table[xy][1];
@@ -1651,7 +1651,6 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t 
(*mv_table)[2], int type)
 score[j]-= 170;
 }
 }
-xy++;
 }
 }
 

___
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/jpeglsdec: Increase range for N in ls_get_code_runterm() by using unsigned

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sat Feb  5 20:41:08 2022 +0100| [07b7a4be0ad847e4a05a31ba85092ceaec4faccf] | 
committer: Michael Niedermayer

avcodec/jpeglsdec: Increase range for N in ls_get_code_runterm() by using 
unsigned

Fixes: left shift of 32768 by 16 places cannot be represented in type 'int'
Fixes: Timeout
Fixes: 
44219/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-4679455379947520
Fixes: 
44088/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-4885976600674304

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 6ee283d7d001cfcfec94a023e172bca731e96514)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index a8d9eaa18a..0cb40cc0f1 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -186,7 +186,7 @@ static inline int ls_get_code_runterm(GetBitContext *gb, 
JLSState *state,
 if (RItype)
 temp += state->N[Q] >> 1;
 
-for (k = 0; (state->N[Q] << k) < temp; k++)
+for (k = 0; ((unsigned)state->N[Q] << k) < temp; k++)
 ;
 
 #ifdef JLS_BROKEN

___
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: Check desc_bytes

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sat Feb  5 20:37:22 2022 +0100| [79d52d06683c46a0343bb6220433e0c7480744d6] | 
committer: Michael Niedermayer

avformat/matroskadec: Check desc_bytes

Fixes: Division by 0
Fixes: 
44035/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-4826721386364928

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 5038933977d06d1048b41d71e0ada4d1ac536ddc)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 8dae8e7cb6..36674195a1 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3818,12 +3818,16 @@ static int64_t 
webm_dash_manifest_compute_bandwidth(AVFormatContext *s, int64_t
 do {
 int64_t desc_bytes = desc_end.end_offset - 
desc_beg.start_offset;
 int64_t desc_ns = desc_end.end_time_ns - 
desc_beg.start_time_ns;
-double desc_sec = desc_ns / nano_seconds_per_second;
-double calc_bits_per_second = (desc_bytes * 8) / desc_sec;
+double desc_sec, calc_bits_per_second, percent, 
mod_bits_per_second;
+if (desc_bytes <= 0)
+return -1;
+
+desc_sec = desc_ns / nano_seconds_per_second;
+calc_bits_per_second = (desc_bytes * 8) / desc_sec;
 
 // Drop the bps by the percentage of bytes buffered.
-double percent = (desc_bytes - prebuffer_bytes) / desc_bytes;
-double mod_bits_per_second = calc_bits_per_second * percent;
+percent = (desc_bytes - prebuffer_bytes) / desc_bytes;
+mod_bits_per_second = calc_bits_per_second * percent;
 
 if (prebuffer < desc_sec) {
 double search_sec =

___
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/utils: Fix invalid NULL pointer operation in ff_parse_key_value()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Fri Feb  4 00:44:32 2022 +0100| [9eca5d77c4678da416212e78b8456faaf9df529d] | 
committer: Michael Niedermayer

avformat/utils: Fix invalid NULL pointer operation in ff_parse_key_value()

Fixes: pointer index expression with base 0x overflowed to 
0x
Fixes: 
44012/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5670607746891776

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 59328aabd2c789ae053e18a62a20a7addfd4d069)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/utils.c b/libavformat/utils.c
index cc5a06b127..cc1e574ddd 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4808,7 +4808,7 @@ void ff_parse_key_value(const char *str, 
ff_parse_key_val_cb callback_get_buf,
 key_len = ptr - key;
 
 callback_get_buf(context, key, key_len, , _len);
-dest_end = dest + dest_len - 1;
+dest_end = dest ? dest + dest_len - 1 : NULL;
 
 if (*ptr == '\"') {
 ptr++;

___
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: Fix infinite loop with bz decompression

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Thu Feb  3 22:46:55 2022 +0100| [0027251644310779f63e7edf7957f52d1a026460] | 
committer: Michael Niedermayer

avformat/matroskadec: Fix infinite loop with bz decompression

The same check is added to zlib too, it seems not needed there though

Fixes: Infinite loop
Fixes: 
43932/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-6175167573786624

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 9c3d2cbb510674226b0c8fa6b146bf891f83786c)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 20a16664c3..8dae8e7cb6 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1393,7 +1393,7 @@ static int matroska_decode_buffer(uint8_t **buf, int 
*buf_size,
 case MATROSKA_TRACK_ENCODING_COMP_ZLIB:
 {
 z_stream zstream = { 0 };
-if (inflateInit() != Z_OK)
+if (!pkt_size || inflateInit() != Z_OK)
 return -1;
 zstream.next_in  = data;
 zstream.avail_in = isize;
@@ -1426,7 +1426,7 @@ static int matroska_decode_buffer(uint8_t **buf, int 
*buf_size,
 case MATROSKA_TRACK_ENCODING_COMP_BZLIB:
 {
 bz_stream bzstream = { 0 };
-if (BZ2_bzDecompressInit(, 0, 0) != BZ_OK)
+if (!pkt_size || BZ2_bzDecompressInit(, 0, 0) != BZ_OK)
 return -1;
 bzstream.next_in  = data;
 bzstream.avail_in = isize;

___
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/mov: Check size before subtraction

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Mon Jan 17 14:26:05 2022 +0100| [e42732b91f93b694d874cf37a49b9635b250afce] | 
committer: Michael Niedermayer

avformat/mov: Check size before subtraction

Fixes: signed integer overflow: -9223372036854775808 - 8 cannot be represented 
in type 'long'
Fixes: 
43542/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5237670148702208

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit d8d9d506a3de976b647bcbb8f76c7b8d30eff576)
Signed-off-by: Michael Niedermayer 

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

 libavformat/mov.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 468e4094b9..78ec7e8f45 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5768,6 +5768,8 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 if (a.size == 0) {
 a.size = atom.size - total_size + 8;
 }
+if (a.size < 0)
+break;
 a.size -= 8;
 if (a.size < 0)
 break;

___
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/apedec: Fix integer overflows in predictor_update_3930()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Mon Jan  3 19:15:18 2022 +0100| [a33ae752259c35a56c0c70ae70077b04bc0b0f75] | 
committer: Michael Niedermayer

avcodec/apedec: Fix integer overflows in predictor_update_3930()

Fixes: signed integer overflow: 1074134419 - -1075212485 cannot be represented 
in type 'int'
Fixes: 
43273/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-4706880883130368

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 0c9c9bbd01bd82c35b6a908592d9dd6d9f4bd4a0)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 8a54c750b5..87d704e600 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1038,13 +1038,13 @@ static av_always_inline int 
predictor_update_3930(APEPredictor *p,
   const int delayA)
 {
 int32_t predictionA, sign;
-int32_t d0, d1, d2, d3;
+uint32_t d0, d1, d2, d3;
 
 p->buf[delayA] = p->lastA[filter];
 d0 = p->buf[delayA];
-d1 = p->buf[delayA] - p->buf[delayA - 1];
-d2 = p->buf[delayA - 1] - p->buf[delayA - 2];
-d3 = p->buf[delayA - 2] - p->buf[delayA - 3];
+d1 = p->buf[delayA] - (unsigned)p->buf[delayA - 1];
+d2 = p->buf[delayA - 1] - (unsigned)p->buf[delayA - 2];
+d3 = p->buf[delayA - 2] - (unsigned)p->buf[delayA - 3];
 
 predictionA = d0 * p->coeffsA[filter][0] +
   d1 * p->coeffsA[filter][1] +
@@ -1055,10 +1055,10 @@ static av_always_inline int 
predictor_update_3930(APEPredictor *p,
 p->filterA[filter] = p->lastA[filter] + ((int)(p->filterA[filter] * 31U) 
>> 5);
 
 sign = APESIGN(decoded);
-p->coeffsA[filter][0] += ((d0 < 0) * 2 - 1) * sign;
-p->coeffsA[filter][1] += ((d1 < 0) * 2 - 1) * sign;
-p->coeffsA[filter][2] += ((d2 < 0) * 2 - 1) * sign;
-p->coeffsA[filter][3] += ((d3 < 0) * 2 - 1) * sign;
+p->coeffsA[filter][0] += (((int32_t)d0 < 0) * 2 - 1) * sign;
+p->coeffsA[filter][1] += (((int32_t)d1 < 0) * 2 - 1) * sign;
+p->coeffsA[filter][2] += (((int32_t)d2 < 0) * 2 - 1) * sign;
+p->coeffsA[filter][3] += (((int32_t)d3 < 0) * 2 - 1) * sign;
 
 return p->filterA[filter];
 }

___
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/apedec: fix integer overflow in 8bit samples

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Thu Dec 23 20:39:14 2021 +0100| [0190d175c6f6301458daadd1aae6c9ae83678ec7] | 
committer: Michael Niedermayer

avcodec/apedec: fix integer overflow in 8bit samples

Fixes: signed integer overflow: 2147483542 + 128 cannot be represented in type 
'int'
Fixes: 
42812/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6344057861832704

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 7cee3b37187dbf61dbebff023f07ceedfc0129bb)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 9e3756fc32..8a54c750b5 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1529,7 +1529,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void 
*data,
 for (ch = 0; ch < s->channels; ch++) {
 sample8 = (uint8_t *)frame->data[ch];
 for (i = 0; i < blockstodecode; i++)
-*sample8++ = (s->decoded[ch][i] + 0x80) & 0xff;
+*sample8++ = (s->decoded[ch][i] + 0x80U) & 0xff;
 }
 break;
 case 16:

___
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/alacdsp: fix integer overflow in decorrelate_stereo()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Thu Jul 23 23:34:15 2020 +0200| [50b56b539ec534d661cf1ffb2b4fbc8cb9f6eace] | 
committer: Michael Niedermayer

avcodec/alacdsp: fix integer overflow in decorrelate_stereo()

Fixes: signed integer overflow: -16777216 * 131 cannot be represented in type 
'int'
Fixes: 
23835/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5669943160078336
Fixes: 
41101/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-4636330705944576

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 68457c1e85122ffcadb0c909070dd210095fd2cd)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/alacdsp.c b/libavcodec/alacdsp.c
index 9996eb4319..8718d1b6b1 100644
--- a/libavcodec/alacdsp.c
+++ b/libavcodec/alacdsp.c
@@ -34,7 +34,7 @@ static void decorrelate_stereo(int32_t *buffer[2], int 
nb_samples,
 a = buffer[0][i];
 b = buffer[1][i];
 
-a -= (b * decorr_left_weight) >> decorr_shift;
+a -= (int)(b * (unsigned)decorr_left_weight) >> decorr_shift;
 b += a;
 
 buffer[0][i] = b;

___
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/flvdec: timestamps cannot use the full int64 range

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Thu Dec 23 20:36:16 2021 +0100| [83778e7787ca07f88f3f4718719c2dbfa363a0fb] | 
committer: Michael Niedermayer

avformat/flvdec: timestamps cannot use the full int64 range

We do not support this as we multiply by 1000
Fixes: signed integer overflow: -45318575073853696 * 1000 cannot be represented 
in type 'long'
Fixes: 
42804/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-4630325425209344

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit c217ca7718c8e24905d7ba9ede719ae040899476)
Signed-off-by: Michael Niedermayer 

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

 libavformat/flvdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 70622e261b..7c8d83edf1 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -432,6 +432,8 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc, int64_t m
 d = av_int2double(avio_rb64(ioc));
 if (isnan(d) || d < INT64_MIN || d > INT64_MAX)
 goto invalid;
+if (current_array ==  && (d <= INT64_MIN / 1000 || d >= 
INT64_MAX / 1000))
+goto invalid;
 current_array[0][i] = d;
 }
 if (times && filepositions) {

___
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/4xm: Check for duplicate track ids

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Tue Dec  7 09:14:09 2021 +0100| [fa922acc51660df7bbf46ade0d8eca87766200fd] | 
committer: Michael Niedermayer

avformat/4xm: Check for duplicate track ids

Signed-off-by: Michael Niedermayer 
(cherry picked from commit dd949124793c722ed55dead9da245574ace81968)
Signed-off-by: Michael Niedermayer 

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

 libavformat/4xm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index bce2727d79..fd224f9ad5 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -149,6 +149,9 @@ static int parse_strk(AVFormatContext *s,
 memset(>tracks[fourxm->track_count], 0,
sizeof(AudioTrack) * (track + 1 - fourxm->track_count));
 fourxm->track_count = track + 1;
+} else {
+if (fourxm->tracks[track].bits)
+return AVERROR_INVALIDDATA;
 }
 fourxm->tracks[track].adpcm   = AV_RL32(buf + 12);
 fourxm->tracks[track].channels= AV_RL32(buf + 36);

___
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/4xm: Consider max_streams on reallocating tracks array

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Tue Dec  7 09:14:08 2021 +0100| [e1793ad68e8e71d3850b44be6ac72df06c3d7ae5] | 
committer: Michael Niedermayer

avformat/4xm: Consider max_streams on reallocating tracks array

Fixes: OOM
Fixes: 
41595/clusterfuzz-testcase-minimized-ffmpeg_dem_FOURXM_fuzzer-6355979363549184

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 0dcd95ef8a2e16ed930296567ab1044e33602a34)
Signed-off-by: Michael Niedermayer 

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

 libavformat/4xm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index 8e2d305b24..bce2727d79 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -137,7 +137,8 @@ static int parse_strk(AVFormatContext *s,
 return AVERROR_INVALIDDATA;
 
 track = AV_RL32(buf + 8);
-if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1) {
+if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1 ||
+track >= s->max_streams) {
 av_log(s, AV_LOG_ERROR, "current_track too large\n");
 return AVERROR_INVALIDDATA;
 }

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

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


[FFmpeg-cvslog] avcodec/vqavideo: reset accounting on error

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Dec 19 22:26:00 2021 +0100| [807a564acf39c40faa2282e47fc0457b6e9e9017] | 
committer: Michael Niedermayer

avcodec/vqavideo: reset accounting on error

Fixes: Timeout (same growing chunk is decoded to failure repeatedly)
Fixes: 
42582/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQA_fuzzer-6531195591065600

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit d8ea7a67ba62f5d4520e75e56b9954d80e7ff223)
Signed-off-by: Michael Niedermayer 

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

 libavcodec/vqavideo.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index b9743abda9..8df3ab3c2b 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -588,13 +588,14 @@ static int vqa_decode_chunk(VqaContext *s, AVFrame *frame)
 if (s->partial_countdown <= 0) {
 bytestream2_init(>gb, s->next_codebook_buffer, 
s->next_codebook_buffer_index);
 /* decompress codebook */
-if ((res = decode_format80(s, s->next_codebook_buffer_index,
-   s->codebook, s->codebook_size, 0)) < 0)
-return res;
+res = decode_format80(s, s->next_codebook_buffer_index,
+  s->codebook, s->codebook_size, 0);
 
 /* reset accounting */
 s->next_codebook_buffer_index = 0;
 s->partial_countdown = s->partial_count;
+if (res < 0)
+return res;
 }
 }
 

___
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/mov: Check next offset in mov_read_dref()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sat Dec  4 20:48:54 2021 +0100| [60500dfc38012613d1dfde59c4ad45e90e0136cf] | 
committer: Michael Niedermayer

avformat/mov: Check next offset in mov_read_dref()

Fixes: signed integer overflow: 9223372036200463215 + 1109914409 cannot be 
represented in type 'long'
Fixes: 
41480/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6553086177443840

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 562021e2fd4d74589905d9c566c686394d2b0526)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a4eb4751c3..468e4094b9 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -597,11 +597,13 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 for (i = 0; i < entries; i++) {
 MOVDref *dref = >drefs[i];
 uint32_t size = avio_rb32(pb);
-int64_t next = avio_tell(pb) + size - 4;
+int64_t next = avio_tell(pb);
 
-if (size < 12)
+if (size < 12 || next < 0 || next > INT64_MAX - size)
 return AVERROR_INVALIDDATA;
 
+next += size - 4;
+
 dref->type = avio_rl32(pb);
 avio_rb32(pb); // version + flags
 

___
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/mxfdec: Check for duplicate mxf_read_index_entry_array()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Dec  5 22:19:05 2021 +0100| [816a97ba507a92c507f6583859b7f91c63da8a91] | 
committer: Michael Niedermayer

avformat/mxfdec: Check for duplicate mxf_read_index_entry_array()

Fixes: memleak
Fixes: 
41596/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6439060204290048

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 4f44a218e53cd92e64ba10a935bc1e7583c3e218)
Signed-off-by: Michael Niedermayer 

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

 libavformat/mxfdec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 8275add38e..06a7af425c 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -900,6 +900,9 @@ static int mxf_read_index_entry_array(AVIOContext *pb, 
MXFIndexTableSegment *seg
 {
 int i, length;
 
+if (segment->temporal_offset_entries)
+return AVERROR_INVALIDDATA;
+
 segment->nb_index_entries = avio_rb32(pb);
 
 length = avio_rb32(pb);

___
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/apedec: Change avg to uint32_t

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Fri Dec  3 17:58:50 2021 +0100| [7300c29bd4c61b7e12b0e68b1d0fb6ae14a81bbe] | 
committer: Michael Niedermayer

avcodec/apedec: Change avg to uint32_t

Fixes: Integer overflow
Fixes: 
40973/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6739312704618496

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Suggested-by: Anton Khirnov 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 0ec75723a484405eb2f2ec2f9e58161b168ed8b0)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index d05aa741ef..9e3756fc32 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -101,7 +101,7 @@ typedef struct APEFilter {
 int16_t *historybuffer; ///< filter memory
 int16_t *delay; ///< filtered values
 
-int avg;
+uint32_t avg;
 } APEFilter;
 
 typedef struct APERice {

___
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/mov: Disallow duplicate smdm

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Fri Dec  3 17:42:22 2021 +0100| [b60f4ff5dd7ca6e41fb660b6a9593a6446d514f5] | 
committer: Michael Niedermayer

avformat/mov: Disallow duplicate smdm

Fixes: memleak
Fixes: 
39879/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5327819907923968

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit b5ba74053c1ef9f38d9e7b3a036675f06d2b2714)
Signed-off-by: Michael Niedermayer 

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

 libavformat/mov.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index aeb3cbbc7e..a4eb4751c3 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4847,6 +4847,9 @@ static int mov_read_smdm(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 av_log(c->fc, AV_LOG_WARNING, "Unsupported Mastering Display Metadata 
box version %d\n", version);
 return 0;
 }
+if (sc->mastering)
+return AVERROR_INVALIDDATA;
+
 avio_skip(pb, 3); /* flags */
 
 sc->mastering = av_mastering_display_metadata_alloc();

___
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/mov: Check for EOF in mov_read_glbl()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sat Dec  4 20:11:35 2021 +0100| [c63fed42930e40b08034c7b0db1139d2739771a8] | 
committer: Michael Niedermayer

avformat/mov: Check for EOF in mov_read_glbl()

Fixes: Infinite loop
Fixes: 
41351/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5433895854669824

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 59b4e7cbd87889c0bac710ac7f62782b637419a1)
Signed-off-by: Michael Niedermayer 

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

 libavformat/mov.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3ec6e91098..aeb3cbbc7e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1700,6 +1700,8 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 // wrap a whole fiel atom inside of a glbl atom.
 unsigned size = avio_rb32(pb);
 unsigned type = avio_rl32(pb);
+if (avio_feof(pb))
+return AVERROR_INVALIDDATA;
 avio_seek(pb, -8, SEEK_CUR);
 if (type == MKTAG('f','i','e','l') && size == atom.size)
 return mov_read_default(c, pb, atom);

___
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/mov: Check channels for mov_parse_stsd_audio()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Nov  7 13:48:24 2021 +0100| [54d7297b338a6c507cb4f9c98789e5a2ec1fe0f5] | 
committer: Michael Niedermayer

avformat/mov: Check channels for mov_parse_stsd_audio()

Fixes: signed integer overflow: -776522110086937600 * 16 cannot be represented 
in type 'long'
Fixes: 
40563/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6644829447127040

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 3a64a4c58255d45e05eff80c9464ad3bdc2d6463)
Signed-off-by: Michael Niedermayer 

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

 libavformat/mov.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f081ced86e..3ec6e91098 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2324,6 +2324,10 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext 
*pb, int entries)
 av_log(c->fc, AV_LOG_ERROR, "Invalid sample rate %d\n", 
st->codecpar->sample_rate);
 return AVERROR_INVALIDDATA;
 }
+if (st->codecpar->channels < 0) {
+av_log(c->fc, AV_LOG_ERROR, "Invalid channels %d\n", 
st->codecpar->channels);
+return AVERROR_INVALIDDATA;
+}
 } else if (st->codecpar->codec_type==AVMEDIA_TYPE_SUBTITLE){
 st->codecpar->codec_id = id;
 mov_parse_stsd_subtitle(c, pb, st, sc,

___
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/avidec: Check read_odml_index() for failure

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Nov 14 18:23:24 2021 +0100| [f486033934426e435e8c21d9eb0d5cfee39d0ab0] | 
committer: Michael Niedermayer

avformat/avidec: Check read_odml_index() for failure

Fixes: Timeout
Fixes: 
40950/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6478873068437504

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 57adb26d058490daf2c5d6ddd3cf0cf2d2212256)
Signed-off-by: Michael Niedermayer 

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

 libavformat/avidec.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index b15aa6ecdb..0cb97dec3d 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -232,6 +232,8 @@ static int read_odml_index(AVFormatContext *s, int64_t 
frame_num)
 } else {
 int64_t offset, pos;
 int duration;
+int ret;
+
 offset = avio_rl64(pb);
 avio_rl32(pb);   /* size */
 duration = avio_rl32(pb);
@@ -249,7 +251,7 @@ static int read_odml_index(AVFormatContext *s, int64_t 
frame_num)
 if (avio_seek(pb, offset + 8, SEEK_SET) < 0)
 return -1;
 avi->odml_depth++;
-read_odml_index(s, frame_num);
+ret = read_odml_index(s, frame_num);
 avi->odml_depth--;
 frame_num += duration;
 
@@ -257,7 +259,8 @@ static int read_odml_index(AVFormatContext *s, int64_t 
frame_num)
 av_log(s, AV_LOG_ERROR, "Failed to restore position after 
reading index\n");
 return -1;
 }
-
+if (ret < 0)
+return ret;
 }
 }
 avi->index_loaded = 2;

___
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/aiffdec: Use av_rescale() for bitrate

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Oct 31 00:11:23 2021 +0200| [1cd6a75cba527e590a8e92fe7005f4a633c14230] | 
committer: Michael Niedermayer

avformat/aiffdec: Use av_rescale() for bitrate

Fixes: integer overflow
Fixes: 
40313/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-4814761406103552

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 905588df975071c03c00b2e923c311b4de65a8f4)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 939e338096..c7572058cc 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -187,8 +187,10 @@ static int get_aiff_header(AVFormatContext *s, int size,
 par->block_align = (av_get_bits_per_sample(par->codec_id) * 
par->channels) >> 3;
 
 if (aiff->block_duration) {
-par->bit_rate = (int64_t)par->sample_rate * (par->block_align << 3) /
-aiff->block_duration;
+par->bit_rate = av_rescale(par->sample_rate, par->block_align * 8LL,
+   aiff->block_duration);
+if (par->bit_rate < 0)
+par->bit_rate = 0;
 }
 
 /* Chunk is over */

___
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/aiffdec: sanity check block_align

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Oct 31 00:10:39 2021 +0200| [a7eeea7872f3fe854a46a57bce14525844128520] | 
committer: Michael Niedermayer

avformat/aiffdec: sanity check block_align

Reviewed-by: Paul B Mahol 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 93f7776921ed8c5219732210067016c3457e864d)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 0b05af7e6d..939e338096 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -353,7 +353,7 @@ got_sound:
 if (!st->codecpar->block_align && st->codecpar->codec_id == 
AV_CODEC_ID_QCELP) {
 av_log(s, AV_LOG_WARNING, "qcelp without wave chunk, assuming full 
rate\n");
 st->codecpar->block_align = 35;
-} else if (!st->codecpar->block_align) {
+} else if (st->codecpar->block_align <= 0) {
 av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid 
block_align value\n");
 return -1;
 }

___
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/aiffdec: Check sample_rate

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Sun Oct 31 00:02:04 2021 +0200| [b982f9fe9d8f76e11b0ce7bd3b60d92e28223787] | 
committer: Michael Niedermayer

avformat/aiffdec: Check sample_rate

Reviewed-by: Paul B Mahol 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 1b04836dff9958e8bfdbed2746b8c40b1e119ecc)
Signed-off-by: Michael Niedermayer 

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

 libavformat/aiffdec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 4a042701e3..0b05af7e6d 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -122,6 +122,9 @@ static int get_aiff_header(AVFormatContext *s, int size,
 sample_rate = val << exp;
 else
 sample_rate = (val + (1ULL<<(-exp-1))) >> -exp;
+if (sample_rate <= 0)
+return AVERROR_INVALIDDATA;
+
 par->sample_rate = sample_rate;
 if (size < 18)
 return AVERROR_INVALIDDATA;

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

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


[FFmpeg-cvslog] avfilter/vf_lenscorrection: fix division by zero

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: release/3.4 | Paul B Mahol  | Sun Oct 13 
23:28:16 2019 +0200| [32a384519a57ad850789636c4c686091a53ce217] | committer: 
Michael Niedermayer

avfilter/vf_lenscorrection: fix division by zero

Fixes #8265

(cherry picked from commit 19587c9332f5be4f6bc6d7b2b8ef3fd21dfeaa01)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c
index 239fe195bd..43f3c1b7d0 100644
--- a/libavfilter/vf_lenscorrection.c
+++ b/libavfilter/vf_lenscorrection.c
@@ -155,10 +155,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 for (plane = 0; plane < rect->nb_planes; ++plane) {
 int hsub = plane == 1 || plane == 2 ? rect->hsub : 0;
 int vsub = plane == 1 || plane == 2 ? rect->vsub : 0;
-int hdiv = 1 << hsub;
-int vdiv = 1 << vsub;
-int w = rect->width / hdiv;
-int h = rect->height / vdiv;
+int w = AV_CEIL_RSHIFT(rect->width, hsub);
+int h = AV_CEIL_RSHIFT(rect->height, vsub);
 int xcenter = rect->cx * w;
 int ycenter = rect->cy * h;
 int k1 = rect->k1 * (1<<24);

___
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/latmenc: abort if no extradata is available

2022-04-13 Thread James Almer
ffmpeg | branch: release/3.4 | James Almer  | Tue Oct 15 
11:38:23 2019 -0300| [b8197738d27f21583d9f83d7fa8c978d3a47af85] | committer: 
Michael Niedermayer

avformat/latmenc: abort if no extradata is available

Fixes ticket #8273.

Reviewed-by: Paul B Mahol 
Signed-off-by: James Almer 
(cherry picked from commit dd01947397b98e94c3f2a79d5820aaf4594f4d3b)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c
index c919976d49..3e1a01c989 100644
--- a/libavformat/latmenc.c
+++ b/libavformat/latmenc.c
@@ -172,7 +172,8 @@ static int latm_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (ret < 0)
 return ret;
 memcpy(par->extradata, side_data, side_data_size);
-}
+} else
+return AVERROR_INVALIDDATA;
 }
 }
 

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

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


[FFmpeg-cvslog] avfilter/vf_gblur: fix heap-buffer overflow

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: release/3.4 | Paul B Mahol  | Wed Oct 16 
12:13:04 2019 +0200| [b239ccff7db0d418a74adcebfb1f2304f9a2f1f0] | committer: 
Michael Niedermayer

avfilter/vf_gblur: fix heap-buffer overflow

Fixes #8282

(cherry picked from commit 64a805883d7223c868a683f0030837d859edd2ab)
Signed-off-by: Michael Niedermayer 

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

 libavfilter/vf_gblur.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index fd901e20d4..0b0274782a 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -222,7 +222,7 @@ static int config_input(AVFilterLink *inlink)
 
 s->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
-s->buffer = av_malloc_array(inlink->w, inlink->h * sizeof(*s->buffer));
+s->buffer = av_malloc_array(FFALIGN(inlink->w, 16), FFALIGN(inlink->h, 16) 
* sizeof(*s->buffer));
 if (!s->buffer)
 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/g729dec: Avoid computing invalid temporary pointers for ff_acelp_weighted_vector_sum()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Thu Oct 17 11:54:12 2019 +0200| [04240e1d09e67c6e92189a96aeab96ef7428d942] | 
committer: Michael Niedermayer

avcodec/g729dec: Avoid computing invalid temporary pointers for 
ff_acelp_weighted_vector_sum()

Fixes: Ticket8176

Reviewed-by: Paul B Mahol 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 2c78a76cb0443f8a12a5eadc3b58373aa2f4ab22)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index 908c12a73a..943ddf5297 100644
--- a/libavcodec/g729dec.c
+++ b/libavcodec/g729dec.c
@@ -536,12 +536,13 @@ static int decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame_ptr,
   fc_v[i] = <
  \ fc_v[i] + gain_pitch * fc_v[i-pitch_delay], i >= 
pitch_delay
 */
-ff_acelp_weighted_vector_sum(fc + pitch_delay_int[i],
- fc + pitch_delay_int[i],
- fc, 1 << 14,
- av_clip(ctx->past_gain_pitch[0], 
SHARP_MIN, SHARP_MAX),
- 0, 14,
- SUBFRAME_SIZE - pitch_delay_int[i]);
+if (SUBFRAME_SIZE > pitch_delay_int[i])
+ff_acelp_weighted_vector_sum(fc + pitch_delay_int[i],
+ fc + pitch_delay_int[i],
+ fc, 1 << 14,
+ av_clip(ctx->past_gain_pitch[0], 
SHARP_MIN, SHARP_MAX),
+ 0, 14,
+ SUBFRAME_SIZE - pitch_delay_int[i]);
 
 memmove(ctx->past_gain_pitch+1, ctx->past_gain_pitch, 5 * 
sizeof(int16_t));
 ctx->past_gain_code[1] = ctx->past_gain_code[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] avformat/movenc: Fix segfault when remuxing rtp hint stream

2022-04-13 Thread Andreas Rheinhardt
ffmpeg | branch: release/3.4 | Andreas Rheinhardt 
 | Tue Sep 29 10:21:34 2020 +0200| 
[3b49688440e7bd004634fe289d3f0e128df236fa] | committer: Michael Niedermayer

avformat/movenc: Fix segfault when remuxing rtp hint stream

When remuxing an rtp hint stream (or any stream with the tag "rtp "),
the mov muxer treats this as one of the rtp hint tracks it creates
internally when ordered to do so; yet this track lacks the
AVFormatContext for the hinting rtp muxer, leading to segfaults in
mov_write_udta_sdp() if a "trak" atom is written for this stream; if not,
the stream's codecpar is freed by mov_free() as if the mov muxer owned
it (it does for the internally created "rtp " tracks), but without
resetting st->codecpar, leading to double-frees lateron. This commit
therefore ignores said tag which makes rtp hint streams unremuxable.

This fixes tickets #8181 and #8186.

Signed-off-by: Andreas Rheinhardt 
(cherry picked from commit 22c3cd176079dd104ec7610ead697235b04396f1)
Signed-off-by: Michael Niedermayer 

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

 libavformat/movenc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d69e0e543d..82e20011ed 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1470,6 +1470,10 @@ static int mov_get_codec_tag(AVFormatContext *s, 
MOVTrack *track)
 {
 int tag = track->par->codec_tag;
 
+// "rtp " is used to distinguish internally created RTP-hint tracks
+// (with rtp_ctx) from other tracks.
+if (tag == MKTAG('r','t','p',' '))
+tag = 0;
 if (!tag || (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
  (track->par->codec_id == AV_CODEC_ID_DVVIDEO ||
   track->par->codec_id == AV_CODEC_ID_RAWVIDEO ||

___
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/flac_parser: Consider AV_INPUT_BUFFER_PADDING_SIZE

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Thu Oct 21 13:25:59 2021 +0200| [59b4b9086a525a15345062059ff57cf86086fdba] | 
committer: Michael Niedermayer

avcodec/flac_parser: Consider AV_INPUT_BUFFER_PADDING_SIZE

Fixes: out if array read
Fixes: 
40109/clusterfuzz-testcase-minimized-ffmpeg_dem_FLAC_fuzzer-4805686811295744

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

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

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

diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index fed33087e8..db6765f34c 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -55,6 +55,7 @@
 
 /** largest possible size of flac header */
 #define MAX_FRAME_HEADER_SIZE 16
+#define MAX_FRAME_VERIFY_SIZE (MAX_FRAME_HEADER_SIZE)
 
 typedef struct FLACHeaderMarker {
 int offset;   /**< byte offset from start of FLACParseContext->buffer 
*/
@@ -169,7 +170,7 @@ static int find_headers_search_validate(FLACParseContext 
*fpc, int offset)
 uint8_t *header_buf;
 int size = 0;
 header_buf = flac_fifo_read_wrap(fpc, offset,
- MAX_FRAME_HEADER_SIZE,
+ MAX_FRAME_VERIFY_SIZE + 
AV_INPUT_BUFFER_PADDING_SIZE,
  >wrap_buf,
  >wrap_buf_allocated_size);
 if (frame_header_is_valid(fpc->avctx, header_buf, )) {

___
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/tty: add probe function

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: release/3.4 | Paul B Mahol  | Mon Jan 27 
21:53:08 2020 +0100| [b5873ca4f527570814420adf10bec529f76b2402] | committer: 
Michael Niedermayer

avformat/tty: add probe function

(cherry picked from commit 3bce9e9b3ea35c54ba793d7da99ea5157532)

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

 libavformat/tty.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/libavformat/tty.c b/libavformat/tty.c
index 8d48f2c45c..60f7e9f87e 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -34,6 +34,13 @@
 #include "internal.h"
 #include "sauce.h"
 
+static int isansicode(int x)
+{
+return x == 0x1B || x == 0x0A || x == 0x0D || (x >= 0x20 && x < 0x7f);
+}
+
+static const char tty_extensions[31] = "ans,art,asc,diz,ice,nfo,txt,vt";
+
 typedef struct TtyDemuxContext {
 AVClass *class;
 int chars_per_frame;
@@ -42,6 +49,17 @@ typedef struct TtyDemuxContext {
 AVRational framerate; /**< Set by a private option. */
 } TtyDemuxContext;
 
+static int read_probe(const AVProbeData *p)
+{
+int cnt = 0;
+
+for (int i = 0; i < p->buf_size; i++)
+cnt += !!isansicode(p->buf[i]);
+
+return (cnt * 100LL / p->buf_size) * (cnt > 400) *
+!!av_match_ext(p->filename, tty_extensions);
+}
+
 /**
  * Parse EFI header
  */
@@ -153,8 +171,9 @@ AVInputFormat ff_tty_demuxer = {
 .name   = "tty",
 .long_name  = NULL_IF_CONFIG_SMALL("Tele-typewriter"),
 .priv_data_size = sizeof(TtyDemuxContext),
+.read_probe = read_probe,
 .read_header= read_header,
 .read_packet= read_packet,
-.extensions = "ans,art,asc,diz,ice,nfo,txt,vt",
+.extensions = tty_extensions,
 .priv_class = _demuxer_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] avutil/mathematics: Document av_rescale_rnd() behavior on non int64 results

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Wed Oct 20 19:51:08 2021 +0200| [ef075e363d1a5040d35e8e65dcc5bb0a257c4681] | 
committer: Michael Niedermayer

avutil/mathematics: Document av_rescale_rnd() behavior on non int64 results

Reviewed-by: Derek Buitenhuis 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit e154353fdb73dc1b3c1519350244d5346f761850)
Signed-off-by: Michael Niedermayer 

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

 libavutil/mathematics.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h
index 54901800ba..64d4137a60 100644
--- a/libavutil/mathematics.h
+++ b/libavutil/mathematics.h
@@ -134,6 +134,7 @@ int64_t av_rescale(int64_t a, int64_t b, int64_t c) 
av_const;
  *
  * The operation is mathematically equivalent to `a * b / c`, but writing that
  * directly can overflow, and does not support different rounding methods.
+ * If the result is not representable then INT64_MIN is returned.
  *
  * @see av_rescale(), av_rescale_q(), av_rescale_q_rnd()
  */

___
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/ttadsp: Fix integer overflows in tta_filter_process_c()

2022-04-13 Thread Michael Niedermayer
ffmpeg | branch: release/3.4 | Michael Niedermayer  | 
Fri Oct 15 00:04:59 2021 +0200| [a2c450db44ca0df462648059283a546de68b0533] | 
committer: Michael Niedermayer

avcodec/ttadsp: Fix integer overflows in tta_filter_process_c()

Fixes: signed integer overflow: 822841647 + 1647055738 cannot be represented in 
type 'int'
Fixes: 
39935/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-4592657142251520

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit f24028c798397af720acb838357785aa705a8122)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/ttadsp.c b/libavcodec/ttadsp.c
index 1d1443aee0..99dd66a0c2 100644
--- a/libavcodec/ttadsp.c
+++ b/libavcodec/ttadsp.c
@@ -47,9 +47,9 @@ static void tta_filter_process_c(int32_t *qmi, int32_t *dx, 
int32_t *dl,
 *error = *in;
 *in += (round >> shift);
 
-dl[4] = -dl[5]; dl[5] = -dl[6];
-dl[6] = *in - dl[7]; dl[7] = *in;
-dl[5] += dl[6]; dl[4] += dl[5];
+dl[4] = -(unsigned)dl[5]; dl[5] = -(unsigned)dl[6];
+dl[6] = *in -(unsigned)dl[7]; dl[7] = *in;
+dl[5] += (unsigned)dl[6]; dl[4] += (unsigned)dl[5];
 }
 
 av_cold void ff_ttadsp_init(TTADSPContext *c)

___
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/af_adenorm: simplify handling of commands

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Apr 13 21:55:22 
2022 +0200| [bf6735e9457005f18bc521e2754b54e06294e971] | committer: Paul B Mahol

avfilter/af_adenorm: simplify handling of commands

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

 libavfilter/af_adenorm.c | 59 ++--
 1 file changed, 17 insertions(+), 42 deletions(-)

diff --git a/libavfilter/af_adenorm.c b/libavfilter/af_adenorm.c
index 04e3338b1a..583b7fafee 100644
--- a/libavfilter/af_adenorm.c
+++ b/libavfilter/af_adenorm.c
@@ -39,8 +39,8 @@ typedef struct ADenormContext {
 int type;
 int64_t in_samples;
 
-void (*filter)(AVFilterContext *ctx, void *dst,
-   const void *src, int nb_samples);
+void (*filter[NB_TYPES])(AVFilterContext *ctx, void *dst,
+ const void *src, int nb_samples);
 } ADenormContext;
 
 static void dc_denorm_fltp(AVFilterContext *ctx, void *dstp,
@@ -158,30 +158,18 @@ static int config_output(AVFilterLink *outlink)
 AVFilterContext *ctx = outlink->src;
 ADenormContext *s = ctx->priv;
 
-switch (s->type) {
-case DC_TYPE:
-switch (outlink->format) {
-case AV_SAMPLE_FMT_FLTP: s->filter = dc_denorm_fltp; break;
-case AV_SAMPLE_FMT_DBLP: s->filter = dc_denorm_dblp; break;
-}
-break;
-case AC_TYPE:
-switch (outlink->format) {
-case AV_SAMPLE_FMT_FLTP: s->filter = ac_denorm_fltp; break;
-case AV_SAMPLE_FMT_DBLP: s->filter = ac_denorm_dblp; break;
-}
+switch (outlink->format) {
+case AV_SAMPLE_FMT_FLTP:
+s->filter[DC_TYPE] = dc_denorm_fltp;
+s->filter[AC_TYPE] = ac_denorm_fltp;
+s->filter[SQ_TYPE] = sq_denorm_fltp;
+s->filter[PS_TYPE] = ps_denorm_fltp;
 break;
-case SQ_TYPE:
-switch (outlink->format) {
-case AV_SAMPLE_FMT_FLTP: s->filter = sq_denorm_fltp; break;
-case AV_SAMPLE_FMT_DBLP: s->filter = sq_denorm_dblp; break;
-}
-break;
-case PS_TYPE:
-switch (outlink->format) {
-case AV_SAMPLE_FMT_FLTP: s->filter = ps_denorm_fltp; break;
-case AV_SAMPLE_FMT_DBLP: s->filter = ps_denorm_dblp; break;
-}
+case AV_SAMPLE_FMT_DBLP:
+s->filter[DC_TYPE] = dc_denorm_dblp;
+s->filter[AC_TYPE] = ac_denorm_dblp;
+s->filter[SQ_TYPE] = sq_denorm_dblp;
+s->filter[PS_TYPE] = ps_denorm_dblp;
 break;
 default:
 av_assert0(0);
@@ -204,9 +192,9 @@ static int filter_channels(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jo
 const int end = (in->ch_layout.nb_channels * (jobnr+1)) / nb_jobs;
 
 for (int ch = start; ch < end; ch++) {
-s->filter(ctx, out->extended_data[ch],
-  in->extended_data[ch],
-  in->nb_samples);
+s->filter[s->type](ctx, out->extended_data[ch],
+   in->extended_data[ch],
+   in->nb_samples);
 }
 
 return 0;
@@ -243,19 +231,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 return ff_filter_frame(outlink, out);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
-   char *res, int res_len, int flags)
-{
-AVFilterLink *outlink = ctx->outputs[0];
-int ret;
-
-ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-if (ret < 0)
-return ret;
-
-return config_output(outlink);
-}
-
 static const AVFilterPad adenorm_inputs[] = {
 {
 .name = "default",
@@ -295,7 +270,7 @@ const AVFilter ff_af_adenorm = {
 FILTER_OUTPUTS(adenorm_outputs),
 FILTER_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP),
 .priv_class  = _class,
-.process_command = process_command,
+.process_command = ff_filter_process_command,
 .flags   = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |
AVFILTER_FLAG_SLICE_THREADS,
 };

___
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/avf_showvolume: check for allocation error and stop leaks

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Apr 13 18:18:49 
2022 +0200| [24144af2dd75c426d6d291f81e8e9206969b805b] | committer: Paul B Mahol

avfilter/avf_showvolume: check for allocation error and stop leaks

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

 libavfilter/avf_showvolume.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c
index 1c072a16a6..eb79a5ebdb 100644
--- a/libavfilter/avf_showvolume.c
+++ b/libavfilter/avf_showvolume.c
@@ -190,6 +190,9 @@ static int config_input(AVFilterLink *inlink)
 s->persistent_max_frames = (int) FFMAX(av_q2d(s->frame_rate) * 
s->draw_persistent_duration, 1.);
 s->max_persistent = av_calloc(inlink->ch_layout.nb_channels * 
s->persistent_max_frames, sizeof(*s->max_persistent));
 s->nb_frames_max_display = av_calloc(inlink->ch_layout.nb_channels * 
s->persistent_max_frames, sizeof(*s->nb_frames_max_display));
+if (!s->max_persistent ||
+!s->nb_frames_max_display)
+return AVERROR(ENOMEM);
 }
 return 0;
 }
@@ -479,6 +482,8 @@ static av_cold void uninit(AVFilterContext *ctx)
 av_freep(>values);
 av_freep(>color_lut);
 av_freep(>max);
+av_freep(>max_persistent);
+av_freep(>nb_frames_max_display);
 }
 
 static const AVFilterPad showvolume_inputs[] = {

___
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/avcodec: Simplify accessing AVSubtitleRect via dedicated pointer

2022-04-13 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Apr 13 16:12:44 2022 +0200| [f6e167998f258dd69cd5e66e8bea52590bdec75a] | 
committer: Andreas Rheinhardt

avcodec/avcodec: Simplify accessing AVSubtitleRect via dedicated pointer

Reviewed-by: Anton Khirnov 
Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index ded6b5b307..a07e3ef4d6 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -453,12 +453,15 @@ void avsubtitle_free(AVSubtitle *sub)
 int i;
 
 for (i = 0; i < sub->num_rects; i++) {
-av_freep(>rects[i]->data[0]);
-av_freep(>rects[i]->data[1]);
-av_freep(>rects[i]->data[2]);
-av_freep(>rects[i]->data[3]);
-av_freep(>rects[i]->text);
-av_freep(>rects[i]->ass);
+AVSubtitleRect *const rect = sub->rects[i];
+
+av_freep(>data[0]);
+av_freep(>data[1]);
+av_freep(>data[2]);
+av_freep(>data[3]);
+av_freep(>text);
+av_freep(>ass);
+
 av_freep(>rects[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] avcodec/avcodec: Don't reset decoder-fields for encoders when flushing

2022-04-13 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Apr 13 16:06:11 2022 +0200| [fa3f9f2f6acc48fe6ac6af1ea723066d6851743c] | 
committer: Andreas Rheinhardt

avcodec/avcodec: Don't reset decoder-fields for encoders when flushing

Reviewed-by: Anton Khirnov 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/avcodec.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index a07e3ef4d6..d11f035481 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -422,6 +422,17 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 }
 if (avci->in_frame)
 av_frame_unref(avci->in_frame);
+} else {
+av_packet_unref(avci->last_pkt_props);
+while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0)
+av_packet_unref(avci->last_pkt_props);
+
+av_packet_unref(avci->in_pkt);
+
+avctx->pts_correction_last_pts =
+avctx->pts_correction_last_dts = INT64_MIN;
+
+av_bsf_flush(avci->bsf);
 }
 
 avci->draining  = 0;
@@ -430,22 +441,10 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 av_frame_unref(avci->buffer_frame);
 av_packet_unref(avci->buffer_pkt);
 
-av_packet_unref(avci->last_pkt_props);
-while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0)
-av_packet_unref(avci->last_pkt_props);
-
-av_packet_unref(avci->in_pkt);
-
 if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
 ff_thread_flush(avctx);
 else if (ffcodec(avctx->codec)->flush)
 ffcodec(avctx->codec)->flush(avctx);
-
-avctx->pts_correction_last_pts =
-avctx->pts_correction_last_dts = INT64_MIN;
-
-if (avci->bsf)
-av_bsf_flush(avci->bsf);
 }
 
 void avsubtitle_free(AVSubtitle *sub)

___
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/encode: Fix check for encoders impl. encode-simple API

2022-04-13 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Apr 13 15:29:21 2022 +0200| [3a920372a11607a4ea6e5a2c29b0b5dbf08f275c] | 
committer: Andreas Rheinhardt

avcodec/encode: Fix check for encoders impl. encode-simple API

FFCodec.cb is a union.

Reviewed-by: Anton Khirnov 
Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 6ae47b736c..e7ae2cd4c1 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -589,7 +589,7 @@ int ff_encode_preinit(AVCodecContext *avctx)
 if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY)
 avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY;
 
-if (ffcodec(avctx->codec)->cb.encode) {
+if (ffcodec(avctx->codec)->cb_type == FF_CODEC_CB_TYPE_ENCODE) {
 avci->in_frame = av_frame_alloc();
 if (!avci->in_frame)
 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/avcodec: Avoid av_frame_unref(NULL)

2022-04-13 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Apr 13 15:40:05 2022 +0200| [3649051dc4e1ede5999a7c688864e5a616f985ee] | 
committer: Andreas Rheinhardt

avcodec/avcodec: Avoid av_frame_unref(NULL)

It works, but it is not documented to work.

Reviewed-by: Anton Khirnov 
Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index e0f38ac42a..ded6b5b307 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -420,6 +420,8 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
"that doesn't support it\n");
 return;
 }
+if (avci->in_frame)
+av_frame_unref(avci->in_frame);
 }
 
 avci->draining  = 0;
@@ -432,7 +434,6 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0)
 av_packet_unref(avci->last_pkt_props);
 
-av_frame_unref(avci->in_frame);
 av_packet_unref(avci->in_pkt);
 
 if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)

___
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/mlpenc: fix encoding after receiving last frame

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Apr 13 14:07:48 
2022 +0200| [f67403edb379ea906cdcaf296977abc894ce2916] | committer: Paul B Mahol

avcodec/mlpenc: fix encoding after receiving last frame

This happened when major header needed to be written
after input EOF.

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

 libavcodec/mlpenc.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 0dc0ecf036..52ddec3a21 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -2122,10 +2122,11 @@ static int mlp_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 
 input_and_return:
 
-if (frame)
+if (frame) {
 ctx->shorten_by = avctx->frame_size - frame->nb_samples;
-ctx->next_major_frame_size += avctx->frame_size;
-ctx->next_major_number_of_frames++;
+ctx->next_major_frame_size += avctx->frame_size;
+ctx->next_major_number_of_frames++;
+}
 if (data)
 input_data(ctx, data, frame->nb_samples);
 
@@ -2166,7 +2167,7 @@ input_and_return:
 }
 }
 
-if (!frame)
+if (!frame && ctx->last_frames < ctx->max_restart_interval - 1)
 avctx->frame_number++;
 
 if (bytes_written > 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] lavc/encode: reindent

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Jan 20 
16:53:18 2022 +0100| [ee26138e67fb01a0d95966ee7d143e7361057fb0] | committer: 
Anton Khirnov

lavc/encode: reindent

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

 libavcodec/encode.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 05fa34d6c5..85b8e089dd 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -411,7 +411,7 @@ int attribute_align_arg 
avcodec_receive_packet(AVCodecContext *avctx, AVPacket *
 
 static int encode_preinit_video(AVCodecContext *avctx)
 {
-const AVPixFmtDescriptor *pixdesc = 
av_pix_fmt_desc_get(avctx->pix_fmt);
+const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt);
 int i;
 
 if (avctx->codec->pix_fmts) {
@@ -433,16 +433,16 @@ static int encode_preinit_video(AVCodecContext *avctx)
 avctx->color_range = AVCOL_RANGE_JPEG;
 }
 
-if (avctx->bits_per_raw_sample < 0
-|| (avctx->bits_per_raw_sample > 8 && pixdesc->comp[0].depth <= 
8)) {
-av_log(avctx, AV_LOG_WARNING, "Specified bit depth %d not possible 
with the specified pixel formats depth %d\n",
-avctx->bits_per_raw_sample, pixdesc->comp[0].depth);
-avctx->bits_per_raw_sample = pixdesc->comp[0].depth;
-}
-if (avctx->width <= 0 || avctx->height <= 0) {
-av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
-return AVERROR(EINVAL);
-}
+if (avctx->bits_per_raw_sample < 0
+|| (avctx->bits_per_raw_sample > 8 && pixdesc->comp[0].depth <= 8)) {
+av_log(avctx, AV_LOG_WARNING, "Specified bit depth %d not possible 
with the specified pixel formats depth %d\n",
+avctx->bits_per_raw_sample, pixdesc->comp[0].depth);
+avctx->bits_per_raw_sample = pixdesc->comp[0].depth;
+}
+if (avctx->width <= 0 || avctx->height <= 0) {
+av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
+return AVERROR(EINVAL);
+}
 
 if (avctx->ticks_per_frame && avctx->time_base.num &&
 avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {

___
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] lavc/encode: factor audio/video-specific parts out of ff_encode_preinit()

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Jan 20 
16:52:01 2022 +0100| [15975881ae183fede130871e1af497ae4f870150] | committer: 
Anton Khirnov

lavc/encode: factor audio/video-specific parts out of ff_encode_preinit()

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

 libavcodec/encode.c | 147 ++--
 1 file changed, 85 insertions(+), 62 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 3d862a0c24..05fa34d6c5 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -409,16 +409,77 @@ int attribute_align_arg 
avcodec_receive_packet(AVCodecContext *avctx, AVPacket *
 return 0;
 }
 
-int ff_encode_preinit(AVCodecContext *avctx)
+static int encode_preinit_video(AVCodecContext *avctx)
 {
-AVCodecInternal *avci = avctx->internal;
+const AVPixFmtDescriptor *pixdesc = 
av_pix_fmt_desc_get(avctx->pix_fmt);
 int i;
 
-if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) {
-av_log(avctx, AV_LOG_ERROR, "The encoder timebase is not set.\n");
+if (avctx->codec->pix_fmts) {
+for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
+if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
+break;
+if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE) {
+char buf[128];
+snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt);
+av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is invalid 
or not supported\n",
+   (char *)av_x_if_null(av_get_pix_fmt_name(avctx->pix_fmt), 
buf));
+return AVERROR(EINVAL);
+}
+if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
+avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ411P ||
+avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ422P ||
+avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ440P ||
+avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
+avctx->color_range = AVCOL_RANGE_JPEG;
+}
+
+if (avctx->bits_per_raw_sample < 0
+|| (avctx->bits_per_raw_sample > 8 && pixdesc->comp[0].depth <= 
8)) {
+av_log(avctx, AV_LOG_WARNING, "Specified bit depth %d not possible 
with the specified pixel formats depth %d\n",
+avctx->bits_per_raw_sample, pixdesc->comp[0].depth);
+avctx->bits_per_raw_sample = pixdesc->comp[0].depth;
+}
+if (avctx->width <= 0 || avctx->height <= 0) {
+av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
+return AVERROR(EINVAL);
+}
+
+if (avctx->ticks_per_frame && avctx->time_base.num &&
+avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
+av_log(avctx, AV_LOG_ERROR,
+   "ticks_per_frame %d too large for the timebase %d/%d.",
+   avctx->ticks_per_frame,
+   avctx->time_base.num,
+   avctx->time_base.den);
 return AVERROR(EINVAL);
 }
 
+if (avctx->hw_frames_ctx) {
+AVHWFramesContext *frames_ctx = 
(AVHWFramesContext*)avctx->hw_frames_ctx->data;
+if (frames_ctx->format != avctx->pix_fmt) {
+av_log(avctx, AV_LOG_ERROR,
+   "Mismatching AVCodecContext.pix_fmt and 
AVHWFramesContext.format\n");
+return AVERROR(EINVAL);
+}
+if (avctx->sw_pix_fmt != AV_PIX_FMT_NONE &&
+avctx->sw_pix_fmt != frames_ctx->sw_format) {
+av_log(avctx, AV_LOG_ERROR,
+   "Mismatching AVCodecContext.sw_pix_fmt (%s) "
+   "and AVHWFramesContext.sw_format (%s)\n",
+   av_get_pix_fmt_name(avctx->sw_pix_fmt),
+   av_get_pix_fmt_name(frames_ctx->sw_format));
+return AVERROR(EINVAL);
+}
+avctx->sw_pix_fmt = frames_ctx->sw_format;
+}
+
+return 0;
+}
+
+static int encode_preinit_audio(AVCodecContext *avctx)
+{
+int i;
+
 if (avctx->codec->sample_fmts) {
 for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
 if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
@@ -438,24 +499,6 @@ int ff_encode_preinit(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 }
-if (avctx->codec->pix_fmts) {
-for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
-if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
-break;
-if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE) {
-char buf[128];
-snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt);
-av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is invalid 
or not supported\n",
-   (char *)av_x_if_null(av_get_pix_fmt_name(avctx->pix_fmt), 
buf));
-return AVERROR(EINVAL);
-}
-if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
-

[FFmpeg-cvslog] lavc/encode: pick a sane default for bits_per_raw_sample if it's not set

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Jan 20 
16:56:53 2022 +0100| [e663030267851e0e0be54dc9d685fa9cd883cef6] | committer: 
Anton Khirnov

lavc/encode: pick a sane default for bits_per_raw_sample if it's not set

Fixes #9563.

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

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

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 85b8e089dd..6ae47b736c 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -555,6 +555,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+if (!avctx->bits_per_raw_sample)
+avctx->bits_per_raw_sample = 8 * 
av_get_bytes_per_sample(avctx->sample_fmt);
+
 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] lavc: move default get_buffer2() to its own file

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Mar 23 
15:44:01 2022 +0100| [ce3c20f2aa349557cb0e6cacf1ad76bc4499b518] | committer: 
Anton Khirnov

lavc: move default get_buffer2() to its own file

It is also used by some encoders, so decode.c is not the right place for
it.

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

 libavcodec/Makefile |   1 +
 libavcodec/decode.c | 278 --
 libavcodec/get_buffer.c | 312 
 3 files changed, 313 insertions(+), 278 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 90f46035d9..4b12228070 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -43,6 +43,7 @@ OBJS = ac3_parser.o   
  \
dirac.o  \
dv_profile.o \
encode.o \
+   get_buffer.o \
imgconvert.o \
jni.o\
mathtables.o \
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index e51a39e70a..69e68ab09d 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -48,25 +48,6 @@
 #include "internal.h"
 #include "thread.h"
 
-typedef struct FramePool {
-/**
- * Pools for each data plane. For audio all the planes have the same size,
- * so only pools[0] is used.
- */
-AVBufferPool *pools[4];
-
-/*
- * Pool parameters
- */
-int format;
-int width, height;
-int stride_align[AV_NUM_DATA_POINTERS];
-int linesize[4];
-int planes;
-int channels;
-int samples;
-} FramePool;
-
 static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
 {
 int ret;
@@ -1250,265 +1231,6 @@ int ff_get_format(AVCodecContext *avctx, const enum 
AVPixelFormat *fmt)
 return ret;
 }
 
-static void frame_pool_free(void *opaque, uint8_t *data)
-{
-FramePool *pool = (FramePool*)data;
-int i;
-
-for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
-av_buffer_pool_uninit(>pools[i]);
-
-av_freep();
-}
-
-static AVBufferRef *frame_pool_alloc(void)
-{
-FramePool *pool = av_mallocz(sizeof(*pool));
-AVBufferRef *buf;
-
-if (!pool)
-return NULL;
-
-buf = av_buffer_create((uint8_t*)pool, sizeof(*pool),
-   frame_pool_free, NULL, 0);
-if (!buf) {
-av_freep();
-return NULL;
-}
-
-return buf;
-}
-
-static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
-{
-FramePool *pool = avctx->internal->pool ?
-  (FramePool*)avctx->internal->pool->data : NULL;
-AVBufferRef *pool_buf;
-int i, ret, ch, planes;
-
-if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
-int planar = av_sample_fmt_is_planar(frame->format);
-ch = frame->ch_layout.nb_channels;
-#if FF_API_OLD_CHANNEL_LAYOUT
-FF_DISABLE_DEPRECATION_WARNINGS
-if (!ch)
-ch = frame->channels;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-planes = planar ? ch : 1;
-}
-
-if (pool && pool->format == frame->format) {
-if (avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
-pool->width == frame->width && pool->height == frame->height)
-return 0;
-if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && pool->planes == planes 
&&
-pool->channels == ch && frame->nb_samples == pool->samples)
-return 0;
-}
-
-pool_buf = frame_pool_alloc();
-if (!pool_buf)
-return AVERROR(ENOMEM);
-pool = (FramePool*)pool_buf->data;
-
-switch (avctx->codec_type) {
-case AVMEDIA_TYPE_VIDEO: {
-int linesize[4];
-int w = frame->width;
-int h = frame->height;
-int unaligned;
-ptrdiff_t linesize1[4];
-size_t size[4];
-
-avcodec_align_dimensions2(avctx, , , pool->stride_align);
-
-do {
-// NOTE: do not align linesizes individually, this breaks e.g. 
assumptions
-// that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2
-ret = av_image_fill_linesizes(linesize, avctx->pix_fmt, w);
-if (ret < 0)
-goto fail;
-// increase alignment of w for next try (rhs gives the lowest bit 
set in w)
-w += w & ~(w - 1);
-
-unaligned = 0;
-for (i = 0; i < 4; i++)
-unaligned |= linesize[i] % pool->stride_align[i];
-} while (unaligned);
-
-for (i = 0; i < 4; i++)
-linesize1[i] = linesize[i];
-ret = av_image_fill_plane_sizes(size, avctx->pix_fmt, 

[FFmpeg-cvslog] lavc/encode: drop EncodeSimpleContext

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr 11 
10:37:24 2022 +0200| [32413600e8d020fbab2c050c0b10b6e65533ddba] | committer: 
Anton Khirnov

lavc/encode: drop EncodeSimpleContext

It has only a single member.

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

 libavcodec/avcodec.c  |  4 ++--
 libavcodec/encode.c   |  7 +++
 libavcodec/internal.h | 12 +++-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index c7daa385e7..e0f38ac42a 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -432,7 +432,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0)
 av_packet_unref(avci->last_pkt_props);
 
-av_frame_unref(avci->es.in_frame);
+av_frame_unref(avci->in_frame);
 av_packet_unref(avci->in_pkt);
 
 if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
@@ -498,7 +498,7 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 av_packet_free(>last_pkt_props);
 
 av_packet_free(>in_pkt);
-av_frame_free(>es.in_frame);
+av_frame_free(>in_frame);
 
 av_buffer_unref(>pool);
 
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 305b732b1c..3d862a0c24 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -175,8 +175,7 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame 
*frame)
 static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
 {
 AVCodecInternal   *avci = avctx->internal;
-EncodeSimpleContext *es = >es;
-AVFrame  *frame = es->in_frame;
+AVFrame  *frame = avci->in_frame;
 const FFCodec *const codec = ffcodec(avctx->codec);
 int got_packet;
 int ret;
@@ -565,8 +564,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY;
 
 if (ffcodec(avctx->codec)->cb.encode) {
-avci->es.in_frame = av_frame_alloc();
-if (!avci->es.in_frame)
+avci->in_frame = av_frame_alloc();
+if (!avci->in_frame)
 return AVERROR(ENOMEM);
 }
 
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index f9d08fcb60..2fa56d3a59 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -47,10 +47,6 @@
 #   define STRIDE_ALIGN 8
 #endif
 
-typedef struct EncodeSimpleContext {
-AVFrame *in_frame;
-} EncodeSimpleContext;
-
 typedef struct AVCodecInternal {
 /**
  * When using frame-threaded decoding, this field is set for the first
@@ -101,7 +97,13 @@ typedef struct AVCodecInternal {
 
 void *frame_thread_encoder;
 
-EncodeSimpleContext es;
+/**
+ * The input frame is stored here for encoders implementing the simple
+ * encode API.
+ *
+ * Not allocated in other cases.
+ */
+AVFrame *in_frame;
 
 /**
  * If this is set, then FFCodec->close (if existing) needs to be called

___
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] fftools/ffmpeg: move freeing the output file to ffmpeg_mux.c

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Nov 10 
17:33:48 2021 +0100| [5c66ee6351ae3523206f64e5dc6c1768e438ed34] | committer: 
Anton Khirnov

fftools/ffmpeg: move freeing the output file to ffmpeg_mux.c

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

 fftools/ffmpeg.c | 14 ++
 fftools/ffmpeg.h |  1 +
 fftools/ffmpeg_mux.c | 17 +
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index cc7855a4cc..69d1949103 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -565,19 +565,9 @@ static void ffmpeg_cleanup(int ret)
 av_freep(_out);
 
 /* close files */
-for (i = 0; i < nb_output_files; i++) {
-OutputFile *of = output_files[i];
-AVFormatContext *s;
-if (!of)
-continue;
-s = of->ctx;
-if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE))
-avio_closep(>pb);
-avformat_free_context(s);
-av_dict_free(>opts);
+for (i = 0; i < nb_output_files; i++)
+of_close(_files[i]);
 
-av_freep(_files[i]);
-}
 for (i = 0; i < nb_output_streams; i++) {
 OutputStream *ost = output_streams[i];
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 4425b7a874..ff8ebbfab5 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -690,6 +690,7 @@ int hwaccel_decode_init(AVCodecContext *avctx);
 /* open the muxer when all the streams are initialized */
 int of_check_init(OutputFile *of);
 int of_write_trailer(OutputFile *of);
+void of_close(OutputFile **pof);
 
 void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost,
  int unqueue);
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 5348eef01d..3cdaa494d7 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -311,3 +311,20 @@ int of_write_trailer(OutputFile *of)
 
 return 0;
 }
+
+void of_close(OutputFile **pof)
+{
+OutputFile *of = *pof;
+AVFormatContext *s;
+
+if (!of)
+return;
+
+s = of->ctx;
+if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE))
+avio_closep(>pb);
+avformat_free_context(s);
+av_dict_free(>opts);
+
+av_freep(pof);
+}

___
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] lavc/avcodec: only allocate the encoding frame for encoders

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Mar 23 
14:17:57 2022 +0100| [1c01dca14471774b93a418127555d85ceb641333] | committer: 
Anton Khirnov

lavc/avcodec: only allocate the encoding frame for encoders

And only when needed, i.e. for encoders using the simple API.

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

 libavcodec/avcodec.c | 4 +---
 libavcodec/encode.c  | 7 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index dbaa9f78a2..c7daa385e7 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -180,14 +180,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 
 avci->buffer_frame = av_frame_alloc();
 avci->buffer_pkt = av_packet_alloc();
-avci->es.in_frame = av_frame_alloc();
 avci->in_pkt = av_packet_alloc();
 avci->last_pkt_props = av_packet_alloc();
 avci->pkt_props = av_fifo_alloc2(1, sizeof(*avci->last_pkt_props),
  AV_FIFO_FLAG_AUTO_GROW);
 if (!avci->buffer_frame || !avci->buffer_pkt  ||
-!avci->es.in_frame  || !avci->in_pkt ||
-!avci->last_pkt_props || !avci->pkt_props) {
+!avci->in_pkt || !avci->last_pkt_props || !avci->pkt_props) {
 ret = AVERROR(ENOMEM);
 goto free_and_end;
 }
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 3891ebcc91..305b732b1c 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -412,6 +412,7 @@ int attribute_align_arg 
avcodec_receive_packet(AVCodecContext *avctx, AVPacket *
 
 int ff_encode_preinit(AVCodecContext *avctx)
 {
+AVCodecInternal *avci = avctx->internal;
 int i;
 
 if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) {
@@ -563,5 +564,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY)
 avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY;
 
+if (ffcodec(avctx->codec)->cb.encode) {
+avci->es.in_frame = av_frame_alloc();
+if (!avci->es.in_frame)
+return AVERROR(ENOMEM);
+}
+
 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] lavc/avcodec: simplify codec id/type validity checking

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Mar 23 
14:11:03 2022 +0100| [7efa6418b83ae123770c6930f492edb87cd19274] | committer: 
Anton Khirnov

lavc/avcodec: simplify codec id/type validity checking

On entry to avcodec_open2(), the AVCodecContext type and id either have
to be UNKNOWN/NONE or have to match the codec to be used.

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

 libavcodec/avcodec.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index fbe4a5e413..dbaa9f78a2 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -158,17 +158,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 codec = avctx->codec;
 codec2 = ffcodec(codec);
 
-if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == 
codec->type) &&
-avctx->codec_id == AV_CODEC_ID_NONE) {
-avctx->codec_type = codec->type;
-avctx->codec_id   = codec->id;
-}
-if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type &&
- avctx->codec_type != 
AVMEDIA_TYPE_ATTACHMENT)) {
+if ((avctx->codec_type != AVMEDIA_TYPE_UNKNOWN && avctx->codec_type != 
codec->type) ||
+(avctx->codec_id   != AV_CODEC_ID_NONE && avctx->codec_id   != 
codec->id)) {
 av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
 return AVERROR(EINVAL);
 }
-avctx->codec = codec;
+
+avctx->codec_type = codec->type;
+avctx->codec_id   = codec->id;
+avctx->codec  = codec;
 
 if (avctx->extradata_size < 0 || avctx->extradata_size >= 
FF_MAX_EXTRADATA_SIZE)
 return AVERROR(EINVAL);

___
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] fftools/ffmpeg: move writing the trailer to ffmpeg_mux.c

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Nov 10 
15:21:47 2021 +0100| [5bc644ea8a6a0f8d02df36a12c1ce09bda696a77] | committer: 
Anton Khirnov

fftools/ffmpeg: move writing the trailer to ffmpeg_mux.c

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

 fftools/ffmpeg.c | 16 +++-
 fftools/ffmpeg.h |  1 +
 fftools/ffmpeg_mux.c | 21 +
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 47724f7231..cc7855a4cc 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4450,19 +4450,9 @@ static int transcode(void)
 
 /* write the trailer if needed */
 for (i = 0; i < nb_output_files; i++) {
-os = output_files[i]->ctx;
-if (!output_files[i]->header_written) {
-av_log(NULL, AV_LOG_ERROR,
-   "Nothing was written into output file %d (%s), because "
-   "at least one of its streams received no packets.\n",
-   i, os->url);
-continue;
-}
-if ((ret = av_write_trailer(os)) < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", 
os->url, av_err2str(ret));
-if (exit_on_error)
-exit_program(1);
-}
+ret = of_write_trailer(output_files[i]);
+if (ret < 0 && exit_on_error)
+exit_program(1);
 }
 
 /* dump report by using the first video and audio streams */
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index cb475bb690..4425b7a874 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -689,6 +689,7 @@ int hwaccel_decode_init(AVCodecContext *avctx);
 
 /* open the muxer when all the streams are initialized */
 int of_check_init(OutputFile *of);
+int of_write_trailer(OutputFile *of);
 
 void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost,
  int unqueue);
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 92d8a8c088..5348eef01d 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -290,3 +290,24 @@ int of_check_init(OutputFile *of)
 
 return 0;
 }
+
+int of_write_trailer(OutputFile *of)
+{
+int ret;
+
+if (!of->header_written) {
+av_log(NULL, AV_LOG_ERROR,
+   "Nothing was written into output file %d (%s), because "
+   "at least one of its streams received no packets.\n",
+   of->index, of->ctx->url);
+return AVERROR(EINVAL);
+}
+
+ret = av_write_trailer(of->ctx);
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", 
of->ctx->url, av_err2str(ret));
+return ret;
+}
+
+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] fftools/ffmpeg: store output format separately from the muxer context

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Nov 11 
10:35:15 2021 +0100| [4a7c8bb3d8cc793dab8baf110c1562980c4a3165] | committer: 
Anton Khirnov

fftools/ffmpeg: store output format separately from the muxer context

Allows accessing it without going through the muxer context. This will
be useful in the following commits, where the muxer context will be
hidden.

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

 fftools/ffmpeg.c | 18 ++
 fftools/ffmpeg.h |  2 ++
 fftools/ffmpeg_opt.c |  1 +
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 69d1949103..a85ed18b08 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2789,9 +2789,9 @@ static int init_output_stream_streamcopy(OutputStream 
*ost)
 
 if (!codec_tag) {
 unsigned int codec_tag_tmp;
-if (!of->ctx->oformat->codec_tag ||
-av_codec_get_id (of->ctx->oformat->codec_tag, par_src->codec_tag) 
== par_src->codec_id ||
-!av_codec_get_tag2(of->ctx->oformat->codec_tag, par_src->codec_id, 
_tag_tmp))
+if (!of->format->codec_tag ||
+av_codec_get_id (of->format->codec_tag, par_src->codec_tag) == 
par_src->codec_id ||
+!av_codec_get_tag2(of->format->codec_tag, par_src->codec_id, 
_tag_tmp))
 codec_tag = par_src->codec_tag;
 }
 
@@ -2809,7 +2809,7 @@ static int init_output_stream_streamcopy(OutputStream 
*ost)
 else
 ost->st->avg_frame_rate = ist->st->avg_frame_rate;
 
-ret = avformat_transfer_internal_stream_timing_info(of->ctx->oformat, 
ost->st, ist->st, copy_tb);
+ret = avformat_transfer_internal_stream_timing_info(of->format, ost->st, 
ist->st, copy_tb);
 if (ret < 0)
 return ret;
 
@@ -3011,7 +3011,8 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 InputStream *ist = get_input_stream(ost);
 AVCodecContext *enc_ctx = ost->enc_ctx;
 AVCodecContext *dec_ctx = NULL;
-AVFormatContext *oc = output_files[ost->file_index]->ctx;
+OutputFile  *of = output_files[ost->file_index];
+AVFormatContext *oc = of->ctx;
 int ret;
 
 set_encoder_id(output_files[ost->file_index], ost);
@@ -3072,7 +3073,8 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))
 enc_ctx->time_base = 
av_buffersink_get_time_base(ost->filter->filter);
 if (   av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != 
VSYNC_PASSTHROUGH
-   && (video_sync_method == VSYNC_CFR || video_sync_method == 
VSYNC_VSCFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & 
AVFMT_VARIABLE_FPS{
+   && (video_sync_method == VSYNC_CFR || video_sync_method == 
VSYNC_VSCFR ||
+   (video_sync_method == VSYNC_AUTO && !(of->format->flags & 
AVFMT_VARIABLE_FPS{
 av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not 
efficiently supporting it.\n"
"Please consider specifying a lower 
framerate, a different muxer or -vsync 2\n");
 }
@@ -3405,7 +3407,7 @@ static int transcode_init(void)
 /* write headers for files with no streams */
 for (i = 0; i < nb_output_files; i++) {
 oc = output_files[i]->ctx;
-if (oc->oformat->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
+if (output_files[i]->format->flags & AVFMT_NOSTREAMS && oc->nb_streams 
== 0) {
 ret = of_check_init(output_files[i]);
 if (ret < 0)
 goto dump_format;
@@ -4615,7 +4617,7 @@ int main(int argc, char **argv)
 }
 
 for (i = 0; i < nb_output_files; i++) {
-if (strcmp(output_files[i]->ctx->oformat->name, "rtp"))
+if (strcmp(output_files[i]->format->name, "rtp"))
 want_sdp = 0;
 }
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index ff8ebbfab5..9f0c093e34 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -579,6 +579,8 @@ typedef struct OutputStream {
 typedef struct OutputFile {
 int index;
 
+const AVOutputFormat *format;
+
 AVFormatContext *ctx;
 AVDictionary *opts;
 int ost_index;   /* index of the first stream in output_streams */
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index daecba9e57..47e8b9b7bd 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2332,6 +2332,7 @@ static int open_output_file(OptionsContext *o, const char 
*filename)
 }
 
 of->ctx = oc;
+of->format = oc->oformat;
 if (o->recording_time != INT64_MAX)
 oc->duration = o->recording_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] fftools/ffmpeg: move some muxing-related code into a separate file

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Nov 10 
14:51:48 2021 +0100| [288aa37387e93deefa66ff01f1ffae1d6a8988e3] | committer: 
Anton Khirnov

fftools/ffmpeg: move some muxing-related code into a separate file

This is a first step towards making muxers more independent from the
rest of the code.

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

 fftools/Makefile |   6 +-
 fftools/ffmpeg.c | 272 ++-
 fftools/ffmpeg.h |  10 ++
 fftools/ffmpeg_mux.c | 292 +++
 4 files changed, 314 insertions(+), 266 deletions(-)

diff --git a/fftools/Makefile b/fftools/Makefile
index 5ebf50d42e..81ad6c4f4f 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -9,7 +9,11 @@ AVBASENAMES  = ffmpeg ffplay ffprobe
 ALLAVPROGS   = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
 ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
 
-OBJS-ffmpeg+= fftools/ffmpeg_opt.o 
fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o
+OBJS-ffmpeg +=  \
+fftools/ffmpeg_filter.o \
+fftools/ffmpeg_hw.o \
+fftools/ffmpeg_mux.o\
+fftools/ffmpeg_opt.o\
 
 define DOFFTOOL
 OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o 
$(OBJS-$(1)-yes)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index bc700052b6..47724f7231 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -137,9 +137,9 @@ static int nb_frames_dup = 0;
 static unsigned dup_warning = 1000;
 static int nb_frames_drop = 0;
 static int64_t decode_error_stat[2];
-static unsigned nb_output_dumped = 0;
+unsigned nb_output_dumped = 0;
 
-static int want_sdp = 1;
+int want_sdp = 1;
 
 static BenchmarkTimeStamps current_time;
 AVIOContext *progress_avio = NULL;
@@ -345,7 +345,7 @@ static volatile int received_sigterm = 0;
 static volatile int received_nb_signals = 0;
 static atomic_int transcode_init_done = ATOMIC_VAR_INIT(0);
 static volatile int ffmpeg_exited = 0;
-static int main_return_code = 0;
+int main_return_code = 0;
 static int64_t copy_ts_first_pts = AV_NOPTS_VALUE;
 
 static void
@@ -711,159 +711,6 @@ static void update_benchmark(const char *fmt, ...)
 }
 }
 
-static void close_all_output_streams(OutputStream *ost, OSTFinished 
this_stream, OSTFinished others)
-{
-int i;
-for (i = 0; i < nb_output_streams; i++) {
-OutputStream *ost2 = output_streams[i];
-ost2->finished |= ost == ost2 ? this_stream : others;
-}
-}
-
-static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int 
unqueue)
-{
-AVFormatContext *s = of->ctx;
-AVStream *st = ost->st;
-int ret;
-
-/*
- * Audio encoders may split the packets --  #frames in != #packets out.
- * But there is no reordering, so we can limit the number of output packets
- * by simply dropping them here.
- * Counting encoded video frames needs to be done separately because of
- * reordering, see do_video_out().
- * Do not count the packet when unqueued because it has been counted when 
queued.
- */
-if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && 
ost->encoding_needed) && !unqueue) {
-if (ost->frame_number >= ost->max_frames) {
-av_packet_unref(pkt);
-return;
-}
-ost->frame_number++;
-}
-
-if (!of->header_written) {
-AVPacket *tmp_pkt;
-/* the muxer is not initialized yet, buffer the packet */
-if (!av_fifo_can_write(ost->muxing_queue)) {
-size_t cur_size = av_fifo_can_read(ost->muxing_queue);
-unsigned int are_we_over_size =
-(ost->muxing_queue_data_size + pkt->size) > 
ost->muxing_queue_data_threshold;
-size_t limit= are_we_over_size ? ost->max_muxing_queue_size : 
SIZE_MAX;
-size_t new_size = FFMIN(2 * cur_size, limit);
-
-if (new_size <= cur_size) {
-av_log(NULL, AV_LOG_ERROR,
-   "Too many packets buffered for output stream %d:%d.\n",
-   ost->file_index, ost->st->index);
-exit_program(1);
-}
-ret = av_fifo_grow2(ost->muxing_queue, new_size - cur_size);
-if (ret < 0)
-exit_program(1);
-}
-ret = av_packet_make_refcounted(pkt);
-if (ret < 0)
-exit_program(1);
-tmp_pkt = av_packet_alloc();
-if (!tmp_pkt)
-exit_program(1);
-av_packet_move_ref(tmp_pkt, pkt);
-ost->muxing_queue_data_size += tmp_pkt->size;
-av_fifo_write(ost->muxing_queue, _pkt, 1);
-return;
-}
-
-if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method 
== VSYNC_DROP) ||
-(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 
0))
-pkt->pts = pkt->dts = AV_NOPTS_VALUE;
-
-if 

[FFmpeg-cvslog] fftools/ffmpeg: store the output file index in OutputFile

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Dec 11 
13:22:36 2021 +0100| [b1a984cb4956e73e6b2bcc6463f4f1d9ba8b5a29] | committer: 
Anton Khirnov

fftools/ffmpeg: store the output file index in OutputFile

Use it to simplify check_init_output_file(). Will allow further
simplifications in the following commits.

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

 fftools/ffmpeg.c | 10 +-
 fftools/ffmpeg.h |  2 ++
 fftools/ffmpeg_opt.c |  1 +
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 29b01f9d93..bc700052b6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2947,7 +2947,7 @@ static int compare_int64(const void *a, const void *b)
 }
 
 /* open the muxer when all the streams are initialized */
-static int check_init_output_file(OutputFile *of, int file_index)
+static int check_init_output_file(OutputFile *of)
 {
 int ret, i;
 
@@ -2962,13 +2962,13 @@ static int check_init_output_file(OutputFile *of, int 
file_index)
 av_log(NULL, AV_LOG_ERROR,
"Could not write header for output file #%d "
"(incorrect codec parameters ?): %s\n",
-   file_index, av_err2str(ret));
+   of->index, av_err2str(ret));
 return ret;
 }
 //assert_avoptions(of->opts);
 of->header_written = 1;
 
-av_dump_format(of->ctx, file_index, of->ctx->url, 1);
+av_dump_format(of->ctx, of->index, of->ctx->url, 1);
 nb_output_dumped++;
 
 if (sdp_filename || want_sdp) {
@@ -3571,7 +3571,7 @@ static int init_output_stream(OutputStream *ost, AVFrame 
*frame,
 
 ost->initialized = 1;
 
-ret = check_init_output_file(output_files[ost->file_index], 
ost->file_index);
+ret = check_init_output_file(output_files[ost->file_index]);
 if (ret < 0)
 return ret;
 
@@ -3674,7 +3674,7 @@ static int transcode_init(void)
 for (i = 0; i < nb_output_files; i++) {
 oc = output_files[i]->ctx;
 if (oc->oformat->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
-ret = check_init_output_file(output_files[i], i);
+ret = check_init_output_file(output_files[i]);
 if (ret < 0)
 goto dump_format;
 }
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 04369df139..0eee6f4da8 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -577,6 +577,8 @@ typedef struct OutputStream {
 } OutputStream;
 
 typedef struct OutputFile {
+int index;
+
 AVFormatContext *ctx;
 AVDictionary *opts;
 int ost_index;   /* index of the first stream in output_streams */
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 8e217af4ab..daecba9e57 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2314,6 +2314,7 @@ static int open_output_file(OptionsContext *o, const char 
*filename)
 
 of = ALLOC_ARRAY_ELEM(output_files, nb_output_files);
 
+of->index  = nb_output_files - 1;
 of->ost_index  = nb_output_streams;
 of->recording_time = o->recording_time;
 of->start_time = o->start_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] fftools/ffmpeg: pass the muxer context explicitly to some functions

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Dec  4 
17:18:50 2021 +0100| [16aea9a38bbe1113b12f814def1d13251e76ecac] | committer: 
Anton Khirnov

fftools/ffmpeg: pass the muxer context explicitly to some functions

Stop accessing OutputFile.ctx. This will be useful in the following
commits, where it will become hidden.

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

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

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 22c88287df..8e217af4ab 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2125,10 +2125,10 @@ static int opt_streamid(void *optctx, const char *opt, 
const char *arg)
 return 0;
 }
 
-static int copy_chapters(InputFile *ifile, OutputFile *ofile, int 
copy_metadata)
+static int copy_chapters(InputFile *ifile, OutputFile *ofile, AVFormatContext 
*os,
+ int copy_metadata)
 {
 AVFormatContext *is = ifile->ctx;
-AVFormatContext *os = ofile->ctx;
 AVChapter **tmp;
 int i;
 
@@ -2168,14 +2168,14 @@ static int copy_chapters(InputFile *ifile, OutputFile 
*ofile, int copy_metadata)
 return 0;
 }
 
-static int set_dispositions(OutputFile *of)
+static int set_dispositions(OutputFile *of, AVFormatContext *ctx)
 {
 int nb_streams[AVMEDIA_TYPE_NB]   = { 0 };
 int have_default[AVMEDIA_TYPE_NB] = { 0 };
 int have_manual = 0;
 
 // first, copy the input dispositions
-for (int i = 0; i< of->ctx->nb_streams; i++) {
+for (int i = 0; i < ctx->nb_streams; i++) {
 OutputStream *ost = output_streams[of->ost_index + i];
 
 nb_streams[ost->st->codecpar->codec_type]++;
@@ -2192,7 +2192,7 @@ static int set_dispositions(OutputFile *of)
 
 if (have_manual) {
 // process manually set dispositions - they override the above copy
-for (int i = 0; i< of->ctx->nb_streams; i++) {
+for (int i = 0; i < ctx->nb_streams; i++) {
 OutputStream *ost = output_streams[of->ost_index + i];
 int ret;
 
@@ -2218,7 +2218,7 @@ static int set_dispositions(OutputFile *of)
 // For each media type with more than one stream, find a suitable 
stream to
 // mark as default, unless one is already marked default.
 // "Suitable" means the first of that type, skipping attached pictures.
-for (int i = 0; i< of->ctx->nb_streams; i++) {
+for (int i = 0; i < ctx->nb_streams; i++) {
 OutputStream *ost = output_streams[of->ost_index + i];
 enum AVMediaType type = ost->st->codecpar->codec_type;
 
@@ -2760,7 +2760,7 @@ loop_end:
 }
 }
 if (o->chapters_input_file >= 0)
-copy_chapters(input_files[o->chapters_input_file], of,
+copy_chapters(input_files[o->chapters_input_file], of, oc,
   !o->metadata_chapters_manual);
 
 /* copy global metadata by default */
@@ -2913,7 +2913,7 @@ loop_end:
 }
 }
 
-err = set_dispositions(of);
+err = set_dispositions(of, oc);
 if (err < 0) {
 av_log(NULL, AV_LOG_FATAL, "Error setting output stream 
dispositions\n");
 exit_program(1);

___
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] fftools/ffmpeg: stop using OutputStream.frame_number for streamcopy

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Mar 31 
16:34:29 2022 +0200| [662364b2efb3540c5b4a2b140601fab7a9c90367] | committer: 
Anton Khirnov

fftools/ffmpeg: stop using OutputStream.frame_number for streamcopy

This field is currently used by checks
- skipping packets before the first keyframe
- skipping packets before start time
to test whether any packets have been output already. But since
frame_number is incremented after the bitstream filters are applied
(which may involve delay), this use is incorrect. The keyframe check
works around this by adding an extra flag, the start-time check does
not.

Simplify both checks by replacing the seen_kf flag with a flag tracking
whether any packets have been output by do_streamcopy().

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

 fftools/ffmpeg.c | 10 +-
 fftools/ffmpeg.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 13be32f0cf..29b01f9d93 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -894,8 +894,6 @@ static void output_packet(OutputFile *of, AVPacket *pkt,
 
 /* apply the output bitstream filters */
 if (ost->bsf_ctx) {
-if (pkt->flags & AV_PKT_FLAG_KEY)
-ost->seen_kf = 1;
 ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt);
 if (ret < 0)
 goto finish;
@@ -2043,11 +2041,11 @@ static void do_streamcopy(InputStream *ist, 
OutputStream *ost, const AVPacket *p
 return;
 }
 
-if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) &&
-!ost->copy_initial_nonkeyframes && !ost->seen_kf)
+if (!ost->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) &&
+!ost->copy_initial_nonkeyframes)
 return;
 
-if (!ost->frame_number && !ost->copy_prior_start) {
+if (!ost->streamcopy_started && !ost->copy_prior_start) {
 int64_t comp_start = start_time;
 if (copy_ts && f->start_time != AV_NOPTS_VALUE)
 comp_start = FFMAX(start_time, f->start_time + f->ts_offset);
@@ -2101,6 +2099,8 @@ static void do_streamcopy(InputStream *ist, OutputStream 
*ost, const AVPacket *p
 ost->sync_opts += opkt->duration;
 
 output_packet(of, opkt, ost, 0);
+
+ost->streamcopy_started = 1;
 }
 
 int guess_input_channel_layout(InputStream *ist)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1e14bf9fa9..04369df139 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -536,7 +536,7 @@ typedef struct OutputStream {
 int inputs_done;
 
 const char *attachment_filename;
-int seen_kf;
+int streamcopy_started;
 int copy_initial_nonkeyframes;
 int copy_prior_start;
 char *disposition;

___
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] fftools/ffmpeg: move a comment to a more appropriate place

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 13 
15:24:19 2021 +0100| [86e1c0303cd6c33d8ff833e8c2fc84163baede06] | committer: 
Anton Khirnov

fftools/ffmpeg: move a comment to a more appropriate place

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

 fftools/ffmpeg.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index afa1b012a6..13be32f0cf 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1238,6 +1238,11 @@ static void do_video_out(OutputFile *of,
 }
 }
 
+/*
+ * For video, number of frames in == number of packets out.
+ * But there may be reordering, so we can't throw away frames on encoder
+ * flush, we need to limit them here, before they go into encoder.
+ */
 nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
 nb0_frames = FFMIN(nb0_frames, nb_frames);
 
@@ -1392,11 +1397,6 @@ static void do_video_out(OutputFile *of,
 }
 }
 ost->sync_opts++;
-/*
- * For video, number of frames in == number of packets out.
- * But there may be reordering, so we can't throw away frames on 
encoder
- * flush, we need to limit them here, before they go into encoder.
- */
 ost->frame_number++;
 
 if (vstats_filename && frame_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] fftools/ffmpeg: drop an obsolete hack

2022-04-13 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Mar 30 
12:31:28 2022 +0200| [a8c95e1febb9229cac8666872bfb35bf564cffda] | committer: 
Anton Khirnov

fftools/ffmpeg: drop an obsolete hack

Introduced in 05741d70c7a. All encoders should set the timestamps
properly now, so it should never be necessary.

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

 fftools/ffmpeg.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 6d62bdc7b0..afa1b012a6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1372,9 +1372,6 @@ static void do_video_out(OutputFile *of,
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, 
>time_base));
 }
 
-if (pkt->pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & 
AV_CODEC_CAP_DELAY))
-pkt->pts = ost->sync_opts;
-
 av_packet_rescale_ts(pkt, enc->time_base, ost->mux_timebase);
 
 if (debug_ts) {

___
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/vf_deblock: fix posible overreads

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Apr 13 10:20:59 
2022 +0200| [9a22c6508a413f62080801c2d08b24d064719fcb] | committer: Paul B Mahol

avfilter/vf_deblock: fix posible overreads

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

 libavfilter/vf_deblock.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_deblock.c b/libavfilter/vf_deblock.c
index b7c6a03d4a..770fce0eab 100644
--- a/libavfilter/vf_deblock.c
+++ b/libavfilter/vf_deblock.c
@@ -337,7 +337,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 s->deblockv(dst + x * s->bpc, out->linesize[plane],
 FFMIN(block, height), s->ath, s->bth, s->gth, s->dth, 
s->max);
 
-for (y = block; y < height; y += block) {
+for (y = block; y < height - block; y += block) {
 dst += out->linesize[plane] * block;
 
 s->deblockh(dst, out->linesize[plane],
@@ -353,6 +353,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 s->ath, s->bth, s->gth, s->dth, s->max);
 }
 }
+
+dst += out->linesize[plane] * block;
+for (x = block; x < width; x += block)
+s->deblockv(dst + x * s->bpc, out->linesize[plane],
+FFMIN(block, height - y), s->ath, s->bth, s->gth, 
s->dth, s->max);
+
 }
 
 if (in != out)

___
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/vf_xmedian: simplify changing index variable

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Apr 13 09:51:30 
2022 +0200| [b74f212b7a9eb6f66584c296375407c410a0d5d1] | committer: Paul B Mahol

avfilter/vf_xmedian: simplify changing index variable

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

 libavfilter/vf_xmedian.c | 34 ++
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/libavfilter/vf_xmedian.c b/libavfilter/vf_xmedian.c
index 155e464ba6..96b6721d98 100644
--- a/libavfilter/vf_xmedian.c
+++ b/libavfilter/vf_xmedian.c
@@ -188,6 +188,14 @@ static int median_frames ## name(AVFilterContext *ctx, 
void *arg, int jobnr, int
 MEDIAN_SLICE(8, uint8_t, compare8)
 MEDIAN_SLICE(16, uint16_t, compare16)
 
+static void update_index(XMedianContext *s)
+{
+if (s->nb_inputs & 1)
+s->index = s->radius * 2.f * s->percentile;
+else
+s->index = av_clip(s->radius * 2.f * s->percentile, 1, s->nb_inputs - 
1);
+}
+
 static int process_frame(FFFrameSync *fs)
 {
 AVFilterContext *ctx = fs->parent;
@@ -198,6 +206,8 @@ static int process_frame(FFFrameSync *fs)
 ThreadData td;
 int i, ret;
 
+update_index(s);
+
 for (i = 0; i < s->nb_inputs; i++) {
 if ((ret = ff_framesync_get_frame(>fs, i, [i], 0)) < 0)
 return ret;
@@ -319,24 +329,6 @@ static int activate(AVFilterContext *ctx)
 return ff_framesync_activate(>fs);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
-   char *res, int res_len, int flags)
-{
-XMedianContext *s = ctx->priv;
-int ret;
-
-ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-if (ret < 0)
-return ret;
-
-if (s->nb_inputs & 1)
-s->index = s->radius * 2.f * s->percentile;
-else
-s->index = av_clip(s->radius * 2.f * s->percentile, 1, s->nb_inputs - 
1);
-
-return 0;
-}
-
 #if CONFIG_XMEDIAN_FILTER
 static av_cold int xmedian_init(AVFilterContext *ctx)
 {
@@ -396,7 +388,7 @@ const AVFilter ff_vf_xmedian = {
 .activate  = activate,
 .flags = AVFILTER_FLAG_DYNAMIC_INPUTS | 
AVFILTER_FLAG_SLICE_THREADS |
  AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
-.process_command = process_command,
+.process_command = ff_filter_process_command,
 };
 
 #endif /* CONFIG_XMEDIAN_FILTER */
@@ -410,6 +402,8 @@ static int tmedian_filter_frame(AVFilterLink *inlink, 
AVFrame *in)
 ThreadData td;
 AVFrame *out;
 
+update_index(s);
+
 if (s->nb_frames < s->nb_inputs) {
 s->frames[s->nb_frames] = in;
 s->nb_frames++;
@@ -477,7 +471,7 @@ const AVFilter ff_vf_tmedian = {
 .init  = init,
 .uninit= uninit,
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | 
AVFILTER_FLAG_SLICE_THREADS,
-.process_command = process_command,
+.process_command = ff_filter_process_command,
 };
 
 #endif /* CONFIG_TMEDIAN_FILTER */

___
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/af_crystalizer: remove no longer needed wrapper function

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Apr 13 09:39:49 
2022 +0200| [9d40fe20c90bf6008d83aa905ab288709035c4ca] | committer: Paul B Mahol

avfilter/af_crystalizer: remove no longer needed wrapper function

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

 libavfilter/af_crystalizer.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/libavfilter/af_crystalizer.c b/libavfilter/af_crystalizer.c
index 3e840d0439..449f24a082 100644
--- a/libavfilter/af_crystalizer.c
+++ b/libavfilter/af_crystalizer.c
@@ -224,18 +224,6 @@ static av_cold void uninit(AVFilterContext *ctx)
 av_frame_free(>prev);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
-   char *res, int res_len, int flags)
-{
-int ret;
-
-ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-if (ret < 0)
-return ret;
-
-return config_input(ctx->inputs[0]);
-}
-
 static const AVFilterPad inputs[] = {
 {
 .name = "default",
@@ -262,7 +250,7 @@ const AVFilter ff_af_crystalizer = {
 FILTER_OUTPUTS(outputs),
 FILTER_SAMPLEFMTS(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
   AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP),
-.process_command = process_command,
+.process_command = ff_filter_process_command,
 .flags  = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
   AVFILTER_FLAG_SLICE_THREADS,
 };

___
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/vf_chromashift: simplify handling of commands

2022-04-13 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Apr 13 09:28:26 
2022 +0200| [63d12a48b574ae52691246486ba13cda4dae8a44] | committer: Paul B Mahol

avfilter/vf_chromashift: simplify handling of commands

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

 libavfilter/vf_chromashift.c | 32 
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/libavfilter/vf_chromashift.c b/libavfilter/vf_chromashift.c
index 0d197b1344..2ddfa61726 100644
--- a/libavfilter/vf_chromashift.c
+++ b/libavfilter/vf_chromashift.c
@@ -49,7 +49,7 @@ typedef struct ChromaShiftContext {
 AVFrame *in;
 
 int is_rgbashift;
-int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
+int (*filter_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
 } ChromaShiftContext;
 
 #define DEFINE_SMEAR(depth, type, div) 
   \
@@ -326,7 +326,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 in->data[0], in->linesize[0],
 s->linesize[0], s->height[0]);
 }
-ff_filter_execute(ctx, s->filter_slice, out, NULL,
+ff_filter_execute(ctx, s->filter_slice[s->edge], out, NULL,
   FFMIN3(s->height[1],
  s->height[2],
  ff_filter_get_nb_threads(ctx)));
@@ -345,15 +345,11 @@ static int config_input(AVFilterLink *inlink)
 s->depth = desc->comp[0].depth;
 s->nb_planes = desc->nb_components;
 if (s->is_rgbashift) {
-if (s->edge)
-s->filter_slice = s->depth > 8 ? rgbawrap_slice16 : 
rgbawrap_slice8;
-else
-s->filter_slice = s->depth > 8 ? rgbasmear_slice16 : 
rgbasmear_slice8;
+s->filter_slice[1] = s->depth > 8 ? rgbawrap_slice16 : rgbawrap_slice8;
+s->filter_slice[0] = s->depth > 8 ? rgbasmear_slice16 : 
rgbasmear_slice8;
 } else {
-if (s->edge)
-s->filter_slice = s->depth > 8 ? wrap_slice16 : wrap_slice8;
-else
-s->filter_slice = s->depth > 8 ? smear_slice16 : smear_slice8;
+s->filter_slice[1] = s->depth > 8 ? wrap_slice16 : wrap_slice8;
+s->filter_slice[0] = s->depth > 8 ? smear_slice16 : smear_slice8;
 }
 s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, 
desc->log2_chroma_h);
 s->height[0] = s->height[3] = inlink->h;
@@ -363,18 +359,6 @@ static int config_input(AVFilterLink *inlink)
 return av_image_fill_linesizes(s->linesize, inlink->format, inlink->w);
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
-   char *res, int res_len, int flags)
-{
-int ret;
-
-ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
-if (ret < 0)
-return ret;
-
-return config_input(ctx->inputs[0]);
-}
-
 #define OFFSET(x) offsetof(ChromaShiftContext, x)
 #define VFR AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | 
AV_OPT_FLAG_RUNTIME_PARAM
 
@@ -431,7 +415,7 @@ const AVFilter ff_vf_chromashift = {
 FILTER_INPUTS(inputs),
 FILTER_PIXFMTS_ARRAY(yuv_pix_fmts),
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | 
AVFILTER_FLAG_SLICE_THREADS,
-.process_command = process_command,
+.process_command = ff_filter_process_command,
 };
 
 static const enum AVPixelFormat rgb_pix_fmts[] = {
@@ -468,5 +452,5 @@ const AVFilter ff_vf_rgbashift = {
 FILTER_INPUTS(inputs),
 FILTER_PIXFMTS_ARRAY(rgb_pix_fmts),
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | 
AVFILTER_FLAG_SLICE_THREADS,
-.process_command = process_command,
+.process_command = ff_filter_process_command,
 };

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