diff options
-rw-r--r-- | src/demuxers/Makefile.am | 17 | ||||
-rw-r--r-- | src/demuxers/demux_film.c | 76 | ||||
-rw-r--r-- | src/demuxers/demux_qt.c | 112 |
3 files changed, 116 insertions, 89 deletions
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am index 0cabddebd..4c84651ca 100644 --- a/src/demuxers/Makefile.am +++ b/src/demuxers/Makefile.am @@ -34,9 +34,10 @@ endif # xineplug_dmx_vqa.la xineplug_dmx_voc.la \ # xineplug_dmx_aiff.la xineplug_dmx_snd.la -lib_LTLIBRARIES = $(ogg_module) $(asf_module) xineplug_dmx_avi.la\ +lib_LTLIBRARIES = $(ogg_module) $(asf_module) $(qt_modules) xineplug_dmx_avi.la\ xineplug_dmx_mpeg_block.la xineplug_dmx_mpeg.la \ - xineplug_dmx_mpeg_elem.la xineplug_dmx_mpeg_audio.la + xineplug_dmx_mpeg_elem.la xineplug_dmx_mpeg_audio.la \ + xineplug_dmx_film.la xineplug_dmx_ogg_la_SOURCES = demux_ogg.c xineplug_dmx_ogg_la_LIBADD = $(OGG_LIBS) $(VORBIS_LIBS)\ @@ -71,9 +72,9 @@ xineplug_dmx_mpeg_elem_la_LDFLAGS = -avoid-version -module #xineplug_dmx_mpeg_ts_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la #xineplug_dmx_mpeg_ts_la_LDFLAGS = -avoid-version -module -#xineplug_dmx_qt_la_SOURCES = demux_qt.c qtpalette.h -#xineplug_dmx_qt_la_LDFLAGS = -avoid-version -module -#xineplug_dmx_qt_la_LIBADD = -lz $(top_builddir)/src/xine-engine/libxine.la +xineplug_dmx_qt_la_SOURCES = demux_qt.c qtpalette.h +xineplug_dmx_qt_la_LDFLAGS = -avoid-version -module +xineplug_dmx_qt_la_LIBADD = -lz $(top_builddir)/src/xine-engine/libxine.la xineplug_dmx_asf_la_SOURCES = demux_asf.c xineplug_dmx_asf_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la @@ -83,9 +84,9 @@ xineplug_dmx_asf_la_LDFLAGS = -avoid-version -module #xineplug_dmx_cda_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la #xineplug_dmx_cda_la_LDFLAGS = -avoid-version -module -#xineplug_dmx_film_la_SOURCES = demux_film.c -#xineplug_dmx_film_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la -#xineplug_dmx_film_la_LDFLAGS = -avoid-version -module +xineplug_dmx_film_la_SOURCES = demux_film.c +xineplug_dmx_film_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la +xineplug_dmx_film_la_LDFLAGS = -avoid-version -module #xineplug_dmx_roq_la_SOURCES = demux_roq.c #xineplug_dmx_roq_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c index 79eebcc33..ed13347fa 100644 --- a/src/demuxers/demux_film.c +++ b/src/demuxers/demux_film.c @@ -21,7 +21,7 @@ * For more information on the FILM file format, visit: * http://www.pcisys.net/~melanson/codecs/ * - * $Id: demux_film.c,v 1.25 2002/09/10 15:07:14 mroi Exp $ + * $Id: demux_film.c,v 1.26 2002/09/21 17:22:21 tmmm Exp $ */ #ifdef HAVE_CONFIG_H @@ -111,9 +111,11 @@ typedef struct { int total_time; } demux_film_t ; -/* returns 1 if FILM file was opened successfully */ -static int open_film_file(demux_film_t *film) -{ +/* Open a FILM file + * This function is called from the _open() function of this demuxer. + * It returns 1 if FILM file was opened successfully. */ +static int open_film_file(demux_film_t *film) { + unsigned char *film_header; unsigned int film_header_size; unsigned char scratch[16]; @@ -138,15 +140,10 @@ static int open_film_file(demux_film_t *film) /* reset the file */ film->input->seek(film->input, 0, SEEK_SET); - /* get the signature, header length and file version */ + /* get the header length and file version */ if (film->input->read(film->input, scratch, 16) != 16) { return 0; } - if (BE_32(&scratch[0]) != FILM_TAG) { - xine_log(film->xine, XINE_LOG_FORMAT, - _("demux_film: This is not a FILM file (why was it sent to this demuxer?\n")); - return 0; - } /* header size = header size - 16-byte FILM signature */ film_header_size = BE_32(&scratch[4]) - 16; @@ -172,7 +169,7 @@ static int open_film_file(demux_film_t *film) /* sanity check the chunk size */ if (i + chunk_size > film_header_size) { - xine_log(film->xine, XINE_LOG_FORMAT, + xine_log(film->xine, XINE_LOG_MSG, _("invalid FILM chunk size\n")); return 0; } @@ -250,7 +247,7 @@ static int open_film_file(demux_film_t *film) break; default: - xine_log(film->xine, XINE_LOG_FORMAT, + xine_log(film->xine, XINE_LOG_MSG, _("unrecognized FILM chunk\n")); return 0; } @@ -487,6 +484,25 @@ static void *demux_film_loop (void *this_gen) { return NULL; } +static int demux_film_send_headers(demux_film_t *this) { + + pthread_mutex_lock(&this->mutex); + + this->video_fifo = this->xine->video_fifo; + this->audio_fifo = this->xine->audio_fifo; + + this->status = DEMUX_OK; + + this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = this->bih.biWidth; + this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = this->bih.biHeight; + + xine_demux_control_headers_done (this->xine); + + pthread_mutex_unlock (&this->mutex); + + return DEMUX_CAN_HANDLE; +} + static int demux_film_open(demux_plugin_t *this_gen, input_plugin_t *input, int stage) { @@ -505,7 +521,8 @@ static int demux_film_open(demux_plugin_t *this_gen, input_plugin_t *input, return DEMUX_CANNOT_HANDLE; } if (strncmp(sig, "FILM", 4) == 0) - return DEMUX_CAN_HANDLE; + if (open_film_file(this)) + return demux_film_send_headers(this); return DEMUX_CANNOT_HANDLE; } @@ -532,10 +549,9 @@ static int demux_film_open(demux_plugin_t *this_gen, input_plugin_t *input, while(*m == ' ' || *m == '\t') m++; - if(!strcasecmp((suffix + 1), m)) { - this->input = input; - return DEMUX_CAN_HANDLE; - } + if(!strcasecmp((suffix + 1), m)) + if (open_film_file(this)) + return demux_film_send_headers(this); } return DEMUX_CANNOT_HANDLE; } @@ -551,8 +567,6 @@ static int demux_film_open(demux_plugin_t *this_gen, input_plugin_t *input, } static int demux_film_start (demux_plugin_t *this_gen, - fifo_buffer_t *video_fifo, - fifo_buffer_t *audio_fifo, off_t start_pos, int start_time) { demux_film_t *this = (demux_film_t *) this_gen; @@ -563,17 +577,9 @@ static int demux_film_start (demux_plugin_t *this_gen, /* if thread is not running, initialize demuxer */ if (!this->thread_running) { - this->video_fifo = video_fifo; - this->audio_fifo = audio_fifo; - - /* open the FILM file */ - if (!open_film_file(this)) { - pthread_mutex_unlock(&this->mutex); - return DEMUX_FINISHED; - } /* print vital stats */ - xine_log (this->xine, XINE_LOG_FORMAT, + xine_log (this->xine, XINE_LOG_MSG, _("demux_film: FILM version %c%c%c%c, running time: %d min, %d sec\n"), this->version[0], this->version[1], @@ -582,7 +588,7 @@ static int demux_film_start (demux_plugin_t *this_gen, this->total_time / 60, this->total_time % 60); if (this->video_type) - xine_log (this->xine, XINE_LOG_FORMAT, + xine_log (this->xine, XINE_LOG_MSG, _("demux_film: %c%c%c%c video @ %dx%d, %d Hz playback clock\n"), (this->video_codec >> 24) & 0xFF, (this->video_codec >> 16) & 0xFF, @@ -592,7 +598,7 @@ static int demux_film_start (demux_plugin_t *this_gen, this->bih.biHeight, this->frequency); else { - xine_log (this->xine, XINE_LOG_FORMAT, + xine_log (this->xine, XINE_LOG_MSG, _("demux_film: unknown video codec %c%c%c%c\n"), (this->video_codec >> 24) & 0xFF, (this->video_codec >> 16) & 0xFF, @@ -602,7 +608,7 @@ static int demux_film_start (demux_plugin_t *this_gen, return DEMUX_FINISHED; } if (this->audio_type) - xine_log (this->xine, XINE_LOG_FORMAT, + xine_log (this->xine, XINE_LOG_MSG, _("demux_film: %d Hz, %d-bit %s%s PCM audio\n"), this->sample_rate, this->audio_bits, @@ -643,7 +649,7 @@ static int demux_film_start (demux_plugin_t *this_gen, this->thread_running = 1; this->current_sample = 0; - this->last_sample = 0; + this->last_sample = 0xFFFFFFFE; if ((err = pthread_create (&this->thread, NULL, demux_film_loop, this)) != 0) { printf ("demux_film: can't create new thread (%s)\n", strerror(err)); @@ -753,7 +759,7 @@ static void demux_film_stop (demux_plugin_t *this_gen) { xine_demux_control_end(this->xine, BUF_FLAG_END_USER); } -static void demux_film_close (demux_plugin_t *this_gen) { +static void demux_film_dispose (demux_plugin_t *this_gen) { demux_film_t *this = (demux_film_t *) this_gen; pthread_mutex_destroy (&this->mutex); @@ -800,7 +806,7 @@ static void *init_demuxer_plugin(xine_t *xine, void* data) { this->demux_plugin.start = demux_film_start; this->demux_plugin.seek = demux_film_seek; this->demux_plugin.stop = demux_film_stop; - this->demux_plugin.close = demux_film_close; + this->demux_plugin.dispose = demux_film_dispose; this->demux_plugin.get_status = demux_film_get_status; this->demux_plugin.get_identifier = demux_film_get_id; this->demux_plugin.get_stream_length = demux_film_get_stream_length; @@ -818,6 +824,6 @@ static void *init_demuxer_plugin(xine_t *xine, void* data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_DEMUX, 10, "film", XINE_VERSION_CODE, NULL, init_demuxer_plugin }, + { PLUGIN_DEMUX, 11, "film", XINE_VERSION_CODE, NULL, init_demuxer_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c index d0849581c..5eaec8f15 100644 --- a/src/demuxers/demux_qt.c +++ b/src/demuxers/demux_qt.c @@ -30,7 +30,7 @@ * build_frame_table * free_qt_info * - * $Id: demux_qt.c,v 1.82 2002/09/05 22:18:52 mroi Exp $ + * $Id: demux_qt.c,v 1.83 2002/09/21 17:22:21 tmmm Exp $ * */ @@ -1414,6 +1414,59 @@ static void *demux_qt_loop (void *this_gen) { return NULL; } +static int demux_qt_send_headers (demux_qt_t *this) { + + pthread_mutex_lock (&this->mutex); + + this->video_fifo = this->xine->video_fifo; + this->audio_fifo = this->xine->audio_fifo; + + this->status = DEMUX_OK; + + /* create the QT structure */ + if ((this->qt = create_qt_info()) == NULL) { + pthread_mutex_unlock(&this->mutex); + this->status = DEMUX_FINISHED; + return DEMUX_CANNOT_HANDLE; + } + + /* open the QT file */ + if (open_qt_file(this->qt, this->input) != QT_OK) { + pthread_mutex_unlock(&this->mutex); + this->status = DEMUX_FINISHED; + return DEMUX_CANNOT_HANDLE; + } + + this->bih.biWidth = this->qt->video_width; + this->bih.biHeight = this->qt->video_height; + + this->bih.biCompression = this->qt->video_codec; + this->qt->video_type = fourcc_to_buf_video(this->bih.biCompression); + + /* hack: workaround a fourcc clash! 'mpg4' is used by MS and Sorenson + * mpeg4 codecs (they are not compatible). + */ + if( this->qt->video_type == BUF_VIDEO_MSMPEG4_V1 ) + this->qt->video_type = BUF_VIDEO_MPEG4; + + if( !this->qt->video_type ) + xine_report_codec( this->xine, XINE_CODEC_VIDEO, this->bih.biCompression, 0, 0); + + this->qt->audio_type = formattag_to_buf_audio(this->qt->audio_codec); + + if( !this->qt->audio_type && this->qt->audio_codec ) + xine_report_codec( this->xine, XINE_CODEC_AUDIO, this->qt->audio_codec, 0, 0); + + this->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = this->bih.biWidth; + this->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = this->bih.biHeight; + + xine_demux_control_headers_done (this->xine); + + pthread_mutex_unlock (&this->mutex); + + return DEMUX_CAN_HANDLE; +} + static int demux_qt_open(demux_plugin_t *this_gen, input_plugin_t *input, int stage) { @@ -1426,7 +1479,10 @@ static int demux_qt_open(demux_plugin_t *this_gen, if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) == 0) return DEMUX_CANNOT_HANDLE; - return is_qt_file(input); + if (is_qt_file(input)) + return demux_qt_send_headers(this); + + return DEMUX_CANNOT_HANDLE; } break; @@ -1451,8 +1507,8 @@ static int demux_qt_open(demux_plugin_t *this_gen, while(*m == ' ' || *m == '\t') m++; if(!strcasecmp((suffix + 1), m)) { - this->input = input; - return DEMUX_CAN_HANDLE; + if (is_qt_file(input)) + return demux_qt_send_headers(this); } } return DEMUX_CANNOT_HANDLE; @@ -1469,8 +1525,6 @@ static int demux_qt_open(demux_plugin_t *this_gen, } static int demux_qt_start (demux_plugin_t *this_gen, - fifo_buffer_t *video_fifo, - fifo_buffer_t *audio_fifo, off_t start_pos, int start_time) { demux_qt_t *this = (demux_qt_t *) this_gen; buf_element_t *buf; @@ -1480,50 +1534,16 @@ static int demux_qt_start (demux_plugin_t *this_gen, /* if thread is not running, initialize demuxer */ if (!this->thread_running) { - this->video_fifo = video_fifo; - this->audio_fifo = audio_fifo; this->waiting_for_keyframe = 0; - /* create the QT structure */ - if ((this->qt = create_qt_info()) == NULL) { - pthread_mutex_unlock(&this->mutex); - return DEMUX_FINISHED; - } - - /* open the QT file */ - if (open_qt_file(this->qt, this->input) != QT_OK) { - pthread_mutex_unlock(&this->mutex); - return DEMUX_FINISHED; - } - - this->bih.biWidth = this->qt->video_width; - this->bih.biHeight = this->qt->video_height; - - this->bih.biCompression = this->qt->video_codec; - this->qt->video_type = fourcc_to_buf_video(this->bih.biCompression); - - /* hack: workaround a fourcc clash! 'mpg4' is used by MS and Sorenson - * mpeg4 codecs (they are not compatible). - */ - if( this->qt->video_type == BUF_VIDEO_MSMPEG4_V1 ) - this->qt->video_type = BUF_VIDEO_MPEG4; - - if( !this->qt->video_type ) - xine_report_codec( this->xine, XINE_CODEC_VIDEO, this->bih.biCompression, 0, 0); - - this->qt->audio_type = formattag_to_buf_audio(this->qt->audio_codec); - - if( !this->qt->audio_type && this->qt->audio_codec ) - xine_report_codec( this->xine, XINE_CODEC_AUDIO, this->qt->audio_codec, 0, 0); - /* print vital stats */ - xine_log (this->xine, XINE_LOG_FORMAT, + xine_log (this->xine, XINE_LOG_MSG, _("demux_qt: Apple Quicktime file, %srunning time: %d min, %d sec\n"), (this->qt->compressed_header) ? "compressed header, " : "", this->qt->duration / this->qt->time_scale / 60, this->qt->duration / this->qt->time_scale % 60); if (this->qt->video_codec) - xine_log (this->xine, XINE_LOG_FORMAT, + xine_log (this->xine, XINE_LOG_MSG, _("demux_qt: '%c%c%c%c' video @ %dx%d\n"), *((char *)&this->qt->video_codec + 0), *((char *)&this->qt->video_codec + 1), @@ -1532,7 +1552,7 @@ static int demux_qt_start (demux_plugin_t *this_gen, this->bih.biWidth, this->bih.biHeight); if (this->qt->audio_codec) - xine_log (this->xine, XINE_LOG_FORMAT, + xine_log (this->xine, XINE_LOG_MSG, _("demux_qt: '%c%c%c%c' audio @ %d Hz, %d bits, %d %s\n"), *((char *)&this->qt->audio_codec + 0), *((char *)&this->qt->audio_codec + 1), @@ -1719,7 +1739,7 @@ static void demux_qt_stop (demux_plugin_t *this_gen) { xine_demux_control_end(this->xine, BUF_FLAG_END_USER); } -static void demux_qt_close (demux_plugin_t *this_gen) { +static void demux_qt_dispose (demux_plugin_t *this_gen) { demux_qt_t *this = (demux_qt_t *) this_gen; free_qt_info(this->qt); @@ -1767,7 +1787,7 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) { this->demux_plugin.start = demux_qt_start; this->demux_plugin.seek = demux_qt_seek; this->demux_plugin.stop = demux_qt_stop; - this->demux_plugin.close = demux_qt_close; + this->demux_plugin.dispose = demux_qt_dispose; this->demux_plugin.get_status = demux_qt_get_status; this->demux_plugin.get_identifier = demux_qt_get_id; this->demux_plugin.get_stream_length = demux_qt_get_stream_length; @@ -1785,6 +1805,6 @@ static void *init_demuxer_plugin (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_DEMUX, 10, "mov", XINE_VERSION_CODE, NULL, init_demuxer_plugin }, + { PLUGIN_DEMUX, 11, "mov", XINE_VERSION_CODE, NULL, init_demuxer_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |