]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavcodec/atrac9tab: Unify tables used to initialize VLCs
Andreas Rheinhardt [Wed, 4 Nov 2020 19:41:35 +0000 (20:41 +0100)]
avcodec/atrac9tab: Unify tables used to initialize VLCs

Using separate tables has the downside that one needs a big number of
pointers to the separate tables (currently 77); unifying them avoids
this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac9dec: Make tables used to initialize VLCs smaller
Andreas Rheinhardt [Wed, 4 Nov 2020 07:25:47 +0000 (08:25 +0100)]
avcodec/atrac9dec: Make tables used to initialize VLCs smaller

The ATRAC9 decoder uses VLCs which are currently initialized with
static length tables of type uint8_t and code tables of type uint16_t.
Furthermore, in one case the actually desired symbols are in the range
-16..15 and in order to achieve this an ad-hoc symbols table of type
int16_t is calculated.

This commit modifies this process by replacing the codes tables by
symbols tables and switching to ff_init_vlc_from_lengths(); the signed
symbols are stored in the table after having been shifted by 16 to fit
into an uint8_t and are shifted back when the VLC is created. This makes
all symbols fit into an uint8_t, saving space. Furthermore, the earlier
tables had holes in them (entries with length zero that were inserted
because the actually used symbols were not contiguous); these holes are
unnecessary in the new approach, leading to further saving.

Finally, given that now both lengths as well as symbols are of the same
type, they can be combined; this saves a pointer for each VLC.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv34: Make initializing static VLC tables thread-safe
Andreas Rheinhardt [Tue, 17 Nov 2020 10:13:56 +0000 (11:13 +0100)]
avcodec/rv34: Make initializing static VLC tables thread-safe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv34: Avoid offsets table for initialization of static VLCs
Andreas Rheinhardt [Wed, 4 Nov 2020 02:27:18 +0000 (03:27 +0100)]
avcodec/rv34: Avoid offsets table for initialization of static VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vc1: Make ff_vc1_init_common() thread-safe
Andreas Rheinhardt [Mon, 16 Nov 2020 14:09:01 +0000 (15:09 +0100)]
avcodec/vc1: Make ff_vc1_init_common() thread-safe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3plus: Run-length encode length tables to make them smaller
Andreas Rheinhardt [Sun, 1 Nov 2020 22:19:18 +0000 (23:19 +0100)]
avcodec/atrac3plus: Run-length encode length tables to make them smaller

This is very beneficial for the scale factor tables where 4*64+4*15
bytes of length information can be replaced by eight codebooks of 12
bytes each; furthermore the number of codes as well as the maximum
length of a code can be easily derived from said codebooks, making
tables containing said information superfluous. This and combining the
symbols into one big array also made an array of pointers to the tables
redundant.

