Skip to content

Commit 919f2aa

Browse files
authored
Merge pull request #930 from kxxt/fix/Frame/GetSamplesPerFrame
Fix Frame::GetSamplesPerFrame when channels = 0
2 parents a204512 + bc73ede commit 919f2aa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Frame.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@ void Frame::SetFrameNumber(int64_t new_number)
455455
// Calculate the # of samples per video frame (for a specific frame number and frame rate)
456456
int Frame::GetSamplesPerFrame(int64_t number, Fraction fps, int sample_rate, int channels)
457457
{
458+
// Directly return 0 if there are no channels
459+
// so that we do not need to deal with NaNs later
460+
if (channels == 0) return 0;
461+
458462
// Get the total # of samples for the previous frame, and the current frame (rounded)
459463
double fps_rate = fps.Reciprocal().ToDouble();
460464

0 commit comments

Comments
 (0)