Improved detecting frames in MPEG 4 video

This commit is contained in:
Klaus Schmidinger 2012-09-18 09:57:38 +02:00
parent 14eb0d77e9
commit ed456adc80
3 changed files with 15 additions and 9 deletions

View File

@ -1322,8 +1322,6 @@ Reinhard Nissl <rnissl@gmx.de>
for reporting that the Transfer Mode indicator bitmap in the LCARS skin may not for reporting that the Transfer Mode indicator bitmap in the LCARS skin may not
fit with small font sizes fit with small font sizes
for reporting a race condition when zapping in transfer mode for reporting a race condition when zapping in transfer mode
for reporting an error in mapping the frame type bits when detecting independent
frames in MPEG 4 video
Richard Robson <richard_robson@beeb.net> Richard Robson <richard_robson@beeb.net>
for reporting freezing replay if a timer starts while in Transfer Mode from the for reporting freezing replay if a timer starts while in Transfer Mode from the
@ -2944,3 +2942,7 @@ Dennis Bendlin <dennisbendlin@online.de>
Oliver Schinagl <oliver@schinagl.nl> Oliver Schinagl <oliver@schinagl.nl>
for a patch that was used to implement the setup options "OSD/Color key [0123]" for a patch that was used to implement the setup options "OSD/Color key [0123]"
Andrey Pridvorov <ua0lnj@bk.ru>
for reporting a problem with detecting frames in MPEG 4 video, and pointing towards
a better way of doing it

View File

@ -7235,15 +7235,14 @@ Video Disk Recorder Revision History
function in order to make use of this new feature. See, for instance, the function function in order to make use of this new feature. See, for instance, the function
cSkinClassicDisplayMenu::SetButtons() in skinclassic.c for details. cSkinClassicDisplayMenu::SetButtons() in skinclassic.c for details.
2012-09-17: Version 1.7.31 2012-09-18: Version 1.7.31
- If regenerating an index file fails and no data is written to the file, VDR now - If regenerating an index file fails and no data is written to the file, VDR now
reports this error and removes the empty index file. reports this error and removes the empty index file.
- Fixed mapping the frame type bits when detecting independent frames in MPEG 4
video (reported by Reinhard Nissl).
- The setup parameter "Recording/Instant rec. time (min)" can now be set to '0', - The setup parameter "Recording/Instant rec. time (min)" can now be set to '0',
which means to record only the currently running event (based on a patch from Matti which means to record only the currently running event (based on a patch from Matti
Lehtimäki). Lehtimäki).
- Decreased the ring buffer put/get trigger sizes from 1/3 to 1/10. - Decreased the ring buffer put/get trigger sizes from 1/3 to 1/10.
- The script given to VDR with the '-r' option is now also called whenever a - The script given to VDR with the '-r' option is now also called whenever a
recording is deleted (thanks to Alexander Wenzel). recording is deleted (thanks to Alexander Wenzel).
- Improved detecting frames in MPEG 4 video (reported by Andrey Pridvorov).

13
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.65 2012/09/14 09:06:14 kls Exp $ * $Id: remux.c 2.66 2012/09/18 09:11:24 kls Exp $
*/ */
#include "remux.h" #include "remux.h"
@ -843,7 +843,8 @@ int cFrameDetector::SkipPackets(const uchar *&Data, int &Length, int &Processed,
int cFrameDetector::Analyze(const uchar *Data, int Length) int cFrameDetector::Analyze(const uchar *Data, int Length)
{ {
int SeenPayloadStart = false; bool SeenPayloadStart = false;
bool SeenAccessUnitDelimiter = false;
int Processed = 0; int Processed = 0;
newFrame = independentFrame = false; newFrame = independentFrame = false;
while (Length >= TS_SIZE) { while (Length >= TS_SIZE) {
@ -970,12 +971,16 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
scanner = EMPTY_SCANNER; scanner = EMPTY_SCANNER;
if (synced && !SeenPayloadStart && Processed) if (synced && !SeenPayloadStart && Processed)
return Processed; // flush everything before this new frame return Processed; // flush everything before this new frame
SeenAccessUnitDelimiter = true;
}
else if (SeenAccessUnitDelimiter && scanner == 0x00000001) { // NALU start
SeenAccessUnitDelimiter = false;
int FrameTypeOffset = i + 1; int FrameTypeOffset = i + 1;
if (FrameTypeOffset >= TS_SIZE) // the byte to check is in the next TS packet if (FrameTypeOffset >= TS_SIZE) // the byte to check is in the next TS packet
i = SkipPackets(Data, Length, Processed, FrameTypeOffset); i = SkipPackets(Data, Length, Processed, FrameTypeOffset);
newFrame = true; newFrame = true;
uchar FrameType = Data[FrameTypeOffset] & 0xE0; uchar FrameType = Data[FrameTypeOffset] & 0x1F;
independentFrame = FrameType == 0x00; independentFrame = FrameType == 0x07;
if (synced) { if (synced) {
if (framesPerPayloadUnit < 0) { if (framesPerPayloadUnit < 0) {
payloadUnitOfFrame = (payloadUnitOfFrame + 1) % -framesPerPayloadUnit; payloadUnitOfFrame = (payloadUnitOfFrame + 1) % -framesPerPayloadUnit;