diff --git a/hooks/install_hooks.sh b/hooks/install_hooks.sh new file mode 100755 index 00000000..eeca5146 --- /dev/null +++ b/hooks/install_hooks.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# install git hooks + +src_dir=../../hooks +dst_dir=../.git/hooks + +if test ! \( -x $dst_dir/pre-commit -a -L $dst_dir/pre-commit \); + +then + + rm -f $dst_dir/pre-commit + + if ! ln -s $src_dir/pre-commit.hook $dst_dir/pre-commit 2> /dev/null + + then + + echo "Failed to create commit hook symlink, copying instead ..." + cp pre-commit.hook ../.git/hooks/pre-commit + + fi + +fi diff --git a/hooks/pre-commit.hook b/hooks/pre-commit.hook new file mode 100755 index 00000000..c00717d5 --- /dev/null +++ b/hooks/pre-commit.hook @@ -0,0 +1,31 @@ +#!/bin/sh + +out_file="./fmt_df.txt" +cur_dir=$(pwd) +script_dir=tools/ + +echo "[git-hook]: before commit, format code use mpp_astyle.sh ..." + +cd $script_dir +./mpp_astyle.sh + +cd $cur_dir + +git diff > $out_file + +if [ -s $out_file ] +then { + echo "[git-hook]: code changed after formating, please commit again." + rm $out_file + echo "[git-hook]: git status below:" + git status + exit 1 +} else { + echo "[git-hook]: nothing change after formating, commit continues." + if [ -f $out_file ] + then { + rm $out_file + } fi + exit 0 +} fi + diff --git a/mpp/codec/dec/m2v/m2vd_parser.c b/mpp/codec/dec/m2v/m2vd_parser.c index 1d1f1403..639aa7e5 100755 --- a/mpp/codec/dec/m2v/m2vd_parser.c +++ b/mpp/codec/dec/m2v/m2vd_parser.c @@ -422,7 +422,7 @@ MPP_RET m2vd_parser_prepare(void *ctx, MppPacket pkt, HalDecTask *task) p->pts = mpp_packet_get_pts(pkt); len_in = (RK_U32)mpp_packet_get_length(pkt); - if(mpp_packet_get_flag(pkt) & MPP_PACKET_FLAG_EXTRA_DATA) { + if (mpp_packet_get_flag(pkt) & MPP_PACKET_FLAG_EXTRA_DATA) { pos += len_in; mpp_packet_set_pos(pkt, pos); return ret; diff --git a/mpp/codec/mpp_rc.cpp b/mpp/codec/mpp_rc.cpp index 7e7dd745..3668b5de 100644 --- a/mpp/codec/mpp_rc.cpp +++ b/mpp/codec/mpp_rc.cpp @@ -605,7 +605,7 @@ MPP_RET mpp_quadreg_update(MppLinReg *ctx, RK_S32 x, RK_S32 r, RK_S32 wlen) else i--; - cq = cx[i]; + cq = cx[i]; /* limite wlen when complexity change sharply */ if (idx++ > wlen) @@ -682,7 +682,7 @@ MPP_RET mpp_quadreg_update(MppLinReg *ctx, RK_S32 x, RK_S32 r, RK_S32 wlen) mpp_rc_dbg_rc("%e %e %e\n", b0, b1, b2); matrix_value = a00 * a11 * a22 + a01 * a12 * a20 + a02 * a10 * a21 - - a02 * a11 * a20 - a00 * a12 * a21 - a01 * a10 * a22; + - a02 * a11 * a20 - a00 * a12 * a21 - a01 * a10 * a22; mpp_rc_dbg_rc("matrix value: %e\n", matrix_value); diff --git a/mpp/hal/worker/libvpu/vpu.c b/mpp/hal/worker/libvpu/vpu.c index 6e0d3dc6..7b24ab5c 100644 --- a/mpp/hal/worker/libvpu/vpu.c +++ b/mpp/hal/worker/libvpu/vpu.c @@ -114,7 +114,7 @@ int VPUClientInit(VPU_CLIENT_TYPE type) if (fd == -1) { mpp_err_f("failed to open %s, errno = %d, error msg: %s\n", - name, errno, strerror(errno)); + name, errno, strerror(errno)); return -1; } ret = ioctl(fd, VPU_IOC_SET_CLIENT_TYPE, (RK_U32)type); diff --git a/tools/astyle b/tools/astyle new file mode 100755 index 00000000..d66ee115 Binary files /dev/null and b/tools/astyle differ diff --git a/tools/mpp_astyle.sh b/tools/mpp_astyle.sh index 14f24bb2..68c05b4f 100755 --- a/tools/mpp_astyle.sh +++ b/tools/mpp_astyle.sh @@ -1,4 +1,4 @@ #!/bin/bash set -e -astyle --options=astylerc ../*.cpp ../*.c ../*.h +./astyle --quiet --options=astylerc ../*.cpp ../*.c ../*.h