Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/SynoBuildConf/abiconfig b/SynoBuildConf/abiconfig
new file mode 100644
index 0000000000..70e02a72b5
--- /dev/null
+++ b/SynoBuildConf/abiconfig
@@ -0,0 +1,4 @@
+{
+ "skip_including": ["d3d11va.h", "dxva2.h", "qsv.h", "vda.h", "vdpau.h", "xvmc.h"],
+ "defines": "#define __STDC_CONSTANT_MACROS"
+}
diff --git a/SynoBuildConf/build b/SynoBuildConf/build
new file mode 100644
index 0000000000..b2b571e726
--- /dev/null
+++ b/SynoBuildConf/build
@@ -0,0 +1,130 @@
+#!/bin/bash
+# Copyright (c) 2000-2015 Synology Inc. All rights reserved.
+
+case ${MakeClean} in
+ [Yy][Ee][Ss])
+ if [ -f config.mak ]; then
+ make distclean
+ fi
+ ;;
+esac
+
+case ${CleanOnly} in
+ [Yy][Ee][Ss])
+ return
+ ;;
+esac
+
+CONFIGURE="./configure.syno"
+case "$PLATFORM_FAMILY" in
+ SYNOPLAT_F_I686|SYNOPLAT_F_X86_64)
+ arch="i686"
+ ;;
+ SYNOPLAT_F_PPC)
+ arch="powerpc"
+ BIG_ENDIAN="yes"
+ ;;
+ SYNOPLAT_F_ARMV5|SYNOPLAT_F_ARMV7)
+ arch="arm"
+ ;;
+ SYNOPLAT_F_ARMV8)
+ arch="arm64"
+ ;;
+ *)
+ SkipThisProject
+ return
+ ;;
+esac
+
+EVANSPORT_INC="-I${SysRootInclude}/intelce-utilities -I${SysRootInclude}/intelce-utilities/linux_user"
+EVANSPORT_LIB="-L${SysRootLib}/intelce-utilities -Wl,-rpath-link=${SysRootLib}/intelce-utilities"
+
+JSONC_INC=$(pkg-config --cflags json-c)
+JSONC_LIB=$(pkg-config --libs json-c)
+
+CFLAGS="${CFLAGS} -DSYNO_DSM"
+
+COMMON_CONFIG="
+ --prefix=/usr
+ --incdir=\${prefix}/include/ffmpeg
+ --arch=${arch}
+ --target-os=linux
+ --cross-prefix=${ToolChainPrefix}
+ --enable-cross-compile
+ --enable-optimizations
+ --enable-pic
+ --enable-gpl
+ --enable-shared
+ --disable-static
+ --enable-version3
+ --enable-nonfree
+ --enable-libfaac
+ --enable-encoders
+ --enable-pthreads
+ --disable-bzlib --disable-protocol=rtp --disable-muxer=image2 --disable-muxer=image2pipe
+ --disable-swscale-alpha
+ --disable-ffserver
+ --disable-ffplay
+ --disable-devices
+ --disable-bzlib
+ --disable-altivec
+ --enable-libopencore-amrnb
+ --enable-libopencore-amrwb
+ --enable-libmp3lame
+ --disable-vaapi
+ --disable-decoder=amrnb
+ --disable-encoder=zmbv
+ --disable-encoder=dca
+ --disable-encoder=ac3
+ --disable-encoder=ac3_fixed
+ --disable-encoder=eac3
+ --disable-decoder=dca
+ --disable-decoder=eac3
+ --disable-decoder=truehd
+ --cc=${CC}
+ "
+
+if checkPlatformFunction SYNO_PLAT_NEON_LIBSWSCALE; then
+ # for alpine neon libswscale patch
+ export EXPORT_BUILD_TARGET="ALPINE"
+fi
+
+if checkPlatformFunction SYNO_FEA_FFMPEG_SMD; then
+ # for evansport platform
+ # add -DSYNO_EVANSPORT for header files in intelce-utilities
+ env CC=${CC} \
+ CFLAGS="${CFLAGS} ${EVANSPORT_INC} ${JSONC_INC} -DSYNO_ENABLE_SMD -DSYNO_EVANSPORT" \
+ LDFLAGS="${LDFLAGS} ${EVANSPORT_LIB}" \
+ CHECK_CFLAG="gnu99" \
+ EVANSPORT_LIB="${EVANSPORT_LIB}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-yasm \
+ --enable-libx264 \
+ --enable-encoder=libx264 \
+ --enable-libh264_smd \
+ --enable-smd \
+ --disable-filter=hqdn3d \
+ --extra-libs="-lgdl -losal -lpal -lsven -lismd_core -lismd_audio -lismd_viddec -lismd_videnc -lismd_vidpproc -lplatform_config -lffmpeg_plugin ${JSONC_LIB}"
+elif checkPlatformFunction SYNO_FEA_FFMPEG_ENABLE_X264; then
+ # for x86_64, alpine
+ env CC=${CC} \
+ CFLAGS="${CFLAGS}" \
+ LDFLAGS="${LDFLAGS}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-yasm \
+ --enable-libx264 \
+ --enable-encoder=libx264
+else
+ env CC=${CC} \
+ CFLAGS="${CFLAGS}" \
+ LDFLAGS="${LDFLAGS}" \
+ bigendian_platform="${BIG_ENDIAN}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG}
+fi
+
+make ${MAKE_FLAGS}
+make tools/qt-faststart ${MAKE_FLAGS}
+# vim:ft=sh
diff --git a/SynoBuildConf/build-virtual-media-server b/SynoBuildConf/build-virtual-media-server
new file mode 100755
index 0000000000..b629df93b6
--- /dev/null
+++ b/SynoBuildConf/build-virtual-media-server
@@ -0,0 +1,164 @@
+#!/bin/bash
+# Copyright (c) 2000-2013 Synology Inc. All rights reserved.
+
+case ${MakeClean} in
+ [Yy][Ee][Ss])
+ if [ -f config.mak ]; then
+ make distclean
+ fi
+ ;;
+esac
+
+case ${CleanOnly} in
+ [Yy][Ee][Ss])
+ return
+ ;;
+esac
+
+CONFIGURE="./configure.syno"
+case "$BUILD_TARGET" in
+ X64|BROMOLOW|CEDARVIEW|EVANSPORT|AVOTON|DOCKERX64|BROMOLOWESM|BRASWELL|APOLLOLAKE|GRANTLEY|BROADWELL|KVMX64|DENVERTON|BROADWELLNK|PURLEY|COFFEELAKE)
+ arch="i686"
+ ;;
+ PPC_QORIQ|PPC_853X)
+ arch="powerpc"
+ BIG_ENDIAN="yes"
+ ;;
+ ALPINE)
+ arch="armv7"
+ ALPINE_EXTRA_CFLAGS="-DSYNO_PLAT_NEON_LIBSWSCALE -I${SysRootPrefix}/pkg/include"
+ ALPINE_EXTRA_LDFLAGS="-L${SysRootPrefix}/pkg/lib"
+ ;;
+ MARVELL_ARMADA370|MARVELL_ARMADA375|MARVELL_ARMADAXP|MARVELL_ARMADA38X|MINDSPEED_COMCERTO2K|BROADCOM_NORTHSTARPLUS|STM_MONACO|HISILICON_HI3535|HISILICON_HI3536)
+ arch="armv7"
+ ;;
+ REALTEK_RTD1296|MARVELL_ARMADA37XX)
+ arch="aarch64"
+ ;;
+ MARVELL_88F6281)
+ arch="arm"
+ ;;
+ *)
+ echo "This platform($BUILD_TARGET) is not supported yet."
+ return
+ ;;
+esac
+
+STANDALONE="FALSE"
+
+JSONC_INC=$(pkg-config --cflags json-c)
+JSONC_LIB=$(pkg-config --libs json-c)
+
+if [ "TRUE" = "${STANDALONE}" ]; then
+ CUSTOM_CONFIG="
+ --disable-shared
+ --enable-static
+ "
+ CUSTOM_CFLAGS="-DSTANDALONE"
+else
+ CUSTOM_CONFIG="
+ --enable-shared
+ --disable-static
+ "
+ CUSTOM_CFLAGS=""
+fi
+
+COMMON_RPATH="-Wl,-rpath=/var/packages/MediaServer/target/lib/ffmpeg -Wl,-rpath=/var/packages/MediaServer/target/lib"
+CFLAGS="${CFLAGS} ${CUSTOM_CFLAGS} -DSYNO_MEDIASERVER"
+LDFLAGS="${LDFLAGS} ${COMMON_RPATH}"
+
+COMMON_CONFIG="
+ --prefix=/usr/pkg
+ --incdir=\${prefix}/include/ffmpeg
+ --arch=${arch}
+ --target-os=linux
+ --cross-prefix=${ToolChainPrefix}
+ --enable-cross-compile
+ --enable-optimizations
+ --enable-pic
+ --enable-gpl
+ --enable-version3
+ --enable-nonfree
+ --enable-libfaac
+ --enable-encoders
+ --enable-pthreads
+ --disable-muxer=image2 --disable-muxer=image2pipe
+ --disable-swscale-alpha
+ --disable-ffplay
+ --disable-doc
+ --disable-devices
+ --disable-bzlib
+ --disable-altivec
+ --enable-libopencore-amrnb
+ --enable-libopencore-amrwb
+ --enable-libmp3lame
+ --disable-decoder=amrnb
+ --disable-encoder=zmbv
+ --cc=${CC}
+ ${CUSTOM_CONFIG}
+ "
+
+export EXPORT_BUILD_TARGET="${BUILD_TARGET}"
+
+if [ "i686" = "${arch}" -a "EVANSPORT" = "${BUILD_TARGET}" ]; then
+
+EVANSPORT_INC="-I${SysRootInclude}/intelce-utilities -I${SysRootInclude}/intelce-utilities/linux_user"
+EVANSPORT_LDFLAGS="-L${SysRootLib}/intelce-utilities"
+EVANSPORT_RPATH_LINK="-Wl,-rpath-link=${SysRootLib}/intelce-utilities"
+
+# for evansport platform
+# add -DSYNO_EVANSPORT for header files in intelce-utilities
+
+env CC=${CC} \
+ CFLAGS="${CFLAGS} ${EVANSPORT_INC} ${JSONC_INC} -DSYNO_ENABLE_SMD -DSYNO_EVANSPORT" \
+ LDFLAGS="${LDFLAGS} ${EVANSPORT_LDFLAGS} ${EVANSPORT_RPATH_LINK}" \
+ CHECK_CFLAG="gnu99" \
+ EVANSPORT_LIB="${EVANSPORT_RPATH_LINK}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-yasm \
+ --enable-libx264 \
+ --enable-encoder=libx264 \
+ --enable-libh264_smd \
+ --enable-smd \
+ --disable-filter=hqdn3d \
+ --extra-libs="${JSONC_LIB} -lgdl -losal -lpal -lsven -lismd_core -lismd_audio -lismd_viddec -lismd_videnc -lismd_vidpproc -lplatform_config -lffmpeg_plugin"
+
+elif [ "i686" = "${arch}" -o "ALPINE" = "${BUILD_TARGET}" ]; then
+env CC=${CC} \
+ CFLAGS="${CFLAGS} ${ALPINE_EXTRA_CFLAGS}" \
+ LDFLAGS="${LDFLAGS} ${ALPINE_EXTRA_LDFLAGS}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-yasm \
+ --enable-libx264 \
+ --enable-encoder=libx264
+
+#support floating point platform with lame
+elif [ "powerpc" = "${arch}" -o "armv7" = "${arch}" -o "aarch64" = "${arch}" ]; then
+env CC=${CC} \
+ CFLAGS="${CFLAGS}" \
+ LDFLAGS="${LDFLAGS}" \
+ bigendian_platform="${BIG_ENDIAN}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-libfdk-aac
+
+#only support fixed point platform with shine
+elif [ "arm" = "${arch}" ]; then
+env CC=${CC} \
+ CFLAGS="${CFLAGS}" \
+ LDFLAGS="${LDFLAGS}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-libshine \
+ --enable-libfdk-aac
+
+else
+ echo "This platform($BUILD_TARGET) is not supported yet."
+ return
+fi
+
+make ${MAKE_FLAGS}
+make tools/qt-faststart ${MAKE_FLAGS}
+# vim:ft=sh
diff --git a/SynoBuildConf/build-virtual-mplayer2 b/SynoBuildConf/build-virtual-mplayer2
new file mode 100755
index 0000000000..94bcca96ce
--- /dev/null
+++ b/SynoBuildConf/build-virtual-mplayer2
@@ -0,0 +1,110 @@
+#!/bin/bash
+# Copyright (c) 2000-2015 Synology Inc. All rights reserved.
+
+case ${MakeClean} in
+ [Yy][Ee][Ss])
+ if [ -f config.mak ]; then
+ make distclean
+ fi
+ ;;
+esac
+
+case ${CleanOnly} in
+ [Yy][Ee][Ss])
+ return
+ ;;
+esac
+
+CONFIGURE="./configure.syno"
+case "$BUILD_TARGET" in
+ X64|BROMOLOW|CEDARVIEW|EVANSPORT|GRANTLEY|BRASWELL|APOLLOLAKE|BROADWELL|AVOTON|KVMX64|DENVERTON|BROADWELLNK|PURLEY|COFFEELAKE)
+ arch="i686"
+ ;;
+ PPC_QORIQ)
+ arch="powerpc"
+ BIG_ENDIAN="yes"
+ ;;
+ PPC_853X|PPC_854X)
+ arch="powerpc"
+ BIG_ENDIAN="yes"
+ # let 853x use mp3float to decode mp3, to avoid Audio Station bug #1134
+ extra_config="--disable-decoder=mp3"
+ ;;
+ MARVELL_ARMADA370|MARVELL_ARMADAXP|MARVELL_ARMADA375|MARVELL_ARMADA38X)
+ arch="armada"
+ ;;
+ ALPINE)
+ ALPINE_EXTRA_CFLAGS="-DSYNO_PLAT_NEON_LIBSWSCALE"
+ arch="arm"
+ ;;
+ REALTEK_RTD1296|MARVELL_ARMADA37XX)
+ arch="aarch64"
+ ;;
+ MINDSPEED_COMCERTO2K|BROADCOM_NORTHSTARPLUS|STM_MONACO|HISILICON_HI3535|HISILICON_HI3536)
+ arch="arm"
+ ;;
+ MARVELL_88F6281)
+ arch="arm"
+ ;;
+ TI_816X)
+ arch="arm"
+ ;;
+ *)
+ echo "This platform($BUILD_TARGET) is not supported yet. Error me!!"
+ return
+ ;;
+esac
+
+COMMON_INC=""
+COMMON_LIB=""
+
+COMMON_CONFIG="
+ --arch=${arch}
+ --target-os=linux
+ --cross-prefix=${ToolChainPrefix}
+ --enable-cross-compile
+ --enable-optimizations
+ --enable-pic
+ --enable-shared
+ --disable-static
+ --enable-version3
+ --enable-encoders
+ --enable-pthreads
+ --enable-libmp3lame
+ --enable-libsoxr
+ --disable-swscale-alpha
+ --disable-postproc
+ --disable-ffserver
+ --disable-ffplay
+ --disable-bzlib
+ --disable-altivec
+ --disable-decoder=amrnb
+ --disable-indev=alsa
+ --disable-outdev=alsa
+ --disable-encoder=zmbv
+ --disable-encoder=dca
+ --disable-encoder=ac3
+ --disable-encoder=ac3_fixed
+ --disable-encoder=eac3
+ --disable-decoder=dca
+ --disable-decoder=eac3
+ --disable-decoder=truehd
+ --enable-avresample
+ --disable-doc
+ "
+
+export EXPORT_BUILD_TARGET="${BUILD_TARGET}"
+
+env CC=${CC} \
+ CFLAGS="${CFLAGS} ${ALPINE_EXTRA_CFLAGS} -DSYNO_AUDIOSTATION" \
+ CHECK_CFLAG="gnu99" \
+ LDFLAGS="${LDFLAGS} \
+ -Wl,-rpath,/var/packages/AudioStation/target/lib/ffmpeg \
+ -Wl,-rpath,/var/packages/AudioStation/target/lib" \
+ bigendian_platform="${BIG_ENDIAN}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ ${extra_config}
+
+make ${MAKE_FLAGS}
+# vim:ft=sh
diff --git a/SynoBuildConf/build-virtual-video-station b/SynoBuildConf/build-virtual-video-station
new file mode 100755
index 0000000000..f1887fe92a
--- /dev/null
+++ b/SynoBuildConf/build-virtual-video-station
@@ -0,0 +1,165 @@
+#!/bin/bash
+# Copyright (c) 2000-2013 Synology Inc. All rights reserved.
+
+case ${MakeClean} in
+ [Yy][Ee][Ss])
+ if [ -f config.mak ]; then
+ make distclean
+ fi
+ ;;
+esac
+
+case ${CleanOnly} in
+ [Yy][Ee][Ss])
+ return
+ ;;
+esac
+
+CONFIGURE="./configure.syno"
+case "$BUILD_TARGET" in
+ X64|BROMOLOW|CEDARVIEW|EVANSPORT|AVOTON|DOCKERX64|BROMOLOWESM|BRASWELL|APOLLOLAKE|GRANTLEY|BROADWELL|KVMX64|DENVERTON|BROADWELLNK|PURLEY|COFFEELAKE)
+ arch="i686"
+ ;;
+ PPC_QORIQ|PPC_853X)
+ arch="powerpc"
+ BIG_ENDIAN="yes"
+ ;;
+ ALPINE)
+ arch="armv7"
+ ALPINE_EXTRA_CFLAGS="-DSYNO_PLAT_NEON_LIBSWSCALE -I${SysRootPrefix}/pkg/include"
+ ALPINE_EXTRA_LDFLAGS="-L${SysRootPrefix}/pkg/lib"
+ ;;
+ MARVELL_ARMADA370|MARVELL_ARMADA375|MARVELL_ARMADAXP|MARVELL_ARMADA38X|MINDSPEED_COMCERTO2K|BROADCOM_NORTHSTARPLUS|STM_MONACO|HISILICON_HI3535|HISILICON_HI3536)
+ arch="armv7"
+ ;;
+ REALTEK_RTD1296|MARVELL_ARMADA37XX)
+ arch="aarch64"
+ ;;
+ MARVELL_88F6281)
+ arch="arm"
+ ;;
+ *)
+ echo "This platform($BUILD_TARGET) is not supported yet."
+ return
+ ;;
+esac
+
+STANDALONE="FALSE"
+
+JSONC_INC=$(pkg-config --cflags json-c)
+JSONC_LIB=$(pkg-config --libs json-c)
+
+if [ "TRUE" = "${STANDALONE}" ]; then
+ CUSTOM_CONFIG="
+ --disable-shared
+ --enable-static
+ "
+ CUSTOM_CFLAGS="-DSTANDALONE"
+else
+ CUSTOM_CONFIG="
+ --enable-shared
+ --disable-static
+ "
+ CUSTOM_CFLAGS=""
+fi
+
+COMMON_RPATH="-Wl,-rpath=/var/packages/VideoStation/target/lib/ffmpeg -Wl,-rpath=/var/packages/VideoStation/target/lib"
+CFLAGS="${CFLAGS} ${CUSTOM_CFLAGS} -DSYNO_VIDEOSTATION"
+LDFLAGS="${LDFLAGS} ${COMMON_RPATH}"
+
+COMMON_CONFIG="
+ --prefix=/usr/pkg
+ --incdir=\${prefix}/include/ffmpeg
+ --arch=${arch}
+ --target-os=linux
+ --cross-prefix=${ToolChainPrefix}
+ --enable-cross-compile
+ --enable-optimizations
+ --enable-pic
+ --enable-gpl
+ --enable-version3
+ --enable-nonfree
+ --enable-libfaac
+ --enable-encoders
+ --enable-pthreads
+ --disable-muxer=image2 --disable-muxer=image2pipe
+ --disable-swscale-alpha
+ --disable-ffplay
+ --disable-ffserver
+ --disable-doc
+ --disable-devices
+ --disable-bzlib
+ --disable-altivec
+ --enable-libopencore-amrnb
+ --enable-libopencore-amrwb
+ --enable-libmp3lame
+ --disable-decoder=amrnb
+ --disable-encoder=zmbv
+ --cc=${CC}
+ ${CUSTOM_CONFIG}
+ "
+
+export EXPORT_BUILD_TARGET="${BUILD_TARGET}"
+
+if [ "i686" = "${arch}" -a "EVANSPORT" = "${BUILD_TARGET}" ]; then
+
+EVANSPORT_INC="-I${SysRootInclude}/intelce-utilities -I${SysRootInclude}/intelce-utilities/linux_user"
+EVANSPORT_LDFLAGS="-L${SysRootLib}/intelce-utilities"
+EVANSPORT_RPATH_LINK="-Wl,-rpath-link=${SysRootLib}/intelce-utilities"
+
+# for evansport platform
+# add -DSYNO_EVANSPORT for header files in intelce-utilities
+
+env CC=${CC} \
+ CFLAGS="${CFLAGS} ${EVANSPORT_INC} ${JSONC_INC} -DSYNO_ENABLE_SMD -DSYNO_EVANSPORT" \
+ LDFLAGS="${LDFLAGS} ${EVANSPORT_LDFLAGS} ${EVANSPORT_RPATH_LINK}" \
+ CHECK_CFLAG="gnu99" \
+ EVANSPORT_LIB="${EVANSPORT_RPATH_LINK}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-yasm \
+ --enable-libx264 \
+ --enable-encoder=libx264 \
+ --enable-libh264_smd \
+ --enable-smd \
+ --disable-filter=hqdn3d \
+ --extra-libs="${JSONC_LIB} -lgdl -losal -lpal -lsven -lismd_core -lismd_audio -lismd_viddec -lismd_videnc -lismd_vidpproc -lplatform_config -lffmpeg_plugin"
+
+elif [ "i686" = "${arch}" -o "ALPINE" = "${BUILD_TARGET}" ]; then
+env CC=${CC} \
+ CFLAGS="${CFLAGS} ${ALPINE_EXTRA_CFLAGS}" \
+ LDFLAGS="${LDFLAGS} ${ALPINE_EXTRA_LDFLAGS}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-yasm \
+ --enable-libx264 \
+ --enable-encoder=libx264
+
+#support floating point platform with lame
+elif [ "powerpc" = "${arch}" -o "armv7" = "${arch}" -o "aarch64" = "${arch}" ]; then
+env CC=${CC} \
+ CFLAGS="${CFLAGS}" \
+ LDFLAGS="${LDFLAGS}" \
+ bigendian_platform="${BIG_ENDIAN}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-libfdk-aac
+
+#only support fixed point platform with shine
+elif [ "arm" = "${arch}" ]; then
+env CC=${CC} \
+ CFLAGS="${CFLAGS}" \
+ LDFLAGS="${LDFLAGS}" \
+ ${CONFIGURE} \
+ ${COMMON_CONFIG} \
+ --enable-libshine \
+ --enable-libfdk-aac
+
+else
+ echo "This platform($BUILD_TARGET) is not supported yet."
+ return
+fi
+
+make ${MAKE_FLAGS}
+make tools/qt-faststart ${MAKE_FLAGS}
+# vim:ft=sh
diff --git a/SynoBuildConf/depends b/SynoBuildConf/depends
new file mode 100644
index 0000000000..928b66dbc1
--- /dev/null
+++ b/SynoBuildConf/depends
@@ -0,0 +1,10 @@
+[BuildDependent-Tag]
+opencore-amr-0.1.2
+xz-5.x
+intelce-utilities
+json-c-0.x
+zlib-1.x
+lame-3.99.x
+faac-1.28
+x264
+
diff --git a/SynoBuildConf/depends-virtual-media-server b/SynoBuildConf/depends-virtual-media-server
new file mode 100755
index 0000000000..b63acaefc5
--- /dev/null
+++ b/SynoBuildConf/depends-virtual-media-server
@@ -0,0 +1,20 @@
+[BuildDependent]
+libshine-3.0.x
+fdk-aac-0.1.x
+x264-virtual-media-server
+
+[BuildDependent-Tag]
+opencore-amr-0.1.2
+xz-5.x
+intelce-utilities
+json-c-0.x
+zlib-1.x
+lame-3.99.x
+faac-1.28
+
+[ReferenceOnly-Tag]
+
+[ReferenceOnly]
+
+[default]
+all="6.0"
diff --git a/SynoBuildConf/depends-virtual-mplayer2 b/SynoBuildConf/depends-virtual-mplayer2
new file mode 100755
index 0000000000..a050cea864
--- /dev/null
+++ b/SynoBuildConf/depends-virtual-mplayer2
@@ -0,0 +1,11 @@
+[BuildDependent]
+soxr
+
+[BuildDependent-Tag]
+
+[ReferenceOnly-Tag]
+
+[ReferenceOnly]
+
+[default]
+all="6.0"
diff --git a/SynoBuildConf/depends-virtual-video-station b/SynoBuildConf/depends-virtual-video-station
new file mode 100755
index 0000000000..6f40bd495f
--- /dev/null
+++ b/SynoBuildConf/depends-virtual-video-station
@@ -0,0 +1,20 @@
+[BuildDependent]
+libshine-3.0.x
+fdk-aac-0.1.x
+x264-virtual-video-station
+
+[BuildDependent-Tag]
+opencore-amr-0.1.2
+xz-5.x
+intelce-utilities
+json-c-0.x
+zlib-1.x
+lame-3.99.x
+faac-1.28
+
+[ReferenceOnly-Tag]
+
+[ReferenceOnly]
+
+[default]
+all="6.0"
diff --git a/SynoBuildConf/error-virtual-media-server b/SynoBuildConf/error-virtual-media-server
new file mode 100644
index 0000000000..3525a4713b
--- /dev/null
+++ b/SynoBuildConf/error-virtual-media-server
@@ -0,0 +1,3 @@
+{
+ "Error": ["OS_INFO"]
+}
diff --git a/SynoBuildConf/error-virtual-video-station b/SynoBuildConf/error-virtual-video-station
new file mode 100644
index 0000000000..3525a4713b
--- /dev/null
+++ b/SynoBuildConf/error-virtual-video-station
@@ -0,0 +1,3 @@
+{
+ "Error": ["OS_INFO"]
+}
diff --git a/SynoBuildConf/install b/SynoBuildConf/install
new file mode 100644
index 0000000000..c8761311cd
--- /dev/null
+++ b/SynoBuildConf/install
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Copyright (c) 2000-2015 Synology Inc. All rights reserved.
+
+INSTALL_DIRS="
+ /lib
+ /usr/bin
+"
+INSTALL_LIB="
+ ./libavcodec/libavcodec.so.56
+ ./libavdevice/libavdevice.so.56
+ ./libavfilter/libavfilter.so.5
+ ./libavformat/libavformat.so.56
+ ./libavutil/libavutil.so.54
+ ./libpostproc/libpostproc.so.53
+ ./libswresample/libswresample.so.1
+ ./libswscale/libswscale.so.3
+"
+INSTALL_USR_BIN="
+ ./tools/qt-faststart
+"
+DoInstall
+
+# to avoid SynoInstall strip check lead to error
+# install ffmpeg_g when DEBUG
+if [ "x$NOSTRIP" != "xNOSTRIP" ]; then
+ InstallFiles "/usr/bin" 755 ffmpeg
+else
+ InstallFiles "/usr/bin" 755 ffmpeg_g
+fi
+
+# vim:ft=sh
diff --git a/SynoBuildConf/install-dev b/SynoBuildConf/install-dev
new file mode 100644
index 0000000000..45f4195424
--- /dev/null
+++ b/SynoBuildConf/install-dev
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Copyright (c) 2000-2015 Synology Inc. All rights reserved.
+
+case ${CleanOnly} in
+ [Yy][Ee][Ss])
+ return
+ ;;
+esac
+
+FFMEPG_INCLUDE="$DebDevDir$SynoIncludeDir/ffmpeg"
+[ -d $FFMEPG_INCLUDE ] || install -d $FFMEPG_INCLUDE
+install -m 644 synoconfig.h "$FFMEPG_INCLUDE"
+
+make DESTDIR=$DebDevDir install
+
+# Remove document
+rm -rf "$DebDevDir${SynoDir}/share"
+rm -rf "$DebDevDir${SynoDir}/bin"
+
+# vim:ft=sh
diff --git a/SynoBuildConf/install-dev-virtual-media-server b/SynoBuildConf/install-dev-virtual-media-server
new file mode 100755
index 0000000000..16bf3da105
--- /dev/null
+++ b/SynoBuildConf/install-dev-virtual-media-server
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Copyright (c) 2000-2013 Synology Inc. All rights reserved.
+
+case ${CleanOnly} in
+ [Yy][Ee][Ss])
+ return
+ ;;
+esac
+
+SynoPkgDir="/usr/pkg"
+FFMEPG_INCLUDE="$DebDevDir$SynoPkgDir/include/ffmpeg"
+[ -d $FFMEPG_INCLUDE ] || install -d $FFMEPG_INCLUDE
+install -m 644 synoconfig.h "$FFMEPG_INCLUDE"
+
+make DESTDIR=$DebDevDir install
+# Remove document
+rm -rf "$DebDevDir${SynoPkgDir}/share"
+rm -rf "$DebDevDir${SynoPkgDir}/bin"
+
+# vim:ft=sh
diff --git a/SynoBuildConf/install-dev-virtual-video-station b/SynoBuildConf/install-dev-virtual-video-station
new file mode 100755
index 0000000000..16bf3da105
--- /dev/null
+++ b/SynoBuildConf/install-dev-virtual-video-station
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Copyright (c) 2000-2013 Synology Inc. All rights reserved.
+
+case ${CleanOnly} in
+ [Yy][Ee][Ss])
+ return
+ ;;
+esac
+
+SynoPkgDir="/usr/pkg"
+FFMEPG_INCLUDE="$DebDevDir$SynoPkgDir/include/ffmpeg"
+[ -d $FFMEPG_INCLUDE ] || install -d $FFMEPG_INCLUDE
+install -m 644 synoconfig.h "$FFMEPG_INCLUDE"
+
+make DESTDIR=$DebDevDir install
+# Remove document
+rm -rf "$DebDevDir${SynoPkgDir}/share"
+rm -rf "$DebDevDir${SynoPkgDir}/bin"
+
+# vim:ft=sh
diff --git a/SynoBuildConf/install-virtual-media-server b/SynoBuildConf/install-virtual-media-server
new file mode 100755
index 0000000000..7ef6aec144
--- /dev/null
+++ b/SynoBuildConf/install-virtual-media-server
@@ -0,0 +1,50 @@
+#!/bin/bash
+# Copyright (c) 2000-2012 Synology Inc. All rights reserved.
+libshine="libshine-3.0.x"
+libfdkaac="fdk-aac-0.1.x"
+
+case "$BUILD_TARGET" in
+ X64|BROMOLOW|CEDARVIEW|EVANSPORT|AVOTON|DOCKERX64|GRANTLEY|BRASWELL|APOLLOLAKE|BROADWELL|KVMX64|ALPINE|DENVERTON|BROADWELLNK|PURLEY|COFFEELAKE)
+ IncludeProjects=""
+ ;;
+ PPC_853X|PPC_QORIQ| \
+ MARVELL_88F6281|MARVELL_ARMADAXP|MARVELL_ARMADA370|MARVELL_ARMADA375|MARVELL_ARMADA38X|REALTEK_RTD1296|\
+ MINDSPEED_COMCERTO2K|BROADCOM_NORTHSTARPLUS|STM_MONACO|HISILICON_HI3536|MARVELL_ARMADA37XX)
+ IncludeProjects="${libshine} ${libfdkaac}"
+ ;;
+ *)
+ echo "This platform($BUILD_TARGET) is not supported yet."
+ exit 1
+ ;;
+esac
+
+# install related projects
+for prj in $IncludeProjects; do
+ env INST_DIR="$INST_DIR" \
+ $ScriptsDir/SynoInstall --single ${prj}
+done
+
+# install ffmpeg project
+InstallPreparePkgDir $INST_DIR "lib/ffmpeg"
+InstallPreparePkgDir $INST_DIR "bin"
+
+LibList=(
+ libavcodec/libavcodec.so.56
+ libavdevice/libavdevice.so.56
+ libavfilter/libavfilter.so.5
+ libavformat/libavformat.so.56
+ libavutil/libavutil.so.54
+ libpostproc/libpostproc.so.53
+ libswresample/libswresample.so.1
+ libswscale/libswscale.so.3
+ )
+
+LibNum=${#LibList[@]}
+
+for (( i=0 ; i < $LibNum ; i++ ))
+do
+ echo "install ${LibList[$i]}"
+ InstallPkgFiles $INST_DIR "lib/ffmpeg" 644 ${LibList[$i]}
+done
+
+InstallPkgFiles $INST_DIR "bin" 755 "ffmpeg ffserver ffprobe"
diff --git a/SynoBuildConf/install-virtual-mplayer2 b/SynoBuildConf/install-virtual-mplayer2
new file mode 100755
index 0000000000..5e984171af
--- /dev/null
+++ b/SynoBuildConf/install-virtual-mplayer2
@@ -0,0 +1,30 @@
+#!/bin/bash
+# Copyright (c) 2000-2012 Synology Inc. All rights reserved.
+
+INST_DIR="/tmp/_audiostation"
+
+InstallPreparePkgDir $INST_DIR "lib/ffmpeg"
+InstallPreparePkgDir $INST_DIR "bin"
+
+LibList=(
+ libavcodec/libavcodec.so.56
+ libavdevice/libavdevice.so.56
+ libavfilter/libavfilter.so.5
+ libavformat/libavformat.so.56
+ libavutil/libavutil.so.54
+ libswresample/libswresample.so.1
+ libswscale/libswscale.so.3
+ libavresample/libavresample.so.2
+ )
+
+LibNum=${#LibList[@]}
+
+for (( i=0 ; i < $LibNum ; i++ ))
+do
+echo "install ${LibList[$i]}"
+InstallPkgFiles $INST_DIR "lib/ffmpeg" 644 ${LibList[$i]}
+done
+
+InstallPkgFiles $INST_DIR "bin" 755 "ffmpeg"
+
+DoInstall
diff --git a/SynoBuildConf/install-virtual-video-station b/SynoBuildConf/install-virtual-video-station
new file mode 100755
index 0000000000..aa753c4f02
--- /dev/null
+++ b/SynoBuildConf/install-virtual-video-station
@@ -0,0 +1,50 @@
+#!/bin/bash
+# Copyright (c) 2000-2012 Synology Inc. All rights reserved.
+libshine="libshine-3.0.x"
+libfdkaac="fdk-aac-0.1.x"
+
+case "$BUILD_TARGET" in
+ X64|BROMOLOW|CEDARVIEW|EVANSPORT|AVOTON|DOCKERX64|GRANTLEY|BRASWELL|APOLLOLAKE|BROADWELL|KVMX64|ALPINE|DENVERTON|BROADWELLNK|PURLEY|COFFEELAKE)
+ IncludeProjects=""
+ ;;
+ PPC_853X|PPC_QORIQ| \
+ MARVELL_88F6281|MARVELL_ARMADAXP|MARVELL_ARMADA370|MARVELL_ARMADA375|MARVELL_ARMADA38X|REALTEK_RTD1296|\
+ MINDSPEED_COMCERTO2K|BROADCOM_NORTHSTARPLUS|STM_MONACO|HISILICON_HI3536|MARVELL_ARMADA37XX)
+ IncludeProjects="${libshine} ${libfdkaac}"
+ ;;
+ *)
+ echo "This platform($BUILD_TARGET) is not supported yet."
+ exit 1
+ ;;
+esac
+
+# install related projects
+for prj in $IncludeProjects; do
+ env INST_DIR="$INST_DIR" \
+ $ScriptsDir/SynoInstall --single ${prj}
+done
+
+# install ffmpeg project
+InstallPreparePkgDir $INST_DIR "lib/ffmpeg"
+InstallPreparePkgDir $INST_DIR "bin"
+
+LibList=(
+ libavcodec/libavcodec.so.56
+ libavdevice/libavdevice.so.56
+ libavfilter/libavfilter.so.5
+ libavformat/libavformat.so.56
+ libavutil/libavutil.so.54
+ libpostproc/libpostproc.so.53
+ libswresample/libswresample.so.1
+ libswscale/libswscale.so.3
+ )
+
+LibNum=${#LibList[@]}
+
+for (( i=0 ; i < $LibNum ; i++ ))
+do
+ echo "install ${LibList[$i]}"
+ InstallPkgFiles $INST_DIR "lib/ffmpeg" 644 ${LibList[$i]}
+done
+
+InstallPkgFiles $INST_DIR "bin" 755 "ffmpeg ffprobe"
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000000..860487ca19
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+2.7.1
diff --git a/configure b/configure
index 3960b735c1..0a4efb8a8e 100755
--- a/configure
+++ b/configure
@@ -281,6 +281,7 @@ External library support:
--enable-x11grab enable X11 grabbing (legacy) [no]
--disable-xlib disable xlib [autodetect]
--disable-zlib disable zlib [autodetect]
+ --enable-smd enable hardware decoding[disables software decoding]
Toolchain options:
--arch=ARCH select architecture [$arch]
@@ -419,7 +420,7 @@ log(){
log_file(){
log BEGIN $1
- pr -n -t $1 >> $logfile
+# pr -n -t $1 >> $logfile
log END $1
}
@@ -1412,6 +1413,7 @@ EXTERNAL_LIBRARY_LIST="
libwavpack
libwebp
libx264
+ libh264_smd
libx265
libxavs
libxcb
@@ -1433,6 +1435,7 @@ EXTERNAL_LIBRARY_LIST="
x11grab
xlib
zlib
+ smd
"
DOCUMENT_LIST="
@@ -2476,6 +2479,7 @@ libwavpack_encoder_deps="libwavpack"
libwebp_encoder_deps="libwebp"
libwebp_anim_encoder_deps="libwebp"
libx264_encoder_deps="libx264"
+libh264_smd_encoder_deps="libh264_smd"
libx264rgb_encoder_deps="libx264"
libx264rgb_encoder_select="libx264_encoder"
libx265_encoder_deps="libx265"
@@ -2965,7 +2969,7 @@ print_3_columns() {
show_list() {
suffix=_$1
shift
- echo $* | sed s/$suffix//g | print_3_columns
+# echo $* | sed s/$suffix//g | print_3_columns
exit 0
}
@@ -3549,14 +3553,14 @@ probe_cc(){
_type=pathscale
_ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
_depflags='-MMD -MF $(@:.o=.d) -MT $@'
- _cflags_speed='-O2'
+ _cflags_speed='-O3'
_cflags_size='-Os'
_flags_filter='filter_out -Wdisabled-optimization'
elif $_cc -v 2>&1 | grep -q Open64; then
_type=open64
_ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
_depflags='-MMD -MF $(@:.o=.d) -MT $@'
- _cflags_speed='-O2'
+ _cflags_speed='-O3'
_cflags_size='-Os'
_flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
elif $_cc -V 2>&1 | grep -q Portland; then
@@ -4096,7 +4100,13 @@ fi
add_cppflags -D_ISOC99_SOURCE
add_cxxflags -D__STDC_CONSTANT_MACROS
-check_cflags -std=c99
+
+if [ "${CHECK_CFLAG}" = gnu99 ]; then
+ check_cflags -std=gnu99
+else
+ check_cflags -std=c99
+fi
+
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
#include <stdlib.h>
EOF
@@ -4605,7 +4615,9 @@ EOF
check_cc <<EOF || die "endian test failed"
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
EOF
-od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
+if [ "yes" = "$bigendian_platform" ]; then
+ enable bigendian
+fi
if ! enabled ppc64 || enabled bigendian; then
disable vsx
@@ -5122,7 +5134,7 @@ enabled libpulse && require_pkg_config libpulse pulse/pulseaudio.h pa_c
enabled libquvi && require_pkg_config libquvi quvi/quvi.h quvi_init
enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
-enabled libshine && require_pkg_config shine shine/layer3.h shine_encode_buffer
+enabled libshine && require shine shine/layer3.h shine_encode_buffer -lm -lshine
enabled libsmbclient && { use_pkg_config smbclient libsmbclient.h smbc_init ||
require smbclient libsmbclient.h smbc_init -lsmbclient; }
enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr
@@ -5152,6 +5164,7 @@ enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFil
enabled libwebp && {
enabled libwebp_encoder && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
enabled libwebp_anim_encoder && { use_pkg_config "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit || disable libwebp_anim_encoder; } }
+enabled libh264_smd && require libffmpeg_plugin libffmpeg_plugin/ismd_ffmpeg_video_enc.h ismd_ffmpeg_video_encoder_dequeue -lffmpeg_plugin
enabled libx264 && { use_pkg_config x264 "stdint.h x264.h" x264_encoder_encode ||
{ require libx264 x264.h x264_encoder_encode -lx264 &&
warn "using libx264 without pkg-config"; } } &&
@@ -5512,7 +5525,7 @@ elif enabled gcc; then
check_cflags -Werror=implicit-function-declaration
check_cflags -Werror=missing-prototypes
check_cflags -Werror=return-type
- check_cflags -Werror=vla
+# check_cflags -Werror=vla
check_cflags -Wformat
check_cflags -fdiagnostics-color=auto
enabled extra_warnings || check_disable_warning -Wno-maybe-uninitialized
@@ -5779,7 +5792,7 @@ echo
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
echo "Enabled ${type}s:"
eval list=\$$(toupper $type)_LIST
- print_enabled '_*' $list | print_3_columns
+# print_enabled '_*' $list | print_3_columns
echo
done
@@ -6041,7 +6054,7 @@ Version: $version
Requires: $(enabled shared || echo $requires)
Requires.private: $(enabled shared && echo $requires)
Conflicts:
-Libs: -L\${libdir} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs)
+Libs: -L\${libdir} ${EVANSPORT_LIB} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs)
Libs.private: $(enabled shared && echo $libs)
Cflags: -I\${includedir}
EOF
diff --git a/ffmpeg.c b/ffmpeg.c
index f5029987ad..46ea2358dd 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -104,6 +104,87 @@
#include "libavutil/avassert.h"
+#include "synoconfig.h"
+
+#ifdef SYNO_EVANSPORT_SMD
+//smd headers
+#include "osal_type.h"
+#include "ismd_vidpproc.h"
+#include "libffmpeg_plugin/ismd_ffmpeg_util.h"
+#include "libffmpeg_plugin/ismd_ffmpeg_video_dec.h"
+#include "libffmpeg_plugin/ismd_ffmpeg_video_enc.h"
+#include "libffmpeg_plugin/ismd_ffmpeg_bitstream.h"
+
+#include "libavcodec/ismd_ffmpeg_audio_util.h"
+#include "libavformat/avformat.h"
+#include "libavcodec/h264_smd.h"
+#include "libavcodec/vc1.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/syno_trans_loading.h"
+#if CONFIG_LIBX264_ENCODER
+#include <x264.h>
+#endif
+
+typedef struct X264Context {
+ AVClass *class;
+#if CONFIG_LIBX264_ENCODER
+ x264_param_t params;
+ x264_t *enc;
+ x264_picture_t pic;
+#endif
+ uint8_t *sei;
+ int sei_size;
+ char *preset;
+ char *tune;
+ char *profile;
+ char *level;
+ int fastfirstpass;
+ char *wpredp;
+ char *x264opts;
+ float crf;
+ float crf_max;
+ int cqp;
+ int aq_mode;
+ float aq_strength;
+ char *psy_rd;
+ int psy;
+ int rc_lookahead;
+ int weightp;
+ int weightb;
+ int ssim;
+ int intra_refresh;
+ int bluray_compat;
+ int b_bias;
+ int b_pyramid;
+ int mixed_refs;
+ int dct8x8;
+ int fast_pskip;
+ int aud;
+ int mbtree;
+ char *deblock;
+ float cplxblur;
+ char *partitions;
+ int direct_pred;
+ int slice_max_size;
+ char *stats;
+ int nal_hrd;
+ int avcintra_class;
+ char *x264_params;
+#ifdef SYNO_EVANSPORT_FLV_EXTRADATA
+ bool dont_free_extradata;
+#endif
+} X264Context;
+
+static viddec_struct_t vid_dec;
+static videnc_struct_t vid_enc;
+bool smd_video_pipeline = false;
+int smd_frame_rate;
+static ismd_codec_type_t get_smd_codec_id(enum AVCodecID ffmpeg_codec_id);
+bool first_read_pts = true;
+int64_t last_pts = -1;
+//smd end
+#endif
+
const char program_name[] = "ffmpeg";
const int program_birth_year = 2000;
@@ -426,12 +507,27 @@ const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
static void ffmpeg_cleanup(int ret)
{
int i, j;
+#ifdef SYNO_EVANSPORT_SMD
+ ismd_result_t ret_val = ISMD_ERROR_UNSPECIFIED;
+#endif
if (do_benchmark) {
int maxrss = getmaxrss() / 1024;
printf("bench: maxrss=%ikB\n", maxrss);
}
+#ifdef SYNO_EVANSPORT_SMD
+ /**************** smd code *******************/
+ synoRemovePID(getpid());
+ if(smd_video_pipeline)
+ {
+ ret_val = ismd_ffmpeg_free_vid_enc_res(&vid_enc);
+ if(ret_val != ISMD_SUCCESS)
+ av_log(NULL,AV_LOG_ERROR,"could not free video encoder resources\n");
+ }
+ /**************** smd code end*******************/
+#endif
+
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
@@ -1018,6 +1114,12 @@ static void do_video_out(AVFormatContext *s,
}
ost->last_droped = nb_frames == nb0_frames && next_picture;
+#ifdef SYNO_EVANSPORT_SMD
+ if (smd_video_pipeline) {
+ nb_frames = 1;
+ }
+#endif
+
/* duplicates frame if needed */
for (i = 0; i < nb_frames; i++) {
AVFrame *in_picture;
@@ -1061,6 +1163,10 @@ static void do_video_out(AVFormatContext *s,
int got_packet, forced_keyframe = 0;
double pts_time;
+#ifdef SYNO_EVANSPORT_SMD
+ if(!smd_video_pipeline)
+ {
+#endif
if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
in_picture->top_field_first = !!ost->top_field_first;
@@ -1127,6 +1233,123 @@ static void do_video_out(AVFormatContext *s,
ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet);
update_benchmark("encode_video %d.%d", ost->file_index, ost->index);
+
+#ifdef SYNO_EVANSPORT_SMD
+ } else {
+ unsigned long fps_num;
+ unsigned long fps_den;
+ unsigned long macroblock_per_sec;
+ unsigned long max_macroblock_per_sec;
+ char* level;
+ bool override;
+ double temp_num;
+ int pkt_size;
+ X264Context *x4 = enc->priv_data;
+ smd_h264_picture_t pic_out;
+ got_packet = 0;
+ ret = 0;
+
+ if ((pkt_size = syno_ismd_ffmpeg_video_encoder_get_first_node_size(&vid_enc)) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "ismd_ffmpeg_video_encoder_dequeue_size_syno\n");
+ exit_program(1);
+ }
+ if (pkt_size > 0) {
+ if (syno_alloc_packet(&pkt, pkt_size) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "syno_alloc_packet error at encoder SMD\n");
+ exit_program(1);
+ }
+ ret = ismd_ffmpeg_video_encoder_dequeue(pkt.data, &pic_out,&vid_enc);
+ if (ret != pkt_size) {
+ av_log(NULL, AV_LOG_FATAL, "ismd_ffmpeg_video_encoder_dequeue size not conform\n");
+ }
+ memset(pkt.data + pkt.size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ }
+
+ if(ret > 0)
+ {
+ if (enable_dtv_smd) {
+ enc->coded_frame->pts = av_rescale_q(pic_out.i_pts, AV_TIME_BASE_Q, enc->time_base);
+ if (AV_NOPTS_VALUE != enc->coded_frame->pts) {
+ pkt.pts= enc->coded_frame->pts;
+ }
+ } else {
+ //TODO call just once
+ ismd_result_t ret_smd = ismd_viddec_get_frame_rate(vid_dec.viddec_handle, &fps_num, &fps_den, &override);
+ if (ret_smd == ISMD_SUCCESS)
+ {
+ temp_num = 90000/(double)fps_num;
+ smd_frame_rate = temp_num*fps_den;//smd clock resuolution is 90000 ticks
+ macroblock_per_sec = ((enc->width*enc->height)/256) *(fps_num/fps_den);
+ if(!x4->level)
+ level = "4.1";
+ else
+ level = x4->level;
+ max_macroblock_per_sec = ismd_ffmpeg_max_macroblock(level);
+ if(macroblock_per_sec > max_macroblock_per_sec)
+ {
+ av_log(enc,AV_LOG_INFO,"macroblocks_per_sec requested %ld\n",macroblock_per_sec);
+ av_log(enc,AV_LOG_INFO,"max macroblocks_per_sec suppored for level %s are %ld\n",level,max_macroblock_per_sec);
+ av_log(enc,AV_LOG_INFO,"please try transcoding to lower resolution\n");
+ exit_program(1);
+ }
+ }
+
+ enc->coded_frame->pts = pic_out.i_pts/smd_frame_rate;
+ if (AV_NOPTS_VALUE != enc->coded_frame->pts) {
+ pkt.pts= enc->coded_frame->pts;
+ if (ist) {
+ pkt.pts += av_rescale_q(input_files[ist->file_index]->first_pts, AV_TIME_BASE_Q, enc->time_base);
+ }
+ }
+ }
+
+ switch (pic_out.i_type)
+ {
+ case SLICE_P:
+ av_log(NULL,AV_LOG_DEBUG,"\n********returning pict type AV_PICTURE_TYPE_P\n");
+ enc->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+ break;
+ case SLICE_B:
+ av_log(NULL,AV_LOG_DEBUG,"\n********returning pict type AV_PICTURE_TYPE_B\n");
+ enc->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+ break;
+ case SLICE_I:
+ av_log(NULL,AV_LOG_DEBUG,"\n********returning pict type AV_PICTURE_TYPE_I\n");
+ enc->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ break;
+ default:
+ enc->coded_frame->pict_type = AV_PICTURE_TYPE_NONE;
+ av_log(NULL,AV_LOG_DEBUG,"\n********ERROR invalid picture type ************\n");
+
+ }
+ enc->coded_frame->key_frame = pic_out.b_keyframe;
+ if (pic_out.b_keyframe) {
+ pkt.flags |= AV_PKT_FLAG_KEY;
+ }
+ if (enable_dtv_smd) {
+ // enable dtv_smd flag, every frame is carryed the same timestamp from input file
+ // on hardware pipeline mode. But we encounter problem of non monotonically increasing
+ // timestamp. min_heap is reorder frame and filter some abnormal frame.
+ ret = syno_smd_push_heap(&pkt);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_FATAL, "syno_smd_push_heap failed\n");
+ exit_program(1);
+ }
+ if (0 == syno_smd_get_heap(&pkt, 0)) {
+ if (last_pts >= pkt.pts) {
+ av_free_packet(&pkt);
+ } else {
+ last_pts = pkt.pts;
+ got_packet = 1;
+ }
+ }
+ } else {
+ got_packet = 1;
+ }
+ }
+ }
+#endif
+
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
@@ -1631,6 +1854,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
static void flush_encoders(void)
{
int i, ret;
+#ifdef SYNO_EVANSPORT_SMD
+ InputStream *ist = NULL;
+#endif
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
@@ -1656,6 +1882,9 @@ static void flush_encoders(void)
desc = "Audio";
break;
case AVMEDIA_TYPE_VIDEO:
+#ifdef SYNO_EVANSPORT_SMD
+ usleep(1000);
+#endif
encode = avcodec_encode_video2;
desc = "Video";
break;
@@ -1671,9 +1900,111 @@ static void flush_encoders(void)
pkt.data = NULL;
pkt.size = 0;
+#ifdef SYNO_EVANSPORT_SMD
+ if (!smd_video_pipeline || AVMEDIA_TYPE_VIDEO != ost->st->codec->codec_type ) {
+#endif
update_benchmark(NULL);
ret = encode(enc, &pkt, NULL, &got_packet);
update_benchmark("flush %s %d.%d", desc, ost->file_index, ost->index);
+#ifdef SYNO_EVANSPORT_SMD
+ } else {
+ unsigned long fps_num;
+ unsigned long fps_den;
+ bool override;
+ double temp_num;
+ int pkt_size;
+ smd_h264_picture_t pic_out;
+ ret = 0;
+
+ if ((pkt_size = syno_ismd_ffmpeg_video_encoder_get_first_node_size(&vid_enc)) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "ismd_ffmpeg_video_encoder_dequeue_size_syno\n");
+ exit_program(1);
+ }
+ if (pkt_size > 0) {
+ if (syno_alloc_packet(&pkt, pkt_size) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "syno_alloc_packet error at encoder SMD\n");
+ exit_program(1);
+ }
+ ret = ismd_ffmpeg_video_encoder_dequeue(pkt.data, &pic_out,&vid_enc);
+ if (ret != pkt_size) {
+ av_log(NULL, AV_LOG_FATAL, "ismd_ffmpeg_video_encoder_dequeue size not conform\n");
+ }
+ memset(pkt.data + pkt.size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ }
+
+ if(ret > 0)
+ {
+ if (enable_dtv_smd) {
+ enc->coded_frame->pts = av_rescale_q(pic_out.i_pts, AV_TIME_BASE_Q, enc->time_base);
+ if (AV_NOPTS_VALUE != enc->coded_frame->pts) {
+ pkt.pts= enc->coded_frame->pts;
+ }
+ } else {
+ //TODO call just once
+ ismd_result_t ret_smd = ismd_viddec_get_frame_rate(vid_dec.viddec_handle, &fps_num, &fps_den, &override);//this actually returns fps
+ if (ret_smd == ISMD_SUCCESS)
+ {
+ temp_num = 90000/(double)fps_num;
+ smd_frame_rate = temp_num*fps_den;//smd clock resuolution is 90000 ticks
+ }
+ av_log(NULL,AV_LOG_DEBUG,"\n********pts from encoder %lld\n",pic_out.i_pts);
+
+ enc->coded_frame->pts = pic_out.i_pts/smd_frame_rate;
+ if (AV_NOPTS_VALUE != enc->coded_frame->pts) {
+ pkt.pts= enc->coded_frame->pts;
+ if (ost->source_index >= 0)
+ ist = input_streams[ost->source_index];
+ if (ist) {
+ pkt.pts += av_rescale_q(input_files[ist->file_index]->first_pts, AV_TIME_BASE_Q, enc->time_base);
+ }
+ }
+ }
+
+ switch (pic_out.i_type)
+ {
+ case SLICE_P:
+ av_log(NULL,AV_LOG_DEBUG,"\n*******returning pict type AV_PICTURE_TYPE_P\n");
+ enc->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+ break;
+ case SLICE_B:
+ av_log(NULL,AV_LOG_DEBUG,"\n*****returning pict type AV_PICTURE_TYPE_B\n");
+ enc->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+ break;
+ case SLICE_I:
+ av_log(NULL,AV_LOG_DEBUG,"\n******returning pict type AV_PICTURE_TYPE_I\n");
+ enc->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ break;
+ default:
+ enc->coded_frame->pict_type = AV_PICTURE_TYPE_NONE;
+ av_log(NULL,AV_LOG_DEBUG,"\n*****ERROR invalid picture type ************\n");
+
+ }
+ enc->coded_frame->key_frame = pic_out.b_keyframe;
+ if (pic_out.b_keyframe) {
+ pkt.flags |= AV_PKT_FLAG_KEY;
+ }
+
+ if (enable_dtv_smd) {
+ //TODO we should care about flush heap buffer
+ ret = syno_smd_push_heap(&pkt);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_FATAL, "syno_smd_push_heap failed\n");
+ exit_program(1);
+ }
+ if (0 == syno_smd_get_heap(&pkt, 1)) {
+ if (last_pts >= pkt.pts) {
+ av_free_packet(&pkt);
+ } else {
+ last_pts = pkt.pts;
+ got_packet = 1;
+ }
+ }
+ } else {
+ got_packet = 1;
+ }
+ }
+ }
+#endif
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "%s encoding failed\n", desc);
exit_program(1);
@@ -1681,6 +2012,9 @@ static void flush_encoders(void)
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
+#ifdef SYNO_EVANSPORT_SMD
+ if(!smd_video_pipeline) {
+#endif
if (!got_packet) {
stop_encoding = 1;
break;
@@ -1692,6 +2026,21 @@ static void flush_encoders(void)
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
pkt_size = pkt.size;
write_frame(os, &pkt, ost);
+#ifdef SYNO_EVANSPORT_SMD
+ } else {
+ if ((ret <= 0) && (vid_enc.eos_received)) {
+ stop_encoding = 1;
+ break;
+ }
+ if (ret >0) {
+ if (pkt.pts != AV_NOPTS_VALUE)
+ pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
+ if (pkt.dts != AV_NOPTS_VALUE)
+ pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
+ write_frame(os, &pkt, ost);
+ }
+ }
+#endif
if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) {
do_video_stats(ost, pkt_size);
}
@@ -1979,6 +2328,29 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
{
+#ifdef SYNO_EVANSPORT_SMD
+ /********************* smd implementation *****************/
+ const uint8_t *buf = pkt->data;
+ int buf_size = pkt->size;
+ uint8_t* buf_with_start_code = NULL;
+ int new_buf_size = buf_size;
+ uint8_t* sps_pps_buf =NULL;
+ AVCodecContext *avctx = ist->dec_ctx;
+
+ ismd_buffer_handle_t ismd_buf = -1;
+ ismd_result_t result = ISMD_SUCCESS;
+ int sps_pps_buf_size =0;
+ bool first_time =true;
+ unsigned char pSeqHeaderRbdu[8];
+ unsigned char SPMP_PESpacket_PayloadFormatHeader[16];
+ int size_SPMP_PESpacket_PayloadFormatHeader;
+ int max_bufsize =0;
+ ismd_codec_type_t smd_codec;
+ H264Context *h;
+ VC1Context *v;
+ /********************* end *****************/
+#endif
+
AVFrame *decoded_frame, *f;
int i, ret = 0, err = 0, resample_changed;
int64_t best_effort_timestamp;
@@ -1991,6 +2363,10 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
decoded_frame = ist->decoded_frame;
pkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
+#ifdef SYNO_EVANSPORT_SMD
+ if(!smd_video_pipeline)
+ {
+#endif
update_benchmark(NULL);
ret = avcodec_decode_video2(ist->dec_ctx,
decoded_frame, got_output, pkt);
@@ -2116,6 +2492,251 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
}
}
+#ifdef SYNO_EVANSPORT_SMD
+ } else {
+ int64_t pts;
+ ret = pkt->size;
+ if (pkt->pts != AV_NOPTS_VALUE) {
+ pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
+ } else {
+ pts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
+ }
+ /******************** write data to decoder input port *******************/
+ smd_codec = get_smd_codec_id(ist->st->codec->codec_id);
+// av_log(NULL,AV_LOG_DEBUG,"\nin transcode_video smd_codec %d\n",smd_codec);
+ switch (smd_codec)
+ {
+ //no special handling is required for mpeg2 mpeg4
+ //we are not supporting msmpeg4
+ case ISMD_CODEC_TYPE_MPEG2:
+ case ISMD_CODEC_TYPE_MPEG4:
+ av_log(NULL, AV_LOG_DEBUG, "\n********* in ISMD_CODEC_TYPE_MPEG2/ISMD_CODEC_TYPE_MPEG4 case **************\n");
+ av_log(NULL, AV_LOG_DEBUG, "\navctx->extradata_size %d\n",avctx->extradata_size);
+ //send headers before first packet
+ if((vid_dec.send_sps_pps) && (avctx->extradata_size > 0))
+ {
+ if ((result = ismd_buffer_alloc(CHUNK_SIZE, &ismd_buf)) == ISMD_SUCCESS)
+ {
+ av_log(NULL, AV_LOG_DEBUG,"\n********* sending extradata size %d ********\n",avctx->extradata_size);
+ if (enable_dtv_smd) {
+ result = syno_ismd_ffmpeg_fill_viddec_buffer(avctx->extradata, ismd_buf,avctx->extradata_size, pts);
+ } else {
+ result = ismd_ffmpeg_fill_viddec_buffer(avctx->extradata, ismd_buf,avctx->extradata_size);
+ }
+ if (result == ISMD_SUCCESS)
+ {
+ // decode it asynchronously
+ if ((result = ismd_ffmpeg_decoder_port_write(&vid_dec,ismd_buf)) != ISMD_SUCCESS)
+ {
+ av_log(NULL, AV_LOG_ERROR,"error: unable to decode smd_buffers11 [%d]\n", result);
+ }
+ }
+ }
+ else
+ {
+ av_log(NULL, AV_LOG_INFO,"error: unable to allocate buffer in decode_frame111 [%d]\n", result);
+ }
+ vid_dec.send_sps_pps = false;
+ }
+ //Mpeg1Context *s = avctx->priv_data;
+ buf_with_start_code = buf;//format is not avc1 so coming buffer is in Byte-stream format.no conversion required
+ if (enable_dtv_smd) {
+ syno_ismd_ffmpeg_decode_vid_buf(&vid_dec, buf_with_start_code, new_buf_size, pts);
+ } else {
+ ismd_ffmpeg_decode_vid_buf(&vid_dec, buf_with_start_code, new_buf_size);
+ }
+ break;
+ case ISMD_CODEC_TYPE_H264:
+ h = avctx->priv_data;
+ if(buf_size > 4)
+ {
+ if(h->is_avc)
+ {
+ buf_with_start_code = av_malloc(pkt->size);//allocate memory for new buffer
+ if(buf_with_start_code == NULL)
+ {
+ av_log(NULL,AV_LOG_ERROR,"\ncould not allocate memory for new buffer \n");
+ assert(0);
+ }
+ if((vid_dec.send_sps_pps) && avctx->extradata_size > 0 && avctx->extradata)
+ {
+ sps_pps_buf_size = ismd_ffmpeg_h264_viddec_extract_sps_pps(avctx->extradata,avctx->extradata_size, &sps_pps_buf);
+ }
+
+ new_buf_size = ismd_ffmpeg_unit_to_byte_stream(&buf_with_start_code, buf, pkt->size, h->nal_length_size);
+ }
+ else
+ {
+ buf_with_start_code = buf;//format is not avc1 so coming buffer is in Byte-stream format.no conversion required
+ }
+ }
+
+ /******************** write sps/pps buffer for avc1 at decoder i/p port ************************************************/
+ if((vid_dec.send_sps_pps) && h->is_avc)
+ {
+ if ((result = ismd_buffer_alloc(CHUNK_SIZE, &ismd_buf)) == ISMD_SUCCESS)
+ {
+ av_log(NULL, AV_LOG_DEBUG,"\n********* sending sps pps buffer write size %d ********\n",sps_pps_buf_size);
+ if (enable_dtv_smd) {
+ result = syno_ismd_ffmpeg_fill_viddec_buffer(sps_pps_buf, ismd_buf, sps_pps_buf_size, pts);
+ } else {
+ result = ismd_ffmpeg_fill_viddec_buffer(sps_pps_buf, ismd_buf, sps_pps_buf_size);
+ }
+ if (result == ISMD_SUCCESS)
+ {
+ // decode it asynchronously
+ if ((result = ismd_ffmpeg_decoder_port_write(&vid_dec,ismd_buf)) != ISMD_SUCCESS)
+ {
+ av_log(NULL, AV_LOG_ERROR,"error: unable to decode smd_buffers11 [%d]\n", result);
+ }
+ }
+ }
+ else
+ {
+ av_log(NULL, AV_LOG_INFO,"error: unable to allocate buffer in decode_frame111 [%d]\n", result);
+ }
+ vid_dec.send_sps_pps = false;
+ }
+ /******************** write nal data of slice data at decoder i/p port ************************************************/
+ if (enable_dtv_smd) {
+ syno_ismd_ffmpeg_decode_vid_buf(&vid_dec, buf_with_start_code, new_buf_size, pts);
+ } else {
+ ismd_ffmpeg_decode_vid_buf(&vid_dec, buf_with_start_code, new_buf_size);
+ }
+
+ if((h->is_avc)&& buf_with_start_code)
+ {
+ av_free(buf_with_start_code);
+ buf_with_start_code = NULL;
+ }
+ break;
+ case ISMD_CODEC_TYPE_VC1:
+ v = avctx->priv_data;
+ if (first_time && (buf_size >= 4)&& (!IS_MARKER(AV_RB32(buf)))) /*frame starts with marker and needs to be parsed */
+ {
+ vid_dec.vc1_without_start_code = true;//not compatible with smd
+ first_time = false;
+
+ }
+ if(vid_dec.vc1_without_start_code)
+ {
+ //write sps to decoder port first this comes out-of-band in wvc1
+ if((vid_dec.send_sps_pps) && avctx->extradata_size > 0 && avctx->extradata)
+ {
+ uint8_t* seq_header_buf = av_malloc(16);//TODO free buffer
+ switch (v->profile)
+ {
+ case PROFILE_ADVANCED:
+ if ((result = ismd_buffer_alloc(CHUNK_SIZE, &ismd_buf)) == ISMD_SUCCESS)
+ {
+ if (enable_dtv_smd) {
+ result = syno_ismd_ffmpeg_fill_viddec_buffer(avctx->extradata+1, ismd_buf, avctx->extradata_size-1, pts);
+ } else {
+ result = ismd_ffmpeg_fill_viddec_buffer(avctx->extradata+1, ismd_buf, avctx->extradata_size-1);
+ }
+ if (result == ISMD_SUCCESS)
+ {
+ // decode it asynchronously
+ if ((result = ismd_ffmpeg_decoder_port_write(&vid_dec,ismd_buf)) != ISMD_SUCCESS)
+ {
+ av_log(NULL, AV_LOG_ERROR,"error: unable to decode smd_buffers [%d]\n", result);
+ }
+ }
+ }
+ break;
+ case PROFILE_SIMPLE:
+ case PROFILE_MAIN:
+ size_SPMP_PESpacket_PayloadFormatHeader = ismd_ffmpeg_vc1_viddec_SPMP_PESpacket_PayloadFormatHeader (pSeqHeaderRbdu, SPMP_PESpacket_PayloadFormatHeader, avctx->extradata, avctx->extradata_size, avctx->width, avctx->height);
+
+ if ((result = ismd_buffer_alloc(CHUNK_SIZE, &ismd_buf)) == ISMD_SUCCESS)
+ {
+ if (enable_dtv_smd) {
+ result = syno_ismd_ffmpeg_fill_viddec_buffer(SPMP_PESpacket_PayloadFormatHeader, ismd_buf, size_SPMP_PESpacket_PayloadFormatHeader, pts);
+ } else {
+ result = ismd_ffmpeg_fill_viddec_buffer(SPMP_PESpacket_PayloadFormatHeader, ismd_buf, size_SPMP_PESpacket_PayloadFormatHeader);
+ }
+ if (result == ISMD_SUCCESS)
+ {
+ // decode it asynchronously
+ if ((result = ismd_ffmpeg_decoder_port_write(&vid_dec,ismd_buf)) != ISMD_SUCCESS)
+ {
+ av_log(NULL, AV_LOG_ERROR,"error: unable to decode smd_buffers [%d]\n", result);
+ }
+ }
+ }
+ break;
+ }
+ vid_dec.send_sps_pps = false;
+ av_free(seq_header_buf);
+ }
+
+ //need to insert start code
+ switch (v->profile)
+ {
+ case PROFILE_ADVANCED:
+ //insert start code
+ av_log(NULL, AV_LOG_DEBUG, "\n***start code not found*** profile %d PROFILE_ADVANCED %d\n",v->profile,PROFILE_ADVANCED);
+ buf_with_start_code = av_malloc(4 + buf_size);//TODO free memory
+
+ new_buf_size = ismd_ffmpeg_vc1_viddec_convert_AP(buf_with_start_code, buf, buf_size);
+
+ break;
+ case PROFILE_SIMPLE:
+ case PROFILE_MAIN:
+ // Calculate maximum buffer size, make room for encapsulation
+ // SMPTE-421M-FDSI doc, Annex-E
+ max_bufsize = ( (pkt->size + 3 ) / 3 ) * 4;
+ buf_with_start_code = av_malloc(max_bufsize);
+ av_log(NULL, AV_LOG_DEBUG, "\n* pkt size %d max_bufsize %d*\n",pkt->size,max_bufsize);
+
+ new_buf_size = ismd_ffmpeg_vc1_viddec_convert_SPMP(buf_with_start_code, pkt->data, pkt->size, max_bufsize);
+
+ break;
+ }
+
+ }
+ else
+ buf_with_start_code = buf;
+ /*********** write buffer data ************************/
+ if (enable_dtv_smd) {
+ syno_ismd_ffmpeg_decode_vid_buf(&vid_dec, buf_with_start_code, new_buf_size, pts);
+ } else {
+ ismd_ffmpeg_decode_vid_buf(&vid_dec, buf_with_start_code, new_buf_size);
+ }
+
+ if((vid_dec.vc1_without_start_code)&& buf_with_start_code)
+ {
+ av_free(buf_with_start_code);
+ }
+
+ break;
+ default:
+ av_log(NULL,AV_LOG_ERROR,"\n********smd can't handle this codec***********\n");
+ return -1;
+ }
+
+ if(vid_dec.eos_written)
+ *got_output = 0;
+ if (!*got_output || ret < 0) {
+ if (!pkt->size) {
+ for (i = 0; i < ist->nb_filters; i++)
+ av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0);
+ }
+ }
+
+ pkt->size = 0;
+
+ //rate_emu_sleep(ist);
+ for (i = 0; i < nb_output_streams; i++) {
+ OutputStream *ost = output_streams[i];
+
+ if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
+ continue;
+ do_video_out(output_files[ost->file_index]->ctx, ost, decoded_frame, 0);
+ }
+ }
+#endif
+
fail:
av_frame_unref(ist->filter_frame);
av_frame_unref(decoded_frame);
@@ -2221,7 +2842,12 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt)
}
// while we have more to decode or while the decoder did output something on EOF
+#ifdef SYNO_EVANSPORT_SMD
+ //to resolve ctrl-C issue
+ while (ist->decoding_needed && (avpkt.size > 0 || (!pkt && (got_output >0)))) {
+#else
while (ist->decoding_needed && (avpkt.size > 0 || (!pkt && got_output))) {
+#endif
int duration;
handle_eof:
@@ -2555,6 +3181,48 @@ static void report_new_stream(int input_index, AVPacket *pkt)
file->nb_streams_warn = pkt->stream_index + 1;
}
+#ifdef SYNO_EVANSPORT_SMD
+static ismd_codec_type_t get_smd_codec_id(enum AVCodecID ffmpeg_codec_id)
+{
+ switch (ffmpeg_codec_id)
+ {
+ case AV_CODEC_ID_MPEG2VIDEO_SYNO:
+ return ISMD_CODEC_TYPE_MPEG2;
+ case AV_CODEC_ID_H264_SYNO:
+ return ISMD_CODEC_TYPE_H264;
+ case AV_CODEC_ID_VC1_SYNO:
+ case AV_CODEC_ID_WMV3_SYNO:
+ return ISMD_CODEC_TYPE_VC1;
+ case AV_CODEC_ID_MPEG4_SYNO:
+ return ISMD_CODEC_TYPE_MPEG4;
+ default:
+ return ISMD_CODEC_TYPE_INVALID;
+ }
+}
+#endif
+
+#ifdef SYNO_EVANSPORT_HANDBRAKE_MP4
+static int IsFileEncodeByHandBrake()
+{
+ int i;
+ AVDictionaryEntry *tag = NULL;
+
+ for (i = 0; i < nb_input_files; i++) {
+ InputFile *ifile = input_files[i];
+ if (0 != strcmp(ifile->ctx->iformat->name, "mov,mp4,m4a,3gp,3g2,mj2")) {
+ continue;
+ }
+ while ((tag = av_dict_get(ifile->ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
+ if (0 == strncmp(tag->key, "encoder", 7) && 0 == strncmp(tag->value, "HandBrake", 9)) {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+#endif
+
static void set_encoder_id(OutputFile *of, OutputStream *ost)
{
AVDictionaryEntry *e;
@@ -2598,6 +3266,14 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost)
static int transcode_init(void)
{
+#ifdef SYNO_EVANSPORT_SMD
+ /************** smd implementation ***********/
+ ismd_result_t result = ISMD_ERROR_UNSPECIFIED;
+ char *hw_decoder_name;
+ ismd_codec_type_t smd_codec;
+ /************** end ***********/
+#endif
+
int ret = 0, i, j, k;
AVFormatContext *oc;
OutputStream *ost;
@@ -3256,6 +3932,102 @@ static int transcode_init(void)
transcode_init_done = 1;
+#ifdef SYNO_EVANSPORT_SMD
+ /******************************* create smd video pipeline here ********************/
+ for (i = 0; i < nb_output_streams; i++)
+ {
+ AVCodecContext *codec = NULL;
+ ost = output_streams[i];
+ codec = ost->st->codec;
+
+ if (codec->codec_id == AV_CODEC_ID_H264)
+ break;
+ }
+ //don't create pipeline in case of stream copy
+ if(!ost->stream_copy)
+ {
+ AVCodecContext *icodec = NULL;
+ AVCodecContext *codec = NULL;
+ codec = ost->enc_ctx;
+ av_log(NULL, AV_LOG_DEBUG,"\n**** encoder codec id **** %d width %d height %d aspect num %d den %d\n", codec->codec_id,codec->width,codec->height,codec->sample_aspect_ratio.num,codec->sample_aspect_ratio.den);
+
+ for (i = 0; i < nb_input_streams; i++)
+ {
+ ist = input_streams[i];
+ icodec = ist->st->codec;
+ av_log(NULL,AV_LOG_DEBUG,"\nicodec->codec_id %d\n",icodec->codec_id);
+ if(icodec->codec_type == AVMEDIA_TYPE_VIDEO)
+ {
+ //set up video decoder
+ if(((icodec->codec_id == AV_CODEC_ID_MPEG2VIDEO_SYNO) || (icodec->codec_id == AV_CODEC_ID_H264_SYNO) ||\
+ (icodec->codec_id == AV_CODEC_ID_VC1_SYNO) ||(icodec->codec_id == AV_CODEC_ID_WMV3_SYNO)||\
+ (icodec->codec_id == AV_CODEC_ID_MPEG4_SYNO)) && \
+ ((codec->codec_id == AV_CODEC_ID_H264) && (0 == strcmp(codec->codec->name, "h264_smd"))))
+ {
+ av_log(NULL,AV_LOG_DEBUG,"\npipeline check successful\n");
+ bool smd_video_available = ismd_ffmpeg_is_video_enc_avail();
+ if(!smd_video_available)
+ {
+#if CONFIG_LIBX264_ENCODER
+ av_log( NULL, AV_LOG_INFO, "\nVideo hardware encoder not available for encoding.Falling back to software\n");
+ return 0;
+#else
+ av_log( NULL, AV_LOG_ERROR, "\nVideo hardware encoder not available for encoding. and software fallback not possible\n");
+ return -1;
+#endif
+ }
+
+ smd_codec = get_smd_codec_id(icodec->codec_id);
+ hw_decoder_name = ismd_ffmpeg_enum_to_string(smd_codec);
+ av_log(NULL, AV_LOG_DEBUG,"\n**** About to open stream for decoding with codec type **** %d smd_codec %d \n", icodec->codec_id, smd_codec);
+ if ((result = ismd_viddec_open(smd_codec, &vid_dec.viddec_handle) != ISMD_SUCCESS))
+ {
+ av_log(NULL, AV_LOG_ERROR,"\n ismd_viddec_open : failed error %d\n",result);
+ return -1;
+ }
+ }
+ }
+ }
+ if(ISMD_SUCCESS == result)
+ {
+#ifdef SYNO_EVANSPORT_HANDBRAKE_MP4
+ if (IsFileEncodeByHandBrake()) {
+ enable_dtv_smd = 1;
+ }
+#endif
+ if (ost->encoding_needed)
+ {
+ //close H.264 smd encoder because transcoding will be done through pipeline
+#ifdef SYNO_EVANSPORT_FLV_EXTRADATA
+ X264Context *x4 = ost->enc_ctx->priv_data;
+ x4->dont_free_extradata = true;
+#endif
+ ost->enc_ctx->codec->close(ost->enc_ctx);
+#ifdef SYNO_EVANSPORT_FLV_EXTRADATA
+ x4->dont_free_extradata = false;
+#endif
+ ost->enc_ctx->coded_frame = av_frame_alloc();
+ if (!ost->enc_ctx->coded_frame)
+ return AVERROR(ENOMEM);
+ }
+ result = ismd_ffmpeg_create_video_pipeline(codec , &vid_dec , &vid_enc, enable_dtv_smd);
+ if (result != ISMD_SUCCESS)
+ {
+ av_log(NULL,AV_LOG_ERROR,"\n FAILURE: could not start video pipeline error: %d\n",result);
+ return -1;
+ }
+ if (!synoAddPID(getpid())) {
+ av_log(NULL, AV_LOG_ERROR, "Syno check hardware transcode falied\n");
+ return -1;
+ }
+ av_log(NULL, AV_LOG_DEBUG, "\nvideo pipeline created successfully\n");
+ av_log( NULL, AV_LOG_INFO, "****** Using SMD H/W %s Decoder and H/W H.264 Encoder(Pipelined Mode)*******\n",hw_decoder_name);
+ smd_video_pipeline = true;
+ }
+ }
+ /******************************* end ********************/
+#endif
+
return 0;
}
@@ -3747,6 +4519,23 @@ static int process_input(int file_index)
}
}
+#ifdef SYNO_EVANSPORT_SMD
+ if (first_read_pts && AVMEDIA_TYPE_VIDEO == ist->st->codec->codec_type &&
+ (AV_CODEC_ID_H264_SYNO != ist->st->codec->codec_id || AV_PKT_FLAG_KEY & pkt.flags)) {
+ if (AV_NOPTS_VALUE != pkt.pts) {
+ first_read_pts = false;
+ ifile->first_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);
+ av_log(NULL, AV_LOG_DEBUG, "first_pts %s pts_time %s frome pts\n"
+ , av_ts2str(ifile->first_pts), av_ts2timestr(ifile->first_pts, &AV_TIME_BASE_Q));
+ } else if (AV_NOPTS_VALUE != pkt.dts){
+ first_read_pts = false;
+ ifile->first_pts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q)+1;
+ av_log(NULL, AV_LOG_DEBUG, "first_pts %s pts_time %s frome dts\n"
+ , av_ts2str(ifile->first_pts), av_ts2timestr(ifile->first_pts, &AV_TIME_BASE_Q));
+ }
+ }
+#endif
+
if (pkt.dts != AV_NOPTS_VALUE)
ifile->last_ts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
diff --git a/ffmpeg.h b/ffmpeg.h
index 7fd129a283..f03f1deb64 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -48,6 +48,8 @@
#include "libswresample/swresample.h"
+#include "synoconfig.h"
+
#define VSYNC_AUTO -1
#define VSYNC_PASSTHROUGH 0
#define VSYNC_CFR 1
@@ -341,6 +343,9 @@ typedef struct InputFile {
int ist_index; /* index of first stream in input_streams */
int64_t input_ts_offset;
int64_t ts_offset;
+#ifdef SYNO_EVANSPORT_SMD
+ int64_t first_pts; /* remember first video pts for handle resume problem on VideoStation */
+#endif
int64_t last_ts;
int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
int seek_timestamp;
@@ -506,6 +511,9 @@ extern int print_stats;
extern int qp_hist;
extern int stdin_interaction;
extern int frame_bits_per_raw_sample;
+// SYNO_EVANSPORT_DTV_SMD_AVSYNC
+extern int enable_dtv_smd;
+// SYNO_EVANSPORT_DTV_SMD_AVSYNC
extern AVIOContext *progress_avio;
extern float max_error_rate;
extern int vdpau_api_ver;
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 79cb5caa34..b465eaad3d 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -41,6 +41,12 @@
#include "libavutil/pixdesc.h"
#include "libavutil/pixfmt.h"
+#include "synoconfig.h"
+
+#ifdef SYNO_DTV_SKIP_UNKNOWN_TRACK
+#include <strings.h>
+#endif
+
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
{\
int i, ret;\
@@ -102,7 +108,18 @@ int qp_hist = 0;
int stdin_interaction = 1;
int frame_bits_per_raw_sample = 0;
float max_error_rate = 2.0/3;
-
+// SYNO_EVANSPORT_DTV_SMD_AVSYNC
+int enable_dtv_smd = 0;
+// SYNO_EVANSPORT_DTV_SMD_AVSYNC
+#ifdef SYNO_DTV_SKIP_UNKNOWN_TRACK
+int dtv_skip_unknown = 0;
+#endif
+#ifdef SYNO_DTV_SKIP_VISUAL_IMPAIRED_TRACK
+int dtv_skip_visual_impaired = 0;
+#endif
+#ifdef SYNO_DTV_SKIP_TELETEXT
+int dtv_skip_teletext = 0;
+#endif
static int intra_only = 0;
static int file_overwrite = 0;
@@ -114,6 +131,10 @@ static int input_stream_potentially_available = 0;
static int ignore_unknown_streams = 0;
static int copy_unknown_streams = 0;
+#ifdef SYNO_EVANSPORT_AUTO_HW_DECODER
+static int auto_detect_HWdecoder = 0;
+#endif
+
static void uninit_options(OptionsContext *o)
{
const OptionDef *po = options;
@@ -294,6 +315,33 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],
*p == ':' ? p + 1 : p) <= 0)
continue;
+#ifdef SYNO_DTV_SKIP_UNKNOWN_TRACK
+ if (dtv_skip_unknown) {
+ char buf[256];
+ AVStream *st = input_files[file_idx]->ctx->streams[i];
+ avcodec_string(buf, sizeof(buf), st->codec, 0);
+ if (!strncasecmp(buf, "unknown", 7)) {
+ continue;
+ }
+ if (strstr(buf, "0 channels") != NULL) {
+ continue;
+ }
+ }
+#endif
+#ifdef SYNO_DTV_SKIP_VISUAL_IMPAIRED_TRACK
+ if (dtv_skip_visual_impaired) {
+ AVStream *st = input_files[file_idx]->ctx->streams[i];
+ if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED) {
+ continue;
+ }
+ }
+#endif
+#ifdef SYNO_DTV_SKIP_TELETEXT
+ if (dtv_skip_teletext &&
+ AV_CODEC_ID_DVB_TELETEXT == input_files[file_idx]->ctx->streams[i]->codec->codec_id) {
+ continue;
+ }
+#endif
GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
m = &o->stream_maps[o->nb_stream_maps - 1];
@@ -561,6 +609,88 @@ static AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int e
return codec;
}
+#ifdef SYNO_SKIP_DISABLED_AUDIO_STREAM
+static int IsAudioCopyStream(OptionsContext *o, AVFormatContext *oc)
+{
+ int ret = 0;
+ char *audio_codec_name = NULL;
+
+ MATCH_PER_TYPE_OPT(codec_names, str, audio_codec_name, oc, "a");
+
+ if (audio_codec_name && 0 == strcmp(audio_codec_name, "copy")) {
+ ret = 1;
+ }
+
+ return ret;
+}
+
+static int IsSkipAudioStream(const InputStream *ist, OptionsContext *o, AVFormatContext *oc)
+{
+ if (ist->st->codec->codec_id == AV_CODEC_ID_DTS
+ || ist->st->codec->codec_id == AV_CODEC_ID_EAC3
+ || ist->st->codec->codec_id == AV_CODEC_ID_TRUEHD)
+ {
+ // if not stream copy
+ if (!IsAudioCopyStream(o, oc)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+#endif
+
+#ifdef SYNO_EVANSPORT_AUTO_HW_DECODER
+static AVCodec *choose_decoder_smd(OptionsContext *o, AVFormatContext *s, AVStream *st)
+{
+ char *codec_name = NULL;
+ AVCodec *result_codec;
+ enum AVCodecID smd_codecID;
+
+ MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
+ if (codec_name) {
+ AVCodec *codec = find_codec_or_die(codec_name, st->codec->codec_type, 0);
+ st->codec->codec_id = codec->id;
+ result_codec = codec;
+ } else {
+ result_codec = avcodec_find_decoder(st->codec->codec_id);
+ }
+
+ if (!result_codec || !auto_detect_HWdecoder) {
+ return result_codec;
+ }
+
+ switch (result_codec->id) {
+ case AV_CODEC_ID_H264:
+ if (FF_PROFILE_H264_HIGH_10 == st->codec->profile || FF_PROFILE_H264_HIGH_10_INTRA == st->codec->profile) {
+ return result_codec;
+ }
+ smd_codecID = AV_CODEC_ID_H264_SYNO;
+ break;
+ case AV_CODEC_ID_MPEG2VIDEO:
+ smd_codecID = AV_CODEC_ID_MPEG2VIDEO_SYNO;
+ break;
+ case AV_CODEC_ID_VC1:
+ smd_codecID = AV_CODEC_ID_VC1_SYNO;
+ break;
+ case AV_CODEC_ID_WMV3:
+ smd_codecID = AV_CODEC_ID_WMV3_SYNO;
+ break;
+ case AV_CODEC_ID_MPEG4:
+ smd_codecID = AV_CODEC_ID_MPEG4_SYNO;
+ break;
+ default:
+ smd_codecID = AV_CODEC_ID_NONE;
+ }
+ if (AV_CODEC_ID_NONE != smd_codecID) {
+ result_codec = avcodec_find_decoder(smd_codecID);
+ st->codec->codec_id = result_codec->id;
+ }
+
+ return result_codec;
+}
+#endif
+
static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st)
{
char *codec_name = NULL;
@@ -615,7 +745,12 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
st->codec->codec_tag = tag;
}
+#ifdef SYNO_EVANSPORT_AUTO_HW_DECODER
+ ist->dec = choose_decoder_smd(o, ic, st);
+#else
ist->dec = choose_decoder(o, ic, st);
+#endif
+
ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codec->codec_id, ic, st, ist->dec);
ist->reinit_filters = -1;
@@ -1937,6 +2072,12 @@ static int open_output_file(OptionsContext *o, const char *filename)
int channels = 0, idx = -1;
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
+#ifdef SYNO_SKIP_DISABLED_AUDIO_STREAM
+ if (IsSkipAudioStream(ist, o, oc)) {
+ // if not stream copy
+ continue;
+ }
+#endif
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
ist->st->codec->channels > channels) {
channels = ist->st->codec->channels;
@@ -2025,6 +2166,12 @@ loop_end:
continue;
if(o-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA)
continue;
+#ifdef SYNO_SKIP_DISABLED_AUDIO_STREAM
+ if (IsSkipAudioStream(ist, o, oc)) {
+ // if not stream copy
+ continue;
+ }
+#endif
switch (ist->st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break;
@@ -2878,6 +3025,27 @@ static int opt_progress(void *optctx, const char *opt, const char *arg)
const OptionDef options[] = {
/* main options */
#include "cmdutils_common_opts.h"
+#ifdef SYNO_EVANSPORT_AUTO_HW_DECODER
+ { "prefer_smd", OPT_BOOL, { &auto_detect_HWdecoder },
+ "enable auto detect Hardware decoder" },
+#endif
+#ifdef SYNO_EVANSPORT_DTV_SMD_AVSYNC
+ { "dtv_smd", OPT_BOOL, { &enable_dtv_smd},
+ "enable passthough timestamp in hardware pipeline mode" },
+#endif
+#ifdef SYNO_DTV_SKIP_UNKNOWN_TRACK
+ { "dtv_skip_unknown", OPT_BOOL, { &dtv_skip_unknown},
+ "skip unknown codec track during dtv streaming" },
+#endif
+#ifdef SYNO_DTV_SKIP_VISUAL_IMPAIRED_TRACK
+ { "dtv_skip_visual_impaired", OPT_BOOL, { &dtv_skip_visual_impaired },
+ "skip visual impaired track during dtv streaming" },
+#endif
+#ifdef SYNO_DTV_SKIP_TELETEXT
+ { "dtv_skip_teletext", OPT_BOOL, { &dtv_skip_teletext },
+ "skip subtitle streams in teletext codec during dtv streaming" },
+#endif
+
{ "f", HAS_ARG | OPT_STRING | OPT_OFFSET |
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(format) },
"force format", "fmt" },
diff --git a/ffserver.c b/ffserver.c
index 2b19bba9ba..da48630c60 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -71,6 +71,8 @@
#include "cmdutils.h"
#include "ffserver_config.h"
+#include "synoconfig.h"
+
const char program_name[] = "ffserver";
const int program_birth_year = 2000;
@@ -2574,8 +2576,10 @@ static int http_receive_data(HTTPContext *c)
} else if (c->buffer_ptr - c->buffer >= 2 &&
!memcmp(c->buffer_ptr - 1, "\r\n", 2)) {
c->chunk_size = strtol(c->buffer, 0, 16);
- if (c->chunk_size == 0) // end of stream
+ if (c->chunk_size <= 0) { // end of stream or invalid chunk size
+ c->chunk_size = 0;
goto fail;
+ }
c->buffer_ptr = c->buffer;
break;
} else if (++loop_run > 10) {
@@ -2598,6 +2602,7 @@ static int http_receive_data(HTTPContext *c)
/* end of connection : close it */
goto fail;
else {
+ av_assert0(len <= c->chunk_size);
c->chunk_size -= len;
c->buffer_ptr += len;
c->data_count += len;
@@ -3425,9 +3430,11 @@ static int add_av_stream(FFServerStream *feed, AVStream *st)
switch(av->codec_type) {
case AVMEDIA_TYPE_AUDIO:
+#ifndef SYNO_FFSERVER_MULTIPLE_AUDIO_TRACK
if (av1->channels == av->channels &&
av1->sample_rate == av->sample_rate)
return i;
+#endif
break;
case AVMEDIA_TYPE_VIDEO:
if (av1->width == av->width &&
diff --git a/ffserver_config.c b/ffserver_config.c
index 06bd8ac44a..83785ec6ad 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -31,6 +31,8 @@
#include "cmdutils.h"
#include "ffserver_config.h"
+#include "synoconfig.h"
+
#define MAX_CHILD_ARGS 64
static int ffserver_save_avoption(const char *opt, const char *arg, int type,
@@ -797,6 +799,9 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
char arg[1024], arg2[1024];
FFServerStream *stream;
int val;
+#ifdef SYNO_FFSERVER_MULTIPLE_AUDIO_TRACK
+ int num_audio_track = 1;
+#endif
av_assert0(pstream);
stream = *pstream;
@@ -1086,6 +1091,11 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
config->no_video = 1;
} else if (!av_strcasecmp(cmd, "NoAudio")) {
config->no_audio = 1;
+#ifdef SYNO_FFSERVER_MULTIPLE_AUDIO_TRACK
+ } else if (!av_strcasecmp(cmd, "SynoNumAudioTrack")) {
+ ffserver_get_arg(arg, sizeof(arg), p);
+ num_audio_track = atoi(arg);
+#endif
} else if (!av_strcasecmp(cmd, "ACL")) {
ffserver_parse_acl_row(stream, NULL, NULL, *p, config->filename,
config->line_num);
@@ -1120,8 +1130,15 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
config->dummy_actx->codec_id = config->guessed_audio_codec_id;
if (!config->no_audio &&
config->dummy_actx->codec_id != AV_CODEC_ID_NONE) {
+#ifdef SYNO_FFSERVER_MULTIPLE_AUDIO_TRACK
+ for (int i = 0; i < num_audio_track; i ++) {
+ AVCodecContext *audio_enc = avcodec_alloc_context3(avcodec_find_encoder(config->dummy_actx->codec_id));
+ add_codec(stream, audio_enc, config);
+ }
+#else
AVCodecContext *audio_enc = avcodec_alloc_context3(avcodec_find_encoder(config->dummy_actx->codec_id));
add_codec(stream, audio_enc, config);
+#endif
}
if (config->dummy_vctx->codec_id == AV_CODEC_ID_NONE)
config->dummy_vctx->codec_id = config->guessed_video_codec_id;
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index bfd6425fd5..c7bcc28745 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -37,6 +37,12 @@ OBJS = allcodecs.o \
vorbis_parser.o \
xiph.o \
+ifdef CONFIG_SMD
+OBJS += ismd_ffmpeg_audio_util.o
+OBJS += syno_trans_loading.o
+endif
+OBJS += synog1codecpatent.o
+
# subsystems
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o
OBJS-$(CONFIG_AC3DSP) += ac3dsp.o
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 622cc5c087..7312cb63c8 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -113,6 +113,9 @@
# include "mips/aacdec_mips.h"
#endif
+#include "synoconfig.h"
+#include "synog1codecpatent.h"
+
static VLC vlc_scalefactors;
static VLC vlc_spectral[11];
@@ -1098,6 +1101,12 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+#ifdef SYNO_CODEC_PATENT_G1
+ if (0 != ActivateCodec("aac_dec")) {
+ return -1;
+ }
+#endif
+
if (avctx->extradata_size > 0) {
if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
avctx->extradata,
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 897c3a10df..9b96ca7f43 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -45,6 +45,9 @@
#include "psymodel.h"
+#include "synoconfig.h"
+#include "synog1codecpatent.h"
+
#define AAC_MAX_CHANNELS 6
#define ERROR_IF(cond, ...) \
@@ -764,6 +767,12 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
uint8_t grouping[AAC_MAX_CHANNELS];
int lengths[2];
+#ifdef SYNO_CODEC_PATENT_G1
+ if (0 != ActivateCodec("aac_enc")) {
+ return -1;
+ }
+#endif
+
avctx->frame_size = 1024;
for (i = 0; i < 16; i++)
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ce977467f9..ea48a5e0d3 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -28,6 +28,8 @@
#include "avcodec.h"
#include "version.h"
+#include "synoconfig.h"
+
#define REGISTER_HWACCEL(X, x) \
{ \
extern AVHWAccel ff_##x##_hwaccel; \
@@ -175,6 +177,9 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (H263, h263);
REGISTER_DECODER(H263I, h263i);
REGISTER_ENCDEC (H263P, h263p);
+#ifdef SYNO_EVANSPORT_SMD
+ REGISTER_DECODER(H264, h264_smd);
+#endif
REGISTER_DECODER(H264, h264);
REGISTER_DECODER(H264_CRYSTALHD, h264_crystalhd);
REGISTER_DECODER(H264_MMAL, h264_mmal);
@@ -212,7 +217,13 @@ void avcodec_register_all(void)
REGISTER_DECODER(MPEG_XVMC, mpeg_xvmc);
#endif /* FF_API_XVMC */
REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video);
+#ifdef SYNO_EVANSPORT_SMD
+ REGISTER_DECODER(MPEG2VIDEO, mpeg2video_smd);
+#endif
REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video);
+#ifdef SYNO_EVANSPORT_SMD
+ REGISTER_DECODER(MPEG4, mpeg4_smd);
+#endif
REGISTER_ENCDEC (MPEG4, mpeg4);
REGISTER_DECODER(MPEG4_CRYSTALHD, mpeg4_crystalhd);
REGISTER_DECODER(MPEG4_VDPAU, mpeg4_vdpau);
@@ -296,6 +307,9 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (V410, v410);
REGISTER_DECODER(VB, vb);
REGISTER_DECODER(VBLE, vble);
+#ifdef SYNO_EVANSPORT_SMD
+ REGISTER_DECODER(VC1, vc1_smd);
+#endif
REGISTER_DECODER(VC1, vc1);
REGISTER_DECODER(VC1_CRYSTALHD, vc1_crystalhd);
REGISTER_DECODER(VC1_VDPAU, vc1_vdpau);
@@ -315,6 +329,9 @@ void avcodec_register_all(void)
REGISTER_DECODER(WEBP, webp);
REGISTER_ENCDEC (WMV1, wmv1);
REGISTER_ENCDEC (WMV2, wmv2);
+#ifdef SYNO_EVANSPORT_SMD
+ REGISTER_DECODER(WMV3, wmv3_smd);
+#endif
REGISTER_DECODER(WMV3, wmv3);
REGISTER_DECODER(WMV3_CRYSTALHD, wmv3_crystalhd);
REGISTER_DECODER(WMV3_VDPAU, wmv3_vdpau);
@@ -545,6 +562,9 @@ void avcodec_register_all(void)
REGISTER_ENCODER(LIBWAVPACK, libwavpack);
REGISTER_ENCODER(LIBWEBP_ANIM, libwebp_anim); /* preferred over libwebp */
REGISTER_ENCODER(LIBWEBP, libwebp);
+#ifdef SYNO_EVANSPORT_SMD
+ REGISTER_ENCODER(H264_SMD, h264_smd);
+#endif
REGISTER_ENCODER(LIBX264, libx264);
REGISTER_ENCODER(LIBX264RGB, libx264rgb);
REGISTER_ENCODER(LIBX265, libx265);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4aeb57aed4..b3cd447ed2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -42,6 +42,8 @@
#include "version.h"
+#include "synoconfig.h"
+
/**
* @defgroup libavc Encoding/Decoding Library
* @{
@@ -294,6 +296,14 @@ enum AVCodecID {
AV_CODEC_ID_TDSC,
AV_CODEC_ID_HQ_HQA,
+#ifdef SYNO_EVANSPORT_SMD
+ AV_CODEC_ID_H264_SYNO,
+ AV_CODEC_ID_MPEG2VIDEO_SYNO,
+ AV_CODEC_ID_VC1_SYNO,
+ AV_CODEC_ID_WMV3_SYNO,
+ AV_CODEC_ID_MPEG4_SYNO,
+#endif
+
AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'),
AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
AV_CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
@@ -3701,6 +3711,10 @@ void avcodec_free_frame(AVFrame **frame);
*/
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
+#ifdef SYNO_EVANSPORT_SMD
+int syno_alloc_packet(AVPacket *avpkt, int size);
+#endif
+
/**
* Close a given AVCodecContext and free all the data associated with it
* (but not the AVCodecContext itself).
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index c1694f3383..7704e4db4a 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -26,6 +26,8 @@
#include "avcodec.h"
#include "version.h"
+#include "synoconfig.h"
+
#define MT(...) (const char *const[]){ __VA_ARGS__, NULL }
static const AVCodecDescriptor codec_descriptors[] = {
@@ -1252,6 +1254,43 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("Canopus HQ/HQA"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
},
+#ifdef SYNO_EVANSPORT_SMD
+ {
+ .id = AV_CODEC_ID_WMV3_SYNO,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "wmv3_smd",
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Hardware(SMD) Decoder"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_VC1_SYNO,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "vc1_smd",
+ .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 Hardware(SMD) Decoder"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_MPEG2VIDEO_SYNO,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "mpeg2video_smd",
+ .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video Hardware(SMD) Decoder"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_MPEG4_SYNO,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "mpeg4_smd",
+ .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Hardware(SMD) Decoder"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_H264_SYNO,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "h264_smd",
+ .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 Hardware(SMD) Decoder"),
+ .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
+ },
+#endif
/* image codecs */
{
diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c
index dd84a07664..4102087311 100644
--- a/libavcodec/dvbsub.c
+++ b/libavcodec/dvbsub.c
@@ -22,6 +22,8 @@
#include "bytestream.h"
#include "libavutil/colorspace.h"
+#include "synoconfig.h"
+
typedef struct DVBSubtitleContext {
int object_version;
} DVBSubtitleContext;
@@ -261,6 +263,10 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s,
if (h->num_rects && !h->rects)
return -1;
+#ifndef SYNO_DTV_MPEGTS_DVBSUB_ENCODING
+ *q++ = 0x00; /* subtitle_stream_id */
+#endif
+
/* page composition segment */
*q++ = 0x0f; /* sync_byte */
@@ -435,6 +441,10 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s,
bytestream_put_be16(&pseg_len, q - pseg_len - 2);
+#ifndef SYNO_DTV_MPEGTS_DVBSUB_ENCODING
+ *q++ = 0xff; /* end of PES data */
+#endif
+
s->object_version = (s->object_version + 1) & 0xf;
return q - outbuf;
}
diff --git a/libavcodec/h263.h b/libavcodec/h263.h
index 1f954cdf6f..77248a7788 100644
--- a/libavcodec/h263.h
+++ b/libavcodec/h263.h
@@ -26,6 +26,8 @@
#include "mpegvideo.h"
#include "rl.h"
+#include "synoconfig.h"
+
#if !FF_API_ASPECT_EXTENDED
#define FF_ASPECT_EXTENDED 15
#endif
@@ -77,13 +79,20 @@ extern uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[];
-
int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code);
av_const int ff_h263_aspect_to_info(AVRational aspect);
int ff_h263_decode_init(AVCodecContext *avctx);
+#ifdef SYNO_EVANSPORT_SMD
+int ff_h263_decode_init_smd(AVCodecContext *avctx);
+#endif
int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt);
+#ifdef SYNO_EVANSPORT_SMD
+int ff_h263_decode_frame_smd(AVCodecContext *avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt);
+#endif
int ff_h263_decode_end(AVCodecContext *avctx);
void ff_h263_encode_mb(MpegEncContext *s,
int16_t block[6][64],
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 15f073ae66..efa533574e 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -45,6 +45,16 @@
#include "thread.h"
#include "wmv2.h"
+#include "synoconfig.h"
+
+#ifdef SYNO_EVANSPORT_SMD
+#include "libffmpeg_plugin/ismd_ffmpeg_util.h"
+#include "libffmpeg_plugin/ismd_ffmpeg_video_dec.h"
+#include "libavformat/avformat.h"
+static viddec_struct_t smd_mpeg4_vid_dec;
+bool smd_mpeg4_vid_dec_available = false;
+#endif
+
static enum AVPixelFormat h263_get_format(AVCodecContext *avctx)
{
if (avctx->codec->id == AV_CODEC_ID_MSS2)
@@ -84,6 +94,10 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
break;
case AV_CODEC_ID_MPEG4:
break;
+#ifdef SYNO_EVANSPORT_SMD
+ case AV_CODEC_ID_MPEG4_SYNO:
+ break;
+#endif
case AV_CODEC_ID_MSMPEG4V1:
s->h263_pred = 1;
s->msmpeg4_version = 1;
@@ -106,6 +120,10 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
break;
case AV_CODEC_ID_VC1:
case AV_CODEC_ID_WMV3:
+#ifdef SYNO_EVANSPORT_SMD
+ case AV_CODEC_ID_VC1_SYNO:
+ case AV_CODEC_ID_WMV3_SYNO:
+#endif
case AV_CODEC_ID_VC1IMAGE:
case AV_CODEC_ID_WMV3IMAGE:
case AV_CODEC_ID_MSS2:
@@ -130,9 +148,15 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
s->ehc_mode = 1;
/* for h263, we allocate the images after having read the header */
+#ifdef SYNO_EVANSPORT_SMD
+ if (avctx->codec->id != AV_CODEC_ID_H263 &&
+ avctx->codec->id != AV_CODEC_ID_H263P &&
+ (avctx->codec->id != AV_CODEC_ID_MPEG4 && avctx->codec->id != AV_CODEC_ID_MPEG4_SYNO)) {
+#else
if (avctx->codec->id != AV_CODEC_ID_H263 &&
avctx->codec->id != AV_CODEC_ID_H263P &&
avctx->codec->id != AV_CODEC_ID_MPEG4) {
+#endif
avctx->pix_fmt = h263_get_format(avctx);
ff_mpv_idct_init(s);
if ((ret = ff_mpv_common_init(s)) < 0)
@@ -146,11 +170,60 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
return 0;
}
+#ifdef SYNO_EVANSPORT_SMD
+av_cold int ff_h263_decode_init_smd(AVCodecContext *avctx)
+{
+ ismd_result_t ret_val = ISMD_ERROR_UNSPECIFIED;
+ if((avctx->codec_id == AV_CODEC_ID_MSMPEG4V1) || (avctx->codec_id == AV_CODEC_ID_MSMPEG4V2) || (avctx->codec_id == AV_CODEC_ID_MSMPEG4V3))
+ {
+ av_log(NULL,AV_LOG_INFO,"\nThis video format is not supported by smd.Falling back to software\n");
+ return 0;
+ }
+
+ smd_mpeg4_vid_dec.codec = ISMD_CODEC_TYPE_MPEG4;
+ // 1. Setup a single stream
+ ret_val = ismd_ffmpeg_setup_viddec_stream(&smd_mpeg4_vid_dec);
+ if(ISMD_SUCCESS == ret_val)
+ {
+ // 2. Start the stream
+ ret_val = ismd_ffmpeg_start_viddec_stream(&smd_mpeg4_vid_dec);
+ }
+ if(ret_val != ISMD_SUCCESS)
+ {
+ av_log(avctx,AV_LOG_INFO,"\nMPEG2 Hardware video decoder not available.Falling Back to software.\n");
+ av_log(avctx,AV_LOG_INFO,"\nMPEG2 can't fall back to software.\n");
+ return -1;
+ }
+ else
+ {
+ av_log(avctx,AV_LOG_INFO,"\n******************Using MPEG4 Hardware video decoder**************\n");
+ smd_mpeg4_vid_dec_available = true;
+ smd_mpeg4_vid_dec.y_mem = NULL;
+ smd_mpeg4_vid_dec.u_mem = NULL;
+ smd_mpeg4_vid_dec.v_mem = NULL;
+ smd_mpeg4_vid_dec.send_sps_pps = true;
+ }
+ return 0;
+}
+#endif
+
av_cold int ff_h263_decode_end(AVCodecContext *avctx)
{
+#ifdef SYNO_EVANSPORT_SMD
+ ismd_result_t ret_val = ISMD_ERROR_UNSPECIFIED;
+#endif
MpegEncContext *s = avctx->priv_data;
ff_mpv_common_end(s);
+#ifdef SYNO_EVANSPORT_SMD
+ if(smd_mpeg4_vid_dec_available)
+ {
+ ret_val = ismd_ffmpeg_free_vid_dec_res(&smd_mpeg4_vid_dec);
+ if(ret_val != ISMD_SUCCESS)
+ av_log(avctx,AV_LOG_ERROR,"could not free video decoder resources\n");
+ }
+ smd_mpeg4_vid_dec_available = false;
+#endif
return 0;
}
@@ -716,6 +789,80 @@ frame_end:
return get_consumed_bytes(s, buf_size);
}
+#ifdef SYNO_EVANSPORT_SMD
+int ff_h263_decode_frame_smd(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
+{
+ ismd_result_t ret_val = ISMD_ERROR_UNSPECIFIED;
+ ismd_result_t result = ISMD_ERROR_UNSPECIFIED;
+ ismd_buffer_handle_t ismd_buf = -1;
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ AVFrame *pict = data;
+
+ int got_frame = 0;
+ smd_video_frame decoded_frame;
+ struct timespec ts;
+
+ if(smd_mpeg4_vid_dec_available)
+ {
+ //send headers before first packet
+ if((smd_mpeg4_vid_dec.send_sps_pps) && (avctx->extradata_size > 0))
+ {
+ if ((result = ismd_buffer_alloc(CHUNK_SIZE, &ismd_buf)) == ISMD_SUCCESS)
+ {
+ if ((result = ismd_ffmpeg_fill_viddec_buffer(avctx->extradata, ismd_buf,avctx->extradata_size)) == ISMD_SUCCESS)
+ {
+ // decode it asynchronously
+ if ((result = ismd_ffmpeg_decoder_port_write(&smd_mpeg4_vid_dec,ismd_buf)) != ISMD_SUCCESS)
+ {
+ av_log(NULL, AV_LOG_ERROR,"error: unable to decode smd_buffers11 [%d]\n", result);
+ }
+ }
+ }
+ else
+ {
+ av_log(NULL, AV_LOG_INFO,"error: unable to allocate buffer in decode_frame111 [%d]\n", result);
+ }
+ smd_mpeg4_vid_dec.send_sps_pps = false;
+ }
+
+ ret_val = ismd_ffmpeg_decode_vid_buf(&smd_mpeg4_vid_dec, buf, buf_size);
+ if(ret_val != ISMD_SUCCESS)
+ {
+ av_log(avctx,AV_LOG_ERROR,"\nismd_ffmpeg_decode_buf failed error:%d buf_size %d\n",ret_val,buf_size);
+ return -1;
+ }
+ ts.tv_sec = 0;
+ ts.tv_nsec = 10;
+ nanosleep (&ts, NULL);
+
+ ismd_ffmpeg_get_decoded_data(&decoded_frame, &smd_mpeg4_vid_dec, &got_frame);
+ if(got_frame)
+ {
+ *data_size = sizeof(AVFrame);
+ avctx->width = decoded_frame.width;
+ avctx->height = decoded_frame.height;
+ avctx->pix_fmt = PIX_FMT_YUV420P;
+
+ pict->pkt_pts = AV_NOPTS_VALUE;
+ pict->pts = AV_NOPTS_VALUE ;
+ pict->data[0] = (uint8_t*)decoded_frame.y_mem;
+ pict->data[1] = (uint8_t*)decoded_frame.u_mem;
+ pict->data[2] = (uint8_t*)decoded_frame.v_mem;
+ pict->linesize[0] = decoded_frame.linesize_y;
+ pict->linesize[1] = decoded_frame.linesize_u;
+ pict->linesize[2] = decoded_frame.linesize_v;
+
+ }
+ return buf_size;
+ }
+ else
+ {
+ return ff_h263_decode_frame(avctx, data, data_size, avpkt);
+ }
+}
+#endif
+
const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] = {
#if CONFIG_H263_VAAPI_HWACCEL || CONFIG_MPEG4_VAAPI_HWACCEL
AV_PIX_FMT_VAAPI_VLD,
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 9a002142cc..b73d84d488 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -51,6 +51,17 @@
#include "thread.h"
#include "vdpau_compat.h"
+#include "synoconfig.h"
+#include "synog1codecpatent.h"
+
+#ifdef SYNO_EVANSPORT_SMD
+#include "libffmpeg_plugin/ismd_ffmpeg_util.h"
+#include "libffmpeg_plugin/ismd_ffmpeg_video_dec.h"
+#include "libavformat/avformat.h"
+static viddec_struct_t smd_h264_vid_dec;
+bool smd_h264_vid_dec_available = false;
+#endif
+
const uint16_t ff_h264_mb_sizes[4] = { 256, 384, 512, 768 };
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx)
@@ -646,6 +657,12 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
H264Context *h = avctx->priv_data;
int ret;
+#ifdef SYNO_CODEC_PATENT_G1
+ if (0 != ActivateCodec("h264_dec")) {
+ return -1;
+ }
+#endif
+
ret = h264_init_context(avctx, h);
if (ret < 0)
return ret;
@@ -658,7 +675,11 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
ff_init_cabac_states();
+#ifdef SYNO_EVANSPORT_SMD
+ if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_H264_SYNO) {
+#else
if (avctx->codec_id == AV_CODEC_ID_H264) {
+#endif
if (avctx->ticks_per_frame == 1) {
if(h->avctx->time_base.den < INT_MAX/2) {
h->avctx->time_base.den *= 2;
@@ -698,6 +719,41 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
return 0;
}
+#ifdef SYNO_EVANSPORT_SMD
+static av_cold int ff_h264_decode_init_smd(AVCodecContext *avctx){
+ ismd_result_t ret_val = ISMD_ERROR_UNSPECIFIED;
+ int result;
+ result = ff_h264_decode_init(avctx);
+
+ /********************* SMD code *******************/
+ smd_h264_vid_dec.codec = ISMD_CODEC_TYPE_H264;
+ // 1. Setup a single stream
+ ret_val = ismd_ffmpeg_setup_viddec_stream(&smd_h264_vid_dec);
+ if(ISMD_SUCCESS == ret_val)
+ {
+ // 2. Start the stream
+ ret_val = ismd_ffmpeg_start_viddec_stream(&smd_h264_vid_dec);
+ }
+ if(ret_val != ISMD_SUCCESS)
+ {
+ av_log(avctx,AV_LOG_INFO,"\nH.264 Hardware video decoder not available.\n");
+ av_log(avctx,AV_LOG_INFO,"\nH.264 can't fall back to software.\n");
+ result = -1;
+ }
+ else
+ {
+ av_log(avctx,AV_LOG_INFO,"\n******************Using H.264 Hardware video decoder**************\n");
+ smd_h264_vid_dec_available = true;
+ smd_h264_vid_dec.y_mem = NULL;
+ smd_h264_vid_dec.u_mem = NULL;
+ smd_h264_vid_dec.v_mem = NULL;
+ smd_h264_vid_dec.send_sps_pps = true;
+ }
+ return result;
+ /********************** SMD END *********************/
+}
+#endif
+
static int decode_init_thread_copy(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
@@ -1848,6 +1904,129 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
return get_consumed_bytes(buf_index, buf_size);
}
+#ifdef SYNO_EVANSPORT_SMD
+static int h264_decode_frame_smd(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
+{
+ ismd_result_t ret_val = ISMD_ERROR_UNSPECIFIED;
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ H264Context *h = avctx->priv_data;
+ AVFrame *pict = data;
+ uint8_t* buf_with_start_code =NULL;
+ int new_buf_size = buf_size;
+ uint8_t* sps_pps_buf =NULL;
+ /**************************** SMD **********************************/
+ ismd_buffer_handle_t ismd_buf = -1;
+ int sps_pps_buf_size =0;
+ ismd_result_t result = ISMD_SUCCESS;
+ int got_frame = 0;
+ smd_video_frame decoded_frame;
+ struct timespec ts;
+ if(smd_h264_vid_dec_available)
+ {
+ if(buf_size > 4)
+ {
+ if(h->is_avc)
+ {
+ av_log(NULL,AV_LOG_DEBUG,"\nh.264 content is in avc1 format\n");
+ //in most of the cases h->nal_length_size is 4.This fields contains
+ //total length of the following nal unit.
+ //start code length is also 4 so you don't need
+ //to allocate buffer more than avpkt->size because you can write insert
+ //start code in place of h->nal_length_size field
+ //but this may not work when h->nal_length_size is 2 which is very rare
+
+ buf_with_start_code = av_malloc(avpkt->size);//allocate memory for new buffer
+ if(buf_with_start_code == NULL)
+ {
+ av_log(NULL,AV_LOG_ERROR,"\ncould not allocate memory for new buffer \n");
+ assert(0);
+ }
+ if((smd_h264_vid_dec.send_sps_pps) && avctx->extradata_size > 0 && avctx->extradata)
+ {
+ sps_pps_buf_size = ismd_ffmpeg_h264_viddec_extract_sps_pps(avctx->extradata,avctx->extradata_size, &sps_pps_buf);
+ }
+
+ new_buf_size = ismd_ffmpeg_unit_to_byte_stream(&buf_with_start_code, buf, avpkt->size, h->nal_length_size);
+ }
+ else
+ {
+ buf_with_start_code = buf;//incoming buffer is in Byte-stream format.no conversion req.
+ }
+ }
+ /*********** write sps/pps buffer for avc1 at decoder i/p port*********************/
+ //send sps pps before first packet
+ if((smd_h264_vid_dec.send_sps_pps) && h->is_avc)
</