Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 148787 | Differences between
and this patch

Collapse All | Expand All

(-)src/arch/MovieTexture/MovieTexture_FFMpeg.cpp (+53 lines)
Lines 166-173 Link Here
166
166
167
	int GetFrame( RageSurface *pOut, float fTargetTime );
167
	int GetFrame( RageSurface *pOut, float fTargetTime );
168
168
169
#if (LIBAVCODEC_BUILD >= 4754)
170
	int GetWidth() const { return m_pStream->codec->width; }
171
	int GetHeight() const { return m_pStream->codec->height; }
172
#else
169
	int GetWidth() const { return m_pStream->codec.width; }
173
	int GetWidth() const { return m_pStream->codec.width; }
170
	int GetHeight() const { return m_pStream->codec.height; }
174
	int GetHeight() const { return m_pStream->codec.height; }
175
#endif
171
176
172
	RageSurface *CreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor );
177
	RageSurface *CreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor );
173
178
Lines 317-323 Link Here
317
		if( m_bGetNextTimestamp )
322
		if( m_bGetNextTimestamp )
318
		{
323
		{
319
			if (m_Packet.dts != int64_t(AV_NOPTS_VALUE))
324
			if (m_Packet.dts != int64_t(AV_NOPTS_VALUE))
325
#if (LIBAVCODEC_BUILD >= 4754)
326
				m_fPTS = (float)m_Packet.dts * m_pStream->time_base.num / m_pStream->time_base.den;
327
#else
320
				m_fPTS = (float)m_Packet.dts / AV_TIME_BASE;
328
				m_fPTS = (float)m_Packet.dts / AV_TIME_BASE;
329
#endif
321
			else
330
			else
322
				m_fPTS = -1;
331
				m_fPTS = -1;
323
			m_bGetNextTimestamp = false;
332
			m_bGetNextTimestamp = false;
Lines 333-339 Link Here
333
		bool bSkipThisFrame = 
342
		bool bSkipThisFrame = 
334
			fTargetTime != -1 &&
343
			fTargetTime != -1 &&
335
			GetTimestamp() + GetFrameDuration() <= fTargetTime &&
344
			GetTimestamp() + GetFrameDuration() <= fTargetTime &&
345
#if (LIBAVCODEC_BUILD >= 4754)
346
			(m_pStream->codec->frame_number % 2) == 0;
347
#else
336
			(m_pStream->codec.frame_number % 2) == 0;
348
			(m_pStream->codec.frame_number % 2) == 0;
349
#endif
337
350
338
		int iGotFrame;
351
		int iGotFrame;
339
		CHECKPOINT;
352
		CHECKPOINT;
Lines 341-347 Link Here
341
		 * to give it a buffer to read from since it tries to read anyway. */
354
		 * to give it a buffer to read from since it tries to read anyway. */
342
		static uint8_t dummy[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
355
		static uint8_t dummy[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
343
		int len = avcodec::avcodec_decode_video(
356
		int len = avcodec::avcodec_decode_video(
357
#if (LIBAVCODEC_BUILD >= 4754)
358
				m_pStream->codec, 
359
#else
344
				&m_pStream->codec, 
360
				&m_pStream->codec, 
361
#endif
345
				&m_Frame, &iGotFrame,
362
				&m_Frame, &iGotFrame,
346
				m_Packet.size? m_Packet.data:dummy, m_Packet.size );
363
				m_Packet.size? m_Packet.data:dummy, m_Packet.size );
347
		CHECKPOINT;
364
		CHECKPOINT;
Lines 375-381 Link Here
375
		}
392
		}
376
393
377
		/* Length of this frame: */
394
		/* Length of this frame: */
395
#if (LIBAVCODEC_BUILD >= 4754)
396
		m_fLastFrameDelay = (float)m_pStream->codec->time_base.num / m_pStream->codec->time_base.den;
397
#else
378
		m_fLastFrameDelay = (float)m_pStream->codec.frame_rate_base / m_pStream->codec.frame_rate;
398
		m_fLastFrameDelay = (float)m_pStream->codec.frame_rate_base / m_pStream->codec.frame_rate;
399
#endif
379
		m_fLastFrameDelay += m_Frame.repeat_pict * (m_fLastFrameDelay * 0.5f);
400
		m_fLastFrameDelay += m_Frame.repeat_pict * (m_fLastFrameDelay * 0.5f);
380
401
381
		++m_iFrameNumber;
402
		++m_iFrameNumber;
Lines 415-423 Link Here
415
	pict.data[0] = (unsigned char *) pSurface->pixels;
436
	pict.data[0] = (unsigned char *) pSurface->pixels;
416
	pict.linesize[0] = pSurface->pitch;
437
	pict.linesize[0] = pSurface->pitch;
417
438
439
#if (LIBAVCODEC_BUILD >= 4754)
440
	avcodec::img_convert( &pict, m_AVTexfmt,
441
			(avcodec::AVPicture *) &m_Frame, m_pStream->codec->pix_fmt, 
442
			m_pStream->codec->width, m_pStream->codec->height );
443
#else
418
	avcodec::img_convert( &pict, m_AVTexfmt,
444
	avcodec::img_convert( &pict, m_AVTexfmt,
419
			(avcodec::AVPicture *) &m_Frame, m_pStream->codec.pix_fmt, 
445
			(avcodec::AVPicture *) &m_Frame, m_pStream->codec.pix_fmt, 
420
			m_pStream->codec.width, m_pStream->codec.height );
446
			m_pStream->codec.width, m_pStream->codec.height );
447
#endif
421
}
448
}
422
449
423
static avcodec::AVStream *FindVideoStream( avcodec::AVFormatContext *m_fctx )
450
static avcodec::AVStream *FindVideoStream( avcodec::AVFormatContext *m_fctx )
Lines 426-433 Link Here
426
	for( int stream = 0; stream < m_fctx->nb_streams; ++stream )
