1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Modified cFrameDetector::Analyze() to minimize file I/O overhead during recording

This commit is contained in:
Klaus Schmidinger 2009-03-27 14:11:43 +01:00
parent 323969e58d
commit e3de25dd11
3 changed files with 139 additions and 128 deletions

View File

@ -2426,3 +2426,6 @@ Derek Kelly (user.vdr@gmail.com)
Marcel Unbehaun <frostworks@gmx.de> Marcel Unbehaun <frostworks@gmx.de>
for adding cRecordingInfo::GetEvent() for adding cRecordingInfo::GetEvent()
Günter Niedermeier <linuxtv@ncs-online.de>
for reporting a problem with file I/O overhead during recording in TS format

View File

@ -6003,3 +6003,6 @@ Video Disk Recorder Revision History
- Adapted cFrameDetector::Analyze() to HD NTSC broadcasts that split frames over - Adapted cFrameDetector::Analyze() to HD NTSC broadcasts that split frames over
several payload units (thanks to Derek Kelly for reporting this and helping in several payload units (thanks to Derek Kelly for reporting this and helping in
testing). testing).
- Modified cFrameDetector::Analyze() to make it process whole frames at once, so
that file I/O overhead is minimized during recording (reported by Günter
Niedermeier).

25
remux.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: remux.c 2.15 2009/03/27 13:32:11 kls Exp $ * $Id: remux.c 2.16 2009/03/27 13:49:58 kls Exp $
*/ */
#include "remux.h" #include "remux.h"
@ -697,8 +697,9 @@ static int CmpUint32(const void *p1, const void *p2)
int cFrameDetector::Analyze(const uchar *Data, int Length) int cFrameDetector::Analyze(const uchar *Data, int Length)
{ {
int Processed = 0;
newFrame = independentFrame = false; newFrame = independentFrame = false;
if (Length >= TS_SIZE) { while (Length >= TS_SIZE) {
if (TsHasPayload(Data) && !TsIsScrambled(Data) && TsPid(Data) == pid) { if (TsHasPayload(Data) && !TsIsScrambled(Data) && TsPid(Data) == pid) {
if (TsPayloadStart(Data)) { if (TsPayloadStart(Data)) {
if (!frameDuration) { if (!frameDuration) {
@ -763,13 +764,13 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
switch (type) { switch (type) {
case 0x02: // MPEG 2 video case 0x02: // MPEG 2 video
if (scanner == 0x00000100) { // Picture Start Code if (scanner == 0x00000100) { // Picture Start Code
if (synced && Processed)
return Processed;
newFrame = true; newFrame = true;
independentFrame = ((Data[i + 2] >> 3) & 0x07) == 1; // I-Frame independentFrame = ((Data[i + 2] >> 3) & 0x07) == 1; // I-Frame
if (synced) { if (synced) {
if (framesPerPayloadUnit <= 1) { if (framesPerPayloadUnit <= 1)
scanning = false; scanning = false;
return TS_SIZE;
}
} }
else { else {
framesInPayloadUnit++; framesInPayloadUnit++;
@ -782,6 +783,8 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
break; break;
case 0x1B: // MPEG 4 video case 0x1B: // MPEG 4 video
if (scanner == 0x00000109) { // Access Unit Delimiter if (scanner == 0x00000109) { // Access Unit Delimiter
if (synced && Processed)
return Processed;
newFrame = true; newFrame = true;
independentFrame = Data[i + 1] == 0x10; independentFrame = Data[i + 1] == 0x10;
if (synced) { if (synced) {
@ -792,10 +795,8 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
if (payloadUnitOfFrame) if (payloadUnitOfFrame)
newFrame = false; newFrame = false;
} }
if (framesPerPayloadUnit <= 1) { if (framesPerPayloadUnit <= 1)
scanning = false; scanning = false;
return TS_SIZE;
}
} }
else { else {
framesInPayloadUnit++; framesInPayloadUnit++;
@ -808,6 +809,8 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
break; break;
case 0x04: // MPEG audio case 0x04: // MPEG audio
case 0x06: // AC3 audio case 0x06: // AC3 audio
if (synced && Processed)
return Processed;
newFrame = true; newFrame = true;
independentFrame = true; independentFrame = true;
if (synced) if (synced)
@ -827,7 +830,9 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
} }
} }
} }
return TS_SIZE; Data += TS_SIZE;
Length -= TS_SIZE;
Processed += TS_SIZE;
} }
return 0; return Processed;
} }