]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavfilter/vf_uspp: Fix leak of qp-table on error
Andreas Rheinhardt [Fri, 12 Mar 2021 13:55:53 +0000 (14:55 +0100)]
avfilter/vf_uspp: Fix leak of qp-table on error

Fixes Coverity issue #1473500.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Reindentation
Andreas Rheinhardt [Fri, 12 Mar 2021 16:40:07 +0000 (17:40 +0100)]
avcodec/decode: Reindentation

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Remove always-true check
Andreas Rheinhardt [Fri, 12 Mar 2021 16:29:28 +0000 (17:29 +0100)]
avcodec/decode: Remove always-true check

Forgotten in 1fd76277708cf83572ba243e98f9e848c652f83d.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/adp, svs: Remove redundant av_shrink_packet()
Andreas Rheinhardt [Fri, 12 Mar 2021 08:23:46 +0000 (09:23 +0100)]
avformat/adp, svs: Remove redundant av_shrink_packet()

av_get_packet() already makes sure that the packet size is accurate
and that the packet data is zero-padded even when one could not read as
much as desired.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/gopher: Add support for Gopher over TLS
parazyd [Sun, 28 Feb 2021 22:47:05 +0000 (23:47 +0100)]
avformat/gopher: Add support for Gopher over TLS

This commit adds a "gophers" handler to the gopher protocol. gophers
is a community-adopted protocol that acts the same way like normal
gopher with the added TLS encapsulation.

The gophers protocol is supported by gopher servers like geomydae(8),
and clients like curl(1), clic(1), and hurl(1).

This commit also adds compilation guards to both gopher and gophers,
since now there are two protocols in the file it makes sense to
have this addition.

Signed-off-by: parazyd <parazyd@dyne.org>
Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/gopher: Add default_whitelist to ff_gopher_protocol
parazyd [Sun, 28 Feb 2021 22:47:03 +0000 (23:47 +0100)]
avformat/gopher: Add default_whitelist to ff_gopher_protocol

Signed-off-by: parazyd <parazyd@dyne.org>
Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/gifenc: Actually use the shrunk palette
Derek Buitenhuis [Wed, 10 Mar 2021 15:18:41 +0000 (15:18 +0000)]
avcodec/gifenc: Actually use the shrunk palette

I have no idea how nobody, including myself, noticed this.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
3 years agoavcodec/h264_slice: don't copy frame data during error concealment
James Almer [Tue, 9 Mar 2021 02:10:10 +0000 (23:10 -0300)]
avcodec/h264_slice: don't copy frame data during error concealment

In addition to the fact that av_image_copy() cannot handle hardware pixel formats,
h->short_ref[0]->f may not be writable at this point.

Based on a patch by Hendrik Leppkes.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavdevice/decklink: add missing include for buffer_size_t
James Almer [Thu, 11 Mar 2021 16:39:36 +0000 (13:39 -0300)]
avdevice/decklink: add missing include for buffer_size_t

Should fix compilation broken in f7abb53cb427515faac582f114ab97cbbd590280.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavisynth: fix audio on big endian
Stephen Hutchinson [Sun, 3 Jan 2021 22:58:36 +0000 (17:58 -0500)]
avisynth: fix audio on big endian

AviSynth+ outputs audio in the same format as the
OS, so assuming little endian formats as input
on big endian OSes results in nothing but static.

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
3 years agoavisynth: populate field order
emcodem [Thu, 21 Jan 2021 17:59:45 +0000 (18:59 +0100)]
avisynth: populate field order

Fixes Trac ticket #8757

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
3 years agoavisynth: more intelligent RGB flipping
Stephen Hutchinson [Tue, 7 Apr 2020 23:47:43 +0000 (19:47 -0400)]
avisynth: more intelligent RGB flipping

avs_is_color_space provides a generic way of checking whether the
video is RGB, and has been available through AVSC_API since 2.6.
This means that GetProcAddress doesn't have to run on every frame.

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
3 years agoavformat/rawenc: Use init instead of write_header function
Andreas Rheinhardt [Mon, 8 Mar 2021 15:16:09 +0000 (16:16 +0100)]
avformat/rawenc: Use init instead of write_header function

