NTIA Technical Memorandum TM-03-398 

Compensating for System Gain–

Motivations, Derivations and Relations 

for Three Common Solutions 

Stephen D. Voran 

U.S. DEPARTMENT OF COMMERCE 

Donald L. Evans, Secretary

Nancy J. Victory, Assistant Secretary 

for Communications and Information 

October 2002 
ii
iii

CONTENTS 

Page 

ABSTRACT.................................................................................................................................... 1 

1. INTRODUCTION................................................................................................................... 1 

2. THREE GAIN COMPENSATION SOLUTIONS.................................................................. 2 

3. ALGEBRAIC AND GEOMETRIC OBSERVATIONS......................................................... 4 

4. EXAMPLE GAIN COMPENSATION RESULTS................................................................. 5 

5. DISCUSSION.......................................................................................................................... 7 

6. CONCLUSIONS ..................................................................................................................... 8 

7. REFERENCES ........................................................................................................................ 9 
COMPENSATING FOR SYSTEM GAIN: MOTIVATIONS, DERIVATIONS, AND 

RELATIONS FOR THREE COMMON SOLUTIONS 

Stephen D. Voran1

It is often desirable to compensate for system gain, especially before objectively 

estimating perceived audio or video quality from system inputs and outputs. A 

common approach is to scale the system output to compensate for system gain. 

One can take three views of the system, and this leads to three different gain 

compensation solutions: one that minimizes distortion, one that matches inputoutput power, and one that maximizes signal-to-distortion ratio. We derive these 

three solutions, describe the algebraic and geometric relationships between them, 

and provide a generalized result that subsumes all three. We provide audio and 

video examples and show that these three solutions can differ significantly. We 

also report some of the gain compensation choices found in the objective audio and 

video quality estimation literature. 

Key words: audio quality estimation, gain compensation, gain estimation, speech quality 

 estimation, system gain, video quality estimation 

1. INTRODUCTION 

There are numerous engineering situations where it is desirable to compensate for system gain. 

Two important examples are the objective estimation of perceived audio or video quality [1]-[9]. 

In general, an audio or video system will distort the audio or video signal and will also apply 

some non-unity gain factor to the signal. Constant non-unity system gain results in a shift of 

volume, contrast, or color saturation. Such shifts are often not considered to be part of the 

distortion introduced by the audio or video system since users often routinely adjust volume, 

contrast, brightness, and color balance to suit individual preferences. Objective estimators of 

perceived audio and video quality are intended to give results that agree with human perception. 

If system gain is not considered to be a distortion component by human subjects, then it should be 

likewise ignored by objective estimators. This means that the system gain must be compensated 

for so that the objective estimator can properly measure the actual distortion components. Figure 

1 describes the typical approach where the system output y is scaled by the reciprocal of the 

estimated system gain g to produce a gain-compensated output signal y . 

 

1

 The author is with the Institute for Telecommunication Sciences, National Telecommunications and 

Information Administration, U.S. Department of Commerce, Boulder, CO 80305. 
2

Figure 1. Typical block diagram for gain-compensated quality estimation of the system S. 

When estimating audio and video quality, there may be other fixed “distortion” components that 

one might wish to compensate for in order to best emulate human perception. These may include 

a shift in mean signal level, a constant delay, or small constant spatial shifts of video frames. 

Compensation for these “distortion” components is outside the scope of this memorandum. 

In this memorandum we point out that there are three distinct, mathematically-motivated solutions 

for compensating for system gain. We derive each solution, describe the algebraic and geometric 

relationships between them, and provide a generalized result that subsumes all three. Finally we 

offer example results taken from a digital speech codec and an analog video recorder. 

Each of these three solutions for system gain compensation has been used before. Different 

authors have chosen different solutions and have offered no comment regarding the other choices. 

Each of the solutions is quite simple and when presented in isolation from the other two, each 

solution may initially appear to be the only logical choice, thus creating the appearance that no 

discussion of the solution is necessary. This memorandum shows that discussion is warranted 

because each solution has a unique mathematical motivation, each solves a unique problem, and 

