From 33996776d4863dc205935fb1273e496e48c199f8 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 24 Jun 2012 00:14:55 +0200 Subject: [PATCH] azbox: fix cVideo::ShowPicture Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/2e05d5fd6f5fa35262cc02cde1368c9e8ebd2282 Author: Stefan Seyfried Date: 2012-06-24 (Sun, 24 Jun 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- azbox/video.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/azbox/video.cpp b/azbox/video.cpp index da46b55..a4aa2b3 100644 --- a/azbox/video.cpp +++ b/azbox/video.cpp @@ -335,7 +335,7 @@ void cVideo::SetVideoMode(analog_mode_t mode) void cVideo::ShowPicture(const char * fname) { lt_debug("%s(%s)\n", __func__, fname); - static const unsigned char pes_header[] = { 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x80, 0x00, 0x00 }; + static const unsigned char pes_header[] = { 0, 0, 1, 0xE0, 0, 0, 0x80, 0x80, 5, 0x21, 0, 1, 0, 1}; static const unsigned char seq_end[] = { 0x00, 0x00, 0x01, 0xB7 }; char destname[512]; char cmd[512]; @@ -395,6 +395,7 @@ void cVideo::ShowPicture(const char * fname) lt_info("%s: VIDEO_SET_FORMAT failed (%m)\n", __func__); bool seq_end_avail = false; size_t pos=0; + int count = 7; unsigned char *iframe = (unsigned char *)malloc((st.st_size < 8192) ? 8192 : st.st_size); if (! iframe) { @@ -402,20 +403,30 @@ void cVideo::ShowPicture(const char * fname) goto out; } read(mfd, iframe, st.st_size); + ioctl(fd, VIDEO_SET_STREAMTYPE, VIDEO_FORMAT_MPEG2); ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY); ioctl(fd, VIDEO_PLAY); ioctl(fd, VIDEO_CONTINUE); ioctl(fd, VIDEO_CLEAR_BUFFER); while (pos <= (st.st_size-4) && !(seq_end_avail = (!iframe[pos] && !iframe[pos+1] && iframe[pos+2] == 1 && iframe[pos+3] == 0xB7))) ++pos; - - if ((iframe[3] >> 4) != 0xE) // no pes header - write(fd, pes_header, sizeof(pes_header)); - write(fd, iframe, st.st_size); + while (count--) + { + if ((iframe[3] >> 4) != 0xE) // no pes header + { + write(fd, pes_header, sizeof(pes_header)); + usleep(8000); + } + else + iframe[4] = iframe[5] = 0x00; + write(fd, iframe, st.st_size); + usleep(8000); + } if (!seq_end_avail) write(fd, seq_end, sizeof(seq_end)); memset(iframe, 0, 8192); write(fd, iframe, 8192); + ioctl(fd, VIDEO_STOP, 0); ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX); free(iframe); }