decoder/mpcdec: fix bogus ReplayGain values
Apparently, libmpcdec sets gain/peak variables to zero if they are not present. This clashes with our formula and results in bogus values which cause noise during playback. Closes https://github.com/MusicPlayerDaemon/MPD/issues/640
This commit is contained in:
		
							
								
								
									
										1
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								NEWS
									
									
									
									
									
								
							| @@ -1,6 +1,7 @@ | |||||||
| ver 0.21.15 (not yet released) | ver 0.21.15 (not yet released) | ||||||
| * decoder | * decoder | ||||||
|   - dsdiff, dsf: fix displayed bit rate |   - dsdiff, dsf: fix displayed bit rate | ||||||
|  |   - mpcdec: fix bogus ReplayGain values | ||||||
| * output | * output | ||||||
|   - solaris: fix build with glibc 2.30 |   - solaris: fix build with glibc 2.30 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -141,8 +141,12 @@ static constexpr ReplayGainTuple | |||||||
| ImportMpcdecReplayGain(mpc_uint16_t gain, mpc_uint16_t peak) noexcept | ImportMpcdecReplayGain(mpc_uint16_t gain, mpc_uint16_t peak) noexcept | ||||||
| { | { | ||||||
| 	auto t = ReplayGainTuple::Undefined(); | 	auto t = ReplayGainTuple::Undefined(); | ||||||
|  |  | ||||||
|  | 	if (gain != 0 && peak != 0) { | ||||||
| 		t.gain = MPC_OLD_GAIN_REF - (gain  / 256.); | 		t.gain = MPC_OLD_GAIN_REF - (gain  / 256.); | ||||||
| 		t.peak = pow(10, peak / 256. / 20) / 32767; | 		t.peak = pow(10, peak / 256. / 20) / 32767; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return t; | 	return t; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -187,6 +191,7 @@ mpcdec_decode(DecoderClient &client, InputStream &is) | |||||||
|  |  | ||||||
| 	{ | 	{ | ||||||
| 		const auto rgi = ImportMpcdecReplayGain(info); | 		const auto rgi = ImportMpcdecReplayGain(info); | ||||||
|  | 		if (rgi.IsDefined()) | ||||||
| 			client.SubmitReplayGain(&rgi); | 			client.SubmitReplayGain(&rgi); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann