Commit Graph

99424 Commits

Author SHA1 Message Date
James Almer 515b6419ca avcodec/cbs: add a flush callback to CodedBitstreamType
Used to reset the codec's private internal state.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-29 21:38:27 -03:00
Paul B Mahol 23d0754165 avfilter/vf_v360: stop using floats variables in xyz_to_octahedron
Use proper integer variables.
2020-09-30 00:09:22 +02:00
Timo Rothenpieler a96743a05c avcodec/cuviddec: handle arbitrarily sized extradata 2020-09-29 23:29:04 +02:00
Andreas Rheinhardt 5bc74d06da avcodec/utils: Only call codec->close if init has been called
avcodec_open2() also called the AVCodec's close function if an error
happened before init had ever been called if the AVCodec has the
FF_CODEC_CAP_INIT_CLEANUP flag set. This is against the documentation of
said flag: "The codec allows calling the close function for deallocation
even if the init function returned a failure."

E.g. the SVQ3 decoder is not ready to be closed if init has never been
called.

Fixes: NULL dereference
Fixes: 25762/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5716279070294016

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

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-29 21:18:19 +02:00
Mark Thompson 4fceb2634e Revert "avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE"
This reverts commit 5bbf58ab87.

The setparams filters are not hwframe aware, so the default context
passthrough behaviour is needed to allow using them with hardware frames.
2020-09-29 17:07:43 +01:00
Paul B Mahol 12585c87e6 avfilter/vf_v360: simplify input flipping 2020-09-29 14:21:22 +02:00
Paul B Mahol 86b29c0cd0 avfilter/vf_v360: split maps into slices 2020-09-29 14:21:20 +02:00
Mingyu Yin ad2546e3b3 dnn/native: add native support for dense
Signed-off-by: Mingyu Yin <mingyu.yin@intel.com>
2020-09-29 14:19:55 +08:00
Rick Kern adcdf0bc60 libavcodec/videotoolboxenc: Fix crash when frame received after error
Signed-off-by: Rick Kern <kernrj@gmail.com>
2020-09-28 21:48:23 -04:00
Tian Qi 9837f5a643 avcodec/videotoolboxenc: move pthread_cond_signal after add buffer to the queue
In the VT encoding insertion by FFmpeg,
and vtenc_q_push is callback to add the encoded data
to the singly linked list group in VTEncContext,
and consumers are notified to fetch it.
However, because it first informs consumers of pthread_cond_signal,
and then inserts the data into the tail,
there is a multi-thread safety hazard.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Rick Kern <kernrj@gmail.com>
2020-09-28 21:46:40 -04:00
Tian Qi 1cbea3f9ca avcodec/videotoolboxenc: don't wait when flushing data
because there is run in thread mode, few times will block
the workflow at the wait, so check the status is flushing data,
don't wait when flushing data.

Signed-off-by: Tian Qi <tianqi@kuaishou.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Rick Kern <kernrj@gmail.com>
2020-09-28 21:46:30 -04:00
Zhao Zhili d80d91d213 avcodec/videotoolboxenc: fix use after destroy
The lock is used in clear_frame_queue().

Signed-off-by: Rick Kern <kernrj@gmail.com>
2020-09-28 21:46:23 -04:00
Zhao Zhili 419d2524a8 avcodec/videotoolboxenc: fix align issue
bool a53_cc is accessed as int:
src/libavutil/opt.c:129:9: runtime error: store to misaligned
address 0x7fbf454121a3 for type 'int', which requires 4 byte alignment

