[FFmpeg-cvslog] avfilter: add showcwt multimedia filter

2022-11-28 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Nov 19 19:01:23 
2022 +0100| [d34c1b389ee6395ba81eec4d50316f189681da5d] | committer: Paul B Mahol

avfilter: add showcwt multimedia filter

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

 Changelog |   1 +
 doc/filters.texi  |  96 ++
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/avf_showcwt.c | 837 ++
 libavfilter/version.h |   4 +-
 6 files changed, 938 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 2e9d9f75ea..8a3f3550a8 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
 - oneVPL support for QSV
 - QSV AV1 encoder
 - QSV decoding and encoding for 10/12bit 422, 10/12bit 444 HEVC and VP9
+- showcwt multimedia filter
 
 
 version 5.1:
diff --git a/doc/filters.texi b/doc/filters.texi
index ecf8dfa47a..c25d7aaecc 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -29274,6 +29274,102 @@ axisfile=myaxis.png:basefreq=40:endfreq=1
 @end example
 @end itemize
 
+@section showcwt
+
+Convert input audio to video output representing frequency spectrum
+using Continuous Wavelet Transform and Morlet wavelet.
+
+The filter accepts the following options:
+
+@table @option
+@item size, s
+Specify the video size for the output. For the syntax of this option,
+check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils 
manual,ffmpeg-utils}.
+Default value is @code{640x512}.
+
+@item rate, r
+Set the output frame rate. Default value is @code{25}.
+
+@item scale
+Set the frequency scale used. Allowed values are:
+
+@table @option
+@item linear
+@item log2
+@item bark
+@item mel
+@item erbs
+@end table
+Default value is @code{linear}.
+
+@item min
+Set the minimum frequency that will be used in output.
+Default is @code{20} Hz.
+
+@item max
+Set the maximum frequency that will be used in output.
+Default is @code{2} Hz. The real frequency upper limit
+depends on input audio's sample rate and such will be enforced
+on this value when it is set to value greater than Nyquist frequency.
+
+@item logb
+Set the logarithmic basis for brightness strength when
+mapping calculated magnitude values to pixel values.
+Allowed range is from @code{0} to @code{1}.
+Default value is @code{0.0001}.
+
+@item deviation
+Set the frequency deviation.
+Lower values than @code{1} are more frequency oriented,
+while higher values than @code{1} are more time oriented.
+Allowed range is from @code{0} to @code{10}.
+Default value is @code{1}.
+
+@item pps
+Set the number of pixel output per each second in one row.
+Allowed range is from @code{1} to @code{1024}.
+Default value is @code{64}.
+
+@item mode
+Set the output visual mode. Allowed values are:
+
+@table @option
+@item magnitude
+Show magnitude.
+@item phase
+Show only phase.
+@item magphase
+Show combination of magnitude and phase.
+Magnitude is mapped to brightness and phase to color.
+@item channel
+Show unique color per channel magnitude.
+@end table
+
+Default value is @code{magnitude}.
+
+@item slide
+Set the output slide method. Allowed values are:
+
+@table @option
+@item replace
+@item scroll
+@end table
+
+@item direction
+Set the direction method for output slide method. Allowed values are:
+
+@table @option
+@item lr
+Direction from left to right.
+@item rl
+Direction from right to left.
+@item ud
+Direction from up to down.
+@item du
+Direction from down to up.
+@end table
+@end table
+
 @section showfreqs
 
 Convert input audio to video output representing the audio power spectrum.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ace0e60ba1..3c6a7b03f4 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -593,6 +593,7 @@ OBJS-$(CONFIG_APHASEMETER_FILTER)+= 
avf_aphasemeter.o
 OBJS-$(CONFIG_AVECTORSCOPE_FILTER)   += avf_avectorscope.o
 OBJS-$(CONFIG_CONCAT_FILTER) += avf_concat.o
 OBJS-$(CONFIG_SHOWCQT_FILTER)+= avf_showcqt.o lswsutils.o 
lavfutils.o
+OBJS-$(CONFIG_SHOWCWT_FILTER)+= avf_showcwt.o
 OBJS-$(CONFIG_SHOWFREQS_FILTER)  += avf_showfreqs.o
 OBJS-$(CONFIG_SHOWSPATIAL_FILTER)+= avf_showspatial.o
 OBJS-$(CONFIG_SHOWSPECTRUM_FILTER)   += avf_showspectrum.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index e0598e9986..347afa787b 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -558,6 +558,7 @@ extern const AVFilter ff_avf_aphasemeter;
 extern const AVFilter ff_avf_avectorscope;
 extern const AVFilter ff_avf_concat;
 extern const AVFilter ff_avf_showcqt;
+extern const AVFilter ff_avf_showcwt;
 extern const AVFilter ff_avf_showfreqs;
 extern const AVFilter ff_avf_showspatial;
 extern const AVFilter ff_avf_showspectrum;
diff --git a/libavfilter/avf_showcwt.c b/libavfilter/avf_showcwt.c
new file mode 100644
index 

[FFmpeg-cvslog] avcodec/mobiclip: Check input size before (re)allocation

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov 18 20:54:12 2022 +0100| [93810a625cb7d0dc174576951519ce72321c9f66] | 
committer: Michael Niedermayer

avcodec/mobiclip: Check input size before (re)allocation

Fixes: Timeout
Fixes: 
52566/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-4913160050311168

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

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

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

diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
index aca462428c..c3b2383dbc 100644
--- a/libavcodec/mobiclip.c
+++ b/libavcodec/mobiclip.c
@@ -1216,6 +1216,9 @@ static int mobiclip_decode(AVCodecContext *avctx, AVFrame 
*rframe,
 AVFrame *frame = s->pic[s->current_pic];
 int ret;
 
+if (avctx->height/16 * (avctx->width/16) * 2 > 8LL*FFALIGN(pkt->size, 2))
+return AVERROR_INVALIDDATA;
+
 av_fast_padded_malloc(>bitstream, >bitstream_size,
   pkt->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] avcodec/h263dec: Avoid parsing extradata repeatedly

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov 18 00:07:05 2022 +0100| [b32316923df0fb932d4e553705328755d3096165] | 
committer: Michael Niedermayer

avcodec/h263dec: Avoid parsing extradata repeatedly

Fixes: Timeout
Fixes: 
52329/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-4716563886637056

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

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

 libavcodec/h263dec.c   | 3 ++-
 libavcodec/mpegvideo.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 71b846ba74..ac7a8521e5 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -492,11 +492,12 @@ retry:
 } else if (CONFIG_MSMPEG4DEC && s->msmpeg4_version) {
 ret = ff_msmpeg4_decode_picture_header(s);
 } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