For the wordlen and code table tables the benefits are not that big
(given these tables don't contain that many elements), but all in all
using codebooks is also advantageouos for them. Therefore it has been
done.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3plus: Combine codebooks into one array
Andreas Rheinhardt [Sun, 1 Nov 2020 19:44:12 +0000 (20:44 +0100)]
avcodec/atrac3plus: Combine codebooks into one array

ATRAC3+ uses VLCs whose code lengths are ascending from left to right in
the tree; ergo it is possible (and done) to run-length encode the
lengths into so-called codebooks. These codebooks were variable-sized:
The first byte contained the minimum length of a code, the second the
maximum length; this was followed by max - min + 1 bytes containing the
actual numbers. The minimal min was 1, the maximal max 12.

While one saves a few bytes by only containing the range that is
actually used, this is more than offset by the fact that there needs
to be a pointer to each of these codebooks.

Furthermore, since 5f8de7b74147e2a347481d7bc900ebecba6f340f the content
of the Atrac3pSpecCodeTab structure (containing data for spectrum
decoding) can be cleanly separated into fields that are only used during
initialization and fields used during actual decoding: The pointers to
the codebooks and the field indicating whether an earlier codebook should
be reused constitute the former category. Therefore the new codebooks are
not placed into the Atrac3pSpecCodeTab (which is now unused during
init), but in an array of its own. The information whether an earlier
codebook should be reused is encoded in the first number of each
spectrum codebook: If it is negative, an earlier codebook (given by the
number) should be reused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3plus: Combine symbols tables
Andreas Rheinhardt [Sun, 1 Nov 2020 17:52:17 +0000 (18:52 +0100)]
avcodec/atrac3plus: Combine symbols tables

This allows to remove lots of pointers (130) to small symbol tables;
it has the downside that some of the default tables must now be coded
explicitly, but this costs only 6 + 4 + 8 + 16 + 8 bytes and is therefore
dwarfed by the gains.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3plus: Simplify getting offset of VLC in VLC_TYPE buf
Andreas Rheinhardt [Sun, 1 Nov 2020 16:59:12 +0000 (17:59 +0100)]
avcodec/atrac3plus: Simplify getting offset of VLC in VLC_TYPE buf

The earlier code used several different offset parameters that were
initialized to magic values. This is unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3plus: Make tables used to initialize VLCs smaller
Andreas Rheinhardt [Sun, 1 Nov 2020 16:01:53 +0000 (17:01 +0100)]
avcodec/atrac3plus: Make tables used to initialize VLCs smaller

The ATRAC3+ decoder currently uses ff_init_vlc_sparse() to initialize
several VLCs; sometimes a symbols table is used, sometimes not; some of
the codes tables are uint16_t, some are uint8_t. Because of these two
latter facts it makes sense to switch to ff_init_vlc_from_lengths()
because it allows to remove the codes at the cost of adding symbols
tables of type uint8_t in the cases where there were none before.

Notice that sometimes the same codes and lengths tables were reused with
two different symbols tables; this could have been preserved (meaning
one could use a lengths table twice), but hasn't, because this allows
to use only one pointer to both the symbols and lengths instead of two
pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3plus: Simplify creating VLCs
Andreas Rheinhardt [Sun, 1 Nov 2020 15:21:32 +0000 (16:21 +0100)]
avcodec/atrac3plus: Simplify creating VLCs

Use ff_init_vlc_from_lengths() to offload the computation of the codes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/truemotion2: Simplify creating VLC table
Andreas Rheinhardt [Sun, 1 Nov 2020 13:23:33 +0000 (14:23 +0100)]
avcodec/truemotion2: Simplify creating VLC table

ff_init_vlc_from_lengths() can be used to offload the computation
of the codes; it also allows to omit the check whether the codes
are already properly ordered (they are). In this case, this also allows
to avoid the allocation of the buffer for the codes.

This improves performance: The amount of decicycles for one call to
tm2_build_huff_tables() when decoding tm20.avi from the FATE-suite
decreased from 46239 to 40035. This test consisted of looping 50 times
over the file and iterating the test ten times.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpeg4videodec: Make studio VLCs static
Andreas Rheinhardt [Wed, 4 Nov 2020 00:37:39 +0000 (01:37 +0100)]
avcodec/mpeg4videodec: Make studio VLCs static

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpeg4video: Make tables used to initialize VLCs smaller
Andreas Rheinhardt [Sun, 1 Nov 2020 04:36:35 +0000 (05:36 +0100)]
avcodec/mpeg4video: Make tables used to initialize VLCs smaller

Switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths()
allows to replace codes which are so long that they need to be stored
in an uint16_t by symbols which fit into an uint8_t; and even these can
be avoided in case of the sprite trajectory VLC.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/indeo2: Make decoder init-threadsafe
Andreas Rheinhardt [Sun, 15 Nov 2020 21:48:35 +0000 (22:48 +0100)]
avcodec/indeo2: Make decoder init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/indeo2: Make tables used to initialize VLCs smaller
Andreas Rheinhardt [Sun, 1 Nov 2020 03:16:25 +0000 (04:16 +0100)]
avcodec/indeo2: Make tables used to initialize VLCs smaller

Switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths()
allows to replace codes which are so long that they need to be stored
in an uint16_t by symbols which fit into an uint8_t; furthermore, it is
also easily possible to already incorporate the offset (the real range
of Indeo 2 symbols starts at one, not zero) into the symbols.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mjpegdec: Simplify creating VLC table
Andreas Rheinhardt [Sun, 1 Nov 2020 02:01:05 +0000 (03:01 +0100)]
avcodec/mjpegdec: Simplify creating VLC table

ff_init_vlc_from_lengths() can be used to offload the computation
of the codes; it also allows to omit the check whether the codes
are already properly ordered (they are).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/sheervideo: Simplify creating VLC table
Andreas Rheinhardt [Sun, 1 Nov 2020 00:21:06 +0000 (01:21 +0100)]
avcodec/sheervideo: Simplify creating VLC table

ff_init_vlc_from_lengths() can be used to offload the computation
of the codes; it also needn't check whether the codes are already
properly ordered (they are).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mss4: Make VLCs static
Andreas Rheinhardt [Tue, 3 Nov 2020 23:04:08 +0000 (00:04 +0100)]
avcodec/mss4: Make VLCs static

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mss4: Don't duplicate standard JPEG tables
Andreas Rheinhardt [Sun, 1 Nov 2020 00:08:15 +0000 (01:08 +0100)]
avcodec/mss4: Don't duplicate standard JPEG tables

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mss4: Simplify creating VLC tables
Andreas Rheinhardt [Sat, 31 Oct 2020 23:26:32 +0000 (00:26 +0100)]
avcodec/mss4: Simplify creating VLC tables

The lengths of the codes used by the mss4 decoder are ascending from
left to right and therefore the lengths can be run-length encoded and
the codes can be easily derived from them. And this is how it is indeed
done. Yet some things can nevertheless be improved:

a) The number of entries of the current VLC is implicitly contained in
the run-length table and needn't be externally prescribed.
b) The maximum length of a code is just the length of the last code
(given that the lengths are ascending), so there is no point in setting
max_bits in the loop itself.
c) One can offload the actual calculation of the codes to
ff_init_vlc_from_lengths().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv40: Avoid code duplication when initializing VLCs
Andreas Rheinhardt [Thu, 5 Nov 2020 00:59:08 +0000 (01:59 +0100)]
avcodec/rv40: Avoid code duplication when initializing VLCs

Besides removing code duplication the method for determining the offset
of each VLC table in the VLC_TYPE buffer also has the advantage of not
wasting space for skipped AIC mode 1 VLCs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv40: Avoid offset table when initializing static VLCs
Andreas Rheinhardt [Wed, 4 Nov 2020 23:42:56 +0000 (00:42 +0100)]
avcodec/rv40: Avoid offset table when initializing static VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv40: Make better use of VLC symbols table
Andreas Rheinhardt [Sat, 31 Oct 2020 21:44:12 +0000 (22:44 +0100)]
avcodec/rv40: Make better use of VLC symbols table

RealVideo 4.0 has a VLC that encodes two intra types per code; each
intra type is in the range 0..8 (inclusive) and up until now the VLC
used symbols in the range 0..80; one type was encoded as the remainder
when dividing the symbol by 9 whereas the other type was encoded as
symbol / 9. This is suboptimal; a better way would be to use the high
and low nibble to encode each symbol. But an even better way is to use
16bit symbols so that the two intra types can be directly written as
a 16bit value.

This commit implements this; in order to avoid huge tables the symbols
are stored as uint8_t with high and low nibbles encoding one type each;
they are only unpacked to uint16_t during initialization.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv40: Make the tables used to initialize VLCs smaller
Andreas Rheinhardt [Sat, 31 Oct 2020 20:35:13 +0000 (21:35 +0100)]
avcodec/rv40: Make the tables used to initialize VLCs smaller