force_one_stream() does not write anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/4xm: Check pre_gb in decode_i_block()
Michael Niedermayer [Tue, 9 Mar 2021 20:39:30 +0000 (21:39 +0100)]
avcodec/4xm: Check pre_gb in decode_i_block()

Fixes: Timeout
Fixes: 31257/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5150866229297152
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavutil/buffer_internal: Include internal for buffer_size_t
Andreas Rheinhardt [Thu, 11 Mar 2021 10:39:58 +0000 (11:39 +0100)]
avutil/buffer_internal: Include internal for buffer_size_t

Fixes checkheaders.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_mathbinary: Fix leak upon error
Andreas Rheinhardt [Wed, 10 Mar 2021 17:45:07 +0000 (18:45 +0100)]
dnn/dnn_backend_native_layer_mathbinary: Fix leak upon error

Fixes Coverity issue #1473568.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Don't pretend convolution can fail
Andreas Rheinhardt [Wed, 10 Mar 2021 20:58:15 +0000 (21:58 +0100)]
dnn/dnn_backend_native_layer_conv2d: Don't pretend convolution can fail

It can't; these are just remnants of commit
3c7cad69f233252e5178f7732baa0da950d74bbd which let the worker threads
do the reallocation.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Check thread creation for errors
Andreas Rheinhardt [Wed, 10 Mar 2021 17:08:10 +0000 (18:08 +0100)]
dnn/dnn_backend_native_layer_conv2d: Check thread creation for errors

Fixes Coverity issue #1473533.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Check allocation
Andreas Rheinhardt [Wed, 10 Mar 2021 16:42:43 +0000 (17:42 +0100)]
dnn/dnn_backend_native_layer_conv2d: Check allocation

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Avoid separate, unchecked allocations
Andreas Rheinhardt [Wed, 10 Mar 2021 16:38:36 +0000 (17:38 +0100)]
dnn/dnn_backend_native_layer_conv2d: Avoid separate, unchecked allocations

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Fix memleak on error
Andreas Rheinhardt [Wed, 10 Mar 2021 16:22:29 +0000 (17:22 +0100)]
dnn/dnn_backend_native_layer_conv2d: Fix memleak on error

If an error happens when preparing the output data buffer, an already
allocated array would leak. Fix this by postponing its allocation.

Fixes Coverity issue #1473531.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Avoid allocation when single-threaded
Andreas Rheinhardt [Wed, 10 Mar 2021 16:03:01 +0000 (17:03 +0100)]
dnn/dnn_backend_native_layer_conv2d: Avoid allocation when single-threaded

Also fixes a memleak in single-threaded mode when an error happens
in preparing the output data buffer; and also removes an unchecked
allocation.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Join two arrays, avoid allocation
Andreas Rheinhardt [Wed, 10 Mar 2021 15:21:13 +0000 (16:21 +0100)]
dnn/dnn_backend_native_layer_conv2d: Join two arrays, avoid allocation

Fixes Coverity issue #1473507.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Fix memleak on realloc failure
Andreas Rheinhardt [Wed, 10 Mar 2021 14:40:36 +0000 (15:40 +0100)]
dnn/dnn_backend_native_layer_conv2d: Fix memleak on realloc failure

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native: Fix typo in log message
Andreas Rheinhardt [Wed, 10 Mar 2021 14:27:52 +0000 (15:27 +0100)]
dnn/dnn_backend_native: Fix typo in log message

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native: Don't use asserts for checks
Andreas Rheinhardt [Wed, 10 Mar 2021 13:00:26 +0000 (14:00 +0100)]
dnn/dnn_backend_native: Don't use asserts for checks

