Fixed a possible division by zero in frame rate detection

This commit is contained in:
Klaus Schmidinger
2014-04-13 14:00:42 +02:00
parent 1dca279938
commit 99d7fe6cf9
3 changed files with 14 additions and 5 deletions

View File

@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: remux.c 2.75.1.5 2014/03/08 15:10:24 kls Exp $
* $Id: remux.c 2.75.1.6 2014/04/13 13:59:21 kls Exp $
*/
#include "remux.h"
@@ -1511,7 +1511,12 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
for (int i = 0; i < numPtsValues; i++)
ptsValues[i] = ptsValues[i + 1] - ptsValues[i];
qsort(ptsValues, numPtsValues, sizeof(uint32_t), CmpUint32);
uint32_t Delta = ptsValues[0] / (framesPerPayloadUnit + parser->IFrameTemporalReferenceOffset());
int Div = framesPerPayloadUnit;
if (framesPerPayloadUnit > 1)
Div += parser->IFrameTemporalReferenceOffset();
if (Div <= 0)
Div = 1;
uint32_t Delta = ptsValues[0] / Div;
// determine frame info:
if (isVideo) {
if (abs(Delta - 3600) <= 1)