each yields a unique result. The solution one uses should reflect a conscious choice based on the 

system under consideration. This memorandum also shows how the three solutions are related to 

each other. 

2. THREE GAIN COMPENSATION SOLUTIONS 

In general, we wish to treat the case where the system S is not well-modeled by gain plus additive 

noise. Rather we assume that S induces some arbitrary distortion and gain g on signal vector x to 

create the output signal vector y. Given a single input vector x and output vector y we must find a 

reasonable value of g so that scaling y by 1g −  will give the compensated output signal vector y . 

Without any loss of generality we assume that all signals have zero mean and non-zero magnitude 

and we assume that the x and y are not orthogonal. 

x 

1

g − 

y

y

Quality 

Estimator 

S 
3

It is certainly reasonable to seek a value of g such that remaining system distortion is minimized: 

T

2 2 1 min min , MD T g g

g g − −⇒ − ⇒ = y y xy x y   x y    (1) 

where we have used conventional least squares to solve for the minimum distortion gain estimate 

MD g . 

For many systems absolute distortion values are less relevant than signal-to-distortion ratios. The 

nature of human auditory and visual perception makes this especially true for audio and video 

signals. Thus it would also be reasonable to seek a value of g such that remaining system signalto-distortion ratio (SDR) is maximized: 

2 2 T

2

max 10log max min , 10 2 2 MS T

g g g

g g

g

    ⇒ ⇒ −⇒ =   − −  

y y x y x y   xy xy  x x

     (2) 

where we have used conventional least squares to solve for the maximum SDR gain estimate 

MS g . 

A third intuitive solution is the matched power solution. This solution forces x and y to have the 

same power and it is also the geometric mean of the two previous solutions: 

2

2 . MP MD MS g gg = = y

x   (3) 

In the decibel domain the geometric mean of (3) becomes an arithmetic mean: 

, where 20log . 10 ( ) 2

MD MS

MP x x

G G G Gg + = =      (4) 

Note that MD g and MS g will correctly detect a negative gain value (indicating a phase inversion in 

S) but MP g as defined in (3) will not. Thus we use an intuitive extension to redefine MP g as 
4

T =sign( ) , MP g

y

x y

x  (5) 

so that all three solutions will have the same sign. 

3. ALGEBRAIC AND GEOMETRIC OBSERVATIONS 

If we define the normalized input-output cross correlation (or input-output direction cosine) ρ as 

T

ρ ρ = −≤ ≤ , 1 1, x y

x y

 (6) 

then we can summarize the three solutions as 

1

1

,

( ),

.

MD

MP

MS

g

g sign

g

ρ

ρ

ρ

−

+

=

=

=

y

x

y

x

y

x







 (7) 

Equation (7) makes it clear that all three solutions have the same sign and that their magnitudes 

can be ordered: 

. MS MP MD ggg  ≤ ≤ (8) 

In the limit as S becomes distortionless, ρ →1 and (7) makes it clear that the three solutions 

converge to a single (matched power) solution as expected. 

Equation (7) also reveals that each of the three solutions is a special case of the more general 

solution 

g sign ( ) ( ) , 1 1, αα ρρ α = −≤ ≤ y

x  (9) 
5

where α = -1, 0, and +1 correspond to the minimum distortion, matched power, and maximum 

SDR solutions respectively. Figure 2 provides an example of the geometric relationships among 

x, y, and the three possible gain-compensated outputs MD y , MP y , and MS y . 

Note that these three solutions allow for arbitrary distortions in S but they also reproduce 

solutions that come from the minimization of additive input or output noises. The case of input 

noise leads to the minimum distortion solution. That is, if we solve for g to satisfy 

= + g ( ) in y xn  while minimizing 2nin , we will arrive at MD g g   = . The case of output noise leads 

to the maximum SDR solution. That is, if we solve for g to satisfy = + g out y x n while 

minimizing 2

nout , we will arrive at MS g g   = . The matched power solution MP g assumes that all 

output power is scaled input power and thus corresponds to the noise-free case y x = g . 