asserts should not be used instead of ordinary input checks.
Yet the native DNN backend did it: get_input_native() asserted that
the first dimension was one, despite this value coming directly from
the input file without having been sanitized.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native: Fix leak in case parsing options fails
Andreas Rheinhardt [Wed, 10 Mar 2021 01:59:47 +0000 (02:59 +0100)]
dnn/dnn_backend_native: Fix leak in case parsing options fails

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native: Avoid allocation for checking file magic
Andreas Rheinhardt [Wed, 10 Mar 2021 01:34:14 +0000 (02:34 +0100)]
dnn/dnn_backend_native: Avoid allocation for checking file magic

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoDoc: Tech Resolution Process
Jean-Baptiste Kempf [Wed, 10 Mar 2021 20:40:22 +0000 (21:40 +0100)]
Doc: Tech Resolution Process

3 years agoavcodec/libilbc: Support newer libiLBC versions
Andreas Rheinhardt [Thu, 11 Mar 2021 00:43:44 +0000 (01:43 +0100)]
avcodec/libilbc: Support newer libiLBC versions

Beginning with version 3.0, libiLBC switched the types of some parts
of their public API to size_t and renamed some types; the old names
continue to work as typedefs, but are deprecated. It furthermore
added version macros.

This commit uses said version macro to use the new types when using
newer libiLBC versions.

Reviewed-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavutil: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 16:58:26 +0000 (13:58 -0300)]
avutil: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 17:16:45 +0000 (14:16 -0300)]
avfilter: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavdevice: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 16:30:00 +0000 (13:30 -0300)]
avdevice: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 16:29:54 +0000 (13:29 -0300)]
avformat: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 16:29:37 +0000 (13:29 -0300)]
avcodec: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/utils: change AVStream side data related public function and struct size...
James Almer [Sat, 6 Mar 2021 18:40:58 +0000 (15:40 -0300)]
avformat/utils: change AVStream side data related public function and struct size types to size_t

av_stream_add_side_data() already defines size as a size_t, so this makes it
consistent across all side data functions.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/packet: change side data related public function and struct size types to...
James Almer [Sat, 6 Mar 2021 15:43:52 +0000 (12:43 -0300)]
avcodec/packet: change side data related public function and struct size types to size_t

av_packet_add_side_data() already defines size as a size_t, so this makes it
consistent across all side data functions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavutil/frame: change av_frame_new_side_data() size parameter type to size_t
James Almer [Sat, 6 Mar 2021 15:35:48 +0000 (12:35 -0300)]
avutil/frame: change av_frame_new_side_data() size parameter type to size_t

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavutil/buffer: change public function and struct size parameter types to size_t
James Almer [Sat, 6 Mar 2021 15:26:16 +0000 (12:26 -0300)]
avutil/buffer: change public function and struct size parameter types to size_t

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/af_dynaudnorm: make better check for available samples
Paul B Mahol [Wed, 10 Mar 2021 22:48:44 +0000 (23:48 +0100)]
avfilter/af_dynaudnorm: make better check for available samples

Also report more correct EOF timestamp.

3 years agoavfilter/vf_nnedi: Fix use of uninitialized value
Andreas Rheinhardt [Tue, 9 Mar 2021 21:43:13 +0000 (22:43 +0100)]
avfilter/vf_nnedi: Fix use of uninitialized value

Fixes Coverity issue #1473546.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agofftools/ffplay: do not write out of rdft visualization texture
Marton Balint [Wed, 3 Mar 2021 22:23:10 +0000 (23:23 +0100)]
fftools/ffplay: do not write out of rdft visualization texture

If the window is resized it was possible that xpos pointed outside the
visualization texture. By rearranging the overflow check we make sure this (and
a crash) does not happen.

We also don't have to use xleft for start position, as that is 0 anyways, and
if we ever want to take into account xleft then the texture should be
positioned accordingly when rendering.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when available
sfan5 [Wed, 17 Feb 2021 15:51:09 +0000 (16:51 +0100)]
avcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when available

Added in Android 10 it provides a reliable way of filtering out
software decoders, unlike existing string-based checks.

3 years agoavcodec/mediacodec_wrapper: check if codec is software earlier
sfan5 [Wed, 17 Feb 2021 15:50:00 +0000 (16:50 +0100)]
avcodec/mediacodec_wrapper: check if codec is software earlier