After permuting the codes, symbols and lengths tables used to initialize
the VLC so that the codes are ordered from left to right in the Huffman
tree, the codes become redundant as they can be easily computed from the
lengths at runtime; in this case one has to use explicit symbol tables,
but all the symbols used here fit into an uint8_t, whereas some codes
needed uint16_t. This saves about 1.6KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdm2: Make decoder init-threadsafe
Andreas Rheinhardt [Sun, 15 Nov 2020 21:09:31 +0000 (22:09 +0100)]
avcodec/qdm2: Make decoder init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdm2: Avoid offsets table when initializing VLCs
Andreas Rheinhardt [Tue, 3 Nov 2020 22:16:47 +0000 (23:16 +0100)]
avcodec/qdm2: Avoid offsets table when initializing VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdm2: Initialize array of VLCs in a loop
Andreas Rheinhardt [Sat, 31 Oct 2020 18:26:39 +0000 (19:26 +0100)]
avcodec/qdm2: Initialize array of VLCs in a loop

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdm2: Apply offsets when initializing VLCs
Andreas Rheinhardt [Sat, 31 Oct 2020 17:23:47 +0000 (18:23 +0100)]
avcodec/qdm2: Apply offsets when initializing VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdm2: Make tables used to initialize VLCs smaller
Andreas Rheinhardt [Sat, 31 Oct 2020 16:33:28 +0000 (17:33 +0100)]
avcodec/qdm2: Make tables used to initialize VLCs smaller

After permuting the codes, symbols and lengths tables used to initialize
the VLCs so that the codes are ordered from left to right in the Huffman
tree, the codes become redundant as they can be easily computed from the
lengths at runtime (or at compile time with --enable-hardcoded-tables);
in this case one has to use explicit symbol tables, but all the symbols
used here fit into an uint8_t, whereas some codes needed uint16_t.
Furthermore, the codes had holes because the range of the symbols was not
contiguous; these have also been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mobiclip: Reindentation
Andreas Rheinhardt [Sat, 31 Oct 2020 11:37:01 +0000 (12:37 +0100)]
avcodec/mobiclip: Reindentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mobiclip: Make decoder init-threadsafe
Andreas Rheinhardt [Sun, 15 Nov 2020 20:39:19 +0000 (21:39 +0100)]
avcodec/mobiclip: Make decoder init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mobiclip: Avoid code duplication when initializing VLCs
Andreas Rheinhardt [Sat, 31 Oct 2020 11:34:13 +0000 (12:34 +0100)]
avcodec/mobiclip: Avoid code duplication when initializing VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mobiclip: Avoid redundant codes table to initialize VLCs
Andreas Rheinhardt [Sat, 31 Oct 2020 00:23:34 +0000 (01:23 +0100)]
avcodec/mobiclip: Avoid redundant codes table to initialize VLCs

If both codes, lengths and symbols tables are ordered so that the codes
are sorted from left to right in the tree, the codes can be easily
derived from the lengths and therefore become redundant. This is
exploited in this commit to remove the codes tables for the mobiclip
decoder; notice that tables for the run-length VLC were already ordered
correctly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc8: Make decoder init-threadsafe
Andreas Rheinhardt [Sun, 15 Nov 2020 20:31:31 +0000 (21:31 +0100)]
avcodec/mpc8: Make decoder init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc7: Make decoder init-threadsafe
Andreas Rheinhardt [Sun, 15 Nov 2020 20:21:48 +0000 (21:21 +0100)]
avcodec/mpc7: Make decoder init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/imc: Make imc/iac decoders init-threadsafe
Andreas Rheinhardt [Sun, 15 Nov 2020 10:42:24 +0000 (11:42 +0100)]
avcodec/imc: Make imc/iac decoders init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc8: Avoid code duplication when initializing VLCs
Andreas Rheinhardt [Fri, 30 Oct 2020 10:43:06 +0000 (11:43 +0100)]
avcodec/mpc8: Avoid code duplication when initializing VLCs

Up until now, VLCs that were part of an array of VLCs were often not
initialized in a loop, but separately. The probable reason for this
was that these VLCs differed slightly in the parameters to be used for
them (i.e. the number of codes or the number of bits to be used
differs), so that one would have to provide these parameters e.g. via
arrays.

Yet these problems have actually largely been solved by now: The length
information is contained in a run-length encoded form that is the same
for all VLCs and both the number of codes as well as the number of bits
to use for each VLC can be easily derived from them.

There is just one problem to be solved: When the underlying tables have
a different number of elements, putting them into an array of arrays
would be wasteful; using an array of pointers to the arrays would
also be wasteful. Therefore this commit combines the tables into bigger
tables. (Given that all the length tables have the same layout this
applies only to the symbols tables.)

Finally, the array containing the offset of the VLC's buffer in the big
buffer has also been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc8: Reduce the size of some VLCs
Andreas Rheinhardt [Fri, 30 Oct 2020 01:27:15 +0000 (02:27 +0100)]
avcodec/mpc8: Reduce the size of some VLCs

Several of the quantisation VLCs come in pairs and up until now the
number of bits used for each VLC was set to the same value for both VLCs
in such a pair even when one of the two required only a lower number.
This is a waste given that the get_vlc2() call is compatible with these
two VLCs using a different number of bits (it uses vlc->bits).

Given that the code lengths are descending it is easily possible to know
the length of the longest code for a given VLC: It is the length of the
first one. With this information one can easily use the least amount of
bits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc8: Reduce the size of the length tables to initialize VLCs
Andreas Rheinhardt [Fri, 30 Oct 2020 01:10:36 +0000 (02:10 +0100)]
avcodec/mpc8: Reduce the size of the length tables to initialize VLCs

