@@ -34,6 +34,7 @@ extern "C" {
34
34
35
35
#include " libavcodec/avcodec.h"
36
36
#include " libavformat/avformat.h"
37
+ #include " libavutil/imgutils.h"
37
38
#include " libswscale/swscale.h"
38
39
39
40
}
@@ -449,11 +450,19 @@ bool MediaEngine::setVideoDim(int width, int height)
449
450
450
451
// Allocate video frame for RGB24
451
452
m_pFrameRGB = av_frame_alloc ();
453
+ #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
454
+ int numBytes = av_image_get_buffer_size ((AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight, 1 );
455
+ #else
452
456
int numBytes = avpicture_get_size ((AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight);
457
+ #endif
453
458
m_buffer = (u8*)av_malloc (numBytes * sizeof (uint8_t ));
454
459
455
460
// Assign appropriate parts of buffer to image planes in m_pFrameRGB
461
+ #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
462
+ av_image_fill_arrays (m_pFrameRGB->data , m_pFrameRGB->linesize , m_buffer, (AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight, 1 );
463
+ #else
456
464
avpicture_fill ((AVPicture *)m_pFrameRGB, m_buffer, (AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight);
465
+ #endif
457
466
#endif // USE_FFMPEG
458
467
return true ;
459
468
}
@@ -522,8 +531,13 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
522
531
// Still need to decode those, so keep calling avcodec_decode_video2().
523
532
if (dataEnd || packet.stream_index == m_videoStream) {
524
533
// avcodec_decode_video2() gives us the re-ordered frames with a NULL packet.
534
+ #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
535
+ if (dataEnd)
536
+ av_packet_unref (&packet);
537
+ #else
525
538
if (dataEnd)
526
539
av_free_packet (&packet);
540
+ #endif
527
541
528
542
int result = avcodec_decode_video2 (m_pCodecCtx, m_pFrame, &frameFinished, &packet);
529
543
if (frameFinished) {
@@ -547,7 +561,11 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
547
561
break ;
548
562
}
549
563
}
564
+ #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
565
+ av_packet_unref (&packet);
566
+ #else
550
567
av_free_packet (&packet);
568
+ #endif
551
569
}
552
570
return bGetFrame;
553
571
#else
0 commit comments