diff --git a/CMakeLists.txt b/CMakeLists.txt index 31aac33..1e249ad 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ SET( PROJECT_NAME playuver ) # Project directories SET( SRC_DIR source ) SET( INC_DIR source ) -SET( LIB_DIR lib ) +SET( LIB_DIR ${SRC_DIR}/lib ) SET( RSC_DIR resources ) SET( UI_DIR ui ) SET( EXTERNAL_SRC external_lib ) diff --git a/source/InputStream.cpp b/source/InputStream.cpp index b41200e..5bf0ff4 100755 --- a/source/InputStream.cpp +++ b/source/InputStream.cpp @@ -136,7 +136,7 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for m_iPixelFormat = input_format; #ifdef USE_FFMPEG - avStatus = m_cLibAvContext.initAvFormat( filename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate ); + avStatus = m_cLibAvContext.initAvFormat( filename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate ); #endif if( m_uiWidth <= 0 || m_uiHeight <= 0 ) diff --git a/source/InputStream.h b/source/InputStream.h index 44c9abb..228a4df 100755 --- a/source/InputStream.h +++ b/source/InputStream.h @@ -36,8 +36,12 @@ #include #endif -#include "TypeDef.h" +#ifdef USE_FFMPEG #include "LibAvContextHandle.h" +#endif + +#include "TypeDef.h" + #include "PlaYUVerFrame.h" namespace plaYUVer diff --git a/lib/ffmpeg/LibAvContextHandle.cpp b/source/lib/ffmpeg/LibAvContextHandle.cpp similarity index 91% rename from lib/ffmpeg/LibAvContextHandle.cpp rename to source/lib/ffmpeg/LibAvContextHandle.cpp index 9cd0d1c..11a3af0 100755 --- a/lib/ffmpeg/LibAvContextHandle.cpp +++ b/source/lib/ffmpeg/LibAvContextHandle.cpp @@ -23,12 +23,7 @@ #include "LibAvContextHandle.h" -#ifdef USE_FFMPEG - #include - -#include - #include "LibMemAlloc.h" #include "PlaYUVerFrame.h" @@ -87,7 +82,7 @@ namespace plaYUVer m_bHasStream = false; } - Bool LibAvContextHandle::initAvFormat( QString filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate ) + Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate ) { Bool bRet = true; int ret = 0; @@ -103,7 +98,7 @@ namespace plaYUVer frame = NULL; m_bHasStream = false; - char *src_filename = filename.toLocal8Bit().data(); + char *src_filename = filename; AVDictionary *format_opts = NULL; /* register all formats and codecs */ @@ -130,14 +125,14 @@ namespace plaYUVer /* open input file, and allocate format context */ if( avformat_open_input( &fmt_ctx, src_filename, NULL, &format_opts ) < 0 ) { - qDebug( ) << " Could not open source file %s !!!" << filename << endl; + //qDebug( ) << " Could not open source file %s !!!" << filename << endl; return false; } /* retrieve stream information */ if( avformat_find_stream_info( fmt_ctx, NULL ) < 0 ) { - qDebug( ) << " Could not find stream information !!!" << endl; + //qDebug( ) << " Could not find stream information !!!" << endl; return false; } @@ -150,7 +145,7 @@ namespace plaYUVer ret = av_image_alloc( video_dst_data, video_dst_linesize, video_dec_ctx->width, video_dec_ctx->height, video_dec_ctx->pix_fmt, 1 ); if( ret < 0 ) { - qDebug( ) << " Could not allocate raw video buffer !!!" << endl; + //qDebug( ) << " Could not allocate raw video buffer !!!" << endl; closeAvFormat(); return false; } @@ -187,7 +182,7 @@ namespace plaYUVer av_dump_format( fmt_ctx, 0, src_filename, 0 ); if( !video_stream ) { - qDebug( ) << " Could not find audio or video stream in the input, aborting !!!" << endl; + //qDebug( ) << " Could not find audio or video stream in the input, aborting !!!" << endl; bRet = false; closeAvFormat(); return false; @@ -196,7 +191,7 @@ namespace plaYUVer frame = avcodec_alloc_frame(); if( !frame ) { - qDebug( ) << " Could not allocate frame !!!" << endl; + //qDebug( ) << " Could not allocate frame !!!" << endl; ret = AVERROR( ENOMEM ); closeAvFormat(); return false; @@ -262,5 +257,3 @@ namespace plaYUVer } } // NAMESPACE - -#endif diff --git a/lib/ffmpeg/LibAvContextHandle.h b/source/lib/ffmpeg/LibAvContextHandle.h similarity index 90% rename from lib/ffmpeg/LibAvContextHandle.h rename to source/lib/ffmpeg/LibAvContextHandle.h index 2eb9fdc..28f8652 100755 --- a/lib/ffmpeg/LibAvContextHandle.h +++ b/source/lib/ffmpeg/LibAvContextHandle.h @@ -24,11 +24,7 @@ #ifndef __LIBAVCONTEXTHANDLE_H__ #define __LIBAVCONTEXTHANDLE_H__ -#include "config.h" - -#ifdef USE_FFMPEG - -#include +//#include "config.h" extern "C" { @@ -46,7 +42,7 @@ namespace plaYUVer class LibAvContextHandle { public: - Bool initAvFormat( QString filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate ); + Bool initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate ); Void closeAvFormat(); Bool decodeAvFormat(); @@ -74,6 +70,4 @@ namespace plaYUVer } // NAMESPACE -#endif - #endif // __LIBAVCONTEXTHANDLE_H__ diff --git a/source/lib/ffmpeg/Makefile b/source/lib/ffmpeg/Makefile new file mode 100644 index 0000000..6e73b6c --- /dev/null +++ b/source/lib/ffmpeg/Makefile @@ -0,0 +1,25 @@ +# Makefile template for shared library + +CC = gcc # C compiler +CFLAGS = -fPIC -Wall -Wextra -O2 -g -I../.. # C flags +LDFLAGS = -shared # linking flags +RM = rm -f # rm command +TARGET_LIB = LibAvContextHandle.so # target lib + +SRCS = LibAvContextHandle.cpp # source files +OBJS = $(SRCS:.c=.o) + +.PHONY: all +all: ${TARGET_LIB} + +$(TARGET_LIB): $(OBJS) + $(CC) ${LDFLAGS} -o $@ $^ + +$(SRCS:.c=.d):%.d:%.cpp + $(CC) $(CFLAGS) -MM $< >$@ + +include $(SRCS:.c=.d) + +.PHONY: clean +clean: + -${RM} ${TARGET_LIB} ${OBJS} $(SRCS:.c=.d) \ No newline at end of file