After permuting both length, code as well as symbol tables so that
the codes are ordered from left to right in the tree, it became apparent
that the length of the codes decreases from left to right. Therefore one
can run-length encode the lengths to save space. This commit implements
this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc8: Apply offsets when initializing VLCs
Andreas Rheinhardt [Thu, 29 Oct 2020 22:54:07 +0000 (23:54 +0100)]
avcodec/mpc8: Apply offsets when initializing VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc8: Reduce size of tables used to initialize VLCs
Andreas Rheinhardt [Thu, 29 Oct 2020 22:34:18 +0000 (23:34 +0100)]
avcodec/mpc8: Reduce size of tables used to initialize VLCs

By switching to ff_init_vlc_from_lengths() one can make a table of
codes of type uint8_t superfluous, saving space.

Other VLCs (those without dedicated symbols table and with codes of
type uint8_t) have been made to use ff_init_vlc_from_lengths(), too,
because it reduces codesize (ff_init_vlc_from_lengths() has two
parameters less than ff_init_vlc_sparse()) and because it allows to
use the offset parameter in future commits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc7: Avoid offsets table when creating VLCs
Andreas Rheinhardt [Tue, 3 Nov 2020 21:41:51 +0000 (22:41 +0100)]
avcodec/mpc7: Avoid offsets table when creating VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc7: Apply offsets when creating VLCs
Andreas Rheinhardt [Thu, 29 Oct 2020 19:21:59 +0000 (20:21 +0100)]
avcodec/mpc7: Apply offsets when creating VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpc7: Reduce size of tables used to initialize VLCs
Andreas Rheinhardt [Thu, 29 Oct 2020 19:13:56 +0000 (20:13 +0100)]
avcodec/mpc7: Reduce size of tables used to initialize VLCs

By switching to ff_init_vlc_from_lengths() one can replace tables of
codes of type uint16_t with tables of symbols of type uint8_t, saving
space.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/motionpixels: Simplify creating VLC tables
Andreas Rheinhardt [Thu, 29 Oct 2020 10:12:32 +0000 (11:12 +0100)]
avcodec/motionpixels: Simplify creating VLC tables

By using ff_init_vlc_from_lengths(), we do not have to keep track of the
codes themselves, but can offload this to ff_init_vlc_from_lengths().

Furthermore, the old code presumed sizeof(int) == 4; this is no longer
so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mimic: Make VLC static
Andreas Rheinhardt [Wed, 28 Oct 2020 13:35:19 +0000 (14:35 +0100)]
avcodec/mimic: Make VLC static

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mimic: Reduce size of tables used to initialize VLCs
Andreas Rheinhardt [Wed, 28 Oct 2020 13:17:40 +0000 (14:17 +0100)]
avcodec/mimic: Reduce size of tables used to initialize VLCs

By switching to ff_init_vlc_from_lengths() one can replace a table of
codes of type uint32_t with a table of symbols of type uint8_t saving
space. The old tables also had holes in it (because of the symbols) which
are now superfluous, saving ever more space.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv10: Simplify handling of skip VLC entries
Andreas Rheinhardt [Wed, 28 Oct 2020 12:15:15 +0000 (13:15 +0100)]
avcodec/rv10: Simplify handling of skip VLC entries

The VLC tables to be used for parsing RealVideo 1.0 DC coefficients are
weird: The luma table contains a block of 2^11 codes beginning with the
same prefix and length that all have the same symbol (i.e. value only
depends upon the prefix); the same goes for the chroma block (except
it's only 2^9 codes). Up until now, these entries (which generally could
be parsed like ordinary entries with subtables) have been treated
specially: They have been treated like open ends of the tree, so that
get_vlc2() returned a value < 0 upon encountering them; afterwards it
was checked whether the right prefix was used and if so, the appropriate
number of bytes was skipped.

But there is actually an easy albeit slightly hacky way to support them
directly without pointless subtables: Just modify the VLC table so that
all the entries sharing the right prefix have a length that equals the
length of the whole entry.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv10: Make VLC tables smaller
Andreas Rheinhardt [Wed, 28 Oct 2020 09:48:09 +0000 (10:48 +0100)]
avcodec/rv10: Make VLC tables smaller

These tables were huge (14 bits) because one needed 14 bits in order to
find out whether a code is valid and in the VLC table or a valid code that
required hacky workarounds due to RealVideo 1.0 using multiple codes
for the same symbol and the code predating the introduction of symbols
tables for VLCs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv10: Use symbol table more effectively
Andreas Rheinhardt [Wed, 28 Oct 2020 08:12:08 +0000 (09:12 +0100)]
avcodec/rv10: Use symbol table more effectively

The RealVideo 1.0 decoder uses VLCs to parse DC coefficients. But the
values returned from get_vlc2() are not directly used; instead
-(val - 128) (which is in the range -127..128) is. This transformation
is unnecessary as it can effectively be done when initializing the VLC
by modifying the symbols table used. There is just one minor
complication: The chroma table is incomplete and in order to distinguish
an error from get_vlc2() (due to an invalid code) the ordinary return
range is modified to 0..255. This is possible because the only caller of
this function is (on success) only interested in the return value modulo
256.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv10: Reduce number of exceptions when reading VLC value
Andreas Rheinhardt [Tue, 27 Oct 2020 22:26:17 +0000 (23:26 +0100)]
avcodec/rv10: Reduce number of exceptions when reading VLC value

RealVideo 1.0 uses an insane way to encode DC coefficients: There are
several symbols that (for no good reason whatsoever) have multiple
encodings, leading to longer codes than necessary.

More specifically, the tree for the 256 luma symbols contains 255 codes
belonging to 255 different symbols on the left; going further right,
the tree consists of two blocks of 128 codes each of length 14 encoding
consecutive numbers (including two encodings for the symbol missing among
the 255 codes on the left); this is followed by two blocks of codes of
length 16 each containing 256 elements with consecutive symbols (i.e.
each of the blocks allows to encode all symbols). The rest of the tree
consists of 2^11 codes that all encode the same symbol.

The tree for the 256 chroma symbols is similar, but is missing the
blocks of length 256 and there are only 2^9 consecutive codes that
encode the same symbol; furthermore, the chroma tree is incomplete:
The right-most node has no right child.

