• Andreas Rheinhardt's avatar
    avformat/matroskaenc: Don't fail if reserved Cues space doesn't suffice · 06f10890
    Andreas Rheinhardt authored
    When the user opted to write the Cues at the beginning, the Cues were
    simply written without checking in advance whether enough space has been
    reserved for them. If it wasn't enough, the data following the space
    reserved for the Cues was simply overwritten, corrupting the file.
    
    This commit changes this by checking whether enough space has been
    reserved for the Cues before outputting anything. If it isn't enough,
    no Cues will be output at all and the file will be finalized normally,
    yet writing the trailer will nevertheless return an error to notify
    the user that his wish of having Cues at the front of the file hasn't
    been fulfilled.
    
    This change opens new usecases for this option: It is now safe to use
    this option to e.g. record live streams or to use it when muxing the
    output of an expensive encoding, because when the reserved space turns
    out to be insufficient, one ends up with a file that just lacks Cues
    but is otherwise fine.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    06f10890
matroskaenc.c 101 KB