1. 10 Jul, 2019 4 commits
  2. 09 Jul, 2019 6 commits
    • Andreas Rheinhardt's avatar
      truehd_core: Switch to in-place modifications · 5a481b15
      Andreas Rheinhardt authored
      The truehd_core bitstream filter decreases the sizes of the
      major_sync_info structure (if present), of the
      substream_directory and of the substreams themselves. As a consequence,
      there is enough space available in front of the actual substream data
      for the new header, so that one only needs to modify the header in front
      of the actual data (which apart from shrinking is left untouched) and
      the packet's size and buffer pointer (after having made sure that the
      packet is writable).
      
      This and switching to bsf_get_packet_ref also removed the need for
      having separate packets for in- and output.
      
      Even if the input is not writable, there are noticable performance
      improvements: The average of 10 iterations of processing a file with 262144
      runs each (inlcuding about 20 skips per iteration) went down from 5669
      to 4362 decicycles. If the input is writable, it goes down to 1363
      decicycles.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      5a481b15
    • Andreas Rheinhardt's avatar
      truehd_core: Use byte offsets instead of bit offsets · 836065b2
      Andreas Rheinhardt authored
      Words of 16 bit are the unit for TrueHD's size and offset fields;
      in particular the sizes of the high-level structures of TrueHD are
      always a multiple of a byte; yet truehd_core unnecessarily used
      bit offsets at several places. This has been changed.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      836065b2
    • 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
    • Andreas Rheinhardt's avatar
      truehd_core: Return error in case of error · 610460a3
      Andreas Rheinhardt authored
      Several checks (e.g. when the size of the input packet is too small)
      simply used "goto fail", but didn't set the return value appropriately
      for an error.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      610460a3
    • Andreas Rheinhardt's avatar
      truehd_core: Correct output size · cbe23e40
      Andreas Rheinhardt authored
      If truehd_core strips Atmos data away, three parts of the output differ
      in size compared to the input access unit: a) The major_sync_info block
      if the extra_channel_meaning_data is present, as the newly written
      output never contains said block; b) the substream_directory (because
      entries relating to discarded substreams are discarded, too); and c)
      the actual substream data. b) and c) have already been taken into account
      when choosing the size of the output packet, but a) has been forgotten.
      
      This is also the reason behind the end of the output buffer having been
      uninitialized until 801d78f0. The workaround added in said commit has
      been removed, too.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      cbe23e40
    • Andreas Rheinhardt's avatar
      truehd_core: Disable 16-channel presentation · 99c19115
      Andreas Rheinhardt authored
      The most serious bit of the substream_info header field (in a mayor sync
      packet) indicates whether a 16-channel presentation is present in the
      bitstream. If set, the extended_substream_info header field contains
      information about the 16-channel presentation. This presentation always
      uses substream 3, a substream that is discarded by truehd_core. So
      substream_info needs to be changed to no longer indicate the presence
      of a 16-channel presentation in order for truehd_core's output to be
      consistent. This is implemented in this commit.
      
      This change also makes MediaInfo no longer display the presence of Atmos
      in the output of truehd_core.
      
      Also, set the (now irrelevant) extended_substream_info field to zero as
      this seems to be the common value for ordinary TrueHD.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      99c19115
  3. 08 Jul, 2019 30 commits