All of this caused problems when parsing these codes; the reason is that
the code for this predates commit b613bacca9c256f1483c46847f713e47a0e9a5f6
which added support for explicit symbol tables and thereby removed the
requirement that different codes have different symbols. In order to
address this, the trees used for parsing were incomplete: They contained
the 255 codes on the left and one code for the remaining symbol. Whenever
a code not in these trees was encountered, it was dealt with in
special cases (one for each of the blocks mentioned above).

This commit reduces the number of special cases: Using a symbols table
allows to treat the blocks of consecutive symbols like ordinary codes;
only the blocks encoding a single symbol are still treated specially
(in order not to waste memory on tables for them).

In order to not increment the size of the tables used to initialize the
VLCs both the symbols as well as the lengths are now run-length encoded.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv10: Reduce the size of the tables used to initialize VLCs
Andreas Rheinhardt [Tue, 27 Oct 2020 19:36:32 +0000 (20:36 +0100)]
avcodec/rv10: Reduce the size of the tables used to initialize VLCs

This can be achieved by switching to ff_init_vlc_from_lengths() which
allows to replace two uint16_t tables for codes with uint8_t tables for
the symbols by permuting the tables so that the codes are ordered from
left to right in the tree in which case they can be easily computed from
the lengths at runtime.

And after doing so, it became apparent that the tables for the symbols
are actually the same for luma and chroma, so that one can even omit one
of them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cook: Inline constants
Andreas Rheinhardt [Tue, 27 Oct 2020 14:32:27 +0000 (15:32 +0100)]
avcodec/cook: Inline constants

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cook: Avoid big length tables for VLC initialization
Andreas Rheinhardt [Tue, 27 Oct 2020 14:21:27 +0000 (15:21 +0100)]
avcodec/cook: Avoid big length tables for VLC initialization

Permuting the tables used to initialize the Cook VLCs so that the code
tables are ordered from left to right in the tree revealed that the
length of the codes are ascending from left to right. Therefore one can
run-length encode them to avoid the big length tables; this saves a bit
more than 1KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cook: Apply offset when initializing VLC table
Andreas Rheinhardt [Tue, 27 Oct 2020 13:27:36 +0000 (14:27 +0100)]
avcodec/cook: Apply offset when initializing VLC table

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cook: Make tables to initialize VLCs smaller
Andreas Rheinhardt [Tue, 27 Oct 2020 13:15:58 +0000 (14:15 +0100)]
avcodec/cook: Make tables to initialize VLCs smaller

Up until now, the Cook decoder used tables for the lengths of codes and
tables of the codes itself to initialize VLCs; the tables for the codes
were of type uint16_t because the codes were so long. It did not use
explicit symbol tables. This commit instead reorders the tables so that
the code tables are sorted from left to right in the tree. Then the
codes can be easily derived from the lengths and therefore be omitted.
This comes at the price of explicitly coding the symbols, but this is
nevertheless a net win because most of the symbols tables can be coded
on one byte. Furthermore, Cook actually does not use a contiguous range
of symbols for its main VLC tables and the old code compensated for that
by adding holes (codes of length zero) to the tables (that are skipped by
ff_init_vlc_sparse()). This is no longer necessary with the new
approach. All in all, this saves about 1.7KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wnv1: Make decoder init-threadsafe
Andreas Rheinhardt [Sun, 15 Nov 2020 11:19:55 +0000 (12:19 +0100)]
avcodec/wnv1: Make decoder init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wnv1: Apply offset during init, not later every time
Andreas Rheinhardt [Sun, 25 Oct 2020 23:28:46 +0000 (00:28 +0100)]
avcodec/wnv1: Apply offset during init, not later every time

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wnv1: Make array for initializing VLC smaller
Andreas Rheinhardt [Sun, 25 Oct 2020 22:11:42 +0000 (23:11 +0100)]
avcodec/wnv1: Make array for initializing VLC smaller

This is possible by switching to ff_init_vlc_from_lengths() which allows
to replace the table for the codes (which need an uint16_t) by a table
of symbols which fit into an uint8_t. Also switch to an ordinary
INIT_VLC macro while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Make VLC tables static
Andreas Rheinhardt [Tue, 3 Nov 2020 20:48:28 +0000 (21:48 +0100)]
avcodec/clearvideo: Make VLC tables static

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Apply VLC offset during init
Andreas Rheinhardt [Tue, 3 Nov 2020 20:07:55 +0000 (21:07 +0100)]
avcodec/clearvideo: Apply VLC offset during init

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Use minimal max_depth in get_vlc2()
Andreas Rheinhardt [Sun, 25 Oct 2020 21:42:29 +0000 (22:42 +0100)]
avcodec/clearvideo: Use minimal max_depth in get_vlc2()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Inline constants
Andreas Rheinhardt [Sun, 25 Oct 2020 21:39:29 +0000 (22:39 +0100)]
avcodec/clearvideo: Inline constants

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Improve handling of VLC escape values
Andreas Rheinhardt [Tue, 17 Nov 2020 07:46:53 +0000 (08:46 +0100)]
avcodec/clearvideo: Improve handling of VLC escape values

Both the motion vector as well as the bias VLCs have an escape code;
for the motion vectors, this value depended on the specific VLC table,
whereas all the bias VLCs used the same value; the escape value has not
been inlined in the latter case.

But for both kinds of VLCs there are lots of values that are unused for
all the VLCs of each kind and each of these can be used as common escape
value, thus allowing to inline the escape value. This commit implements
this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Avoid huge VLC length tables
Andreas Rheinhardt [Sun, 25 Oct 2020 21:17:28 +0000 (22:17 +0100)]
avcodec/clearvideo: Avoid huge VLC length tables

