Skip to content

Discrepancy in the complexity of the Copy() function

There is a platform/compiler-dependent discrepancy in how the complexity of the Copy() function in the BASOP code is counted. The IF() statement is counted as one operation (4 complexity points), and the ELSE() statement is also counted as one operation (4 complexity points).

The Copy() function is currently written as follows:

void Copy( const Word16 x[], /* i : input vector */
            Word16 y[],      /* o : output vector */
            const Word16 L   /* i : vector length */ )
{
     Word16 i;
     IF( y < x )
     {
         FOR( i = 0; i < L; i++ )
         {
             y[i] = x[i];
             move16();
         }
     }
     ELSE
     {
         FOR( i = L - 1; i >= 0; i-- )
         {
             y[i] = x[i];
             move16();
         }
     }
}

Depending on the locations of the x[] and y[] buffers in RAM, the mechanism may or may not count the ELSE() statement. This inconsistency can lead to discrepancies in complexity numbers, for example, between Linux and Windows platforms or across different compilers.