453
	for( int stream = 0; stream < m_fctx->nb_streams; ++stream )
427
	{
454
	{
428
		avcodec::AVStream *enc = m_fctx->streams[stream];
455
		avcodec::AVStream *enc = m_fctx->streams[stream];
456
#if (LIBAVCODEC_BUILD >= 4754)
457
		if( enc->codec->codec_type == avcodec::CODEC_TYPE_VIDEO )
458
			return enc;
459
#else
429
		if( enc->codec.codec_type == avcodec::CODEC_TYPE_VIDEO )
460
		if( enc->codec.codec_type == avcodec::CODEC_TYPE_VIDEO )
430
			return enc;
461
			return enc;
462
#endif
431
	}
463
	}
432
	return NULL;
464
	return NULL;
433
}
465
}
Lines 550-555 Link Here
550
	if ( stream == NULL )
582
	if ( stream == NULL )
551
		return ssprintf( "AVCodec (%s): Couldn't find any video streams", sFile.c_str() );
583
		return ssprintf( "AVCodec (%s): Couldn't find any video streams", sFile.c_str() );
552
584
585
#if (LIBAVCODEC_BUILD >= 4754)
586
	if( stream->codec->codec_id == avcodec::CODEC_ID_NONE )
587
		return ssprintf( "AVCodec (%s): Unsupported codec %08x", sFile.c_str(), stream->codec->codec_tag );
588
589
	avcodec::AVCodec *codec = avcodec::avcodec_find_decoder( stream->codec->codec_id );
590
	if( codec == NULL )
591
		return ssprintf( "AVCodec (%s): Couldn't find decoder %i", sFile.c_str(), stream->codec->codec_id );
592
593
	LOG->Trace("Opening codec %s", codec->name );
594
	ret = avcodec::avcodec_open( stream->codec, codec );
595
#else
553
	if( stream->codec.codec_id == avcodec::CODEC_ID_NONE )
596
	if( stream->codec.codec_id == avcodec::CODEC_ID_NONE )
554
		return ssprintf( "AVCodec (%s): Unsupported codec %08x", sFile.c_str(), stream->codec.codec_tag );
597
		return ssprintf( "AVCodec (%s): Unsupported codec %08x", sFile.c_str(), stream->codec.codec_tag );
555
598
Lines 559-570 Link Here
559
602
560
	LOG->Trace("Opening codec %s", codec->name );
603
	LOG->Trace("Opening codec %s", codec->name );
561
	ret = avcodec::avcodec_open( &stream->codec, codec );
