• Andreas Rheinhardt's avatar
    avcodec/cfhddata: Reduce stack usage · e6d89d0e
    Andreas Rheinhardt authored
    Creating CFHD RL VLC tables works by first extending
    the codes by the sign, followed by creating a VLC,
    followed by deriving the RL VLC from this VLC (which
    is then discarded). Extending the codes uses stack arrays.
    
    The tables used to initialize the VLC are already sorted
    from left-to-right in the tree. This means that the
    corresponding VLC entries are generally also ascending,
    but not always: Entries from subtables always follow
    the corresponding main table although it is possible
    for the right-most node to fit into the main table.
    
    This suggests that one can try to use the final destination
    buffer as scratch buffer for the tables with sign included.
    Unfortunately it works for neither of the tables if one
    uses the right-most part of the RL VLC buffer as scratch buffer;
    using the left-most part of the RL VLC buffer as scratch buffer
    might work if one traverses the VLC entries from end to start.
    But it works only for the little RL VLC (table 9), not for table 18.
    
    Therefore this patch uses the RL VLC buffer for table 9
    as scratch buffer for creating the bigger table 18.
    Afterwards the left part of the buffer for table 9 is
    used as scratch buffer to create table 9.
    
    This fixes the cfhd part of ticket #9399 (if it is not already fixed).
    Notice that I do not consider the previous stack usage excessive.
    Reviewed-by: 's avatarPaul B Mahol <onemda@gmail.com>
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
    e6d89d0e
cfhddata.c 9.72 KB