Skip to content

Commit 3f2d09b

Browse files
committed
More bug fixes in ffmpeg.
1 parent 1dc206a commit 3f2d09b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Source/Ports/FFmpeg/LibAvUtil/SampleFmt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public static c_int Av_Samples_Get_Buffer_Size(CPointer<c_int> lineSize, c_int n
174174
}
175175

176176
// Check for integer overflow
177-
if ((nb_Channels > (c_int.MaxValue / align)) || (((int64_t)nb_Samples * nb_Samples) > ((c_int.MaxValue - (align * nb_Samples)) / sample_Size)))
177+
if ((nb_Channels > (c_int.MaxValue / align)) || (((int64_t)nb_Channels * nb_Samples) > ((c_int.MaxValue - (align * nb_Channels)) / sample_Size)))
178178
return Error.EINVAL;
179179

180180
c_int line_Size = planar != 0 ? Macros.FFAlign(nb_Samples * sample_Size, align) : Macros.FFAlign(nb_Samples * sample_Size * nb_Channels, align);

Source/Ports/FFmpeg/LibSwResample/SwResample.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ public static c_int Swr_Init(SwrContext s)//XX 138
317317
goto Fail;
318318
}
319319

320+
const c_int RSC = 1;
321+
320322
if (s.In.Ch_Count == 0)
321323
s.In.Ch_Count = s.In_Ch_Layout.Nb_Channels;
322324

@@ -353,6 +355,8 @@ public static c_int Swr_Init(SwrContext s)//XX 138
353355
goto Fail;
354356
}
355357

358+
s.Resample_First = ((RSC * s.Out.Ch_Count / s.Used_Ch_Layout.Nb_Channels) - RSC) < ((s.Out_Sample_Rate / (c_float)s.In_Sample_Rate) - 1.0f) ? 1 : 0;
359+
356360
s.In.CopyTo(s.In_Buffer);
357361
s.In.CopyTo(s.Silence);
358362
s.Out.CopyTo(s.Drop_Temp);

0 commit comments

Comments
 (0)