From 56621fbffbbef9cf2bbd6f89dfac115da3571e9d Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Mon, 13 Apr 2020 21:26:43 +0100 Subject: [PATCH] use new openh264 version v2.1.0 --- src/openh264/.gitignore | 0 src/openh264/.reviewboardrc | 0 src/openh264/.travis.yml | 6 +- src/openh264/CODING_STYLE | 0 src/openh264/CONTRIBUTORS | 0 src/openh264/LICENSE | 0 src/openh264/Makefile | 6 +- src/openh264/README.md | 0 src/openh264/RELEASES | 6 + .../autotest/performanceTest/.gitignore | 0 .../android/run_AutoTest_android.sh | 0 .../performanceTest/ios/run_AutoTest_ios.sh | 0 .../autotest/performanceTest/ios/uiascript.js | 0 .../autotest/performanceTest/run_perfTest.sh | 0 .../unitTest/android/run_AutoTest_android.sh | 0 .../autotest/unitTest/ios/run_AutoTest_ios.sh | 0 .../autotest/unitTest/run_ParseUTxml.sh | 0 .../autotest/unitTest/run_unitTest.sh | 0 .../build/AutoBuildForWPAndWindows.bat | 0 src/openh264/build/Dockerfile | 0 src/openh264/build/arch.mk | 20 +- src/openh264/build/astyle.cfg | 0 src/openh264/build/gtest-targets.mk | 0 src/openh264/build/mips-simd-check.sh | 32 + src/openh264/build/mktargets.py | 43 +- src/openh264/build/msvc-app.mk | 0 src/openh264/build/msvc-common.mk | 0 src/openh264/build/platform-android.mk | 13 +- src/openh264/build/platform-bsd.mk | 0 src/openh264/build/platform-cygwin_nt.mk | 0 src/openh264/build/platform-darwin.mk | 4 +- src/openh264/build/platform-ios.mk | 0 src/openh264/build/platform-linux.mk | 0 src/openh264/build/platform-mingw_nt.mk | 0 src/openh264/build/platform-msvc-app.mk | 0 src/openh264/build/platform-msvc-wp.mk | 0 src/openh264/build/platform-msvc.mk | 0 src/openh264/build/x86-common.mk | 0 src/openh264/codec/api/meson.build | 0 src/openh264/codec/api/svc/codec_api.h | 0 src/openh264/codec/api/svc/codec_app_def.h | 4 +- src/openh264/codec/api/svc/codec_def.h | 1 + src/openh264/codec/api/svc/codec_ver.h | 8 +- src/openh264/codec/api/svc/meson.build | 0 src/openh264/codec/build/android/.gitignore | 0 .../build/android/dec/AndroidManifest.xml | 0 .../codec/build/android/dec/jni/Android.mk | 0 .../build/android/dec/jni/Application.mk | 0 .../codec/build/android/dec/jni/myjni.cpp | 0 .../build/android/dec/jni/welsdecdemo.mk | 0 .../build/android/dec/res/layout/main.xml | 0 .../build/android/dec/res/values/strings.xml | 0 .../dec/src/com/wels/dec/WelsDecTest.java | 0 .../build/android/enc/AndroidManifest.xml | 0 .../codec/build/android/enc/jni/Android.mk | 0 .../build/android/enc/jni/Application.mk | 0 .../codec/build/android/enc/jni/myjni.cpp | 0 .../build/android/enc/jni/welsencdemo.mk | 0 .../build/android/enc/res/layout/main.xml | 0 .../build/android/enc/res/values/strings.xml | 0 .../enc/src/com/wels/enc/WelsEncTest.java | 0 src/openh264/codec/build/iOS/.gitignore | 0 .../common/common.xcodeproj/project.pbxproj | 0 .../dec/demo/demo.xcodeproj/project.pbxproj | 0 .../build/iOS/dec/demo/demo/DEMOAppDelegate.h | 0 .../build/iOS/dec/demo/demo/DEMOAppDelegate.m | 0 .../iOS/dec/demo/demo/DEMOViewController.h | 0 .../iOS/dec/demo/demo/DEMOViewController.m | 0 .../demo/DEMOViewControllerShowResource.h | 0 .../demo/DEMOViewControllerShowResource.m | 0 .../iOS/dec/demo/demo/Default-568h@2x.png | Bin .../codec/build/iOS/dec/demo/demo/Default.png | Bin .../build/iOS/dec/demo/demo/Default@2x.png | Bin .../build/iOS/dec/demo/demo/demo-Info.plist | 0 .../dec/demo/demo/en.lproj/InfoPlist.strings | 0 .../en.lproj/MainStoryboard_iPad.storyboard | 0 .../en.lproj/MainStoryboard_iPhone.storyboard | 0 .../codec/build/iOS/dec/demo/demo/main.m | 0 .../welsdec/welsdec.xcodeproj/project.pbxproj | 0 .../encDemo/encDemo.xcodeproj/project.pbxproj | 0 .../iOS/enc/encDemo/encDemo/AppDelegate.h | 0 .../iOS/enc/encDemo/encDemo/AppDelegate.m | 0 .../encDemo/Base.lproj/Main_iPad.storyboard | 0 .../encDemo/Base.lproj/Main_iPhone.storyboard | 0 .../AppIcon.appiconset/Contents.json | 0 .../LaunchImage.launchimage/Contents.json | 0 .../iOS/enc/encDemo/encDemo/ViewController.h | 0 .../iOS/enc/encDemo/encDemo/ViewController.m | 0 .../encDemo/en.lproj/InfoPlist.strings | 0 .../enc/encDemo/encDemo/encDemo-Info.plist | 0 .../build/iOS/enc/encDemo/encDemo/main.m | 0 .../welsenc/welsenc.xcodeproj/project.pbxproj | 0 .../openh264.xcodeproj/project.pbxproj | 0 .../processing.xcodeproj/project.pbxproj | 0 src/openh264/codec/build/win32/.gitignore | 0 .../codec/build/win32/dec/WelsDecCore.vcproj | 8 + .../codec/build/win32/dec/WelsDecPlus.vcproj | 0 .../codec/build/win32/dec/WelsDecoder.sln | 0 .../codec/build/win32/dec/decConsole.vcproj | 0 .../codec/build/win32/enc/WelsEncCore.vcproj | 0 .../codec/build/win32/enc/WelsEncPlus.vcproj | 0 .../codec/build/win32/enc/WelsEncoder.sln | 0 .../codec/build/win32/enc/encConsole.vcproj | 0 .../codec/build/windowsphone/.gitignore | 0 .../codec/build/windowsphone/all/CodecApp.sln | 0 .../build/windowsphone/all/CodecApp/App.xaml | 0 .../windowsphone/all/CodecApp/App.xaml.cs | 0 .../all/CodecApp/Assets/AlignmentGrid.png | Bin .../all/CodecApp/Assets/ApplicationIcon.png | Bin .../all/CodecApp/Assets/BadgeLogo.png | Bin .../windowsphone/all/CodecApp/Assets/Logo.png | Bin .../all/CodecApp/Assets/SplashScreen.png | Bin .../all/CodecApp/Assets/SquareTile150x150.png | Bin .../all/CodecApp/Assets/SquareTile71x71.png | Bin .../all/CodecApp/Assets/StoreLogo.png | Bin .../Assets/Tiles/FlipCycleTileLarge.png | Bin .../Assets/Tiles/FlipCycleTileMedium.png | Bin .../Assets/Tiles/FlipCycleTileSmall.png | Bin .../Assets/Tiles/IconicTileMediumLarge.png | Bin .../CodecApp/Assets/Tiles/IconicTileSmall.png | Bin .../all/CodecApp/Assets/WideLogo.png | Bin .../windowsphone/all/CodecApp/CodecApp.csproj | 0 .../all/CodecApp/LocalizedStrings.cs | 0 .../windowsphone/all/CodecApp/MainPage.xaml | 0 .../all/CodecApp/MainPage.xaml.cs | 0 .../all/CodecApp/Package.appxmanifest | 0 .../all/CodecApp/Properties/AppManifest.xml | 0 .../all/CodecApp/Properties/AssemblyInfo.cs | 0 .../all/CodecApp/Properties/WMAppManifest.xml | 0 .../Resources/AppResources.Designer.cs | 0 .../all/CodecApp/Resources/AppResources.resx | 0 .../windowsphone/all/CodecApp/layer2.cfg | 0 .../windowsphone/all/CodecApp/welsenc.cfg | 0 .../windowsphone/all/CodecRTComponent.cpp | 0 .../build/windowsphone/all/CodecRTComponent.h | 0 .../windowsphone/all/CodecRTComponent.vcxproj | 0 .../all/CodecRTComponent.vcxproj.filters | 0 .../codec/common/arm/arm_arch_common_macro.S | 0 src/openh264/codec/common/arm/copy_mb_neon.S | 0 .../codec/common/arm/deblocking_neon.S | 0 .../codec/common/arm/expand_picture_neon.S | 0 .../codec/common/arm/intra_pred_common_neon.S | 0 src/openh264/codec/common/arm/mc_neon.S | 0 .../common/arm64/arm_arch64_common_macro.S | 0 .../codec/common/arm64/copy_mb_aarch64_neon.S | 0 .../common/arm64/deblocking_aarch64_neon.S | 0 .../arm64/expand_picture_aarch64_neon.S | 0 .../arm64/intra_pred_common_aarch64_neon.S | 0 .../codec/common/arm64/mc_aarch64_neon.S | 0 src/openh264/codec/common/inc/.gitignore | 0 src/openh264/codec/common/inc/WelsList.h | 0 src/openh264/codec/common/inc/WelsLock.h | 0 src/openh264/codec/common/inc/WelsTask.h | 0 .../codec/common/inc/WelsTaskThread.h | 0 src/openh264/codec/common/inc/WelsThread.h | 0 src/openh264/codec/common/inc/WelsThreadLib.h | 13 + .../codec/common/inc/WelsThreadPool.h | 0 src/openh264/codec/common/inc/asmdefs_mmi.h | 2 +- src/openh264/codec/common/inc/copy_mb.h | 0 src/openh264/codec/common/inc/cpu.h | 0 src/openh264/codec/common/inc/cpu_core.h | 1 + .../codec/common/inc/crt_util_safe_x.h | 0 .../codec/common/inc/deblocking_common.h | 0 src/openh264/codec/common/inc/expand_pic.h | 5 + src/openh264/codec/common/inc/golomb_common.h | 0 .../codec/common/inc/intra_pred_common.h | 0 src/openh264/codec/common/inc/ls_defines.h | 0 src/openh264/codec/common/inc/macros.h | 0 src/openh264/codec/common/inc/mc.h | 0 src/openh264/codec/common/inc/measure_time.h | 0 src/openh264/codec/common/inc/memory_align.h | 0 src/openh264/codec/common/inc/sad_common.h | 0 src/openh264/codec/common/inc/typedefs.h | 0 src/openh264/codec/common/inc/utils.h | 0 src/openh264/codec/common/inc/version.h | 0 .../codec/common/inc/version_gen.h.template | 0 .../codec/common/inc/welsCodecTrace.h | 0 .../codec/common/inc/wels_common_defs.h | 0 .../codec/common/inc/wels_const_common.h | 0 src/openh264/codec/common/meson.build | 0 src/openh264/codec/common/mips/copy_mb_mmi.c | 0 src/openh264/codec/common/mips/deblock_mmi.c | 0 .../codec/common/mips/expand_picture_mmi.c | 0 .../codec/common/mips/intra_pred_com_mmi.c | 0 src/openh264/codec/common/mips/satd_sad_mmi.c | 0 .../codec/common/src/WelsTaskThread.cpp | 0 src/openh264/codec/common/src/WelsThread.cpp | 0 .../codec/common/src/WelsThreadLib.cpp | 12 - .../codec/common/src/WelsThreadPool.cpp | 0 .../codec/common/src/common_tables.cpp | 0 src/openh264/codec/common/src/copy_mb.cpp | 0 src/openh264/codec/common/src/cpu.cpp | 45 +- .../codec/common/src/crt_util_safe_x.cpp | 0 .../codec/common/src/deblocking_common.cpp | 0 src/openh264/codec/common/src/expand_pic.cpp | 234 +++ .../codec/common/src/intra_pred_common.cpp | 0 src/openh264/codec/common/src/mc.cpp | 0 .../codec/common/src/memory_align.cpp | 0 src/openh264/codec/common/src/sad_common.cpp | 0 src/openh264/codec/common/src/utils.cpp | 0 .../codec/common/src/welsCodecTrace.cpp | 0 src/openh264/codec/common/targets.mk | 18 +- src/openh264/codec/common/x86/asm_inc.asm | 0 src/openh264/codec/common/x86/cpuid.asm | 0 src/openh264/codec/common/x86/dct.asm | 0 src/openh264/codec/common/x86/deblock.asm | 0 .../codec/common/x86/expand_picture.asm | 0 .../codec/common/x86/intra_pred_com.asm | 0 src/openh264/codec/common/x86/mb_copy.asm | 0 src/openh264/codec/common/x86/mc_chroma.asm | 0 src/openh264/codec/common/x86/mc_luma.asm | 0 src/openh264/codec/common/x86/satd_sad.asm | 0 src/openh264/codec/common/x86/vaa.asm | 0 .../codec/console/common/inc/read_config.h | 0 src/openh264/codec/console/common/meson.build | 0 .../codec/console/common/src/read_config.cpp | 0 src/openh264/codec/console/common/targets.mk | 0 .../codec/console/dec/inc/d3d9_utils.h | 0 src/openh264/codec/console/dec/meson.build | 0 .../codec/console/dec/src/d3d9_utils.cpp | 0 .../codec/console/dec/src/h264dec.cpp | 188 ++- src/openh264/codec/console/dec/targets.mk | 0 src/openh264/codec/console/enc/meson.build | 0 .../codec/console/enc/src/welsenc.cpp | 0 src/openh264/codec/console/enc/targets.mk | 0 src/openh264/codec/console/meson.build | 0 .../codec/decoder/core/arm/block_add_neon.S | 0 .../codec/decoder/core/arm/intra_pred_neon.S | 0 .../core/arm64/block_add_aarch64_neon.S | 0 .../core/arm64/intra_pred_aarch64_neon.S | 0 .../codec/decoder/core/inc/au_parser.h | 0 .../codec/decoder/core/inc/bit_stream.h | 0 .../codec/decoder/core/inc/cabac_decoder.h | 0 .../codec/decoder/core/inc/deblocking.h | 30 +- .../codec/decoder/core/inc/dec_frame.h | 0 .../codec/decoder/core/inc/dec_golomb.h | 0 .../codec/decoder/core/inc/decode_mb_aux.h | 0 .../codec/decoder/core/inc/decode_slice.h | 9 +- src/openh264/codec/decoder/core/inc/decoder.h | 21 +- .../codec/decoder/core/inc/decoder_context.h | 168 +- .../codec/decoder/core/inc/decoder_core.h | 28 + .../codec/decoder/core/inc/error_code.h | 0 .../decoder/core/inc/error_concealment.h | 0 src/openh264/codec/decoder/core/inc/fmo.h | 0 .../decoder/core/inc/get_intra_predictor.h | 0 .../codec/decoder/core/inc/manage_dec_ref.h | 3 +- .../codec/decoder/core/inc/mb_cache.h | 0 .../codec/decoder/core/inc/memmgr_nal_unit.h | 0 src/openh264/codec/decoder/core/inc/mv_pred.h | 15 +- .../codec/decoder/core/inc/nal_prefix.h | 0 src/openh264/codec/decoder/core/inc/nalu.h | 0 .../codec/decoder/core/inc/parameter_sets.h | 0 .../decoder/core/inc/parse_mb_syn_cabac.h | 0 .../decoder/core/inc/parse_mb_syn_cavlc.h | 14 +- .../codec/decoder/core/inc/pic_queue.h | 3 + src/openh264/codec/decoder/core/inc/picture.h | 11 +- src/openh264/codec/decoder/core/inc/rec_mb.h | 5 +- src/openh264/codec/decoder/core/inc/slice.h | 0 .../codec/decoder/core/inc/vlc_decoder.h | 0 .../decoder/core/inc/wels_common_basis.h | 0 .../codec/decoder/core/inc/wels_const.h | 0 .../decoder/core/inc/wels_decoder_thread.h | 170 ++ .../codec/decoder/core/mips/dct_mmi.c | 0 .../codec/decoder/core/src/au_parser.cpp | 123 +- .../codec/decoder/core/src/bit_stream.cpp | 0 .../codec/decoder/core/src/cabac_decoder.cpp | 0 .../codec/decoder/core/src/deblocking.cpp | 283 ++-- .../codec/decoder/core/src/decode_mb_aux.cpp | 0 .../codec/decoder/core/src/decode_slice.cpp | 1470 +++++++++-------- .../codec/decoder/core/src/decoder.cpp | 198 ++- .../codec/decoder/core/src/decoder_core.cpp | 586 +++++-- .../decoder/core/src/decoder_data_tables.cpp | 0 .../decoder/core/src/error_concealment.cpp | 68 +- src/openh264/codec/decoder/core/src/fmo.cpp | 0 .../decoder/core/src/get_intra_predictor.cpp | 0 .../codec/decoder/core/src/manage_dec_ref.cpp | 138 +- .../decoder/core/src/memmgr_nal_unit.cpp | 0 .../codec/decoder/core/src/mv_pred.cpp | 446 ++--- .../decoder/core/src/parse_mb_syn_cabac.cpp | 89 +- .../decoder/core/src/parse_mb_syn_cavlc.cpp | 297 ++-- .../codec/decoder/core/src/pic_queue.cpp | 73 +- .../codec/decoder/core/src/rec_mb.cpp | 373 +++-- .../decoder/core/src/wels_decoder_thread.cpp | 311 ++++ src/openh264/codec/decoder/core/x86/dct.asm | 0 .../codec/decoder/core/x86/intra_pred.asm | 0 src/openh264/codec/decoder/meson.build | 1 + .../codec/decoder/plus/inc/welsDecoderExt.h | 54 +- .../codec/decoder/plus/src/welsDecoderExt.cpp | 1232 +++++++++----- .../decoder/plus/src/wels_dec_export.def | 0 src/openh264/codec/decoder/targets.mk | 19 +- .../codec/encoder/core/arm/intra_pred_neon.S | 0 .../core/arm/intra_pred_sad_3_opt_neon.S | 0 .../codec/encoder/core/arm/memory_neon.S | 0 .../codec/encoder/core/arm/pixel_neon.S | 0 .../codec/encoder/core/arm/reconstruct_neon.S | 0 .../encoder/core/arm/svc_motion_estimation.S | 0 .../core/arm64/intra_pred_aarch64_neon.S | 0 .../arm64/intra_pred_sad_3_opt_aarch64_neon.S | 0 .../encoder/core/arm64/memory_aarch64_neon.S | 0 .../encoder/core/arm64/pixel_aarch64_neon.S | 0 .../core/arm64/reconstruct_aarch64_neon.S | 0 .../svc_motion_estimation_aarch64_neon.S | 0 .../codec/encoder/core/inc/as264_common.h | 0 src/openh264/codec/encoder/core/inc/au_set.h | 0 .../codec/encoder/core/inc/deblocking.h | 0 .../codec/encoder/core/inc/decode_mb_aux.h | 0 src/openh264/codec/encoder/core/inc/dq_map.h | 0 .../codec/encoder/core/inc/encode_mb_aux.h | 0 src/openh264/codec/encoder/core/inc/encoder.h | 0 .../codec/encoder/core/inc/encoder_context.h | 0 src/openh264/codec/encoder/core/inc/extern.h | 0 .../encoder/core/inc/get_intra_predictor.h | 0 .../codec/encoder/core/inc/mb_cache.h | 0 src/openh264/codec/encoder/core/inc/md.h | 0 src/openh264/codec/encoder/core/inc/mt_defs.h | 0 src/openh264/codec/encoder/core/inc/mv_pred.h | 0 .../codec/encoder/core/inc/nal_encap.h | 0 .../codec/encoder/core/inc/param_svc.h | 0 .../codec/encoder/core/inc/parameter_sets.h | 0 .../codec/encoder/core/inc/paraset_strategy.h | 0 src/openh264/codec/encoder/core/inc/picture.h | 0 .../codec/encoder/core/inc/picture_handle.h | 0 src/openh264/codec/encoder/core/inc/rc.h | 0 .../codec/encoder/core/inc/ref_list_mgr_svc.h | 0 src/openh264/codec/encoder/core/inc/sample.h | 0 .../codec/encoder/core/inc/set_mb_syn_cabac.h | 0 .../codec/encoder/core/inc/set_mb_syn_cavlc.h | 0 src/openh264/codec/encoder/core/inc/slice.h | 0 .../encoder/core/inc/slice_multi_threading.h | 0 src/openh264/codec/encoder/core/inc/stat.h | 0 .../encoder/core/inc/svc_base_layer_md.h | 0 .../codec/encoder/core/inc/svc_enc_frame.h | 0 .../codec/encoder/core/inc/svc_enc_golomb.h | 0 .../encoder/core/inc/svc_enc_macroblock.h | 0 .../encoder/core/inc/svc_enc_slice_segment.h | 0 .../codec/encoder/core/inc/svc_encode_mb.h | 0 .../codec/encoder/core/inc/svc_encode_slice.h | 0 .../encoder/core/inc/svc_mode_decision.h | 0 .../encoder/core/inc/svc_motion_estimate.h | 0 .../codec/encoder/core/inc/svc_set_mb_syn.h | 0 .../encoder/core/inc/svc_set_mb_syn_cavlc.h | 0 .../codec/encoder/core/inc/vlc_encoder.h | 0 .../encoder/core/inc/wels_common_basis.h | 0 .../codec/encoder/core/inc/wels_const.h | 0 .../encoder/core/inc/wels_func_ptr_def.h | 0 .../codec/encoder/core/inc/wels_preprocess.h | 0 .../codec/encoder/core/inc/wels_task_base.h | 0 .../encoder/core/inc/wels_task_encoder.h | 0 .../encoder/core/inc/wels_task_management.h | 0 .../encoder/core/inc/wels_transpose_matrix.h | 0 .../codec/encoder/core/mips/dct_mmi.c | 0 .../codec/encoder/core/mips/quant_mmi.c | 0 .../codec/encoder/core/mips/score_mmi.c | 0 .../codec/encoder/core/src/au_set.cpp | 0 .../codec/encoder/core/src/deblocking.cpp | 0 .../codec/encoder/core/src/decode_mb_aux.cpp | 0 .../codec/encoder/core/src/encode_mb_aux.cpp | 0 .../codec/encoder/core/src/encoder.cpp | 0 .../encoder/core/src/encoder_data_tables.cpp | 0 .../codec/encoder/core/src/encoder_ext.cpp | 0 .../encoder/core/src/get_intra_predictor.cpp | 0 src/openh264/codec/encoder/core/src/md.cpp | 0 .../codec/encoder/core/src/mv_pred.cpp | 0 .../codec/encoder/core/src/nal_encap.cpp | 0 .../encoder/core/src/paraset_strategy.cpp | 0 .../codec/encoder/core/src/picture_handle.cpp | 0 .../codec/encoder/core/src/ratectl.cpp | 0 .../encoder/core/src/ref_list_mgr_svc.cpp | 0 .../codec/encoder/core/src/sample.cpp | 0 .../encoder/core/src/set_mb_syn_cabac.cpp | 0 .../encoder/core/src/set_mb_syn_cavlc.cpp | 0 .../core/src/slice_multi_threading.cpp | 0 .../encoder/core/src/svc_base_layer_md.cpp | 0 .../core/src/svc_enc_slice_segment.cpp | 0 .../codec/encoder/core/src/svc_encode_mb.cpp | 0 .../encoder/core/src/svc_encode_slice.cpp | 0 .../encoder/core/src/svc_mode_decision.cpp | 0 .../encoder/core/src/svc_motion_estimate.cpp | 0 .../encoder/core/src/svc_set_mb_syn_cabac.cpp | 0 .../encoder/core/src/svc_set_mb_syn_cavlc.cpp | 0 .../encoder/core/src/wels_preprocess.cpp | 0 .../codec/encoder/core/src/wels_task_base.cpp | 0 .../encoder/core/src/wels_task_encoder.cpp | 0 .../encoder/core/src/wels_task_management.cpp | 0 src/openh264/codec/encoder/core/x86/coeff.asm | 0 src/openh264/codec/encoder/core/x86/dct.asm | 0 .../codec/encoder/core/x86/intra_pred.asm | 0 .../encoder/core/x86/matrix_transpose.asm | 0 .../codec/encoder/core/x86/memzero.asm | 0 src/openh264/codec/encoder/core/x86/quant.asm | 0 .../codec/encoder/core/x86/sample_sc.asm | 0 src/openh264/codec/encoder/core/x86/score.asm | 0 src/openh264/codec/encoder/meson.build | 0 .../codec/encoder/plus/inc/welsEncoderExt.h | 0 .../codec/encoder/plus/src/DllEntry.cpp | 0 .../codec/encoder/plus/src/welsEncoderExt.cpp | 0 .../encoder/plus/src/wels_enc_export.def | 0 src/openh264/codec/encoder/targets.mk | 18 +- src/openh264/codec/meson.build | 0 .../codec/processing/build/win32/.gitignore | 0 .../processing/build/win32/WelsVP.vcproj | 0 .../codec/processing/interface/IWelsVP.h | 0 src/openh264/codec/processing/meson.build | 0 .../AdaptiveQuantization.cpp | 0 .../AdaptiveQuantization.h | 0 .../src/arm/adaptive_quantization.S | 0 .../processing/src/arm/down_sample_neon.S | 0 .../codec/processing/src/arm/pixel_sad_neon.S | 0 .../codec/processing/src/arm/vaa_calc_neon.S | 0 .../adaptive_quantization_aarch64_neon.S | 0 .../src/arm64/down_sample_aarch64_neon.S | 0 .../src/arm64/pixel_sad_aarch64_neon.S | 0 .../src/arm64/vaa_calc_aarch64_neon.S | 0 .../BackgroundDetection.cpp | 0 .../backgrounddetection/BackgroundDetection.h | 0 .../processing/src/common/WelsFrameWork.cpp | 0 .../processing/src/common/WelsFrameWork.h | 0 .../processing/src/common/WelsFrameWorkEx.cpp | 0 .../codec/processing/src/common/WelsVP.def | 0 .../codec/processing/src/common/WelsVP.rc | 0 .../codec/processing/src/common/common.h | 0 .../codec/processing/src/common/memory.cpp | 0 .../codec/processing/src/common/memory.h | 0 .../codec/processing/src/common/resource.h | 0 .../codec/processing/src/common/typedef.h | 0 .../codec/processing/src/common/util.h | 0 .../complexityanalysis/ComplexityAnalysis.cpp | 0 .../complexityanalysis/ComplexityAnalysis.h | 0 .../codec/processing/src/denoise/denoise.cpp | 0 .../codec/processing/src/denoise/denoise.h | 0 .../processing/src/denoise/denoise_filter.cpp | 0 .../processing/src/downsample/downsample.cpp | 0 .../processing/src/downsample/downsample.h | 0 .../src/downsample/downsamplefuncs.cpp | 0 .../src/imagerotate/imagerotate.cpp | 0 .../processing/src/imagerotate/imagerotate.h | 0 .../src/imagerotate/imagerotatefuncs.cpp | 0 .../codec/processing/src/mips/vaa_mmi.c | 0 .../SceneChangeDetection.cpp | 0 .../SceneChangeDetection.h | 6 + .../src/scrolldetection/ScrollDetection.cpp | 0 .../src/scrolldetection/ScrollDetection.h | 0 .../scrolldetection/ScrollDetectionFuncs.cpp | 0 .../scrolldetection/ScrollDetectionFuncs.h | 0 .../processing/src/vaacalc/vaacalcfuncs.cpp | 0 .../processing/src/vaacalc/vaacalculation.cpp | 0 .../processing/src/vaacalc/vaacalculation.h | 0 .../processing/src/x86/denoisefilter.asm | 0 .../src/x86/downsample_bilinear.asm | 0 src/openh264/codec/processing/src/x86/vaa.asm | 0 src/openh264/codec/processing/targets.mk | 18 +- src/openh264/docs/doxygen/Doxyfile | 0 src/openh264/docs/doxygen/Home.rest | 0 src/openh264/docs/doxygen/ISVCDecoder.rest | 0 src/openh264/docs/doxygen/ISVCEncoder.rest | 0 .../docs/doxygen/UsageExampleForDecoder.rest | 0 .../docs/doxygen/UsageExampleForEncoder.rest | 0 src/openh264/docs/doxygen2rst.py | 0 src/openh264/gmpopenh264.info | 2 +- src/openh264/include/meson.build | 0 src/openh264/include/wels/meson.build | 0 src/openh264/meson.build | 7 +- src/openh264/meson_options.txt | 1 + src/openh264/module/RefCounted.h | 0 src/openh264/module/gmp-openh264.cpp | 0 src/openh264/module/targets.mk | 0 src/openh264/module/task_utils.h | 0 src/openh264/module/task_utils.py | 0 src/openh264/module/task_utils_generated.h | 0 src/openh264/openh264.def | 0 src/openh264/openh264.pc.in | 2 +- src/openh264/openh264.rc | 8 +- src/openh264/openh264.rc.template | 0 .../Adobe_PDF_sample_a_1024x768_50Frms.264 | Bin src/openh264/res/BA1_FT_C.264 | Bin src/openh264/res/BA1_Sony_D.jsv | Bin src/openh264/res/BAMQ1_JVC_C.264 | Bin src/openh264/res/BAMQ2_JVC_C.264 | Bin src/openh264/res/BANM_MW_D.264 | Bin src/openh264/res/BASQP1_Sony_C.jsv | Bin src/openh264/res/BA_MW_D.264 | Bin src/openh264/res/BA_MW_D_IDR_LOST.264 | Bin src/openh264/res/BA_MW_D_P_LOST.264 | Bin src/openh264/res/CI1_FT_B.264 | Bin src/openh264/res/CI_MW_D.264 | Bin src/openh264/res/CVFC1_Sony_C.jsv | Bin src/openh264/res/CVPCMNL1_SVA_C.264 | Bin .../res/CiscoVT2people_160x96_6fps.yuv | 0 .../res/CiscoVT2people_320x192_12fps.yuv | 0 .../Cisco_Absolute_Power_1280x720_30fps.yuv | 0 ...e_PDF_sample_a_1024x768_CAVLC_Bframe_9.264 | Bin ...sco_Men_whisper_640x320_CABAC_Bframe_9.264 | Bin ...sco_Men_whisper_640x320_CAVLC_Bframe_9.264 | Bin src/openh264/res/Error_I_P.264 | Bin src/openh264/res/LS_SVA_D.264 | Bin src/openh264/res/MIDR_MW_D.264 | Bin src/openh264/res/MPS_MW_A.264 | Bin src/openh264/res/MR1_BT_A.h264 | Bin src/openh264/res/MR1_MW_A.264 | Bin src/openh264/res/MR2_MW_A.264 | Bin src/openh264/res/MR2_TANDBERG_E.264 | Bin src/openh264/res/NL1_Sony_D.jsv | Bin src/openh264/res/NLMQ1_JVC_C.264 | Bin src/openh264/res/NLMQ2_JVC_C.264 | Bin src/openh264/res/NRF_MW_E.264 | Bin src/openh264/res/QCIF_2P_I_allIPCM.264 | Bin src/openh264/res/SVA_BA1_B.264 | Bin src/openh264/res/SVA_BA2_D.264 | Bin src/openh264/res/SVA_Base_B.264 | Bin src/openh264/res/SVA_CL1_E.264 | Bin src/openh264/res/SVA_FM1_E.264 | Bin src/openh264/res/SVA_NL1_B.264 | Bin src/openh264/res/SVA_NL2_E.264 | Bin src/openh264/res/SarVui.264 | Bin src/openh264/res/Static.264 | Bin src/openh264/res/Static_152_100.yuv | 0 .../VID_1280x544_cabac_temporal_direct.264 | Bin .../VID_1280x544_cavlc_temporal_direct.264 | Bin .../VID_1280x720_cabac_temporal_direct.264 | Bin .../VID_1280x720_cavlc_temporal_direct.264 | Bin .../VID_1920x1080_cabac_temporal_direct.264 | Bin .../VID_1920x1080_cavlc_temporal_direct.264 | Bin src/openh264/res/Zhling_1280x720.264 | Bin src/openh264/res/jm_1080p_allslice.264 | Bin src/openh264/res/sps_subsetsps_bothVUI.264 | Bin src/openh264/res/test_cif_I_CABAC_PCM.264 | Bin src/openh264/res/test_cif_I_CABAC_slice.264 | Bin src/openh264/res/test_cif_P_CABAC_slice.264 | Bin src/openh264/res/test_qcif_cabac.264 | Bin src/openh264/res/test_scalinglist_jm.264 | Bin src/openh264/res/test_vd_1d.264 | Bin src/openh264/res/test_vd_rc.264 | Bin src/openh264/subprojects/gtest.wrap | 0 src/openh264/test/BaseDecoderTest.h | 0 src/openh264/test/BaseEncoderTest.h | 0 src/openh264/test/BaseThreadDecoderTest.h | 61 + src/openh264/test/api/BaseDecoderTest.cpp | 0 src/openh264/test/api/BaseEncoderTest.cpp | 0 .../test/api/BaseThreadDecoderTest.cpp | 358 ++++ src/openh264/test/api/DataGenerator.cpp | 0 src/openh264/test/api/c_interface_test.c | 0 src/openh264/test/api/cpp_interface_test.cpp | 0 src/openh264/test/api/decode_api_test.cpp | 0 src/openh264/test/api/decode_encode_test.cpp | 0 src/openh264/test/api/decoder_ec_test.cpp | 0 src/openh264/test/api/decoder_test.cpp | 0 .../test/api/encode_decode_api_test.cpp | 0 .../test/api/encode_decode_api_test.h | 0 .../test/api/encode_decode_api_test.template | 0 src/openh264/test/api/encode_options_test.cpp | 0 src/openh264/test/api/encoder_test.cpp | 0 src/openh264/test/api/ltr_test.cpp | 0 src/openh264/test/api/meson.build | 2 + src/openh264/test/api/sha1.c | 0 src/openh264/test/api/simple_test.cpp | 0 src/openh264/test/api/targets.mk | 2 + src/openh264/test/api/thread_decoder_test.cpp | 153 ++ src/openh264/test/build/android/.gitignore | 0 .../test/build/android/AndroidManifest.xml | 0 .../test/build/android/jni/Android.mk | 0 .../test/build/android/jni/Application.mk | 4 + .../test/build/android/jni/codec_unittest.cpp | 0 .../android/res/layout/activity_main.xml | 0 .../build/android/res/values-v11/styles.xml | 0 .../android/res/values-w820dp/dimens.xml | 0 .../test/build/android/res/values/dimens.xml | 0 .../test/build/android/res/values/strings.xml | 0 .../test/build/android/res/values/styles.xml | 0 .../cisco/codec/unittest/MainActivity.java | 0 src/openh264/test/build/win32/.gitignore | 0 .../test/build/win32/codec_ut/Codec_UT.sln | 0 .../win32/codec_ut/codec_unittest.vcproj | 8 + .../win32/codec_ut/preprocessing_lib.vcproj | 0 .../test/build/windowsphone/.gitignore | 0 .../windowsphone/codec_ut/CodecUTApp/App.xaml | 0 .../codec_ut/CodecUTApp/App.xaml.cs | 0 .../CodecUTApp/Assets/AlignmentGrid.png | Bin .../CodecUTApp/Assets/ApplicationIcon.png | Bin .../codec_ut/CodecUTApp/Assets/BadgeLogo.png | Bin .../codec_ut/CodecUTApp/Assets/Logo.png | Bin .../CodecUTApp/Assets/SplashScreen.png | Bin .../CodecUTApp/Assets/SquareTile150x150.png | Bin .../CodecUTApp/Assets/SquareTile71x71.png | Bin .../codec_ut/CodecUTApp/Assets/StoreLogo.png | Bin .../Assets/Tiles/FlipCycleTileLarge.png | Bin .../Assets/Tiles/FlipCycleTileMedium.png | Bin .../Assets/Tiles/FlipCycleTileSmall.png | Bin .../Assets/Tiles/IconicTileMediumLarge.png | Bin .../Assets/Tiles/IconicTileSmall.png | Bin .../codec_ut/CodecUTApp/Assets/WideLogo.png | Bin .../codec_ut/CodecUTApp/CodecUTApp.csproj | 0 .../codec_ut/CodecUTApp/LocalizedStrings.cs | 0 .../codec_ut/CodecUTApp/MainPage.xaml | 0 .../codec_ut/CodecUTApp/MainPage.xaml.cs | 0 .../codec_ut/CodecUTApp/Package.appxmanifest | 0 .../CodecUTApp/Properties/AppManifest.xml | 0 .../CodecUTApp/Properties/AssemblyInfo.cs | 0 .../CodecUTApp/Properties/WMAppManifest.xml | 0 .../Resources/AppResources.Designer.cs | 0 .../CodecUTApp/Resources/AppResources.resx | 0 .../build/windowsphone/codec_ut/Codec_UT.sln | 0 .../codec_ut/Codec_UT_RTComponent.cpp | 0 .../codec_ut/Codec_UT_RTComponent.h | 0 .../codec_ut/Codec_UT_RTComponent.vcxproj | 0 .../Codec_UT_RTComponent.vcxproj.filters | 0 src/openh264/test/common/CWelsListTest.cpp | 0 src/openh264/test/common/ExpandPicture.cpp | 0 src/openh264/test/common/WelsTaskListTest.cpp | 0 .../test/common/WelsThreadPoolTest.cpp | 0 src/openh264/test/common/WelsThreadPoolTest.h | 0 src/openh264/test/common/meson.build | 0 src/openh264/test/common/targets.mk | 0 src/openh264/test/decoder/DecUT_Deblock.cpp | 0 .../test/decoder/DecUT_DeblockCommon.cpp | 36 +- src/openh264/test/decoder/DecUT_DecExt.cpp | 0 .../test/decoder/DecUT_ErrorConcealment.cpp | 9 +- .../test/decoder/DecUT_IdctResAddPred.cpp | 0 .../test/decoder/DecUT_IntraPrediction.cpp | 0 .../test/decoder/DecUT_ParseSyntax.cpp | 30 +- src/openh264/test/decoder/DecUT_PredMv.cpp | 0 src/openh264/test/decoder/meson.build | 0 src/openh264/test/decoder/targets.mk | 0 src/openh264/test/encoder/EncUT_Cavlc.cpp | 0 .../test/encoder/EncUT_DecodeMbAux.cpp | 0 .../test/encoder/EncUT_EncoderExt.cpp | 0 src/openh264/test/encoder/EncUT_EncoderMb.cpp | 0 .../test/encoder/EncUT_EncoderMbAux.cpp | 0 .../encoder/EncUT_EncoderTaskManagement.cpp | 0 src/openh264/test/encoder/EncUT_ExpGolomb.cpp | 0 .../test/encoder/EncUT_GetIntraPredictor.cpp | 0 .../test/encoder/EncUT_InterfaceTest.cpp | 0 src/openh264/test/encoder/EncUT_MBCopy.cpp | 0 .../test/encoder/EncUT_MemoryAlloc.cpp | 0 .../test/encoder/EncUT_MemoryZero.cpp | 0 .../test/encoder/EncUT_MotionCompensation.cpp | 0 .../test/encoder/EncUT_MotionEstimate.cpp | 0 .../encoder/EncUT_ParameterSetStrategy.cpp | 0 .../test/encoder/EncUT_Reconstruct.cpp | 0 src/openh264/test/encoder/EncUT_SVC_me.cpp | 0 src/openh264/test/encoder/EncUT_Sample.cpp | 0 .../encoder/EncUT_SliceBufferReallocate.cpp | 0 .../encoder/EncUT_SliceBufferReallocate.h | 0 src/openh264/test/encoder/meson.build | 0 src/openh264/test/encoder/targets.mk | 0 .../test/encoder_binary_comparison/.gitignore | 0 .../test/encoder_binary_comparison/AboutTest | 0 ...024x768_50Frms.264_AllCases_SHA1_Table.csv | 0 .../BA_MW_D.264_AllCases_SHA1_Table.csv | 0 ...hling_1280x720.264_AllCases_SHA1_Table.csv | 0 src/openh264/test/meson.build | 26 +- .../ProcessUT_AdaptiveQuantization.cpp | 0 .../test/processing/ProcessUT_DownSample.cpp | 0 .../processing/ProcessUT_ScrollDetection.cpp | 0 .../test/processing/ProcessUT_VaaCalc.cpp | 0 src/openh264/test/processing/meson.build | 0 src/openh264/test/processing/targets.mk | 0 src/openh264/test/sha1.h | 0 src/openh264/test/test_stdint.h | 0 src/openh264/test/utils/BufferedData.h | 0 src/openh264/test/utils/DataGenerator.h | 0 src/openh264/test/utils/FileInputStream.h | 0 src/openh264/test/utils/HashFunctions.h | 0 src/openh264/test/utils/InputStream.h | 0 src/openh264/testbin/CmdLineReadMe | 0 src/openh264/testbin/layer2.cfg | 0 src/openh264/testbin/layer2_arbitrary_res.cfg | 0 src/openh264/testbin/layer2_vd.cfg | 0 src/openh264/testbin/layer2_vd_rc.cfg | 0 src/openh264/testbin/welsenc.cfg | 0 .../testbin/welsenc_arbitrary_res.cfg | 0 src/openh264/testbin/welsenc_ios.cfg | 0 src/openh264/testbin/welsenc_vd_1d.cfg | 0 src/openh264/testbin/welsenc_vd_rc.cfg | 0 src/openh264/ut.def | 0 674 files changed, 5312 insertions(+), 2346 deletions(-) mode change 100755 => 100644 src/openh264/.gitignore mode change 100755 => 100644 src/openh264/.reviewboardrc mode change 100755 => 100644 src/openh264/.travis.yml mode change 100755 => 100644 src/openh264/CODING_STYLE mode change 100755 => 100644 src/openh264/CONTRIBUTORS mode change 100755 => 100644 src/openh264/LICENSE mode change 100755 => 100644 src/openh264/Makefile mode change 100755 => 100644 src/openh264/README.md mode change 100755 => 100644 src/openh264/RELEASES mode change 100755 => 100644 src/openh264/autotest/performanceTest/.gitignore mode change 100755 => 100644 src/openh264/autotest/performanceTest/android/run_AutoTest_android.sh mode change 100755 => 100644 src/openh264/autotest/performanceTest/ios/run_AutoTest_ios.sh mode change 100755 => 100644 src/openh264/autotest/performanceTest/ios/uiascript.js mode change 100755 => 100644 src/openh264/autotest/performanceTest/run_perfTest.sh mode change 100755 => 100644 src/openh264/autotest/unitTest/android/run_AutoTest_android.sh mode change 100755 => 100644 src/openh264/autotest/unitTest/ios/run_AutoTest_ios.sh mode change 100755 => 100644 src/openh264/autotest/unitTest/run_ParseUTxml.sh mode change 100755 => 100644 src/openh264/autotest/unitTest/run_unitTest.sh mode change 100755 => 100644 src/openh264/build/AutoBuildForWPAndWindows.bat mode change 100755 => 100644 src/openh264/build/Dockerfile mode change 100755 => 100644 src/openh264/build/arch.mk mode change 100755 => 100644 src/openh264/build/astyle.cfg mode change 100755 => 100644 src/openh264/build/gtest-targets.mk create mode 100755 src/openh264/build/mips-simd-check.sh mode change 100755 => 100644 src/openh264/build/msvc-app.mk mode change 100755 => 100644 src/openh264/build/msvc-common.mk mode change 100755 => 100644 src/openh264/build/platform-android.mk mode change 100755 => 100644 src/openh264/build/platform-bsd.mk mode change 100755 => 100644 src/openh264/build/platform-cygwin_nt.mk mode change 100755 => 100644 src/openh264/build/platform-darwin.mk mode change 100755 => 100644 src/openh264/build/platform-ios.mk mode change 100755 => 100644 src/openh264/build/platform-linux.mk mode change 100755 => 100644 src/openh264/build/platform-mingw_nt.mk mode change 100755 => 100644 src/openh264/build/platform-msvc-app.mk mode change 100755 => 100644 src/openh264/build/platform-msvc-wp.mk mode change 100755 => 100644 src/openh264/build/platform-msvc.mk mode change 100755 => 100644 src/openh264/build/x86-common.mk mode change 100755 => 100644 src/openh264/codec/api/meson.build mode change 100755 => 100644 src/openh264/codec/api/svc/codec_api.h mode change 100755 => 100644 src/openh264/codec/api/svc/codec_app_def.h mode change 100755 => 100644 src/openh264/codec/api/svc/codec_def.h mode change 100755 => 100644 src/openh264/codec/api/svc/codec_ver.h mode change 100755 => 100644 src/openh264/codec/api/svc/meson.build mode change 100755 => 100644 src/openh264/codec/build/android/.gitignore mode change 100755 => 100644 src/openh264/codec/build/android/dec/AndroidManifest.xml mode change 100755 => 100644 src/openh264/codec/build/android/dec/jni/Android.mk mode change 100755 => 100644 src/openh264/codec/build/android/dec/jni/Application.mk mode change 100755 => 100644 src/openh264/codec/build/android/dec/jni/myjni.cpp mode change 100755 => 100644 src/openh264/codec/build/android/dec/jni/welsdecdemo.mk mode change 100755 => 100644 src/openh264/codec/build/android/dec/res/layout/main.xml mode change 100755 => 100644 src/openh264/codec/build/android/dec/res/values/strings.xml mode change 100755 => 100644 src/openh264/codec/build/android/dec/src/com/wels/dec/WelsDecTest.java mode change 100755 => 100644 src/openh264/codec/build/android/enc/AndroidManifest.xml mode change 100755 => 100644 src/openh264/codec/build/android/enc/jni/Android.mk mode change 100755 => 100644 src/openh264/codec/build/android/enc/jni/Application.mk mode change 100755 => 100644 src/openh264/codec/build/android/enc/jni/myjni.cpp mode change 100755 => 100644 src/openh264/codec/build/android/enc/jni/welsencdemo.mk mode change 100755 => 100644 src/openh264/codec/build/android/enc/res/layout/main.xml mode change 100755 => 100644 src/openh264/codec/build/android/enc/res/values/strings.xml mode change 100755 => 100644 src/openh264/codec/build/android/enc/src/com/wels/enc/WelsEncTest.java mode change 100755 => 100644 src/openh264/codec/build/iOS/.gitignore mode change 100755 => 100644 src/openh264/codec/build/iOS/common/common.xcodeproj/project.pbxproj mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo.xcodeproj/project.pbxproj mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/DEMOAppDelegate.h mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/DEMOAppDelegate.m mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewController.h mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewController.m mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewControllerShowResource.h mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewControllerShowResource.m mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/Default-568h@2x.png mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/Default.png mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/Default@2x.png mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/demo-Info.plist mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/InfoPlist.strings mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/MainStoryboard_iPad.storyboard mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/MainStoryboard_iPhone.storyboard mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/demo/demo/main.m mode change 100755 => 100644 src/openh264/codec/build/iOS/dec/welsdec/welsdec.xcodeproj/project.pbxproj mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo.xcodeproj/project.pbxproj mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/AppDelegate.h mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/AppDelegate.m mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/Base.lproj/Main_iPad.storyboard mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/Base.lproj/Main_iPhone.storyboard mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/Images.xcassets/AppIcon.appiconset/Contents.json mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/Images.xcassets/LaunchImage.launchimage/Contents.json mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/ViewController.h mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/ViewController.m mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/en.lproj/InfoPlist.strings mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/encDemo-Info.plist mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/encDemo/encDemo/main.m mode change 100755 => 100644 src/openh264/codec/build/iOS/enc/welsenc/welsenc.xcodeproj/project.pbxproj mode change 100755 => 100644 src/openh264/codec/build/iOS/openh264/openh264.xcodeproj/project.pbxproj mode change 100755 => 100644 src/openh264/codec/build/iOS/processing/processing.xcodeproj/project.pbxproj mode change 100755 => 100644 src/openh264/codec/build/win32/.gitignore mode change 100755 => 100644 src/openh264/codec/build/win32/dec/WelsDecCore.vcproj mode change 100755 => 100644 src/openh264/codec/build/win32/dec/WelsDecPlus.vcproj mode change 100755 => 100644 src/openh264/codec/build/win32/dec/WelsDecoder.sln mode change 100755 => 100644 src/openh264/codec/build/win32/dec/decConsole.vcproj mode change 100755 => 100644 src/openh264/codec/build/win32/enc/WelsEncCore.vcproj mode change 100755 => 100644 src/openh264/codec/build/win32/enc/WelsEncPlus.vcproj mode change 100755 => 100644 src/openh264/codec/build/win32/enc/WelsEncoder.sln mode change 100755 => 100644 src/openh264/codec/build/win32/enc/encConsole.vcproj mode change 100755 => 100644 src/openh264/codec/build/windowsphone/.gitignore mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp.sln mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/App.xaml mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/App.xaml.cs mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/AlignmentGrid.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/ApplicationIcon.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/BadgeLogo.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Logo.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SplashScreen.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SquareTile150x150.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SquareTile71x71.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/StoreLogo.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileLarge.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileMedium.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileSmall.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/IconicTileMediumLarge.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/IconicTileSmall.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Assets/WideLogo.png mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/CodecApp.csproj mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/LocalizedStrings.cs mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/MainPage.xaml mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/MainPage.xaml.cs mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Package.appxmanifest mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Properties/AppManifest.xml mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Properties/AssemblyInfo.cs mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Properties/WMAppManifest.xml mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Resources/AppResources.Designer.cs mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/Resources/AppResources.resx mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/layer2.cfg mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecApp/welsenc.cfg mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecRTComponent.cpp mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecRTComponent.h mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecRTComponent.vcxproj mode change 100755 => 100644 src/openh264/codec/build/windowsphone/all/CodecRTComponent.vcxproj.filters mode change 100755 => 100644 src/openh264/codec/common/arm/arm_arch_common_macro.S mode change 100755 => 100644 src/openh264/codec/common/arm/copy_mb_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm/deblocking_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm/expand_picture_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm/intra_pred_common_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm/mc_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm64/arm_arch64_common_macro.S mode change 100755 => 100644 src/openh264/codec/common/arm64/copy_mb_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm64/deblocking_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm64/expand_picture_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm64/intra_pred_common_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/common/arm64/mc_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/common/inc/.gitignore mode change 100755 => 100644 src/openh264/codec/common/inc/WelsList.h mode change 100755 => 100644 src/openh264/codec/common/inc/WelsLock.h mode change 100755 => 100644 src/openh264/codec/common/inc/WelsTask.h mode change 100755 => 100644 src/openh264/codec/common/inc/WelsTaskThread.h mode change 100755 => 100644 src/openh264/codec/common/inc/WelsThread.h mode change 100755 => 100644 src/openh264/codec/common/inc/WelsThreadLib.h mode change 100755 => 100644 src/openh264/codec/common/inc/WelsThreadPool.h mode change 100755 => 100644 src/openh264/codec/common/inc/asmdefs_mmi.h mode change 100755 => 100644 src/openh264/codec/common/inc/copy_mb.h mode change 100755 => 100644 src/openh264/codec/common/inc/cpu.h mode change 100755 => 100644 src/openh264/codec/common/inc/cpu_core.h mode change 100755 => 100644 src/openh264/codec/common/inc/crt_util_safe_x.h mode change 100755 => 100644 src/openh264/codec/common/inc/deblocking_common.h mode change 100755 => 100644 src/openh264/codec/common/inc/expand_pic.h mode change 100755 => 100644 src/openh264/codec/common/inc/golomb_common.h mode change 100755 => 100644 src/openh264/codec/common/inc/intra_pred_common.h mode change 100755 => 100644 src/openh264/codec/common/inc/ls_defines.h mode change 100755 => 100644 src/openh264/codec/common/inc/macros.h mode change 100755 => 100644 src/openh264/codec/common/inc/mc.h mode change 100755 => 100644 src/openh264/codec/common/inc/measure_time.h mode change 100755 => 100644 src/openh264/codec/common/inc/memory_align.h mode change 100755 => 100644 src/openh264/codec/common/inc/sad_common.h mode change 100755 => 100644 src/openh264/codec/common/inc/typedefs.h mode change 100755 => 100644 src/openh264/codec/common/inc/utils.h mode change 100755 => 100644 src/openh264/codec/common/inc/version.h mode change 100755 => 100644 src/openh264/codec/common/inc/version_gen.h.template mode change 100755 => 100644 src/openh264/codec/common/inc/welsCodecTrace.h mode change 100755 => 100644 src/openh264/codec/common/inc/wels_common_defs.h mode change 100755 => 100644 src/openh264/codec/common/inc/wels_const_common.h mode change 100755 => 100644 src/openh264/codec/common/meson.build mode change 100755 => 100644 src/openh264/codec/common/mips/copy_mb_mmi.c mode change 100755 => 100644 src/openh264/codec/common/mips/deblock_mmi.c mode change 100755 => 100644 src/openh264/codec/common/mips/expand_picture_mmi.c mode change 100755 => 100644 src/openh264/codec/common/mips/intra_pred_com_mmi.c mode change 100755 => 100644 src/openh264/codec/common/mips/satd_sad_mmi.c mode change 100755 => 100644 src/openh264/codec/common/src/WelsTaskThread.cpp mode change 100755 => 100644 src/openh264/codec/common/src/WelsThread.cpp mode change 100755 => 100644 src/openh264/codec/common/src/WelsThreadLib.cpp mode change 100755 => 100644 src/openh264/codec/common/src/WelsThreadPool.cpp mode change 100755 => 100644 src/openh264/codec/common/src/common_tables.cpp mode change 100755 => 100644 src/openh264/codec/common/src/copy_mb.cpp mode change 100755 => 100644 src/openh264/codec/common/src/cpu.cpp mode change 100755 => 100644 src/openh264/codec/common/src/crt_util_safe_x.cpp mode change 100755 => 100644 src/openh264/codec/common/src/deblocking_common.cpp mode change 100755 => 100644 src/openh264/codec/common/src/expand_pic.cpp mode change 100755 => 100644 src/openh264/codec/common/src/intra_pred_common.cpp mode change 100755 => 100644 src/openh264/codec/common/src/mc.cpp mode change 100755 => 100644 src/openh264/codec/common/src/memory_align.cpp mode change 100755 => 100644 src/openh264/codec/common/src/sad_common.cpp mode change 100755 => 100644 src/openh264/codec/common/src/utils.cpp mode change 100755 => 100644 src/openh264/codec/common/src/welsCodecTrace.cpp mode change 100755 => 100644 src/openh264/codec/common/targets.mk mode change 100755 => 100644 src/openh264/codec/common/x86/asm_inc.asm mode change 100755 => 100644 src/openh264/codec/common/x86/cpuid.asm mode change 100755 => 100644 src/openh264/codec/common/x86/dct.asm mode change 100755 => 100644 src/openh264/codec/common/x86/deblock.asm mode change 100755 => 100644 src/openh264/codec/common/x86/expand_picture.asm mode change 100755 => 100644 src/openh264/codec/common/x86/intra_pred_com.asm mode change 100755 => 100644 src/openh264/codec/common/x86/mb_copy.asm mode change 100755 => 100644 src/openh264/codec/common/x86/mc_chroma.asm mode change 100755 => 100644 src/openh264/codec/common/x86/mc_luma.asm mode change 100755 => 100644 src/openh264/codec/common/x86/satd_sad.asm mode change 100755 => 100644 src/openh264/codec/common/x86/vaa.asm mode change 100755 => 100644 src/openh264/codec/console/common/inc/read_config.h mode change 100755 => 100644 src/openh264/codec/console/common/meson.build mode change 100755 => 100644 src/openh264/codec/console/common/src/read_config.cpp mode change 100755 => 100644 src/openh264/codec/console/common/targets.mk mode change 100755 => 100644 src/openh264/codec/console/dec/inc/d3d9_utils.h mode change 100755 => 100644 src/openh264/codec/console/dec/meson.build mode change 100755 => 100644 src/openh264/codec/console/dec/src/d3d9_utils.cpp mode change 100755 => 100644 src/openh264/codec/console/dec/src/h264dec.cpp mode change 100755 => 100644 src/openh264/codec/console/dec/targets.mk mode change 100755 => 100644 src/openh264/codec/console/enc/meson.build mode change 100755 => 100644 src/openh264/codec/console/enc/src/welsenc.cpp mode change 100755 => 100644 src/openh264/codec/console/enc/targets.mk mode change 100755 => 100644 src/openh264/codec/console/meson.build mode change 100755 => 100644 src/openh264/codec/decoder/core/arm/block_add_neon.S mode change 100755 => 100644 src/openh264/codec/decoder/core/arm/intra_pred_neon.S mode change 100755 => 100644 src/openh264/codec/decoder/core/arm64/block_add_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/decoder/core/arm64/intra_pred_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/au_parser.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/bit_stream.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/cabac_decoder.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/deblocking.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/dec_frame.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/dec_golomb.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/decode_mb_aux.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/decode_slice.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/decoder.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/decoder_context.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/decoder_core.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/error_code.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/error_concealment.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/fmo.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/get_intra_predictor.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/manage_dec_ref.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/mb_cache.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/memmgr_nal_unit.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/mv_pred.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/nal_prefix.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/nalu.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/parameter_sets.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/parse_mb_syn_cabac.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/parse_mb_syn_cavlc.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/pic_queue.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/picture.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/rec_mb.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/slice.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/vlc_decoder.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/wels_common_basis.h mode change 100755 => 100644 src/openh264/codec/decoder/core/inc/wels_const.h create mode 100644 src/openh264/codec/decoder/core/inc/wels_decoder_thread.h mode change 100755 => 100644 src/openh264/codec/decoder/core/mips/dct_mmi.c mode change 100755 => 100644 src/openh264/codec/decoder/core/src/au_parser.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/bit_stream.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/cabac_decoder.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/deblocking.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/decode_mb_aux.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/decode_slice.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/decoder.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/decoder_core.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/decoder_data_tables.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/error_concealment.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/fmo.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/get_intra_predictor.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/manage_dec_ref.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/memmgr_nal_unit.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/mv_pred.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/parse_mb_syn_cabac.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/parse_mb_syn_cavlc.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/pic_queue.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/src/rec_mb.cpp create mode 100644 src/openh264/codec/decoder/core/src/wels_decoder_thread.cpp mode change 100755 => 100644 src/openh264/codec/decoder/core/x86/dct.asm mode change 100755 => 100644 src/openh264/codec/decoder/core/x86/intra_pred.asm mode change 100755 => 100644 src/openh264/codec/decoder/meson.build mode change 100755 => 100644 src/openh264/codec/decoder/plus/inc/welsDecoderExt.h mode change 100755 => 100644 src/openh264/codec/decoder/plus/src/welsDecoderExt.cpp mode change 100755 => 100644 src/openh264/codec/decoder/plus/src/wels_dec_export.def mode change 100755 => 100644 src/openh264/codec/decoder/targets.mk mode change 100755 => 100644 src/openh264/codec/encoder/core/arm/intra_pred_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm/intra_pred_sad_3_opt_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm/memory_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm/pixel_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm/reconstruct_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm/svc_motion_estimation.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm64/intra_pred_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm64/intra_pred_sad_3_opt_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm64/memory_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm64/pixel_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm64/reconstruct_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/arm64/svc_motion_estimation_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/as264_common.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/au_set.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/deblocking.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/decode_mb_aux.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/dq_map.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/encode_mb_aux.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/encoder.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/encoder_context.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/extern.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/get_intra_predictor.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/mb_cache.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/md.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/mt_defs.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/mv_pred.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/nal_encap.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/param_svc.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/parameter_sets.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/paraset_strategy.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/picture.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/picture_handle.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/rc.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/ref_list_mgr_svc.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/sample.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/set_mb_syn_cabac.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/set_mb_syn_cavlc.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/slice.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/slice_multi_threading.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/stat.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_base_layer_md.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_enc_frame.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_enc_golomb.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_enc_macroblock.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_enc_slice_segment.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_encode_mb.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_encode_slice.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_mode_decision.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_motion_estimate.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_set_mb_syn.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/svc_set_mb_syn_cavlc.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/vlc_encoder.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/wels_common_basis.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/wels_const.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/wels_func_ptr_def.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/wels_preprocess.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/wels_task_base.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/wels_task_encoder.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/wels_task_management.h mode change 100755 => 100644 src/openh264/codec/encoder/core/inc/wels_transpose_matrix.h mode change 100755 => 100644 src/openh264/codec/encoder/core/mips/dct_mmi.c mode change 100755 => 100644 src/openh264/codec/encoder/core/mips/quant_mmi.c mode change 100755 => 100644 src/openh264/codec/encoder/core/mips/score_mmi.c mode change 100755 => 100644 src/openh264/codec/encoder/core/src/au_set.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/deblocking.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/decode_mb_aux.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/encode_mb_aux.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/encoder.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/encoder_data_tables.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/encoder_ext.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/get_intra_predictor.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/md.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/mv_pred.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/nal_encap.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/paraset_strategy.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/picture_handle.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/ratectl.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/ref_list_mgr_svc.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/sample.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/set_mb_syn_cabac.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/set_mb_syn_cavlc.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/slice_multi_threading.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/svc_base_layer_md.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/svc_enc_slice_segment.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/svc_encode_mb.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/svc_encode_slice.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/svc_mode_decision.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/svc_motion_estimate.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/wels_preprocess.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/wels_task_base.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/wels_task_encoder.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/src/wels_task_management.cpp mode change 100755 => 100644 src/openh264/codec/encoder/core/x86/coeff.asm mode change 100755 => 100644 src/openh264/codec/encoder/core/x86/dct.asm mode change 100755 => 100644 src/openh264/codec/encoder/core/x86/intra_pred.asm mode change 100755 => 100644 src/openh264/codec/encoder/core/x86/matrix_transpose.asm mode change 100755 => 100644 src/openh264/codec/encoder/core/x86/memzero.asm mode change 100755 => 100644 src/openh264/codec/encoder/core/x86/quant.asm mode change 100755 => 100644 src/openh264/codec/encoder/core/x86/sample_sc.asm mode change 100755 => 100644 src/openh264/codec/encoder/core/x86/score.asm mode change 100755 => 100644 src/openh264/codec/encoder/meson.build mode change 100755 => 100644 src/openh264/codec/encoder/plus/inc/welsEncoderExt.h mode change 100755 => 100644 src/openh264/codec/encoder/plus/src/DllEntry.cpp mode change 100755 => 100644 src/openh264/codec/encoder/plus/src/welsEncoderExt.cpp mode change 100755 => 100644 src/openh264/codec/encoder/plus/src/wels_enc_export.def mode change 100755 => 100644 src/openh264/codec/encoder/targets.mk mode change 100755 => 100644 src/openh264/codec/meson.build mode change 100755 => 100644 src/openh264/codec/processing/build/win32/.gitignore mode change 100755 => 100644 src/openh264/codec/processing/build/win32/WelsVP.vcproj mode change 100755 => 100644 src/openh264/codec/processing/interface/IWelsVP.h mode change 100755 => 100644 src/openh264/codec/processing/meson.build mode change 100755 => 100644 src/openh264/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/adaptivequantization/AdaptiveQuantization.h mode change 100755 => 100644 src/openh264/codec/processing/src/arm/adaptive_quantization.S mode change 100755 => 100644 src/openh264/codec/processing/src/arm/down_sample_neon.S mode change 100755 => 100644 src/openh264/codec/processing/src/arm/pixel_sad_neon.S mode change 100755 => 100644 src/openh264/codec/processing/src/arm/vaa_calc_neon.S mode change 100755 => 100644 src/openh264/codec/processing/src/arm64/adaptive_quantization_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/processing/src/arm64/down_sample_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/processing/src/arm64/pixel_sad_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/processing/src/arm64/vaa_calc_aarch64_neon.S mode change 100755 => 100644 src/openh264/codec/processing/src/backgrounddetection/BackgroundDetection.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/backgrounddetection/BackgroundDetection.h mode change 100755 => 100644 src/openh264/codec/processing/src/common/WelsFrameWork.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/common/WelsFrameWork.h mode change 100755 => 100644 src/openh264/codec/processing/src/common/WelsFrameWorkEx.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/common/WelsVP.def mode change 100755 => 100644 src/openh264/codec/processing/src/common/WelsVP.rc mode change 100755 => 100644 src/openh264/codec/processing/src/common/common.h mode change 100755 => 100644 src/openh264/codec/processing/src/common/memory.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/common/memory.h mode change 100755 => 100644 src/openh264/codec/processing/src/common/resource.h mode change 100755 => 100644 src/openh264/codec/processing/src/common/typedef.h mode change 100755 => 100644 src/openh264/codec/processing/src/common/util.h mode change 100755 => 100644 src/openh264/codec/processing/src/complexityanalysis/ComplexityAnalysis.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/complexityanalysis/ComplexityAnalysis.h mode change 100755 => 100644 src/openh264/codec/processing/src/denoise/denoise.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/denoise/denoise.h mode change 100755 => 100644 src/openh264/codec/processing/src/denoise/denoise_filter.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/downsample/downsample.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/downsample/downsample.h mode change 100755 => 100644 src/openh264/codec/processing/src/downsample/downsamplefuncs.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/imagerotate/imagerotate.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/imagerotate/imagerotate.h mode change 100755 => 100644 src/openh264/codec/processing/src/imagerotate/imagerotatefuncs.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/mips/vaa_mmi.c mode change 100755 => 100644 src/openh264/codec/processing/src/scenechangedetection/SceneChangeDetection.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/scenechangedetection/SceneChangeDetection.h mode change 100755 => 100644 src/openh264/codec/processing/src/scrolldetection/ScrollDetection.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/scrolldetection/ScrollDetection.h mode change 100755 => 100644 src/openh264/codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/scrolldetection/ScrollDetectionFuncs.h mode change 100755 => 100644 src/openh264/codec/processing/src/vaacalc/vaacalcfuncs.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/vaacalc/vaacalculation.cpp mode change 100755 => 100644 src/openh264/codec/processing/src/vaacalc/vaacalculation.h mode change 100755 => 100644 src/openh264/codec/processing/src/x86/denoisefilter.asm mode change 100755 => 100644 src/openh264/codec/processing/src/x86/downsample_bilinear.asm mode change 100755 => 100644 src/openh264/codec/processing/src/x86/vaa.asm mode change 100755 => 100644 src/openh264/codec/processing/targets.mk mode change 100755 => 100644 src/openh264/docs/doxygen/Doxyfile mode change 100755 => 100644 src/openh264/docs/doxygen/Home.rest mode change 100755 => 100644 src/openh264/docs/doxygen/ISVCDecoder.rest mode change 100755 => 100644 src/openh264/docs/doxygen/ISVCEncoder.rest mode change 100755 => 100644 src/openh264/docs/doxygen/UsageExampleForDecoder.rest mode change 100755 => 100644 src/openh264/docs/doxygen/UsageExampleForEncoder.rest mode change 100755 => 100644 src/openh264/docs/doxygen2rst.py mode change 100755 => 100644 src/openh264/gmpopenh264.info mode change 100755 => 100644 src/openh264/include/meson.build mode change 100755 => 100644 src/openh264/include/wels/meson.build mode change 100755 => 100644 src/openh264/meson.build create mode 100644 src/openh264/meson_options.txt mode change 100755 => 100644 src/openh264/module/RefCounted.h mode change 100755 => 100644 src/openh264/module/gmp-openh264.cpp mode change 100755 => 100644 src/openh264/module/targets.mk mode change 100755 => 100644 src/openh264/module/task_utils.h mode change 100755 => 100644 src/openh264/module/task_utils.py mode change 100755 => 100644 src/openh264/module/task_utils_generated.h mode change 100755 => 100644 src/openh264/openh264.def mode change 100755 => 100644 src/openh264/openh264.pc.in mode change 100755 => 100644 src/openh264/openh264.rc mode change 100755 => 100644 src/openh264/openh264.rc.template mode change 100755 => 100644 src/openh264/res/Adobe_PDF_sample_a_1024x768_50Frms.264 mode change 100755 => 100644 src/openh264/res/BA1_FT_C.264 mode change 100755 => 100644 src/openh264/res/BA1_Sony_D.jsv mode change 100755 => 100644 src/openh264/res/BAMQ1_JVC_C.264 mode change 100755 => 100644 src/openh264/res/BAMQ2_JVC_C.264 mode change 100755 => 100644 src/openh264/res/BANM_MW_D.264 mode change 100755 => 100644 src/openh264/res/BASQP1_Sony_C.jsv mode change 100755 => 100644 src/openh264/res/BA_MW_D.264 mode change 100755 => 100644 src/openh264/res/BA_MW_D_IDR_LOST.264 mode change 100755 => 100644 src/openh264/res/BA_MW_D_P_LOST.264 mode change 100755 => 100644 src/openh264/res/CI1_FT_B.264 mode change 100755 => 100644 src/openh264/res/CI_MW_D.264 mode change 100755 => 100644 src/openh264/res/CVFC1_Sony_C.jsv mode change 100755 => 100644 src/openh264/res/CVPCMNL1_SVA_C.264 mode change 100755 => 100644 src/openh264/res/CiscoVT2people_160x96_6fps.yuv mode change 100755 => 100644 src/openh264/res/CiscoVT2people_320x192_12fps.yuv mode change 100755 => 100644 src/openh264/res/Cisco_Absolute_Power_1280x720_30fps.yuv mode change 100755 => 100644 src/openh264/res/Cisco_Adobe_PDF_sample_a_1024x768_CAVLC_Bframe_9.264 mode change 100755 => 100644 src/openh264/res/Cisco_Men_whisper_640x320_CABAC_Bframe_9.264 mode change 100755 => 100644 src/openh264/res/Cisco_Men_whisper_640x320_CAVLC_Bframe_9.264 mode change 100755 => 100644 src/openh264/res/Error_I_P.264 mode change 100755 => 100644 src/openh264/res/LS_SVA_D.264 mode change 100755 => 100644 src/openh264/res/MIDR_MW_D.264 mode change 100755 => 100644 src/openh264/res/MPS_MW_A.264 mode change 100755 => 100644 src/openh264/res/MR1_BT_A.h264 mode change 100755 => 100644 src/openh264/res/MR1_MW_A.264 mode change 100755 => 100644 src/openh264/res/MR2_MW_A.264 mode change 100755 => 100644 src/openh264/res/MR2_TANDBERG_E.264 mode change 100755 => 100644 src/openh264/res/NL1_Sony_D.jsv mode change 100755 => 100644 src/openh264/res/NLMQ1_JVC_C.264 mode change 100755 => 100644 src/openh264/res/NLMQ2_JVC_C.264 mode change 100755 => 100644 src/openh264/res/NRF_MW_E.264 mode change 100755 => 100644 src/openh264/res/QCIF_2P_I_allIPCM.264 mode change 100755 => 100644 src/openh264/res/SVA_BA1_B.264 mode change 100755 => 100644 src/openh264/res/SVA_BA2_D.264 mode change 100755 => 100644 src/openh264/res/SVA_Base_B.264 mode change 100755 => 100644 src/openh264/res/SVA_CL1_E.264 mode change 100755 => 100644 src/openh264/res/SVA_FM1_E.264 mode change 100755 => 100644 src/openh264/res/SVA_NL1_B.264 mode change 100755 => 100644 src/openh264/res/SVA_NL2_E.264 mode change 100755 => 100644 src/openh264/res/SarVui.264 mode change 100755 => 100644 src/openh264/res/Static.264 mode change 100755 => 100644 src/openh264/res/Static_152_100.yuv mode change 100755 => 100644 src/openh264/res/VID_1280x544_cabac_temporal_direct.264 mode change 100755 => 100644 src/openh264/res/VID_1280x544_cavlc_temporal_direct.264 mode change 100755 => 100644 src/openh264/res/VID_1280x720_cabac_temporal_direct.264 mode change 100755 => 100644 src/openh264/res/VID_1280x720_cavlc_temporal_direct.264 mode change 100755 => 100644 src/openh264/res/VID_1920x1080_cabac_temporal_direct.264 mode change 100755 => 100644 src/openh264/res/VID_1920x1080_cavlc_temporal_direct.264 mode change 100755 => 100644 src/openh264/res/Zhling_1280x720.264 mode change 100755 => 100644 src/openh264/res/jm_1080p_allslice.264 mode change 100755 => 100644 src/openh264/res/sps_subsetsps_bothVUI.264 mode change 100755 => 100644 src/openh264/res/test_cif_I_CABAC_PCM.264 mode change 100755 => 100644 src/openh264/res/test_cif_I_CABAC_slice.264 mode change 100755 => 100644 src/openh264/res/test_cif_P_CABAC_slice.264 mode change 100755 => 100644 src/openh264/res/test_qcif_cabac.264 mode change 100755 => 100644 src/openh264/res/test_scalinglist_jm.264 mode change 100755 => 100644 src/openh264/res/test_vd_1d.264 mode change 100755 => 100644 src/openh264/res/test_vd_rc.264 mode change 100755 => 100644 src/openh264/subprojects/gtest.wrap mode change 100755 => 100644 src/openh264/test/BaseDecoderTest.h mode change 100755 => 100644 src/openh264/test/BaseEncoderTest.h create mode 100644 src/openh264/test/BaseThreadDecoderTest.h mode change 100755 => 100644 src/openh264/test/api/BaseDecoderTest.cpp mode change 100755 => 100644 src/openh264/test/api/BaseEncoderTest.cpp create mode 100644 src/openh264/test/api/BaseThreadDecoderTest.cpp mode change 100755 => 100644 src/openh264/test/api/DataGenerator.cpp mode change 100755 => 100644 src/openh264/test/api/c_interface_test.c mode change 100755 => 100644 src/openh264/test/api/cpp_interface_test.cpp mode change 100755 => 100644 src/openh264/test/api/decode_api_test.cpp mode change 100755 => 100644 src/openh264/test/api/decode_encode_test.cpp mode change 100755 => 100644 src/openh264/test/api/decoder_ec_test.cpp mode change 100755 => 100644 src/openh264/test/api/decoder_test.cpp mode change 100755 => 100644 src/openh264/test/api/encode_decode_api_test.cpp mode change 100755 => 100644 src/openh264/test/api/encode_decode_api_test.h mode change 100755 => 100644 src/openh264/test/api/encode_decode_api_test.template mode change 100755 => 100644 src/openh264/test/api/encode_options_test.cpp mode change 100755 => 100644 src/openh264/test/api/encoder_test.cpp mode change 100755 => 100644 src/openh264/test/api/ltr_test.cpp mode change 100755 => 100644 src/openh264/test/api/meson.build mode change 100755 => 100644 src/openh264/test/api/sha1.c mode change 100755 => 100644 src/openh264/test/api/simple_test.cpp mode change 100755 => 100644 src/openh264/test/api/targets.mk create mode 100644 src/openh264/test/api/thread_decoder_test.cpp mode change 100755 => 100644 src/openh264/test/build/android/.gitignore mode change 100755 => 100644 src/openh264/test/build/android/AndroidManifest.xml mode change 100755 => 100644 src/openh264/test/build/android/jni/Android.mk mode change 100755 => 100644 src/openh264/test/build/android/jni/Application.mk mode change 100755 => 100644 src/openh264/test/build/android/jni/codec_unittest.cpp mode change 100755 => 100644 src/openh264/test/build/android/res/layout/activity_main.xml mode change 100755 => 100644 src/openh264/test/build/android/res/values-v11/styles.xml mode change 100755 => 100644 src/openh264/test/build/android/res/values-w820dp/dimens.xml mode change 100755 => 100644 src/openh264/test/build/android/res/values/dimens.xml mode change 100755 => 100644 src/openh264/test/build/android/res/values/strings.xml mode change 100755 => 100644 src/openh264/test/build/android/res/values/styles.xml mode change 100755 => 100644 src/openh264/test/build/android/src/com/cisco/codec/unittest/MainActivity.java mode change 100755 => 100644 src/openh264/test/build/win32/.gitignore mode change 100755 => 100644 src/openh264/test/build/win32/codec_ut/Codec_UT.sln mode change 100755 => 100644 src/openh264/test/build/win32/codec_ut/codec_unittest.vcproj mode change 100755 => 100644 src/openh264/test/build/win32/codec_ut/preprocessing_lib.vcproj mode change 100755 => 100644 src/openh264/test/build/windowsphone/.gitignore mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/App.xaml mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/App.xaml.cs mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/AlignmentGrid.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/ApplicationIcon.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/BadgeLogo.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Logo.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SplashScreen.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SquareTile150x150.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SquareTile71x71.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/StoreLogo.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileLarge.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileMedium.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileSmall.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/IconicTileMediumLarge.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/IconicTileSmall.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/WideLogo.png mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/CodecUTApp.csproj mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/LocalizedStrings.cs mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/MainPage.xaml mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/MainPage.xaml.cs mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Package.appxmanifest mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/AppManifest.xml mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/AssemblyInfo.cs mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/WMAppManifest.xml mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Resources/AppResources.Designer.cs mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Resources/AppResources.resx mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/Codec_UT.sln mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.cpp mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.h mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.vcxproj mode change 100755 => 100644 src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.vcxproj.filters mode change 100755 => 100644 src/openh264/test/common/CWelsListTest.cpp mode change 100755 => 100644 src/openh264/test/common/ExpandPicture.cpp mode change 100755 => 100644 src/openh264/test/common/WelsTaskListTest.cpp mode change 100755 => 100644 src/openh264/test/common/WelsThreadPoolTest.cpp mode change 100755 => 100644 src/openh264/test/common/WelsThreadPoolTest.h mode change 100755 => 100644 src/openh264/test/common/meson.build mode change 100755 => 100644 src/openh264/test/common/targets.mk mode change 100755 => 100644 src/openh264/test/decoder/DecUT_Deblock.cpp mode change 100755 => 100644 src/openh264/test/decoder/DecUT_DeblockCommon.cpp mode change 100755 => 100644 src/openh264/test/decoder/DecUT_DecExt.cpp mode change 100755 => 100644 src/openh264/test/decoder/DecUT_ErrorConcealment.cpp mode change 100755 => 100644 src/openh264/test/decoder/DecUT_IdctResAddPred.cpp mode change 100755 => 100644 src/openh264/test/decoder/DecUT_IntraPrediction.cpp mode change 100755 => 100644 src/openh264/test/decoder/DecUT_ParseSyntax.cpp mode change 100755 => 100644 src/openh264/test/decoder/DecUT_PredMv.cpp mode change 100755 => 100644 src/openh264/test/decoder/meson.build mode change 100755 => 100644 src/openh264/test/decoder/targets.mk mode change 100755 => 100644 src/openh264/test/encoder/EncUT_Cavlc.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_DecodeMbAux.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_EncoderExt.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_EncoderMb.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_EncoderMbAux.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_EncoderTaskManagement.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_ExpGolomb.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_GetIntraPredictor.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_InterfaceTest.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_MBCopy.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_MemoryAlloc.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_MemoryZero.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_MotionCompensation.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_MotionEstimate.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_ParameterSetStrategy.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_Reconstruct.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_SVC_me.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_Sample.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_SliceBufferReallocate.cpp mode change 100755 => 100644 src/openh264/test/encoder/EncUT_SliceBufferReallocate.h mode change 100755 => 100644 src/openh264/test/encoder/meson.build mode change 100755 => 100644 src/openh264/test/encoder/targets.mk mode change 100755 => 100644 src/openh264/test/encoder_binary_comparison/.gitignore mode change 100755 => 100644 src/openh264/test/encoder_binary_comparison/AboutTest mode change 100755 => 100644 src/openh264/test/encoder_binary_comparison/SHA1Table/Adobe_PDF_sample_a_1024x768_50Frms.264_AllCases_SHA1_Table.csv mode change 100755 => 100644 src/openh264/test/encoder_binary_comparison/SHA1Table/BA_MW_D.264_AllCases_SHA1_Table.csv mode change 100755 => 100644 src/openh264/test/encoder_binary_comparison/SHA1Table/Zhling_1280x720.264_AllCases_SHA1_Table.csv mode change 100755 => 100644 src/openh264/test/meson.build mode change 100755 => 100644 src/openh264/test/processing/ProcessUT_AdaptiveQuantization.cpp mode change 100755 => 100644 src/openh264/test/processing/ProcessUT_DownSample.cpp mode change 100755 => 100644 src/openh264/test/processing/ProcessUT_ScrollDetection.cpp mode change 100755 => 100644 src/openh264/test/processing/ProcessUT_VaaCalc.cpp mode change 100755 => 100644 src/openh264/test/processing/meson.build mode change 100755 => 100644 src/openh264/test/processing/targets.mk mode change 100755 => 100644 src/openh264/test/sha1.h mode change 100755 => 100644 src/openh264/test/test_stdint.h mode change 100755 => 100644 src/openh264/test/utils/BufferedData.h mode change 100755 => 100644 src/openh264/test/utils/DataGenerator.h mode change 100755 => 100644 src/openh264/test/utils/FileInputStream.h mode change 100755 => 100644 src/openh264/test/utils/HashFunctions.h mode change 100755 => 100644 src/openh264/test/utils/InputStream.h mode change 100755 => 100644 src/openh264/testbin/CmdLineReadMe mode change 100755 => 100644 src/openh264/testbin/layer2.cfg mode change 100755 => 100644 src/openh264/testbin/layer2_arbitrary_res.cfg mode change 100755 => 100644 src/openh264/testbin/layer2_vd.cfg mode change 100755 => 100644 src/openh264/testbin/layer2_vd_rc.cfg mode change 100755 => 100644 src/openh264/testbin/welsenc.cfg mode change 100755 => 100644 src/openh264/testbin/welsenc_arbitrary_res.cfg mode change 100755 => 100644 src/openh264/testbin/welsenc_ios.cfg mode change 100755 => 100644 src/openh264/testbin/welsenc_vd_1d.cfg mode change 100755 => 100644 src/openh264/testbin/welsenc_vd_rc.cfg mode change 100755 => 100644 src/openh264/ut.def diff --git a/src/openh264/.gitignore b/src/openh264/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/.reviewboardrc b/src/openh264/.reviewboardrc old mode 100755 new mode 100644 diff --git a/src/openh264/.travis.yml b/src/openh264/.travis.yml old mode 100755 new mode 100644 index 6e79ec142..5eec0c291 --- a/src/openh264/.travis.yml +++ b/src/openh264/.travis.yml @@ -1,5 +1,5 @@ language: cpp -dist: trusty +dist: xenial compiler: - g++ @@ -7,8 +7,8 @@ compiler: before_install: - sudo apt-get update -qq - - sudo apt-get install -qq nasm g++-multilib gcc-multilib libc6-dev-i386 python3-pip unzip - - sudo python3 -m pip install meson==0.44.1 + - sudo apt-get install -qq nasm g++-multilib gcc-multilib libc6-dev-i386 python3-pip python3-setuptools unzip + - sudo python3 -m pip install meson==0.47.0 - wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip - unzip ninja-linux.zip - export PATH=$PATH:$PWD diff --git a/src/openh264/CODING_STYLE b/src/openh264/CODING_STYLE old mode 100755 new mode 100644 diff --git a/src/openh264/CONTRIBUTORS b/src/openh264/CONTRIBUTORS old mode 100755 new mode 100644 diff --git a/src/openh264/LICENSE b/src/openh264/LICENSE old mode 100755 new mode 100644 diff --git a/src/openh264/Makefile b/src/openh264/Makefile old mode 100755 new mode 100644 index 74ff029d9..bf398d796 --- a/src/openh264/Makefile +++ b/src/openh264/Makefile @@ -36,7 +36,7 @@ STATIC_LDFLAGS=-lstdc++ STRIP ?= strip SHAREDLIB_MAJORVERSION=5 -FULL_VERSION := 2.0.0 +FULL_VERSION := 2.1.0 ifeq (,$(wildcard $(SRC_PATH)gmp-api)) HAVE_GMP_API=No @@ -285,10 +285,10 @@ endif endif $(PROJECT_NAME).pc: $(PROJECT_NAME).pc.in - @sed -e 's;@prefix@;$(PREFIX);' -e 's;@VERSION@;$(FULL_VERSION);' -e 's;@LIBS@;;' -e 's;@LIBS_PRIVATE@;$(STATIC_LDFLAGS);' < $< > $@ + @sed -e 's;@prefix@;$(PREFIX);' -e 's;@libdir@;$(PREFIX)/lib;' -e 's;@VERSION@;$(FULL_VERSION);' -e 's;@LIBS@;;' -e 's;@LIBS_PRIVATE@;$(STATIC_LDFLAGS);' < $< > $@ $(PROJECT_NAME)-static.pc: $(PROJECT_NAME).pc.in - @sed -e 's;@prefix@;$(PREFIX);' -e 's;@VERSION@;$(FULL_VERSION);' -e 's;@LIBS@;$(STATIC_LDFLAGS);' -e 's;@LIBS_PRIVATE@;;' < $< > $@ + @sed -e 's;@prefix@;$(PREFIX);' -e 's;@libdir@;$(PREFIX)/lib;' -e 's;@VERSION@;$(FULL_VERSION);' -e 's;@LIBS@;$(STATIC_LDFLAGS);' -e 's;@LIBS_PRIVATE@;;' < $< > $@ install-headers: mkdir -p $(DESTDIR)$(PREFIX)/include/wels diff --git a/src/openh264/README.md b/src/openh264/README.md old mode 100755 new mode 100644 diff --git a/src/openh264/RELEASES b/src/openh264/RELEASES old mode 100755 new mode 100644 index c3b4a66ee..9d5f5969a --- a/src/openh264/RELEASES +++ b/src/openh264/RELEASES @@ -1,6 +1,12 @@ Releases ----------- +v2.1.0 +------ +- Experimentally support for multi-thread decoding(default disabled,and may result in random problems if enabled) +- Assembly optimization for loongson platform +- Update meson version to 5 +- Some minor bug fixes v2.0.0 ------ diff --git a/src/openh264/autotest/performanceTest/.gitignore b/src/openh264/autotest/performanceTest/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/autotest/performanceTest/android/run_AutoTest_android.sh b/src/openh264/autotest/performanceTest/android/run_AutoTest_android.sh old mode 100755 new mode 100644 diff --git a/src/openh264/autotest/performanceTest/ios/run_AutoTest_ios.sh b/src/openh264/autotest/performanceTest/ios/run_AutoTest_ios.sh old mode 100755 new mode 100644 diff --git a/src/openh264/autotest/performanceTest/ios/uiascript.js b/src/openh264/autotest/performanceTest/ios/uiascript.js old mode 100755 new mode 100644 diff --git a/src/openh264/autotest/performanceTest/run_perfTest.sh b/src/openh264/autotest/performanceTest/run_perfTest.sh old mode 100755 new mode 100644 diff --git a/src/openh264/autotest/unitTest/android/run_AutoTest_android.sh b/src/openh264/autotest/unitTest/android/run_AutoTest_android.sh old mode 100755 new mode 100644 diff --git a/src/openh264/autotest/unitTest/ios/run_AutoTest_ios.sh b/src/openh264/autotest/unitTest/ios/run_AutoTest_ios.sh old mode 100755 new mode 100644 diff --git a/src/openh264/autotest/unitTest/run_ParseUTxml.sh b/src/openh264/autotest/unitTest/run_ParseUTxml.sh old mode 100755 new mode 100644 diff --git a/src/openh264/autotest/unitTest/run_unitTest.sh b/src/openh264/autotest/unitTest/run_unitTest.sh old mode 100755 new mode 100644 diff --git a/src/openh264/build/AutoBuildForWPAndWindows.bat b/src/openh264/build/AutoBuildForWPAndWindows.bat old mode 100755 new mode 100644 diff --git a/src/openh264/build/Dockerfile b/src/openh264/build/Dockerfile old mode 100755 new mode 100644 diff --git a/src/openh264/build/arch.mk b/src/openh264/build/arch.mk old mode 100755 new mode 100644 index 8ac3e70a5..1bf318ab9 --- a/src/openh264/build/arch.mk +++ b/src/openh264/build/arch.mk @@ -30,14 +30,26 @@ CFLAGS += -DHAVE_NEON_AARCH64 endif endif -#for loongson +#for mips ifneq ($(filter mips mips64, $(ARCH)),) ifeq ($(USE_ASM), Yes) +ENABLE_MMI=Yes +ENABLE_MSA=Yes ASM_ARCH = mips ASMFLAGS += -I$(SRC_PATH)codec/common/mips/ -LOONGSON3A = $(shell g++ -dM -E - < /dev/null | grep '_MIPS_TUNE ' | cut -f 3 -d " ") -ifeq ($(LOONGSON3A), "loongson3a") -CFLAGS += -DHAVE_MMI +#mmi +ifeq ($(ENABLE_MMI), Yes) +ENABLE_MMI = $(shell $(SRC_PATH)build/mips-simd-check.sh $(CC) mmi) +ifeq ($(ENABLE_MMI), Yes) +CFLAGS += -DHAVE_MMI -Wa,-mloongson-mmi,-mloongson-ext +endif +endif +#msa +ifeq ($(ENABLE_MSA), Yes) +ENABLE_MSA = $(shell $(SRC_PATH)build/mips-simd-check.sh $(CC) msa) +ifeq ($(ENABLE_MSA), Yes) +CFLAGS += -DHAVE_MSA -mmsa +endif endif endif endif diff --git a/src/openh264/build/astyle.cfg b/src/openh264/build/astyle.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/build/gtest-targets.mk b/src/openh264/build/gtest-targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/mips-simd-check.sh b/src/openh264/build/mips-simd-check.sh new file mode 100755 index 000000000..5efffbef2 --- /dev/null +++ b/src/openh264/build/mips-simd-check.sh @@ -0,0 +1,32 @@ +#!/bin/bash +#********************************************************************************** +# This script is using in build/arch.mk for mips to detect the simd instructions: +# mmi, msa (maybe more in the future). +# +# --usage: +# ./mips-simd-check.sh $(CC) mmi +# or ./mips-simd-check.sh $(CC) msa +# +# date: 10/17/2019 Created +#********************************************************************************** + +TMPC=$(mktemp tmp.XXXXXX.c) +TMPO=$(mktemp tmp.XXXXXX.o) +if [ $2 == "mmi" ] +then + echo "void main(void){ __asm__ volatile(\"punpcklhw \$f0, \$f0, \$f0\"); }" > $TMPC + $1 -Wa,-mloongson-mmi $TMPC -o $TMPO &> /dev/null + if test -s $TMPO + then + echo "Yes" + fi +elif [ $2 == "msa" ] +then + echo "void main(void){ __asm__ volatile(\"addvi.b \$w0, \$w1, 1\"); }" > $TMPC + $1 -mmsa $TMPC -o $TMPO &> /dev/null + if test -s $TMPO + then + echo "Yes" + fi +fi +rm -f $TMPC $TMPO diff --git a/src/openh264/build/mktargets.py b/src/openh264/build/mktargets.py index 593280c09..518909d3d 100755 --- a/src/openh264/build/mktargets.py +++ b/src/openh264/build/mktargets.py @@ -119,9 +119,9 @@ for file in sfiles: armfiles.append(file) mipsfiles = [] for file in cfiles: - c = file.split('/') - if 'mips' in c: - mipsfiles.append(file) + c = file.split('/') + if 'mips' in c: + mipsfiles.append(file) cfiles = [x for x in cfiles if x not in mipsfiles] @@ -181,15 +181,34 @@ if len(arm64files) > 0: f.write("OBJS += $(%s_OBJSARM64)\n\n"%(PREFIX)) if len(mipsfiles) > 0: - f.write("%s_ASM_MIPS_SRCS=\\\n"%(PREFIX)) - for c in mipsfiles: - f.write("\t$(%s_SRCDIR)/%s\\\n"%(PREFIX, c)) - f.write("\n") - f.write("%s_OBJSMIPS += $(%s_ASM_MIPS_SRCS:.c=.$(OBJ))\n"%(PREFIX, PREFIX)) - f.write("ifeq ($(ASM_ARCH), mips)\n") - f.write("%s_OBJS += $(%s_OBJSMIPS)\n"%(PREFIX,PREFIX)) - f.write("endif\n") - f.write("OBJS += $(%s_OBJSMIPS)\n\n"%(PREFIX)) + mmifiles = [] + for file in mipsfiles: + if '_mmi' in file: + mmifiles.append(file) + f.write("%s_ASM_MIPS_MMI_SRCS=\\\n"%(PREFIX)) + for c in mmifiles: + f.write("\t$(%s_SRCDIR)/%s\\\n"%(PREFIX, c)) + f.write("\n") + f.write("%s_OBJSMIPS_MMI += $(%s_ASM_MIPS_MMI_SRCS:.c=.$(OBJ))\n\n"%(PREFIX, PREFIX)) + msafiles = [] + for file in mipsfiles: + if '_msa' in file: + msafiles.append(file) + f.write("%s_ASM_MIPS_MSA_SRCS=\\\n"%(PREFIX)) + for c in msafiles: + f.write("\t$(%s_SRCDIR)/%s\\\n"%(PREFIX, c)) + f.write("\n") + f.write("%s_OBJSMIPS_MSA += $(%s_ASM_MIPS_MSA_SRCS:.c=.$(OBJ))\n"%(PREFIX, PREFIX)) + f.write("ifeq ($(ASM_ARCH), mips)\n") + f.write("ifeq ($(ENABLE_MMI), Yes)\n") + f.write("%s_OBJS += $(%s_OBJSMIPS_MMI)\n"%(PREFIX,PREFIX)) + f.write("endif\n") + f.write("ifeq ($(ENABLE_MSA), Yes)\n") + f.write("%s_OBJS += $(%s_OBJSMIPS_MSA)\n"%(PREFIX,PREFIX)) + f.write("endif\n") + f.write("endif\n") + f.write("OBJS += $(%s_OBJSMIPS_MMI)\n"%(PREFIX)) + f.write("OBJS += $(%s_OBJSMIPS_MSA)\n\n"%(PREFIX)) f.write("OBJS += $(%s_OBJS)\n\n"%(PREFIX)) write_cpp_rule_pattern(f) diff --git a/src/openh264/build/msvc-app.mk b/src/openh264/build/msvc-app.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/msvc-common.mk b/src/openh264/build/msvc-common.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/platform-android.mk b/src/openh264/build/platform-android.mk old mode 100755 new mode 100644 index 6f6ce3475..5cebcb05e --- a/src/openh264/build/platform-android.mk +++ b/src/openh264/build/platform-android.mk @@ -49,6 +49,7 @@ CFLAGS += -isystem $(NDKROOT)/sysroot/usr/include -isystem $(NDKROOT)/sysroot/us CXXFLAGS += -fno-rtti -fno-exceptions LDFLAGS += --sysroot=$(SYSROOT) SHLDFLAGS = -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -Wl,-soname,lib$(PROJECT_NAME).so +UTSHLDFLAGS = -Wl,-soname,libut.so ifeq ($(NDK_TOOLCHAIN_VERSION), clang) HOST_OS = $(shell uname -s | tr [A-Z] [a-z]) @@ -70,9 +71,11 @@ ifeq ($(NDK_TOOLCHAIN_VERSION), clang) CFLAGS += -target $(TARGET_NAME) LDFLAGS += -target $(TARGET_NAME) -gcc-toolchain $(GCC_TOOLCHAIN_PATH) - LDFLAGS += -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libunwind.a endif +# background reading: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#unwinding +LDFLAGS += -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libunwind.a + ifneq ($(findstring /,$(CXX)),$(findstring \,$(CXX))) ifneq ($(CXX),$(wildcard $(CXX))) ifneq ($(CXX).exe,$(wildcard $(CXX).exe)) @@ -81,10 +84,18 @@ endif endif endif +ifeq ($(NDK_TOOLCHAIN_VERSION), clang) +STL_INCLUDES = \ + -I$(NDKROOT)/sources/cxx-stl/llvm-libc++/include \ + -I$(NDKROOT)/sources/cxx-stl/llvm-libc++abi/include +STL_LIB = \ + $(NDKROOT)/sources/cxx-stl/llvm-libc++/libs/$(APP_ABI)/libc++_static.a +else STL_INCLUDES = \ -I$(NDKROOT)/sources/cxx-stl/stlport/stlport STL_LIB = \ $(NDKROOT)/sources/cxx-stl/stlport/libs/$(APP_ABI)/libstlport_static.a +endif GTEST_INCLUDES = $(STL_INCLUDES) CODEC_UNITTEST_INCLUDES = $(STL_INCLUDES) diff --git a/src/openh264/build/platform-bsd.mk b/src/openh264/build/platform-bsd.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/platform-cygwin_nt.mk b/src/openh264/build/platform-cygwin_nt.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/platform-darwin.mk b/src/openh264/build/platform-darwin.mk old mode 100755 new mode 100644 index 6c7b24434..6551cea50 --- a/src/openh264/build/platform-darwin.mk +++ b/src/openh264/build/platform-darwin.mk @@ -3,8 +3,8 @@ SHAREDLIB_DIR = $(PREFIX)/lib SHAREDLIBSUFFIX = dylib SHAREDLIBSUFFIXFULLVER=$(FULL_VERSION).$(SHAREDLIBSUFFIX) SHAREDLIBSUFFIXMAJORVER=$(SHAREDLIB_MAJORVERSION).$(SHAREDLIBSUFFIX) -CURRENT_VERSION := 2.0.0 -COMPATIBILITY_VERSION := 2.0.0 +CURRENT_VERSION := 2.1.0 +COMPATIBILITY_VERSION := 2.1.0 SHLDFLAGS = -dynamiclib -twolevel_namespace -undefined dynamic_lookup \ -fno-common -headerpad_max_install_names -install_name \ $(SHAREDLIB_DIR)/$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXMAJORVER) diff --git a/src/openh264/build/platform-ios.mk b/src/openh264/build/platform-ios.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/platform-linux.mk b/src/openh264/build/platform-linux.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/platform-mingw_nt.mk b/src/openh264/build/platform-mingw_nt.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/platform-msvc-app.mk b/src/openh264/build/platform-msvc-app.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/platform-msvc-wp.mk b/src/openh264/build/platform-msvc-wp.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/platform-msvc.mk b/src/openh264/build/platform-msvc.mk old mode 100755 new mode 100644 diff --git a/src/openh264/build/x86-common.mk b/src/openh264/build/x86-common.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/api/meson.build b/src/openh264/codec/api/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/api/svc/codec_api.h b/src/openh264/codec/api/svc/codec_api.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/api/svc/codec_app_def.h b/src/openh264/codec/api/svc/codec_app_def.h old mode 100755 new mode 100644 index 1e26f9f27..bb3c3d67b --- a/src/openh264/codec/api/svc/codec_app_def.h +++ b/src/openh264/codec/api/svc/codec_app_def.h @@ -167,8 +167,8 @@ typedef enum { DECODER_OPTION_LEVEL, ///< get current AU level info,only is used in GetOption DECODER_OPTION_STATISTICS_LOG_INTERVAL,///< set log output interval DECODER_OPTION_IS_REF_PIC, ///< feedback current frame is ref pic or not - DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER ///< number of frames remaining in decoder buffer when pictures are required to re-ordered into display-order. - + DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER, ///< number of frames remaining in decoder buffer when pictures are required to re-ordered into display-order. + DECODER_OPTION_NUM_OF_THREADS, ///< number of decoding threads. The maximum thread count is equal or less than lesser of (cpu core counts and 16). } DECODER_OPTION; /** diff --git a/src/openh264/codec/api/svc/codec_def.h b/src/openh264/codec/api/svc/codec_def.h old mode 100755 new mode 100644 index 4f7eb9d88..edde5f4a2 --- a/src/openh264/codec/api/svc/codec_def.h +++ b/src/openh264/codec/api/svc/codec_def.h @@ -201,6 +201,7 @@ typedef struct TagBufferInfo { union { SSysMEMBuffer sSystemBuffer; ///< memory info for one picture } UsrData; ///< output buffer info + unsigned char* pDst[3]; //point to picture YUV data } SBufferInfo; diff --git a/src/openh264/codec/api/svc/codec_ver.h b/src/openh264/codec/api/svc/codec_ver.h old mode 100755 new mode 100644 index 06d5efcd2..a4e494f6b --- a/src/openh264/codec/api/svc/codec_ver.h +++ b/src/openh264/codec/api/svc/codec_ver.h @@ -4,12 +4,12 @@ #include "codec_app_def.h" -static const OpenH264Version g_stCodecVersion = {2, 0, 0, 1905}; -static const char* const g_strCodecVer = "OpenH264 version:2.0.0.1905"; +static const OpenH264Version g_stCodecVersion = {2, 1, 0, 2002}; +static const char* const g_strCodecVer = "OpenH264 version:2.1.0.2002"; #define OPENH264_MAJOR (2) -#define OPENH264_MINOR (0) +#define OPENH264_MINOR (1) #define OPENH264_REVISION (0) -#define OPENH264_RESERVED (1905) +#define OPENH264_RESERVED (2002) #endif // CODEC_VER_H diff --git a/src/openh264/codec/api/svc/meson.build b/src/openh264/codec/api/svc/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/.gitignore b/src/openh264/codec/build/android/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/dec/AndroidManifest.xml b/src/openh264/codec/build/android/dec/AndroidManifest.xml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/dec/jni/Android.mk b/src/openh264/codec/build/android/dec/jni/Android.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/dec/jni/Application.mk b/src/openh264/codec/build/android/dec/jni/Application.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/dec/jni/myjni.cpp b/src/openh264/codec/build/android/dec/jni/myjni.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/dec/jni/welsdecdemo.mk b/src/openh264/codec/build/android/dec/jni/welsdecdemo.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/dec/res/layout/main.xml b/src/openh264/codec/build/android/dec/res/layout/main.xml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/dec/res/values/strings.xml b/src/openh264/codec/build/android/dec/res/values/strings.xml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/dec/src/com/wels/dec/WelsDecTest.java b/src/openh264/codec/build/android/dec/src/com/wels/dec/WelsDecTest.java old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/enc/AndroidManifest.xml b/src/openh264/codec/build/android/enc/AndroidManifest.xml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/enc/jni/Android.mk b/src/openh264/codec/build/android/enc/jni/Android.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/enc/jni/Application.mk b/src/openh264/codec/build/android/enc/jni/Application.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/enc/jni/myjni.cpp b/src/openh264/codec/build/android/enc/jni/myjni.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/enc/jni/welsencdemo.mk b/src/openh264/codec/build/android/enc/jni/welsencdemo.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/enc/res/layout/main.xml b/src/openh264/codec/build/android/enc/res/layout/main.xml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/enc/res/values/strings.xml b/src/openh264/codec/build/android/enc/res/values/strings.xml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/android/enc/src/com/wels/enc/WelsEncTest.java b/src/openh264/codec/build/android/enc/src/com/wels/enc/WelsEncTest.java old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/.gitignore b/src/openh264/codec/build/iOS/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/common/common.xcodeproj/project.pbxproj b/src/openh264/codec/build/iOS/common/common.xcodeproj/project.pbxproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo.xcodeproj/project.pbxproj b/src/openh264/codec/build/iOS/dec/demo/demo.xcodeproj/project.pbxproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/DEMOAppDelegate.h b/src/openh264/codec/build/iOS/dec/demo/demo/DEMOAppDelegate.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/DEMOAppDelegate.m b/src/openh264/codec/build/iOS/dec/demo/demo/DEMOAppDelegate.m old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewController.h b/src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewController.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewController.m b/src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewController.m old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewControllerShowResource.h b/src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewControllerShowResource.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewControllerShowResource.m b/src/openh264/codec/build/iOS/dec/demo/demo/DEMOViewControllerShowResource.m old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/Default-568h@2x.png b/src/openh264/codec/build/iOS/dec/demo/demo/Default-568h@2x.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/Default.png b/src/openh264/codec/build/iOS/dec/demo/demo/Default.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/Default@2x.png b/src/openh264/codec/build/iOS/dec/demo/demo/Default@2x.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/demo-Info.plist b/src/openh264/codec/build/iOS/dec/demo/demo/demo-Info.plist old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/InfoPlist.strings b/src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/InfoPlist.strings old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/MainStoryboard_iPad.storyboard b/src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/MainStoryboard_iPad.storyboard old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/MainStoryboard_iPhone.storyboard b/src/openh264/codec/build/iOS/dec/demo/demo/en.lproj/MainStoryboard_iPhone.storyboard old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/demo/demo/main.m b/src/openh264/codec/build/iOS/dec/demo/demo/main.m old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/dec/welsdec/welsdec.xcodeproj/project.pbxproj b/src/openh264/codec/build/iOS/dec/welsdec/welsdec.xcodeproj/project.pbxproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo.xcodeproj/project.pbxproj b/src/openh264/codec/build/iOS/enc/encDemo/encDemo.xcodeproj/project.pbxproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/AppDelegate.h b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/AppDelegate.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/AppDelegate.m b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/AppDelegate.m old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/Base.lproj/Main_iPad.storyboard b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/Base.lproj/Main_iPad.storyboard old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/Base.lproj/Main_iPhone.storyboard b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/Base.lproj/Main_iPhone.storyboard old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/Images.xcassets/AppIcon.appiconset/Contents.json b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/Images.xcassets/AppIcon.appiconset/Contents.json old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/Images.xcassets/LaunchImage.launchimage/Contents.json b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/Images.xcassets/LaunchImage.launchimage/Contents.json old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/ViewController.h b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/ViewController.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/ViewController.m b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/ViewController.m old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/en.lproj/InfoPlist.strings b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/en.lproj/InfoPlist.strings old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/encDemo-Info.plist b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/encDemo-Info.plist old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/encDemo/encDemo/main.m b/src/openh264/codec/build/iOS/enc/encDemo/encDemo/main.m old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/enc/welsenc/welsenc.xcodeproj/project.pbxproj b/src/openh264/codec/build/iOS/enc/welsenc/welsenc.xcodeproj/project.pbxproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/openh264/openh264.xcodeproj/project.pbxproj b/src/openh264/codec/build/iOS/openh264/openh264.xcodeproj/project.pbxproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/iOS/processing/processing.xcodeproj/project.pbxproj b/src/openh264/codec/build/iOS/processing/processing.xcodeproj/project.pbxproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/win32/.gitignore b/src/openh264/codec/build/win32/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/win32/dec/WelsDecCore.vcproj b/src/openh264/codec/build/win32/dec/WelsDecCore.vcproj old mode 100755 new mode 100644 index 558e1f24b..8eb895cd1 --- a/src/openh264/codec/build/win32/dec/WelsDecCore.vcproj +++ b/src/openh264/codec/build/win32/dec/WelsDecCore.vcproj @@ -860,6 +860,10 @@ RelativePath="..\..\..\common\inc\wels_const_common.h" > + + + + diff --git a/src/openh264/codec/build/win32/dec/WelsDecPlus.vcproj b/src/openh264/codec/build/win32/dec/WelsDecPlus.vcproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/win32/dec/WelsDecoder.sln b/src/openh264/codec/build/win32/dec/WelsDecoder.sln old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/win32/dec/decConsole.vcproj b/src/openh264/codec/build/win32/dec/decConsole.vcproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/win32/enc/WelsEncCore.vcproj b/src/openh264/codec/build/win32/enc/WelsEncCore.vcproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/win32/enc/WelsEncPlus.vcproj b/src/openh264/codec/build/win32/enc/WelsEncPlus.vcproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/win32/enc/WelsEncoder.sln b/src/openh264/codec/build/win32/enc/WelsEncoder.sln old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/win32/enc/encConsole.vcproj b/src/openh264/codec/build/win32/enc/encConsole.vcproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/.gitignore b/src/openh264/codec/build/windowsphone/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp.sln b/src/openh264/codec/build/windowsphone/all/CodecApp.sln old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/App.xaml b/src/openh264/codec/build/windowsphone/all/CodecApp/App.xaml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/App.xaml.cs b/src/openh264/codec/build/windowsphone/all/CodecApp/App.xaml.cs old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/AlignmentGrid.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/AlignmentGrid.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/ApplicationIcon.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/ApplicationIcon.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/BadgeLogo.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/BadgeLogo.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Logo.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Logo.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SplashScreen.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SplashScreen.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SquareTile150x150.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SquareTile150x150.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SquareTile71x71.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/SquareTile71x71.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/StoreLogo.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/StoreLogo.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileLarge.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileLarge.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileMedium.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileMedium.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileSmall.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/FlipCycleTileSmall.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/IconicTileMediumLarge.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/IconicTileMediumLarge.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/IconicTileSmall.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/Tiles/IconicTileSmall.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/WideLogo.png b/src/openh264/codec/build/windowsphone/all/CodecApp/Assets/WideLogo.png old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/CodecApp.csproj b/src/openh264/codec/build/windowsphone/all/CodecApp/CodecApp.csproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/LocalizedStrings.cs b/src/openh264/codec/build/windowsphone/all/CodecApp/LocalizedStrings.cs old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/MainPage.xaml b/src/openh264/codec/build/windowsphone/all/CodecApp/MainPage.xaml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/MainPage.xaml.cs b/src/openh264/codec/build/windowsphone/all/CodecApp/MainPage.xaml.cs old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Package.appxmanifest b/src/openh264/codec/build/windowsphone/all/CodecApp/Package.appxmanifest old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Properties/AppManifest.xml b/src/openh264/codec/build/windowsphone/all/CodecApp/Properties/AppManifest.xml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Properties/AssemblyInfo.cs b/src/openh264/codec/build/windowsphone/all/CodecApp/Properties/AssemblyInfo.cs old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Properties/WMAppManifest.xml b/src/openh264/codec/build/windowsphone/all/CodecApp/Properties/WMAppManifest.xml old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Resources/AppResources.Designer.cs b/src/openh264/codec/build/windowsphone/all/CodecApp/Resources/AppResources.Designer.cs old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/Resources/AppResources.resx b/src/openh264/codec/build/windowsphone/all/CodecApp/Resources/AppResources.resx old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/layer2.cfg b/src/openh264/codec/build/windowsphone/all/CodecApp/layer2.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecApp/welsenc.cfg b/src/openh264/codec/build/windowsphone/all/CodecApp/welsenc.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecRTComponent.cpp b/src/openh264/codec/build/windowsphone/all/CodecRTComponent.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecRTComponent.h b/src/openh264/codec/build/windowsphone/all/CodecRTComponent.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecRTComponent.vcxproj b/src/openh264/codec/build/windowsphone/all/CodecRTComponent.vcxproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/build/windowsphone/all/CodecRTComponent.vcxproj.filters b/src/openh264/codec/build/windowsphone/all/CodecRTComponent.vcxproj.filters old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm/arm_arch_common_macro.S b/src/openh264/codec/common/arm/arm_arch_common_macro.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm/copy_mb_neon.S b/src/openh264/codec/common/arm/copy_mb_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm/deblocking_neon.S b/src/openh264/codec/common/arm/deblocking_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm/expand_picture_neon.S b/src/openh264/codec/common/arm/expand_picture_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm/intra_pred_common_neon.S b/src/openh264/codec/common/arm/intra_pred_common_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm/mc_neon.S b/src/openh264/codec/common/arm/mc_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm64/arm_arch64_common_macro.S b/src/openh264/codec/common/arm64/arm_arch64_common_macro.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm64/copy_mb_aarch64_neon.S b/src/openh264/codec/common/arm64/copy_mb_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm64/deblocking_aarch64_neon.S b/src/openh264/codec/common/arm64/deblocking_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm64/expand_picture_aarch64_neon.S b/src/openh264/codec/common/arm64/expand_picture_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm64/intra_pred_common_aarch64_neon.S b/src/openh264/codec/common/arm64/intra_pred_common_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/arm64/mc_aarch64_neon.S b/src/openh264/codec/common/arm64/mc_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/.gitignore b/src/openh264/codec/common/inc/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/WelsList.h b/src/openh264/codec/common/inc/WelsList.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/WelsLock.h b/src/openh264/codec/common/inc/WelsLock.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/WelsTask.h b/src/openh264/codec/common/inc/WelsTask.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/WelsTaskThread.h b/src/openh264/codec/common/inc/WelsTaskThread.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/WelsThread.h b/src/openh264/codec/common/inc/WelsThread.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/WelsThreadLib.h b/src/openh264/codec/common/inc/WelsThreadLib.h old mode 100755 new mode 100644 index 494a076c0..cd26dbdd9 --- a/src/openh264/codec/common/inc/WelsThreadLib.h +++ b/src/openh264/codec/common/inc/WelsThreadLib.h @@ -60,6 +60,19 @@ typedef HANDLE WELS_EVENT; #define WELS_THREAD_ROUTINE_TYPE DWORD WINAPI #define WELS_THREAD_ROUTINE_RETURN(rc) return (DWORD)rc; +#ifdef WINAPI_FAMILY +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#define WP80 + +#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0) +#define GetSystemInfo(x) GetNativeSystemInfo(x) +#define CreateEvent(attr, reset, init, name) CreateEventEx(attr, name, ((reset) ? CREATE_EVENT_MANUAL_RESET : 0) | ((init) ? CREATE_EVENT_INITIAL_SET : 0), EVENT_ALL_ACCESS) +#define CreateSemaphore(a, b, c, d) CreateSemaphoreEx(a, b, c, d, 0, SEMAPHORE_ALL_ACCESS) +#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE) +#define WaitForMultipleObjects(a, b, c, d) WaitForMultipleObjectsEx(a, b, c, d, FALSE) +#endif +#endif + #else // NON-WINDOWS #include diff --git a/src/openh264/codec/common/inc/WelsThreadPool.h b/src/openh264/codec/common/inc/WelsThreadPool.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/asmdefs_mmi.h b/src/openh264/codec/common/inc/asmdefs_mmi.h old mode 100755 new mode 100644 index 5baa823e2..69a7ae398 --- a/src/openh264/codec/common/inc/asmdefs_mmi.h +++ b/src/openh264/codec/common/inc/asmdefs_mmi.h @@ -289,7 +289,7 @@ * backup register */ #define BACKUP_REG \ - double __back_temp[8]; \ + double __attribute__((aligned(16))) __back_temp[8]; \ if (_MIPS_SIM == _ABI64) \ __asm__ volatile ( \ "gssqc1 $f25, $f24, 0x00(%[temp]) \n\t" \ diff --git a/src/openh264/codec/common/inc/copy_mb.h b/src/openh264/codec/common/inc/copy_mb.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/cpu.h b/src/openh264/codec/common/inc/cpu.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/cpu_core.h b/src/openh264/codec/common/inc/cpu_core.h old mode 100755 new mode 100644 index e5906c62b..f25787b04 --- a/src/openh264/codec/common/inc/cpu_core.h +++ b/src/openh264/codec/common/inc/cpu_core.h @@ -86,6 +86,7 @@ /* For loongson */ #define WELS_CPU_MMI 0x00000001 /* mmi */ +#define WELS_CPU_MSA 0x00000002 /* msa */ /* * Interfaces for CPU core feature detection as below diff --git a/src/openh264/codec/common/inc/crt_util_safe_x.h b/src/openh264/codec/common/inc/crt_util_safe_x.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/deblocking_common.h b/src/openh264/codec/common/inc/deblocking_common.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/expand_pic.h b/src/openh264/codec/common/inc/expand_pic.h old mode 100755 new mode 100644 index cbb69b421..2b06d9e47 --- a/src/openh264/codec/common/inc/expand_pic.h +++ b/src/openh264/codec/common/inc/expand_pic.h @@ -47,6 +47,7 @@ extern "C" { #endif//__cplusplus #define PADDING_LENGTH 32 // reference extension +#define CHROMA_PADDING_LENGTH 16 // chroma reference extension #if defined(X86_ASM) void ExpandPictureLuma_sse2 (uint8_t* pDst, @@ -89,6 +90,10 @@ typedef struct TagExpandPicFunc { PExpandPictureFunc pfExpandChromaPicture[2]; } SExpandPicFunc; +void PadMBLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, const int32_t& kiPicH, + const int32_t& kiMbX, const int32_t& kiMbY, const int32_t& kiMBWidth, const int32_t& kiMBHeight); +void PadMBChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, const int32_t& kiPicH, + const int32_t& kiMbX, const int32_t& kiMbY, const int32_t& kiMBWidth, const int32_t& kiMBHeight); void ExpandReferencingPicture (uint8_t* pData[3], int32_t iWidth, int32_t iHeight, int32_t iStride[3], PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]); diff --git a/src/openh264/codec/common/inc/golomb_common.h b/src/openh264/codec/common/inc/golomb_common.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/intra_pred_common.h b/src/openh264/codec/common/inc/intra_pred_common.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/ls_defines.h b/src/openh264/codec/common/inc/ls_defines.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/macros.h b/src/openh264/codec/common/inc/macros.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/mc.h b/src/openh264/codec/common/inc/mc.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/measure_time.h b/src/openh264/codec/common/inc/measure_time.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/memory_align.h b/src/openh264/codec/common/inc/memory_align.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/sad_common.h b/src/openh264/codec/common/inc/sad_common.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/typedefs.h b/src/openh264/codec/common/inc/typedefs.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/utils.h b/src/openh264/codec/common/inc/utils.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/version.h b/src/openh264/codec/common/inc/version.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/version_gen.h.template b/src/openh264/codec/common/inc/version_gen.h.template old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/welsCodecTrace.h b/src/openh264/codec/common/inc/welsCodecTrace.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/wels_common_defs.h b/src/openh264/codec/common/inc/wels_common_defs.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/inc/wels_const_common.h b/src/openh264/codec/common/inc/wels_const_common.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/meson.build b/src/openh264/codec/common/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/mips/copy_mb_mmi.c b/src/openh264/codec/common/mips/copy_mb_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/mips/deblock_mmi.c b/src/openh264/codec/common/mips/deblock_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/mips/expand_picture_mmi.c b/src/openh264/codec/common/mips/expand_picture_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/mips/intra_pred_com_mmi.c b/src/openh264/codec/common/mips/intra_pred_com_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/mips/satd_sad_mmi.c b/src/openh264/codec/common/mips/satd_sad_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/WelsTaskThread.cpp b/src/openh264/codec/common/src/WelsTaskThread.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/WelsThread.cpp b/src/openh264/codec/common/src/WelsThread.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/WelsThreadLib.cpp b/src/openh264/codec/common/src/WelsThreadLib.cpp old mode 100755 new mode 100644 index 8aa67f116..4477e34e3 --- a/src/openh264/codec/common/src/WelsThreadLib.cpp +++ b/src/openh264/codec/common/src/WelsThreadLib.cpp @@ -71,18 +71,6 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#ifdef WINAPI_FAMILY -#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -#define WP80 - -#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0) -#define GetSystemInfo(x) GetNativeSystemInfo(x) -#define CreateEvent(attr, reset, init, name) CreateEventEx(attr, name, ((reset) ? CREATE_EVENT_MANUAL_RESET : 0) | ((init) ? CREATE_EVENT_INITIAL_SET : 0), EVENT_ALL_ACCESS) -#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE) -#define WaitForMultipleObjects(a, b, c, d) WaitForMultipleObjectsEx(a, b, c, d, FALSE) -#endif -#endif - WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) { InitializeCriticalSection (mutex); diff --git a/src/openh264/codec/common/src/WelsThreadPool.cpp b/src/openh264/codec/common/src/WelsThreadPool.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/common_tables.cpp b/src/openh264/codec/common/src/common_tables.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/copy_mb.cpp b/src/openh264/codec/common/src/copy_mb.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/cpu.cpp b/src/openh264/codec/common/src/cpu.cpp old mode 100755 new mode 100644 index a39fd0645..15ed947d1 --- a/src/openh264/codec/common/src/cpu.cpp +++ b/src/openh264/codec/common/src/cpu.cpp @@ -309,12 +309,45 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) { #elif defined(mips) /* for loongson */ +static uint32_t get_cpu_flags_from_cpuinfo(void) +{ + uint32_t flags = 0; + +# ifdef __linux__ + FILE* fp = fopen("/proc/cpuinfo", "r"); + if (!fp) + return flags; + + char buf[200]; + memset(buf, 0, sizeof(buf)); + while (fgets(buf, sizeof(buf), fp)) { + if (!strncmp(buf, "model name", strlen("model name"))) { + if (strstr(buf, "Loongson-3A") || strstr(buf, "Loongson-3B") || + strstr(buf, "Loongson-2K")) { + flags |= WELS_CPU_MMI; + } + break; + } + } + while (fgets(buf, sizeof(buf), fp)) { + if(!strncmp(buf, "ASEs implemented", strlen("ASEs implemented"))) { + if (strstr(buf, "loongson-mmi") || strstr(buf, "loongson-ext")) { + flags |= WELS_CPU_MMI; + } + if (strstr(buf, "msa")) { + flags |= WELS_CPU_MSA; + } + break; + } + } + fclose(fp); +# endif + + return flags; +} + uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) { -#if defined(HAVE_MMI) - return WELS_CPU_MMI; -#else - return 0; -#endif + return get_cpu_flags_from_cpuinfo(); } #else /* Neither X86_ASM, HAVE_NEON, HAVE_NEON_AARCH64 nor mips */ @@ -324,5 +357,3 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) { } #endif - - diff --git a/src/openh264/codec/common/src/crt_util_safe_x.cpp b/src/openh264/codec/common/src/crt_util_safe_x.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/deblocking_common.cpp b/src/openh264/codec/common/src/deblocking_common.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/expand_pic.cpp b/src/openh264/codec/common/src/expand_pic.cpp old mode 100755 new mode 100644 index 65ffb3fdd..fcd96540e --- a/src/openh264/codec/common/src/expand_pic.cpp +++ b/src/openh264/codec/common/src/expand_pic.cpp @@ -33,6 +33,240 @@ #include "expand_pic.h" #include "cpu_core.h" +static inline void MBPadTopLeftLuma_c (uint8_t*& pDst, const int32_t& kiStride) { + const uint8_t kuiTL = pDst[0]; + int32_t i = 0; + uint8_t* pTopLeft = pDst; + do { + pTopLeft -= kiStride; + // pad pTop + memcpy (pTopLeft, pDst, 16); // confirmed_safe_unsafe_usage + memset (pTopLeft - PADDING_LENGTH, kuiTL, PADDING_LENGTH); //pTop left + } while (++i < PADDING_LENGTH); +} + +static inline void MBPadTopLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbX) { + uint8_t* pTopLine = pDst + (kiMbX << 4); + int32_t i = 0; + uint8_t* pTop = pTopLine; + do { + pTop -= kiStride; + // pad pTop + memcpy (pTop, pTopLine, 16); // confirmed_safe_unsafe_usage + } while (++i < PADDING_LENGTH); +} + +static inline void MBPadBottomLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbX, + const int32_t& kiPicH) { + uint8_t* pBottomLine = pDst + (kiPicH - 1) * kiStride + (kiMbX << 4); + int32_t i = 0; + uint8_t* pBottom = pBottomLine; + do { + pBottom += kiStride; + // pad pBottom + memcpy (pBottom, pBottomLine, 16); // confirmed_safe_unsafe_usage + } while (++i < PADDING_LENGTH); +} + +static inline void MBPadTopRightLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW) { + uint8_t* pTopRight = pDst + kiPicW; + const uint8_t kuiTR = pTopRight[-1]; + int32_t i = 0; + uint8_t* pTop = pTopRight; + do { + pTop -= kiStride; + // pad pTop + memcpy (pTop - 16, pTopRight - 16, 16); // confirmed_safe_unsafe_usage + memset (pTop, kuiTR, PADDING_LENGTH); //pTop Right + } while (++i < PADDING_LENGTH); +} + +static inline void MBPadBottomLeftLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicH) { + uint8_t* pDstLastLine = pDst + (kiPicH - 1) * kiStride; + const uint8_t kuiBL = pDstLastLine[0]; + int32_t i = 0; + uint8_t* pBottom = pDstLastLine; + do { + pBottom += kiStride; + // pad pBottom + memcpy (pBottom, pDstLastLine, 16); // confirmed_safe_unsafe_usage + memset (pBottom - PADDING_LENGTH, kuiBL, PADDING_LENGTH); //pBottom left + } while (++i < PADDING_LENGTH); +} + +static inline void MBPadBottomRightLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, + const int32_t& kiPicH) { + uint8_t* pDstLastLine = pDst + (kiPicH - 1) * kiStride + kiPicW; + const uint8_t kuiBR = pDstLastLine[-1]; + int32_t i = 0; + uint8_t* pBottom = pDstLastLine; + do { + pBottom += kiStride; + // pad pBottom + memcpy (pBottom - 16, pDstLastLine - 16, 16); // confirmed_safe_unsafe_usage + memset (pBottom, kuiBR, PADDING_LENGTH); //pBottom Right + } while (++i < PADDING_LENGTH); +} + +static inline void MBPadLeftLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbY) { + uint8_t* pTmp = pDst + (kiMbY << 4) * kiStride; + for (int32_t i = 0; i < 16; ++i) { + // pad left + memset (pTmp - PADDING_LENGTH, pTmp[0], PADDING_LENGTH); + pTmp += kiStride; + } +} + +static inline void MBPadRightLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbY, + const int32_t& kiPicW) { + uint8_t* pTmp = pDst + (kiMbY << 4) * kiStride + kiPicW; + for (int32_t i = 0; i < 16; ++i) { + // pad right + memset (pTmp, pTmp[-1], PADDING_LENGTH); + pTmp += kiStride; + } +} + +static inline void MBPadTopChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbX) { + uint8_t* pTopLine = pDst + (kiMbX << 3); + int32_t i = 0; + uint8_t* pTop = pTopLine; + do { + pTop -= kiStride; + // pad pTop + memcpy (pTop, pTopLine, 8); // confirmed_safe_unsafe_usage + } while (++i < CHROMA_PADDING_LENGTH); +} + +static inline void MBPadBottomChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbX, + const int32_t& kiPicH) { + uint8_t* pBottomLine = pDst + (kiPicH - 1) * kiStride + (kiMbX << 3); + int32_t i = 0; + uint8_t* pBottom = pBottomLine; + do { + pBottom += kiStride; + // pad pBottom + memcpy (pBottom, pBottomLine, 8); // confirmed_safe_unsafe_usage + } while (++i < CHROMA_PADDING_LENGTH); +} + +static inline void MBPadTopLeftChroma_c (uint8_t*& pDst, const int32_t& kiStride) { + const uint8_t kuiTL = pDst[0]; + int32_t i = 0; + uint8_t* pTopLeft = pDst; + do { + pTopLeft -= kiStride; + // pad pTop + memcpy (pTopLeft, pDst, 8); // confirmed_safe_unsafe_usage + memset (pTopLeft - CHROMA_PADDING_LENGTH, kuiTL, CHROMA_PADDING_LENGTH); //pTop left + } while (++i < CHROMA_PADDING_LENGTH); +} + +static inline void MBPadTopRightChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW) { + uint8_t* pTopRight = pDst + kiPicW; + const uint8_t kuiTR = pTopRight[-1]; + int32_t i = 0; + uint8_t* pTop = pTopRight; + do { + pTop -= kiStride; + // pad pTop + memcpy (pTop - 8, pTopRight - 8, 8); // confirmed_safe_unsafe_usage + memset (pTop, kuiTR, CHROMA_PADDING_LENGTH); //pTop Right + } while (++i < CHROMA_PADDING_LENGTH); +} + +static inline void MBPadBottomLeftChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicH) { + uint8_t* pDstLastLine = pDst + (kiPicH - 1) * kiStride; + const uint8_t kuiBL = pDstLastLine[0]; + int32_t i = 0; + uint8_t* pBottom = pDstLastLine; + do { + pBottom += kiStride; + // pad pBottom + memcpy (pBottom, pDstLastLine, 8); // confirmed_safe_unsafe_usage + memset (pBottom - CHROMA_PADDING_LENGTH, kuiBL, CHROMA_PADDING_LENGTH); //pBottom left + } while (++i < CHROMA_PADDING_LENGTH); +} + +static inline void MBPadBottomRightChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, + const int32_t kiPicH) { + uint8_t* pDstLastLine = pDst + (kiPicH - 1) * kiStride + kiPicW; + const uint8_t kuiBR = pDstLastLine[-1]; + int32_t i = 0; + uint8_t* pBottom = pDstLastLine; + do { + pBottom += kiStride; + // pad pBottom + memcpy (pBottom - 8, pDstLastLine - 8, 8); // confirmed_safe_unsafe_usage + memset (pBottom, kuiBR, CHROMA_PADDING_LENGTH); //pBottom Right + } while (++i < CHROMA_PADDING_LENGTH); +} + +static inline void MBPadLeftChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbY) { + uint8_t* pTmp = pDst + (kiMbY << 3) * kiStride; + for (int32_t i = 0; i < 8; ++i) { + // pad left + memset (pTmp - CHROMA_PADDING_LENGTH, pTmp[0], CHROMA_PADDING_LENGTH); + pTmp += kiStride; + } +} + +static inline void MBPadRightChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbY, + const int32_t& kiPicW) { + uint8_t* pTmp = pDst + (kiMbY << 3) * kiStride + kiPicW; + for (int32_t i = 0; i < 8; ++i) { + // pad right + memset (pTmp, pTmp[-1], CHROMA_PADDING_LENGTH); + pTmp += kiStride; + } +} + +void PadMBLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, const int32_t& kiPicH, + const int32_t& kiMbX, const int32_t& kiMbY, const int32_t& kiMBWidth, const int32_t& kiMBHeight) { + if (kiMbX == 0 && kiMbY == 0) { + MBPadTopLeftLuma_c (pDst, kiStride); + } else if (kiMbY == 0 && kiMbX == kiMBWidth - 1) { + MBPadTopRightLuma_c (pDst, kiStride, kiPicW); + } else if (kiMbY == kiMBHeight - 1 && kiMbX == 0) { + MBPadBottomLeftLuma_c (pDst, kiStride, kiPicH); + } else if (kiMbY == kiMBHeight - 1 && kiMbX == kiMBWidth - 1) { + MBPadBottomRightLuma_c (pDst, kiStride, kiPicW, kiPicH); + } + if (kiMbX == 0) { + MBPadLeftLuma_c (pDst, kiStride, kiMbY); + } else if (kiMbX == kiMBWidth - 1) { + MBPadRightLuma_c (pDst, kiStride, kiMbY, kiPicW); + } + if (kiMbY == 0 && kiMbX > 0 && kiMbX < kiMBWidth - 1) { + MBPadTopLuma_c (pDst, kiStride, kiMbX); + } else if (kiMbY == kiMBHeight - 1 && kiMbX > 0 && kiMbX < kiMBWidth - 1) { + MBPadBottomLuma_c (pDst, kiStride, kiMbX, kiPicH); + } +} + +void PadMBChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, const int32_t& kiPicH, + const int32_t& kiMbX, const int32_t& kiMbY, const int32_t& kiMBWidth, const int32_t& kiMBHeight) { + if (kiMbX == 0 && kiMbY == 0) { + MBPadTopLeftChroma_c (pDst, kiStride); + } else if (kiMbY == 0 && kiMbX == kiMBWidth - 1) { + MBPadTopRightChroma_c (pDst, kiStride, kiPicW); + } else if (kiMbY == kiMBHeight - 1 && kiMbX == 0) { + MBPadBottomLeftChroma_c (pDst, kiStride, kiPicH); + } else if (kiMbY == kiMBHeight - 1 && kiMbX == kiMBWidth - 1) { + MBPadBottomRightChroma_c (pDst, kiStride, kiPicW, kiPicH); + } + if (kiMbX == 0) { + MBPadLeftChroma_c (pDst, kiStride, kiMbY); + } else if (kiMbX == kiMBWidth - 1) { + MBPadRightChroma_c (pDst, kiStride, kiMbY, kiPicW); + } + if (kiMbY == 0 && kiMbX > 0 && kiMbX < kiMBWidth - 1) { + MBPadTopChroma_c (pDst, kiStride, kiMbX); + } else if (kiMbY == kiMBHeight - 1 && kiMbX > 0 && kiMbX < kiMBWidth - 1) { + MBPadBottomChroma_c (pDst, kiStride, kiMbX, kiPicH); + } +} + // rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009 static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH) { diff --git a/src/openh264/codec/common/src/intra_pred_common.cpp b/src/openh264/codec/common/src/intra_pred_common.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/mc.cpp b/src/openh264/codec/common/src/mc.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/memory_align.cpp b/src/openh264/codec/common/src/memory_align.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/sad_common.cpp b/src/openh264/codec/common/src/sad_common.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/utils.cpp b/src/openh264/codec/common/src/utils.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/src/welsCodecTrace.cpp b/src/openh264/codec/common/src/welsCodecTrace.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/targets.mk b/src/openh264/codec/common/targets.mk old mode 100755 new mode 100644 index 96843cd9d..f2cd192fd --- a/src/openh264/codec/common/targets.mk +++ b/src/openh264/codec/common/targets.mk @@ -66,18 +66,28 @@ COMMON_OBJS += $(COMMON_OBJSARM64) endif OBJS += $(COMMON_OBJSARM64) -COMMON_ASM_MIPS_SRCS=\ +COMMON_ASM_MIPS_MMI_SRCS=\ $(COMMON_SRCDIR)/mips/copy_mb_mmi.c\ $(COMMON_SRCDIR)/mips/deblock_mmi.c\ $(COMMON_SRCDIR)/mips/expand_picture_mmi.c\ $(COMMON_SRCDIR)/mips/intra_pred_com_mmi.c\ $(COMMON_SRCDIR)/mips/satd_sad_mmi.c\ -COMMON_OBJSMIPS += $(COMMON_ASM_MIPS_SRCS:.c=.$(OBJ)) +COMMON_OBJSMIPS_MMI += $(COMMON_ASM_MIPS_MMI_SRCS:.c=.$(OBJ)) + +COMMON_ASM_MIPS_MSA_SRCS=\ + +COMMON_OBJSMIPS_MSA += $(COMMON_ASM_MIPS_MSA_SRCS:.c=.$(OBJ)) ifeq ($(ASM_ARCH), mips) -COMMON_OBJS += $(COMMON_OBJSMIPS) +ifeq ($(ENABLE_MMI), Yes) +COMMON_OBJS += $(COMMON_OBJSMIPS_MMI) endif -OBJS += $(COMMON_OBJSMIPS) +ifeq ($(ENABLE_MSA), Yes) +COMMON_OBJS += $(COMMON_OBJSMIPS_MSA) +endif +endif +OBJS += $(COMMON_OBJSMIPS_MMI) +OBJS += $(COMMON_OBJSMIPS_MSA) OBJS += $(COMMON_OBJS) diff --git a/src/openh264/codec/common/x86/asm_inc.asm b/src/openh264/codec/common/x86/asm_inc.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/cpuid.asm b/src/openh264/codec/common/x86/cpuid.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/dct.asm b/src/openh264/codec/common/x86/dct.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/deblock.asm b/src/openh264/codec/common/x86/deblock.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/expand_picture.asm b/src/openh264/codec/common/x86/expand_picture.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/intra_pred_com.asm b/src/openh264/codec/common/x86/intra_pred_com.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/mb_copy.asm b/src/openh264/codec/common/x86/mb_copy.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/mc_chroma.asm b/src/openh264/codec/common/x86/mc_chroma.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/mc_luma.asm b/src/openh264/codec/common/x86/mc_luma.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/satd_sad.asm b/src/openh264/codec/common/x86/satd_sad.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/common/x86/vaa.asm b/src/openh264/codec/common/x86/vaa.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/common/inc/read_config.h b/src/openh264/codec/console/common/inc/read_config.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/common/meson.build b/src/openh264/codec/console/common/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/common/src/read_config.cpp b/src/openh264/codec/console/common/src/read_config.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/common/targets.mk b/src/openh264/codec/console/common/targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/dec/inc/d3d9_utils.h b/src/openh264/codec/console/dec/inc/d3d9_utils.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/dec/meson.build b/src/openh264/codec/console/dec/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/dec/src/d3d9_utils.cpp b/src/openh264/codec/console/dec/src/d3d9_utils.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/dec/src/h264dec.cpp b/src/openh264/codec/console/dec/src/h264dec.cpp old mode 100755 new mode 100644 index 782854e5a..0b59ec105 --- a/src/openh264/codec/console/dec/src/h264dec.cpp +++ b/src/openh264/codec/console/dec/src/h264dec.cpp @@ -52,7 +52,6 @@ #include "measure_time.h" #include "d3d9_utils.h" - using namespace std; #if defined (WINDOWS_PHONE) @@ -69,6 +68,105 @@ int g_iDecodedFrameNum = 0; #endif //using namespace WelsDec; +int32_t readPicture (uint8_t* pBuf, const int32_t& iFileSize, const int32_t& bufPos, uint8_t*& pSpsBuf, + int32_t& sps_byte_count) { + int32_t bytes_available = iFileSize - bufPos; + if (bytes_available < 4) { + return bytes_available; + } + uint8_t* ptr = pBuf + bufPos; + int32_t read_bytes = 0; + int32_t sps_count = 0; + int32_t pps_count = 0; + int32_t non_idr_pict_count = 0; + int32_t idr_pict_count = 0; + pSpsBuf = NULL; + sps_byte_count = 0; + while (read_bytes < bytes_available - 4) { + bool has4ByteStartCode = ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 1; + bool has3ByteStartCode = false; + if (!has4ByteStartCode) { + has3ByteStartCode = ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 1; + } + if (has4ByteStartCode || has3ByteStartCode) { + uint8_t nal_unit_type = has4ByteStartCode ? (ptr[4] & 0x1F) : (ptr[3] & 0x1F); + if (nal_unit_type == 1) { + if (++non_idr_pict_count == 1 && idr_pict_count == 1) { + return read_bytes; + } + if (non_idr_pict_count == 2) { + return read_bytes; + } + } else if (nal_unit_type == 5) { + if (++idr_pict_count == 1 && non_idr_pict_count == 1) { + return read_bytes; + } + if (idr_pict_count == 2) { + return read_bytes; + } + } else if (nal_unit_type == 7) { + pSpsBuf = ptr + (has4ByteStartCode ? 4 : 3); + if ((++sps_count == 1) && (non_idr_pict_count == 1 || idr_pict_count == 1)) { + return read_bytes; + } + } else if (nal_unit_type == 8) { + if (++pps_count == 1 && sps_count == 1) { + sps_byte_count = int32_t (ptr - pSpsBuf); + } + } + if (read_bytes >= bytes_available - 4) { + return bytes_available; + } + read_bytes += 4; + ptr += 4; + } else { + ++ptr; + ++read_bytes; + } + } + return bytes_available; +} + +void FlushFrames (ISVCDecoder* pDecoder, int64_t& iTotal, FILE* pYuvFile, FILE* pOptionFile, int32_t& iFrameCount, + unsigned long long& uiTimeStamp, int32_t& iWidth, int32_t& iHeight, int32_t& iLastWidth, int32_t iLastHeight) { + uint8_t* pData[3] = { NULL }; + uint8_t* pDst[3] = { NULL }; + SBufferInfo sDstBufInfo; + int32_t num_of_frames_in_buffer = 0; + CUtils cOutputModule; + pDecoder->GetOption (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER, &num_of_frames_in_buffer); + for (int32_t i = 0; i < num_of_frames_in_buffer; ++i) { + int64_t iStart = WelsTime(); + pData[0] = NULL; + pData[1] = NULL; + pData[2] = NULL; + memset (&sDstBufInfo, 0, sizeof (SBufferInfo)); + sDstBufInfo.uiInBsTimeStamp = uiTimeStamp; + pDecoder->FlushFrame (pData, &sDstBufInfo); + if (sDstBufInfo.iBufferStatus == 1) { + pDst[0] = sDstBufInfo.pDst[0]; + pDst[1] = sDstBufInfo.pDst[1]; + pDst[2] = sDstBufInfo.pDst[2]; + } + int64_t iEnd = WelsTime(); + iTotal += iEnd - iStart; + if (sDstBufInfo.iBufferStatus == 1) { + cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile); + iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth; + iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight; + if (pOptionFile != NULL) { + if (iWidth != iLastWidth && iHeight != iLastHeight) { + fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile); + fwrite (&iWidth, sizeof (iWidth), 1, pOptionFile); + fwrite (&iHeight, sizeof (iHeight), 1, pOptionFile); + iLastWidth = iWidth; + iLastHeight = iHeight; + } + } + ++iFrameCount; + } + } +} void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName, int32_t& iWidth, int32_t& iHeight, const char* pOptionFileName, const char* pLengthFileName, int32_t iErrorConMethod, @@ -95,14 +193,17 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons int32_t iBufPos = 0; int32_t iFileSize; - int32_t i = 0; int32_t iLastWidth = 0, iLastHeight = 0; int32_t iFrameCount = 0; int32_t iEndOfStreamFlag = 0; - int32_t num_of_frames_in_buffer = 0; pDecoder->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iErrorConMethod); CUtils cOutputModule; double dElapsed = 0; + uint8_t uLastSpsBuf[32]; + int32_t iLastSpsByteCount = 0; + + int32_t iThreadCount = 1; + pDecoder->GetOption (DECODER_OPTION_NUM_OF_THREADS, &iThreadCount); if (kpH264FileName) { pH264File = fopen (kpH264FileName, "rb"); @@ -181,13 +282,32 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons goto label_exit; iSliceSize = static_cast (pInfo[2]); } else { - for (i = 0; i < iFileSize; i++) { - if ((pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 0 && pBuf[iBufPos + i + 3] == 1 - && i > 0) || (pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 1 && i > 0)) { - break; + if (iThreadCount >= 1) { + uint8_t* uSpsPtr = NULL; + int32_t iSpsByteCount = 0; + iSliceSize = readPicture (pBuf, iFileSize, iBufPos, uSpsPtr, iSpsByteCount); + if (iLastSpsByteCount > 0 && iSpsByteCount > 0) { + if (iSpsByteCount != iLastSpsByteCount || memcmp (uSpsPtr, uLastSpsBuf, iLastSpsByteCount) != 0) { + //whenever new sequence is different from preceding sequence. All pending frames must be flushed out before the new sequence can start to decode. + FlushFrames (pDecoder, iTotal, pYuvFile, pOptionFile, iFrameCount, uiTimeStamp, iWidth, iHeight, iLastWidth, + iLastHeight); + } } + if (iSpsByteCount > 0 && uSpsPtr != NULL) { + if (iSpsByteCount > 32) iSpsByteCount = 32; + iLastSpsByteCount = iSpsByteCount; + memcpy (uLastSpsBuf, uSpsPtr, iSpsByteCount); + } + } else { + int i = 0; + for (i = 0; i < iFileSize; i++) { + if ((pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 0 && pBuf[iBufPos + i + 3] == 1 + && i > 0) || (pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 1 && i > 0)) { + break; + } + } + iSliceSize = i; } - iSliceSize = i; } if (iSliceSize < 4) { //too small size, no effective data, ignore iBufPos += iSliceSize; @@ -225,9 +345,9 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons } if (sDstBufInfo.iBufferStatus == 1) { - pDst[0] = pData[0]; - pDst[1] = pData[1]; - pDst[2] = pData[2]; + pDst[0] = sDstBufInfo.pDst[0]; + pDst[1] = sDstBufInfo.pDst[1]; + pDst[2] = sDstBufInfo.pDst[2]; } iEnd = WelsTime(); iTotal += iEnd - iStart; @@ -257,9 +377,9 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons sDstBufInfo.uiInBsTimeStamp = uiTimeStamp; pDecoder->DecodeFrame2 (NULL, 0, pData, &sDstBufInfo); if (sDstBufInfo.iBufferStatus == 1) { - pDst[0] = pData[0]; - pDst[1] = pData[1]; - pDst[2] = pData[2]; + pDst[0] = sDstBufInfo.pDst[0]; + pDst[1] = sDstBufInfo.pDst[1]; + pDst[2] = sDstBufInfo.pDst[2]; } iEnd = WelsTime(); iTotal += iEnd - iStart; @@ -283,41 +403,8 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons iBufPos += iSliceSize; ++ iSliceIndex; } - - pDecoder->GetOption (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER, &num_of_frames_in_buffer); - for (int32_t i = 0; i < num_of_frames_in_buffer; ++i) { - iStart = WelsTime(); - pData[0] = NULL; - pData[1] = NULL; - pData[2] = NULL; - memset (&sDstBufInfo, 0, sizeof (SBufferInfo)); - sDstBufInfo.uiInBsTimeStamp = uiTimeStamp; - sDstBufInfo.iBufferStatus = 1; - pDecoder->FlushFrame (pData, &sDstBufInfo); - if (sDstBufInfo.iBufferStatus == 1) { - pDst[0] = pData[0]; - pDst[1] = pData[1]; - pDst[2] = pData[2]; - } - iEnd = WelsTime(); - iTotal += iEnd - iStart; - if (sDstBufInfo.iBufferStatus == 1) { - cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile); - iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth; - iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight; - - if (pOptionFile != NULL) { - if (iWidth != iLastWidth && iHeight != iLastHeight) { - fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile); - fwrite (&iWidth, sizeof (iWidth), 1, pOptionFile); - fwrite (&iHeight, sizeof (iHeight), 1, pOptionFile); - iLastWidth = iWidth; - iLastHeight = iHeight; - } - } - ++iFrameCount; - } - } + FlushFrames (pDecoder, iTotal, pYuvFile, pOptionFile, iFrameCount, uiTimeStamp, iWidth, iHeight, iLastWidth, + iLastHeight); dElapsed = iTotal / 1e6; fprintf (stderr, "-------------------------------------------------------\n"); fprintf (stderr, "iWidth:\t\t%d\nheight:\t\t%d\nFrames:\t\t%d\ndecode time:\t%f sec\nFPS:\t\t%f fps\n", @@ -489,6 +576,9 @@ int32_t main (int32_t iArgC, char* pArgV[]) { pDecoder->SetOption (DECODER_OPTION_TRACE_LEVEL, &iLevelSetting); } + int32_t iThreadCount = 0; + pDecoder->SetOption (DECODER_OPTION_NUM_OF_THREADS, &iThreadCount); + if (pDecoder->Initialize (&sDecParam)) { printf ("Decoder initialization failed.\n"); return 1; diff --git a/src/openh264/codec/console/dec/targets.mk b/src/openh264/codec/console/dec/targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/enc/meson.build b/src/openh264/codec/console/enc/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/enc/src/welsenc.cpp b/src/openh264/codec/console/enc/src/welsenc.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/enc/targets.mk b/src/openh264/codec/console/enc/targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/codec/console/meson.build b/src/openh264/codec/console/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/arm/block_add_neon.S b/src/openh264/codec/decoder/core/arm/block_add_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/arm/intra_pred_neon.S b/src/openh264/codec/decoder/core/arm/intra_pred_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/arm64/block_add_aarch64_neon.S b/src/openh264/codec/decoder/core/arm64/block_add_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/arm64/intra_pred_aarch64_neon.S b/src/openh264/codec/decoder/core/arm64/intra_pred_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/au_parser.h b/src/openh264/codec/decoder/core/inc/au_parser.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/bit_stream.h b/src/openh264/codec/decoder/core/inc/bit_stream.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/cabac_decoder.h b/src/openh264/codec/decoder/core/inc/cabac_decoder.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/deblocking.h b/src/openh264/codec/decoder/core/inc/deblocking.h old mode 100755 new mode 100644 index 43cd6ce94..e84114a83 --- a/src/openh264/codec/decoder/core/inc/deblocking.h +++ b/src/openh264/codec/decoder/core/inc/deblocking.h @@ -66,6 +66,26 @@ void DeblockingInit (PDeblockingFunc pDeblockingFunc, int32_t iCpu); */ void WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb); +/*! +* \brief AVC slice init deblocking filtering target layer +* +* \in and out param SDeblockingFilter +* \in and out param iFilterIdc +* +* \return NONE +*/ +void WelsDeblockingInitFilter (PWelsDecoderContext pCtx, SDeblockingFilter& pFilter, int32_t& iFilterIdc); + +/*! +* \brief AVC MB deblocking filtering target layer +* +* \param DqLayer which has the current location of MB to be deblocked. +* +* \return NONE +*/ +void WelsDeblockingFilterMB (PDqLayer pCurDqLayer, SDeblockingFilter& pFilter, int32_t& iFilterIdc, + PDeblockingFilterMbFunc pDeblockMb); + /*! * \brief pixel deblocking filtering * @@ -77,13 +97,21 @@ void WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFun * \return NONE */ -uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy); +uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, + int32_t iNeighMb, int32_t iMbXy); uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy); int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc); void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag); +inline int8_t* GetPNzc (PDqLayer pCurDqLayer, int32_t iMbXy) { + if (pCurDqLayer->pDec != NULL && pCurDqLayer->pDec->pNzc != NULL) { + return pCurDqLayer->pDec->pNzc[iMbXy]; + } + return pCurDqLayer->pNzc[iMbXy]; +} + } // namespace WelsDec #endif //WELS_DEBLOCKING_H__ diff --git a/src/openh264/codec/decoder/core/inc/dec_frame.h b/src/openh264/codec/decoder/core/inc/dec_frame.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/dec_golomb.h b/src/openh264/codec/decoder/core/inc/dec_golomb.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/decode_mb_aux.h b/src/openh264/codec/decoder/core/inc/decode_mb_aux.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/decode_slice.h b/src/openh264/codec/decoder/core/inc/decode_slice.h old mode 100755 new mode 100644 index 4f21709c8..f7197abbf --- a/src/openh264/codec/decoder/core/inc/decode_slice.h +++ b/src/openh264/codec/decoder/core/inc/decode_slice.h @@ -58,15 +58,16 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx); //construction based on slice int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNalUnit pNalCur); +int32_t WelsDecodeAndConstructSlice (PWelsDecoderContext pCtx); int32_t WelsTargetMbConstruction (PWelsDecoderContext pCtx); -int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer, bool bOutput); -int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer, +int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer, bool bOutput); +int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer, uint8_t* pDstY, uint8_t* pDstU, uint8_t* pDstV, int32_t iStrideL, int32_t iStrideC); -int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer); +int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer); void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp, PWelsDecoderContext pCtx); -int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer); +int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer); void WelsChromaDcIdct (int16_t* pBlock); bool ComputeColocatedTemporalScaling (PWelsDecoderContext pCtx); diff --git a/src/openh264/codec/decoder/core/inc/decoder.h b/src/openh264/codec/decoder/core/inc/decoder.h old mode 100755 new mode 100644 index 3cc514faa..0c84739d5 --- a/src/openh264/codec/decoder/core/inc/decoder.h +++ b/src/openh264/codec/decoder/core/inc/decoder.h @@ -59,6 +59,21 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa */ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx); +/* +* fill last decoded picture info +*/ +void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo); + +/*! +* \brief fill data fields in SPS and PPS default for decoder context +*/ +void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx); + +/*! +* \brief copy SpsPps from one Ctx to another ctx for threaded code +*/ +void CopySpsPps (PWelsDecoderContext pFromCtx, PWelsDecoderContext pToCtx); + /*! ************************************************************************************* * \brief Initialize Wels decoder parameters and memory @@ -157,7 +172,11 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx); //update decoder statistics information void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput); //Destroy picutre buffer -void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa); +void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa); +//reset picture reodering buffer list +void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo, + const bool& bFullReset); + #ifdef __cplusplus } #endif//__cplusplus diff --git a/src/openh264/codec/decoder/core/inc/decoder_context.h b/src/openh264/codec/decoder/core/inc/decoder_context.h old mode 100755 new mode 100644 index adc51632c..2ad2aeda2 --- a/src/openh264/codec/decoder/core/inc/decoder_context.h +++ b/src/openh264/codec/decoder/core/inc/decoder_context.h @@ -56,6 +56,7 @@ #include "expand_pic.h" #include "mc.h" #include "memory_align.h" +#include "wels_decoder_thread.h" namespace WelsDec { #define MAX_PRED_MODE_ID_I16x16 3 @@ -64,6 +65,7 @@ namespace WelsDec { #define WELS_QP_MAX 51 #define LONG_TERM_REF +#define IMinInt32 -0x7FFFFFFF typedef struct SWels_Cabac_Element { uint8_t uiState; uint8_t uiMPS; @@ -172,7 +174,7 @@ typedef struct tagDeblockingFilter { int8_t iChromaQP[2]; int8_t iLumaQP; struct TagDeblockingFunc* pLoopf; - PPicture *pRefPics[LIST_A]; + PPicture* pRefPics[LIST_A]; } SDeblockingFilter, *PDeblockingFilter; typedef void (*PDeblockingFilterMbFunc) (PDqLayer pCurDqLayer, PDeblockingFilter filter, int32_t boundry_flag); @@ -215,7 +217,7 @@ typedef struct TagBlockFunc { } SBlockFunc; typedef void (*PWelsFillNeighborMbInfoIntra4x4Func) (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, - int8_t* pIntraPredMode, PDqLayer pCurLayer); + int8_t* pIntraPredMode, PDqLayer pCurDqLayer); typedef void (*PWelsMapNeighToSample) (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail); typedef void (*PWelsMap16NeighToSample) (PWelsNeighAvail pNeighAvail, uint8_t* pSampleAvail); typedef int32_t (*PWelsParseIntra4x4ModeFunc) (PWelsNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs, @@ -229,6 +231,72 @@ enum { OVERWRITE_SUBSETSPS = 1 << 2 }; + +//Decoder SPS and PPS global CTX +typedef struct tagWelsWelsDecoderSpsPpsCTX { + SPosOffset sFrameCrop; + + SSps sSpsBuffer[MAX_SPS_COUNT + 1]; + SPps sPpsBuffer[MAX_PPS_COUNT + 1]; + + SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1]; + SNalUnit sPrefixNal; + + PSps pActiveLayerSps[MAX_LAYER_NUM]; + bool bAvcBasedFlag; // For decoding bitstream: + + // for EC parameter sets + bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence? + bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence? + bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence? + + int32_t iSpsErrorIgnored; + int32_t iSubSpsErrorIgnored; + int32_t iPpsErrorIgnored; + + bool bSpsAvailFlags[MAX_SPS_COUNT]; + bool bSubspsAvailFlags[MAX_SPS_COUNT]; + bool bPpsAvailFlags[MAX_PPS_COUNT]; + int32_t iPPSLastInvalidId; + int32_t iPPSInvalidNum; + int32_t iSPSLastInvalidId; + int32_t iSPSInvalidNum; + int32_t iSubSPSLastInvalidId; + int32_t iSubSPSInvalidNum; + int32_t iSeqId; //sequence id + int iOverwriteFlags; +} SWelsDecoderSpsPpsCTX, *PWelsDecoderSpsPpsCTX; + +//Last Decoded Picture Info +typedef struct tagSWelsLastDecPicInfo { + // Save the last nal header info + SNalUnitHeaderExt sLastNalHdrExt; + SSliceHeader sLastSliceHeader; + int32_t iPrevPicOrderCntMsb; + int32_t iPrevPicOrderCntLsb; + PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment + int32_t iPrevFrameNum;// frame number of previous frame well decoded for non-truncated mode yet + bool bLastHasMmco5; + uint32_t uiDecodingTimeStamp; //represent relative decoding time stamps +} SWelsLastDecPicInfo, *PWelsLastDecPicInfo; + +typedef struct tagPictInfo { + SBufferInfo sBufferInfo; + int32_t iPOC; + int32_t iPicBuffIdx; + uint32_t uiDecodingTimeStamp; + bool bLastGOP; +} SPictInfo, *PPictInfo; + +typedef struct tagPictReoderingStatus { + int32_t iPictInfoIndex; + int32_t iMinPOC; + int32_t iNumOfPicts; + int32_t iLastGOPRemainPicts; + int32_t iLastWrittenPOC; + int32_t iLargestBufferedPicIndex; +} SPictReoderingStatus, *PPictReoderingStatus; + /* * SWelsDecoderContext: to maintail all modules data over decoder@framework */ @@ -263,9 +331,6 @@ typedef struct TagWelsDecoderContext { EWelsSliceType eSliceType; // Slice type bool bUsedAsRef; //flag as ref int32_t iFrameNum; - int32_t - iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet - bool bLastHasMmco5; // int32_t iErrorCode; // error code return while decoding in case packets lost SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage PFmo pFmo; // current fmo context after parsed slice_header @@ -305,6 +370,7 @@ typedef struct TagWelsDecoderContext { uint32_t iMbHeight; } sMb; + // reconstruction picture PPicture pDec; //pointer to current picture being reconstructed @@ -313,65 +379,44 @@ typedef struct TagWelsDecoderContext { // reference pictures SRefPic sRefPic; - - SVlcTable sVlcTable; // vlc table + SRefPic sTmpRefPic; //used to temporarily save RefPic for next active thread + SVlcTable* pVlcTable; // vlc table SBitStringAux sBs; int32_t iMaxBsBufferSizeInByte; //actual memory size for BS buffer /* Global memory external */ + SWelsDecoderSpsPpsCTX sSpsPpsCtx; + bool bHasNewSps; SPosOffset sFrameCrop; - SSps sSpsBuffer[MAX_SPS_COUNT + 1]; - SPps sPpsBuffer[MAX_PPS_COUNT + 1]; PSliceHeader pSliceHeader; PPicBuff pPicBuff; // Initially allocated memory for pictures which are used in decoding. int32_t iPicQueueNumber; - SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1]; - SNalUnit sPrefixNal; - PAccessUnit pAccessUnitList; // current access unit list to be performed - PSps pActiveLayerSps[MAX_LAYER_NUM]; + //PSps pActiveLayerSps[MAX_LAYER_NUM]; PSps pSps; // used by current AU PPps pPps; // used by current AU // Memory for pAccessUnitList is dynamically held till decoder destruction. PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated - + PNalUnit pNalCur; // point to current NAL Nnit + uint8_t uiNalRefIdc; // NalRefIdc for easy access; int32_t iPicWidthReq; // picture width have requested the memory int32_t iPicHeightReq; // picture height have requested the memory uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID - bool bAvcBasedFlag; // For decoding bitstream: + //bool bAvcBasedFlag; // For decoding bitstream: bool bEndOfStreamFlag; // Flag on end of stream requested by external application layer bool bInstantDecFlag; // Flag for no-delay decoding bool bInitialDqLayersMem; // dq layers related memory is available? bool bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1 -// for EC parameter sets - bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence? - bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence? - bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence? - - int32_t iSpsErrorIgnored; - int32_t iSubSpsErrorIgnored; - int32_t iPpsErrorIgnored; - - bool bSpsAvailFlags[MAX_SPS_COUNT]; - bool bSubspsAvailFlags[MAX_SPS_COUNT]; - bool bPpsAvailFlags[MAX_PPS_COUNT]; - int32_t iPPSLastInvalidId; - int32_t iPPSInvalidNum; - int32_t iSPSLastInvalidId; - int32_t iSPSInvalidNum; - int32_t iSubSPSLastInvalidId; - int32_t iSubSPSInvalidNum; - bool bReferenceLostAtT0Flag; int32_t iTotalNumMbRec; //record current number of decoded MB #ifdef LONG_TERM_REF @@ -385,7 +430,6 @@ typedef struct TagWelsDecoderContext { #endif bool bNewSeqBegin; bool bNextNewSeqBegin; - int iOverwriteFlags; //for Parse only bool bFramePending; @@ -397,7 +441,7 @@ typedef struct TagWelsDecoderContext { SPpsBsInfo sPpsBsInfo [MAX_PPS_COUNT]; SParserBsInfo* pParserBsInfo; - PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment + //PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16; PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t @@ -437,18 +481,14 @@ typedef struct TagWelsDecoderContext { //trace handle void* pTraceHandle; -//Save the last nal header info - SNalUnitHeaderExt sLastNalHdrExt; - SSliceHeader sLastSliceHeader; - int32_t iPrevPicOrderCntMsb; - int32_t iPrevPicOrderCntLsb; + PWelsLastDecPicInfo pLastDecPicInfo; SWelsCabacCtx sWelsCabacContexts[4][WELS_QP_MAX + 1][WELS_CONTEXT_COUNT]; bool bCabacInited; SWelsCabacCtx pCabacCtx[WELS_CONTEXT_COUNT]; PWelsCabacDecEngine pCabacDecEngine; double dDecTime; - SDecoderStatistics sDecoderStatistics;// For real time debugging + SDecoderStatistics* pDecoderStatistics; // For real time debugging int32_t iMbEcedNum; int32_t iMbEcedPropNum; int32_t iMbNum; @@ -457,6 +497,7 @@ typedef struct TagWelsDecoderContext { int32_t iECMVs[16][2]; PPicture pECRefPic[16]; unsigned long long uiTimeStamp; + uint32_t uiDecodingTimeStamp; //represent relative decoding time stamps // To support scaling list HP uint16_t pDequant_coeff_buffer4x4[6][52][16]; uint16_t pDequant_coeff_buffer8x8[6][52][64]; @@ -466,15 +507,56 @@ typedef struct TagWelsDecoderContext { bool bDequantCoeff4x4Init; bool bUseScalingList; CMemoryAlign* pMemAlign; + void* pThreadCtx; + void* pLastThreadCtx; + WELS_MUTEX* pCsDecoder; + int16_t lastReadyHeightOffset[LIST_A][MAX_REF_PIC_COUNT]; //last ready reference MB offset + PPictInfo pPictInfoList; + PPictReoderingStatus pPictReoderingStatus; } SWelsDecoderContext, *PWelsDecoderContext; +typedef struct tagSWelsDecThread { + SWelsDecSemphore* sIsBusy; + SWelsDecSemphore sIsActivated; + SWelsDecSemphore sIsIdle; + SWelsDecThread sThrHandle; + uint32_t uiCommand; + uint32_t uiThrNum; + uint32_t uiThrMaxNum; + uint32_t uiThrStackSize; + DECLARE_PROCTHREAD_PTR (pThrProcMain); +} SWelsDecThreadInfo, *PWelsDecThreadInfo; + +typedef struct tagSWelsDecThreadCtx { + SWelsDecThreadInfo sThreadInfo; + PWelsDecoderContext pCtx; + void* threadCtxOwner; + uint8_t* kpSrc; + int32_t kiSrcLen; + uint8_t** ppDst; + SBufferInfo sDstInfo; + PPicture pDec; + SWelsDecEvent sImageReady; + SWelsDecEvent sSliceDecodeStart; + SWelsDecEvent sSliceDecodeFinish; + int32_t iPicBuffIdx; //picBuff Index +} SWelsDecoderThreadCTX, *PWelsDecoderThreadCTX; + static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) { if (pCtx->iTotalNumMbRec == 0) { for (int i = 0; i < MAX_LAYER_NUM; i++) { - pCtx->pActiveLayerSps[i] = NULL; + pCtx->sSpsPpsCtx.pActiveLayerSps[i] = NULL; } } } +static inline int32_t GetThreadCount (PWelsDecoderContext pCtx) { + int32_t iThreadCount = 0; + if (pCtx->pThreadCtx != NULL) { + PWelsDecoderThreadCTX pThreadCtx = (PWelsDecoderThreadCTX)pCtx->pThreadCtx; + iThreadCount = pThreadCtx->sThreadInfo.uiThrMaxNum; + } + return iThreadCount; +} //#ifdef __cplusplus //} //#endif//__cplusplus diff --git a/src/openh264/codec/decoder/core/inc/decoder_core.h b/src/openh264/codec/decoder/core/inc/decoder_core.h old mode 100755 new mode 100644 index 41cd1d6a9..df2533996 --- a/src/openh264/codec/decoder/core/inc/decoder_core.h +++ b/src/openh264/codec/decoder/core/inc/decoder_core.h @@ -129,6 +129,34 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co */ bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kpDst, PNalUnit const kpSrc); +/* +* WelsDecodeInitAccessUnitStart +* check and (re)allocate picture buffers on new sequence begin +* bit_len: size in bit length of data +* buf_len: size in byte length of data +* coded_au: mark an Access Unit decoding finished +* return: +* 0 - success; otherwise returned error_no defined in error_no.h +*/ +int32_t WelsDecodeInitAccessUnitStart (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo); +/* +* AllocPicBuffOnNewSeqBegin +* check and (re)allocate picture buffers on new sequence begin +* return: +* 0 - success; otherwise returned error_no defined in error_no.h +*/ +int32_t AllocPicBuffOnNewSeqBegin (PWelsDecoderContext pCtx); + +/* +* InitConstructAccessUnit +* Init before constructing an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to +* joint a collective access unit. +* parameter\ +* SBufferInfo: Buffer info +* return: +* 0 - success; otherwise returned error_no defined in error_no.h +*/ +int32_t InitConstructAccessUnit (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo); /* * ConstructAccessUnit diff --git a/src/openh264/codec/decoder/core/inc/error_code.h b/src/openh264/codec/decoder/core/inc/error_code.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/error_concealment.h b/src/openh264/codec/decoder/core/inc/error_concealment.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/fmo.h b/src/openh264/codec/decoder/core/inc/fmo.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/get_intra_predictor.h b/src/openh264/codec/decoder/core/inc/get_intra_predictor.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/manage_dec_ref.h b/src/openh264/codec/decoder/core/inc/manage_dec_ref.h old mode 100755 new mode 100644 index 7be76f291..164ae15d6 --- a/src/openh264/codec/decoder/core/inc/manage_dec_ref.h +++ b/src/openh264/codec/decoder/core/inc/manage_dec_ref.h @@ -48,11 +48,12 @@ namespace WelsDec { void WelsResetRefPic (PWelsDecoderContext pCtx); +void WelsResetRefPicWithoutUnRef (PWelsDecoderContext pCtx); int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc); int32_t WelsInitBSliceRefList (PWelsDecoderContext pCtx, int32_t iPoc); int32_t WelsReorderRefList (PWelsDecoderContext pCtx); int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx); -int32_t WelsMarkAsRef (PWelsDecoderContext pCtx); +int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, PPicture pLastDec = NULL); } // namespace WelsDec diff --git a/src/openh264/codec/decoder/core/inc/mb_cache.h b/src/openh264/codec/decoder/core/inc/mb_cache.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/memmgr_nal_unit.h b/src/openh264/codec/decoder/core/inc/memmgr_nal_unit.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/mv_pred.h b/src/openh264/codec/decoder/core/inc/mv_pred.h old mode 100755 new mode 100644 index 44b121e8b..bdbc7cd20 --- a/src/openh264/codec/decoder/core/inc/mv_pred.h +++ b/src/openh264/codec/decoder/core/inc/mv_pred.h @@ -91,7 +91,7 @@ void UpdateP8x16MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][ * \param * \param output iMvp[] */ -void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]); +void PredPSkipMvFromNeighbor (PDqLayer pCurDqLayer, int16_t iMvp[2]); /*! * \brief get the motion predictor and reference for B-slice direct mode version 2 @@ -149,7 +149,7 @@ void PredInter8x16Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[ * \param * \param output motion vector cache and motion vector deviation cache */ -void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW, +void FillSpatialDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW, const SubMbType& subMbType, const bool& bIsLongRef, int16_t pMvDirect[LIST_A][2], int8_t iRef[LIST_A], int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]); @@ -158,7 +158,8 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int * \param * \param output motion vector cache and motion vector deviation cache */ -void FillTemporalDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW, +void FillTemporalDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount, + const int8_t& iPartW, const SubMbType& subMbType, int8_t iRef[LIST_A], int16_t (*mvColoc)[2], int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]); @@ -177,6 +178,14 @@ int8_t MapColToList0 (PWelsDecoderContext& pCtx, const int8_t& colocRefIndexL0, */ void Update8x8RefIdx (PDqLayer& pCurDqLayer, const int16_t& iPartIdx, const int32_t& listIdx, const int8_t& iRef); +inline uint32_t* GetMbType (PDqLayer& pCurDqLayer) { + if (pCurDqLayer->pDec != NULL) { + return pCurDqLayer->pDec->pMbType; + } else { + return pCurDqLayer->pMbType; + } +} + } // namespace WelsDec #endif//WELS_MV_PRED_H__ diff --git a/src/openh264/codec/decoder/core/inc/nal_prefix.h b/src/openh264/codec/decoder/core/inc/nal_prefix.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/nalu.h b/src/openh264/codec/decoder/core/inc/nalu.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/parameter_sets.h b/src/openh264/codec/decoder/core/inc/parameter_sets.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/parse_mb_syn_cabac.h b/src/openh264/codec/decoder/core/inc/parse_mb_syn_cabac.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/parse_mb_syn_cavlc.h b/src/openh264/codec/decoder/core/inc/parse_mb_syn_cavlc.h old mode 100755 new mode 100644 index c0fa53a35..d04855164 --- a/src/openh264/codec/decoder/core/inc/parse_mb_syn_cavlc.h +++ b/src/openh264/codec/decoder/core/inc/parse_mb_syn_cavlc.h @@ -51,18 +51,18 @@ namespace WelsDec { -void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer); -void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurLayer); +void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurDqLayer); +void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurDqLayer); void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, - PDqLayer pCurLayer); + PDqLayer pCurDqLayer); void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, - PDqLayer pCurLayer); + PDqLayer pCurDqLayer); void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int16_t iMvArray[LIST_A][30][MV_A], int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], - PDqLayer pCurLayer); -void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurLayer); + PDqLayer pCurDqLayer); +void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurDqLayer); void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, - int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer); + int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurDqLayer); /*! * \brief check iPredMode for intra16x16 eligible or not diff --git a/src/openh264/codec/decoder/core/inc/pic_queue.h b/src/openh264/codec/decoder/core/inc/pic_queue.h old mode 100755 new mode 100644 index 7e7e17ff9..473f80ff1 --- a/src/openh264/codec/decoder/core/inc/pic_queue.h +++ b/src/openh264/codec/decoder/core/inc/pic_queue.h @@ -53,6 +53,9 @@ typedef struct TagPicBuff { */ PPicture PrefetchPic (PPicBuff pPicBuff); // To get current node applicable +PPicture PrefetchPicForThread (PPicBuff pPicBuff); // To get current node applicable in the case of threaded mode +PPicture PrefetchLastPicForThread (PPicBuff pPicBuff, + const int32_t& iLast); // To get last node applicable in the case of threaded mode } // namespace WelsDec diff --git a/src/openh264/codec/decoder/core/inc/picture.h b/src/openh264/codec/decoder/core/inc/picture.h old mode 100755 new mode 100644 index 46bdd3b36..bdacc364c --- a/src/openh264/codec/decoder/core/inc/picture.h +++ b/src/openh264/codec/decoder/core/inc/picture.h @@ -37,6 +37,7 @@ #include "typedefs.h" #include "wels_common_defs.h" #include "wels_const_common.h" +#include "wels_decoder_thread.h" using namespace WelsCommon; @@ -68,8 +69,7 @@ struct SPicture { /*******************************sef_definition for misc use****************************/ bool bUsedAsRef; //for ref pic management bool bIsLongRef; // long term reference frame flag //for ref pic management - uint8_t uiRefCount; - bool bAvailableFlag; // indicate whether it is available in this picture memory block. + int8_t iRefCount; bool bIsComplete; // indicate whether current picture is complete, not from EC /*******************************for future use****************************/ @@ -85,15 +85,22 @@ struct SPicture { int32_t iSpsId; //against mosaic caused by cross-IDR interval reference. int32_t iPpsId; unsigned long long uiTimeStamp; + uint32_t uiDecodingTimeStamp; //represent relative decoding time stamps + int32_t iPicBuffIdx; + EWelsSliceType eSliceType; + bool bIsUngroupedMultiSlice; //multi-slice picture with each each slice group contains one slice. bool bNewSeqBegin; int32_t iMbEcedNum; int32_t iMbEcedPropNum; int32_t iMbNum; + bool* pMbCorrectlyDecodedFlag; + int8_t (*pNzc)[24]; uint32_t* pMbType; // mb type used for direct mode int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; // used for direct mode int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM]; //used for direct mode struct SPicture* pRefPic[LIST_A][17]; //ref pictures used for direct mode + SWelsDecEvent* pReadyEvent; //MB line ready event };// "Picture" declaration is comflict with Mac system diff --git a/src/openh264/codec/decoder/core/inc/rec_mb.h b/src/openh264/codec/decoder/core/inc/rec_mb.h old mode 100755 new mode 100644 index a976620bb..be0c4a740 --- a/src/openh264/codec/decoder/core/inc/rec_mb.h +++ b/src/openh264/codec/decoder/core/inc/rec_mb.h @@ -74,10 +74,11 @@ typedef struct TagMCRefMember { int32_t iPicHeight; } sMCRefMember; -void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc, +void BaseMC (PWelsDecoderContext pCtx, sMCRefMember* pMCRefMem, const int32_t& listIdx, const int8_t& iRefIdx, + int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc, int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]); -void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurLayer); +void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurDqLayer); int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer); diff --git a/src/openh264/codec/decoder/core/inc/slice.h b/src/openh264/codec/decoder/core/inc/slice.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/vlc_decoder.h b/src/openh264/codec/decoder/core/inc/vlc_decoder.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/wels_common_basis.h b/src/openh264/codec/decoder/core/inc/wels_common_basis.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/wels_const.h b/src/openh264/codec/decoder/core/inc/wels_const.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/inc/wels_decoder_thread.h b/src/openh264/codec/decoder/core/inc/wels_decoder_thread.h new file mode 100644 index 000000000..ebb8015c9 --- /dev/null +++ b/src/openh264/codec/decoder/core/inc/wels_decoder_thread.h @@ -0,0 +1,170 @@ +/*! + * \copy + * Copyright (c) 2009-2019, Cisco Systems + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * \file wels_decoder_thread.h + * + * \brief Interfaces introduced in thread programming + * + * \date 08/06/2018 Created + * + ************************************************************************************* + */ + +#ifndef _WELS_DECODER_THREAD_H_ +#define _WELS_DECODER_THREAD_H_ + +#include "WelsThreadLib.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define WELS_DEC_MAX_NUM_CPU 16 +#define WELS_DEC_MAX_THREAD_STACK_SIZE 4096 +#define WELS_DEC_THREAD_COMMAND_RUN 0 +#define WELS_DEC_THREAD_COMMAND_ABORT 1 + +#if defined(_WIN32) || defined(__CYGWIN__) +typedef struct tagWelsDecSemphore { + WELS_THREAD_HANDLE h; +} SWelsDecSemphore; + +typedef struct tagWelsDecEvent { + WELS_THREAD_HANDLE h; + int isSignaled; +} SWelsDecEvent; + +typedef struct tagWelsDecThread { + WELS_THREAD_HANDLE h; +} SWelsDecThread; + +#define WelsDecThreadFunc(fn,a) DWORD WINAPI fn(LPVOID a) +#define WelsDecThreadFuncArg(a) LPWELS_THREAD_ROUTINE a +#define WELS_DEC_THREAD_WAIT_TIMEDOUT WAIT_TIMEOUT +#define WELS_DEC_THREAD_WAIT_SIGNALED WAIT_OBJECT_0 +#define WELS_DEC_THREAD_WAIT_INFINITE INFINITE + +#else // NON-WINDOWS + +typedef pthread_mutexattr_t WELS_MUTEX_ATTR; + +typedef struct tagWelsDecSemphore { + long max; + long v; + WELS_EVENT e; + WELS_MUTEX m; +} SWelsDecSemphore; + +typedef struct tagWelsDecEvent { + int manualReset; + int isSignaled; + pthread_cond_t c; + WELS_MUTEX m; +} SWelsDecEvent; + +typedef struct tagWelsDecThread { + WELS_THREAD_HANDLE h; +} SWelsDecThread; + +#define WelsDecThreadFunc(fn,a) void* fn(void* a) +#define WelsDecThreadFuncArg(a) void* (*a)(void*) + +#define WELS_DEC_THREAD_WAIT_TIMEDOUT ETIMEDOUT +#define WELS_DEC_THREAD_WAIT_SIGNALED EINTR +#define WELS_DEC_THREAD_WAIT_INFINITE -1 + +#endif//_WIN32 + +#define WelsDecThreadReturn WELS_THREAD_ROUTINE_RETURN(0); + +int32_t GetCPUCount(); + +// Event +int EventCreate (SWelsDecEvent* e, int manualReset, int initialState); +void EventPost (SWelsDecEvent* e); +int EventWait (SWelsDecEvent* e, int32_t timeout); +void EventReset (SWelsDecEvent* e); +void EventDestroy (SWelsDecEvent* e); + +// Semaphore +int SemCreate (SWelsDecSemphore* s, long value, long max); +int SemWait (SWelsDecSemphore* s, int32_t timeout); +void SemRelease (SWelsDecSemphore* s, long* prev_count); +void SemDestroy (SWelsDecSemphore* s); + +// Thread +int ThreadCreate (SWelsDecThread* t, LPWELS_THREAD_ROUTINE tf, void* ta); +int ThreadWait (SWelsDecThread* t); + +#define DECLARE_PROCTHREAD(name, argument) \ + WelsDecThreadFunc(name,argument) + +#define DECLARE_PROCTHREAD_PTR(name) \ + LPWELS_THREAD_ROUTINE name + +#define CREATE_THREAD(ph, threadproc,argument) \ + ThreadCreate(ph, threadproc, (void*)argument) + +#define CREATE_EVENT(ph, manualreset,initial_state,name) \ + EventCreate(ph,(int)(manualreset),(int)(initial_state)) + +#define CREATE_SEMAPHORE(ph, initial_count,max_count, name) \ + SemCreate(ph, (long)initial_count,(long)(max_count)) + +#define CLOSE_EVENT(ph) \ + EventDestroy(ph) + +#define CLOSE_SEMAPHORE(ph) \ + SemDestroy(ph) + +#define SET_EVENT(ph) \ + EventPost(ph) + +#define RESET_EVENT(ph) \ + EventReset(ph) + +#define RELEASE_SEMAPHORE(ph) \ + SemRelease(ph,NULL) + +#define WAIT_EVENT(ph,timeout) \ + EventWait(ph, (int32_t)timeout) + +#define WAIT_THREAD(ph) \ + ThreadWait(ph) + +#define WAIT_SEMAPHORE(ph,timeout) \ + SemWait(ph,(int32_t)timeout) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/openh264/codec/decoder/core/mips/dct_mmi.c b/src/openh264/codec/decoder/core/mips/dct_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/src/au_parser.cpp b/src/openh264/codec/decoder/core/src/au_parser.cpp old mode 100755 new mode 100644 index 9f7091e47..91f89b437 --- a/src/openh264/codec/decoder/core/src/au_parser.cpp +++ b/src/openh264/codec/decoder/core/src/au_parser.cpp @@ -148,48 +148,50 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade ++ (*pConsumedBytes); if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_SPS_NAL (pNalUnitHeader->eNalUnitType) - || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->bSpsExistAheadFlag)) { - if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSpsErrorIgnored == 0) { + || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->sSpsPpsCtx.bSpsExistAheadFlag)) { + if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iSpsErrorIgnored == 0) { WelsLog (pLogCtx, WELS_LOG_WARNING, "parse_nal(), no exist Sequence Parameter Sets ahead of sequence when try to decode NAL(type:%d).", pNalUnitHeader->eNalUnitType); } else { - pCtx->iSpsErrorIgnored++; + pCtx->sSpsPpsCtx.iSpsErrorIgnored++; } - pCtx->sDecoderStatistics.iSpsNoExistNalNum++; + pCtx->pDecoderStatistics->iSpsNoExistNalNum++; pCtx->iErrorCode = dsNoParamSets; return NULL; } - pCtx->iSpsErrorIgnored = 0; + pCtx->sSpsPpsCtx.iSpsErrorIgnored = 0; if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_PARAM_SETS_NALS (pNalUnitHeader->eNalUnitType) - || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->bPpsExistAheadFlag)) { - if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iPpsErrorIgnored == 0) { + || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->sSpsPpsCtx.bPpsExistAheadFlag)) { + if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iPpsErrorIgnored == 0) { WelsLog (pLogCtx, WELS_LOG_WARNING, "parse_nal(), no exist Picture Parameter Sets ahead of sequence when try to decode NAL(type:%d).", pNalUnitHeader->eNalUnitType); } else { - pCtx->iPpsErrorIgnored++; + pCtx->sSpsPpsCtx.iPpsErrorIgnored++; } - pCtx->sDecoderStatistics.iPpsNoExistNalNum++; + pCtx->pDecoderStatistics->iPpsNoExistNalNum++; pCtx->iErrorCode = dsNoParamSets; return NULL; } - pCtx->iPpsErrorIgnored = 0; - if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bPpsExistAheadFlag)) || - (IS_NEW_INTRODUCED_SVC_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bSubspsExistAheadFlag - || pCtx->bPpsExistAheadFlag))) { - if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSubSpsErrorIgnored == 0) { + pCtx->sSpsPpsCtx.iPpsErrorIgnored = 0; + if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->sSpsPpsCtx.bSpsExistAheadFlag + || pCtx->sSpsPpsCtx.bPpsExistAheadFlag)) || + (IS_NEW_INTRODUCED_SVC_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->sSpsPpsCtx.bSpsExistAheadFlag + || pCtx->sSpsPpsCtx.bSubspsExistAheadFlag + || pCtx->sSpsPpsCtx.bPpsExistAheadFlag))) { + if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iSubSpsErrorIgnored == 0) { WelsLog (pLogCtx, WELS_LOG_WARNING, "ParseNalHeader(), no exist Parameter Sets ahead of sequence when try to decode slice(type:%d).", pNalUnitHeader->eNalUnitType); } else { - pCtx->iSubSpsErrorIgnored++; + pCtx->sSpsPpsCtx.iSubSpsErrorIgnored++; } - pCtx->sDecoderStatistics.iSubSpsNoExistNalNum++; + pCtx->pDecoderStatistics->iSubSpsNoExistNalNum++; pCtx->iErrorCode |= dsNoParamSets; return NULL; } - pCtx->iSubSpsErrorIgnored = 0; + pCtx->sSpsPpsCtx.iSubSpsErrorIgnored = 0; switch (pNalUnitHeader->eNalUnitType) { case NAL_UNIT_AU_DELIMITER: @@ -201,7 +203,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade break; case NAL_UNIT_PREFIX: - pCurNal = &pCtx->sPrefixNal; + pCurNal = &pCtx->sSpsPpsCtx.sPrefixNal; pCurNal->uiTimeStamp = pCtx->uiTimeStamp; if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) { @@ -365,9 +367,9 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade memcpy (pSavedData->pCurPos + iStartDeltaByte, pSrcNal, iActualLen); pSavedData->pCurPos += iStartDeltaByte + iActualLen; } - if (NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) { - if (pCtx->sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) { - PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sPrefixNal); + if (NAL_UNIT_PREFIX == pCtx->sSpsPpsCtx.sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) { + if (pCtx->sSpsPpsCtx.sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) { + PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sSpsPpsCtx.sPrefixNal); } } @@ -496,8 +498,8 @@ bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt; const SSliceHeader* kpLastSliceHeader = &kpLastNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; const SSliceHeader* kpCurSliceHeader = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; - if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL - && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) { + if (pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL + && pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) { return true; // the active sps changed, new sequence begins, so the current au is ready } @@ -548,8 +550,8 @@ bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, bool CheckNextAuNewSeq (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PSps kpSps) { const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt; - if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL - && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) + if (pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL + && pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) return true; if (kpCurNalHeaderExt->bIdrFlag) return true; @@ -606,7 +608,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t pCtx->iErrorCode |= dsBitstreamError; return iErr; } - + pCtx->bHasNewSps = true; break; case NAL_UNIT_PPS: @@ -620,17 +622,18 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t return iErr; } } - iErr = ParsePps (pCtx, &pCtx->sPpsBuffer[0], pBs, pSrcNal, kSrcNalLen); + iErr = ParsePps (pCtx, &pCtx->sSpsPpsCtx.sPpsBuffer[0], pBs, pSrcNal, kSrcNalLen); if (ERR_NONE != iErr) { // modified for pps invalid, 12/1/2009 if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) pCtx->iErrorCode |= dsNoParamSets; else pCtx->iErrorCode |= dsBitstreamError; + pCtx->bHasNewSps = false; return iErr; } - pCtx->bPpsExistAheadFlag = true; - + pCtx->sSpsPpsCtx.bPpsExistAheadFlag = true; + ++ (pCtx->sSpsPpsCtx.iSeqId); break; case NAL_UNIT_SEI: @@ -683,7 +686,7 @@ int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePi } int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) { - PNalUnit pCurNal = &pCtx->sPrefixNal; + PNalUnit pCurNal = &pCtx->sSpsPpsCtx.sPrefixNal; uint32_t uiCode; if (pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) { @@ -834,12 +837,12 @@ const SLevelLimits* GetLevelLimits (int32_t iLevelIdx, bool bConstraint3) { bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) { for (int i = 0; i < MAX_LAYER_NUM; i++) { - if (pCtx->pActiveLayerSps[i] == pSps) + if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] == pSps) return true; } // Pre-active, will be used soon if (bUseSubsetFlag) { - if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->bSubspsAvailFlags[pSps->iSpsId]) { + if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->sSpsPpsCtx.bSubspsAvailFlags[pSps->iSpsId]) { if (pCtx->iTotalNumMbRec > 0) { return true; } @@ -857,7 +860,7 @@ bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) { } } } else { - if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->bSpsAvailFlags[pSps->iSpsId]) { + if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->sSpsPpsCtx.bSpsAvailFlags[pSps->iSpsId]) { if (pCtx->iTotalNumMbRec > 0) { return true; } @@ -1251,57 +1254,57 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc) - pCtx->bAvcBasedFlag = false; + pCtx->sSpsPpsCtx.bAvcBasedFlag = false; *pPicWidth = pSps->iMbWidth << 4; *pPicHeight = pSps->iMbHeight << 4; PSps pTmpSps = NULL; if (kbUseSubsetFlag) { - pTmpSps = &pCtx->sSubsetSpsBuffer[iSpsId].sSps; + pTmpSps = &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId].sSps; } else { - pTmpSps = &pCtx->sSpsBuffer[iSpsId]; + pTmpSps = &pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId]; } if (CheckSpsActive (pCtx, pTmpSps, kbUseSubsetFlag)) { // we are overwriting the active sps, copy a temp buffer if (kbUseSubsetFlag) { - if (memcmp (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)) != 0) { + if (memcmp (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)) != 0) { if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) { - memcpy (&pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps)); + memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps)); pCtx->bAuReadyFlag = true; pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1; - pCtx->iOverwriteFlags |= OVERWRITE_SUBSETSPS; + pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SUBSETSPS; } else if ((pCtx->pSps != NULL) && (pCtx->pSps->iSpsId == pSubsetSps->sSps.iSpsId)) { - memcpy (&pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps)); - pCtx->iOverwriteFlags |= OVERWRITE_SUBSETSPS; + memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps)); + pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SUBSETSPS; } else { - memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)); + memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)); } } } else { - if (memcmp (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps)) != 0) { + if (memcmp (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps)) != 0) { if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) { - memcpy (&pCtx->sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps)); - pCtx->iOverwriteFlags |= OVERWRITE_SPS; + memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps)); + pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SPS; pCtx->bAuReadyFlag = true; pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1; } else if ((pCtx->pSps != NULL) && (pCtx->pSps->iSpsId == pSps->iSpsId)) { - memcpy (&pCtx->sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps)); - pCtx->iOverwriteFlags |= OVERWRITE_SPS; + memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps)); + pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SPS; } else { - memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps)); + memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps)); } } } } // Not overwrite active sps, just copy to final place else if (kbUseSubsetFlag) { - memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)); - pCtx->bSubspsAvailFlags[iSpsId] = true; - pCtx->bSubspsExistAheadFlag = true; + memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)); + pCtx->sSpsPpsCtx.bSubspsAvailFlags[iSpsId] = true; + pCtx->sSpsPpsCtx.bSubspsExistAheadFlag = true; } else { - memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps)); - pCtx->bSpsAvailFlags[iSpsId] = true; - pCtx->bSpsExistAheadFlag = true; + memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps)); + pCtx->sSpsPpsCtx.bSpsAvailFlags[iSpsId] = true; + pCtx->sSpsPpsCtx.bSpsExistAheadFlag = true; } return ERR_NONE; } @@ -1421,8 +1424,8 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //pic_scaling_matrix_present_flag pPps->bPicScalingMatrixPresentFlag = !!uiCode; if (pPps->bPicScalingMatrixPresentFlag) { - if (pCtx->bSpsAvailFlags[pPps->iSpsId]) { - WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bTransform8x8ModeFlag, + if (pCtx->sSpsPpsCtx.bSpsAvailFlags[pPps->iSpsId]) { + WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsPpsCtx.sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bTransform8x8ModeFlag, pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4, pPps->iScalingList8x8)); } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, @@ -1440,16 +1443,16 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, if (pCtx->pPps != NULL && pCtx->pPps->iPpsId == pPps->iPpsId) { if (memcmp (pCtx->pPps, pPps, sizeof (*pPps)) != 0) { - memcpy (&pCtx->sPpsBuffer[MAX_PPS_COUNT], pPps, sizeof (SPps)); - pCtx->iOverwriteFlags |= OVERWRITE_PPS; + memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT], pPps, sizeof (SPps)); + pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_PPS; if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) { pCtx->bAuReadyFlag = true; pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1; } } } else { - memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps)); - pCtx->bPpsAvailFlags[uiPpsId] = true; + memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[uiPpsId], pPps, sizeof (SPps)); + pCtx->sSpsPpsCtx.bPpsAvailFlags[uiPpsId] = true; } if (pCtx->pParam->bParseOnly) { if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //pps bs exceeds diff --git a/src/openh264/codec/decoder/core/src/bit_stream.cpp b/src/openh264/codec/decoder/core/src/bit_stream.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/src/cabac_decoder.cpp b/src/openh264/codec/decoder/core/src/cabac_decoder.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/src/deblocking.cpp b/src/openh264/codec/decoder/core/src/deblocking.cpp old mode 100755 new mode 100644 index 88ba9be8b..a3a6fded3 --- a/src/openh264/codec/decoder/core/src/deblocking.cpp +++ b/src/openh264/codec/decoder/core/src/deblocking.cpp @@ -201,11 +201,12 @@ void inline DeblockingBSInsideMBAvsbase8x8 (int8_t* pNnzTab, uint8_t nBS[2][4][4 nBS[1][2][2] = nBS[1][2][3] = (i8x8NnzTab[1] | i8x8NnzTab[3]) << iLShiftFactor; } -void static inline DeblockingBSInsideMBNormal (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab, +void static inline DeblockingBSInsideMBNormal (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], + int8_t* pNnzTab, int32_t iMbXy) { uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; - int8_t* iRefIdx = pCurDqLayer->pRefIndex[LIST_0][iMbXy]; - void *iRefs[MB_BLOCK4x4_NUM]; + int8_t* iRefIdx = pCurDqLayer->pDec->pRefIndex[LIST_0][iMbXy]; + void* iRefs[MB_BLOCK4x4_NUM]; int i; ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4); @@ -226,15 +227,15 @@ void static inline DeblockingBSInsideMBNormal (PDeblockingFilter pFilter, PDqLa pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]); } //vertical - nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], + nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], g_kuiMbCountScan4Idx[1 << 2], g_kuiMbCountScan4Idx[0]); - nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], + nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[2 << 2]); //horizontal - nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], + nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], g_kuiMbCountScan4Idx[2 << 2], g_kuiMbCountScan4Idx[0]); - nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], + nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[1 << 2]); } else { uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); @@ -244,60 +245,61 @@ void static inline DeblockingBSInsideMBNormal (PDeblockingFilter pFilter, PDqLa for (int i = 0; i < 3; i++) uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1]; - nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0); - nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1); - nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2); + nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 1, 0); + nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 2, 1); + nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 3, 2); for (int i = 0; i < 3; i++) uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1]; - nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4); - nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5); - nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6); + nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 5, 4); + nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 6, 5); + nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 7, 6); for (int i = 0; i < 3; i++) uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1]; - nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8); - nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9); - nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10); + nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 9, 8); + nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 10, 9); + nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 11, 10); for (int i = 0; i < 3; i++) uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1]; - nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12); - nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13); - nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14); + nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 13, 12); + nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 14, 13); + nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 15, 14); // horizontal * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1); - nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0); - nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1); - nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2); - nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3); + nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 4, 0); + nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 5, 1); + nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 6, 2); + nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 7, 3); * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2); - nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4); - nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5); - nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6); - nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7); + nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 8, 4); + nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 9, 5); + nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 10, 6); + nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 11, 7); * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3); - nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8); - nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9); - nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10); - nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11); + nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 12, 8); + nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 13, 9); + nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 14, 10); + nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 15, 11); } } -void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab, +void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, + uint8_t nBS[2][4][4], int8_t* pNnzTab, int32_t iMbXy) { uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; - void *iRefs[LIST_A][MB_BLOCK4x4_NUM]; + void* iRefs[LIST_A][MB_BLOCK4x4_NUM]; ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4); int8_t i8x8NnzTab[4]; int l; for (l = 0; l < LIST_A; l++) { - int8_t* iRefIdx = pCurDqLayer->pRefIndex[l][iMbXy]; + int8_t* iRefIdx = pCurDqLayer->pDec->pRefIndex[l][iMbXy]; int i; /* Look up each reference picture based on indices */ for (i = 0; i < MB_BLOCK4x4_NUM; i++) { @@ -321,7 +323,7 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][iIndex] && iRefs[listIdx][iNeigborIndex]) { nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefs[listIdx], - pCurDqLayer->pMv[listIdx][iMbXy], + pCurDqLayer->pDec->pMv[listIdx][iMbXy], iIndex, iNeigborIndex); break; } @@ -332,7 +334,7 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][iIndex] && iRefs[listIdx][iNeigborIndex]) { nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefs[listIdx], - pCurDqLayer->pMv[listIdx][iMbXy], + pCurDqLayer->pDec->pMv[listIdx][iMbXy], iIndex, iNeigborIndex); break; } @@ -345,7 +347,7 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][iIndex] && iRefs[listIdx][iNeigborIndex]) { nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefs[listIdx], - pCurDqLayer->pMv[listIdx][iMbXy], + pCurDqLayer->pDec->pMv[listIdx][iMbXy], iIndex, iNeigborIndex); break; } @@ -357,7 +359,7 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][iIndex] && iRefs[listIdx][iNeigborIndex]) { nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefs[listIdx], - pCurDqLayer->pMv[listIdx][iMbXy], + pCurDqLayer->pDec->pMv[listIdx][iMbXy], iIndex, iNeigborIndex); break; } @@ -373,21 +375,21 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, nBS[0][1][0] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][1] && iRefs[listIdx][0]) { - nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 1, 0); + nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 1, 0); break; } } nBS[0][2][0] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][2] && iRefs[listIdx][1]) { - nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 2, 1); + nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 2, 1); break; } } nBS[0][3][0] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][3] && iRefs[listIdx][2]) { - nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 3, 2); + nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 3, 2); break; } } @@ -397,21 +399,21 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, nBS[0][1][1] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][5] && iRefs[listIdx][4]) { - nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 5, 4); + nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 5, 4); break; } } nBS[0][2][1] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][6] && iRefs[listIdx][5]) { - nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 6, 5); + nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 6, 5); break; } } nBS[0][3][1] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][7] && iRefs[listIdx][6]) { - nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 7, 6); + nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 7, 6); break; } } @@ -421,21 +423,21 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, nBS[0][1][2] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][9] && iRefs[listIdx][8]) { - nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 9, 8); + nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 9, 8); break; } } nBS[0][2][2] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][10] && iRefs[listIdx][9]) { - nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 10, 9); + nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 10, 9); break; } } nBS[0][3][2] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][11] && iRefs[listIdx][10]) { - nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 11, 10); + nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 11, 10); break; } } @@ -445,21 +447,21 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, nBS[0][1][3] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][13] && iRefs[listIdx][12]) { - nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 13, 12); + nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 13, 12); break; } } nBS[0][2][3] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][14] && iRefs[listIdx][13]) { - nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 14, 13); + nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 14, 13); break; } } nBS[0][3][3] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][15] && iRefs[listIdx][14]) { - nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 15, 14); + nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 15, 14); break; } } @@ -469,28 +471,28 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, nBS[1][1][0] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][4] && iRefs[listIdx][0]) { - nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 4, 0); + nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 4, 0); break; } } nBS[1][1][1] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][5] && iRefs[listIdx][1]) { - nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 5, 1); + nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 5, 1); break; } } nBS[1][1][2] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][6] && iRefs[listIdx][2]) { - nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 6, 2); + nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 6, 2); break; } } nBS[1][1][3] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][7] && iRefs[listIdx][3]) { - nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 7, 3); + nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 7, 3); break; } } @@ -499,28 +501,28 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, nBS[1][2][0] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][8] && iRefs[listIdx][4]) { - nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 8, 4); + nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 8, 4); break; } } nBS[1][2][1] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][9] && iRefs[listIdx][5]) { - nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 9, 5); + nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 9, 5); break; } } nBS[1][2][2] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][10] && iRefs[listIdx][6]) { - nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 10, 6); + nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 10, 6); break; } } nBS[1][2][3] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][11] && iRefs[listIdx][7]) { - nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 11, 7); + nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 11, 7); break; } } @@ -529,28 +531,28 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, nBS[1][3][0] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][12] && iRefs[listIdx][8]) { - nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 12, 8); + nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 12, 8); break; } } nBS[1][3][1] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][13] && iRefs[listIdx][9]) { - nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 13, 9); + nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 13, 9); break; } } nBS[1][3][2] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][14] && iRefs[listIdx][10]) { - nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 14, 10); + nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 14, 10); break; } } nBS[1][3][3] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (iRefs[listIdx][15] && iRefs[listIdx][11]) { - nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 15, 11); + nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 15, 11); break; } } @@ -558,7 +560,8 @@ void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, } -uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) { +uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, + int32_t iNeighMb, int32_t iMbXy) { int32_t i, j; uint32_t uiBSx4; uint8_t* pBS = (uint8_t*) (&uiBSx4); @@ -566,21 +569,23 @@ uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCu const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4]; const uint8_t* pB8x8Idx = &g_kuiTableB8x8Idx[iEdge][0]; const uint8_t* pBn8x8Idx = &g_kuiTableB8x8Idx[iEdge][8]; - int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[LIST_0]; + int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pRefIndex[LIST_0] : + pCurDqLayer->pRefIndex[LIST_0]; if (pCurDqLayer->pTransformSize8x8Flag[iMbXy] && pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) { for (i = 0; i < 2; i++) { uint8_t uiNzc = 0; for (j = 0; uiNzc == 0 && j < 4; j++) { - uiNzc |= (pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)] | pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]); + uiNzc |= (GetPNzc (pCurDqLayer, iMbXy)[* (pB8x8Idx + j)] | GetPNzc (pCurDqLayer, iNeighMb)[* (pBn8x8Idx + j)]); } if (uiNzc) { pBS[i << 1] = pBS[1 + (i << 1)] = 2; } else { PPicture ref0, ref1; ref0 = (iRefIdx[iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iMbXy][*pB8x8Idx]] : NULL; - ref1 = (iRefIdx[iNeighMb][*pBn8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBn8x8Idx]] : NULL; - pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, + ref1 = (iRefIdx[iNeighMb][*pBn8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBn8x8Idx]] : + NULL; + pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[LIST_0], iMbXy, iNeighMb, *pB8x8Idx, *pBn8x8Idx); } pB8x8Idx += 4; @@ -590,16 +595,17 @@ uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCu for (i = 0; i < 2; i++) { uint8_t uiNzc = 0; for (j = 0; uiNzc == 0 && j < 4; j++) { - uiNzc |= pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)]; + uiNzc |= GetPNzc (pCurDqLayer, iMbXy)[* (pB8x8Idx + j)]; } for (j = 0; j < 2; j++) { - if (uiNzc | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { + if (uiNzc | GetPNzc (pCurDqLayer, iNeighMb)[*pBnIdx]) { pBS[j + (i << 1)] = 2; } else { PPicture ref0, ref1; ref0 = (iRefIdx[iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iMbXy][*pB8x8Idx]] : NULL; ref1 = (iRefIdx[iNeighMb][*pBnIdx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBnIdx]] : NULL; - pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pB8x8Idx, + pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, + (pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMv[LIST_0] : pCurDqLayer->pMv[LIST_0]), iMbXy, iNeighMb, *pB8x8Idx, *pBnIdx); } pBnIdx++; @@ -610,16 +616,18 @@ uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCu for (i = 0; i < 2; i++) { uint8_t uiNzc = 0; for (j = 0; uiNzc == 0 && j < 4; j++) { - uiNzc |= pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]; + uiNzc |= GetPNzc (pCurDqLayer, iNeighMb)[* (pBn8x8Idx + j)]; } for (j = 0; j < 2; j++) { - if (uiNzc | pCurDqLayer->pNzc[iMbXy][*pBIdx]) { + if (uiNzc | GetPNzc (pCurDqLayer, iMbXy)[*pBIdx]) { pBS[j + (i << 1)] = 2; } else { PPicture ref0, ref1; ref0 = (iRefIdx[iMbXy][*pBIdx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iMbXy][*pBIdx]] : NULL; - ref1 = (iRefIdx[iNeighMb][*pBn8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBn8x8Idx]] : NULL; - pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx, + ref1 = (iRefIdx[iNeighMb][*pBn8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBn8x8Idx]] : + NULL; + pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, + (pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMv[LIST_0] : pCurDqLayer->pMv[LIST_0]), iMbXy, iNeighMb, *pBIdx, *pBn8x8Idx); } pBIdx++; @@ -629,13 +637,14 @@ uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCu } else { // only 4x4 transform for (i = 0; i < 4; i++) { - if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { + if (GetPNzc (pCurDqLayer, iMbXy)[*pBIdx] | GetPNzc (pCurDqLayer, iNeighMb)[*pBnIdx]) { pBS[i] = 2; } else { PPicture ref0, ref1; ref0 = (iRefIdx[iMbXy][*pBIdx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iMbXy][*pBIdx]] : NULL; ref1 = (iRefIdx[iNeighMb][*pBnIdx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBnIdx]] : NULL; - pBS[i] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx, *pBnIdx); + pBS[i] = MB_BS_MV (ref0, ref1, (pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMv[LIST_0] : pCurDqLayer->pMv[LIST_0]), + iMbXy, iNeighMb, *pBIdx, *pBnIdx); } pBIdx++; pBnIdx++; @@ -644,7 +653,8 @@ uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCu return uiBSx4; } -uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) { +uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, + int32_t iNeighMb, int32_t iMbXy) { int32_t i, j; uint32_t uiBSx4; uint8_t* pBS = (uint8_t*) (&uiBSx4); @@ -658,19 +668,19 @@ uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLay for (i = 0; i < 2; i++) { uint8_t uiNzc = 0; for (j = 0; uiNzc == 0 && j < 4; j++) { - uiNzc |= (pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)] | pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]); + uiNzc |= (GetPNzc (pCurDqLayer, iMbXy)[* (pB8x8Idx + j)] | GetPNzc (pCurDqLayer, iNeighMb)[* (pBn8x8Idx + j)]); } if (uiNzc) { pBS[i << 1] = pBS[1 + (i << 1)] = 2; } else { pBS[i << 1] = pBS[1 + (i << 1)] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { - if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST - && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) { - int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[listIdx]; + if (pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST + && pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) { + int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec->pRefIndex[listIdx]; ref0 = pFilter->pRefPics[listIdx][iRefIdx[iMbXy][*pB8x8Idx]]; ref1 = pFilter->pRefPics[listIdx][iRefIdx[iNeighMb][*pBn8x8Idx]]; - pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, + pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[listIdx], iMbXy, iNeighMb, *pB8x8Idx, *pBn8x8Idx); break; } @@ -683,20 +693,20 @@ uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLay for (i = 0; i < 2; i++) { uint8_t uiNzc = 0; for (j = 0; uiNzc == 0 && j < 4; j++) { - uiNzc |= pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)]; + uiNzc |= GetPNzc (pCurDqLayer, iMbXy)[* (pB8x8Idx + j)]; } for (j = 0; j < 2; j++) { - if (uiNzc | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { + if (uiNzc | GetPNzc (pCurDqLayer, iNeighMb)[*pBnIdx]) { pBS[j + (i << 1)] = 2; } else { pBS[j + (i << 1)] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { - if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST - && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) { - int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[listIdx]; + if (pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST + && pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) { + int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec->pRefIndex[listIdx]; ref0 = pFilter->pRefPics[listIdx][iRefIdx[iMbXy][*pB8x8Idx]]; ref1 = pFilter->pRefPics[listIdx][iRefIdx[iNeighMb][*pBnIdx]]; - pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pB8x8Idx, + pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[listIdx], iMbXy, iNeighMb, *pB8x8Idx, *pBnIdx); break; } @@ -710,20 +720,20 @@ uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLay for (i = 0; i < 2; i++) { uint8_t uiNzc = 0; for (j = 0; uiNzc == 0 && j < 4; j++) { - uiNzc |= pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]; + uiNzc |= GetPNzc (pCurDqLayer, iNeighMb)[* (pBn8x8Idx + j)]; } for (j = 0; j < 2; j++) { - if (uiNzc | pCurDqLayer->pNzc[iMbXy][*pBIdx]) { + if (uiNzc | GetPNzc (pCurDqLayer, iMbXy)[*pBIdx]) { pBS[j + (i << 1)] = 2; } else { pBS[j + (i << 1)] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { - if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST - && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) { - int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[listIdx]; + if (pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST + && pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) { + int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec->pRefIndex[listIdx]; ref0 = pFilter->pRefPics[listIdx][iRefIdx[iMbXy][*pBIdx]]; ref1 = pFilter->pRefPics[listIdx][iRefIdx[iNeighMb][*pBn8x8Idx]]; - pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBn8x8Idx); + pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBn8x8Idx); break; } } @@ -735,17 +745,17 @@ uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLay } else { // only 4x4 transform for (i = 0; i < 4; i++) { - if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { + if (GetPNzc (pCurDqLayer, iMbXy)[*pBIdx] | GetPNzc (pCurDqLayer, iNeighMb)[*pBnIdx]) { pBS[i] = 2; } else { pBS[i] = 1; for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { - if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST - && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) { - int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[listIdx]; + if (pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST + && pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) { + int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec->pRefIndex[listIdx]; ref0 = pFilter->pRefPics[listIdx][iRefIdx[iMbXy][*pBIdx]]; ref1 = pFilter->pRefPics[listIdx][iRefIdx[iNeighMb][*pBnIdx]]; - pBS[i] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBnIdx); + pBS[i] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBnIdx); break; } } @@ -972,7 +982,7 @@ void FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uin static void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4], - int32_t iBoundryFlag) { + int32_t iBoundryFlag) { int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; int32_t iMbX = pCurDqLayer->iMbX; int32_t iMbY = pCurDqLayer->iMbY; @@ -1224,7 +1234,8 @@ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t uint8_t nBS[2][4][4] = {{{ 0 }}}; int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; - uint32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex]; + uint32_t iCurMbType = pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMbType[iMbXyIndex] : + pCurDqLayer->pMbType[iMbXyIndex]; int32_t iMbNb; PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; @@ -1242,11 +1253,13 @@ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t if (iBoundryFlag & LEFT_FLAG_MASK) { iMbNb = iMbXyIndex - 1; + uint32_t uiMbType = pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMbType[iMbNb] : pCurDqLayer->pMbType[iMbNb]; if (bBSlice) { - * (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBSliceBsMarginalMBAvcbase ( + * (uint32_t*)nBS[0][0] = IS_INTRA (uiMbType) ? 0x04040404 : + DeblockingBSliceBsMarginalMBAvcbase ( pFilter, pCurDqLayer, 0, iMbNb, iMbXyIndex); } else { - * (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase ( + * (uint32_t*)nBS[0][0] = IS_INTRA (uiMbType) ? 0x04040404 : DeblockingBsMarginalMBAvcbase ( pFilter, pCurDqLayer, 0, iMbNb, iMbXyIndex); } } else { @@ -1254,11 +1267,13 @@ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t } if (iBoundryFlag & TOP_FLAG_MASK) { iMbNb = iMbXyIndex - pCurDqLayer->iMbWidth; + uint32_t uiMbType = pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMbType[iMbNb] : pCurDqLayer->pMbType[iMbNb]; if (bBSlice) { - * (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBSliceBsMarginalMBAvcbase ( + * (uint32_t*)nBS[1][0] = IS_INTRA (uiMbType) ? 0x04040404 : + DeblockingBSliceBsMarginalMBAvcbase ( pFilter, pCurDqLayer, 1, iMbNb, iMbXyIndex); } else { - * (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase ( + * (uint32_t*)nBS[1][0] = IS_INTRA (uiMbType) ? 0x04040404 : DeblockingBsMarginalMBAvcbase ( pFilter, pCurDqLayer, 1, iMbNb, iMbXyIndex); } } else { @@ -1271,16 +1286,16 @@ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t } else { if (IS_INTER_16x16 (iCurMbType)) { if (!pCurDqLayer->pTransformSize8x8Flag[pCurDqLayer->iMbXyIndex]) { - DeblockingBSInsideMBAvsbase (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1); + DeblockingBSInsideMBAvsbase (GetPNzc (pCurDqLayer, iMbXyIndex), nBS, 1); } else { - DeblockingBSInsideMBAvsbase8x8 (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1); + DeblockingBSInsideMBAvsbase8x8 (GetPNzc (pCurDqLayer, iMbXyIndex), nBS, 1); } } else { if (bBSlice) { - DeblockingBSliceBSInsideMBNormal (pFilter, pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex); + DeblockingBSliceBSInsideMBNormal (pFilter, pCurDqLayer, nBS, GetPNzc (pCurDqLayer, iMbXyIndex), iMbXyIndex); } else { - DeblockingBSInsideMBNormal (pFilter, pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex); + DeblockingBSInsideMBNormal (pFilter, pCurDqLayer, nBS, GetPNzc (pCurDqLayer, iMbXyIndex), iMbXyIndex); } } } @@ -1360,6 +1375,56 @@ void WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFun } while (1); } } + +/*! +* \brief AVC slice init deblocking filtering target layer +* +* \in and out param SDeblockingFilter +* \in and out param iFilterIdc +* +* \return NONE +*/ +void WelsDeblockingInitFilter (PWelsDecoderContext pCtx, SDeblockingFilter& pFilter, int32_t& iFilterIdc) { + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt; + + memset (&pFilter, 0, sizeof (pFilter)); + + iFilterIdc = pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc; + + /* Step1: parameters set */ + pFilter.pCsData[0] = pCtx->pDec->pData[0]; + pFilter.pCsData[1] = pCtx->pDec->pData[1]; + pFilter.pCsData[2] = pCtx->pDec->pData[2]; + + pFilter.iCsStride[0] = pCtx->pDec->iLinesize[0]; + pFilter.iCsStride[1] = pCtx->pDec->iLinesize[1]; + + pFilter.eSliceType = (EWelsSliceType)pCurDqLayer->sLayerInfo.sSliceInLayer.eSliceType; + + pFilter.iSliceAlphaC0Offset = pSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; + pFilter.iSliceBetaOffset = pSliceHeaderExt->sSliceHeader.iSliceBetaOffset; + + pFilter.pLoopf = &pCtx->sDeblockingFunc; + pFilter.pRefPics[0] = pCtx->sRefPic.pRefList[0]; + pFilter.pRefPics[1] = pCtx->sRefPic.pRefList[1]; +} + +/*! +* \brief AVC MB deblocking filtering target layer +* +* \param DqLayer which has the current location of MB to be deblocked. +* +* \return NONE +*/ +void WelsDeblockingFilterMB (PDqLayer pCurDqLayer, SDeblockingFilter& pFilter, int32_t& iFilterIdc, + PDeblockingFilterMbFunc pDeblockMb) { + /* macroblock deblocking */ + if (0 == iFilterIdc || 2 == iFilterIdc) { + int32_t iBoundryFlag = DeblockingAvailableNoInterlayer (pCurDqLayer, iFilterIdc); + pDeblockMb (pCurDqLayer, &pFilter, iBoundryFlag); + } +} /*! * \brief deblocking module initialize * diff --git a/src/openh264/codec/decoder/core/src/decode_mb_aux.cpp b/src/openh264/codec/decoder/core/src/decode_mb_aux.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/src/decode_slice.cpp b/src/openh264/codec/decoder/core/src/decode_slice.cpp old mode 100755 new mode 100644 index 856820205..d06a7d77f --- a/src/openh264/codec/decoder/core/src/decode_slice.cpp +++ b/src/openh264/codec/decoder/core/src/decode_slice.cpp @@ -79,36 +79,36 @@ static bool CheckRefPics (const PWelsDecoderContext& pCtx) { } int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PSlice pCurSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PSlice pCurSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pCurSlice->sSliceHeaderExt.sSliceHeader; int32_t iTotalMbTargetLayer = pSliceHeader->pSps->uiTotalMbCount; - int32_t iCurLayerWidth = pCurLayer->iMbWidth << 4; - int32_t iCurLayerHeight = pCurLayer->iMbHeight << 4; + int32_t iCurLayerWidth = pCurDqLayer->iMbWidth << 4; + int32_t iCurLayerHeight = pCurDqLayer->iMbHeight << 4; int32_t iNextMbXyIndex = 0; PFmo pFmo = pCtx->pFmo; int32_t iTotalNumMb = pCurSlice->iTotalMbInCurSlice; int32_t iCountNumMb = 0; - PDeblockingFilterMbFunc pDeblockMb; + PDeblockingFilterMbFunc pDeblockMb = WelsDeblockingMb; - if (!pCtx->bAvcBasedFlag && iCurLayerWidth != pCtx->iCurSeqIntervalMaxPicWidth) { + if (!pCtx->sSpsPpsCtx.bAvcBasedFlag && iCurLayerWidth != pCtx->iCurSeqIntervalMaxPicWidth) { return ERR_INFO_WIDTH_MISMATCH; } iNextMbXyIndex = pSliceHeader->iFirstMbInSlice; - pCurLayer->iMbX = iNextMbXyIndex % pCurLayer->iMbWidth; - pCurLayer->iMbY = iNextMbXyIndex / pCurLayer->iMbWidth; - pCurLayer->iMbXyIndex = iNextMbXyIndex; + pCurDqLayer->iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth; + pCurDqLayer->iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth; + pCurDqLayer->iMbXyIndex = iNextMbXyIndex; if (0 == iNextMbXyIndex) { - pCurLayer->pDec->iSpsId = pCtx->pSps->iSpsId; - pCurLayer->pDec->iPpsId = pCtx->pPps->iPpsId; + pCurDqLayer->pDec->iSpsId = pCtx->pSps->iSpsId; + pCurDqLayer->pDec->iPpsId = pCtx->pPps->iPpsId; - pCurLayer->pDec->uiQualityId = pCurLayer->sLayerInfo.sNalHeaderExt.uiQualityId; + pCurDqLayer->pDec->uiQualityId = pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId; } do { @@ -120,16 +120,16 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { if (WelsTargetMbConstruction (pCtx)) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d", - pCurLayer->iMbX, pCurLayer->iMbY, pCurSlice->eSliceType); + pCurDqLayer->iMbX, pCurDqLayer->iMbY, pCurSlice->eSliceType); return ERR_INFO_MB_RECON_FAIL; } } ++iCountNumMb; - if (!pCurLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex]) { //already con-ed, overwrite - pCurLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex] = true; - pCtx->pDec->iMbEcedPropNum += (pCurLayer->pMbRefConcealedFlag[iNextMbXyIndex] ? 1 : 0); + if (!pCurDqLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex]) { //already con-ed, overwrite + pCurDqLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex] = true; + pCtx->pDec->iMbEcedPropNum += (pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] ? 1 : 0); ++pCtx->iTotalNumMbRec; } @@ -149,9 +149,9 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbTargetLayer) { // slice group boundary or end of a frame break; } - pCurLayer->iMbX = iNextMbXyIndex % pCurLayer->iMbWidth; - pCurLayer->iMbY = iNextMbXyIndex / pCurLayer->iMbWidth; - pCurLayer->iMbXyIndex = iNextMbXyIndex; + pCurDqLayer->iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth; + pCurDqLayer->iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth; + pCurDqLayer->iMbXyIndex = iNextMbXyIndex; } while (1); pCtx->pDec->iWidthInPixel = iCurLayerWidth; @@ -163,8 +163,6 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { if (pCtx->pParam->bParseOnly) //for parse only, deblocking should not go on return ERR_NONE; - pDeblockMb = WelsDeblockingMb; - if (1 == pSliceHeader->uiDisableDeblockingFilterIdc || pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice <= 0) { return ERR_NONE;//NO_SUPPORTED_FILTER_IDX @@ -176,32 +174,32 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { return ERR_NONE; } -int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer, +int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer, uint8_t* pDstY, uint8_t* pDstU, uint8_t* pDstV, int32_t iStrideL, int32_t iStrideC) { - int32_t iMbXy = pCurLayer->iMbXyIndex; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; int32_t i, iIndex, iOffset; - if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { for (i = 0; i < 4; i++) { iIndex = g_kuiMbCountScan4Idx[i << 2]; - if (pCurLayer->pNzc[iMbXy][iIndex] || pCurLayer->pNzc[iMbXy][iIndex + 1] || pCurLayer->pNzc[iMbXy][iIndex + 4] - || pCurLayer->pNzc[iMbXy][iIndex + 5]) { + if (pCurDqLayer->pNzc[iMbXy][iIndex] || pCurDqLayer->pNzc[iMbXy][iIndex + 1] || pCurDqLayer->pNzc[iMbXy][iIndex + 4] + || pCurDqLayer->pNzc[iMbXy][iIndex + 5]) { iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2); - pCtx->pIdctResAddPredFunc8x8 (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 6)); + pCtx->pIdctResAddPredFunc8x8 (pDstY + iOffset, iStrideL, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 6)); } } } else { // luma. - const int8_t* pNzc = pCurLayer->pNzc[iMbXy]; - int16_t* pScaledTCoeff = pCurLayer->pScaledTCoeff[iMbXy]; + const int8_t* pNzc = pCurDqLayer->pNzc[iMbXy]; + int16_t* pScaledTCoeff = pCurDqLayer->pScaledTCoeff[iMbXy]; pCtx->pIdctFourResAddPredFunc (pDstY + 0 * iStrideL + 0, iStrideL, pScaledTCoeff + 0 * 64, pNzc + 0); pCtx->pIdctFourResAddPredFunc (pDstY + 0 * iStrideL + 8, iStrideL, pScaledTCoeff + 1 * 64, pNzc + 2); pCtx->pIdctFourResAddPredFunc (pDstY + 8 * iStrideL + 0, iStrideL, pScaledTCoeff + 2 * 64, pNzc + 8); pCtx->pIdctFourResAddPredFunc (pDstY + 8 * iStrideL + 8, iStrideL, pScaledTCoeff + 3 * 64, pNzc + 10); } - const int8_t* pNzc = pCurLayer->pNzc[iMbXy]; - int16_t* pScaledTCoeff = pCurLayer->pScaledTCoeff[iMbXy]; + const int8_t* pNzc = pCurDqLayer->pNzc[iMbXy]; + int16_t* pScaledTCoeff = pCurDqLayer->pScaledTCoeff[iMbXy]; // Cb. pCtx->pIdctFourResAddPredFunc (pDstU, iStrideC, pScaledTCoeff + 4 * 64, pNzc + 16); // Cr. @@ -209,17 +207,17 @@ int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLa return ERR_NONE; } -int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) { - int32_t iMbX = pCurLayer->iMbX; - int32_t iMbY = pCurLayer->iMbY; +int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer) { + int32_t iMbX = pCurDqLayer->iMbX; + int32_t iMbY = pCurDqLayer->iMbY; uint8_t* pDstY, *pDstCb, *pDstCr; int32_t iLumaStride = pCtx->pDec->iLinesize[0]; int32_t iChromaStride = pCtx->pDec->iLinesize[1]; - pDstY = pCurLayer->pDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4); - pDstCb = pCurLayer->pDec->pData[1] + ((iMbY * iChromaStride + iMbX) << 3); - pDstCr = pCurLayer->pDec->pData[2] + ((iMbY * iChromaStride + iMbX) << 3); + pDstY = pCurDqLayer->pDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4); + pDstCb = pCurDqLayer->pDec->pData[1] + ((iMbY * iChromaStride + iMbX) << 3); + pDstCr = pCurDqLayer->pDec->pData[2] + ((iMbY * iChromaStride + iMbX) << 3); if (pCtx->eSliceType == P_SLICE) { WELS_B_MB_REC_VERIFY (GetInterPred (pDstY, pDstCb, pDstCr, pCtx)); @@ -236,10 +234,12 @@ int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) { pDstYCbCr[2] = pDstCr; WELS_B_MB_REC_VERIFY (GetInterBPred (pDstYCbCr, pTempDstYCbCr, pCtx)); } - WelsMbInterSampleConstruction (pCtx, pCurLayer, pDstY, pDstCb, pDstCr, iLumaStride, iChromaStride); + WelsMbInterSampleConstruction (pCtx, pCurDqLayer, pDstY, pDstCb, pDstCr, iLumaStride, iChromaStride); - pCtx->sBlockFunc.pWelsSetNonZeroCountFunc ( - pCurLayer->pNzc[pCurLayer->iMbXyIndex]); // set all none-zero nzc to 1; dbk can be opti! + if (GetThreadCount (pCtx) <= 1) { + pCtx->sBlockFunc.pWelsSetNonZeroCountFunc ( + pCurDqLayer->pNzc[pCurDqLayer->iMbXyIndex]); // set all none-zero nzc to 1; dbk can be opti! + } return ERR_NONE; } @@ -285,33 +285,33 @@ void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp, PWelsDecoderContext pC #undef STRIDE } -int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer, bool bOutput) { +int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer, bool bOutput) { //seems IPCM should not enter this path - int32_t iMbXy = pCurLayer->iMbXyIndex; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; - WelsFillRecNeededMbInfo (pCtx, bOutput, pCurLayer); + WelsFillRecNeededMbInfo (pCtx, bOutput, pCurDqLayer); - if (IS_INTRA16x16 (pCurLayer->pMbType[iMbXy])) { - RecI16x16Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer); - } else if (IS_INTRA8x8 (pCurLayer->pMbType[iMbXy])) { - RecI8x8Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer); - } else if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) { - RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer); + if (IS_INTRA16x16 (pCurDqLayer->pDec->pMbType[iMbXy])) { + RecI16x16Mb (iMbXy, pCtx, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer); + } else if (IS_INTRA8x8 (pCurDqLayer->pDec->pMbType[iMbXy])) { + RecI8x8Mb (iMbXy, pCtx, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer); + } else if (IS_INTRA4x4 (pCurDqLayer->pDec->pMbType[iMbXy])) { + RecI4x4Mb (iMbXy, pCtx, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer); } return ERR_NONE; } -int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) { - int32_t iMbX = pCurLayer->iMbX; - int32_t iMbY = pCurLayer->iMbY; +int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer) { + int32_t iMbX = pCurDqLayer->iMbX; + int32_t iMbY = pCurDqLayer->iMbY; uint8_t* pDstY, *pDstCb, *pDstCr; int32_t iLumaStride = pCtx->pDec->iLinesize[0]; int32_t iChromaStride = pCtx->pDec->iLinesize[1]; - pDstY = pCurLayer->pDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4); - pDstCb = pCurLayer->pDec->pData[1] + ((iMbY * iChromaStride + iMbX) << 3); - pDstCr = pCurLayer->pDec->pData[2] + ((iMbY * iChromaStride + iMbX) << 3); + pDstY = pCurDqLayer->pDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4); + pDstCb = pCurDqLayer->pDec->pData[1] + ((iMbY * iChromaStride + iMbX) << 3); + pDstCr = pCurDqLayer->pDec->pData[2] + ((iMbY * iChromaStride + iMbX) << 3); if (pCtx->eSliceType == P_SLICE) { WELS_B_MB_REC_VERIFY (GetInterPred (pDstY, pDstCb, pDstCr, pCtx)); @@ -332,24 +332,24 @@ int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) { } int32_t WelsTargetMbConstruction (PWelsDecoderContext pCtx) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - if (MB_TYPE_INTRA_PCM == pCurLayer->pMbType[pCurLayer->iMbXyIndex]) { + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + if (MB_TYPE_INTRA_PCM == pCurDqLayer->pDec->pMbType[pCurDqLayer->iMbXyIndex]) { //already decoded and reconstructed when parsing return ERR_NONE; - } else if (IS_INTRA (pCurLayer->pMbType[pCurLayer->iMbXyIndex])) { - WelsMbIntraPredictionConstruction (pCtx, pCurLayer, 1); - } else if (IS_INTER (pCurLayer->pMbType[pCurLayer->iMbXyIndex])) { //InterMB - if (0 == pCurLayer->pCbp[pCurLayer->iMbXyIndex]) { //uiCbp==0 include SKIP + } else if (IS_INTRA (pCurDqLayer->pDec->pMbType[pCurDqLayer->iMbXyIndex])) { + WelsMbIntraPredictionConstruction (pCtx, pCurDqLayer, 1); + } else if (IS_INTER (pCurDqLayer->pDec->pMbType[pCurDqLayer->iMbXyIndex])) { //InterMB + if (0 == pCurDqLayer->pCbp[pCurDqLayer->iMbXyIndex]) { //uiCbp==0 include SKIP if (!CheckRefPics (pCtx)) { return ERR_INFO_MB_RECON_FAIL; } - return WelsMbInterPrediction (pCtx, pCurLayer); + return WelsMbInterPrediction (pCtx, pCurDqLayer); } else { - WelsMbInterConstruction (pCtx, pCurLayer); + WelsMbInterConstruction (pCtx, pCurDqLayer); } } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsTargetMbConstruction():::::Unknown MB type: %d", - pCurLayer->pMbType[pCurLayer->iMbXyIndex]); + pCurDqLayer->pDec->pMbType[pCurDqLayer->iMbXyIndex]); return ERR_INFO_MB_RECON_FAIL; } @@ -644,25 +644,25 @@ int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAva } int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBsAux = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBsAux = pCurDqLayer->pBitStringAux; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; SWelsNeighAvail sNeighAvail; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; - int32_t iMbXy = pCurLayer->iMbXyIndex; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; int32_t i; uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0; ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; - pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; - GetNeighborAvailMbType (&sNeighAvail, pCurLayer); + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; + pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; + GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer); WELS_READ_VERIFY (ParseMBTypeISliceCabac (pCtx, &sNeighAvail, uiMbType)); if (uiMbType > 25) { return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE); @@ -680,104 +680,104 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui return ERR_NONE; } else if (0 == uiMbType) { //I4x4 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4; if (pCtx->pPps->bTransform8x8ModeFlag) { // Transform 8x8 cabac will be added soon WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, &sNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); } if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { - uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; - pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); + uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8; + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer)); } else { - pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer)); } //get uiCbp for I4x4 WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp)); - pCurLayer->pCbp[iMbXy] = uiCbp; + pCurDqLayer->pCbp[iMbXy] = uiCbp; pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp; uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? uiCbp >> 4 : 0; uiCbpLuma = uiCbp & 15; } else { //I16x16; - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; - pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; - uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ; - uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15; - WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer); - WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBsAux, pCurLayer)); + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; + pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; + uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0 ; + uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15; + WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBsAux, pCurDqLayer)); } - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); - ST32 (&pCurLayer->pNzc[iMbXy][16], 0); - ST32 (&pCurLayer->pNzc[iMbXy][20], 0); - pCurLayer->pCbfDc[iMbXy] = 0; + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0); + pCurDqLayer->pCbfDc[iMbXy] = 0; - if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurLayer->pMbType[iMbXy])) { - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; + if (pCurDqLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurDqLayer->pDec->pMbType[iMbXy])) { + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i]), 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i]), 0, 51)]; } } - if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { - memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0])); + if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { + memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0])); int32_t iQpDelta, iId8x8, iId4x4; WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, iQpDelta)); if (iQpDelta > 25 || iQpDelta < -26) {//out of iQpDelta range return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP); } - pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp - pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy]; + pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp + pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy]; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pSlice->iLastMbQp + - pSliceHeader->pPps->iChromaQpIndexOffset[i]), 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pSlice->iLastMbQp + + pSliceHeader->pPps->iChromaQpIndexOffset[i]), 0, 51)]; } - if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { //step1: Luma DC WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 0, 16, g_kuiLumaDcZigzagScan, - I16_LUMA_DC, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)); + I16_LUMA_DC, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)); //step2: Luma AC if (uiCbpLuma) { for (i = 0; i < 16; i++) { WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, - pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), pCurLayer->pLumaQp[iMbXy], pCtx)); + pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4), pCurDqLayer->pLumaQp[iMbXy], pCtx)); } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } else { //pNonZeroCount = 0 - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); } } else { //non-MB_TYPE_INTRA16x16 - if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { // Transform 8x8 support for CABAC for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { if (uiCbpLuma & (1 << iId8x8)) { WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (&sNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2), iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, LUMA_DC_AC_INTRA_8, - pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx)); + pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurDqLayer->pLumaQp[iMbXy], pCtx)); } else { ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); } } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } else { for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { if (uiCbpLuma & (1 << iId8x8)) { @@ -785,8 +785,8 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { //Luma (DC and AC decoding together) WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)); + g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)); iIdx++; } } else { @@ -794,10 +794,10 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); } } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } } int32_t iMbResProperty; @@ -808,7 +808,7 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui for (i = 0; i < 2; i++) { iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U; WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan, - iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)); + iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)); } } @@ -820,27 +820,27 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, - pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx)); + pCurDqLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)); iIdx++; } } - ST16 (&pCurLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1])); - ST16 (&pCurLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2])); - ST16 (&pCurLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4])); - ST16 (&pCurLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5])); + ST16 (&pCurDqLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1])); + ST16 (&pCurDqLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2])); + ST16 (&pCurDqLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4])); + ST16 (&pCurDqLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5])); } else { - ST16 (&pCurLayer->pNzc[iMbXy][16], 0); - ST16 (&pCurLayer->pNzc[iMbXy][20], 0); - ST16 (&pCurLayer->pNzc[iMbXy][18], 0); - ST16 (&pCurLayer->pNzc[iMbXy][22], 0); + ST16 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST16 (&pCurDqLayer->pNzc[iMbXy][20], 0); + ST16 (&pCurDqLayer->pNzc[iMbXy][18], 0); + ST16 (&pCurDqLayer->pNzc[iMbXy][22], 0); } } else { - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); - ST32 (&pCurLayer->pNzc[iMbXy][16], 0); - ST32 (&pCurLayer->pNzc[iMbXy][20], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0); } WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag)); @@ -856,21 +856,21 @@ int32_t WelsDecodeMbCabacISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin } int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBsAux = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBsAux = pCurDqLayer->pBitStringAux; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; - int32_t iMbXy = pCurLayer->iMbXyIndex; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; int32_t iMbResProperty; int32_t i; uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0; ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; WELS_READ_VERIFY (ParseMBTypePSliceCabac (pCtx, pNeighAvail, uiMbType)); // uiMbType = 4 is not allowded. @@ -878,10 +878,10 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv int16_t pMotionVector[LIST_A][30][MV_A]; int16_t pMvdCache[LIST_A][30][MV_A]; int8_t pRefIndex[LIST_A][30]; - pCurLayer->pMbType[iMbXy] = g_ksInterPMbTypeInfo[uiMbType].iType; - WelsFillCacheInterCabac (pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pCurLayer); + pCurDqLayer->pDec->pMbType[iMbXy] = g_ksInterPMbTypeInfo[uiMbType].iType; + WelsFillCacheInterCabac (pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pCurDqLayer); WELS_READ_VERIFY (ParseInterPMotionInfoCabac (pCtx, pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex)); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; } else { //Intra mode uiMbType -= 5; if (uiMbType > 25) @@ -901,58 +901,58 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv } else { //normal Intra mode if (0 == uiMbType) { //Intra4x4 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4; if (pCtx->pPps->bTransform8x8ModeFlag) { WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); } if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { - uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; - pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); + uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8; + pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer)); } else { - pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); + pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer)); } } else { //Intra16x16 - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; - pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; - uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; - uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15; - WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer); - WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurLayer)); + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; + pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; + uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0; + uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15; + WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurDqLayer)); } } } - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); - ST32 (&pCurLayer->pNzc[iMbXy][16], 0); - ST32 (&pCurLayer->pNzc[iMbXy][20], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0); - if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) { WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, uiCbp)); - pCurLayer->pCbp[iMbXy] = uiCbp; + pCurDqLayer->pCbp[iMbXy] = uiCbp; pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp; - uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ; - uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15; + uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0 ; + uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15; } - if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { - if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) { // Need modification when B picutre add in bool bNeedParseTransformSize8x8Flag = - (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16) - || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) - && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8) - && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4) - && ((pCurLayer->pCbp[iMbXy] & 0x0F) > 0) + (((pCurDqLayer->pDec->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurDqLayer->pDec->pMbType[iMbXy] <= MB_TYPE_8x16) + || pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) + && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA8x8) + && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA4x4) + && ((pCurDqLayer->pCbp[iMbXy] & 0x0F) > 0) && (pCtx->pPps->bTransform8x8ModeFlag)); if (bNeedParseTransformSize8x8Flag) { @@ -961,7 +961,7 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv } } - memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0])); + memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0])); int32_t iQpDelta, iId8x8, iId4x4; @@ -969,33 +969,33 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP); } - pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp - pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy]; + pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp + pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy]; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } - if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { //step1: Luma DC WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 0, 16, g_kuiLumaDcZigzagScan, - I16_LUMA_DC, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)); + I16_LUMA_DC, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)); //step2: Luma AC if (uiCbpLuma) { for (i = 0; i < 16; i++) { WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, - 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)); + 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)); } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } else { - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); } } else { //non-MB_TYPE_INTRA16x16 if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { @@ -1004,27 +1004,27 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv if (uiCbpLuma & (1 << iId8x8)) { WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (pNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2), iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, - IS_INTRA (pCurLayer->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8, - pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx)); + IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8, + pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurDqLayer->pLumaQp[iMbXy], pCtx)); } else { ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); } } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } else { - iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; + iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { if (uiCbpLuma & (1 << iId8x8)) { int32_t iIdx = (iId8x8 << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { //Luma (DC and AC decoding together) WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), - pCurLayer->pLumaQp[iMbXy], + g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)); iIdx++; } @@ -1033,10 +1033,10 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); } } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } } @@ -1044,19 +1044,19 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv //step1: DC if (1 == uiCbpChroma || 2 == uiCbpChroma) { for (i = 0; i < 2; i++) { - if (IS_INTRA (pCurLayer->pMbType[iMbXy])) + if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U; else iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER; WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan, - iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)); + iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)); } } //step2: AC if (2 == uiCbpChroma) { for (i = 0; i < 2; i++) { - if (IS_INTRA (pCurLayer->pMbType[iMbXy])) + if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U; else iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER; @@ -1064,23 +1064,23 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, index, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), - iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx)); + iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)); index++; } } - ST16 (&pCurLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1])); - ST16 (&pCurLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2])); - ST16 (&pCurLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4])); - ST16 (&pCurLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5])); + ST16 (&pCurDqLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1])); + ST16 (&pCurDqLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2])); + ST16 (&pCurDqLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4])); + ST16 (&pCurDqLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5])); } else { - ST32 (&pCurLayer->pNzc[iMbXy][16], 0); - ST32 (&pCurLayer->pNzc[iMbXy][20], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0); } } else { - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } } @@ -1093,21 +1093,21 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv } int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBsAux = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBsAux = pCurDqLayer->pBitStringAux; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; - int32_t iMbXy = pCurLayer->iMbXyIndex; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; int32_t iMbResProperty; int32_t i; uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0; ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; WELS_READ_VERIFY (ParseMBTypeBSliceCabac (pCtx, pNeighAvail, uiMbType)); @@ -1116,12 +1116,12 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv int16_t pMvdCache[LIST_A][30][MV_A]; int8_t pRefIndex[LIST_A][30]; int8_t pDirect[30]; - pCurLayer->pMbType[iMbXy] = g_ksInterBMbTypeInfo[uiMbType].iType; - WelsFillCacheInterCabac (pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pCurLayer); - WelsFillDirectCacheCabac (pNeighAvail, pDirect, pCurLayer); + pCurDqLayer->pDec->pMbType[iMbXy] = g_ksInterBMbTypeInfo[uiMbType].iType; + WelsFillCacheInterCabac (pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pCurDqLayer); + WelsFillDirectCacheCabac (pNeighAvail, pDirect, pCurDqLayer); WELS_READ_VERIFY (ParseInterBMotionInfoCabac (pCtx, pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pDirect)); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; } else { //Intra mode uiMbType -= 23; if (uiMbType > 25) @@ -1141,59 +1141,59 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv } else { //normal Intra mode if (0 == uiMbType) { //Intra4x4 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4; if (pCtx->pPps->bTransform8x8ModeFlag) { WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); } if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { - uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; - pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); + uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8; + pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer)); } else { - pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); + pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer)); } } else { //Intra16x16 - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; - pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; - uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; - uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15; - WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer); - WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurLayer)); + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; + pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; + uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0; + uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15; + WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurDqLayer)); } } } - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); - ST32 (&pCurLayer->pNzc[iMbXy][16], 0); - ST32 (&pCurLayer->pNzc[iMbXy][20], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0); - if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) { WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, uiCbp)); - pCurLayer->pCbp[iMbXy] = uiCbp; + pCurDqLayer->pCbp[iMbXy] = uiCbp; pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp; - uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; - uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15; + uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0; + uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15; } - if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { - if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) { // Need modification when B picutre add in bool bNeedParseTransformSize8x8Flag = - (((IS_INTER_16x16 (pCurLayer->pMbType[iMbXy]) || IS_DIRECT (pCurLayer->pMbType[iMbXy]) - || IS_INTER_16x8 (pCurLayer->pMbType[iMbXy]) || IS_INTER_8x16 (pCurLayer->pMbType[iMbXy])) - || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) - && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8) - && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4) - && ((pCurLayer->pCbp[iMbXy] & 0x0F) > 0) + (((IS_INTER_16x16 (pCurDqLayer->pDec->pMbType[iMbXy]) || IS_DIRECT (pCurDqLayer->pDec->pMbType[iMbXy]) + || IS_INTER_16x8 (pCurDqLayer->pDec->pMbType[iMbXy]) || IS_INTER_8x16 (pCurDqLayer->pDec->pMbType[iMbXy])) + || pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) + && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA8x8) + && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA4x4) + && ((pCurDqLayer->pCbp[iMbXy] & 0x0F) > 0) && (pCtx->pPps->bTransform8x8ModeFlag)); if (bNeedParseTransformSize8x8Flag) { @@ -1202,7 +1202,7 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv } } - memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0])); + memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0])); int32_t iQpDelta, iId8x8, iId4x4; @@ -1210,33 +1210,33 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP); } - pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp - pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy]; + pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp + pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy]; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } - if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { //step1: Luma DC WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 0, 16, g_kuiLumaDcZigzagScan, - I16_LUMA_DC, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)); + I16_LUMA_DC, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)); //step2: Luma AC if (uiCbpLuma) { for (i = 0; i < 16; i++) { WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, - 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)); + 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)); } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } else { - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); } } else { //non-MB_TYPE_INTRA16x16 if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { @@ -1245,27 +1245,27 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv if (uiCbpLuma & (1 << iId8x8)) { WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (pNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2), iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, - IS_INTRA (pCurLayer->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8, - pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx)); + IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8, + pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurDqLayer->pLumaQp[iMbXy], pCtx)); } else { ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); } } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } else { - iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; + iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { if (uiCbpLuma & (1 << iId8x8)) { int32_t iIdx = (iId8x8 << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { //Luma (DC and AC decoding together) WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), - pCurLayer->pLumaQp[iMbXy], + g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)); iIdx++; } @@ -1274,10 +1274,10 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); } } - ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); - ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); - ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); - ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); + ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); } } @@ -1285,19 +1285,19 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv //step1: DC if (1 == uiCbpChroma || 2 == uiCbpChroma) { for (i = 0; i < 2; i++) { - if (IS_INTRA (pCurLayer->pMbType[iMbXy])) + if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U; else iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER; WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan, - iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)); + iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)); } } //step2: AC if (2 == uiCbpChroma) { for (i = 0; i < 2; i++) { - if (IS_INTRA (pCurLayer->pMbType[iMbXy])) + if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U; else iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER; @@ -1305,23 +1305,23 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, index, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), - iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx)); + iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)); index++; } } - ST16 (&pCurLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1])); - ST16 (&pCurLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2])); - ST16 (&pCurLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4])); - ST16 (&pCurLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5])); + ST16 (&pCurDqLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1])); + ST16 (&pCurDqLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2])); + ST16 (&pCurDqLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4])); + ST16 (&pCurDqLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5])); } else { - ST32 (&pCurLayer->pNzc[iMbXy][16], 0); - ST32 (&pCurLayer->pNzc[iMbXy][20], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0); } } else { - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } } @@ -1335,53 +1335,55 @@ int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; uint32_t uiCode; - int32_t iMbXy = pCurLayer->iMbXyIndex; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; int32_t i; SWelsNeighAvail uiNeighAvail; - pCurLayer->pCbp[iMbXy] = 0; - pCurLayer->pCbfDc[iMbXy] = 0; - pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC; + pCurDqLayer->pCbp[iMbXy] = 0; + pCurDqLayer->pCbfDc[iMbXy] = 0; + pCurDqLayer->pChromaPredMode[iMbXy] = C_PRED_DC; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; - GetNeighborAvailMbType (&uiNeighAvail, pCurLayer); + GetNeighborAvailMbType (&uiNeighAvail, pCurDqLayer); WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode)); if (uiCode) { int16_t pMv[2] = {0}; - pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP; - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); - ST32 (&pCurLayer->pNzc[iMbXy][16], 0); - ST32 (&pCurLayer->pNzc[iMbXy][20], 0); + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP; + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; - memset (pCurLayer->pRefIndex[0][iMbXy], 0, sizeof (int8_t) * 16); - pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[0] && ppRefPic[0]->bIsComplete); + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; + memset (pCurDqLayer->pDec->pRefIndex[0][iMbXy], 0, sizeof (int8_t) * 16); + bool bIsPending = GetThreadCount (pCtx) > 1; + pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[0] && (ppRefPic[0]->bIsComplete + || bIsPending)); //predict mv - PredPSkipMvFromNeighbor (pCurLayer, pMv); + PredPSkipMvFromNeighbor (pCurDqLayer, pMv); for (i = 0; i < 16; i++) { - ST32 (pCurLayer->pMv[0][iMbXy][i], * (uint32_t*)pMv); - ST32 (pCurLayer->pMvd[0][iMbXy][i], 0); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][i], * (uint32_t*)pMv); + ST32 (pCurDqLayer->pMvd[0][iMbXy][i], 0); } //if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag) { - // memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t)); + // memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t)); //} //reset rS - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } //for neighboring CABAC usage @@ -1398,43 +1400,45 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PPicture* ppRefPicL0 = pCtx->sRefPic.pRefList[LIST_0]; PPicture* ppRefPicL1 = pCtx->sRefPic.pRefList[LIST_1]; uint32_t uiCode; - int32_t iMbXy = pCurLayer->iMbXyIndex; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; int32_t i; SWelsNeighAvail uiNeighAvail; - pCurLayer->pCbp[iMbXy] = 0; - pCurLayer->pCbfDc[iMbXy] = 0; - pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC; + pCurDqLayer->pCbp[iMbXy] = 0; + pCurDqLayer->pCbfDc[iMbXy] = 0; + pCurDqLayer->pChromaPredMode[iMbXy] = C_PRED_DC; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; - GetNeighborAvailMbType (&uiNeighAvail, pCurLayer); + GetNeighborAvailMbType (&uiNeighAvail, pCurDqLayer); WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode)); - memset (pCurLayer->pDirect[iMbXy], 0, sizeof (int8_t) * 16); + memset (pCurDqLayer->pDirect[iMbXy], 0, sizeof (int8_t) * 16); + + bool bIsPending = GetThreadCount (pCtx) > 1; if (uiCode) { int16_t pMv[LIST_A][2] = { {0, 0}, { 0, 0 } }; int8_t ref[LIST_A] = { 0 }; - pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP | MB_TYPE_DIRECT; - ST32 (&pCurLayer->pNzc[iMbXy][0], 0); - ST32 (&pCurLayer->pNzc[iMbXy][4], 0); - ST32 (&pCurLayer->pNzc[iMbXy][8], 0); - ST32 (&pCurLayer->pNzc[iMbXy][12], 0); - ST32 (&pCurLayer->pNzc[iMbXy][16], 0); - ST32 (&pCurLayer->pNzc[iMbXy][20], 0); + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP | MB_TYPE_DIRECT; + ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0); + ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; - memset (pCurLayer->pRefIndex[LIST_0][iMbXy], 0, sizeof (int8_t) * 16); - memset (pCurLayer->pRefIndex[LIST_1][iMbXy], 0, sizeof (int8_t) * 16); - pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete) - || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete); + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; + memset (pCurDqLayer->pDec->pRefIndex[LIST_0][iMbXy], 0, sizeof (int8_t) * 16); + memset (pCurDqLayer->pDec->pRefIndex[LIST_1][iMbXy], 0, sizeof (int8_t) * 16); + pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && (ppRefPicL0[0]->bIsComplete + || bIsPending)) || ! (ppRefPicL1[0] && (ppRefPicL1[0]->bIsComplete || bIsPending)); if (pCtx->bMbRefConcealed) { SLogContext* pLogCtx = & (pCtx->sLogCtx); @@ -1460,10 +1464,10 @@ int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin //reset rS - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } //for neighboring CABAC usage @@ -1509,12 +1513,12 @@ int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) { } int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNalUnit pNalCur) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; PFmo pFmo = pCtx->pFmo; int32_t iRet; int32_t iNextMbXyIndex, iSliceIdc; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeaderExt pSliceHeaderExt = &pSlice->sSliceHeaderExt; PSliceHeader pSliceHeader = &pSliceHeaderExt->sSliceHeader; int32_t iMbX, iMbY; @@ -1560,7 +1564,7 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal } pCtx->eSliceType = pSliceHeader->eSliceType; - if (pCurLayer->sLayerInfo.pPps->bEntropyCodingModeFlag == 1) { + if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag == 1) { int32_t iQp = pSlice->sSliceHeaderExt.sSliceHeader.iSliceQp; int32_t iCabacInitIdc = pSlice->sSliceHeaderExt.sSliceHeader.iCabacInitIdc; WelsCabacContextInit (pCtx, pSlice->eSliceType, iCabacInitIdc, iQp); @@ -1572,24 +1576,24 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal WelsCalcDeqCoeffScalingList (pCtx); iNextMbXyIndex = pSliceHeader->iFirstMbInSlice; - iMbX = iNextMbXyIndex % pCurLayer->iMbWidth; - iMbY = iNextMbXyIndex / pCurLayer->iMbWidth; // error is introduced by multiple slices case, 11/23/2009 + iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth; + iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth; // error is introduced by multiple slices case, 11/23/2009 pSlice->iMbSkipRun = -1; - iSliceIdc = (pSliceHeader->iFirstMbInSlice << 7) + pCurLayer->uiLayerDqId; + iSliceIdc = (pSliceHeader->iFirstMbInSlice << 7) + pCurDqLayer->uiLayerDqId; - pCurLayer->iMbX = iMbX; - pCurLayer->iMbY = iMbY; - pCurLayer->iMbXyIndex = iNextMbXyIndex; + pCurDqLayer->iMbX = iMbX; + pCurDqLayer->iMbY = iMbY; + pCurDqLayer->iMbXyIndex = iNextMbXyIndex; do { if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) { // slice group boundary or end of a frame break; } - pCurLayer->pSliceIdc[iNextMbXyIndex] = iSliceIdc; + pCurDqLayer->pSliceIdc[iNextMbXyIndex] = iSliceIdc; pCtx->bMbRefConcealed = false; iRet = pDecMbFunc (pCtx, pNalCur, uiEosFlag); - pCurLayer->pMbRefConcealedFlag[iNextMbXyIndex] = pCtx->bMbRefConcealed; + pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] = pCtx->bMbRefConcealed; if (iRet != ERR_NONE) { return iRet; } @@ -1603,21 +1607,185 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal } else { ++iNextMbXyIndex; } - iMbX = iNextMbXyIndex % pCurLayer->iMbWidth; - iMbY = iNextMbXyIndex / pCurLayer->iMbWidth; - pCurLayer->iMbX = iMbX; - pCurLayer->iMbY = iMbY; - pCurLayer->iMbXyIndex = iNextMbXyIndex; + iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth; + iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth; + pCurDqLayer->iMbX = iMbX; + pCurDqLayer->iMbY = iMbY; + pCurDqLayer->iMbXyIndex = iNextMbXyIndex; } while (1); return ERR_NONE; } +int32_t WelsDecodeAndConstructSlice (PWelsDecoderContext pCtx) { + PNalUnit pNalCur = pCtx->pNalCur; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PFmo pFmo = pCtx->pFmo; + int32_t iRet; + int32_t iNextMbXyIndex, iSliceIdc; + + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; + PSliceHeaderExt pSliceHeaderExt = &pSlice->sSliceHeaderExt; + PSliceHeader pSliceHeader = &pSliceHeaderExt->sSliceHeader; + int32_t iMbX, iMbY; + const int32_t kiCountNumMb = pSliceHeader->pSps->uiTotalMbCount; //need to be correct when fmo or multi slice + int32_t iTotalMbTargetLayer = kiCountNumMb; + uint32_t uiEosFlag = 0; + PWelsDecMbFunc pDecMbFunc; + + pSlice->iTotalMbInCurSlice = 0; //initialize at the starting of slice decoding. + + if (pCtx->pPps->bEntropyCodingModeFlag) { + if (pSlice->sSliceHeaderExt.bAdaptiveMotionPredFlag || + pSlice->sSliceHeaderExt.bAdaptiveBaseModeFlag || + pSlice->sSliceHeaderExt.bAdaptiveResidualPredFlag) { + WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, + "WelsDecodeSlice()::::ILP flag exist, not supported with CABAC enabled!"); + pCtx->iErrorCode |= dsBitstreamError; + return dsBitstreamError; + } + if (P_SLICE == pSliceHeader->eSliceType) + pDecMbFunc = WelsDecodeMbCabacPSlice; + else if (B_SLICE == pSliceHeader->eSliceType) + pDecMbFunc = WelsDecodeMbCabacBSlice; + else //I_SLICE. B_SLICE is being supported + pDecMbFunc = WelsDecodeMbCabacISlice; + } else { + if (P_SLICE == pSliceHeader->eSliceType) { + pDecMbFunc = WelsDecodeMbCavlcPSlice; + } else if (B_SLICE == pSliceHeader->eSliceType) { + pDecMbFunc = WelsDecodeMbCavlcBSlice; + } else { //I_SLICE + pDecMbFunc = WelsDecodeMbCavlcISlice; + } + } + + if (pSliceHeader->pPps->bConstainedIntraPredFlag) { + pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain1IntraNxN; + pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleConstrain1; + pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleConstrain1; + } else { + pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain0IntraNxN; + pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleNormal; + pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleNormal; + } + + pCtx->eSliceType = pSliceHeader->eSliceType; + if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag == 1) { + int32_t iQp = pSlice->sSliceHeaderExt.sSliceHeader.iSliceQp; + int32_t iCabacInitIdc = pSlice->sSliceHeaderExt.sSliceHeader.iCabacInitIdc; + WelsCabacContextInit (pCtx, pSlice->eSliceType, iCabacInitIdc, iQp); + //InitCabacCtx (pCtx->pCabacCtx, pSlice->eSliceType, iCabacInitIdc, iQp); + pSlice->iLastDeltaQp = 0; + WELS_READ_VERIFY (InitCabacDecEngineFromBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux)); + } + //try to calculate the dequant_coeff + WelsCalcDeqCoeffScalingList (pCtx); + + iNextMbXyIndex = pSliceHeader->iFirstMbInSlice; + iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth; + iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth; // error is introduced by multiple slices case, 11/23/2009 + pSlice->iMbSkipRun = -1; + iSliceIdc = (pSliceHeader->iFirstMbInSlice << 7) + pCurDqLayer->uiLayerDqId; + + pCurDqLayer->iMbX = iMbX; + pCurDqLayer->iMbY = iMbY; + pCurDqLayer->iMbXyIndex = iNextMbXyIndex; + + PDeblockingFilterMbFunc pDeblockMb = WelsDeblockingMb; + + SDeblockingFilter pFilter; + int32_t iFilterIdc = 1; + if (pSliceHeader->uiDisableDeblockingFilterIdc != 1) { + WelsDeblockingInitFilter (pCtx, pFilter, iFilterIdc); + } + + do { + if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) { // slice group boundary or end of a frame + break; + } + + pCurDqLayer->pSliceIdc[iNextMbXyIndex] = iSliceIdc; + pCtx->bMbRefConcealed = false; + iRet = pDecMbFunc (pCtx, pNalCur, uiEosFlag); + pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] = pCtx->bMbRefConcealed; + if (iRet != ERR_NONE) { + return iRet; + } + if (WelsTargetMbConstruction (pCtx)) { + WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, + "WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d", + pCurDqLayer->iMbX, pCurDqLayer->iMbY, pSlice->eSliceType); + + return ERR_INFO_MB_RECON_FAIL; + } + memcpy (pCtx->pDec->pNzc[pCurDqLayer->iMbXyIndex], pCurDqLayer->pNzc[pCurDqLayer->iMbXyIndex], 24); + if (pCtx->eSliceType != I_SLICE) { + pCtx->sBlockFunc.pWelsSetNonZeroCountFunc ( + pCtx->pDec->pNzc[pCurDqLayer->iMbXyIndex]); // set all none-zero nzc to 1; dbk can be opti! + } + WelsDeblockingFilterMB (pCurDqLayer, pFilter, iFilterIdc, pDeblockMb); + if (pCtx->uiNalRefIdc > 0) { + if (pCurDqLayer->iMbX == 0 || pCurDqLayer->iMbX == pCurDqLayer->iMbWidth - 1 || pCurDqLayer->iMbY == 0 + || pCurDqLayer->iMbY == pCurDqLayer->iMbHeight - 1) { + PadMBLuma_c (pCurDqLayer->pDec->pData[0], pCurDqLayer->pDec->iLinesize[0], pCurDqLayer->pDec->iWidthInPixel, + pCurDqLayer->pDec->iHeightInPixel, pCurDqLayer->iMbX, pCurDqLayer->iMbY, pCurDqLayer->iMbWidth, pCurDqLayer->iMbHeight); + PadMBChroma_c (pCurDqLayer->pDec->pData[1], pCurDqLayer->pDec->iLinesize[1], pCurDqLayer->pDec->iWidthInPixel / 2, + pCurDqLayer->pDec->iHeightInPixel / 2, pCurDqLayer->iMbX, pCurDqLayer->iMbY, pCurDqLayer->iMbWidth, + pCurDqLayer->iMbHeight); + PadMBChroma_c (pCurDqLayer->pDec->pData[2], pCurDqLayer->pDec->iLinesize[2], pCurDqLayer->pDec->iWidthInPixel / 2, + pCurDqLayer->pDec->iHeightInPixel / 2, pCurDqLayer->iMbX, pCurDqLayer->iMbY, pCurDqLayer->iMbWidth, + pCurDqLayer->iMbHeight); + } + } + if (!pCurDqLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex]) { //already con-ed, overwrite + pCurDqLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex] = true; + pCtx->pDec->iMbEcedPropNum += (pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] ? 1 : 0); + ++pCtx->iTotalNumMbRec; + } + + if (pCtx->iTotalNumMbRec > iTotalMbTargetLayer) { + WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, + "WelsTargetSliceConstruction():::pCtx->iTotalNumMbRec:%d, iTotalMbTargetLayer:%d", + pCtx->iTotalNumMbRec, iTotalMbTargetLayer); + + return ERR_INFO_MB_NUM_EXCEED_FAIL; + } + + ++pSlice->iTotalMbInCurSlice; + if (uiEosFlag) { //end of slice + SET_EVENT (&pCtx->pDec->pReadyEvent[pCurDqLayer->iMbY]); + break; + } + if (pSliceHeader->pPps->uiNumSliceGroups > 1) { + iNextMbXyIndex = FmoNextMb (pFmo, iNextMbXyIndex); + } else { + ++iNextMbXyIndex; + } + int32_t iLastMby = iMbY; + int32_t iLastMbx = iMbX; + iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth; + iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth; + pCurDqLayer->iMbX = iMbX; + pCurDqLayer->iMbY = iMbY; + pCurDqLayer->iMbXyIndex = iNextMbXyIndex; + if (GetThreadCount (pCtx) > 1) { + if ((iMbY > iLastMby) && (iLastMbx == pCurDqLayer->iMbWidth - 1)) { + SET_EVENT (&pCtx->pDec->pReadyEvent[iLastMby]); + } + } + } while (1); + if (GetThreadCount (pCtx) > 1) { + SET_EVENT (&pCtx->pDec->pReadyEvent[pCurDqLayer->iMbY]); + } + return ERR_NONE; +} + int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { - SVlcTable* pVlcTable = &pCtx->sVlcTable; - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + SVlcTable* pVlcTable = pCtx->pVlcTable; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurDqLayer->pBitStringAux; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; SWelsNeighAvail sNeighAvail; @@ -1626,10 +1794,10 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; - int32_t iMbX = pCurLayer->iMbX; - int32_t iMbY = pCurLayer->iMbY; - const int32_t iMbXy = pCurLayer->iMbXyIndex; - int8_t* pNzc = pCurLayer->pNzc[iMbXy]; + int32_t iMbX = pCurDqLayer->iMbX; + int32_t iMbY = pCurDqLayer->iMbY; + const int32_t iMbXy = pCurDqLayer->iMbXyIndex; + int8_t* pNzc = pCurDqLayer->pNzc[iMbXy]; int32_t i; int32_t iRet = ERR_NONE; uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0; @@ -1637,12 +1805,12 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { int32_t iCode; ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); - GetNeighborAvailMbType (&sNeighAvail, pCurLayer); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; - pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; + GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer); + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; + pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType uiMbType = uiCode; @@ -1653,15 +1821,15 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { if (25 == uiMbType) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "I_PCM mode exists in I slice!"); - int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0]; - int32_t iDecStrideC = pCurLayer->pDec->iLinesize[1]; + int32_t iDecStrideL = pCurDqLayer->pDec->iLinesize[0]; + int32_t iDecStrideC = pCurDqLayer->pDec->iLinesize[1]; int32_t iOffsetL = (iMbX + iMbY * iDecStrideL) << 4; int32_t iOffsetC = (iMbX + iMbY * iDecStrideC) << 3; - uint8_t* pDecY = pCurLayer->pDec->pData[0] + iOffsetL; - uint8_t* pDecU = pCurLayer->pDec->pData[1] + iOffsetC; - uint8_t* pDecV = pCurLayer->pDec->pData[2] + iOffsetC; + uint8_t* pDecY = pCurDqLayer->pDec->pData[0] + iOffsetL; + uint8_t* pDecU = pCurDqLayer->pDec->pData[1] + iOffsetC; + uint8_t* pDecV = pCurDqLayer->pDec->pData[2] + iOffsetC; uint8_t* pTmpBsBuf; @@ -1672,7 +1840,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { int32_t iIndex = ((-pBs->iLeftBits) >> 3) + 2; - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA_PCM; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA_PCM; //step 1: locating bit-stream pointer [must align into integer byte] pBs->pCurBuf -= iIndex; @@ -1700,27 +1868,27 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { pBs->pCurBuf += 384; //step 3: update QP and pNonZeroCount - pCurLayer->pLumaQp[iMbXy] = 0; - memset (pCurLayer->pChromaQp[iMbXy], 0, sizeof (pCurLayer->pChromaQp[iMbXy])); - memset (pNzc, 16, sizeof (pCurLayer->pNzc[iMbXy])); //Rec. 9.2.1 for PCM, nzc=16 + pCurDqLayer->pLumaQp[iMbXy] = 0; + memset (pCurDqLayer->pChromaQp[iMbXy], 0, sizeof (pCurDqLayer->pChromaQp[iMbXy])); + memset (pNzc, 16, sizeof (pCurDqLayer->pNzc[iMbXy])); //Rec. 9.2.1 for PCM, nzc=16 WELS_READ_VERIFY (InitReadBits (pBs, 0)); return ERR_NONE; } else if (0 == uiMbType) { //reference to JM ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4; if (pCtx->pPps->bTransform8x8ModeFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag - pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; - if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { - uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { + uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8; } } - if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) { - pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); + if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer)); } else { - pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer)); } //uiCbp @@ -1736,19 +1904,19 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { uiCbp = g_kuiIntra4x4CbpTable[uiCbp]; else uiCbp = g_kuiIntra4x4CbpTable400[uiCbp]; - pCurLayer->pCbp[iMbXy] = uiCbp; + pCurDqLayer->pCbp[iMbXy] = uiCbp; uiCbpC = uiCbp >> 4; uiCbpL = uiCbp & 15; } else { //I_PCM exclude, we can ignore it - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; - pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; - uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; - uiCbpL = pCurLayer->pCbp[iMbXy] & 15; - WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer); - WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)); + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; + pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; + uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0; + uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15; + WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurDqLayer)); } ST32A4 (&pNzc[0], 0); @@ -1758,17 +1926,17 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { ST32A4 (&pNzc[16], 0); ST32A4 (&pNzc[20], 0); - if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurLayer->pMbType[iMbXy])) { - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; + if (pCurDqLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurDqLayer->pDec->pMbType[iMbXy])) { + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } } - if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { - memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0])); + if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { + memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0])); int32_t iQpDelta, iId8x8, iId4x4; WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //mb_qp_delta @@ -1778,29 +1946,29 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP); } - pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp - pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy]; + pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp + pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy]; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, - 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, + 51)]; } BsStartCavlc (pBs); - if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { //step1: Luma DC if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan, I16_LUMA_DC, - pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } //step2: Luma AC if (uiCbpL) { for (i = 0; i < 16; i++) { if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, - g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } } @@ -1810,15 +1978,15 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); } } else { //non-MB_TYPE_INTRA16x16 - if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { - iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8; + iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8; if (uiCbpL & (1 << iId8x8)) { int32_t iIndex = (iId8x8 << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { if ((iRet = WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet; } iIndex++; @@ -1839,8 +2007,8 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { //Luma (DC and AC decoding together) if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } iIndex++; @@ -1863,7 +2031,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { for (i = 0; i < 2; i++) { //Cb Cr iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U; if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, - pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { + pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { return iRet;//abnormal } } @@ -1876,8 +2044,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { int32_t iIndex = 16 + (i << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - WELS_MAX (iScanIdxStart, - 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), - pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { + 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, + pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), + pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { return iRet;//abnormal } iIndex++; @@ -1895,9 +2064,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { } int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSliceHeaderExt pSliceHeaderExt = &pCurLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurDqLayer->pBitStringAux; + PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt; int32_t iBaseModeFlag; int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15 uint32_t uiCode; @@ -1922,7 +2091,7 @@ int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin // check whether there is left bits to read next time in case multiple slices iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits); // sub 1, for stop bit - if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary + if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary uiEosFlag = 1; } if (iUsedBits > (pBs->iBits - @@ -1936,20 +2105,20 @@ int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin } int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { - SVlcTable* pVlcTable = &pCtx->sVlcTable; - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + SVlcTable* pVlcTable = pCtx->pVlcTable; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurDqLayer->pBitStringAux; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; SWelsNeighAvail sNeighAvail; - int32_t iMbX = pCurLayer->iMbX; - int32_t iMbY = pCurLayer->iMbY; - const int32_t iMbXy = pCurLayer->iMbXyIndex; - int8_t* pNzc = pCurLayer->pNzc[iMbXy]; + int32_t iMbX = pCurDqLayer->iMbX; + int32_t iMbY = pCurDqLayer->iMbY; + const int32_t iMbXy = pCurDqLayer->iMbXyIndex; + int8_t* pNzc = pCurDqLayer->pNzc[iMbXy]; int32_t i; int32_t iRet = ERR_NONE; uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0; @@ -1957,16 +2126,16 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { int32_t iCode; int32_t iMbResProperty; - GetNeighborAvailMbType (&sNeighAvail, pCurLayer); + GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer); ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23 + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType uiMbType = uiCode; if (uiMbType < 5) { //inter MB type int16_t iMotionVector[LIST_A][30][MV_A]; int8_t iRefIndex[LIST_A][30]; - pCurLayer->pMbType[iMbXy] = g_ksInterPMbTypeInfo[uiMbType].iType; - WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer); + pCurDqLayer->pDec->pMbType[iMbXy] = g_ksInterPMbTypeInfo[uiMbType].iType; + WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurDqLayer); if ((iRet = ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) != ERR_NONE) { return iRet;//abnormal @@ -1974,13 +2143,13 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { if (pSlice->sSliceHeaderExt.bAdaptiveResidualPredFlag == 1) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //residual_prediction_flag - pCurLayer->pResidualPredFlag[iMbXy] = uiCode; + pCurDqLayer->pResidualPredFlag[iMbXy] = uiCode; } else { - pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; + pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; } - if (pCurLayer->pResidualPredFlag[iMbXy] == 0) { - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; + if (pCurDqLayer->pResidualPredFlag[iMbXy] == 0) { + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "residual_pred_flag = 1 not supported."); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -1994,15 +2163,15 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { if (25 == uiMbType) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "I_PCM mode exists in P slice!"); - int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0]; - int32_t iDecStrideC = pCurLayer->pDec->iLinesize[1]; + int32_t iDecStrideL = pCurDqLayer->pDec->iLinesize[0]; + int32_t iDecStrideC = pCurDqLayer->pDec->iLinesize[1]; int32_t iOffsetL = (iMbX + iMbY * iDecStrideL) << 4; int32_t iOffsetC = (iMbX + iMbY * iDecStrideC) << 3; - uint8_t* pDecY = pCurLayer->pDec->pData[0] + iOffsetL; - uint8_t* pDecU = pCurLayer->pDec->pData[1] + iOffsetC; - uint8_t* pDecV = pCurLayer->pDec->pData[2] + iOffsetC; + uint8_t* pDecY = pCurDqLayer->pDec->pData[0] + iOffsetL; + uint8_t* pDecU = pCurDqLayer->pDec->pData[1] + iOffsetC; + uint8_t* pDecV = pCurDqLayer->pDec->pData[2] + iOffsetC; uint8_t* pTmpBsBuf; @@ -2012,7 +2181,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { int32_t iIndex = ((-pBs->iLeftBits) >> 3) + 2; - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA_PCM; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA_PCM; //step 1: locating bit-stream pointer [must align into integer byte] pBs->pCurBuf -= iIndex; @@ -2041,8 +2210,8 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { pBs->pCurBuf += 384; //step 3: update QP and pNonZeroCount - pCurLayer->pLumaQp[iMbXy] = 0; - pCurLayer->pChromaQp[iMbXy][0] = pCurLayer->pChromaQp[iMbXy][1] = 0; + pCurDqLayer->pLumaQp[iMbXy] = 0; + pCurDqLayer->pChromaQp[iMbXy][0] = pCurDqLayer->pChromaQp[iMbXy][1] = 0; //Rec. 9.2.1 for PCM, nzc=16 ST32A4 (&pNzc[0], 0x10101010); ST32A4 (&pNzc[4], 0x10101010); @@ -2055,38 +2224,38 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { } else { if (0 == uiMbType) { ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4; if (pCtx->pPps->bTransform8x8ModeFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag - pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; - if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { - uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { + uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8; } } - if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) { - pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); + if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer)); } else { - pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer)); } } else { //I_PCM exclude, we can ignore it - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; - pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; - uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; - uiCbpL = pCurLayer->pCbp[iMbXy] & 15; - WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer); - if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)) != ERR_NONE) { + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; + pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; + uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0; + uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15; + WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurDqLayer); + if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurDqLayer)) != ERR_NONE) { return iRet; } } } } - if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern uiCbp = uiCode; { @@ -2094,29 +2263,29 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP); if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15)) return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP); - if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA4x4 == pCurDqLayer->pDec->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurDqLayer->pDec->pMbType[iMbXy]) { uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp]; } else //inter uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiInterCbpTable[uiCbp] : g_kuiInterCbpTable400[uiCbp]; } - pCurLayer->pCbp[iMbXy] = uiCbp; - uiCbpC = pCurLayer->pCbp[iMbXy] >> 4; - uiCbpL = pCurLayer->pCbp[iMbXy] & 15; + pCurDqLayer->pCbp[iMbXy] = uiCbp; + uiCbpC = pCurDqLayer->pCbp[iMbXy] >> 4; + uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15; // Need modification when B picutre add in bool bNeedParseTransformSize8x8Flag = - (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16) - || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) - && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8) - && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4) + (((pCurDqLayer->pDec->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurDqLayer->pDec->pMbType[iMbXy] <= MB_TYPE_8x16) + || pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) + && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA8x8) + && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA4x4) && (uiCbpL > 0) && (pCtx->pPps->bTransform8x8ModeFlag)); if (bNeedParseTransformSize8x8Flag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag - pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; } } @@ -2126,17 +2295,18 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { ST32A4 (&pNzc[12], 0); ST32A4 (&pNzc[16], 0); ST32A4 (&pNzc[20], 0); - if (pCurLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurLayer->pMbType[iMbXy]) && !IS_I_BL (pCurLayer->pMbType[iMbXy])) { - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; + if (pCurDqLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurDqLayer->pDec->pMbType[iMbXy]) + && !IS_I_BL (pCurDqLayer->pDec->pMbType[iMbXy])) { + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } } - if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { int32_t iQpDelta, iId8x8, iId4x4; - memset (pCurLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t)); + memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t)); WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //mb_qp_delta iQpDelta = iCode; @@ -2144,28 +2314,28 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP); } - pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp - pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy]; + pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp + pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy]; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, - 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, + 51)]; } BsStartCavlc (pBs); - if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { //step1: Luma DC if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan, I16_LUMA_DC, - pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } //step2: Luma AC if (uiCbpL) { for (i = 0; i < 16; i++) { if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, - g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } } @@ -2175,15 +2345,15 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); } } else { //non-MB_TYPE_INTRA16x16 - if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { - iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8; + iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8; if (uiCbpL & (1 << iId8x8)) { int32_t iIndex = (iId8x8 << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { if ((iRet = WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet; } iIndex++; @@ -2199,14 +2369,14 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); } else { // Normal T4x4 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { - iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; + iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; if (uiCbpL & (1 << iId8x8)) { int32_t iIndex = (iId8x8 << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { //Luma (DC and AC decoding together) if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } iIndex++; @@ -2228,13 +2398,13 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { //step1: DC if (1 == uiCbpC || 2 == uiCbpC) { for (i = 0; i < 2; i++) { //Cb Cr - if (IS_INTRA (pCurLayer->pMbType[iMbXy])) + if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U; else iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER; if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, - pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { + pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { return iRet;//abnormal } } @@ -2243,7 +2413,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { //step2: AC if (2 == uiCbpC) { for (i = 0; i < 2; i++) { //Cb Cr - if (IS_INTRA (pCurLayer->pMbType[iMbXy])) + if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U; else iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER; @@ -2251,8 +2421,9 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { int32_t iIndex = 16 + (i << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - WELS_MAX (iScanIdxStart, - 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), - pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { + 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, + pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), + pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { return iRet;//abnormal } iIndex++; @@ -2270,20 +2441,20 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { } int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurDqLayer->pBitStringAux; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; intX_t iUsedBits; - const int32_t iMbXy = pCurLayer->iMbXyIndex; - int8_t* pNzc = pCurLayer->pNzc[iMbXy]; + const int32_t iMbXy = pCurDqLayer->iMbXyIndex; + int8_t* pNzc = pCurDqLayer->pNzc[iMbXy]; int32_t iBaseModeFlag, i; int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15 uint32_t uiCode; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; if (-1 == pSlice->iMbSkipRun) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run @@ -2295,7 +2466,7 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin if (pSlice->iMbSkipRun--) { int16_t iMv[2]; - pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP; ST32A4 (&pNzc[0], 0); ST32A4 (&pNzc[4], 0); ST32A4 (&pNzc[8], 0); @@ -2303,30 +2474,32 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin ST32A4 (&pNzc[16], 0); ST32A4 (&pNzc[20], 0); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; - memset (pCurLayer->pRefIndex[0][iMbXy], 0, sizeof (int8_t) * 16); - pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[0] && ppRefPic[0]->bIsComplete); + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; + memset (pCurDqLayer->pDec->pRefIndex[0][iMbXy], 0, sizeof (int8_t) * 16); + bool bIsPending = GetThreadCount (pCtx) > 1; + pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[0] && (ppRefPic[0]->bIsComplete + || bIsPending)); //predict iMv - PredPSkipMvFromNeighbor (pCurLayer, iMv); + PredPSkipMvFromNeighbor (pCurDqLayer, iMv); for (i = 0; i < 16; i++) { - ST32A2 (pCurLayer->pMv[0][iMbXy][i], * (uint32_t*)iMv); + ST32A2 (pCurDqLayer->pDec->pMv[0][iMbXy][i], * (uint32_t*)iMv); } //if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag) { - // memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t)); + // memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t)); //} //reset rS if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag || (pNalCur->sNalHeaderExt.uiQualityId == 0 && pNalCur->sNalHeaderExt.uiDependencyId == 0)) { - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } } - pCurLayer->pCbp[iMbXy] = 0; + pCurDqLayer->pCbp[iMbXy] = 0; } else { if (pSlice->sSliceHeaderExt.bAdaptiveBaseModeFlag == 1) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //base_mode_flag @@ -2348,7 +2521,7 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin // check whether there is left bits to read next time in case multiple slices iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits); // sub 1, for stop bit - if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary + if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary uiEosFlag = 1; } if (iUsedBits > (pBs->iBits - @@ -2362,21 +2535,21 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin } int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurDqLayer->pBitStringAux; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PPicture* ppRefPicL0 = pCtx->sRefPic.pRefList[LIST_0]; PPicture* ppRefPicL1 = pCtx->sRefPic.pRefList[LIST_1]; intX_t iUsedBits; - const int32_t iMbXy = pCurLayer->iMbXyIndex; - int8_t* pNzc = pCurLayer->pNzc[iMbXy]; + const int32_t iMbXy = pCurDqLayer->iMbXyIndex; + int8_t* pNzc = pCurDqLayer->pNzc[iMbXy]; int32_t iBaseModeFlag, i; int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15 uint32_t uiCode; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; if (-1 == pSlice->iMbSkipRun) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run @@ -2389,7 +2562,7 @@ int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin int16_t iMv[LIST_A][2] = { { 0, 0 }, { 0, 0 } }; int8_t ref[LIST_A] = { 0 }; - pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP | MB_TYPE_DIRECT; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP | MB_TYPE_DIRECT; ST32A4 (&pNzc[0], 0); ST32A4 (&pNzc[4], 0); ST32A4 (&pNzc[8], 0); @@ -2397,11 +2570,12 @@ int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin ST32A4 (&pNzc[16], 0); ST32A4 (&pNzc[20], 0); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; - memset (pCurLayer->pRefIndex[LIST_0][iMbXy], 0, sizeof (int8_t) * 16); - memset (pCurLayer->pRefIndex[LIST_1][iMbXy], 0, sizeof (int8_t) * 16); - pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete) - || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete); + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; + memset (pCurDqLayer->pDec->pRefIndex[LIST_0][iMbXy], 0, sizeof (int8_t) * 16); + memset (pCurDqLayer->pDec->pRefIndex[LIST_1][iMbXy], 0, sizeof (int8_t) * 16); + bool bIsPending = GetThreadCount (pCtx) > 1; + pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && (ppRefPicL0[0]->bIsComplete + || bIsPending)) || ! (ppRefPicL1[0] && (ppRefPicL1[0]->bIsComplete || bIsPending)); /*if (pCtx->bMbRefConcealed) { SLogContext* pLogCtx = & (pCtx->sLogCtx); @@ -2426,20 +2600,20 @@ int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin } //if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag) { - // memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t)); + // memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t)); //} //reset rS if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag || (pNalCur->sNalHeaderExt.uiQualityId == 0 && pNalCur->sNalHeaderExt.uiDependencyId == 0)) { - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } } - pCurLayer->pCbp[iMbXy] = 0; + pCurDqLayer->pCbp[iMbXy] = 0; } else { if (pSlice->sSliceHeaderExt.bAdaptiveBaseModeFlag == 1) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //base_mode_flag @@ -2461,7 +2635,7 @@ int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin // check whether there is left bits to read next time in case multiple slices iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits); // sub 1, for stop bit - if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary + if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary uiEosFlag = 1; } if (iUsedBits > (pBs->iBits - @@ -2475,20 +2649,20 @@ int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin } int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { - SVlcTable* pVlcTable = &pCtx->sVlcTable; - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + SVlcTable* pVlcTable = pCtx->pVlcTable; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurDqLayer->pBitStringAux; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; SWelsNeighAvail sNeighAvail; - int32_t iMbX = pCurLayer->iMbX; - int32_t iMbY = pCurLayer->iMbY; - const int32_t iMbXy = pCurLayer->iMbXyIndex; - int8_t* pNzc = pCurLayer->pNzc[iMbXy]; + int32_t iMbX = pCurDqLayer->iMbX; + int32_t iMbY = pCurDqLayer->iMbY; + const int32_t iMbXy = pCurDqLayer->iMbXyIndex; + int8_t* pNzc = pCurDqLayer->pNzc[iMbXy]; int32_t i; int32_t iRet = ERR_NONE; uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0; @@ -2496,16 +2670,16 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { int32_t iCode; int32_t iMbResProperty; - GetNeighborAvailMbType (&sNeighAvail, pCurLayer); + GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer); ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23 + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType uiMbType = uiCode; if (uiMbType < 23) { //inter MB type int16_t iMotionVector[LIST_A][30][MV_A]; int8_t iRefIndex[LIST_A][30]; - pCurLayer->pMbType[iMbXy] = g_ksInterBMbTypeInfo[uiMbType].iType; - WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer); + pCurDqLayer->pDec->pMbType[iMbXy] = g_ksInterBMbTypeInfo[uiMbType].iType; + WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurDqLayer); if ((iRet = ParseInterBInfo (pCtx, iMotionVector, iRefIndex, pBs)) != ERR_NONE) { return iRet;//abnormal @@ -2513,13 +2687,13 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { if (pSlice->sSliceHeaderExt.bAdaptiveResidualPredFlag == 1) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //residual_prediction_flag - pCurLayer->pResidualPredFlag[iMbXy] = uiCode; + pCurDqLayer->pResidualPredFlag[iMbXy] = uiCode; } else { - pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; + pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; } - if (pCurLayer->pResidualPredFlag[iMbXy] == 0) { - pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; + if (pCurDqLayer->pResidualPredFlag[iMbXy] == 0) { + pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0; } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "residual_pred_flag = 1 not supported."); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -2533,15 +2707,15 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { if (25 == uiMbType) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "I_PCM mode exists in B slice!"); - int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0]; - int32_t iDecStrideC = pCurLayer->pDec->iLinesize[1]; + int32_t iDecStrideL = pCurDqLayer->pDec->iLinesize[0]; + int32_t iDecStrideC = pCurDqLayer->pDec->iLinesize[1]; int32_t iOffsetL = (iMbX + iMbY * iDecStrideL) << 4; int32_t iOffsetC = (iMbX + iMbY * iDecStrideC) << 3; - uint8_t* pDecY = pCurLayer->pDec->pData[0] + iOffsetL; - uint8_t* pDecU = pCurLayer->pDec->pData[1] + iOffsetC; - uint8_t* pDecV = pCurLayer->pDec->pData[2] + iOffsetC; + uint8_t* pDecY = pCurDqLayer->pDec->pData[0] + iOffsetL; + uint8_t* pDecU = pCurDqLayer->pDec->pData[1] + iOffsetC; + uint8_t* pDecV = pCurDqLayer->pDec->pData[2] + iOffsetC; uint8_t* pTmpBsBuf; @@ -2551,7 +2725,7 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { int32_t iIndex = ((-pBs->iLeftBits) >> 3) + 2; - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA_PCM; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA_PCM; //step 1: locating bit-stream pointer [must align into integer byte] pBs->pCurBuf -= iIndex; @@ -2580,8 +2754,8 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { pBs->pCurBuf += 384; //step 3: update QP and pNonZeroCount - pCurLayer->pLumaQp[iMbXy] = 0; - pCurLayer->pChromaQp[iMbXy][0] = pCurLayer->pChromaQp[iMbXy][1] = 0; + pCurDqLayer->pLumaQp[iMbXy] = 0; + pCurDqLayer->pChromaQp[iMbXy][0] = pCurDqLayer->pChromaQp[iMbXy][1] = 0; //Rec. 9.2.1 for PCM, nzc=16 ST32A4 (&pNzc[0], 0x10101010); ST32A4 (&pNzc[4], 0x10101010); @@ -2594,38 +2768,38 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { } else { if (0 == uiMbType) { ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4; if (pCtx->pPps->bTransform8x8ModeFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag - pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; - if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { - uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { + uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8; } } - if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) { - pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); + if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer)); } else { - pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); - WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer); + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer)); } } else { //I_PCM exclude, we can ignore it - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; - pCurLayer->pTransformSize8x8Flag[iMbXy] = false; - pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; - pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; - pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; - uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; - uiCbpL = pCurLayer->pCbp[iMbXy] & 15; - WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer); - if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)) != ERR_NONE) { + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false; + pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; + pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; + pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; + uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0; + uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15; + WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurDqLayer); + if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurDqLayer)) != ERR_NONE) { return iRet; } } } } - if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern uiCbp = uiCode; { @@ -2633,29 +2807,29 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP); if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15)) return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP); - if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA4x4 == pCurDqLayer->pDec->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurDqLayer->pDec->pMbType[iMbXy]) { uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp]; } else //inter uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiInterCbpTable[uiCbp] : g_kuiInterCbpTable400[uiCbp]; } - pCurLayer->pCbp[iMbXy] = uiCbp; - uiCbpC = pCurLayer->pCbp[iMbXy] >> 4; - uiCbpL = pCurLayer->pCbp[iMbXy] & 15; + pCurDqLayer->pCbp[iMbXy] = uiCbp; + uiCbpC = pCurDqLayer->pCbp[iMbXy] >> 4; + uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15; // Need modification when B picutre add in bool bNeedParseTransformSize8x8Flag = - (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16) - || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) - && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8) - && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4) + (((pCurDqLayer->pDec->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurDqLayer->pDec->pMbType[iMbXy] <= MB_TYPE_8x16) + || pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) + && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA8x8) + && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA4x4) && (uiCbpL > 0) && (pCtx->pPps->bTransform8x8ModeFlag)); if (bNeedParseTransformSize8x8Flag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag - pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; + pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; } } @@ -2665,17 +2839,18 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { ST32A4 (&pNzc[12], 0); ST32A4 (&pNzc[16], 0); ST32A4 (&pNzc[20], 0); - if (pCurLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurLayer->pMbType[iMbXy]) && !IS_I_BL (pCurLayer->pMbType[iMbXy])) { - pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; + if (pCurDqLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurDqLayer->pDec->pMbType[iMbXy]) + && !IS_I_BL (pCurDqLayer->pDec->pMbType[iMbXy])) { + pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)]; } } - if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { int32_t iQpDelta, iId8x8, iId4x4; - memset (pCurLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t)); + memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t)); WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //mb_qp_delta iQpDelta = iCode; @@ -2683,28 +2858,28 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP); } - pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp - pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy]; + pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp + pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy]; for (i = 0; i < 2; i++) { - pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + - pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, - 51)]; + pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp + + pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, + 51)]; } BsStartCavlc (pBs); - if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { + if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) { //step1: Luma DC if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan, I16_LUMA_DC, - pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } //step2: Luma AC if (uiCbpL) { for (i = 0; i < 16; i++) { if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, - g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } } @@ -2714,15 +2889,15 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); } } else { //non-MB_TYPE_INTRA16x16 - if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { - iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8; + iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8; if (uiCbpL & (1 << iId8x8)) { int32_t iIndex = (iId8x8 << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { if ((iRet = WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet; } iIndex++; @@ -2738,14 +2913,14 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); } else { // Normal T4x4 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { - iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; + iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; if (uiCbpL & (1 << iId8x8)) { int32_t iIndex = (iId8x8 << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { //Luma (DC and AC decoding together) if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1, - g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), - pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { + g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), + pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) { return iRet;//abnormal } iIndex++; @@ -2767,13 +2942,13 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { //step1: DC if (1 == uiCbpC || 2 == uiCbpC) { for (i = 0; i < 2; i++) { //Cb Cr - if (IS_INTRA (pCurLayer->pMbType[iMbXy])) + if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U; else iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER; if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, - pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { + pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { return iRet;//abnormal } } @@ -2782,7 +2957,7 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { //step2: AC if (2 == uiCbpC) { for (i = 0; i < 2; i++) { //Cb Cr - if (IS_INTRA (pCurLayer->pMbType[iMbXy])) + if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U; else iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER; @@ -2790,8 +2965,9 @@ int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) { int32_t iIndex = 16 + (i << 2); for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - WELS_MAX (iScanIdxStart, - 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), - pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { + 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, + pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), + pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) { return iRet;//abnormal } iIndex++; @@ -2860,8 +3036,8 @@ void WelsBlockZero8x8_c (int16_t* pBlock, int32_t iStride) { // to all direct MBs in this slice, as per clause 8.4.1.2.3 // of T-REC H.264 201704 bool ComputeColocatedTemporalScaling (PWelsDecoderContext pCtx) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PSlice pCurSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + PSlice pCurSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pCurSlice->sSliceHeaderExt.sSliceHeader; if (!pSliceHeader->iDirectSpatialMvPredFlag) { uint32_t uiRefCount = pSliceHeader->uiRefCount[LIST_0]; diff --git a/src/openh264/codec/decoder/core/src/decoder.cpp b/src/openh264/codec/decoder/core/src/decoder.cpp old mode 100755 new mode 100644 index 93645f654..3b38032ac --- a/src/openh264/codec/decoder/core/src/decoder.cpp +++ b/src/openh264/codec/decoder/core/src/decoder.cpp @@ -52,6 +52,7 @@ #include "decode_slice.h" #include "error_concealment.h" #include "memory_align.h" +#include "wels_decoder_thread.h" namespace WelsDec { @@ -61,6 +62,7 @@ extern void FreePicture (PPicture pPic, CMemoryAlign* pMa); static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize, const int32_t kiPicWidth, const int32_t kiPicHeight) { + PPicBuff pPicBuf = NULL; int32_t iPicIdx = 0; if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { @@ -79,7 +81,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons if (NULL == pPicBuf->ppPic) { pPicBuf->iCapacity = 0; - DestroyPicBuff (&pPicBuf, pMa); + DestroyPicBuff (pCtx, &pPicBuf, pMa); return ERR_INFO_OUT_OF_MEMORY; } @@ -88,7 +90,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons if (NULL == pPic) { // init capacity first for free memory pPicBuf->iCapacity = iPicIdx; - DestroyPicBuff (&pPicBuf, pMa); + DestroyPicBuff (pCtx, &pPicBuf, pMa); return ERR_INFO_OUT_OF_MEMORY; } pPicBuf->ppPic[iPicIdx] = pPic; @@ -122,7 +124,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co if (NULL == pPicNewBuf->ppPic) { pPicNewBuf->iCapacity = 0; - DestroyPicBuff (&pPicNewBuf, pMa); + DestroyPicBuff (pCtx, &pPicNewBuf, pMa); return ERR_INFO_OUT_OF_MEMORY; } @@ -132,7 +134,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co if (NULL == pPic) { // Set maximum capacity as the new malloc memory at the tail pPicNewBuf->iCapacity = iPicIdx; - DestroyPicBuff (&pPicNewBuf, pMa); + DestroyPicBuff (pCtx, &pPicNewBuf, pMa); return ERR_INFO_OUT_OF_MEMORY; } pPicNewBuf->ppPic[iPicIdx] = pPic; @@ -149,8 +151,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { pPicNewBuf->ppPic[i]->bUsedAsRef = false; pPicNewBuf->ppPic[i]->bIsLongRef = false; - pPicNewBuf->ppPic[i]->uiRefCount = 0; - pPicNewBuf->ppPic[i]->bAvailableFlag = true; + pPicNewBuf->ppPic[i]->iRefCount = 0; pPicNewBuf->ppPic[i]->bIsComplete = false; } // remove old PicBuf @@ -186,13 +187,15 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co if (NULL == pPicNewBuf->ppPic) { pPicNewBuf->iCapacity = 0; - DestroyPicBuff (&pPicNewBuf, pMa); + DestroyPicBuff (pCtx, &pPicNewBuf, pMa); return ERR_INFO_OUT_OF_MEMORY; } + ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false); + int32_t iPrevPicIdx = -1; for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) { - if (pCtx->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) { + if (pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) { break; } } @@ -210,22 +213,12 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co } //update references due to allocation changes + //all references' references have to be reset oss-buzz 14423 for (int32_t i = 0; i < kiNewSize; i++) { for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { int32_t j = -1; while (++j < MAX_DPB_COUNT && pPicNewBuf->ppPic[i]->pRefPic[listIdx][j] != NULL) { - unsigned long long uiTimeStamp = pPicNewBuf->ppPic[i]->pRefPic[listIdx][j]->uiTimeStamp; - bool foundThePic = false; - for (int32_t k = 0; k < kiNewSize; k++) { - if (pPicNewBuf->ppPic[k]->uiTimeStamp == uiTimeStamp) { - pPicNewBuf->ppPic[i]->pRefPic[listIdx][j] = pPicNewBuf->ppPic[k]; - foundThePic = true; - break; - } - } - if (!foundThePic) { - pPicNewBuf->ppPic[i]->pRefPic[listIdx][j] = NULL; - } + pPicNewBuf->ppPic[i]->pRefPic[listIdx][j] = NULL; } } } @@ -246,8 +239,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { pPicNewBuf->ppPic[i]->bUsedAsRef = false; pPicNewBuf->ppPic[i]->bIsLongRef = false; - pPicNewBuf->ppPic[i]->uiRefCount = 0; - pPicNewBuf->ppPic[i]->bAvailableFlag = true; + pPicNewBuf->ppPic[i]->iRefCount = 0; pPicNewBuf->ppPic[i]->bIsComplete = false; } // remove old PicBuf @@ -263,9 +255,11 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co return ERR_NONE; } -void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { +void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa) { PPicBuff pPicBuf = NULL; + ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false); + if (NULL == ppPicBuf || NULL == *ppPicBuf) return; @@ -294,6 +288,24 @@ void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { *ppPicBuf = NULL; } +//reset picture reodering buffer list +void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo, + const bool& fullReset) { + if (pPictReoderingStatus != NULL && pPictInfo != NULL) { + int32_t pictInfoListCount = fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1); + pPictReoderingStatus->iPictInfoIndex = 0; + pPictReoderingStatus->iMinPOC = IMinInt32; + pPictReoderingStatus->iNumOfPicts = 0; + pPictReoderingStatus->iLastGOPRemainPicts = 0; + pPictReoderingStatus->iLastWrittenPOC = IMinInt32; + pPictReoderingStatus->iLargestBufferedPicIndex = 0; + for (int32_t i = 0; i < pictInfoListCount; ++i) { + pPictInfo[i].bLastGOP = false; + pPictInfo[i].iPOC = IMinInt32; + } + } +} + /* * fill data fields in default for decoder context */ @@ -318,7 +330,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { pCtx->bFreezeOutput = true; pCtx->iFrameNum = -1; - pCtx->iPrevFrameNum = -1; + pCtx->pLastDecPicInfo->iPrevFrameNum = -1; pCtx->iErrorCode = ERR_NONE; pCtx->pDec = NULL; @@ -331,31 +343,91 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { pCtx->pPicBuff = NULL; - pCtx->bAvcBasedFlag = true; - pCtx->pPreviousDecodedPictureInDpb = NULL; - pCtx->sDecoderStatistics.iAvgLumaQp = -1; - pCtx->sDecoderStatistics.iStatisticsLogInterval = 1000; + //pCtx->sSpsPpsCtx.bAvcBasedFlag = true; + pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL; + pCtx->pDecoderStatistics->iAvgLumaQp = -1; + pCtx->pDecoderStatistics->iStatisticsLogInterval = 1000; pCtx->bUseScalingList = false; - pCtx->iSpsErrorIgnored = 0; - pCtx->iSubSpsErrorIgnored = 0; - pCtx->iPpsErrorIgnored = 0; - pCtx->iPPSInvalidNum = 0; - pCtx->iPPSLastInvalidId = -1; - pCtx->iSPSInvalidNum = 0; - pCtx->iSPSLastInvalidId = -1; - pCtx->iSubSPSInvalidNum = 0; - pCtx->iSubSPSLastInvalidId = -1; + /*pCtx->sSpsPpsCtx.iSpsErrorIgnored = 0; + pCtx->sSpsPpsCtx.iSubSpsErrorIgnored = 0; + pCtx->sSpsPpsCtx.iPpsErrorIgnored = 0; + pCtx->sSpsPpsCtx.iPPSInvalidNum = 0; + pCtx->sSpsPpsCtx.iPPSLastInvalidId = -1; + pCtx->sSpsPpsCtx.iSPSInvalidNum = 0; + pCtx->sSpsPpsCtx.iSPSLastInvalidId = -1; + pCtx->sSpsPpsCtx.iSubSPSInvalidNum = 0; + pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = -1; + */ pCtx->iFeedbackNalRefIdc = -1; //initialize - pCtx->iPrevPicOrderCntMsb = 0; - pCtx->iPrevPicOrderCntLsb = 0; + pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0; + pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0; } +/* +* fill data fields in SPS and PPS default for decoder context +*/ +void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx) { + sSpsPpsCtx.bSpsExistAheadFlag = false; + sSpsPpsCtx.bSubspsExistAheadFlag = false; + sSpsPpsCtx.bPpsExistAheadFlag = false; + sSpsPpsCtx.bAvcBasedFlag = true; + sSpsPpsCtx.iSpsErrorIgnored = 0; + sSpsPpsCtx.iSubSpsErrorIgnored = 0; + sSpsPpsCtx.iPpsErrorIgnored = 0; + sSpsPpsCtx.iPPSInvalidNum = 0; + sSpsPpsCtx.iPPSLastInvalidId = -1; + sSpsPpsCtx.iSPSInvalidNum = 0; + sSpsPpsCtx.iSPSLastInvalidId = -1; + sSpsPpsCtx.iSubSPSInvalidNum = 0; + sSpsPpsCtx.iSubSPSLastInvalidId = -1; + sSpsPpsCtx.iSeqId = -1; +} + +/* +* fill last decoded picture info +*/ +void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo) { + sLastDecPicInfo.iPrevPicOrderCntMsb = 0; + sLastDecPicInfo.iPrevPicOrderCntLsb = 0; + sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL; + sLastDecPicInfo.iPrevFrameNum = -1; + sLastDecPicInfo.bLastHasMmco5 = false; + sLastDecPicInfo.uiDecodingTimeStamp = 0; +} + +/*! +* \brief copy SpsPps from one Ctx to another ctx for threaded code +*/ +void CopySpsPps (PWelsDecoderContext pFromCtx, PWelsDecoderContext pToCtx) { + pToCtx->sSpsPpsCtx = pFromCtx->sSpsPpsCtx; + PAccessUnit pFromCurAu = pFromCtx->pAccessUnitList; + PSps pTmpLayerSps[MAX_LAYER_NUM]; + for (int i = 0; i < MAX_LAYER_NUM; i++) { + pTmpLayerSps[i] = NULL; + } + // track the layer sps for the current au + for (unsigned int i = pFromCurAu->uiStartPos; i <= pFromCurAu->uiEndPos; i++) { + uint32_t uiDid = pFromCurAu->pNalUnitsList[i]->sNalHeaderExt.uiDependencyId; + pTmpLayerSps[uiDid] = pFromCurAu->pNalUnitsList[i]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps; + for (unsigned int j = 0; j < MAX_SPS_COUNT + 1; ++j) { + if (&pFromCtx->sSpsPpsCtx.sSpsBuffer[j] == pTmpLayerSps[uiDid]) { + pTmpLayerSps[uiDid] = &pToCtx->sSpsPpsCtx.sSpsBuffer[j]; + break; + } + } + } + for (int i = 0; i < MAX_LAYER_NUM; i++) { + if (pTmpLayerSps[i] != NULL) { + pToCtx->sSpsPpsCtx.pActiveLayerSps[i] = pTmpLayerSps[i]; + } + } +} + /* * destory_mb_blocks */ - /* * get size of reference picture list in target layer incoming, = (iNumRefFrames */ @@ -366,6 +438,9 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { iNumRefFrames = MAX_REF_PIC_COUNT + 2; } else { iNumRefFrames = pCtx->pSps->iNumRefFrames + 2; + if (GetThreadCount (pCtx) > 1) { + iNumRefFrames = MAX_REF_PIC_COUNT + 1; + } } #ifdef LONG_TERM_REF @@ -407,7 +482,9 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer // sync update pRefList - WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free + if (GetThreadCount (pCtx) <= 1) { + WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free + } if (pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel) && pCtx->pPicBuff != NULL && pCtx->pPicBuff->iCapacity != iPicQueueSize) { @@ -435,11 +512,11 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const // for Recycled_Pic_Queue PPicBuff* ppPic = &pCtx->pPicBuff; if (NULL != ppPic && NULL != *ppPic) { - DestroyPicBuff (ppPic, pMa); + DestroyPicBuff (pCtx, ppPic, pMa); } - pCtx->pPreviousDecodedPictureInDpb = NULL; + pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL; // currently only active for LIST_0 due to have no B frames iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff, iPicQueueSize, kiPicWidth, kiPicHeight); @@ -481,7 +558,18 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { PPicBuff* pPicBuff = &pCtx->pPicBuff; if (NULL != pPicBuff && NULL != *pPicBuff) { - DestroyPicBuff (pPicBuff, pMa); + DestroyPicBuff (pCtx, pPicBuff, pMa); + } + if (GetThreadCount (pCtx) > 1) { + //prevent from double destruction of PPicBuff + PWelsDecoderThreadCTX pThreadCtx = (PWelsDecoderThreadCTX) (pCtx->pThreadCtx); + int32_t threadCount = pThreadCtx->sThreadInfo.uiThrMaxNum; + int32_t id = pThreadCtx->sThreadInfo.uiThrNum; + for (int32_t i = 0; i < threadCount; ++i) { + if (pThreadCtx[i - id].pCtx != NULL) { + pThreadCtx[i - id].pCtx->pPicBuff = NULL; + } + } } if (pCtx->pTempDec) { @@ -510,7 +598,7 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { InitDecFuncs (pCtx, pCtx->uiCpuFlag); // vlc tables - InitVlcTable (&pCtx->sVlcTable); + InitVlcTable (pCtx->pVlcTable); // static memory iRet = WelsInitStaticMemory (pCtx); @@ -725,7 +813,11 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in } CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo); if (pCtx->bAuReadyFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) { - ConstructAccessUnit (pCtx, ppDst, pDstBufInfo); + if (pCtx->pThreadCtx == NULL) { + ConstructAccessUnit (pCtx, ppDst, pDstBufInfo); + } else { + pCtx->pAccessUnitList->uiAvailUnitsNum = 1; + } } } DecodeFinishUpdate (pCtx); @@ -781,9 +873,15 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) { iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3); } - CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo); + if (pCtx->pThreadCtx == NULL) { + CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo); + } if (pCtx->bAuReadyFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) { - ConstructAccessUnit (pCtx, ppDst, pDstBufInfo); + if (pCtx->pThreadCtx == NULL) { + ConstructAccessUnit (pCtx, ppDst, pDstBufInfo); + } else { + pCtx->pAccessUnitList->uiAvailUnitsNum = 1; + } } } DecodeFinishUpdate (pCtx); @@ -1098,7 +1196,7 @@ void UpdateDecStatFreezingInfo (const bool kbIdrFlag, SDecoderStatistics* pDecSt void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) { PDqLayer pCurDq = pCtx->pCurDqLayer; PPicture pPic = pCtx->pDec; - SDecoderStatistics* pDecStat = &pCtx->sDecoderStatistics; + SDecoderStatistics* pDecStat = pCtx->pDecoderStatistics; if (pDecStat->iAvgLumaQp == -1) //first correct frame received pDecStat->iAvgLumaQp = 0; @@ -1140,7 +1238,7 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) { //update decoder statistics information void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput) { if (pCtx->bFreezeOutput) - UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, &pCtx->sDecoderStatistics); + UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, pCtx->pDecoderStatistics); else if (kbOutput) UpdateDecStatNoFreezingInfo (pCtx); } diff --git a/src/openh264/codec/decoder/core/src/decoder_core.cpp b/src/openh264/codec/decoder/core/src/decoder_core.cpp old mode 100755 new mode 100644 index c4246af29..a31700012 --- a/src/openh264/codec/decoder/core/src/decoder_core.cpp +++ b/src/openh264/codec/decoder/core/src/decoder_core.cpp @@ -77,11 +77,11 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) { - if ((pCtx->sDecoderStatistics.uiWidth != (unsigned int) kiActualWidth) - || (pCtx->sDecoderStatistics.uiHeight != (unsigned int) kiActualHeight)) { - pCtx->sDecoderStatistics.uiResolutionChangeTimes++; - pCtx->sDecoderStatistics.uiWidth = kiActualWidth; - pCtx->sDecoderStatistics.uiHeight = kiActualHeight; + if ((pCtx->pDecoderStatistics->uiWidth != (unsigned int) kiActualWidth) + || (pCtx->pDecoderStatistics->uiHeight != (unsigned int) kiActualHeight)) { + pCtx->pDecoderStatistics->uiResolutionChangeTimes++; + pCtx->pDecoderStatistics->uiWidth = kiActualWidth; + pCtx->pDecoderStatistics->uiHeight = kiActualHeight; } UpdateDecStatNoFreezingInfo (pCtx); } @@ -194,8 +194,9 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t "DecodeFrameConstruction(): iTotalNumMbRec:%d, total_num_mb_sps:%d, cur_layer_mb_width:%d, cur_layer_mb_height:%d ", pCtx->iTotalNumMbRec, kiTotalNumMbInCurLayer, pCurDq->iMbWidth, pCurDq->iMbHeight); bFrameCompleteFlag = false; //return later after output buffer is done - if (pCtx->bInstantDecFlag) //no-delay decoding, wait for new slice + if (pCtx->bInstantDecFlag) { //no-delay decoding, wait for new slice return ERR_INFO_MB_NUM_INADEQUATE; + } } else if (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag && (pCtx->iErrorCode == dsErrorFree)) { //complete non-ECed IDR frame done pCtx->pDec->bIsComplete = true; @@ -219,10 +220,30 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t ppDst[0] = ppDst[0] + pCtx->sFrameCrop.iTopOffset * 2 * pPic->iLinesize[0] + pCtx->sFrameCrop.iLeftOffset * 2; ppDst[1] = ppDst[1] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset; ppDst[2] = ppDst[2] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset; + for (int i = 0; i < 3; ++i) { + pDstInfo->pDst[i] = ppDst[i]; + } pDstInfo->iBufferStatus = 1; - - bool bOutResChange = (pCtx->iLastImgWidthInPixel != pDstInfo->UsrData.sSystemBuffer.iWidth) - || (pCtx->iLastImgHeightInPixel != pDstInfo->UsrData.sSystemBuffer.iHeight); + if (GetThreadCount (pCtx) > 1 && pPic->bIsComplete == false) { + pPic->bIsComplete = true; + } + if (GetThreadCount (pCtx) > 1) { + uint32_t uiMbHeight = (pCtx->pDec->iHeightInPixel + 15) >> 4; + for (uint32_t i = 0; i < uiMbHeight; ++i) { + SET_EVENT (&pCtx->pDec->pReadyEvent[i]); + } + } + bool bOutResChange = false; + if (GetThreadCount (pCtx) <= 1 || pCtx->pLastThreadCtx == NULL) { + bOutResChange = (pCtx->iLastImgWidthInPixel != pDstInfo->UsrData.sSystemBuffer.iWidth) + || (pCtx->iLastImgHeightInPixel != pDstInfo->UsrData.sSystemBuffer.iHeight); + } else { + if (pCtx->pLastThreadCtx != NULL) { + PWelsDecoderThreadCTX pLastThreadCtx = (PWelsDecoderThreadCTX) (pCtx->pLastThreadCtx); + bOutResChange = (pLastThreadCtx->pCtx->iLastImgWidthInPixel != pDstInfo->UsrData.sSystemBuffer.iWidth) + || (pLastThreadCtx->pCtx->iLastImgHeightInPixel != pDstInfo->UsrData.sSystemBuffer.iHeight); + } + } pCtx->iLastImgWidthInPixel = pDstInfo->UsrData.sSystemBuffer.iWidth; pCtx->iLastImgHeightInPixel = pDstInfo->UsrData.sSystemBuffer.iHeight; if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) //no buffer output if EC is disabled and frame incomplete @@ -250,11 +271,11 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t pCtx->iMbNum = pPic->iMbNum; pCtx->iMbEcedPropNum = pPic->iMbEcedPropNum; if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { - if (pDstInfo->iBufferStatus && ((pCtx->sDecoderStatistics.uiWidth != (unsigned int) kiActualWidth) - || (pCtx->sDecoderStatistics.uiHeight != (unsigned int) kiActualHeight))) { - pCtx->sDecoderStatistics.uiResolutionChangeTimes++; - pCtx->sDecoderStatistics.uiWidth = kiActualWidth; - pCtx->sDecoderStatistics.uiHeight = kiActualHeight; + if (pDstInfo->iBufferStatus && ((pCtx->pDecoderStatistics->uiWidth != (unsigned int) kiActualWidth) + || (pCtx->pDecoderStatistics->uiHeight != (unsigned int) kiActualHeight))) { + pCtx->pDecoderStatistics->uiResolutionChangeTimes++; + pCtx->pDecoderStatistics->uiWidth = kiActualWidth; + pCtx->pDecoderStatistics->uiHeight = kiActualHeight; } UpdateDecStat (pCtx, pDstInfo->iBufferStatus != 0); } @@ -527,8 +548,8 @@ int32_t ParseDecRefPicMarking (PWelsDecoderContext pCtx, PBitStringAux pBs, PSli WELS_VERIFY_RETURN_IF (-1, (!bAllowMmco5 || bMmco5Exist)); bMmco5Exist = true; - pCtx->iPrevPicOrderCntLsb = 0; - pCtx->iPrevPicOrderCntMsb = 0; + pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0; + pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0; pSh->iPicOrderCntLsb = 0; if (pCtx->pSliceHeader) pCtx->pSliceHeader->iPicOrderCntLsb = 0; @@ -846,8 +867,9 @@ void UpdateDecoderStatisticsForActiveParaset (SDecoderStatistics* pDecoderStatis * Parse slice header of bitstream in avc for storing data structure */ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, const bool kbExtensionFlag) { - PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - - 1]; + PNalUnit const kpCurNal = + pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - + 1]; PNalUnitHeaderExt pNalHeaderExt = NULL; PSliceHeader pSliceHead = NULL; @@ -924,22 +946,22 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co iPpsId = uiCode; //add check PPS available here - if (pCtx->bPpsAvailFlags[iPpsId] == false) { - pCtx->sDecoderStatistics.iPpsReportErrorNum++; - if (pCtx->iPPSLastInvalidId != iPpsId) { + if (pCtx->sSpsPpsCtx.bPpsAvailFlags[iPpsId] == false) { + pCtx->pDecoderStatistics->iPpsReportErrorNum++; + if (pCtx->sSpsPpsCtx.iPPSLastInvalidId != iPpsId) { WelsLog (pLogCtx, WELS_LOG_ERROR, "PPS id (%d) is invalid, previous id (%d) error ignored (%d)!", iPpsId, - pCtx->iPPSLastInvalidId, pCtx->iPPSInvalidNum); - pCtx->iPPSLastInvalidId = iPpsId; - pCtx->iPPSInvalidNum = 0; + pCtx->sSpsPpsCtx.iPPSLastInvalidId, pCtx->sSpsPpsCtx.iPPSInvalidNum); + pCtx->sSpsPpsCtx.iPPSLastInvalidId = iPpsId; + pCtx->sSpsPpsCtx.iPPSInvalidNum = 0; } else { - pCtx->iPPSInvalidNum++; + pCtx->sSpsPpsCtx.iPPSInvalidNum++; } pCtx->iErrorCode |= dsNoParamSets; return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID); } - pCtx->iPPSLastInvalidId = -1; + pCtx->sSpsPpsCtx.iPPSLastInvalidId = -1; - pPps = &pCtx->sPpsBuffer[iPpsId]; + pPps = &pCtx->sSpsPpsCtx.sPpsBuffer[iPpsId]; if (pPps->uiNumSliceGroups == 0) { WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced"); @@ -948,38 +970,38 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } if (kbExtensionFlag) { - pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId]; + pSubsetSps = &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[pPps->iSpsId]; pSps = &pSubsetSps->sSps; - if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) { - pCtx->sDecoderStatistics.iSubSpsReportErrorNum++; - if (pCtx->iSubSPSLastInvalidId != pPps->iSpsId) { + if (pCtx->sSpsPpsCtx.bSubspsAvailFlags[pPps->iSpsId] == false) { + pCtx->pDecoderStatistics->iSubSpsReportErrorNum++; + if (pCtx->sSpsPpsCtx.iSubSPSLastInvalidId != pPps->iSpsId) { WelsLog (pLogCtx, WELS_LOG_ERROR, "Sub SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId, - pCtx->iSubSPSLastInvalidId, pCtx->iSubSPSInvalidNum); - pCtx->iSubSPSLastInvalidId = pPps->iSpsId; - pCtx->iSubSPSInvalidNum = 0; + pCtx->sSpsPpsCtx.iSubSPSLastInvalidId, pCtx->sSpsPpsCtx.iSubSPSInvalidNum); + pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = pPps->iSpsId; + pCtx->sSpsPpsCtx.iSubSPSInvalidNum = 0; } else { - pCtx->iSubSPSInvalidNum++; + pCtx->sSpsPpsCtx.iSubSPSInvalidNum++; } pCtx->iErrorCode |= dsNoParamSets; return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID); } - pCtx->iSubSPSLastInvalidId = -1; + pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = -1; } else { - if (pCtx->bSpsAvailFlags[pPps->iSpsId] == false) { - pCtx->sDecoderStatistics.iSpsReportErrorNum++; - if (pCtx->iSPSLastInvalidId != pPps->iSpsId) { + if (pCtx->sSpsPpsCtx.bSpsAvailFlags[pPps->iSpsId] == false) { + pCtx->pDecoderStatistics->iSpsReportErrorNum++; + if (pCtx->sSpsPpsCtx.iSPSLastInvalidId != pPps->iSpsId) { WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId, - pCtx->iSPSLastInvalidId, pCtx->iSPSInvalidNum); - pCtx->iSPSLastInvalidId = pPps->iSpsId; - pCtx->iSPSInvalidNum = 0; + pCtx->sSpsPpsCtx.iSPSLastInvalidId, pCtx->sSpsPpsCtx.iSPSInvalidNum); + pCtx->sSpsPpsCtx.iSPSLastInvalidId = pPps->iSpsId; + pCtx->sSpsPpsCtx.iSPSInvalidNum = 0; } else { - pCtx->iSPSInvalidNum++; + pCtx->sSpsPpsCtx.iSPSInvalidNum++; } pCtx->iErrorCode |= dsNoParamSets; return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID); } - pCtx->iSPSLastInvalidId = -1; - pSps = &pCtx->sSpsBuffer[pPps->iSpsId]; + pCtx->sSpsPpsCtx.iSPSLastInvalidId = -1; + pSps = &pCtx->sSpsPpsCtx.sSpsBuffer[pPps->iSpsId]; } pSliceHead->iPpsId = iPpsId; pSliceHead->iSpsId = pPps->iSpsId; @@ -1049,16 +1071,18 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co //Calculate poc if necessary int32_t pocLsb = pSliceHead->iPicOrderCntLsb; if (pSliceHead->bIdrFlag || kpCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR) { - pCtx->iPrevPicOrderCntMsb = 0; - pCtx->iPrevPicOrderCntLsb = 0; + pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0; + pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0; } int32_t pocMsb; - if (pocLsb < pCtx->iPrevPicOrderCntLsb && pCtx->iPrevPicOrderCntLsb - pocLsb >= iMaxPocLsb / 2) - pocMsb = pCtx->iPrevPicOrderCntMsb + iMaxPocLsb; - else if (pocLsb > pCtx->iPrevPicOrderCntLsb && pocLsb - pCtx->iPrevPicOrderCntLsb > iMaxPocLsb / 2) - pocMsb = pCtx->iPrevPicOrderCntMsb - iMaxPocLsb; + if (pocLsb < pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb + && pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb - pocLsb >= iMaxPocLsb / 2) + pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb + iMaxPocLsb; + else if (pocLsb > pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb + && pocLsb - pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb > iMaxPocLsb / 2) + pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb - iMaxPocLsb; else - pocMsb = pCtx->iPrevPicOrderCntMsb; + pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb; pSliceHead->iPicOrderCntLsb = pocMsb + pocLsb; if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) { @@ -1066,8 +1090,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } if (kpCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) { - pCtx->iPrevPicOrderCntLsb = pocLsb; - pCtx->iPrevPicOrderCntMsb = pocMsb; + pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = pocLsb; + pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = pocMsb; } //End of Calculating poc } else if (pSps->uiPocType == 1 && !pSps->bDeltaPicOrderAlwaysZeroFlag) { @@ -1376,7 +1400,7 @@ bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst pNalHdrExtS = &kpSrc->sNalHeaderExt; pShExtD = &kppDst->sNalData.sVclNal.sSliceHeaderExt; pPrefixS = &kpSrc->sNalData.sPrefixNal; - pSps = &pCtx->sSpsBuffer[pCtx->sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId]; + pSps = &pCtx->sSpsPpsCtx.sSpsBuffer[pCtx->sSpsPpsCtx.sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId]; pNalHdrExtD->uiDependencyId = pNalHdrExtS->uiDependencyId; pNalHdrExtD->uiQualityId = pNalHdrExtS->uiQualityId; @@ -1438,7 +1462,7 @@ int32_t UpdateAccessUnit (PWelsDecoderContext pCtx) { if (uiActualIdx == pCurAu->uiActualUnitsNum) { // no found IDR nal within incoming AU, need exit to avoid mosaic issue, 11/19/2009 - pCtx->sDecoderStatistics.uiIDRLostNum++; + pCtx->pDecoderStatistics->uiIDRLostNum++; if (!pCtx->bParamSetsLostFlag) WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "UpdateAccessUnit():::::Key frame lost.....CAN NOT find IDR from current AU."); @@ -1460,7 +1484,6 @@ int32_t UpdateAccessUnit (PWelsDecoderContext pCtx) { int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWidth, const int32_t kiMaxHeight) { int32_t i = 0; - WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiMaxWidth <= 0 || kiMaxHeight <= 0)) pCtx->sMb.iMbWidth = (kiMaxWidth + 15) >> 4; pCtx->sMb.iMbHeight = (kiMaxHeight + 15) >> 4; @@ -1506,7 +1529,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid sizeof ( bool), "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]"); - pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), + pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + bool), "pCtx->sMb.pTransformSize8x8Flag[]"); pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( int8_t) * 2, @@ -1517,9 +1541,11 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); pCtx->sMb.pCbfDc[i] = (uint16_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint16_t), "pCtx->sMb.pCbfDc[]"); - pCtx->sMb.pNzc[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, + pCtx->sMb.pNzc[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + int8_t) * 24, "pCtx->sMb.pNzc[]"); - pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, + pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + int8_t) * 24, "pCtx->sMb.pNzcRs[]"); pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * @@ -1537,20 +1563,24 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid "pCtx->sMb.pChromaPredMode[]"); pCtx->sMb.pCbp[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), "pCtx->sMb.pCbp[]"); - pCtx->sMb.pSubMbType[i] = (uint32_t (*)[MB_PARTITION_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * + pCtx->sMb.pSubMbType[i] = (uint32_t (*)[MB_PARTITION_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth * + pCtx->sMb.iMbHeight * sizeof ( uint32_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); pCtx->sMb.pSliceIdc[i] = (int32_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 - pCtx->sMb.pResidualPredFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), + pCtx->sMb.pResidualPredFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + int8_t), "pCtx->sMb.pResidualPredFlag[]"); - pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( - int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); + pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * + sizeof ( + int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( bool), "pCtx->sMb.pMbCorrectlyDecodedFlag[]"); - pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), + pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + bool), "pCtx->pMbRefConcealedFlag[]"); // check memory block valid due above allocated.. @@ -1597,6 +1627,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid return ERR_NONE; } + + void UninitialDqLayersContext (PWelsDecoderContext pCtx) { int32_t i = 0; CMemoryAlign* pMa = pCtx->pMemAlign; @@ -1825,9 +1857,9 @@ void ForceClearCurrentNal (PAccessUnit pAu) { } void ForceResetParaSetStatusAndAUList (PWelsDecoderContext pCtx) { - pCtx->bSpsExistAheadFlag = false; - pCtx->bSubspsExistAheadFlag = false; - pCtx->bPpsExistAheadFlag = false; + pCtx->sSpsPpsCtx.bSpsExistAheadFlag = false; + pCtx->sSpsPpsCtx.bSubspsExistAheadFlag = false; + pCtx->sSpsPpsCtx.bPpsExistAheadFlag = false; // Force clear the AU list pCtx->pAccessUnitList->uiAvailUnitsNum = 0; @@ -2101,14 +2133,14 @@ int32_t WelsDecodeAccessUnitStart (PWelsDecoderContext pCtx) { return iRet; pCtx->pAccessUnitList->uiStartPos = 0; - if (!pCtx->bAvcBasedFlag && !CheckIntegrityNalUnitsList (pCtx)) { + if (!pCtx->sSpsPpsCtx.bAvcBasedFlag && !CheckIntegrityNalUnitsList (pCtx)) { pCtx->iErrorCode |= dsBitstreamError; return dsBitstreamError; } //check current AU has only one layer or not //If YES, can use deblocking based on AVC - if (!pCtx->bAvcBasedFlag) { + if (!pCtx->sSpsPpsCtx.bAvcBasedFlag) { CheckOnlyOneLayerInAu (pCtx); } @@ -2119,8 +2151,8 @@ void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx) { //save previous header info PAccessUnit pCurAu = pCtx->pAccessUnitList; PNalUnit pCurNal = pCurAu->pNalUnitsList[pCurAu->uiEndPos]; - memcpy (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, sizeof (SNalUnitHeaderExt)); - memcpy (&pCtx->sLastSliceHeader, + memcpy (&pCtx->pLastDecPicInfo->sLastNalHdrExt, &pCurNal->sNalHeaderExt, sizeof (SNalUnitHeaderExt)); + memcpy (&pCtx->pLastDecPicInfo->sLastSliceHeader, &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader, sizeof (SSliceHeader)); // uninitialize context of current access unit and rbsp buffer clean ResetCurrentAccessUnit (pCtx); @@ -2147,7 +2179,7 @@ static bool CheckNewSeqBeginAndUpdateActiveLayerSps (PWelsDecoderContext pCtx) { } int iMaxActiveLayer = 0, iMaxCurrentLayer = 0; for (int i = MAX_LAYER_NUM - 1; i >= 0; i--) { - if (pCtx->pActiveLayerSps[i] != NULL) { + if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] != NULL) { iMaxActiveLayer = i; break; } @@ -2159,37 +2191,39 @@ static bool CheckNewSeqBeginAndUpdateActiveLayerSps (PWelsDecoderContext pCtx) { } } if ((iMaxCurrentLayer != iMaxActiveLayer) - || (pTmpLayerSps[iMaxCurrentLayer] != pCtx->pActiveLayerSps[iMaxActiveLayer])) { + || (pTmpLayerSps[iMaxCurrentLayer] != pCtx->sSpsPpsCtx.pActiveLayerSps[iMaxActiveLayer])) { bNewSeq = true; } // fill active sps if the current sps is not null while active layer is null if (!bNewSeq) { for (int i = 0; i < MAX_LAYER_NUM; i++) { - if (pCtx->pActiveLayerSps[i] == NULL && pTmpLayerSps[i] != NULL) { - pCtx->pActiveLayerSps[i] = pTmpLayerSps[i]; + if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] == NULL && pTmpLayerSps[i] != NULL) { + pCtx->sSpsPpsCtx.pActiveLayerSps[i] = pTmpLayerSps[i]; } } } else { // UpdateActiveLayerSps if new sequence start - memcpy (&pCtx->pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof (PSps)); + memcpy (&pCtx->sSpsPpsCtx.pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof (PSps)); } return bNewSeq; } static void WriteBackActiveParameters (PWelsDecoderContext pCtx) { - if (pCtx->iOverwriteFlags & OVERWRITE_PPS) { - memcpy (&pCtx->sPpsBuffer[pCtx->sPpsBuffer[MAX_PPS_COUNT].iPpsId], &pCtx->sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps)); + if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_PPS) { + memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT].iPpsId], + &pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps)); } - if (pCtx->iOverwriteFlags & OVERWRITE_SPS) { - memcpy (&pCtx->sSpsBuffer[pCtx->sSpsBuffer[MAX_SPS_COUNT].iSpsId], &pCtx->sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps)); + if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SPS) { + memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT].iSpsId], + &pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps)); pCtx->bNewSeqBegin = true; } - if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS) { - memcpy (&pCtx->sSubsetSpsBuffer[pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId], - &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps)); + if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SUBSETSPS) { + memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId], + &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps)); pCtx->bNewSeqBegin = true; } - pCtx->iOverwriteFlags = OVERWRITE_NONE; + pCtx->sSpsPpsCtx.iOverwriteFlags = OVERWRITE_NONE; } /* @@ -2208,22 +2242,19 @@ void DecodeFinishUpdate (PWelsDecoderContext pCtx) { } /* - * ConstructAccessUnit - * construct an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to - * joint a collective access unit. - * parameter\ - * buf: bitstream data buffer - * bit_len: size in bit length of data - * buf_len: size in byte length of data - * coded_au: mark an Access Unit decoding finished - * return: - * 0 - success; otherwise returned error_no defined in error_no.h - */ -int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) { - int32_t iErr; +* WelsDecodeInitAccessUnitStart +* check and (re)allocate picture buffers on new sequence begin +* bit_len: size in bit length of data +* buf_len: size in byte length of data +* coded_au: mark an Access Unit decoding finished +* return: +* 0 - success; otherwise returned error_no defined in error_no.h +*/ +int32_t WelsDecodeInitAccessUnitStart (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo) { + int32_t iErr = ERR_NONE; PAccessUnit pCurAu = pCtx->pAccessUnitList; pCtx->bAuReadyFlag = false; - pCtx->bLastHasMmco5 = false; + pCtx->pLastDecPicInfo->bLastHasMmco5 = false; bool bTmpNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps (pCtx); pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || bTmpNewSeqBegin; iErr = WelsDecodeAccessUnitStart (pCtx); @@ -2243,17 +2274,82 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI pCtx->pSps = pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps; pCtx->pPps = pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pPps; - //try to allocate or relocate DPB memory only when new sequence is coming. - if (pCtx->bNewSeqBegin) { - WelsResetRefPic (pCtx); //clear ref pPic when IDR NAL - iErr = SyncPictureResolutionExt (pCtx, pCtx->pSps->iMbWidth, pCtx->pSps->iMbHeight); + return iErr; +} +/* +* AllocPicBuffOnNewSeqBegin +* check and (re)allocate picture buffers on new sequence begin +* return: +* 0 - success; otherwise returned error_no defined in error_no.h +*/ +int32_t AllocPicBuffOnNewSeqBegin (PWelsDecoderContext pCtx) { + //try to allocate or relocate DPB memory only when new sequence is coming. + if (GetThreadCount (pCtx) <= 1) { + WelsResetRefPic (pCtx); //clear ref pPic when IDR NAL + } + int32_t iErr = SyncPictureResolutionExt (pCtx, pCtx->pSps->iMbWidth, pCtx->pSps->iMbHeight); + + if (ERR_NONE != iErr) { + WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "sync picture resolution ext failed, the error is %d", iErr); + return iErr; + } + + return iErr; +} + +/* +* InitConstructAccessUnit +* Init before constructing an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to +* joint a collective access unit. +* parameter\ +* SBufferInfo: Buffer info +* return: +* 0 - success; otherwise returned error_no defined in error_no.h +*/ +int32_t InitConstructAccessUnit (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo) { + int32_t iErr = ERR_NONE; + + iErr = WelsDecodeInitAccessUnitStart (pCtx, pDstInfo); + if (ERR_NONE != iErr) { + return iErr; + } + if (pCtx->bNewSeqBegin) { + iErr = AllocPicBuffOnNewSeqBegin (pCtx); if (ERR_NONE != iErr) { - WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "sync picture resolution ext failed, the error is %d", iErr); return iErr; } } + return iErr; +} + +/* + * ConstructAccessUnit + * construct an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to + * joint a collective access unit. + * parameter\ + * buf: bitstream data buffer + * bit_len: size in bit length of data + * buf_len: size in byte length of data + * coded_au: mark an Access Unit decoding finished + * return: + * 0 - success; otherwise returned error_no defined in error_no.h + */ +int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) { + int32_t iErr = ERR_NONE; + if (pCtx->pThreadCtx == NULL) { + iErr = InitConstructAccessUnit (pCtx, pDstInfo); + if (ERR_NONE != iErr) { + return iErr; + } + } + if (pCtx->pCabacDecEngine == NULL) { + pCtx->pCabacDecEngine = (SWelsCabacDecEngine*)pCtx->pMemAlign->WelsMallocz (sizeof (SWelsCabacDecEngine), + "pCtx->pCabacDecEngine"); + WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine)) + } + iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo); WelsDecodeAccessUnitEnd (pCtx); @@ -2320,12 +2416,14 @@ void WelsDqLayerDecodeStart (PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pS pCtx->bUsedAsRef = false; pCtx->iFrameNum = pSh->iFrameNum; - UpdateDecoderStatisticsForActiveParaset (& (pCtx->sDecoderStatistics), - pSps, pPps); + UpdateDecoderStatisticsForActiveParaset (pCtx->pDecoderStatistics, pSps, pPps); } int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) { int32_t iRet = ERR_NONE; + if (GetThreadCount (pCtx) > 1 && pCtx->bNewSeqBegin) { + WelsResetRefPic (pCtx); + } if (pCtx->eSliceType == B_SLICE) { iRet = WelsInitBSliceRefList (pCtx, iPoc); CreateImplicitWeightTable (pCtx); @@ -2380,13 +2478,27 @@ void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) { * Decode current access unit when current AU is completed. */ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) { - int32_t iRefCount[LIST_A]; - PNalUnit pNalCur = NULL; + PNalUnit pNalCur = pCtx->pNalCur = NULL; PAccessUnit pCurAu = pCtx->pAccessUnitList; int32_t iIdx = pCurAu->uiStartPos; int32_t iEndIdx = pCurAu->uiEndPos; + //get current thread ctx + PWelsDecoderThreadCTX pThreadCtx = NULL; + if (pCtx->pThreadCtx != NULL) { + pThreadCtx = (PWelsDecoderThreadCTX)pCtx->pThreadCtx; + } + //get last thread ctx + PWelsDecoderThreadCTX pLastThreadCtx = NULL; + if (pCtx->pLastThreadCtx != NULL) { + pLastThreadCtx = (PWelsDecoderThreadCTX) (pCtx->pLastThreadCtx); + if (pLastThreadCtx->pDec == NULL) { + pLastThreadCtx->pDec = PrefetchLastPicForThread (pCtx->pPicBuff, + pLastThreadCtx->iPicBuffIdx); + } + } + int32_t iThreadCount = GetThreadCount (pCtx); int32_t iPpsId = 0; int32_t iRet = ERR_NONE; @@ -2396,12 +2508,12 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf const uint8_t kuiDependencyIdMax = (kuiTargetLayerDqId & 0x7F) >> 4; int16_t iLastIdD = -1, iLastIdQ = -1; int16_t iCurrIdD = 0, iCurrIdQ = 0; - uint8_t uiNalRefIdc = 0; + pCtx->uiNalRefIdc = 0; bool bFreshSliceAvailable = true; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008 //update pCurDqLayer at the starting of AU decoding - if (pCtx->bInitialDqLayersMem) { + if (pCtx->bInitialDqLayersMem || pCtx->pCurDqLayer == NULL) { pCtx->pCurDqLayer = pCtx->pDqLayersList[0]; } @@ -2414,7 +2526,47 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf PSliceHeaderExt pShExt = NULL; PSliceHeader pSh = NULL; + if (pLastThreadCtx != NULL) { + pSh = &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; + if (pSh->iFirstMbInSlice == 0) { + if (pLastThreadCtx->pCtx->pDec != NULL && pLastThreadCtx->pCtx->pDec->bIsUngroupedMultiSlice) { + WAIT_EVENT (&pLastThreadCtx->sSliceDecodeFinish, WELS_DEC_THREAD_WAIT_INFINITE); + } + pCtx->pDec = NULL; + pCtx->iTotalNumMbRec = 0; + } else if (pLastThreadCtx->pCtx->pDec != NULL) { + if (pSh->iFrameNum == pLastThreadCtx->pCtx->pDec->iFrameNum + && pSh->iPicOrderCntLsb == pLastThreadCtx->pCtx->pDec->iFramePoc) { + WAIT_EVENT (&pLastThreadCtx->sSliceDecodeFinish, WELS_DEC_THREAD_WAIT_INFINITE); + pCtx->pDec = pLastThreadCtx->pCtx->pDec; + pCtx->pDec->bIsUngroupedMultiSlice = true; + pCtx->sRefPic = pLastThreadCtx->pCtx->sRefPic; + pCtx->iTotalNumMbRec = pLastThreadCtx->pCtx->iTotalNumMbRec; + } + } + } + bool isNewFrame = true; + if (iThreadCount > 1) { + isNewFrame = pCtx->pDec == NULL; + } if (pCtx->pDec == NULL) { + if (pLastThreadCtx != NULL) { + pLastThreadCtx->pDec->bUsedAsRef = pLastThreadCtx->pCtx->uiNalRefIdc > 0; + if (pLastThreadCtx->pDec->bUsedAsRef) { + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { + uint32_t i = 0; + while (i < MAX_DPB_COUNT && pLastThreadCtx->pCtx->sRefPic.pRefList[listIdx][i]) { + pLastThreadCtx->pDec->pRefPic[listIdx][i] = pLastThreadCtx->pCtx->sRefPic.pRefList[listIdx][i]; + ++i; + } + } + pLastThreadCtx->pCtx->sTmpRefPic = pLastThreadCtx->pCtx->sRefPic; + WelsMarkAsRef (pLastThreadCtx->pCtx, pLastThreadCtx->pDec); + pCtx->sRefPic = pLastThreadCtx->pCtx->sTmpRefPic; + } else { + pCtx->sRefPic = pLastThreadCtx->pCtx->sRefPic; + } + } pCtx->pDec = PrefetchPic (pCtx->pPicBuff); if (pCtx->iTotalNumMbRec != 0) pCtx->iTotalNumMbRec = 0; @@ -2427,17 +2579,33 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf pCtx->iErrorCode |= dsOutOfMemory; return ERR_INFO_REF_COUNT_OVERFLOW; } + if (pThreadCtx != NULL) { + pCtx->pDec->bIsUngroupedMultiSlice = false; + pThreadCtx->pDec = pCtx->pDec; + if (iThreadCount > 1) ++pCtx->pDec->iRefCount; + uint32_t uiMbHeight = (pCtx->pDec->iHeightInPixel + 15) >> 4; + for (uint32_t i = 0; i < uiMbHeight; ++i) { + RESET_EVENT (&pCtx->pDec->pReadyEvent[i]); + } + } pCtx->pDec->bNewSeqBegin = pCtx->bNewSeqBegin; //set flag for start decoding } else if (pCtx->iTotalNumMbRec == 0) { //pDec != NULL, already start pCtx->pDec->bNewSeqBegin = pCtx->bNewSeqBegin; //set flag for start decoding } pCtx->pDec->uiTimeStamp = pNalCur->uiTimeStamp; + pCtx->pDec->uiDecodingTimeStamp = pCtx->uiDecodingTimeStamp; + if (pThreadCtx != NULL) { + pThreadCtx->iPicBuffIdx = pCtx->pDec->iPicBuffIdx; + pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag = pCtx->pDec->pMbCorrectlyDecodedFlag; + } if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i) memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t))); memset (pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag, 0, pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight * sizeof (bool)); memset (pCtx->pCurDqLayer->pMbRefConcealedFlag, 0, pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight * sizeof (bool)); + memset (pCtx->pDec->pRefPic[LIST_0], 0, sizeof (PPicture) * MAX_DPB_COUNT); + memset (pCtx->pDec->pRefPic[LIST_1], 0, sizeof (PPicture) * MAX_DPB_COUNT); pCtx->pDec->iMbNum = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight; pCtx->pDec->iMbEcedNum = 0; pCtx->pDec->iMbEcedPropNum = 0; @@ -2468,6 +2636,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf pCtx->pDec->iFrameNum = pSh->iFrameNum; pCtx->pDec->iFramePoc = pSh->iPicOrderCntLsb; // still can not obtain correct, because current do not support POCtype 2 pCtx->pDec->bIdrFlag = pNalCur->sNalHeaderExt.bIdrFlag; + pCtx->pDec->eSliceType = pSh->eSliceType; memcpy (&pLayerInfo.sSliceInLayer.sSliceHeaderExt, pShExt, sizeof (SSliceHeaderExt)); //confirmed_safe_unsafe_usage pLayerInfo.sSliceInLayer.bSliceHeaderExtFlag = pNalCur->sNalData.sVclNal.bSliceHeaderExtFlag; @@ -2475,7 +2644,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf pLayerInfo.sSliceInLayer.iLastMbQp = pSh->iSliceQp; dq_cur->pBitStringAux = &pNalCur->sNalData.sVclNal.sSliceBitsRead; - uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc; + pCtx->uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc; iPpsId = pSh->iPpsId; @@ -2500,11 +2669,9 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf bFreshSliceAvailable = (iCurrIdD != iLastIdD || iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder + WelsDqLayerDecodeStart (pCtx, pNalCur, pLayerInfo.pSps, pLayerInfo.pPps); - if (iCurrIdQ == BASE_QUALITY_ID) { - ST64 (iRefCount, LD64 (pLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.uiRefCount)); - } if ((iLastIdD < 0) || //case 1: first layer (iLastIdD == iCurrIdD)) { //case 2: same uiDId @@ -2514,11 +2681,23 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf const bool kbIdrFlag = dq_cur->sLayerInfo.sNalHeaderExt.bIdrFlag || (dq_cur->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR); // Subclause 8.2.5.2 Decoding process for gaps in frame_num + int32_t iPrevFrameNum = pCtx->pLastDecPicInfo->iPrevFrameNum; + if (pLastThreadCtx != NULL) { + if (pCtx->bNewSeqBegin) { + iPrevFrameNum = 0; + } else if (pLastThreadCtx->pDec != NULL) { + iPrevFrameNum = pLastThreadCtx->pDec->iFrameNum; + } else { + iPrevFrameNum = pCtx->bNewSeqBegin ? 0 : pLastThreadCtx->pCtx->iFrameNum; + } + } if (!kbIdrFlag && - pSh->iFrameNum != pCtx->iPrevFrameNum && - pSh->iFrameNum != ((pCtx->iPrevFrameNum + 1) & ((1 << dq_cur->sLayerInfo.pSps->uiLog2MaxFrameNum) - 1))) { + pSh->iFrameNum != iPrevFrameNum && + pSh->iFrameNum != ((iPrevFrameNum + 1) & ((1 << dq_cur->sLayerInfo.pSps->uiLog2MaxFrameNum) - + 1))) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, - "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d", pCtx->iPrevFrameNum, + "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d", + iPrevFrameNum, pSh->iFrameNum); bAllRefComplete = false; @@ -2534,8 +2713,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf } } - if (iCurrIdD == kuiDependencyIdMax && iCurrIdQ == BASE_QUALITY_ID) { - iRet = InitRefPicList (pCtx, uiNalRefIdc, pSh->iPicOrderCntLsb); + if (iCurrIdD == kuiDependencyIdMax && iCurrIdQ == BASE_QUALITY_ID && isNewFrame) { + iRet = InitRefPicList (pCtx, pCtx->uiNalRefIdc, pSh->iPicOrderCntLsb); if (iRet) { pCtx->bRPLRError = true; bAllRefComplete = false; // RPLR error, set ref pictures complete flag false @@ -2554,7 +2733,13 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf if (pSh->eSliceType == B_SLICE && !pSh->iDirectSpatialMvPredFlag) ComputeColocatedTemporalScaling (pCtx); - iRet = WelsDecodeSlice (pCtx, bFreshSliceAvailable, pNalCur); + if (iThreadCount > 1) { + memset (&pCtx->lastReadyHeightOffset[0][0], -1, LIST_A * MAX_REF_PIC_COUNT * sizeof (int16_t)); + SET_EVENT (&pThreadCtx->sSliceDecodeStart); + iRet = WelsDecodeAndConstructSlice (pCtx); + } else { + iRet = WelsDecodeSlice (pCtx, bFreshSliceAvailable, pNalCur); + } //Output good store_base reconstruction when enhancement quality layer occurred error for MGS key picture case if (iRet != ERR_NONE) { @@ -2570,17 +2755,19 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf } } - if (bReconstructSlice) { + if (iThreadCount <= 1 && bReconstructSlice) { if ((iRet = WelsDecodeConstructSlice (pCtx, pNalCur)) != ERR_NONE) { pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false return iRet; } } if (bAllRefComplete && pCtx->eSliceType != I_SLICE) { - if (pCtx->sRefPic.uiRefCount[LIST_0] > 0) { - bAllRefComplete &= CheckRefPicturesComplete (pCtx); - } else { - bAllRefComplete = false; + if (iThreadCount <= 1) { + if (pCtx->sRefPic.uiRefCount[LIST_0] > 0) { + bAllRefComplete &= CheckRefPicturesComplete (pCtx); + } else { + bAllRefComplete = false; + } } } } @@ -2632,55 +2819,80 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf } } + if (iThreadCount >= 1) { + int32_t id = pThreadCtx->sThreadInfo.uiThrNum; + for (int32_t i = 0; i < iThreadCount; ++i) { + if (i == id || pThreadCtx[i - id].pCtx->uiDecodingTimeStamp == 0) continue; + if (pThreadCtx[i - id].pCtx->uiDecodingTimeStamp < pCtx->uiDecodingTimeStamp) { + WAIT_EVENT (&pThreadCtx[i - id].sSliceDecodeFinish, WELS_DEC_THREAD_WAIT_INFINITE); + } + } + pCtx->pLastDecPicInfo->uiDecodingTimeStamp = pCtx->uiDecodingTimeStamp; + } iRet = DecodeFrameConstruction (pCtx, ppDst, pDstInfo); - if (iRet) + if (iRet) { + if (iThreadCount > 1) { + SET_EVENT (&pThreadCtx->sSliceDecodeFinish); + } return iRet; + } - pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC - pCtx->bUsedAsRef = false; - if (uiNalRefIdc > 0) { - pCtx->bUsedAsRef = true; - //save MBType, MV and RefIndex for use in B-Slice direct mode - memcpy (pCtx->pDec->pMbType, pCtx->pCurDqLayer->pMbType, pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint32_t)); - memcpy (pCtx->pDec->pMv[LIST_0], pCtx->pCurDqLayer->pMv[LIST_0], - pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t) * MV_A * MB_BLOCK4x4_NUM); - memcpy (pCtx->pDec->pMv[LIST_1], pCtx->pCurDqLayer->pMv[LIST_1], - pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t) * MV_A * MB_BLOCK4x4_NUM); - memcpy (pCtx->pDec->pRefIndex[LIST_0], pCtx->pCurDqLayer->pRefIndex[LIST_0], - pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * MB_BLOCK4x4_NUM); - memcpy (pCtx->pDec->pRefIndex[LIST_1], pCtx->pCurDqLayer->pRefIndex[LIST_1], - pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * MB_BLOCK4x4_NUM); - for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { - uint32_t i = 0; - while (i < MAX_DPB_COUNT && pCtx->sRefPic.pRefList[listIdx][i]) { - pCtx->pDec->pRefPic[listIdx][i] = pCtx->sRefPic.pRefList[listIdx][i]; - ++i; + pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC + pCtx->bUsedAsRef = pCtx->uiNalRefIdc > 0; + if (iThreadCount <= 1) { + if (pCtx->bUsedAsRef) { + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { + uint32_t i = 0; + while (i < MAX_DPB_COUNT && pCtx->sRefPic.pRefList[listIdx][i]) { + pCtx->pDec->pRefPic[listIdx][i] = pCtx->sRefPic.pRefList[listIdx][i]; + ++i; + } } - } - iRet = WelsMarkAsRef (pCtx); - if (iRet != ERR_NONE) { - if (iRet == ERR_INFO_DUPLICATE_FRAME_NUM) - pCtx->iErrorCode |= dsBitstreamError; - if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) { - pCtx->pDec = NULL; - return iRet; + iRet = WelsMarkAsRef (pCtx); + if (iRet != ERR_NONE) { + if (iRet == ERR_INFO_DUPLICATE_FRAME_NUM) + pCtx->iErrorCode |= dsBitstreamError; + if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) { + pCtx->pDec = NULL; + return iRet; + } } + if (!pCtx->pParam->bParseOnly) + ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel, + pCtx->pDec->iLinesize, + pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture); } - if (!pCtx->pParam->bParseOnly) - ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel, - pCtx->pDec->iLinesize, - pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture); + } else if (iThreadCount > 1) { + SET_EVENT (&pThreadCtx->sImageReady); } pCtx->pDec = NULL; //after frame decoding, always set to NULL } // need update frame_num due current frame is well decoded if (pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc > 0) - pCtx->iPrevFrameNum = pSh->iFrameNum; - if (pCtx->bLastHasMmco5) - pCtx->iPrevFrameNum = 0; + pCtx->pLastDecPicInfo->iPrevFrameNum = pSh->iFrameNum; + if (pCtx->pLastDecPicInfo->bLastHasMmco5) + pCtx->pLastDecPicInfo->iPrevFrameNum = 0; + if (iThreadCount > 1) { + int32_t id = pThreadCtx->sThreadInfo.uiThrNum; + for (int32_t i = 0; i < iThreadCount; ++i) { + if (pThreadCtx[i - id].pCtx != NULL) { + unsigned long long uiTimeStamp = pThreadCtx[i - id].pCtx->uiTimeStamp; + if (uiTimeStamp > 0 && pThreadCtx[i - id].pCtx->sSpsPpsCtx.iSeqId > pCtx->sSpsPpsCtx.iSeqId) { + CopySpsPps (pThreadCtx[i - id].pCtx, pCtx); + if (pCtx->pPicBuff != pThreadCtx[i - id].pCtx->pPicBuff) { + pCtx->pPicBuff = pThreadCtx[i - id].pCtx->pPicBuff; + } + InitialDqLayersContext (pCtx, pCtx->pSps->iMbWidth << 4, pCtx->pSps->iMbHeight << 4); + break; + } + } + } + } + if (iThreadCount > 1) { + SET_EVENT (&pThreadCtx->sSliceDecodeFinish); + } } - return ERR_NONE; } @@ -2690,7 +2902,8 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { //VCL data, AU list should have data PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos]; bAuBoundaryFlag = (pCtx->iTotalNumMbRec != 0) - && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader, + && (CheckAccessUnitBoundaryExt (&pCtx->pLastDecPicInfo->sLastNalHdrExt, &pCurNal->sNalHeaderExt, + &pCtx->pLastDecPicInfo->sLastSliceHeader, &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader)); } else { //non VCL if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_AU_DELIMITER) { @@ -2698,11 +2911,11 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SEI) { bAuBoundaryFlag = true; } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SPS) { - bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SPS); + bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SPS); } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SUBSET_SPS) { - bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS); + bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SUBSETSPS); } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_PPS) { - bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_PPS); + bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_PPS); } if (bAuBoundaryFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) { //Construct remaining data first ConstructAccessUnit (pCtx, ppDst, pDstInfo); @@ -2718,8 +2931,8 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn pCtx->pDec->iPpsId = pCtx->pPps->iPpsId; DecodeFrameConstruction (pCtx, ppDst, pDstInfo); - pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use - if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) { + pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use + if (pCtx->pLastDecPicInfo->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) { if (MarkECFrameAsRef (pCtx) == ERR_INFO_INVALID_PTR) { pCtx->iErrorCode |= dsRefListNullPtrs; return false; @@ -2730,7 +2943,8 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn pCtx->bFrameFinish = true; //clear frame pending status here! } else { if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) { - if ((pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) && (pCtx->sLastNalHdrExt.uiTemporalId == 0)) + if ((pCtx->pLastDecPicInfo->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) + && (pCtx->pLastDecPicInfo->sLastNalHdrExt.uiTemporalId == 0)) pCtx->iErrorCode |= dsNoParamSets; else pCtx->iErrorCode |= dsBitstreamError; @@ -2740,9 +2954,9 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn } pCtx->pDec = NULL; if (pAu->pNalUnitsList[pAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc > 0) - pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num - if (pCtx->bLastHasMmco5) - pCtx->iPrevFrameNum = 0; + pCtx->pLastDecPicInfo->iPrevFrameNum = pCtx->pLastDecPicInfo->sLastSliceHeader.iFrameNum; //save frame_num + if (pCtx->pLastDecPicInfo->bLastHasMmco5) + pCtx->pLastDecPicInfo->iPrevFrameNum = 0; } return ERR_NONE; } @@ -2753,28 +2967,37 @@ bool CheckRefPicturesComplete (PWelsDecoderContext pCtx) { int32_t iRealMbIdx = pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; for (int32_t iMbIdx = 0; bAllRefComplete && iMbIdx < pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice; iMbIdx++) { - switch (pCtx->pCurDqLayer->pMbType[iRealMbIdx]) { + switch (pCtx->pCurDqLayer->pDec->pMbType[iRealMbIdx]) { case MB_TYPE_SKIP: case MB_TYPE_16x16: - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete; break; case MB_TYPE_16x8: - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete; - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete; break; case MB_TYPE_8x16: - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete; - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete; break; case MB_TYPE_8x8: case MB_TYPE_8x8_REF0: - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete; - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete; - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete; - bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][10] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete; + bAllRefComplete &= + pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][10] ]->bIsComplete; break; default: @@ -2785,6 +3008,7 @@ bool CheckRefPicturesComplete (PWelsDecoderContext pCtx) { if (iRealMbIdx == -1) //caused by abnormal return of FmoNextMb() return false; } + return bAllRefComplete; } } // namespace WelsDec diff --git a/src/openh264/codec/decoder/core/src/decoder_data_tables.cpp b/src/openh264/codec/decoder/core/src/decoder_data_tables.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/src/error_concealment.cpp b/src/openh264/codec/decoder/core/src/error_concealment.cpp old mode 100755 new mode 100644 index b11f76402..64da75469 --- a/src/openh264/codec/decoder/core/src/error_concealment.cpp +++ b/src/openh264/codec/decoder/core/src/error_concealment.cpp @@ -83,7 +83,7 @@ void InitErrorCon (PWelsDecoderContext pCtx) { //Do error concealment using frame copy method void DoErrorConFrameCopy (PWelsDecoderContext pCtx) { PPicture pDstPic = pCtx->pDec; - PPicture pSrcPic = pCtx->pPreviousDecodedPictureInDpb; + PPicture pSrcPic = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb; uint32_t uiHeightInPixelY = (pCtx->pSps->iMbHeight) << 4; int32_t iStrideY = pDstPic->iLinesize[0]; int32_t iStrideUV = pDstPic->iLinesize[1]; @@ -109,7 +109,7 @@ void DoErrorConSliceCopy (PWelsDecoderContext pCtx) { int32_t iMbWidth = (int32_t) pCtx->pSps->iMbWidth; int32_t iMbHeight = (int32_t) pCtx->pSps->iMbHeight; PPicture pDstPic = pCtx->pDec; - PPicture pSrcPic = pCtx->pPreviousDecodedPictureInDpb; + PPicture pSrcPic = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb; if ((pCtx->pParam->eEcActiveIdc == ERROR_CON_SLICE_COPY) && (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag)) pSrcPic = NULL; //no cross IDR method, should fill in data instead of copy @@ -245,7 +245,7 @@ void DoMbECMvCopy (PWelsDecoderContext pCtx, PPicture pDec, PPicture pRef, int32 } iMVs[0] = iFullMVx - (iMbXInPix << 2); iMVs[1] = iFullMVy - (iMbYInPix << 2); - BaseMC (pMCRefMem, iMbXInPix, iMbYInPix, &pCtx->sMcFunc, 16, 16, iMVs); + BaseMC (pCtx, pMCRefMem, -1, -1, iMbXInPix, iMbYInPix, &pCtx->sMcFunc, 16, 16, iMVs); } return; } @@ -266,40 +266,40 @@ void GetAvilInfoFromCorrectMb (PWelsDecoderContext pCtx) { for (int32_t iMbY = 0; iMbY < iMbHeight; ++iMbY) { for (int32_t iMbX = 0; iMbX < iMbWidth; ++iMbX) { iMbXyIndex = iMbY * iMbWidth + iMbX; - if (pMbCorrectlyDecodedFlag[iMbXyIndex] && IS_INTER (pCurDqLayer->pMbType[iMbXyIndex])) { - uint32_t iMBType = pCurDqLayer->pMbType[iMbXyIndex]; + if (pMbCorrectlyDecodedFlag[iMbXyIndex] && IS_INTER (pCurDqLayer->pDec->pMbType[iMbXyIndex])) { + uint32_t iMBType = pCurDqLayer->pDec->pMbType[iMbXyIndex]; switch (iMBType) { case MB_TYPE_SKIP: case MB_TYPE_16x16: - iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][0]; - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][0][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][0][1]; + iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][0]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][1]; pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx]; iInterMbCorrectNum[iRefIdx]++; break; case MB_TYPE_16x8: - iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][0]; - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][0][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][0][1]; + iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][0]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][1]; pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx]; iInterMbCorrectNum[iRefIdx]++; - iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][8]; - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][8][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][8][1]; + iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][8]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][8][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][8][1]; pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx]; iInterMbCorrectNum[iRefIdx]++; break; case MB_TYPE_8x16: - iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][0]; - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][0][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][0][1]; + iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][0]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][1]; pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx]; iInterMbCorrectNum[iRefIdx]++; - iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][2]; - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][2][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][2][1]; + iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][2]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][2][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][2][1]; pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx]; iInterMbCorrectNum[iRefIdx]++; break; @@ -311,39 +311,39 @@ void GetAvilInfoFromCorrectMb (PWelsDecoderContext pCtx) { for (i = 0; i < 4; i++) { iSubMBType = pCurDqLayer->pSubMbType[iMbXyIndex][i]; iIIdx = ((i >> 1) << 3) + ((i & 1) << 1); - iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][iIIdx]; + iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][iIIdx]; pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx]; switch (iSubMBType) { case SUB_MB_TYPE_8x8: - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][1]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][1]; iInterMbCorrectNum[iRefIdx]++; break; case SUB_MB_TYPE_8x4: - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][1]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][1]; - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + 4][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + 4][1]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + 4][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + 4][1]; iInterMbCorrectNum[iRefIdx] += 2; break; case SUB_MB_TYPE_4x8: - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][1]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][1]; - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + 1][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + 1][1]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + 1][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + 1][1]; iInterMbCorrectNum[iRefIdx] += 2; break; case SUB_MB_TYPE_4x4: { for (j = 0; j < 4; j++) { iJIdx = ((j >> 1) << 2) + (j & 1); - pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + iJIdx][0]; - pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + iJIdx][1]; + pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + iJIdx][0]; + pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + iJIdx][1]; } iInterMbCorrectNum[iRefIdx] += 4; } @@ -372,7 +372,7 @@ void DoErrorConSliceMVCopy (PWelsDecoderContext pCtx) { int32_t iMbWidth = (int32_t) pCtx->pSps->iMbWidth; int32_t iMbHeight = (int32_t) pCtx->pSps->iMbHeight; PPicture pDstPic = pCtx->pDec; - PPicture pSrcPic = pCtx->pPreviousDecodedPictureInDpb; + PPicture pSrcPic = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb; bool* pMbCorrectlyDecodedFlag = pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag; int32_t iMbXyIndex; diff --git a/src/openh264/codec/decoder/core/src/fmo.cpp b/src/openh264/codec/decoder/core/src/fmo.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/src/get_intra_predictor.cpp b/src/openh264/codec/decoder/core/src/get_intra_predictor.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/src/manage_dec_ref.cpp b/src/openh264/codec/decoder/core/src/manage_dec_ref.cpp old mode 100755 new mode 100644 index 39e204e17..05aa40e13 --- a/src/openh264/codec/decoder/core/src/manage_dec_ref.cpp +++ b/src/openh264/codec/decoder/core/src/manage_dec_ref.cpp @@ -42,6 +42,7 @@ #include "manage_dec_ref.h" #include "error_concealment.h" #include "error_code.h" +#include "decoder.h" namespace WelsDec { @@ -50,10 +51,10 @@ static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameId static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum); static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx); -static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking); -static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, +static int32_t MMCO (PWelsDecoderContext pCtx, PRefPic pRefPic, PRefPicMarking pRefPicMarking); +static int32_t MMCOProcess (PWelsDecoderContext pCtx, PRefPic pRefPic, uint32_t uiMmcoType, int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx); -static int32_t SlidingWindow (PWelsDecoderContext pCtx); +static int32_t SlidingWindow (PWelsDecoderContext pCtx, PRefPic pRefPic); static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic); static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx, uint32_t uiLongTermPicNum); @@ -63,7 +64,7 @@ static int32_t WelsCheckAndRecoverForFutureDecoding (PWelsDecoderContext pCtx); #ifdef LONG_TERM_REF int32_t GetLTRFrameIndex (PRefPic pRefPic, int32_t iAncLTRFrameNum); #endif -static int32_t RemainOneBufferInDpbForEC (PWelsDecoderContext pCtx); +static int32_t RemainOneBufferInDpbForEC (PWelsDecoderContext pCtx, PRefPic pRefPic); static void SetUnRef (PPicture pRef) { if (NULL != pRef) { @@ -79,9 +80,19 @@ static void SetUnRef (PPicture pRef) { pRef->uiSpatialId = -1; pRef->iSpsId = -1; pRef->bIsComplete = false; + pRef->iRefCount = 0; + + if (pRef->eSliceType == I_SLICE) { + return; + } + int32_t lists = pRef->eSliceType == P_SLICE ? 1 : 2; for (int32_t i = 0; i < MAX_DPB_COUNT; ++i) { - pRef->pRefPic[LIST_0][i] = NULL; - pRef->pRefPic[LIST_1][i] = NULL; + for (int32_t list = 0; list < lists; ++list) { + if (pRef->pRefPic[list][i] != NULL) { + pRef->pRefPic[list][i]->iRefCount = 0; + pRef->pRefPic[list][i] = NULL; + } + } } } } @@ -115,9 +126,29 @@ void WelsResetRefPic (PWelsDecoderContext pCtx) { pRefPic->uiLongRefCount[LIST_0] = 0; } +void WelsResetRefPicWithoutUnRef (PWelsDecoderContext pCtx) { + int32_t i = 0; + PRefPic pRefPic = &pCtx->sRefPic; + pCtx->sRefPic.uiLongRefCount[LIST_0] = pCtx->sRefPic.uiShortRefCount[LIST_0] = 0; + + pRefPic->uiRefCount[LIST_0] = 0; + pRefPic->uiRefCount[LIST_1] = 0; + + for (i = 0; i < MAX_DPB_COUNT; i++) { + pRefPic->pShortRefList[LIST_0][i] = NULL; + } + pRefPic->uiShortRefCount[LIST_0] = 0; + + for (i = 0; i < MAX_DPB_COUNT; i++) { + pRefPic->pLongRefList[LIST_0][i] = NULL; + } + pRefPic->uiLongRefCount[LIST_0] = 0; +} + static int32_t WelsCheckAndRecoverForFutureDecoding (PWelsDecoderContext pCtx) { - if ((pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] <= 0) && (pCtx->eSliceType != I_SLICE - && pCtx->eSliceType != SI_SLICE)) { + if ((pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] <= 0) + && (pCtx->eSliceType != I_SLICE + && pCtx->eSliceType != SI_SLICE)) { if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { //IDR lost!, recover it for future decoding with data all set to 0 PPicture pRef = PrefetchPic (pCtx->pPicBuff); @@ -140,24 +171,29 @@ static int32_t WelsCheckAndRecoverForFutureDecoding (PWelsDecoderContext pCtx) { || (ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->pParam->eEcActiveIdc) || (ERROR_CON_SLICE_MV_COPY_CROSS_IDR == pCtx->pParam->eEcActiveIdc) || (ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->pParam->eEcActiveIdc)) - && (NULL != pCtx->pPreviousDecodedPictureInDpb); - bCopyPrevious = bCopyPrevious && (pRef->iWidthInPixel == pCtx->pPreviousDecodedPictureInDpb->iWidthInPixel) - && (pRef->iHeightInPixel == pCtx->pPreviousDecodedPictureInDpb->iHeightInPixel); + && (NULL != pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb); + bCopyPrevious = bCopyPrevious + && (pRef->iWidthInPixel == pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iWidthInPixel) + && (pRef->iHeightInPixel == pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iHeightInPixel); if (!bCopyPrevious) { memset (pRef->pData[0], 128, pRef->iLinesize[0] * pRef->iHeightInPixel); memset (pRef->pData[1], 128, pRef->iLinesize[1] * pRef->iHeightInPixel / 2); memset (pRef->pData[2], 128, pRef->iLinesize[2] * pRef->iHeightInPixel / 2); - } else if (pRef == pCtx->pPreviousDecodedPictureInDpb) { + } else if (pRef == pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsInitRefList()::EC memcpy overlap."); } else { - memcpy (pRef->pData[0], pCtx->pPreviousDecodedPictureInDpb->pData[0], pRef->iLinesize[0] * pRef->iHeightInPixel); - memcpy (pRef->pData[1], pCtx->pPreviousDecodedPictureInDpb->pData[1], pRef->iLinesize[1] * pRef->iHeightInPixel / 2); - memcpy (pRef->pData[2], pCtx->pPreviousDecodedPictureInDpb->pData[2], pRef->iLinesize[2] * pRef->iHeightInPixel / 2); + memcpy (pRef->pData[0], pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->pData[0], + pRef->iLinesize[0] * pRef->iHeightInPixel); + memcpy (pRef->pData[1], pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->pData[1], + pRef->iLinesize[1] * pRef->iHeightInPixel / 2); + memcpy (pRef->pData[2], pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->pData[2], + pRef->iLinesize[2] * pRef->iHeightInPixel / 2); } pRef->iFrameNum = 0; pRef->iFramePoc = 0; pRef->uiTemporalId = pRef->uiQualityId = 0; + pRef->eSliceType = pCtx->eSliceType; ExpandReferencingPicture (pRef->pData, pRef->iWidthInPixel, pRef->iHeightInPixel, pRef->iLinesize, pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture); AddShortTermToList (&pCtx->sRefPic, pRef); @@ -532,13 +568,20 @@ int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx) { for (i = WELS_MAX (1, WELS_MAX (iCount, pCtx->sRefPic.uiRefCount[listIdx])); i < iRefCount; i++) ppRefList[i] = ppRefList[i - 1]; - pCtx->sRefPic.uiRefCount[listIdx] = (uint8_t)WELS_MIN (WELS_MAX (iCount, pCtx->sRefPic.uiRefCount[listIdx]), iRefCount); + pCtx->sRefPic.uiRefCount[listIdx] = (uint8_t)WELS_MIN (WELS_MAX (iCount, pCtx->sRefPic.uiRefCount[listIdx]), + iRefCount); } return ERR_NONE; } -int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) { - PRefPic pRefPic = &pCtx->sRefPic; +int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, PPicture pLastDec) { + PPicture pDec = pLastDec; + bool isThreadCtx = true; + if (pDec == NULL) { + pDec = pCtx->pDec; + isThreadCtx = false; + } + PRefPic pRefPic = isThreadCtx ? &pCtx->sTmpRefPic : &pCtx->sRefPic; PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking; PAccessUnit pCurAU = pCtx->pAccessUnitList; bool bIsIDRAU = false; @@ -546,10 +589,10 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) { int32_t iRet = ERR_NONE; - pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId; - pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId; - pCtx->pDec->iSpsId = pCtx->pSps->iSpsId; - pCtx->pDec->iPpsId = pCtx->pPps->iPpsId; + pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId; + pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId; + pDec->iSpsId = pCtx->pSps->iSpsId; + pDec->iPpsId = pCtx->pPps->iPpsId; for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) { if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR @@ -560,33 +603,33 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) { } if (bIsIDRAU) { if (pRefPicMarking->bLongTermRefFlag) { - pCtx->sRefPic.iMaxLongTermFrameIdx = 0; - AddLongTermToList (pRefPic, pCtx->pDec, 0, 0); + pRefPic->iMaxLongTermFrameIdx = 0; + AddLongTermToList (pRefPic, pDec, 0, 0); } else { - pCtx->sRefPic.iMaxLongTermFrameIdx = -1; + pRefPic->iMaxLongTermFrameIdx = -1; } } else { if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) { - iRet = MMCO (pCtx, pRefPicMarking); + iRet = MMCO (pCtx, pRefPic, pRefPicMarking); if (iRet != ERR_NONE) { if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { - iRet = RemainOneBufferInDpbForEC (pCtx); + iRet = RemainOneBufferInDpbForEC (pCtx, pRefPic); WELS_VERIFY_RETURN_IF (iRet, iRet); } else { return iRet; } } - if (pCtx->bLastHasMmco5) { - pCtx->pDec->iFrameNum = 0; - pCtx->pDec->iFramePoc = 0; + if (pCtx->pLastDecPicInfo->bLastHasMmco5) { + pDec->iFrameNum = 0; + pDec->iFramePoc = 0; } } else { - iRet = SlidingWindow (pCtx); + iRet = SlidingWindow (pCtx, pRefPic); if (iRet != ERR_NONE) { if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { - iRet = RemainOneBufferInDpbForEC (pCtx); + iRet = RemainOneBufferInDpbForEC (pCtx, pRefPic); WELS_VERIFY_RETURN_IF (iRet, iRet); } else { return iRet; @@ -595,22 +638,22 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) { } } - if (!pCtx->pDec->bIsLongRef) { + if (!pDec->bIsLongRef) { if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] >= WELS_MAX (1, pCtx->pSps->iNumRefFrames)) { if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { - iRet = RemainOneBufferInDpbForEC (pCtx); + iRet = RemainOneBufferInDpbForEC (pCtx, pRefPic); WELS_VERIFY_RETURN_IF (iRet, iRet); } else { return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW; } } - iRet = AddShortTermToList (pRefPic, pCtx->pDec); + iRet = AddShortTermToList (pRefPic, pDec); } return iRet; } -static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { +static int32_t MMCO (PWelsDecoderContext pCtx, PRefPic pRefPic, PRefPicMarking pRefPicMarking) { PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps; int32_t i = 0; int32_t iRet = ERR_NONE; @@ -624,7 +667,8 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { if (uiMmcoType > MMCO_LONG) { return ERR_INFO_INVALID_MMCO_OPCODE_BASE; } - iRet = MMCOProcess (pCtx, uiMmcoType, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx); + iRet = MMCOProcess (pCtx, pRefPic, uiMmcoType, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, + iMaxLongTermFrameIdx); if (iRet != ERR_NONE) { return iRet; } @@ -635,9 +679,8 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { return ERR_NONE; } -static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, +static int32_t MMCOProcess (PWelsDecoderContext pCtx, PRefPic pRefPic, uint32_t uiMmcoType, int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) { - PRefPic pRefPic = &pCtx->sRefPic; PPicture pPic = NULL; int32_t i = 0; int32_t iRet = ERR_NONE; @@ -684,7 +727,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, break; case MMCO_RESET: WelsResetRefPic (pCtx); - pCtx->bLastHasMmco5 = true; + pCtx->pLastDecPicInfo->bLastHasMmco5 = true; break; case MMCO_LONG: if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) { @@ -709,13 +752,12 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, return iRet; } -static int32_t SlidingWindow (PWelsDecoderContext pCtx) { - PRefPic pRefPic = &pCtx->sRefPic; +static int32_t SlidingWindow (PWelsDecoderContext pCtx, PRefPic pRefPic) { PPicture pPic = NULL; int32_t i = 0; - if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) { - if (pCtx->sRefPic.uiShortRefCount[LIST_0] == 0) { + if (pRefPic->uiShortRefCount[LIST_0] + pRefPic->uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) { + if (pRefPic->uiShortRefCount[LIST_0] == 0) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "No reference picture in short term list when sliding window"); return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH; } @@ -740,8 +782,8 @@ static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) { for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) { if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) { iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1; - pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false; pPic = pRefPic->pShortRefList[LIST_0][i]; + pPic->bUsedAsRef = false; pRefPic->pShortRefList[LIST_0][i] = NULL; if (iMoveSize > 0) { memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1], @@ -752,7 +794,6 @@ static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) { break; } } - return pPic; } @@ -878,14 +919,13 @@ int32_t GetLTRFrameIndex (PRefPic pRefPic, int32_t iAncLTRFrameNum) { } #endif -static int32_t RemainOneBufferInDpbForEC (PWelsDecoderContext pCtx) { +static int32_t RemainOneBufferInDpbForEC (PWelsDecoderContext pCtx, PRefPic pRefPic) { int32_t iRet = ERR_NONE; - PRefPic pRefPic = &pCtx->sRefPic; if (pRefPic->uiShortRefCount[0] + pRefPic->uiLongRefCount[0] < pCtx->pSps->iNumRefFrames) return iRet; if (pRefPic->uiShortRefCount[0] > 0) { - iRet = SlidingWindow (pCtx); + iRet = SlidingWindow (pCtx, pRefPic); } else { //all LTR, remove the smallest long_term_frame_idx int32_t iLongTermFrameIdx = 0; int32_t iMaxLongTermFrameIdx = pRefPic->iMaxLongTermFrameIdx; diff --git a/src/openh264/codec/decoder/core/src/memmgr_nal_unit.cpp b/src/openh264/codec/decoder/core/src/memmgr_nal_unit.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/src/mv_pred.cpp b/src/openh264/codec/decoder/core/src/mv_pred.cpp old mode 100755 new mode 100644 index fd2bb260d..642a982d9 --- a/src/openh264/codec/decoder/core/src/mv_pred.cpp +++ b/src/openh264/codec/decoder/core/src/mv_pred.cpp @@ -155,7 +155,7 @@ void CopyRectBlock4Cols (void* vdst, void* vsrc, const int32_t stride_dst, const memcpy (&dst[stride_dst * 3], &src[stride_src * 3], 16); } } -void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { +void PredPSkipMvFromNeighbor (PDqLayer pCurDqLayer, int16_t iMvp[2]) { bool bTopAvail, bLeftTopAvail, bRightTopAvail, bLeftAvail; int32_t iCurSliceIdc, iTopSliceIdc, iLeftTopSliceIdc, iRightTopSliceIdc, iLeftSliceIdc; @@ -170,14 +170,14 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { int8_t iMatchRef; int16_t iMvA[2], iMvB[2], iMvC[2], iMvD[2]; - iCurXy = pCurLayer->iMbXyIndex; - iCurX = pCurLayer->iMbX; - iCurY = pCurLayer->iMbY; - iCurSliceIdc = pCurLayer->pSliceIdc[iCurXy]; + iCurXy = pCurDqLayer->iMbXyIndex; + iCurX = pCurDqLayer->iMbX; + iCurY = pCurDqLayer->iMbY; + iCurSliceIdc = pCurDqLayer->pSliceIdc[iCurXy]; if (iCurX != 0) { iLeftXy = iCurXy - 1; - iLeftSliceIdc = pCurLayer->pSliceIdc[iLeftXy]; + iLeftSliceIdc = pCurDqLayer->pSliceIdc[iLeftXy]; bLeftAvail = (iLeftSliceIdc == iCurSliceIdc); } else { bLeftAvail = 0; @@ -185,19 +185,19 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { } if (iCurY != 0) { - iTopXy = iCurXy - pCurLayer->iMbWidth; - iTopSliceIdc = pCurLayer->pSliceIdc[iTopXy]; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; + iTopSliceIdc = pCurDqLayer->pSliceIdc[iTopXy]; bTopAvail = (iTopSliceIdc == iCurSliceIdc); if (iCurX != 0) { iLeftTopXy = iTopXy - 1; - iLeftTopSliceIdc = pCurLayer->pSliceIdc[iLeftTopXy]; + iLeftTopSliceIdc = pCurDqLayer->pSliceIdc[iLeftTopXy]; bLeftTopAvail = (iLeftTopSliceIdc == iCurSliceIdc); } else { bLeftTopAvail = 0; } - if (iCurX != (pCurLayer->iMbWidth - 1)) { + if (iCurX != (pCurDqLayer->iMbWidth - 1)) { iRightTopXy = iTopXy + 1; - iRightTopSliceIdc = pCurLayer->pSliceIdc[iRightTopXy]; + iRightTopSliceIdc = pCurDqLayer->pSliceIdc[iRightTopXy]; bRightTopAvail = (iRightTopSliceIdc == iCurSliceIdc); } else { bRightTopAvail = 0; @@ -208,18 +208,18 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { bRightTopAvail = 0; } - iLeftType = ((iCurX != 0 && bLeftAvail) ? pCurLayer->pMbType[iLeftXy] : 0); - iTopType = ((iCurY != 0 && bTopAvail) ? pCurLayer->pMbType[iTopXy] : 0); + iLeftType = ((iCurX != 0 && bLeftAvail) ? GetMbType (pCurDqLayer)[iLeftXy] : 0); + iTopType = ((iCurY != 0 && bTopAvail) ? GetMbType (pCurDqLayer)[iTopXy] : 0); iLeftTopType = ((iCurX != 0 && iCurY != 0 && bLeftTopAvail) - ? pCurLayer->pMbType[iLeftTopXy] : 0); - iRightTopType = ((iCurX != pCurLayer->iMbWidth - 1 && iCurY != 0 && bRightTopAvail) - ? pCurLayer->pMbType[iRightTopXy] : 0); + ? GetMbType (pCurDqLayer)[iLeftTopXy] : 0); + iRightTopType = ((iCurX != pCurDqLayer->iMbWidth - 1 && iCurY != 0 && bRightTopAvail) + ? GetMbType (pCurDqLayer)[iRightTopXy] : 0); /*get neb mv&iRefIdxArray*/ /*left*/ if (bLeftAvail && IS_INTER (iLeftType)) { - ST32 (iMvA, LD32 (pCurLayer->pMv[0][iLeftXy][3])); - iLeftRef = pCurLayer->pRefIndex[0][iLeftXy][3]; + ST32 (iMvA, LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[0][iLeftXy][3] : pCurDqLayer->pMv[0][iLeftXy][3])); + iLeftRef = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[0][iLeftXy][3] : pCurDqLayer->pRefIndex[0][iLeftXy][3]; } else { ST32 (iMvA, 0); if (0 == bLeftAvail) { //not available @@ -236,8 +236,8 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { /*top*/ if (bTopAvail && IS_INTER (iTopType)) { - ST32 (iMvB, LD32 (pCurLayer->pMv[0][iTopXy][12])); - iTopRef = pCurLayer->pRefIndex[0][iTopXy][12]; + ST32 (iMvB, LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[0][iTopXy][12] : pCurDqLayer->pMv[0][iTopXy][12])); + iTopRef = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[0][iTopXy][12] : pCurDqLayer->pRefIndex[0][iTopXy][12]; } else { ST32 (iMvB, 0); if (0 == bTopAvail) { //not available @@ -254,8 +254,10 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { /*right_top*/ if (bRightTopAvail && IS_INTER (iRightTopType)) { - ST32 (iMvC, LD32 (pCurLayer->pMv[0][iRightTopXy][12])); - iRightTopRef = pCurLayer->pRefIndex[0][iRightTopXy][12]; + ST32 (iMvC, LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[0][iRightTopXy][12] : + pCurDqLayer->pMv[0][iRightTopXy][12])); + iRightTopRef = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[0][iRightTopXy][12] : + pCurDqLayer->pRefIndex[0][iRightTopXy][12]; } else { ST32 (iMvC, 0); if (0 == bRightTopAvail) { //not available @@ -267,8 +269,9 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { /*left_top*/ if (bLeftTopAvail && IS_INTER (iLeftTopType)) { - ST32 (iMvD, LD32 (pCurLayer->pMv[0][iLeftTopXy][15])); - iLeftTopRef = pCurLayer->pRefIndex[0][iLeftTopXy][15]; + ST32 (iMvD, LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[0][iLeftTopXy][15] : pCurDqLayer->pMv[0][iLeftTopXy][15])); + iLeftTopRef = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[0][iLeftTopXy][15] : + pCurDqLayer->pRefIndex[0][iLeftTopXy][15]; } else { ST32 (iMvD, 0); if (0 == bLeftTopAvail) { //not available @@ -305,13 +308,21 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { } int32_t GetColocatedMb (PWelsDecoderContext pCtx, MbType& mbType, SubMbType& subMbType) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - int32_t iMbXy = pCurLayer->iMbXyIndex; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; - uint32_t is8x8 = IS_Inter_8x8 (pCurLayer->pMbType[iMbXy]); - mbType = pCurLayer->pMbType[iMbXy]; + uint32_t is8x8 = IS_Inter_8x8 (GetMbType (pCurDqLayer)[iMbXy]); + mbType = GetMbType (pCurDqLayer)[iMbXy]; PPicture colocPic = pCtx->sRefPic.pRefList[LIST_1][0]; + if (GetThreadCount (pCtx) > 1) { + if (16 * pCurDqLayer->iMbY > pCtx->lastReadyHeightOffset[1][0]) { + if (colocPic->pReadyEvent[pCurDqLayer->iMbY].isSignaled != 1) { + WAIT_EVENT (&colocPic->pReadyEvent[pCurDqLayer->iMbY], WELS_DEC_THREAD_WAIT_INFINITE); + } + pCtx->lastReadyHeightOffset[1][0] = 16 * pCurDqLayer->iMbY; + } + } if (colocPic == NULL) { SLogContext* pLogCtx = & (pCtx->sLogCtx); @@ -336,43 +347,43 @@ int32_t GetColocatedMb (PWelsDecoderContext pCtx, MbType& mbType, SubMbType& sub } if (IS_INTRA (coloc_mbType)) { - SetRectBlock (pCurLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 1, sizeof (int8_t)); + SetRectBlock (pCurDqLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 1, sizeof (int8_t)); return ERR_NONE; } - SetRectBlock (pCurLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 0, sizeof (int8_t)); + SetRectBlock (pCurDqLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 0, sizeof (int8_t)); if (IS_INTER_16x16 (mbType)) { int16_t iMVZero[2] = { 0 }; int16_t* pMv = IS_TYPE_L1 (coloc_mbType) ? colocPic->pMv[LIST_1][iMbXy][0] : iMVZero; - ST32 (pCurLayer->iColocMv[LIST_0][0], LD32 (colocPic->pMv[LIST_0][iMbXy][0])); - ST32 (pCurLayer->iColocMv[LIST_1][0], LD32 (pMv)); - pCurLayer->iColocRefIndex[LIST_0][0] = colocPic->pRefIndex[LIST_0][iMbXy][0]; - pCurLayer->iColocRefIndex[LIST_1][0] = IS_TYPE_L1 (coloc_mbType) ? colocPic->pRefIndex[LIST_1][iMbXy][0] : - REF_NOT_IN_LIST; + ST32 (pCurDqLayer->iColocMv[LIST_0][0], LD32 (colocPic->pMv[LIST_0][iMbXy][0])); + ST32 (pCurDqLayer->iColocMv[LIST_1][0], LD32 (pMv)); + pCurDqLayer->iColocRefIndex[LIST_0][0] = colocPic->pRefIndex[LIST_0][iMbXy][0]; + pCurDqLayer->iColocRefIndex[LIST_1][0] = IS_TYPE_L1 (coloc_mbType) ? colocPic->pRefIndex[LIST_1][iMbXy][0] : + REF_NOT_IN_LIST; } else { if (!pCtx->pSps->bDirect8x8InferenceFlag) { - CopyRectBlock4Cols (pCurLayer->iColocMv[LIST_0], colocPic->pMv[LIST_0][iMbXy], 16, 16, 4, 4); - CopyRectBlock4Cols (pCurLayer->iColocRefIndex[LIST_0], colocPic->pRefIndex[LIST_0][iMbXy], 4, 4, 4, 1); + CopyRectBlock4Cols (pCurDqLayer->iColocMv[LIST_0], colocPic->pMv[LIST_0][iMbXy], 16, 16, 4, 4); + CopyRectBlock4Cols (pCurDqLayer->iColocRefIndex[LIST_0], colocPic->pRefIndex[LIST_0][iMbXy], 4, 4, 4, 1); if (IS_TYPE_L1 (coloc_mbType)) { - CopyRectBlock4Cols (pCurLayer->iColocMv[LIST_1], colocPic->pMv[LIST_1][iMbXy], 16, 16, 4, 4); - CopyRectBlock4Cols (pCurLayer->iColocRefIndex[LIST_1], colocPic->pRefIndex[LIST_1][iMbXy], 4, 4, 4, 1); + CopyRectBlock4Cols (pCurDqLayer->iColocMv[LIST_1], colocPic->pMv[LIST_1][iMbXy], 16, 16, 4, 4); + CopyRectBlock4Cols (pCurDqLayer->iColocRefIndex[LIST_1], colocPic->pRefIndex[LIST_1][iMbXy], 4, 4, 4, 1); } else { // only forward prediction - SetRectBlock (pCurLayer->iColocRefIndex[LIST_1], 4, 4, 4, (uint8_t)REF_NOT_IN_LIST, 1); + SetRectBlock (pCurDqLayer->iColocRefIndex[LIST_1], 4, 4, 4, (uint8_t)REF_NOT_IN_LIST, 1); } } else { for (int32_t listIdx = 0; listIdx < 1 + !! (coloc_mbType & MB_TYPE_L1); listIdx++) { - SetRectBlock (pCurLayer->iColocMv[listIdx][0], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][0]), 4); - SetRectBlock (pCurLayer->iColocMv[listIdx][2], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][3]), 4); - SetRectBlock (pCurLayer->iColocMv[listIdx][8], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][12]), 4); - SetRectBlock (pCurLayer->iColocMv[listIdx][10], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][15]), 4); + SetRectBlock (pCurDqLayer->iColocMv[listIdx][0], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][0]), 4); + SetRectBlock (pCurDqLayer->iColocMv[listIdx][2], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][3]), 4); + SetRectBlock (pCurDqLayer->iColocMv[listIdx][8], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][12]), 4); + SetRectBlock (pCurDqLayer->iColocMv[listIdx][10], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][15]), 4); - SetRectBlock (&pCurLayer->iColocRefIndex[listIdx][0], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][0], 1); - SetRectBlock (&pCurLayer->iColocRefIndex[listIdx][2], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][3], 1); - SetRectBlock (&pCurLayer->iColocRefIndex[listIdx][8], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][12], 1); - SetRectBlock (&pCurLayer->iColocRefIndex[listIdx][10], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][15], 1); + SetRectBlock (&pCurDqLayer->iColocRefIndex[listIdx][0], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][0], 1); + SetRectBlock (&pCurDqLayer->iColocRefIndex[listIdx][2], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][3], 1); + SetRectBlock (&pCurDqLayer->iColocRefIndex[listIdx][8], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][12], 1); + SetRectBlock (&pCurDqLayer->iColocRefIndex[listIdx][10], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][15], 1); } if (! (coloc_mbType & MB_TYPE_L1)) // only forward prediction - SetRectBlock (&pCurLayer->iColocRefIndex[1][0], 4, 4, 4, (uint8_t)REF_NOT_IN_LIST, 1); + SetRectBlock (&pCurDqLayer->iColocRefIndex[1][0], 4, 4, 4, (uint8_t)REF_NOT_IN_LIST, 1); } } return ERR_NONE; @@ -382,9 +393,9 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], SubMbType& subMbType) { int32_t ret = ERR_NONE; - PDqLayer pCurLayer = pCtx->pCurDqLayer; - int32_t iMbXy = pCurLayer->iMbXyIndex; - bool bSkipOrDirect = (IS_SKIP (pCurLayer->pMbType[iMbXy]) | IS_DIRECT (pCurLayer->pMbType[iMbXy])) > 0; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; + bool bSkipOrDirect = (IS_SKIP (GetMbType (pCurDqLayer)[iMbXy]) | IS_DIRECT (GetMbType (pCurDqLayer)[iMbXy])) > 0; MbType mbType; ret = GetColocatedMb (pCtx, mbType, subMbType); @@ -404,15 +415,15 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int8_t iDiagonalRef[LIST_A]; int16_t iMvA[LIST_A][2], iMvB[LIST_A][2], iMvC[LIST_A][2], iMvD[LIST_A][2]; - iCurXy = pCurLayer->iMbXyIndex; + iCurXy = pCurDqLayer->iMbXyIndex; - iCurX = pCurLayer->iMbX; - iCurY = pCurLayer->iMbY; - iCurSliceIdc = pCurLayer->pSliceIdc[iCurXy]; + iCurX = pCurDqLayer->iMbX; + iCurY = pCurDqLayer->iMbY; + iCurSliceIdc = pCurDqLayer->pSliceIdc[iCurXy]; if (iCurX != 0) { iLeftXy = iCurXy - 1; - iLeftSliceIdc = pCurLayer->pSliceIdc[iLeftXy]; + iLeftSliceIdc = pCurDqLayer->pSliceIdc[iLeftXy]; bLeftAvail = (iLeftSliceIdc == iCurSliceIdc); } else { bLeftAvail = 0; @@ -420,19 +431,19 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], } if (iCurY != 0) { - iTopXy = iCurXy - pCurLayer->iMbWidth; - iTopSliceIdc = pCurLayer->pSliceIdc[iTopXy]; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; + iTopSliceIdc = pCurDqLayer->pSliceIdc[iTopXy]; bTopAvail = (iTopSliceIdc == iCurSliceIdc); if (iCurX != 0) { iLeftTopXy = iTopXy - 1; - iLeftTopSliceIdc = pCurLayer->pSliceIdc[iLeftTopXy]; + iLeftTopSliceIdc = pCurDqLayer->pSliceIdc[iLeftTopXy]; bLeftTopAvail = (iLeftTopSliceIdc == iCurSliceIdc); } else { bLeftTopAvail = 0; } - if (iCurX != (pCurLayer->iMbWidth - 1)) { + if (iCurX != (pCurDqLayer->iMbWidth - 1)) { iRightTopXy = iTopXy + 1; - iRightTopSliceIdc = pCurLayer->pSliceIdc[iRightTopXy]; + iRightTopSliceIdc = pCurDqLayer->pSliceIdc[iRightTopXy]; bRightTopAvail = (iRightTopSliceIdc == iCurSliceIdc); } else { bRightTopAvail = 0; @@ -443,20 +454,22 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], bRightTopAvail = 0; } - iLeftType = ((iCurX != 0 && bLeftAvail) ? pCurLayer->pMbType[iLeftXy] : 0); - iTopType = ((iCurY != 0 && bTopAvail) ? pCurLayer->pMbType[iTopXy] : 0); + iLeftType = ((iCurX != 0 && bLeftAvail) ? GetMbType (pCurDqLayer)[iLeftXy] : 0); + iTopType = ((iCurY != 0 && bTopAvail) ? GetMbType (pCurDqLayer)[iTopXy] : 0); iLeftTopType = ((iCurX != 0 && iCurY != 0 && bLeftTopAvail) - ? pCurLayer->pMbType[iLeftTopXy] : 0); - iRightTopType = ((iCurX != pCurLayer->iMbWidth - 1 && iCurY != 0 && bRightTopAvail) - ? pCurLayer->pMbType[iRightTopXy] : 0); + ? GetMbType (pCurDqLayer)[iLeftTopXy] : 0); + iRightTopType = ((iCurX != pCurDqLayer->iMbWidth - 1 && iCurY != 0 && bRightTopAvail) + ? GetMbType (pCurDqLayer)[iRightTopXy] : 0); /*get neb mv&iRefIdxArray*/ for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { /*left*/ if (bLeftAvail && IS_INTER (iLeftType)) { - ST32 (iMvA[listIdx], LD32 (pCurLayer->pMv[listIdx][iLeftXy][3])); - iLeftRef[listIdx] = pCurLayer->pRefIndex[listIdx][iLeftXy][3]; + ST32 (iMvA[listIdx], LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[listIdx][iLeftXy][3] : + pCurDqLayer->pMv[listIdx][iLeftXy][3])); + iLeftRef[listIdx] = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][3] : + pCurDqLayer->pRefIndex[listIdx][iLeftXy][3]; } else { ST32 (iMvA[listIdx], 0); if (0 == bLeftAvail) { //not available @@ -468,8 +481,10 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], /*top*/ if (bTopAvail && IS_INTER (iTopType)) { - ST32 (iMvB[listIdx], LD32 (pCurLayer->pMv[listIdx][iTopXy][12])); - iTopRef[listIdx] = pCurLayer->pRefIndex[listIdx][iTopXy][12]; + ST32 (iMvB[listIdx], LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[listIdx][iTopXy][12] : + pCurDqLayer->pMv[listIdx][iTopXy][12])); + iTopRef[listIdx] = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[listIdx][iTopXy][12] : + pCurDqLayer->pRefIndex[listIdx][iTopXy][12]; } else { ST32 (iMvB[listIdx], 0); if (0 == bTopAvail) { //not available @@ -481,8 +496,10 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], /*right_top*/ if (bRightTopAvail && IS_INTER (iRightTopType)) { - ST32 (iMvC[listIdx], LD32 (pCurLayer->pMv[listIdx][iRightTopXy][12])); - iRightTopRef[listIdx] = pCurLayer->pRefIndex[listIdx][iRightTopXy][12]; + ST32 (iMvC[listIdx], LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[listIdx][iRightTopXy][12] : + pCurDqLayer->pMv[listIdx][iRightTopXy][12])); + iRightTopRef[listIdx] = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[listIdx][iRightTopXy][12] : + pCurDqLayer->pRefIndex[listIdx][iRightTopXy][12]; } else { ST32 (iMvC[listIdx], 0); if (0 == bRightTopAvail) { //not available @@ -493,8 +510,10 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], } /*left_top*/ if (bLeftTopAvail && IS_INTER (iLeftTopType)) { - ST32 (iMvD[listIdx], LD32 (pCurLayer->pMv[listIdx][iLeftTopXy][15])); - iLeftTopRef[listIdx] = pCurLayer->pRefIndex[listIdx][iLeftTopXy][15]; + ST32 (iMvD[listIdx], LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[listIdx][iLeftTopXy][15] : + pCurDqLayer->pMv[listIdx][iLeftTopXy][15])); + iLeftTopRef[listIdx] = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[listIdx][iLeftTopXy][15] : + pCurDqLayer->pRefIndex[listIdx][iLeftTopXy][15]; } else { ST32 (iMvD[listIdx], 0); if (0 == bLeftTopAvail) { //not available @@ -543,7 +562,7 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], mbType &= ~MB_TYPE_L0; subMbType &= ~MB_TYPE_L0; } - pCurLayer->pMbType[iMbXy] = mbType; + GetMbType (pCurDqLayer)[iMbXy] = mbType; int16_t pMvd[4] = { 0 }; @@ -551,31 +570,31 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], if (IS_INTER_16x16 (mbType)) { if ((* (int32_t*)iMvp[LIST_0] | * (int32_t*)iMvp[LIST_1])) { - if (0 == pCurLayer->iColocIntra[0] && !bIsLongRef - && ((pCurLayer->iColocRefIndex[LIST_0][0] == 0 && (unsigned) (pCurLayer->iColocMv[LIST_0][0][0] + 1) <= 2 - && (unsigned) (pCurLayer->iColocMv[LIST_0][0][1] + 1) <= 2) - || (pCurLayer->iColocRefIndex[LIST_0][0] < 0 && pCurLayer->iColocRefIndex[LIST_1][0] == 0 - && (unsigned) (pCurLayer->iColocMv[LIST_1][0][0] + 1) <= 2 - && (unsigned) (pCurLayer->iColocMv[LIST_1][0][1] + 1) <= 2))) { + if (0 == pCurDqLayer->iColocIntra[0] && !bIsLongRef + && ((pCurDqLayer->iColocRefIndex[LIST_0][0] == 0 && (unsigned) (pCurDqLayer->iColocMv[LIST_0][0][0] + 1) <= 2 + && (unsigned) (pCurDqLayer->iColocMv[LIST_0][0][1] + 1) <= 2) + || (pCurDqLayer->iColocRefIndex[LIST_0][0] < 0 && pCurDqLayer->iColocRefIndex[LIST_1][0] == 0 + && (unsigned) (pCurDqLayer->iColocMv[LIST_1][0][0] + 1) <= 2 + && (unsigned) (pCurDqLayer->iColocMv[LIST_1][0][1] + 1) <= 2))) { if (0 >= ref[0]) * (uint32_t*)iMvp[LIST_0] = 0; if (0 >= ref[1]) * (uint32_t*)iMvp[LIST_1] = 0; } } - UpdateP16x16DirectCabac (pCurLayer); + UpdateP16x16DirectCabac (pCurDqLayer); for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { - UpdateP16x16MotionInfo (pCurLayer, listIdx, ref[listIdx], iMvp[listIdx]); - UpdateP16x16MvdCabac (pCurLayer, pMvd, listIdx); + UpdateP16x16MotionInfo (pCurDqLayer, listIdx, ref[listIdx], iMvp[listIdx]); + UpdateP16x16MvdCabac (pCurDqLayer, pMvd, listIdx); } } else { if (bSkipOrDirect) { int8_t pSubPartCount[4], pPartW[4]; for (int32_t i = 0; i < 4; i++) { //Direct 8x8 Ref and mv int16_t iIdx8 = i << 2; - pCurLayer->pSubMbType[iMbXy][i] = subMbType; + pCurDqLayer->pSubMbType[iMbXy][i] = subMbType; int8_t pRefIndex[LIST_A][30]; - UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0); - UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1); - UpdateP8x8DirectCabac (pCurLayer, iIdx8); + UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0); + UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1); + UpdateP8x8DirectCabac (pCurDqLayer, iIdx8); pSubPartCount[i] = g_ksInterBSubMbTypeInfo[0].iPartCount; pPartW[i] = g_ksInterBSubMbTypeInfo[0].iPartWidth; @@ -584,7 +603,7 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], pSubPartCount[i] = 4; pPartW[i] = 1; } - FillSpatialDirect8x8Mv (pCurLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, bIsLongRef, iMvp, ref, NULL, NULL); + FillSpatialDirect8x8Mv (pCurDqLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, bIsLongRef, iMvp, ref, NULL, NULL); } } } @@ -594,9 +613,9 @@ int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int32_t PredBDirectTemporal (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int8_t ref[LIST_A], SubMbType& subMbType) { int32_t ret = ERR_NONE; - PDqLayer pCurLayer = pCtx->pCurDqLayer; - int32_t iMbXy = pCurLayer->iMbXyIndex; - bool bSkipOrDirect = (IS_SKIP (pCurLayer->pMbType[iMbXy]) | IS_DIRECT (pCurLayer->pMbType[iMbXy])) > 0; + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; + bool bSkipOrDirect = (IS_SKIP (GetMbType (pCurDqLayer)[iMbXy]) | IS_DIRECT (GetMbType (pCurDqLayer)[iMbXy])) > 0; MbType mbType; ret = GetColocatedMb (pCtx, mbType, subMbType); @@ -604,42 +623,42 @@ int32_t PredBDirectTemporal (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], return ret; } - pCurLayer->pMbType[iMbXy] = mbType; + GetMbType (pCurDqLayer)[iMbXy] = mbType; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int16_t pMvd[4] = { 0 }; const int32_t ref0Count = WELS_MIN (pSliceHeader->uiRefCount[LIST_0], pCtx->sRefPic.uiRefCount[LIST_0]); if (IS_INTER_16x16 (mbType)) { ref[LIST_0] = 0; ref[LIST_1] = 0; - UpdateP16x16DirectCabac (pCurLayer); - UpdateP16x16RefIdx (pCurLayer, LIST_1, ref[LIST_1]); + UpdateP16x16DirectCabac (pCurDqLayer); + UpdateP16x16RefIdx (pCurDqLayer, LIST_1, ref[LIST_1]); ST64 (iMvp, 0); - if (pCurLayer->iColocIntra[0]) { - UpdateP16x16MotionOnly (pCurLayer, LIST_0, iMvp[LIST_0]); - UpdateP16x16MotionOnly (pCurLayer, LIST_1, iMvp[LIST_1]); - UpdateP16x16RefIdx (pCurLayer, LIST_0, ref[LIST_0]); + if (pCurDqLayer->iColocIntra[0]) { + UpdateP16x16MotionOnly (pCurDqLayer, LIST_0, iMvp[LIST_0]); + UpdateP16x16MotionOnly (pCurDqLayer, LIST_1, iMvp[LIST_1]); + UpdateP16x16RefIdx (pCurDqLayer, LIST_0, ref[LIST_0]); } else { ref[LIST_0] = 0; - int16_t* mv = pCurLayer->iColocMv[LIST_0][0]; - int8_t colocRefIndexL0 = pCurLayer->iColocRefIndex[LIST_0][0]; + int16_t* mv = pCurDqLayer->iColocMv[LIST_0][0]; + int8_t colocRefIndexL0 = pCurDqLayer->iColocRefIndex[LIST_0][0]; if (colocRefIndexL0 >= 0) { ref[LIST_0] = MapColToList0 (pCtx, colocRefIndexL0, ref0Count); } else { - mv = pCurLayer->iColocMv[LIST_1][0]; + mv = pCurDqLayer->iColocMv[LIST_1][0]; } - UpdateP16x16RefIdx (pCurLayer, LIST_0, ref[LIST_0]); + UpdateP16x16RefIdx (pCurDqLayer, LIST_0, ref[LIST_0]); iMvp[LIST_0][0] = (pSlice->iMvScale[LIST_0][ref[LIST_0]] * mv[0] + 128) >> 8; iMvp[LIST_0][1] = (pSlice->iMvScale[LIST_0][ref[LIST_0]] * mv[1] + 128) >> 8; - UpdateP16x16MotionOnly (pCurLayer, LIST_0, iMvp[LIST_0]); + UpdateP16x16MotionOnly (pCurDqLayer, LIST_0, iMvp[LIST_0]); iMvp[LIST_1][0] = iMvp[LIST_0][0] - mv[0]; iMvp[LIST_1][1] = iMvp[LIST_0][1] - mv[1]; - UpdateP16x16MotionOnly (pCurLayer, LIST_1, iMvp[LIST_1]); + UpdateP16x16MotionOnly (pCurDqLayer, LIST_1, iMvp[LIST_1]); } - UpdateP16x16MvdCabac (pCurLayer, pMvd, LIST_0); - UpdateP16x16MvdCabac (pCurLayer, pMvd, LIST_1); + UpdateP16x16MvdCabac (pCurDqLayer, pMvd, LIST_0); + UpdateP16x16MvdCabac (pCurDqLayer, pMvd, LIST_1); } else { if (bSkipOrDirect) { int8_t pSubPartCount[4], pPartW[4]; @@ -647,27 +666,27 @@ int32_t PredBDirectTemporal (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], for (int32_t i = 0; i < 4; i++) { int16_t iIdx8 = i << 2; const uint8_t iScan4Idx = g_kuiScan4[iIdx8]; - pCurLayer->pSubMbType[iMbXy][i] = subMbType; + pCurDqLayer->pSubMbType[iMbXy][i] = subMbType; - int16_t (*mvColoc)[2] = pCurLayer->iColocMv[LIST_0]; + int16_t (*mvColoc)[2] = pCurDqLayer->iColocMv[LIST_0]; ref[LIST_1] = 0; - UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1); - if (pCurLayer->iColocIntra[iScan4Idx]) { + UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1); + if (pCurDqLayer->iColocIntra[iScan4Idx]) { ref[LIST_0] = 0; - UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0); + UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0); ST64 (iMvp, 0); } else { ref[LIST_0] = 0; - int8_t colocRefIndexL0 = pCurLayer->iColocRefIndex[LIST_0][iScan4Idx]; + int8_t colocRefIndexL0 = pCurDqLayer->iColocRefIndex[LIST_0][iScan4Idx]; if (colocRefIndexL0 >= 0) { ref[LIST_0] = MapColToList0 (pCtx, colocRefIndexL0, ref0Count); } else { - mvColoc = pCurLayer->iColocMv[LIST_1]; + mvColoc = pCurDqLayer->iColocMv[LIST_1]; } - UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0); + UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0); } - UpdateP8x8DirectCabac (pCurLayer, iIdx8); + UpdateP8x8DirectCabac (pCurDqLayer, iIdx8); pSubPartCount[i] = g_ksInterBSubMbTypeInfo[0].iPartCount; pPartW[i] = g_ksInterBSubMbTypeInfo[0].iPartWidth; @@ -676,7 +695,7 @@ int32_t PredBDirectTemporal (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], pSubPartCount[i] = 4; pPartW[i] = 1; } - FillTemporalDirect8x8Mv (pCurLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, ref, mvColoc, NULL, NULL); + FillTemporalDirect8x8Mv (pCurDqLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, ref, mvColoc, NULL, NULL); } } } @@ -785,14 +804,23 @@ void UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int32_t listIdx, int8_t iRef, //mb const uint8_t kuiScan4Idx = g_kuiScan4[i]; const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx; + if (pCurDqLayer->pDec != NULL) { + ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2); + ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); - ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx ], kiRef2); - ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + } else { + ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2); + ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4Idx ], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx ], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4IdxPlus4], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + } } } @@ -808,8 +836,8 @@ void UpdateP16x16RefIdx (PDqLayer pCurDqLayer, int32_t listIdx, int8_t iRef) { const uint8_t kuiScan4Idx = g_kuiScan4[i]; const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx; - ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2); - ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); + ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2); + ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); } } @@ -824,11 +852,17 @@ void UpdateP16x16MotionOnly (PDqLayer pCurDqLayer, int32_t listIdx, int16_t iMVs //mb const uint8_t kuiScan4Idx = g_kuiScan4[i]; const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx; - - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + if (pCurDqLayer->pDec != NULL) { + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + } else { + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + } } } @@ -848,12 +882,21 @@ void UpdateP16x8MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][ const uint8_t kuiCacheIdxPlus6 = 6 + kuiCacheIdx; //mb - ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx ], kiRef2); - ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4Idx ], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx ], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4IdxPlus4], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + if (pCurDqLayer->pDec != NULL) { + ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2); + ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + } else { + ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2); + ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + } //cache ST16 (&iRefIndex[listIdx][kuiCacheIdx ], kiRef2); ST16 (&iRefIndex[listIdx][kuiCacheIdxPlus6], kiRef2); @@ -879,12 +922,21 @@ void UpdateP8x16MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][ const uint8_t kuiCacheIdxPlus6 = 6 + kuiCacheIdx; //mb - ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx ], kiRef2); - ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4Idx ], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx ], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4IdxPlus4], kiMV32); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + if (pCurDqLayer->pDec != NULL) { + ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2); + ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + } else { + ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2); + ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32); + ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32); + } //cache ST16 (&iRefIndex[listIdx][kuiCacheIdx ], kiRef2); ST16 (&iRefIndex[listIdx][kuiCacheIdxPlus6], kiRef2); @@ -895,10 +947,10 @@ void UpdateP8x16MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][ } } -void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW, +void FillSpatialDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW, const SubMbType& subMbType, const bool& bIsLongRef, int16_t pMvDirect[LIST_A][2], int8_t iRef[LIST_A], int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]) { - int32_t iMbXy = pCurLayer->iMbXyIndex; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; for (int32_t j = 0; j < iPartCount; j++) { int8_t iPartIdx = iIdx8 + j * iPartW; uint8_t iScan4Idx = g_kuiScan4[iPartIdx]; @@ -909,10 +961,10 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int if (IS_SUB_8x8 (subMbType)) { * (uint32_t*)pMV = * (uint32_t*)pMvDirect[LIST_0]; ST32 ((pMV + 2), LD32 (pMV)); - ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], LD64 (pMV)); - ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx + 4], LD64 (pMV)); - ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); - ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0); + ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], LD64 (pMV)); + ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx + 4], LD64 (pMV)); + ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); + ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0); if (pMotionVector != NULL) { ST64 (pMotionVector[LIST_0][iCacheIdx], LD64 (pMV)); ST64 (pMotionVector[LIST_0][iCacheIdx + 6], LD64 (pMV)); @@ -923,10 +975,10 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int } * (uint32_t*)pMV = * (uint32_t*)pMvDirect[LIST_1]; ST32 ((pMV + 2), LD32 (pMV)); - ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], LD64 (pMV)); - ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx + 4], LD64 (pMV)); - ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); - ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0); + ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], LD64 (pMV)); + ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx + 4], LD64 (pMV)); + ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); + ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0); if (pMotionVector != NULL) { ST64 (pMotionVector[LIST_1][iCacheIdx], LD64 (pMV)); ST64 (pMotionVector[LIST_1][iCacheIdx + 6], LD64 (pMV)); @@ -937,8 +989,8 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int } } else { //SUB_4x4 * (uint32_t*)pMV = * (uint32_t*)pMvDirect[LIST_0]; - ST32 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], LD32 (pMV)); - ST32 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); + ST32 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], LD32 (pMV)); + ST32 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); if (pMotionVector != NULL) { ST32 (pMotionVector[LIST_0][iCacheIdx], LD32 (pMV)); } @@ -946,8 +998,8 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int ST32 (pMvdCache[LIST_0][iCacheIdx], 0); } * (uint32_t*)pMV = * (uint32_t*)pMvDirect[LIST_1]; - ST32 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], LD32 (pMV)); - ST32 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); + ST32 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], LD32 (pMV)); + ST32 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); if (pMotionVector != NULL) { ST32 (pMotionVector[LIST_1][iCacheIdx], LD32 (pMV)); } @@ -956,19 +1008,19 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int } } if ((* (int32_t*)pMvDirect[LIST_0] | * (int32_t*)pMvDirect[LIST_1])) { - uint32_t uiColZeroFlag = (0 == pCurLayer->iColocIntra[iColocIdx]) && !bIsLongRef && - (pCurLayer->iColocRefIndex[LIST_0][iColocIdx] == 0 || (pCurLayer->iColocRefIndex[LIST_0][iColocIdx] < 0 - && pCurLayer->iColocRefIndex[LIST_1][iColocIdx] == 0)); - const int16_t (*mvColoc)[2] = 0 == pCurLayer->iColocRefIndex[LIST_0][iColocIdx] ? pCurLayer->iColocMv[LIST_0] : - pCurLayer->iColocMv[LIST_1]; + uint32_t uiColZeroFlag = (0 == pCurDqLayer->iColocIntra[iColocIdx]) && !bIsLongRef && + (pCurDqLayer->iColocRefIndex[LIST_0][iColocIdx] == 0 || (pCurDqLayer->iColocRefIndex[LIST_0][iColocIdx] < 0 + && pCurDqLayer->iColocRefIndex[LIST_1][iColocIdx] == 0)); + const int16_t (*mvColoc)[2] = 0 == pCurDqLayer->iColocRefIndex[LIST_0][iColocIdx] ? pCurDqLayer->iColocMv[LIST_0] : + pCurDqLayer->iColocMv[LIST_1]; const int16_t* mv = mvColoc[iColocIdx]; if (IS_SUB_8x8 (subMbType)) { if (uiColZeroFlag && ((unsigned) (mv[0] + 1) <= 2 && (unsigned) (mv[1] + 1) <= 2)) { if (iRef[LIST_0] == 0) { - ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], 0); - ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx + 4], 0); - ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); - ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0); + ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], 0); + ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx + 4], 0); + ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); + ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0); if (pMotionVector != NULL) { ST64 (pMotionVector[LIST_0][iCacheIdx], 0); ST64 (pMotionVector[LIST_0][iCacheIdx + 6], 0); @@ -980,10 +1032,10 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int } if (iRef[LIST_1] == 0) { - ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], 0); - ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx + 4], 0); - ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); - ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0); + ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], 0); + ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx + 4], 0); + ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); + ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0); if (pMotionVector != NULL) { ST64 (pMotionVector[LIST_1][iCacheIdx], 0); ST64 (pMotionVector[LIST_1][iCacheIdx + 6], 0); @@ -997,8 +1049,8 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int } else { if (uiColZeroFlag && ((unsigned) (mv[0] + 1) <= 2 && (unsigned) (mv[1] + 1) <= 2)) { if (iRef[LIST_0] == 0) { - ST32 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], 0); - ST32 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); + ST32 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], 0); + ST32 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); if (pMotionVector != NULL) { ST32 (pMotionVector[LIST_0][iCacheIdx], 0); } @@ -1007,8 +1059,8 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int } } if (iRef[LIST_1] == 0) { - ST32 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], 0); - ST32 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); + ST32 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], 0); + ST32 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); if (pMotionVector != NULL) { ST32 (pMotionVector[LIST_1][iCacheIdx], 0); } @@ -1022,11 +1074,12 @@ void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int } } -void FillTemporalDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW, +void FillTemporalDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount, + const int8_t& iPartW, const SubMbType& subMbType, int8_t iRef[LIST_A], int16_t (*mvColoc)[2], int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]) { - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; - int32_t iMbXy = pCurLayer->iMbXyIndex; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; int16_t pMvDirect[LIST_A][2] = { { 0, 0 }, { 0, 0 } }; for (int32_t j = 0; j < iPartCount; j++) { int8_t iPartIdx = iIdx8 + j * iPartW; @@ -1038,16 +1091,16 @@ void FillTemporalDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const in int16_t pMV[4] = { 0 }; if (IS_SUB_8x8 (subMbType)) { - if (!pCurLayer->iColocIntra[iColocIdx]) { + if (!pCurDqLayer->iColocIntra[iColocIdx]) { pMvDirect[LIST_0][0] = (pSlice->iMvScale[LIST_0][iRef[LIST_0]] * mv[0] + 128) >> 8; pMvDirect[LIST_0][1] = (pSlice->iMvScale[LIST_0][iRef[LIST_0]] * mv[1] + 128) >> 8; } ST32 (pMV, LD32 (pMvDirect[LIST_0])); ST32 ((pMV + 2), LD32 (pMvDirect[LIST_0])); - ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], LD64 (pMV)); - ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx + 4], LD64 (pMV)); - ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); - ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0); + ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], LD64 (pMV)); + ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx + 4], LD64 (pMV)); + ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); + ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0); if (pMotionVector != NULL) { ST64 (pMotionVector[LIST_0][iCacheIdx], LD64 (pMV)); ST64 (pMotionVector[LIST_0][iCacheIdx + 6], LD64 (pMV)); @@ -1056,16 +1109,16 @@ void FillTemporalDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const in ST64 (pMvdCache[LIST_0][iCacheIdx], 0); ST64 (pMvdCache[LIST_0][iCacheIdx + 6], 0); } - if (!pCurLayer->iColocIntra[g_kuiScan4[iIdx8]]) { + if (!pCurDqLayer->iColocIntra[g_kuiScan4[iIdx8]]) { pMvDirect[LIST_1][0] = pMvDirect[LIST_0][0] - mv[0]; pMvDirect[LIST_1][1] = pMvDirect[LIST_0][1] - mv[1]; } ST32 (pMV, LD32 (pMvDirect[LIST_1])); ST32 ((pMV + 2), LD32 (pMvDirect[LIST_1])); - ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], LD64 (pMV)); - ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx + 4], LD64 (pMV)); - ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); - ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0); + ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], LD64 (pMV)); + ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx + 4], LD64 (pMV)); + ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); + ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0); if (pMotionVector != NULL) { ST64 (pMotionVector[LIST_1][iCacheIdx], LD64 (pMV)); ST64 (pMotionVector[LIST_1][iCacheIdx + 6], LD64 (pMV)); @@ -1075,24 +1128,24 @@ void FillTemporalDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const in ST64 (pMvdCache[LIST_1][iCacheIdx + 6], 0); } } else { //SUB_4x4 - if (!pCurLayer->iColocIntra[iColocIdx]) { + if (!pCurDqLayer->iColocIntra[iColocIdx]) { pMvDirect[LIST_0][0] = (pSlice->iMvScale[LIST_0][iRef[LIST_0]] * mv[0] + 128) >> 8; pMvDirect[LIST_0][1] = (pSlice->iMvScale[LIST_0][iRef[LIST_0]] * mv[1] + 128) >> 8; } - ST32 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], LD32 (pMvDirect[LIST_0])); - ST32 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); + ST32 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], LD32 (pMvDirect[LIST_0])); + ST32 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0); if (pMotionVector != NULL) { ST32 (pMotionVector[LIST_0][iCacheIdx], LD32 (pMvDirect[LIST_0])); } if (pMvdCache != NULL) { ST32 (pMvdCache[LIST_0][iCacheIdx], 0); } - if (!pCurLayer->iColocIntra[iColocIdx]) { + if (!pCurDqLayer->iColocIntra[iColocIdx]) { pMvDirect[LIST_1][0] = pMvDirect[LIST_0][0] - mv[0]; pMvDirect[LIST_1][1] = pMvDirect[LIST_0][1] - mv[1]; } - ST32 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], LD32 (pMvDirect[LIST_1])); - ST32 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); + ST32 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], LD32 (pMvDirect[LIST_1])); + ST32 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0); if (pMotionVector != NULL) { ST32 (pMotionVector[LIST_1][iCacheIdx], LD32 (pMvDirect[LIST_1])); } @@ -1122,8 +1175,9 @@ int8_t MapColToList0 (PWelsDecoderContext& pCtx, const int8_t& colocRefIndexL0, void Update8x8RefIdx (PDqLayer& pCurDqLayer, const int16_t& iPartIdx, const int32_t& listIdx, const int8_t& iRef) { int32_t iMbXy = pCurDqLayer->iMbXyIndex; const uint8_t iScan4Idx = g_kuiScan4[iPartIdx]; - pCurDqLayer->pRefIndex[listIdx][iMbXy][iScan4Idx] = pCurDqLayer->pRefIndex[listIdx][iMbXy][iScan4Idx + 1] = - pCurDqLayer->pRefIndex[listIdx][iMbXy][iScan4Idx + 4] = pCurDqLayer->pRefIndex[listIdx][iMbXy][iScan4Idx + 5] = iRef; + pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx] = pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx + 1] = + pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx + 4] = pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx + + 5] = iRef; } } // namespace WelsDec diff --git a/src/openh264/codec/decoder/core/src/parse_mb_syn_cabac.cpp b/src/openh264/codec/decoder/core/src/parse_mb_syn_cabac.cpp old mode 100755 new mode 100644 index 14bbab838..690acd09e --- a/src/openh264/codec/decoder/core/src/parse_mb_syn_cabac.cpp +++ b/src/openh264/codec/decoder/core/src/parse_mb_syn_cabac.cpp @@ -35,6 +35,7 @@ #include "mv_pred.h" #include "error_code.h" #include + namespace WelsDec { #define IDX_UNUSED -1 @@ -110,8 +111,8 @@ void UpdateP16x8RefIdxCabac (PDqLayer pCurDqLayer, int8_t pRefIndex[LIST_A][30], const uint8_t iCacheIdx = g_kuiCache30ScanIdx[iPartIdx]; const uint8_t iCacheIdx6 = 6 + iCacheIdx; //mb - ST32 (&pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx ], iRef4Bytes); - ST32 (&pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx4], iRef4Bytes); + ST32 (&pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx ], iRef4Bytes); + ST32 (&pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx4], iRef4Bytes); //cache ST32 (&pRefIndex[iListIdx][iCacheIdx ], iRef4Bytes); ST32 (&pRefIndex[iListIdx][iCacheIdx6], iRef4Bytes); @@ -129,8 +130,8 @@ void UpdateP8x16RefIdxCabac (PDqLayer pCurDqLayer, int8_t pRefIndex[LIST_A][30], const uint8_t iScan4Idx4 = 4 + iScan4Idx; const uint8_t iCacheIdx6 = 6 + iCacheIdx; //mb - ST16 (&pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx ], iRef2Bytes); - ST16 (&pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx4], iRef2Bytes); + ST16 (&pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx ], iRef2Bytes); + ST16 (&pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx4], iRef2Bytes); //cache ST16 (&pRefIndex[iListIdx][iCacheIdx ], iRef2Bytes); ST16 (&pRefIndex[iListIdx][iCacheIdx6], iRef2Bytes); @@ -141,8 +142,10 @@ void UpdateP8x8RefIdxCabac (PDqLayer pCurDqLayer, int8_t pRefIndex[LIST_A][30], const int8_t iListIdx) { int32_t iMbXy = pCurDqLayer->iMbXyIndex; const uint8_t iScan4Idx = g_kuiScan4[iPartIdx]; - pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx] = pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx + 1] = - pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx + 4] = pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx + 5] = iRef; + pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx] = pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx + 1] + = + pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx + 4] = pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx + + 5] = iRef; } void UpdateP8x8DirectCabac (PDqLayer pCurDqLayer, int32_t iPartIdx) { @@ -476,7 +479,7 @@ int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeigh uint32_t uiCode; int32_t iIdxA, iIdxB, iCtxInc; int8_t* pChromaPredMode = pCtx->pCurDqLayer->pChromaPredMode; - uint32_t* pMbType = pCtx->pCurDqLayer->pMbType; + uint32_t* pMbType = pCtx->pCurDqLayer->pDec->pMbType; int32_t iLeftAvail = uiNeighAvail & 0x04; int32_t iTopAvail = uiNeighAvail & 0x01; @@ -532,7 +535,9 @@ int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN pRefCount[0] = pSliceHeader->uiRefCount[0]; pRefCount[1] = pSliceHeader->uiRefCount[1]; - switch (pCurDqLayer->pMbType[iMbXy]) { + bool bIsPending = GetThreadCount (pCtx) > 1; + + switch (pCurDqLayer->pDec->pMbType[iMbXy]) { case MB_TYPE_16x16: { iPartIdx = 0; WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, 0, LIST_0, iPartIdx, pRefCount[0], 0, @@ -547,7 +552,7 @@ int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRef[0]] - && ppRefPic[iRef[0]]->bIsComplete); + && (ppRefPic[iRef[0]]->bIsComplete || bIsPending)); PredMv (pMotionVector, pRefIndex, LIST_0, 0, 4, iRef[0], pMv); WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, pMvd[0])); WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, pMvd[1])); @@ -573,7 +578,7 @@ int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRef[i]] - && ppRefPic[iRef[i]]->bIsComplete); + && (ppRefPic[iRef[i]]->bIsComplete || bIsPending)); UpdateP16x8RefIdxCabac (pCurDqLayer, pRefIndex, iPartIdx, iRef[i], LIST_0); } for (i = 0; i < 2; i++) { @@ -603,7 +608,7 @@ int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRef[i]] - && ppRefPic[iRef[i]]->bIsComplete); + && (ppRefPic[iRef[i]]->bIsComplete || bIsPending)); UpdateP8x16RefIdxCabac (pCurDqLayer, pRefIndex, iPartIdx, iRef[i], LIST_0); } for (i = 0; i < 2; i++) { @@ -651,7 +656,7 @@ int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[pRefIdx[i]] - && ppRefPic[pRefIdx[i]]->bIsComplete); + && (ppRefPic[pRefIdx[i]]->bIsComplete || bIsPending)); UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, pRefIdx[i], LIST_0); } //mv @@ -677,8 +682,8 @@ int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN if (SUB_MB_TYPE_8x8 == uiSubMbType) { ST32 ((pMv + 2), LD32 (pMv)); ST32 ((pMvd + 2), LD32 (pMvd)); - ST64 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx], LD64 (pMv)); - ST64 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx + 4], LD64 (pMv)); + ST64 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx], LD64 (pMv)); + ST64 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx + 4], LD64 (pMv)); ST64 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx], LD64 (pMvd)); ST64 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx + 4], LD64 (pMvd)); ST64 (pMotionVector[0][iCacheIdx ], LD64 (pMv)); @@ -688,13 +693,13 @@ int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } else if (SUB_MB_TYPE_8x4 == uiSubMbType) { ST32 ((pMv + 2), LD32 (pMv)); ST32 ((pMvd + 2), LD32 (pMvd)); - ST64 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx ], LD64 (pMv)); + ST64 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx ], LD64 (pMv)); ST64 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx ], LD64 (pMvd)); ST64 (pMotionVector[0][iCacheIdx ], LD64 (pMv)); ST64 (pMvdCache[0][iCacheIdx ], LD64 (pMvd)); } else if (SUB_MB_TYPE_4x8 == uiSubMbType) { - ST32 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx ], LD32 (pMv)); - ST32 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx + 4], LD32 (pMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx ], LD32 (pMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx + 4], LD32 (pMv)); ST32 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx ], LD32 (pMvd)); ST32 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx + 4], LD32 (pMvd)); ST32 (pMotionVector[0][iCacheIdx ], LD32 (pMv)); @@ -702,7 +707,7 @@ int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN ST32 (pMvdCache[0][iCacheIdx ], LD32 (pMvd)); ST32 (pMvdCache[0][iCacheIdx + 6], LD32 (pMvd)); } else { //SUB_MB_TYPE_4x4 - ST32 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx ], LD32 (pMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx ], LD32 (pMv)); ST32 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx ], LD32 (pMvd)); ST32 (pMotionVector[0][iCacheIdx ], LD32 (pMv)); ST32 (pMvdCache[0][iCacheIdx ], LD32 (pMvd)); @@ -734,7 +739,9 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN pRefCount[0] = pSliceHeader->uiRefCount[0]; pRefCount[1] = pSliceHeader->uiRefCount[1]; - MbType mbType = pCurDqLayer->pMbType[iMbXy]; + MbType mbType = pCurDqLayer->pDec->pMbType[iMbXy]; + + bool bIsPending = GetThreadCount (pCtx) > 1; if (IS_DIRECT (mbType)) { @@ -772,7 +779,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (pCtx->sRefPic.pRefList[listIdx][iRef[listIdx]] - && pCtx->sRefPic.pRefList[listIdx][iRef[listIdx]]->bIsComplete); + && (pCtx->sRefPic.pRefList[listIdx][iRef[listIdx]]->bIsComplete || bIsPending)); } } for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { @@ -809,7 +816,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (pCtx->sRefPic.pRefList[listIdx][ref_idx] - && pCtx->sRefPic.pRefList[listIdx][ref_idx]->bIsComplete); + && (pCtx->sRefPic.pRefList[listIdx][ref_idx]->bIsComplete || bIsPending)); } UpdateP16x8RefIdxCabac (pCurDqLayer, pRefIndex, iPartIdx, ref_idx, listIdx); ref_idx_list[listIdx][i] = ref_idx; @@ -853,7 +860,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (pCtx->sRefPic.pRefList[listIdx][ref_idx] - && pCtx->sRefPic.pRefList[listIdx][ref_idx]->bIsComplete); + && (pCtx->sRefPic.pRefList[listIdx][ref_idx]->bIsComplete || bIsPending)); } UpdateP8x16RefIdxCabac (pCurDqLayer, pRefIndex, iPartIdx, ref_idx, listIdx); ref_idx_list[listIdx][i] = ref_idx; @@ -987,7 +994,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (pCtx->sRefPic.pRefList[listIdx][iref] - && pCtx->sRefPic.pRefList[listIdx][iref]->bIsComplete); + && (pCtx->sRefPic.pRefList[listIdx][iref]->bIsComplete || bIsPending)); } Update8x8RefIdx (pCurDqLayer, iIdx8, listIdx, iref); ref_idx_list[listIdx][i] = iref; @@ -1030,8 +1037,8 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN if (IS_SUB_8x8 (subMbType)) { //MB_TYPE_8x8 ST32 ((pMv + 2), LD32 (pMv)); ST32 ((pMvd + 2), LD32 (pMvd)); - ST64 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx], LD64 (pMv)); - ST64 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx + 4], LD64 (pMv)); + ST64 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx], LD64 (pMv)); + ST64 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx + 4], LD64 (pMv)); ST64 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx], LD64 (pMvd)); ST64 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx + 4], LD64 (pMvd)); ST64 (pMotionVector[listIdx][iCacheIdx], LD64 (pMv)); @@ -1039,13 +1046,13 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN ST64 (pMvdCache[listIdx][iCacheIdx], LD64 (pMvd)); ST64 (pMvdCache[listIdx][iCacheIdx + 6], LD64 (pMvd)); } else if (IS_SUB_4x4 (subMbType)) { //MB_TYPE_4x4 - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx], LD32 (pMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx], LD32 (pMv)); ST32 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx], LD32 (pMvd)); ST32 (pMotionVector[listIdx][iCacheIdx], LD32 (pMv)); ST32 (pMvdCache[listIdx][iCacheIdx], LD32 (pMvd)); } else if (IS_SUB_4x8 (subMbType)) { //MB_TYPE_4x8 5, 7, 9 - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx], LD32 (pMv)); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx + 4], LD32 (pMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx], LD32 (pMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx + 4], LD32 (pMv)); ST32 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx], LD32 (pMvd)); ST32 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx + 4], LD32 (pMvd)); ST32 (pMotionVector[listIdx][iCacheIdx], LD32 (pMv)); @@ -1055,7 +1062,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN } else { //MB_TYPE_8x4 4, 6, 8 ST32 ((pMv + 2), LD32 (pMv)); ST32 ((pMvd + 2), LD32 (pMvd)); - ST64 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx], LD64 (pMv)); + ST64 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx], LD64 (pMv)); ST64 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx], LD64 (pMvd)); ST64 (pMotionVector[listIdx][iCacheIdx], LD64 (pMv)); ST64 (pMvdCache[listIdx][iCacheIdx], LD64 (pMvd)); @@ -1077,7 +1084,7 @@ int32_t ParseRefIdxCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t uiCode; int32_t iIdxA = 0, iIdxB = 0; int32_t iCtxInc = 0; - int8_t* pRefIdxInMB = pCtx->pCurDqLayer->pRefIndex[iListIdx][pCtx->pCurDqLayer->iMbXyIndex]; + int8_t* pRefIdxInMB = pCtx->pCurDqLayer->pDec->pRefIndex[iListIdx][pCtx->pCurDqLayer->iMbXyIndex]; int8_t* pDirect = pCtx->pCurDqLayer->pDirect[pCtx->pCurDqLayer->iMbXyIndex]; if (iZOrderIdx == 0) { iIdxB = (pNeighAvail->iTopAvail && pNeighAvail->iTopType != MB_TYPE_INTRA_PCM @@ -1270,7 +1277,7 @@ int32_t ParseCbfInfoCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNzcCache, int3 int32_t iTopBlkXy = iCurrBlkXy - pCtx->pCurDqLayer->iMbWidth; //default value: MB neighboring int32_t iLeftBlkXy = iCurrBlkXy - 1; //default value: MB neighboring uint16_t* pCbfDc = pCtx->pCurDqLayer->pCbfDc; - uint32_t* pMbType = pCtx->pCurDqLayer->pMbType; + uint32_t* pMbType = pCtx->pCurDqLayer->pDec->pMbType; int32_t iCtxInc; uiCbfBit = 0; nA = nB = (int8_t)!!IS_INTRA (pMbType[iCurrBlkXy]); @@ -1493,12 +1500,12 @@ int32_t ParseIPCMInfoCabac (PWelsDecoderContext pCtx) { int32_t i; PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine; SBitStringAux* pBsAux = pCtx->pCurDqLayer->pBitStringAux; - SDqLayer* pCurLayer = pCtx->pCurDqLayer; - int32_t iDstStrideLuma = pCurLayer->pDec->iLinesize[0]; - int32_t iDstStrideChroma = pCurLayer->pDec->iLinesize[1]; - int32_t iMbX = pCurLayer->iMbX; - int32_t iMbY = pCurLayer->iMbY; - int32_t iMbXy = pCurLayer->iMbXyIndex; + SDqLayer* pCurDqLayer = pCtx->pCurDqLayer; + int32_t iDstStrideLuma = pCurDqLayer->pDec->iLinesize[0]; + int32_t iDstStrideChroma = pCurDqLayer->pDec->iLinesize[1]; + int32_t iMbX = pCurDqLayer->iMbX; + int32_t iMbY = pCurDqLayer->iMbY; + int32_t iMbXy = pCurDqLayer->iMbXyIndex; int32_t iMbOffsetLuma = (iMbX + iMbY * iDstStrideLuma) << 4; int32_t iMbOffsetChroma = (iMbX + iMbY * iDstStrideChroma) << 3; @@ -1509,7 +1516,7 @@ int32_t ParseIPCMInfoCabac (PWelsDecoderContext pCtx) { uint8_t* pPtrSrc; - pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA_PCM; + pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA_PCM; RestoreCabacDecEngineToBS (pCabacDecEngine, pBsAux); intX_t iBytesLeft = pBsAux->pEndBuf - pBsAux->pCurBuf; if (iBytesLeft < 384) { @@ -1536,9 +1543,9 @@ int32_t ParseIPCMInfoCabac (PWelsDecoderContext pCtx) { pBsAux->pCurBuf += 384; - pCurLayer->pLumaQp[iMbXy] = 0; - pCurLayer->pChromaQp[iMbXy][0] = pCurLayer->pChromaQp[iMbXy][1] = 0; - memset (pCurLayer->pNzc[iMbXy], 16, sizeof (pCurLayer->pNzc[iMbXy])); + pCurDqLayer->pLumaQp[iMbXy] = 0; + pCurDqLayer->pChromaQp[iMbXy][0] = pCurDqLayer->pChromaQp[iMbXy][1] = 0; + memset (pCurDqLayer->pNzc[iMbXy], 16, sizeof (pCurDqLayer->pNzc[iMbXy])); //step 4: cabac engine init WELS_READ_VERIFY (InitReadBits (pBsAux, 1)); diff --git a/src/openh264/codec/decoder/core/src/parse_mb_syn_cavlc.cpp b/src/openh264/codec/decoder/core/src/parse_mb_syn_cavlc.cpp old mode 100755 new mode 100644 index 83f8f6573..ba3a46d58 --- a/src/openh264/codec/decoder/core/src/parse_mb_syn_cavlc.cpp +++ b/src/openh264/codec/decoder/core/src/parse_mb_syn_cavlc.cpp @@ -53,20 +53,20 @@ typedef struct TagReadBitsCache { uint8_t* pBuf; } SReadBitsCache; -void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer) { +void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurDqLayer) { int32_t iCurSliceIdc, iTopSliceIdc, iLeftTopSliceIdc, iRightTopSliceIdc, iLeftSliceIdc; int32_t iCurXy, iTopXy = 0, iLeftXy = 0, iLeftTopXy = 0, iRightTopXy = 0; int32_t iCurX, iCurY; - iCurXy = pCurLayer->iMbXyIndex; - iCurX = pCurLayer->iMbX; - iCurY = pCurLayer->iMbY; - iCurSliceIdc = pCurLayer->pSliceIdc[iCurXy]; + iCurXy = pCurDqLayer->iMbXyIndex; + iCurX = pCurDqLayer->iMbX; + iCurY = pCurDqLayer->iMbY; + iCurSliceIdc = pCurDqLayer->pSliceIdc[iCurXy]; if (iCurX != 0) { iLeftXy = iCurXy - 1; - iLeftSliceIdc = pCurLayer->pSliceIdc[iLeftXy]; + iLeftSliceIdc = pCurDqLayer->pSliceIdc[iLeftXy]; pNeighAvail->iLeftAvail = (iLeftSliceIdc == iCurSliceIdc); - pNeighAvail->iLeftCbp = pNeighAvail->iLeftAvail ? pCurLayer->pCbp[iLeftXy] : 0; + pNeighAvail->iLeftCbp = pNeighAvail->iLeftAvail ? pCurDqLayer->pCbp[iLeftXy] : 0; } else { pNeighAvail->iLeftAvail = 0; pNeighAvail->iLeftTopAvail = 0; @@ -74,20 +74,20 @@ void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer) { } if (iCurY != 0) { - iTopXy = iCurXy - pCurLayer->iMbWidth; - iTopSliceIdc = pCurLayer->pSliceIdc[iTopXy]; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; + iTopSliceIdc = pCurDqLayer->pSliceIdc[iTopXy]; pNeighAvail->iTopAvail = (iTopSliceIdc == iCurSliceIdc); - pNeighAvail->iTopCbp = pNeighAvail->iTopAvail ? pCurLayer->pCbp[iTopXy] : 0; + pNeighAvail->iTopCbp = pNeighAvail->iTopAvail ? pCurDqLayer->pCbp[iTopXy] : 0; if (iCurX != 0) { iLeftTopXy = iTopXy - 1; - iLeftTopSliceIdc = pCurLayer->pSliceIdc[iLeftTopXy]; + iLeftTopSliceIdc = pCurDqLayer->pSliceIdc[iLeftTopXy]; pNeighAvail->iLeftTopAvail = (iLeftTopSliceIdc == iCurSliceIdc); } else { pNeighAvail->iLeftTopAvail = 0; } - if (iCurX != (pCurLayer->iMbWidth - 1)) { + if (iCurX != (pCurDqLayer->iMbWidth - 1)) { iRightTopXy = iTopXy + 1; - iRightTopSliceIdc = pCurLayer->pSliceIdc[iRightTopXy]; + iRightTopSliceIdc = pCurDqLayer->pSliceIdc[iRightTopXy]; pNeighAvail->iRightTopAvail = (iRightTopSliceIdc == iCurSliceIdc); } else { pNeighAvail->iRightTopAvail = 0; @@ -99,18 +99,18 @@ void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer) { pNeighAvail->iTopCbp = 0; } - pNeighAvail->iLeftType = (pNeighAvail->iLeftAvail ? pCurLayer->pMbType[iLeftXy] : 0); - pNeighAvail->iTopType = (pNeighAvail->iTopAvail ? pCurLayer->pMbType[iTopXy] : 0); - pNeighAvail->iLeftTopType = (pNeighAvail->iLeftTopAvail ? pCurLayer->pMbType[iLeftTopXy] : 0); - pNeighAvail->iRightTopType = (pNeighAvail->iRightTopAvail ? pCurLayer->pMbType[iRightTopXy] : 0); + pNeighAvail->iLeftType = (pNeighAvail->iLeftAvail ? pCurDqLayer->pDec->pMbType[iLeftXy] : 0); + pNeighAvail->iTopType = (pNeighAvail->iTopAvail ? pCurDqLayer->pDec->pMbType[iTopXy] : 0); + pNeighAvail->iLeftTopType = (pNeighAvail->iLeftTopAvail ? pCurDqLayer->pDec->pMbType[iLeftTopXy] : 0); + pNeighAvail->iRightTopType = (pNeighAvail->iRightTopAvail ? pCurDqLayer->pDec->pMbType[iRightTopXy] : 0); } void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, - PDqLayer pCurLayer) { //no matter slice type, intra_pred_constrained_flag - int32_t iCurXy = pCurLayer->iMbXyIndex; + PDqLayer pCurDqLayer) { //no matter slice type, intra_pred_constrained_flag + int32_t iCurXy = pCurDqLayer->iMbXyIndex; int32_t iTopXy = 0; int32_t iLeftXy = 0; if (pNeighAvail->iTopAvail) { - iTopXy = iCurXy - pCurLayer->iMbWidth; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; } if (pNeighAvail->iLeftAvail) { iLeftXy = iCurXy - 1; @@ -118,10 +118,10 @@ void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCo //stuff non_zero_coeff_count from pNeighAvail(left and top) if (pNeighAvail->iTopAvail) { - ST32 (&pNonZeroCount[1], LD32 (&pCurLayer->pNzc[iTopXy][12])); + ST32 (&pNonZeroCount[1], LD32 (&pCurDqLayer->pNzc[iTopXy][12])); pNonZeroCount[0] = pNonZeroCount[5] = pNonZeroCount[29] = 0; - ST16 (&pNonZeroCount[6], LD16 (&pCurLayer->pNzc[iTopXy][20])); - ST16 (&pNonZeroCount[30], LD16 (&pCurLayer->pNzc[iTopXy][22])); + ST16 (&pNonZeroCount[6], LD16 (&pCurDqLayer->pNzc[iTopXy][20])); + ST16 (&pNonZeroCount[30], LD16 (&pCurDqLayer->pNzc[iTopXy][22])); } else { ST32 (&pNonZeroCount[1], 0xFFFFFFFFU); pNonZeroCount[0] = pNonZeroCount[5] = pNonZeroCount[29] = 0xFF; @@ -130,15 +130,15 @@ void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCo } if (pNeighAvail->iLeftAvail) { - pNonZeroCount[8 * 1] = pCurLayer->pNzc[iLeftXy][3]; - pNonZeroCount[8 * 2] = pCurLayer->pNzc[iLeftXy][7]; - pNonZeroCount[8 * 3] = pCurLayer->pNzc[iLeftXy][11]; - pNonZeroCount[8 * 4] = pCurLayer->pNzc[iLeftXy][15]; + pNonZeroCount[8 * 1] = pCurDqLayer->pNzc[iLeftXy][3]; + pNonZeroCount[8 * 2] = pCurDqLayer->pNzc[iLeftXy][7]; + pNonZeroCount[8 * 3] = pCurDqLayer->pNzc[iLeftXy][11]; + pNonZeroCount[8 * 4] = pCurDqLayer->pNzc[iLeftXy][15]; - pNonZeroCount[5 + 8 * 1] = pCurLayer->pNzc[iLeftXy][17]; - pNonZeroCount[5 + 8 * 2] = pCurLayer->pNzc[iLeftXy][21]; - pNonZeroCount[5 + 8 * 4] = pCurLayer->pNzc[iLeftXy][19]; - pNonZeroCount[5 + 8 * 5] = pCurLayer->pNzc[iLeftXy][23]; + pNonZeroCount[5 + 8 * 1] = pCurDqLayer->pNzc[iLeftXy][17]; + pNonZeroCount[5 + 8 * 2] = pCurDqLayer->pNzc[iLeftXy][21]; + pNonZeroCount[5 + 8 * 4] = pCurDqLayer->pNzc[iLeftXy][19]; + pNonZeroCount[5 + 8 * 5] = pCurDqLayer->pNzc[iLeftXy][23]; } else { pNonZeroCount[8 * 1] = pNonZeroCount[8 * 2] = @@ -153,16 +153,16 @@ void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCo } } void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, - PDqLayer pCurLayer) { //no matter slice type - int32_t iCurXy = pCurLayer->iMbXyIndex; + PDqLayer pCurDqLayer) { //no matter slice type + int32_t iCurXy = pCurDqLayer->iMbXyIndex; int32_t iTopXy = 0; int32_t iLeftXy = 0; //stuff non_zero_coeff_count from pNeighAvail(left and top) - WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer); + WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer); if (pNeighAvail->iTopAvail) { - iTopXy = iCurXy - pCurLayer->iMbWidth; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; } if (pNeighAvail->iLeftAvail) { iLeftXy = iCurXy - 1; @@ -170,7 +170,7 @@ void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNon //intraNxN_pred_mode if (pNeighAvail->iTopAvail && IS_INTRANxN (pNeighAvail->iTopType)) { //top - ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0])); + ST32 (pIntraPredMode + 1, LD32 (&pCurDqLayer->pIntraPredMode[iTopXy][0])); } else { int32_t iPred; if (IS_INTRA16x16 (pNeighAvail->iTopType) || (MB_TYPE_INTRA_PCM == pNeighAvail->iTopType)) @@ -181,10 +181,10 @@ void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNon } if (pNeighAvail->iLeftAvail && IS_INTRANxN (pNeighAvail->iLeftType)) { //left - pIntraPredMode[ 0 + 8 ] = pCurLayer->pIntraPredMode[iLeftXy][4]; - pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5]; - pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6]; - pIntraPredMode[ 0 + 8 * 4] = pCurLayer->pIntraPredMode[iLeftXy][3]; + pIntraPredMode[ 0 + 8 ] = pCurDqLayer->pIntraPredMode[iLeftXy][4]; + pIntraPredMode[ 0 + 8 * 2] = pCurDqLayer->pIntraPredMode[iLeftXy][5]; + pIntraPredMode[ 0 + 8 * 3] = pCurDqLayer->pIntraPredMode[iLeftXy][6]; + pIntraPredMode[ 0 + 8 * 4] = pCurDqLayer->pIntraPredMode[iLeftXy][3]; } else { int8_t iPred; if (IS_INTRA16x16 (pNeighAvail->iLeftType) || (MB_TYPE_INTRA_PCM == pNeighAvail->iLeftType)) @@ -199,16 +199,16 @@ void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNon } void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, - PDqLayer pCurLayer) { //no matter slice type - int32_t iCurXy = pCurLayer->iMbXyIndex; + PDqLayer pCurDqLayer) { //no matter slice type + int32_t iCurXy = pCurDqLayer->iMbXyIndex; int32_t iTopXy = 0; int32_t iLeftXy = 0; //stuff non_zero_coeff_count from pNeighAvail(left and top) - WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer); + WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer); if (pNeighAvail->iTopAvail) { - iTopXy = iCurXy - pCurLayer->iMbWidth; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; } if (pNeighAvail->iLeftAvail) { iLeftXy = iCurXy - 1; @@ -216,7 +216,7 @@ void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNon //intra4x4_pred_mode if (pNeighAvail->iTopAvail && IS_INTRANxN (pNeighAvail->iTopType)) { //top - ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0])); + ST32 (pIntraPredMode + 1, LD32 (&pCurDqLayer->pIntraPredMode[iTopXy][0])); } else { int32_t iPred; if (pNeighAvail->iTopAvail) @@ -227,10 +227,10 @@ void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNon } if (pNeighAvail->iLeftAvail && IS_INTRANxN (pNeighAvail->iLeftType)) { //left - pIntraPredMode[ 0 + 8 * 1] = pCurLayer->pIntraPredMode[iLeftXy][4]; - pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5]; - pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6]; - pIntraPredMode[ 0 + 8 * 4] = pCurLayer->pIntraPredMode[iLeftXy][3]; + pIntraPredMode[ 0 + 8 * 1] = pCurDqLayer->pIntraPredMode[iLeftXy][4]; + pIntraPredMode[ 0 + 8 * 2] = pCurDqLayer->pIntraPredMode[iLeftXy][5]; + pIntraPredMode[ 0 + 8 * 3] = pCurDqLayer->pIntraPredMode[iLeftXy][6]; + pIntraPredMode[ 0 + 8 * 4] = pCurDqLayer->pIntraPredMode[iLeftXy][3]; } else { int8_t iPred; if (pNeighAvail->iLeftAvail) @@ -245,52 +245,52 @@ void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNon } void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int16_t iMvArray[LIST_A][30][MV_A], - int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer) { - int32_t iCurXy = pCurLayer->iMbXyIndex; + int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurDqLayer) { + int32_t iCurXy = pCurDqLayer->iMbXyIndex; int32_t iTopXy = 0; int32_t iLeftXy = 0; int32_t iLeftTopXy = 0; int32_t iRightTopXy = 0; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int32_t listCount = 1; if (pSliceHeader->eSliceType == B_SLICE) { listCount = 2; } //stuff non_zero_coeff_count from pNeighAvail(left and top) - WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer); + WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer); if (pNeighAvail->iTopAvail) { - iTopXy = iCurXy - pCurLayer->iMbWidth; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; } if (pNeighAvail->iLeftAvail) { iLeftXy = iCurXy - 1; } if (pNeighAvail->iLeftTopAvail) { - iLeftTopXy = iCurXy - 1 - pCurLayer->iMbWidth; + iLeftTopXy = iCurXy - 1 - pCurDqLayer->iMbWidth; } if (pNeighAvail->iRightTopAvail) { - iRightTopXy = iCurXy + 1 - pCurLayer->iMbWidth; + iRightTopXy = iCurXy + 1 - pCurDqLayer->iMbWidth; } for (int32_t listIdx = 0; listIdx < listCount; ++listIdx) { //stuff mv_cache and iRefIdxArray from left and top (inter) if (pNeighAvail->iLeftAvail && IS_INTER (pNeighAvail->iLeftType)) { - ST32 (iMvArray[listIdx][6], LD32 (pCurLayer->pMv[listIdx][iLeftXy][3])); - ST32 (iMvArray[listIdx][12], LD32 (pCurLayer->pMv[listIdx][iLeftXy][7])); - ST32 (iMvArray[listIdx][18], LD32 (pCurLayer->pMv[listIdx][iLeftXy][11])); - ST32 (iMvArray[listIdx][24], LD32 (pCurLayer->pMv[listIdx][iLeftXy][15])); + ST32 (iMvArray[listIdx][6], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][3])); + ST32 (iMvArray[listIdx][12], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][7])); + ST32 (iMvArray[listIdx][18], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][11])); + ST32 (iMvArray[listIdx][24], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][15])); - ST32 (iMvdCache[listIdx][6], LD32 (pCurLayer->pMvd[listIdx][iLeftXy][3])); - ST32 (iMvdCache[listIdx][12], LD32 (pCurLayer->pMvd[listIdx][iLeftXy][7])); - ST32 (iMvdCache[listIdx][18], LD32 (pCurLayer->pMvd[listIdx][iLeftXy][11])); - ST32 (iMvdCache[listIdx][24], LD32 (pCurLayer->pMvd[listIdx][iLeftXy][15])); + ST32 (iMvdCache[listIdx][6], LD32 (pCurDqLayer->pMvd[listIdx][iLeftXy][3])); + ST32 (iMvdCache[listIdx][12], LD32 (pCurDqLayer->pMvd[listIdx][iLeftXy][7])); + ST32 (iMvdCache[listIdx][18], LD32 (pCurDqLayer->pMvd[listIdx][iLeftXy][11])); + ST32 (iMvdCache[listIdx][24], LD32 (pCurDqLayer->pMvd[listIdx][iLeftXy][15])); - iRefIdxArray[listIdx][6] = pCurLayer->pRefIndex[listIdx][iLeftXy][3]; - iRefIdxArray[listIdx][12] = pCurLayer->pRefIndex[listIdx][iLeftXy][7]; - iRefIdxArray[listIdx][18] = pCurLayer->pRefIndex[listIdx][iLeftXy][11]; - iRefIdxArray[listIdx][24] = pCurLayer->pRefIndex[listIdx][iLeftXy][15]; + iRefIdxArray[listIdx][6] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][3]; + iRefIdxArray[listIdx][12] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][7]; + iRefIdxArray[listIdx][18] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][11]; + iRefIdxArray[listIdx][24] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][15]; } else { ST32 (iMvArray[listIdx][6], 0); ST32 (iMvArray[listIdx][12], 0); @@ -316,9 +316,9 @@ void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCoun } } if (pNeighAvail->iLeftTopAvail && IS_INTER (pNeighAvail->iLeftTopType)) { - ST32 (iMvArray[listIdx][0], LD32 (pCurLayer->pMv[listIdx][iLeftTopXy][15])); - ST32 (iMvdCache[listIdx][0], LD32 (pCurLayer->pMvd[listIdx][iLeftTopXy][15])); - iRefIdxArray[listIdx][0] = pCurLayer->pRefIndex[listIdx][iLeftTopXy][15]; + ST32 (iMvArray[listIdx][0], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftTopXy][15])); + ST32 (iMvdCache[listIdx][0], LD32 (pCurDqLayer->pMvd[listIdx][iLeftTopXy][15])); + iRefIdxArray[listIdx][0] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftTopXy][15]; } else { ST32 (iMvArray[listIdx][0], 0); ST32 (iMvdCache[listIdx][0], 0); @@ -330,11 +330,11 @@ void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCoun } if (pNeighAvail->iTopAvail && IS_INTER (pNeighAvail->iTopType)) { - ST64 (iMvArray[listIdx][1], LD64 (pCurLayer->pMv[listIdx][iTopXy][12])); - ST64 (iMvArray[listIdx][3], LD64 (pCurLayer->pMv[listIdx][iTopXy][14])); - ST64 (iMvdCache[listIdx][1], LD64 (pCurLayer->pMvd[listIdx][iTopXy][12])); - ST64 (iMvdCache[listIdx][3], LD64 (pCurLayer->pMvd[listIdx][iTopXy][14])); - ST32 (&iRefIdxArray[listIdx][1], LD32 (&pCurLayer->pRefIndex[listIdx][iTopXy][12])); + ST64 (iMvArray[listIdx][1], LD64 (pCurDqLayer->pDec->pMv[listIdx][iTopXy][12])); + ST64 (iMvArray[listIdx][3], LD64 (pCurDqLayer->pDec->pMv[listIdx][iTopXy][14])); + ST64 (iMvdCache[listIdx][1], LD64 (pCurDqLayer->pMvd[listIdx][iTopXy][12])); + ST64 (iMvdCache[listIdx][3], LD64 (pCurDqLayer->pMvd[listIdx][iTopXy][14])); + ST32 (&iRefIdxArray[listIdx][1], LD32 (&pCurDqLayer->pDec->pRefIndex[listIdx][iTopXy][12])); } else { ST64 (iMvArray[listIdx][1], 0); ST64 (iMvArray[listIdx][3], 0); @@ -354,9 +354,9 @@ void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCoun } if (pNeighAvail->iRightTopAvail && IS_INTER (pNeighAvail->iRightTopType)) { - ST32 (iMvArray[listIdx][5], LD32 (pCurLayer->pMv[listIdx][iRightTopXy][12])); - ST32 (iMvdCache[listIdx][5], LD32 (pCurLayer->pMvd[listIdx][iRightTopXy][12])); - iRefIdxArray[listIdx][5] = pCurLayer->pRefIndex[listIdx][iRightTopXy][12]; + ST32 (iMvArray[listIdx][5], LD32 (pCurDqLayer->pDec->pMv[listIdx][iRightTopXy][12])); + ST32 (iMvdCache[listIdx][5], LD32 (pCurDqLayer->pMvd[listIdx][iRightTopXy][12])); + iRefIdxArray[listIdx][5] = pCurDqLayer->pDec->pRefIndex[listIdx][iRightTopXy][12]; } else { ST32 (iMvArray[listIdx][5], 0); if (0 == pNeighAvail->iRightTopAvail) { //not available @@ -385,56 +385,56 @@ void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCoun } } -void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurLayer) { +void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurDqLayer) { - int32_t iCurXy = pCurLayer->iMbXyIndex; + int32_t iCurXy = pCurDqLayer->iMbXyIndex; int32_t iTopXy = 0; int32_t iLeftXy = 0; int32_t iLeftTopXy = 0; int32_t iRightTopXy = 0; if (pNeighAvail->iTopAvail) { - iTopXy = iCurXy - pCurLayer->iMbWidth; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; } if (pNeighAvail->iLeftAvail) { iLeftXy = iCurXy - 1; } if (pNeighAvail->iLeftTopAvail) { - iLeftTopXy = iCurXy - 1 - pCurLayer->iMbWidth; + iLeftTopXy = iCurXy - 1 - pCurDqLayer->iMbWidth; } if (pNeighAvail->iRightTopAvail) { - iRightTopXy = iCurXy + 1 - pCurLayer->iMbWidth; + iRightTopXy = iCurXy + 1 - pCurDqLayer->iMbWidth; } memset (iDirect, 0, 30); if (pNeighAvail->iLeftAvail && IS_INTER (pNeighAvail->iLeftType)) { - iDirect[6] = pCurLayer->pDirect[iLeftXy][3]; - iDirect[12] = pCurLayer->pDirect[iLeftXy][7]; - iDirect[18] = pCurLayer->pDirect[iLeftXy][11]; - iDirect[24] = pCurLayer->pDirect[iLeftXy][15]; + iDirect[6] = pCurDqLayer->pDirect[iLeftXy][3]; + iDirect[12] = pCurDqLayer->pDirect[iLeftXy][7]; + iDirect[18] = pCurDqLayer->pDirect[iLeftXy][11]; + iDirect[24] = pCurDqLayer->pDirect[iLeftXy][15]; } if (pNeighAvail->iLeftTopAvail && IS_INTER (pNeighAvail->iLeftTopType)) { - iDirect[0] = pCurLayer->pDirect[iLeftTopXy][15]; + iDirect[0] = pCurDqLayer->pDirect[iLeftTopXy][15]; } if (pNeighAvail->iTopAvail && IS_INTER (pNeighAvail->iTopType)) { - ST32 (&iDirect[1], LD32 (&pCurLayer->pDirect[iTopXy][12])); + ST32 (&iDirect[1], LD32 (&pCurDqLayer->pDirect[iTopXy][12])); } if (pNeighAvail->iRightTopAvail && IS_INTER (pNeighAvail->iRightTopType)) { - iDirect[5] = pCurLayer->pDirect[iRightTopXy][12]; + iDirect[5] = pCurDqLayer->pDirect[iRightTopXy][12]; } //right-top 4*4 block unavailable } void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, - int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer) { - int32_t iCurXy = pCurLayer->iMbXyIndex; + int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurDqLayer) { + int32_t iCurXy = pCurDqLayer->iMbXyIndex; int32_t iTopXy = 0; int32_t iLeftXy = 0; int32_t iLeftTopXy = 0; int32_t iRightTopXy = 0; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int32_t listCount = 1; if (pSliceHeader->eSliceType == B_SLICE) { @@ -442,32 +442,32 @@ void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, } //stuff non_zero_coeff_count from pNeighAvail(left and top) - WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer); + WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer); if (pNeighAvail->iTopAvail) { - iTopXy = iCurXy - pCurLayer->iMbWidth; + iTopXy = iCurXy - pCurDqLayer->iMbWidth; } if (pNeighAvail->iLeftAvail) { iLeftXy = iCurXy - 1; } if (pNeighAvail->iLeftTopAvail) { - iLeftTopXy = iCurXy - 1 - pCurLayer->iMbWidth; + iLeftTopXy = iCurXy - 1 - pCurDqLayer->iMbWidth; } if (pNeighAvail->iRightTopAvail) { - iRightTopXy = iCurXy + 1 - pCurLayer->iMbWidth; + iRightTopXy = iCurXy + 1 - pCurDqLayer->iMbWidth; } for (int32_t listIdx = 0; listIdx < listCount; ++listIdx) { //stuff mv_cache and iRefIdxArray from left and top (inter) if (pNeighAvail->iLeftAvail && IS_INTER (pNeighAvail->iLeftType)) { - ST32 (iMvArray[listIdx][6], LD32 (pCurLayer->pMv[listIdx][iLeftXy][3])); - ST32 (iMvArray[listIdx][12], LD32 (pCurLayer->pMv[listIdx][iLeftXy][7])); - ST32 (iMvArray[listIdx][18], LD32 (pCurLayer->pMv[listIdx][iLeftXy][11])); - ST32 (iMvArray[listIdx][24], LD32 (pCurLayer->pMv[listIdx][iLeftXy][15])); - iRefIdxArray[listIdx][6] = pCurLayer->pRefIndex[listIdx][iLeftXy][3]; - iRefIdxArray[listIdx][12] = pCurLayer->pRefIndex[listIdx][iLeftXy][7]; - iRefIdxArray[listIdx][18] = pCurLayer->pRefIndex[listIdx][iLeftXy][11]; - iRefIdxArray[listIdx][24] = pCurLayer->pRefIndex[listIdx][iLeftXy][15]; + ST32 (iMvArray[listIdx][6], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][3])); + ST32 (iMvArray[listIdx][12], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][7])); + ST32 (iMvArray[listIdx][18], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][11])); + ST32 (iMvArray[listIdx][24], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][15])); + iRefIdxArray[listIdx][6] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][3]; + iRefIdxArray[listIdx][12] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][7]; + iRefIdxArray[listIdx][18] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][11]; + iRefIdxArray[listIdx][24] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][15]; } else { ST32 (iMvArray[listIdx][6], 0); ST32 (iMvArray[listIdx][12], 0); @@ -487,8 +487,8 @@ void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, } } if (pNeighAvail->iLeftTopAvail && IS_INTER (pNeighAvail->iLeftTopType)) { - ST32 (iMvArray[listIdx][0], LD32 (pCurLayer->pMv[listIdx][iLeftTopXy][15])); - iRefIdxArray[listIdx][0] = pCurLayer->pRefIndex[listIdx][iLeftTopXy][15]; + ST32 (iMvArray[listIdx][0], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftTopXy][15])); + iRefIdxArray[listIdx][0] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftTopXy][15]; } else { ST32 (iMvArray[listIdx][0], 0); if (0 == pNeighAvail->iLeftTopAvail) { //not available @@ -498,9 +498,9 @@ void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, } } if (pNeighAvail->iTopAvail && IS_INTER (pNeighAvail->iTopType)) { - ST64 (iMvArray[listIdx][1], LD64 (pCurLayer->pMv[listIdx][iTopXy][12])); - ST64 (iMvArray[listIdx][3], LD64 (pCurLayer->pMv[listIdx][iTopXy][14])); - ST32 (&iRefIdxArray[listIdx][1], LD32 (&pCurLayer->pRefIndex[listIdx][iTopXy][12])); + ST64 (iMvArray[listIdx][1], LD64 (pCurDqLayer->pDec->pMv[listIdx][iTopXy][12])); + ST64 (iMvArray[listIdx][3], LD64 (pCurDqLayer->pDec->pMv[listIdx][iTopXy][14])); + ST32 (&iRefIdxArray[listIdx][1], LD32 (&pCurDqLayer->pDec->pRefIndex[listIdx][iTopXy][12])); } else { ST64 (iMvArray[listIdx][1], 0); ST64 (iMvArray[listIdx][3], 0); @@ -517,8 +517,8 @@ void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, } } if (pNeighAvail->iRightTopAvail && IS_INTER (pNeighAvail->iRightTopType)) { - ST32 (iMvArray[listIdx][5], LD32 (pCurLayer->pMv[listIdx][iRightTopXy][12])); - iRefIdxArray[listIdx][5] = pCurLayer->pRefIndex[listIdx][iRightTopXy][12]; + ST32 (iMvArray[listIdx][5], LD32 (pCurDqLayer->pDec->pMv[listIdx][iRightTopXy][12])); + iRefIdxArray[listIdx][5] = pCurDqLayer->pDec->pRefIndex[listIdx][iRightTopXy][12]; } else { ST32 (iMvArray[listIdx][5], 0); if (0 == pNeighAvail->iRightTopAvail) { //not available @@ -1083,7 +1083,9 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M iRefCount[0] = pSliceHeader->uiRefCount[0]; iRefCount[1] = pSliceHeader->uiRefCount[1]; - switch (pCurDqLayer->pMbType[iMbXy]) { + bool bIsPending = GetThreadCount (pCtx) > 1; + + switch (pCurDqLayer->pDec->pMbType[iMbXy]) { case MB_TYPE_16x16: { int32_t iRefIdx = 0; if (pSlice->sSliceHeaderExt.bAdaptiveMotionPredFlag) { @@ -1105,7 +1107,7 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx] - && ppRefPic[iRefIdx]->bIsComplete); + && (ppRefPic[iRefIdx]->bIsComplete || bIsPending)); } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -1146,7 +1148,7 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]] - && ppRefPic[iRefIdx[i]]->bIsComplete); + && (ppRefPic[iRefIdx[i]]->bIsComplete || bIsPending)); } for (i = 0; i < 2; i++) { PredInter16x8Mv (iMvArray, iRefIdxArray, LIST_0, i << 3, iRefIdx[i], iMv); @@ -1183,7 +1185,7 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]] - && ppRefPic[iRefIdx[i]]->bIsComplete); + && (ppRefPic[iRefIdx[i]]->bIsComplete || bIsPending)); } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -1207,7 +1209,7 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M int32_t iRefIdx[4] = {0}, iSubPartCount[4], iPartWidth[4]; uint32_t uiSubMbType; - if (MB_TYPE_8x8_REF0 == pCurDqLayer->pMbType[iMbXy]) { + if (MB_TYPE_8x8_REF0 == pCurDqLayer->pDec->pMbType[iMbXy]) { iRefCount[0] = iRefCount[1] = 1; } @@ -1235,8 +1237,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M } //iRefIdxArray - if (MB_TYPE_8x8_REF0 == pCurDqLayer->pMbType[iMbXy]) { - memset (pCurDqLayer->pRefIndex[0][iMbXy], 0, 16); + if (MB_TYPE_8x8_REF0 == pCurDqLayer->pDec->pMbType[iMbXy]) { + memset (pCurDqLayer->pDec->pRefIndex[0][iMbXy], 0, 16); } else { for (i = 0; i < 4; i++) { int16_t iIndex8 = i << 2; @@ -1255,10 +1257,11 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]] - && ppRefPic[iRefIdx[i]]->bIsComplete); + && (ppRefPic[iRefIdx[i]]->bIsComplete || bIsPending)); - pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 1] = - pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 5] = iRefIdx[i]; + pCurDqLayer->pDec->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pDec->pRefIndex[0][iMbXy][uiScan4Idx + 1] = + pCurDqLayer->pDec->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pDec->pRefIndex[0][iMbXy][uiScan4Idx + 5] = + iRefIdx[i]; } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -1290,26 +1293,26 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M iMv[1] += iCode; WELS_CHECK_SE_BOTH_WARNING (iMv[1], iMinVmv, iMaxVmv, "vertical mv"); if (SUB_MB_TYPE_8x8 == uiSubMbType) { - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 1], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 4], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 5], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 1], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 4], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 5], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx ], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx + 1], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx + 6], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx + 7], LD32 (iMv)); } else if (SUB_MB_TYPE_8x4 == uiSubMbType) { - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 1], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 1], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx ], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx + 1], LD32 (iMv)); } else if (SUB_MB_TYPE_4x8 == uiSubMbType) { - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 4], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 4], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx ], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx + 6], LD32 (iMv)); } else { //SUB_MB_TYPE_4x4 == uiSubMbType - ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv)); ST32 (iMvArray[0][uiCacheIdx ], LD32 (iMv)); } } @@ -1345,7 +1348,9 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ iRefCount[0] = pSliceHeader->uiRefCount[0]; iRefCount[1] = pSliceHeader->uiRefCount[1]; - MbType mbType = pCurDqLayer->pMbType[iMbXy]; + bool bIsPending = GetThreadCount (pCtx) > 1; + + MbType mbType = pCurDqLayer->pDec->pMbType[iMbXy]; if (IS_DIRECT (mbType)) { int16_t pMvDirect[LIST_A][2] = { { 0, 0 }, { 0, 0 } }; @@ -1390,7 +1395,7 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[listIdx][ref_idx_list[listIdx][0]] - && ppRefPic[listIdx][ref_idx_list[listIdx][0]]->bIsComplete); + && (ppRefPic[listIdx][ref_idx_list[listIdx][0]]->bIsComplete || bIsPending)); } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -1440,7 +1445,7 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ } ref_idx_list[listIdx][i] = iRefIdx; pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[listIdx][iRefIdx] - && ppRefPic[listIdx][iRefIdx]->bIsComplete); + && (ppRefPic[listIdx][iRefIdx]->bIsComplete || bIsPending)); } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -1499,7 +1504,7 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ } ref_idx_list[listIdx][i] = iRefIdx; pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[listIdx][iRefIdx] - && ppRefPic[listIdx][iRefIdx]->bIsComplete); + && (ppRefPic[listIdx][iRefIdx]->bIsComplete || bIsPending)); } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -1644,7 +1649,7 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ } } pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[listIdx][iref] - && ppRefPic[listIdx][iref]->bIsComplete); + && (ppRefPic[listIdx][iref]->bIsComplete || bIsPending)); } else { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); @@ -1689,26 +1694,26 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ * (uint32_t*)iMv = 0; } if (IS_SUB_8x8 (subMbType)) { //MB_TYPE_8x8 - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 1], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 4], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 5], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 1], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 4], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 5], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx + 1], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx + 6], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx + 7], LD32 (iMv)); } else if (IS_SUB_8x4 (subMbType)) { - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 1], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 1], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx + 1], LD32 (iMv)); } else if (IS_SUB_4x8 (subMbType)) { - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv)); - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 4], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 4], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx + 6], LD32 (iMv)); } else { //SUB_MB_TYPE_4x4 == uiSubMbType - ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv)); + ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv)); ST32 (iMvArray[listIdx][uiCacheIdx], LD32 (iMv)); } } diff --git a/src/openh264/codec/decoder/core/src/pic_queue.cpp b/src/openh264/codec/decoder/core/src/pic_queue.cpp old mode 100755 new mode 100644 index a2c5e7f08..475df0ac0 --- a/src/openh264/codec/decoder/core/src/pic_queue.cpp +++ b/src/openh264/codec/decoder/core/src/pic_queue.cpp @@ -106,13 +106,15 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const pPic->iWidthInPixel = kiPicWidth; pPic->iHeightInPixel = kiPicHeight; pPic->iFrameNum = -1; - pPic->bAvailableFlag = true; + pPic->iRefCount = 0; uint32_t uiMbWidth = (kiPicWidth + 15) >> 4; uint32_t uiMbHeight = (kiPicHeight + 15) >> 4; uint32_t uiMbCount = uiMbWidth * uiMbHeight; - pPic->pMbType = (uint32_t*)pMa->WelsMallocz (uiMbCount * sizeof (uint32_t), - "pPic->pMbType"); + + pPic->pMbCorrectlyDecodedFlag = (bool*)pMa->WelsMallocz (uiMbCount * sizeof (bool), "pPic->pMbCorrectlyDecodedFlag"); + pPic->pNzc = GetThreadCount (pCtx) > 1 ? (int8_t (*)[24])pMa->WelsMallocz (uiMbCount * 24, "pPic->pNzc") : NULL; + pPic->pMbType = (uint32_t*)pMa->WelsMallocz (uiMbCount * sizeof (uint32_t), "pPic->pMbType"); pPic->pMv[LIST_0] = (int16_t (*)[16][2])pMa->WelsMallocz (uiMbCount * sizeof ( int16_t) * MV_A * MB_BLOCK4x4_NUM, "pPic->pMv[]"); pPic->pMv[LIST_1] = (int16_t (*)[16][2])pMa->WelsMallocz (uiMbCount * sizeof ( @@ -121,6 +123,15 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[]"); pPic->pRefIndex[LIST_1] = (int8_t (*)[16])pMa->WelsMallocz (uiMbCount * sizeof ( int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[]"); + if (pCtx->pThreadCtx != NULL) { + pPic->pReadyEvent = (SWelsDecEvent*)pMa->WelsMallocz (uiMbHeight * sizeof (SWelsDecEvent), "pPic->pReadyEvent"); + for (uint32_t i = 0; i < uiMbHeight; ++i) { + CREATE_EVENT (&pPic->pReadyEvent[i], 1, 0, NULL); + } + } else { + pPic->pReadyEvent = NULL; + } + return pPic; } @@ -131,6 +142,16 @@ void FreePicture (PPicture pPic, CMemoryAlign* pMa) { pPic->pBuffer[0] = NULL; } + if (pPic->pMbCorrectlyDecodedFlag) { + pMa->WelsFree (pPic->pMbCorrectlyDecodedFlag, "pPic->pMbCorrectlyDecodedFlag"); + pPic->pMbCorrectlyDecodedFlag = NULL; + } + + if (pPic->pNzc) { + pMa->WelsFree (pPic->pNzc, "pPic->pNzc"); + pPic->pNzc = NULL; + } + if (pPic->pMbType) { pMa->WelsFree (pPic->pMbType, "pPic->pMbType"); pPic->pMbType = NULL; @@ -147,6 +168,14 @@ void FreePicture (PPicture pPic, CMemoryAlign* pMa) { pPic->pRefIndex[listIdx] = NULL; } } + if (pPic->pReadyEvent != NULL) { + uint32_t uiMbHeight = (pPic->iHeightInPixel + 15) >> 4; + for (uint32_t i = 0; i < uiMbHeight; ++i) { + CLOSE_EVENT (&pPic->pReadyEvent[i]); + } + pMa->WelsFree (pPic->pReadyEvent, "pPic->pReadyEvent"); + pPic->pReadyEvent = NULL; + } pMa->WelsFree (pPic, "pPic"); pPic = NULL; } @@ -160,25 +189,55 @@ PPicture PrefetchPic (PPicBuff pPicBuf) { } for (iPicIdx = pPicBuf->iCurrentIdx + 1; iPicIdx < pPicBuf->iCapacity ; ++iPicIdx) { - if (pPicBuf->ppPic[iPicIdx] != NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag - && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) { + if (pPicBuf->ppPic[iPicIdx] != NULL && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef + && pPicBuf->ppPic[iPicIdx]->iRefCount <= 0) { pPic = pPicBuf->ppPic[iPicIdx]; break; } } if (pPic != NULL) { pPicBuf->iCurrentIdx = iPicIdx; + pPic->iPicBuffIdx = iPicIdx; return pPic; } for (iPicIdx = 0 ; iPicIdx <= pPicBuf->iCurrentIdx ; ++iPicIdx) { - if (pPicBuf->ppPic[iPicIdx] != NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag - && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) { + if (pPicBuf->ppPic[iPicIdx] != NULL && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef + && pPicBuf->ppPic[iPicIdx]->iRefCount <= 0) { pPic = pPicBuf->ppPic[iPicIdx]; break; } } pPicBuf->iCurrentIdx = iPicIdx; + if (pPic != NULL) { + pPic->iPicBuffIdx = iPicIdx; + } + return pPic; +} + +PPicture PrefetchPicForThread (PPicBuff pPicBuf) { + PPicture pPic = NULL; + + if (pPicBuf->iCapacity == 0) { + return NULL; + } + pPic = pPicBuf->ppPic[pPicBuf->iCurrentIdx]; + pPic->iPicBuffIdx = pPicBuf->iCurrentIdx; + if (++pPicBuf->iCurrentIdx >= pPicBuf->iCapacity) { + pPicBuf->iCurrentIdx = 0; + } + return pPic; +} + +PPicture PrefetchLastPicForThread (PPicBuff pPicBuf, const int32_t& iLastPicBuffIdx) { + PPicture pPic = NULL; + + if (pPicBuf->iCapacity == 0) { + return NULL; + } + if (iLastPicBuffIdx >= 0 && iLastPicBuffIdx < pPicBuf->iCapacity) { + pPic = pPicBuf->ppPic[iLastPicBuffIdx]; + } return pPic; } diff --git a/src/openh264/codec/decoder/core/src/rec_mb.cpp b/src/openh264/codec/decoder/core/src/rec_mb.cpp old mode 100755 new mode 100644 index 2db6de7ba..9034cc4d7 --- a/src/openh264/codec/decoder/core/src/rec_mb.cpp +++ b/src/openh264/codec/decoder/core/src/rec_mb.cpp @@ -44,20 +44,20 @@ namespace WelsDec { -void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurLayer) { +void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurDqLayer) { PPicture pCurPic = pCtx->pDec; int32_t iLumaStride = pCurPic->iLinesize[0]; int32_t iChromaStride = pCurPic->iLinesize[1]; - int32_t iMbX = pCurLayer->iMbX; - int32_t iMbY = pCurLayer->iMbY; + int32_t iMbX = pCurDqLayer->iMbX; + int32_t iMbY = pCurDqLayer->iMbY; - pCurLayer->iLumaStride = iLumaStride; - pCurLayer->iChromaStride = iChromaStride; + pCurDqLayer->iLumaStride = iLumaStride; + pCurDqLayer->iChromaStride = iChromaStride; if (bOutput) { - pCurLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX) << 4); - pCurLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX) << 3); - pCurLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX) << 3); + pCurDqLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX) << 4); + pCurDqLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX) << 3); + pCurDqLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX) << 3); } } @@ -214,11 +214,10 @@ int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLe //according to current 8*8 block ref_index to gain reference picture -static inline int32_t GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, int8_t* pRefIdxList, - int32_t iIndex, int32_t listIdx) { +static inline int32_t GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, const int8_t& iRefIdx, + int32_t listIdx) { PPicture pRefPic; - int8_t iRefIdx = pRefIdxList[iIndex]; if (iRefIdx >= 0) { pRefPic = pCtx->sRefPic.pRefList[listIdx][iRefIdx]; @@ -242,7 +241,9 @@ static inline int32_t GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pC #ifndef MC_FLOW_SIMPLE_JUDGE #define MC_FLOW_SIMPLE_JUDGE 1 #endif //MC_FLOW_SIMPLE_JUDGE -void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc, +void BaseMC (PWelsDecoderContext pCtx, sMCRefMember* pMCRefMem, const int32_t& listIdx, const int8_t& iRefIdx, + int32_t iXOffset, int32_t iYOffset, + SMcFunc* pMCFunc, int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) { int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel int32_t iFullMVy = (iYOffset << 2) + iMVs[1]; @@ -251,6 +252,27 @@ void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFun iFullMVy = WELS_CLIP3 (iFullMVy, ((-PADDING_LENGTH + 2) * (1 << 2)), ((pMCRefMem->iPicHeight + PADDING_LENGTH - 19) * (1 << 2))); + if (GetThreadCount (pCtx) > 1 && iRefIdx >= 0) { + // wait for the lines of reference macroblock (3 + 16). + PPicture pRefPic = pCtx->sRefPic.pRefList[listIdx][iRefIdx]; + if (pCtx->bNewSeqBegin && (pCtx->iErrorCode & dsRefLost)) { + //set event if refpic is lost to prevent from infinite waiting. + if (!pRefPic->pReadyEvent[0].isSignaled) { + for (uint32_t ln = 0; ln < pCtx->sMb.iMbHeight; ++ln) { + SET_EVENT (&pRefPic->pReadyEvent[ln]); + } + } + } + int32_t offset = (iFullMVy >> 2) + iBlkHeight + 3 + 16; + if (offset > pCtx->lastReadyHeightOffset[listIdx][iRefIdx]) { + const int32_t down_line = WELS_MIN (offset >> 4, int32_t (pCtx->sMb.iMbHeight) - 1); + if (pRefPic->pReadyEvent[down_line].isSignaled != 1) { + WAIT_EVENT (&pRefPic->pReadyEvent[down_line], WELS_DEC_THREAD_WAIT_INFINITE); + } + pCtx->lastReadyHeightOffset[listIdx][iRefIdx] = offset; + } + } + int32_t iSrcPixOffsetLuma = (iFullMVx >> 2) + (iFullMVy >> 2) * pMCRefMem->iSrcLineLuma; int32_t iSrcPixOffsetChroma = (iFullMVx >> 3) + (iFullMVy >> 3) * pMCRefMem->iSrcLineChroma; @@ -446,7 +468,7 @@ int32_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWels int16_t iMVs[2] = {0}; - uint32_t iMBType = pCurDqLayer->pMbType[iMBXY]; + uint32_t iMBType = pCurDqLayer->pDec->pMbType[iMBXY]; int32_t iMBOffsetX = pCurDqLayer->iMbX << 4; int32_t iMBOffsetY = pCurDqLayer->iMbY << 4; @@ -466,65 +488,66 @@ int32_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWels pMCRefMem.iDstLineLuma = iDstLineLuma; pMCRefMem.iDstLineChroma = iDstLineChroma; - int32_t iRefIndex = 0; + int8_t iRefIndex = 0; switch (iMBType) { case MB_TYPE_SKIP: case MB_TYPE_16x16: - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0)); - BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][0][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][0][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][0]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, LIST_0)); + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { - iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][0]; WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 16); } break; case MB_TYPE_16x8: - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0)); - BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][0][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][0][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][0]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, LIST_0)); + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { - iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0]; WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 8); } - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8, LIST_0)); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][8][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][8][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][8]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, LIST_0)); pMCRefMem.pDstY = pPredY + (iDstLineLuma << 3); pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2); pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2); - BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs); + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { - iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][8]; WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 8); } break; case MB_TYPE_8x16: - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0)); - BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][0][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][0][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][0]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, LIST_0)); + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { - iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0]; WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 16); } - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 2, LIST_0)); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][2][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][2][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][2]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, LIST_0)); pMCRefMem.pDstY = pPredY + 8; pMCRefMem.pDstU = pPredCb + 4; pMCRefMem.pDstV = pPredCr + 4; - BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs); + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { - iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][2]; WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 16); } break; @@ -541,9 +564,8 @@ int32_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWels iYOffset = iMBOffsetY + iBlk8Y; iIIdx = ((i >> 1) << 3) + ((i & 1) << 1); - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx, LIST_0)); - iRefIndex = pCurDqLayer->bUseWeightPredictionFlag ? pCurDqLayer->pRefIndex[0][iMBXY][iIIdx] : 0; - + iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][iIIdx]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, LIST_0)); pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma; pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma; pDstV = pPredCr + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma; @@ -552,9 +574,9 @@ int32_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWels pMCRefMem.pDstV = pDstV; switch (iSubMBType) { case SUB_MB_TYPE_8x8: - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 8); @@ -562,21 +584,21 @@ int32_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWels break; case SUB_MB_TYPE_8x4: - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 4); } - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][1]; + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + 4][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + 4][1]; pMCRefMem.pDstY += (iDstLineLuma << 2); pMCRefMem.pDstU += (iDstLineChroma << 1); pMCRefMem.pDstV += (iDstLineChroma << 1); - BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 4); @@ -584,21 +606,21 @@ int32_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWels break; case SUB_MB_TYPE_4x8: - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 8); } - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][1]; + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + 1][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + 1][1]; pMCRefMem.pDstY += 4; pMCRefMem.pDstU += 2; pMCRefMem.pDstV += 2; - BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 8); @@ -618,9 +640,9 @@ int32_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWels pMCRefMem.pDstU = pDstU + iUVLineStride; pMCRefMem.pDstV = pDstV + iUVLineStride; - iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0]; - iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1]; - BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + iJIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + iJIdx][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); if (pCurDqLayer->bUseWeightPredictionFlag) { WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 4); @@ -652,7 +674,7 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels int16_t iMVs[2] = { 0 }; - uint32_t iMBType = pCurDqLayer->pMbType[iMBXY]; + uint32_t iMBType = pCurDqLayer->pDec->pMbType[iMBXY]; int32_t iMBOffsetX = pCurDqLayer->iMbX << 4; int32_t iMBOffsetY = pCurDqLayer->iMbY << 4; @@ -677,37 +699,38 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels pTempMCRefMem.pDstV = pTempPredYCbCr[2]; - int32_t iRefIndex1 = 0; - int32_t iRefIndex2 = 0; + int8_t iRefIndex0 = 0; + int8_t iRefIndex1 = 0; + int8_t iRefIndex = 0; bool bWeightedBipredIdcIs1 = pCurDqLayer->sLayerInfo.pPps->uiWeightedBipredIdc == 1; if (IS_INTER_16x16 (iMBType)) { if (IS_TYPE_L0 (iMBType) && IS_TYPE_L1 (iMBType)) { - iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][0][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][0][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_0][iMBXY], 0, LIST_0)); - BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][0][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][0][1]; + iRefIndex0 = pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY][0]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex0, LIST_0)); + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex0, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][0][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][0][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], 0, LIST_1)); - BaseMC (&pTempMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); - iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][0]; - iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][0]; + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][0][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][0][1]; + iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][0]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, iRefIndex1, LIST_1)); + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 16, 16); + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 16, 16); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 16, 16); } } else { int32_t listIdx = (iMBType & MB_TYPE_P0L0) ? LIST_0 : LIST_1; - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][0][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][0][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], 0, listIdx)); - BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][0][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][0][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][0]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, listIdx)); + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); if (bWeightedBipredIdcIs1) { - int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][0]; WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 16, 16); } } @@ -719,29 +742,31 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (IS_DIR (iMBType, i, listIdx)) { lastListIdx = listIdx; - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iPartIdx][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iPartIdx][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], iPartIdx, listIdx)); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iPartIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iPartIdx][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iPartIdx]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, listIdx)); if (i) { pMCRefMem.pDstY += (iDstLineLuma << 3); pMCRefMem.pDstU += (iDstLineChroma << 2); pMCRefMem.pDstV += (iDstLineChroma << 2); } - BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs); + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs); if (++listCount == 2) { - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iPartIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iPartIdx][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], iPartIdx, LIST_1)); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iPartIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iPartIdx][1]; + iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][iPartIdx]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, iRefIndex1, LIST_1)); if (i) { pTempMCRefMem.pDstY += (iDstLineLuma << 3); pTempMCRefMem.pDstU += (iDstLineChroma << 2); pTempMCRefMem.pDstV += (iDstLineChroma << 2); } - BaseMC (&pTempMCRefMem, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs); + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][iPartIdx]; - iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][iPartIdx]; - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 16, 8); + iRefIndex0 = pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY][iPartIdx]; + iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][iPartIdx]; + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 16, 8); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 16, 8); } @@ -750,7 +775,7 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels } if (listCount == 1) { if (bWeightedBipredIdcIs1) { - int32_t iRefIndex = pCurDqLayer->pRefIndex[lastListIdx][iMBXY][iPartIdx]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[lastListIdx][iMBXY][iPartIdx]; WeightPrediction (pCurDqLayer, &pMCRefMem, lastListIdx, iRefIndex, 16, 8); } } @@ -762,29 +787,31 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { if (IS_DIR (iMBType, i, listIdx)) { lastListIdx = listIdx; - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][i << 1][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][i << 1][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], i << 1, listIdx)); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][i << 1][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][i << 1][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][i << 1]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, listIdx)); if (i) { pMCRefMem.pDstY += 8; pMCRefMem.pDstU += 4; pMCRefMem.pDstV += 4; } - BaseMC (&pMCRefMem, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs); + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs); if (++listCount == 2) { - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][i << 1][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][i << 1][1]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], i << 1, LIST_1)); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][i << 1][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][i << 1][1]; + iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][i << 1]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, iRefIndex1, LIST_1)); if (i) { pTempMCRefMem.pDstY += 8; pTempMCRefMem.pDstU += 4; pTempMCRefMem.pDstV += 4; } - BaseMC (&pTempMCRefMem, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs); + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][i << 1]; - iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][i << 1]; - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 16); + iRefIndex0 = pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY][i << 1]; + iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][i << 1]; + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 8, 16); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 16); } @@ -793,7 +820,7 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels } if (listCount == 1) { if (bWeightedBipredIdcIs1) { - int32_t iRefIndex = pCurDqLayer->pRefIndex[lastListIdx][iMBXY][i << 1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[lastListIdx][iMBXY][i << 1]; WeightPrediction (pCurDqLayer, &pMCRefMem, lastListIdx, iRefIndex, 8, 16); } } @@ -830,53 +857,53 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels pTempMCRefMem.pDstV = pDstV2; if ((IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType))) { - iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][iIIdx]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_0][iMBXY], iIIdx, LIST_0)); + iRefIndex0 = pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY][iIIdx]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex0, LIST_0)); - iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][iIIdx]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], iIIdx, LIST_1)); + iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][iIIdx]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, iRefIndex1, LIST_1)); } else { int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1; - iRefIndex1 = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx]; - WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], iIIdx, listIdx)); + iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx]; + WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, iRefIndex, listIdx)); } if (IS_SUB_8x8 (iSubMBType)) { if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { - iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex0, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1]; - BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 8); + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 8, 8); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 8); } } else { int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1; - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx]; + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); if (bWeightedBipredIdcIs1) { - int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx]; WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 8, 8); } } } else if (IS_SUB_8x4 (iSubMBType)) { if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { //B_Bi_8x4 - iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1]; - BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex0, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 4); + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 8, 4); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 4); } @@ -884,49 +911,49 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels pMCRefMem.pDstY += (iDstLineLuma << 2); pMCRefMem.pDstU += (iDstLineChroma << 1); pMCRefMem.pDstV += (iDstLineChroma << 1); - iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 4][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 4][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + 4][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + 4][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex0, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); pTempMCRefMem.pDstY += (iDstLineLuma << 2); pTempMCRefMem.pDstU += (iDstLineChroma << 1); pTempMCRefMem.pDstV += (iDstLineChroma << 1); - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 4][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 4][1]; - BaseMC (&pTempMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + 4][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + 4][1]; + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 4); + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 8, 4); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 4); } } else { //B_L0_8x4 B_L1_8x4 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1; - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx]; + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); pMCRefMem.pDstY += (iDstLineLuma << 2); pMCRefMem.pDstU += (iDstLineChroma << 1); pMCRefMem.pDstV += (iDstLineChroma << 1); - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 4][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 4][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + 4][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + 4][1]; + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); if (bWeightedBipredIdcIs1) { - int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx]; WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 8, 4); } } } else if (IS_SUB_4x8 (iSubMBType)) { if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { //B_Bi_4x8 - iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1]; - BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex0, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][1]; + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 8); + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 4, 8); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 8); } @@ -934,35 +961,35 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels pMCRefMem.pDstY += 4; pMCRefMem.pDstU += 2; pMCRefMem.pDstV += 2; - iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 1][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 1][1]; - BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + 1][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + 1][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex0, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); pTempMCRefMem.pDstY += 4; pTempMCRefMem.pDstU += 2; pTempMCRefMem.pDstV += 2; - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 1][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 1][1]; - BaseMC (&pTempMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + 1][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + 1][1]; + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 8); + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 4, 8); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 8); } } else { //B_L0_4x8 B_L1_4x8 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1; - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1]; - BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][1]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx]; + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); pMCRefMem.pDstY += 4; pMCRefMem.pDstU += 2; pMCRefMem.pDstV += 2; - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 1][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 1][1]; - BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + 1][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + 1][1]; + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); if (bWeightedBipredIdcIs1) { - int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx]; WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 4, 8); } } @@ -980,27 +1007,27 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels pMCRefMem.pDstU = pDstU + iUVLineStride; pMCRefMem.pDstV = pDstV + iUVLineStride; - iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + iJIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + iJIdx][1]; - BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + iJIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + iJIdx][1]; + BaseMC (pCtx, &pMCRefMem, LIST_0, iRefIndex0, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); pTempMCRefMem.pDstY = pDstY2 + iBlk8X + iBlk8Y * iDstLineLuma; pTempMCRefMem.pDstU = pDstU2 + iUVLineStride; pTempMCRefMem.pDstV = pDstV2 + iUVLineStride;; - iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + iJIdx][0]; - iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + iJIdx][1]; - BaseMC (&pTempMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + iJIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + iJIdx][1]; + BaseMC (pCtx, &pTempMCRefMem, LIST_1, iRefIndex1, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); if (pCurDqLayer->bUseWeightedBiPredIdc) { - BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 4); + BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex0, iRefIndex1, bWeightedBipredIdcIs1, 4, 4); } else { BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 4); } } } else { int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1; - int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx]; + iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx]; for (int32_t j = 0; j < 4; j++) { int32_t iUVLineStride; iJIdx = ((j >> 1) << 2) + (j & 1); @@ -1013,9 +1040,9 @@ int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWels pMCRefMem.pDstU = pDstU + iUVLineStride; pMCRefMem.pDstV = pDstV + iUVLineStride; - iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + iJIdx][0]; - iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + iJIdx][1]; - BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); + iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + iJIdx][0]; + iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + iJIdx][1]; + BaseMC (pCtx, &pMCRefMem, listIdx, iRefIndex, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); if (bWeightedBipredIdcIs1) { WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 4, 4); } diff --git a/src/openh264/codec/decoder/core/src/wels_decoder_thread.cpp b/src/openh264/codec/decoder/core/src/wels_decoder_thread.cpp new file mode 100644 index 000000000..d05aa4515 --- /dev/null +++ b/src/openh264/codec/decoder/core/src/wels_decoder_thread.cpp @@ -0,0 +1,311 @@ +/*! + * \copy + * Copyright (c) 2009-2019, Cisco Systems + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * \file wels_decoder_thread.cpp + * + * \brief Interfaces introduced in thread programming + * + * \date 08/06/2018 Created + * + ************************************************************************************* + */ + + +#ifdef __linux__ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#elif !defined(_WIN32) && !defined(__CYGWIN__) +#include +#include +#include +#ifndef __Fuchsia__ +#include +#endif +#ifdef __APPLE__ +#define HW_NCPU_NAME "hw.logicalcpu" +#else +#define HW_NCPU_NAME "hw.ncpu" +#endif +#endif + +#include "wels_decoder_thread.h" +#include +#include + +int32_t GetCPUCount() { + WelsLogicalProcessInfo pInfo; + pInfo.ProcessorCount = 1; + WelsQueryLogicalProcessInfo (&pInfo); + return pInfo.ProcessorCount; +} + +int ThreadCreate (SWelsDecThread* t, LPWELS_THREAD_ROUTINE tf, void* ta) { + WELS_THREAD_ATTR attr = 0; + return WelsThreadCreate (& (t->h), tf, ta, attr); +} + +int ThreadWait (SWelsDecThread* t) { + return WelsThreadJoin (t->h); +} + +#if defined(_WIN32) || defined(__CYGWIN__) + +int EventCreate (SWelsDecEvent* e, int manualReset, int initialState) { + e->h = CreateEvent (NULL, manualReset, initialState, NULL); + e->isSignaled = initialState; + return (e->h != NULL) ? 0 : 1; +} + +void EventReset (SWelsDecEvent* e) { + ResetEvent (e->h); + e->isSignaled = 0; +} + +void EventPost (SWelsDecEvent* e) { + SetEvent (e->h); + e->isSignaled = 1; +} + +int EventWait (SWelsDecEvent* e, int32_t timeout) { + DWORD result; + if ((uint32_t)timeout == WELS_DEC_THREAD_WAIT_INFINITE || timeout < 0) + result = WaitForSingleObject (e->h, INFINITE); + else + result = WaitForSingleObject (e->h, timeout); + + if (result == WAIT_OBJECT_0) + return WELS_DEC_THREAD_WAIT_SIGNALED; + else + return WAIT_TIMEOUT; +} + +void EventDestroy (SWelsDecEvent* e) { + CloseHandle (e->h); + e->h = NULL; +} + +int SemCreate (SWelsDecSemphore* s, long value, long max) { + s->h = CreateSemaphore (NULL, value, max, NULL); + return (s->h != NULL) ? 0 : 1; +} + +int SemWait (SWelsDecSemphore* s, int32_t timeout) { + DWORD result; + if ((uint32_t)timeout == WELS_DEC_THREAD_WAIT_INFINITE || timeout < 0) + result = WaitForSingleObject (s->h, INFINITE); + else + result = WaitForSingleObject (s->h, timeout); + + if (result == WAIT_OBJECT_0) { + return WELS_DEC_THREAD_WAIT_SIGNALED; + } else { + return WELS_DEC_THREAD_WAIT_TIMEDOUT; + } +} + +void SemRelease (SWelsDecSemphore* s, long* prevcount) { + ReleaseSemaphore (s->h, 1, prevcount); +} + +void SemDestroy (SWelsDecSemphore* s) { + CloseHandle (s->h); + s->h = NULL; +} + +#else /* _WIN32 */ + +static void getTimespecFromTimeout (struct timespec* ts, int32_t timeout) { + struct timeval tv; + gettimeofday (&tv, 0); + ts->tv_nsec = tv.tv_usec * 1000 + timeout * 1000000; + ts->tv_sec = tv.tv_sec + ts->tv_nsec / 1000000000; + ts->tv_nsec %= 1000000000; +} +int EventCreate (SWelsDecEvent* e, int manualReset, int initialState) { + if (pthread_mutex_init (& (e->m), NULL)) + return 1; + if (pthread_cond_init (& (e->c), NULL)) + return 2; + + e->isSignaled = initialState; + e->manualReset = manualReset; + + return 0; +} + +void EventReset (SWelsDecEvent* e) { + pthread_mutex_lock (& (e->m)); + e->isSignaled = 0; + pthread_mutex_unlock (& (e->m)); +} + +void EventPost (SWelsDecEvent* e) { + pthread_mutex_lock (& (e->m)); + pthread_cond_broadcast (& (e->c)); + e->isSignaled = 1; + pthread_mutex_unlock (& (e->m)); +} + +int EventWait (SWelsDecEvent* e, int32_t timeout) { + pthread_mutex_lock (& (e->m)); + int signaled = e->isSignaled; + if (timeout == 0) { + pthread_mutex_unlock (& (e->m)); + if (signaled) + return WELS_DEC_THREAD_WAIT_SIGNALED; + else + return WELS_DEC_THREAD_WAIT_TIMEDOUT; + } + if (signaled) { + if (!e->manualReset) { + e->isSignaled = 0; + } + pthread_mutex_unlock (& (e->m)); + return WELS_DEC_THREAD_WAIT_SIGNALED; + } + int rc = 0; + if (timeout == WELS_DEC_THREAD_WAIT_INFINITE || timeout < 0) { + rc = pthread_cond_wait (& (e->c), & (e->m)); + } else { + struct timespec ts; + getTimespecFromTimeout (&ts, timeout); + rc = pthread_cond_timedwait (& (e->c), & (e->m), &ts); + } + if (!e->manualReset) { + e->isSignaled = 0; + } + pthread_mutex_unlock (& (e->m)); + if (rc == 0) + return WELS_DEC_THREAD_WAIT_SIGNALED; + else + return WELS_DEC_THREAD_WAIT_TIMEDOUT; +} + +void EventDestroy (SWelsDecEvent* e) { + pthread_mutex_destroy (& (e->m)); + pthread_cond_destroy (& (e->c)); +} + +int SemCreate (SWelsDecSemphore* s, long value, long max) { + s->v = value; + s->max = max; + if (pthread_mutex_init (& (s->m), NULL)) + return 1; + const char* event_name = ""; + if (WelsEventOpen (& (s->e), event_name)) { + return 2; + } + return 0; +} + +int SemWait (SWelsDecSemphore* s, int32_t timeout) { +#if defined(__APPLE__) + pthread_mutex_lock (& (s->m)); +#endif + int rc = 0; + if (timeout != 0) { + while ((s->v) == 0) { + if (timeout == WELS_DEC_THREAD_WAIT_INFINITE || timeout < 0) { + // infinite wait until released +#if defined(__APPLE__) + rc = pthread_cond_wait (& (s->e), & (s->m)); +#else + rc = sem_wait (s->e); + if (rc != 0) rc = errno; +#endif + } else { + struct timespec ts; + getTimespecFromTimeout (&ts, timeout); +#if defined(__APPLE__) + rc = pthread_cond_timedwait (& (s->e), & (s->m), &ts); +#else + rc = sem_timedwait (s->e, &ts); + if (rc != 0) rc = errno; +#endif + if (rc != EINTR) { + // if timed out we return to the caller + break; + } + } + } + // only decrement counter if semaphore was signaled + if (rc == 0) + s->v -= 1; + + } else { + // Special handling for timeout of 0 + if (s->v > 0) { + s->v -= 1; + rc = 0; + } else { + rc = 1; + } + } +#if defined(__APPLE__) + pthread_mutex_unlock (& (s->m)); +#endif + // set return value + if (rc == 0) + return WELS_DEC_THREAD_WAIT_SIGNALED; + else + return WELS_DEC_THREAD_WAIT_TIMEDOUT; +} + +void SemRelease (SWelsDecSemphore* s, long* o_pPrevCount) { + long prevcount; +#ifdef __APPLE__ + pthread_mutex_lock (& (s->m)); + prevcount = s->v; + if (s->v < s->max) + s->v += 1; + pthread_cond_signal (& (s->e)); + pthread_mutex_unlock (& (s->m)); +#else + prevcount = s->v; + if (s->v < s->max) + s->v += 1; + sem_post (s->e); +#endif + if (o_pPrevCount != NULL) { + *o_pPrevCount = prevcount; + } +} + +void SemDestroy (SWelsDecSemphore* s) { + pthread_mutex_destroy (& (s->m)); + const char* event_name = ""; + WelsEventClose (& (s->e), event_name); +} + +#endif /* !_WIN32 */ + diff --git a/src/openh264/codec/decoder/core/x86/dct.asm b/src/openh264/codec/decoder/core/x86/dct.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/core/x86/intra_pred.asm b/src/openh264/codec/decoder/core/x86/intra_pred.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/meson.build b/src/openh264/codec/decoder/meson.build old mode 100755 new mode 100644 index f93837eaf..e4d123cca --- a/src/openh264/codec/decoder/meson.build +++ b/src/openh264/codec/decoder/meson.build @@ -19,6 +19,7 @@ cpp_sources = [ 'core/src/pic_queue.cpp', 'core/src/rec_mb.cpp', 'plus/src/welsDecoderExt.cpp', + 'core/src/wels_decoder_thread.cpp', ] asm_sources = [ diff --git a/src/openh264/codec/decoder/plus/inc/welsDecoderExt.h b/src/openh264/codec/decoder/plus/inc/welsDecoderExt.h old mode 100755 new mode 100644 index c0654548a..cfacbc83f --- a/src/openh264/codec/decoder/plus/inc/welsDecoderExt.h +++ b/src/openh264/codec/decoder/plus/inc/welsDecoderExt.h @@ -109,33 +109,53 @@ class CWelsDecoder : public ISVCDecoder { virtual long EXTAPI SetOption (DECODER_OPTION eOptID, void* pOption); virtual long EXTAPI GetOption (DECODER_OPTION eOptID, void* pOption); - typedef struct tagPictInfo { - SBufferInfo sBufferInfo; - int32_t iPOC; - int32_t iPicBuffIdx; - bool bLastGOP; - unsigned char* pData[3]; - } SPictInfo, *PPictInfo; + public: + DECODING_STATE DecodeFrame2WithCtx (PWelsDecoderContext pCtx, const unsigned char* kpSrc, const int kiSrcLen, + unsigned char** ppDst, SBufferInfo* pDstInfo); + DECODING_STATE ParseAccessUnit (SWelsDecoderThreadCTX& sThreadCtx); private: - PWelsDecoderContext m_pDecContext; welsCodecTrace* m_pWelsTrace; + uint32_t m_uiDecodeTimeStamp; + bool m_bIsBaseline; + int32_t m_iCpuCount; + int32_t m_iThreadCount; + int32_t m_iCtxCount; + PPicBuff m_pPicBuff; + bool m_bParamSetsLostFlag; + bool m_bFreezeOutput; + int32_t m_DecCtxActiveCount; + PWelsDecoderThreadCTX m_pDecThrCtx; + PWelsDecoderThreadCTX m_pLastDecThrCtx; + int32_t m_iLastBufferedIdx; + WELS_MUTEX m_csDecoder; + SWelsDecEvent m_sBufferingEvent; + SWelsDecEvent m_sReleaseBufferEvent; + SWelsDecSemphore m_sIsBusy; SPictInfo m_sPictInfoList[16]; - int32_t m_iPictInfoIndex; - int32_t m_iMinPOC; - int32_t m_iNumOfPicts; - int32_t m_iLastGOPRemainPicts; - int32_t m_LastWrittenPOC; - int32_t m_iLargestBufferedPicIndex; + SPictReoderingStatus m_sReoderingStatus; + PWelsDecoderThreadCTX m_pDecThrCtxActive[WELS_DEC_MAX_NUM_CPU]; + SVlcTable m_sVlcTable; + SWelsLastDecPicInfo m_sLastDecPicInfo; + SDecoderStatistics m_sDecoderStatistics;// For real time debugging + private: int32_t InitDecoder (const SDecodingParam* pParam); void UninitDecoder (void); - int32_t ResetDecoder(); - void ResetReorderingPictureBuffers(); + int32_t InitDecoderCtx (PWelsDecoderContext& pCtx, const SDecodingParam* pParam); + void UninitDecoderCtx (PWelsDecoderContext& pCtx); + int32_t ResetDecoder (PWelsDecoderContext& pCtx); + int32_t ThreadResetDecoder (PWelsDecoderContext& pCtx); void OutputStatisticsLog (SDecoderStatistics& sDecoderStatistics); - DECODING_STATE ReorderPicturesInDisplay (unsigned char** ppDst, SBufferInfo* pDstInfo); + DECODING_STATE ReorderPicturesInDisplay (PWelsDecoderContext pCtx, unsigned char** ppDst, SBufferInfo* pDstInfo); + int ThreadDecodeFrameInternal (const unsigned char* kpSrc, const int kiSrcLen, unsigned char** ppDst, + SBufferInfo* pDstInfo); + void BufferingReadyPicture (PWelsDecoderContext pCtx, unsigned char** ppDst, SBufferInfo* pDstInfo); + void ReleaseBufferedReadyPicture (PWelsDecoderContext pCtx, unsigned char** ppDst, SBufferInfo* pDstInfo); + void OpenDecoderThreads(); + void CloseDecoderThreads(); #ifdef OUTPUT_BIT_STREAM WelsFileHandle* m_pFBS; WelsFileHandle* m_pFBSSize; diff --git a/src/openh264/codec/decoder/plus/src/welsDecoderExt.cpp b/src/openh264/codec/decoder/plus/src/welsDecoderExt.cpp old mode 100755 new mode 100644 index 98a376ddc..c402d7987 --- a/src/openh264/codec/decoder/plus/src/welsDecoderExt.cpp +++ b/src/openh264/codec/decoder/plus/src/welsDecoderExt.cpp @@ -51,6 +51,7 @@ //#include "macros.h" #include "decoder.h" #include "decoder_core.h" +#include "manage_dec_ref.h" #include "error_concealment.h" #include "measure_time.h" @@ -67,14 +68,11 @@ extern "C" { #include #include #include +#include #else #include #endif -#define _PICTURE_REORDERING_ 1 - -static int32_t sIMinInt32 = -0x7FFFFFFF; - namespace WelsDec { ////////////////////////////////////////////////////////////////////// @@ -90,15 +88,62 @@ namespace WelsDec { * * return: none ***************************************************************************/ +DECLARE_PROCTHREAD (pThrProcInit, p) { + SWelsDecThreadInfo* sThreadInfo = (SWelsDecThreadInfo*)p; +#if defined(WIN32) + _alloca (WELS_DEC_MAX_THREAD_STACK_SIZE * (sThreadInfo->uiThrNum + 1)); +#endif + return sThreadInfo->pThrProcMain (p); +} + +static DECODING_STATE ConstructAccessUnit (CWelsDecoder* pWelsDecoder, PWelsDecoderThreadCTX pThrCtx) { + int iRet = dsErrorFree; + //WelsMutexLock (&pWelsDecoder->m_csDecoder); + if (pThrCtx->pCtx->pLastThreadCtx != NULL) { + PWelsDecoderThreadCTX pLastThreadCtx = (PWelsDecoderThreadCTX) (pThrCtx->pCtx->pLastThreadCtx); + WAIT_EVENT (&pLastThreadCtx->sSliceDecodeStart, WELS_DEC_THREAD_WAIT_INFINITE); + RESET_EVENT (&pLastThreadCtx->sSliceDecodeStart); + } + pThrCtx->pDec = NULL; + if (GetThreadCount (pThrCtx->pCtx) > 1) { + RESET_EVENT (&pThrCtx->sSliceDecodeFinish); + } + iRet |= pWelsDecoder->DecodeFrame2WithCtx (pThrCtx->pCtx, NULL, 0, pThrCtx->ppDst, &pThrCtx->sDstInfo); + + //WelsMutexUnlock (&pWelsDecoder->m_csDecoder); + return (DECODING_STATE)iRet; +} + +DECLARE_PROCTHREAD (pThrProcFrame, p) { + SWelsDecoderThreadCTX* pThrCtx = (SWelsDecoderThreadCTX*)p; + while (1) { + RELEASE_SEMAPHORE (pThrCtx->sThreadInfo.sIsBusy); + RELEASE_SEMAPHORE (&pThrCtx->sThreadInfo.sIsIdle); + WAIT_SEMAPHORE (&pThrCtx->sThreadInfo.sIsActivated, WELS_DEC_THREAD_WAIT_INFINITE); + if (pThrCtx->sThreadInfo.uiCommand == WELS_DEC_THREAD_COMMAND_RUN) { + CWelsDecoder* pWelsDecoder = (CWelsDecoder*)pThrCtx->threadCtxOwner; + ConstructAccessUnit (pWelsDecoder, pThrCtx); + } else if (pThrCtx->sThreadInfo.uiCommand == WELS_DEC_THREAD_COMMAND_ABORT) { + break; + } + } + return 0; +} + CWelsDecoder::CWelsDecoder (void) - : m_pDecContext (NULL), - m_pWelsTrace (NULL), - m_iPictInfoIndex (0), - m_iMinPOC (sIMinInt32), - m_iNumOfPicts (0), - m_iLastGOPRemainPicts (0), - m_LastWrittenPOC (sIMinInt32), - m_iLargestBufferedPicIndex (0) { + : m_pWelsTrace (NULL), + m_uiDecodeTimeStamp (0), + m_bIsBaseline (false), + m_iCpuCount (1), + m_iThreadCount (0), + m_iCtxCount (1), + m_pPicBuff (NULL), + m_bParamSetsLostFlag (false), + m_bFreezeOutput (false), + m_DecCtxActiveCount (0), + m_pDecThrCtx (NULL), + m_pLastDecThrCtx (NULL), + m_iLastBufferedIdx (0) { #ifdef OUTPUT_BIT_STREAM char chFileName[1024] = { 0 }; //for .264 int iBufUsed = 0; @@ -120,11 +165,18 @@ CWelsDecoder::CWelsDecoder (void) WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry"); } - for (int32_t i = 0; i < 16; ++i) { - m_sPictInfoList[i].bLastGOP = false; - m_sPictInfoList[i].iPOC = sIMinInt32; + ResetReorderingPictureBuffers (&m_sReoderingStatus, m_sPictInfoList, true); + + m_iCpuCount = GetCPUCount(); + if (m_iCpuCount > WELS_DEC_MAX_NUM_CPU) { + m_iCpuCount = WELS_DEC_MAX_NUM_CPU; } + m_pDecThrCtx = new SWelsDecoderThreadCTX[m_iCtxCount]; + memset (m_pDecThrCtx, 0, sizeof (SWelsDecoderThreadCTX)*m_iCtxCount); + for (int32_t i = 0; i < WELS_DEC_MAX_NUM_CPU; ++i) { + m_pDecThrCtxActive[i] = NULL; + } #ifdef OUTPUT_BIT_STREAM SWelsTime sCurTime; @@ -180,7 +232,7 @@ CWelsDecoder::~CWelsDecoder() { if (m_pWelsTrace != NULL) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()"); } - + CloseDecoderThreads(); UninitDecoder(); #ifdef OUTPUT_BIT_STREAM @@ -198,6 +250,10 @@ CWelsDecoder::~CWelsDecoder() { delete m_pWelsTrace; m_pWelsTrace = NULL; } + if (m_pDecThrCtx != NULL) { + delete[] m_pDecThrCtx; + m_pDecThrCtx = NULL; + } } long CWelsDecoder::Initialize (const SDecodingParam* pParam) { @@ -226,26 +282,88 @@ long CWelsDecoder::Uninitialize() { } void CWelsDecoder::UninitDecoder (void) { - if (NULL == m_pDecContext) - return; - - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::UninitDecoder(), openh264 codec version = %s.", - VERSION_NUMBER); - - WelsEndDecoder (m_pDecContext); - - if (m_pDecContext->pMemAlign != NULL) { - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, - "CWelsDecoder::UninitDecoder(), verify memory usage (%d bytes) after free..", - m_pDecContext->pMemAlign->WelsGetMemoryUsage()); - delete m_pDecContext->pMemAlign; - m_pDecContext->pMemAlign = NULL; + for (int32_t i = 0; i < m_iCtxCount; ++i) { + if (m_pDecThrCtx[i].pCtx != NULL) { + if (i > 0) { + WelsResetRefPicWithoutUnRef (m_pDecThrCtx[i].pCtx); + } + UninitDecoderCtx (m_pDecThrCtx[i].pCtx); + } } +} - if (NULL != m_pDecContext) { - WelsFree (m_pDecContext, "m_pDecContext"); +void CWelsDecoder::OpenDecoderThreads() { + if (m_iThreadCount >= 1) { + m_uiDecodeTimeStamp = 0; + CREATE_SEMAPHORE (&m_sIsBusy, m_iThreadCount, m_iThreadCount, NULL); + WelsMutexInit (&m_csDecoder); + CREATE_EVENT (&m_sBufferingEvent, 1, 0, NULL); + SET_EVENT (&m_sBufferingEvent); + CREATE_EVENT (&m_sReleaseBufferEvent, 1, 0, NULL); + SET_EVENT (&m_sReleaseBufferEvent); + for (int32_t i = 0; i < m_iThreadCount; ++i) { + m_pDecThrCtx[i].sThreadInfo.uiThrMaxNum = m_iThreadCount; + m_pDecThrCtx[i].sThreadInfo.uiThrNum = i; + m_pDecThrCtx[i].sThreadInfo.uiThrStackSize = WELS_DEC_MAX_THREAD_STACK_SIZE; + m_pDecThrCtx[i].sThreadInfo.pThrProcMain = pThrProcFrame; + m_pDecThrCtx[i].sThreadInfo.sIsBusy = &m_sIsBusy; + m_pDecThrCtx[i].sThreadInfo.uiCommand = WELS_DEC_THREAD_COMMAND_RUN; + m_pDecThrCtx[i].threadCtxOwner = this; + m_pDecThrCtx[i].kpSrc = NULL; + m_pDecThrCtx[i].kiSrcLen = 0; + m_pDecThrCtx[i].ppDst = NULL; + m_pDecThrCtx[i].pDec = NULL; + CREATE_EVENT (&m_pDecThrCtx[i].sImageReady, 1, 0, NULL); + CREATE_EVENT (&m_pDecThrCtx[i].sSliceDecodeStart, 1, 0, NULL); + CREATE_EVENT (&m_pDecThrCtx[i].sSliceDecodeFinish, 1, 0, NULL); + CREATE_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsIdle, 0, 1, NULL); + CREATE_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsActivated, 0, 1, NULL); + CREATE_THREAD (&m_pDecThrCtx[i].sThreadInfo.sThrHandle, pThrProcInit, (void*) (& (m_pDecThrCtx[i]))); + } + } +} +void CWelsDecoder::CloseDecoderThreads() { + if (m_iThreadCount >= 1) { + for (int32_t i = 0; i < m_iThreadCount; i++) { //waiting the completion begun slices + WAIT_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsIdle, WELS_DEC_THREAD_WAIT_INFINITE); + m_pDecThrCtx[i].sThreadInfo.uiCommand = WELS_DEC_THREAD_COMMAND_ABORT; + RELEASE_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsActivated); + WAIT_THREAD (&m_pDecThrCtx[i].sThreadInfo.sThrHandle); + CLOSE_EVENT (&m_pDecThrCtx[i].sImageReady); + CLOSE_EVENT (&m_pDecThrCtx[i].sSliceDecodeStart); + CLOSE_EVENT (&m_pDecThrCtx[i].sSliceDecodeFinish); + CLOSE_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsIdle); + CLOSE_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsActivated); + } + WelsMutexDestroy (&m_csDecoder); + CLOSE_EVENT (&m_sBufferingEvent); + CLOSE_EVENT (&m_sReleaseBufferEvent); + CLOSE_SEMAPHORE (&m_sIsBusy); + } +} - m_pDecContext = NULL; +void CWelsDecoder::UninitDecoderCtx (PWelsDecoderContext& pCtx) { + if (pCtx != NULL) { + + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::UninitDecoderCtx(), openh264 codec version = %s.", + VERSION_NUMBER); + + WelsEndDecoder (pCtx); + + if (pCtx->pMemAlign != NULL) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, + "CWelsDecoder::UninitDecoder(), verify memory usage (%d bytes) after free..", + pCtx->pMemAlign->WelsGetMemoryUsage()); + delete pCtx->pMemAlign; + pCtx->pMemAlign = NULL; + } + + if (NULL != pCtx) { + WelsFree (pCtx, "m_pDecContext"); + + pCtx = NULL; + } + if (m_iCtxCount <= 1) m_pDecThrCtx[0].pCtx = NULL; } } @@ -255,49 +373,100 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d", VERSION_NUMBER, (int32_t)pParam->bParseOnly); - + if (m_iThreadCount >= 1 && pParam->bParseOnly) { + m_iThreadCount = 0; + } + OpenDecoderThreads(); //reset decoder context - if (m_pDecContext) //free - UninitDecoder(); - m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); - if (NULL == m_pDecContext) - return cmMallocMemeError; - int32_t iCacheLineSize = 16; // on chip cache line size in byte - m_pDecContext->pMemAlign = new CMemoryAlign (iCacheLineSize); - WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pMemAlign), UninitDecoder()) - - //fill in default value into context - WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx); - - //check param and update decoder context - m_pDecContext->pParam = (SDecodingParam*)m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam), - "SDecodingParam"); - WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pParam), UninitDecoder()); - int32_t iRet = DecoderConfigParam (m_pDecContext, pParam); - WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess); - - //init decoder - WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx), - UninitDecoder()) - + memset (&m_sDecoderStatistics, 0, sizeof (SDecoderStatistics)); + memset (&m_sLastDecPicInfo, 0, sizeof (SWelsLastDecPicInfo)); + memset (&m_sVlcTable, 0, sizeof (SVlcTable)); + UninitDecoder(); + WelsDecoderLastDecPicInfoDefaults (m_sLastDecPicInfo); + for (int32_t i = 0; i < m_iCtxCount; ++i) { + InitDecoderCtx (m_pDecThrCtx[i].pCtx, pParam); + if (m_iThreadCount >= 1) { + m_pDecThrCtx[i].pCtx->pThreadCtx = &m_pDecThrCtx[i]; + } + } + m_bParamSetsLostFlag = false; + m_bFreezeOutput = false; return cmResultSuccess; } -int32_t CWelsDecoder::ResetDecoder() { - // TBC: need to be modified when context and trace point are null - if (m_pDecContext != NULL && m_pWelsTrace != NULL) { - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ResetDecoder(), context error code is %d", - m_pDecContext->iErrorCode); - SDecodingParam sPrevParam; - memcpy (&sPrevParam, m_pDecContext->pParam, sizeof (SDecodingParam)); +// the return value of this function is not suitable, it need report failure info to upper layer. +int32_t CWelsDecoder::InitDecoderCtx (PWelsDecoderContext& pCtx, const SDecodingParam* pParam) { - WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, InitDecoder (&sPrevParam), UninitDecoder()); + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, + "CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d", + VERSION_NUMBER, (int32_t)pParam->bParseOnly); + + //reset decoder context + UninitDecoderCtx (pCtx); + pCtx = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); + if (NULL == pCtx) + return cmMallocMemeError; + int32_t iCacheLineSize = 16; // on chip cache line size in byte + pCtx->pMemAlign = new CMemoryAlign (iCacheLineSize); + WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == pCtx->pMemAlign), UninitDecoderCtx (pCtx)) + if (m_iCtxCount <= 1) m_pDecThrCtx[0].pCtx = pCtx; + //fill in default value into context + pCtx->pLastDecPicInfo = &m_sLastDecPicInfo; + pCtx->pDecoderStatistics = &m_sDecoderStatistics; + pCtx->pVlcTable = &m_sVlcTable; + pCtx->pPictInfoList = m_sPictInfoList; + pCtx->pPictReoderingStatus = &m_sReoderingStatus; + pCtx->pCsDecoder = &m_csDecoder; + WelsDecoderDefaults (pCtx, &m_pWelsTrace->m_sLogCtx); + WelsDecoderSpsPpsDefaults (pCtx->sSpsPpsCtx); + //check param and update decoder context + pCtx->pParam = (SDecodingParam*)pCtx->pMemAlign->WelsMallocz (sizeof (SDecodingParam), + "SDecodingParam"); + WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == pCtx->pParam), UninitDecoderCtx (pCtx)); + int32_t iRet = DecoderConfigParam (pCtx, pParam); + WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess); + + //init decoder + WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, WelsInitDecoder (pCtx, &m_pWelsTrace->m_sLogCtx), + UninitDecoderCtx (pCtx)) + pCtx->pPicBuff = NULL; + return cmResultSuccess; +} + +int32_t CWelsDecoder::ResetDecoder (PWelsDecoderContext& pCtx) { + // TBC: need to be modified when context and trace point are null + if (m_iThreadCount >= 1) { + ThreadResetDecoder (pCtx); + } else { + if (pCtx != NULL && m_pWelsTrace != NULL) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ResetDecoder(), context error code is %d", + pCtx->iErrorCode); + SDecodingParam sPrevParam; + memcpy (&sPrevParam, pCtx->pParam, sizeof (SDecodingParam)); + + WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, InitDecoderCtx (pCtx, &sPrevParam), + UninitDecoderCtx (pCtx)); + } else if (m_pWelsTrace != NULL) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null"); + } + ResetReorderingPictureBuffers (&m_sReoderingStatus, m_sPictInfoList, false); + } + return ERR_INFO_UNINIT; +} + +int32_t CWelsDecoder::ThreadResetDecoder (PWelsDecoderContext& pCtx) { + // TBC: need to be modified when context and trace point are null + SDecodingParam sPrevParam; + if (pCtx != NULL && m_pWelsTrace != NULL) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ResetDecoder(), context error code is %d", pCtx->iErrorCode); + memcpy (&sPrevParam, pCtx->pParam, sizeof (SDecodingParam)); + ResetReorderingPictureBuffers (&m_sReoderingStatus, m_sPictInfoList, true); + CloseDecoderThreads(); + UninitDecoder(); + InitDecoder (&sPrevParam); } else if (m_pWelsTrace != NULL) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null"); } -#ifdef _PICTURE_REORDERING_ - ResetReorderingPictureBuffers(); -#endif return ERR_INFO_UNINIT; } @@ -306,71 +475,100 @@ int32_t CWelsDecoder::ResetDecoder() { */ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { int iVal = 0; - - if (m_pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL && - eOptID != DECODER_OPTION_TRACE_CALLBACK && eOptID != DECODER_OPTION_TRACE_CALLBACK_CONTEXT) - return dsInitialOptExpected; - if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded - if (pOption == NULL) - return cmInitParaError; - - iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag - - m_pDecContext->bEndOfStreamFlag = iVal ? true : false; - - return cmResultSuccess; - } else if (eOptID == DECODER_OPTION_ERROR_CON_IDC) { // Indicate error concealment status - if (pOption == NULL) - return cmInitParaError; - - iVal = * ((int*)pOption); // int value for error concealment idc - iVal = WELS_CLIP3 (iVal, (int32_t)ERROR_CON_DISABLE, (int32_t)ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE); - if ((m_pDecContext->pParam->bParseOnly) && (iVal != (int32_t)ERROR_CON_DISABLE)) { - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, - "CWelsDecoder::SetOption for ERROR_CON_IDC = %d not allowd for parse only!.", iVal); - return cmInitParaError; - } - - m_pDecContext->pParam->eEcActiveIdc = (ERROR_CON_IDC)iVal; - InitErrorCon (m_pDecContext); - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, - "CWelsDecoder::SetOption for ERROR_CON_IDC = %d.", iVal); - - return cmResultSuccess; - } else if (eOptID == DECODER_OPTION_TRACE_LEVEL) { - if (m_pWelsTrace) { - uint32_t level = * ((uint32_t*)pOption); - m_pWelsTrace->SetTraceLevel (level); + if (eOptID == DECODER_OPTION_NUM_OF_THREADS) { + if (pOption != NULL) { + int32_t threadCount = * ((int32_t*)pOption); + if (threadCount < 0) threadCount = 0; + if (threadCount > m_iCpuCount) { + threadCount = m_iCpuCount; + } + if (threadCount > 3) { + threadCount = 3; + } + if (threadCount != m_iThreadCount) { + m_iThreadCount = threadCount; + if (m_pDecThrCtx != NULL) { + delete [] m_pDecThrCtx; + m_iCtxCount = m_iThreadCount == 0 ? 1 : m_iThreadCount; + m_pDecThrCtx = new SWelsDecoderThreadCTX[m_iCtxCount]; + memset (m_pDecThrCtx, 0, sizeof (SWelsDecoderThreadCTX)*m_iCtxCount); + } + } } return cmResultSuccess; - } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK) { - if (m_pWelsTrace) { - WelsTraceCallback callback = * ((WelsTraceCallback*)pOption); - m_pWelsTrace->SetTraceCallback (callback); - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, - "CWelsDecoder::SetOption():DECODER_OPTION_TRACE_CALLBACK callback = %p.", - callback); - } - return cmResultSuccess; - } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK_CONTEXT) { - if (m_pWelsTrace) { - void* ctx = * ((void**)pOption); - m_pWelsTrace->SetTraceCallbackContext (ctx); - } - return cmResultSuccess; - } else if (eOptID == DECODER_OPTION_GET_STATISTICS) { - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, - "CWelsDecoder::SetOption():DECODER_OPTION_GET_STATISTICS: this option is get-only!"); - return cmInitParaError; - } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) { - if (pOption) { - m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption)); + } + for (int32_t i = 0; i < m_iCtxCount; ++i) { + PWelsDecoderContext pDecContext = m_pDecThrCtx[i].pCtx; + if (pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL && + eOptID != DECODER_OPTION_TRACE_CALLBACK && eOptID != DECODER_OPTION_TRACE_CALLBACK_CONTEXT) + return dsInitialOptExpected; + if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded + if (pOption == NULL) + return cmInitParaError; + + iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag + + if (pDecContext == NULL) return dsInitialOptExpected; + + pDecContext->bEndOfStreamFlag = iVal ? true : false; + return cmResultSuccess; + } else if (eOptID == DECODER_OPTION_ERROR_CON_IDC) { // Indicate error concealment status + if (pOption == NULL) + return cmInitParaError; + + if (pDecContext == NULL) return dsInitialOptExpected; + + iVal = * ((int*)pOption); // int value for error concealment idc + iVal = WELS_CLIP3 (iVal, (int32_t)ERROR_CON_DISABLE, (int32_t)ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE); + if ((pDecContext->pParam->bParseOnly) && (iVal != (int32_t)ERROR_CON_DISABLE)) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, + "CWelsDecoder::SetOption for ERROR_CON_IDC = %d not allowd for parse only!.", iVal); + return cmInitParaError; + } + + pDecContext->pParam->eEcActiveIdc = (ERROR_CON_IDC)iVal; + InitErrorCon (pDecContext); + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, + "CWelsDecoder::SetOption for ERROR_CON_IDC = %d.", iVal); + + return cmResultSuccess; + } else if (eOptID == DECODER_OPTION_TRACE_LEVEL) { + if (m_pWelsTrace) { + uint32_t level = * ((uint32_t*)pOption); + m_pWelsTrace->SetTraceLevel (level); + } + return cmResultSuccess; + } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK) { + if (m_pWelsTrace) { + WelsTraceCallback callback = * ((WelsTraceCallback*)pOption); + m_pWelsTrace->SetTraceCallback (callback); + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, + "CWelsDecoder::SetOption():DECODER_OPTION_TRACE_CALLBACK callback = %p.", + callback); + } + return cmResultSuccess; + } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK_CONTEXT) { + if (m_pWelsTrace) { + void* ctx = * ((void**)pOption); + m_pWelsTrace->SetTraceCallbackContext (ctx); + } + return cmResultSuccess; + } else if (eOptID == DECODER_OPTION_GET_STATISTICS) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, + "CWelsDecoder::SetOption():DECODER_OPTION_GET_STATISTICS: this option is get-only!"); + return cmInitParaError; + } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) { + if (pOption) { + if (pDecContext == NULL) return dsInitialOptExpected; + pDecContext->pDecoderStatistics->iStatisticsLogInterval = (* ((unsigned int*)pOption)); + return cmResultSuccess; + } + } else if (eOptID == DECODER_OPTION_GET_SAR_INFO) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, + "CWelsDecoder::SetOption():DECODER_OPTION_GET_SAR_INFO: this option is get-only!"); + return cmInitParaError; } - } else if (eOptID == DECODER_OPTION_GET_SAR_INFO) { - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, - "CWelsDecoder::SetOption():DECODER_OPTION_GET_SAR_INFO: this option is get-only!"); - return cmInitParaError; } return cmInitParaError; } @@ -380,105 +578,109 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { */ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) { int iVal = 0; - - if (m_pDecContext == NULL) + if (DECODER_OPTION_NUM_OF_THREADS == eOptID) { + * ((int*)pOption) = m_iThreadCount; + return cmResultSuccess; + } + PWelsDecoderContext pDecContext = m_pDecThrCtx[0].pCtx; + if (pDecContext == NULL) return cmInitExpected; if (pOption == NULL) return cmInitParaError; if (DECODER_OPTION_END_OF_STREAM == eOptID) { - iVal = m_pDecContext->bEndOfStreamFlag; + iVal = pDecContext->bEndOfStreamFlag; * ((int*)pOption) = iVal; return cmResultSuccess; } #ifdef LONG_TERM_REF else if (DECODER_OPTION_IDR_PIC_ID == eOptID) { - iVal = m_pDecContext->uiCurIdrPicId; + iVal = pDecContext->uiCurIdrPicId; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_FRAME_NUM == eOptID) { - iVal = m_pDecContext->iFrameNum; + iVal = pDecContext->iFrameNum; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_LTR_MARKING_FLAG == eOptID) { - iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag; + iVal = pDecContext->bCurAuContainLtrMarkSeFlag; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID) { - iVal = m_pDecContext->iFrameNumOfAuMarkedLtr; + iVal = pDecContext->iFrameNumOfAuMarkedLtr; * ((int*)pOption) = iVal; return cmResultSuccess; } #endif else if (DECODER_OPTION_VCL_NAL == eOptID) { //feedback whether or not have VCL NAL in current AU - iVal = m_pDecContext->iFeedbackVclNalInAu; + iVal = pDecContext->iFeedbackVclNalInAu; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_TEMPORAL_ID == eOptID) { //if have VCL NAL in current AU, then feedback the temporal ID - iVal = m_pDecContext->iFeedbackTidInAu; + iVal = pDecContext->iFeedbackTidInAu; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_IS_REF_PIC == eOptID) { - iVal = m_pDecContext->iFeedbackNalRefIdc; + iVal = pDecContext->iFeedbackNalRefIdc; if (iVal > 0) iVal = 1; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_ERROR_CON_IDC == eOptID) { - iVal = (int)m_pDecContext->pParam->eEcActiveIdc; + iVal = (int)pDecContext->pParam->eEcActiveIdc; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_GET_STATISTICS == eOptID) { // get decoder statistics info for real time debugging SDecoderStatistics* pDecoderStatistics = (static_cast (pOption)); - memcpy (pDecoderStatistics, &m_pDecContext->sDecoderStatistics, sizeof (SDecoderStatistics)); + memcpy (pDecoderStatistics, pDecContext->pDecoderStatistics, sizeof (SDecoderStatistics)); - if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount != 0) { //not original status - pDecoderStatistics->fAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) / - (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount); - pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) / - (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount + m_pDecContext->sDecoderStatistics.uiFreezingIDRNum + - m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum); + if (pDecContext->pDecoderStatistics->uiDecodedFrameCount != 0) { //not original status + pDecoderStatistics->fAverageFrameSpeedInMs = (float) (pDecContext->dDecTime) / + (pDecContext->pDecoderStatistics->uiDecodedFrameCount); + pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (pDecContext->dDecTime) / + (pDecContext->pDecoderStatistics->uiDecodedFrameCount + pDecContext->pDecoderStatistics->uiFreezingIDRNum + + pDecContext->pDecoderStatistics->uiFreezingNonIDRNum); } return cmResultSuccess; } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) { if (pOption) { - iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval; + iVal = pDecContext->pDecoderStatistics->iStatisticsLogInterval; * ((unsigned int*)pOption) = iVal; return cmResultSuccess; } } else if (DECODER_OPTION_GET_SAR_INFO == eOptID) { //get decoder SAR info in VUI PVuiSarInfo pVuiSarInfo = (static_cast (pOption)); memset (pVuiSarInfo, 0, sizeof (SVuiSarInfo)); - if (!m_pDecContext->pSps) { + if (!pDecContext->pSps) { return cmInitExpected; } else { - pVuiSarInfo->uiSarWidth = m_pDecContext->pSps->sVui.uiSarWidth; - pVuiSarInfo->uiSarHeight = m_pDecContext->pSps->sVui.uiSarHeight; - pVuiSarInfo->bOverscanAppropriateFlag = m_pDecContext->pSps->sVui.bOverscanAppropriateFlag; + pVuiSarInfo->uiSarWidth = pDecContext->pSps->sVui.uiSarWidth; + pVuiSarInfo->uiSarHeight = pDecContext->pSps->sVui.uiSarHeight; + pVuiSarInfo->bOverscanAppropriateFlag = pDecContext->pSps->sVui.bOverscanAppropriateFlag; return cmResultSuccess; } } else if (DECODER_OPTION_PROFILE == eOptID) { - if (!m_pDecContext->pSps) { + if (!pDecContext->pSps) { return cmInitExpected; } - iVal = (int)m_pDecContext->pSps->uiProfileIdc; + iVal = (int)pDecContext->pSps->uiProfileIdc; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_LEVEL == eOptID) { - if (!m_pDecContext->pSps) { + if (!pDecContext->pSps) { return cmInitExpected; } - iVal = (int)m_pDecContext->pSps->uiLevelIdc; + iVal = (int)pDecContext->pSps->uiLevelIdc; * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER == eOptID) { - if (m_pDecContext->pSps && m_pDecContext->pSps->uiProfileIdc != 66) { - * ((int*)pOption) = m_iNumOfPicts > 0 ? m_iNumOfPicts : 0; - } else { - * ((int*)pOption) = 0; + for (int32_t activeThread = 0; activeThread < m_DecCtxActiveCount; ++activeThread) { + WAIT_SEMAPHORE (&m_pDecThrCtxActive[activeThread]->sThreadInfo.sIsIdle, WELS_DEC_THREAD_WAIT_INFINITE); + RELEASE_SEMAPHORE (&m_pDecThrCtxActive[activeThread]->sThreadInfo.sIsIdle); } + * ((int*)pOption) = m_sReoderingStatus.iNumOfPicts; return cmResultSuccess; } @@ -489,7 +691,17 @@ DECODING_STATE CWelsDecoder::DecodeFrameNoDelay (const unsigned char* kpSrc, const int kiSrcLen, unsigned char** ppDst, SBufferInfo* pDstInfo) { - int iRet; + int iRet = dsErrorFree; + if (m_iThreadCount >= 1) { + iRet = ThreadDecodeFrameInternal (kpSrc, kiSrcLen, ppDst, pDstInfo); + if (m_sReoderingStatus.iNumOfPicts) { + WAIT_EVENT (&m_sBufferingEvent, WELS_DEC_THREAD_WAIT_INFINITE); + RESET_EVENT (&m_sReleaseBufferEvent); + ReleaseBufferedReadyPicture (NULL, ppDst, pDstInfo); + SET_EVENT (&m_sReleaseBufferEvent); + } + return (DECODING_STATE)iRet; + } //SBufferInfo sTmpBufferInfo; //unsigned char* ppTmpDst[3] = {NULL, NULL, NULL}; iRet = (int)DecodeFrame2 (kpSrc, kiSrcLen, ppDst, pDstInfo); @@ -507,24 +719,24 @@ DECODING_STATE CWelsDecoder::DecodeFrameNoDelay (const unsigned char* kpSrc, return (DECODING_STATE)iRet; } -DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, +DECODING_STATE CWelsDecoder::DecodeFrame2WithCtx (PWelsDecoderContext pDecContext, const unsigned char* kpSrc, const int kiSrcLen, unsigned char** ppDst, SBufferInfo* pDstInfo) { - if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) { + if (pDecContext == NULL || pDecContext->pParam == NULL) { if (m_pWelsTrace != NULL) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeFrame2 without Initialize.\n"); } return dsInitialOptExpected; } - if (m_pDecContext->pParam->bParseOnly) { + if (pDecContext->pParam->bParseOnly) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be false for this API calling! \n"); - m_pDecContext->iErrorCode |= dsInvalidArgument; + pDecContext->iErrorCode |= dsInvalidArgument; return dsInvalidArgument; } - if (CheckBsBuffer (m_pDecContext, kiSrcLen)) { - if (ResetDecoder()) + if (CheckBsBuffer (pDecContext, kiSrcLen)) { + if (ResetDecoder (pDecContext)) return dsOutOfMemory; return dsErrorFree; @@ -540,177 +752,243 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, WelsFflush (m_pFBSSize); } #endif//OUTPUT_BIT_STREAM - m_pDecContext->bEndOfStreamFlag = false; + pDecContext->bEndOfStreamFlag = false; + if (GetThreadCount (pDecContext) <= 0) { + pDecContext->uiDecodingTimeStamp = ++m_uiDecodeTimeStamp; + } } else { //For application MODE, the error detection should be added for safe. //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL. - m_pDecContext->bEndOfStreamFlag = true; - m_pDecContext->bInstantDecFlag = true; + pDecContext->bEndOfStreamFlag = true; + pDecContext->bInstantDecFlag = true; } int64_t iStart, iEnd; iStart = WelsTime(); - ppDst[0] = ppDst[1] = ppDst[2] = NULL; - m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding. - m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize + if (GetThreadCount (pDecContext) <= 1) { + ppDst[0] = ppDst[1] = ppDst[2] = NULL; + } + pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding. + pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize unsigned long long uiInBsTimeStamp = pDstInfo->uiInBsTimeStamp; - memset (pDstInfo, 0, sizeof (SBufferInfo)); + if (GetThreadCount (pDecContext) <= 1) { + memset (pDstInfo, 0, sizeof (SBufferInfo)); + } pDstInfo->uiInBsTimeStamp = uiInBsTimeStamp; #ifdef LONG_TERM_REF - m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR - m_pDecContext->bCurAuContainLtrMarkSeFlag = false; - m_pDecContext->iFrameNumOfAuMarkedLtr = 0; - m_pDecContext->iFrameNum = -1; //initialize + pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR + pDecContext->bCurAuContainLtrMarkSeFlag = false; + pDecContext->iFrameNumOfAuMarkedLtr = 0; + pDecContext->iFrameNum = -1; //initialize #endif - m_pDecContext->iFeedbackTidInAu = -1; //initialize - m_pDecContext->iFeedbackNalRefIdc = -1; //initialize + pDecContext->iFeedbackTidInAu = -1; //initialize + pDecContext->iFeedbackNalRefIdc = -1; //initialize if (pDstInfo) { pDstInfo->uiOutYuvTimeStamp = 0; - m_pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp; + pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp; } else { - m_pDecContext->uiTimeStamp = 0; + pDecContext->uiTimeStamp = 0; } - WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, ppDst, + WelsDecodeBs (pDecContext, kpSrc, kiSrcLen, ppDst, pDstInfo, NULL); //iErrorCode has been modified in this function - m_pDecContext->bInstantDecFlag = false; //reset no-delay flag - if (m_pDecContext->iErrorCode) { + pDecContext->bInstantDecFlag = false; //reset no-delay flag + if (pDecContext->iErrorCode) { EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently - eNalType = m_pDecContext->sCurNalHead.eNalUnitType; - if (m_pDecContext->iErrorCode & dsOutOfMemory) { - if (ResetDecoder()) { + eNalType = pDecContext->sCurNalHead.eNalUnitType; + if (pDecContext->iErrorCode & dsOutOfMemory) { + if (ResetDecoder (pDecContext)) { return dsOutOfMemory; } return dsErrorFree; } - if (m_pDecContext->iErrorCode & dsRefListNullPtrs) { - if (ResetDecoder()) { + if (pDecContext->iErrorCode & dsRefListNullPtrs) { + if (ResetDecoder (pDecContext)) { return dsRefListNullPtrs; } return dsErrorFree; } - if ((m_pDecContext->iErrorCode & (dsBitstreamError | dsDataErrorConcealed)) && m_pDecContext->eSliceType == B_SLICE) { - if (ResetDecoder()) { + if ((pDecContext->iErrorCode & (dsBitstreamError | dsDataErrorConcealed)) && pDecContext->eSliceType == B_SLICE) { + if (ResetDecoder (pDecContext)) { pDstInfo->iBufferStatus = 0; - return (DECODING_STATE)m_pDecContext->iErrorCode; + return (DECODING_STATE)pDecContext->iErrorCode; } return dsErrorFree; } //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss. if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) || - (VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType)) { - if (m_pDecContext->pParam->eEcActiveIdc == ERROR_CON_DISABLE) { + (VIDEO_BITSTREAM_AVC == pDecContext->eVideoType)) { + if (pDecContext->pParam->eEcActiveIdc == ERROR_CON_DISABLE) { #ifdef LONG_TERM_REF - m_pDecContext->bParamSetsLostFlag = true; + pDecContext->bParamSetsLostFlag = true; #else - m_pDecContext->bReferenceLostAtT0Flag = true; + pDecContext->bReferenceLostAtT0Flag = true; #endif } } - if (m_pDecContext->bPrintFrameErrorTraceFlag) { + if (pDecContext->bPrintFrameErrorTraceFlag) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n", - m_pDecContext->iErrorCode); - m_pDecContext->bPrintFrameErrorTraceFlag = false; + pDecContext->iErrorCode); + pDecContext->bPrintFrameErrorTraceFlag = false; } else { - m_pDecContext->iIgnoredErrorInfoPacketCount++; - if (m_pDecContext->iIgnoredErrorInfoPacketCount == INT_MAX) { + pDecContext->iIgnoredErrorInfoPacketCount++; + if (pDecContext->iIgnoredErrorInfoPacketCount == INT_MAX) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "continuous error reached INT_MAX! Restart as 0."); - m_pDecContext->iIgnoredErrorInfoPacketCount = 0; + pDecContext->iIgnoredErrorInfoPacketCount = 0; } } - if ((m_pDecContext->pParam->eEcActiveIdc != ERROR_CON_DISABLE) && (pDstInfo->iBufferStatus == 1)) { + if ((pDecContext->pParam->eEcActiveIdc != ERROR_CON_DISABLE) && (pDstInfo->iBufferStatus == 1)) { //TODO after dec status updated - m_pDecContext->iErrorCode |= dsDataErrorConcealed; + pDecContext->iErrorCode |= dsDataErrorConcealed; - m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; - if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t - ResetDecStatNums (&m_pDecContext->sDecoderStatistics); - m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; + pDecContext->pDecoderStatistics->uiDecodedFrameCount++; + if (pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t + ResetDecStatNums (pDecContext->pDecoderStatistics); + pDecContext->pDecoderStatistics->uiDecodedFrameCount++; } - int32_t iMbConcealedNum = m_pDecContext->iMbEcedNum + m_pDecContext->iMbEcedPropNum; - m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->iMbNum == 0 ? - (m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : (( - m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + (( - iMbConcealedNum * 100) / m_pDecContext->iMbNum)); - m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ? - (m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : (( - m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + (( - m_pDecContext->iMbEcedPropNum * 100) / m_pDecContext->iMbNum)); - m_pDecContext->sDecoderStatistics.uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1); - m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 : - m_pDecContext->sDecoderStatistics.uiAvgEcRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum; - m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 : - m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum; + int32_t iMbConcealedNum = pDecContext->iMbEcedNum + pDecContext->iMbEcedPropNum; + pDecContext->pDecoderStatistics->uiAvgEcRatio = pDecContext->iMbNum == 0 ? + (pDecContext->pDecoderStatistics->uiAvgEcRatio * pDecContext->pDecoderStatistics->uiEcFrameNum) : (( + pDecContext->pDecoderStatistics->uiAvgEcRatio * pDecContext->pDecoderStatistics->uiEcFrameNum) + (( + iMbConcealedNum * 100) / pDecContext->iMbNum)); + pDecContext->pDecoderStatistics->uiAvgEcPropRatio = pDecContext->iMbNum == 0 ? + (pDecContext->pDecoderStatistics->uiAvgEcPropRatio * pDecContext->pDecoderStatistics->uiEcFrameNum) : (( + pDecContext->pDecoderStatistics->uiAvgEcPropRatio * pDecContext->pDecoderStatistics->uiEcFrameNum) + (( + pDecContext->iMbEcedPropNum * 100) / pDecContext->iMbNum)); + pDecContext->pDecoderStatistics->uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1); + pDecContext->pDecoderStatistics->uiAvgEcRatio = pDecContext->pDecoderStatistics->uiEcFrameNum == 0 ? 0 : + pDecContext->pDecoderStatistics->uiAvgEcRatio / pDecContext->pDecoderStatistics->uiEcFrameNum; + pDecContext->pDecoderStatistics->uiAvgEcPropRatio = pDecContext->pDecoderStatistics->uiEcFrameNum == 0 ? 0 : + pDecContext->pDecoderStatistics->uiAvgEcPropRatio / pDecContext->pDecoderStatistics->uiEcFrameNum; } iEnd = WelsTime(); - m_pDecContext->dDecTime += (iEnd - iStart) / 1e3; + pDecContext->dDecTime += (iEnd - iStart) / 1e3; - OutputStatisticsLog (m_pDecContext->sDecoderStatistics); + OutputStatisticsLog (*pDecContext->pDecoderStatistics); -#ifdef _PICTURE_REORDERING_ - ReorderPicturesInDisplay (ppDst, pDstInfo); -#endif + if (GetThreadCount (pDecContext) >= 1) { + WAIT_EVENT (&m_sReleaseBufferEvent, WELS_DEC_THREAD_WAIT_INFINITE); + RESET_EVENT (&m_sBufferingEvent); + BufferingReadyPicture (pDecContext, ppDst, pDstInfo); + SET_EVENT (&m_sBufferingEvent); + } else { + ReorderPicturesInDisplay (pDecContext, ppDst, pDstInfo); + } - return (DECODING_STATE)m_pDecContext->iErrorCode; + return (DECODING_STATE)pDecContext->iErrorCode; } // else Error free, the current codec works well if (pDstInfo->iBufferStatus == 1) { - m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; - if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t - ResetDecStatNums (&m_pDecContext->sDecoderStatistics); - m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; + pDecContext->pDecoderStatistics->uiDecodedFrameCount++; + if (pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t + ResetDecStatNums (pDecContext->pDecoderStatistics); + pDecContext->pDecoderStatistics->uiDecodedFrameCount++; } - OutputStatisticsLog (m_pDecContext->sDecoderStatistics); + OutputStatisticsLog (*pDecContext->pDecoderStatistics); } iEnd = WelsTime(); - m_pDecContext->dDecTime += (iEnd - iStart) / 1e3; + pDecContext->dDecTime += (iEnd - iStart) / 1e3; -#ifdef _PICTURE_REORDERING_ - ReorderPicturesInDisplay (ppDst, pDstInfo); -#endif + if (GetThreadCount (pDecContext) >= 1) { + WAIT_EVENT (&m_sReleaseBufferEvent, WELS_DEC_THREAD_WAIT_INFINITE); + RESET_EVENT (&m_sBufferingEvent); + BufferingReadyPicture (pDecContext, ppDst, pDstInfo); + SET_EVENT (&m_sBufferingEvent); + } else { + ReorderPicturesInDisplay (pDecContext, ppDst, pDstInfo); + } return dsErrorFree; } +DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, + const int kiSrcLen, + unsigned char** ppDst, + SBufferInfo* pDstInfo) { + PWelsDecoderContext pDecContext = m_pDecThrCtx[0].pCtx; + return DecodeFrame2WithCtx (pDecContext, kpSrc, kiSrcLen, ppDst, pDstInfo); +} + DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst, SBufferInfo* pDstInfo) { - if (m_pDecContext->bEndOfStreamFlag && m_iNumOfPicts > 0) { - m_iMinPOC = sIMinInt32; - for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { - if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) { - m_iMinPOC = m_sPictInfoList[i].iPOC; - m_iPictInfoIndex = i; - } - if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) { - m_iMinPOC = m_sPictInfoList[i].iPOC; - m_iPictInfoIndex = i; + bool bEndOfStreamFlag = true; + if (m_iThreadCount <= 1) { + for (int32_t j = 0; j < m_iCtxCount; ++j) { + if (!m_pDecThrCtx[j].pCtx->bEndOfStreamFlag) { + bEndOfStreamFlag = false; } } } - if (m_iMinPOC > sIMinInt32) { - m_LastWrittenPOC = m_iMinPOC; + if (bEndOfStreamFlag && m_sReoderingStatus.iNumOfPicts > 0) { + m_sReoderingStatus.iMinPOC = IMinInt32; + if (m_bIsBaseline) { + uint32_t uiDecodingTimeStamp = 0; + int32_t firstValidIdx = -1; + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (m_sPictInfoList[i].iPOC > IMinInt32) { + uiDecodingTimeStamp = m_sPictInfoList[i].uiDecodingTimeStamp; + m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; + m_sReoderingStatus.iPictInfoIndex = i; + firstValidIdx = i; + break; + } + } + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (i == firstValidIdx) continue; + if (m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].uiDecodingTimeStamp < uiDecodingTimeStamp) { + uiDecodingTimeStamp = m_sPictInfoList[i].uiDecodingTimeStamp; + m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; + m_sReoderingStatus.iPictInfoIndex = i; + } + } + } else { + int32_t firstValidIdx = -1; + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (m_sReoderingStatus.iMinPOC == IMinInt32 && m_sPictInfoList[i].iPOC > IMinInt32) { + m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; + m_sReoderingStatus.iPictInfoIndex = i; + firstValidIdx = i; + break; + } + } + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (i == firstValidIdx) continue; + if (m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].iPOC < m_sReoderingStatus.iMinPOC) { + m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; + m_sReoderingStatus.iPictInfoIndex = i; + } + } + } + } + if (m_sReoderingStatus.iMinPOC > IMinInt32) { + m_sReoderingStatus.iLastWrittenPOC = m_sReoderingStatus.iMinPOC; #if defined (_DEBUG) #ifdef _MOTION_VECTOR_DUMP_ - fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC); + fprintf (stderr, "Output POC: #%d uiDecodingTimeStamp=%d\n", m_sReoderingStatus.iLastWrittenPOC, + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].uiDecodingTimeStamp); #endif #endif - memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); - ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0]; - ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1]; - ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2]; - m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32; - if (m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) - m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; - m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false; - m_iMinPOC = sIMinInt32; - --m_iNumOfPicts; + memcpy (pDstInfo, &m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); + ppDst[0] = pDstInfo->pDst[0]; + ppDst[1] = pDstInfo->pDst[1]; + ppDst[2] = pDstInfo->pDst[2]; + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32; + PPicBuff pPicBuff = m_iThreadCount <= 1 ? m_pDecThrCtx[0].pCtx->pPicBuff : m_pPicBuff; + if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx < pPicBuff->iCapacity) { + PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]; + --pPic->iRefCount; + } + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false; + m_sReoderingStatus.iMinPOC = IMinInt32; + --m_sReoderingStatus.iNumOfPicts; } + return dsErrorFree; } @@ -759,157 +1037,223 @@ void CWelsDecoder::OutputStatisticsLog (SDecoderStatistics& sDecoderStatistics) } } -DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SBufferInfo* pDstInfo) { - DECODING_STATE iRet = dsErrorFree; - if (pDstInfo->iBufferStatus == 1 && m_pDecContext->pSps->uiProfileIdc != 66 - && m_pDecContext->pSps->uiProfileIdc != 83) { - /*if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) { - m_LastWrittenPOC = 0; - return dsErrorFree; - } - if (m_iNumOfPicts == 0 && m_pDecContext->pPreviousDecodedPictureInDpb->bNewSeqBegin - && m_pDecContext->eSliceType != I_SLICE) { - m_LastWrittenPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb; - return dsErrorFree; - }*/ - if (m_iNumOfPicts && m_pDecContext->pPreviousDecodedPictureInDpb - && m_pDecContext->pPreviousDecodedPictureInDpb->bNewSeqBegin) { - m_iLastGOPRemainPicts = m_iNumOfPicts; - for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { - if (m_sPictInfoList[i].iPOC > sIMinInt32) { +void CWelsDecoder::BufferingReadyPicture (PWelsDecoderContext pCtx, unsigned char** ppDst, + SBufferInfo* pDstInfo) { + if (pDstInfo->iBufferStatus == 0) { + return; + } + m_bIsBaseline = pCtx->pSps->uiProfileIdc == 66 || pCtx->pSps->uiProfileIdc == 83; + if (!m_bIsBaseline) { + if (m_sReoderingStatus.iNumOfPicts && pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb + && pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin) { + m_sReoderingStatus.iLastGOPRemainPicts = m_sReoderingStatus.iNumOfPicts; + + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (m_sPictInfoList[i].iPOC > IMinInt32) { m_sPictInfoList[i].bLastGOP = true; } } } else { - if (m_iNumOfPicts > 0) { + if (m_sReoderingStatus.iNumOfPicts > 0) { //This can happen when decoder moves to next GOP without being able to decoder first picture PicOrderCntLsb = 0 bool hasGOPChanged = false; - for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { - if (m_sPictInfoList[i].iPOC == m_pDecContext->pSliceHeader->iPicOrderCntLsb) { + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (m_sPictInfoList[i].iPOC == pCtx->pSliceHeader->iPicOrderCntLsb) { hasGOPChanged = true; break; } } if (hasGOPChanged) { - m_iLastGOPRemainPicts = m_iNumOfPicts; - for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { - if (m_sPictInfoList[i].iPOC > sIMinInt32) { + m_sReoderingStatus.iLastGOPRemainPicts = m_sReoderingStatus.iNumOfPicts; + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (m_sPictInfoList[i].iPOC > IMinInt32) { m_sPictInfoList[i].bLastGOP = true; } } } } } - for (int32_t i = 0; i < 16; ++i) { - if (m_sPictInfoList[i].iPOC == sIMinInt32) { - memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo)); - m_sPictInfoList[i].pData[0] = ppDst[0]; - m_sPictInfoList[i].pData[1] = ppDst[1]; - m_sPictInfoList[i].pData[2] = ppDst[2]; - m_sPictInfoList[i].iPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb; - m_sPictInfoList[i].iPicBuffIdx = m_pDecContext->pPicBuff->iCurrentIdx; - m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[i].iPicBuffIdx]->bAvailableFlag = false; - m_sPictInfoList[i].bLastGOP = false; - pDstInfo->iBufferStatus = 0; - ++m_iNumOfPicts; - if (i > m_iLargestBufferedPicIndex) { - m_iLargestBufferedPicIndex = i; - } + } + for (int32_t i = 0; i < 16; ++i) { + if (m_sPictInfoList[i].iPOC == IMinInt32) { + memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo)); + m_sPictInfoList[i].iPOC = pCtx->pSliceHeader->iPicOrderCntLsb; + m_sPictInfoList[i].uiDecodingTimeStamp = pCtx->uiDecodingTimeStamp; + m_sPictInfoList[i].iPicBuffIdx = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iPicBuffIdx; + if (GetThreadCount (pCtx) <= 1) ++pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iRefCount; + m_sPictInfoList[i].bLastGOP = false; + m_iLastBufferedIdx = i; + pDstInfo->iBufferStatus = 0; + ++m_sReoderingStatus.iNumOfPicts; + if (i > m_sReoderingStatus.iLargestBufferedPicIndex) { + m_sReoderingStatus.iLargestBufferedPicIndex = i; + } + break; + } + } +} + +void CWelsDecoder::ReleaseBufferedReadyPicture (PWelsDecoderContext pCtx, unsigned char** ppDst, + SBufferInfo* pDstInfo) { + PPicBuff pPicBuff = pCtx ? pCtx->pPicBuff : m_pPicBuff; + if (pCtx == NULL && m_iThreadCount <= 1) { + pCtx = m_pDecThrCtx[0].pCtx; + } + if (!m_bIsBaseline && m_sReoderingStatus.iLastGOPRemainPicts > 0) { + m_sReoderingStatus.iMinPOC = IMinInt32; + int32_t firstValidIdx = -1; + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (m_sReoderingStatus.iMinPOC == IMinInt32 && m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].bLastGOP) { + m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; + m_sReoderingStatus.iPictInfoIndex = i; + firstValidIdx = i; break; } } - if (m_iLastGOPRemainPicts > 0) { - m_iMinPOC = sIMinInt32; - for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { - if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].bLastGOP) { - m_iMinPOC = m_sPictInfoList[i].iPOC; - m_iPictInfoIndex = i; - } - if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC && m_sPictInfoList[i].bLastGOP) { - m_iMinPOC = m_sPictInfoList[i].iPOC; - m_iPictInfoIndex = i; - } - } - m_LastWrittenPOC = m_iMinPOC; -#if defined (_DEBUG) -#ifdef _MOTION_VECTOR_DUMP_ - fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC); -#endif -#endif - memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); - ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0]; - ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1]; - ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2]; - m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32; - if (m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) - m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; - m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false; - m_iMinPOC = sIMinInt32; - --m_iNumOfPicts; - --m_iLastGOPRemainPicts; - if (m_iLastGOPRemainPicts == 0) { - m_LastWrittenPOC = sIMinInt32; - } - return iRet; - } - if (m_iNumOfPicts > 0) { - m_iMinPOC = sIMinInt32; - for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { - if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) { - m_iMinPOC = m_sPictInfoList[i].iPOC; - m_iPictInfoIndex = i; - } - if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) { - m_iMinPOC = m_sPictInfoList[i].iPOC; - m_iPictInfoIndex = i; - } + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (i == firstValidIdx) continue; + if (m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].iPOC < m_sReoderingStatus.iMinPOC + && m_sPictInfoList[i].bLastGOP) { + m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; + m_sReoderingStatus.iPictInfoIndex = i; } } - if (m_iMinPOC > sIMinInt32) { - if ((m_LastWrittenPOC > sIMinInt32 && m_iMinPOC - m_LastWrittenPOC <= 1) - || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) { - m_LastWrittenPOC = m_iMinPOC; + m_sReoderingStatus.iLastWrittenPOC = m_sReoderingStatus.iMinPOC; #if defined (_DEBUG) #ifdef _MOTION_VECTOR_DUMP_ - fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC); + fprintf (stderr, "Output POC: #%d uiDecodingTimeStamp=%d\n", m_sReoderingStatus.iLastWrittenPOC, + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].uiDecodingTimeStamp); #endif #endif - memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); - ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0]; - ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1]; - ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2]; - m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32; - if (m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) - m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; - m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false; - m_iMinPOC = sIMinInt32; - --m_iNumOfPicts; - return iRet; + memcpy (pDstInfo, &m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); + ppDst[0] = pDstInfo->pDst[0]; + ppDst[1] = pDstInfo->pDst[1]; + ppDst[2] = pDstInfo->pDst[2]; + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32; + PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]; + --pPic->iRefCount; + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false; + m_sReoderingStatus.iMinPOC = IMinInt32; + --m_sReoderingStatus.iNumOfPicts; + --m_sReoderingStatus.iLastGOPRemainPicts; + if (m_sReoderingStatus.iLastGOPRemainPicts == 0) { + m_sReoderingStatus.iLastWrittenPOC = IMinInt32; + } + return; + } + if (m_sReoderingStatus.iNumOfPicts && m_bIsBaseline) { + uint32_t uiDecodingTimeStamp = 0; + int32_t firstValidIdx = -1; + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (m_sPictInfoList[i].iPOC > IMinInt32) { + uiDecodingTimeStamp = m_sPictInfoList[i].uiDecodingTimeStamp; + m_sReoderingStatus.iPictInfoIndex = i; + firstValidIdx = i; + break; + } + } + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (i == firstValidIdx) continue; + if (m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].uiDecodingTimeStamp < uiDecodingTimeStamp) { + uiDecodingTimeStamp = m_sPictInfoList[i].uiDecodingTimeStamp; + m_sReoderingStatus.iPictInfoIndex = i; + } + } + if (uiDecodingTimeStamp > 0) { +#if defined (_DEBUG) +#ifdef _MOTION_VECTOR_DUMP_ + fprintf (stderr, "Output POC: #%d uiDecodingTimeStamp=%d\n", m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC, + uiDecodingTimeStamp); +#endif +#endif + memcpy (pDstInfo, &m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); + ppDst[0] = pDstInfo->pDst[0]; + ppDst[1] = pDstInfo->pDst[1]; + ppDst[2] = pDstInfo->pDst[2]; + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32; + PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]; + --pPic->iRefCount; + --m_sReoderingStatus.iNumOfPicts; + } + return; + } + if (m_sReoderingStatus.iNumOfPicts > 0) { + m_sReoderingStatus.iMinPOC = IMinInt32; + int32_t firstValidIdx = -1; + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (m_sReoderingStatus.iMinPOC == IMinInt32 && m_sPictInfoList[i].iPOC > IMinInt32) { + m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; + m_sReoderingStatus.iPictInfoIndex = i; + firstValidIdx = i; + break; + } + } + for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { + if (i == firstValidIdx) continue; + if (m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].iPOC < m_sReoderingStatus.iMinPOC) { + m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; + m_sReoderingStatus.iPictInfoIndex = i; } } } + if (m_sReoderingStatus.iMinPOC > IMinInt32) { + int32_t iLastPOC = pCtx != NULL ? pCtx->pSliceHeader->iPicOrderCntLsb : m_sPictInfoList[m_iLastBufferedIdx].iPOC; + bool isReady = (m_sReoderingStatus.iLastWrittenPOC > IMinInt32 + && m_sReoderingStatus.iMinPOC - m_sReoderingStatus.iLastWrittenPOC <= 1) + || m_sReoderingStatus.iMinPOC < iLastPOC; + if (isReady) { + m_sReoderingStatus.iLastWrittenPOC = m_sReoderingStatus.iMinPOC; +#if defined (_DEBUG) +#ifdef _MOTION_VECTOR_DUMP_ + fprintf (stderr, "Output POC: #%d uiDecodingTimeStamp=%d\n", m_sReoderingStatus.iLastWrittenPOC, + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].uiDecodingTimeStamp); +#endif +#endif + memcpy (pDstInfo, &m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); + ppDst[0] = pDstInfo->pDst[0]; + ppDst[1] = pDstInfo->pDst[1]; + ppDst[2] = pDstInfo->pDst[2]; + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32; + PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]; + --pPic->iRefCount; + m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false; + m_sReoderingStatus.iMinPOC = IMinInt32; + --m_sReoderingStatus.iNumOfPicts; + } + } +} +DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (PWelsDecoderContext pDecContext, unsigned char** ppDst, + SBufferInfo* pDstInfo) { + DECODING_STATE iRet = dsErrorFree; + if (pDstInfo->iBufferStatus == 1) { + m_bIsBaseline = pDecContext->pSps->uiProfileIdc == 66 || pDecContext->pSps->uiProfileIdc == 83; + if (!m_bIsBaseline) { + BufferingReadyPicture (pDecContext, ppDst, pDstInfo); + ReleaseBufferedReadyPicture (pDecContext, ppDst, pDstInfo); + } + } return iRet; } -DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, - const int kiSrcLen, - SParserBsInfo* pDstInfo) { - if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) { +DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, const int kiSrcLen, SParserBsInfo* pDstInfo) { + PWelsDecoderContext pDecContext = m_pDecThrCtx[0].pCtx; + + if (pDecContext == NULL || pDecContext->pParam == NULL) { if (m_pWelsTrace != NULL) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeParser without Initialize.\n"); } return dsInitialOptExpected; } - if (!m_pDecContext->pParam->bParseOnly) { + if (!pDecContext->pParam->bParseOnly) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be true for this API calling! \n"); - m_pDecContext->iErrorCode |= dsInvalidArgument; + pDecContext->iErrorCode |= dsInvalidArgument; return dsInvalidArgument; } int64_t iEnd, iStart = WelsTime(); - if (CheckBsBuffer (m_pDecContext, kiSrcLen)) { - if (ResetDecoder()) + if (CheckBsBuffer (pDecContext, kiSrcLen)) { + if (ResetDecoder (pDecContext)) return dsOutOfMemory; return dsErrorFree; @@ -921,58 +1265,57 @@ DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, WelsFflush (m_pFBS); } #endif//OUTPUT_BIT_STREAM - m_pDecContext->bEndOfStreamFlag = false; + pDecContext->bEndOfStreamFlag = false; } else { //For application MODE, the error detection should be added for safe. //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL. - m_pDecContext->bEndOfStreamFlag = true; - m_pDecContext->bInstantDecFlag = true; + pDecContext->bEndOfStreamFlag = true; + pDecContext->bInstantDecFlag = true; } - m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding. - m_pDecContext->pParam->eEcActiveIdc = ERROR_CON_DISABLE; //add protection to disable EC here. - m_pDecContext->iFeedbackNalRefIdc = -1; //initialize - if (!m_pDecContext->bFramePending) { //frame complete - m_pDecContext->pParserBsInfo->iNalNum = 0; - memset (m_pDecContext->pParserBsInfo->pNalLenInByte, 0, MAX_NAL_UNITS_IN_LAYER); + pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding. + pDecContext->pParam->eEcActiveIdc = ERROR_CON_DISABLE; //add protection to disable EC here. + pDecContext->iFeedbackNalRefIdc = -1; //initialize + if (!pDecContext->bFramePending) { //frame complete + pDecContext->pParserBsInfo->iNalNum = 0; + memset (pDecContext->pParserBsInfo->pNalLenInByte, 0, MAX_NAL_UNITS_IN_LAYER); } pDstInfo->iNalNum = 0; pDstInfo->iSpsWidthInPixel = pDstInfo->iSpsHeightInPixel = 0; if (pDstInfo) { - m_pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp; + pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp; pDstInfo->uiOutBsTimeStamp = 0; } else { - m_pDecContext->uiTimeStamp = 0; + pDecContext->uiTimeStamp = 0; } - WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, NULL, NULL, pDstInfo); - if (m_pDecContext->iErrorCode & dsOutOfMemory) { - if (ResetDecoder()) + WelsDecodeBs (pDecContext, kpSrc, kiSrcLen, NULL, NULL, pDstInfo); + if (pDecContext->iErrorCode & dsOutOfMemory) { + if (ResetDecoder (pDecContext)) return dsOutOfMemory; return dsErrorFree; } - if (!m_pDecContext->bFramePending && m_pDecContext->pParserBsInfo->iNalNum) { - memcpy (pDstInfo, m_pDecContext->pParserBsInfo, sizeof (SParserBsInfo)); + if (!pDecContext->bFramePending && pDecContext->pParserBsInfo->iNalNum) { + memcpy (pDstInfo, pDecContext->pParserBsInfo, sizeof (SParserBsInfo)); - if (m_pDecContext->iErrorCode == ERR_NONE) { //update statistics: decoding frame count - m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; - if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t - ResetDecStatNums (&m_pDecContext->sDecoderStatistics); - m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; + if (pDecContext->iErrorCode == ERR_NONE) { //update statistics: decoding frame count + pDecContext->pDecoderStatistics->uiDecodedFrameCount++; + if (pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t + ResetDecStatNums (pDecContext->pDecoderStatistics); + pDecContext->pDecoderStatistics->uiDecodedFrameCount++; } } } - m_pDecContext->bInstantDecFlag = false; //reset no-delay flag + pDecContext->bInstantDecFlag = false; //reset no-delay flag - if (m_pDecContext->iErrorCode && m_pDecContext->bPrintFrameErrorTraceFlag) { - WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n", m_pDecContext->iErrorCode); - m_pDecContext->bPrintFrameErrorTraceFlag = false; + if (pDecContext->iErrorCode && pDecContext->bPrintFrameErrorTraceFlag) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n", pDecContext->iErrorCode); + pDecContext->bPrintFrameErrorTraceFlag = false; } iEnd = WelsTime(); - m_pDecContext->dDecTime += (iEnd - iStart) / 1e3; - - return (DECODING_STATE) m_pDecContext->iErrorCode; + pDecContext->dDecTime += (iEnd - iStart) / 1e3; + return (DECODING_STATE)pDecContext->iErrorCode; } DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc, @@ -1014,17 +1357,92 @@ DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc, return state; } -void CWelsDecoder::ResetReorderingPictureBuffers() { - m_iPictInfoIndex = 0; - m_iMinPOC = sIMinInt32; - m_iNumOfPicts = 0; - m_iLastGOPRemainPicts = 0; - m_LastWrittenPOC = sIMinInt32; - m_iLargestBufferedPicIndex = 0; - for (int32_t i = 0; i < 16; ++i) { - m_sPictInfoList[i].bLastGOP = false; - m_sPictInfoList[i].iPOC = sIMinInt32; +DECODING_STATE CWelsDecoder::ParseAccessUnit (SWelsDecoderThreadCTX& sThreadCtx) { + sThreadCtx.pCtx->bHasNewSps = false; + sThreadCtx.pCtx->bParamSetsLostFlag = m_bParamSetsLostFlag; + sThreadCtx.pCtx->bFreezeOutput = m_bFreezeOutput; + sThreadCtx.pCtx->uiDecodingTimeStamp = ++m_uiDecodeTimeStamp; + bool bPicBuffChanged = false; + if (m_pLastDecThrCtx != NULL && sThreadCtx.pCtx->sSpsPpsCtx.iSeqId < m_pLastDecThrCtx->pCtx->sSpsPpsCtx.iSeqId) { + CopySpsPps (m_pLastDecThrCtx->pCtx, sThreadCtx.pCtx); + sThreadCtx.pCtx->iPicQueueNumber = m_pLastDecThrCtx->pCtx->iPicQueueNumber; + if (sThreadCtx.pCtx->pPicBuff != m_pPicBuff) { + bPicBuffChanged = true; + sThreadCtx.pCtx->pPicBuff = m_pPicBuff; + sThreadCtx.pCtx->bHaveGotMemory = m_pPicBuff != NULL; + sThreadCtx.pCtx->iImgWidthInPixel = m_pLastDecThrCtx->pCtx->iImgWidthInPixel; + sThreadCtx.pCtx->iImgHeightInPixel = m_pLastDecThrCtx->pCtx->iImgHeightInPixel; + } } + int32_t iRet = DecodeFrame2WithCtx (sThreadCtx.pCtx, sThreadCtx.kpSrc, sThreadCtx.kiSrcLen, sThreadCtx.ppDst, + &sThreadCtx.sDstInfo); + + int32_t iErr = InitConstructAccessUnit (sThreadCtx.pCtx, &sThreadCtx.sDstInfo); + if (ERR_NONE != iErr) { + return (DECODING_STATE) (iRet | iErr); + } + if (sThreadCtx.pCtx->bNewSeqBegin) { + m_pPicBuff = sThreadCtx.pCtx->pPicBuff; + } else if (bPicBuffChanged) { + InitialDqLayersContext (sThreadCtx.pCtx, sThreadCtx.pCtx->pSps->iMbWidth << 4, sThreadCtx.pCtx->pSps->iMbHeight << 4); + } + m_bParamSetsLostFlag = sThreadCtx.pCtx->bNewSeqBegin ? false : sThreadCtx.pCtx->bParamSetsLostFlag; + m_bFreezeOutput = sThreadCtx.pCtx->bNewSeqBegin ? false : sThreadCtx.pCtx->bFreezeOutput; + return (DECODING_STATE)iErr; +} +/* +* Run decoding picture in separate thread. +*/ + +int CWelsDecoder::ThreadDecodeFrameInternal (const unsigned char* kpSrc, const int kiSrcLen, unsigned char** ppDst, + SBufferInfo* pDstInfo) { + int state = dsErrorFree; + int32_t i, j; + int32_t signal = 0; + + //serial using of threads + if (m_DecCtxActiveCount < m_iThreadCount) { + signal = m_DecCtxActiveCount; + } else { + signal = m_pDecThrCtxActive[0]->sThreadInfo.uiThrNum; + } + + WAIT_SEMAPHORE (&m_pDecThrCtx[signal].sThreadInfo.sIsIdle, WELS_DEC_THREAD_WAIT_INFINITE); + + for (i = 0; i < m_DecCtxActiveCount; ++i) { + if (m_pDecThrCtxActive[i] == &m_pDecThrCtx[signal]) { + m_pDecThrCtxActive[i] = NULL; + for (j = i; j < m_DecCtxActiveCount - 1; j++) { + m_pDecThrCtxActive[j] = m_pDecThrCtxActive[j + 1]; + m_pDecThrCtxActive[j + 1] = NULL; + } + --m_DecCtxActiveCount; + break; + } + } + + m_pDecThrCtxActive[m_DecCtxActiveCount++] = &m_pDecThrCtx[signal]; + if (m_pLastDecThrCtx != NULL) { + m_pDecThrCtx[signal].pCtx->pLastThreadCtx = m_pLastDecThrCtx; + } + m_pDecThrCtx[signal].kpSrc = const_cast (kpSrc); + m_pDecThrCtx[signal].kiSrcLen = kiSrcLen; + m_pDecThrCtx[signal].ppDst = ppDst; + memcpy (&m_pDecThrCtx[signal].sDstInfo, pDstInfo, sizeof (SBufferInfo)); + + ParseAccessUnit (m_pDecThrCtx[signal]); + if (m_iThreadCount > 1) { + m_pLastDecThrCtx = &m_pDecThrCtx[signal]; + } + m_pDecThrCtx[signal].sThreadInfo.uiCommand = WELS_DEC_THREAD_COMMAND_RUN; + RELEASE_SEMAPHORE (&m_pDecThrCtx[signal].sThreadInfo.sIsActivated); + + // wait early picture + if (m_DecCtxActiveCount >= m_iThreadCount) { + WAIT_SEMAPHORE (&m_pDecThrCtxActive[0]->sThreadInfo.sIsIdle, WELS_DEC_THREAD_WAIT_INFINITE); + RELEASE_SEMAPHORE (&m_pDecThrCtxActive[0]->sThreadInfo.sIsIdle); + } + return state; } } // namespace WelsDec diff --git a/src/openh264/codec/decoder/plus/src/wels_dec_export.def b/src/openh264/codec/decoder/plus/src/wels_dec_export.def old mode 100755 new mode 100644 diff --git a/src/openh264/codec/decoder/targets.mk b/src/openh264/codec/decoder/targets.mk old mode 100755 new mode 100644 index eaf5d3c07..88dc5afb1 --- a/src/openh264/codec/decoder/targets.mk +++ b/src/openh264/codec/decoder/targets.mk @@ -22,6 +22,7 @@ DECODER_CPP_SRCS=\ $(DECODER_SRCDIR)/core/src/parse_mb_syn_cavlc.cpp\ $(DECODER_SRCDIR)/core/src/pic_queue.cpp\ $(DECODER_SRCDIR)/core/src/rec_mb.cpp\ + $(DECODER_SRCDIR)/core/src/wels_decoder_thread.cpp\ $(DECODER_SRCDIR)/plus/src/welsDecoderExt.cpp\ DECODER_OBJS += $(DECODER_CPP_SRCS:.cpp=.$(OBJ)) @@ -56,14 +57,24 @@ DECODER_OBJS += $(DECODER_OBJSARM64) endif OBJS += $(DECODER_OBJSARM64) -DECODER_ASM_MIPS_SRCS=\ +DECODER_ASM_MIPS_MMI_SRCS=\ $(DECODER_SRCDIR)/core/mips/dct_mmi.c\ -DECODER_OBJSMIPS += $(DECODER_ASM_MIPS_SRCS:.c=.$(OBJ)) +DECODER_OBJSMIPS_MMI += $(DECODER_ASM_MIPS_MMI_SRCS:.c=.$(OBJ)) + +DECODER_ASM_MIPS_MSA_SRCS=\ + +DECODER_OBJSMIPS_MSA += $(DECODER_ASM_MIPS_MSA_SRCS:.c=.$(OBJ)) ifeq ($(ASM_ARCH), mips) -DECODER_OBJS += $(DECODER_OBJSMIPS) +ifeq ($(ENABLE_MMI), Yes) +DECODER_OBJS += $(DECODER_OBJSMIPS_MMI) endif -OBJS += $(DECODER_OBJSMIPS) +ifeq ($(ENABLE_MSA), Yes) +DECODER_OBJS += $(DECODER_OBJSMIPS_MSA) +endif +endif +OBJS += $(DECODER_OBJSMIPS_MMI) +OBJS += $(DECODER_OBJSMIPS_MSA) OBJS += $(DECODER_OBJS) diff --git a/src/openh264/codec/encoder/core/arm/intra_pred_neon.S b/src/openh264/codec/encoder/core/arm/intra_pred_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm/intra_pred_sad_3_opt_neon.S b/src/openh264/codec/encoder/core/arm/intra_pred_sad_3_opt_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm/memory_neon.S b/src/openh264/codec/encoder/core/arm/memory_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm/pixel_neon.S b/src/openh264/codec/encoder/core/arm/pixel_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm/reconstruct_neon.S b/src/openh264/codec/encoder/core/arm/reconstruct_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm/svc_motion_estimation.S b/src/openh264/codec/encoder/core/arm/svc_motion_estimation.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm64/intra_pred_aarch64_neon.S b/src/openh264/codec/encoder/core/arm64/intra_pred_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm64/intra_pred_sad_3_opt_aarch64_neon.S b/src/openh264/codec/encoder/core/arm64/intra_pred_sad_3_opt_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm64/memory_aarch64_neon.S b/src/openh264/codec/encoder/core/arm64/memory_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm64/pixel_aarch64_neon.S b/src/openh264/codec/encoder/core/arm64/pixel_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm64/reconstruct_aarch64_neon.S b/src/openh264/codec/encoder/core/arm64/reconstruct_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/arm64/svc_motion_estimation_aarch64_neon.S b/src/openh264/codec/encoder/core/arm64/svc_motion_estimation_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/as264_common.h b/src/openh264/codec/encoder/core/inc/as264_common.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/au_set.h b/src/openh264/codec/encoder/core/inc/au_set.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/deblocking.h b/src/openh264/codec/encoder/core/inc/deblocking.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/decode_mb_aux.h b/src/openh264/codec/encoder/core/inc/decode_mb_aux.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/dq_map.h b/src/openh264/codec/encoder/core/inc/dq_map.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/encode_mb_aux.h b/src/openh264/codec/encoder/core/inc/encode_mb_aux.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/encoder.h b/src/openh264/codec/encoder/core/inc/encoder.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/encoder_context.h b/src/openh264/codec/encoder/core/inc/encoder_context.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/extern.h b/src/openh264/codec/encoder/core/inc/extern.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/get_intra_predictor.h b/src/openh264/codec/encoder/core/inc/get_intra_predictor.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/mb_cache.h b/src/openh264/codec/encoder/core/inc/mb_cache.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/md.h b/src/openh264/codec/encoder/core/inc/md.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/mt_defs.h b/src/openh264/codec/encoder/core/inc/mt_defs.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/mv_pred.h b/src/openh264/codec/encoder/core/inc/mv_pred.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/nal_encap.h b/src/openh264/codec/encoder/core/inc/nal_encap.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/param_svc.h b/src/openh264/codec/encoder/core/inc/param_svc.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/parameter_sets.h b/src/openh264/codec/encoder/core/inc/parameter_sets.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/paraset_strategy.h b/src/openh264/codec/encoder/core/inc/paraset_strategy.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/picture.h b/src/openh264/codec/encoder/core/inc/picture.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/picture_handle.h b/src/openh264/codec/encoder/core/inc/picture_handle.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/rc.h b/src/openh264/codec/encoder/core/inc/rc.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/ref_list_mgr_svc.h b/src/openh264/codec/encoder/core/inc/ref_list_mgr_svc.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/sample.h b/src/openh264/codec/encoder/core/inc/sample.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/set_mb_syn_cabac.h b/src/openh264/codec/encoder/core/inc/set_mb_syn_cabac.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/set_mb_syn_cavlc.h b/src/openh264/codec/encoder/core/inc/set_mb_syn_cavlc.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/slice.h b/src/openh264/codec/encoder/core/inc/slice.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/slice_multi_threading.h b/src/openh264/codec/encoder/core/inc/slice_multi_threading.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/stat.h b/src/openh264/codec/encoder/core/inc/stat.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_base_layer_md.h b/src/openh264/codec/encoder/core/inc/svc_base_layer_md.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_enc_frame.h b/src/openh264/codec/encoder/core/inc/svc_enc_frame.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_enc_golomb.h b/src/openh264/codec/encoder/core/inc/svc_enc_golomb.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_enc_macroblock.h b/src/openh264/codec/encoder/core/inc/svc_enc_macroblock.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_enc_slice_segment.h b/src/openh264/codec/encoder/core/inc/svc_enc_slice_segment.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_encode_mb.h b/src/openh264/codec/encoder/core/inc/svc_encode_mb.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_encode_slice.h b/src/openh264/codec/encoder/core/inc/svc_encode_slice.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_mode_decision.h b/src/openh264/codec/encoder/core/inc/svc_mode_decision.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_motion_estimate.h b/src/openh264/codec/encoder/core/inc/svc_motion_estimate.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_set_mb_syn.h b/src/openh264/codec/encoder/core/inc/svc_set_mb_syn.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/svc_set_mb_syn_cavlc.h b/src/openh264/codec/encoder/core/inc/svc_set_mb_syn_cavlc.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/vlc_encoder.h b/src/openh264/codec/encoder/core/inc/vlc_encoder.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/wels_common_basis.h b/src/openh264/codec/encoder/core/inc/wels_common_basis.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/wels_const.h b/src/openh264/codec/encoder/core/inc/wels_const.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/wels_func_ptr_def.h b/src/openh264/codec/encoder/core/inc/wels_func_ptr_def.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/wels_preprocess.h b/src/openh264/codec/encoder/core/inc/wels_preprocess.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/wels_task_base.h b/src/openh264/codec/encoder/core/inc/wels_task_base.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/wels_task_encoder.h b/src/openh264/codec/encoder/core/inc/wels_task_encoder.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/wels_task_management.h b/src/openh264/codec/encoder/core/inc/wels_task_management.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/inc/wels_transpose_matrix.h b/src/openh264/codec/encoder/core/inc/wels_transpose_matrix.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/mips/dct_mmi.c b/src/openh264/codec/encoder/core/mips/dct_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/mips/quant_mmi.c b/src/openh264/codec/encoder/core/mips/quant_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/mips/score_mmi.c b/src/openh264/codec/encoder/core/mips/score_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/au_set.cpp b/src/openh264/codec/encoder/core/src/au_set.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/deblocking.cpp b/src/openh264/codec/encoder/core/src/deblocking.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/decode_mb_aux.cpp b/src/openh264/codec/encoder/core/src/decode_mb_aux.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/encode_mb_aux.cpp b/src/openh264/codec/encoder/core/src/encode_mb_aux.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/encoder.cpp b/src/openh264/codec/encoder/core/src/encoder.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/encoder_data_tables.cpp b/src/openh264/codec/encoder/core/src/encoder_data_tables.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/encoder_ext.cpp b/src/openh264/codec/encoder/core/src/encoder_ext.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/get_intra_predictor.cpp b/src/openh264/codec/encoder/core/src/get_intra_predictor.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/md.cpp b/src/openh264/codec/encoder/core/src/md.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/mv_pred.cpp b/src/openh264/codec/encoder/core/src/mv_pred.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/nal_encap.cpp b/src/openh264/codec/encoder/core/src/nal_encap.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/paraset_strategy.cpp b/src/openh264/codec/encoder/core/src/paraset_strategy.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/picture_handle.cpp b/src/openh264/codec/encoder/core/src/picture_handle.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/ratectl.cpp b/src/openh264/codec/encoder/core/src/ratectl.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/ref_list_mgr_svc.cpp b/src/openh264/codec/encoder/core/src/ref_list_mgr_svc.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/sample.cpp b/src/openh264/codec/encoder/core/src/sample.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/set_mb_syn_cabac.cpp b/src/openh264/codec/encoder/core/src/set_mb_syn_cabac.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/set_mb_syn_cavlc.cpp b/src/openh264/codec/encoder/core/src/set_mb_syn_cavlc.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/slice_multi_threading.cpp b/src/openh264/codec/encoder/core/src/slice_multi_threading.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/svc_base_layer_md.cpp b/src/openh264/codec/encoder/core/src/svc_base_layer_md.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/svc_enc_slice_segment.cpp b/src/openh264/codec/encoder/core/src/svc_enc_slice_segment.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/svc_encode_mb.cpp b/src/openh264/codec/encoder/core/src/svc_encode_mb.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/svc_encode_slice.cpp b/src/openh264/codec/encoder/core/src/svc_encode_slice.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/svc_mode_decision.cpp b/src/openh264/codec/encoder/core/src/svc_mode_decision.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/svc_motion_estimate.cpp b/src/openh264/codec/encoder/core/src/svc_motion_estimate.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp b/src/openh264/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp b/src/openh264/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/wels_preprocess.cpp b/src/openh264/codec/encoder/core/src/wels_preprocess.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/wels_task_base.cpp b/src/openh264/codec/encoder/core/src/wels_task_base.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/wels_task_encoder.cpp b/src/openh264/codec/encoder/core/src/wels_task_encoder.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/src/wels_task_management.cpp b/src/openh264/codec/encoder/core/src/wels_task_management.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/x86/coeff.asm b/src/openh264/codec/encoder/core/x86/coeff.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/x86/dct.asm b/src/openh264/codec/encoder/core/x86/dct.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/x86/intra_pred.asm b/src/openh264/codec/encoder/core/x86/intra_pred.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/x86/matrix_transpose.asm b/src/openh264/codec/encoder/core/x86/matrix_transpose.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/x86/memzero.asm b/src/openh264/codec/encoder/core/x86/memzero.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/x86/quant.asm b/src/openh264/codec/encoder/core/x86/quant.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/x86/sample_sc.asm b/src/openh264/codec/encoder/core/x86/sample_sc.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/core/x86/score.asm b/src/openh264/codec/encoder/core/x86/score.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/meson.build b/src/openh264/codec/encoder/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/plus/inc/welsEncoderExt.h b/src/openh264/codec/encoder/plus/inc/welsEncoderExt.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/plus/src/DllEntry.cpp b/src/openh264/codec/encoder/plus/src/DllEntry.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/plus/src/welsEncoderExt.cpp b/src/openh264/codec/encoder/plus/src/welsEncoderExt.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/plus/src/wels_enc_export.def b/src/openh264/codec/encoder/plus/src/wels_enc_export.def old mode 100755 new mode 100644 diff --git a/src/openh264/codec/encoder/targets.mk b/src/openh264/codec/encoder/targets.mk old mode 100755 new mode 100644 index 1f053280e..4fb2e690e --- a/src/openh264/codec/encoder/targets.mk +++ b/src/openh264/codec/encoder/targets.mk @@ -82,16 +82,26 @@ ENCODER_OBJS += $(ENCODER_OBJSARM64) endif OBJS += $(ENCODER_OBJSARM64) -ENCODER_ASM_MIPS_SRCS=\ +ENCODER_ASM_MIPS_MMI_SRCS=\ $(ENCODER_SRCDIR)/core/mips/dct_mmi.c\ $(ENCODER_SRCDIR)/core/mips/quant_mmi.c\ $(ENCODER_SRCDIR)/core/mips/score_mmi.c\ -ENCODER_OBJSMIPS += $(ENCODER_ASM_MIPS_SRCS:.c=.$(OBJ)) +ENCODER_OBJSMIPS_MMI += $(ENCODER_ASM_MIPS_MMI_SRCS:.c=.$(OBJ)) + +ENCODER_ASM_MIPS_MSA_SRCS=\ + +ENCODER_OBJSMIPS_MSA += $(ENCODER_ASM_MIPS_MSA_SRCS:.c=.$(OBJ)) ifeq ($(ASM_ARCH), mips) -ENCODER_OBJS += $(ENCODER_OBJSMIPS) +ifeq ($(ENABLE_MMI), Yes) +ENCODER_OBJS += $(ENCODER_OBJSMIPS_MMI) endif -OBJS += $(ENCODER_OBJSMIPS) +ifeq ($(ENABLE_MSA), Yes) +ENCODER_OBJS += $(ENCODER_OBJSMIPS_MSA) +endif +endif +OBJS += $(ENCODER_OBJSMIPS_MMI) +OBJS += $(ENCODER_OBJSMIPS_MSA) OBJS += $(ENCODER_OBJS) diff --git a/src/openh264/codec/meson.build b/src/openh264/codec/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/build/win32/.gitignore b/src/openh264/codec/processing/build/win32/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/build/win32/WelsVP.vcproj b/src/openh264/codec/processing/build/win32/WelsVP.vcproj old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/interface/IWelsVP.h b/src/openh264/codec/processing/interface/IWelsVP.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/meson.build b/src/openh264/codec/processing/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp b/src/openh264/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/adaptivequantization/AdaptiveQuantization.h b/src/openh264/codec/processing/src/adaptivequantization/AdaptiveQuantization.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/arm/adaptive_quantization.S b/src/openh264/codec/processing/src/arm/adaptive_quantization.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/arm/down_sample_neon.S b/src/openh264/codec/processing/src/arm/down_sample_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/arm/pixel_sad_neon.S b/src/openh264/codec/processing/src/arm/pixel_sad_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/arm/vaa_calc_neon.S b/src/openh264/codec/processing/src/arm/vaa_calc_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/arm64/adaptive_quantization_aarch64_neon.S b/src/openh264/codec/processing/src/arm64/adaptive_quantization_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/arm64/down_sample_aarch64_neon.S b/src/openh264/codec/processing/src/arm64/down_sample_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/arm64/pixel_sad_aarch64_neon.S b/src/openh264/codec/processing/src/arm64/pixel_sad_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/arm64/vaa_calc_aarch64_neon.S b/src/openh264/codec/processing/src/arm64/vaa_calc_aarch64_neon.S old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/backgrounddetection/BackgroundDetection.cpp b/src/openh264/codec/processing/src/backgrounddetection/BackgroundDetection.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/backgrounddetection/BackgroundDetection.h b/src/openh264/codec/processing/src/backgrounddetection/BackgroundDetection.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/WelsFrameWork.cpp b/src/openh264/codec/processing/src/common/WelsFrameWork.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/WelsFrameWork.h b/src/openh264/codec/processing/src/common/WelsFrameWork.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/WelsFrameWorkEx.cpp b/src/openh264/codec/processing/src/common/WelsFrameWorkEx.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/WelsVP.def b/src/openh264/codec/processing/src/common/WelsVP.def old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/WelsVP.rc b/src/openh264/codec/processing/src/common/WelsVP.rc old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/common.h b/src/openh264/codec/processing/src/common/common.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/memory.cpp b/src/openh264/codec/processing/src/common/memory.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/memory.h b/src/openh264/codec/processing/src/common/memory.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/resource.h b/src/openh264/codec/processing/src/common/resource.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/typedef.h b/src/openh264/codec/processing/src/common/typedef.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/common/util.h b/src/openh264/codec/processing/src/common/util.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/complexityanalysis/ComplexityAnalysis.cpp b/src/openh264/codec/processing/src/complexityanalysis/ComplexityAnalysis.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/complexityanalysis/ComplexityAnalysis.h b/src/openh264/codec/processing/src/complexityanalysis/ComplexityAnalysis.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/denoise/denoise.cpp b/src/openh264/codec/processing/src/denoise/denoise.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/denoise/denoise.h b/src/openh264/codec/processing/src/denoise/denoise.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/denoise/denoise_filter.cpp b/src/openh264/codec/processing/src/denoise/denoise_filter.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/downsample/downsample.cpp b/src/openh264/codec/processing/src/downsample/downsample.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/downsample/downsample.h b/src/openh264/codec/processing/src/downsample/downsample.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/downsample/downsamplefuncs.cpp b/src/openh264/codec/processing/src/downsample/downsamplefuncs.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/imagerotate/imagerotate.cpp b/src/openh264/codec/processing/src/imagerotate/imagerotate.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/imagerotate/imagerotate.h b/src/openh264/codec/processing/src/imagerotate/imagerotate.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/imagerotate/imagerotatefuncs.cpp b/src/openh264/codec/processing/src/imagerotate/imagerotatefuncs.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/mips/vaa_mmi.c b/src/openh264/codec/processing/src/mips/vaa_mmi.c old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/scenechangedetection/SceneChangeDetection.cpp b/src/openh264/codec/processing/src/scenechangedetection/SceneChangeDetection.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/scenechangedetection/SceneChangeDetection.h b/src/openh264/codec/processing/src/scenechangedetection/SceneChangeDetection.h old mode 100755 new mode 100644 index ae146cff7..78c225ee7 --- a/src/openh264/codec/processing/src/scenechangedetection/SceneChangeDetection.h +++ b/src/openh264/codec/processing/src/scenechangedetection/SceneChangeDetection.h @@ -89,6 +89,12 @@ class CSceneChangeDetectorVideo { } #endif +#ifdef HAVE_MMI + if (iCpuFlag & WELS_CPU_MMI) { + m_pfSad = WelsSampleSad8x8_mmi; + } +#endif + m_fSceneChangeMotionRatioLarge = SCENE_CHANGE_MOTION_RATIO_LARGE_VIDEO; m_fSceneChangeMotionRatioMedium = SCENE_CHANGE_MOTION_RATIO_MEDIUM; } diff --git a/src/openh264/codec/processing/src/scrolldetection/ScrollDetection.cpp b/src/openh264/codec/processing/src/scrolldetection/ScrollDetection.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/scrolldetection/ScrollDetection.h b/src/openh264/codec/processing/src/scrolldetection/ScrollDetection.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp b/src/openh264/codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/scrolldetection/ScrollDetectionFuncs.h b/src/openh264/codec/processing/src/scrolldetection/ScrollDetectionFuncs.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/vaacalc/vaacalcfuncs.cpp b/src/openh264/codec/processing/src/vaacalc/vaacalcfuncs.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/vaacalc/vaacalculation.cpp b/src/openh264/codec/processing/src/vaacalc/vaacalculation.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/vaacalc/vaacalculation.h b/src/openh264/codec/processing/src/vaacalc/vaacalculation.h old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/x86/denoisefilter.asm b/src/openh264/codec/processing/src/x86/denoisefilter.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/x86/downsample_bilinear.asm b/src/openh264/codec/processing/src/x86/downsample_bilinear.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/src/x86/vaa.asm b/src/openh264/codec/processing/src/x86/vaa.asm old mode 100755 new mode 100644 diff --git a/src/openh264/codec/processing/targets.mk b/src/openh264/codec/processing/targets.mk old mode 100755 new mode 100644 index 300de2d80..0f8873335 --- a/src/openh264/codec/processing/targets.mk +++ b/src/openh264/codec/processing/targets.mk @@ -58,14 +58,24 @@ PROCESSING_OBJS += $(PROCESSING_OBJSARM64) endif OBJS += $(PROCESSING_OBJSARM64) -PROCESSING_ASM_MIPS_SRCS=\ +PROCESSING_ASM_MIPS_MMI_SRCS=\ $(PROCESSING_SRCDIR)/src/mips/vaa_mmi.c\ -PROCESSING_OBJSMIPS += $(PROCESSING_ASM_MIPS_SRCS:.c=.$(OBJ)) +PROCESSING_OBJSMIPS_MMI += $(PROCESSING_ASM_MIPS_MMI_SRCS:.c=.$(OBJ)) + +PROCESSING_ASM_MIPS_MSA_SRCS=\ + +PROCESSING_OBJSMIPS_MSA += $(PROCESSING_ASM_MIPS_MSA_SRCS:.c=.$(OBJ)) ifeq ($(ASM_ARCH), mips) -PROCESSING_OBJS += $(PROCESSING_OBJSMIPS) +ifeq ($(ENABLE_MMI), Yes) +PROCESSING_OBJS += $(PROCESSING_OBJSMIPS_MMI) endif -OBJS += $(PROCESSING_OBJSMIPS) +ifeq ($(ENABLE_MSA), Yes) +PROCESSING_OBJS += $(PROCESSING_OBJSMIPS_MSA) +endif +endif +OBJS += $(PROCESSING_OBJSMIPS_MMI) +OBJS += $(PROCESSING_OBJSMIPS_MSA) OBJS += $(PROCESSING_OBJS) diff --git a/src/openh264/docs/doxygen/Doxyfile b/src/openh264/docs/doxygen/Doxyfile old mode 100755 new mode 100644 diff --git a/src/openh264/docs/doxygen/Home.rest b/src/openh264/docs/doxygen/Home.rest old mode 100755 new mode 100644 diff --git a/src/openh264/docs/doxygen/ISVCDecoder.rest b/src/openh264/docs/doxygen/ISVCDecoder.rest old mode 100755 new mode 100644 diff --git a/src/openh264/docs/doxygen/ISVCEncoder.rest b/src/openh264/docs/doxygen/ISVCEncoder.rest old mode 100755 new mode 100644 diff --git a/src/openh264/docs/doxygen/UsageExampleForDecoder.rest b/src/openh264/docs/doxygen/UsageExampleForDecoder.rest old mode 100755 new mode 100644 diff --git a/src/openh264/docs/doxygen/UsageExampleForEncoder.rest b/src/openh264/docs/doxygen/UsageExampleForEncoder.rest old mode 100755 new mode 100644 diff --git a/src/openh264/docs/doxygen2rst.py b/src/openh264/docs/doxygen2rst.py old mode 100755 new mode 100644 diff --git a/src/openh264/gmpopenh264.info b/src/openh264/gmpopenh264.info old mode 100755 new mode 100644 index 8a791ec4f..7a666efb8 --- a/src/openh264/gmpopenh264.info +++ b/src/openh264/gmpopenh264.info @@ -1,4 +1,4 @@ Name: gmpopenh264 Description: GMP Plugin for OpenH264. -Version: 2.0.0 +Version: 2.1.0 APIs: encode-video[h264], decode-video[h264] diff --git a/src/openh264/include/meson.build b/src/openh264/include/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/include/wels/meson.build b/src/openh264/include/wels/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/meson.build b/src/openh264/meson.build old mode 100755 new mode 100644 index 8813deb8a..dc677ef29 --- a/src/openh264/meson.build +++ b/src/openh264/meson.build @@ -1,10 +1,10 @@ project('openh264', ['c', 'cpp'], - version : '1.8.0', - meson_version : '>= 0.43', + version : '2.0.0', + meson_version : '>= 0.47', default_options : [ 'warning_level=1', 'buildtype=debugoptimized' ]) -major_version = '4' +major_version = '5' cpp = meson.get_compiler('cpp') @@ -125,6 +125,7 @@ pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir')) foreach t : ['', '-static'] pkgconf = configuration_data() pkgconf.set('prefix', join_paths(get_option('prefix'))) + pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir'))) pkgconf.set('VERSION', meson.project_version()) if t == '-static' do_install = false diff --git a/src/openh264/meson_options.txt b/src/openh264/meson_options.txt new file mode 100644 index 000000000..a2c14d168 --- /dev/null +++ b/src/openh264/meson_options.txt @@ -0,0 +1 @@ +option('tests', type : 'feature', value : 'auto', yield : true) diff --git a/src/openh264/module/RefCounted.h b/src/openh264/module/RefCounted.h old mode 100755 new mode 100644 diff --git a/src/openh264/module/gmp-openh264.cpp b/src/openh264/module/gmp-openh264.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/module/targets.mk b/src/openh264/module/targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/module/task_utils.h b/src/openh264/module/task_utils.h old mode 100755 new mode 100644 diff --git a/src/openh264/module/task_utils.py b/src/openh264/module/task_utils.py old mode 100755 new mode 100644 diff --git a/src/openh264/module/task_utils_generated.h b/src/openh264/module/task_utils_generated.h old mode 100755 new mode 100644 diff --git a/src/openh264/openh264.def b/src/openh264/openh264.def old mode 100755 new mode 100644 diff --git a/src/openh264/openh264.pc.in b/src/openh264/openh264.pc.in old mode 100755 new mode 100644 index 7fb5d0c13..f86225c0b --- a/src/openh264/openh264.pc.in +++ b/src/openh264/openh264.pc.in @@ -1,5 +1,5 @@ prefix=@prefix@ -libdir=${prefix}/lib +libdir=@libdir@ includedir=${prefix}/include Name: OpenH264 diff --git a/src/openh264/openh264.rc b/src/openh264/openh264.rc old mode 100755 new mode 100644 index a0163fbe1..7ff7ad803 --- a/src/openh264/openh264.rc +++ b/src/openh264/openh264.rc @@ -24,8 +24,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,0,1905 - PRODUCTVERSION 2,0,0,1905 + FILEVERSION 2,1,0,2002 + PRODUCTVERSION 2,1,0,2002 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,12 +43,12 @@ BEGIN VALUE "Comments", "Cisco OpenH264 codec" VALUE "CompanyName", "Cisco Systems Inc." VALUE "FileDescription", "Cisco OpenH264 codec" - VALUE "FileVersion", "2.0.0.1905" + VALUE "FileVersion", "2.1.0.2002" VALUE "InternalName", "openh264.dll" VALUE "LegalCopyright", "© 2011-2015 Cisco and/or its affiliates. All rights reserved." VALUE "OriginalFilename", "openh264.dll" VALUE "ProductName", "Cisco OpenH264 codec" - VALUE "ProductVersion", "2.0.0.1905" + VALUE "ProductVersion", "2.1.0.2002" END END BLOCK "VarFileInfo" diff --git a/src/openh264/openh264.rc.template b/src/openh264/openh264.rc.template old mode 100755 new mode 100644 diff --git a/src/openh264/res/Adobe_PDF_sample_a_1024x768_50Frms.264 b/src/openh264/res/Adobe_PDF_sample_a_1024x768_50Frms.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/BA1_FT_C.264 b/src/openh264/res/BA1_FT_C.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/BA1_Sony_D.jsv b/src/openh264/res/BA1_Sony_D.jsv old mode 100755 new mode 100644 diff --git a/src/openh264/res/BAMQ1_JVC_C.264 b/src/openh264/res/BAMQ1_JVC_C.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/BAMQ2_JVC_C.264 b/src/openh264/res/BAMQ2_JVC_C.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/BANM_MW_D.264 b/src/openh264/res/BANM_MW_D.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/BASQP1_Sony_C.jsv b/src/openh264/res/BASQP1_Sony_C.jsv old mode 100755 new mode 100644 diff --git a/src/openh264/res/BA_MW_D.264 b/src/openh264/res/BA_MW_D.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/BA_MW_D_IDR_LOST.264 b/src/openh264/res/BA_MW_D_IDR_LOST.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/BA_MW_D_P_LOST.264 b/src/openh264/res/BA_MW_D_P_LOST.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/CI1_FT_B.264 b/src/openh264/res/CI1_FT_B.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/CI_MW_D.264 b/src/openh264/res/CI_MW_D.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/CVFC1_Sony_C.jsv b/src/openh264/res/CVFC1_Sony_C.jsv old mode 100755 new mode 100644 diff --git a/src/openh264/res/CVPCMNL1_SVA_C.264 b/src/openh264/res/CVPCMNL1_SVA_C.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/CiscoVT2people_160x96_6fps.yuv b/src/openh264/res/CiscoVT2people_160x96_6fps.yuv old mode 100755 new mode 100644 diff --git a/src/openh264/res/CiscoVT2people_320x192_12fps.yuv b/src/openh264/res/CiscoVT2people_320x192_12fps.yuv old mode 100755 new mode 100644 diff --git a/src/openh264/res/Cisco_Absolute_Power_1280x720_30fps.yuv b/src/openh264/res/Cisco_Absolute_Power_1280x720_30fps.yuv old mode 100755 new mode 100644 diff --git a/src/openh264/res/Cisco_Adobe_PDF_sample_a_1024x768_CAVLC_Bframe_9.264 b/src/openh264/res/Cisco_Adobe_PDF_sample_a_1024x768_CAVLC_Bframe_9.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/Cisco_Men_whisper_640x320_CABAC_Bframe_9.264 b/src/openh264/res/Cisco_Men_whisper_640x320_CABAC_Bframe_9.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/Cisco_Men_whisper_640x320_CAVLC_Bframe_9.264 b/src/openh264/res/Cisco_Men_whisper_640x320_CAVLC_Bframe_9.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/Error_I_P.264 b/src/openh264/res/Error_I_P.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/LS_SVA_D.264 b/src/openh264/res/LS_SVA_D.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/MIDR_MW_D.264 b/src/openh264/res/MIDR_MW_D.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/MPS_MW_A.264 b/src/openh264/res/MPS_MW_A.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/MR1_BT_A.h264 b/src/openh264/res/MR1_BT_A.h264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/MR1_MW_A.264 b/src/openh264/res/MR1_MW_A.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/MR2_MW_A.264 b/src/openh264/res/MR2_MW_A.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/MR2_TANDBERG_E.264 b/src/openh264/res/MR2_TANDBERG_E.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/NL1_Sony_D.jsv b/src/openh264/res/NL1_Sony_D.jsv old mode 100755 new mode 100644 diff --git a/src/openh264/res/NLMQ1_JVC_C.264 b/src/openh264/res/NLMQ1_JVC_C.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/NLMQ2_JVC_C.264 b/src/openh264/res/NLMQ2_JVC_C.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/NRF_MW_E.264 b/src/openh264/res/NRF_MW_E.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/QCIF_2P_I_allIPCM.264 b/src/openh264/res/QCIF_2P_I_allIPCM.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/SVA_BA1_B.264 b/src/openh264/res/SVA_BA1_B.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/SVA_BA2_D.264 b/src/openh264/res/SVA_BA2_D.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/SVA_Base_B.264 b/src/openh264/res/SVA_Base_B.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/SVA_CL1_E.264 b/src/openh264/res/SVA_CL1_E.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/SVA_FM1_E.264 b/src/openh264/res/SVA_FM1_E.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/SVA_NL1_B.264 b/src/openh264/res/SVA_NL1_B.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/SVA_NL2_E.264 b/src/openh264/res/SVA_NL2_E.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/SarVui.264 b/src/openh264/res/SarVui.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/Static.264 b/src/openh264/res/Static.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/Static_152_100.yuv b/src/openh264/res/Static_152_100.yuv old mode 100755 new mode 100644 diff --git a/src/openh264/res/VID_1280x544_cabac_temporal_direct.264 b/src/openh264/res/VID_1280x544_cabac_temporal_direct.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/VID_1280x544_cavlc_temporal_direct.264 b/src/openh264/res/VID_1280x544_cavlc_temporal_direct.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/VID_1280x720_cabac_temporal_direct.264 b/src/openh264/res/VID_1280x720_cabac_temporal_direct.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/VID_1280x720_cavlc_temporal_direct.264 b/src/openh264/res/VID_1280x720_cavlc_temporal_direct.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/VID_1920x1080_cabac_temporal_direct.264 b/src/openh264/res/VID_1920x1080_cabac_temporal_direct.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/VID_1920x1080_cavlc_temporal_direct.264 b/src/openh264/res/VID_1920x1080_cavlc_temporal_direct.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/Zhling_1280x720.264 b/src/openh264/res/Zhling_1280x720.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/jm_1080p_allslice.264 b/src/openh264/res/jm_1080p_allslice.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/sps_subsetsps_bothVUI.264 b/src/openh264/res/sps_subsetsps_bothVUI.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/test_cif_I_CABAC_PCM.264 b/src/openh264/res/test_cif_I_CABAC_PCM.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/test_cif_I_CABAC_slice.264 b/src/openh264/res/test_cif_I_CABAC_slice.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/test_cif_P_CABAC_slice.264 b/src/openh264/res/test_cif_P_CABAC_slice.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/test_qcif_cabac.264 b/src/openh264/res/test_qcif_cabac.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/test_scalinglist_jm.264 b/src/openh264/res/test_scalinglist_jm.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/test_vd_1d.264 b/src/openh264/res/test_vd_1d.264 old mode 100755 new mode 100644 diff --git a/src/openh264/res/test_vd_rc.264 b/src/openh264/res/test_vd_rc.264 old mode 100755 new mode 100644 diff --git a/src/openh264/subprojects/gtest.wrap b/src/openh264/subprojects/gtest.wrap old mode 100755 new mode 100644 diff --git a/src/openh264/test/BaseDecoderTest.h b/src/openh264/test/BaseDecoderTest.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/BaseEncoderTest.h b/src/openh264/test/BaseEncoderTest.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/BaseThreadDecoderTest.h b/src/openh264/test/BaseThreadDecoderTest.h new file mode 100644 index 000000000..c900a5a44 --- /dev/null +++ b/src/openh264/test/BaseThreadDecoderTest.h @@ -0,0 +1,61 @@ +#ifndef __BASETHREADDECODERTEST_H__ +#define __BASETHREADDECODERTEST_H__ + +#include "test_stdint.h" +#include +#include +#include "codec_api.h" + +#include "utils/BufferedData.h" + +class BaseThreadDecoderTest { + public: + struct Plane { + const uint8_t* data; + int width; + int height; + int stride; + }; + + struct Frame { + Plane y; + Plane u; + Plane v; + }; + + typedef enum tagDecodeStatus { + OpenFile, + Decoding, + EndOfStream, + End + } eDecodeStatus; + + struct Callback { + virtual void onDecodeFrame (const Frame& frame) = 0; + }; + + BaseThreadDecoderTest(); + int32_t SetUp(); + void TearDown(); + bool ThreadDecodeFile (const char* fileName, Callback* cbk); + + bool Open (const char* fileName); + bool DecodeNextFrame (Callback* cbk); + ISVCDecoder* decoder_; + + private: + void DecodeFrame (const uint8_t* src, size_t sliceSize, Callback* cbk); + void FlushFrame (Callback* cbk); + + std::ifstream file_; + BufferedData buf_; + BufferedData buf[16]; + SBufferInfo sBufInfo; + uint8_t* pData[3]; + uint64_t uiTimeStamp; + FILE* pYuvFile; + bool bEnableYuvDumpTest; + eDecodeStatus decodeStatus_; +}; + +#endif //__BASETHREADDECODERTEST_H__ diff --git a/src/openh264/test/api/BaseDecoderTest.cpp b/src/openh264/test/api/BaseDecoderTest.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/BaseEncoderTest.cpp b/src/openh264/test/api/BaseEncoderTest.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/BaseThreadDecoderTest.cpp b/src/openh264/test/api/BaseThreadDecoderTest.cpp new file mode 100644 index 000000000..8858dabf9 --- /dev/null +++ b/src/openh264/test/api/BaseThreadDecoderTest.cpp @@ -0,0 +1,358 @@ +#include +#include +#include "codec_def.h" +#include "codec_app_def.h" +#include "utils/BufferedData.h" +#include "BaseThreadDecoderTest.h" + +static void Write2File (FILE* pFp, unsigned char* pData[3], int iStride[2], int iWidth, int iHeight) { + int i; + unsigned char* pPtr = NULL; + + pPtr = pData[0]; + for (i = 0; i < iHeight; i++) { + fwrite (pPtr, 1, iWidth, pFp); + pPtr += iStride[0]; + } + + iHeight = iHeight / 2; + iWidth = iWidth / 2; + pPtr = pData[1]; + for (i = 0; i < iHeight; i++) { + fwrite (pPtr, 1, iWidth, pFp); + pPtr += iStride[1]; + } + + pPtr = pData[2]; + for (i = 0; i < iHeight; i++) { + fwrite (pPtr, 1, iWidth, pFp); + pPtr += iStride[1]; + } +} + +static void Process (SBufferInfo* pInfo, FILE* pFp) { + if (pFp && pInfo->pDst[0] && pInfo->pDst[1] && pInfo->pDst[2] && pInfo) { + int iStride[2]; + int iWidth = pInfo->UsrData.sSystemBuffer.iWidth; + int iHeight = pInfo->UsrData.sSystemBuffer.iHeight; + iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0]; + iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1]; + + Write2File (pFp, (unsigned char**)pInfo->pDst, iStride, iWidth, iHeight); + } +} + +static bool ReadFrame (std::ifstream* file, BufferedData* buf) { + // start code of a frame is {0, 0, 1} or {0, 0, 0, 1} + char b; + + buf->Clear(); + int32_t sps_count = 0; + int32_t non_idr_pict_count = 0; + int32_t idr_pict_count = 0; + int32_t zeroCount = 0; + for (;;) { + file->read (&b, 1); + if (file->gcount() != 1) { // end of file + return true; + } + if (!buf->PushBack (b)) { + std::cout << "unable to allocate memory" << std::endl; + return false; + } + if (buf->Length() < 5) { + continue; + } + uint8_t nal_unit_type = 0; + int32_t startcode_len_plus_one = 0; + if (buf->Length() == 5) { + if (buf->data()[2] == 1) { + nal_unit_type = buf->data()[3] & 0x1F; + } else { + nal_unit_type = buf->data()[4] & 0x1F; + } + } else { + if (zeroCount < 2) { + zeroCount = b != 0 ? 0 : zeroCount + 1; + } + if (zeroCount == 2) { + file->read (&b, 1); + if (file->gcount() != 1) { // end of file + return true; + } + if (!buf->PushBack (b)) { + std::cout << "unable to allocate memory" << std::endl; + return false; + } + if (b == 1) { //0x000001 + file->read (&b, 1); + if (file->gcount() != 1) { // end of file + return true; + } + if (!buf->PushBack (b)) { + std::cout << "unable to allocate memory" << std::endl; + return false; + } + nal_unit_type = b & 0x1F; + startcode_len_plus_one = 4; + zeroCount = 0; + } else if (b == 0) { + file->read (&b, 1); + if (file->gcount() != 1) { // end of file + return true; + } + if (!buf->PushBack (b)) { + std::cout << "unable to allocate memory" << std::endl; + return false; + } + if (b == 1) { //0x00000001 + file->read (&b, 1); + if (file->gcount() != 1) { // end of file + return true; + } + if (!buf->PushBack (b)) { + std::cout << "unable to allocate memory" << std::endl; + return false; + } + nal_unit_type = b & 0x1F; + startcode_len_plus_one = 5; + zeroCount = 0; + } else { + zeroCount = 0; + } + } else { + zeroCount = 0; + } + } + } + if (nal_unit_type == 1) { + if (++non_idr_pict_count == 1 && idr_pict_count == 1) { + file->seekg (-startcode_len_plus_one, file->cur).good(); + buf->SetLength (buf->Length() - startcode_len_plus_one); + return true; + } + if (non_idr_pict_count == 2) { + file->seekg (-startcode_len_plus_one, file->cur).good(); + buf->SetLength (buf->Length() - startcode_len_plus_one); + return true; + } + } else if (nal_unit_type == 5) { + if (++idr_pict_count == 1 && non_idr_pict_count == 1) { + file->seekg (-startcode_len_plus_one, file->cur).good(); + buf->SetLength (buf->Length() - startcode_len_plus_one); + return true; + } + if (idr_pict_count == 2) { + file->seekg (-startcode_len_plus_one, file->cur).good(); + buf->SetLength (buf->Length() - startcode_len_plus_one); + return true; + } + } else if (nal_unit_type == 7) { + if ((++sps_count == 1) && (non_idr_pict_count == 1 || idr_pict_count == 1)) { + file->seekg (-startcode_len_plus_one, file->cur).good(); + buf->SetLength (buf->Length() - startcode_len_plus_one); + return true; + } + } + } +} + +BaseThreadDecoderTest::BaseThreadDecoderTest() + : decoder_ (NULL), uiTimeStamp (0), pYuvFile (NULL), bEnableYuvDumpTest (false), decodeStatus_ (OpenFile) { +} + +int32_t BaseThreadDecoderTest::SetUp() { + long rv = WelsCreateDecoder (&decoder_); + EXPECT_EQ (0, rv); + EXPECT_TRUE (decoder_ != NULL); + if (decoder_ == NULL) { + return rv; + } + + SDecodingParam decParam; + memset (&decParam, 0, sizeof (SDecodingParam)); + decParam.uiTargetDqLayer = UCHAR_MAX; + decParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; + decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; + int iThreadCount = (rand() % 2) + 2; + decoder_->SetOption (DECODER_OPTION_NUM_OF_THREADS, &iThreadCount); + + rv = decoder_->Initialize (&decParam); + EXPECT_EQ (0, rv); + return (int32_t)rv; +} + +void BaseThreadDecoderTest::TearDown() { + if (decoder_ != NULL) { + decoder_->Uninitialize(); + WelsDestroyDecoder (decoder_); + } +} + + +void BaseThreadDecoderTest::DecodeFrame (const uint8_t* src, size_t sliceSize, Callback* cbk) { + SBufferInfo bufInfo; + memset (pData, 0, sizeof (pData)); + memset (&bufInfo, 0, sizeof (SBufferInfo)); + bufInfo.uiInBsTimeStamp = ++uiTimeStamp; + + DECODING_STATE rv = decoder_->DecodeFrameNoDelay (src, (int) sliceSize, pData, &bufInfo); + ASSERT_TRUE (rv == dsErrorFree); + sBufInfo = bufInfo; + if (sBufInfo.iBufferStatus == 1 && cbk != NULL) { + if (bEnableYuvDumpTest) { + Process (&sBufInfo, pYuvFile); + } + const Frame frame = { + { + // y plane + sBufInfo.pDst[0], + bufInfo.UsrData.sSystemBuffer.iWidth, + bufInfo.UsrData.sSystemBuffer.iHeight, + bufInfo.UsrData.sSystemBuffer.iStride[0] + }, + { + // u plane + sBufInfo.pDst[1], + sBufInfo.UsrData.sSystemBuffer.iWidth / 2, + sBufInfo.UsrData.sSystemBuffer.iHeight / 2, + sBufInfo.UsrData.sSystemBuffer.iStride[1] + }, + { + // v plane + sBufInfo.pDst[2], + sBufInfo.UsrData.sSystemBuffer.iWidth / 2, + sBufInfo.UsrData.sSystemBuffer.iHeight / 2, + sBufInfo.UsrData.sSystemBuffer.iStride[1] + }, + }; + cbk->onDecodeFrame (frame); + } +} +void BaseThreadDecoderTest::FlushFrame (Callback* cbk) { + SBufferInfo bufInfo; + memset (pData, 0, sizeof (pData)); + memset (&bufInfo, 0, sizeof (SBufferInfo)); + + DECODING_STATE rv = decoder_->FlushFrame (pData, &bufInfo); + ASSERT_TRUE (rv == dsErrorFree); + sBufInfo = bufInfo; + if (sBufInfo.iBufferStatus == 1 && cbk != NULL) { + if (bEnableYuvDumpTest) { + Process (&sBufInfo, pYuvFile); + } + const Frame frame = { + { + // y plane + sBufInfo.pDst[0], + sBufInfo.UsrData.sSystemBuffer.iWidth, + sBufInfo.UsrData.sSystemBuffer.iHeight, + sBufInfo.UsrData.sSystemBuffer.iStride[0] + }, + { + // u plane + sBufInfo.pDst[1], + sBufInfo.UsrData.sSystemBuffer.iWidth / 2, + sBufInfo.UsrData.sSystemBuffer.iHeight / 2, + sBufInfo.UsrData.sSystemBuffer.iStride[1] + }, + { + // v plane + sBufInfo.pDst[2], + sBufInfo.UsrData.sSystemBuffer.iWidth / 2, + sBufInfo.UsrData.sSystemBuffer.iHeight / 2, + sBufInfo.UsrData.sSystemBuffer.iStride[1] + }, + }; + cbk->onDecodeFrame (frame); + } +} +bool BaseThreadDecoderTest::ThreadDecodeFile (const char* fileName, Callback* cbk) { + std::ifstream file (fileName, std::ios::in | std::ios::binary); + if (!file.is_open()) + return false; + + std::string outFileName = std::string (fileName); + size_t pos = outFileName.find_last_of ("."); + if (bEnableYuvDumpTest) { + outFileName = outFileName.substr (0, pos) + std::string (".yuv"); + pYuvFile = fopen (outFileName.c_str(), "wb"); + } + + int iBufIndex = 0; + uiTimeStamp = 0; + memset (&sBufInfo, 0, sizeof (SBufferInfo)); + while (true) { + if (false == ReadFrame (&file, &buf[iBufIndex])) + return false; + if (::testing::Test::HasFatalFailure()) { + return false; + } + if (buf[iBufIndex].Length() == 0) { + break; + } + DecodeFrame (buf[iBufIndex].data(), buf[iBufIndex].Length(), cbk); + if (::testing::Test::HasFatalFailure()) { + return false; + } + if (++iBufIndex >= 16) { + iBufIndex = 0; + } + } + + int32_t iEndOfStreamFlag = 1; + decoder_->SetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag); + + // Flush out last frames in decoder buffer + int32_t num_of_frames_in_buffer = 0; + decoder_->GetOption (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER, &num_of_frames_in_buffer); + for (int32_t i = 0; i < num_of_frames_in_buffer; ++i) { + FlushFrame (cbk); + } + if (bEnableYuvDumpTest) { + fclose (pYuvFile); + } + return true; +} + +bool BaseThreadDecoderTest::Open (const char* fileName) { + if (decodeStatus_ == OpenFile) { + file_.open (fileName, std::ios_base::out | std::ios_base::binary); + if (file_.is_open()) { + decodeStatus_ = Decoding; + return true; + } + } + return false; +} + +bool BaseThreadDecoderTest::DecodeNextFrame (Callback* cbk) { + switch (decodeStatus_) { + case Decoding: + if (false == ReadFrame (&file_, &buf_)) + return false; + if (::testing::Test::HasFatalFailure()) { + return false; + } + if (buf_.Length() == 0) { + decodeStatus_ = EndOfStream; + return true; + } + DecodeFrame (buf_.data(), buf_.Length(), cbk); + if (::testing::Test::HasFatalFailure()) { + return false; + } + return true; + case EndOfStream: { + int32_t iEndOfStreamFlag = 1; + decoder_->SetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag); + DecodeFrame (NULL, 0, cbk); + decodeStatus_ = End; + break; + } + case OpenFile: + case End: + break; + } + return false; +} diff --git a/src/openh264/test/api/DataGenerator.cpp b/src/openh264/test/api/DataGenerator.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/c_interface_test.c b/src/openh264/test/api/c_interface_test.c old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/cpp_interface_test.cpp b/src/openh264/test/api/cpp_interface_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/decode_api_test.cpp b/src/openh264/test/api/decode_api_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/decode_encode_test.cpp b/src/openh264/test/api/decode_encode_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/decoder_ec_test.cpp b/src/openh264/test/api/decoder_ec_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/decoder_test.cpp b/src/openh264/test/api/decoder_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/encode_decode_api_test.cpp b/src/openh264/test/api/encode_decode_api_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/encode_decode_api_test.h b/src/openh264/test/api/encode_decode_api_test.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/encode_decode_api_test.template b/src/openh264/test/api/encode_decode_api_test.template old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/encode_options_test.cpp b/src/openh264/test/api/encode_options_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/encoder_test.cpp b/src/openh264/test/api/encoder_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/ltr_test.cpp b/src/openh264/test/api/ltr_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/meson.build b/src/openh264/test/api/meson.build old mode 100755 new mode 100644 index 815a7ebd6..7655a3782 --- a/src/openh264/test/api/meson.build +++ b/src/openh264/test/api/meson.build @@ -1,5 +1,6 @@ test_sources = [ 'BaseDecoderTest.cpp', + 'BaseThreadDecoderTest.cpp', 'BaseEncoderTest.cpp', 'cpp_interface_test.cpp', 'DataGenerator.cpp', @@ -7,6 +8,7 @@ test_sources = [ 'decode_encode_test.cpp', 'decoder_ec_test.cpp', 'decoder_test.cpp', + 'thread_decoder_test.cpp', 'encode_decode_api_test.cpp', 'encode_options_test.cpp', 'encoder_test.cpp', diff --git a/src/openh264/test/api/sha1.c b/src/openh264/test/api/sha1.c old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/simple_test.cpp b/src/openh264/test/api/simple_test.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/api/targets.mk b/src/openh264/test/api/targets.mk old mode 100755 new mode 100644 index 5c2f65249..3a9dd8155 --- a/src/openh264/test/api/targets.mk +++ b/src/openh264/test/api/targets.mk @@ -4,6 +4,7 @@ API_TEST_SRCDIR=test/api API_TEST_CPP_SRCS=\ $(API_TEST_SRCDIR)/BaseDecoderTest.cpp\ + $(API_TEST_SRCDIR)/BaseThreadDecoderTest.cpp\ $(API_TEST_SRCDIR)/BaseEncoderTest.cpp\ $(API_TEST_SRCDIR)/cpp_interface_test.cpp\ $(API_TEST_SRCDIR)/DataGenerator.cpp\ @@ -11,6 +12,7 @@ API_TEST_CPP_SRCS=\ $(API_TEST_SRCDIR)/decode_encode_test.cpp\ $(API_TEST_SRCDIR)/decoder_ec_test.cpp\ $(API_TEST_SRCDIR)/decoder_test.cpp\ + $(API_TEST_SRCDIR)/thread_decoder_test.cpp\ $(API_TEST_SRCDIR)/encode_decode_api_test.cpp\ $(API_TEST_SRCDIR)/encode_options_test.cpp\ $(API_TEST_SRCDIR)/encoder_test.cpp\ diff --git a/src/openh264/test/api/thread_decoder_test.cpp b/src/openh264/test/api/thread_decoder_test.cpp new file mode 100644 index 000000000..2b5c21589 --- /dev/null +++ b/src/openh264/test/api/thread_decoder_test.cpp @@ -0,0 +1,153 @@ +#include +#include "utils/HashFunctions.h" +#include "BaseThreadDecoderTest.h" +#include + +static void UpdateHashFromPlane (SHA1Context* ctx, const uint8_t* plane, + int width, int height, int stride) { + for (int i = 0; i < height; i++) { + SHA1Input (ctx, plane, width); + plane += stride; + } +} + +class ThreadDecoderCapabilityTest : public ::testing::Test { + public: + virtual void SetUp() {} + virtual void TearDown() {} +}; + +TEST_F (ThreadDecoderCapabilityTest, JustInit) { + SDecoderCapability sDecCap; + int iRet = WelsGetDecoderCapability (&sDecCap); + ASSERT_TRUE (iRet == 0); + EXPECT_EQ (sDecCap.iProfileIdc, 66); + EXPECT_EQ (sDecCap.iProfileIop, 0xE0); + EXPECT_EQ (sDecCap.iLevelIdc, 32); + EXPECT_EQ (sDecCap.iMaxMbps, 216000); + EXPECT_EQ (sDecCap.iMaxFs, 5120); + EXPECT_EQ (sDecCap.iMaxCpb, 20000); + EXPECT_EQ (sDecCap.iMaxDpb, 20480); + EXPECT_EQ (sDecCap.iMaxBr, 20000); + EXPECT_EQ (sDecCap.bRedPicCap, false); +} + + +class ThreadDecoderInitTest : public ::testing::Test, public BaseThreadDecoderTest { + public: + virtual void SetUp() { + BaseThreadDecoderTest::SetUp(); + } + virtual void TearDown() { + BaseThreadDecoderTest::TearDown(); + } +}; + +TEST_F (ThreadDecoderInitTest, JustInit) {} +struct FileParam { + const char* fileName; + const char* hashStr; +}; + +class ThreadDecoderOutputTest : public ::testing::WithParamInterface, + public ThreadDecoderInitTest, public BaseThreadDecoderTest::Callback { + public: + virtual void SetUp() { + ThreadDecoderInitTest::SetUp(); + if (HasFatalFailure()) { + return; + } + SHA1Reset (&ctx_); + } + virtual void onDecodeFrame (const Frame& frame) { + const Plane& y = frame.y; + const Plane& u = frame.u; + const Plane& v = frame.v; + UpdateHashFromPlane (&ctx_, y.data, y.width, y.height, y.stride); + UpdateHashFromPlane (&ctx_, u.data, u.width, u.height, u.stride); + UpdateHashFromPlane (&ctx_, v.data, v.width, v.height, v.stride); + } + protected: + SHA1Context ctx_; +}; + +TEST_P (ThreadDecoderOutputTest, CompareOutput) { + FileParam p = GetParam(); +#if defined(ANDROID_NDK) + std::string filename = std::string ("/sdcard/") + p.fileName; + ASSERT_TRUE (ThreadDecodeFile (filename.c_str(), this)); +#else + ASSERT_TRUE (ThreadDecodeFile (p.fileName, this)); +#endif + + unsigned char digest[SHA_DIGEST_LENGTH]; + SHA1Result (&ctx_, digest); + if (!HasFatalFailure()) { + std::string p_hashStr (p.hashStr); + std::stringstream ss (p_hashStr); + std::string buf[4]; + const char* hashStr[4]; + int i = 0; + while (i < 4 && ss >> buf[i]) { + hashStr[i] = buf[i].c_str(); + ++i; + } + CompareHashAnyOf (digest, hashStr, i); + } +} +static const FileParam kFileParamArray[] = { + {"res/Adobe_PDF_sample_a_1024x768_50Frms.264", "041434a5819d1d903d49c0eda884b345e9f83596 9aa9a4d9598eb3e1093311826844f37c43e4c521"}, + /*{"res/BA1_FT_C.264", "07490b43e8da6d9ef2fab066a0ac7491c7027297 3e7a012a01904cdc78c63ae20235665441b4e0a7"}, + {"res/BA1_Sony_D.jsv", "37c9a951a0348d6abe1880b59e2b5a4d7d18c94c"}, + {"res/BAMQ1_JVC_C.264", "6720462624f632f5475716ef32a7bbd12b3b428a 477b1e45e30661a138ff0b43c1ed3e00ded13d9c"}, + {"res/BAMQ2_JVC_C.264", "5f0fbb0dab7961e782224f6887c83d4866fc1af8 e3dfdc770fa5fee8b92f896a92214886c109a688"}, + {"res/BA_MW_D.264", "ace02cdce720bdb0698b40dc749a0e61fe0f590b"}, + {"res/BANM_MW_D.264", "c51f1d2fa63dba4f5787f1b726c056d1c01d6ab9"}, + {"res/BASQP1_Sony_C.jsv", "68e604b77e3f57f8ef1c2e450fcef03f5d2aee90 d5e1f122e8bf8d58bc6775d69b837db0d9ea3454"}, + {"res/CI1_FT_B.264", "2e4d613dddd7c15d0daaaa60ffc038001dfad017 05cb35998476202eb4a3e67d4314c0cca5d743f6"}, + {"res/CI_MW_D.264", "49a8916edd3e571efad328f2784fbe6aec5570d7"}, + {"res/CVFC1_Sony_C.jsv", "109dfc8357a98b16aa74469a5506e362e563aa85 7d2a1c2e863baaaefff70ca4e6a62cb16f8792b2"}, + {"res/CVPCMNL1_SVA_C.264", "c2b0d964de727c64b9fccb58f63b567c82bda95a"}, + //{"res/LS_SVA_D.264", "72118f4d1674cf14e58bed7e67cb3aeed3df62b9"}, //DPB buffer is too small + {"res/MIDR_MW_D.264", "aeded2be7b97484cbf25f367ec34208f2220a8ab"}, + {"res/MPS_MW_A.264", "b0fce28218e678d89f464810f88b143ada49dd06"}, + //{"res/MR1_BT_A.h264", "eebd1d7cdb67df5b8688b1ce18f6acae129b32e6 d20e96f9ecc2e24c13eb25b1c786da53eb716327"}, three hash values temp disabled + {"res/MR1_MW_A.264", "14d8ddb12ed711444039329db29c496b079680ba"}, + //{"res/MR2_MW_A.264", "6d332a653fe3b923eb3af8f3695d46ce2a1d4b2c e379caa57c0c60ca6d6091c19815c7422e3c59c7 34f0359290b9e83be82ea2f8e763d920ec446b7b 14a38e41f4dbf924b8eff6e96aad77394c8aabcd"}, + //{"res/MR2_TANDBERG_E.264", "74d618bc7d9d41998edf4c85d51aa06111db6609"}, //DPB buffer is too small + {"res/NL1_Sony_D.jsv", "e401e30669938443c2f02522fd4d5aa1382931a0"}, + {"res/NLMQ1_JVC_C.264", "f3265c6ddf8db1b2bf604d8a2954f75532e28cda a86ec7a843e93f44aaee2619a7932c6c5c8d233f"}, + {"res/NLMQ2_JVC_C.264", "350ae86ef9ba09390d63a09b7f9ff54184109ca8 95e6e4426b75f38a6744f3d04cfc62a2c0489354"}, + {"res/NRF_MW_E.264", "866f267afd2ed1595bcb90de0f539e929c169aa4 db2d135cef07db8247ef858daf870d07955b912a"}, + {"res/QCIF_2P_I_allIPCM.264", "9879ce127d3263cfbaf5211ab6657dbf0ccabea8"}, + { "res/SVA_BA1_B.264", "4cb45a99ae44a0a98b174efd66245daa1fbaeb47 e9127875b268f9e7da4c495799b9972b8e72cf7b"}, + {"res/SVA_BA2_D.264", "ac9e960015b96f83279840802f6637c61ee1c5b8 719fe839fa68b915b614fbbbae15edf492cc2133"}, + {"res/SVA_Base_B.264", "a66d05c38b8f6e4e55e18237cac70b0c211a3b6e d8f923b278e6e9cbf51b495b29c2debe53526518"}, + {"res/SVA_CL1_E.264", "4fe09ab6cdc965ea10a20f1d6dd38aca954412bb"}, + {"res/SVA_FM1_E.264", "9aea4ea84c75adbdf884dcab3705ed5a96406e85 dc22699d39caf9eb1d32ecd4966869578d24cd86"}, + {"res/SVA_NL1_B.264", "6d63f72a0c0d833b1db0ba438afff3b4180fb3e6"}, + {"res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"}, + //{"res/SarVui.264", "1843d19d8e13588ef5de2d647804ae141e55cf72 719fe839fa68b915b614fbbbae15edf492cc2133"}, //same as "res/SVA_BA1_B.264" + {"res/Static.264", "d865faee7df56a8f532b7baeacb814483b8be148 52af285a888b8c9e04dc9f38fd61105e805ada3a 1b6313262bff9c329aaf7dd3582525bd609c3974"}, + {"res/Zhling_1280x720.264", "10f9c803e80b51786f7833255afc3ef75c5c1339"}, + {"res/sps_subsetsps_bothVUI.264", "d65a34075c452196401340c554e83225c9454397"}, + //{"res/test_cif_I_CABAC_PCM.264", "dfe2f87ac76bdb58e227267907a2eeccf04715ad 02ac993be06b5d88118beb96ee5dfd0995b7cb00 95fdf21470d3bbcf95505abb2164042063a79d98 c2b42f489ca9c2ebc43c0ab2238551a0c958a692"}, + {"res/test_cif_I_CABAC_slice.264", "4260cc7a211895341092b0361bcfc3f13721ab44 106da52c2c6d30255b6ac0aa0b4a881a06ebb762"}, + //{"res/test_cif_P_CABAC_slice.264", "ac2d1e9ca0e097ab44a4b592a93e06e5c0c3d761 276a5ccef4bbe20ad9c769824aea5553acc7b54a 8ba773ccf5f682a4a90b0d070aa4198a5cfa0220 b09e066f797235fed8f59c408b5914d143f71c9e"}, + {"res/test_qcif_cabac.264", "c79e9a32e4d9e38a1bd12079da19dcb0d2efe539"}, + {"res/test_scalinglist_jm.264", "b36efd05c8b17faa23f1c071b92aa5d55a5a826f"}, + {"res/test_vd_1d.264", "15d8beaf991f9e5d56a854cdafc0a7abdd5bec69"}, + {"res/test_vd_rc.264", "cd6ef57fc884e5ecd9867591b01e35e3f091b8d0"}, + {"res/Cisco_Men_whisper_640x320_CABAC_Bframe_9.264", "7df59855104a319b44a7611dd6c37b1670bf74c9 f5593d374e8f68b1c882d407d961d80cf10ba737"}, + {"res/Cisco_Men_whisper_640x320_CAVLC_Bframe_9.264", "0d77e3c53f46d8962cd95b975e76d0f32613da0f 67eec8abb0b22ff0f00d06c769b8a2e44cec33cf"}, + {"res/Cisco_Adobe_PDF_sample_a_1024x768_CAVLC_Bframe_9.264", "6cac61a6b58bba59b8e9944b18aba2df20efeca2"}, + {"res/VID_1280x544_cabac_temporal_direct.264", "e8ee8dd56ec5df1338f3c21ed8690d074c7ec03f"}, + {"res/VID_1280x720_cabac_temporal_direct.264", "1efa6aec8c5f953c53d713c31999420fdbd10b22"}, + {"res/VID_1920x1080_cabac_temporal_direct.264", "90b3f1cf0c85b490108a2db40d2b2151ee346dfb aafd2606e8fe8be2a956deed48218c9f5176b3d0"}, + {"res/VID_1280x544_cavlc_temporal_direct.264", "fe779025f3b42d6fc3590476cb3594540950d716"}, + {"res/VID_1280x720_cavlc_temporal_direct.264", "1c5afab7cfeb082b087821d4220d57238c1c161f"}, + {"res/VID_1920x1080_cavlc_temporal_direct.264", "5c47d30fed9d2988c653b2c3bc83f6d19dfa5ab1 eecd84b68f416270eb21c6c90a4cef8603d37e25"},*/ +}; + +INSTANTIATE_TEST_CASE_P (ThreadDecodeFile, ThreadDecoderOutputTest, + ::testing::ValuesIn (kFileParamArray)); diff --git a/src/openh264/test/build/android/.gitignore b/src/openh264/test/build/android/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/AndroidManifest.xml b/src/openh264/test/build/android/AndroidManifest.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/jni/Android.mk b/src/openh264/test/build/android/jni/Android.mk old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/jni/Application.mk b/src/openh264/test/build/android/jni/Application.mk old mode 100755 new mode 100644 index 48ca94b65..175295f48 --- a/src/openh264/test/build/android/jni/Application.mk +++ b/src/openh264/test/build/android/jni/Application.mk @@ -1,2 +1,6 @@ +ifeq ($(NDK_TOOLCHAIN_VERSION), clang) +APP_STL := c++_shared +else APP_STL := stlport_shared +endif APP_PLATFORM := android-12 diff --git a/src/openh264/test/build/android/jni/codec_unittest.cpp b/src/openh264/test/build/android/jni/codec_unittest.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/res/layout/activity_main.xml b/src/openh264/test/build/android/res/layout/activity_main.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/res/values-v11/styles.xml b/src/openh264/test/build/android/res/values-v11/styles.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/res/values-w820dp/dimens.xml b/src/openh264/test/build/android/res/values-w820dp/dimens.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/res/values/dimens.xml b/src/openh264/test/build/android/res/values/dimens.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/res/values/strings.xml b/src/openh264/test/build/android/res/values/strings.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/res/values/styles.xml b/src/openh264/test/build/android/res/values/styles.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/android/src/com/cisco/codec/unittest/MainActivity.java b/src/openh264/test/build/android/src/com/cisco/codec/unittest/MainActivity.java old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/win32/.gitignore b/src/openh264/test/build/win32/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/win32/codec_ut/Codec_UT.sln b/src/openh264/test/build/win32/codec_ut/Codec_UT.sln old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/win32/codec_ut/codec_unittest.vcproj b/src/openh264/test/build/win32/codec_ut/codec_unittest.vcproj old mode 100755 new mode 100644 index 2f013d943..b6bce06c3 --- a/src/openh264/test/build/win32/codec_ut/codec_unittest.vcproj +++ b/src/openh264/test/build/win32/codec_ut/codec_unittest.vcproj @@ -330,6 +330,10 @@ RelativePath="..\..\..\api\BaseDecoderTest.cpp" > + + @@ -362,6 +366,10 @@ RelativePath="..\..\..\api\decoder_test.cpp" > + + diff --git a/src/openh264/test/build/win32/codec_ut/preprocessing_lib.vcproj b/src/openh264/test/build/win32/codec_ut/preprocessing_lib.vcproj old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/.gitignore b/src/openh264/test/build/windowsphone/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/App.xaml b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/App.xaml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/App.xaml.cs b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/App.xaml.cs old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/AlignmentGrid.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/AlignmentGrid.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/ApplicationIcon.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/ApplicationIcon.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/BadgeLogo.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/BadgeLogo.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Logo.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Logo.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SplashScreen.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SplashScreen.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SquareTile150x150.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SquareTile150x150.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SquareTile71x71.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/SquareTile71x71.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/StoreLogo.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/StoreLogo.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileLarge.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileLarge.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileMedium.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileMedium.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileSmall.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/FlipCycleTileSmall.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/IconicTileMediumLarge.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/IconicTileMediumLarge.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/IconicTileSmall.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/Tiles/IconicTileSmall.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/WideLogo.png b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Assets/WideLogo.png old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/CodecUTApp.csproj b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/CodecUTApp.csproj old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/LocalizedStrings.cs b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/LocalizedStrings.cs old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/MainPage.xaml b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/MainPage.xaml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/MainPage.xaml.cs b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/MainPage.xaml.cs old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Package.appxmanifest b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Package.appxmanifest old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/AppManifest.xml b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/AppManifest.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/AssemblyInfo.cs b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/AssemblyInfo.cs old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/WMAppManifest.xml b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Properties/WMAppManifest.xml old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Resources/AppResources.Designer.cs b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Resources/AppResources.Designer.cs old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Resources/AppResources.resx b/src/openh264/test/build/windowsphone/codec_ut/CodecUTApp/Resources/AppResources.resx old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/Codec_UT.sln b/src/openh264/test/build/windowsphone/codec_ut/Codec_UT.sln old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.cpp b/src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.h b/src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.vcxproj b/src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.vcxproj old mode 100755 new mode 100644 diff --git a/src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.vcxproj.filters b/src/openh264/test/build/windowsphone/codec_ut/Codec_UT_RTComponent.vcxproj.filters old mode 100755 new mode 100644 diff --git a/src/openh264/test/common/CWelsListTest.cpp b/src/openh264/test/common/CWelsListTest.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/common/ExpandPicture.cpp b/src/openh264/test/common/ExpandPicture.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/common/WelsTaskListTest.cpp b/src/openh264/test/common/WelsTaskListTest.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/common/WelsThreadPoolTest.cpp b/src/openh264/test/common/WelsThreadPoolTest.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/common/WelsThreadPoolTest.h b/src/openh264/test/common/WelsThreadPoolTest.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/common/meson.build b/src/openh264/test/common/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/test/common/targets.mk b/src/openh264/test/common/targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/test/decoder/DecUT_Deblock.cpp b/src/openh264/test/decoder/DecUT_Deblock.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/decoder/DecUT_DeblockCommon.cpp b/src/openh264/test/decoder/DecUT_DeblockCommon.cpp old mode 100755 new mode 100644 index 0443ec341..189da6f84 --- a/src/openh264/test/decoder/DecUT_DeblockCommon.cpp +++ b/src/openh264/test/decoder/DecUT_DeblockCommon.cpp @@ -804,11 +804,11 @@ TEST (DecoderDeblocking, DeblockingBsMarginalMBAvcbase) { // Dummy picture list pointers to 1..MAX_DPB_COUNT // the pointer values don't need to be valid, just different for (i = 0; i < MAX_DPB_COUNT; i++) - iFilterPics[0][i] = iFilterPics[1][i] = (PPicture)(iFilterPics + (i<<3)); + iFilterPics[0][i] = iFilterPics[1][i] = (PPicture) (iFilterPics[0] + i); sFilter.pRefPics[0] = iFilterPics[0]; sFilter.pRefPics[1] = iFilterPics[1]; - + sDqLayer.pDec = NULL; #define UT_DB_CLEAN_STATUS \ memset(iNoZeroCount, 0, sizeof(int8_t)*24*2); \ memset(iLayerRefIndex, 0, sizeof(int8_t)*2*16*2); \ @@ -829,14 +829,14 @@ TEST (DecoderDeblocking, DeblockingBsMarginalMBAvcbase) { // (1) iEdge == 0, current block NoZeroCount != 0 UT_DB_CLEAN_STATUS iNoZeroCount[0 * 24 + iCurrBlock] = 1; // Current MB_block position - SET_REF_VALUE(2, iPos); + SET_REF_VALUE (2, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " NoZeroCount!=0"; // (2) iEdge == 0, neighbor block NoZeroCount != 0 UT_DB_CLEAN_STATUS iNoZeroCount[1 * 24 + iNeighborBlock ] = 1; // Neighbor MB_block position - SET_REF_VALUE(2, iPos); + SET_REF_VALUE (2, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " NoZeroCount!=0"; @@ -844,63 +844,67 @@ TEST (DecoderDeblocking, DeblockingBsMarginalMBAvcbase) { UT_DB_CLEAN_STATUS iLayerRefIndex[0][0 * 16 + iCurrBlock] = 0; iLayerRefIndex[0][1 * 16 + iNeighborBlock] = 1; - SET_REF_VALUE(1, iPos); + SET_REF_VALUE (1, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " Ref idx diff"; // (4) iEdge == 0, abs(mv diff) < 4 UT_DB_CLEAN_STATUS iLayerMv[0][0 * 16 + iCurrBlock][0] = rand() % 4; - EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == 0) << iEdge << " " << iPos << " diff_mv < 4"; + EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, + 0) == 0) << iEdge << " " << iPos << " diff_mv < 4"; UT_DB_CLEAN_STATUS iLayerMv[0][0 * 16 + iCurrBlock][1] = rand() % 4; - EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == 0) << iEdge << " " << iPos << " diff_mv < 4"; + EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, + 0) == 0) << iEdge << " " << iPos << " diff_mv < 4"; UT_DB_CLEAN_STATUS iLayerMv[0][1 * 16 + iNeighborBlock][0] = rand() % 4; - EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == 0) << iEdge << " " << iPos << " diff_mv < 4"; + EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, + 0) == 0) << iEdge << " " << iPos << " diff_mv < 4"; UT_DB_CLEAN_STATUS iLayerMv[0][1 * 16 + iNeighborBlock][1] = rand() % 4; - EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == 0) << iEdge << " " << iPos << " diff_mv < 4"; + EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, + 0) == 0) << iEdge << " " << iPos << " diff_mv < 4"; // (5) iEdge == 0, abs(mv diff) > 4 UT_DB_CLEAN_STATUS iLayerMv[0][0 * 16 + iCurrBlock][0] = 4; - SET_REF_VALUE(1, iPos); + SET_REF_VALUE (1, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4"; UT_DB_CLEAN_STATUS iLayerMv[0][0 * 16 + iCurrBlock][1] = 4; - SET_REF_VALUE(1, iPos); + SET_REF_VALUE (1, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4"; UT_DB_CLEAN_STATUS iLayerMv[0][1 * 16 + iNeighborBlock][0] = 4; - SET_REF_VALUE(1, iPos); + SET_REF_VALUE (1, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4"; UT_DB_CLEAN_STATUS iLayerMv[0][1 * 16 + iNeighborBlock][1] = 4; - SET_REF_VALUE(1, iPos); + SET_REF_VALUE (1, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4"; UT_DB_CLEAN_STATUS iLayerMv[0][0 * 16 + iCurrBlock][0] = -2048; iLayerMv[0][1 * 16 + iNeighborBlock][0] = 2047; - SET_REF_VALUE(1, iPos); + SET_REF_VALUE (1, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == maximum"; UT_DB_CLEAN_STATUS iLayerMv[0][0 * 16 + iCurrBlock][1] = -2048; iLayerMv[0][1 * 16 + iNeighborBlock][1] = 2047; - SET_REF_VALUE(1, iPos); + SET_REF_VALUE (1, iPos); EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == maximum"; } @@ -912,7 +916,7 @@ TEST (Deblocking, WelsDeblockingMb) { /* Deblock one MB, calculate the Bs inside the function, only consider the intra / intra block */ SDqLayer sDqLayer; sDqLayer.sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.eSliceType = P_SLICE; - + sDqLayer.pDec = NULL; SDeblockingFilter sFilter; SDeblockingFunc sDBFunc; sFilter.pLoopf = &sDBFunc; diff --git a/src/openh264/test/decoder/DecUT_DecExt.cpp b/src/openh264/test/decoder/DecUT_DecExt.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/decoder/DecUT_ErrorConcealment.cpp b/src/openh264/test/decoder/DecUT_ErrorConcealment.cpp old mode 100755 new mode 100644 index 382956446..28483c137 --- a/src/openh264/test/decoder/DecUT_ErrorConcealment.cpp +++ b/src/openh264/test/decoder/DecUT_ErrorConcealment.cpp @@ -21,6 +21,7 @@ typedef struct TagECInputCtx { SPicture sAncPic; //Anc picture for comparison SPicture sSrcPic; //Src picture as common input picture data SPicture sWelsPic; //Wels picture to be compared + SWelsLastDecPicInfo sLastDecPicInfo; } SECInputCtx, *PECInputCtx; void FreeInputData (PECInputCtx pECCtx) { @@ -90,7 +91,7 @@ int32_t InitAndAllocInputData (PECInputCtx& pECCtx) { pECCtx->pCtx->pDec = &pECCtx->sWelsPic; pECCtx->pCtx->pCurDqLayer = &pECCtx->sDqLayer; pECCtx->pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag = pECCtx->pMbCorrectlyDecodedFlag; - + pECCtx->pCtx->pLastDecPicInfo = &pECCtx->sLastDecPicInfo; pECCtx->pCtx->pSps = (PSps) WelsMallocz (sizeof (SSps), "pECCtx->pCtx->pSps"); if (pECCtx->pCtx->pSps == NULL) return 1; @@ -124,7 +125,7 @@ void DoAncErrorConSliceCopy (PECInputCtx pECCtx) { int32_t iMbWidth = (int32_t) pECCtx->iMbWidth; int32_t iMbHeight = (int32_t) pECCtx->iMbHeight; PPicture pDstPic = &pECCtx->sAncPic; - PPicture pSrcPic = pECCtx->pCtx->pPreviousDecodedPictureInDpb; + PPicture pSrcPic = pECCtx->pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb; if ((pECCtx->pCtx->pParam->eEcActiveIdc == ERROR_CON_SLICE_COPY) && (pECCtx->pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag)) pSrcPic = NULL; @@ -244,7 +245,7 @@ TEST (ErrorConTest, DoErrorConFrameCopy) { int32_t iLumaSize = pECCtx->iMbWidth * pECCtx->iMbHeight * 256; for (int iRef = 0; iRef < 2; ++ iRef) { //no ref, with ref - pECCtx->pCtx->pPreviousDecodedPictureInDpb = iRef ? &pECCtx->sSrcPic : NULL; + pECCtx->pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = iRef ? &pECCtx->sSrcPic : NULL; for (int iIDR = 0; iIDR < 2; ++ iIDR) { //non IDR, IDR pECCtx->pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag = (iIDR > 0); //Do reference code method @@ -279,7 +280,7 @@ TEST (ErrorConTest, DoErrorConSliceCopy) { pECCtx->pCtx->pParam->eEcActiveIdc = iEC > 0 ? ERROR_CON_SLICE_COPY_CROSS_IDR : ERROR_CON_SLICE_COPY; InitECCopyData (pECCtx); for (int iRef = 0; iRef < 2; ++ iRef) { //no ref, with ref - pECCtx->pCtx->pPreviousDecodedPictureInDpb = iRef ? &pECCtx->sSrcPic : NULL; + pECCtx->pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = iRef ? &pECCtx->sSrcPic : NULL; for (int iIDR = 0; iIDR < 2; ++ iIDR) { //non IDR, IDR pECCtx->pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag = (iIDR > 0); //Do reference code method diff --git a/src/openh264/test/decoder/DecUT_IdctResAddPred.cpp b/src/openh264/test/decoder/DecUT_IdctResAddPred.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/decoder/DecUT_IntraPrediction.cpp b/src/openh264/test/decoder/DecUT_IntraPrediction.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/decoder/DecUT_ParseSyntax.cpp b/src/openh264/test/decoder/DecUT_ParseSyntax.cpp old mode 100755 new mode 100644 index adc31ee12..4e78b158e --- a/src/openh264/test/decoder/DecUT_ParseSyntax.cpp +++ b/src/openh264/test/decoder/DecUT_ParseSyntax.cpp @@ -155,6 +155,11 @@ class DecoderParseSyntaxTest : public ::testing::Test { SDecodingParam m_sDecParam; SBufferInfo m_sBufferInfo; SParserBsInfo m_sParserBsInfo; + SWelsDecoderSpsPpsCTX m_sDecoderSpsPpsCTX; + SWelsLastDecPicInfo m_sLastDecPicInfo; + SDecoderStatistics m_sDecoderStatistics; + SVlcTable m_sVlcTable; + uint8_t* m_pData[3]; unsigned char m_szBuffer[BUF_SIZE]; //for mocking packet int m_iBufLength; //record the valid data in m_szBuffer @@ -168,6 +173,11 @@ int32_t DecoderParseSyntaxTest::Init() { memset (&m_sBufferInfo, 0, sizeof (SBufferInfo)); memset (&m_sDecParam, 0, sizeof (SDecodingParam)); memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo)); + memset (&m_sDecoderSpsPpsCTX, 0, sizeof (SWelsDecoderSpsPpsCTX)); + memset (&m_sLastDecPicInfo, 0, sizeof (SWelsLastDecPicInfo)); + memset (&m_sDecoderStatistics, 0, sizeof (SDecoderStatistics)); + memset (&m_sVlcTable, 0, sizeof (SVlcTable)); + m_sDecParam.pFileNameRestructed = NULL; m_sDecParam.uiCpuLoad = rand() % 100; m_sDecParam.uiTargetDqLayer = rand() % 100; @@ -193,6 +203,10 @@ int32_t DecoderParseSyntaxTest::Init() { m_pCtx = NULL; return ERR_MALLOC_FAILED; } + m_pCtx->pLastDecPicInfo = &m_sLastDecPicInfo; + m_pCtx->pDecoderStatistics = &m_sDecoderStatistics; + m_pCtx->pVlcTable = &m_sVlcTable; + WelsDecoderSpsPpsDefaults (m_pCtx->sSpsPpsCtx); CM_RETURN eRet = (CM_RETURN)Initialize (&m_sDecParam, m_pCtx, &m_pWelsTrace->m_sLogCtx); return (int32_t)eRet; } @@ -377,23 +391,23 @@ void DecoderParseSyntaxTest::TestScalingList() { iRet = Init(); ASSERT_EQ (iRet, ERR_NONE); ASSERT_TRUE (DecodeBs ("res/BA_MW_D.264", CorrectDec)); - ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false); - EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t))); - ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false); - EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t))); + ASSERT_TRUE (m_pCtx->sSpsPpsCtx.sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false); + EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsPpsCtx.sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t))); + ASSERT_TRUE (m_pCtx->sSpsPpsCtx.sPpsBuffer[0].bPicScalingMatrixPresentFlag == false); + EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsPpsCtx.sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t))); Uninit(); //Scalinglist value just written into sps and pps iRet = Init(); ASSERT_EQ (iRet, ERR_NONE); ASSERT_TRUE (DecodeBs ("res/test_scalinglist_jm.264", CorrectDec)); - ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag); + ASSERT_TRUE (m_pCtx->sSpsPpsCtx.sSpsBuffer[0].bSeqScalingMatrixPresentFlag); for (int i = 0; i < 6; i++) { - EXPECT_EQ (0, memcmp (iScalingList[i], m_pCtx->sSpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t))); + EXPECT_EQ (0, memcmp (iScalingList[i], m_pCtx->sSpsPpsCtx.sSpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t))); } - ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == true); + ASSERT_TRUE (m_pCtx->sSpsPpsCtx.sPpsBuffer[0].bPicScalingMatrixPresentFlag == true); for (int i = 0; i < 6; i++) { - EXPECT_EQ (0, memcmp (iScalingListPPS[i], m_pCtx->sPpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t))); + EXPECT_EQ (0, memcmp (iScalingListPPS[i], m_pCtx->sSpsPpsCtx.sPpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t))); } Uninit(); } diff --git a/src/openh264/test/decoder/DecUT_PredMv.cpp b/src/openh264/test/decoder/DecUT_PredMv.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/decoder/meson.build b/src/openh264/test/decoder/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/test/decoder/targets.mk b/src/openh264/test/decoder/targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_Cavlc.cpp b/src/openh264/test/encoder/EncUT_Cavlc.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_DecodeMbAux.cpp b/src/openh264/test/encoder/EncUT_DecodeMbAux.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_EncoderExt.cpp b/src/openh264/test/encoder/EncUT_EncoderExt.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_EncoderMb.cpp b/src/openh264/test/encoder/EncUT_EncoderMb.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_EncoderMbAux.cpp b/src/openh264/test/encoder/EncUT_EncoderMbAux.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_EncoderTaskManagement.cpp b/src/openh264/test/encoder/EncUT_EncoderTaskManagement.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_ExpGolomb.cpp b/src/openh264/test/encoder/EncUT_ExpGolomb.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_GetIntraPredictor.cpp b/src/openh264/test/encoder/EncUT_GetIntraPredictor.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_InterfaceTest.cpp b/src/openh264/test/encoder/EncUT_InterfaceTest.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_MBCopy.cpp b/src/openh264/test/encoder/EncUT_MBCopy.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_MemoryAlloc.cpp b/src/openh264/test/encoder/EncUT_MemoryAlloc.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_MemoryZero.cpp b/src/openh264/test/encoder/EncUT_MemoryZero.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_MotionCompensation.cpp b/src/openh264/test/encoder/EncUT_MotionCompensation.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_MotionEstimate.cpp b/src/openh264/test/encoder/EncUT_MotionEstimate.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_ParameterSetStrategy.cpp b/src/openh264/test/encoder/EncUT_ParameterSetStrategy.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_Reconstruct.cpp b/src/openh264/test/encoder/EncUT_Reconstruct.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_SVC_me.cpp b/src/openh264/test/encoder/EncUT_SVC_me.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_Sample.cpp b/src/openh264/test/encoder/EncUT_Sample.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_SliceBufferReallocate.cpp b/src/openh264/test/encoder/EncUT_SliceBufferReallocate.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/EncUT_SliceBufferReallocate.h b/src/openh264/test/encoder/EncUT_SliceBufferReallocate.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/meson.build b/src/openh264/test/encoder/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder/targets.mk b/src/openh264/test/encoder/targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder_binary_comparison/.gitignore b/src/openh264/test/encoder_binary_comparison/.gitignore old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder_binary_comparison/AboutTest b/src/openh264/test/encoder_binary_comparison/AboutTest old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder_binary_comparison/SHA1Table/Adobe_PDF_sample_a_1024x768_50Frms.264_AllCases_SHA1_Table.csv b/src/openh264/test/encoder_binary_comparison/SHA1Table/Adobe_PDF_sample_a_1024x768_50Frms.264_AllCases_SHA1_Table.csv old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder_binary_comparison/SHA1Table/BA_MW_D.264_AllCases_SHA1_Table.csv b/src/openh264/test/encoder_binary_comparison/SHA1Table/BA_MW_D.264_AllCases_SHA1_Table.csv old mode 100755 new mode 100644 diff --git a/src/openh264/test/encoder_binary_comparison/SHA1Table/Zhling_1280x720.264_AllCases_SHA1_Table.csv b/src/openh264/test/encoder_binary_comparison/SHA1Table/Zhling_1280x720.264_AllCases_SHA1_Table.csv old mode 100755 new mode 100644 diff --git a/src/openh264/test/meson.build b/src/openh264/test/meson.build old mode 100755 new mode 100644 index 585515693..4cda986aa --- a/src/openh264/test/meson.build +++ b/src/openh264/test/meson.build @@ -1,15 +1,17 @@ -gtest_main_dep = dependency('gtest', main : true, fallback: ['gtest', 'gtest_main_dep'], required: false) -gtest_dep = dependency('gtest', fallback: ['gtest', 'gtest_dep'], required: false) +if not get_option('tests').disabled() + gtest_main_dep = dependency('gtest', main : true, fallback: ['gtest', 'gtest_main_dep'], required: true) + gtest_dep = dependency('gtest', fallback: ['gtest', 'gtest_dep'], required: true) -test_inc = include_directories('.') + test_inc = include_directories('.') -test_data_generator_sources = files('api/DataGenerator.cpp') -test_base_encoder_sources = files('api/BaseEncoderTest.cpp') + test_data_generator_sources = files('api/DataGenerator.cpp') + test_base_encoder_sources = files('api/BaseEncoderTest.cpp') -if gtest_dep.found() - subdir('api') - subdir('common') - subdir('decoder') - subdir('encoder') - subdir('processing') -endif + if gtest_dep.found() + subdir('api') + subdir('common') + subdir('decoder') + subdir('encoder') + subdir('processing') + endif +endif \ No newline at end of file diff --git a/src/openh264/test/processing/ProcessUT_AdaptiveQuantization.cpp b/src/openh264/test/processing/ProcessUT_AdaptiveQuantization.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/processing/ProcessUT_DownSample.cpp b/src/openh264/test/processing/ProcessUT_DownSample.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/processing/ProcessUT_ScrollDetection.cpp b/src/openh264/test/processing/ProcessUT_ScrollDetection.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/processing/ProcessUT_VaaCalc.cpp b/src/openh264/test/processing/ProcessUT_VaaCalc.cpp old mode 100755 new mode 100644 diff --git a/src/openh264/test/processing/meson.build b/src/openh264/test/processing/meson.build old mode 100755 new mode 100644 diff --git a/src/openh264/test/processing/targets.mk b/src/openh264/test/processing/targets.mk old mode 100755 new mode 100644 diff --git a/src/openh264/test/sha1.h b/src/openh264/test/sha1.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/test_stdint.h b/src/openh264/test/test_stdint.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/utils/BufferedData.h b/src/openh264/test/utils/BufferedData.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/utils/DataGenerator.h b/src/openh264/test/utils/DataGenerator.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/utils/FileInputStream.h b/src/openh264/test/utils/FileInputStream.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/utils/HashFunctions.h b/src/openh264/test/utils/HashFunctions.h old mode 100755 new mode 100644 diff --git a/src/openh264/test/utils/InputStream.h b/src/openh264/test/utils/InputStream.h old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/CmdLineReadMe b/src/openh264/testbin/CmdLineReadMe old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/layer2.cfg b/src/openh264/testbin/layer2.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/layer2_arbitrary_res.cfg b/src/openh264/testbin/layer2_arbitrary_res.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/layer2_vd.cfg b/src/openh264/testbin/layer2_vd.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/layer2_vd_rc.cfg b/src/openh264/testbin/layer2_vd_rc.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/welsenc.cfg b/src/openh264/testbin/welsenc.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/welsenc_arbitrary_res.cfg b/src/openh264/testbin/welsenc_arbitrary_res.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/welsenc_ios.cfg b/src/openh264/testbin/welsenc_ios.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/welsenc_vd_1d.cfg b/src/openh264/testbin/welsenc_vd_1d.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/testbin/welsenc_vd_rc.cfg b/src/openh264/testbin/welsenc_vd_rc.cfg old mode 100755 new mode 100644 diff --git a/src/openh264/ut.def b/src/openh264/ut.def old mode 100755 new mode 100644