mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Detect more h264 streams with leading zeros.
This commit is contained in:
parent
f28a737a9a
commit
baa4500a2c
@ -1,6 +1,7 @@
|
|||||||
User johns
|
User johns
|
||||||
Date:
|
Date:
|
||||||
|
|
||||||
|
Detect more h264 streams with leading zeros.
|
||||||
VDPAU: support for studio levels added.
|
VDPAU: support for studio levels added.
|
||||||
Add support for skip chroma deinterlace to software deinterlacer.
|
Add support for skip chroma deinterlace to software deinterlacer.
|
||||||
Type of software deinterlacer now configurable from setup menu.
|
Type of software deinterlacer now configurable from setup menu.
|
||||||
|
70
softhddev.c
70
softhddev.c
@ -803,6 +803,8 @@ int PlayVideo(const uint8_t * data, int size)
|
|||||||
const uint8_t *check;
|
const uint8_t *check;
|
||||||
int64_t pts;
|
int64_t pts;
|
||||||
int n;
|
int n;
|
||||||
|
int z;
|
||||||
|
int l;
|
||||||
|
|
||||||
if (Usr1Signal) { // x11 server ready
|
if (Usr1Signal) { // x11 server ready
|
||||||
Usr1Signal = 0;
|
Usr1Signal = 0;
|
||||||
@ -877,9 +879,72 @@ int PlayVideo(const uint8_t * data, int size)
|
|||||||
|
|
||||||
check = data + 9 + n;
|
check = data + 9 + n;
|
||||||
if (0) {
|
if (0) {
|
||||||
printf("%02x: %02x %02x %02x %02x %02x\n", data[6], check[0], check[1],
|
printf("%02x: %02x %02x %02x %02x %02x %02x %02x\n", data[6], check[0],
|
||||||
check[2], check[3], check[4]);
|
check[1], check[2], check[3], check[4], check[5], check[6]);
|
||||||
}
|
}
|
||||||
|
#if 1 // FIXME: test code for better h264 detection
|
||||||
|
z = 0;
|
||||||
|
l = size - 9 - n;
|
||||||
|
while (!*check) { // count leading zeros
|
||||||
|
if (--l < 4) {
|
||||||
|
Error(_("[softhddev] invalid video packet %d bytes\n"), size);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
++check;
|
||||||
|
++z;
|
||||||
|
}
|
||||||
|
|
||||||
|
// H264 Access Unit Delimiter 0x00 0x00 0x00 0x01 0x09
|
||||||
|
if ((data[6] & 0xC0) == 0x80 && z > 2 && check[0] == 0x01
|
||||||
|
&& check[1] == 0x09) {
|
||||||
|
if (VideoCodecID == CODEC_ID_H264) {
|
||||||
|
VideoNextPacket(CODEC_ID_H264);
|
||||||
|
} else {
|
||||||
|
Debug(3, "video: h264 detected\n");
|
||||||
|
VideoCodecID = CODEC_ID_H264;
|
||||||
|
}
|
||||||
|
// SKIP PES header
|
||||||
|
VideoEnqueue(pts, check - 5, l + 5);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
// PES start code 0x00 0x00 0x01
|
||||||
|
if (z > 1 && check[0] == 0x01) {
|
||||||
|
if (VideoCodecID == CODEC_ID_MPEG2VIDEO) {
|
||||||
|
VideoNextPacket(CODEC_ID_MPEG2VIDEO);
|
||||||
|
} else {
|
||||||
|
Debug(3, "video: mpeg2 detected ID %02x\n", check[3]);
|
||||||
|
VideoCodecID = CODEC_ID_MPEG2VIDEO;
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (ValidateMpeg(data, size)) {
|
||||||
|
Debug(3, "softhddev/video: invalid mpeg2 video packet\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// SKIP PES header
|
||||||
|
VideoEnqueue(pts, check - 3, l + 3);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
// this happens when vdr sends incomplete packets
|
||||||
|
|
||||||
|
if (VideoCodecID == CODEC_ID_NONE) {
|
||||||
|
Debug(3, "video: not detected\n");
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
// SKIP PES header
|
||||||
|
VideoEnqueue(pts, data + 9 + n, size - 9 - n);
|
||||||
|
|
||||||
|
// incomplete packets produce artefacts after channel switch
|
||||||
|
// packet < 65526 is the last split packet, detect it here for
|
||||||
|
// better latency
|
||||||
|
if (size < 65526 && VideoCodecID == CODEC_ID_MPEG2VIDEO) {
|
||||||
|
// mpeg codec supports incomplete packets
|
||||||
|
// waiting for a full complete packages, increases needed delays
|
||||||
|
VideoNextPacket(CODEC_ID_MPEG2VIDEO);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
#else
|
||||||
// FIXME: no valid mpeg2/h264 detection yet
|
// FIXME: no valid mpeg2/h264 detection yet
|
||||||
// FIXME: better skip all zero's >3 && 0x01 0x09 h264, >2 && 0x01 -> mpeg2
|
// FIXME: better skip all zero's >3 && 0x01 0x09 h264, >2 && 0x01 -> mpeg2
|
||||||
|
|
||||||
@ -938,6 +1003,7 @@ int PlayVideo(const uint8_t * data, int size)
|
|||||||
VideoEnqueue(pts, check, size - 9 - n);
|
VideoEnqueue(pts, check, size - 9 - n);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_JPEG) && JPEG_LIB_VERSION >= 80
|
#if defined(USE_JPEG) && JPEG_LIB_VERSION >= 80
|
||||||
|
Loading…
Reference in New Issue
Block a user