Signed-off-by: Rick Kern <kernrj@gmail.com>
2020-09-28 21:45:54 -04:00
Harry Mallon e16788a323 avcodec/videotoolboxenc: Allow full range 10bit pixel format input
Signed-off-by: Harry Mallon <harry.mallon@codex.online>
Signed-off-by: Rick Kern <kernrj@gmail.com>
2020-09-28 20:46:36 -04:00
Harry Mallon 80384a6ec3 avcodec/videotoolboxenc: Set profile (main/main10) on HEVC encode
Signed-off-by: Harry Mallon <harry.mallon@codex.online>
Signed-off-by: Rick Kern <kernrj@gmail.com>
2020-09-28 20:46:05 -04:00
Michael Niedermayer ddf2ba5497 avcodec/mv30: Fix several integer overflows in idct_1d()
Fixes: signed integer overflow: -1846510390 + -361755993 cannot be represented in type 'int'
Fixes: 23941/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5654696631730176

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-29 00:43:26 +02:00
Michael Niedermayer 165d6b876b avcodec/pgxdec: Fix invalid shift in write_frame_*
Fixes: left shift of negative value -121
Fixes: 23911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGX_fuzzer-4986800258154496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-29 00:43:26 +02:00
Andreas Rheinhardt 4106013523 avformat/movenc: Fix segfault upon allocation error
Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-28 20:41:20 +02:00
Michael Niedermayer 24352ca792 avformat/iff: Check data_size not overflowing int64
Fixes: Infinite loop
Fixes: 25844/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5660803318153216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-28 20:22:30 +02:00
Anton Khirnov 56ff01e6ec pthread_frame: use av_buffer_replace() to simplify code 2020-09-28 11:33:36 +02:00
Anton Khirnov 16f8b96dfa mpegvideo: use av_buffer_replace() to simplify code 2020-09-28 11:33:36 +02:00
Anton Khirnov eff289ce9f hevcdec: use av_buffer_replace() to simplify code 2020-09-28 11:33:36 +02:00
Anton Khirnov 68918d3b7f lavu/buffer: add a convenience function for replacing buffers
A common pattern e.g. in libavcodec is replacing/updating buffer
references: unref old one, ref new one. This function allows simplifying
such code and avoiding unnecessary refs+unrefs if the references are
already equivalent.
2020-09-28 11:33:35 +02:00
Pavel Koshevoy 5bbf58ab87 avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE
Allow setparams to be used with hw backed frames and
avoid an assertion failure in avfilter_config_links.
2020-09-27 19:15:44 -06:00
Jun Zhao 5bf22519ce lavf/hls: add AC-3/EAC-3 to allowed extensions file list
Add AC-3/EAC-3 to allowed extensions file list.

From HTTP Live Streaming 2nd Edition draft-pantos-hls-rfc8216bis-07
section 3.1.3.Packed Audio, HLS demuxer need to support MP3/AC-3/EAC-3.

Reviewd-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-09-28 09:12:09 +08:00
Jun Zhao ef868fa4a1 examples/muxing: misc style fixes
misc style fixes.

Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-09-28 09:11:21 +08:00
Paul B Mahol 6db1b1af4c avfilter/vf_v360: add octahedron format 2020-09-27 22:40:26 +02:00
Andrew Klaassen a6e72fb46d vf_colorspace: Added linear trc.
This patch adds the coefficients for the linear gamma function (1,0,1,0)
to the colorspace filter.

Signed-off-by: Andrew Klaassen <clawsoon@yahoo.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2020-09-27 09:14:46 -04:00
Paul B Mahol a3a6b56200 avcodec: add Argonaut Games Video decoder 2020-09-27 09:56:13 +02:00
Andreas Rheinhardt e575d59afe tests/fate-run: Always overwrite output files for md5 tests
Otherwise the result of such tests will not accurately reflect the
current state.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-27 09:51:31 +02:00
Zane van Iperen ce30c3d5b9
avformat/argo_brp: use header frame counts
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-27 09:11:36 +10:00
Zane van Iperen 3ffb15a105
avformat/argo_brp: allow v1.1 ASF streams to have a non-22050 sample rate in certain circumstances
It seems that in files where the BASF block isn't first, v1.1 ASF streams are
allowed to be non-22050. Either this format is really inconsistent, or
FX Fighter and Croc just ignored the sample rate field, requiring the v1.1
restriction in the first place.

This bumps the version to 1.2 in these streams so they're not "corrected".