Figure 2. Example geometry of the three gain-compensation solutions. 

4. EXAMPLE GAIN COMPENSATION RESULTS 

In this section we present gain compensation examples for speech and video systems. In the 

speech example the input x is a ten-second speech signal and the system S is a 5.3 kbps speech 

codec conforming to ITU-T Recommendation G.723.1 [10]. In the video example the input x is 

one frame of a video chrominance signal and the system S consists of several play and record 

cycles of an analog video tape recorder. Figure 3 and Figure 4 show the SDR and distortion as a 

function of G for the speech and video examples respectively. The calculated values of GMS  , 

x 

y 

( ) 1 θ cos ρ − =

( ) 1 cos MD MD g θ − = = y y yx

y  

MD y

MP y

MS y

1

MP MP g − = = y y y x

y  

( )

1 1

cos

MS MS g θ

− = = y y yx

y  
6

Figure 3. Example gain-compensated SDR (solid line) and gain-compensated distortion (dashed 

 line) vs. estimated gain (G ) for a speech codec. 

Figure 4. Example gain-compensated SDR (solid line) and gain-compensated distortion (dashed 

 line) vs. estimated gain (G ) for an analog video tape recorder. 
7

GMP  , and GMD  are marked. As expected, GMS  corresponds to the SDR maximum, GMD 

corresponds to the distortion minimum, and GMP  is midway between GMS  and GMD  . Note that in 

the speech example, the values of the three gain compensation solutions span a range of about 0.8 

dB, and the resulting SDR and distortion values span a range of about 0.4 dB. For the video 

example these ranges are smaller. In general, these ranges will depend on both the input x and the 

system S.

5. DISCUSSION 

We have established that there are multiple well-motivated solutions to the gain compensation 

problem described in Figure 1, and that these solutions can differ significantly in real 

applications. We might ask which solution should be used in practice but of course there is no 

single answer. Each solution does exactly what its name says it does, so the question of which 

solution to use becomes the question of which attribute is most relevant in a given context. Do 

we wish to minimize distortion, match power, or maximize SDR? 

We could also ask the question somewhat differently in terms of g . Loosely speaking, we could 

ask if 1

g −  should describe how to scale the output to make it “as close as possible” to the input 

(leading to the minimum distortion solution), or if g should describe the output-to-input power 

ratio (leading to the matched power solution), or if g should describe how to scale the input to 

make it “as close as possible” to the output (leading to the maximum SDR solution)? 

We could ask the question in a third way, using even more informal language. Should 1

g − 

describe the fraction of the output that “matches” the input (leading to the minimum distortion 

solution where we project the input vector onto the output vector), or should g describe the 

output-to-input power ratio (leading to the matched power solution), or should g describe the 

fraction of the input that “matches” the output (leading to the maximum SDR solution where we 

project the output vector onto the input vector)? 

As noted above, the nature of human auditory and visual perception may make SDR more 

relevant than distortion in audio and video systems. This might lead one towards a maximum 

SDR solution for the gain compensation problem in the audio and video system context. We note 

further that “distortion” as we have used it here is waveform distortion. In perception-based 

audio codecs, waveforms may be severely distorted while the perceived audio signal is minimally 

distorted. For these and similar systems, the matched power solution may be more appropriate 

than the minimum waveform distortion solution or the maximum waveform SDR solution. For 

the audio or video quality estimation application, it may be even more appropriate to compensate 

for system gain by the matching of some estimates of perceived loudness or contrast. 

A variety of gain compensation choices can be found in the objective audio and video quality 

estimation literature. The audio quality estimation algorithm in [6] includes a level adaptation 

stage that effectively calculates 0 MD < g for frequency-domain excitation patterns. When 1 MD g ≤

the input is scaled by MD g , otherwise the output is scaled by 1

MD g −  . The speech quality estimation 

algorithms given in [2] and [3] effectively perform matched power gain compensation, but they 
8

apply different scale factors to both the input and output signals to bring them to a common fixed 

level (e.g. unit variance). The speech quality estimation algorithm in [4] performs matched power 

