1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00
Commit Graph

43480 Commits

Author SHA1 Message Date
Andreas Rheinhardt
38ee8f80ea avcodec/photocd: Remove set-but-unused variables
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 22:05:31 +02:00
Andreas Rheinhardt
c1a5d06b82 avcodec/mobiclip: Fix mixed declarations and code
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 22:04:57 +02:00
Andreas Rheinhardt
ae343d6595 avcodec/binkaudio: Avoid allocation for array
The array in question can not be too large (only 26 elements), so it can
simply be put on the context.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 20:43:43 +02:00
Andreas Rheinhardt
c703088c1b avcodec/binkaudio: Remove unused array from context
Unused since 7bfd1766d1.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 20:42:57 +02:00
Andreas Rheinhardt
2777bae7f2 avcodec/binkaudio: Don't use static storage for context-dependent data
Move it to the context instead.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 20:42:10 +02:00
Andreas Rheinhardt
d2308b9237 avcodec/bink: Only keep what is used from HpelDSPContext
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 20:40:55 +02:00
Andreas Rheinhardt
ceeba2ac2b avcodec/bink: Combine allocations of arrays into one
Saves allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 20:40:02 +02:00
Andreas Rheinhardt
4f67288948 avcodec/bink: Fix memleak upon init failure
The init function first allocates an AVFrame and then some buffers; if
one of the buffers couldn't be allocated, the AVFrame leaks. Solve this
by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 20:37:12 +02:00
Paul B Mahol
c8e38950e3 avcodec: add PhotoCD decoder 2020-09-04 16:01:53 +02:00
Paul B Mahol
7f95339319 avcodec: add MobiClip video decoder 2020-09-03 18:09:30 +02:00
Paul B Mahol
1304078d3c avcodec: add FastAudio decoder 2020-09-03 18:07:58 +02:00
Paul B Mahol
a1caa16d45 avcodec: add ADPCM IMA MOFLEX decoder 2020-09-03 18:06:50 +02:00
Paul B Mahol
2d16b6bd3e avcodec/dxtory: add support for vertically flipped frames 2020-09-03 18:03:27 +02:00
Limin Wang
4cfe8123ea avcodec/nvenc_hevc: add ff_nvenc_encode_flush() for .flush
for the .capabilities have AV_CODEC_CAP_ENCODER_FLUSH, so it's better to add it.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-09-03 21:30:01 +08:00
Paul B Mahol
7b1ed4b53a avcodec/proresdec2: let long name match one from codec_desc.c 2020-09-02 19:03:55 +02:00
Fei Wang
bf6db5732c avcodec/cbs_av1: add missing frame restoration type enum values
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-02 12:33:02 -03:00
Mark Thompson
2a19232c19 cbs_av1: Fill tile width/height values when uniform_tile_spacing_flag is set
They are not explicitly in the bitstream in this case, but it is helpful
to be able to use these values without always needing to check the flag
beforehand.
2020-09-02 00:00:57 +01:00
Mark Thompson
cf6af829c2 cbs_mpeg2: Use table-based alloc/free 2020-09-02 00:00:57 +01:00
Mark Thompson
ae7686a64f cbs_av1: Use table-based alloc/free 2020-09-02 00:00:57 +01:00
Mark Thompson
f643f9bd6d cbs_vp9: Use table-based alloc/free 2020-09-02 00:00:57 +01:00
Mark Thompson
e38646de1c cbs_h265: Use table-based alloc/free 2020-09-02 00:00:57 +01:00
Andreas Rheinhardt
d1c6e09d09 h264_redundant_pps: Make it reference-compatible
Since c6a63e1109, the parameter sets
modified as content of PPS units were references shared with the
CodedBitstreamH264Context, so modifying them alters the parsing process
of future access units which meant that frames often got discarded
because invalid values were parsed. This patch makes h264_redundant_pps
compatible with the reality of reference-counted parameter sets.

