Fix build with ffmpeg3

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/1/head
Slávek Banko 8 years ago
parent 4e1ef6663b
commit ac177cd732

@ -27,6 +27,10 @@
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO #define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
#endif #endif
#if !defined(NEW_FFMPEG) || LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51,42,0)
#define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
#endif
#include <tqimage.h> #include <tqimage.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <tdelocale.h> #include <tdelocale.h>
@ -43,7 +47,9 @@ int glibref=0;
void av_free_packet_internal(AVPacket *pkt) void av_free_packet_internal(AVPacket *pkt)
{ {
if (pkt) { if (pkt) {
# if LIBAVCODEC_VERSION_INT < (AV_VERSION_INT(56,0,0))
if (pkt->destruct) pkt->destruct(pkt); if (pkt->destruct) pkt->destruct(pkt);
# endif
pkt->data = NULL; pkt->size = 0; pkt->data = NULL; pkt->size = 0;
} }
} }
@ -259,14 +265,14 @@ bool k9AviDecode::open(const TQString & _fileName) {
int numBytes; int numBytes;
// Determine required buffer size and allocate buffer // Determine required buffer size and allocate buffer
numBytes=avpicture_get_size(PIX_FMT_RGB24, m_CodecCtx->width, numBytes=avpicture_get_size(AV_PIX_FMT_RGB24, m_CodecCtx->width,
m_CodecCtx->height); m_CodecCtx->height);
m_buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t)); m_buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
// Assign appropriate parts of buffer to image planes in pFrameRGB // Assign appropriate parts of buffer to image planes in pFrameRGB
// Note that pFrameRGB is an AVFrame, but AVFrame is a superset // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
// of AVPicture // of AVPicture
avpicture_fill((AVPicture *)m_FrameRGB, m_buffer, PIX_FMT_RGB24, avpicture_fill((AVPicture *)m_FrameRGB, m_buffer, AV_PIX_FMT_RGB24,
m_CodecCtx->width, m_CodecCtx->height); m_CodecCtx->width, m_CodecCtx->height);
m_duration=(double)m_FormatCtx->duration / AV_TIME_BASE; m_duration=(double)m_FormatCtx->duration / AV_TIME_BASE;
@ -321,7 +327,7 @@ void k9AviDecode::readFrame(double _seconds) {
bFound=true; bFound=true;
# ifndef HAVE_SWSCALE # ifndef HAVE_SWSCALE
// Convert the image from its native format to RGB // Convert the image from its native format to RGB
img_convert((AVPicture *)m_FrameRGB, PIX_FMT_RGB24, img_convert((AVPicture *)m_FrameRGB, AV_PIX_FMT_RGB24,
(AVPicture*)m_Frame, m_CodecCtx->pix_fmt, (AVPicture*)m_Frame, m_CodecCtx->pix_fmt,
m_CodecCtx->width, m_CodecCtx->height); m_CodecCtx->width, m_CodecCtx->height);
@ -329,7 +335,7 @@ void k9AviDecode::readFrame(double _seconds) {
SaveFrame(m_FrameRGB, m_CodecCtx->width, SaveFrame(m_FrameRGB, m_CodecCtx->width,
m_CodecCtx->height); m_CodecCtx->height);
# else # else
toRGB_convert_ctx=sws_getContext(m_CodecCtx->width, m_CodecCtx->height, m_CodecCtx->pix_fmt, m_CodecCtx->width, m_CodecCtx->height, PIX_FMT_RGB24, sws_flags,NULL,NULL,NULL); toRGB_convert_ctx=sws_getContext(m_CodecCtx->width, m_CodecCtx->height, m_CodecCtx->pix_fmt, m_CodecCtx->width, m_CodecCtx->height, AV_PIX_FMT_RGB24, sws_flags,NULL,NULL,NULL);
sws_scale(toRGB_convert_ctx, m_Frame->data, m_Frame->linesize, 0, m_CodecCtx->height, m_FrameRGB->data,m_FrameRGB->linesize); sws_scale(toRGB_convert_ctx, m_Frame->data, m_Frame->linesize, 0, m_CodecCtx->height, m_FrameRGB->data,m_FrameRGB->linesize);
// convert frame to QImage // convert frame to QImage
SaveFrame(m_FrameRGB, m_CodecCtx->width, SaveFrame(m_FrameRGB, m_CodecCtx->width,

Loading…
Cancel
Save