604
	ret = avcodec::avcodec_open( &stream->codec, codec );
605
#endif
562
	if ( ret < 0 )
606
	if ( ret < 0 )
563
		return ssprintf( averr_ssprintf(ret, "AVCodec (%s): Couldn't open codec \"%s\"", sFile.c_str(), codec->name) );
607
		return ssprintf( averr_ssprintf(ret, "AVCodec (%s): Couldn't open codec \"%s\"", sFile.c_str(), codec->name) );
564
	m_pStream = stream;
608
	m_pStream = stream;
565
609
610
#if (LIBAVCODEC_BUILD >= 4754)
611
	LOG->Trace( "Bitrate: %i", m_pStream->codec->bit_rate );
612
	LOG->Trace( "Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(m_pStream->codec->pix_fmt) );
613
#else
566
	LOG->Trace( "Bitrate: %i", m_pStream->codec.bit_rate );
614
	LOG->Trace( "Bitrate: %i", m_pStream->codec.bit_rate );
567
	LOG->Trace( "Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(m_pStream->codec.pix_fmt) );
615
	LOG->Trace( "Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(m_pStream->codec.pix_fmt) );
616
#endif
568
617
569
	return RString();
618
	return RString();
570
}
619
}
Lines 573-579 Link Here
573
{
622
{
574
	if( m_pStream )
623
	if( m_pStream )
575
	{
624
	{
625
#if (LIBAVCODEC_BUILD >= 4754)
626
		avcodec::avcodec_close( m_pStream->codec );
627
#else
576
		avcodec::avcodec_close( &m_pStream->codec );
628
		avcodec::avcodec_close( &m_pStream->codec );
629
#endif
577
		m_pStream = NULL;
630
		m_pStream = NULL;
578
	}
631
	}
579
632
(-)autoconf/m4/video.m4 (-38 lines)
Lines 19-62 Link Here
19
AC_SEARCH_LIBS(avcodec_init, [avcodec], have_libavcodec=yes,  have_libavcodec=no)
19
AC_SEARCH_LIBS(avcodec_init, [avcodec], have_libavcodec=yes,  have_libavcodec=no)
20
AC_SEARCH_LIBS(guess_format, [avformat], have_libavformat=yes,  have_libavformat=no)
20
AC_SEARCH_LIBS(guess_format, [avformat], have_libavformat=yes,  have_libavformat=no)
21
fi
21
fi
22
23
if test "$have_libavcodec" = "yes"; then
24
  AC_MSG_CHECKING([for matching libavcodec headers and libs])
25
  AC_TRY_RUN([
26
	#include <ffmpeg/avcodec.h>
27
	int main()
28
	{
29
		return ( LIBAVCODEC_VERSION_INT == avcodec_version() &&
30
			 LIBAVCODEC_BUILD == avcodec_build() ) ? 0:1;
31
	}
32
	],,have_libavcodec=no,)
33
  AC_MSG_RESULT($have_libavcodec)
34
  if test "$have_libavcodec" = "yes"; then
35
    AC_MSG_CHECKING([for libavcodec = 0.4.9-pre1])
36
    AC_TRY_RUN([
37
	#include <ffmpeg/avcodec.h>
38
	int main()
39
	{
40
		return ( LIBAVCODEC_VERSION_INT == 0x000409 &&
41
			 LIBAVCODEC_BUILD == 4718 ) ? 0:1;
42
	}
43
	],,have_libavcodec=no,)
44
    AC_MSG_RESULT($have_libavcodec)
45
  fi
46
fi
47
48
if test "$have_libavformat" = "yes"; then
49
  AC_MSG_CHECKING([for libavformat = 0.4.9-pre1])
50
  AC_TRY_RUN([
51
	#include <ffmpeg/avformat.h>
52
	int main()
53
	{
54
		return ( LIBAVFORMAT_VERSION_INT == 0x000409 &&
55
			 LIBAVFORMAT_BUILD == 4616 )? 0:1;
56
	}
57
	],,have_libavformat=no,)
58
  AC_MSG_RESULT($have_libavformat)
59
fi
60
fi
22
fi
61
23
62
have_ffmpeg=no
24
have_ffmpeg=no

Return to bug 148787