Fixes #7807.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2020-09-02 00:00:57 +01:00
Mark Thompson
0720e15c03 cbs_h2645: Ensure that non-refcounted parameter sets are fully copied
Only copying the main structure is not necessarily sufficient - there
could be references to substructures.
2020-09-02 00:00:57 +01:00
Mark Thompson
42daac1c74 cbs: Add support functions for handling unit content references
Use the unit type table to determine what we need to do to clone the
internals of the unit content when making copies for refcounting or
writeability.  (This will still fail for units with complex content
if they do not have a defined clone function.)

Setup and naming from a patch by Andreas Rheinhardt
<andreas.rheinhardt@gmail.com>, but with the implementation changed
to use the unit type information if possible rather than requiring a
codec-specific function.
2020-09-02 00:00:57 +01:00
Mark Thompson
2cb152d52f cbs_h264: Use table-based alloc/free 2020-09-02 00:00:57 +01:00
Mark Thompson
225f287885 cbs: Add macros to support defining unit type tables 2020-09-02 00:00:57 +01:00
Mark Thompson
bc7a7e0d65 cbs: Describe allocate/free methods in tabular form
Unit types are split into three categories, depending on how their
content is managed:
* POD structure - these require no special treatment.
* Structure containing references to refcounted buffers - these can use
  a common free function when the offsets of all the internal references
  are known.
* More complex structures - these still require ad-hoc treatment.

For each codec we can then maintain a table of descriptors for each set of
equivalent unit types, defining the mechanism needed to allocate/free that
unit content.  This is not required to be used immediately - a new alloc
function supports this, but does not replace the old one which works without
referring to these tables.
2020-09-02 00:00:57 +01:00
Mark Thompson
1fe77d4a63 cbs: Ensure that reference fields always follow the associated pointer
Having these together allows us to find both pointers given the address
of only one of them.
2020-09-02 00:00:50 +01:00
James Almer
0271098e6c avcodec/encode: unref the packet on AVCodec.receive_packet() failure
Fixes memleaks with some encoders that don't unref the packet before
returning.
This is consistent with the behavior of AVCodec.encode()
implementations in encode_simple_internal().