3 years agoavformat/mvdec: Allocate extradata only once
Michael Niedermayer [Fri, 1 Jan 2021 23:36:39 +0000 (00:36 +0100)]
avformat/mvdec: Allocate extradata only once

Fixes: memleak
Fixes: 28686/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5822961932173312
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavcodec/amfenc_hevc: Recommend values for min and max video quantizer scale.
Ovchinnikov Dmitrii [Tue, 9 Mar 2021 19:05:07 +0000 (22:05 +0300)]
libavcodec/amfenc_hevc: Recommend values for min and max video quantizer scale.

Current settings makes bitrate larger than expected, more information:
https://github.com/HandBrake/HandBrake/issues/3447#issue-820490736

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/decode: Reindent after previous commits
Andreas Rheinhardt [Thu, 4 Mar 2021 13:04:08 +0000 (14:04 +0100)]
avcodec/decode: Reindent after previous commits

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Don't needlessly copy side-data for subtitles
Andreas Rheinhardt [Thu, 4 Mar 2021 12:49:20 +0000 (13:49 +0100)]
avcodec/decode: Don't needlessly copy side-data for subtitles

AVCodecInternal.last_pkt_props is not used when decoding subtitles;
ergo it makes no sense to set it at all.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Avoid stack packets when decoding subtitles
Andreas Rheinhardt [Thu, 4 Mar 2021 09:53:26 +0000 (10:53 +0100)]
avcodec/decode: Avoid stack packets when decoding subtitles

Use AVCodecInternal.buffer_pkt (previously only used in
avcodec_send_packet) instead of stack packets when decoding subtitles.
Also stop sharing side-data between packets and use the user-supplied
packet directly for decoding when possible (no subtitle decoder ever
modifies the packet it is given).
Reusing AVCodecInternal.buffer_pkt is based upon an idea from James
Almer.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qsvdec: Make functions used only here static, remove header
Andreas Rheinhardt [Thu, 4 Mar 2021 15:08:41 +0000 (16:08 +0100)]
avcodec/qsvdec: Make functions used only here static, remove header

Forgotten after d78ecf10bd745cb69a71b32419e0661bfdcfb1fd.

(Also mark some AVPackets as const.)

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec: Constify some AVPackets
Andreas Rheinhardt [Thu, 4 Mar 2021 12:13:20 +0000 (13:13 +0100)]
avcodec: Constify some AVPackets

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agomailmap: add entry for myself
Linjie Fu [Mon, 8 Mar 2021 15:06:10 +0000 (15:06 +0000)]
mailmap: add entry for myself

Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
3 years agoavcodec/dcadsp: Fix integer overflow in dmix_add_c()
Michael Niedermayer [Sat, 30 Jan 2021 18:09:36 +0000 (19:09 +0100)]
avcodec/dcadsp: Fix integer overflow in dmix_add_c()

Fixes: signed integer overflow: 1515225320 + 759416059 cannot be represented in type 'int'
Fixes: 29256/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_fuzzer-5719088561258496
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/flvdec: Check double before cast in parse_keyframes_index()
Michael Niedermayer [Tue, 26 Jan 2021 15:50:10 +0000 (16:50 +0100)]
avformat/flvdec: Check double before cast in parse_keyframes_index()

Fixes: -2.21166e+304 is outside the range of representable values of type 'long'
Fixes: 29169/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5725452796821504
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/paf: Check for EOF before allocation in read_header()
Michael Niedermayer [Tue, 19 Jan 2021 23:11:34 +0000 (00:11 +0100)]
avformat/paf: Check for EOF before allocation in read_header()

Fixes: OOM
Fixes: 26584/clusterfuzz-testcase-minimized-ffmpeg_dem_PAF_fuzzer-5172661183053824
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools/target_dec_fuzzer: Adjust flv1 threshold
Michael Niedermayer [Wed, 20 Jan 2021 23:44:48 +0000 (00:44 +0100)]
tools/target_dec_fuzzer: Adjust flv1 threshold