After the motion vector and bias values tables have been reordered so
that the codes are ordered from left to right, it emerged that the
length of these entries are actually ascending for every table.
Therefore it is possible to encode them in a run-length style and create
the actual length tables during runtime. This commit implements this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Avoid code duplication when initializing VLCs
Andreas Rheinhardt [Sun, 25 Oct 2020 20:07:20 +0000 (21:07 +0100)]
avcodec/clearvideo: Avoid code duplication when initializing VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Avoid code tables for initializing VLCs
Andreas Rheinhardt [Sun, 25 Oct 2020 16:54:44 +0000 (17:54 +0100)]
avcodec/clearvideo: Avoid code tables for initializing VLCs

The ClearVideo decoder uses VLC tables that are initialized at runtime
from static length, symbol and codes tables. Yet the code tables can be
omitted by subjecting all of these tables to the permutation that orders
the codes from left to right in the tree. After this is done, the codes
can be easily computed at runtime from the lengths and therefore
omitted. This saves about 10KB.

Only one minor complication is encountered when doing so: The tree
corresponding to the AC VLC codes is incomplete; but this can be
handled by adding an entry with negative length.

Furthermore, there are also VLCs that are only initialized with lengths
and codes tables with codes of type uint16_t. These have also been
switched to ff_init_vlc_from_lengths() as this means that one can
replace the uint16_t codes tables with uint8_t symbols tables.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/imc: Avoid offsets table when creating VLCs
Andreas Rheinhardt [Tue, 3 Nov 2020 19:28:54 +0000 (20:28 +0100)]
avcodec/imc: Avoid offsets table when creating VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/imc: Make Huffman tables smaller
Andreas Rheinhardt [Sun, 25 Oct 2020 14:35:00 +0000 (15:35 +0100)]
avcodec/imc: Make Huffman tables smaller

The IMC decoder uses Huffman tables which are created at runtime from
length tables of type uint8_t and code tables of type uint16_t together
with an implicit symbols table (i.e. symbol[i] == i). This commit
changes this: All three tables are subjected to the same permutation to
order the codes from left to right in the tree; afterwards the codes can
be omitted because they are easily computable at runtime from the
lengths, whereas the symbols need to be explicitly coded now. But said
symbols fit into an uint8_t, so one saves space.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/on2avc: Apply offset when initializing VLC
Andreas Rheinhardt [Sun, 25 Oct 2020 13:21:16 +0000 (14:21 +0100)]
avcodec/on2avc: Apply offset when initializing VLC

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/on2avcdata: Combine tables for codebooks
Andreas Rheinhardt [Sun, 25 Oct 2020 13:04:59 +0000 (14:04 +0100)]
avcodec/on2avcdata: Combine tables for codebooks

Using one big table for the codebook symbols and lengths makes it
possible to remove the pointers to the individual tables.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/on2avc: Use smaller tables for VLCs
Andreas Rheinhardt [Sun, 25 Oct 2020 11:48:41 +0000 (12:48 +0100)]
avcodec/on2avc: Use smaller tables for VLCs

The On2 audio decoder uses huge tables to initialize VLC tables. These
tables (mostly) use symbols tables in addition to the codes tables and
the lengths tables. This commit makes the codes tables redundant and
removes them: If all tables are permuted so that the codes are ordered
from left to right in the Huffman tree, the codes become redundant and
can be easily calculated at runtime from the lengths
(via ff_init_vlc_from_lengths()); this also avoids sorting the codes in
ff_init_vlc_sparse()*.

The symbols tables are always 16bit, the codes tables are 32bit, 16bit
or (rarely) 8bit, the lengths tables are always 8bit. Even though some
symbols tables have been used twice (which is no longer possible now
because different permutations need to be performed on the code tables
sharing the same symbol table in order to order them from left to right),
this nevertheless saves about 28KB.

*: If the initializations of the VLCs are repeated 2048 times
(interleaved with calls to free the VLCs which have not been timed), the
number of decicycles spent on each round of initializations improves
from 27669656 to 7356159.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Improve creating Huffman VLC tables
Andreas Rheinhardt [Sun, 25 Oct 2020 09:24:31 +0000 (10:24 +0100)]
avcodec/smacker: Improve creating Huffman VLC tables

The Smacker Huffman tables are already stored in a tree-like structure;
in particular, they are naturally ordered from left to right in the
tree and are therefore suitable to be initialized by
ff_init_vlc_from_lengths() which avoids traversing the data twice in
order to sort only the codes that are so long that they need into a
subtable.

This improves performance (and reduces codesize): For the sample from
ticket #2425 the number of decicycles for parsing and creating the VLCs
in smka_decode_frame() decreased from 412322 to 359152 (tested with
10 runs each looping 20 times over the file).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cllc: Improve creating VLCs
Andreas Rheinhardt [Sat, 24 Oct 2020 22:56:42 +0000 (00:56 +0200)]
avcodec/cllc: Improve creating VLCs

One can offload the computation of the codes to
ff_init_vlc_from_lengths(); this also improves performance: The number
of decicycles for one call to read_code_table() decreased from 198343
to 148338 with the sample sample-cllc-rgb.avi from the FATE suite; it
has been looped 100 times and the test repeated ten times to test it
sufficiently often.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/tscc2: Make VLC tables static
Andreas Rheinhardt [Tue, 3 Nov 2020 19:11:18 +0000 (20:11 +0100)]
avcodec/tscc2: Make VLC tables static

Also use a named constant for the number of bits of the VLC tables.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/bitstream: Allow static VLC tables to be bigger than needed
Andreas Rheinhardt [Tue, 3 Nov 2020 18:20:15 +0000 (19:20 +0100)]
avcodec/bitstream: Allow static VLC tables to be bigger than needed

Right now the allocated size of the VLC table of a static VLC has to
exactly match the size actually used for the VLC: If it is not enough,
abort is called; if it is more than enough, an error message is
emitted. This is no problem when one wants to initialize an individual
VLC via one of the INIT_VLC macros as one just hardcodes the needed
size. Yet it is an obstacle when one wants to initialize several VLCs
in a loop as one then needs to add an array for the sizes/offsets of
the VLC tables (unless max_depth of all arrays is one in which case
the sizes are derivable from the number of bits used).

