mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[codec,aac] add NaN filter
ffmpeg format conversion from int16 to float sometimes produces values that are NaN or Infinity. Replace these values as these input values break the AAC encoder
This commit is contained in:
@@ -430,9 +430,29 @@ static BOOL ffmpeg_resample_frame(AVAudioResampleContext* context, AVFrame* in,
|
||||
static BOOL ffmpeg_encode_frame(AVCodecContext* context, AVFrame* in, AVPacket* packet,
|
||||
wStream* out)
|
||||
{
|
||||
int ret;
|
||||
if (in->format == AV_SAMPLE_FMT_FLTP)
|
||||
{
|
||||
uint8_t** pp = in->extended_data;
|
||||
for (int y = 0; y < in->channels; y++)
|
||||
{
|
||||
float* data = pp[y];
|
||||
for (int x = 0; x < in->nb_samples; x++)
|
||||
{
|
||||
const float val1 = data[x];
|
||||
if (isnan(val1))
|
||||
data[x] = 0.0f;
|
||||
else if (isinf(val1))
|
||||
{
|
||||
if (val1 < 0.0f)
|
||||
data[x] = -1.0f;
|
||||
else
|
||||
data[x] = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* send the packet with the compressed data to the encoder */
|
||||
ret = avcodec_send_frame(context, in);
|
||||
int ret = avcodec_send_frame(context, in);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user