Found in Alien Odyssey games files in:
./GRAPHICS/COMMBUNK/{{COMADD1,COMM2_{1,2,3E},COMM3_{2,3,4,5,6}},FADE{1,2}}.BRP

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-27 09:11:36 +10:00
Zane van Iperen 97efac3ac1
avformat/argo_brp: cosmetics
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-27 09:11:35 +10:00
Zane van Iperen da5ab5a0b6
avformat/argo_brp: handle the case where the BASF block isn't the first
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-27 09:11:35 +10:00
Zane van Iperen 2e7752afff
avformat/argo_brp: support MASK streams
We can't actually use them though.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-27 09:11:34 +10:00
Zane van Iperen ebfed56858
avformat/argo_{asf,brp}: fix potential segfault in ff_argo_asf_fill_stream()
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-27 09:11:29 +10:00
Andriy Gelman ff5fcd0be0 avcodec/v4l2_buffers: remove unused function argument
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-09-26 17:37:51 -04:00
Paul B Mahol 85195f6ae9 avfilter/vf_histogram: add slide modes for thistogram 2020-09-26 22:04:27 +02:00
Andreas Rheinhardt a162e78cd5 avcodec/fraps: Use cached bitstream reader
This proved beneficial for performance: For the sample [1] the number
of decicycles in one decode call decreased from 155851561 to 108158037
for Clang 10 and from 168270467 to 128847479 for GCC 9.3. For x86-32
compiled with GCC 9.3 and run on an x64 Haswell the number increased
from 158405517 to 202215769, so that the cached bitstream reader is only
enabled if HAVE_FAST_64BIT is set. These values are the average of 10
runs each looping five times over the input.

[1]: samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2593/fraps_flv1_decoding_errors.avi

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 21:10:45 +02:00
Andreas Rheinhardt bc6838deb9 avcodec/fraps: Use unchecked bitstream reader
The fraps decoder already checked for overreads manually (and errored
out in this scenario), yet it still enabled implicit checks, leading to
worse performance and more code size.

This commit disables the implicit bitstream reader checks. For the
sample [1] this improves performance from 195105896 to 155851561
decicycles for Clang 10 and from 222801887 to 168270467 decicycles when
compiled with GCC 9.3. These values are the average of 10 runs each
looping ten times over the input.

[1]: samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2593/fraps_flv1_decoding_errors.avi

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 21:10:45 +02:00
Andreas Rheinhardt bb16dbc002 avcodec/utvideo: Move stuff only used by Ut encoder to Ut encoder
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 21:10:45 +02:00
Andreas Rheinhardt 5f5f0b06cf avcodec/utvideo: Remove unused array
Unused since 3594788b71.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 21:10:45 +02:00
Andreas Rheinhardt 341914495e avcodec/utvideodec: Avoid qsort when creating Huffman tables
The Ut video format uses Huffman trees which are only implicitly coded
in the bitstream: Only the lengths of the codes are coded, the rest has
to be inferred by the decoder according to the rule that the longer
codes are to the left of shorter codes in the tree and on each level the
symbols are descending from left to right.

Because longer codes are to the left of shorter codes, one needs to know
how many non-leaf nodes there are on each level in order to know the
code of the next left-most leaf (which belongs to the highest symbol on
that level). The current code does this by sorting the entries to be
ascending according to length and (for entries with the same length)
ascending according to their symbols. This array is then traversed in
reverse order, so that the lowest level is dealt with first, so that the
number of non-leaf nodes of the next higher level is known when
processing said level.

But this can also be calculated without sorting: Simply count how many
leaf nodes there are on each level. Then one can calculate the number of
non-leaf nodes on each level iteratively from the lowest level upwards:
It is just half the number of nodes of the level below.

This improves performance: For the sample from ticket #4044 the amount
of decicycles for one call to build_huff() decreased from 1055489 to
446310 for Clang 10 and from 1080306 to 535155 for GCC 9.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 21:10:45 +02:00
Andreas Rheinhardt 9c8b85f5fa avcodec/utvideodec: Remove code duplication when creating Huffman tables
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 21:10:45 +02:00
Andreas Rheinhardt 099feb9411 avcodec/utvideodec/enc: Fix edge case of creating Huffman table
The Ut Video format stores Huffman tables in its bitstream by coding
the length of a given symbol; it does not code the actual code directly,
instead this is to be inferred by the rule that a symbol is to the left
of every shorter symbol in the Huffman tree and that for symbols of the
same length the symbol is descending from left to right. With one
exception, this is also what our de- and encoder did.

The exception only matters when there are codes of length 32, because
in this case the first symbol of this length did not get the code 0,
but 1; this is tantamount to pretending that there is a (nonexistent)
leaf of length 32. This is simply false. The reference software agrees
with this [1].

[1]: 2700a471a7/utv_core/HuffmanCode.cpp (L280)

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 21:10:29 +02:00
Andreas Rheinhardt 116b235a0b avcodec/magicyuv: Don't waste stack space
Now that the HuffEntries are no longer sorted by the MagicYUV decoder,
their symbols are trivial: The symbol of the element with index i is i.
They can therefore be removed. Furthermore, despite the length of the
codes being in the range 1..32 bits, the actual value of the codes is
<= 4096 (for 12 bit content). The reason for this is that the longer
codes are on the left side of the tree, so that the higher bits of
these codes are simply zero. By using an uint16_t for the codes and
removing the symbols entry, the size of each HuffEntry is decreased from
eight to four, saving 16KB of stack space.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 20:38:30 +02:00
Andreas Rheinhardt 1bf30a1beb avcodec/magicyuv: Avoid AV_QSORT when creating Huffman table
The MagicYUV format stores Huffman tables in its bitstream by coding
the length of a given symbol; it does not code the actual code directly,
instead this is to be inferred by the rule that a symbol is to the left
of every shorter symbol in the Huffman tree and that for symbols of the
same length the symbol is ascending from left to right.

Our decoder implemented this by first sorting the array containing
length and symbol of each element according to descending length and
for equal length, according to ascending symbol. Afterwards, the current
state in the tree got encoded in a variable code; if the next array entry
had length len, then the len most significant bits of code contained
the code of this entry. Whenever an entry of the array of length
len was processed, code was incremented by 1U << (32 - len). So two
entries of length len have the same effect as incrementing code by
1U << (32 - (len - 1)), which corresponds to the parent node of length
len - 1 of the two nodes of length len etc.

This commit modifies this to avoid sorting the entries before
calculating the codes. This is done by calculating how many non-leaf
nodes there are on each level of the tree before calculating the codes.
Afterwards every leaf node on this level gets assigned the number of
nodes already on this level as code. This of course works only because
the entries are already sorted by their symbol initially, so that this
algorithm indeed gives ascending symbols from left to right on every
level.

This offers both speed- as well as (obvious) codesize advantages. With
Clang 10 the number of decicycles for build_huffman decreased from
1561987 to 1228405; for GCC 9 it went from 1825096 decicyles to 1429921.
These tests were carried out with a sample with 150 frames that was
looped 13 times; and this was iterated 10 times. The earlier reference
point here is from the point when the loop generating the codes was
traversed in reverse order (as the patch reversing the order led to
performance penalties).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 20:38:30 +02:00
Andreas Rheinhardt 59f7d68514 avcodec/magicyuv: Fix edge case of building Huffman table
The MagicYUV format stores Huffman tables in its bitstream by coding
the length of a given symbol; it does not code the actual code directly,
instead this is to be inferred by the rule that a symbol is to the left
of every shorter symbol in the Huffman tree and that for symbols of the
same length the symbol is ascending from left to right. With one
exception, this is also what our decoder did.

The exception only matters when there are codes of length 32, because
in this case the first symbol of this length did not get the code 0,
but 1; e.g. if there were exactly two nodes of length 32, then they
would get assigned the codes 1 and 2 and a node of length 31 will get
the 31-bit code 1 which is a prefix of the 32 bit code 2, making the
Huffman table invalid. On the other hand, if there were only one symbol
with the length 32, the earlier code would accept this un-Huffman-tree.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 20:38:30 +02:00
Andreas Rheinhardt 68b6614e38 avcodec/magicyuv: Don't invert order unnecessarily
The MagicYUV decoder currently sets both the length and the symbol field
of an array of HuffEntries; hereby the symbol of the ith entry (0-based)
is just i. Then said array gets sorted so that entries with greater
length are at the end and entries with the same length are ordered so
that those with smaller symbols are at the end. Afterwards the newly
sorted array is traversed in reverse order. This commit instead inverts
the ordering and traverses the array in its ordinary order in order to
simplify understanding.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 20:38:30 +02:00
Andreas Rheinhardt 157953066c avcodec/magicyuv: Replace implicit checks for overread by explicit ones
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-26 20:38:30 +02:00