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 |
|