• Jean-Michel Trivi's avatar
    Encoder quantizer fix · ed247dfa
    Jean-Michel Trivi authored
    AAC Encoder: Saturate quantizer shift value to prevent
      undefined behaviour.
    
    In very rare cases the shift value 'totalShift = (16-4)-(3*(totalShift>>2))'
     can be greater than accu data width. If you apply a shift with more then
     31 bit the result depends on the architecture and is not defined in C.
    For certain platforms zeros are shifted in. That would be our desired behaviour.
    On other platforms the shift will be applied as modulo. For example >>34
     would be applied as >>2. To prevent this discrepancy the shift value
     is limited/saturated to DFRACT_BITS-1. 'accu >>= fixMin(totalShift,DFRACT_BITS-1)'.
    
    Bug 9428126
    
    Change-Id: I27177654c4dc22cf899bc35dad9cdd040dccb02d
    ed247dfa
quantize.cpp 14.1 KB