1 --- src/arch/MovieTexture/MovieTexture_FFMpeg.cpp.ori 2005-12-29 16:54:24.744730500 +0100
2 +++ src/arch/MovieTexture/MovieTexture_FFMpeg.cpp 2005-12-29 16:56:23.100127250 +0100
4 if ( GetNextTimestamp )
6 if (pkt.dts != int64_t(AV_NOPTS_VALUE))
7 +#if (LIBAVCODEC_BUILD >= 4754)
8 + pts = (float)pkt.dts * m_stream->time_base.num / m_stream->time_base.den;
10 pts = (float)pkt.dts / AV_TIME_BASE;
14 GetNextTimestamp = false;
16 * to give it a buffer to read from since it tries to read anyway. */
17 static uint8_t dummy[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
18 int len = avcodec::avcodec_decode_video(
19 +#if (LIBAVCODEC_BUILD >= 4754)
25 pkt.size? pkt.data:dummy, pkt.size );
30 /* Length of this frame: */
31 +#if (LIBAVCODEC_BUILD >= 4754)
32 + LastFrameDelay = (float)m_stream->codec->time_base.num / m_stream->codec->time_base.den;
34 LastFrameDelay = (float)m_stream->codec.frame_rate_base / m_stream->codec.frame_rate;
36 LastFrameDelay += frame.repeat_pict * (LastFrameDelay * 0.5f);
40 pict.data[0] = (unsigned char *)m_img->pixels;
41 pict.linesize[0] = m_img->pitch;
43 +#if (LIBAVCODEC_BUILD >= 4754)
44 + avcodec::img_convert(&pict, AVPixelFormats[m_AVTexfmt].pf,
45 + (avcodec::AVPicture *) &decoder->frame, decoder->m_stream->codec->pix_fmt,
46 + decoder->m_stream->codec->width, decoder->m_stream->codec->height);
48 avcodec::img_convert(&pict, AVPixelFormats[m_AVTexfmt].pf,
49 (avcodec::AVPicture *) &decoder->frame, decoder->m_stream->codec.pix_fmt,
50 decoder->m_stream->codec.width, decoder->m_stream->codec.height);
53 m_ImageWaiting = FRAME_WAITING;
56 for( int stream = 0; stream < m_fctx->nb_streams; ++stream )
58 avcodec::AVStream *enc = m_fctx->streams[stream];
59 +#if (LIBAVCODEC_BUILD >= 4754)
60 + if( enc->codec->codec_type == avcodec::CODEC_TYPE_VIDEO )
63 if( enc->codec.codec_type == avcodec::CODEC_TYPE_VIDEO )
70 m_bThreaded = PREFSMAN->m_bThreadedMovieDecode;
73 +#if (LIBAVCODEC_BUILD >= 4754)
74 + LOG->Trace("Bitrate: %i", decoder->m_stream->codec->bit_rate );
75 + LOG->Trace("Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(decoder->m_stream->codec->pix_fmt) );
77 LOG->Trace("Bitrate: %i", decoder->m_stream->codec.bit_rate );
78 LOG->Trace("Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(decoder->m_stream->codec.pix_fmt) );
81 /* Decode one frame, to guarantee that the texture is drawn when this function returns. */
82 int ret = decoder->GetFrame();
85 RageException::Throw( "AVCodec (%s): Couldn't find any video streams", GetID().filename.c_str() );
87 +#if (LIBAVCODEC_BUILD >= 4754)
88 + if( stream->codec->codec_id == avcodec::CODEC_ID_NONE )
89 + RageException::ThrowNonfatal( "AVCodec (%s): Unsupported codec %08x", GetID().filename.c_str(), stream->codec->codec_tag );
91 + avcodec::AVCodec *codec = avcodec::avcodec_find_decoder( stream->codec->codec_id );
93 + RageException::Throw( "AVCodec (%s): Couldn't find decoder %i", GetID().filename.c_str(), stream->codec->codec_id );
95 + LOG->Trace("Opening codec %s", codec->name );
96 + ret = avcodec::avcodec_open( stream->codec, codec );
98 if( stream->codec.codec_id == avcodec::CODEC_ID_NONE )
99 RageException::ThrowNonfatal( "AVCodec (%s): Unsupported codec %08x", GetID().filename.c_str(), stream->codec.codec_tag );
103 LOG->Trace("Opening codec %s", codec->name );
104 ret = avcodec::avcodec_open( &stream->codec, codec );
107 RageException::Throw( averr_ssprintf(ret, "AVCodec (%s): Couldn't open codec \"%s\"", GetID().filename.c_str(), codec->name) );
111 if( decoder->m_stream )
113 +#if (LIBAVCODEC_BUILD >= 4754)
114 + avcodec::avcodec_close( decoder->m_stream->codec );
116 avcodec::avcodec_close( &decoder->m_stream->codec );
118 decoder->m_stream = NULL;
122 /* Cap the max texture size to the hardware max. */
123 actualID.iMaxSize = min( actualID.iMaxSize, DISPLAY->GetMaxTextureSize() );
125 +#if (LIBAVCODEC_BUILD >= 4754)
126 + m_iSourceWidth = decoder->m_stream->codec->width;
127 + m_iSourceHeight = decoder->m_stream->codec->height;
129 m_iSourceWidth = decoder->m_stream->codec.width;
130 m_iSourceHeight = decoder->m_stream->codec.height;
133 /* image size cannot exceed max size */
134 m_iImageWidth = min( m_iSourceWidth, actualID.iMaxSize );
136 m_FrameSkipMode = true;
139 +#if (LIBAVCODEC_BUILD >= 4754)
140 + if( m_FrameSkipMode && decoder->m_stream->codec->frame_number % 2 )
142 if( m_FrameSkipMode && decoder->m_stream->codec.frame_number % 2 )
144 return -1; /* skip */