-if (s->avctx->extradata_size && s->picture_number == 0) {
+if (s->avctx->extradata_size && !s->extradata_parsed) {
 GetBitContext gb;
 
 if (init_get_bits8(, s->avctx->extradata, 
s->avctx->extradata_size) >= 0 )
 ff_mpeg4_decode_picture_header(avctx->priv_data, , 1, 0);
+s->extradata_parsed = 1;
 }
 ret = ff_mpeg4_decode_picture_header(avctx->priv_data, >gb, 0, 0);
 } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index ccec0dd75f..6440b906b1 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -117,6 +117,7 @@ typedef struct MpegEncContext {
 int input_picture_number;  ///< used to set pic->display_picture_number, 
should not be used for/by anything else
 int coded_picture_number;  ///< used to set pic->coded_picture_number, 
should not be used for/by anything else
 int picture_number;   //FIXME remove, unclear definition
+int extradata_parsed;
 int picture_in_gop_number; ///< 0-> first pic in gop, ...
 int mb_width, mb_height;   ///< number of MBs horizontally & vertically
 int mb_stride; ///< mb_width+1 used for some arrays to allow 
simple addressing of left & top MBs without sig11

___
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/tiff: Avoid 0.0/0.0 in camera_xyz_coeff()

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Nov 17 23:18:01 2022 +0100| [ff2d1bbe737539b9f564e53f84b7309bc2a38243] | 
committer: Michael Niedermayer

avcodec/tiff: Avoid 0.0/0.0 in camera_xyz_coeff()

Fixes: division by zero
Fixes: 
52230/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5922608915021824

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

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

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 5b56892071..cde318d5e5 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1896,6 +1896,8 @@ static void camera_xyz_coeff(TiffContext *s,
 for (i = 0; i < 3; i++) {
 for (num = j = 0; j < 3; j++)
 num += cam2rgb[i][j];
+if (!num)
+num = 1;
 for (j = 0; j < 3; j++)
 cam2rgb[i][j] /= num;
 s->premultiply[i] = 1.f / 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] avformat/id3v2: Check taglen in read_uslt()

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov 18 19:04:47 2022 +0100| [a798af91d7d1fc31cfc1ae09cc6ab3907304f44f] | 
committer: Michael Niedermayer

avformat/id3v2: Check taglen in read_uslt()

Fixes: Timeout (read mostly the same data repeatly)
Fixes: 
52457/clusterfuzz-testcase-minimized-ffmpeg_dem_ALP_fuzzer-6610706313379840
Fixes: 
53098/clusterfuzz-testcase-minimized-ffmpeg_dem_SOL_fuzzer-6481382981632000

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

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

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

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 191a305ffb..cb31864045 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -377,10 +377,10 @@ static void read_uslt(AVFormatContext *s, AVIOContext 
*pb, int taglen,
 lang[3] = '\0';
 taglen -= 3;
 
-if (decode_str(s, pb, encoding, , ) < 0)
+if (decode_str(s, pb, encoding, , ) < 0 || taglen < 0)
 goto error;
 
-if (decode_str(s, pb, encoding, , ) < 0)
+if (decode_str(s, pb, encoding, , ) < 0 || taglen < 0)
 goto error;
 
 // FFmpeg does not support hierarchical metadata, so concatenate the keys.

___
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/tiff: Ignore tile_count

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov 18 18:26:59 2022 +0100| [65ce417828cc6f5209d8467bc7755f0c59e9aa49] | 
committer: Michael Niedermayer

avcodec/tiff: Ignore tile_count

Fixes: out of array access
Fixes: 
52427/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4849108968144896

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

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

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index cde318d5e5..41b5a6b7e4 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -110,7 +110,6 @@ typedef struct TiffContext {
 int is_tiled;
 int tile_byte_counts_offset, tile_offsets_offset;
 int tile_width, tile_length;
-int tile_count;
 
 int is_jpeg;
 
@@ -994,7 +993,7 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame 
*frame,
 tile_count_y = (s->height + s->tile_length - 1) / s->tile_length;
 
 /* Iterate over the number of tiles */
-for (tile_idx = 0; tile_idx < s->tile_count; tile_idx++) {
+for (tile_idx = 0; tile_idx < tile_count_x * tile_count_y; tile_idx++) {
 tile_x = tile_idx % tile_count_x;
 tile_y = tile_idx / tile_count_x;
 
@@ -1430,7 +1429,6 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
 break;
 case TIFF_TILE_OFFSETS:
 s->tile_offsets_offset = off;
-s->tile_count = count;
 s->is_tiled = 1;
 break;
 case TIFF_TILE_BYTE_COUNTS:
@@ -2096,7 +2094,7 @@ again:
 return AVERROR_INVALIDDATA;
 }
 
-has_tile_bits  = s->is_tiled || s->tile_byte_counts_offset || 
s->tile_offsets_offset || s->tile_width || s->tile_length || s->tile_count;
+has_tile_bits  = s->is_tiled || s->tile_byte_counts_offset || 
s->tile_offsets_offset || s->tile_width || s->tile_length;
 has_strip_bits = s->strippos || s->strips || s->stripoff || s->rps || 
s->sot || s->sstype || s->stripsize || s->stripsizesoff;
 
 if (has_tile_bits && has_strip_bits) {

___
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/apac: use unsigned for sample residual

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed 
Nov 16 22:01:34 2022 +0100| [b2c1a0fc2b196d4cdbaae5b120229138857b559f] | 
committer: Michael Niedermayer

avcodec/apac: use unsigned for sample residual

Fixes: signed integer overflow: -2146670226 + -2227242 cannot be represented in 
type 'int'
Fixes: 
51943/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APAC_fuzzer-5779018251370496

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

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

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

diff --git a/libavcodec/apac.c b/libavcodec/apac.c
index 784abb622c..030f81adce 100644
--- a/libavcodec/apac.c
+++ b/libavcodec/apac.c
@@ -208,7 +208,7 @@ static int apac_decode(AVCodecContext *avctx, AVFrame 
*frame,
 
 for (int i = 0; i < c->block_length; i++) {
 int val = get_bits_long(gb, c->bit_length);
-int delta = (val & 1) ? ~(val >> 1) : (val >> 1);
+unsigned delta = (val & 1) ? ~(val >> 1) : (val >> 1);
 int sample;
 
 delta += c->last_delta;

___
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/ffv1dec: restructure slice coordinate reading a bit

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Nov 22 23:34:22 2022 +0100| [74b6ac7ebb5c1e06a5fdfa29f79a18599942dbfa] | 
committer: Michael Niedermayer

avcodec/ffv1dec: restructure slice coordinate reading a bit

Fixes: signed integer overflow: -1094995528 * 8224 cannot be represented in 
type 'int'
Fixes: 
53508/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-474551033462784

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

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

 libavcodec/ffv1dec.c | 65 ++--
 1 file changed, 38 insertions(+), 27 deletions(-)

diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index b1cfc4bf57..d74786cec3 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -168,24 +168,31 @@ static int decode_slice_header(const FFV1Context *f, 
FFV1Context *fs)
 RangeCoder *c = >c;
 uint8_t state[CONTEXT_SIZE];
 unsigned ps, i, context_count;
+int sx, sy, sw, sh;
+
 memset(state, 128, sizeof(state));
+sx = get_symbol(c, state, 0);
+sy = get_symbol(c, state, 0);
+sw = get_symbol(c, state, 0) + 1U;
+sh = get_symbol(c, state, 0) + 1U;
 
 av_assert0(f->version > 2);
 
-fs->slice_x  =  get_symbol(c, state, 0)  * f->width ;
-fs->slice_y  =  get_symbol(c, state, 0)  * f->height;
-fs->slice_width  = (get_symbol(c, state, 0) + 1) * f->width  + fs->slice_x;
-fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
-
-fs->slice_x /= f->num_h_slices;
-fs->slice_y /= f->num_v_slices;
-fs->slice_width  = fs->slice_width /f->num_h_slices - fs->slice_x;
-fs->slice_height = fs->slice_height/f->num_v_slices - fs->slice_y;
-if ((unsigned)fs->slice_width > f->width || (unsigned)fs->slice_height > 
f->height)
-return -1;
-if ((unsigned)fs->slice_x + (uint64_t)fs->slice_width  > f->width
- || (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
-return -1;
+
+if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
+return AVERROR_INVALIDDATA;
+if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh)
+return AVERROR_INVALIDDATA;
+
+fs->slice_x  =  sx   * (int64_t)f->width  / f->num_h_slices;
+fs->slice_y  =  sy   * (int64_t)f->height / f->num_v_slices;
+fs->slice_width  = (sx + sw) * (int64_t)f->width  / f->num_h_slices - 
fs->slice_x;
+fs->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - 
fs->slice_y;
+
+av_assert0((unsigned)fs->slice_width  <= f->width &&
+(unsigned)fs->slice_height <= f->height);
+av_assert0 (   (unsigned)fs->slice_x + (uint64_t)fs->slice_width  <= 
f->width
+&& (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= 
f->height);
 
 if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23))
 return AVERROR_INVALIDDATA;
@@ -770,21 +777,25 @@ static int read_header(FFV1Context *f)
 fs->slice_damaged = 0;
 
 if (f->version == 2) {
-fs->slice_x  =  get_symbol(c, state, 0)  * f->width ;
-fs->slice_y  =  get_symbol(c, state, 0)  * f->height;
-fs->slice_width  = (get_symbol(c, state, 0) + 1) * f->width  + 
fs->slice_x;
-fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + 
fs->slice_y;
-
-fs->slice_x /= f->num_h_slices;
-fs->slice_y /= f->num_v_slices;
-fs->slice_width  = fs->slice_width  / f->num_h_slices - 
fs->slice_x;
-fs->slice_height = fs->slice_height / f->num_v_slices - 
fs->slice_y;
-if ((unsigned)fs->slice_width  > f->width ||
-(unsigned)fs->slice_height > f->height)
+int sx = get_symbol(c, state, 0);
+int sy = get_symbol(c, state, 0);
+int sw = get_symbol(c, state, 0) + 1U;
+int sh = get_symbol(c, state, 0) + 1U;
+
+if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
 return AVERROR_INVALIDDATA;
-if (   (unsigned)fs->slice_x + (uint64_t)fs->slice_width  > 
f->width
-|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > 
f->height)
+if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh)
 return AVERROR_INVALIDDATA;
+
+fs->slice_x  =  sx   * (int64_t)f->width  / 
f->num_h_slices;
+fs->slice_y  =  sy   * (int64_t)f->height / 
f->num_v_slices;
+fs->slice_width  = (sx + sw) * (int64_t)f->width  / 
f->num_h_slices - fs->slice_x;
+fs->slice_height = (sy + sh) * (int64_t)f->height / 
f->num_v_slices - fs->slice_y;
+
+av_assert0((unsigned)fs->slice_width  <= f->width &&
+   (unsigned)fs->slice_height <= f->height);

[FFmpeg-cvslog] avcodec/pictordec: Remove mid exit branch

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov 25 14:29:32 2022 +0100| [88f0e05c72f0de0cae3d9f0c5644f1965632b641] | 
committer: Michael Niedermayer

avcodec/pictordec: Remove mid exit branch

This causes the RLE decoder to exit before applying the last RLE run
All images i tested with are unchanged, this makes the special case
for handling the last run unused for non truncated images.

Reviewed-by: Peter Ross 
Signed-off-by: Michael Niedermayer 

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

 libavcodec/pictordec.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
index 1c07aa98f4..aef3d3de76 100644
--- a/libavcodec/pictordec.c
+++ b/libavcodec/pictordec.c
@@ -262,8 +262,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 run = bytestream2_get_le16(>g);
 val = bytestream2_get_byte(>g);
 }
-if (!bytestream2_get_bytes_left(>g))
-break;
 
 if (bits_per_plane == 8) {
 picmemset_8bpp(s, frame, val, run, , );

___
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/mlpdec: Check max matrix instead of max channel in noise check

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Nov 21 22:59:55 2022 +0100| [aa79560de5e9596ada0345e5d12aa00dbeddaaa6] | 
committer: Michael Niedermayer

avcodec/mlpdec: Check max matrix instead of max channel in noise check

This is a regression since: adaa06581c5444c94eef72d61b8166f096e2687a
Before this, max_channel and  max_matrix_channel where compared for equality

Fixes: out of array access
Fixes: 
53340/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-514959011885875

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

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

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

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 0b0eb75990..5b14a3b03b 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -539,7 +539,7 @@ static int read_restart_header(MLPDecodeContext *m, 
GetBitContext *gbp,
 
 /* This should happen for TrueHD streams with >6 channels and MLP's noise
  * type. It is not yet known if this is allowed. */
-if (max_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) {
+if (max_matrix_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) {
 avpriv_request_sample(m->avctx,
   "%d channels (more than the "
   "maximum supported by the decoder)",

___
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/bonk: Use unsigned in predictor_init_state() to avoid undefined behavior

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed 
Nov 16 14:11:51 2022 +0100| [8f975641d7e853bd8e407974db5fba998e6eb5f4] | 
committer: Michael Niedermayer

avcodec/bonk: Use unsigned in predictor_init_state() to avoid undefined behavior

Fixes: signed integer overflow: -5010 * -717450 cannot be represented in type 
'int'
Fixes: 
53370/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-4945644204195840

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

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

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

diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c
index 4793bf2561..182b5ef459 100644
--- a/libavcodec/bonk.c
+++ b/libavcodec/bonk.c
@@ -280,10 +280,10 @@ static int predictor_calc_error(int *k, int *state, int 
order, int error)
 return x;
 }
 
-static void predictor_init_state(int *k, int *state, int order)
+static void predictor_init_state(int *k, unsigned *state, int order)
 {
 for (int i = order - 2; i >= 0; i--) {
-int x = state[i];
+unsigned x = state[i];
 
 for (int j = 0, p = i + 1; p < order; j++, p++) {
 int tmp = x + shift_down(k[j] * state[p], LATTICE_SHIFT);

___
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/pictordec: Check that the image fits in the input

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Nov 22 21:54:51 2022 +0100| [1fdb65d2b7e23d042c211f1afe5e673233fd24c6] | 
committer: Michael Niedermayer

avcodec/pictordec: Check that the image fits in the input

Fixes: Timeout
Fixes: 
53438/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-5458939919859712

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

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

 libavcodec/pictordec.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
index 71bad40a0a..1c07aa98f4 100644
--- a/libavcodec/pictordec.c
+++ b/libavcodec/pictordec.c
@@ -162,6 +162,25 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 
 if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
 return -1;
+
+/*
+There are 2 coding modes, RLE and RAW.
+Undamaged RAW should be proportional to W*H and thus bigger than RLE
+RLE codes the most compressed runs by
+1 byte for val (=marker)
+1 byte run (=0)
+2 bytes run
+1 byte val
+thats 5 bytes and the maximum run we can code is 65535
+
+The RLE decoder can exit prematurly but it does not on any image 
available
+Based on this the formula is assumed correct for undamaged images.
+If an image is found which exploits the special end
+handling and breaks this formula then this needs to be adapted.
+*/
+if (bytestream2_get_bytes_left(>g) < s->width * s->height / 65535 * 5)
+return AVERROR_INVALIDDATA;
+
 if (s->width != avctx->width || s->height != avctx->height) {
 ret = ff_set_dimensions(avctx, s->width, s->height);
 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/dts2pts_bsf: Eliminate some 64bit corner cases

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Nov 21 23:59:49 2022 +0100| [5185d5656b5fc37541606a804f831e08e434baab] | 
committer: Michael Niedermayer

avcodec/dts2pts_bsf: Eliminate some 64bit corner cases

Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an 
unsigned type to negate this value to itself
Fixes: 
53364/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-4693772269387776

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

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

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

diff --git a/libavcodec/dts2pts_bsf.c b/libavcodec/dts2pts_bsf.c
index 8142562d2c..522d5e1eb0 100644
--- a/libavcodec/dts2pts_bsf.c
+++ b/libavcodec/dts2pts_bsf.c
@@ -301,15 +301,15 @@ static int h264_filter(AVBSFContext *ctx)
 
 if (output_picture_number != h264->last_poc) {
 if (h264->last_poc != INT_MIN) {
-int diff = FFABS(h264->last_poc - output_picture_number);
+int64_t diff = FFABS(h264->last_poc - 
(int64_t)output_picture_number);
 
 if ((output_picture_number < 0) && !h264->last_poc)
 h264->poc_diff = 0;
-else if (FFABS(output_picture_number) < h264->poc_diff) {
+else if (FFABS((int64_t)output_picture_number) < 
h264->poc_diff) {
 diff = FFABS(output_picture_number);
 h264->poc_diff = 0;
 }
-if (!h264->poc_diff || (h264->poc_diff > diff)) {
+if ((!h264->poc_diff || (h264->poc_diff > diff)) && diff 
<= INT_MAX) {
 h264->poc_diff = diff;
 if (h264->poc_diff == 1 && 
h264->sps.frame_mbs_only_flag) {
 av_tree_enumerate(s->root, >poc_diff, NULL, 
dec_poc);

___
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/tx: Use unsigned in ff_tx_fft_sr_combine() to avoid undefined behavior

2022-11-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Nov 21 00:20:14 2022 +0100| [7792825ad6b84f54f5a7fd7f90a907291363c419] | 
committer: Michael Niedermayer

avutil/tx: Use unsigned in ff_tx_fft_sr_combine() to avoid undefined behavior

Fixes: signed integer overflow: -1284837070 - 982101618 cannot be represented 
in type 'int'
Fixes: 
53105/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-4848015827664896

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

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

 libavutil/tx_priv.h | 3 +++
 libavutil/tx_template.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index 8a79cf0dd3..72f336eea7 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -34,6 +34,7 @@
 #define MULT(x, m) ((x) * (m))
 #define SCALE_TYPE float
 typedef float TXSample;
+typedef float TXUSample;
 typedef AVComplexFloat TXComplex;
 #elif defined(TX_DOUBLE)
 #define TX_TAB(x) x ## _double
@@ -45,6 +46,7 @@ typedef AVComplexFloat TXComplex;
 #define MULT(x, m) ((x) * (m))
 #define SCALE_TYPE double
 typedef double TXSample;
+typedef double TXUSample;
 typedef AVComplexDouble TXComplex;
 #elif defined(TX_INT32)
 #define TX_TAB(x) x ## _int32
@@ -56,6 +58,7 @@ typedef AVComplexDouble TXComplex;
 #define MULT(x, m) (int64_t)(x)) * (int64_t)(m)) + 0x4000) >> 31)
 #define SCALE_TYPE float
 typedef int32_t TXSample;
+typedef uint32_t TXUSample;
 typedef AVComplexInt32 TXComplex;
 #else
 typedef void TXComplex;
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index 1de92b9786..56e4f6b04d 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -563,7 +563,7 @@ static inline void TX_NAME(ff_tx_fft_sr_combine)(TXComplex 
*z,
 int o2 = 4*len;
 int o3 = 6*len;
 const TXSample *wim = cos + o1 - 7;
-TXSample t1, t2, t3, t4, t5, t6, r0, i0, r1, i1;
+TXUSample t1, t2, t3, t4, t5, t6, r0, i0, r1, i1;
 
 for (int i = 0; i < len; i += 4) {
 TRANSFORM(z[0], z[o1 + 0], z[o2 + 0], z[o3 + 0], cos[0], wim[7]);

___
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] x86/tx_float: fix stray change in 15xM FFT and replace imul->lea

2022-11-28 Thread Lynne
ffmpeg | branch: master | Lynne  | Mon Nov 28 04:15:36 2022 
+0100| [90c17a05aab798199f3cdafb7cab61f666f132be] | committer: Hendrik Leppkes

x86/tx_float: fix stray change in 15xM FFT and replace imul->lea

Thanks to rorgoroth for bisecting and kurosu for the lea suggestion.

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

 libavutil/x86/tx_float.asm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm
index 2ad84c2885..e1533a8595 100644
--- a/libavutil/x86/tx_float.asm
+++ b/libavutil/x86/tx_float.asm
@@ -1772,7 +1772,7 @@ IMDCT_FN avx2
 %macro PFA_15_FN 2
 INIT_YMM %1
 %if %2
-cglobal fft_pfa_15xM_asm_float, 0, 8, 0, ctx, out, in, stride, len, lut, buf, 
map, tgt, tmp, \
+cglobal fft_pfa_15xM_asm_float, 0, 0, 0, ctx, out, in, stride, len, lut, buf, 
map, tgt, tmp, \
  tgt5, stride3, stride5, btmp
 %else
 cglobal fft_pfa_15xM_float, 4, 14, 16, 320, ctx, out, in, stride, len, lut, 
buf, map, tgt, tmp, \
@@ -1892,7 +1892,7 @@ cglobal fft_pfa_15xM_float, 4, 14, 16, 320, ctx, out, in, 
stride, len, lut, buf,
 mov stride5q, lenq
 mov tgt5q, btmpq
 POP strideq
-imul tmpq, strideq, 3
+lea tmpq, [strideq + 2*strideq]
 
 .post:
 LOAD64_LUT m0, inq, stride3q, 0, tmpq, m8, m9

___
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_libplacebo: support more output formats

2022-11-28 Thread Niklas Haas
ffmpeg | branch: master | Niklas Haas  | Wed Nov 23 14:24:00 
2022 +0100| [48c385fb4c181dec891ee137f993f120c43b8001] | committer: Niklas Haas

avfilter/vf_libplacebo: support more output formats

Rather than hard-coding AV_PIX_FMT_VULKAN, expand this to the full list
of formats supported by . We re-use the
existing `format` option to allow selecting specific software formats in
addition to specific vulkan hwframe formats.

Some minor changes are necessary to account for the fact that
`ff_vk_filter_config_output` is now only called optionally, the fact
that the output format must now be parsed before `query_format` gets
called, and the fact that we need to call a different function to
retrieve data from the `pl_frame` in the non-hwaccel case.

Signed-off-by: Niklas Haas 

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

 libavfilter/vf_libplacebo.c | 87 ++---
 1 file changed, 59 insertions(+), 28 deletions(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index ce57e7539e..3678b60b7d 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -62,10 +62,11 @@ typedef struct LibplaceboContext {
 pl_vulkan vulkan;
 pl_gpu gpu;
 pl_renderer renderer;
-pl_tex tex[4];
+pl_tex tex[8];
 
 /* settings */
 char *out_format_string;
+enum AVPixelFormat out_format;
 char *w_expr;
 char *h_expr;
 AVRational target_sar;
@@ -215,6 +216,8 @@ static int find_scaler(AVFilterContext *avctx,
 return AVERROR(EINVAL);
 }
 
+static void libplacebo_uninit(AVFilterContext *avctx);
+
 static int libplacebo_init(AVFilterContext *avctx)
 {
 LibplaceboContext *s = avctx->priv;
@@ -229,6 +232,18 @@ static int libplacebo_init(AVFilterContext *avctx)
 if (!s->log)
 return AVERROR(ENOMEM);
 
+if (s->out_format_string) {
+s->out_format = av_get_pix_fmt(s->out_format_string);
+if (s->out_format == AV_PIX_FMT_NONE) {
+av_log(avctx, AV_LOG_ERROR, "Invalid output format: %s\n",
+   s->out_format_string);
+libplacebo_uninit(avctx);
+return AVERROR(EINVAL);
+}
+} else {
+s->out_format = AV_PIX_FMT_NONE;
+}
+
 /* Note: s->vulkan etc. are initialized later, when hwctx is available */
 return 0;
 }
@@ -320,6 +335,7 @@ static int process_frames(AVFilterContext *avctx, AVFrame 
*out, AVFrame *in)
 LibplaceboContext *s = avctx->priv;
 struct pl_render_params params;
 enum pl_tone_map_mode tonemapping_mode = s->tonemapping_mode;
+const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(out->format);
 enum pl_gamut_mode gamut_mode = s->gamut_mode;
 struct pl_frame image, target;
 ok = pl_map_avframe_ex(s->gpu, , pl_avframe_params(
@@ -328,10 +344,14 @@ static int process_frames(AVFilterContext *avctx, AVFrame 
*out, AVFrame *in)
 .map_dovi = s->apply_dovi,
 ));
 
-ok &= pl_map_avframe_ex(s->gpu, , pl_avframe_params(
-.frame= out,
-.map_dovi = false,
-));
+if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
+ok &= pl_map_avframe_ex(s->gpu, , pl_avframe_params(
+.frame= out,
+.map_dovi = false,
+));
+} else {
+ok &= pl_frame_recreate_from_avframe(s->gpu, , s->tex + 4, out);
+}
 
 if (!ok) {
 err = AVERROR_EXTERNAL;
@@ -434,7 +454,13 @@ static int process_frames(AVFilterContext *avctx, AVFrame 
*out, AVFrame *in)
 
 pl_render_image(s->renderer, , , );
 pl_unmap_avframe(s->gpu, );
-pl_unmap_avframe(s->gpu, );
+
+if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
+pl_unmap_avframe(s->gpu, );
+} else if (!pl_download_avframe(s->gpu, , out)) {
+err = AVERROR_EXTERNAL;
+goto fail;
+}
 
 /* Flush the command queues for performance */
 pl_gpu_flush(s->gpu);
@@ -516,10 +542,7 @@ static int libplacebo_query_format(AVFilterContext *ctx)
 int err = 0;
 LibplaceboContext *s = ctx->priv;
 const AVPixFmtDescriptor *desc = NULL;
-AVFilterFormats *in_fmts = NULL;
-static const enum AVPixelFormat out_fmts[] = {
-AV_PIX_FMT_VULKAN, AV_PIX_FMT_NONE,
-};
+AVFilterFormats *formats = NULL;
 
 RET(init_vulkan(ctx));
 
@@ -534,14 +557,24 @@ static int libplacebo_query_format(AVFilterContext *ctx)
 #endif
 
 if (pl_test_pixfmt(s->gpu, pixfmt)) {
-if ((err = ff_add_format(_fmts, pixfmt)) < 0)
+if ((err = ff_add_format(, pixfmt)) < 0)
 return err;
 }
 }
 
-RET(ff_formats_ref(in_fmts, >inputs[0]->outcfg.formats));
-RET(ff_formats_ref(ff_make_format_list(out_fmts),
-   >outputs[0]->incfg.formats));
+RET(ff_formats_ref(formats, >inputs[0]->outcfg.formats));
+
+if (s->out_format != AV_PIX_FMT_NONE) {
+/* Support only requested format, and hwaccel (vulkan) 

[FFmpeg-cvslog] avcodec/mjpegenc: take into account component count when writing the SOF header size

2022-11-28 Thread James Almer
ffmpeg | branch: release/4.1 | James Almer  | Thu Nov 24 
20:00:18 2022 -0300| [a8a208b123e0704ff187b0dc21eeb63f440692aa] | committer: 
James Almer

avcodec/mjpegenc: take into account component count when writing the SOF header 
size

Fixes ticket #10069

Signed-off-by: James Almer 
(cherry picked from commit 100939695307743396e30e6310d2ea9cf42f9aab)

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

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

diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 31868c9bed..37c15367a4 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -275,7 +275,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, 
PutBitContext *pb,
 default: av_assert0(0);
 }
 
-put_bits(pb, 16, 17);
+put_bits(pb, 16, 8 + 3 * components);
 if (lossless && (  avctx->pix_fmt == AV_PIX_FMT_BGR0
 || avctx->pix_fmt == AV_PIX_FMT_BGRA
 || avctx->pix_fmt == AV_PIX_FMT_BGR24))

___
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/mjpegenc: take into account component count when writing the SOF header size

2022-11-28 Thread James Almer
ffmpeg | branch: release/4.2 | James Almer  | Thu Nov 24 
20:00:18 2022 -0300| [e228a0cccd31c2466ea968f34be4ec0da50bd792] | committer: 
James Almer

avcodec/mjpegenc: take into account component count when writing the SOF header 
size

Fixes ticket #10069

Signed-off-by: James Almer 
(cherry picked from commit 100939695307743396e30e6310d2ea9cf42f9aab)

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

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

diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 31868c9bed..37c15367a4 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -275,7 +275,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, 
PutBitContext *pb,
 default: av_assert0(0);
 }
 
-put_bits(pb, 16, 17);
+put_bits(pb, 16, 8 + 3 * components);
 if (lossless && (  avctx->pix_fmt == AV_PIX_FMT_BGR0
 || avctx->pix_fmt == AV_PIX_FMT_BGRA
 || avctx->pix_fmt == AV_PIX_FMT_BGR24))

___
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/mjpegenc: take into account component count when writing the SOF header size

2022-11-28 Thread James Almer
ffmpeg | branch: release/4.3 | James Almer  | Thu Nov 24 
20:00:18 2022 -0300| [3b11b5f2f3b68fdf2d3e3a060a8469298f76b03a] | committer: 
James Almer

avcodec/mjpegenc: take into account component count when writing the SOF header 
size

Fixes ticket #10069

Signed-off-by: James Almer 
(cherry picked from commit 100939695307743396e30e6310d2ea9cf42f9aab)

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

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

diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 3038ebde6e..24aa293438 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -275,7 +275,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, 
PutBitContext *pb,
 default: av_assert0(0);
 }
 
-put_bits(pb, 16, 17);
+put_bits(pb, 16, 8 + 3 * components);
 if (lossless && (  avctx->pix_fmt == AV_PIX_FMT_BGR0
 || avctx->pix_fmt == AV_PIX_FMT_BGRA
 || avctx->pix_fmt == AV_PIX_FMT_BGR24))

___
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/mjpegenc: take into account component count when writing the SOF header size

2022-11-28 Thread James Almer
ffmpeg | branch: release/4.4 | James Almer  | Thu Nov 24 
20:00:18 2022 -0300| [a54187b7d9ac4a2b54153956b4a9c9731f9d4eb3] | committer: 
James Almer

avcodec/mjpegenc: take into account component count when writing the SOF header 
size

Fixes ticket #10069

Signed-off-by: James Almer 
(cherry picked from commit 100939695307743396e30e6310d2ea9cf42f9aab)

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

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

diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 12dd7be2e8..0845814834 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -247,7 +247,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, 
PutBitContext *pb,
 default: av_assert0(0);
 }
 
-put_bits(pb, 16, 17);
+put_bits(pb, 16, 8 + 3 * components);
 if (lossless && (  avctx->pix_fmt == AV_PIX_FMT_BGR0
 || avctx->pix_fmt == AV_PIX_FMT_BGRA
 || avctx->pix_fmt == AV_PIX_FMT_BGR24))

___
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/mjpegenc: take into account component count when writing the SOF header size

2022-11-28 Thread James Almer
ffmpeg | branch: release/5.0 | James Almer  | Thu Nov 24 
20:00:18 2022 -0300| [c77210491a2427495b86979bac968f75d2641934] | committer: 
James Almer

avcodec/mjpegenc: take into account component count when writing the SOF header 
size

Fixes ticket #10069

Signed-off-by: James Almer 
(cherry picked from commit 100939695307743396e30e6310d2ea9cf42f9aab)

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

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

diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 368e87128c..f0b1f2d9f1 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -247,7 +247,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, 
PutBitContext *pb,
 default: av_assert0(0);
 }
 
-put_bits(pb, 16, 17);
+put_bits(pb, 16, 8 + 3 * components);
 if (lossless && (  avctx->pix_fmt == AV_PIX_FMT_BGR0
 || avctx->pix_fmt == AV_PIX_FMT_BGRA
 || avctx->pix_fmt == AV_PIX_FMT_BGR24))

___
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/mjpegenc: take into account component count when writing the SOF header size

2022-11-28 Thread James Almer
ffmpeg | branch: release/5.1 | James Almer  | Thu Nov 24 
20:00:18 2022 -0300| [5746987bad4dd3880cd3a321ef3d970663cd8085] | committer: 
James Almer

avcodec/mjpegenc: take into account component count when writing the SOF header 
size

Fixes ticket #10069

Signed-off-by: James Almer 
(cherry picked from commit 100939695307743396e30e6310d2ea9cf42f9aab)

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

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

diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 98c464fc62..18e72ebd98 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -309,7 +309,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, 
PutBitContext *pb,
 default: av_assert0(0);
 }
 
-put_bits(pb, 16, 17);
+put_bits(pb, 16, 8 + 3 * components);
 if (lossless && (  avctx->pix_fmt == AV_PIX_FMT_BGR0
 || avctx->pix_fmt == AV_PIX_FMT_BGRA
 || avctx->pix_fmt == AV_PIX_FMT_BGR24))

___
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: remove a useless inner block

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Nov 26 
00:50:50 2022 +0100| [d04ec7efe3370b9bb39ddaca2a014f47f6ff5993] | committer: 
Anton Khirnov

fftools/ffmpeg: remove a useless inner block

adjust_frame_pts_to_encoder_tb() is so small that this serves no useful
purpose.

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

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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0128476f57..045cc609b9 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -676,17 +676,18 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
  AVFrame *frame)
 {
 double float_pts = AV_NOPTS_VALUE; // this is identical to frame.pts but 
with higher precision
-AVCodecContext *enc = ost->enc_ctx;
-AVRational filter_tb = (AVRational){ -1, -1 };
+const int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ?
+   0 : of->start_time;
+
+AVCodecContext *const enc = ost->enc_ctx;
+
+AVRationaltb = enc->time_base;
+AVRational filter_tb = frame->time_base;
+const int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
+
 if (frame->pts == AV_NOPTS_VALUE)
 goto early_exit;
 
-{
-int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : 
of->start_time;
-AVRational tb = enc->time_base;
-int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
-filter_tb = frame->time_base;
-
 tb.den <<= extra_bits;
 float_pts =
 av_rescale_q(frame->pts, filter_tb, tb) -
@@ -699,7 +700,6 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 av_rescale_q(frame->pts, filter_tb, enc->time_base) -
 av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
 frame->time_base = enc->time_base;
-}
 
 early_exit:
 

___
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: cosmetics

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Nov 26 
00:50:50 2022 +0100| [becbb22eb032149836070d13edf6b92f87780b35] | committer: 
Anton Khirnov

fftools/ffmpeg: cosmetics

Reindent after previous commit and break/split some lines as
appropriate.

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

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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 045cc609b9..771219f7df 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -688,18 +688,17 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 if (frame->pts == AV_NOPTS_VALUE)
 goto early_exit;
 
-tb.den <<= extra_bits;
-float_pts =
-av_rescale_q(frame->pts, filter_tb, tb) -
-av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
-float_pts /= 1 << extra_bits;
-// avoid exact midoints to reduce the chance of rounding differences, 
this can be removed in case the fps code is changed to work with integers
-float_pts += FFSIGN(float_pts) * 1.0 / (1<<17);
-
-frame->pts =
-av_rescale_q(frame->pts, filter_tb, enc->time_base) -
-av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
-frame->time_base = enc->time_base;
+tb.den <<= extra_bits;
+float_pts = av_rescale_q(frame->pts, filter_tb, tb) -
+av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
+float_pts /= 1 << extra_bits;
+// avoid exact midoints to reduce the chance of rounding differences, this
+// can be removed in case the fps code is changed to work with integers
+float_pts += FFSIGN(float_pts) * 1.0 / (1<<17);
+
+frame->pts = av_rescale_q(frame->pts, filter_tb, enc->time_base) -
+ av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
+frame->time_base = enc->time_base;
 
 early_exit:
 

___
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 logging filtered frame timestamps

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Nov 25 
23:06:17 2022 +0100| [d9534ec84e3567c5776ae24c4671d32555f9ca9f] | committer: 
Anton Khirnov

fftools/ffmpeg: move logging filtered frame timestamps

Do it right after the frame is received from the filtergraph. This is a
more logical place for this and will simplify future commits.

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

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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 44582e3568..263670d3f5 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -676,7 +676,6 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
  AVFrame *frame)
 {
 double float_pts = AV_NOPTS_VALUE; // this is identical to frame.pts but 
with higher precision
-int64_t orig_pts = AV_NOPTS_VALUE;
 AVCodecContext *enc = ost->enc_ctx;
 AVRational filter_tb = (AVRational){ -1, -1 };
 if (!frame || frame->pts == AV_NOPTS_VALUE ||
@@ -690,7 +689,6 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 AVRational tb = enc->time_base;
 int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
 filter_tb = av_buffersink_get_time_base(filter);
-orig_pts = frame->pts;
 
 tb.den <<= extra_bits;
 float_pts =
@@ -708,11 +706,6 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 early_exit:
 
 if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "filter_raw -> pts:%s pts_time:%s 
time_base:%d/%d\n",
-   frame ? av_ts2str(orig_pts) : "NULL",
-   frame ? av_ts2timestr(orig_pts, _tb) : "NULL",
-   filter_tb.num, filter_tb.den);
-
 av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s exact:%f 
time_base:%d/%d\n",
frame ? av_ts2str(frame->pts) : "NULL",
(enc && frame) ? av_ts2timestr(frame->pts, >time_base) : 
"NULL",
@@ -1302,6 +1295,12 @@ static int reap_filters(int flush)
 AVRational tb = av_buffersink_get_time_base(filter);
 ost->last_filter_pts = av_rescale_q(filtered_frame->pts, tb,
 AV_TIME_BASE_Q);
+
+if (debug_ts)
+av_log(NULL, AV_LOG_INFO, "filter_raw -> pts:%s 
pts_time:%s time_base:%d/%d\n",
+   av_ts2str(filtered_frame->pts),
+   av_ts2timestr(filtered_frame->pts, ),
+   tb.num, tb.den);
 }
 
 switch (av_buffersink_get_type(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] fftools/ffmpeg: drop an always-false check

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Nov 25 
21:31:09 2022 +0100| [d60d6d819d49740eeba51d8b60e34d9340eeeaf6] | committer: 
Anton Khirnov

fftools/ffmpeg: drop an always-false check

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

 fftools/ffmpeg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 8f27b5ca3f..0128476f57 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -678,7 +678,7 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 double float_pts = AV_NOPTS_VALUE; // this is identical to frame.pts but 
with higher precision
 AVCodecContext *enc = ost->enc_ctx;
 AVRational filter_tb = (AVRational){ -1, -1 };
-if (frame->pts == AV_NOPTS_VALUE || !enc)
+if (frame->pts == AV_NOPTS_VALUE)
 goto early_exit;
 
 {

___
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 calling adjust_frame_pts_to_encoder_tb() for audio

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Nov 25 
23:42:23 2022 +0100| [86a71d6b3c11da9fd0606ddf814affa92eef83cf] | committer: 
Anton Khirnov

fftools/ffmpeg: stop calling adjust_frame_pts_to_encoder_tb() for audio

Almost none of that function's complexity is useful for audio, it can
be replaced by a simple av_rescale_q().

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

 fftools/ffmpeg.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 2ee40890a9..cb65f26100 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -933,15 +933,22 @@ static int submit_encode_frame(OutputFile *of, 
OutputStream *ost,
 static void do_audio_out(OutputFile *of, OutputStream *ost,
  AVFrame *frame)
 {
+AVCodecContext *enc = ost->enc_ctx;
 int ret;
 
-adjust_frame_pts_to_encoder_tb(of, ost, frame);
-
 if (!check_recording_time(ost, ost->next_pts, ost->enc_ctx->time_base))
 return;
 
 if (frame->pts == AV_NOPTS_VALUE)
 frame->pts = ost->next_pts;
+else {
+int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : 
of->start_time;
+frame->pts =
+av_rescale_q(frame->pts, frame->time_base, enc->time_base) -
+av_rescale_q(start_time, AV_TIME_BASE_Q,   enc->time_base);
+}
+frame->time_base = enc->time_base;
+
 ost->next_pts = frame->pts + frame->nb_samples;
 
 ret = submit_encode_frame(of, ost, 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] fftools/ffmpeg: only convert video frame pts if we have a frame

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Nov 25 
21:31:09 2022 +0100| [8ee4365ad8e437e564e4daa8ac4b9f94624c386c] | committer: 
Anton Khirnov

fftools/ffmpeg: only convert video frame pts if we have a frame

Calling adjust_frame_pts_to_encoder_tb() with a NULL frame does not
perform a meaningful action.

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

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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e56681a461..8f27b5ca3f 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -678,7 +678,7 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 double float_pts = AV_NOPTS_VALUE; // this is identical to frame.pts but 
with higher precision
 AVCodecContext *enc = ost->enc_ctx;
 AVRational filter_tb = (AVRational){ -1, -1 };
-if (!frame || frame->pts == AV_NOPTS_VALUE || !enc)
+if (frame->pts == AV_NOPTS_VALUE || !enc)
 goto early_exit;
 
 {
@@ -1092,12 +1092,10 @@ static void do_video_out(OutputFile *of,
 int64_t nb_frames, nb0_frames, i;
 double delta, delta0;
 double duration = 0;
-double sync_ipts = AV_NOPTS_VALUE;
 InputStream *ist = ost->ist;
 AVFilterContext *filter = ost->filter->filter;
 
 init_output_stream_wrapper(ost, next_picture, 1);
-sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture);
 
 frame_rate = av_buffersink_get_frame_rate(filter);
 if (frame_rate.num > 0 && frame_rate.den > 0)
@@ -1121,6 +1119,7 @@ static void do_video_out(OutputFile *of,
   ost->last_nb0_frames[1],
   ost->last_nb0_frames[2]);
 } else {
+double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, 
next_picture);
 /* delta0 is the "drift" between the input frame (next_picture) and
  * where it would fall in the output. */
 delta0 = sync_ipts - ost->next_pts;

___
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: set AVFrame.time_base after filtering

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Nov 25 
23:20:55 2022 +0100| [a186360f27cad75855f9d6efe67c68bd1deb2f15] | committer: 
Anton Khirnov

fftools/ffmpeg: set AVFrame.time_base after filtering

Makes it easier to track what timebase are the frame timestamps in and
allows to stop accessing filters in code that shouldn't deal with
filtering.

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

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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 263670d3f5..2ee40890a9 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -678,17 +678,14 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 double float_pts = AV_NOPTS_VALUE; // this is identical to frame.pts but 
with higher precision
 AVCodecContext *enc = ost->enc_ctx;
 AVRational filter_tb = (AVRational){ -1, -1 };
-if (!frame || frame->pts == AV_NOPTS_VALUE ||
-!enc || !ost->filter || !ost->filter->graph->graph)
+if (!frame || frame->pts == AV_NOPTS_VALUE || !enc)
 goto early_exit;
 
 {
-AVFilterContext *filter = ost->filter->filter;
-
 int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : 
of->start_time;
 AVRational tb = enc->time_base;
 int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
-filter_tb = av_buffersink_get_time_base(filter);
+filter_tb = frame->time_base;
 
 tb.den <<= extra_bits;
 float_pts =
@@ -701,6 +698,7 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile 
*of, OutputStream *ost,
 frame->pts =
 av_rescale_q(frame->pts, filter_tb, enc->time_base) -
 av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
+frame->time_base = enc->time_base;
 }
 
 early_exit:
@@ -1295,6 +1293,7 @@ static int reap_filters(int flush)
 AVRational tb = av_buffersink_get_time_base(filter);
 ost->last_filter_pts = av_rescale_q(filtered_frame->pts, tb,
 AV_TIME_BASE_Q);
+filtered_frame->time_base = tb;
 
 if (debug_ts)
 av_log(NULL, AV_LOG_INFO, "filter_raw -> pts:%s 
pts_time:%s time_base:%d/%d\n",

___
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: call check_recording_time() with actual frame pts

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Nov 25 
23:47:12 2022 +0100| [617ea07c220b1c5cce5de56ab5c3cfaaf376d357] | committer: 
Anton Khirnov

fftools/ffmpeg: call check_recording_time() with actual frame pts

Not its estimated value that will not necessarily be used.

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

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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index cb65f26100..e56681a461 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -936,9 +936,6 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
 AVCodecContext *enc = ost->enc_ctx;
 int ret;
 
-if (!check_recording_time(ost, ost->next_pts, ost->enc_ctx->time_base))
-return;
-
 if (frame->pts == AV_NOPTS_VALUE)
 frame->pts = ost->next_pts;
 else {
@@ -949,6 +946,9 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
 }
 frame->time_base = enc->time_base;
 
+if (!check_recording_time(ost, frame->pts, frame->time_base))
+return;
+
 ost->next_pts = frame->pts + frame->nb_samples;
 
 ret = submit_encode_frame(of, ost, 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] fftools/ffmpeg: avoid storing full forced keyframe spec

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Nov 17 
14:35:36 2022 +0100| [2fa2e146ccf589aebb5865e5c1713a4ddef73345] | committer: 
Anton Khirnov

fftools/ffmpeg: avoid storing full forced keyframe spec

It is not needed after the spec is parsed. Also avoids ugly string
comparisons for each video frame.

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

 fftools/ffmpeg.c  |  7 ++-
 fftools/ffmpeg.h  |  7 ++-
 fftools/ffmpeg_mux.c  |  1 -
 fftools/ffmpeg_mux_init.c | 35 ---
 4 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 12ce108cc6..44582e3568 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1067,13 +1067,10 @@ static enum AVPictureType 
forced_kf_apply(KeyframeForceCtx *kf, AVRational tb,
 kf->expr_const_values[FKF_N_FORCED] += 1;
 goto force_keyframe;
 }
-} else if (kf->forced_keyframes&&
-   !strncmp(kf->forced_keyframes, "source", 6) &&
+} else if (kf->type == KF_FORCE_SOURCE &&
in_picture->key_frame == 1 && !dup_idx) {
 goto force_keyframe;
-} else if (kf->forced_keyframes &&
-   !strncmp(kf->forced_keyframes, "source_no_drop", 14) &&
-   !dup_idx) {
+} else if (kf->type == KF_FORCE_SOURCE_NO_DROP && !dup_idx) {
 kf->dropped_keyframe = 0;
 if ((in_picture->key_frame == 1) || kf->dropped_keyframe)
 goto force_keyframe;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index bf2abf55ee..5527dbe49b 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -487,8 +487,13 @@ typedef enum {
 MUXER_FINISHED = 2,
 } OSTFinished ;
 
+enum {
+KF_FORCE_SOURCE = 1,
+KF_FORCE_SOURCE_NO_DROP = 2,
+};
+
 typedef struct KeyframeForceCtx {
-char*forced_keyframes;
+int  type;
 
 int64_t  ref_pts;
 
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index de5facbdc0..20524e5a28 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -667,7 +667,6 @@ static void ost_free(OutputStream **post)
 av_packet_free(>pkt);
 av_dict_free(>encoder_opts);
 
-av_freep(>kf.forced_keyframes);
 av_freep(>kf.pts);
 av_expr_free(ost->kf.pexpr);
 
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 25e2ab8631..0280759b05 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -604,10 +604,6 @@ static OutputStream *new_video_stream(Muxer *mux, const 
OptionsContext *o, Input
 }
 }
 
-MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->kf.forced_keyframes, 
oc, st);
-if (ost->kf.forced_keyframes)
-ost->kf.forced_keyframes = av_strdup(ost->kf.forced_keyframes);
-
 MATCH_PER_STREAM_OPT(force_fps, i, ost->force_fps, oc, st);
 
 ost->top_field_first = -1;
@@ -1759,13 +1755,14 @@ static int compare_int64(const void *a, const void *b)
 return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b);
 }
 
-static void parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux)
+static void parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux,
+const char *spec)
 {
 const char *p;
 int n = 1, i, size, index = 0;
 int64_t t, *pts;
 
-for (p = kf->forced_keyframes; *p; p++)
+for (p = spec; *p; p++)
 if (*p == ',')
 n++;
 size = n;
@@ -1773,7 +1770,7 @@ static void parse_forced_key_frames(KeyframeForceCtx *kf, 
const Muxer *mux)
 if (!pts)
 report_and_exit(AVERROR(ENOMEM));
 
-p = kf->forced_keyframes;
+p = spec;
 for (i = 0; i < n; i++) {
 char *next = strchr(p, ',');
 
@@ -1812,20 +1809,24 @@ static void parse_forced_key_frames(KeyframeForceCtx 
*kf, const Muxer *mux)
 kf->pts= pts;
 }
 
-static int process_forced_keyframes(Muxer *mux)
+static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
 {
 for (int i = 0; i < mux->of.nb_streams; i++) {
 OutputStream *ost = mux->of.streams[i];
+const char *forced_keyframes = NULL;
+
+MATCH_PER_STREAM_OPT(forced_key_frames, str, forced_keyframes, 
mux->fc, ost->st);
 
-if (!ost->kf.forced_keyframes)
+if (!(ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
+  ost->enc_ctx && forced_keyframes))
 continue;
 
-if (!strncmp(ost->kf.forced_keyframes, "expr:", 5)) {
-int ret = av_expr_parse(>kf.pexpr, ost->kf.forced_keyframes+5,
+if (!strncmp(forced_keyframes, "expr:", 5)) {
+int ret = av_expr_parse(>kf.pexpr, forced_keyframes + 5,
 forced_keyframes_const_names, NULL, NULL, 
NULL, NULL, 0, NULL);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR,

[FFmpeg-cvslog] fftools/ffmpeg: parse forced keyframes in of_open()

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Nov 17 
14:22:58 2022 +0100| [334e52e09441213c9c391d7c0f5d0126eaa98396] | committer: 
Anton Khirnov

fftools/ffmpeg: parse forced keyframes in of_open()

Allows to remove the ugly of_get_chapters() wrapper.

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

 fftools/ffmpeg.c  |  89 --
 fftools/ffmpeg.h  |   2 -
 fftools/ffmpeg_mux.c  |   8 
 fftools/ffmpeg_mux_init.c | 106 ++
 4 files changed, 106 insertions(+), 99 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5d39d8f69b..12ce108cc6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -113,15 +113,6 @@ const int program_birth_year = 2000;
 
 static FILE *vstats_file;
 
-const char *const forced_keyframes_const_names[] = {
-"n",
-"n_forced",
-"prev_forced_n",
-"prev_forced_t",
-"t",
-NULL
-};
-
 typedef struct BenchmarkTimeStamps {
 int64_t real_usec;
 int64_t user_usec;
@@ -2590,11 +2581,6 @@ static int init_input_stream(InputStream *ist, char 
*error, int error_len)
 return 0;
 }
 
-static int compare_int64(const void *a, const void *b)
-{
-return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b);
-}
-
 static int init_output_stream_streamcopy(OutputStream *ost)
 {
 OutputFile *of = output_files[ost->file_index];
@@ -2748,61 +2734,6 @@ static void set_encoder_id(OutputFile *of, OutputStream 
*ost)
 AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE);
 }
 
-static void parse_forced_key_frames(KeyframeForceCtx *kf, OutputFile *of)
-{
-const char *p;
-int n = 1, i, size, index = 0;
-int64_t t, *pts;
-
-for (p = kf->forced_keyframes; *p; p++)
-if (*p == ',')
-n++;
-size = n;
-pts = av_malloc_array(size, sizeof(*pts));
-if (!pts)
-report_and_exit(AVERROR(ENOMEM));
-
-p = kf->forced_keyframes;
-for (i = 0; i < n; i++) {
-char *next = strchr(p, ',');
-
-if (next)
-*next++ = 0;
-
-if (!memcmp(p, "chapters", 8)) {
-AVChapter * const *ch;
-unsigned intnb_ch;
-int j;
-
-ch = of_get_chapters(of, _ch);
-
-if (nb_ch > INT_MAX - size ||
-!(pts = av_realloc_f(pts, size += nb_ch - 1,
- sizeof(*pts
-report_and_exit(AVERROR(ENOMEM));
-t = p[8] ? parse_time_or_die("force_key_frames", p + 8, 1) : 0;
-
-for (j = 0; j < nb_ch; j++) {
-const AVChapter *c = ch[j];
-av_assert1(index < size);
-pts[index++] = av_rescale_q(c->start, c->time_base,
-AV_TIME_BASE_Q) + t;
-}
-
-} else {
-av_assert1(index < size);
-pts[index++] = parse_time_or_die("force_key_frames", p, 1);
-}
-
-p = next;
-}
-
-av_assert0(index == size);
-qsort(pts, size, sizeof(*pts), compare_int64);
-kf->nb_pts = size;
-kf->pts= pts;
-}
-
 static void init_encoder_time_base(OutputStream *ost, AVRational 
default_time_base)
 {
 InputStream *ist = ost->ist;
@@ -2949,26 +2880,6 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 enc_ctx->field_order = AV_FIELD_TT;
 }
 
-if (ost->kf.forced_keyframes) {
-if (!strncmp(ost->kf.forced_keyframes, "expr:", 5)) {
-ret = av_expr_parse(>kf.pexpr, ost->kf.forced_keyframes+5,
-forced_keyframes_const_names, NULL, NULL, 
NULL, NULL, 0, NULL);
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR,
-   "Invalid force_key_frames expression '%s'\n", 
ost->kf.forced_keyframes+5);
-return ret;
-}
-ost->kf.expr_const_values[FKF_N] = 0;
-ost->kf.expr_const_values[FKF_N_FORCED]  = 0;
-ost->kf.expr_const_values[FKF_PREV_FORCED_N] = NAN;
-ost->kf.expr_const_values[FKF_PREV_FORCED_T] = NAN;
-
-// Don't parse the 'forced_keyframes' in case of 
'keep-source-keyframes',
-// parse it only for static kf timings
-} else if(strncmp(ost->kf.forced_keyframes, "source", 6)) {
-parse_forced_key_frames(>kf, of);
-}
-}
 break;
 case AVMEDIA_TYPE_SUBTITLE:
 enc_ctx->time_base = AV_TIME_BASE_Q;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index f5d51b90ec..bf2abf55ee 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -757,8 +757,6 @@ void of_close(OutputFile **pof);
  */
 void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int 
eof);
 int64_t of_filesize(OutputFile *of);
-AVChapter * 

[FFmpeg-cvslog] fftools/ffmpeg: store forced keyframe pts in AV_TIME_BASE_Q

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Nov 17 
12:55:47 2022 +0100| [efe442362794abe3cef43eea6b4071919b0b2866] | committer: 
Anton Khirnov

fftools/ffmpeg: store forced keyframe pts in AV_TIME_BASE_Q

Rather than the encoder timebase. Since the times are parsed as
microseconds, this will not reduce precision, except possibly when
chapter times are used and the chapter timebase happens to be better
aligned with the encoder timebase, which is unlikely.

This will allow parsing the keyframe times earlier (before encoder
timebase is known) in future commits.

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

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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 3d10ffc3b2..5d39d8f69b 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1052,7 +1052,7 @@ static enum AVPictureType 
forced_kf_apply(KeyframeForceCtx *kf, AVRational tb,
 
 pts_time = (in_picture->pts - kf->ref_pts) * av_q2d(tb);
 if (kf->index < kf->nb_pts &&
-in_picture->pts >= kf->pts[kf->index]) {
+av_compare_ts(in_picture->pts, tb, kf->pts[kf->index], AV_TIME_BASE_Q) 
>= 0) {
 kf->index++;
 goto force_keyframe;
 } else if (kf->pexpr) {
@@ -2748,8 +2748,7 @@ static void set_encoder_id(OutputFile *of, OutputStream 
*ost)
 AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE);
 }
 
-static void parse_forced_key_frames(KeyframeForceCtx *kf, OutputFile *of,
-AVCodecContext *avctx)
+static void parse_forced_key_frames(KeyframeForceCtx *kf, OutputFile *of)
 {
 const char *p;
 int n = 1, i, size, index = 0;
@@ -2782,21 +2781,17 @@ static void parse_forced_key_frames(KeyframeForceCtx 
*kf, OutputFile *of,
  sizeof(*pts
 report_and_exit(AVERROR(ENOMEM));
 t = p[8] ? parse_time_or_die("force_key_frames", p + 8, 1) : 0;
-t = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base);
 
 for (j = 0; j < nb_ch; j++) {
 const AVChapter *c = ch[j];
 av_assert1(index < size);
 pts[index++] = av_rescale_q(c->start, c->time_base,
-avctx->time_base) + t;
+AV_TIME_BASE_Q) + t;
 }
 
 } else {
-
-t = parse_time_or_die("force_key_frames", p, 1);
 av_assert1(index < size);
-pts[index++] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base);
-
+pts[index++] = parse_time_or_die("force_key_frames", p, 1);
 }
 
 p = next;
@@ -2971,7 +2966,7 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 // Don't parse the 'forced_keyframes' in case of 
'keep-source-keyframes',
 // parse it only for static kf timings
 } else if(strncmp(ost->kf.forced_keyframes, "source", 6)) {
-parse_forced_key_frames(>kf, of, ost->enc_ctx);
+parse_forced_key_frames(>kf, of);
 }
 }
 break;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index db1f00b259..f5d51b90ec 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -492,6 +492,7 @@ typedef struct KeyframeForceCtx {
 
 int64_t  ref_pts;
 
+// timestamps of the forced keyframes, in AV_TIME_BASE_Q
 int64_t *pts;
 int   nb_pts;
 int  index;

___
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 force-keyframe-related vars to a separate struct

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Nov 17 
12:42:01 2022 +0100| [b1143330c8db6e738312245414656a001cd007a4] | committer: 
Anton Khirnov

fftools/ffmpeg: move force-keyframe-related vars to a separate struct

There are 8 of them and they are typically used together. Allows to pass
just this struct to forced_kf_apply(), which makes it clear that the
rest of the OutputStream is not accessed there.

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

 fftools/ffmpeg.c  | 92 +++
 fftools/ffmpeg.h  | 25 -
 fftools/ffmpeg_mux.c  |  7 ++--
 fftools/ffmpeg_mux_init.c |  8 ++---
 4 files changed, 68 insertions(+), 64 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index ba91af2c95..3d10ffc3b2 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1042,52 +1042,49 @@ static void do_subtitle_out(OutputFile *of,
 }
 }
 
-static enum AVPictureType forced_kf_apply(OutputStream *ost,
+static enum AVPictureType forced_kf_apply(KeyframeForceCtx *kf, AVRational tb,
   const AVFrame *in_picture, int 
dup_idx)
 {
-AVCodecContext *enc = ost->enc_ctx;
 double pts_time;
 
-if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE)
-ost->forced_kf_ref_pts = in_picture->pts;
+if (kf->ref_pts == AV_NOPTS_VALUE)
+kf->ref_pts = in_picture->pts;
 
-pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * 
av_q2d(enc->time_base);
-if (ost->forced_kf_index < ost->forced_kf_count &&
-in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
-ost->forced_kf_index++;
+pts_time = (in_picture->pts - kf->ref_pts) * av_q2d(tb);
+if (kf->index < kf->nb_pts &&
+in_picture->pts >= kf->pts[kf->index]) {
+kf->index++;
 goto force_keyframe;
-} else if (ost->forced_keyframes_pexpr) {
+} else if (kf->pexpr) {
 double res;
-ost->forced_keyframes_expr_const_values[FKF_T] = pts_time;
-res = av_expr_eval(ost->forced_keyframes_pexpr,
-   ost->forced_keyframes_expr_const_values, NULL);
+kf->expr_const_values[FKF_T] = pts_time;
+res = av_expr_eval(kf->pexpr,
+   kf->expr_const_values, NULL);
 ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f 
prev_forced_t:%f -> res:%f\n",
-ost->forced_keyframes_expr_const_values[FKF_N],
-ost->forced_keyframes_expr_const_values[FKF_N_FORCED],
-ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
-ost->forced_keyframes_expr_const_values[FKF_T],
-ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
+kf->expr_const_values[FKF_N],
+kf->expr_const_values[FKF_N_FORCED],
+kf->expr_const_values[FKF_PREV_FORCED_N],
+kf->expr_const_values[FKF_T],
+kf->expr_const_values[FKF_PREV_FORCED_T],
 res);
 
-ost->forced_keyframes_expr_const_values[FKF_N] += 1;
+kf->expr_const_values[FKF_N] += 1;
 
 if (res) {
-ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
-ost->forced_keyframes_expr_const_values[FKF_N] - 1;
-ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
-ost->forced_keyframes_expr_const_values[FKF_T];
-ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
+kf->expr_const_values[FKF_PREV_FORCED_N] = 
kf->expr_const_values[FKF_N] - 1;
+kf->expr_const_values[FKF_PREV_FORCED_T] = 
kf->expr_const_values[FKF_T];
+kf->expr_const_values[FKF_N_FORCED] += 1;
 goto force_keyframe;
 }
-} else if (ost->forced_keyframes&&
-   !strncmp(ost->forced_keyframes, "source", 6) &&
+} else if (kf->forced_keyframes&&
+   !strncmp(kf->forced_keyframes, "source", 6) &&
in_picture->key_frame == 1 && !dup_idx) {
 goto force_keyframe;
-} else if (ost->forced_keyframes &&
-   !strncmp(ost->forced_keyframes, "source_no_drop", 14) &&
+} else if (kf->forced_keyframes &&
+   !strncmp(kf->forced_keyframes, "source_no_drop", 14) &&
!dup_idx) {
-ost->dropped_keyframe = 0;
-if ((in_picture->key_frame == 1) || ost->dropped_keyframe)
+kf->dropped_keyframe = 0;
+if ((in_picture->key_frame == 1) || kf->dropped_keyframe)
 goto force_keyframe;
 }
 
@@ -1223,7 +1220,7 @@ static void do_video_out(OutputFile *of,
 }
 }
 ost->last_dropped = nb_frames == nb0_frames && next_picture;
-ost->dropped_keyframe = ost->last_dropped && next_picture 

[FFmpeg-cvslog] fftools/ffmpeg: stop explicitly closing decoders

2022-11-28 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Nov 17 
11:59:55 2022 +0100| [630fbdcc526c919986ff8ccc6712653ff1ef637b] | committer: 
Anton Khirnov

fftools/ffmpeg: stop explicitly closing decoders

It serves no purpose, they will be closed and freed in
avcodec_free_context() called from ist_free().

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

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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 3767ab444b..ba91af2c95 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3908,13 +3908,6 @@ static int transcode(void)
 exit_program(1);
 }
 
-/* close each decoder */
-for (ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
-if (ist->decoding_needed) {
-avcodec_close(ist->dec_ctx);
-}
-}
-
 hw_device_free_all();
 
 /* finished ! */

___
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/amrwbdec: update .p.sample_fmts to planar variant

2022-11-28 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Nov 28 09:08:11 
2022 +0100| [e8e9950f2abeec6735054a0cc0841684c100e052] | committer: Paul B Mahol

avcodec/amrwbdec: update .p.sample_fmts to planar variant

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

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

diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index b59066adcf..9d75b972fa 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -1304,6 +1304,6 @@ const FFCodec ff_amrwb_decoder = {
 .init   = amrwb_decode_init,
 FF_CODEC_DECODE_CB(amrwb_decode_frame),
 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
-.p.sample_fmts  = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT,
+.p.sample_fmts  = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
  AV_SAMPLE_FMT_NONE },
 };

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

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