diff options
Diffstat (limited to 'src/libffmpeg/xine_decoder.c')
-rw-r--r-- | src/libffmpeg/xine_decoder.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/libffmpeg/xine_decoder.c b/src/libffmpeg/xine_decoder.c index 9ddbf2a7b..9b2b5c836 100644 --- a/src/libffmpeg/xine_decoder.c +++ b/src/libffmpeg/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.72 2002/11/20 11:57:43 mroi Exp $ + * $Id: xine_decoder.c,v 1.73 2002/12/02 22:00:14 miguelfreitas Exp $ * * xine decoder plugin using ffmpeg * @@ -38,6 +38,7 @@ #include "buffer.h" #include "metronom.h" #include "xineutils.h" +#include "math.h" #include "libavcodec/avcodec.h" #include "libavcodec/dsputil.h" @@ -50,7 +51,6 @@ typedef struct { video_decoder_class_t decoder_class; - int illegal_vlc; } ff_video_class_t; typedef struct ff_decoder_s { @@ -124,6 +124,7 @@ static void init_video_codec (ff_video_decoder_t *this, AVCodec *codec) { this->context = avcodec_alloc_context(); this->context->width = this->bih.biWidth; this->context->height = this->bih.biHeight; + this->context->fourcc = this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC]; if (avcodec_open (this->context, codec) < 0) { printf ("ffmpeg: couldn't open decoder\n"); @@ -134,14 +135,6 @@ static void init_video_codec (ff_video_decoder_t *this, AVCodec *codec) { this->decoder_ok = 1; this->stream->video_out->open (this->stream->video_out, this->stream); - /* needed to play streams generated by MS ISO MPEG4 codec. - Michael Niedermayer explained: - M$ "ISO MPEG4" uses illegal vlc code combinations, a ISO MPEG4 compliant - decoder which support error resilience should handle them like errors. - */ - if (this->class->illegal_vlc) - this->context->error_resilience=-1; - if (this->buf) free (this->buf); @@ -309,6 +302,7 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { if (buf->decoder_flags & BUF_FLAG_HEADER) { AVCodec *codec = NULL; + xine_bmiheader *bih; int codec_type; #ifdef LOG @@ -317,7 +311,8 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { /* init package containing bih */ - memcpy ( &this->bih, buf->content, sizeof (xine_bmiheader)); + bih = (xine_bmiheader *)buf->content; + memcpy ( &this->bih, bih, sizeof (xine_bmiheader)); this->video_step = buf->decoder_info[1]; this->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = this->bih.biWidth; @@ -405,6 +400,14 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { } init_video_codec (this, codec); + + if( bih->biSize > sizeof(xine_bmiheader) ) { + this->context->extradata_size = bih->biSize - sizeof(xine_bmiheader); + this->context->extradata = malloc(this->context->extradata_size); + memcpy( this->context->extradata, + (uint8_t *)bih + sizeof(xine_bmiheader), + this->context->extradata_size ); + } } else if (this->decoder_ok) { @@ -634,6 +637,7 @@ void avcodec_register_all(void) register_avcodec(&dvvideo_decoder); // register_avcodec(&dvaudio_decoder); register_avcodec(&mjpeg_decoder); + register_avcodec(&mjpegb_decoder); register_avcodec(&wmav1_decoder); register_avcodec(&wmav2_decoder); @@ -653,6 +657,9 @@ static void ff_dispose (video_decoder_t *this_gen) { this->decoder_ok = 0; } + if(this->context && this->context->extradata) + free(this->context->extradata); + if( this->context ) free( this->context ); @@ -730,10 +737,6 @@ static void *init_video_plugin (xine_t *xine, void *data) { this->decoder_class.get_description = ff_video_get_description; this->decoder_class.dispose = ff_video_dispose_class; - this->illegal_vlc = xine->config->register_bool (xine->config, "codec.ffmpeg_illegal_vlc", 1, - _("allow illegal vlc codes in mpeg4 streams"), NULL, - 10, NULL, NULL); - pthread_once( &once_control, init_once_routine ); return this; @@ -784,6 +787,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) this->context->block_align = audio_header->nBlockAlign; this->context->bit_rate = audio_header->nAvgBytesPerSec * 8; this->context->codec_id = codec->id; + this->context->fourcc = this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC]; if( audio_header->cbSize > 0 ) { this->context->extradata = malloc(audio_header->cbSize); this->context->extradata_size = audio_header->cbSize; @@ -981,7 +985,7 @@ static uint32_t supported_video_types[] = { BUF_VIDEO_MSMPEG4_V2, BUF_VIDEO_MSMPEG4_V3, BUF_VIDEO_WMV7, - /*BUF_VIDEO_WMV8,*/ + /*BUF_VIDEO_WMV8,*/ BUF_VIDEO_MPEG4, BUF_VIDEO_XVID, BUF_VIDEO_DIVX5, |