gain compensation and applies a scale factor to the output only. The video quality estimation 

algorithm in [8] uses an iterative algorithm to find a robust estimate of MS g . This algorithm uses 

weighted least-squares and places smaller weights on samples that have greater distortion so that 

they will not unduly influence the gain estimate. The resulting scale factor is applied to the 

output only. 

Finally we mention system gain compensation via input scaling as shown in Figure 5. This is a 

somewhat less intuitive but still reasonable alternative to the output scaling approach given in 

Figure 1. If the input scaling approach is adopted, then the minimum distortion and maximum 

SDR solutions will be identical to each other and will be given by (2). The matched power 

solution will be unchanged and thus will be given by (5). 

Figure 5. Block diagram for gain-compensated quality estimation with input scaling. 

6. CONCLUSIONS 

There are three mathematically-motivated solutions to the gain compensation problem described 

in Figure 1. The solution used should reflect a conscious choice based on the system under 

consideration. Depending on which attribute is most relevant, we may choose to seek a gain 

compensation that minimizes distortion, matches power, or maximizes SDR. We have derived 

these three solutions, described the algebraic and geometric relationships between them, and 

provided a generalized result that subsumes all three. We have demonstrated that these solutions 

can differ significantly in real applications (e.g. 0.8 dB for the G.723.1 speech coder) and have 

reported some of the gain compensation choices found in the objective audio and video quality 

estimation literature. 

x 

y

y

Quality 

Estimator 

x S 

g

y

y

Quality 

Estimator 

S 

x
9

7. REFERENCES 

[1] A.W. Rix, J.G. Beerends, M.P. Hollier, and A.P. Hekstra, “Perceptual evaluation of 

speech quality (PESQ) – A new method for speech quality assessment of telephone 

networks and codecs,” in Proc. IEEE International Conference on Acoustics, Speech and 

Signal Processing 2001, Salt Lake City, May 2001, vol. 2, pp. 749-752. 

[2] ITU-T Recommendation P.862, “Perceptual evaluation of speech quality (PESQ), an 

objective method for end-to-end speech quality assessment of narrowband telephone 

networks and speech codecs,” Geneva, 2001. 

[3] S.D. Voran, “Objective estimation of perceived speech quality, part II: Evaluation of the 

measuring normalizing block technique,” IEEE Transactions on Speech and Audio 

Processing, vol. 7, no. 4, pp. 383-390, Jul. 1999. 

[4] ITU-T Recommendation P.861, “Objective quality measurement of telephone-band (300-

3400 Hz) speech codecs,” Geneva, 1996. 

[5] T. Thiede, W.C. Treurniet, R. Bitto, C. Schmidmer, T. Sporer, J.G. Beerends, C. Colomes, 

M. Keyhl, G. Stoll, K. Brandenburg, and B. Feiten, “PEAQ – The ITU standard for 

objective measurement of perceived audio quality,” Journal of the Audio Engineering 

Society, vol. 48, no. 1/2, Jan./Feb. 2000. 

[6] ITU-R Recommendation BS.1387, “Method for objective measurements of perceived 

audio quality,” Geneva, 2001. 

[7] S. Wolf, “Measuring the end-to-end performance of digital video systems,” IEEE 

Transactions on Broadcasting, vol. 43, no. 3, pp. 320-328, Sep. 1997. 

[8] S. Wolf and M. Pinson, “Video quality measurement techniques,” NTIA Report 02-392, 

Jun. 2002 (available at http://www.its.bldrdoc.gov/n3/video/documents.htm). 

[9] C.J. van den Branden Lambrecht, D.M. Costantini, G.L. Sicuranza, and M. Kunt, “Quality 

assessment of motion rendition in video coding,” IEEE Transactions on Circuits and 

Systems for Video Technology, vol. 9, no. 5, pp. 766-782, Aug. 1999. 

[10] ITU-T Recommendation G.723.1, “Dual rate speech coder for multimedia 

communications transmitting at 5.3 and 6.3 kbit/s,” Geneva, 1996.