Yet said size array is not necessary if one disables the warning for too
big buffers. The reason is that the amount of entries needed for the
table is of course generated as a byproduct of initializing the VLC.
To this end a flag that disables the warning has been added.
So one can proceed as follows:

static VLC vlcs[NUM];
static VLC_TYPE vlc_table[BUF_SIZE][2];

for (int i = 0, offset = 0; i < NUM; i++) {
    vlcs[i].table           = &vlc_table[offset];
    vlcs[i].table_allocated = BUF_SIZE - offset;
    init_vlc(); /* With INIT_VLC_STATIC_OVERLONG flag */
    offset += vlcs[i].table_size;
}

Of course, BUF_SIZE should be equal to the number of entries actually
needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/tscc2: Combine tables for initializing VLCs
Andreas Rheinhardt [Thu, 29 Oct 2020 16:59:14 +0000 (17:59 +0100)]
avcodec/tscc2: Combine tables for initializing VLCs

Using one big table for the symbols and lengths makes it
possible to remove the pointers to the individual tables.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/tscc2: Reduce the size of the tables used to initialize VLCs
Andreas Rheinhardt [Thu, 29 Oct 2020 15:13:03 +0000 (16:13 +0100)]
avcodec/tscc2: Reduce the size of the tables used to initialize VLCs

After permuting both the codes, lengths and symbols tables so that
the codes tables are ordered from left to right in the tree, the codes
tables can be easily computed from the lengths tables at runtime and
therefore omitted. This saves about 2KB from the binary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/bitstream: Add second function to create VLCs
Andreas Rheinhardt [Sat, 24 Oct 2020 22:54:21 +0000 (00:54 +0200)]
avcodec/bitstream: Add second function to create VLCs

When using ff_init_vlc_sparse() to create a VLC, three input tables are
used: A table for lengths, one for codes and one for symbols; the latter
one can be omitted, then a default one will be used. These input tables
will be traversed twice, once to get the long codes (which will be put
into subtables) and once for the small codes. The long codes are then
sorted so that entries that should be in the same subtable are
contiguous.

This commit adds an alternative to ff_init_vlc_sparse():
ff_init_vlc_from_lengths(). It is based upon the observation that if
lengths, codes and symbols tables are permuted (in the same way) so that
the codes are ordered from left to right in the corresponding tree and
if said tree is complete (i.e. every non-leaf node has two children),
the codes can be easily computed from the lengths and are therefore
redundant. This means that if one initializes such a VLC with explicitly
coded lengths, codes and symbols, the codes can be avoided; and even if
one has no explicitly coded symbols, it might still be beneficial to
remove the codes even when one has to add a new symbol table, because
codes are typically longer than symbols so that the latter often fit
into a smaller type, saving space.

Furthermore, given that the codes here are by definition ordered from
left to right, it is unnecessary to sort them again; for the same
reason, one does not have to traverse the input twice. This function
proved to be faster than ff_init_vlc_sparse() whenever it has been
benchmarked.

This function is usable for static tables (they can simply be permuted
once) as well as in scenarios where the tables are naturally ordered
from left to right in the tree; the latter e.g. happens with Smacker,
Theora and several other formats.

In order to make it also usable for (static) tables with incomplete trees,
negative lengths are used to indicate that there is an open end of a
certain length.

Finally, ff_init_vlc_from_lengths() has one downside compared to
ff_init_vlc_sparse(): The latter uses tables that can be reused by
encoders. Of course, one could calculate the needed table at runtime
if one so wishes, but it is nevertheless an obstacle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/aeval: add timeline support for aeval
Paul B Mahol [Tue, 8 Dec 2020 14:17:49 +0000 (15:17 +0100)]
avfilter/aeval: add timeline support for aeval

3 years agohlsenc: expand hls_fmp4_init_filename with strftime()
Nikola Pajkovsky [Tue, 27 Oct 2020 11:28:59 +0000 (12:28 +0100)]
hlsenc: expand hls_fmp4_init_filename with strftime()

the init.mp4 can be expanded with strftime the same way as
hls_segment_filename.

Signed-off-by: Nikola Pajkovsky <nikola@pajkovsky.cz>
Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
3 years agoavformat/hls: Fixes overwriting existing #EXT-X-PROGRAM-DATE-TIME value in HLS playlist
Vignesh Ravichandran [Tue, 1 Dec 2020 10:10:40 +0000 (15:40 +0530)]
avformat/hls: Fixes overwriting existing #EXT-X-PROGRAM-DATE-TIME value in HLS playlist

fix ticket: 8989

This is is due to the following behavior in the current code:
1. The initial_prog_date_time gets set to the current local time
2. The existing playlist (.m3u8) file gets parsed and the segments
   present are added to the variant stream
3. The new segment is created and added
4. The existing segments and the new segment are written to the
   playlist file. The initial_prog_date_time from point 1 is used
   for calculating "#EXT-X-PROGRAM-DATE-TIME" for the segments,
   which results in incorrect "#EXT-X-PROGRAM-DATE-TIME" values
   for existing segments
The following approach fixes this bug:
1. Add a new variable "discont_program_date_time" of type double
   to HLSSegment struct
2. Store the "EXT-X-PROGRAM-DATE-TIME" value from the existing
   segments in this variable
3. When writing to playlist file if "discont_program_date_time"
   is set, then use that value for "EXT-X-PROGRAM-DATE-TIME" else
   use the value present in vs->initial_prog_date_time

Signed-off-by: Vignesh Ravichandran <vignesh.ravichandran02@gmail.com>
Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
3 years agoavfilter/f_perms: add timeline support
Paul B Mahol [Mon, 7 Dec 2020 20:05:37 +0000 (21:05 +0100)]
avfilter/f_perms: add timeline support

