Pass audio PTS to codec.

Correct PTS extraction and pass it to codec module.
C++ destructor calls C function.
Fix spuDecoder is used uninitialized.
This commit is contained in:
Johns 2011-12-08 20:50:32 +01:00
parent 74c509a3e0
commit e1d8609143
4 changed files with 51 additions and 20 deletions

12
Todo
View File

@ -1,8 +1,18 @@
libva-intel-driver: libva-intel-driver:
unscaled osd not working intel still has hangups
osd has sometimes wrong size (workaround written)
can show defect surfaces (white bars on top of frame) only interlace
defect shown upto driver surface swap?
libva-vdpau-driver: libva-vdpau-driver:
G210 osd update too slow (needs hardware problem workaround) G210 osd update too slow (needs hardware problem workaround)
x11:
support resize of x11 window
support fullscreen window
support fullscreen / window toggle
video/audio asyncron video/audio asyncron
playback of >2 channels on 2 channel hardware playback of >2 channels on 2 channel hardware

View File

@ -26,6 +26,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <inttypes.h>
#include <unistd.h> #include <unistd.h>
#include <libintl.h> #include <libintl.h>
@ -78,30 +79,32 @@ void PlayAudio(const uint8_t * data, int size, uint8_t id)
// MPEG-PS mp2 MPEG1, MPEG2, AC3 // MPEG-PS mp2 MPEG1, MPEG2, AC3
if (size < 9) { if (size < 9) {
Error("[softhddev] invalid audio packet\n"); Error(_("[softhddev] invalid audio packet\n"));
return; return;
} }
avpkt->pts = AV_NOPTS_VALUE; n = data[8]; // header size
avpkt->dts = AV_NOPTS_VALUE;
if (data[7] & 0x80) { av_init_packet(avpkt);
if (data[7] & 0x80 && n >= 5) {
avpkt->pts = avpkt->pts =
(int64_t) (data[9] & 0x0E) << 29 | data[10] << 22 | (data[11] & (int64_t) (data[9] & 0x0E) << 29 | data[10] << 22 | (data[11] &
0xFE) << 15 | data[12] << 7 | (data[13] & 0xFE) >> 1; 0xFE) << 14 | data[12] << 7 | (data[13] & 0xFE) >> 1;
// Debug(3, "audio: pts %ld\n", avpkt->pts); // Debug(3, "audio: pts %#012" PRIx64 "\n", avpkt->pts);
} }
if (0) { // dts is unused
if (data[7] & 0x40) { if (data[7] & 0x40) {
avpkt->dts = avpkt->dts =
(int64_t) (data[14] & 0x0E) << 29 | data[15] << 22 | (data[16] & (int64_t) (data[14] & 0x0E) << 29 | data[15] << 22 | (data[16]
0xFE) << 15 | data[17] << 7 | (data[18] & 0xFE) >> 1; & 0xFE) << 14 | data[17] << 7 | (data[18] & 0xFE) >> 1;
Debug(3, "audio: dts %ld\n", avpkt->dts); Debug(3, "audio: dts %#012" PRIx64 "\n", avpkt->dts);
}
} }
n = data[8]; // header size
data += 9 + n; data += 9 + n;
size -= 9 + n; // skip pes header size -= 9 + n; // skip pes header
if (size <= 0) { if (size <= 0) {
Error("[softhddev] invalid audio packet\n"); Error(_("[softhddev] invalid audio packet\n"));
return; return;
} }
// Syncword - 0x0B77 // Syncword - 0x0B77
@ -113,6 +116,7 @@ void PlayAudio(const uint8_t * data, int size, uint8_t id)
if (AudioCodecID != CODEC_ID_AC3) { if (AudioCodecID != CODEC_ID_AC3) {
Debug(3, "[softhddev]%s: AC-3 %d\n", __FUNCTION__, id); Debug(3, "[softhddev]%s: AC-3 %d\n", __FUNCTION__, id);
CodecAudioClose(MyAudioDecoder); CodecAudioClose(MyAudioDecoder);
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_AC3); CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_AC3);
AudioCodecID = CODEC_ID_AC3; AudioCodecID = CODEC_ID_AC3;
} }
@ -125,6 +129,7 @@ void PlayAudio(const uint8_t * data, int size, uint8_t id)
if (AudioCodecID != CODEC_ID_MP2) { if (AudioCodecID != CODEC_ID_MP2) {
Debug(3, "[softhddev]%s: MP2 %d\n", __FUNCTION__, id); Debug(3, "[softhddev]%s: MP2 %d\n", __FUNCTION__, id);
CodecAudioClose(MyAudioDecoder); CodecAudioClose(MyAudioDecoder);
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2); CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2);
AudioCodecID = CODEC_ID_MP2; AudioCodecID = CODEC_ID_MP2;
} }
@ -143,7 +148,6 @@ void PlayAudio(const uint8_t * data, int size, uint8_t id)
return; return;
} }
av_init_packet(avpkt);
avpkt->data = (void *)data; avpkt->data = (void *)data;
avpkt->size = size; avpkt->size = size;
//memset(avpkt->data + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); //memset(avpkt->data + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
@ -244,8 +248,12 @@ static void VideoEnqueue(const void *data, int size)
avpkt->stream_index + size + FF_INPUT_BUFFER_PADDING_SIZE); avpkt->stream_index + size + FF_INPUT_BUFFER_PADDING_SIZE);
av_grow_packet(avpkt, av_grow_packet(avpkt,
(size + FF_INPUT_BUFFER_PADDING_SIZE + VIDEO_BUFFER_SIZE / 2) ((size + FF_INPUT_BUFFER_PADDING_SIZE + VIDEO_BUFFER_SIZE / 2)
/ (VIDEO_BUFFER_SIZE / 2)); / (VIDEO_BUFFER_SIZE / 2)) * (VIDEO_BUFFER_SIZE / 2));
if (avpkt->size <
avpkt->stream_index + size + FF_INPUT_BUFFER_PADDING_SIZE) {
abort();
}
} }
#ifdef DEBUG #ifdef DEBUG
if (!avpkt->stream_index) { // debug save time of first packet if (!avpkt->stream_index) { // debug save time of first packet
@ -504,8 +512,8 @@ void PlayVideo(const uint8_t * data, int size)
if (data[7] & 0x80) { if (data[7] & 0x80) {
pts = pts =
(int64_t) (data[9] & 0x0E) << 29 | data[10] << 22 | (data[11] & (int64_t) (data[9] & 0x0E) << 29 | data[10] << 22 | (data[11] &
0xFE) << 15 | data[12] << 7 | (data[13] & 0xFE) >> 1; 0xFE) << 14 | data[12] << 7 | (data[13] & 0xFE) >> 1;
// Debug(3, "video: pts %ld\n", pts); // Debug(3, "video: pts %#012" PRIx64 "\n", pts);
} }
// FIXME: no valid mpeg2/h264 detection yet // FIXME: no valid mpeg2/h264 detection yet
@ -776,6 +784,13 @@ static void StartXServer(void)
Error(_("x-setup: Failed to start X server '%s'\n"), args[0]); Error(_("x-setup: Failed to start X server '%s'\n"), args[0]);
} }
/**
** Exit + cleanup.
*/
void SoftHdDeviceExit(void)
{
}
/** /**
** Prepare plugin. ** Prepare plugin.
*/ */

