• Anssi Hannula's avatar
    avformat/spdifenc: fix handling of large TrueHD frames · 36e156be
    Anssi Hannula authored
    The TrueHD IEC 61937 encapsulation code uses a very naive method of
    always inserting 24 TrueHD frames evenly in a MAT frame. This does not
    work for larger frames as they may exceed the size of 1/24th of a MAT
    frame.
    
    To fix that, use the input_timing field in the TrueHD frame to determine
    the proper position of the TrueHD frame in the MAT frame. That field is
    basically a dts field, telling the time to feed this frame to the
    decoder in sample count units.
    
    This can cause a TrueHD frame to be split between two MAT frames, so a
    second concatenation hd_buf is added, alternating with the first buffer.
    
    Large frames are preceded by smaller frames that have input_timing
    values that cause the frames to be sent out faster than the nominal rate
    (i.e. increasing decoder latency, long decoder buffer), allowing the
    larger frames to then be sent out slower than the nominal rate as the
    decoder has enough data buffered to keep it busy.
    36e156be
spdifenc.c 24.3 KB