LAME -q switch: Difference between revisions

From Hydrogenaudio Knowledgebase
m (moved LAME Q Switch to LAME q Switch: the quality switch is lowercase.)
No edit summary
Line 1: Line 1:
=Internal Variables=
When using [[LAME]] from the command line, the switch '''-q''' (quality) can be added in either VBR or CBR mode to alter various parameters used when encoding, which are predicted (at least in theory) to affect the quality of the output MP3 stream.


==Equivalences==
===CBR===
Some values of -q seem to produce equivalent files, at least in terms of the audio itself.
* -q5 and -q6 output identical results. LAME's header will indicate the different quality parameter, but the files, including the actual audio, are otherwise a perfect match.
* -q8 is always mapped to -q7 and thus outputs identical files, including the header.
* -q9 outputs the same file as -q7 and -q8, although the official documentation describes it as a different quality. The LAME header will be different for CBR/ABR and identical for VBR.
===VBR===
VBR encoding modes take some different code paths and ignore some of the listed values. In particular, the ten values of -q are mapped to a smaller number of actual qualities under VBR:
* -q7 to -q9 are mapped to -q7. This level uses a psymodel but does not calculate quantisation noise when encoding: it takes a quick guess.
* -q5 and -q6 include all features of -q7, calculate and consider actual quantisation noise, and additionally enable subblock gain.
* -q0 to -q4 include all features of higher numbers and additionally use the best search when applying Huffman coding.
==Effects==
This table documents the parameters that are affected by the value assigned to -q. These are most relevant to CBR for the reasons noted above.
{| border=1 class="wikitable" style="text-align:center"
{| border=1 class="wikitable" style="text-align:center"
! -q n !! huffman search !! full_outer_loop !! sv_qnt.substep_shaping !! subblock gain !! noise shaping !! amplification !! stopping !! description
! -q n !! Huffman coding search !! Use full outer loop for Huffman encoding !! sv_qnt.substep_shaping !! Subblock gain !! Noise-shaping !! Amplification !! Stopping !! Description
|-
|-
| 0 || best   || 1 || 2 ||  1 || 1 || 2 || 1 || align="left" | Use slowest & best possible version of all algorithms.
| 0 || Best   || Yes || 2 ||  1 || 1 || 2 || 1 || align="left" | Use all the best, and slowest, parameters/algorithms that are available.
|-
|-
| 1 || best   || 0 || 2 ||  1 || 1 || 2 || 1 ||
| 1 || Best   || No || 2 ||  1 || 1 || 2 || 1 ||
|-
|-
| 2 || best   || 0 || 2 ||  1 || 1 || 1 || 1 || align="left" | Recommended.  Same as -h. -q 0 and -q 1 are slow and may not produce significantly higher quality.
| 2 || Best   || No || 2 ||  1 || 1 || 1 || 1 || align="left" | Same as -h. Higher quality than the default -q3. -q2 was the default in older versions of LAME.
|-
|-
| 3 || best   || 0 || ? ||  1 || 1 || 1 || 1 || align="left" | Default value. Good speed, good quality.
| 3 || Best   || No || ? ||  1 || 1 || 1 || 1 || align="left" | Default value. Good speed, good quality. Lower values of -q may not produce significantly higher quality.
|-
|-
| 4 || best   || 0 || ? ||  1 || 1 || 0 || 0 ||
| 4 || Best   || No || ? ||  1 || 1 || 0 || 0 ||
|-
|-
| 5-6 || normal || 0 || ? ||  1 || 1 || 0 || 0 ||
| 5-6 || Normal || No || ? ||  1 || 1 || 0 || 0 ||
|-
|-
| 7-8 || normal || 0 || ? || -1 || 0 || 0 || 0 || align="left" | Same as -f. Very fast, ok quality. (psycho acoustics are used for pre-echo & M/S, but no noise shaping is done.
| 7-8 || Normal || No || ? || -1 || 0 || 0 || 0 || align="left" | Same as -f. Very fast, OK quality. Psychoacoustics are used for pre-echo and mid/side stereo, but no noise-shaping is done.
|-
|-
| 9 || normal || 0 || ? || -1 || 0 || 0 || 0 || align="left" | Disables almost all algorithms including psy-model. Poor quality.
| 9 || Normal || No || ? || -1 || 0 || 0 || 0 || align="left" | Disables almost all algorithms including psy-model. Poor quality.
|}
|}
= VBR =
{| border=1 class="wikitable"
! -q n !! description
|-
| 0-4 || Default value. Use the best algorithm.
|-
| 5-6 || Use the not so good algorithm
|-
| 7-9 ||
|}
=Observations=
* -q 5-6 Output Same Results. LAME header will indicate the different quality parameter. But the files are otherwise a perfect match.
* -q 7-8 Is always mapped to -q 7 and thus outputs identical files, including the LAME header.
* -q 9 Output is same as -q 7. But official doc describes it as a different quality. LAME header will be different for CBR/ABR and identical for VBR.

Revision as of 16:15, 3 June 2013

When using LAME from the command line, the switch -q (quality) can be added in either VBR or CBR mode to alter various parameters used when encoding, which are predicted (at least in theory) to affect the quality of the output MP3 stream.

Equivalences

CBR

Some values of -q seem to produce equivalent files, at least in terms of the audio itself.

  • -q5 and -q6 output identical results. LAME's header will indicate the different quality parameter, but the files, including the actual audio, are otherwise a perfect match.
  • -q8 is always mapped to -q7 and thus outputs identical files, including the header.
  • -q9 outputs the same file as -q7 and -q8, although the official documentation describes it as a different quality. The LAME header will be different for CBR/ABR and identical for VBR.

VBR

VBR encoding modes take some different code paths and ignore some of the listed values. In particular, the ten values of -q are mapped to a smaller number of actual qualities under VBR:

  • -q7 to -q9 are mapped to -q7. This level uses a psymodel but does not calculate quantisation noise when encoding: it takes a quick guess.
  • -q5 and -q6 include all features of -q7, calculate and consider actual quantisation noise, and additionally enable subblock gain.
  • -q0 to -q4 include all features of higher numbers and additionally use the best search when applying Huffman coding.

Effects

This table documents the parameters that are affected by the value assigned to -q. These are most relevant to CBR for the reasons noted above.

-q n Huffman coding search Use full outer loop for Huffman encoding sv_qnt.substep_shaping Subblock gain Noise-shaping Amplification Stopping Description
0 Best Yes 2 1 1 2 1 Use all the best, and slowest, parameters/algorithms that are available.
1 Best No 2 1 1 2 1
2 Best No 2 1 1 1 1 Same as -h. Higher quality than the default -q3. -q2 was the default in older versions of LAME.
3 Best No ? 1 1 1 1 Default value. Good speed, good quality. Lower values of -q may not produce significantly higher quality.
4 Best No ? 1 1 0 0
5-6 Normal No ? 1 1 0 0
7-8 Normal No ? -1 0 0 0 Same as -f. Very fast, OK quality. Psychoacoustics are used for pre-echo and mid/side stereo, but no noise-shaping is done.
9 Normal No ? -1 0 0 0 Disables almost all algorithms including psy-model. Poor quality.