• Andreas Rheinhardt's avatar
    truehd_core: Miscellaneous improvements · 2275e705
    Andreas Rheinhardt authored
    1. The loop counter of the substream_directory loop is always less than
    the number of substreams, yet within the loop it is checked whether it
    is less than FFMIN(3, s->hdr.num_substreams), although the check for < 3
    would suffice.
    2. In case the packet is a major sync packet, the last two bytes of the
    major sync structure were initialized to 0xff and then immediately
    overwritten afterwards without ever making use of the values just set.
    3. When updating the parity_nibble during writing the new
    substream_directory, the parity_nibble is updated one byte at a time
    with bytes that might be read from the output packet's data. But one can
    do both bytes at the same time without resorting to the data just
    written by XOR'ing with the variable that contains the value that has
    just been written as a big endian number. This changes the intermediate
    value of parity_nibble, but in the end it just amounts to a reordering
    of the sum modulo two that will eventually be written as parity_nibble.
    Due to associativity and commutativity, this value is unchanged.
    4. init_get_bits8 already checks that no overflow happens during the
    conversion of its argument from bytes to bits. ff_mlp_read_major_sync
    makes sure not to overread (the maximum size of a major_sync_info is 60
    bytes anyway) and last_offset is < 2^13, so that no overflow in the
    calculation of size can happen, i.e. the check for whether size is >= 0
    is unnecessary. But then size is completely unnecessary and can be
    removed.
    5. In case the packet is just passed through, it is unnecessary to read
    the packet's dts. This is therefore postponed to when we know that the
    packet is not passed through.
    6. Given that it seems overkill to use a bitreader just for one
    variable, the size of the input access unit is now read directly.
    7. A substream's offset (of the end of the substream) is now stored as is
    (i.e. in units of words).
    
    These changes amount to a slight performance improvement: It improved
    from 5897 decicycles of ten runs with about 262144 runs each (including
    an insignificant amount -- about 20-25 usually of skips) to 5747
    decicycles under the same conditions.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    2275e705
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
ffbuild Loading commit data...
fftools Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
configure Loading commit data...