diff --git a/source/ffmpeg-cpp/CMakeLists.txt b/source/ffmpeg-cpp/CMakeLists.txt new file mode 100644 index 0000000..668e193 --- /dev/null +++ b/source/ffmpeg-cpp/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.5) +project(ffmpeg-cpp) + +SET(CMAKE_CXX_STANDARD 11) + +set (CXX_FLAGS + -g + -fPIC + -Wall + -Wno-unused-parameter + -Wno-unused-function + -Wunused-variable + -Wunused-value + -Wshadow + -Wcast-qual + -Wcast-align + -Wwrite-strings + -Wsign-compare + -Winvalid-pch + -fms-extensions + -Wfloat-equal + -Wextra + -std=c++11 + ) + +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb -D_DEBUG") +SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -ggdb -DNDEBUG") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/3rd/ffmpeg/include) +LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/3rd/ffmpeg/lib) + +include_directories(ffmpeg-cpp) + +file(GLOB_RECURSE ffmpeg-cpp-srcs ffmpeg-cpp/*.cpp *.h) + +add_library(ffmpeg-cpp ${ffmpeg-cpp-srcs}) +target_link_libraries(ffmpeg-cpp avcodec avdevice avfilter avformat avutil postproc swresample swscale) \ No newline at end of file diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/AudioFormatConverter.h b/source/ffmpeg-cpp/ffmpeg-cpp/AudioFormatConverter.h index 8891b53..639f879 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/AudioFormatConverter.h +++ b/source/ffmpeg-cpp/ffmpeg-cpp/AudioFormatConverter.h @@ -3,6 +3,10 @@ #include "ffmpeg.h" #include "ConvertedAudioProcessor.h" +#ifndef nullptr +#define nullptr NULL +#endif + namespace ffmpegcpp { class AudioFormatConverter diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/CodecDeducer.cpp b/source/ffmpeg-cpp/ffmpeg-cpp/CodecDeducer.cpp index 99bc65c..e30f52c 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/CodecDeducer.cpp +++ b/source/ffmpeg-cpp/ffmpeg-cpp/CodecDeducer.cpp @@ -1,5 +1,6 @@ #include "CodecDeducer.h" #include "FFmpegException.h" +#include using namespace std; diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/Codecs/VideoCodec.cpp b/source/ffmpeg-cpp/ffmpeg-cpp/Codecs/VideoCodec.cpp index c166957..b99eef0 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/Codecs/VideoCodec.cpp +++ b/source/ffmpeg-cpp/ffmpeg-cpp/Codecs/VideoCodec.cpp @@ -1,3 +1,4 @@ +#include #include "VideoCodec.h" #include "FFmpegException.h" @@ -102,7 +103,7 @@ namespace ffmpegcpp while (p->num) { double pVal = av_q2d(*p); - double diff = abs(pVal - fVal); + double diff = fabs(pVal - fVal); if (diff < bestDiff) { bestDiff = diff; diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/FFmpegException.cpp b/source/ffmpeg-cpp/ffmpeg-cpp/FFmpegException.cpp index 660aa8b..f93743a 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/FFmpegException.cpp +++ b/source/ffmpeg-cpp/ffmpeg-cpp/FFmpegException.cpp @@ -4,14 +4,11 @@ using namespace std; namespace ffmpegcpp { - FFmpegException::FFmpegException(string error) : exception(error.c_str()) + FFmpegException::FFmpegException(string error) { } FFmpegException::FFmpegException(string error, int returnValue) - : exception( - (error + ": " + av_make_error_string(this->error, AV_ERROR_MAX_STRING_SIZE, returnValue)).c_str() - ) { } } \ No newline at end of file diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/FFmpegException.h b/source/ffmpeg-cpp/ffmpeg-cpp/FFmpegException.h index d3da0dd..da39d1b 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/FFmpegException.h +++ b/source/ffmpeg-cpp/ffmpeg-cpp/FFmpegException.h @@ -15,7 +15,7 @@ namespace ffmpegcpp FFmpegException(std::string error, int returnValue); - virtual char const* what() const + virtual char const* what() throw() { return std::exception::what(); } diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/Frame Sinks/FrameSinkStream.h b/source/ffmpeg-cpp/ffmpeg-cpp/Frame Sinks/FrameSinkStream.h index 483ff7e..e4ec466 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/Frame Sinks/FrameSinkStream.h +++ b/source/ffmpeg-cpp/ffmpeg-cpp/Frame Sinks/FrameSinkStream.h @@ -2,7 +2,7 @@ #include "ffmpeg.h" #include "FrameWriter.h" -#include "Demuxing/Streamdata.h" +#include "Demuxing/StreamData.h" namespace ffmpegcpp { diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/codecs/H264NVEncCodec.h b/source/ffmpeg-cpp/ffmpeg-cpp/codecs/H264NVEncCodec.h index 2d99be5..5c6ba4e 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/codecs/H264NVEncCodec.h +++ b/source/ffmpeg-cpp/ffmpeg-cpp/codecs/H264NVEncCodec.h @@ -1,5 +1,5 @@ #pragma once -#include "VideoCodec.h" +#include "Codecs/VideoCodec.h" namespace ffmpegcpp { diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/codecs/H265NVEncCodec.h b/source/ffmpeg-cpp/ffmpeg-cpp/codecs/H265NVEncCodec.h index 58099b0..fb973f2 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/codecs/H265NVEncCodec.h +++ b/source/ffmpeg-cpp/ffmpeg-cpp/codecs/H265NVEncCodec.h @@ -1,5 +1,5 @@ #pragma once -#include "VideoCodec.h" +#include "Codecs/VideoCodec.h" namespace ffmpegcpp { diff --git a/source/ffmpeg-cpp/ffmpeg-cpp/ffmpeg.h b/source/ffmpeg-cpp/ffmpeg-cpp/ffmpeg.h index 76cad06..8ad9ba1 100644 --- a/source/ffmpeg-cpp/ffmpeg-cpp/ffmpeg.h +++ b/source/ffmpeg-cpp/ffmpeg-cpp/ffmpeg.h @@ -1,8 +1,11 @@ #pragma once #define _CRTDBG_MAP_ALLOC -#include +#include + +#ifdef _WIN32 #include +#endif extern "C" { #include