bf559326 | 2014-10-06 13:04:57 | Francois Andriot |
Fix crash when authoring DVD and selecting video file |
||
M k9author/k9avidecode.cpp |
||
diff --git a/k9author/k9avidecode.cpp b/k9author/k9avidecode.cpp index ec7b82d..731b1d3 100644 --- a/k9author/k9avidecode.cpp +++ b/k9author/k9avidecode.cpp @@ -119,6 +119,13 @@ m_opened=false; glibref++; + + m_FormatCtx = NULL; + m_CodecCtx = NULL; + m_Codec = NULL; + m_Frame = NULL; + m_FrameRGB = NULL; + m_buffer = NULL; } @@ -148,7 +155,7 @@ // Open video file if ( # if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 2, 0) - avformat_open_input(&m_FormatCtx, _fileName.utf8(), 0, 0)!=0 + avformat_open_input(&m_FormatCtx, _fileName.utf8(), NULL, NULL)!=0 # else av_open_input_file(&m_FormatCtx, _fileName.utf8(), NULL, 0, NULL)!=0 # endif |
||
18d94a86 | 2014-10-06 13:05:06 | Timothy Pearson |
Delete unneeded subdirs file |
||
R subdirs |
||
diff --git a/subdirs b/subdirs deleted file mode 100644 index 5fdca8a..0000000 --- a/subdirs +++ /dev/null @@ -1,11 +0,0 @@ -doc -dvdread -k9Mplayer -k9author -k9decmpeg -k9devices -k9vamps -libdvdnav -libk9copy -po -src |
||
effa31d9 | 2014-10-06 14:02:57 | Timothy Pearson |
Fix crash when img_convert unavailable |
||
M config.h.in M configure.in.in M k9author/k9avidecode.cpp M k9author/k9avidecode.h |
||
diff --git a/config.h.in b/config.h.in index 959d138..70e6595 100644 --- a/config.h.in +++ b/config.h.in @@ -93,6 +93,9 @@ /* Define if you have the strlcpy prototype */ #undef HAVE_STRLCPY_PROTO +/* swscale support */ +#undef HAVE_SWSCALE + /* Define to 1 if you have the <sys/bitypes.h> header file. */ #undef HAVE_SYS_BITYPES_H @@ -127,6 +130,9 @@ /* No openGL support */ #undef NO_OPENGL +/* No swscale support */ +#undef NO_SWSCALE + /* old ffmpeg */ #undef OLD_FFMPEG diff --git a/configure.in.in b/configure.in.in index c9a3329..1bf34d1 100755 --- a/configure.in.in +++ b/configure.in.in @@ -73,3 +73,8 @@ CFLAGS="$cflags_safe" AC_LANG_RESTORE +have_swscale=no +AC_CHECK_HEADER([libswscale/swscale.h], \ +[AC_DEFINE(HAVE_SWSCALE, 1, [swscale support]) have_swscale=yes], \ +[AC_DEFINE(NO_SWSCALE, 1, [No swscale support])]) + diff --git a/k9author/k9avidecode.cpp b/k9author/k9avidecode.cpp index 731b1d3..77f8d2b 100644 --- a/k9author/k9avidecode.cpp +++ b/k9author/k9avidecode.cpp @@ -35,6 +35,7 @@ void *CodecHandle=0; void *FormatHandle=0; void *UtilHandle=0; +void *SwscaleHandle=0; int glibref=0; #ifdef NEW_FFMPEG @@ -49,12 +50,22 @@ #endif #endif +#ifdef HAVE_SWSCALE +#include "libswscale/swscale.h" +static int sws_flags = SWS_BICUBIC; +#endif + k9AviDecode::k9AviDecode(TQObject *parent, const char *name) : TQObject(parent, name) { if (glibref==0) { CodecHandle=dlopen("libavcodec.so",RTLD_LAZY | RTLD_GLOBAL); FormatHandle=dlopen("libavformat.so",RTLD_LAZY | RTLD_GLOBAL); UtilHandle=dlopen("libavutil.so",RTLD_LAZY | RTLD_GLOBAL); +# ifdef HAVE_SWSCALE + SwscaleHandle=dlopen("libswscale.so",RTLD_LAZY); + if (SwscaleHandle==0) + SwscaleHandle=dlopen("libswscale.so.2",RTLD_LAZY); +# endif } if (!CodecHandle) { m_error =i18n("Cannot open then library %1").arg("libavcodec"); @@ -68,6 +79,11 @@ if (!UtilHandle) { m_error =i18n("Cannot open then library %1").arg("libavutil"); return; + } +# endif +# ifdef HAVE_SWSCALE + if (!SwscaleHandle) { + m_error =i18n("Cannot open the library %1").arg("libswscale"); } # endif m_error=""; @@ -98,7 +114,12 @@ # else avcodec_decode_video = (avcodec_decode_video_t)dlsym(CodecHandle,"avcodec_decode_video"); # endif +# ifndef HAVE_SWSCALE img_convert = (img_convert_t)dlsym(CodecHandle,"img_convert"); + //if img_convert is null (deprecated in ffmpeg), we need libswscale + if (!img_convert) + errs << i18n("Cannot open the library %1").arg("libswscale"); +# endif av_free = (av_free_t)dlsym(CodecHandle,"av_free"); avcodec_close = (avcodec_close_t)dlsym(FormatHandle,"avcodec_close"); # if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 17, 0) @@ -109,6 +130,11 @@ av_seek_frame=(av_seek_frame_t)dlsym(FormatHandle,"av_seek_frame"); av_rescale_q=(av_rescale_q_t)dlsym(FormatHandle,"av_rescale_q"); avcodec_flush_buffers=(avcodec_flush_buffers_t)dlsym(CodecHandle,"avcodec_flush_buffers"); +# ifdef HAVE_SWSCALE + sws_freeContext= (sws_freeContext_t)dlsym(SwscaleHandle,"sws_freeContext"); + sws_getContext=(sws_getContext_t)dlsym(SwscaleHandle,"sws_getContext"); + sws_scale= (sws_scale_t)dlsym(SwscaleHandle,"sws_scale"); +# endif # if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 33, 0) av_gettime=(av_gettime_t)dlsym(UtilHandle,"av_gettime"); @@ -139,6 +165,11 @@ if(UtilHandle) { dlclose(UtilHandle); } +# ifdef HAVE_SWSCALE + if (SwscaleHandle) { + dlclose(CodecHandle); + } +# endif } } @@ -257,6 +288,9 @@ int frameFinished=0; AVPacket packet; +# ifdef HAVE_SWSCALE + struct SwsContext *toRGB_convert_ctx; +# endif bool bFound=false; while (av_read_frame(m_FormatCtx, &packet)>=0 && !bFound) { // Is this a packet from the video stream? @@ -281,6 +315,7 @@ # endif if (cur_dts >=fspos) { bFound=true; +# ifndef HAVE_SWSCALE // Convert the image from its native format to RGB img_convert((AVPicture *)m_FrameRGB, PIX_FMT_RGB24, (AVPicture*)m_Frame, m_CodecCtx->pix_fmt, @@ -289,6 +324,14 @@ // convert frame to TQImage SaveFrame(m_FrameRGB, m_CodecCtx->width, m_CodecCtx->height); +# 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); + 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 + SaveFrame(m_FrameRGB, m_CodecCtx->width, + m_CodecCtx->height); + sws_freeContext(toRGB_convert_ctx); +# endif } } } diff --git a/k9author/k9avidecode.h b/k9author/k9avidecode.h index 62b7b23..907533d 100644 --- a/k9author/k9avidecode.h +++ b/k9author/k9avidecode.h @@ -22,6 +22,9 @@ #include <libavutil/avutil.h> #endif +#ifdef HAVE_SWSCALE +#include <libswscale/swscale.h> +#endif #include <tqimage.h> @@ -76,7 +79,11 @@ typedef int (*av_seek_frame_t)(AVFormatContext *,int,int64_t timestamp,int flags); typedef int64_t (*av_rescale_q_t)(int64_t , AVRational , AVRational ) ; typedef void (*avcodec_flush_buffers_t)(AVCodecContext *); - +#ifdef HAVE_SWSCALE +typedef void (*sws_freeContext_t)(struct SwsContext *swsContext); +typedef struct SwsContext* (*sws_getContext_t)(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, double *param); +typedef int (*sws_scale_t)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,int srcSliceH, uint8_t* dst[], int dstStride[]); +#endif class k9AviDecode : public TQObject @@ -138,6 +145,11 @@ av_rescale_q_t av_rescale_q; av_gettime_t av_gettime; avcodec_flush_buffers_t avcodec_flush_buffers; +# ifdef HAVE_SWSCALE + sws_freeContext_t sws_freeContext; + sws_getContext_t sws_getContext; + sws_scale_t sws_scale; +# endif AVFormatContext *m_FormatCtx; |
||
0e824732 | 2014-10-06 14:10:23 | Timothy Pearson |
Fix another crash casued by old av_packet_free routine |
||
M k9author/k9avidecode.cpp M k9author/k9avidecode.h M src/k9copy.cpp |
||
diff --git a/k9author/k9avidecode.cpp b/k9author/k9avidecode.cpp index 77f8d2b..a3a23c6 100644 --- a/k9author/k9avidecode.cpp +++ b/k9author/k9avidecode.cpp @@ -40,7 +40,7 @@ #ifdef NEW_FFMPEG #ifdef NEEDS_AV_FREE_PACKET -void av_free_packet(AVPacket *pkt) +void av_free_packet_internal(AVPacket *pkt) { if (pkt) { if (pkt->destruct) pkt->destruct(pkt); ** Diff limit reached (max: 250 lines) ** |