Fix bug: mpeg stills not displayed.

This commit is contained in:
Johns 2012-02-12 16:57:32 +01:00
parent 616cd9e133
commit 6df970ca9e
2 changed files with 38 additions and 19 deletions

View File

@ -1,6 +1,7 @@
User johns User johns
Date: Date:
Fix bug: mpeg stills not displayed.
Detect audio stream type only after stream switch. Detect audio stream type only after stream switch.
Detect more h264 streams with leading zeros. Detect more h264 streams with leading zeros.
VDPAU: support for studio levels added. VDPAU: support for studio levels added.

View File

@ -485,6 +485,7 @@ static void VideoEnqueue(int64_t pts, const void *data, int size)
// new + grow reserves FF_INPUT_BUFFER_PADDING_SIZE // new + grow reserves FF_INPUT_BUFFER_PADDING_SIZE
av_grow_packet(avpkt, ((size + VIDEO_BUFFER_SIZE / 2) av_grow_packet(avpkt, ((size + VIDEO_BUFFER_SIZE / 2)
/ (VIDEO_BUFFER_SIZE / 2)) * (VIDEO_BUFFER_SIZE / 2)); / (VIDEO_BUFFER_SIZE / 2)) * (VIDEO_BUFFER_SIZE / 2));
// FIXME: out of memory!
#ifdef DEBUG #ifdef DEBUG
if (avpkt->size <= avpkt->stream_index + size) { if (avpkt->size <= avpkt->stream_index + size) {
fprintf(stderr, "%d %d %d\n", avpkt->size, avpkt->stream_index, fprintf(stderr, "%d %d %d\n", avpkt->size, avpkt->stream_index,
@ -1166,6 +1167,9 @@ void Freeze(void)
/** /**
** Display the given I-frame as a still picture. ** Display the given I-frame as a still picture.
**
** @param data pes frame data
** @param size number of bytes in frame
*/ */
void StillPicture(const uint8_t * data, int size) void StillPicture(const uint8_t * data, int size)
{ {
@ -1178,10 +1182,10 @@ void StillPicture(const uint8_t * data, int size)
Error(_("[softhddev] invalid still video packet\n")); Error(_("[softhddev] invalid still video packet\n"));
return; return;
} }
if (VideoCodecID == CODEC_ID_NONE) { if (VideoCodecID == CODEC_ID_NONE) {
// FIXME: should detect codec, see PlayVideo // FIXME: should detect codec, see PlayVideo
Error(_("[softhddev] no codec known for still picture\n")); Error(_("[softhddev] no codec known for still picture\n"));
return;
} }
//Clear(); // flush video buffers //Clear(); // flush video buffers
@ -1191,28 +1195,42 @@ void StillPicture(const uint8_t * data, int size)
const uint8_t *split; const uint8_t *split;
int n; int n;
// split the I-frame into single pes packets if ((data[3] & 0xF0) == 0xE0) { // PES packet
split = data; split = data;
n = size; n = size;
do { // split the I-frame into single pes packets
int len; do {
int len;
len = (split[4] << 8) + split[5]; len = (split[4] << 8) + split[5];
if (len > n) { if (!len || len + 6 > n) {
break; PlayVideo(split, n); // feed remaining bytes
break;
}
PlayVideo(split, len + 6); // feed it
split += 6 + len;
n -= 6 + len;
} while (n > 6);
VideoNextPacket(VideoCodecID); // terminate last packet
if (VideoCodecID == CODEC_ID_H264) {
VideoEnqueue(AV_NOPTS_VALUE, seq_end_h264,
sizeof(seq_end_h264));
} else {
VideoEnqueue(AV_NOPTS_VALUE, seq_end_mpeg,
sizeof(seq_end_mpeg));
} }
PlayVideo(split, len + 6); // feed it VideoNextPacket(VideoCodecID); // terminate last packet
split += 6 + len; } else { // ES packet
n -= 6 + len;
} while (n > 6);
VideoNextPacket(VideoCodecID); // terminate last packet
if (VideoCodecID == CODEC_ID_H264) { if (VideoCodecID != CODEC_ID_MPEG2VIDEO) {
VideoEnqueue(AV_NOPTS_VALUE, seq_end_h264, sizeof(seq_end_h264)); VideoNextPacket(CODEC_ID_NONE); // close last stream
} else { VideoCodecID = CODEC_ID_MPEG2VIDEO;
}
VideoEnqueue(AV_NOPTS_VALUE, data, size);
VideoEnqueue(AV_NOPTS_VALUE, seq_end_mpeg, sizeof(seq_end_mpeg)); VideoEnqueue(AV_NOPTS_VALUE, seq_end_mpeg, sizeof(seq_end_mpeg));
VideoNextPacket(VideoCodecID); // terminate last packet
} }
VideoNextPacket(VideoCodecID); // terminate last packet
} }
} }
@ -1497,7 +1515,7 @@ void SoftHdDeviceExit(void)
StopVideo(); StopVideo();
CodecExit(); CodecExit();
VideoPacketExit(); //VideoPacketExit();
if (ConfigStartX11Server) { if (ConfigStartX11Server) {
Debug(3, "x-setup: Stop x11 server\n"); Debug(3, "x-setup: Stop x11 server\n");