[cmake]: add codec option

Use mpp/codecs.cmake to enable/disable codecs in order to reduce library
size.
All decoder and encoder can be disbaled now. Default all open.

Change-Id: I3307460df12f2f3fc82898d823ab2da12002d6c6
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2016-09-10 15:22:40 +08:00
parent 2ee1843c54
commit 30c6bd08c1
28 changed files with 479 additions and 287 deletions

View File

@@ -1,6 +1,7 @@
#!/bin/bash
# Run this from within a bash shell
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release \
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=./arm.linux.cross.cmake \
-DCMAKE_RKPLATFORM_ENABLE=ON \
-G "Unix Makefiles" \
../../../ && cmake --build .

View File

@@ -1,4 +1,12 @@
# vim: syntax=cmake
# ----------------------------------------------------------------------------
# setup mpp codec config first
# ----------------------------------------------------------------------------
include(codecs.cmake)
# ----------------------------------------------------------------------------
# add include directory
# ----------------------------------------------------------------------------
include_directories(.)
include_directories(common)
include_directories(base/inc)

View File

@@ -9,6 +9,7 @@ add_library(mpp_codec STATIC
mpp_dec.cpp
mpp_parser.cpp
)
set_target_properties(mpp_codec PROPERTIES FOLDER "mpp/codec")
add_subdirectory(dec)
@@ -17,16 +18,16 @@ add_subdirectory(enc)
target_link_libraries(mpp_codec
${CODEC_AVSD}
codec_h263d
codec_h264d
codec_h265d
codec_m2vd
codec_mpg4d
codec_vp8d
codec_vp9d
codec_jpegd
codec_h264e
codec_jpege
${CODEC_H263D}
${CODEC_H264D}
${CODEC_H265D}
${CODEC_MPEG2D}
${CODEC_MPEG4D}
${CODEC_VP8D}
${CODEC_VP9D}
${CODEC_JPEGD}
${CODEC_H264E}
${CODEC_JPEGE}
codec_dummy_enc
codec_dummy_dec
mpp_base)

View File

@@ -2,25 +2,38 @@
add_subdirectory(dummy)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/avs")
set(HAVE_AVSD true)
set(CODEC_AVSD codec_avsd)
add_definitions(-DHAVE_AVSD)
if( HAVE_AVSD )
add_subdirectory(avs)
endif()
if( HAVE_H263D )
add_subdirectory(h263)
endif()
if( HAVE_H264D )
add_subdirectory(h264)
endif()
if( HAVE_H265D )
add_subdirectory(h265)
endif()
if( HAVE_MPEG2D )
add_subdirectory(m2v)
endif()
if( HAVE_MPEG4D )
add_subdirectory(mpg4)
endif()
if( HAVE_VP8D )
add_subdirectory(vp8)
endif()
if( HAVE_VP9D )
add_subdirectory(vp9)
endif()
if( HAVE_JPEGD )
add_subdirectory(jpeg)
endif()

View File

@@ -8,9 +8,10 @@ set(H263D_PARSER_SRC
h263d_parser.c
)
add_library(codec_h263d STATIC
add_library(${CODEC_H263D} STATIC
${H263D_PARSER_SRC} ${H263D_PARSER_HDR}
)
set_target_properties(codec_h263d PROPERTIES FOLDER "mpp/codec")
target_link_libraries(codec_h263d mpp_base)
set_target_properties(${CODEC_H263D} PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_H263D} mpp_base)

View File

