Skip to content
Snippets Groups Projects
  • Sven M. Hallberg's avatar
    8e6bcd9c
    lzw: simplify grammar by using h_bind to choose code length · 8e6bcd9c
    Sven M. Hallberg authored
    This replaces the validations on code9 etc. with one continuation that
    picks the appropriate parser.
    
    Also relaxes the parser to allow further output codes after the table is
    full. Looking at the spec, it seems to me at this times that the
    requirement for a clear code when the table is full is a requirement on
    producers of PDF files, but not on the file format itself. As far as I
    understand, conforming files can be created by a non-conforming process.
    
    Note: The implementation uses a slight trick to handle the last code
    (4095) correctly. Quoting the comment in act_output():
    
        Rather than going through the effort of ensuring that the last
        code is only updated once, we simply assign one more code as a
        dummy.
    
    So, the table is now 4097 entries in actual size. The last one will
    receive a bogus update every cycle, so that the last real code does not.
    This is less work than actually detecting and avoiding the bogus updates.
    8e6bcd9c
    History
    lzw: simplify grammar by using h_bind to choose code length
    Sven M. Hallberg authored
    This replaces the validations on code9 etc. with one continuation that
    picks the appropriate parser.
    
    Also relaxes the parser to allow further output codes after the table is
    full. Looking at the spec, it seems to me at this times that the
    requirement for a clear code when the table is full is a requirement on
    producers of PDF files, but not on the file format itself. As far as I
    understand, conforming files can be created by a non-conforming process.
    
    Note: The implementation uses a slight trick to handle the last code
    (4095) correctly. Quoting the comment in act_output():
    
        Rather than going through the effort of ensuring that the last
        code is only updated once, we simply assign one more code as a
        dummy.
    
    So, the table is now 4097 entries in actual size. The last one will
    receive a bogus update every cycle, so that the last real code does not.
    This is less work than actually detecting and avoiding the bogus updates.