 adif2mp4
----------

    This tool converts between any of raw, adts, adif and mp4ff file formats.
  Input format is auto-detected (if possible), output can be specified with
  '-o'. If you handle raw files as input, also don't forget to give a correct
  sampling-rate and profile ('-s xxx -p xxx').
    Be aware these conversions can be somewhat tricky, and it might be
  necessary to run the program several times on the same file, until all
  output-data is correct. Also be aware of possible bitrate changes, especially
  when handling ADTS-files.

- General proceeding to correctly convert between the file formats:
	1) run adif2mp4 to calculate the bitrate of input and output files.
	2) run adif2mp4 with the proposed bitrate as output bitrate
	   (using -b xxx) to get valid values for initial bitbuffer fullness.
	3) run adif2mp4 a third time giving both a valid bitrate and
	   buffer_fullness (with '-b xxx -f xxx').

    Some steps may be skipped with some files, other bitstreams won't be valid
  even after repeating all of these steps several times...

- More hints on conversion:
    The 'proposed bitrate' is the bitrate you should choose, if you want the
  first and last buffer-fullness value to be the same as they were in the
  input (or as they were calculated from the input). This works very good for
  most files. You can affect this value by giving a input bitrate with '-bi'.
    The bitrate should in general change if and only if you convert between
  ADTS and something different.

- Input-elements, output-elements: (more advanced hints)
    If your input-file has extra elements (multi-program) only the 'decoded'
  elements for your program are copied to output (choose program with '-i').
  Unused elements are stripped and thus cause a change in bitrate.
    FILL-elements are in general copied as well, but giving '-Fd' they are
  also discarded. You could loose DRC-information this way.
    New FILL-elements can be added with '-Fa' (to combine: '-Fad'). You only
  should have to do this with incorrect bitstreams, or to compensate lost
  bits from stripped elements. Some examples on this:


          buffer-borders     block
        6144(empty)    0(full)                  6144(empty)    0(full)
           |           |                           |           |
   #       |           |     0                     +           |
        #  |           |     1                     |    +      |
       #   |           |     2                     |   +       |
           |    +      |     3                     |           |#
           | +         |     4        ==>          |         + |
           |    +      |     5                     |           |#
           |   +       |     6                     |           +
           |+          |     7                     |        +  |
           |           |                           |           |
1) invalid inputstream without FILL-elements

           |           |                           |           |
   #       |           |     0                  ---+           |
        #  |           |     1                     |    +      |
       #   |           |     2                     |   +       |
           |    +      |     3                     |           |#
           | +         |     4        ==>          |         + |
           |    +      |     5                     |           |#
           |   +       |     6                     |           +
           |+          |     7                     |        +  |
           |           |                           |           |
2) invalid inputstream without FILL-elements
   adding new with 'adif2mp4 -Fa [...]'

           |           |                           |           |
   #       |           |     0                     +           |
       -#  |           |     1                     |    +      |
      -#   |           |     2                     |  +        |
           |  --+      |     3                     |         + |
           |-+         |     4        -->          |     +     |
           |----+      |     5                     |    +      |
           | --+       |     6                     | +         |
        ---|+          |     7                -----+           |
           |           |                           |           |
3) invalid inputstream having FILL-elements
   processing with 'adif2mp4 -Fad [...]'

'#': invalid buffer_fullness value
'+': valid buffer_fullness value
'-': FILL-element(s)

  => Best results are usually achived by deleting all FILL-elements and adding
  new only if necessary ('adif2mp4 -Fad [...]'). This only fails if there are
  several consecutive blocks filling the whole buffer, without any deletable
  elements inside.

  Still the best solution is controlling the buffer requirements in the
  encoder...


-----------

 2001-07-30	OK	Olaf Kaehler <kaehleof@iis.fhg.de>