Fixes: Timeout (long -> 95ms)
Fixes: 29068/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLV_fuzzer-6509662832820224
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/aacdec_template: Avoid undefined negation in imdct_and_windowing_eld()
Michael Niedermayer [Wed, 20 Jan 2021 22:56:43 +0000 (23:56 +0100)]
avcodec/aacdec_template: Avoid undefined negation in imdct_and_windowing_eld()

Fixes: negation of -2147483648 cannot be represented in type 'INTFLOAT' (aka 'int'); cast to an unsigned type to negate this value to itself
Fixes: 29057/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5642758933053440
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/swfdec: Check outlen before allocation
Michael Niedermayer [Thu, 21 Jan 2021 23:39:19 +0000 (00:39 +0100)]
avformat/swfdec: Check outlen before allocation

Fixes: Timeout (too long -> 241ms)
Fixes: 29083/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-6273684478230528
The source of the magic number is
A very quick simulation of the best case compression for "compress"
below is not nice written code as i did not expect I or anyone else
would ever see it again

I would have preferred some nicer expression or course, but thats
what it seems to be asymptotically. For smaller amounts of data a
tighter bound is possible but i saw no nice way to consider that
and it seems also overkill to try to do it more fine grained for
just this

main(){
    int64_t bits = 0;
    int bank = 256;
    int bitbank = 8;
    for(unsigned i = 0; i<1024*1024*1024*4U-100000;) {
        int word_size = bank-255;
        i += word_size;
        bits += bitbank;

        if (!(bank & (bank-1)))
            bitbank ++;
        bank++;
        if (bitbank > 16) {
            printf("BEST %f \n", 8.0 * i / bits );
            bank = 256;
            bitbank = 8;
        }
    }
}

above assumes i remembered correctly how the algorithm works but the
value was close to what actual compession of zeros gave

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mpeg4videodec: add forgotten flags to mpeg4_options
Paul B Mahol [Tue, 2 Mar 2021 18:52:18 +0000 (19:52 +0100)]
avcodec/mpeg4videodec: add forgotten flags to mpeg4_options

3 years agomobiclip: fix copyright headers
Florian Nouwt [Mon, 8 Mar 2021 10:54:04 +0000 (11:54 +0100)]
mobiclip: fix copyright headers