View File

@ -55,6 +55,8 @@ extern "C"
/// C plugin process the command line arguments /// C plugin process the command line arguments
extern int ProcessArgs(int, char *const[]); extern int ProcessArgs(int, char *const[]);
/// C plugin exit + cleanup
extern void SoftHdDeviceExit(void);
/// C plugin start code /// C plugin start code
extern void Start(void); extern void Start(void);
/// C plugin stop code /// C plugin stop code

View File

@ -219,7 +219,7 @@ class cSoftOsdProvider:public cOsdProvider
cSoftOsdProvider(void); cSoftOsdProvider(void);
}; };
cOsd *cSoftOsdProvider::Osd; cOsd *cSoftOsdProvider::Osd; ///< single osd
/** /**
** Create a new OSD. ** Create a new OSD.
@ -330,6 +330,8 @@ class cSoftHdDevice:public cDevice
cSoftHdDevice::cSoftHdDevice(void) cSoftHdDevice::cSoftHdDevice(void)
{ {
dsyslog("[softhddev]%s\n", __FUNCTION__); dsyslog("[softhddev]%s\n", __FUNCTION__);
spuDecoder = NULL;
} }
cSoftHdDevice::~cSoftHdDevice(void) cSoftHdDevice::~cSoftHdDevice(void)
@ -577,6 +579,8 @@ cPluginSoftHdDevice::~cPluginSoftHdDevice(void)
{ {
// Clean up after yourself! // Clean up after yourself!
dsyslog("[softhddev]%s:\n", __FUNCTION__); dsyslog("[softhddev]%s:\n", __FUNCTION__);
::SoftHdDeviceExit();
} }
const char *cPluginSoftHdDevice::Version(void) const char *cPluginSoftHdDevice::Version(void)