Found-by: mkver
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-01 10:05:05 -03:00
Paul B Mahol
97c73ba565 avcodec/qpeg: speed-up copy of bytes 2020-09-01 14:19:19 +02:00
Andreas Rheinhardt
a13a23bdf2 avcodec/magicyuv: Avoid intermediate array when parsing Huffman tables
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 11:05:38 +02:00
Andreas Rheinhardt
61499c6456 avcodec/magicyuv: Unify creating Huffman tables
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 11:05:38 +02:00
Andreas Rheinhardt
aae499f77a avcodec/magicyuv: Reuse array instead of using multiple arrays
The lengths of the VLC codes are implicitly contained in the VLC tables
itself; apart from that they are not used lateron. So it is unnecessary
to store them and the very same array can be reused to parse the Huffman
table for the next plane.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 11:05:38 +02:00
Andreas Rheinhardt
7f452c099a avcodec/magicyuv: Don't zero unnecessarily
The code already checks that exactly the expected amount of entries are
read and set. Ergo it is unnecessary to zero them at the beginning.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 11:05:38 +02:00
Andreas Rheinhardt
e8716b7e4c avcodec/magicyuv: Simplify check for invalid Huffman codes
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 11:05:38 +02:00
Andreas Rheinhardt
18dbbff525 avcodec/magicyuv: Unify qsort comparison functions
Up until now, there were three comparison functions depending upon
bitness. But they all are actually the same, namely a lexical ordering:
entry a > entry b iff a.len > b.len or a.len == b.len and a.sym < b.sym.
So they can be easily unified.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 11:05:38 +02:00
Andreas Rheinhardt
d0b0fc7cb9 avcodec/magicyuv: Avoid copying values around pointlessly
When parsing Huffman tables, an array of HuffEntries (a struct
containing a code's bitlength, its bits and its symbol) is used as
intermediate tables in order to sort the entries (the order depends on
both the length of the entries as well as on their symbols). After sorting
them, the symbol and len components are copied into other arrays (the
HuffEntries' code has never been set or used, despite using quite a lot
of stack space) and the codes are generated. Afterwards, the VLC is
created.

Yet ff_init_vlc_sparse() can handle non-continuous arrays as input;
there is no need to copy the entries at all. This commit implements
this.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 11:05:38 +02:00
Andreas Rheinhardt
7332a23b84 avcodec/magicyuv: Don't invert Huffman table symbols twice
When the MagicYUV decoder builds Huffman tables from an array of code
lengths, it proceeds as follows: First it copies the entries of the
array of lengths into an array of HuffEntries (a struct which contains
a length and a symbol field); it also sets the symbol field in
descending order from nb_elem - 1 to 0, where nb_elem is the common number
of elements of the length and HuffEntry arrays. Then the HuffEntry array
is sorted lexicographically: a > b iff a.len > b.len or a.len == b.len and
a.sym > b.sym. Afterwards the symbols of the so sorted array are
inverted again (i.e. each symbol sym is replaced by nb_elem - sym).

Yet inverting can easily be avoided altogether: Just modify the order so
that smaller symbols correspond to bigger HuffEntries. This leads to the
same permutation as the current code does and given that the two
inversions just cancel each other out, the result is the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 11:05:38 +02:00
Andreas Rheinhardt
6fad76b51d avcodec/bitstream: Remove outdated comment
The comment referred to the INIT_VLC_USE_STATIC flag which has been
removed in 2009 in 595324e143b57a52e2329eb47b84395c70f93087; the
function it referred to was removed even earlier in commit
83422c1940 in 2008.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01 09:07:58 +02:00
Paul B Mahol
04d335e436 avcodec/sheervideo: use cached bitstream reader except for x32 2020-08-31 20:10:24 +02:00
Paul B Mahol
57915df230 avcodec/magicyuv: change bits used by 12bit tables
Higher number slows decoder.
2020-08-31 19:56:22 +02:00
Paul B Mahol
276d86a8b8 avcodec/magicyuv: use cached bitstream reader except for x32 2020-08-31 16:31:25 +02:00
Paul B Mahol
445e5fb67a avcodec/magicyuv: invert symbols when building vlc
Instead at every decoded symbol.
2020-08-31 16:31:10 +02:00
Andreas Rheinhardt
e6c5102fb4 avcodec/roqvideodec: Remove set-but-unused frame stats
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-31 03:00:09 +02:00
Andreas Rheinhardt
a067d44955 avcodec/roqvideodec: Move transient GetByteContext to the stack
This avoids keeping potentially dangling pointers in the context,
beautifies the code (by replacing "&ri->gb" by gb for every access to
the GetByteContext) and also highlights the GetByteContext's short-lived
nature better.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-31 02:59:36 +02:00
Paul B Mahol
72942ad6d4 avcodec/cdxl: also mark decoded frame as keyframe 2020-08-31 00:15:22 +02:00
Paul B Mahol
ef46de695f avcodec/qpeg: reduce unnecessary size of tables 2020-08-30 23:52:21 +02:00
Gautam Ramakrishnan
341064d68a libavcodec/jpeg2000: fix tag tree reset
The implementation of the tag tree did not
set the correct reset value for the encoder.
This lead to inefficent tag tree being encoded.
This patch fixes the implementation of the
ff_tag_tree_zero() function.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Gautam Ramakrishnan
f0e33119e4 libavcodec/j2kenc: Support for multiple layers
This patch allows setting a compression ratio and to
set multiple layers. The user has to input a compression
ratio for each layer.
The per layer compression ration can be set as follows:
-layer_rates "r1,r2,...rn"
for to create 'n' layers.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Gautam Ramakrishnan
3c06045a8b libavcodec/j2kenc: Fix tag tree coding
The implementation of tag tree encoding was incorrect.
However, this error was not visible as the current j2k
encoder encodes only 1 layer.
This patch fixes tag tree coding for JPEG2000 such tag
tree coding would work for multi layer encoding.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00