@@ -5,6 +5,7 @@ include_directories(.)
set(H264D_API
../../inc/h264d_api.h
)
set(H264D_COMMON
../../../common/h264d_log.h
../../../common/h264d_syntax.h
@@ -23,7 +24,6 @@ set(H264D_HDR
h264d_init.h
h264d_fill.h
h264d_rwfile.h
)
# h264 decoder sourse
@@ -40,17 +40,16 @@ set(H264D_SRC
h264d_init.c
h264d_fill.c
h264d_rwfile.c
)
add_library(codec_h264d STATIC
add_library(${CODEC_H264D} STATIC
${H264D_API}
${H264D_COMMON}
${H264D_HDR}
${H264D_SRC}
)
target_link_libraries(codec_h264d mpp_base)
set_target_properties(codec_h264d PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_H264D} mpp_base)
set_target_properties(${CODEC_H264D} PROPERTIES FOLDER "mpp/codec")

View File

@@ -12,12 +12,13 @@ set(H265D_PARSER_SRC
h265d_sei.c
h265d_parser2_syntax.c
)
add_library(codec_h265d STATIC
${H265D_PARSER_SRC} ${H265D_PARSER_HDR}
add_library(${CODEC_H265D} STATIC
${H265D_PARSER_SRC}
${H265D_PARSER_HDR}
)
set_target_properties(codec_h265d PROPERTIES FOLDER "mpp/codec")
target_link_libraries(codec_h265d mpp_base)
set_target_properties(${CODEC_H265D} PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_H265D} mpp_base)
add_subdirectory(test)

View File

@@ -6,12 +6,13 @@ set(JPEGD_PARSER_HDR
set(JPEGD_PARSER_SRC
jpegd_parser.c
)
add_library(codec_jpegd STATIC
${JPEGD_PARSER_SRC} ${JPEGD_PARSER_HDR}
add_library(${CODEC_JPEGD} STATIC
${JPEGD_PARSER_SRC}
${JPEGD_PARSER_HDR}
)
set_target_properties(codec_jpegd PROPERTIES FOLDER "mpp/codec")
target_link_libraries(codec_jpegd mpp_base)
set_target_properties(${CODEC_JPEGD} PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_JPEGD} mpp_base)
#add_subdirectory(test)

View File

@@ -5,6 +5,7 @@ include_directories(.)
set(M2VD_API
../../inc/m2vd_api.h
)
set(M2VD_COMMON
)
@@ -21,15 +22,12 @@ set(M2VD_SRC
m2vd_parser.c
)
add_library(codec_m2vd STATIC
add_library(${CODEC_MPEG2D} STATIC
${M2VD_API}
${M2VD_COMMON}
${M2VD_HDR}
${M2VD_SRC}
)
target_link_libraries(codec_m2vd
mpp_base
)
set_target_properties(codec_m2vd PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_MPEG2D} mpp_base)
set_target_properties(${CODEC_MPEG2D} PROPERTIES FOLDER "mpp/codec")

View File

@@ -8,9 +8,10 @@ set(MPG4D_PARSER_SRC
mpg4d_parser.c
)
add_library(codec_mpg4d STATIC
${MPG4D_PARSER_SRC} ${MPG4D_PARSER_HDR}
add_library(${CODEC_MPEG4D} STATIC
${MPG4D_PARSER_SRC}
${MPG4D_PARSER_HDR}
)
set_target_properties(codec_mpg4d PROPERTIES FOLDER "mpp/codec")
target_link_libraries(codec_mpg4d mpp_base)
set_target_properties(${CODEC_MPEG4D} PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_MPEG4D} mpp_base)

View File

@@ -18,12 +18,11 @@ set(VP8D_SRC
vp8d_parser.c
)
add_library(codec_vp8d STATIC
add_library(${CODEC_VP8D} STATIC
${VP8D_API}
${VP8D_HDR}
${VP8D_SRC}
)
target_link_libraries(codec_vp8d mpp_base)
set_target_properties(codec_vp8d PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_VP8D} mpp_base)
set_target_properties(${CODEC_VP8D} PROPERTIES FOLDER "mpp/codec")

View File

@@ -6,16 +6,11 @@ set(VP9_D_API
../../inc/vp9d_api.h
)
# h264 decoder header
# vp9 decoder header
set(VP9D_HDR
)
# h264 decoder sourse
# vp9 decoder sourse
set(VP9D_SRC
vp9d_api.c
vp9d_parser.c
@@ -23,13 +18,11 @@ set(VP9D_SRC
vp9d_parser2_syntax.c
)
add_library(codec_vp9d STATIC
add_library(${CODEC_VP9D} STATIC
${VP9D_API}
${VP9D_HDR}
${VP9D_SRC}
)
target_link_libraries(codec_vp9d mpp_base)
set_target_properties(codec_vp9d PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_VP9D} mpp_base)
set_target_properties(${CODEC_VP9D} PROPERTIES FOLDER "mpp/codec")

View File

@@ -4,11 +4,8 @@ include_directories(include)
# h264 encoder api
set(H264E_API
# ../../inc/h264d_api.h
)
set(H264E_COMMON
# ../../../common/h264d_log.h
# ../../../common/h264d_syntax.h
)
# h264 encoder header
@@ -52,11 +49,12 @@ set(H264E_SRC
)
add_library(codec_h264e STATIC
add_library(${CODEC_H264E} STATIC
${H264E_API}
${H264E_COMMON}
${H264E_HDR}
${H264E_SRC}
)
target_link_libraries(codec_h264e mpp_base)
set_target_properties(codec_h264e PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_H264E} mpp_base)
set_target_properties(${CODEC_H264E} PROPERTIES FOLDER "mpp/codec")

View File

@@ -1,9 +1,9 @@
# vim: syntax=cmake
include_directories(.)
add_library(codec_jpege STATIC
add_library(${CODEC_JPEGE} STATIC
jpege_api.c
)
target_link_libraries(codec_jpege mpp_base)
set_target_properties(codec_jpege PROPERTIES FOLDER "mpp/codec")
target_link_libraries(${CODEC_JPEGE} mpp_base)
set_target_properties(${CODEC_JPEGE} PROPERTIES FOLDER "mpp/codec")

View File

@@ -28,8 +28,12 @@
* all decoder static register here
*/
static const ControlApi *controllers[] = {
#if HAVE_H264E
&api_h264e_controller,
#endif
#if HAVE_JPEGE
&api_jpege_controller,
#endif
};
typedef struct ControllerImpl_t {

View File

@@ -43,14 +43,30 @@ static const ParserApi *parsers[] = {
#if HAVE_AVSD
&api_avsd_parser,
#endif
#if HAVE_H263D
&api_h263d_parser,
#endif
#if HAVE_H264D
&api_h264d_parser,
#endif
#if HAVE_H265D
&api_h265d_parser,
#endif
#if HAVE_MPEG2D
&api_m2vd_parser,
#endif
#if HAVE_MPEG4D
&api_mpg4d_parser,
#endif
#if HAVE_VP8D
&api_vp8d_parser,
#endif
#if HAVE_VP9D
&api_vp9d_parser,
#endif
#if HAVE_JPEGD
&api_jpegd_parser,
#endif
&dummy_dec_parser,
};

89
mpp/codecs.cmake Normal file
View File

@@ -0,0 +1,89 @@
# This file setup the enable flag of all supported codecs
if( NOT DEFINED DISABLE_AVSD AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/codec/dec/avs" )
set(HAVE_AVSD true)
set(CODEC_AVSD codec_avsd)
set(HAL_AVSD hal_avsd)
add_definitions(-DHAVE_AVSD)
endif()
# H.263 decoder
if( NOT DEFINED DISABLE_H263D )
set(HAVE_H263D true)
set(CODEC_H263D codec_h263d)
set(HAL_H263D hal_h263d)
add_definitions(-DHAVE_H263D)
endif()
# H.264 decoder
if( NOT DEFINED DISABLE_H264D )
set(HAVE_H264D true)
set(CODEC_H264D codec_h264d)
set(HAL_H264D hal_h264d)
add_definitions(-DHAVE_H264D)
endif()
# H.265 decoder
if( NOT DEFINED DISABLE_H265D )
set(HAVE_H265D true)
set(CODEC_H265D codec_h265d)
set(HAL_H265D hal_h265d)
add_definitions(-DHAVE_H265D)
endif()
# mpeg2 decoder
if( NOT DEFINED DISABLE_MPEG2D )
set(HAVE_MPEG2D true)
set(CODEC_MPEG2D codec_mpeg2d)
set(HAL_MPEG2D hal_mpeg2d)
add_definitions(-DHAVE_MPEG2D)
endif()
# mpeg4 decoder
if( NOT DEFINED DISABLE_MPEG4D )
set(HAVE_MPEG4D true)
set(CODEC_MPEG4D codec_mpeg4d)
set(HAL_MPEG4D hal_mpeg4d)
add_definitions(-DHAVE_MPEG4D)
endif()
# VP8 decoder
if( NOT DEFINED DISABLE_VP8D )
set(HAVE_VP8D true)
set(CODEC_VP8D codec_vp8d)
set(HAL_VP8D hal_vp8d)
add_definitions(-DHAVE_VP8D)
endif()
# VP9 decoder
if( NOT DEFINED DISABLE_VP9D )
set(HAVE_VP9D true)
set(CODEC_VP9D codec_vp9d)
set(HAL_VP9D hal_vp9d)
add_definitions(-DHAVE_VP9D)
endif()
# jpeg decoder
if( NOT DEFINED DISABLE_JPEGD )
set(HAVE_JPEGD true)
set(CODEC_JPEGD codec_jpegd)
set(HAL_JPEGD hal_jpegd)
add_definitions(-DHAVE_JPEGD)
endif()
# H.264 encoder
if( NOT DEFINED DISABLE_H264E )
set(HAVE_H264E true)
set(CODEC_H264E codec_h264e)
set(HAL_H264E hal_h264e)
add_definitions(-DHAVE_H264E)
endif()
# jpeg encoder
if( NOT DEFINED DISABLE_JPEGE )
set(HAVE_JPEGE true)
set(CODEC_JPEGE codec_jpege)
set(HAL_JPEGE hal_jpege)
add_definitions(-DHAVE_JPEGE)
endif()

View File

@@ -1,6 +1,15 @@
# vim: syntax=cmake
include_directories(worker/inc)
# ----------------------------------------------------------------------------
# add hardware hal
# ----------------------------------------------------------------------------
add_subdirectory(vpu)
add_subdirectory(rkdec)
add_subdirectory(rkenc)
add_subdirectory(dummy)
add_subdirectory(rkdec/avsd)
# ----------------------------------------------------------------------------
# add mpp_hal implement
# ----------------------------------------------------------------------------
@@ -12,30 +21,6 @@ add_library(mpp_hal STATIC
set_target_properties(mpp_hal PROPERTIES FOLDER "mpp/hal")
add_subdirectory(dummy)
add_subdirectory(rkdec/h264d)
add_subdirectory(rkdec/h265d)
add_subdirectory(rkdec/vp9d)
add_subdirectory(rkdec/avsd)
add_subdirectory(vpu/h263d)
add_subdirectory(vpu/m2vd)
add_subdirectory(vpu/mpg4d)
add_subdirectory(vpu/vp8d)
add_subdirectory(vpu/jpegd)
add_subdirectory(rkenc/h264e)
add_subdirectory(vpu/jpege)
# ----------------------------------------------------------------------------
# add hardware worker implement
# ----------------------------------------------------------------------------
@@ -46,19 +31,18 @@ if(RKPLATFORM)
set(RKPLAT_VPU worker_vpu)
endif(RKPLATFORM)
target_link_libraries(mpp_hal
hal_avsd
hal_h263d
hal_h264d
hal_h265d
hal_m2vd
hal_mpg4d
hal_vp8d
hal_vp9d
hal_jpegd
hal_h264e
hal_jpege
${HAL_AVSD}
${HAL_H263D}
${HAL_H264D}
${HAL_H265D}
${HAL_MPEG2D}
${HAL_MPEG4D}
${HAL_VP8D}
${HAL_VP9D}
${HAL_JPEGD}
${HAL_H264E}
${HAL_JPEGE}
hal_dummy
${RKPLAT_VPU}
)

View File

@@ -45,15 +45,33 @@
* all hardware api static register here
*/
static const MppHalApi *hw_apis[] = {
#if HAVE_AVSD
&hal_api_avsd,
#endif
#if HAVE_H263D
&hal_api_h263d,
#endif
#if HAVE_H264D
&hal_api_h264d,
#endif
#if HAVE_H265D
&hal_api_h265d,
#endif
#if HAVE_MPEG2D
&hal_api_m2vd,
#endif
#if HAVE_MPEG4D
&hal_api_mpg4d,
#endif
#if HAVE_VP8D
&hal_api_vp8d,
#endif
#if HAVE_VP9D
&hal_api_vp9d,
#endif
#if HAVE_JPEGD
&hal_api_jpegd,
#endif
&hal_api_h264e,
&hal_api_jpege,
&hal_api_dummy_dec,

View File

@@ -0,0 +1,13 @@
# vim: syntax=cmake
if( HAVE_H264D )
add_subdirectory(h264d)
endif()
if( HAVE_H265D )
add_subdirectory(h265d)
endif()
if( HAVE_VP9D )
add_subdirectory(vp9d)
endif()

View File

@@ -10,12 +10,12 @@ set(HAL_H265D_SRC
hal_h265d_reg.c
)
add_library(hal_h265d STATIC
${HAL_H265D_SRC} ${HAL_H265D_HDR}
add_library(${HAL_H265D} STATIC
${HAL_H265D_SRC}
${HAL_H265D_HDR}
)
set_target_properties(hal_h265d PROPERTIES FOLDER "mpp/hal")
target_link_libraries(hal_h265d mpp_base)
set_target_properties(${HAL_H265D} PROPERTIES FOLDER "mpp/hal")
target_link_libraries(${HAL_H265D} mpp_base)
#add_subdirectory(test)

View File

@@ -0,0 +1,2 @@
# vim: syntax=cmake
add_subdirectory(h264e)

View File

@@ -0,0 +1,25 @@
# vim: syntax=cmake
if( HAVE_H263D )
add_subdirectory(h263d)
endif()
if( HAVE_MPEG2D )
add_subdirectory(m2vd)
endif()
if( HAVE_MPEG4D )
add_subdirectory(mpg4d)
endif()
if( HAVE_VP8D )
add_subdirectory(vp8d)
endif()
if( HAVE_JPEGD )
add_subdirectory(jpegd)
endif()
if( HAVE_JPEGE )
add_subdirectory(jpege)
endif()

View File

@@ -9,9 +9,10 @@ set(HAL_JPEGE_SRC
hal_jpege_api.c
)
add_library(hal_jpege STATIC
${HAL_JPEGE_SRC} ${HAL_JPEGE_HDR}
add_library(${HAL_JPEGE} STATIC
${HAL_JPEGE_SRC}
${HAL_JPEGE_HDR}
)
set_target_properties(hal_jpege PROPERTIES FOLDER "mpp/hal")
target_link_libraries(hal_jpege mpp_base)
set_target_properties(${HAL_JPEGE} PROPERTIES FOLDER "mpp/hal")
target_link_libraries(${HAL_JPEGE} mpp_base)

View File

@@ -7,7 +7,6 @@ set(HAL_M2VD_API
../../../common/m2vd_syntax.h
)
#hal m2v header
set(HAL_M2VD_HDR
hal_m2vd_reg.h
@@ -19,14 +18,12 @@ set(HAL_M2VD_SRC
hal_m2vd_reg.c
)
add_library(hal_m2vd STATIC
add_library(${HAL_MPEG2D} STATIC
${HAL_M2VD_API}
${HAL_M2VD_HDR}
${HAL_M2VD_SRC}
)
target_link_libraries(hal_m2vd mpp_base)
set_target_properties(hal_m2vd PROPERTIES FOLDER "mpp/hal")
target_link_libraries(${HAL_MPEG2D} mpp_base)
set_target_properties(${HAL_MPEG2D} PROPERTIES FOLDER "mpp/hal")

View File

@@ -8,11 +8,12 @@ set(HAL_MPEG4D_SRC
hal_mpg4d_reg.c
)
add_library(hal_mpg4d STATIC
${HAL_MPEG4D_SRC} ${HAL_MPEG4D_HDR}
add_library(${HAL_MPEG4D} STATIC
${HAL_MPEG4D_SRC}
${HAL_MPEG4D_HDR}
)
set_target_properties(hal_mpg4d PROPERTIES FOLDER "mpp/hal")
target_link_libraries(hal_mpg4d mpp_base)
set_target_properties(${HAL_MPEG4D} PROPERTIES FOLDER "mpp/hal")
target_link_libraries(${HAL_MPEG4D} mpp_base)
#add_subdirectory(test)

View File

@@ -35,17 +35,39 @@ typedef struct {
} MppCodingTypeInfo;
static MppCodingTypeInfo support_list[] = {
#if HAVE_MPEG2D
{ MPP_CTX_DEC, MPP_VIDEO_CodingMPEG2, "dec", "mpeg2", },
#endif
#if HAVE_MPEG4D
{ MPP_CTX_DEC, MPP_VIDEO_CodingMPEG4, "dec", "mpeg4", },
#endif
#if HAVE_H263D
{ MPP_CTX_DEC, MPP_VIDEO_CodingH263, "dec", "h.263", },
#endif
#if HAVE_H264D
{ MPP_CTX_DEC, MPP_VIDEO_CodingAVC, "dec", "h.264/AVC", },
#endif
#if HAVE_H265D
{ MPP_CTX_DEC, MPP_VIDEO_CodingHEVC, "dec", "h.265/HEVC", },
#endif
#if HAVE_VP8D
{ MPP_CTX_DEC, MPP_VIDEO_CodingVP8, "dec", "vp8", },
#endif
#if HAVE_VP9D
{ MPP_CTX_DEC, MPP_VIDEO_CodingVP9, "dec", "VP9", },
#endif
#if HAVE_AVSD
{ MPP_CTX_DEC, MPP_VIDEO_CodingAVS, "dec", "avs+", },
#endif
#if HAVE_JPEGD
{ MPP_CTX_DEC, MPP_VIDEO_CodingMJPEG, "dec", "jpeg", },
#endif
#if HAVE_H264E
{ MPP_CTX_ENC, MPP_VIDEO_CodingAVC, "enc", "h.264/AVC", },
#endif
#if HAVE_JPEGE
{ MPP_CTX_ENC, MPP_VIDEO_CodingMJPEG, "enc", "jpeg", },
#endif
};
#define check_mpp_ctx(ctx) _check_mpp_ctx(ctx, __FUNCTION__)

View File

@@ -24,19 +24,25 @@ endmacro()
add_mpp_test(mpp_info)
# h264 decoder test
if( HAVE_H264D )
include_directories(../codec/dec/h264)
add_mpp_test(h264d)
endif()
# vp9 decoder test
if( HAVE_VP9D )
include_directories(../codec/dec/vp9)
add_mpp_test(vp9d)
endif()
if (${HAVE_AVSD})
if( HAVE_AVSD )
# avs decoder test
include_directories(../codec/dec/avs)
add_mpp_test(avsd)
endif()
# jpeg decoder test
if( HAVE_JPEGD )
include_directories(../codec/dec/jpeg)
add_mpp_test(jpegd)
endif()