3 years agoavfilter/af_earwax: fix filter behavior
Paul B Mahol [Fri, 4 Dec 2020 16:54:05 +0000 (17:54 +0100)]
avfilter/af_earwax: fix filter behavior

Previous filter output was incorrect. New one actually follows
graph in comments described on side of filter taps.

3 years agoavcodec/dynamic_hdr10_plus: remove unused const variables
James Almer [Mon, 7 Dec 2020 17:28:50 +0000 (14:28 -0300)]
avcodec/dynamic_hdr10_plus: remove unused const variables

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/dynamic_hdr10_plus: don't take a GetBitContext as input argument
James Almer [Sun, 6 Dec 2020 15:30:14 +0000 (12:30 -0300)]
avcodec/dynamic_hdr10_plus: don't take a GetBitContext as input argument

Create a local one instead from a byte buffer input argument.
This prevents skipping bytes that may belong to another SEI message.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/hevc_sei: keep size in sync with the registered ITU-T T35 SEI GetBitContext
James Almer [Sun, 6 Dec 2020 15:30:13 +0000 (12:30 -0300)]
avcodec/hevc_sei: keep size in sync with the registered ITU-T T35 SEI GetBitContext

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/hevc_sei: split Dynamic HDR10+ SEI parsing into its own function
James Almer [Sun, 6 Dec 2020 14:04:05 +0000 (11:04 -0300)]
avcodec/hevc_sei: split Dynamic HDR10+ SEI parsing into its own function

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agodoc/filters: fix obvious mistake for minimum accepted value
Paul B Mahol [Mon, 7 Dec 2020 12:12:42 +0000 (13:12 +0100)]
doc/filters: fix obvious mistake for minimum accepted value

3 years agoavformat/tee: allow packets with negative timestamps
Jan Ekström [Tue, 14 Jul 2020 08:54:08 +0000 (11:54 +0300)]
avformat/tee: allow packets with negative timestamps

As this is a meta muxer and the same flag is set with the fifo
meta muxer, there is really no reason not to have this set here
as well.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
3 years agoavcodec/nvdec: Add support for decoding monochrome av1
Philip Langdale [Sun, 6 Dec 2020 04:25:29 +0000 (20:25 -0800)]
avcodec/nvdec: Add support for decoding monochrome av1

The nvidia hardware explicitly supports decoding monochrome content,
presumably for the AVIF alpha channel. Supporting this requires an
adjustment in av1dec and explicit monochrome detection in nvdec.

I'm not sure why the monochrome path in av1dec did what it did - it
seems non-functional - YUV440P doesn't seem a logical pix_fmt for
monochrome and conditioning on chroma sub-sampling doesn't make sense.
So I changed it.

I've tested 8bit content, but I haven't found a way to create a 10bit
sample, so that path is untested for now.

3 years agoavcodec/h264idct_template: Fix integer overflow in ff_h264_chroma422_dc_dequant_idct()
Michael Niedermayer [Thu, 5 Nov 2020 21:14:21 +0000 (22:14 +0100)]
avcodec/h264idct_template: Fix integer overflow in ff_h264_chroma422_dc_dequant_idct()

Fixes: signed integer overflow: -2105540608 - 2105540608 cannot be represented in type 'int'
Fixes: 26870/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5656647567147008
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/dsfdec: Check block_align more completely
Michael Niedermayer [Thu, 5 Nov 2020 20:22:13 +0000 (21:22 +0100)]
avformat/dsfdec: Check block_align more completely

Fixes: infinite loop
Fixes: 26865/clusterfuzz-testcase-minimized-ffmpeg_dem_DSF_fuzzer-5649473830912000
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/av1dec: check size before addition in probing
Michael Niedermayer [Thu, 5 Nov 2020 19:04:20 +0000 (20:04 +0100)]
avformat/av1dec: check size before addition in probing

Fixes: signed integer overflow: 175 + 2147483571 cannot be represented in type 'int'
Fixes: 26833/clusterfuzz-testcase-minimized-ffmpeg_dem_IMAGE2_fuzzer-5969501214212096
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/realtextdec: read_ts() in 64bits
Michael Niedermayer [Thu, 5 Nov 2020 15:19:18 +0000 (16:19 +0100)]
avformat/realtextdec: read_ts() in 64bits

Fixes: signed integer overflow: 46671062 * 100 cannot be represented in type 'int'
Fixes: 26826/clusterfuzz-testcase-minimized-ffmpeg_dem_REALTEXT_fuzzer-5644062910316544
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/dv: fix timestamps of audio packets in case of dropped corrupt audio frames
Marton Balint [Sat, 31 Oct 2020 16:51:34 +0000 (17:51 +0100)]
avformat/dv: fix timestamps of audio packets in case of dropped corrupt audio frames

By using the frame counter (and the video time base) for audio pts we lose some
timestamp precision but we ensure that video and audio coming from the same DV
frame are always in sync.

This patch also makes timestamps after seek consistent and it should also fix
the timestamps when the audio clock is unlocked and have a completely
indpendent clock source. (E.g. runs on fixed 48009 Hz which should have been
exact 48000 Hz)

Fixes out of sync timestamps in ticket #8762.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/dynamic_hdr10_plus: use get_bits_long() where needed
James Almer [Sun, 6 Dec 2020 16:36:37 +0000 (13:36 -0300)]
avcodec/dynamic_hdr10_plus: use get_bits_long() where needed

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/hevc_sei: replace en dash character with a hyphen
James Almer [Sun, 6 Dec 2020 15:29:18 +0000 (12:29 -0300)]
avcodec/hevc_sei: replace en dash character with a hyphen

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/vf_showinfo: include the correct Dynamic HDR10+ header
James Almer [Sun, 6 Dec 2020 15:08:58 +0000 (12:08 -0300)]
avfilter/vf_showinfo: include the correct Dynamic HDR10+ header

Signed-off-by: James Almer <jamrial@gmail.com>