summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Hintukainen <phintuka@users.sourceforge.net>2009-11-17 13:17:25 +0000
committerPetri Hintukainen <phintuka@users.sourceforge.net>2009-11-17 13:17:25 +0000
commit1c0d093f3bfd5861550d9fbb23a998b0204b9bed (patch)
tree5f8909ca1fc3ba55d8e18b35d69e446132680527
parent1274b6893595f44a6b0b7d4c90527bc1b717c629 (diff)
downloadxine-lib-1c0d093f3bfd5861550d9fbb23a998b0204b9bed.tar.gz
xine-lib-1c0d093f3bfd5861550d9fbb23a998b0204b9bed.tar.bz2
VC1 support fixes
There are two tricks to make VC1 decoding work: 1) VC1 sequence and entry point headers must be present in context->extradata. 2) video width and height must be known when opening decoder. Some container formats store required extra data, but mpeg-ts does not. 1) is fixed by scanning the stream for headers and discarding all data until proper headers are found. 2) is fixed by re-opening decoder with width and height information from first open.
-rw-r--r--ChangeLog1
-rw-r--r--src/combined/ffmpeg/ff_video_decoder.c62
2 files changed, 63 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f8ba8a1e5..3f37ddd20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,7 @@ xine-lib (1.1.17) 2009-??-??
* The XML parser & lexer code now has re-entrancy.
* Fixed a bug which prevented "dvb://" (no channel specified) working with
the default configuration.
+ * Handle VC1 extradata requirement (should fix playback).
xine-lib (1.1.16.3) 2009-04-03
* Security fixes:
diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c
index 60f2c5d9c..98caac269 100644
--- a/src/combined/ffmpeg/ff_video_decoder.c
+++ b/src/combined/ffmpeg/ff_video_decoder.c
@@ -340,6 +340,22 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type)
return;
}
+ if (this->codec->id == CODEC_ID_VC1 &&
+ (!this->bih.biWidth || !this->bih.biHeight)) {
+ /* VC1 codec must be re-opened with correct width and height. */
+ avcodec_close(this->context);
+
+ if (avcodec_open (this->context, this->codec) < 0) {
+ pthread_mutex_unlock(&ffmpeg_lock);
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+ _("ffmpeg_video_dec: couldn't open decoder (pass 2)\n"));
+ free(this->context);
+ this->context = NULL;
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
+ return;
+ }
+ }
+
if (this->class->thread_count > 1) {
avcodec_thread_init(this->context, this->class->thread_count);
this->context->thread_count = this->class->thread_count;
@@ -1165,6 +1181,49 @@ static void ff_check_pts_tagging(ff_video_decoder_t *this, uint64_t pts)
}
}
+static int ff_vc1_find_header(ff_video_decoder_t *this, buf_element_t *buf)
+{
+ uint8_t *p = buf->content;
+
+ if (!p[0] && !p[1] && p[2] == 1 && p[3] == 0x0f) {
+ int i;
+
+ this->context->extradata = calloc(1, buf->size);
+ this->context->extradata_size = 0;
+
+ for (i = 0; i < buf->size && i < 128; i++) {
+ if (!p[i] && !p[i+1] && p[i+2]) {
+ lprintf("00 00 01 %02x at %d\n", p[i+3], i);
+ if (p[i+3] != 0x0e && p[i+3] != 0x0f)
+ break;
+ }
+ this->context->extradata[i] = p[i];
+ this->context->extradata_size++;
+ }
+
+ lprintf("ff_video_decoder: found VC1 sequence header\n");
+ return 1;
+ }
+
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "ffmpeg_video_dec: VC1 extradata missing !\n");
+ return 0;
+}
+
+static int ff_check_extradata(ff_video_decoder_t *this, unsigned int codec_type, buf_element_t *buf)
+{
+ if (this->context && this->context->extradata)
+ return 1;
+
+ switch (codec_type) {
+ case BUF_VIDEO_VC1:
+ return ff_vc1_find_header(this, buf);
+ default:;
+ }
+
+ return 1;
+}
+
#endif /* AVCODEC_HAS_REORDERED_OPAQUE */
static void ff_handle_buffer (ff_video_decoder_t *this, buf_element_t *buf) {
uint8_t *chunk_buf = this->buf;
@@ -1176,6 +1235,9 @@ static void ff_handle_buffer (ff_video_decoder_t *this, buf_element_t *buf) {
if (this->decoder_init_mode) {
int codec_type = buf->type & 0xFFFF0000;
+ if (!ff_check_extradata(this, codec_type, buf))
+ return;
+
/* init ffmpeg decoder */
init_video_codec(this, codec_type);
init_postprocess(this);