The Mobiclip related code was based on Mobius (https://github.com/adibsurani/Mobius),
which was based on my original reverse engineering efforts (https://github.com/Gericom/MobiclipDecoder).
This commit adds the appropriate copyright headers on the related files.

Signed-off-by: Florian Nouwt <fnouwt2@gmail.com>
3 years agoavcodec/ylc: Reindent after previous commit
Andreas Rheinhardt [Mon, 8 Mar 2021 15:08:52 +0000 (16:08 +0100)]
avcodec/ylc: Reindent after previous commit

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ylc: Avoid code duplication when creating and freeing VLCs
Andreas Rheinhardt [Mon, 8 Mar 2021 15:05:26 +0000 (16:05 +0100)]
avcodec/ylc: Avoid code duplication when creating and freeing VLCs

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ylc: Use only one temporary buffer
Andreas Rheinhardt [Mon, 8 Mar 2021 13:12:06 +0000 (14:12 +0100)]
avcodec/ylc: Use only one temporary buffer

The effective lifetime of the buffer used to build the VLCs and
the buffer containing the bitstream is disjoint, so that one can use
a common buffer for both.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ylc: Remove write-only variable
Andreas Rheinhardt [Mon, 8 Mar 2021 12:59:54 +0000 (13:59 +0100)]
avcodec/ylc: Remove write-only variable

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/h261dec: Remove parse_context cruft
Andreas Rheinhardt [Tue, 22 Dec 2020 17:54:12 +0000 (18:54 +0100)]
avcodec/h261dec: Remove parse_context cruft

The H.261 decoder doesn't use the ParseContext of its
MpegEncContext since e7316976650b429345da619c3acff38004aaf6b8.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolavc: clarify thread_safe_callbacks doxy
Anton Khirnov [Tue, 2 Mar 2021 09:08:08 +0000 (10:08 +0100)]
lavc: clarify thread_safe_callbacks doxy

State explicitly when this field will be removed and how to access it in
a forward compatible way.

3 years agolscrdec: add copyright header
Anton Khirnov [Thu, 4 Mar 2021 09:02:49 +0000 (10:02 +0100)]
lscrdec: add copyright header

As requested by the author.

3 years agolavc: remove tests/options
Anton Khirnov [Mon, 14 Dec 2020 14:32:41 +0000 (15:32 +0100)]
lavc: remove tests/options

It tests deprecated avcodec_copy_context().

3 years agotests/api-flac-test: reindent
Anton Khirnov [Wed, 27 Jan 2021 12:38:00 +0000 (13:38 +0100)]
tests/api-flac-test: reindent

3 years agotests/api-flac-test: convert to new encoding/decoding API
Anton Khirnov [Wed, 27 Jan 2021 12:38:00 +0000 (13:38 +0100)]
tests/api-flac-test: convert to new encoding/decoding API

3 years agotests/api-flac-test: ensure the frame is writable before writing to it
Anton Khirnov [Wed, 27 Jan 2021 10:43:03 +0000 (11:43 +0100)]
tests/api-flac-test: ensure the frame is writable before writing to it

The encoder may keep a reference to frames that were sent to it, so the
caller cannot modify them without checking first.

3 years agomjpegdec: handle lowres with AVID cropping
Anton Khirnov [Mon, 1 Mar 2021 09:10:54 +0000 (10:10 +0100)]
mjpegdec: handle lowres with AVID cropping

3 years agoavcodec/jpeglsenc: Allocate buffers together
Andreas Rheinhardt [Thu, 3 Sep 2020 17:50:03 +0000 (19:50 +0200)]
avcodec/jpeglsenc: Allocate buffers together

Having only one allocation that is not automatically freed in particular
means that one does not need to free the already allocated buffers
when allocating another one fails.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/jpeglsenc: Avoid allocation of JLSState
Andreas Rheinhardt [Thu, 3 Sep 2020 17:48:10 +0000 (19:48 +0200)]
avcodec/jpeglsenc: Avoid allocation of JLSState

This state is currently allocated and freed for every packet; but it can
just be moved to the stack instead.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/jpeglsenc: Only use one line at a time as spare buffer
Andreas Rheinhardt [Thu, 3 Sep 2020 17:02:59 +0000 (19:02 +0200)]
avcodec/jpeglsenc: Only use one line at a time as spare buffer

ls_encode_line() encodes one line of input from left to right and
to do so it uses the values of the left, upper left, upper and upper
right pixels for prediction (i.e. the values that a decoder gets when it
decodes the already encoded part of the picture). So a simple algorithm
would use a buffer that can hold two lines, namely the current line as
well as the last line and swap the pointers to the two lines after
decoding each line. Yet if one is currently encoding the pixel with
index k of a line, one doesn't need any pixel with index < k - 1 of the
last line at all and similarly, no pixels with index >= k have been
written yet. So the overlap in the effective lifetime is pretty limited
and since the last patch (which stopped reading the upper left pixel and
instead reused the value of the upper pixel from the last iteration of
the loop) it is inexistent. Ergo one only needs one line and doesn't
need to swap the lines out.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/jpeglsenc: Move check out of loop
Andreas Rheinhardt [Thu, 3 Sep 2020 16:39:43 +0000 (18:39 +0200)]
avcodec/jpeglsenc: Move check out of loop

ls_encode_line() encodes a line of input, going from left to right. In
order to calculate a predicted value it uses the left and upper-left
value of the output picture (that is, it uses how a decoder would see
the already encoded part of the picture), unless this is the very first
pixel of this line in which case one uses the first pixel of the last
(upper) line and the line before the last line. Therefore the loop
contained a check for whether this is the beginning of a new line. This
commit moves said check out of the loop by initializing these values
before the loop and by updating these values at the end of the loop
body; already read/calculated values are reused for this (the prediction
also needs the value of the upper pixel and this can be reused for the
upper left value of the next iteration of the loop).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/jpeglsenc: Don't modify frame we don't own
Andreas Rheinhardt [Thu, 3 Sep 2020 14:25:24 +0000 (16:25 +0200)]
avcodec/jpeglsenc: Don't modify frame we don't own

The jpegls encoder uses three buffers (as well as its state) to perform
its function: A copy of the last encoded line as a decoder would decode it,
the part of the current line that has been encoded (again, as a decoder
would decode it) and the part of the current line that is not yet encoded.

The encoder solves this by modifying the input frame as it encodes the
output (it also zero-allocates a line to serve as last line for the
first line where no preceding line exists); yet this is wrong as said
frame is not owned by the encoder, so it must not be modified (and it is
given to the encoder as const AVFrame *) without making it writable.

This patch solves this bug by allocating two lines, one for the last and
one for the currently encoded line of output (as a decoder would decode it).

Notice that the frame is only modified if the encoder is in the
non-default non-lossless mode.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/jpeglsenc: Don't use put bits API for byte-aligned writes
Andreas Rheinhardt [Thu, 3 Sep 2020 10:42:09 +0000 (12:42 +0200)]
avcodec/jpeglsenc: Don't use put bits API for byte-aligned writes

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/codec: Update init_static_data doxygen
Andreas Rheinhardt [Sat, 6 Mar 2021 13:31:05 +0000 (14:31 +0100)]
avcodec/codec: Update init_static_data doxygen

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/avcodec: Don't suggest calling deprecated avcodec_register_all()
Andreas Rheinhardt [Fri, 26 Feb 2021 03:59:59 +0000 (04:59 +0100)]
avcodec/avcodec: Don't suggest calling deprecated avcodec_register_all()

Despite avcodec_register and avcodec_register_all being deprecated,
their documentation still said that one of them has to be called
before doing anything else. Clarify this confusing situation.

Furthermore, don't use avcodec_register_all in sample code for
a non-deprecated function.

Reviewed-by: mypopy@gmail.com <mypopy@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Don't needlessly strdup metadata
Andreas Rheinhardt [Tue, 2 Mar 2021 14:44:07 +0000 (15:44 +0100)]
avformat/dashdec: Don't needlessly strdup metadata

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Remove limit on length of id
Andreas Rheinhardt [Tue, 2 Mar 2021 14:32:30 +0000 (15:32 +0100)]
avformat/dashdec: Remove limit on length of id

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/codec: add doxy to AVCodec.decode()
James Almer [Fri, 5 Mar 2021 04:05:05 +0000 (01:05 -0300)]
avcodec/codec: add doxy to AVCodec.decode()

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/codec: use the correct name for all AVCodec.decode() parameters
James Almer [Fri, 5 Mar 2021 04:01:08 +0000 (01:01 -0300)]
avcodec/codec: use the correct name for all AVCodec.decode() parameters

This field hasn't been used to return the output frame size since
avcodec_decode_audio4() was introduced.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/codec: remove outdated comment about AVCodec.encode2()
James Almer [Fri, 5 Mar 2021 03:55:21 +0000 (00:55 -0300)]
avcodec/codec: remove outdated comment about AVCodec.encode2()

The packet passed as argument to this function hasn't contained
a user-provided buffer since 93016f5d1d.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/buffersink: Postpone removal of av_[a]buffersink_params_alloc
Andreas Rheinhardt [Sat, 6 Mar 2021 17:23:43 +0000 (18:23 +0100)]
avfilter/buffersink: Postpone removal of av_[a]buffersink_params_alloc

They have been deprecated in 61097535cdaa91fea0d62c567b3af02a940f6c2d,
yet this was less than two years ago. Removing them will therefore have
to wait.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/avfilter: Remove avfilter_link_set_closed() on bump
Andreas Rheinhardt [Sat, 6 Mar 2021 17:02:47 +0000 (18:02 +0100)]
avfilter/avfilter: Remove avfilter_link_set_closed() on bump

Deprecated in 39a09e995d32d16e4f8c87a6ff5273cb9d98146e.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodoc/muxers.texi: Readd documentation removed accidentally
Andreas Rheinhardt [Sat, 6 Mar 2021 16:11:38 +0000 (17:11 +0100)]
doc/muxers.texi: Readd documentation removed accidentally

Happened in e7c04eaf50b4b50f2528ab2c69b76777a1862535.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/http: Fix leak when using deprecated option
Andreas Rheinhardt [Sat, 6 Mar 2021 12:55:04 +0000 (13:55 +0100)]
avformat/http: Fix leak when using deprecated option

When the deprecated option "user-agent" was set to something different
than its default value, said option would always precede and overwrite
the ordinary user_agent option (regardless of whether it was explicitly
set) which leads to a leak of the user_agent option (which has a default
value, so the leak happens always).
Fix this by setting the same destination for both options; the last
option applied wins then.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/libxvid: Remove unnecessary header
Andreas Rheinhardt [Sat, 6 Mar 2021 12:05:42 +0000 (13:05 +0100)]
avcodec/libxvid: Remove unnecessary header

Forgotten in a1c6fc773f941fd6a6ef3f12f102a7902ae69453.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter: add msad video filter
Paul B Mahol [Wed, 3 Mar 2021 18:31:38 +0000 (19:31 +0100)]
avfilter: add msad video filter

3 years agoavfilter: add identity video filter
Paul B Mahol [Wed, 3 Mar 2021 14:21:04 +0000 (15:21 +0100)]
avfilter: add identity video filter

3 years agoavcodec/parser: Schedule av_parser_change for removal
Andreas Rheinhardt [Fri, 26 Feb 2021 09:32:51 +0000 (10:32 +0100)]
avcodec/parser: Schedule av_parser_change for removal

Originally deprecated in 748c2fca7e4d99357c234936aa71212a6282be36,
publically deprecated in 9a07c1332cfe092b57b5758f22b686ca58806c60
(merged into FFmpeg in 1885ffb03d0af28e6bac2bcc8725fa15b93f6ac9).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat: add TTML muxer
Jan Ekström [Thu, 4 Mar 2021 17:09:50 +0000 (19:09 +0200)]
avformat: add TTML muxer

Enables writing TTML documents or encoded TTML paragraphs as such
documents.

Additionally, a test for the combined TTML encoder and muxer has
been added to validate that the components still work.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
3 years agoavcodec: add TTML encoder
Jan Ekström [Thu, 19 Jan 2017 13:02:27 +0000 (13:02 +0000)]
avcodec: add TTML encoder

Enables encoding of other subtitle formats into TTML paragraphs.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
3 years agoavcodec: enable usage of err_recognition for encoders
Jan Ekström [Mon, 22 Feb 2021 12:21:09 +0000 (14:21 +0200)]
avcodec: enable usage of err_recognition for encoders

Enables the usage of such values as AV_EF_EXPLODE in encoders, which
can be useful in cases such as subtitle encoders where they have the
responsibility to validate the correctness of an incoming ASS dialog line.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
3 years agoffprobe: switch to av_bprint_escape for XML escaping
Jan Ekström [Mon, 16 Nov 2020 07:46:42 +0000 (09:46 +0200)]
ffprobe: switch to av_bprint_escape for XML escaping

Additionally update the result of the ffprobe XML writing test.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
3 years agoavutil/{avstring,bprint}: add XML escaping from ffprobe to avutil
Stefano Sabatini [Mon, 16 Nov 2020 07:38:39 +0000 (09:38 +0200)]
avutil/{avstring,bprint}: add XML escaping from ffprobe to avutil

Base escaping only escapes values required for base character data
according to part 2.4 of XML, and if additional flags are added
single and double quotes can additionally be escaped in order
to handle single and double quoted attributes.

Co-authored-by: Jan Ekström <jan.ekstrom@24i.com>
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
3 years agoavcodec/decode: Check size before opening iconv
Andreas Rheinhardt [Thu, 4 Mar 2021 08:36:15 +0000 (09:36 +0100)]
avcodec/decode: Check size before opening iconv

Avoids closing iconv when the size check fails.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Return early upon failure
Andreas Rheinhardt [Thu, 4 Mar 2021 08:32:21 +0000 (09:32 +0100)]
avcodec/decode: Return early upon failure

Allows to remove one level of indentation.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>