Browse Source

starfive(multimedia): Update usdk for multimedia feature

1. Update submodule path and Makefile
2. Update the buildroot ramfs config for conf/buildroot_initramfs_config
3. Update the linux config for conf/beaglev_defconfig_513
4. Add chip&media VPU hard decode module wave511, remove the firmwaire bin
   build it to library libsfdec.so
5. Add the starfive OpenMax-IL library which adapt the wave511 decode library
   build it to library libsf-omx-il.so which could be used for gst-omx or ffmpeg-omx plugin

Signed-off-by: sw.multimedia <sw.multimedia@starfivetech.com>
Signed-off-by: andy.hu <andy.hu@starfivetech.com>
Signed-off-by: Curry Zhang <curry.zhang@starfivetech.com>
Signed-off-by: david.li <david.li@starfivetech.com>
sw.multimedia 2 years ago
parent
commit
fd0be29ca1
100 changed files with 27203 additions and 25 deletions
  1. 8 7
      .gitmodules
  2. 1 1
      HiFive_U-Boot
  3. 25 6
      Makefile
  4. 12 3
      build.sh
  5. 1 1
      buildroot
  6. 226 0
      conf/beaglev_defconfig_513
  7. 72 4
      conf/buildroot_initramfs_config
  8. 13 0
      conf/sdk_210209_defconfig
  9. 1 1
      conf/u74_nvdla-uboot-fit-image.its
  10. 1 1
      linux
  11. 1 1
      opensbi
  12. 1 0
      soft_3rdpart/README.md
  13. 78 0
      soft_3rdpart/omx-il/Makefile
  14. 300 0
      soft_3rdpart/omx-il/component/video/common/SF_OMX_video_common.c
  15. 47 0
      soft_3rdpart/omx-il/component/video/common/SF_OMX_video_common.h
  16. 881 0
      soft_3rdpart/omx-il/component/video/dec/SF_OMX_Vdec_decoder.c
  17. 55 0
      soft_3rdpart/omx-il/component/video/enc/SF_OMX_Venc_encoder.c
  18. 397 0
      soft_3rdpart/omx-il/core/SF_OMX_Core.c
  19. 156 0
      soft_3rdpart/omx-il/core/SF_OMX_Core.h
  20. 1310 0
      soft_3rdpart/omx-il/include/khronos/OMX_Audio.h
  21. 569 0
      soft_3rdpart/omx-il/include/khronos/OMX_Component.h
  22. 193 0
      soft_3rdpart/omx-il/include/khronos/OMX_ContentPipe.h
  23. 1422 0
      soft_3rdpart/omx-il/include/khronos/OMX_Core.h
  24. 920 0
      soft_3rdpart/omx-il/include/khronos/OMX_IVCommon.h
  25. 328 0
      soft_3rdpart/omx-il/include/khronos/OMX_Image.h
  26. 260 0
      soft_3rdpart/omx-il/include/khronos/OMX_Index.h
  27. 105 0
      soft_3rdpart/omx-il/include/khronos/OMX_IndexExt.h
  28. 366 0
      soft_3rdpart/omx-il/include/khronos/OMX_Other.h
  29. 352 0
      soft_3rdpart/omx-il/include/khronos/OMX_Types.h
  30. 1141 0
      soft_3rdpart/omx-il/include/khronos/OMX_Video.h
  31. 401 0
      soft_3rdpart/omx-il/include/khronos/OMX_VideoExt.h
  32. 146 0
      soft_3rdpart/omx-il/tests/wave511test.c
  33. 123 0
      soft_3rdpart/omx-il/tests/wave521test.c
  34. 97 0
      soft_3rdpart/wave511/README.md
  35. 543 0
      soft_3rdpart/wave511/code/TestMultiInstance.sh
  36. 20 0
      soft_3rdpart/wave511/code/TestRunnerParamWave511Dec.txt
  37. 25 0
      soft_3rdpart/wave511/code/TestRunnerParamWave521CEnc.txt
  38. 618 0
      soft_3rdpart/wave511/code/TestRunnerWave511Dec.sh
  39. 600 0
      soft_3rdpart/wave511/code/TestRunnerWave521CEnc.sh
  40. 50 0
      soft_3rdpart/wave511/code/WaveDecDriver.mak
  41. 41 0
      soft_3rdpart/wave511/code/WaveDecDriver_buildroot.mak
  42. 184 0
      soft_3rdpart/wave511/code/WaveDecode-ffmpeg.mak
  43. 168 0
      soft_3rdpart/wave511/code/WaveDecode.mak
  44. 239 0
      soft_3rdpart/wave511/code/WaveDecodeMult.mak
  45. 168 0
      soft_3rdpart/wave511/code/WaveDecode_buildroot.mak
  46. 11 0
      soft_3rdpart/wave511/code/build_env.sh
  47. 39 0
      soft_3rdpart/wave511/code/build_for_vdec.sh
  48. 41 0
      soft_3rdpart/wave511/code/build_lib.sh
  49. 59 0
      soft_3rdpart/wave511/code/cfg/avc_inter_10b_03.cfg
  50. 58 0
      soft_3rdpart/wave511/code/cfg/avc_inter_8b_02.cfg
  51. 58 0
      soft_3rdpart/wave511/code/cfg/avc_uhd_cavlc_8b_04.cfg
  52. 76 0
      soft_3rdpart/wave511/code/cfg/hevc_bg_8b_01.cfg
  53. 74 0
      soft_3rdpart/wave511/code/cfg/hevc_fhd_inter_8b_11.cfg
  54. 79 0
      soft_3rdpart/wave511/code/cfg/hevc_inter_10b_01.cfg
  55. 5 0
      soft_3rdpart/wave511/code/cmd/all_multi_8b.cmd
  56. 1 0
      soft_3rdpart/wave511/code/cmd/avc_main10_dec_test.cmd
  57. 1 0
      soft_3rdpart/wave511/code/cmd/avc_main10_enc_test.cmd
  58. 1 0
      soft_3rdpart/wave511/code/cmd/avc_main_dec_test.cmd
  59. 1 0
      soft_3rdpart/wave511/code/cmd/avc_main_enc_test.cmd
  60. 5 0
      soft_3rdpart/wave511/code/cmd/dec_multi_8b.cmd
  61. 5 0
      soft_3rdpart/wave511/code/cmd/enc_multi_8b.cmd
  62. 1 0
      soft_3rdpart/wave511/code/cmd/hevc_main10_dec_test.cmd
  63. 1 0
      soft_3rdpart/wave511/code/cmd/hevc_main10_enc_test.cmd
  64. 1 0
      soft_3rdpart/wave511/code/cmd/hevc_main_dec_test.cmd
  65. 1 0
      soft_3rdpart/wave511/code/cmd/hevc_main_enc_test.cmd
  66. 2022 0
      soft_3rdpart/wave511/code/common.sh
  67. 107 0
      soft_3rdpart/wave511/code/config.h
  68. 2 0
      soft_3rdpart/wave511/code/cp.sh
  69. 108 0
      soft_3rdpart/wave511/code/sample_v2/component/cnm_app.c
  70. 76 0
      soft_3rdpart/wave511/code/sample_v2/component/cnm_app.h
  71. 58 0
      soft_3rdpart/wave511/code/sample_v2/component/cnm_app_internal.h
  72. 198 0
      soft_3rdpart/wave511/code/sample_v2/component/cnm_task.c
  73. 720 0
      soft_3rdpart/wave511/code/sample_v2/component/component.c
  74. 593 0
      soft_3rdpart/wave511/code/sample_v2/component/component.h
  75. 43 0
      soft_3rdpart/wave511/code/sample_v2/component/component_list.h
  76. 113 0
      soft_3rdpart/wave511/code/sample_v2/component/component_template.c
  77. 1162 0
      soft_3rdpart/wave511/code/sample_v2/component_decoder/coda9/component_coda9_dec_decoder.c
  78. 1070 0
      soft_3rdpart/wave511/code/sample_v2/component_decoder/component_dec_decoder.c
  79. 422 0
      soft_3rdpart/wave511/code/sample_v2/component_decoder/component_dec_feeder.c
  80. 517 0
      soft_3rdpart/wave511/code/sample_v2/component_decoder/component_dec_renderer.c
  81. 552 0
      soft_3rdpart/wave511/code/sample_v2/component_decoder/decoder_listener.c
  82. 68 0
      soft_3rdpart/wave511/code/sample_v2/component_decoder/decoder_listener.h
  83. 920 0
      soft_3rdpart/wave511/code/sample_v2/component_encoder/coda9/component_coda9_enc_encoder.c
  84. 1225 0
      soft_3rdpart/wave511/code/sample_v2/component_encoder/component_enc_encoder.c
  85. 424 0
      soft_3rdpart/wave511/code/sample_v2/component_encoder/component_enc_feeder.c
  86. 285 0
      soft_3rdpart/wave511/code/sample_v2/component_encoder/component_enc_reader.c
  87. 258 0
      soft_3rdpart/wave511/code/sample_v2/component_encoder/encoder_listener.c
  88. 98 0
      soft_3rdpart/wave511/code/sample_v2/component_encoder/encoder_listener.h
  89. 55 0
      soft_3rdpart/wave511/code/sample_v2/component_list_all.h
  90. 43 0
      soft_3rdpart/wave511/code/sample_v2/component_list_decoder.h
  91. 43 0
      soft_3rdpart/wave511/code/sample_v2/component_list_encoder.h
  92. 515 0
      soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bitstreamfeeder.c
  93. 173 0
      soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bitstreamreader.c
  94. 125 0
      soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bsfeeder_buffer_impl.c
  95. 168 0
      soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bsfeeder_fixedsize_impl.c
  96. 1158 0
      soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bsfeeder_framesize_impl.c
  97. 137 0
      soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bsfeeder_size_plus_es_impl.c
  98. 145 0
      soft_3rdpart/wave511/code/sample_v2/helper/comparator/bin_comparator_impl.c
  99. 28 0
      soft_3rdpart/wave511/code/sample_v2/helper/comparator/byframe_comparator_impl.c
  100. 389 0
      soft_3rdpart/wave511/code/sample_v2/helper/comparator/comparator.c

+ 8 - 7
.gitmodules

@@ -1,16 +1,17 @@
 [submodule "buildroot"]
 	path = buildroot
-	url = https://github.com/starfive-tech/sft-riscv-buildroot.git
-	branch = starfive
+	url = git@github.com:starfive-tech/sft-riscv-buildroot.git
+	branch = starlight_multimedia
 [submodule "HiFive_U-Boot"]
 	path = HiFive_U-Boot
-	url = https://github.com/starfive-tech/sft-riscv-uboot.git
-	branch = starfive
+	url = git@github.com:starfive-tech/u-boot.git
+	branch = JH7100_starlight_multimedia
 [submodule "linux"]
 	path = linux
-	url = https://github.com/starfive-tech/sft-riscv-linux-5.10.git
-	branch = starfive
+	url = git@github.com:starfive-tech/linux.git
+	branch = beaglev-5.13.y_multimedia
 [submodule "opensbi"]
 	path = opensbi
-	url = https://github.com/starfive-tech/sft-riscv-opensbi.git
+	url = git@github.com:starfive-tech/sft-riscv-opensbi.git
 	branch = starfive
+

+ 1 - 1
HiFive_U-Boot

@@ -1 +1 @@
-Subproject commit 7dac1a6eaa1b20775b96aa8c6f45e356cd0a604d
+Subproject commit 824962164c0178e155c54a97dfcac7a2e0d25e45

+ 25 - 6
Makefile

@@ -28,7 +28,7 @@ buildroot_rootfs_config := $(confdir)/buildroot_rootfs_config
 
 linux_srcdir := $(srcdir)/linux
 linux_wrkdir := $(wrkdir)/linux
-linux_defconfig := $(confdir)/sdk_210209_defconfig
+linux_defconfig := $(confdir)/beaglev_defconfig_513
 
 vmlinux := $(linux_wrkdir)/vmlinux
 vmlinux_stripped := $(linux_wrkdir)/vmlinux-stripped
@@ -53,6 +53,7 @@ initramfs := $(wrkdir)/initramfs.cpio.gz
 sbi_srcdir := $(srcdir)/opensbi
 sbi_wrkdir := $(wrkdir)/opensbi
 sbi_bin := $(wrkdir)/opensbi/platform/starfive/vic7100/firmware/fw_payload.bin
+#sbi_bin := $(wrkdir)/opensbi/platform/generic/firmware/fw_payload.bin
 fit := $(wrkdir)/image.fit
 
 fesvr_srcdir := $(srcdir)/riscv-fesvr
@@ -69,12 +70,13 @@ qemu := $(qemu_wrkdir)/prefix/bin/qemu-system-riscv64
 
 uboot_srcdir := $(srcdir)/HiFive_U-Boot
 uboot_wrkdir := $(wrkdir)/HiFive_U-Boot
-uboot_dtb_file := $(wrkdir)/HiFive_U-Boot/arch/riscv/dts/starfive_vic7100_evb.dtb
+uboot_dtb_file := $(wrkdir)/HiFive_U-Boot/arch/riscv/dts/jh7100-beaglev-starlight.dtb
 uboot := $(uboot_wrkdir)/u-boot.bin
 uboot_config := HiFive-U540_regression_defconfig
 
 ifeq ($(TARGET_BOARD),U74)
-	uboot_config := starfive_vic7100_evb_smode_defconfig
+	uboot_config := starfive_jh7100_starlight_smode_defconfig
+	# uboot_config := starfive_vic7100_evb_smode_defconfig
 else
 	uboot_config := HiFive-U540_nvdla_iofpga_defconfig
 endif
@@ -151,6 +153,7 @@ buildroot_rootfs-menuconfig: $(buildroot_rootfs_wrkdir)/.config $(buildroot_srcd
 	cp $(dir $<)defconfig conf/buildroot_rootfs_config
 
 $(buildroot_initramfs_sysroot_stamp): $(buildroot_initramfs_tar)
+	-rm -rf $(buildroot_initramfs_sysroot)
 	mkdir -p $(buildroot_initramfs_sysroot)
 	tar -xpf $< -C $(buildroot_initramfs_sysroot) --exclude ./dev --exclude ./usr/share/locale
 	touch $@
@@ -188,13 +191,29 @@ $(vmlinux): $(linux_srcdir) $(linux_wrkdir)/.config $(target_gcc) $(buildroot_in
 		INSTALL_MOD_PATH=$(buildroot_initramfs_sysroot) \
 		modules_install
 
+# vpu building depend on the $(vmlinux), $(vmlinux) depend on $(buildroot_initramfs_sysroot)
+# so vpubuild should be built after $(vmlinux)
+vpubuild: $(vmlinux) wave511-build omxil-build gstomx-build
+wave511-build:
+	$(MAKE) -C $(buildroot_initramfs_wrkdir) O=$(buildroot_initramfs_wrkdir) wave511-dirclean
+	$(MAKE) -C $(buildroot_initramfs_wrkdir) O=$(buildroot_initramfs_wrkdir) wave511-rebuild
+wave521-build:
+	$(MAKE) -C $(buildroot_initramfs_wrkdir) O=$(buildroot_initramfs_wrkdir) wave521-dirclean
+	$(MAKE) -C $(buildroot_initramfs_wrkdir) O=$(buildroot_initramfs_wrkdir) wave521-rebuild
+omxil-build:
+	$(MAKE) -C $(buildroot_initramfs_wrkdir) O=$(buildroot_initramfs_wrkdir) sf-omx-il-dirclean
+	$(MAKE) -C $(buildroot_initramfs_wrkdir) O=$(buildroot_initramfs_wrkdir) sf-omx-il-rebuild
+gstomx-build:
+	$(MAKE) -C $(buildroot_initramfs_wrkdir) O=$(buildroot_initramfs_wrkdir) sf-gst-omx-dirclean
+	$(MAKE) -C $(buildroot_initramfs_wrkdir) O=$(buildroot_initramfs_wrkdir) sf-gst-omx-rebuild
+
 .PHONY: initrd
 initrd: $(initramfs)
 
-$(initramfs).d: $(buildroot_initramfs_sysroot)
+$(initramfs).d: $(buildroot_initramfs_sysroot) $(buildroot_initramfs_tar)
 	$(linux_srcdir)/usr/gen_initramfs_list.sh -l $(confdir)/initramfs.txt $(buildroot_initramfs_sysroot) > $@
 
-$(initramfs): $(buildroot_initramfs_sysroot) $(vmlinux)
+$(initramfs): $(buildroot_initramfs_sysroot) $(vmlinux) $(buildroot_initramfs_tar)
 	cd $(linux_wrkdir) && \
 		$(linux_srcdir)/usr/gen_initramfs_list.sh \
 		-o $@ -u $(shell id -u) -g $(shell id -g) \
@@ -220,7 +239,7 @@ sbi: $(uboot) $(vmlinux)
 		PLATFORM=starfive/vic7100 FW_PAYLOAD_PATH=$(uboot) FW_PAYLOAD_FDT_PATH=$(uboot_dtb_file)
 
 
-$(fit): sbi $(vmlinux_bin) $(uboot) $(its_file) ${initramfs}
+$(fit): sbi $(vmlinux_bin) $(uboot) $(its_file) $(initramfs)
 	$(uboot_wrkdir)/tools/mkimage -f $(its_file) -A riscv -O linux -T flat_dt $@
 	@if [ -f fsz.sh ]; then ./fsz.sh $(sbi_bin); fi
 

+ 12 - 3
build.sh

@@ -1,15 +1,24 @@
 #!/bin/bash
+set -e
 
 CORES=$(getconf _NPROCESSORS_ONLN)
 
-make clean || true
-make distclean || true
-
 git submodule sync
 git submodule update --recursive --init
 
+#make clean || true
+#make distclean || true
+rm -rf work/
 make MKFS_VFAT="/sbin/mkfs.vfat" \
     MKFS_EXT4="/sbin/mkfs.ext4" \
     PARTPROBE="/sbin/partprobe" \
     SGDISK="/sbin/sgdisk" \
     -j${CORES}
+make vpubuild
+rm -rf work/buildroot_initramfs/images/rootfs.tar
+make MKFS_VFAT="/sbin/mkfs.vfat" \
+    MKFS_EXT4="/sbin/mkfs.ext4" \
+    PARTPROBE="/sbin/partprobe" \
+    SGDISK="/sbin/sgdisk" \
+    -j${CORES}
+

+ 1 - 1
buildroot

@@ -1 +1 @@
-Subproject commit 2e13b6d470e16b103f793aa1f6e246ac6d610242
+Subproject commit c6d44a530d459156cba379f8becf864250cc1c0e

+ 226 - 0
conf/beaglev_defconfig_513

@@ -0,0 +1,226 @@
+CONFIG_LOCALVERSION="-beaglev"
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_WATCH_QUEUE=y
+# CONFIG_CROSS_MEMORY_ATTACH is not set
+CONFIG_NO_HZ_IDLE=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BPF_SYSCALL=y
+CONFIG_PSI=y
+# CONFIG_CPU_ISOLATION is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_CGROUPS=y
+CONFIG_CGROUP_SCHED=y
+CONFIG_CFS_BANDWIDTH=y
+CONFIG_CGROUP_PIDS=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_NAMESPACES=y
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+CONFIG_EXPERT=y
+# CONFIG_SYSFS_SYSCALL is not set
+CONFIG_USERFAULTFD=y
+CONFIG_PERF_EVENTS=y
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_SLUB_DEBUG is not set
+CONFIG_SHUFFLE_PAGE_ALLOCATOR=y
+CONFIG_SOC_STARFIVE_VIC7100=y
+CONFIG_SMP=y
+CONFIG_NR_CPUS=2
+CONFIG_HZ_100=y
+# CONFIG_RISCV_SBI_V01 is not set
+CONFIG_CMDLINE="earlyprintk console=tty1 console=ttyS0,115200 debug rootwait stmmaceth=chain_mode:1"
+CONFIG_CMDLINE_FORCE=y
+CONFIG_JUMP_LABEL=y
+# CONFIG_SECCOMP is not set
+# CONFIG_STACKPROTECTOR is not set
+# CONFIG_GCC_PLUGINS is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_BLK_WBT=y
+# CONFIG_BLK_DEBUG_FS is not set
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_MQ_IOSCHED_DEADLINE is not set
+# CONFIG_MQ_IOSCHED_KYBER is not set
+CONFIG_IOSCHED_BFQ=y
+CONFIG_PAGE_REPORTING=y
+CONFIG_KSM=y
+CONFIG_CMA=y
+CONFIG_ZSMALLOC=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_INET_DIAG is not set
+# CONFIG_IPV6_SIT is not set
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_FQ_CODEL=y
+CONFIG_CFG80211=y
+# CONFIG_CFG80211_DEFAULT_PS is not set
+CONFIG_RFKILL=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+CONFIG_EXTRA_FIRMWARE="regulatory.db regulatory.db.p7s brcm/brcmfmac43430-sdio.bin brcm/brcmfmac43430-sdio.clm_blob brcm/brcmfmac43430-sdio.beagle,beaglev-starlight-jh7100.txt"
+CONFIG_EXTRA_FIRMWARE_DIR="firmware"
+CONFIG_MTD=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_PARTITIONED_MASTER=y
+CONFIG_MTD_SPI_NOR=y
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
+CONFIG_ZRAM=y
+CONFIG_ZRAM_MEMORY_TRACKING=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_LOOP_MIN_COUNT=1
+CONFIG_BLK_DEV_NBD=y
+CONFIG_SCSI=y
+# CONFIG_SCSI_PROC_FS is not set
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_SCAN_ASYNC=y
+# CONFIG_SCSI_LOWLEVEL is not set
+CONFIG_NETDEVICES=y
+CONFIG_WIREGUARD=y
+CONFIG_TUN=y
+CONFIG_STMMAC_ETH=y
+CONFIG_MICREL_PHY=y
+CONFIG_BRCMFMAC=y
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_SERIO is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_LDISC_AUTOLOAD is not set
+CONFIG_SERIAL_8250=y
+# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
+# CONFIG_SERIAL_8250_16550A_VARIANTS is not set
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_DW=y
+# CONFIG_DEVMEM is not set
+# CONFIG_I2C_COMPAT is not set
+CONFIG_I2C_CHARDEV=y
+# CONFIG_I2C_HELPER_AUTO is not set
+CONFIG_I2C_DESIGNWARE_PLATFORM=y
+CONFIG_SPI=y
+CONFIG_SPI_CADENCE_QUADSPI=y
+CONFIG_SPI_DESIGNWARE=y
+CONFIG_SPI_DW_DMA=y
+CONFIG_SPI_DW_MMIO=y
+CONFIG_SPI_SPIDEV=y
+# CONFIG_PTP_1588_CLOCK is not set
+CONFIG_GPIO_SYSFS=y
+# CONFIG_GPIO_CDEV_V1 is not set
+CONFIG_GPIO_TPS65086=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_TPS65086=y
+CONFIG_SENSORS_SFCTEMP=y
+CONFIG_THERMAL=y
+CONFIG_THERMAL_NETLINK=y
+CONFIG_THERMAL_STATISTICS=y
+CONFIG_THERMAL_WRITABLE_TRIPS=y
+CONFIG_CPU_THERMAL=y
+CONFIG_MFD_TPS65086=y
+# CONFIG_MEDIA_CEC_SUPPORT is not set
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_USB_SUPPORT=y
+CONFIG_USB_VIDEO_CLASS=y
+CONFIG_V4L_PLATFORM_DRIVERS=y
+CONFIG_VIDEO_STARFIVE_VIN=y
+CONFIG_VIN_SENSOR_IMX219=y
+CONFIG_DRM=y
+CONFIG_FB_STARFIVE=y
+CONFIG_FB_STARFIVE_HDMI_TDA998X=y
+CONFIG_FB_STARFIVE_VIDEO=y
+CONFIG_LOGO=y
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_SOC=y
+CONFIG_SND_DESIGNWARE_I2S=y
+CONFIG_SND_STARFIVE_PWMDAC=y
+CONFIG_SND_SOC_WM8960=y
+CONFIG_SND_SIMPLE_CARD=y
+CONFIG_USB=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+CONFIG_USB_MON=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DBGCAP=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_UAS=y
+CONFIG_USB_CDNS_SUPPORT=y
+CONFIG_USB_CDNS3=y
+CONFIG_USB_CDNS3_HOST=y
+CONFIG_USB_GADGET=y
+CONFIG_MMC=y
+# CONFIG_PWRSEQ_EMMC is not set
+CONFIG_MMC_DW=y
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+CONFIG_DMADEVICES=y
+CONFIG_DW_AXI_DMAC=y
+CONFIG_DMABUF_HEAPS=y
+CONFIG_DMABUF_HEAPS_SYSTEM=y
+# CONFIG_VIRTIO_MENU is not set
+# CONFIG_VHOST_MENU is not set
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_PWM=y
+CONFIG_PWM_SIFIVE_PTC=y
+CONFIG_NVDLA=y
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_BTRFS_FS=y
+CONFIG_BTRFS_FS_POSIX_ACL=y
+# CONFIG_MANDATORY_FILE_LOCKING is not set
+# CONFIG_DNOTIFY is not set
+CONFIG_FANOTIFY=y
+CONFIG_AUTOFS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-15"
+CONFIG_FAT_DEFAULT_UTF8=y
+CONFIG_EXFAT_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_NFS_FS=y
+CONFIG_ROOT_NFS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_15=y
+CONFIG_NLS_UTF8=y
+CONFIG_LSM=""
+CONFIG_CRYPTO_ZSTD=y
+# CONFIG_CRYPTO_HW is not set
+# CONFIG_RAID6_PQ_BENCHMARK is not set
+CONFIG_DMA_CMA=y
+CONFIG_PRINTK_TIME=y
+# CONFIG_SYMBOLIC_ERRNAME is not set
+CONFIG_STRIP_ASM_SYMS=y
+# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_DEBUG_MISC is not set
+CONFIG_DEBUG_RODATA_TEST=y
+CONFIG_DEBUG_WX=y
+CONFIG_SOFTLOCKUP_DETECTOR=y
+CONFIG_WQ_WATCHDOG=y
+# CONFIG_SCHED_DEBUG is not set
+CONFIG_STACKTRACE=y
+CONFIG_RCU_CPU_STALL_TIMEOUT=60
+# CONFIG_RCU_TRACE is not set
+# CONFIG_FTRACE is not set
+# CONFIG_RUNTIME_TESTING_MENU is not set

+ 72 - 4
conf/buildroot_initramfs_config

@@ -1,8 +1,8 @@
 BR2_riscv=y
 BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
 BR2_KERNEL_HEADERS_CUSTOM_GIT=y
-BR2_KERNEL_HEADERS_CUSTOM_REPO_URL="https://github.com/starfive-tech/sft-riscvpi-linux-5.10.git"
-BR2_KERNEL_HEADERS_CUSTOM_REPO_VERSION="starfive"
+BR2_KERNEL_HEADERS_CUSTOM_REPO_URL="https://github.com/starfive-tech/linux.git"
+BR2_KERNEL_HEADERS_CUSTOM_REPO_VERSION="beaglev-5.13.y"
 BR2_PACKAGE_GLIBC_UTILS=y
 BR2_GCC_VERSION_10_X=y
 BR2_TOOLCHAIN_BUILDROOT_CXX=y
@@ -13,6 +13,71 @@ BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
 BR2_TARGET_GENERIC_ROOT_PASSWD="starfive"
 BR2_SYSTEM_DHCP="eth0"
 BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+BR2_PACKAGE_ALSA_UTILS=y
+BR2_PACKAGE_ALSA_UTILS_ALSACONF=y
+BR2_PACKAGE_ALSA_UTILS_ALSALOOP=y
+BR2_PACKAGE_ALSA_UTILS_AMIXER=y
+BR2_PACKAGE_ALSA_UTILS_APLAY=y
+BR2_PACKAGE_ALSA_UTILS_ASEQDUMP=y
+BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST=y
+BR2_PACKAGE_GSTREAMER1=y
+BR2_PACKAGE_GSTREAMER1_CHECK=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_INSTALL_TOOLS=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_APP=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_AUDIOMIXER=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_AUDIORATE=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_AUDIOTESTSRC=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOCONVERT=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_RAWPARSE=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOTESTSRC=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEORATE=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_ALSA=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_OGG=y
+BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VORBIS=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_JPEG=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PNG=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_AUDIOPARSERS=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_AUTODETECT=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_DEBUGUTILS=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_DEINTERLACE=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_FLV=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_ID3DEMUX=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_IMAGEFREEZE=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_INTERLEAVE=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_LAW=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_LEVEL=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_MATROSKA=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_MULTIFILE=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_MULTIPART=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_RTP=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_RTSP=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_VIDEOCROP=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_VIDEOFILTER=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_VIDEOMIXER=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_WAVENC=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_V4L2=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_V4L2_PROBE=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_FLAC=y
+BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_VPX=y
+BR2_PACKAGE_GST1_PLUGINS_BAD=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_AUTOCONVERT=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_ID3TAG=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_JPEGFORMAT=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_MPEGDEMUX=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_MPEGTSDEMUX=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_RAWPARSE=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_SPEED=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_VIDEOFILTERS=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_VIDEOFRAME_AUDIOLEVEL=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_VIDEOPARSERS=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_FBDEV=y
+BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_X265=y
+BR2_PACKAGE_GST1_PLUGINS_UGLY=y
+BR2_PACKAGE_GST1_PLUGINS_UGLY_PLUGIN_ASFDEMUX=y
+BR2_PACKAGE_GST1_PLUGINS_UGLY_PLUGIN_MPEG2DEC=y
+BR2_PACKAGE_GST1_PLUGINS_UGLY_PLUGIN_X264=y
+BR2_PACKAGE_GST1_LIBAV=y
 BR2_PACKAGE_DHRYSTONE=y
 BR2_PACKAGE_GDB=y
 BR2_PACKAGE_GDB_VERSION_9_2=y
@@ -52,9 +117,9 @@ BR2_PACKAGE_LIBKCAPI_ENCAPP=y
 BR2_PACKAGE_LIBKCAPI_RNGAPP=y
 BR2_PACKAGE_LIBKCAPI_SPEED=y
 BR2_PACKAGE_LIBKCAPI_TEST=y
-BR2_PACKAGE_JPEG=y
 BR2_PACKAGE_DTC=y
 BR2_PACKAGE_DTC_PROGRAMS=y
+BR2_PACKAGE_LIBV4L_UTILS=y
 BR2_PACKAGE_LIBTIRPC=y
 BR2_PACKAGE_BLUEZ5_UTILS=y
 BR2_PACKAGE_BLUEZ5_UTILS_OBEX=y
@@ -65,7 +130,6 @@ BR2_PACKAGE_BLUEZ5_UTILS_PLUGINS_HEALTH=y
 BR2_PACKAGE_BLUEZ5_UTILS_PLUGINS_MIDI=y
 BR2_PACKAGE_BLUEZ5_UTILS_PLUGINS_NFC=y
 BR2_PACKAGE_BLUEZ5_UTILS_PLUGINS_SAP=y
-BR2_PACKAGE_BRCM_PATCHRAM_PLUS=y
 BR2_PACKAGE_DHCP=y
 BR2_PACKAGE_DHCP_SERVER=y
 BR2_PACKAGE_DHCP_SERVER_DELAYED_ACK=y
@@ -86,12 +150,16 @@ BR2_PACKAGE_WPA_SUPPLICANT_WPA3=y
 BR2_PACKAGE_WPA_SUPPLICANT_CLI=y
 BR2_PACKAGE_WPA_SUPPLICANT_WPA_CLIENT_SO=y
 BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y
+BR2_PACKAGE_BASH=y
 BR2_PACKAGE_SCREEN=y
 BR2_PACKAGE_HTOP=y
 BR2_PACKAGE_UTIL_LINUX_MOUNT=y
+BR2_PACKAGE_V4L2_TEST=y
+BR2_PACKAGE_PP_TEST=y
 BR2_TARGET_OPENSBI=y
 BR2_PACKAGE_HOST_GENEXT2FS=y
 BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_GPTFDISK=y
 BR2_PACKAGE_HOST_MTOOLS=y
 BR2_PACKAGE_HOST_SQUASHFS=y
+BR2_PACKAGE_HOST_STFISP_SETFILE=y

+ 13 - 0
conf/sdk_210209_defconfig

@@ -163,16 +163,28 @@ CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_POWER_RESET_SYSCON_POWEROFF=y
 CONFIG_SENSORS_SFCTMP=y
+CONFIG_WATCHDOG=y
+CONFIG_STARFIVE_WATCHDOG=y
 # CONFIG_MEDIA_CEC_SUPPORT is not set
 CONFIG_MEDIA_SUPPORT=y
 CONFIG_MEDIA_SUBDRV_AUTOSELECT=y
+CONFIG_MEDIA_USB_SUPPORT=y
+CONFIG_USB_VIDEO_CLASS=y
 CONFIG_V4L_PLATFORM_DRIVERS=y
 CONFIG_VIDEO_STF_VIN=y
+# CONFIG_VIN_SENSOR_OV5640=y
+# CONFIG_VIN_SENSOR_SC2235=y
+CONFIG_VIN_SENSOR_OV4689=y
+# CONFIG_VIDEO_STARFIVE_VIN_SENSOR_IMX219=y
 CONFIG_DRM=y
+# CONFIG_FB=y
 CONFIG_FB_STARFIVE=y
 CONFIG_FB_STARFIVE_HDMI_TDA998X=y
+CONFIG_FB_STARFIVE_VIDEO=y
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
+CONFIG_LOGO=y
 CONFIG_SOUND=y
 CONFIG_SND=y
 CONFIG_SND_SOC=y
@@ -203,6 +215,7 @@ CONFIG_DW_AXI_DMAC=y
 # CONFIG_VIRTIO_MENU is not set
 # CONFIG_VHOST_MENU is not set
 CONFIG_GOLDFISH=y
+CONFIG_STARFIVE_TIMER=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_RPMSG_CHAR=y
 CONFIG_RPMSG_VIRTIO=y

+ 1 - 1
conf/u74_nvdla-uboot-fit-image.its

@@ -30,7 +30,7 @@
                 };
 
                 fdt {
-                        data = /incbin/("../work/HiFive_U-Boot/arch/riscv/dts/starfive_vic7100_evb.dtb");
+                        data = /incbin/("../work/HiFive_U-Boot/arch/riscv/dts/jh7100-beaglev-starlight.dtb");
                         type = "flat_dt";
                         arch = "riscv";
                         load = <0x0 0x86000000>;

+ 1 - 1
linux

@@ -1 +1 @@
-Subproject commit 93604a0a3ecc4ef8efb9d877854f89df2c7208f7
+Subproject commit 4f7f38a3e767dabd6009dca2485f75778229a0d8

+ 1 - 1
opensbi

@@ -1 +1 @@
-Subproject commit b4f8f7ca312804fd99bc3ebfa0644ea4b369c307
+Subproject commit 9bbe683fa60bdd560ded480fcec30c9e591fcb70

+ 1 - 0
soft_3rdpart/README.md

@@ -0,0 +1 @@
+This directory add for soft of 3rd party. such as: WAVE511, WAVE521, JPEG, VP6

+ 78 - 0
soft_3rdpart/omx-il/Makefile

@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2021 StarFive Technology Co., Ltd.
+#
+# Project: Starfive Openmax IL Shimlayer
+#
+.PHONY: CREATE_DIR
+BUILD_CONFIGURATION := EmbeddedRiscvLinux
+
+PRODUCT := OMX_IL
+
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedRiscvLinux")
+    CROSS_CC_PREFIX = riscv64-buildroot-linux-gnu-
+    PLATFORM        = riscvlinux
+endif
+CC  = $(CROSS_CC_PREFIX)gcc
+CXX = $(CROSS_CC_PREFIX)g++
+LINKER=$(CC)
+AR  = $(CROSS_CC_PREFIX)ar
+
+DEFINES = -DUSE_FEEDING_METHOD_BUFFER
+INCLUDES = -I./include/khronos -I./core -I./component/video/common
+$(warning "the value of LOCAL_PATH is$(STAGING_DIR)")
+INCLUDES += -I$(STAGING_DIR)/usr/include/wave511/sample_v2/component/
+INCLUDES += -I$(STAGING_DIR)/usr/include/wave511/sample_v2/component_encoder/
+INCLUDES += -I$(STAGING_DIR)/usr/include/wave511/sample_v2/component_decoder/
+INCLUDES += -I$(STAGING_DIR)/usr/include/wave511/
+INCLUDES += -I$(STAGING_DIR)/usr/include/wave511/vpuapi/
+INCLUDES += -I$(STAGING_DIR)/usr/include/wave511/sample_v2/helper/
+
+CFLAGS  += -g -I. -Wno-implicit-function-declaration -Wno-format -Wl,--fatal-warning $(INCLUDES) $(DEFINES) $(PLATFORM_FLAGS)
+CFLAGS  += -fpic
+ARFLAGS += cru
+LDFLAGS = -ldl -lpthread
+
+OBJDIR=obj
+ALLOBJS=*.o
+ALLDEPS=*.dep
+ALLLIBS=*.a
+RM=rm -f
+MKDIR=mkdir -p
+SOURCES_COMMON = SF_OMX_Core.c SF_OMX_video_common.c 
+SOURCES_COMMON += SF_OMX_Vdec_decoder.c
+
+SOURCES_TESTS_WAVE521 = wave521test.c
+SOURCES_TESTS_WAVE511 = wave511test.c
+
+VPATH  = component/video/common:
+VPATH += component/video/enc:
+VPATH += component/video/dec:
+VPATH += core:
+VPATH += tests:
+
+OBJECTNAMES_COMMON=$(patsubst %.c,%.o,$(SOURCES_COMMON))
+OBJECTPATHS_COMMON=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_COMMON)))
+OBJECTNAMES_WAVE521=$(patsubst %.c,%.o,$(SOURCES_TESTS_WAVE521))
+OBJECTPATHS_WAVE521=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_WAVE521)))
+OBJECTNAMES_WAVE511=$(patsubst %.c,%.o,$(SOURCES_TESTS_WAVE511))
+OBJECTPATHS_WAVE511=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_WAVE511)))
+
+all: CREATE_DIR $(OBJECTPATHS_COMMON)
+	$(CC) -fPIC -shared -o libsf-omx-il.so $(LDFLAGS) $(OBJECTPATHS_COMMON)
+
+wave521-test: CREATE_DIR $(OBJECTPATHS_WAVE521)
+	$(CC) -o wave521test $(LDFLAGS) $(OBJECTPATHS_WAVE521) -lsf-omx-il -L./
+
+wave511-test: CREATE_DIR $(OBJECTPATHS_WAVE511)
+	$(CC) -o wave511test $(LDFLAGS) $(OBJECTPATHS_WAVE511) -lsf-omx-il -L./
+
+clean:
+
+CREATE_DIR:
+	-mkdir -p $(OBJDIR)
+
+obj/%.o: %.c $(MAKEFILE)
+	$(CC) $(CFLAGS) -Wall -c $< -o $@ -MD -MF $(@:.o=.dep)
+
+

+ 300 - 0
soft_3rdpart/omx-il/component/video/common/SF_OMX_video_common.c

@@ -0,0 +1,300 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 StarFive Technology Co., Ltd.
+ */
+#include "SF_OMX_video_common.h"
+
+OMX_ERRORTYPE GetStateCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    OMX_COMPONENTTYPE *pOMXComponent = NULL;
+    SF_OMX_COMPONENT *pSfOMXComponent = NULL;
+    ComponentState state;
+
+    FunctionIn();
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    pSfOMXComponent = pOMXComponent->pComponentPrivate;
+    state = pSfOMXComponent->functions->ComponentGetState(pSfOMXComponent->hSFComponentExecoder);
+    LOG(SF_LOG_INFO, "state = %d\r\n", state);
+    switch (state)
+    {
+    case COMPONENT_STATE_CREATED:
+    case COMPONENT_STATE_PREPARED:
+    case COMPONENT_STATE_NONE:
+        *pState = OMX_StateLoaded;
+        break;
+    case COMPONENT_STATE_TERMINATED:
+        *pState = OMX_StateIdle;
+        break;
+    case COMPONENT_STATE_EXECUTED:
+        *pState = OMX_StateExecuting;
+        break;
+    default:
+        LOG(SF_LOG_WARN, "unknown state:%d \r\n", state);
+        ret = OMX_ErrorUndefined;
+        break;
+    }
+EXIT:
+    FunctionOut();
+    return ret;
+}
+
+OMX_ERRORTYPE ComponentClearCommon(SF_OMX_COMPONENT *hComponent)
+{
+    hComponent->functions->ComponentRelease(hComponent->hSFComponentExecoder);
+    hComponent->functions->ComponentDestroy(hComponent->hSFComponentExecoder, NULL);
+    hComponent->functions->DeInitLog();
+    dlclose(hComponent->soHandle);
+    free(hComponent->functions);
+    free(hComponent->testConfig);
+    free(hComponent->config);
+    free(hComponent->lsnCtx);
+    free(hComponent->pOMXComponent);
+    for (int i = 0; i < 2; i++)
+    {
+        OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = &hComponent->portDefinition[i];
+        free(pPortDefinition->format.video.cMIMEType);
+    }
+    return OMX_ErrorNone;
+}
+
+BOOL CheckEncTestConfig(TestEncConfig *testConfig)
+{
+    FunctionIn();
+    if ((testConfig->compareType & (1 << MODE_SAVE_ENCODED)) && testConfig->bitstreamFileName[0] == 0)
+    {
+        testConfig->compareType &= ~(1 << MODE_SAVE_ENCODED);
+        LOG(SF_LOG_ERR, "You want to Save bitstream data. Set the path\r\n");
+        return FALSE;
+    }
+
+    if ((testConfig->compareType & (1 << MODE_COMP_ENCODED)) && testConfig->ref_stream_path[0] == 0)
+    {
+        testConfig->compareType &= ~(1 << MODE_COMP_ENCODED);
+        LOG(SF_LOG_ERR, "You want to Compare bitstream data. Set the path\r\n");
+        return FALSE;
+    }
+
+    FunctionOut();
+    return TRUE;
+}
+
+BOOL CheckDecTestConfig(TestDecConfig *testConfig)
+{
+    BOOL isValidParameters = TRUE;
+
+    /* Check parameters */
+    if (testConfig->skipMode < 0 || testConfig->skipMode == 3 || testConfig->skipMode > 4)
+    {
+        LOG(SF_LOG_WARN, "Invalid skip mode: %d\n", testConfig->skipMode);
+        isValidParameters = FALSE;
+    }
+    if ((FORMAT_422 < testConfig->wtlFormat && testConfig->wtlFormat <= FORMAT_400) ||
+        testConfig->wtlFormat < FORMAT_420 || testConfig->wtlFormat >= FORMAT_MAX)
+    {
+        LOG(SF_LOG_WARN, "Invalid WTL format(%d)\n", testConfig->wtlFormat);
+        isValidParameters = FALSE;
+    }
+    if (isValidParameters == TRUE && (testConfig->scaleDownWidth > 0 || testConfig->scaleDownHeight > 0))
+    {
+    }
+    if (testConfig->renderType < RENDER_DEVICE_NULL || testConfig->renderType >= RENDER_DEVICE_MAX)
+    {
+        LOG(SF_LOG_WARN, "unknown render device type(%d)\n", testConfig->renderType);
+        isValidParameters = FALSE;
+    }
+    if (testConfig->thumbnailMode == TRUE && testConfig->skipMode != 0)
+    {
+        LOG(SF_LOG_WARN, "Turn off thumbnail mode or skip mode\n");
+        isValidParameters = FALSE;
+    }
+
+    return isValidParameters;
+}
+
+OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *hComponent)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    char *strDebugLevel = NULL;
+    int debugLevel = 0;
+
+    FunctionIn();
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+
+    hComponent->pOMXComponent = malloc(sizeof(OMX_COMPONENTTYPE));
+    if (hComponent->pOMXComponent == NULL)
+    {
+        ret = OMX_ErrorInsufficientResources;
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        goto ERROR;
+    }
+    memset(hComponent->pOMXComponent, 0, sizeof(OMX_COMPONENTTYPE));
+    hComponent->soHandle = dlopen(hComponent->libName, RTLD_NOW);
+    if (hComponent->soHandle == NULL)
+    {
+        ret = OMX_ErrorInsufficientResources;
+        LOG(SF_LOG_ERR, "could not open %s\r\n", hComponent->libName);
+        goto ERROR;
+    }
+
+    hComponent->functions = malloc(sizeof(SF_COMPONENT_FUNCTIONS));
+    if (hComponent->functions == NULL)
+    {
+        ret = OMX_ErrorInsufficientResources;
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        goto ERROR;
+    }
+    memset(hComponent->functions, 0, sizeof(SF_COMPONENT_FUNCTIONS));
+    sf_get_component_functions(hComponent->functions, hComponent->soHandle);
+
+    // Init VPU log
+    if (hComponent->functions->InitLog && hComponent->functions->SetMaxLogLevel)
+    {
+        hComponent->functions->InitLog();
+        strDebugLevel = getenv("VPU_DEBUG");
+        if (strDebugLevel)
+        {
+            debugLevel = atoi(strDebugLevel);
+            if (debugLevel >=0)
+            {
+                hComponent->functions->SetMaxLogLevel(debugLevel);
+            }
+        }
+    }
+
+    if (strstr(hComponent->componentName, "sf.enc") != NULL)
+    {
+        hComponent->testConfig = malloc(sizeof(TestEncConfig));
+        if (hComponent->testConfig == NULL)
+        {
+            ret = OMX_ErrorInsufficientResources;
+            LOG(SF_LOG_ERR, "malloc fail\r\n");
+            goto ERROR;
+        }
+        hComponent->lsnCtx = malloc(sizeof(EncListenerContext));
+        if (hComponent->lsnCtx == NULL)
+        {
+            ret = OMX_ErrorInsufficientResources;
+            LOG(SF_LOG_ERR, "malloc fail\r\n");
+            goto ERROR;
+        }
+        memset(hComponent->testConfig, 0, sizeof(TestEncConfig));
+        memset(hComponent->lsnCtx, 0, sizeof(EncListenerContext));
+        hComponent->functions->SetDefaultEncTestConfig(hComponent->testConfig);
+    }
+    else if (strstr(hComponent->componentName, "sf.dec") != NULL)
+    {
+        hComponent->testConfig = malloc(sizeof(TestDecConfig));
+        if (hComponent->testConfig == NULL)
+        {
+            ret = OMX_ErrorInsufficientResources;
+            LOG(SF_LOG_ERR, "malloc fail\r\n");
+            goto ERROR;
+        }
+        hComponent->lsnCtx = malloc(sizeof(DecListenerContext));
+        if (hComponent->lsnCtx == NULL)
+        {
+            ret = OMX_ErrorInsufficientResources;
+            LOG(SF_LOG_ERR, "malloc fail\r\n");
+            goto ERROR;
+        }
+        memset(hComponent->testConfig, 0, sizeof(TestDecConfig));
+        memset(hComponent->lsnCtx, 0, sizeof(DecListenerContext));
+        hComponent->functions->SetDefaultDecTestConfig(hComponent->testConfig);
+    }
+    else
+    {
+        ret = OMX_ErrorBadParameter;
+        LOG(SF_LOG_ERR, "unknown component!\r\n");
+        goto ERROR;
+    }
+
+    hComponent->config = malloc(sizeof(CNMComponentConfig));
+    if (hComponent->config == NULL)
+    {
+        ret = OMX_ErrorInsufficientResources;
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        goto ERROR;
+    }
+    memset(hComponent->config, 0, sizeof(CNMComponentConfig));
+
+    hComponent->pOMXComponent->pComponentPrivate = hComponent;
+    for (int i = 0; i < 2; i++)
+    {
+        OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = &hComponent->portDefinition[i];
+        INIT_SET_SIZE_VERSION(pPortDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
+        pPortDefinition->nPortIndex = i;
+        pPortDefinition->nBufferCountActual = 5;
+        pPortDefinition->nBufferCountMin = 1;
+        pPortDefinition->nBufferSize = 0;
+        pPortDefinition->eDomain = OMX_PortDomainVideo;
+        pPortDefinition->format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+        pPortDefinition->format.video.nFrameHeight = DEFAULT_FRAME_HEIGHT;
+        pPortDefinition->format.video.nStride = DEFAULT_FRAME_WIDTH;
+        pPortDefinition->format.video.nSliceHeight = DEFAULT_FRAME_HEIGHT;
+        pPortDefinition->format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+        pPortDefinition->format.video.cMIMEType = malloc(OMX_MAX_STRINGNAME_SIZE);
+        if (pPortDefinition->format.video.cMIMEType == NULL)
+        {
+            ret = OMX_ErrorInsufficientResources;
+            free(pPortDefinition->format.video.cMIMEType);
+            pPortDefinition->format.video.cMIMEType = NULL;
+            LOG(SF_LOG_ERR, "malloc fail\r\n");
+            goto ERROR;
+        }
+        memset(pPortDefinition->format.video.cMIMEType, 0, OMX_MAX_STRINGNAME_SIZE);
+        pPortDefinition->format.video.pNativeRender = 0;
+        pPortDefinition->format.video.bFlagErrorConcealment = OMX_FALSE;
+        pPortDefinition->format.video.eColorFormat = OMX_COLOR_FormatUnused;
+        pPortDefinition->bEnabled = OMX_TRUE;
+    }
+
+    hComponent->portDefinition[0].eDir = OMX_DirInput;
+    hComponent->portDefinition[0].nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
+
+    strcpy(hComponent->portDefinition[1].format.video.cMIMEType, "raw/video");
+    hComponent->portDefinition[1].format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+    hComponent->portDefinition[1].eDir = OMX_DirOutput;
+    hComponent->portDefinition[1].nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+
+    memset(hComponent->pBufferArray, 0, sizeof(hComponent->pBufferArray));
+    FunctionOut();
+EXIT:
+    return ret;
+ERROR:
+    if (hComponent->pOMXComponent)
+    {
+        free(hComponent->pOMXComponent);
+        hComponent->pOMXComponent = NULL;
+    }
+    if (hComponent->functions)
+    {
+        free(hComponent->functions);
+        hComponent->functions = NULL;
+    }
+    if (hComponent->testConfig)
+    {
+        free(hComponent->testConfig);
+        hComponent->testConfig = NULL;
+    }
+    if (hComponent->lsnCtx)
+    {
+        free(hComponent->lsnCtx);
+        hComponent->lsnCtx = NULL;
+    }
+    if (hComponent->config)
+    {
+        free(hComponent->config);
+        hComponent->config = NULL;
+    }
+    return ret;
+}

+ 47 - 0
soft_3rdpart/omx-il/component/video/common/SF_OMX_video_common.h

@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 StarFive Technology Co., Ltd.
+ */
+#ifndef SF_OMX_VIDEO_COMMON
+#define SF_OMX_VIDEO_COMMON
+
+#include "OMX_Component.h"
+#include "OMX_Video.h"
+#include "OMX_VideoExt.h"
+#include "OMX_Index.h"
+#include "OMX_IndexExt.h"
+#include "SF_OMX_Core.h"
+#include "component.h"
+
+#define INIT_SET_SIZE_VERSION(_struct_, _structType_) \
+    do                                                \
+    {                                                 \
+        memset((_struct_), 0, sizeof(_structType_));  \
+        (_struct_)->nSize = sizeof(_structType_);     \
+        (_struct_)->nVersion.s.nVersionMajor = 1;     \
+        (_struct_)->nVersion.s.nVersionMinor = 18;    \
+        (_struct_)->nVersion.s.nRevision = 1;         \
+        (_struct_)->nVersion.s.nStep = 0;             \
+    } while (0)
+
+#define DEFAULT_FRAME_WIDTH 0
+#define DEFAULT_FRAME_HEIGHT 0
+#define DEFAULT_VIDEO_INPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT) / 2
+#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+    BOOL CheckEncTestConfig(TestEncConfig *testConfig);
+    BOOL CheckDecTestConfig(TestDecConfig *testConfig);
+    OMX_ERRORTYPE GetStateCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState);
+    OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *hComponent);
+    OMX_ERRORTYPE ComponentClearCommon(SF_OMX_COMPONENT *hComponent);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

+ 881 - 0
soft_3rdpart/omx-il/component/video/dec/SF_OMX_Vdec_decoder.c

@@ -0,0 +1,881 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 StarFive Technology Co., Ltd.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SF_OMX_video_common.h"
+#include "SF_OMX_Core.h"
+
+extern OMX_TICKS gInitTimeStamp;
+static void OnEventArrived(Component com, unsigned long event, void *data, void *context)
+{
+    SF_OMX_COMPONENT *pSfOMXComponent = GetSFOMXComponrntByComponent(com);
+    PortContainerExternal *pPortContainerExternal = (PortContainerExternal *)data;
+    OMX_BUFFERHEADERTYPE *pOMXBuffer;
+    static OMX_U32 dec_cnt = 0;
+    static struct timeval tv_old = {0};
+    OMX_U32 fps = 0;
+    OMX_U64 diff_time = 0; // ms
+    FunctionIn();
+
+    LOG(SF_LOG_INFO, "event=%X\r\n", event);
+    switch (event)
+    {
+    case COMPONENT_EVENT_DEC_EMPTY_BUFFER_DONE:
+        pOMXBuffer = GetOMXBufferByAddr(pSfOMXComponent, (OMX_U8 *)pPortContainerExternal->pBuffer);
+        pSfOMXComponent->callbacks->EmptyBufferDone(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData, pOMXBuffer);
+        sem_post(pSfOMXComponent->inputSemaphore);
+        break;
+    case COMPONENT_EVENT_DEC_FILL_BUFFER_DONE:
+    {
+        struct timeval tv;
+        pOMXBuffer = GetOMXBufferByAddr(pSfOMXComponent, (OMX_U8 *)pPortContainerExternal->pBuffer);
+        gettimeofday(&tv, NULL);
+        pOMXBuffer->nFilledLen = pPortContainerExternal->nFilledLen;
+        pOMXBuffer->nTimeStamp = tv.tv_sec * 1000000 + tv.tv_usec - gInitTimeStamp;
+#if 0
+        {
+            FILE *fb = fopen("./out.bcp", "ab+");
+            LOG(SF_LOG_INFO, "%d %d\r\n", pOMXBuffer->nFilledLen, pOMXBuffer->nOffset);
+            fwrite(pOMXBuffer->pBuffer, 1, pOMXBuffer->nFilledLen, fb);
+            fclose(fb);
+        }
+#endif
+
+        // Following is to print the decoding fps
+        if (dec_cnt == 0) {
+            tv_old = tv;
+        }
+        if (dec_cnt++ >= 50) {
+            diff_time = (tv.tv_sec - tv_old.tv_sec) * 1000 + (tv.tv_usec - tv_old.tv_usec) / 1000;
+            fps = 1000  * (dec_cnt - 1) / diff_time;
+            dec_cnt = 0;
+            LOG(SF_LOG_WARN, "Decoding fps: %d \r\n", fps);
+        }
+
+        LOG(SF_LOG_PERF, "OMX finish one buffer\r\n");
+        pSfOMXComponent->callbacks->FillBufferDone(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData, pOMXBuffer);
+    }
+    break;
+    case COMPONENT_EVENT_DEC_REGISTER_FB:
+    {
+        struct timeval tv;
+        gettimeofday(&tv, NULL);
+        gInitTimeStamp = tv.tv_sec * 1000000 + tv.tv_usec;
+        pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData, OMX_EventPortSettingsChanged,
+                                                 1, OMX_IndexParamPortDefinition, NULL);
+    }
+    break;
+    case COMPONENT_EVENT_DEC_DECODED_ALL:
+        pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData, OMX_EventBufferFlag,
+                                                 1, 1, NULL);
+    default:
+        break;
+    }
+    FunctionOut();
+}
+
+static OMX_ERRORTYPE SF_OMX_EmptyThisBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+
+    SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
+
+    ComponentImpl *pFeederComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentFeeder;
+
+    sem_wait(pSfOMXComponent->inputSemaphore);
+    PortContainerExternal *pPortContainerExternal = malloc(sizeof(PortContainerExternal));
+    if (pPortContainerExternal == NULL)
+    {
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        return OMX_ErrorInsufficientResources;
+    }
+    memset(pPortContainerExternal, 0, sizeof(PortContainerExternal));
+    pPortContainerExternal->pBuffer = pBuffer->pBuffer;
+    pPortContainerExternal->nFilledLen = pBuffer->nFilledLen;
+    pPortContainerExternal->nFlags = pBuffer->nFlags;
+
+    if (pSfOMXComponent->functions->Queue_Enqueue(pFeederComponent->srcPort.inputQ, (void *)pPortContainerExternal) != OMX_TRUE)
+    {
+        LOG(SF_LOG_ERR, "%p:%p FAIL\r\n", pFeederComponent->srcPort.inputQ, pPortContainerExternal);
+        free(pPortContainerExternal);
+        return OMX_ErrorInsufficientResources;
+    }
+    LOG(SF_LOG_PERF, "input queue count=%d\r\n", pSfOMXComponent->functions->Queue_Get_Cnt(pFeederComponent->srcPort.inputQ));
+    free(pPortContainerExternal);
+
+    pFeederComponent->pause = OMX_FALSE;
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_FillThisBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    SF_OMX_COMPONENT *pSfOMXComponent = (SF_OMX_COMPONENT *)pOMXComponent->pComponentPrivate;
+    ComponentImpl *pRendererComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentRender;
+    PortContainerExternal *pPortContainerExternal = malloc(sizeof(PortContainerExternal));
+    if (pPortContainerExternal == NULL)
+    {
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        return OMX_ErrorInsufficientResources;
+    }
+    memset(pPortContainerExternal, 0, sizeof(PortContainerExternal));
+    pPortContainerExternal->pBuffer = pBuffer->pBuffer;
+    pPortContainerExternal->nFilledLen = pBuffer->nAllocLen;
+
+    if (pSfOMXComponent->functions->Queue_Enqueue(pRendererComponent->sinkPort.inputQ, (void *)pPortContainerExternal) == FALSE)
+    {
+        LOG(SF_LOG_ERR, "%p:%p FAIL\r\n", pRendererComponent->sinkPort.inputQ, pPortContainerExternal);
+        free(pPortContainerExternal);
+        return OMX_ErrorInsufficientResources;
+    }
+    LOG(SF_LOG_PERF, "output queue count=%d\r\n", pSfOMXComponent->functions->Queue_Get_Cnt(pRendererComponent->sinkPort.inputQ));
+    free(pPortContainerExternal);
+    pRendererComponent->pause = OMX_FALSE;
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_UseBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN OMX_U32 nSizeBytes,
+    OMX_IN OMX_U8 *pBuffer)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
+
+    FunctionIn();
+
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+    OMX_BUFFERHEADERTYPE *temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)malloc(sizeof(OMX_BUFFERHEADERTYPE));
+    if (temp_bufferHeader == NULL)
+    {
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        return OMX_ErrorInsufficientResources;
+    }
+    memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+    temp_bufferHeader->nAllocLen = nSizeBytes;
+    temp_bufferHeader->pAppPrivate = pAppPrivate;
+    temp_bufferHeader->pBuffer = pBuffer;
+    *ppBufferHdr = temp_bufferHeader;
+
+    ret = StoreOMXBuffer(pSfOMXComponent, temp_bufferHeader);
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_AllocateBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN OMX_U32 nSizeBytes)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
+
+    OMX_BUFFERHEADERTYPE *temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)malloc(sizeof(OMX_BUFFERHEADERTYPE));
+    if (temp_bufferHeader == NULL)
+    {
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        return OMX_ErrorInsufficientResources;
+    }
+    memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+    temp_bufferHeader->pBuffer = malloc(nSizeBytes);
+    if (temp_bufferHeader->pBuffer == NULL)
+    {
+        free(temp_bufferHeader);
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        return OMX_ErrorInsufficientResources;
+    }
+    memset(temp_bufferHeader->pBuffer, 0, nSizeBytes);
+    temp_bufferHeader->nAllocLen = nSizeBytes;
+    temp_bufferHeader->pAppPrivate = pAppPrivate;
+
+    *ppBuffer = temp_bufferHeader;
+
+    ret = StoreOMXBuffer(pSfOMXComponent, temp_bufferHeader);
+    LOG(SF_LOG_PERF, "buffer count = %d\r\n", GetOMXBufferCount(pSfOMXComponent));
+
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_GetParameter(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_IN OMX_INDEXTYPE nParamIndex,
+    OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
+
+    FunctionIn();
+
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+    switch ((OMX_U32)nParamIndex)
+    {
+    case OMX_IndexParamVideoInit:
+
+        break;
+    case OMX_IndexParamVideoPortFormat:
+    {
+        OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
+        OMX_U32 index = portFormat->nIndex;
+        switch (index)
+        {
+        case 0:
+            portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+            portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+            portFormat->xFramerate = 30;
+        default:
+            if (index > 0)
+            {
+                ret = OMX_ErrorNoMore;
+            }
+        }
+    }
+
+    break;
+    case OMX_IndexParamVideoBitrate:
+        break;
+    case OMX_IndexParamVideoQuantization:
+
+        break;
+    case OMX_IndexParamPortDefinition:
+    {
+        OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+        OMX_U32 portIndex = pPortDefinition->nPortIndex;
+        memcpy(pPortDefinition, &pSfOMXComponent->portDefinition[portIndex], pPortDefinition->nSize);
+    }
+
+    break;
+    case OMX_IndexParamVideoIntraRefresh:
+
+        break;
+
+    case OMX_IndexParamStandardComponentRole:
+
+        break;
+    case OMX_IndexParamVideoAvc:
+        break;
+    case OMX_IndexParamVideoHevc:
+        break;
+    case OMX_IndexParamVideoProfileLevelQuerySupported:
+
+        break;
+
+    default:
+
+        break;
+    }
+
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+static OMX_ERRORTYPE SF_OMX_SetParameter(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_IN OMX_INDEXTYPE nIndex,
+    OMX_IN OMX_PTR ComponentParameterStructure)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    FunctionIn();
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
+
+    if (pSfOMXComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+    TestDecConfig *testConfig = pSfOMXComponent->testConfig;
+
+    switch ((OMX_U32)nIndex)
+    {
+    case OMX_IndexParamVideoPortFormat:
+        break;
+    case OMX_IndexParamVideoBitrate:
+        break;
+    case OMX_IndexParamVideoQuantization:
+
+        break;
+    case OMX_IndexParamPortDefinition:
+    {
+        OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+        OMX_PARAM_PORTDEFINITIONTYPE *pInputPort = &pSfOMXComponent->portDefinition[0];
+        OMX_PARAM_PORTDEFINITIONTYPE *pOutputPort = &pSfOMXComponent->portDefinition[1];
+        TestDecConfig *pTestDecConfig = (TestDecConfig *)pSfOMXComponent->testConfig;
+        OMX_U32 portIndex = pPortDefinition->nPortIndex;
+        OMX_U32 width = pPortDefinition->format.video.nFrameWidth;
+        OMX_U32 height = pPortDefinition->format.video.nFrameHeight;
+        LOG(SF_LOG_INFO, "Set width = %d, height = %d on port %d\r\n", width, height, pPortDefinition->nPortIndex);
+
+        memcpy(&pSfOMXComponent->portDefinition[portIndex], pPortDefinition, pPortDefinition->nSize);
+
+        if (portIndex == 0)
+        {
+            pInputPort->format.video.nStride = width;
+            pInputPort->format.video.nSliceHeight = height;
+            pInputPort->nBufferSize = width * height * 2;
+        } else if (portIndex == 1)
+        {
+            if (width == 1)
+            {
+                width = pInputPort->format.video.nFrameWidth;
+            }
+            if (height == 1)
+            {
+                height = pInputPort->format.video.nFrameHeight;
+            }
+            int scalew = pInputPort->format.video.nFrameWidth / width;
+            int scaleh = pInputPort->format.video.nFrameHeight / height;
+            if (scalew > 8 || scaleh > 8 || scalew < 1 || scaleh < 1)
+            {
+                LOG(SF_LOG_ERR, "Scaling should be 1 to 1/8 (down-scaling only)!\r\n");
+                ret = OMX_ErrorBadParameter;
+                goto EXIT;
+            }
+            pOutputPort->format.video.nFrameWidth = width;
+            pOutputPort->format.video.nFrameHeight = height;
+            pOutputPort->format.video.nStride = width;
+            pOutputPort->format.video.nSliceHeight = height;
+            pTestDecConfig->scaleDownWidth = VPU_CEIL(width, 2);
+            pTestDecConfig->scaleDownHeight = VPU_CEIL(height, 2);
+            LOG(SF_LOG_INFO, "Set scale = %d, %d\r\n", pTestDecConfig->scaleDownWidth , pTestDecConfig->scaleDownHeight);
+            switch (pOutputPort->format.video.eColorFormat)
+            {
+            case OMX_COLOR_FormatYUV420Planar:
+            case OMX_COLOR_FormatYUV420SemiPlanar:
+                if (width && height)
+                    pOutputPort->nBufferSize = (width * height * 3) / 2;
+                break;
+            default:
+                if (width && height)
+                    pOutputPort->nBufferSize = width * height * 2;
+                break;
+            }
+        }
+    }
+    break;
+    case OMX_IndexParamVideoIntraRefresh:
+
+        break;
+
+    case OMX_IndexParamStandardComponentRole:
+
+        break;
+    case OMX_IndexParamVideoAvc:
+        testConfig->bitFormat = 0;
+        break;
+    case OMX_IndexParamVideoHevc:
+        testConfig->bitFormat = 12;
+        break;
+    case OMX_IndexConfigCommonInputCrop:
+        memcpy(testConfig->inputPath, ComponentParameterStructure, strlen(ComponentParameterStructure));
+        break;
+    case OMX_IndexConfigCommonOutputCrop:
+        memcpy(testConfig->outputPath, ComponentParameterStructure, strlen(ComponentParameterStructure));
+        break;
+    default:
+
+        break;
+    }
+
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_GetConfig(
+    OMX_HANDLETYPE hComponent,
+    OMX_INDEXTYPE nIndex,
+    OMX_PTR pComponentConfigStructure)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    FunctionIn();
+
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+
+    switch (nIndex)
+    {
+    case OMX_IndexConfigVideoAVCIntraPeriod:
+
+        break;
+    case OMX_IndexConfigVideoBitrate:
+
+        break;
+    case OMX_IndexConfigVideoFramerate:
+
+        break;
+
+    default:
+        break;
+    }
+
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_SetConfig(
+    OMX_HANDLETYPE hComponent,
+    OMX_INDEXTYPE nIndex,
+    OMX_PTR pComponentConfigStructure)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    FunctionIn();
+
+    if (hComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+
+    switch ((OMX_U32)nIndex)
+    {
+    case OMX_IndexConfigVideoAVCIntraPeriod:
+        break;
+    case OMX_IndexConfigVideoBitrate:
+        break;
+    case OMX_IndexConfigVideoFramerate:
+        break;
+    case OMX_IndexConfigVideoIntraVOPRefresh:
+        break;
+    default:
+
+        break;
+    }
+
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_GetExtensionIndex(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_IN OMX_STRING cParameterName,
+    OMX_OUT OMX_INDEXTYPE *pIndexType)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    FunctionIn();
+
+    FunctionOut();
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_GetComponentVersion(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_OUT OMX_STRING pComponentName,
+    OMX_OUT OMX_VERSIONTYPE *pComponentVersion,
+    OMX_OUT OMX_VERSIONTYPE *pSpecVersion,
+    OMX_OUT OMX_UUIDTYPE *pComponentUUID)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    FunctionIn();
+
+    FunctionOut();
+    return ret;
+}
+
+static OMX_ERRORTYPE InitDecoder(SF_OMX_COMPONENT *pSfOMXComponent)
+{
+    TestDecConfig *testConfig = NULL;
+    CNMComponentConfig *config = NULL;
+    Uint32 sizeInWord;
+    char *fwPath = NULL;
+
+    if (pSfOMXComponent->hSFComponentExecoder != NULL)
+    {
+        return OMX_ErrorNone;
+    }
+
+    FunctionIn();
+
+    testConfig = (TestDecConfig *)pSfOMXComponent->testConfig;
+
+    testConfig->productId = (ProductId)pSfOMXComponent->functions->VPU_GetProductId(testConfig->coreIdx);
+    if (CheckDecTestConfig(testConfig) == FALSE)
+    {
+        LOG(SF_LOG_ERR, "fail to CheckTestConfig()\n");
+        return OMX_ErrorBadParameter;
+    }
+
+    switch (testConfig->productId)
+    {
+    case PRODUCT_ID_521:
+        fwPath = pSfOMXComponent->fwPath;
+        break;
+    case PRODUCT_ID_511:
+        fwPath = pSfOMXComponent->fwPath;
+        break;
+    case PRODUCT_ID_517:
+        fwPath = CORE_7_BIT_CODE_FILE_PATH;
+        break;
+    default:
+        LOG(SF_LOG_ERR, "Unknown product id: %d, whether kernel module loaded?\n", testConfig->productId);
+        return OMX_ErrorBadParameter;
+    }
+    LOG(SF_LOG_INFO, "FW PATH = %s\n", fwPath);
+    if (pSfOMXComponent->functions->LoadFirmware(testConfig->productId, (Uint8 **)&(pSfOMXComponent->pusBitCode), &sizeInWord, fwPath) < 0)
+    {
+        LOG(SF_LOG_ERR, "Failed to load firmware: %s\n", fwPath);
+        return OMX_ErrorInsufficientResources;
+    }
+
+    config = pSfOMXComponent->config;
+    memcpy(&(config->testDecConfig), testConfig, sizeof(TestDecConfig));
+    config->bitcode = (Uint8 *)pSfOMXComponent->pusBitCode;
+    config->sizeOfBitcode = sizeInWord;
+
+    if (pSfOMXComponent->functions->SetUpDecoderOpenParam(&config->decOpenParam, &config->testDecConfig) != RETCODE_SUCCESS)
+    {
+        LOG(SF_LOG_ERR, "SetupDecoderOpenParam error\n");
+        return OMX_ErrorBadParameter;
+    }
+    pSfOMXComponent->hSFComponentExecoder = pSfOMXComponent->functions->ComponentCreate("wave_decoder", config);
+    pSfOMXComponent->hSFComponentFeeder = pSfOMXComponent->functions->ComponentCreate("feeder", config);
+    pSfOMXComponent->hSFComponentRender = pSfOMXComponent->functions->ComponentCreate("renderer", config);
+
+    ComponentImpl *pFeederComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentFeeder;
+    pSfOMXComponent->functions->ComponentPortCreate(&pFeederComponent->srcPort, pSfOMXComponent->hSFComponentFeeder, 5, sizeof(PortContainerExternal));
+
+    ComponentImpl *pRenderComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentRender;
+    pSfOMXComponent->functions->ComponentPortDestroy(&pRenderComponent->sinkPort);
+    pSfOMXComponent->functions->ComponentPortCreate(&pRenderComponent->sinkPort, pSfOMXComponent->hSFComponentRender, 5, sizeof(PortContainerExternal));
+
+    if (pSfOMXComponent->functions->SetupDecListenerContext(pSfOMXComponent->lsnCtx, config, NULL) == TRUE)
+    {
+        pSfOMXComponent->functions->ComponentRegisterListener(pSfOMXComponent->hSFComponentExecoder,
+                                                              COMPONENT_EVENT_DEC_ALL, pSfOMXComponent->functions->DecoderListener, (void *)pSfOMXComponent->lsnCtx);
+        pSfOMXComponent->functions->ComponentRegisterListener(pSfOMXComponent->hSFComponentExecoder,
+                                                              COMPONENT_EVENT_DEC_REGISTER_FB, OnEventArrived, (void *)pSfOMXComponent->lsnCtx);
+        pSfOMXComponent->functions->ComponentRegisterListener(pSfOMXComponent->hSFComponentExecoder,
+                                                              COMPONENT_EVENT_DEC_DECODED_ALL, OnEventArrived, (void *)pSfOMXComponent->lsnCtx);
+        pSfOMXComponent->functions->ComponentRegisterListener(pSfOMXComponent->hSFComponentFeeder,
+                                                              COMPONENT_EVENT_DEC_ALL, OnEventArrived, (void *)pSfOMXComponent->lsnCtx);
+        pSfOMXComponent->functions->ComponentRegisterListener(pSfOMXComponent->hSFComponentRender,
+                                                              COMPONENT_EVENT_DEC_ALL, OnEventArrived, (void *)pSfOMXComponent->lsnCtx);
+    }
+    else
+    {
+        LOG(SF_LOG_ERR, "ComponentRegisterListener fail\r\n");
+        return OMX_ErrorBadParameter;
+    }
+
+    pSfOMXComponent->functions->ComponentSetupTunnel(pSfOMXComponent->hSFComponentFeeder, pSfOMXComponent->hSFComponentExecoder);
+    pSfOMXComponent->functions->ComponentSetupTunnel(pSfOMXComponent->hSFComponentExecoder, pSfOMXComponent->hSFComponentRender);
+    FunctionOut();
+    return OMX_ErrorNone;
+}
+
+static OMX_ERRORTYPE SF_OMX_SendCommand(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_IN OMX_COMMANDTYPE Cmd,
+    OMX_IN OMX_U32 nParam,
+    OMX_IN OMX_PTR pCmdData)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
+    ComponentImpl *pSFComponentDecoder = NULL;
+    ComponentImpl *pSFComponentFeeder = NULL;
+    ComponentImpl *pSFComponentRender = NULL;
+    ComponentState componentState;
+
+    FunctionIn();
+    if (hComponent == NULL || pSfOMXComponent == NULL)
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+
+    switch (Cmd)
+    {
+    case OMX_CommandStateSet:
+        switch (nParam)
+        {
+        case OMX_StateIdle:
+            ret = InitDecoder(pSfOMXComponent);
+            if (ret != OMX_ErrorNone)
+            {
+                goto EXIT;
+            }
+            pSFComponentDecoder = (ComponentImpl *)pSfOMXComponent->hSFComponentExecoder;
+            pSFComponentFeeder = (ComponentImpl *)pSfOMXComponent->hSFComponentFeeder;
+            pSFComponentRender = (ComponentImpl *)pSfOMXComponent->hSFComponentRender;
+
+            pSFComponentDecoder->pause = OMX_TRUE;
+            pSFComponentFeeder->pause = OMX_TRUE;
+            pSFComponentRender->pause = OMX_TRUE;
+            pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
+                                                     OMX_EventCmdComplete, OMX_CommandStateSet, nParam, NULL);
+            break;
+
+        case OMX_StateExecuting:
+            ret = InitDecoder(pSfOMXComponent);
+            if (ret != OMX_ErrorNone)
+            {
+                goto EXIT;
+            }
+            pSFComponentDecoder = (ComponentImpl *)pSfOMXComponent->hSFComponentExecoder;
+            pSFComponentFeeder = (ComponentImpl *)pSfOMXComponent->hSFComponentFeeder;
+            pSFComponentRender = (ComponentImpl *)pSfOMXComponent->hSFComponentRender;
+
+            pSFComponentDecoder->pause = OMX_FALSE;
+            if (pSFComponentDecoder->thread == NULL)
+            {
+                LOG(SF_LOG_INFO, "execute component %s\r\n", pSFComponentDecoder->name);
+                componentState = pSfOMXComponent->functions->ComponentExecute(pSFComponentDecoder);
+                LOG(SF_LOG_INFO, "ret = %d\r\n", componentState);
+            }
+            if (pSFComponentFeeder->thread == NULL)
+            {
+                LOG(SF_LOG_INFO, "execute component %s\r\n", pSFComponentFeeder->name);
+                componentState = pSfOMXComponent->functions->ComponentExecute(pSFComponentFeeder);
+                LOG(SF_LOG_INFO, "ret = %d\r\n", componentState);
+            }
+            if (pSFComponentRender->thread == NULL)
+            {
+                LOG(SF_LOG_INFO, "execute component %s\r\n", pSFComponentRender->name);
+                componentState = pSfOMXComponent->functions->ComponentExecute(pSFComponentRender);
+                LOG(SF_LOG_INFO, "ret = %d\r\n", componentState);
+            }
+            break;
+        default:
+            break;
+        }
+        pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
+                                                 OMX_EventCmdComplete, OMX_CommandStateSet, nParam, NULL);
+        break;
+    case OMX_CommandFlush:
+        pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
+                                                 OMX_EventCmdComplete, OMX_CommandFlush, nParam, NULL);
+        break;
+    case OMX_CommandPortDisable:
+        pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
+                                                 OMX_EventCmdComplete, OMX_CommandPortDisable, nParam, NULL);
+        break;
+    case OMX_CommandPortEnable:
+        pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
+                                                 OMX_EventCmdComplete, OMX_CommandPortEnable, nParam, NULL);
+        break;
+    case OMX_CommandMarkBuffer:
+
+        break;
+    default:
+        break;
+    }
+
+EXIT:
+    FunctionOut();
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_GetState(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_OUT OMX_STATETYPE *pState)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+    GetStateCommon(hComponent, pState);
+
+    FunctionOut();
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_FreeBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
+
+    FunctionIn();
+    ClearOMXBuffer(pSfOMXComponent, pBufferHdr);
+    LOG(SF_LOG_PERF, "buffer count = %d\r\n", GetOMXBufferCount(pSfOMXComponent));
+    free(pBufferHdr);
+
+    FunctionOut();
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_UseEGLImage(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN void *eglImage)
+{
+    (void)hComponent;
+    (void)ppBufferHdr;
+    (void)nPortIndex;
+    (void)pAppPrivate;
+    (void)eglImage;
+    return OMX_ErrorNotImplemented;
+}
+
+static OMX_ERRORTYPE SF_OMX_ComponentConstructor(SF_OMX_COMPONENT *hComponent)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+
+    ret = InitComponentStructorCommon(hComponent);
+    if (ret != OMX_ErrorNone)
+    {
+        goto EXIT;
+    }
+    TestDecConfig *pTestDecConfig = (TestDecConfig *)hComponent->testConfig;
+    pTestDecConfig->feedingMode = FEEDING_METHOD_BUFFER;
+    pTestDecConfig->bitstreamMode = BS_MODE_PIC_END;
+    pTestDecConfig->bitFormat = hComponent->bitFormat;
+    /* 
+     if cbcrInterleave is FALSE and nv21 is FALSE, the default dec format is I420
+     if cbcrInterleave is TRUE and nv21 is FALSE, then the dec format is NV12
+     if cbcrInterleave is TRUE and nv21 is TRUE, then the dec format is NV21
+    */
+    pTestDecConfig->cbcrInterleave = TRUE;
+    pTestDecConfig->nv21 = FALSE;
+
+    hComponent->pOMXComponent->UseBuffer = &SF_OMX_UseBuffer;
+    hComponent->pOMXComponent->AllocateBuffer = &SF_OMX_AllocateBuffer;
+    hComponent->pOMXComponent->EmptyThisBuffer = &SF_OMX_EmptyThisBuffer;
+    hComponent->pOMXComponent->FillThisBuffer = &SF_OMX_FillThisBuffer;
+    hComponent->pOMXComponent->FreeBuffer = &SF_OMX_FreeBuffer;
+    // hComponent->pOMXComponent->ComponentTunnelRequest = &SF_OMX_ComponentTunnelRequest;
+    hComponent->pOMXComponent->GetParameter = &SF_OMX_GetParameter;
+    hComponent->pOMXComponent->SetParameter = &SF_OMX_SetParameter;
+    hComponent->pOMXComponent->GetConfig = &SF_OMX_GetConfig;
+    hComponent->pOMXComponent->SetConfig = &SF_OMX_SetConfig;
+    hComponent->pOMXComponent->SendCommand = &SF_OMX_SendCommand;
+    hComponent->pOMXComponent->GetState = &SF_OMX_GetState;
+    // hComponent->pOMXComponent->GetExtensionIndex = &SF_OMX_GetExtensionIndex;
+    // hComponent->pOMXComponent->ComponentRoleEnum = &SF_OMX_ComponentRoleEnum;
+    // hComponent->pOMXComponent->ComponentDeInit = &SF_OMX_ComponentDeInit;
+    hComponent->inputSemaphore = (sem_t *)malloc(sizeof(sem_t));
+    if (hComponent->inputSemaphore == NULL)
+    {
+        LOG(SF_LOG_ERR, "malloc fail\r\n");
+        ret = OMX_ErrorInsufficientResources;
+        goto EXIT;
+    }
+    sem_init(hComponent->inputSemaphore, 0, 5);
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_ComponentClear(SF_OMX_COMPONENT *hComponent)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    ComponentImpl *pSFComponentDecoder = (ComponentImpl *)hComponent->hSFComponentExecoder;
+    ComponentImpl *pSFComponentFeeder = (ComponentImpl *)hComponent->hSFComponentFeeder;
+    ComponentImpl *pSFComponentRender = (ComponentImpl *)hComponent->hSFComponentRender;
+
+    FunctionIn();
+    if (pSFComponentDecoder == NULL || pSFComponentFeeder == NULL || pSFComponentRender == NULL)
+    {
+        goto EXIT;
+    }
+    pSFComponentDecoder->terminate = OMX_TRUE;
+    pSFComponentFeeder->terminate = OMX_TRUE;
+    pSFComponentRender->terminate = OMX_TRUE;
+    hComponent->functions->ComponentWait(hComponent->hSFComponentFeeder);
+    hComponent->functions->ComponentWait(hComponent->hSFComponentExecoder);
+    hComponent->functions->ComponentWait(hComponent->hSFComponentRender);
+
+    free(hComponent->pusBitCode);
+    hComponent->functions->ClearDecListenerContext(hComponent->lsnCtx);
+    ComponentClearCommon(hComponent);
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+SF_OMX_COMPONENT sf_dec_decoder_h265 = {
+    .componentName = "sf.dec.decoder.h265",
+    .libName = "libsfdec.so",
+    .pOMXComponent = NULL,
+    .SF_OMX_ComponentConstructor = SF_OMX_ComponentConstructor,
+    .SF_OMX_ComponentClear = SF_OMX_ComponentClear,
+    .functions = NULL,
+    .bitFormat = STD_HEVC,
+    .fwPath = "/lib/firmware/chagall.bin"};
+
+SF_OMX_COMPONENT sf_dec_decoder_h264 = {
+    .componentName = "sf.dec.decoder.h264",
+    .libName = "libsfdec.so",
+    .pOMXComponent = NULL,
+    .SF_OMX_ComponentConstructor = SF_OMX_ComponentConstructor,
+    .SF_OMX_ComponentClear = SF_OMX_ComponentClear,
+    .functions = NULL,
+    .bitFormat = STD_AVC,
+    .fwPath = "/lib/firmware/chagall.bin"};

+ 55 - 0
soft_3rdpart/omx-il/component/video/enc/SF_OMX_Venc_encoder.c

@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 StarFive Technology Co., Ltd.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SF_OMX_video_common.h"
+#include "SF_OMX_Core.h"
+
+static OMX_ERRORTYPE SF_OMX_UseEGLImage(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN void *eglImage)
+{
+    (void)hComponent;
+    (void)ppBufferHdr;
+    (void)nPortIndex;
+    (void)pAppPrivate;
+    (void)eglImage;
+    return OMX_ErrorNotImplemented;
+}
+
+static OMX_ERRORTYPE SF_OMX_ComponentConstructor(SF_OMX_COMPONENT *hComponent)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+static OMX_ERRORTYPE SF_OMX_ComponentClear(SF_OMX_COMPONENT *hComponent)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+
+EXIT:
+    FunctionOut();
+
+    return ret;  
+}
+
+SF_OMX_COMPONENT sf_enc_encoder = {
+    .componentName = "sf.enc.encoder",
+    .libName = "libsfenc.so",
+    .pOMXComponent = NULL,
+    .SF_OMX_ComponentConstructor = SF_OMX_ComponentConstructor,
+    .SF_OMX_ComponentClear = SF_OMX_ComponentClear,
+    .functions = NULL,
+};

+ 397 - 0
soft_3rdpart/omx-il/core/SF_OMX_Core.c

@@ -0,0 +1,397 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 StarFive Technology Co., Ltd.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdlib.h>
+#include "SF_OMX_Core.h"
+
+static int gInitialized = 0;
+OMX_TICKS gInitTimeStamp = 0;
+int gDebugLevel = SF_LOG_ERR;
+extern SF_OMX_COMPONENT sf_dec_decoder_h265;
+extern SF_OMX_COMPONENT sf_dec_decoder_h264;
+
+static SF_OMX_COMPONENT *sf_omx_component_list[] = {
+    &sf_dec_decoder_h265,
+    &sf_dec_decoder_h264,
+    NULL,
+};
+
+#define SF_OMX_COMPONENT_NUM (sizeof(sf_omx_component_list) / sizeof(SF_OMX_COMPONENT *))
+
+int GetNumberOfComponent()
+{
+    return sizeof(sf_omx_component_list) / sizeof(SF_OMX_COMPONENT *);
+}
+
+OMX_ERRORTYPE SF_OMX_ComponentLoad(SF_OMX_COMPONENT *sf_component)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    FunctionIn();
+
+    sf_component->SF_OMX_ComponentConstructor(sf_component);
+
+    FunctionOut();
+
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    char *debugLevel = NULL;
+    FunctionIn();
+    if (gInitialized == 0)
+    {
+        gInitialized = 1;
+    }
+
+    debugLevel = getenv("OMX_DEBUG");
+    if (debugLevel != NULL)
+    {
+        gDebugLevel = atoi(debugLevel);
+    }
+
+    FunctionOut();
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    FunctionIn();
+
+    FunctionOut();
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(
+    OMX_OUT OMX_STRING cComponentName,
+    OMX_IN OMX_U32 nNameLength,
+    OMX_IN OMX_U32 nIndex)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    FunctionIn();
+
+    if (nIndex >= SF_OMX_COMPONENT_NUM)
+    {
+        ret = OMX_ErrorNoMore;
+        goto EXIT;
+    }
+    snprintf(cComponentName, nNameLength, "%s", sf_omx_component_list[nIndex]->componentName);
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(
+    OMX_OUT OMX_HANDLETYPE *pHandle,
+    OMX_IN OMX_STRING cComponentName,
+    OMX_IN OMX_PTR pAppData,
+    OMX_IN OMX_CALLBACKTYPE *pCallBacks)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    unsigned int i = 0;
+    SF_OMX_COMPONENT *pSf_omx_component = NULL;
+
+    FunctionIn();
+    if (gInitialized != 1)
+    {
+        ret = OMX_ErrorNotReady;
+        goto EXIT;
+    }
+
+    if ((pHandle == NULL) || (cComponentName == NULL))
+    {
+        ret = OMX_ErrorBadParameter;
+        goto EXIT;
+    }
+
+    for (i = 0; i < SF_OMX_COMPONENT_NUM; i++)
+    {
+        pSf_omx_component = sf_omx_component_list[i];
+        if (pSf_omx_component == NULL)
+        {
+            ret = OMX_ErrorBadParameter;
+            goto EXIT;
+        }
+        if (strcmp(cComponentName, pSf_omx_component->componentName) == 0)
+        {
+            ret = pSf_omx_component->SF_OMX_ComponentConstructor(pSf_omx_component);
+            if (ret != OMX_ErrorNone)
+            {
+                goto EXIT;
+            }
+            *pHandle = pSf_omx_component->pOMXComponent;
+            pSf_omx_component->callbacks = pCallBacks;
+            pSf_omx_component->pAppData = pAppData;
+            break;
+        }
+    }
+EXIT:
+    FunctionOut();
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+    SF_OMX_COMPONENT *pSfOMXComponent = (SF_OMX_COMPONENT *)pOMXComponent->pComponentPrivate;
+    FunctionIn();
+    ret = pSfOMXComponent->SF_OMX_ComponentClear(pSfOMXComponent);
+
+    FunctionOut();
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel(
+    OMX_IN OMX_HANDLETYPE hOutput,
+    OMX_IN OMX_U32 nPortOutput,
+    OMX_IN OMX_HANDLETYPE hInput,
+    OMX_IN OMX_U32 nPortInput)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    // OMX_COMPONENTTYPE *pOMXComponent_hOutput = (OMX_COMPONENTTYPE *)hOutput;
+    // OMX_COMPONENTTYPE *pOMXComponent_hInput = (OMX_COMPONENTTYPE *)hInput;
+
+    FunctionIn();
+    ret = OMX_ErrorNotImplemented;
+
+    FunctionOut();
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_GetContentPipe(
+    OMX_OUT OMX_HANDLETYPE *hPipe,
+    OMX_IN OMX_STRING szURI)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+
+    FunctionOut();
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole(
+    OMX_IN OMX_STRING role,
+    OMX_INOUT OMX_U32 *pNumComps,
+    OMX_INOUT OMX_U8 **compNames)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+
+    FunctionOut();
+    return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent(
+    OMX_IN OMX_STRING compName,
+    OMX_INOUT OMX_U32 *pNumRoles,
+    OMX_OUT OMX_U8 **roles)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+    FunctionIn();
+
+    FunctionOut();
+    return ret;
+}
+
+void sf_get_component_functions(SF_COMPONENT_FUNCTIONS *funcs, OMX_PTR *sohandle)
+{
+    FunctionIn();
+    funcs->ComponentCreate = dlsym(sohandle, "ComponentCreate");
+    funcs->ComponentExecute = dlsym(sohandle, "ComponentExecute");
+    funcs->ComponentGetParameter = dlsym(sohandle, "ComponentGetParameter");
+    funcs->ComponentGetState = dlsym(sohandle, "ComponentGetState");
+    funcs->ComponentNotifyListeners = dlsym(sohandle, "ComponentNotifyListeners");
+    funcs->ComponentPortCreate = dlsym(sohandle, "ComponentPortCreate");
+    funcs->ComponentPortDestroy = dlsym(sohandle, "ComponentPortDestroy");
+    funcs->ComponentPortFlush = dlsym(sohandle, "ComponentPortFlush");
+    funcs->ComponentPortGetData = dlsym(sohandle, "ComponentPortGetData");
+    funcs->ComponentPortPeekData = dlsym(sohandle, "ComponentPortPeekData");
+    funcs->ComponentPortSetData = dlsym(sohandle, "ComponentPortSetData");
+    funcs->ComponentPortWaitReadyStatus = dlsym(sohandle, "ComponentPortWaitReadyStatus");
+    funcs->ComponentRelease = dlsym(sohandle, "ComponentRelease");
+    funcs->ComponentSetParameter = dlsym(sohandle, "ComponentSetParameter");
+    funcs->ComponentStop = dlsym(sohandle, "ComponentStop");
+    funcs->ComponentSetupTunnel = dlsym(sohandle, "ComponentSetupTunnel");
+    funcs->ComponentWait = dlsym(sohandle, "ComponentWait");
+    funcs->WaitBeforeComponentPortGetData = dlsym(sohandle, "WaitBeforeComponentPortGetData");
+    funcs->ComponentChangeState = dlsym(sohandle, "ComponentChangeState");
+    funcs->ComponentDestroy = dlsym(sohandle, "ComponentDestroy");
+    funcs->ComponentRegisterListener = dlsym(sohandle, "ComponentRegisterListener");
+    funcs->ComponentPortHasInputData = dlsym(sohandle, "ComponentPortHasInputData");
+    funcs->ComponentPortGetSize = dlsym(sohandle, "ComponentPortGetSize");
+    funcs->ComponentParamReturnTest = dlsym(sohandle, "ComponentParamReturnTest");
+    //Listener
+    funcs->SetupDecListenerContext = dlsym(sohandle, "SetupDecListenerContext");
+    funcs->SetupEncListenerContext = dlsym(sohandle, "SetupEncListenerContext");
+    funcs->ClearDecListenerContext = dlsym(sohandle, "ClearDecListenerContext");
+    funcs->HandleDecCompleteSeqEvent = dlsym(sohandle, "HandleDecCompleteSeqEvent");
+    funcs->HandleDecRegisterFbEvent = dlsym(sohandle, "HandleDecRegisterFbEvent");
+    funcs->HandleDecGetOutputEvent = dlsym(sohandle, "HandleDecGetOutputEvent");
+    funcs->HandleDecCloseEvent = dlsym(sohandle, "HandleDecCloseEvent");
+    funcs->ClearEncListenerContext = dlsym(sohandle, "ClearEncListenerContext");
+    funcs->HandleEncFullEvent = dlsym(sohandle, "HandleEncFullEvent");
+    funcs->HandleEncGetOutputEvent = dlsym(sohandle, "HandleEncGetOutputEvent");
+    funcs->HandleEncCompleteSeqEvent = dlsym(sohandle, "HandleEncCompleteSeqEvent");
+    funcs->HandleEncGetEncCloseEvent = dlsym(sohandle, "HandleEncGetEncCloseEvent");
+    funcs->EncoderListener = dlsym(sohandle, "EncoderListener");
+    funcs->DecoderListener = dlsym(sohandle, "DecoderListener");
+    // Helper
+    funcs->SetDefaultEncTestConfig = dlsym(sohandle, "SetDefaultEncTestConfig");
+    funcs->SetDefaultDecTestConfig = dlsym(sohandle, "SetDefaultDecTestConfig");
+    funcs->LoadFirmware = dlsym(sohandle, "LoadFirmware");
+    funcs->SetupEncoderOpenParam = dlsym(sohandle, "SetupEncoderOpenParam");
+    funcs->SetUpDecoderOpenParam = dlsym(sohandle, "SetUpDecoderOpenParam");
+    // VPU
+    funcs->VPU_GetProductId = dlsym(sohandle, "VPU_GetProductId");
+    funcs->Queue_Enqueue = dlsym(sohandle, "Queue_Enqueue");
+    funcs->Queue_Get_Cnt = dlsym(sohandle, "Queue_Get_Cnt");
+    // VPU Log
+    funcs->InitLog = dlsym(sohandle, "InitLog");
+    funcs->DeInitLog = dlsym(sohandle, "DeInitLog");
+    funcs->SetMaxLogLevel = dlsym(sohandle, "SetMaxLogLevel");
+    funcs->GetMaxLogLevel = dlsym(sohandle, "GetMaxLogLevel");
+    FunctionOut();
+}
+
+SF_OMX_COMPONENT *GetSFOMXComponrntByComponent(Component *pComponent)
+{
+    SF_OMX_COMPONENT *pSFOMXComponent = NULL;
+    int size = GetNumberOfComponent();
+
+    FunctionIn();
+    for (int i = 0; i < size; i++)
+    {
+        pSFOMXComponent = sf_omx_component_list[i];
+        if (pSFOMXComponent == NULL)
+        {
+            goto EXIT;
+        }
+        if (pSFOMXComponent->hSFComponentExecoder == pComponent || pSFOMXComponent->hSFComponentFeeder == pComponent || pSFOMXComponent->hSFComponentRender == pComponent)
+        {
+            break;
+        }
+    }
+EXIT:
+    FunctionOut();
+
+    return pSFOMXComponent;
+}
+
+OMX_ERRORTYPE ClearOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer)
+{
+    OMX_U32 i = 0;
+    for (i = 0; i < sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]); i++)
+    {
+        if (pSfOMXComponent->pBufferArray[i] == pBuffer)
+        {
+            pSfOMXComponent->pBufferArray[i] = NULL;
+            return OMX_ErrorNone;
+        }
+    }
+    if (i == sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]))
+    {
+        LOG(SF_LOG_ERR, "Could Not found omx buffer!\r\n");
+    }
+    return OMX_ErrorBadParameter;
+}
+
+OMX_U32 GetOMXBufferCount(SF_OMX_COMPONENT *pSfOMXComponent)
+{
+    OMX_U32 i = 0;
+    OMX_U32 count = 0;
+    for (i = 0; i < sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]); i++)
+    {
+        if (pSfOMXComponent->pBufferArray[i] != NULL)
+        {
+            count++;
+        }
+    }
+
+    return count;
+}
+
+OMX_ERRORTYPE StoreOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer)
+{
+    OMX_U32 i = 0;
+    for (i = 0; i < sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]); i++)
+    {
+        if (pSfOMXComponent->pBufferArray[i] == NULL)
+        {
+            pSfOMXComponent->pBufferArray[i] = pBuffer;
+            return OMX_ErrorNone;
+        }
+    }
+    if (i == sizeof(pSfOMXComponent->pBufferArray))
+    {
+        LOG(SF_LOG_ERR, "Buffer arrary full!\r\n");
+    }
+    return OMX_ErrorInsufficientResources;
+}
+
+OMX_BUFFERHEADERTYPE *GetOMXBufferByAddr(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8 *pAddr)
+{
+    OMX_U32 i = 0;
+    OMX_BUFFERHEADERTYPE *pOMXBuffer;
+
+    for (i = 0; i < sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]); i++)
+    {
+        pOMXBuffer = pSfOMXComponent->pBufferArray[i];
+        if (pOMXBuffer->pBuffer == pAddr)
+        {
+            return pOMXBuffer;
+        }
+    }
+    if (i == sizeof(pSfOMXComponent->pBufferArray))
+    {
+        LOG(SF_LOG_ERR, "could not find buffer!\r\n");
+    }
+    return NULL;
+}
+void SF_LogMsg(int level, const char *function, int line, const char *format, ...)
+{
+    char *prefix = "";
+    va_list ptr;
+    struct timeval tv;
+
+    if (level > gDebugLevel)
+    {
+        return;
+    }
+
+    switch (level)
+    {
+    case SF_LOG_ERR:
+        prefix = "[ERROR]";
+        break;
+    case SF_LOG_WARN:
+        prefix = "[WARN ]";
+        break;
+    case SF_LOG_PERF:
+        prefix = "[PERF ]";
+        break;
+    case SF_LOG_INFO:
+        prefix = "[INFO ]";
+        break;
+    case SF_LOG_DEBUG:
+        prefix = "[DEBUG]";
+        break;
+    default:
+        break;
+    }
+    gettimeofday(&tv, NULL);
+    printf("[%06d:%06d]%10s%32s%10d\t", tv.tv_sec, tv.tv_usec, prefix, function, line);
+    va_start(ptr, format);
+    vprintf(format, ptr);
+    va_end(ptr);
+}

+ 156 - 0
soft_3rdpart/omx-il/core/SF_OMX_Core.h

@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 StarFive Technology Co., Ltd.
+ */
+#ifndef OMX__CORE
+#define OMX__CORE
+
+#include <semaphore.h>
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+#include "OMX_Component.h"
+#include "component.h"
+#include "encoder_listener.h"
+#include "decoder_listener.h"
+#include <sys/time.h>
+#include <stdarg.h>
+#include <dlfcn.h>
+#include <string.h>
+
+#define ENABLE_DEBUG
+#ifdef ENABLE_DEBUG
+enum
+{
+    SF_LOG_ERR = 0,
+    SF_LOG_WARN,
+    SF_LOG_PERF,
+    SF_LOG_INFO,
+    SF_LOG_DEBUG,
+    SF_LOG_ALL,
+};
+void SF_LogMsg(int level, const char *function, int line, const char *format, ...);
+#define LOG(level, ...) SF_LogMsg(level, __FUNCTION__, __LINE__, __VA_ARGS__);
+#define FunctionIn() SF_LogMsg(SF_LOG_DEBUG, __FUNCTION__, __LINE__, "FUN IN\r\n");
+#define FunctionOut() SF_LogMsg(SF_LOG_DEBUG, __FUNCTION__, __LINE__, "FUN OUT\r\n");
+#else
+#define FunctionIn()
+#define FunctionOut()
+#endif
+
+typedef struct _SF_COMPONENT_FUNCTIONS
+{
+    Component (*ComponentCreate)(const char *componentName, CNMComponentConfig *componentParam);
+    BOOL(*ComponentSetupTunnel)(Component fromComponent, Component toComponent);
+    ComponentState (*ComponentExecute)(Component component);
+    Int32 (*ComponentWait)(Component component);
+    void (*ComponentStop)(Component component);
+    void (*ComponentRelease)(Component component);
+    BOOL(*ComponentChangeState)(Component component, Uint32 state);
+    BOOL(*ComponentDestroy)(Component component, BOOL *ret);
+    CNMComponentParamRet (*ComponentGetParameter)(Component from, Component to, GetParameterCMD commandType, void *data);
+    CNMComponentParamRet (*ComponentSetParameter)(Component from, Component to, SetParameterCMD commandType, void *data);
+    void (*ComponentNotifyListeners)(Component component, Uint64 event, void *data);
+    BOOL(*ComponentRegisterListener)(Component component, Uint64 events, ComponentListenerFunc func, void *context);
+    void (*ComponentPortCreate)(Port *port, Component owner, Uint32 depth, Uint32 size);
+    void (*ComponentPortSetData)(Port *port, PortContainer *portData);
+    PortContainer *(*ComponentPortPeekData)(Port *port);
+    PortContainer *(*ComponentPortGetData)(Port *port);
+    void *(*WaitBeforeComponentPortGetData)(Port *port);
+    void (*ComponentPortWaitReadyStatus)(Port *port);
+    void (*ComponentPortDestroy)(Port *port);
+    BOOL(*ComponentPortHasInputData)(Port *port);
+    Uint32 (*ComponentPortGetSize)(Port *port);
+    void (*ComponentPortFlush)(Component component);
+    ComponentState (*ComponentGetState)(Component component);
+    BOOL(*ComponentParamReturnTest)(CNMComponentParamRet ret, BOOL *retry);
+    // Listener
+    BOOL(*SetupDecListenerContext)(DecListenerContext *ctx, CNMComponentConfig *config, Component renderer);
+    BOOL(*SetupEncListenerContext)(EncListenerContext *ctx, CNMComponentConfig *config);
+    void (*ClearDecListenerContext)(DecListenerContext *ctx);
+    void (*HandleDecCompleteSeqEvent)(Component com, CNMComListenerDecCompleteSeq *param, DecListenerContext *ctx);
+    void (*HandleDecRegisterFbEvent)(Component com, CNMComListenerDecRegisterFb *param, DecListenerContext *ctx);
+    void (*HandleDecGetOutputEvent)(Component com, CNMComListenerDecDone *param, DecListenerContext *ctx);
+    void (*HandleDecCloseEvent)(Component com, CNMComListenerDecClose *param, DecListenerContext *ctx);
+    void (*ClearEncListenerContext)(EncListenerContext *ctx);
+    void (*HandleEncFullEvent)(Component com, CNMComListenerEncFull *param, EncListenerContext *ctx);
+    void (*HandleEncGetOutputEvent)(Component com, CNMComListenerEncDone *param, EncListenerContext *ctx);
+    void (*HandleEncCompleteSeqEvent)(Component com, CNMComListenerEncCompleteSeq *param, EncListenerContext *ctx);
+    void (*HandleEncGetEncCloseEvent)(Component com, CNMComListenerEncClose *param, EncListenerContext *ctx);
+    void (*EncoderListener)(Component com, Uint64 event, void *data, void *context);
+    void (*DecoderListener)(Component com, Uint64 event, void *data, void *context);
+    // Helper
+    void (*SetDefaultEncTestConfig)(TestEncConfig *testConfig);
+    void (*SetDefaultDecTestConfig)(TestDecConfig *testConfig);
+    Int32 (*LoadFirmware)(Int32 productId, Uint8 **retFirmware, Uint32 *retSizeInWord, const char *path);
+    BOOL(*SetupEncoderOpenParam)(EncOpenParam *param, TestEncConfig *config, ENC_CFG *encCfg);
+    RetCode (*SetUpDecoderOpenParam)(DecOpenParam *param, TestDecConfig *config);
+    // VPU
+    int (*VPU_GetProductId)(int coreIdx);
+    BOOL(*Queue_Enqueue)(Queue *queue, void *data);
+    Uint32 (*Queue_Get_Cnt)(Queue *queue);
+    // VPU Log
+    int (*InitLog)(void);
+    void (*DeInitLog)(void);
+    void (*SetMaxLogLevel)(int level);
+    int (*GetMaxLogLevel)(void);
+} SF_COMPONENT_FUNCTIONS;
+
+typedef struct _SF_OMX_COMPONENT
+{
+    OMX_STRING componentName;
+    OMX_STRING libName;
+    OMX_COMPONENTTYPE *pOMXComponent;
+    OMX_ERRORTYPE (*SF_OMX_ComponentConstructor)(struct _SF_OMX_COMPONENT *hComponent);
+    OMX_ERRORTYPE (*SF_OMX_ComponentClear)(struct _SF_OMX_COMPONENT *hComponent);
+    SF_COMPONENT_FUNCTIONS *functions;
+    Component *hSFComponentExecoder;
+    Component *hSFComponentFeeder;
+    Component *hSFComponentRender;
+    void *testConfig;
+    CNMComponentConfig *config;
+    void *lsnCtx;
+    OMX_PTR soHandle;
+    Uint16 *pusBitCode;
+    OMX_CALLBACKTYPE *callbacks;
+    OMX_PTR pAppData;
+    OMX_PARAM_PORTDEFINITIONTYPE portDefinition[2];
+    OMX_BUFFERHEADERTYPE *pBufferArray[64];
+    sem_t *inputSemaphore;
+    CodStd bitFormat;
+    OMX_STRING fwPath;
+} SF_OMX_COMPONENT;
+
+#define PRINT_STUCT(a, b)                                   \
+    do                                                      \
+    {                                                       \
+        printf("size = %d\r\n", sizeof(b));                 \
+        for (int i = 0; i < sizeof(b); i += sizeof(void *)) \
+        {                                                   \
+            for (int j = 0; j < sizeof(void *); j++)        \
+            {                                               \
+                printf("%02X ", *((char *)a + i + j));      \
+            }                                               \
+            for (int j = 0; j < sizeof(void *); j++)        \
+            {                                               \
+                printf("%c", *((char *)a + i + j));         \
+            }                                               \
+            printf("\r\n");                                 \
+        }                                                   \
+    } while (0)
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+    void sf_get_component_functions(SF_COMPONENT_FUNCTIONS *funcs, OMX_PTR *sohandle);
+    SF_OMX_COMPONENT *GetSFOMXComponrntByComponent(Component *pComponent);
+    OMX_BUFFERHEADERTYPE *GetOMXBufferByAddr(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8 *pAddr);
+    OMX_ERRORTYPE StoreOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer);
+    OMX_ERRORTYPE ClearOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer);
+    OMX_U32 GetOMXBufferCount(SF_OMX_COMPONENT *pSfOMXComponent);
+#ifdef __cplusplus
+}
+#endif
+
+#endif

+ 1310 - 0
soft_3rdpart/omx-il/include/khronos/OMX_Audio.h

@@ -0,0 +1,1310 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** @file OMX_Audio.h - OpenMax IL version 1.1.2
+ *  The structures needed by Audio components to exchange
+ *  parameters and configuration data with the componenmilts.
+ */
+
+#ifndef OMX_Audio_h
+#define OMX_Audio_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Each OMX header must include all required header files to allow the
+ *  header to compile without errors.  The includes below are required
+ *  for this header file to compile successfully
+ */
+
+#include <OMX_Core.h>
+
+/** @defgroup midi MIDI
+ * @ingroup audio
+ */
+
+/** @defgroup effects Audio effects
+ * @ingroup audio
+ */
+
+/** @defgroup audio OpenMAX IL Audio Domain
+ * Structures for OpenMAX IL Audio domain
+ * @{
+ */
+
+/** Enumeration used to define the possible audio codings.
+ *  If "OMX_AUDIO_CodingUnused" is selected, the coding selection must
+ *  be done in a vendor specific way.  Since this is for an audio
+ *  processing element this enum is relevant.  However, for another
+ *  type of component other enums would be in this area.
+ */
+typedef enum OMX_AUDIO_CODINGTYPE {
+    OMX_AUDIO_CodingUnused = 0,  /**< Placeholder value when coding is N/A  */
+    OMX_AUDIO_CodingAutoDetect,  /**< auto detection of audio format */
+    OMX_AUDIO_CodingPCM,         /**< Any variant of PCM coding */
+    OMX_AUDIO_CodingADPCM,       /**< Any variant of ADPCM encoded data */
+    OMX_AUDIO_CodingAMR,         /**< Any variant of AMR encoded data */
+    OMX_AUDIO_CodingGSMFR,       /**< Any variant of GSM fullrate (i.e. GSM610) */
+    OMX_AUDIO_CodingGSMEFR,      /**< Any variant of GSM Enhanced Fullrate encoded data*/
+    OMX_AUDIO_CodingGSMHR,       /**< Any variant of GSM Halfrate encoded data */
+    OMX_AUDIO_CodingPDCFR,       /**< Any variant of PDC Fullrate encoded data */
+    OMX_AUDIO_CodingPDCEFR,      /**< Any variant of PDC Enhanced Fullrate encoded data */
+    OMX_AUDIO_CodingPDCHR,       /**< Any variant of PDC Halfrate encoded data */
+    OMX_AUDIO_CodingTDMAFR,      /**< Any variant of TDMA Fullrate encoded data (TIA/EIA-136-420) */
+    OMX_AUDIO_CodingTDMAEFR,     /**< Any variant of TDMA Enhanced Fullrate encoded data (TIA/EIA-136-410) */
+    OMX_AUDIO_CodingQCELP8,      /**< Any variant of QCELP 8kbps encoded data */
+    OMX_AUDIO_CodingQCELP13,     /**< Any variant of QCELP 13kbps encoded data */
+    OMX_AUDIO_CodingEVRC,        /**< Any variant of EVRC encoded data */
+    OMX_AUDIO_CodingSMV,         /**< Any variant of SMV encoded data */
+    OMX_AUDIO_CodingG711,        /**< Any variant of G.711 encoded data */
+    OMX_AUDIO_CodingG723,        /**< Any variant of G.723 dot 1 encoded data */
+    OMX_AUDIO_CodingG726,        /**< Any variant of G.726 encoded data */
+    OMX_AUDIO_CodingG729,        /**< Any variant of G.729 encoded data */
+    OMX_AUDIO_CodingAAC,         /**< Any variant of AAC encoded data */
+    OMX_AUDIO_CodingMP3,         /**< Any variant of MP3 encoded data */
+    OMX_AUDIO_CodingSBC,         /**< Any variant of SBC encoded data */
+    OMX_AUDIO_CodingVORBIS,      /**< Any variant of VORBIS encoded data */
+    OMX_AUDIO_CodingWMA,         /**< Any variant of WMA encoded data */
+    OMX_AUDIO_CodingRA,          /**< Any variant of RA encoded data */
+    OMX_AUDIO_CodingMIDI,        /**< Any variant of MIDI encoded data */
+    OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_CodingMax = 0x7FFFFFFF
+} OMX_AUDIO_CODINGTYPE;
+
+
+/** The PortDefinition structure is used to define all of the parameters
+ *  necessary for the compliant component to setup an input or an output audio
+ *  path.  If additional information is needed to define the parameters of the
+ *  port (such as frequency), additional structures must be sent such as the
+ *  OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port.
+ */
+typedef struct OMX_AUDIO_PORTDEFINITIONTYPE {
+    OMX_STRING cMIMEType;            /**< MIME type of data for the port */
+    OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference
+                                               for an output device,
+                                               otherwise this field is 0 */
+    OMX_BOOL bFlagErrorConcealment;  /**< Turns on error concealment if it is
+                                          supported by the OMX component */
+    OMX_AUDIO_CODINGTYPE eEncoding;  /**< Type of data expected for this
+                                          port (e.g. PCM, AMR, MP3, etc) */
+} OMX_AUDIO_PORTDEFINITIONTYPE;
+
+
+/**  Port format parameter.  This structure is used to enumerate
+  *  the various data input/output format supported by the port.
+  */
+typedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE {
+    OMX_U32 nSize;                  /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
+    OMX_U32 nPortIndex;             /**< Indicates which port to set */
+    OMX_U32 nIndex;                 /**< Indicates the enumeration index for the format from 0x0 to N-1 */
+    OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */
+} OMX_AUDIO_PARAM_PORTFORMATTYPE;
+
+
+/** PCM mode type  */
+typedef enum OMX_AUDIO_PCMMODETYPE {
+    OMX_AUDIO_PCMModeLinear = 0,  /**< Linear PCM encoded data */
+    OMX_AUDIO_PCMModeALaw,        /**< A law PCM encoded data (G.711) */
+    OMX_AUDIO_PCMModeMULaw,       /**< Mu law PCM encoded data (G.711)  */
+    OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_PCMModeMax = 0x7FFFFFFF
+} OMX_AUDIO_PCMMODETYPE;
+
+
+typedef enum OMX_AUDIO_CHANNELTYPE {
+    OMX_AUDIO_ChannelNone = 0x0,    /**< Unused or empty */
+    OMX_AUDIO_ChannelLF   = 0x1,    /**< Left front */
+    OMX_AUDIO_ChannelRF   = 0x2,    /**< Right front */
+    OMX_AUDIO_ChannelCF   = 0x3,    /**< Center front */
+    OMX_AUDIO_ChannelLS   = 0x4,    /**< Left surround */
+    OMX_AUDIO_ChannelRS   = 0x5,    /**< Right surround */
+    OMX_AUDIO_ChannelLFE  = 0x6,    /**< Low frequency effects */
+    OMX_AUDIO_ChannelCS   = 0x7,    /**< Back surround */
+    OMX_AUDIO_ChannelLR   = 0x8,    /**< Left rear. */
+    OMX_AUDIO_ChannelRR   = 0x9,    /**< Right rear. */
+    OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_ChannelMax  = 0x7FFFFFFF
+} OMX_AUDIO_CHANNELTYPE;
+
+#define OMX_AUDIO_MAXCHANNELS 16  /**< maximum number distinct audio channels that a buffer may contain */
+#define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */
+
+/** PCM format description */
+typedef struct OMX_AUDIO_PARAM_PCMMODETYPE {
+    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */
+    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */
+    OMX_U32 nPortIndex;               /**< port that this structure applies to */
+    OMX_U32 nChannels;                /**< Number of channels (e.g. 2 for stereo) */
+    OMX_NUMERICALDATATYPE eNumData;   /**< indicates PCM data as signed or unsigned */
+    OMX_ENDIANTYPE eEndian;           /**< indicates PCM data as little or big endian */
+    OMX_BOOL bInterleaved;            /**< True for normal interleaved data; false for
+                                           non-interleaved data (e.g. block data) */
+    OMX_U32 nBitPerSample;            /**< Bit per sample */
+    OMX_U32 nSamplingRate;            /**< Sampling rate of the source data.  Use 0 for
+                                           variable or unknown sampling rate. */
+    OMX_AUDIO_PCMMODETYPE ePCMMode;   /**< PCM mode enumeration */
+    OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */
+
+} OMX_AUDIO_PARAM_PCMMODETYPE;
+
+
+/** Audio channel mode.  This is used by both AAC and MP3, although the names are more appropriate
+ * for the MP3.  For example, JointStereo for MP3 is CouplingChannels for AAC.
+ */
+typedef enum OMX_AUDIO_CHANNELMODETYPE {
+    OMX_AUDIO_ChannelModeStereo = 0,  /**< 2 channels, the bitrate allocation between those
+                                          two channels changes accordingly to each channel information */
+    OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between
+                                           2 channels for higher compression gain */
+    OMX_AUDIO_ChannelModeDual,        /**< 2 mono-channels, each channel is encoded with half
+                                           the bitrate of the overall bitrate */
+    OMX_AUDIO_ChannelModeMono,        /**< Mono channel mode */
+    OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF
+} OMX_AUDIO_CHANNELMODETYPE;
+
+
+typedef enum OMX_AUDIO_MP3STREAMFORMATTYPE {
+    OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */
+    OMX_AUDIO_MP3StreamFormatMP2Layer3,     /**< MP3 Audio MPEG 2 Layer 3 Stream format */
+    OMX_AUDIO_MP3StreamFormatMP2_5Layer3,   /**< MP3 Audio MPEG2.5 Layer 3 Stream format */
+    OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_MP3STREAMFORMATTYPE;
+
+/** MP3 params */
+typedef struct OMX_AUDIO_PARAM_MP3TYPE {
+    OMX_U32 nSize;                 /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */
+    OMX_U32 nPortIndex;            /**< port that this structure applies to */
+    OMX_U32 nChannels;             /**< Number of channels */
+    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable
+                                        rate or unknown bit rates */
+    OMX_U32 nSampleRate;           /**< Sampling rate of the source data.  Use 0 for
+                                        variable or unknown sampling rate. */
+    OMX_U32 nAudioBandWidth;       /**< Audio band width (in Hz) to which an encoder should
+                                        limit the audio signal. Use 0 to let encoder decide */
+    OMX_AUDIO_CHANNELMODETYPE eChannelMode;   /**< Channel mode enumeration */
+    OMX_AUDIO_MP3STREAMFORMATTYPE eFormat;  /**< MP3 stream format */
+} OMX_AUDIO_PARAM_MP3TYPE;
+
+
+typedef enum OMX_AUDIO_AACSTREAMFORMATTYPE {
+    OMX_AUDIO_AACStreamFormatMP2ADTS = 0, /**< AAC Audio Data Transport Stream 2 format */
+    OMX_AUDIO_AACStreamFormatMP4ADTS,     /**< AAC Audio Data Transport Stream 4 format */
+    OMX_AUDIO_AACStreamFormatMP4LOAS,     /**< AAC Low Overhead Audio Stream format */
+    OMX_AUDIO_AACStreamFormatMP4LATM,     /**< AAC Low overhead Audio Transport Multiplex */
+    OMX_AUDIO_AACStreamFormatADIF,        /**< AAC Audio Data Interchange Format */
+    OMX_AUDIO_AACStreamFormatMP4FF,       /**< AAC inside MPEG-4/ISO File Format */
+    OMX_AUDIO_AACStreamFormatRAW,         /**< AAC Raw Format */
+    OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_AACSTREAMFORMATTYPE;
+
+
+/** AAC mode type.  Note that the term profile is used with the MPEG-2
+ * standard and the term object type and profile is used with MPEG-4 */
+typedef enum OMX_AUDIO_AACPROFILETYPE {
+    OMX_AUDIO_AACObjectNull = 0,      /**< Null, not used */
+    OMX_AUDIO_AACObjectMain = 1,      /**< AAC Main object */
+    OMX_AUDIO_AACObjectLC,            /**< AAC Low Complexity object (AAC profile) */
+    OMX_AUDIO_AACObjectSSR,           /**< AAC Scalable Sample Rate object */
+    OMX_AUDIO_AACObjectLTP,           /**< AAC Long Term Prediction object */
+    OMX_AUDIO_AACObjectHE,            /**< AAC High Efficiency (object type SBR, HE-AAC profile) */
+    OMX_AUDIO_AACObjectScalable,      /**< AAC Scalable object */
+    OMX_AUDIO_AACObjectERLC = 17,     /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */
+    OMX_AUDIO_AACObjectLD = 23,       /**< AAC Low Delay object (Error Resilient) */
+    OMX_AUDIO_AACObjectHE_PS = 29,    /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */
+    OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_AACObjectMax = 0x7FFFFFFF
+} OMX_AUDIO_AACPROFILETYPE;
+
+
+/** AAC tool usage (for nAACtools in OMX_AUDIO_PARAM_AACPROFILETYPE).
+ * Required for encoder configuration and optional as decoder info output.
+ * For MP3, OMX_AUDIO_CHANNELMODETYPE is sufficient. */
+#define OMX_AUDIO_AACToolNone 0x00000000 /**< no AAC tools allowed (encoder config) or active (decoder info output) */
+#define OMX_AUDIO_AACToolMS   0x00000001 /**< MS: Mid/side joint coding tool allowed or active */
+#define OMX_AUDIO_AACToolIS   0x00000002 /**< IS: Intensity stereo tool allowed or active */
+#define OMX_AUDIO_AACToolTNS  0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */
+#define OMX_AUDIO_AACToolPNS  0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */
+#define OMX_AUDIO_AACToolLTP  0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */
+#define OMX_AUDIO_AACToolAll  0x7FFFFFFF /**< all AAC tools allowed or active (*/
+
+/** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE).
+ * Required for ER encoder configuration and optional as decoder info output */
+#define OMX_AUDIO_AACERNone  0x00000000  /**< no AAC ER tools allowed/used */
+#define OMX_AUDIO_AACERVCB11 0x00000001  /**< VCB11: Virtual Code Books for AAC section data */
+#define OMX_AUDIO_AACERRVLC  0x00000002  /**< RVLC: Reversible Variable Length Coding */
+#define OMX_AUDIO_AACERHCR   0x00000004  /**< HCR: Huffman Codeword Reordering */
+#define OMX_AUDIO_AACERAll   0x7FFFFFFF  /**< all AAC ER tools allowed/used */
+
+
+/** AAC params */
+typedef struct OMX_AUDIO_PARAM_AACPROFILETYPE {
+    OMX_U32 nSize;                 /**< Size of this structure, in Bytes */
+    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */
+    OMX_U32 nPortIndex;            /**< Port that this structure applies to */
+    OMX_U32 nChannels;             /**< Number of channels */
+    OMX_U32 nSampleRate;           /**< Sampling rate of the source data.  Use 0 for
+                                        variable or unknown sampling rate. */
+    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable
+                                        rate or unknown bit rates */
+    OMX_U32 nAudioBandWidth;       /**< Audio band width (in Hz) to which an encoder should
+                                        limit the audio signal. Use 0 to let encoder decide */
+    OMX_U32 nFrameLength;          /**< Frame length (in audio samples per channel) of the codec.
+                                        Can be 1024 or 960 (AAC-LC), 2048 (HE-AAC), 480 or 512 (AAC-LD).
+                                        Use 0 to let encoder decide */
+    OMX_U32 nAACtools;             /**< AAC tool usage */
+    OMX_U32 nAACERtools;           /**< MPEG-4 AAC error resilience tool usage */
+    OMX_AUDIO_AACPROFILETYPE eAACProfile;   /**< AAC profile enumeration */
+    OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat; /**< AAC stream format enumeration */
+    OMX_AUDIO_CHANNELMODETYPE eChannelMode;   /**< Channel mode enumeration */
+} OMX_AUDIO_PARAM_AACPROFILETYPE;
+
+
+/** VORBIS params */
+typedef struct OMX_AUDIO_PARAM_VORBISTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U32 nChannels;        /**< Number of channels */
+    OMX_U32 nBitRate;         /**< Bit rate of the encoded data data.  Use 0 for variable
+                                   rate or unknown bit rates. Encoding is set to the
+                                   bitrate closest to specified  value (in bps) */
+    OMX_U32 nMinBitRate;      /**< Sets minimum bitrate (in bps). */
+    OMX_U32 nMaxBitRate;      /**< Sets maximum bitrate (in bps). */
+
+    OMX_U32 nSampleRate;      /**< Sampling rate of the source data.  Use 0 for
+                                   variable or unknown sampling rate. */
+    OMX_U32 nAudioBandWidth;  /**< Audio band width (in Hz) to which an encoder should
+                                   limit the audio signal. Use 0 to let encoder decide */
+    OMX_S32 nQuality;         /**< Sets encoding quality to n, between -1 (low) and 10 (high).
+                                   In the default mode of operation, teh quality level is 3.
+                                   Normal quality range is 0 - 10. */
+    OMX_BOOL bManaged;        /**< Set  bitrate  management  mode. This turns off the
+                                   normal VBR encoding, but allows hard or soft bitrate
+                                   constraints to be enforced by the encoder. This mode can
+                                   be slower, and may also be lower quality. It is
+                                   primarily useful for streaming. */
+    OMX_BOOL bDownmix;        /**< Downmix input from stereo to mono (has no effect on
+                                   non-stereo streams). Useful for lower-bitrate encoding. */
+} OMX_AUDIO_PARAM_VORBISTYPE;
+
+
+/** WMA Version */
+typedef enum OMX_AUDIO_WMAFORMATTYPE {
+    OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */
+    OMX_AUDIO_WMAFormat7,          /**< Windows Media Audio format 7 */
+    OMX_AUDIO_WMAFormat8,          /**< Windows Media Audio format 8 */
+    OMX_AUDIO_WMAFormat9,          /**< Windows Media Audio format 9 */
+    OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_WMAFORMATTYPE;
+
+
+/** WMA Profile */
+typedef enum OMX_AUDIO_WMAPROFILETYPE {
+    OMX_AUDIO_WMAProfileUnused = 0,  /**< profile unused or unknown */
+    OMX_AUDIO_WMAProfileL1,          /**< Windows Media audio version 9 profile L1 */
+    OMX_AUDIO_WMAProfileL2,          /**< Windows Media audio version 9 profile L2 */
+    OMX_AUDIO_WMAProfileL3,          /**< Windows Media audio version 9 profile L3 */
+    OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF
+} OMX_AUDIO_WMAPROFILETYPE;
+
+
+/** WMA params */
+typedef struct OMX_AUDIO_PARAM_WMATYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U16 nChannels;        /**< Number of channels */
+    OMX_U32 nBitRate;         /**< Bit rate of the input data.  Use 0 for variable
+                                   rate or unknown bit rates */
+    OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */
+    OMX_AUDIO_WMAPROFILETYPE eProfile;  /**< Profile of WMA stream / data */
+    OMX_U32 nSamplingRate;    /**< Sampling rate of the source data */
+    OMX_U16 nBlockAlign;      /**< is the block alignment, or block size, in bytes of the audio codec */
+    OMX_U16 nEncodeOptions;   /**< WMA Type-specific data */
+    OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */
+} OMX_AUDIO_PARAM_WMATYPE;
+
+/**
+ * RealAudio format
+ */
+typedef enum OMX_AUDIO_RAFORMATTYPE {
+    OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */
+    OMX_AUDIO_RA8,                /**< RealAudio 8 codec */
+    OMX_AUDIO_RA9,                /**< RealAudio 9 codec */
+    OMX_AUDIO_RA10_AAC,           /**< MPEG-4 AAC codec for bitrates of more than 128kbps */
+    OMX_AUDIO_RA10_CODEC,         /**< RealAudio codec for bitrates less than 128 kbps */
+    OMX_AUDIO_RA10_LOSSLESS,      /**< RealAudio Lossless */
+    OMX_AUDIO_RA10_MULTICHANNEL,  /**< RealAudio Multichannel */
+    OMX_AUDIO_RA10_VOICE,         /**< RealAudio Voice for bitrates below 15 kbps */
+    OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_RAFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_RAFORMATTYPE;
+
+/** RA (Real Audio) params */
+typedef struct OMX_AUDIO_PARAM_RATYPE {
+    OMX_U32 nSize;              /**< Size of this structure, in Bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< Port that this structure applies to */
+    OMX_U32 nChannels;          /**< Number of channels */
+    OMX_U32 nSamplingRate;      /**< is the sampling rate of the source data */
+    OMX_U32 nBitsPerFrame;      /**< is the value for bits per frame  */
+    OMX_U32 nSamplePerFrame;    /**< is the value for samples per frame */
+    OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */
+    OMX_U32 nCouplingStartRegion;   /**< is the coupling start region in the stream  */
+    OMX_U32 nNumRegions;        /**< is the number of regions value */
+    OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */
+} OMX_AUDIO_PARAM_RATYPE;
+
+
+/** SBC Allocation Method Type */
+typedef enum OMX_AUDIO_SBCALLOCMETHODTYPE {
+    OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */
+    OMX_AUDIO_SBCAllocMethodSNR,      /**< SNR allocation method */
+    OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF
+} OMX_AUDIO_SBCALLOCMETHODTYPE;
+
+
+/** SBC params */
+typedef struct OMX_AUDIO_PARAM_SBCTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_U32 nChannels;         /**< Number of channels */
+    OMX_U32 nBitRate;          /**< Bit rate of the input data.  Use 0 for variable
+                                    rate or unknown bit rates */
+    OMX_U32 nSampleRate;       /**< Sampling rate of the source data.  Use 0 for
+                                    variable or unknown sampling rate. */
+    OMX_U32 nBlocks;           /**< Number of blocks */
+    OMX_U32 nSubbands;         /**< Number of subbands */
+    OMX_U32 nBitPool;          /**< Bitpool value */
+    OMX_BOOL bEnableBitrate;   /**< Use bitrate value instead of bitpool */
+    OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */
+    OMX_AUDIO_SBCALLOCMETHODTYPE eSBCAllocType;   /**< SBC Allocation method type */
+} OMX_AUDIO_PARAM_SBCTYPE;
+
+
+/** ADPCM stream format parameters */
+typedef struct OMX_AUDIO_PARAM_ADPCMTYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< port that this structure applies to */
+    OMX_U32 nChannels;          /**< Number of channels in the data stream (not
+                                     necessarily the same as the number of channels
+                                     to be rendered. */
+    OMX_U32 nBitsPerSample;     /**< Number of bits in each sample */
+    OMX_U32 nSampleRate;        /**< Sampling rate of the source data.  Use 0 for
+                                    variable or unknown sampling rate. */
+} OMX_AUDIO_PARAM_ADPCMTYPE;
+
+
+/** G723 rate */
+typedef enum OMX_AUDIO_G723RATE {
+    OMX_AUDIO_G723ModeUnused = 0,  /**< AMRNB Mode unused / unknown */
+    OMX_AUDIO_G723ModeLow,         /**< 5300 bps */
+    OMX_AUDIO_G723ModeHigh,        /**< 6300 bps */
+    OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_G723ModeMax = 0x7FFFFFFF
+} OMX_AUDIO_G723RATE;
+
+
+/** G723 - Sample rate must be 8 KHz */
+typedef struct OMX_AUDIO_PARAM_G723TYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */
+    OMX_AUDIO_G723RATE eBitRate;  /**< todo: Should this be moved to a config? */
+    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */
+    OMX_BOOL bPostFilter;         /**< Enable Post Filter */
+} OMX_AUDIO_PARAM_G723TYPE;
+
+
+/** ITU G726 (ADPCM) rate */
+typedef enum OMX_AUDIO_G726MODE {
+    OMX_AUDIO_G726ModeUnused = 0,  /**< G726 Mode unused / unknown */
+    OMX_AUDIO_G726Mode16,          /**< 16 kbps */
+    OMX_AUDIO_G726Mode24,          /**< 24 kbps */
+    OMX_AUDIO_G726Mode32,          /**< 32 kbps, most common rate, also G721 */
+    OMX_AUDIO_G726Mode40,          /**< 40 kbps */
+    OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_G726ModeMax = 0x7FFFFFFF
+} OMX_AUDIO_G726MODE;
+
+
+/** G.726 stream format parameters - must be at 8KHz */
+typedef struct OMX_AUDIO_PARAM_G726TYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< port that this structure applies to */
+    OMX_U32 nChannels;          /**< Number of channels in the data stream (not
+                                     necessarily the same as the number of channels
+                                     to be rendered. */
+    OMX_AUDIO_G726MODE eG726Mode;
+} OMX_AUDIO_PARAM_G726TYPE;
+
+
+/** G729 coder type */
+typedef enum OMX_AUDIO_G729TYPE {
+    OMX_AUDIO_G729 = 0,           /**< ITU G.729  encoded data */
+    OMX_AUDIO_G729A,              /**< ITU G.729 annex A  encoded data */
+    OMX_AUDIO_G729B,              /**< ITU G.729 with annex B encoded data */
+    OMX_AUDIO_G729AB,             /**< ITU G.729 annexes A and B encoded data */
+    OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_G729Max = 0x7FFFFFFF
+} OMX_AUDIO_G729TYPE;
+
+
+/** G729 stream format parameters - fixed 6KHz sample rate */
+typedef struct OMX_AUDIO_PARAM_G729TYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U32 nChannels;        /**< Number of channels in the data stream (not
+                                   necessarily the same as the number of channels
+                                   to be rendered. */
+    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */
+    OMX_AUDIO_G729TYPE eBitType;
+} OMX_AUDIO_PARAM_G729TYPE;
+
+
+/** AMR Frame format */
+typedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE {
+    OMX_AUDIO_AMRFrameFormatConformance = 0,  /**< Frame Format is AMR Conformance
+                                                   (Standard) Format */
+    OMX_AUDIO_AMRFrameFormatIF1,              /**< Frame Format is AMR Interface
+                                                   Format 1 */
+    OMX_AUDIO_AMRFrameFormatIF2,              /**< Frame Format is AMR Interface
+                                                   Format 2*/
+    OMX_AUDIO_AMRFrameFormatFSF,              /**< Frame Format is AMR File Storage
+                                                   Format */
+    OMX_AUDIO_AMRFrameFormatRTPPayload,       /**< Frame Format is AMR Real-Time
+                                                   Transport Protocol Payload Format */
+    OMX_AUDIO_AMRFrameFormatITU,              /**< Frame Format is ITU Format (added at Motorola request) */
+    OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_AMRFRAMEFORMATTYPE;
+
+
+/** AMR band mode */
+typedef enum OMX_AUDIO_AMRBANDMODETYPE {
+    OMX_AUDIO_AMRBandModeUnused = 0,          /**< AMRNB Mode unused / unknown */
+    OMX_AUDIO_AMRBandModeNB0,                 /**< AMRNB Mode 0 =  4750 bps */
+    OMX_AUDIO_AMRBandModeNB1,                 /**< AMRNB Mode 1 =  5150 bps */
+    OMX_AUDIO_AMRBandModeNB2,                 /**< AMRNB Mode 2 =  5900 bps */
+    OMX_AUDIO_AMRBandModeNB3,                 /**< AMRNB Mode 3 =  6700 bps */
+    OMX_AUDIO_AMRBandModeNB4,                 /**< AMRNB Mode 4 =  7400 bps */
+    OMX_AUDIO_AMRBandModeNB5,                 /**< AMRNB Mode 5 =  7950 bps */
+    OMX_AUDIO_AMRBandModeNB6,                 /**< AMRNB Mode 6 = 10200 bps */
+    OMX_AUDIO_AMRBandModeNB7,                 /**< AMRNB Mode 7 = 12200 bps */
+    OMX_AUDIO_AMRBandModeWB0,                 /**< AMRWB Mode 0 =  6600 bps */
+    OMX_AUDIO_AMRBandModeWB1,                 /**< AMRWB Mode 1 =  8850 bps */
+    OMX_AUDIO_AMRBandModeWB2,                 /**< AMRWB Mode 2 = 12650 bps */
+    OMX_AUDIO_AMRBandModeWB3,                 /**< AMRWB Mode 3 = 14250 bps */
+    OMX_AUDIO_AMRBandModeWB4,                 /**< AMRWB Mode 4 = 15850 bps */
+    OMX_AUDIO_AMRBandModeWB5,                 /**< AMRWB Mode 5 = 18250 bps */
+    OMX_AUDIO_AMRBandModeWB6,                 /**< AMRWB Mode 6 = 19850 bps */
+    OMX_AUDIO_AMRBandModeWB7,                 /**< AMRWB Mode 7 = 23050 bps */
+    OMX_AUDIO_AMRBandModeWB8,                 /**< AMRWB Mode 8 = 23850 bps */
+    OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF
+} OMX_AUDIO_AMRBANDMODETYPE;
+
+
+/** AMR Discontinuous Transmission mode */
+typedef enum OMX_AUDIO_AMRDTXMODETYPE {
+    OMX_AUDIO_AMRDTXModeOff = 0,        /**< AMR Discontinuous Transmission Mode is disabled */
+    OMX_AUDIO_AMRDTXModeOnVAD1,         /**< AMR Discontinuous Transmission Mode using
+                                             Voice Activity Detector 1 (VAD1) is enabled */
+    OMX_AUDIO_AMRDTXModeOnVAD2,         /**< AMR Discontinuous Transmission Mode using
+                                             Voice Activity Detector 2 (VAD2) is enabled */
+    OMX_AUDIO_AMRDTXModeOnAuto,         /**< The codec will automatically select between
+                                             Off, VAD1 or VAD2 modes */
+
+    OMX_AUDIO_AMRDTXasEFR,             /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */
+
+    OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF
+} OMX_AUDIO_AMRDTXMODETYPE;
+
+
+/** AMR params */
+typedef struct OMX_AUDIO_PARAM_AMRTYPE {
+    OMX_U32 nSize;                          /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;               /**< OMX specification version information */
+    OMX_U32 nPortIndex;                     /**< port that this structure applies to */
+    OMX_U32 nChannels;                      /**< Number of channels */
+    OMX_U32 nBitRate;                       /**< Bit rate read only field */
+    OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */
+    OMX_AUDIO_AMRDTXMODETYPE  eAMRDTXMode;  /**< AMR DTX Mode enumeration */
+    OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */
+} OMX_AUDIO_PARAM_AMRTYPE;
+
+
+/** GSM_FR (ETSI 06.10, 3GPP 46.010) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_GSMFRTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */
+    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_GSMFRTYPE;
+
+
+/** GSM-HR (ETSI 06.20, 3GPP 46.020) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_GSMHRTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */
+    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_GSMHRTYPE;
+
+
+/** GSM-EFR (ETSI 06.60, 3GPP 46.060) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_GSMEFRTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */
+    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_GSMEFRTYPE;
+
+
+/** TDMA FR (TIA/EIA-136-420, VSELP 7.95kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_TDMAFRTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */
+    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_TDMAFRTYPE;
+
+
+/** TDMA EFR (TIA/EIA-136-410, ACELP 7.4kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_TDMAEFRTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */
+    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_TDMAEFRTYPE;
+
+
+/** PDC FR ( RCR-27, VSELP 6.7kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_PDCFRTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */
+    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_PDCFRTYPE;
+
+
+/** PDC EFR ( RCR-27, ACELP 6.7kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_PDCEFRTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */
+    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_PDCEFRTYPE;
+
+/** PDC HR ( RCR-27, PSI-CELP 3.45kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_PDCHRTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */
+    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_PDCHRTYPE;
+
+
+/** CDMA Rate types */
+typedef enum OMX_AUDIO_CDMARATETYPE {
+    OMX_AUDIO_CDMARateBlank = 0,          /**< CDMA encoded frame is blank */
+    OMX_AUDIO_CDMARateFull,               /**< CDMA encoded frame in full rate */
+    OMX_AUDIO_CDMARateHalf,               /**< CDMA encoded frame in half rate */
+    OMX_AUDIO_CDMARateQuarter,            /**< CDMA encoded frame in quarter rate */
+    OMX_AUDIO_CDMARateEighth,             /**< CDMA encoded frame in eighth rate (DTX)*/
+    OMX_AUDIO_CDMARateErasure,            /**< CDMA erasure frame */
+    OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_CDMARateMax = 0x7FFFFFFF
+} OMX_AUDIO_CDMARATETYPE;
+
+
+/** QCELP8 (TIA/EIA-96, up to 8kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_QCELP8TYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_U32 nBitRate;             /**< Bit rate of the input data.  Use 0 for variable
+                                       rate or unknown bit rates */
+    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */
+    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */
+    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */
+} OMX_AUDIO_PARAM_QCELP8TYPE;
+
+
+/** QCELP13 ( CDMA, EIA/TIA-733, 13.3kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_QCELP13TYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */
+    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */
+    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */
+} OMX_AUDIO_PARAM_QCELP13TYPE;
+
+
+/** EVRC ( CDMA, EIA/TIA-127, RCELP up to 8.55kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_EVRCTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< actual Frame rate */
+    OMX_BOOL bRATE_REDUCon;       /**< RATE_REDUCtion is requested for this frame */
+    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */
+    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */
+    OMX_BOOL bHiPassFilter;       /**< Enable encoder's High Pass Filter */
+    OMX_BOOL bNoiseSuppressor;    /**< Enable encoder's noise suppressor pre-processing */
+    OMX_BOOL bPostFilter;         /**< Enable decoder's post Filter */
+} OMX_AUDIO_PARAM_EVRCTYPE;
+
+
+/** SMV ( up to 8.55kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_SMVTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */
+    OMX_BOOL bRATE_REDUCon;           /**< RATE_REDUCtion is requested for this frame */
+    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 ??*/
+    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 ??*/
+    OMX_BOOL bHiPassFilter;       /**< Enable encoder's High Pass Filter ??*/
+    OMX_BOOL bNoiseSuppressor;    /**< Enable encoder's noise suppressor pre-processing */
+    OMX_BOOL bPostFilter;         /**< Enable decoder's post Filter ??*/
+} OMX_AUDIO_PARAM_SMVTYPE;
+
+
+/** MIDI Format
+ * @ingroup midi
+ */
+typedef enum OMX_AUDIO_MIDIFORMATTYPE {
+    OMX_AUDIO_MIDIFormatUnknown = 0, /**< MIDI Format unknown or don't care */
+    OMX_AUDIO_MIDIFormatSMF0,        /**< Standard MIDI File Type 0 */
+    OMX_AUDIO_MIDIFormatSMF1,        /**< Standard MIDI File Type 1 */
+    OMX_AUDIO_MIDIFormatSMF2,        /**< Standard MIDI File Type 2 */
+    OMX_AUDIO_MIDIFormatSPMIDI,      /**< SP-MIDI */
+    OMX_AUDIO_MIDIFormatXMF0,        /**< eXtensible Music Format type 0 */
+    OMX_AUDIO_MIDIFormatXMF1,        /**< eXtensible Music Format type 1 */
+    OMX_AUDIO_MIDIFormatMobileXMF,   /**< Mobile XMF (eXtensible Music Format type 2) */
+    OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_MIDIFORMATTYPE;
+
+
+/** MIDI params
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_PARAM_MIDITYPE {
+    OMX_U32 nSize;                 /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */
+    OMX_U32 nPortIndex;            /**< port that this structure applies to */
+    OMX_U32 nFileSize;             /**< size of the MIDI file in bytes, where the entire
+                                        MIDI file passed in, otherwise if 0x0, the MIDI data
+                                        is merged and streamed (instead of passed as an
+                                        entire MIDI file) */
+    OMX_BU32 sMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic
+                                        voices. A value of zero indicates that the default
+                                        polyphony of the device is used  */
+    OMX_BOOL bLoadDefaultSound;    /**< Whether to load default sound
+                                        bank at initialization */
+    OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */
+} OMX_AUDIO_PARAM_MIDITYPE;
+
+
+/** Type of the MIDI sound bank
+ * @ingroup midi
+ */
+typedef enum OMX_AUDIO_MIDISOUNDBANKTYPE {
+    OMX_AUDIO_MIDISoundBankUnused = 0,           /**< unused/unknown soundbank type */
+    OMX_AUDIO_MIDISoundBankDLS1,                 /**< DLS version 1 */
+    OMX_AUDIO_MIDISoundBankDLS2,                 /**< DLS version 2 */
+    OMX_AUDIO_MIDISoundBankMobileDLSBase,        /**< Mobile DLS, using the base functionality */
+    OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */
+    OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF
+} OMX_AUDIO_MIDISOUNDBANKTYPE;
+
+
+/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank
+ * @ingroup midi
+ */
+typedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE {
+    OMX_AUDIO_MIDISoundBankLayoutUnused = 0,   /**< unused/unknown soundbank type */
+    OMX_AUDIO_MIDISoundBankLayoutGM,           /**< GS layout (based on bank MSB 0x00) */
+    OMX_AUDIO_MIDISoundBankLayoutGM2,          /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */
+    OMX_AUDIO_MIDISoundBankLayoutUser,         /**< Does not conform to any bank numbering standards */
+    OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF
+} OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE;
+
+
+/** MIDI params to load/unload user soundbank
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U32 nDLSIndex;        /**< DLS file index to be loaded */
+    OMX_U32 nDLSSize;         /**< Size in bytes */
+    OMX_PTR pDLSData;         /**< Pointer to DLS file data */
+    OMX_AUDIO_MIDISOUNDBANKTYPE eMidiSoundBank;   /**< Midi sound bank type enumeration */
+    OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE eMidiSoundBankLayout; /**< Midi sound bank layout enumeration */
+} OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE;
+
+
+/** Structure for Live MIDI events and MIP messages.
+ * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.)
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< Port that this structure applies to */
+    OMX_U32 nMidiEventSize;   /**< Size of immediate MIDI events or MIP message in bytes  */
+    OMX_U8 nMidiEvents[1];    /**< MIDI event array to be rendered immediately, or an
+                                   array for the MIP message buffer, where the size is
+                                   indicated by nMidiEventSize */
+} OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE;
+
+
+/** MIDI sound bank/ program pair in a given channel
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< Port that this structure applies to */
+    OMX_U32 nChannel;           /**< Valid channel values range from 1 to 16 */
+    OMX_U16 nIDProgram;         /**< Valid program ID range is 1 to 128 */
+    OMX_U16 nIDSoundBank;       /**< Sound bank ID */
+    OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks
+                                     by index if multiple banks are present */
+} OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE;
+
+
+/** MIDI control
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10
+                                       format based on JAVA MMAPI (JSR-135) requirement */
+    OMX_BU32 sPlayBackRate;       /**< Relative playback rate, stored as Q14.17 fixed-point
+                                       number based on JSR-135 requirement */
+    OMX_BU32 sTempo ;             /**< Tempo in beats per minute (BPM), stored as Q22.10
+                                       fixed-point number based on JSR-135 requirement */
+    OMX_U32 nMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic
+                                       voices. A value of zero indicates that the default
+                                       polyphony of the device is used  */
+    OMX_U32 nNumRepeat;           /**< Number of times to repeat playback */
+    OMX_U32 nStopTime;            /**< Time in milliseconds to indicate when playback
+                                       will stop automatically.  Set to zero if not used */
+    OMX_U16 nChannelMuteMask;     /**< 16 bit mask for channel mute status */
+    OMX_U16 nChannelSoloMask;     /**< 16 bit mask for channel solo status */
+    OMX_U32 nTrack0031MuteMask;   /**< 32 bit mask for track mute status. Note: This is for tracks 0-31 */
+    OMX_U32 nTrack3263MuteMask;   /**< 32 bit mask for track mute status. Note: This is for tracks 32-63 */
+    OMX_U32 nTrack0031SoloMask;   /**< 32 bit mask for track solo status. Note: This is for tracks 0-31 */
+    OMX_U32 nTrack3263SoloMask;   /**< 32 bit mask for track solo status. Note: This is for tracks 32-63 */
+
+} OMX_AUDIO_CONFIG_MIDICONTROLTYPE;
+
+
+/** MIDI Playback States
+ * @ingroup midi
+ */
+typedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE {
+    OMX_AUDIO_MIDIPlayBackStateUnknown = 0,      /**< Unknown state or state does not map to
+                                                    other defined states */
+    OMX_AUDIO_MIDIPlayBackStateClosedEngaged,    /**< No MIDI resource is currently open.
+                                                    The MIDI engine is currently processing
+                                                    MIDI events. */
+    OMX_AUDIO_MIDIPlayBackStateParsing,          /**< A MIDI resource is open and is being
+                                                    primed. The MIDI engine is currently
+                                                    processing MIDI events. */
+    OMX_AUDIO_MIDIPlayBackStateOpenEngaged,      /**< A MIDI resource is open and primed but
+                                                    not playing. The MIDI engine is currently
+                                                    processing MIDI events. The transition to
+                                                    this state is only possible from the
+                                                    OMX_AUDIO_MIDIPlayBackStatePlaying state,
+                                                    when the 'playback head' reaches the end
+                                                    of media data or the playback stops due
+                                                    to stop time set.*/
+    OMX_AUDIO_MIDIPlayBackStatePlaying,          /**< A MIDI resource is open and currently
+                                                    playing. The MIDI engine is currently
+                                                    processing MIDI events.*/
+    OMX_AUDIO_MIDIPlayBackStatePlayingPartially, /**< Best-effort playback due to SP-MIDI/DLS
+                                                    resource constraints */
+    OMX_AUDIO_MIDIPlayBackStatePlayingSilently,  /**< Due to system resource constraints and
+                                                    SP-MIDI content constraints, there is
+                                                    no audible MIDI content during playback
+                                                    currently. The situation may change if
+                                                    resources are freed later.*/
+    OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF
+} OMX_AUDIO_MIDIPLAYBACKSTATETYPE;
+
+
+/** MIDI status
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< port that this structure applies to */
+    OMX_U16 nNumTracks;         /**< Number of MIDI tracks in the file, read only field.
+                                     NOTE: May not return a meaningful value until the entire
+                                     file is parsed and buffered.  */
+    OMX_U32 nDuration;          /**< The length of the currently open MIDI resource
+                                     in milliseconds. NOTE: May not return a meaningful value
+                                     until the entire file is parsed and buffered.  */
+    OMX_U32 nPosition;          /**< Current Position of the MIDI resource being played
+                                     in milliseconds */
+    OMX_BOOL bVibra;            /**< Does Vibra track exist? NOTE: May not return a meaningful
+                                     value until the entire file is parsed and buffered. */
+    OMX_U32 nNumMetaEvents;     /**< Total number of MIDI Meta Events in the currently
+                                     open MIDI resource. NOTE: May not return a meaningful value
+                                     until the entire file is parsed and buffered.  */
+    OMX_U32 nNumActiveVoices;   /**< Number of active voices in the currently playing
+                                     MIDI resource. NOTE: May not return a meaningful value until
+                                     the entire file is parsed and buffered. */
+    OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState;  /**< MIDI playback state enumeration, read only field */
+} OMX_AUDIO_CONFIG_MIDISTATUSTYPE;
+
+
+/** MIDI Meta Event structure one per Meta Event.
+ *  MIDI Meta Events are like audio metadata, except that they are interspersed
+ *  with the MIDI content throughout the file and are not localized in the header.
+ *  As such, it is necessary to retrieve information about these Meta Events from
+ *  the engine, as it encounters these Meta Events within the MIDI content.
+ *  For example, SMF files can have up to 14 types of MIDI Meta Events (copyright,
+ *  author, default tempo, etc.) scattered throughout the file.
+ *  @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U32 nIndex;           /**< Index of Meta Event */
+    OMX_U8 nMetaEventType;    /**< Meta Event Type, 7bits (i.e. 0 - 127) */
+    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */
+    OMX_U32 nTrack;           /**< track number for the meta event */
+    OMX_U32 nPosition;        /**< Position of the meta-event in milliseconds */
+} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE;
+
+
+/** MIDI Meta Event Data structure - one per Meta Event.
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U32 nIndex;           /**< Index of Meta Event */
+    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */
+    OMX_U8 nData[1];          /**< array of one or more bytes of meta data
+                                   as indicated by the nMetaEventSize field */
+} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE;
+
+
+/** Audio Volume adjustment for a port */
+typedef struct OMX_AUDIO_CONFIG_VOLUMETYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< Port index indicating which port to
+                                     set.  Select the input port to set
+                                     just that port's volume.  Select the
+                                     output port to adjust the master
+                                     volume. */
+    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100)
+                                     or logarithmic scale (mB) */
+    OMX_BS32 sVolume;           /**< Volume linear setting in the 0..100 range, OR
+                                     Volume logarithmic setting for this port.  The values
+                                     for volume are in mB (millibels = 1/100 dB) relative
+                                     to a gain of 1 (e.g. the output is the same as the
+                                     input level).  Values are in mB from nMax
+                                     (maximum volume) to nMin mB (typically negative).
+                                     Since the volume is "voltage"
+                                     and not a "power", it takes a setting of
+                                     -600 mB to decrease the volume by 1/2.  If
+                                     a component cannot accurately set the
+                                     volume to the requested value, it must
+                                     set the volume to the closest value BELOW
+                                     the requested value.  When getting the
+                                     volume setting, the current actual volume
+                                     must be returned. */
+} OMX_AUDIO_CONFIG_VOLUMETYPE;
+
+
+/** Audio Volume adjustment for a channel */
+typedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< Port index indicating which port to
+                                     set.  Select the input port to set
+                                     just that port's volume.  Select the
+                                     output port to adjust the master
+                                     volume. */
+    OMX_U32 nChannel;           /**< channel to select from 0 to N-1,
+                                     using OMX_ALL to apply volume settings
+                                     to all channels */
+    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100) or
+                                     logarithmic scale (mB) */
+    OMX_BS32 sVolume;           /**< Volume linear setting in the 0..100 range, OR
+                                     Volume logarithmic setting for this port.
+                                     The values for volume are in mB
+                                     (millibels = 1/100 dB) relative to a gain
+                                     of 1 (e.g. the output is the same as the
+                                     input level).  Values are in mB from nMax
+                                     (maximum volume) to nMin mB (typically negative).
+                                     Since the volume is "voltage"
+                                     and not a "power", it takes a setting of
+                                     -600 mB to decrease the volume by 1/2.  If
+                                     a component cannot accurately set the
+                                     volume to the requested value, it must
+                                     set the volume to the closest value BELOW
+                                     the requested value.  When getting the
+                                     volume setting, the current actual volume
+                                     must be returned. */
+    OMX_BOOL bIsMIDI;           /**< TRUE if nChannel refers to a MIDI channel,
+                                     FALSE otherwise */
+} OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE;
+
+
+/** Audio balance setting */
+typedef struct OMX_AUDIO_CONFIG_BALANCETYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< Port index indicating which port to
+                                     set.  Select the input port to set
+                                     just that port's balance.  Select the
+                                     output port to adjust the master
+                                     balance. */
+    OMX_S32 nBalance;           /**< balance setting for this port
+                                     (-100 to 100, where -100 indicates
+                                     all left, and no right */
+} OMX_AUDIO_CONFIG_BALANCETYPE;
+
+
+/** Audio Port mute */
+typedef struct OMX_AUDIO_CONFIG_MUTETYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< Port index indicating which port to
+                                     set.  Select the input port to set
+                                     just that port's mute.  Select the
+                                     output port to adjust the master
+                                     mute. */
+    OMX_BOOL bMute;             /**< Mute setting for this port */
+} OMX_AUDIO_CONFIG_MUTETYPE;
+
+
+/** Audio Channel mute */
+typedef struct OMX_AUDIO_CONFIG_CHANNELMUTETYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< port that this structure applies to */
+    OMX_U32 nChannel;           /**< channel to select from 0 to N-1,
+                                     using OMX_ALL to apply mute settings
+                                     to all channels */
+    OMX_BOOL bMute;             /**< Mute setting for this channel */
+    OMX_BOOL bIsMIDI;           /**< TRUE if nChannel refers to a MIDI channel,
+                                     FALSE otherwise */
+} OMX_AUDIO_CONFIG_CHANNELMUTETYPE;
+
+
+
+/** Enable / Disable for loudness control, which boosts bass and to a
+ *  smaller extent high end frequencies to compensate for hearing
+ *  ability at the extreme ends of the audio spectrum
+ */
+typedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_BOOL bLoudness;        /**< Enable/disable for loudness */
+} OMX_AUDIO_CONFIG_LOUDNESSTYPE;
+
+
+/** Enable / Disable for bass, which controls low frequencies
+ */
+typedef struct OMX_AUDIO_CONFIG_BASSTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_BOOL bEnable;          /**< Enable/disable for bass control */
+    OMX_S32 nBass;             /**< bass setting for the port, as a
+                                    continuous value from -100 to 100
+                                    (0 means no change in bass level)*/
+} OMX_AUDIO_CONFIG_BASSTYPE;
+
+
+/** Enable / Disable for treble, which controls high frequencies tones
+ */
+typedef struct OMX_AUDIO_CONFIG_TREBLETYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_BOOL bEnable;          /**< Enable/disable for treble control */
+    OMX_S32  nTreble;          /**< treble setting for the port, as a
+                                    continuous value from -100 to 100
+                                    (0 means no change in treble level) */
+} OMX_AUDIO_CONFIG_TREBLETYPE;
+
+
+/** An equalizer is typically used for two reasons: to compensate for an
+ *  sub-optimal frequency response of a system to make it sound more natural
+ *  or to create intentionally some unnatural coloring to the sound to create
+ *  an effect.
+ *  @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_EQUALIZERTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_BOOL bEnable;          /**< Enable/disable for equalizer */
+    OMX_BU32 sBandIndex;       /**< Band number to be set.  Upper Limit is
+                                    N-1, where N is the number of bands, lower limit is 0 */
+    OMX_BU32 sCenterFreq;      /**< Center frequecies in Hz.  This is a
+                                    read only element and is used to determine
+                                    the lower, center and upper frequency of
+                                    this band.  */
+    OMX_BS32 sBandLevel;       /**< band level in millibels */
+} OMX_AUDIO_CONFIG_EQUALIZERTYPE;
+
+
+/** Stereo widening mode type
+ * @ingroup effects
+ */
+typedef enum OMX_AUDIO_STEREOWIDENINGTYPE {
+    OMX_AUDIO_StereoWideningHeadphones,    /**< Stereo widening for loudspeakers */
+    OMX_AUDIO_StereoWideningLoudspeakers,  /**< Stereo widening for closely spaced loudspeakers */
+    OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF
+} OMX_AUDIO_STEREOWIDENINGTYPE;
+
+
+/** Control for stereo widening, which is a special 2-channel
+ *  case of the audio virtualizer effect. For example, for 5.1-channel
+ *  output, it translates to virtual surround sound.
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_BOOL bEnable;          /**< Enable/disable for stereo widening control */
+    OMX_AUDIO_STEREOWIDENINGTYPE eWideningType; /**< Stereo widening algorithm type */
+    OMX_U32  nStereoWidening;  /**< stereo widening setting for the port,
+                                    as a continuous value from 0 to 100  */
+} OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE;
+
+
+/** The chorus effect (or ``choralizer'') is any signal processor which makes
+ *  one sound source (such as a voice) sound like many such sources singing
+ *  (or playing) in unison. Since performance in unison is never exact, chorus
+ *  effects simulate this by making independently modified copies of the input
+ *  signal. Modifications may include (1) delay, (2) frequency shift, and
+ *  (3) amplitude modulation.
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_CHORUSTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_BOOL bEnable;          /**< Enable/disable for chorus */
+    OMX_BU32 sDelay;           /**< average delay in milliseconds */
+    OMX_BU32 sModulationRate;  /**< rate of modulation in millihertz */
+    OMX_U32 nModulationDepth;  /**< depth of modulation as a percentage of
+                                    delay (i.e. 0 to 100) */
+    OMX_BU32 nFeedback;        /**< Feedback from chorus output to input in percentage */
+} OMX_AUDIO_CONFIG_CHORUSTYPE;
+
+
+/** Reverberation is part of the reflected sound that follows the early
+ *  reflections. In a typical room, this consists of a dense succession of
+ *  echoes whose energy decays exponentially. The reverberation effect structure
+ *  as defined here includes both (early) reflections as well as (late) reverberations.
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_BOOL bEnable;             /**< Enable/disable for reverberation control */
+    OMX_BS32 sRoomLevel;          /**< Intensity level for the whole room effect
+                                       (i.e. both early reflections and late
+                                       reverberation) in millibels */
+    OMX_BS32 sRoomHighFreqLevel;  /**< Attenuation at high frequencies
+                                       relative to the intensity at low
+                                       frequencies in millibels */
+    OMX_BS32 sReflectionsLevel;   /**< Intensity level of early reflections
+                                       (relative to room value), in millibels */
+    OMX_BU32 sReflectionsDelay;   /**< Delay time of the first reflection relative
+                                       to the direct path, in milliseconds */
+    OMX_BS32 sReverbLevel;        /**< Intensity level of late reverberation
+                                       relative to room level, in millibels */
+    OMX_BU32 sReverbDelay;        /**< Time delay from the first early reflection
+                                       to the beginning of the late reverberation
+                                       section, in milliseconds */
+    OMX_BU32 sDecayTime;          /**< Late reverberation decay time at low
+                                       frequencies, in milliseconds */
+    OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative
+                                       to low frequency decay time in percent  */
+    OMX_U32 nDensity;             /**< Modal density in the late reverberation decay,
+                                       in percent (i.e. 0 - 100) */
+    OMX_U32 nDiffusion;           /**< Echo density in the late reverberation decay,
+                                       in percent (i.e. 0 - 100) */
+    OMX_BU32 sReferenceHighFreq;  /**< Reference high frequency in Hertz. This is
+                                       the frequency used as the reference for all
+                                       the high-frequency settings above */
+
+} OMX_AUDIO_CONFIG_REVERBERATIONTYPE;
+
+
+/** Possible settings for the Echo Cancelation structure to use
+ * @ingroup effects
+ */
+typedef enum OMX_AUDIO_ECHOCANTYPE {
+    OMX_AUDIO_EchoCanOff = 0,    /**< Echo Cancellation is disabled */
+    OMX_AUDIO_EchoCanNormal,     /**< Echo Cancellation normal operation -
+                                     echo from plastics and face */
+    OMX_AUDIO_EchoCanHFree,      /**< Echo Cancellation optimized for
+                                     Hands Free operation */
+    OMX_AUDIO_EchoCanCarKit,    /**< Echo Cancellation optimized for
+                                     Car Kit (longer echo) */
+    OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_AUDIO_EchoCanMax = 0x7FFFFFFF
+} OMX_AUDIO_ECHOCANTYPE;
+
+
+/** Enable / Disable for echo cancelation, which removes undesired echo's
+ *  from the audio
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_AUDIO_ECHOCANTYPE eEchoCancelation; /**< Echo cancelation settings */
+} OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE;
+
+
+/** Enable / Disable for noise reduction, which undesired noise from
+ * the audio
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nPortIndex;        /**< port that this structure applies to */
+    OMX_BOOL bNoiseReduction;  /**< Enable/disable for noise reduction */
+} OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */
+

+ 569 - 0
soft_3rdpart/omx-il/include/khronos/OMX_Component.h

@@ -0,0 +1,569 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_Component.h - OpenMax IL version 1.1.2
+ *  The OMX_Component header file contains the definitions used to define
+ *  the public interface of a component.  This header file is intended to
+ *  be used by both the application and the component.
+ */
+
+#ifndef OMX_Component_h
+#define OMX_Component_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+
+/* Each OMX header must include all required header files to allow the
+ *  header to compile without errors.  The includes below are required
+ *  for this header file to compile successfully
+ */
+
+#include <OMX_Audio.h>
+#include <OMX_Video.h>
+#include <OMX_Image.h>
+#include <OMX_Other.h>
+
+/** @ingroup comp */
+typedef enum OMX_PORTDOMAINTYPE {
+    OMX_PortDomainAudio,
+    OMX_PortDomainVideo,
+    OMX_PortDomainImage,
+    OMX_PortDomainOther,
+    OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_PortDomainMax = 0x7ffffff
+} OMX_PORTDOMAINTYPE;
+
+/** @ingroup comp */
+typedef struct OMX_PARAM_PORTDEFINITIONTYPE {
+    OMX_U32 nSize;                 /**< Size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */
+    OMX_U32 nPortIndex;            /**< Port number the structure applies to */
+    OMX_DIRTYPE eDir;              /**< Direction (input or output) of this port */
+    OMX_U32 nBufferCountActual;    /**< The actual number of buffers allocated on this port */
+    OMX_U32 nBufferCountMin;       /**< The minimum number of buffers this port requires */
+    OMX_U32 nBufferSize;           /**< Size, in bytes, for buffers to be used for this channel */
+    OMX_BOOL bEnabled;             /**< Ports default to enabled and are enabled/disabled by
+                                        OMX_CommandPortEnable/OMX_CommandPortDisable.
+                                        When disabled a port is unpopulated. A disabled port
+                                        is not populated with buffers on a transition to IDLE. */
+    OMX_BOOL bPopulated;           /**< Port is populated with all of its buffers as indicated by
+                                        nBufferCountActual. A disabled port is always unpopulated.
+                                        An enabled port is populated on a transition to OMX_StateIdle
+                                        and unpopulated on a transition to loaded. */
+    OMX_PORTDOMAINTYPE eDomain;    /**< Domain of the port. Determines the contents of metadata below. */
+    union {
+        OMX_AUDIO_PORTDEFINITIONTYPE audio;
+        OMX_VIDEO_PORTDEFINITIONTYPE video;
+        OMX_IMAGE_PORTDEFINITIONTYPE image;
+        OMX_OTHER_PORTDEFINITIONTYPE other;
+    } format;
+    OMX_BOOL bBuffersContiguous;
+    OMX_U32 nBufferAlignment;
+} OMX_PARAM_PORTDEFINITIONTYPE;
+
+/** @ingroup comp */
+typedef struct OMX_PARAM_U32TYPE {
+    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */
+    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */
+    OMX_U32 nPortIndex;               /**< port that this structure applies to */
+    OMX_U32 nU32;                     /**< U32 value */
+} OMX_PARAM_U32TYPE;
+
+/** @ingroup rpm */
+typedef enum OMX_SUSPENSIONPOLICYTYPE {
+    OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */
+    OMX_SuspensionEnabled,  /**< Suspension allowed */
+    OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_SuspensionPolicyMax = 0x7fffffff
+} OMX_SUSPENSIONPOLICYTYPE;
+
+/** @ingroup rpm */
+typedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_SUSPENSIONPOLICYTYPE ePolicy;
+} OMX_PARAM_SUSPENSIONPOLICYTYPE;
+
+/** @ingroup rpm */
+typedef enum OMX_SUSPENSIONTYPE {
+    OMX_NotSuspended, /**< component is not suspended */
+    OMX_Suspended,    /**< component is suspended */
+    OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_SuspendMax = 0x7FFFFFFF
+} OMX_SUSPENSIONTYPE;
+
+/** @ingroup rpm */
+typedef struct OMX_PARAM_SUSPENSIONTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_SUSPENSIONTYPE eType;
+} OMX_PARAM_SUSPENSIONTYPE ;
+
+typedef struct OMX_CONFIG_BOOLEANTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_BOOL bEnabled;
+} OMX_CONFIG_BOOLEANTYPE;
+
+/* Parameter specifying the content uri to use. */
+/** @ingroup cp */
+typedef struct OMX_PARAM_CONTENTURITYPE {
+    OMX_U32 nSize;                      /**< size of the structure in bytes, including
+                                             actual URI name */
+    OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */
+    OMX_U8 contentURI[1];               /**< The URI name */
+} OMX_PARAM_CONTENTURITYPE;
+
+/* Parameter specifying the pipe to use. */
+/** @ingroup cp */
+typedef struct OMX_PARAM_CONTENTPIPETYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_HANDLETYPE hPipe;       /**< The pipe handle*/
+} OMX_PARAM_CONTENTPIPETYPE;
+
+/** @ingroup rpm */
+typedef struct OMX_RESOURCECONCEALMENTTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment
+                                            methods (like degrading algorithm quality to
+                                            lower resource consumption or functional bypass)
+                                            on a component as a resolution to resource conflicts. */
+} OMX_RESOURCECONCEALMENTTYPE;
+
+
+/** @ingroup metadata */
+typedef enum OMX_METADATACHARSETTYPE {
+    OMX_MetadataCharsetUnknown = 0,
+    OMX_MetadataCharsetASCII,
+    OMX_MetadataCharsetBinary,
+    OMX_MetadataCharsetCodePage1252,
+    OMX_MetadataCharsetUTF8,
+    OMX_MetadataCharsetJavaConformantUTF8,
+    OMX_MetadataCharsetUTF7,
+    OMX_MetadataCharsetImapUTF7,
+    OMX_MetadataCharsetUTF16LE,
+    OMX_MetadataCharsetUTF16BE,
+    OMX_MetadataCharsetGB12345,
+    OMX_MetadataCharsetHZGB2312,
+    OMX_MetadataCharsetGB2312,
+    OMX_MetadataCharsetGB18030,
+    OMX_MetadataCharsetGBK,
+    OMX_MetadataCharsetBig5,
+    OMX_MetadataCharsetISO88591,
+    OMX_MetadataCharsetISO88592,
+    OMX_MetadataCharsetISO88593,
+    OMX_MetadataCharsetISO88594,
+    OMX_MetadataCharsetISO88595,
+    OMX_MetadataCharsetISO88596,
+    OMX_MetadataCharsetISO88597,
+    OMX_MetadataCharsetISO88598,
+    OMX_MetadataCharsetISO88599,
+    OMX_MetadataCharsetISO885910,
+    OMX_MetadataCharsetISO885913,
+    OMX_MetadataCharsetISO885914,
+    OMX_MetadataCharsetISO885915,
+    OMX_MetadataCharsetShiftJIS,
+    OMX_MetadataCharsetISO2022JP,
+    OMX_MetadataCharsetISO2022JP1,
+    OMX_MetadataCharsetISOEUCJP,
+    OMX_MetadataCharsetSMS7Bit,
+    OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_MetadataCharsetTypeMax = 0x7FFFFFFF
+} OMX_METADATACHARSETTYPE;
+
+/** @ingroup metadata */
+typedef enum OMX_METADATASCOPETYPE {
+    OMX_MetadataScopeAllLevels,
+    OMX_MetadataScopeTopLevel,
+    OMX_MetadataScopePortLevel,
+    OMX_MetadataScopeNodeLevel,
+    OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_MetadataScopeTypeMax = 0x7fffffff
+} OMX_METADATASCOPETYPE;
+
+/** @ingroup metadata */
+typedef enum OMX_METADATASEARCHMODETYPE {
+    OMX_MetadataSearchValueSizeByIndex,
+    OMX_MetadataSearchItemByIndex,
+    OMX_MetadataSearchNextItemByKey,
+    OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_MetadataSearchTypeMax = 0x7fffffff
+} OMX_METADATASEARCHMODETYPE;
+/** @ingroup metadata */
+typedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_METADATASCOPETYPE eScopeMode;
+    OMX_U32 nScopeSpecifier;
+    OMX_U32 nMetadataItemCount;
+} OMX_CONFIG_METADATAITEMCOUNTTYPE;
+
+/** @ingroup metadata */
+typedef struct OMX_CONFIG_METADATAITEMTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_METADATASCOPETYPE eScopeMode;
+    OMX_U32 nScopeSpecifier;
+    OMX_U32 nMetadataItemIndex;
+    OMX_METADATASEARCHMODETYPE eSearchMode;
+    OMX_METADATACHARSETTYPE eKeyCharset;
+    OMX_U8 nKeySizeUsed;
+    OMX_U8 nKey[128];
+    OMX_METADATACHARSETTYPE eValueCharset;
+    OMX_STRING sLanguageCountry;
+    OMX_U32 nValueMaxSize;
+    OMX_U32 nValueSizeUsed;
+    OMX_U8 nValue[1];
+} OMX_CONFIG_METADATAITEMTYPE;
+
+/* @ingroup metadata */
+typedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_BOOL bAllKeys;
+    OMX_U32 nParentNodeID;
+    OMX_U32 nNumNodes;
+} OMX_CONFIG_CONTAINERNODECOUNTTYPE;
+
+/** @ingroup metadata */
+typedef struct OMX_CONFIG_CONTAINERNODEIDTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_BOOL bAllKeys;
+    OMX_U32 nParentNodeID;
+    OMX_U32 nNodeIndex;
+    OMX_U32 nNodeID;
+    OMX_STRING cNodeName;
+    OMX_BOOL bIsLeafType;
+} OMX_CONFIG_CONTAINERNODEIDTYPE;
+
+/** @ingroup metadata */
+typedef struct OMX_PARAM_METADATAFILTERTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_BOOL bAllKeys;  /* if true then this structure refers to all keys and
+                         * the three key fields below are ignored */
+    OMX_METADATACHARSETTYPE eKeyCharset;
+    OMX_U32 nKeySizeUsed;
+    OMX_U8   nKey [128];
+    OMX_U32 nLanguageCountrySizeUsed;
+    OMX_U8 nLanguageCountry[128];
+    OMX_BOOL bEnabled;  /* if true then key is part of filter (e.g.
+                         * retained for query later). If false then
+                         * key is not part of filter */
+} OMX_PARAM_METADATAFILTERTYPE;
+
+/** The OMX_HANDLETYPE structure defines the component handle.  The component
+ *  handle is used to access all of the component's public methods and also
+ *  contains pointers to the component's private data area.  The component
+ *  handle is initialized by the OMX core (with help from the component)
+ *  during the process of loading the component.  After the component is
+ *  successfully loaded, the application can safely access any of the
+ *  component's public functions (although some may return an error because
+ *  the state is inappropriate for the access).
+ *
+ *  @ingroup comp
+ */
+typedef struct OMX_COMPONENTTYPE {
+    /** The size of this structure, in bytes.  It is the responsibility
+        of the allocator of this structure to fill in this value.  Since
+        this structure is allocated by the GetHandle function, this
+        function will fill in this value. */
+    OMX_U32 nSize;
+
+    /** nVersion is the version of the OMX specification that the structure
+        is built against.  It is the responsibility of the creator of this
+        structure to initialize this value and every user of this structure
+        should verify that it knows how to use the exact version of
+        this structure found herein. */
+    OMX_VERSIONTYPE nVersion;
+
+    /** pComponentPrivate is a pointer to the component private data area.
+        This member is allocated and initialized by the component when the
+        component is first loaded.  The application should not access this
+        data area. */
+    OMX_PTR pComponentPrivate;
+
+    /** pApplicationPrivate is a pointer that is a parameter to the
+        OMX_GetHandle method, and contains an application private value
+        provided by the IL client.  This application private data is
+        returned to the IL Client by OMX in all callbacks */
+    OMX_PTR pApplicationPrivate;
+
+    /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL
+        specification for details on the GetComponentVersion method.
+     */
+    OMX_ERRORTYPE (*GetComponentVersion)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_OUT OMX_STRING pComponentName,
+        OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
+        OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
+        OMX_OUT OMX_UUIDTYPE* pComponentUUID);
+
+    /** refer to OMX_SendCommand in OMX_core.h or the OMX IL
+        specification for details on the SendCommand method.
+     */
+    OMX_ERRORTYPE (*SendCommand)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_COMMANDTYPE Cmd,
+        OMX_IN  OMX_U32 nParam1,
+        OMX_IN  OMX_PTR pCmdData);
+
+    /** refer to OMX_GetParameter in OMX_core.h or the OMX IL
+        specification for details on the GetParameter method.
+     */
+    OMX_ERRORTYPE (*GetParameter)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_INDEXTYPE nParamIndex,
+        OMX_INOUT OMX_PTR pComponentParameterStructure);
+
+
+    /** refer to OMX_SetParameter in OMX_core.h or the OMX IL
+        specification for details on the SetParameter method.
+     */
+    OMX_ERRORTYPE (*SetParameter)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_INDEXTYPE nIndex,
+        OMX_IN  OMX_PTR pComponentParameterStructure);
+
+
+    /** refer to OMX_GetConfig in OMX_core.h or the OMX IL
+        specification for details on the GetConfig method.
+     */
+    OMX_ERRORTYPE (*GetConfig)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_INDEXTYPE nIndex,
+        OMX_INOUT OMX_PTR pComponentConfigStructure);
+
+
+    /** refer to OMX_SetConfig in OMX_core.h or the OMX IL
+        specification for details on the SetConfig method.
+     */
+    OMX_ERRORTYPE (*SetConfig)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_INDEXTYPE nIndex,
+        OMX_IN  OMX_PTR pComponentConfigStructure);
+
+
+    /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL
+        specification for details on the GetExtensionIndex method.
+     */
+    OMX_ERRORTYPE (*GetExtensionIndex)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_STRING cParameterName,
+        OMX_OUT OMX_INDEXTYPE* pIndexType);
+
+
+    /** refer to OMX_GetState in OMX_core.h or the OMX IL
+        specification for details on the GetState method.
+     */
+    OMX_ERRORTYPE (*GetState)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_OUT OMX_STATETYPE* pState);
+
+
+    /** The ComponentTunnelRequest method will interact with another OMX
+        component to determine if tunneling is possible and to setup the
+        tunneling.  The return codes for this method can be used to
+        determine if tunneling is not possible, or if tunneling is not
+        supported.
+
+        Base profile components (i.e. non-interop) do not support this
+        method and should return OMX_ErrorNotImplemented
+
+        The interop profile component MUST support tunneling to another
+        interop profile component with a compatible port parameters.
+        A component may also support proprietary communication.
+
+        If proprietary communication is supported the negotiation of
+        proprietary communication is done outside of OMX in a vendor
+        specific way. It is only required that the proper result be
+        returned and the details of how the setup is done is left
+        to the component implementation.
+
+        When this method is invoked when nPort in an output port, the
+        component will:
+        1.  Populate the pTunnelSetup structure with the output port's
+            requirements and constraints for the tunnel.
+
+        When this method is invoked when nPort in an input port, the
+        component will:
+        1.  Query the necessary parameters from the output port to
+            determine if the ports are compatible for tunneling
+        2.  If the ports are compatible, the component should store
+            the tunnel step provided by the output port
+        3.  Determine which port (either input or output) is the buffer
+            supplier, and call OMX_SetParameter on the output port to
+            indicate this selection.
+
+        The component will return from this call within 5 msec.
+
+        @param [in] hComp
+            Handle of the component to be accessed.  This is the component
+            handle returned by the call to the OMX_GetHandle method.
+        @param [in] nPort
+            nPort is used to select the port on the component to be used
+            for tunneling.
+        @param [in] hTunneledComp
+            Handle of the component to tunnel with.  This is the component
+            handle returned by the call to the OMX_GetHandle method.  When
+            this parameter is 0x0 the component should setup the port for
+            communication with the application / IL Client.
+        @param [in] nPortOutput
+            nPortOutput is used indicate the port the component should
+            tunnel with.
+        @param [in] pTunnelSetup
+            Pointer to the tunnel setup structure.  When nPort is an output port
+            the component should populate the fields of this structure.  When
+            When nPort is an input port the component should review the setup
+            provided by the component with the output port.
+        @return OMX_ERRORTYPE
+            If the command successfully executes, the return code will be
+            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+        @ingroup tun
+    */
+
+    OMX_ERRORTYPE (*ComponentTunnelRequest)(
+        OMX_IN  OMX_HANDLETYPE hComp,
+        OMX_IN  OMX_U32 nPort,
+        OMX_IN  OMX_HANDLETYPE hTunneledComp,
+        OMX_IN  OMX_U32 nTunneledPort,
+        OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup);
+
+    /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL
+        specification for details on the UseBuffer method.
+        @ingroup buf
+     */
+    OMX_ERRORTYPE (*UseBuffer)(
+        OMX_IN OMX_HANDLETYPE hComponent,
+        OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+        OMX_IN OMX_U32 nPortIndex,
+        OMX_IN OMX_PTR pAppPrivate,
+        OMX_IN OMX_U32 nSizeBytes,
+        OMX_IN OMX_U8* pBuffer);
+
+    /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL
+        specification for details on the AllocateBuffer method.
+        @ingroup buf
+     */
+    OMX_ERRORTYPE (*AllocateBuffer)(
+        OMX_IN OMX_HANDLETYPE hComponent,
+        OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer,
+        OMX_IN OMX_U32 nPortIndex,
+        OMX_IN OMX_PTR pAppPrivate,
+        OMX_IN OMX_U32 nSizeBytes);
+
+    /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL
+        specification for details on the FreeBuffer method.
+        @ingroup buf
+     */
+    OMX_ERRORTYPE (*FreeBuffer)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_U32 nPortIndex,
+        OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+    /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL
+        specification for details on the EmptyThisBuffer method.
+        @ingroup buf
+     */
+    OMX_ERRORTYPE (*EmptyThisBuffer)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+    /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL
+        specification for details on the FillThisBuffer method.
+        @ingroup buf
+     */
+    OMX_ERRORTYPE (*FillThisBuffer)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+    /** The SetCallbacks method is used by the core to specify the callback
+        structure from the application to the component.  This is a blocking
+        call.  The component will return from this call within 5 msec.
+        @param [in] hComponent
+            Handle of the component to be accessed.  This is the component
+            handle returned by the call to the GetHandle function.
+        @param [in] pCallbacks
+            pointer to an OMX_CALLBACKTYPE structure used to provide the
+            callback information to the component
+        @param [in] pAppData
+            pointer to an application defined value.  It is anticipated that
+            the application will pass a pointer to a data structure or a "this
+            pointer" in this area to allow the callback (in the application)
+            to determine the context of the call
+        @return OMX_ERRORTYPE
+            If the command successfully executes, the return code will be
+            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+     */
+    OMX_ERRORTYPE (*SetCallbacks)(
+        OMX_IN  OMX_HANDLETYPE hComponent,
+        OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
+        OMX_IN  OMX_PTR pAppData);
+
+    /** ComponentDeInit method is used to deinitialize the component
+        providing a means to free any resources allocated at component
+        initialization.  NOTE:  After this call the component handle is
+        not valid for further use.
+        @param [in] hComponent
+            Handle of the component to be accessed.  This is the component
+            handle returned by the call to the GetHandle function.
+        @return OMX_ERRORTYPE
+            If the command successfully executes, the return code will be
+            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+     */
+    OMX_ERRORTYPE (*ComponentDeInit)(
+        OMX_IN  OMX_HANDLETYPE hComponent);
+
+    /** @ingroup buf */
+    OMX_ERRORTYPE (*UseEGLImage)(
+        OMX_IN OMX_HANDLETYPE hComponent,
+        OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+        OMX_IN OMX_U32 nPortIndex,
+        OMX_IN OMX_PTR pAppPrivate,
+        OMX_IN void* eglImage);
+
+    OMX_ERRORTYPE (*ComponentRoleEnum)(
+        OMX_IN OMX_HANDLETYPE hComponent,
+        OMX_OUT OMX_U8 *cRole,
+        OMX_IN OMX_U32 nIndex);
+
+} OMX_COMPONENTTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */

+ 193 - 0
soft_3rdpart/omx-il/include/khronos/OMX_ContentPipe.h

@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_ContentPipe.h - OpenMax IL version 1.1.2
+ *  The OMX_ContentPipe header file contains the definitions used to define
+ *  the public interface for content piples.  This header file is intended to
+ *  be used by the component.
+ */
+
+#ifndef OMX_CONTENTPIPE_H
+#define OMX_CONTENTPIPE_H
+
+#ifndef KD_EACCES
+/* OpenKODE error codes. CPResult values may be zero (indicating success
+   or one of the following values) */
+#define KD_EACCES (1)
+#define KD_EADDRINUSE (2)
+#define KD_EAGAIN (5)
+#define KD_EBADF (7)
+#define KD_EBUSY (8)
+#define KD_ECONNREFUSED (9)
+#define KD_ECONNRESET (10)
+#define KD_EDEADLK (11)
+#define KD_EDESTADDRREQ (12)
+#define KD_ERANGE (35)
+#define KD_EEXIST (13)
+#define KD_EFBIG (14)
+#define KD_EHOSTUNREACH (15)
+#define KD_EINVAL (17)
+#define KD_EIO (18)
+#define KD_EISCONN (20)
+#define KD_EISDIR (21)
+#define KD_EMFILE (22)
+#define KD_ENAMETOOLONG (23)
+#define KD_ENOENT (24)
+#define KD_ENOMEM (25)
+#define KD_ENOSPC (26)
+#define KD_ENOSYS (27)
+#define KD_ENOTCONN (28)
+#define KD_EPERM (33)
+#define KD_ETIMEDOUT (36)
+#define KD_EILSEQ (19)
+#endif
+
+/** Map types from OMX standard types only here so interface is as generic as possible. */
+typedef OMX_U32    CPresult;
+typedef char *     CPstring;
+typedef void *     CPhandle;
+typedef OMX_U32    CPuint;
+typedef OMX_S32    CPint;
+typedef char       CPbyte;
+typedef OMX_BOOL   CPbool;
+
+/** enumeration of origin types used in the CP_PIPETYPE's Seek function
+ * @ingroup cp
+ */
+typedef enum CP_ORIGINTYPE {
+    CP_OriginBegin,
+    CP_OriginCur,
+    CP_OriginEnd,
+    CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    CP_OriginMax = 0X7FFFFFFF
+} CP_ORIGINTYPE;
+
+/** enumeration of contact access types used in the CP_PIPETYPE's Open function
+ * @ingroup cp
+ */
+typedef enum CP_ACCESSTYPE {
+    CP_AccessRead,
+    CP_AccessWrite,
+    CP_AccessReadWrite ,
+    CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    CP_AccessMax = 0X7FFFFFFF
+} CP_ACCESSTYPE;
+
+/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function
+ * @ingroup cp
+ */
+typedef enum CP_CHECKBYTESRESULTTYPE {
+    CP_CheckBytesOk,                    /**< There are at least the request number
+                                              of bytes available */
+    CP_CheckBytesNotReady,              /**< The pipe is still retrieving bytes
+                                              and presently lacks sufficient bytes.
+                                              Client will be called when they are
+                                              sufficient bytes are available. */
+    CP_CheckBytesInsufficientBytes  ,     /**< The pipe has retrieved all bytes
+                                              but those available are less than those
+                                              requested */
+    CP_CheckBytesAtEndOfStream,         /**< The pipe has reached the end of stream
+                                              and no more bytes are available. */
+    CP_CheckBytesOutOfBuffers,          /**< All read/write buffers are currently in use. */
+    CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    CP_CheckBytesMax = 0X7FFFFFFF
+} CP_CHECKBYTESRESULTTYPE;
+
+/** enumeration of content pipe events sent to the client callback.
+ * @ingroup cp
+ */
+typedef enum CP_EVENTTYPE {
+    CP_BytesAvailable,              /** bytes requested in a CheckAvailableBytes call are now available*/
+    CP_Overflow,                   /** enumeration of content pipe events sent to the client callback*/
+    CP_PipeDisconnected  ,              /** enumeration of content pipe events sent to the client callback*/
+    CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    CP_EventMax = 0X7FFFFFFF
+} CP_EVENTTYPE;
+
+/** content pipe definition
+ * @ingroup cp
+ */
+typedef struct CP_PIPETYPE {
+    /** Open a content stream for reading or writing. */
+    CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess );
+
+    /** Close a content stream. */
+    CPresult (*Close)( CPhandle hContent );
+
+    /** Create a content source and open it for writing. */
+    CPresult (*Create)( CPhandle *hContent, CPstring szURI );
+
+    /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/
+    CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult );
+
+    /** Seek to certain position in the content relative to the specified origin. */
+    CPresult (*SetPosition)( CPhandle  hContent, CPint nOffset, CP_ORIGINTYPE eOrigin);
+
+    /** Retrieve the current position relative to the start of the content. */
+    CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition);
+
+    /** Retrieve data of the specified size from the content stream (advance content pointer by size of data).
+       Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */
+    CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize);
+
+    /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes.
+       Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also
+       returns the size of the block actually read. Content pointer advances the by the returned size.
+       Note: pipe provides pointer. This function is appropriate for large reads. The client must call
+       ReleaseReadBuffer when done with buffer.
+
+       In some cases the requested block may not reside in contiguous memory within the
+       pipe implementation. For instance if the pipe leverages a circular buffer then the requested
+       block may straddle the boundary of the circular buffer. By default a pipe implementation
+       performs a copy in this case to provide the block to the pipe client in one contiguous buffer.
+       If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory
+       boundary. Here the client may retrieve the data in segments over successive calls. */
+    CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy);
+
+    /** Release a buffer obtained by ReadBuffer back to the pipe. */
+    CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer);
+
+    /** Write data of the specified size to the content (advance content pointer by size of data).
+       Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */
+    CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize);
+
+    /** Retrieve a buffer allocated by the pipe used to write data to the content.
+       Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate
+       for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/
+    CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize);
+
+    /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the
+       the contents of the buffer to content and advance content pointer by the size of the buffer */
+    CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize);
+
+    /** Register a per-handle client callback with the content pipe. */
+    CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam));
+
+} CP_PIPETYPE;
+
+#endif
+

+ 1422 - 0
soft_3rdpart/omx-il/include/khronos/OMX_Core.h

@@ -0,0 +1,1422 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_Core.h - OpenMax IL version 1.1.2
+ *  The OMX_Core header file contains the definitions used by both the
+ *  application and the component to access common items.
+ */
+
+#ifndef OMX_Core_h
+#define OMX_Core_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Each OMX header shall include all required header files to allow the
+ *  header to compile without errors.  The includes below are required
+ *  for this header file to compile successfully
+ */
+
+#include <OMX_Index.h>
+
+
+/** The OMX_COMMANDTYPE enumeration is used to specify the action in the
+ *  OMX_SendCommand macro.
+ *  @ingroup core
+ */
+typedef enum OMX_COMMANDTYPE
+{
+    OMX_CommandStateSet,    /**< Change the component state */
+    OMX_CommandFlush,       /**< Flush the data queue(s) of a component */
+    OMX_CommandPortDisable, /**< Disable a port on a component. */
+    OMX_CommandPortEnable,  /**< Enable a port on a component. */
+    OMX_CommandMarkBuffer,  /**< Mark a component/buffer for observation */
+    OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_CommandMax = 0X7FFFFFFF
+} OMX_COMMANDTYPE;
+
+
+
+/** The OMX_STATETYPE enumeration is used to indicate or change the component
+ *  state.  This enumeration reflects the current state of the component when
+ *  used with the OMX_GetState macro or becomes the parameter in a state change
+ *  command when used with the OMX_SendCommand macro.
+ *
+ *  The component will be in the Loaded state after the component is initially
+ *  loaded into memory.  In the Loaded state, the component is not allowed to
+ *  allocate or hold resources other than to build it's internal parameter
+ *  and configuration tables.  The application will send one or more
+ *  SetParameters/GetParameters and SetConfig/GetConfig commands to the
+ *  component and the component will record each of these parameter and
+ *  configuration changes for use later.  When the application sends the
+ *  Idle command, the component will acquire the resources needed for the
+ *  specified configuration and will transition to the idle state if the
+ *  allocation is successful.  If the component cannot successfully
+ *  transition to the idle state for any reason, the state of the component
+ *  shall be fully rolled back to the Loaded state (e.g. all allocated
+ *  resources shall be released).  When the component receives the command
+ *  to go to the Executing state, it shall begin processing buffers by
+ *  sending all input buffers it holds to the application.  While
+ *  the component is in the Idle state, the application may also send the
+ *  Pause command.  If the component receives the pause command while in the
+ *  Idle state, the component shall send all input buffers it holds to the
+ *  application, but shall not begin processing buffers.  This will allow the
+ *  application to prefill buffers.
+ *
+ *  @ingroup comp
+ */
+
+typedef enum OMX_STATETYPE {
+    OMX_StateInvalid,      /**< component has detected that it's internal data
+                                structures are corrupted to the point that
+                                it cannot determine it's state properly */
+    OMX_StateLoaded,      /**< component has been loaded but has not completed
+                                initialization.  The OMX_SetParameter macro
+                                and the OMX_GetParameter macro are the only
+                                valid macros allowed to be sent to the
+                                component in this state. */
+    OMX_StateIdle,        /**< component initialization has been completed
+                                successfully and the component is ready to
+                                to start. */
+    OMX_StateExecuting,   /**< component has accepted the start command and
+                                is processing data (if data is available) */
+    OMX_StatePause,       /**< component has received pause command */
+    OMX_StateWaitForResources, /**< component is waiting for resources, either after
+                                preemption or before it gets the resources requested.
+                                See specification for complete details. */
+    OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_StateMax = 0X7FFFFFFF
+} OMX_STATETYPE;
+
+/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors.  These
+ *  errors should cover most of the common failure cases.  However,
+ *  vendors are free to add additional error messages of their own as
+ *  long as they follow these rules:
+ *  1.  Vendor error messages shall be in the range of 0x90000000 to
+ *      0x9000FFFF.
+ *  2.  Vendor error messages shall be defined in a header file provided
+ *      with the component.  No error messages are allowed that are
+ *      not defined.
+ */
+typedef enum OMX_ERRORTYPE {
+    OMX_ErrorNone = 0,
+
+    /** There were insufficient resources to perform the requested operation */
+    OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000,
+
+    /** There was an error, but the cause of the error could not be determined */
+    OMX_ErrorUndefined = (OMX_S32) 0x80001001,
+
+    /** The component name string was not valid */
+    OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002,
+
+    /** No component with the specified name string was found */
+    OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003,
+
+    /** The component specified did not have a "OMX_ComponentInit" or
+        "OMX_ComponentDeInit entry point */
+    OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004,
+
+    /** One or more parameters were not valid */
+    OMX_ErrorBadParameter = (OMX_S32) 0x80001005,
+
+    /** The requested function is not implemented */
+    OMX_ErrorNotImplemented = (OMX_S32) 0x80001006,
+
+    /** The buffer was emptied before the next buffer was ready */
+    OMX_ErrorUnderflow = (OMX_S32) 0x80001007,
+
+    /** The buffer was not available when it was needed */
+    OMX_ErrorOverflow = (OMX_S32) 0x80001008,
+
+    /** The hardware failed to respond as expected */
+    OMX_ErrorHardware = (OMX_S32) 0x80001009,
+
+    /** The component is in the state OMX_StateInvalid */
+    OMX_ErrorInvalidState = (OMX_S32) 0x8000100A,
+
+    /** Stream is found to be corrupt */
+    OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B,
+
+    /** Ports being connected are not compatible */
+    OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C,
+
+    /** Resources allocated to an idle component have been
+        lost resulting in the component returning to the loaded state */
+    OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D,
+
+    /** No more indicies can be enumerated */
+    OMX_ErrorNoMore = (OMX_S32) 0x8000100E,
+
+    /** The component detected a version mismatch */
+    OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F,
+
+    /** The component is not ready to return data at this time */
+    OMX_ErrorNotReady = (OMX_S32) 0x80001010,
+
+    /** There was a timeout that occurred */
+    OMX_ErrorTimeout = (OMX_S32) 0x80001011,
+
+    /** This error occurs when trying to transition into the state you are already in */
+    OMX_ErrorSameState = (OMX_S32) 0x80001012,
+
+    /** Resources allocated to an executing or paused component have been
+        preempted, causing the component to return to the idle state */
+    OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013,
+
+    /** A non-supplier port sends this error to the IL client (via the EventHandler callback)
+        during the allocation of buffers (on a transition from the LOADED to the IDLE state or
+        on a port restart) when it deems that it has waited an unusually long time for the supplier
+        to send it an allocated buffer via a UseBuffer call. */
+    OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014,
+
+    /** A non-supplier port sends this error to the IL client (via the EventHandler callback)
+        during the deallocation of buffers (on a transition from the IDLE to LOADED state or
+        on a port stop) when it deems that it has waited an unusually long time for the supplier
+        to request the deallocation of a buffer header via a FreeBuffer call. */
+    OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015,
+
+    /** A supplier port sends this error to the IL client (via the EventHandler callback)
+        during the stopping of a port (either on a transition from the IDLE to LOADED
+        state or a port stop) when it deems that it has waited an unusually long time for
+        the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */
+    OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016,
+
+    /** Attempting a state transtion that is not allowed */
+    OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017,
+
+    /* Attempting a command that is not allowed during the present state. */
+    OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018,
+
+    /** The values encapsulated in the parameter or config structure are not supported. */
+    OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019,
+
+    /** The parameter or config indicated by the given index is not supported. */
+    OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A,
+
+    /** The port index supplied is incorrect. */
+    OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B,
+
+    /** The port has lost one or more of its buffers and it thus unpopulated. */
+    OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C,
+
+    /** Component suspended due to temporary loss of resources */
+    OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D,
+
+    /** Component suspended due to an inability to acquire dynamic resources */
+    OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E,
+
+    /** When the macroblock error reporting is enabled the component returns new error
+    for every frame that has errors */
+    OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F,
+
+    /** A component reports this error when it cannot parse or determine the format of an input stream. */
+    OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020,
+
+    /** The content open operation failed. */
+    OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021,
+
+    /** The content creation operation failed. */
+    OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022,
+
+    /** Separate table information is being used */
+    OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023,
+
+    /** Tunneling is unsupported by the component*/
+    OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024,
+
+    OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_ErrorMax = 0x7FFFFFFF
+} OMX_ERRORTYPE;
+
+/** @ingroup core */
+typedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN  OMX_HANDLETYPE hComponent);
+
+/** @ingroup core */
+typedef struct OMX_COMPONENTREGISTERTYPE {
+    const char          * pName;       /* Component name, 128 byte limit (including '\0') applies */
+    OMX_COMPONENTINITTYPE pInitialize; /* Component instance initialization function */
+} OMX_COMPONENTREGISTERTYPE;
+
+/** @ingroup core */
+extern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[];
+
+/** @ingroup rpm */
+typedef struct OMX_PRIORITYMGMTTYPE {
+    OMX_U32 nSize;             /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
+    OMX_U32 nGroupPriority;            /**< Priority of the component group */
+    OMX_U32 nGroupID;                  /**< ID of the component group */
+} OMX_PRIORITYMGMTTYPE;
+
+/* Component name and Role names are limited to 128 characters including the terminating '\0'. */
+#define OMX_MAX_STRINGNAME_SIZE 128
+
+/** @ingroup comp */
+typedef struct OMX_PARAM_COMPONENTROLETYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE];  /**< name of standard component which defines component role */
+} OMX_PARAM_COMPONENTROLETYPE;
+
+/** End of Stream Buffer Flag:
+  *
+  * A component sets EOS when it has no more data to emit on a particular
+  * output port. Thus an output port shall set EOS on the last buffer it
+  * emits. A component's determination of when an output port should
+  * cease sending data is implemenation specific.
+  * @ingroup buf
+  */
+
+#define OMX_BUFFERFLAG_EOS 0x00000001
+
+/** Start Time Buffer Flag:
+ *
+ * The source of a stream (e.g. a demux component) sets the STARTTIME
+ * flag on the buffer that contains the starting timestamp for the
+ * stream. The starting timestamp corresponds to the first data that
+ * should be displayed at startup or after a seek.
+ * The first timestamp of the stream is not necessarily the start time.
+ * For instance, in the case of a seek to a particular video frame,
+ * the target frame may be an interframe. Thus the first buffer of
+ * the stream will be the intra-frame preceding the target frame and
+ * the starttime will occur with the target frame (with any other
+ * required frames required to reconstruct the target intervening).
+ *
+ * The STARTTIME flag is directly associated with the buffer's
+ * timestamp ' thus its association to buffer data and its
+ * propagation is identical to the timestamp's.
+ *
+ * When a Sync Component client receives a buffer with the
+ * STARTTIME flag it shall perform a SetConfig on its sync port
+ * using OMX_ConfigTimeClientStartTime and passing the buffer's
+ * timestamp.
+ *
+ * @ingroup buf
+ */
+
+#define OMX_BUFFERFLAG_STARTTIME 0x00000002
+
+
+
+/** Decode Only Buffer Flag:
+ *
+ * The source of a stream (e.g. a demux component) sets the DECODEONLY
+ * flag on any buffer that should shall be decoded but should not be
+ * displayed. This flag is used, for instance, when a source seeks to
+ * a target interframe that requires the decode of frames preceding the
+ * target to facilitate the target's reconstruction. In this case the
+ * source would emit the frames preceding the target downstream
+ * but mark them as decode only.
+ *
+ * The DECODEONLY is associated with buffer data and propagated in a
+ * manner identical to the buffer timestamp.
+ *
+ * A component that renders data should ignore all buffers with
+ * the DECODEONLY flag set.
+ *
+ * @ingroup buf
+ */
+
+#define OMX_BUFFERFLAG_DECODEONLY 0x00000004
+
+
+/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt
+ * @ingroup buf
+ */
+
+#define OMX_BUFFERFLAG_DATACORRUPT 0x00000008
+
+/* End of Frame: The buffer contains exactly one end of frame and no data
+ *  occurs after the end of frame. This flag is an optional hint. The absence
+ *  of this flag does not imply the absence of an end of frame within the buffer.
+ * @ingroup buf
+*/
+#define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010
+
+/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame '
+ *  a frame that has no dependency on any other frame information
+ *  @ingroup buf
+ */
+#define OMX_BUFFERFLAG_SYNCFRAME 0x00000020
+
+/* Extra data present flag: there is extra data appended to the data stream
+ * residing in the buffer
+ * @ingroup buf
+ */
+#define OMX_BUFFERFLAG_EXTRADATA 0x00000040
+
+/** Codec Config Buffer Flag:
+* OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an
+* output port when all bytes in the buffer form part or all of a set of
+* codec specific configuration data.  Examples include SPS/PPS nal units
+* for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for
+* OMX_AUDIO_CodingAAC.  Any component that for a given stream sets
+* OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes
+* with frame data in the same buffer, and shall send all buffers
+* containing codec configuration bytes before any buffers containing
+* frame data that those configurations bytes describe.
+* If the stream format for a particular codec has a frame specific
+* header at the start of each frame, for example OMX_AUDIO_CodingMP3 or
+* OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as
+* normal without setting OMX_BUFFERFLAG_CODECCONFIG.
+ * @ingroup buf
+ */
+#define OMX_BUFFERFLAG_CODECCONFIG 0x00000080
+
+
+
+/** @ingroup buf */
+typedef struct OMX_BUFFERHEADERTYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U8* pBuffer;            /**< Pointer to actual block of memory
+                                     that is acting as the buffer */
+    OMX_U32 nAllocLen;          /**< size of the buffer allocated, in bytes */
+    OMX_U32 nFilledLen;         /**< number of bytes currently in the
+                                     buffer */
+    OMX_U32 nOffset;            /**< start offset of valid data in bytes from
+                                     the start of the buffer */
+    OMX_PTR pAppPrivate;        /**< pointer to any data the application
+                                     wants to associate with this buffer */
+    OMX_PTR pPlatformPrivate;   /**< pointer to any data the platform
+                                     wants to associate with this buffer */
+    OMX_PTR pInputPortPrivate;  /**< pointer to any data the input port
+                                     wants to associate with this buffer */
+    OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port
+                                     wants to associate with this buffer */
+    OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a
+                                              mark event upon processing this buffer. */
+    OMX_PTR pMarkData;          /**< Application specific data associated with
+                                     the mark sent on a mark event to disambiguate
+                                     this mark from others. */
+    OMX_U32 nTickCount;         /**< Optional entry that the component and
+                                     application can update with a tick count
+                                     when they access the component.  This
+                                     value should be in microseconds.  Since
+                                     this is a value relative to an arbitrary
+                                     starting point, this value cannot be used
+                                     to determine absolute time.  This is an
+                                     optional entry and not all components
+                                     will update it.*/
+    OMX_TICKS nTimeStamp;          /**< Timestamp corresponding to the sample
+                                     starting at the first logical sample
+                                     boundary in the buffer. Timestamps of
+                                     successive samples within the buffer may
+                                     be inferred by adding the duration of the
+                                     of the preceding buffer to the timestamp
+                                     of the preceding buffer.*/
+    OMX_U32     nFlags;           /**< buffer specific flags */
+    OMX_U32 nOutputPortIndex;     /**< The index of the output port (if any) using
+                                     this buffer */
+    OMX_U32 nInputPortIndex;      /**< The index of the input port (if any) using
+                                     this buffer */
+} OMX_BUFFERHEADERTYPE;
+
+/** The OMX_EXTRADATATYPE enumeration is used to define the
+ * possible extra data payload types.
+ * NB: this enum is binary backwards compatible with the previous
+ * OMX_EXTRADATA_QUANT define.  This should be replaced with
+ * OMX_ExtraDataQuantization.
+ */
+typedef enum OMX_EXTRADATATYPE {
+    OMX_ExtraDataNone = 0,                       /**< Indicates that no more extra data sections follow */
+    OMX_ExtraDataQuantization,                   /**< The data payload contains quantization data */
+    OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_ExtraDataMax = 0x7FFFFFFF
+} OMX_EXTRADATATYPE;
+
+
+typedef struct OMX_OTHER_EXTRADATATYPE  {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_EXTRADATATYPE eType;       /* Extra Data type */
+    OMX_U32 nDataSize;   /* Size of the supporting data to follow */
+    OMX_U8  data[1];     /* Supporting data hint  */
+} OMX_OTHER_EXTRADATATYPE;
+
+/** @ingroup comp */
+typedef struct OMX_PORT_PARAM_TYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPorts;             /**< The number of ports for this component */
+    OMX_U32 nStartPortNumber;   /** first port number for this type of port */
+} OMX_PORT_PARAM_TYPE;
+
+/** @ingroup comp */
+typedef enum OMX_EVENTTYPE {
+    OMX_EventCmdComplete,         /**< component has sucessfully completed a command */
+    OMX_EventError,               /**< component has detected an error condition */
+    OMX_EventMark,                /**< component has detected a buffer mark */
+    OMX_EventPortSettingsChanged, /**< component is reported a port settings change */
+    OMX_EventBufferFlag,          /**< component has detected an EOS */
+    OMX_EventResourcesAcquired,   /**< component has been granted resources and is
+                                       automatically starting the state change from
+                                       OMX_StateWaitForResources to OMX_StateIdle. */
+    OMX_EventComponentResumed,     /**< Component resumed due to reacquisition of resources */
+    OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */
+    OMX_EventPortFormatDetected,      /**< Component has detected a supported format. */
+    OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_EventMax = 0x7FFFFFFF
+} OMX_EVENTTYPE;
+
+typedef struct OMX_CALLBACKTYPE {
+    /** The EventHandler method is used to notify the application when an
+        event of interest occurs.  Events are defined in the OMX_EVENTTYPE
+        enumeration.  Please see that enumeration for details of what will
+        be returned for each type of event. Callbacks should not return
+        an error to the component, so if an error occurs, the application
+        shall handle it internally.  This is a blocking call.
+
+        The application should return from this call within 5 msec to avoid
+        blocking the component for an excessively long period of time.
+
+        @param hComponent
+            handle of the component to access.  This is the component
+            handle returned by the call to the GetHandle function.
+        @param pAppData
+            pointer to an application defined value that was provided in the
+            pAppData parameter to the OMX_GetHandle method for the component.
+            This application defined value is provided so that the application
+            can have a component specific context when receiving the callback.
+        @param eEvent
+            Event that the component wants to notify the application about.
+        @param nData1
+            nData will be the OMX_ERRORTYPE for an error event and will be
+            an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event.
+         @param nData2
+            nData2 will hold further information related to the event. Can be OMX_STATETYPE for
+            a OMX_CommandStateSet command or port index for a OMX_PortSettingsChanged event.
+            Default value is 0 if not used. )
+        @param pEventData
+            Pointer to additional event-specific data (see spec for meaning).
+      */
+
+    OMX_ERRORTYPE (*EventHandler)(
+        OMX_IN OMX_HANDLETYPE hComponent,
+        OMX_IN OMX_PTR pAppData,
+        OMX_IN OMX_EVENTTYPE eEvent,
+        OMX_IN OMX_U32 nData1,
+        OMX_IN OMX_U32 nData2,
+        OMX_IN OMX_PTR pEventData);
+
+    /** The EmptyBufferDone method is used to return emptied buffers from an
+        input port back to the application for reuse.  This is a blocking call
+        so the application should not attempt to refill the buffers during this
+        call, but should queue them and refill them in another thread.  There
+        is no error return, so the application shall handle any errors generated
+        internally.
+
+        The application should return from this call within 5 msec.
+
+        @param hComponent
+            handle of the component to access.  This is the component
+            handle returned by the call to the GetHandle function.
+        @param pAppData
+            pointer to an application defined value that was provided in the
+            pAppData parameter to the OMX_GetHandle method for the component.
+            This application defined value is provided so that the application
+            can have a component specific context when receiving the callback.
+        @param pBuffer
+            pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer
+            or AllocateBuffer indicating the buffer that was emptied.
+        @ingroup buf
+     */
+    OMX_ERRORTYPE (*EmptyBufferDone)(
+        OMX_IN OMX_HANDLETYPE hComponent,
+        OMX_IN OMX_PTR pAppData,
+        OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
+
+    /** The FillBufferDone method is used to return filled buffers from an
+        output port back to the application for emptying and then reuse.
+        This is a blocking call so the application should not attempt to
+        empty the buffers during this call, but should queue the buffers
+        and empty them in another thread.  There is no error return, so
+        the application shall handle any errors generated internally.  The
+        application shall also update the buffer header to indicate the
+        number of bytes placed into the buffer.
+
+        The application should return from this call within 5 msec.
+
+        @param hComponent
+            handle of the component to access.  This is the component
+            handle returned by the call to the GetHandle function.
+        @param pAppData
+            pointer to an application defined value that was provided in the
+            pAppData parameter to the OMX_GetHandle method for the component.
+            This application defined value is provided so that the application
+            can have a component specific context when receiving the callback.
+        @param pBuffer
+            pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer
+            or AllocateBuffer indicating the buffer that was filled.
+        @ingroup buf
+     */
+    OMX_ERRORTYPE (*FillBufferDone)(
+        OMX_OUT OMX_HANDLETYPE hComponent,
+        OMX_OUT OMX_PTR pAppData,
+        OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);
+
+} OMX_CALLBACKTYPE;
+
+/** The OMX_BUFFERSUPPLIERTYPE enumeration is used to dictate port supplier
+    preference when tunneling between two ports.
+    @ingroup tun buf
+*/
+typedef enum OMX_BUFFERSUPPLIERTYPE {
+    OMX_BufferSupplyUnspecified = 0x0, /**< port supplying the buffers is unspecified,
+                                              or don't care */
+    OMX_BufferSupplyInput,             /**< input port supplies the buffers */
+    OMX_BufferSupplyOutput,            /**< output port supplies the buffers */
+    OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_BufferSupplyMax = 0x7FFFFFFF
+} OMX_BUFFERSUPPLIERTYPE;
+
+
+/** buffer supplier parameter
+ * @ingroup tun
+ */
+typedef struct OMX_PARAM_BUFFERSUPPLIERTYPE {
+    OMX_U32 nSize; /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex; /**< port that this structure applies to */
+    OMX_BUFFERSUPPLIERTYPE eBufferSupplier; /**< buffer supplier */
+} OMX_PARAM_BUFFERSUPPLIERTYPE;
+
+
+/**< indicates that buffers received by an input port of a tunnel
+     may not modify the data in the buffers
+     @ingroup tun
+ */
+#define OMX_PORTTUNNELFLAG_READONLY 0x00000001
+
+
+/** The OMX_TUNNELSETUPTYPE structure is used to pass data from an output
+    port to an input port as part the two ComponentTunnelRequest calls
+    resulting from a OMX_SetupTunnel call from the IL Client.
+    @ingroup tun
+ */
+typedef struct OMX_TUNNELSETUPTYPE {
+    OMX_U32 nTunnelFlags;             /**< bit flags for tunneling */
+    OMX_BUFFERSUPPLIERTYPE eSupplier; /**< supplier preference */
+} OMX_TUNNELSETUPTYPE;
+
+/* OMX Component headers is included to enable the core to use
+   macros for functions into the component for OMX release 1.0.
+   Developers should not access any structures or data from within
+   the component header directly */
+/* TO BE REMOVED - #include <OMX_Component.h> */
+
+/** GetComponentVersion will return information about the component.
+    This is a blocking call.  This macro will go directly from the
+    application to the component (via a core macro).  The
+    component will return from this call within 5 msec.
+    @param [in] hComponent
+        handle of component to execute the command
+    @param [out] pComponentName
+        pointer to an empty string of length 128 bytes.  The component
+        will write its name into this string.  The name will be
+        terminated by a single zero byte.  The name of a component will
+        be 127 bytes or less to leave room for the trailing zero byte.
+        An example of a valid component name is "OMX.ABC.ChannelMixer\0".
+    @param [out] pComponentVersion
+        pointer to an OMX Version structure that the component will fill
+        in.  The component will fill in a value that indicates the
+        component version.  NOTE: the component version is NOT the same
+        as the OMX Specification version (found in all structures).  The
+        component version is defined by the vendor of the component and
+        its value is entirely up to the component vendor.
+    @param [out] pSpecVersion
+        pointer to an OMX Version structure that the component will fill
+        in.  The SpecVersion is the version of the specification that the
+        component was built against.  Please note that this value may or
+        may not match the structure's version.  For example, if the
+        component was built against the 2.0 specification, but the
+        application (which creates the structure is built against the
+        1.0 specification the versions would be different.
+    @param [out] pComponentUUID
+        pointer to the UUID of the component which will be filled in by
+        the component.  The UUID is a unique identifier that is set at
+        RUN time for the component and is unique to each instantion of
+        the component.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp
+ */
+#define OMX_GetComponentVersion(                            \
+        hComponent,                                         \
+        pComponentName,                                     \
+        pComponentVersion,                                  \
+        pSpecVersion,                                       \
+        pComponentUUID)                                     \
+    ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion(  \
+        hComponent,                                         \
+        pComponentName,                                     \
+        pComponentVersion,                                  \
+        pSpecVersion,                                       \
+        pComponentUUID)                 /* Macro End */
+
+
+/** Send a command to the component.  This call is a non-blocking call.
+    The component should check the parameters and then queue the command
+    to the component thread to be executed.  The component thread shall
+    send the EventHandler() callback at the conclusion of the command.
+    This macro will go directly from the application to the component (via
+    a core macro).  The component will return from this call within 5 msec.
+
+    When the command is "OMX_CommandStateSet" the component will queue a
+    state transition to the new state idenfied in nParam.
+
+    When the command is "OMX_CommandFlush", to flush a port's buffer queues,
+    the command will force the component to return all buffers NOT CURRENTLY
+    BEING PROCESSED to the application, in the order in which the buffers
+    were received.
+
+    When the command is "OMX_CommandPortDisable" or
+    "OMX_CommandPortEnable", the component's port (given by the value of
+    nParam) will be stopped or restarted.
+
+    When the command "OMX_CommandMarkBuffer" is used to mark a buffer, the
+    pCmdData will point to a OMX_MARKTYPE structure containing the component
+    handle of the component to examine the buffer chain for the mark.  nParam1
+    contains the index of the port on which the buffer mark is applied.
+
+    Specification text for more details.
+
+    @param [in] hComponent
+        handle of component to execute the command
+    @param [in] Cmd
+        Command for the component to execute
+    @param [in] nParam
+        Parameter for the command to be executed.  When Cmd has the value
+        OMX_CommandStateSet, value is a member of OMX_STATETYPE.  When Cmd has
+        the value OMX_CommandFlush, value of nParam indicates which port(s)
+        to flush. -1 is used to flush all ports a single port index will
+        only flush that port.  When Cmd has the value "OMX_CommandPortDisable"
+        or "OMX_CommandPortEnable", the component's port is given by
+        the value of nParam.  When Cmd has the value "OMX_CommandMarkBuffer"
+        the components pot is given by the value of nParam.
+    @param [in] pCmdData
+        Parameter pointing to the OMX_MARKTYPE structure when Cmd has the value
+        "OMX_CommandMarkBuffer".
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp
+ */
+#define OMX_SendCommand(                                    \
+         hComponent,                                        \
+         Cmd,                                               \
+         nParam,                                            \
+         pCmdData)                                          \
+     ((OMX_COMPONENTTYPE*)hComponent)->SendCommand(         \
+         hComponent,                                        \
+         Cmd,                                               \
+         nParam,                                            \
+         pCmdData)                          /* Macro End */
+
+
+/** The OMX_GetParameter macro will get one of the current parameter
+    settings from the component.  This macro cannot only be invoked when
+    the component is in the OMX_StateInvalid state.  The nParamIndex
+    parameter is used to indicate which structure is being requested from
+    the component.  The application shall allocate the correct structure
+    and shall fill in the structure size and version information before
+    invoking this macro.  When the parameter applies to a port, the
+    caller shall fill in the appropriate nPortIndex value indicating the
+    port on which the parameter applies. If the component has not had
+    any settings changed, then the component should return a set of
+    valid DEFAULT  parameters for the component.  This is a blocking
+    call.
+
+    The component should return from this call within 20 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [in] nParamIndex
+        Index of the structure to be filled.  This value is from the
+        OMX_INDEXTYPE enumeration.
+    @param [in,out] pComponentParameterStructure
+        Pointer to application allocated structure to be filled by the
+        component.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp
+ */
+#define OMX_GetParameter(                                   \
+        hComponent,                                         \
+        nParamIndex,                                        \
+        pComponentParameterStructure)                        \
+    ((OMX_COMPONENTTYPE*)hComponent)->GetParameter(         \
+        hComponent,                                         \
+        nParamIndex,                                        \
+        pComponentParameterStructure)    /* Macro End */
+
+
+/** The OMX_SetParameter macro will send an initialization parameter
+    structure to a component.  Each structure shall be sent one at a time,
+    in a separate invocation of the macro.  This macro can only be
+    invoked when the component is in the OMX_StateLoaded state, or the
+    port is disabled (when the parameter applies to a port). The
+    nParamIndex parameter is used to indicate which structure is being
+    passed to the component.  The application shall allocate the
+    correct structure and shall fill in the structure size and version
+    information (as well as the actual data) before invoking this macro.
+    The application is free to dispose of this structure after the call
+    as the component is required to copy any data it shall retain.  This
+    is a blocking call.
+
+    The component should return from this call within 20 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [in] nIndex
+        Index of the structure to be sent.  This value is from the
+        OMX_INDEXTYPE enumeration.
+    @param [in] pComponentParameterStructure
+        pointer to application allocated structure to be used for
+        initialization by the component.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp
+ */
+#define OMX_SetParameter(                                   \
+        hComponent,                                         \
+        nParamIndex,                                        \
+        pComponentParameterStructure)                        \
+    ((OMX_COMPONENTTYPE*)hComponent)->SetParameter(         \
+        hComponent,                                         \
+        nParamIndex,                                        \
+        pComponentParameterStructure)    /* Macro End */
+
+
+/** The OMX_GetConfig macro will get one of the configuration structures
+    from a component.  This macro can be invoked anytime after the
+    component has been loaded.  The nParamIndex call parameter is used to
+    indicate which structure is being requested from the component.  The
+    application shall allocate the correct structure and shall fill in the
+    structure size and version information before invoking this macro.
+    If the component has not had this configuration parameter sent before,
+    then the component should return a set of valid DEFAULT values for the
+    component.  This is a blocking call.
+
+    The component should return from this call within 5 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [in] nIndex
+        Index of the structure to be filled.  This value is from the
+        OMX_INDEXTYPE enumeration.
+    @param [in,out] pComponentConfigStructure
+        pointer to application allocated structure to be filled by the
+        component.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp
+*/
+#define OMX_GetConfig(                                      \
+        hComponent,                                         \
+        nConfigIndex,                                       \
+        pComponentConfigStructure)                           \
+    ((OMX_COMPONENTTYPE*)hComponent)->GetConfig(            \
+        hComponent,                                         \
+        nConfigIndex,                                       \
+        pComponentConfigStructure)       /* Macro End */
+
+
+/** The OMX_SetConfig macro will send one of the configuration
+    structures to a component.  Each structure shall be sent one at a time,
+    each in a separate invocation of the macro.  This macro can be invoked
+    anytime after the component has been loaded.  The application shall
+    allocate the correct structure and shall fill in the structure size
+    and version information (as well as the actual data) before invoking
+    this macro.  The application is free to dispose of this structure after
+    the call as the component is required to copy any data it shall retain.
+    This is a blocking call.
+
+    The component should return from this call within 5 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [in] nConfigIndex
+        Index of the structure to be sent.  This value is from the
+        OMX_INDEXTYPE enumeration above.
+    @param [in] pComponentConfigStructure
+        pointer to application allocated structure to be used for
+        initialization by the component.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp
+ */
+#define OMX_SetConfig(                                      \
+        hComponent,                                         \
+        nConfigIndex,                                       \
+        pComponentConfigStructure)                           \
+    ((OMX_COMPONENTTYPE*)hComponent)->SetConfig(            \
+        hComponent,                                         \
+        nConfigIndex,                                       \
+        pComponentConfigStructure)       /* Macro End */
+
+
+/** The OMX_GetExtensionIndex macro will invoke a component to translate
+    a vendor specific configuration or parameter string into an OMX
+    structure index.  There is no requirement for the vendor to support
+    this command for the indexes already found in the OMX_INDEXTYPE
+    enumeration (this is done to save space in small components).  The
+    component shall support all vendor supplied extension indexes not found
+    in the master OMX_INDEXTYPE enumeration.  This is a blocking call.
+
+    The component should return from this call within 5 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the GetHandle function.
+    @param [in] cParameterName
+        OMX_STRING that shall be less than 128 characters long including
+        the trailing null byte.  This is the string that will get
+        translated by the component into a configuration index.
+    @param [out] pIndexType
+        a pointer to a OMX_INDEXTYPE to receive the index value.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp
+ */
+#define OMX_GetExtensionIndex(                              \
+        hComponent,                                         \
+        cParameterName,                                     \
+        pIndexType)                                         \
+    ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex(    \
+        hComponent,                                         \
+        cParameterName,                                     \
+        pIndexType)                     /* Macro End */
+
+
+/** The OMX_GetState macro will invoke the component to get the current
+    state of the component and place the state value into the location
+    pointed to by pState.
+
+    The component should return from this call within 5 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [out] pState
+        pointer to the location to receive the state.  The value returned
+        is one of the OMX_STATETYPE members
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp
+ */
+#define OMX_GetState(                                       \
+        hComponent,                                         \
+        pState)                                             \
+    ((OMX_COMPONENTTYPE*)hComponent)->GetState(             \
+        hComponent,                                         \
+        pState)                         /* Macro End */
+
+
+/** The OMX_UseBuffer macro will request that the component use
+    a buffer (and allocate its own buffer header) already allocated
+    by another component, or by the IL Client. This is a blocking
+    call.
+
+    The component should return from this call within 20 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [out] ppBuffer
+        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the
+        pointer to the buffer header
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp buf
+ */
+
+#define OMX_UseBuffer(                                      \
+           hComponent,                                      \
+           ppBufferHdr,                                     \
+           nPortIndex,                                      \
+           pAppPrivate,                                     \
+           nSizeBytes,                                      \
+           pBuffer)                                         \
+    ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer(            \
+           hComponent,                                      \
+           ppBufferHdr,                                     \
+           nPortIndex,                                      \
+           pAppPrivate,                                     \
+           nSizeBytes,                                      \
+           pBuffer)
+
+
+/** The OMX_AllocateBuffer macro will request that the component allocate
+    a new buffer and buffer header.  The component will allocate the
+    buffer and the buffer header and return a pointer to the buffer
+    header.  This is a blocking call.
+
+    The component should return from this call within 5 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [out] ppBuffer
+        pointer to an OMX_BUFFERHEADERTYPE structure used to receive
+        the pointer to the buffer header
+    @param [in] nPortIndex
+        nPortIndex is used to select the port on the component the buffer will
+        be used with.  The port can be found by using the nPortIndex
+        value as an index into the Port Definition array of the component.
+    @param [in] pAppPrivate
+        pAppPrivate is used to initialize the pAppPrivate member of the
+        buffer header structure.
+    @param [in] nSizeBytes
+        size of the buffer to allocate.  Used when bAllocateNew is true.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp buf
+ */
+#define OMX_AllocateBuffer(                                 \
+        hComponent,                                         \
+        ppBuffer,                                           \
+        nPortIndex,                                         \
+        pAppPrivate,                                        \
+        nSizeBytes)                                         \
+    ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer(       \
+        hComponent,                                         \
+        ppBuffer,                                           \
+        nPortIndex,                                         \
+        pAppPrivate,                                        \
+        nSizeBytes)                     /* Macro End */
+
+
+/** The OMX_FreeBuffer macro will release a buffer header from the component
+    which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If
+    the component allocated the buffer (see the OMX_UseBuffer macro) then
+    the component shall free the buffer and buffer header. This is a
+    blocking call.
+
+    The component should return from this call within 20 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [in] nPortIndex
+        nPortIndex is used to select the port on the component the buffer will
+        be used with.
+    @param [in] pBuffer
+        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer
+        or AllocateBuffer.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp buf
+ */
+#define OMX_FreeBuffer(                                     \
+        hComponent,                                         \
+        nPortIndex,                                         \
+        pBuffer)                                            \
+    ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer(           \
+        hComponent,                                         \
+        nPortIndex,                                         \
+        pBuffer)                        /* Macro End */
+
+
+/** The OMX_EmptyThisBuffer macro will send a buffer full of data to an
+    input port of a component.  The buffer will be emptied by the component
+    and returned to the application via the EmptyBufferDone call back.
+    This is a non-blocking call in that the component will record the buffer
+    and return immediately and then empty the buffer, later, at the proper
+    time.  As expected, this macro may be invoked only while the component
+    is in the OMX_StateExecuting.  If nPortIndex does not specify an input
+    port, the component shall return an error.
+
+    The component should return from this call within 5 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [in] pBuffer
+        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer
+        or AllocateBuffer.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp buf
+ */
+#define OMX_EmptyThisBuffer(                                \
+        hComponent,                                         \
+        pBuffer)                                            \
+    ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer(      \
+        hComponent,                                         \
+        pBuffer)                        /* Macro End */
+
+
+/** The OMX_FillThisBuffer macro will send an empty buffer to an
+    output port of a component.  The buffer will be filled by the component
+    and returned to the application via the FillBufferDone call back.
+    This is a non-blocking call in that the component will record the buffer
+    and return immediately and then fill the buffer, later, at the proper
+    time.  As expected, this macro may be invoked only while the component
+    is in the OMX_ExecutingState.  If nPortIndex does not specify an output
+    port, the component shall return an error.
+
+    The component should return from this call within 5 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [in] pBuffer
+        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer
+        or AllocateBuffer.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp buf
+ */
+#define OMX_FillThisBuffer(                                 \
+        hComponent,                                         \
+        pBuffer)                                            \
+    ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer(       \
+        hComponent,                                         \
+        pBuffer)                        /* Macro End */
+
+
+
+/** The OMX_UseEGLImage macro will request that the component use
+    a EGLImage provided by EGL (and allocate its own buffer header)
+    This is a blocking call.
+
+    The component should return from this call within 20 msec.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the OMX_GetHandle function.
+    @param [out] ppBuffer
+        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the
+        pointer to the buffer header.  Note that the memory location used
+        for this buffer is NOT visible to the IL Client.
+    @param [in] nPortIndex
+        nPortIndex is used to select the port on the component the buffer will
+        be used with.  The port can be found by using the nPortIndex
+        value as an index into the Port Definition array of the component.
+    @param [in] pAppPrivate
+        pAppPrivate is used to initialize the pAppPrivate member of the
+        buffer header structure.
+    @param [in] eglImage
+        eglImage contains the handle of the EGLImage to use as a buffer on the
+        specified port.  The component is expected to validate properties of
+        the EGLImage against the configuration of the port to ensure the component
+        can use the EGLImage as a buffer.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup comp buf
+ */
+#define OMX_UseEGLImage(                                    \
+           hComponent,                                      \
+           ppBufferHdr,                                     \
+           nPortIndex,                                      \
+           pAppPrivate,                                     \
+           eglImage)                                        \
+    ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage(          \
+           hComponent,                                      \
+           ppBufferHdr,                                     \
+           nPortIndex,                                      \
+           pAppPrivate,                                     \
+           eglImage)
+
+/** The OMX_Init method is used to initialize the OMX core.  It shall be the
+    first call made into OMX and it should only be executed one time without
+    an interviening OMX_Deinit call.
+
+    The core should return from this call within 20 msec.
+
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup core
+ */
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void);
+
+
+/** The OMX_Deinit method is used to deinitialize the OMX core.  It shall be
+    the last call made into OMX. In the event that the core determines that
+    thare are components loaded when this call is made, the core may return
+    with an error rather than try to unload the components.
+
+    The core should return from this call within 20 msec.
+
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup core
+ */
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void);
+
+
+/** The OMX_ComponentNameEnum method will enumerate through all the names of
+    recognised valid components in the system. This function is provided
+    as a means to detect all the components in the system run-time. There is
+    no strict ordering to the enumeration order of component names, although
+    each name will only be enumerated once.  If the OMX core supports run-time
+    installation of new components, it is only requried to detect newly
+    installed components when the first call to enumerate component names
+    is made (i.e. when nIndex is 0x0).
+
+    The core should return from this call in 20 msec.
+
+    @param [out] cComponentName
+        pointer to a null terminated string with the component name.  The
+        names of the components are strings less than 127 bytes in length
+        plus the trailing null for a maximum size of 128 bytes.  An example
+        of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0".  Names are
+        assigned by the vendor, but shall start with "OMX." and then have
+        the Vendor designation next.
+    @param [in] nNameLength
+        number of characters in the cComponentName string.  With all
+        component name strings restricted to less than 128 characters
+        (including the trailing null) it is recomended that the caller
+        provide a input string for the cComponentName of 128 characters.
+    @param [in] nIndex
+        number containing the enumeration index for the component.
+        Multiple calls to OMX_ComponentNameEnum with increasing values
+        of nIndex will enumerate through the component names in the
+        system until OMX_ErrorNoMore is returned.  The value of nIndex
+        is 0 to (N-1), where N is the number of valid installed components
+        in the system.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  When the value of nIndex exceeds the number of
+        components in the system minus 1, OMX_ErrorNoMore will be
+        returned. Otherwise the appropriate OMX error will be returned.
+    @ingroup core
+ */
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(
+    OMX_OUT OMX_STRING cComponentName,
+    OMX_IN  OMX_U32 nNameLength,
+    OMX_IN  OMX_U32 nIndex);
+
+
+/** The OMX_GetHandle method will locate the component specified by the
+    component name given, load that component into memory and then invoke
+    the component's methods to create an instance of the component.
+
+    The core should return from this call within 20 msec.
+
+    @param [out] pHandle
+        pointer to an OMX_HANDLETYPE pointer to be filled in by this method.
+    @param [in] cComponentName
+        pointer to a null terminated string with the component name.  The
+        names of the components are strings less than 127 bytes in length
+        plus the trailing null for a maximum size of 128 bytes.  An example
+        of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0".  Names are
+        assigned by the vendor, but shall start with "OMX." and then have
+        the Vendor designation next.
+    @param [in] pAppData
+        pointer to an application defined value that will be returned
+        during callbacks so that the application can identify the source
+        of the callback.
+    @param [in] pCallBacks
+        pointer to a OMX_CALLBACKTYPE structure that will be passed to the
+        component to initialize it with.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup core
+ */
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(
+    OMX_OUT OMX_HANDLETYPE* pHandle,
+    OMX_IN  OMX_STRING cComponentName,
+    OMX_IN  OMX_PTR pAppData,
+    OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
+
+
+/** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle
+    method.  If the component reference count goes to zero, the component will
+    be unloaded from memory.
+
+    The core should return from this call within 20 msec when the component is
+    in the OMX_StateLoaded state.
+
+    @param [in] hComponent
+        Handle of the component to be accessed.  This is the component
+        handle returned by the call to the GetHandle function.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+    @ingroup core
+ */
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(
+    OMX_IN  OMX_HANDLETYPE hComponent);
+
+
+
+/** The OMX_SetupTunnel method will handle the necessary calls to the components
+    to setup the specified tunnel the two components.  NOTE: This is
+    an actual method (not a #define macro).  This method will make calls into
+    the component ComponentTunnelRequest method to do the actual tunnel
+    connection.
+
+    The ComponentTunnelRequest method on both components will be called.
+    This method shall not be called unless the component is in the
+    OMX_StateLoaded state except when the ports used for the tunnel are
+    disabled. In this case, the component may be in the OMX_StateExecuting,
+    OMX_StatePause, or OMX_StateIdle states.
+
+    The core should return from this call within 20 msec.
+
+    @param [in] hOutput
+        Handle of the component to be accessed.  Also this is the handle
+        of the component whose port, specified in the nPortOutput parameter
+        will be used the source for the tunnel. This is the component handle
+        returned by the call to the OMX_GetHandle function.  There is a
+        requirement that hOutput be the source for the data when
+        tunelling (i.e. nPortOutput is an output port).  If 0x0, the component
+        specified in hInput will have it's port specified in nPortInput
+        setup for communication with the application / IL client.
+    @param [in] nPortOutput
+        nPortOutput is used to select the source port on component to be
+        used in the tunnel.
+    @param [in] hInput
+        This is the component to setup the tunnel with. This is the handle
+        of the component whose port, specified in the nPortInput parameter
+        will be used the destination for the tunnel. This is the component handle
+        returned by the call to the OMX_GetHandle function.  There is a
+        requirement that hInput be the destination for the data when
+        tunelling (i.e. nPortInut is an input port).   If 0x0, the component
+        specified in hOutput will have it's port specified in nPortPOutput
+        setup for communication with the application / IL client.
+    @param [in] nPortInput
+        nPortInput is used to select the destination port on component to be
+        used in the tunnel.
+    @return OMX_ERRORTYPE
+        If the command successfully executes, the return code will be
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
+        When OMX_ErrorNotImplemented is returned, one or both components is
+        a non-interop component and does not support tunneling.
+
+        On failure, the ports of both components are setup for communication
+        with the application / IL Client.
+    @ingroup core tun
+ */
+OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel(
+    OMX_IN  OMX_HANDLETYPE hOutput,
+    OMX_IN  OMX_U32 nPortOutput,
+    OMX_IN  OMX_HANDLETYPE hInput,
+    OMX_IN  OMX_U32 nPortInput);
+
+/** @ingroup cp */
+OMX_API OMX_ERRORTYPE   OMX_GetContentPipe(
+    OMX_OUT OMX_HANDLETYPE *hPipe,
+    OMX_IN OMX_STRING szURI);
+
+/** The OMX_GetComponentsOfRole method will return the number of components that support the given
+    role and (if the compNames field is non-NULL) the names of those components. The call will fail if
+    an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the
+    client should:
+        * first call this function with the compNames field NULL to determine the number of component names
+        * second call this function with the compNames field pointing to an array of names allocated
+          according to the number returned by the first call.
+
+    The core should return from this call within 5 msec.
+
+    @param [in] role
+        This is generic standard component name consisting only of component class
+        name and the type within that class (e.g. 'audio_decoder.aac').
+    @param [inout] pNumComps
+        This is used both as input and output.
+
+        If compNames is NULL, the input is ignored and the output specifies how many components support
+        the given role.
+
+        If compNames is not NULL, on input it bounds the size of the input structure and
+        on output, it specifies the number of components string names listed within the compNames parameter.
+    @param [inout] compNames
+        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts
+        a list of the names of all physical components that implement the specified standard component name.
+        Each name is NULL terminated. numComps indicates the number of names.
+    @ingroup core
+ */
+OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole (
+    OMX_IN      OMX_STRING role,
+    OMX_INOUT   OMX_U32 *pNumComps,
+    OMX_INOUT   OMX_U8  **compNames);
+
+/** The OMX_GetRolesOfComponent method will return the number of roles supported by the given
+    component and (if the roles field is non-NULL) the names of those roles. The call will fail if
+    an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the
+    client should:
+        * first call this function with the roles field NULL to determine the number of role names
+        * second call this function with the roles field pointing to an array of names allocated
+          according to the number returned by the first call.
+
+    The core should return from this call within 5 msec.
+
+    @param [in] compName
+        This is the name of the component being queried about.
+    @param [inout] pNumRoles
+        This is used both as input and output.
+
+        If roles is NULL, the input is ignored and the output specifies how many roles the component supports.
+
+        If compNames is not NULL, on input it bounds the size of the input structure and
+        on output, it specifies the number of roles string names listed within the roles parameter.
+    @param [out] roles
+        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings
+        which accepts a list of the names of all standard components roles implemented on the
+        specified component name. numComps indicates the number of names.
+    @ingroup core
+ */
+OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent (
+    OMX_IN      OMX_STRING compName,
+    OMX_INOUT   OMX_U32 *pNumRoles,
+    OMX_OUT     OMX_U8 **roles);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */
+

+ 920 - 0
soft_3rdpart/omx-il/include/khronos/OMX_IVCommon.h

@@ -0,0 +1,920 @@
+/**
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * @file OMX_IVCommon.h - OpenMax IL version 1.1.2
+ *  The structures needed by Video and Image components to exchange
+ *  parameters and configuration data with the components.
+ */
+#ifndef OMX_IVCommon_h
+#define OMX_IVCommon_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * Each OMX header must include all required header files to allow the header
+ * to compile without errors.  The includes below are required for this header
+ * file to compile successfully
+ */
+
+#include <OMX_Core.h>
+
+/** @defgroup iv OpenMAX IL Imaging and Video Domain
+ * Common structures for OpenMAX IL Imaging and Video domains
+ * @{
+ */
+
+
+/**
+ * Enumeration defining possible uncompressed image/video formats.
+ *
+ * ENUMS:
+ *  Unused                 : Placeholder value when format is N/A
+ *  Monochrome             : black and white
+ *  8bitRGB332             : Red 7:5, Green 4:2, Blue 1:0
+ *  12bitRGB444            : Red 11:8, Green 7:4, Blue 3:0
+ *  16bitARGB4444          : Alpha 15:12, Red 11:8, Green 7:4, Blue 3:0
+ *  16bitARGB1555          : Alpha 15, Red 14:10, Green 9:5, Blue 4:0
+ *  16bitRGB565            : Red 15:11, Green 10:5, Blue 4:0
+ *  16bitBGR565            : Blue 15:11, Green 10:5, Red 4:0
+ *  18bitRGB666            : Red 17:12, Green 11:6, Blue 5:0
+ *  18bitARGB1665          : Alpha 17, Red 16:11, Green 10:5, Blue 4:0
+ *  19bitARGB1666          : Alpha 18, Red 17:12, Green 11:6, Blue 5:0
+ *  24bitRGB888            : Red 24:16, Green 15:8, Blue 7:0
+ *  24bitBGR888            : Blue 24:16, Green 15:8, Red 7:0
+ *  24bitARGB1887          : Alpha 23, Red 22:15, Green 14:7, Blue 6:0
+ *  25bitARGB1888          : Alpha 24, Red 23:16, Green 15:8, Blue 7:0
+ *  32bitBGRA8888          : Blue 31:24, Green 23:16, Red 15:8, Alpha 7:0
+ *  32bitARGB8888          : Alpha 31:24, Red 23:16, Green 15:8, Blue 7:0
+ *  YUV411Planar           : U,Y are subsampled by a factor of 4 horizontally
+ *  YUV411PackedPlanar     : packed per payload in planar slices
+ *  YUV420Planar           : Three arrays Y,U,V.
+ *  YUV420PackedPlanar     : packed per payload in planar slices
+ *  YUV420SemiPlanar       : Two arrays, one is all Y, the other is U and V
+ *  YUV422Planar           : Three arrays Y,U,V.
+ *  YUV422PackedPlanar     : packed per payload in planar slices
+ *  YUV422SemiPlanar       : Two arrays, one is all Y, the other is U and V
+ *  YCbYCr                 : Organized as 16bit YUYV (i.e. YCbYCr)
+ *  YCrYCb                 : Organized as 16bit YVYU (i.e. YCrYCb)
+ *  CbYCrY                 : Organized as 16bit UYVY (i.e. CbYCrY)
+ *  CrYCbY                 : Organized as 16bit VYUY (i.e. CrYCbY)
+ *  YUV444Interleaved      : Each pixel contains equal parts YUV
+ *  RawBayer8bit           : SMIA camera output format
+ *  RawBayer10bit          : SMIA camera output format
+ *  RawBayer8bitcompressed : SMIA camera output format
+ */
+typedef enum OMX_COLOR_FORMATTYPE {
+    OMX_COLOR_FormatUnused,
+    OMX_COLOR_FormatMonochrome,
+    OMX_COLOR_Format8bitRGB332,
+    OMX_COLOR_Format12bitRGB444,
+    OMX_COLOR_Format16bitARGB4444,
+    OMX_COLOR_Format16bitARGB1555,
+    OMX_COLOR_Format16bitRGB565,
+    OMX_COLOR_Format16bitBGR565,
+    OMX_COLOR_Format18bitRGB666,
+    OMX_COLOR_Format18bitARGB1665,
+    OMX_COLOR_Format19bitARGB1666,
+    OMX_COLOR_Format24bitRGB888,
+    OMX_COLOR_Format24bitBGR888,
+    OMX_COLOR_Format24bitARGB1887,
+    OMX_COLOR_Format25bitARGB1888,
+    OMX_COLOR_Format32bitBGRA8888,
+    OMX_COLOR_Format32bitARGB8888,
+    OMX_COLOR_FormatYUV411Planar,
+    OMX_COLOR_FormatYUV411PackedPlanar,
+    OMX_COLOR_FormatYUV420Planar,
+    OMX_COLOR_FormatYUV420PackedPlanar,
+    OMX_COLOR_FormatYUV420SemiPlanar,
+    OMX_COLOR_FormatYUV422Planar,
+    OMX_COLOR_FormatYUV422PackedPlanar,
+    OMX_COLOR_FormatYUV422SemiPlanar,
+    OMX_COLOR_FormatYCbYCr,
+    OMX_COLOR_FormatYCrYCb,
+    OMX_COLOR_FormatCbYCrY,
+    OMX_COLOR_FormatCrYCbY,
+    OMX_COLOR_FormatYUV444Interleaved,
+    OMX_COLOR_FormatRawBayer8bit,
+    OMX_COLOR_FormatRawBayer10bit,
+    OMX_COLOR_FormatRawBayer8bitcompressed,
+    OMX_COLOR_FormatL2,
+    OMX_COLOR_FormatL4,
+    OMX_COLOR_FormatL8,
+    OMX_COLOR_FormatL16,
+    OMX_COLOR_FormatL24,
+    OMX_COLOR_FormatL32,
+    OMX_COLOR_FormatYUV420PackedSemiPlanar,
+    OMX_COLOR_FormatYUV422PackedSemiPlanar,
+    OMX_COLOR_Format18BitBGR666,
+    OMX_COLOR_Format24BitARGB6666,
+    OMX_COLOR_Format24BitABGR6666,
+    OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_COLOR_FormatMax = 0x7FFFFFFF
+} OMX_COLOR_FORMATTYPE;
+
+
+/**
+ * Defines the matrix for conversion from RGB to YUV or vice versa.
+ * iColorMatrix should be initialized with the fixed point values
+ * used in converting between formats.
+ */
+typedef struct OMX_CONFIG_COLORCONVERSIONTYPE {
+    OMX_U32 nSize;              /**< Size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version info */
+    OMX_U32 nPortIndex;         /**< Port that this struct applies to */
+    OMX_S32 xColorMatrix[3][3]; /**< Stored in signed Q16 format */
+    OMX_S32 xColorOffset[4];    /**< Stored in signed Q16 format */
+} OMX_CONFIG_COLORCONVERSIONTYPE;
+
+
+/**
+ * Structure defining percent to scale each frame dimension.  For example:
+ * To make the width 50% larger, use fWidth = 1.5 and to make the width
+ * 1/2 the original size, use fWidth = 0.5
+ */
+typedef struct OMX_CONFIG_SCALEFACTORTYPE {
+    OMX_U32 nSize;            /**< Size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version info */
+    OMX_U32 nPortIndex;       /**< Port that this struct applies to */
+    OMX_S32 xWidth;           /**< Fixed point value stored as Q16 */
+    OMX_S32 xHeight;          /**< Fixed point value stored as Q16 */
+} OMX_CONFIG_SCALEFACTORTYPE;
+
+
+/**
+ * Enumeration of possible image filter types
+ */
+typedef enum OMX_IMAGEFILTERTYPE {
+    OMX_ImageFilterNone,
+    OMX_ImageFilterNoise,
+    OMX_ImageFilterEmboss,
+    OMX_ImageFilterNegative,
+    OMX_ImageFilterSketch,
+    OMX_ImageFilterOilPaint,
+    OMX_ImageFilterHatch,
+    OMX_ImageFilterGpen,
+    OMX_ImageFilterAntialias,
+    OMX_ImageFilterDeRing,
+    OMX_ImageFilterSolarize,
+    OMX_ImageFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_ImageFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_ImageFilterMax = 0x7FFFFFFF
+} OMX_IMAGEFILTERTYPE;
+
+
+/**
+ * Image filter configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize        : Size of the structure in bytes
+ *  nVersion     : OMX specification version information
+ *  nPortIndex   : Port that this structure applies to
+ *  eImageFilter : Image filter type enumeration
+ */
+typedef struct OMX_CONFIG_IMAGEFILTERTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_IMAGEFILTERTYPE eImageFilter;
+} OMX_CONFIG_IMAGEFILTERTYPE;
+
+
+/**
+ * Customized U and V for color enhancement
+ *
+ * STRUCT MEMBERS:
+ *  nSize             : Size of the structure in bytes
+ *  nVersion          : OMX specification version information
+ *  nPortIndex        : Port that this structure applies to
+ *  bColorEnhancement : Enable/disable color enhancement
+ *  nCustomizedU      : Practical values: 16-240, range: 0-255, value set for
+ *                      U component
+ *  nCustomizedV      : Practical values: 16-240, range: 0-255, value set for
+ *                      V component
+ */
+typedef struct OMX_CONFIG_COLORENHANCEMENTTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bColorEnhancement;
+    OMX_U8 nCustomizedU;
+    OMX_U8 nCustomizedV;
+} OMX_CONFIG_COLORENHANCEMENTTYPE;
+
+
+/**
+ * Define color key and color key mask
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nARGBColor : 32bit Alpha, Red, Green, Blue Color
+ *  nARGBMask  : 32bit Mask for Alpha, Red, Green, Blue channels
+ */
+typedef struct OMX_CONFIG_COLORKEYTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nARGBColor;
+    OMX_U32 nARGBMask;
+} OMX_CONFIG_COLORKEYTYPE;
+
+
+/**
+ * List of color blend types for pre/post processing
+ *
+ * ENUMS:
+ *  None          : No color blending present
+ *  AlphaConstant : Function is (alpha_constant * src) +
+ *                  (1 - alpha_constant) * dst)
+ *  AlphaPerPixel : Function is (alpha * src) + (1 - alpha) * dst)
+ *  Alternate     : Function is alternating pixels from src and dst
+ *  And           : Function is (src & dst)
+ *  Or            : Function is (src | dst)
+ *  Invert        : Function is ~src
+ */
+typedef enum OMX_COLORBLENDTYPE {
+    OMX_ColorBlendNone,
+    OMX_ColorBlendAlphaConstant,
+    OMX_ColorBlendAlphaPerPixel,
+    OMX_ColorBlendAlternate,
+    OMX_ColorBlendAnd,
+    OMX_ColorBlendOr,
+    OMX_ColorBlendInvert,
+    OMX_ColorBlendKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_ColorBlendVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_ColorBlendMax = 0x7FFFFFFF
+} OMX_COLORBLENDTYPE;
+
+
+/**
+ * Color blend configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize             : Size of the structure in bytes
+ *  nVersion          : OMX specification version information
+ *  nPortIndex        : Port that this structure applies to
+ *  nRGBAlphaConstant : Constant global alpha values when global alpha is used
+ *  eColorBlend       : Color blend type enumeration
+ */
+typedef struct OMX_CONFIG_COLORBLENDTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nRGBAlphaConstant;
+    OMX_COLORBLENDTYPE  eColorBlend;
+} OMX_CONFIG_COLORBLENDTYPE;
+
+
+/**
+ * Hold frame dimension
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nWidth     : Frame width in pixels
+ *  nHeight    : Frame height in pixels
+ */
+typedef struct OMX_FRAMESIZETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nWidth;
+    OMX_U32 nHeight;
+} OMX_FRAMESIZETYPE;
+
+
+/**
+ * Rotation configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nRotation  : +/- integer rotation value
+ */
+typedef struct OMX_CONFIG_ROTATIONTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_S32 nRotation;
+} OMX_CONFIG_ROTATIONTYPE;
+
+
+/**
+ * Possible mirroring directions for pre/post processing
+ *
+ * ENUMS:
+ *  None       : No mirroring
+ *  Vertical   : Vertical mirroring, flip on X axis
+ *  Horizontal : Horizontal mirroring, flip on Y axis
+ *  Both       : Both vertical and horizontal mirroring
+ */
+typedef enum OMX_MIRRORTYPE {
+    OMX_MirrorNone = 0,
+    OMX_MirrorVertical,
+    OMX_MirrorHorizontal,
+    OMX_MirrorBoth,
+    OMX_MirrorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_MirrorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_MirrorMax = 0x7FFFFFFF
+} OMX_MIRRORTYPE;
+
+
+/**
+ * Mirroring configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  eMirror    : Mirror type enumeration
+ */
+typedef struct OMX_CONFIG_MIRRORTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_MIRRORTYPE  eMirror;
+} OMX_CONFIG_MIRRORTYPE;
+
+
+/**
+ * Position information only
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nX         : X coordinate for the point
+ *  nY         : Y coordinate for the point
+ */
+typedef struct OMX_CONFIG_POINTTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_S32 nX;
+    OMX_S32 nY;
+} OMX_CONFIG_POINTTYPE;
+
+
+/**
+ * Frame size plus position
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nLeft      : X Coordinate of the top left corner of the rectangle
+ *  nTop       : Y Coordinate of the top left corner of the rectangle
+ *  nWidth     : Width of the rectangle
+ *  nHeight    : Height of the rectangle
+ */
+typedef struct OMX_CONFIG_RECTTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_S32 nLeft;
+    OMX_S32 nTop;
+    OMX_U32 nWidth;
+    OMX_U32 nHeight;
+} OMX_CONFIG_RECTTYPE;
+
+
+/**
+ * Deblocking state; it is required to be set up before starting the codec
+ *
+ * STRUCT MEMBERS:
+ *  nSize       : Size of the structure in bytes
+ *  nVersion    : OMX specification version information
+ *  nPortIndex  : Port that this structure applies to
+ *  bDeblocking : Enable/disable deblocking mode
+ */
+typedef struct OMX_PARAM_DEBLOCKINGTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bDeblocking;
+} OMX_PARAM_DEBLOCKINGTYPE;
+
+
+/**
+ * Stabilization state
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  bStab      : Enable/disable frame stabilization state
+ */
+typedef struct OMX_CONFIG_FRAMESTABTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bStab;
+} OMX_CONFIG_FRAMESTABTYPE;
+
+
+/**
+ * White Balance control type
+ *
+ * STRUCT MEMBERS:
+ *  SunLight : Referenced in JSR-234
+ *  Flash    : Optimal for device's integrated flash
+ */
+typedef enum OMX_WHITEBALCONTROLTYPE {
+    OMX_WhiteBalControlOff = 0,
+    OMX_WhiteBalControlAuto,
+    OMX_WhiteBalControlSunLight,
+    OMX_WhiteBalControlCloudy,
+    OMX_WhiteBalControlShade,
+    OMX_WhiteBalControlTungsten,
+    OMX_WhiteBalControlFluorescent,
+    OMX_WhiteBalControlIncandescent,
+    OMX_WhiteBalControlFlash,
+    OMX_WhiteBalControlHorizon,
+    OMX_WhiteBalControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_WhiteBalControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_WhiteBalControlMax = 0x7FFFFFFF
+} OMX_WHITEBALCONTROLTYPE;
+
+
+/**
+ * White Balance control configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize            : Size of the structure in bytes
+ *  nVersion         : OMX specification version information
+ *  nPortIndex       : Port that this structure applies to
+ *  eWhiteBalControl : White balance enumeration
+ */
+typedef struct OMX_CONFIG_WHITEBALCONTROLTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_WHITEBALCONTROLTYPE eWhiteBalControl;
+} OMX_CONFIG_WHITEBALCONTROLTYPE;
+
+
+/**
+ * Exposure control type
+ */
+typedef enum OMX_EXPOSURECONTROLTYPE {
+    OMX_ExposureControlOff = 0,
+    OMX_ExposureControlAuto,
+    OMX_ExposureControlNight,
+    OMX_ExposureControlBackLight,
+    OMX_ExposureControlSpotLight,
+    OMX_ExposureControlSports,
+    OMX_ExposureControlSnow,
+    OMX_ExposureControlBeach,
+    OMX_ExposureControlLargeAperture,
+    OMX_ExposureControlSmallApperture,
+    OMX_ExposureControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_ExposureControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_ExposureControlMax = 0x7FFFFFFF
+} OMX_EXPOSURECONTROLTYPE;
+
+
+/**
+ * White Balance control configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize            : Size of the structure in bytes
+ *  nVersion         : OMX specification version information
+ *  nPortIndex       : Port that this structure applies to
+ *  eExposureControl : Exposure control enumeration
+ */
+typedef struct OMX_CONFIG_EXPOSURECONTROLTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_EXPOSURECONTROLTYPE eExposureControl;
+} OMX_CONFIG_EXPOSURECONTROLTYPE;
+
+
+/**
+ * Defines sensor supported mode.
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nFrameRate : Single shot mode is indicated by a 0
+ *  bOneShot   : Enable for single shot, disable for streaming
+ *  sFrameSize : Framesize
+ */
+typedef struct OMX_PARAM_SENSORMODETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nFrameRate;
+    OMX_BOOL bOneShot;
+    OMX_FRAMESIZETYPE sFrameSize;
+} OMX_PARAM_SENSORMODETYPE;
+
+
+/**
+ * Defines contrast level
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nContrast  : Values allowed for contrast -100 to 100, zero means no change
+ */
+typedef struct OMX_CONFIG_CONTRASTTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_S32 nContrast;
+} OMX_CONFIG_CONTRASTTYPE;
+
+
+/**
+ * Defines brightness level
+ *
+ * STRUCT MEMBERS:
+ *  nSize       : Size of the structure in bytes
+ *  nVersion    : OMX specification version information
+ *  nPortIndex  : Port that this structure applies to
+ *  nBrightness : 0-100%
+ */
+typedef struct OMX_CONFIG_BRIGHTNESSTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nBrightness;
+} OMX_CONFIG_BRIGHTNESSTYPE;
+
+
+/**
+ * Defines backlight level configuration for a video sink, e.g. LCD panel
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nBacklight : Values allowed for backlight 0-100%
+ *  nTimeout   : Number of milliseconds before backlight automatically turns
+ *               off.  A value of 0x0 disables backight timeout
+ */
+typedef struct OMX_CONFIG_BACKLIGHTTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nBacklight;
+    OMX_U32 nTimeout;
+} OMX_CONFIG_BACKLIGHTTYPE;
+
+
+/**
+ * Defines setting for Gamma
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nGamma     : Values allowed for gamma -100 to 100, zero means no change
+ */
+typedef struct OMX_CONFIG_GAMMATYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_S32 nGamma;
+} OMX_CONFIG_GAMMATYPE;
+
+
+/**
+ * Define for setting saturation
+ *
+ * STRUCT MEMBERS:
+ *  nSize       : Size of the structure in bytes
+ *  nVersion    : OMX specification version information
+ *  nPortIndex  : Port that this structure applies to
+ *  nSaturation : Values allowed for saturation -100 to 100, zero means
+ *                no change
+ */
+typedef struct OMX_CONFIG_SATURATIONTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_S32 nSaturation;
+} OMX_CONFIG_SATURATIONTYPE;
+
+
+/**
+ * Define for setting Lightness
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nLightness : Values allowed for lightness -100 to 100, zero means no
+ *               change
+ */
+typedef struct OMX_CONFIG_LIGHTNESSTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_S32 nLightness;
+} OMX_CONFIG_LIGHTNESSTYPE;
+
+
+/**
+ * Plane blend configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Index of input port associated with the plane.
+ *  nDepth     : Depth of the plane in relation to the screen. Higher
+ *               numbered depths are "behind" lower number depths.
+ *               This number defaults to the Port Index number.
+ *  nAlpha     : Transparency blending component for the entire plane.
+ *               See blending modes for more detail.
+ */
+typedef struct OMX_CONFIG_PLANEBLENDTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nDepth;
+    OMX_U32 nAlpha;
+} OMX_CONFIG_PLANEBLENDTYPE;
+
+
+/**
+ * Define interlace type
+ *
+ * STRUCT MEMBERS:
+ *  nSize                 : Size of the structure in bytes
+ *  nVersion              : OMX specification version information
+ *  nPortIndex            : Port that this structure applies to
+ *  bEnable               : Enable control variable for this functionality
+ *                          (see below)
+ *  nInterleavePortIndex  : Index of input or output port associated with
+ *                          the interleaved plane.
+ *  pPlanarPortIndexes[4] : Index of input or output planar ports.
+ */
+typedef struct OMX_PARAM_INTERLEAVETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bEnable;
+    OMX_U32 nInterleavePortIndex;
+} OMX_PARAM_INTERLEAVETYPE;
+
+
+/**
+ * Defines the picture effect used for an input picture
+ */
+typedef enum OMX_TRANSITIONEFFECTTYPE {
+    OMX_EffectNone,
+    OMX_EffectFadeFromBlack,
+    OMX_EffectFadeToBlack,
+    OMX_EffectUnspecifiedThroughConstantColor,
+    OMX_EffectDissolve,
+    OMX_EffectWipe,
+    OMX_EffectUnspecifiedMixOfTwoScenes,
+    OMX_EffectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_EffectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_EffectMax = 0x7FFFFFFF
+} OMX_TRANSITIONEFFECTTYPE;
+
+
+/**
+ * Structure used to configure current transition effect
+ *
+ * STRUCT MEMBERS:
+ * nSize      : Size of the structure in bytes
+ * nVersion   : OMX specification version information
+ * nPortIndex : Port that this structure applies to
+ * eEffect    : Effect to enable
+ */
+typedef struct OMX_CONFIG_TRANSITIONEFFECTTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_TRANSITIONEFFECTTYPE eEffect;
+} OMX_CONFIG_TRANSITIONEFFECTTYPE;
+
+
+/**
+ * Defines possible data unit types for encoded video data. The data unit
+ * types are used both for encoded video input for playback as well as
+ * encoded video output from recording.
+ */
+typedef enum OMX_DATAUNITTYPE {
+    OMX_DataUnitCodedPicture,
+    OMX_DataUnitVideoSegment,
+    OMX_DataUnitSeveralSegments,
+    OMX_DataUnitArbitraryStreamSection,
+    OMX_DataUnitKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_DataUnitVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_DataUnitMax = 0x7FFFFFFF
+} OMX_DATAUNITTYPE;
+
+
+/**
+ * Defines possible encapsulation types for coded video data unit. The
+ * encapsulation information is used both for encoded video input for
+ * playback as well as encoded video output from recording.
+ */
+typedef enum OMX_DATAUNITENCAPSULATIONTYPE {
+    OMX_DataEncapsulationElementaryStream,
+    OMX_DataEncapsulationGenericPayload,
+    OMX_DataEncapsulationRtpPayload,
+    OMX_DataEncapsulationKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_DataEncapsulationVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_DataEncapsulationMax = 0x7FFFFFFF
+} OMX_DATAUNITENCAPSULATIONTYPE;
+
+
+/**
+ * Structure used to configure the type of being decoded/encoded
+ */
+typedef struct OMX_PARAM_DATAUNITTYPE {
+    OMX_U32 nSize;            /**< Size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< Port that this structure applies to */
+    OMX_DATAUNITTYPE eUnitType;
+    OMX_DATAUNITENCAPSULATIONTYPE eEncapsulationType;
+} OMX_PARAM_DATAUNITTYPE;
+
+
+/**
+ * Defines dither types
+ */
+typedef enum OMX_DITHERTYPE {
+    OMX_DitherNone,
+    OMX_DitherOrdered,
+    OMX_DitherErrorDiffusion,
+    OMX_DitherOther,
+    OMX_DitherKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_DitherVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_DitherMax = 0x7FFFFFFF
+} OMX_DITHERTYPE;
+
+
+/**
+ * Structure used to configure current type of dithering
+ */
+typedef struct OMX_CONFIG_DITHERTYPE {
+    OMX_U32 nSize;            /**< Size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< Port that this structure applies to */
+    OMX_DITHERTYPE eDither;   /**< Type of dithering to use */
+} OMX_CONFIG_DITHERTYPE;
+
+typedef struct OMX_CONFIG_CAPTUREMODETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;     /**< Port that this structure applies to */
+    OMX_BOOL bContinuous;   /**< If true then ignore frame rate and emit capture
+                             *   data as fast as possible (otherwise obey port's frame rate). */
+    OMX_BOOL bFrameLimited; /**< If true then terminate capture after the port emits the
+                             *   specified number of frames (otherwise the port does not
+                             *   terminate the capture until instructed to do so by the client).
+                             *   Even if set, the client may manually terminate the capture prior
+                             *   to reaching the limit. */
+    OMX_U32 nFrameLimit;      /**< Limit on number of frames emitted during a capture (only
+                               *   valid if bFrameLimited is set). */
+} OMX_CONFIG_CAPTUREMODETYPE;
+
+typedef enum OMX_METERINGTYPE {
+
+    OMX_MeteringModeAverage,     /**< Center-weighted average metering. */
+    OMX_MeteringModeSpot,         /**< Spot (partial) metering. */
+    OMX_MeteringModeMatrix,      /**< Matrix or evaluative metering. */
+
+    OMX_MeteringKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_MeteringVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_EVModeMax = 0x7fffffff
+} OMX_METERINGTYPE;
+
+typedef struct OMX_CONFIG_EXPOSUREVALUETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_METERINGTYPE eMetering;
+    OMX_S32 xEVCompensation;      /**< Fixed point value stored as Q16 */
+    OMX_U32 nApertureFNumber;     /**< e.g. nApertureFNumber = 2 implies "f/2" - Q16 format */
+    OMX_BOOL bAutoAperture;     /**< Whether aperture number is defined automatically */
+    OMX_U32 nShutterSpeedMsec;    /**< Shutterspeed in milliseconds */
+    OMX_BOOL bAutoShutterSpeed; /**< Whether shutter speed is defined automatically */
+    OMX_U32 nSensitivity;         /**< e.g. nSensitivity = 100 implies "ISO 100" */
+    OMX_BOOL bAutoSensitivity;  /**< Whether sensitivity is defined automatically */
+} OMX_CONFIG_EXPOSUREVALUETYPE;
+
+/**
+ * Focus region configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize           : Size of the structure in bytes
+ *  nVersion        : OMX specification version information
+ *  nPortIndex      : Port that this structure applies to
+ *  bCenter         : Use center region as focus region of interest
+ *  bLeft           : Use left region as focus region of interest
+ *  bRight          : Use right region as focus region of interest
+ *  bTop            : Use top region as focus region of interest
+ *  bBottom         : Use bottom region as focus region of interest
+ *  bTopLeft        : Use top left region as focus region of interest
+ *  bTopRight       : Use top right region as focus region of interest
+ *  bBottomLeft     : Use bottom left region as focus region of interest
+ *  bBottomRight    : Use bottom right region as focus region of interest
+ */
+typedef struct OMX_CONFIG_FOCUSREGIONTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bCenter;
+    OMX_BOOL bLeft;
+    OMX_BOOL bRight;
+    OMX_BOOL bTop;
+    OMX_BOOL bBottom;
+    OMX_BOOL bTopLeft;
+    OMX_BOOL bTopRight;
+    OMX_BOOL bBottomLeft;
+    OMX_BOOL bBottomRight;
+} OMX_CONFIG_FOCUSREGIONTYPE;
+
+/**
+ * Focus Status type
+ */
+typedef enum OMX_FOCUSSTATUSTYPE {
+    OMX_FocusStatusOff = 0,
+    OMX_FocusStatusRequest,
+    OMX_FocusStatusReached,
+    OMX_FocusStatusUnableToReach,
+    OMX_FocusStatusLost,
+    OMX_FocusStatusKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_FocusStatusVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_FocusStatusMax = 0x7FFFFFFF
+} OMX_FOCUSSTATUSTYPE;
+
+/**
+ * Focus status configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize               : Size of the structure in bytes
+ *  nVersion            : OMX specification version information
+ *  nPortIndex          : Port that this structure applies to
+ *  eFocusStatus        : Specifies the focus status
+ *  bCenterStatus       : Use center region as focus region of interest
+ *  bLeftStatus         : Use left region as focus region of interest
+ *  bRightStatus        : Use right region as focus region of interest
+ *  bTopStatus          : Use top region as focus region of interest
+ *  bBottomStatus       : Use bottom region as focus region of interest
+ *  bTopLeftStatus      : Use top left region as focus region of interest
+ *  bTopRightStatus     : Use top right region as focus region of interest
+ *  bBottomLeftStatus   : Use bottom left region as focus region of interest
+ *  bBottomRightStatus  : Use bottom right region as focus region of interest
+ */
+typedef struct OMX_PARAM_FOCUSSTATUSTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_FOCUSSTATUSTYPE eFocusStatus;
+    OMX_BOOL bCenterStatus;
+    OMX_BOOL bLeftStatus;
+    OMX_BOOL bRightStatus;
+    OMX_BOOL bTopStatus;
+    OMX_BOOL bBottomStatus;
+    OMX_BOOL bTopLeftStatus;
+    OMX_BOOL bTopRightStatus;
+    OMX_BOOL bBottomLeftStatus;
+    OMX_BOOL bBottomRightStatus;
+} OMX_PARAM_FOCUSSTATUSTYPE;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */

+ 328 - 0
soft_3rdpart/omx-il/include/khronos/OMX_Image.h

@@ -0,0 +1,328 @@
+/**
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file OMX_Image.h - OpenMax IL version 1.1.2
+ * The structures needed by Image components to exchange parameters and
+ * configuration data with the components.
+ */
+#ifndef OMX_Image_h
+#define OMX_Image_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/**
+ * Each OMX header must include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully
+ */
+
+#include <OMX_IVCommon.h>
+
+/** @defgroup imaging OpenMAX IL Imaging Domain
+ * @ingroup iv
+ * Structures for OpenMAX IL Imaging domain
+ * @{
+ */
+
+/**
+ * Enumeration used to define the possible image compression coding.
+ */
+typedef enum OMX_IMAGE_CODINGTYPE {
+    OMX_IMAGE_CodingUnused,      /**< Value when format is N/A */
+    OMX_IMAGE_CodingAutoDetect,  /**< Auto detection of image format */
+    OMX_IMAGE_CodingJPEG,        /**< JPEG/JFIF image format */
+    OMX_IMAGE_CodingJPEG2K,      /**< JPEG 2000 image format */
+    OMX_IMAGE_CodingEXIF,        /**< EXIF image format */
+    OMX_IMAGE_CodingTIFF,        /**< TIFF image format */
+    OMX_IMAGE_CodingGIF,         /**< Graphics image format */
+    OMX_IMAGE_CodingPNG,         /**< PNG image format */
+    OMX_IMAGE_CodingLZW,         /**< LZW image format */
+    OMX_IMAGE_CodingBMP,         /**< Windows Bitmap format */
+    OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_IMAGE_CodingMax = 0x7FFFFFFF
+} OMX_IMAGE_CODINGTYPE;
+
+
+/**
+ * Data structure used to define an image path. The number of image paths
+ * for input and output will vary by type of the image component.
+ *
+ *  Input (aka Source) : Zero Inputs, one Output,
+ *  Splitter           : One Input, 2 or more Outputs,
+ *  Processing Element : One Input, one output,
+ *  Mixer              : 2 or more inputs, one output,
+ *  Output (aka Sink)  : One Input, zero outputs.
+ *
+ * The PortDefinition structure is used to define all of the parameters
+ * necessary for the compliant component to setup an input or an output
+ * image path.  If additional vendor specific data is required, it should
+ * be transmitted to the component using the CustomCommand function.
+ * Compliant components will prepopulate this structure with optimal
+ * values during the OMX_GetParameter() command.
+ *
+ * STRUCT MEMBERS:
+ *  cMIMEType             : MIME type of data for the port
+ *  pNativeRender         : Platform specific reference for a display if a
+ *                          sync, otherwise this field is 0
+ *  nFrameWidth           : Width of frame to be used on port if
+ *                          uncompressed format is used.  Use 0 for
+ *                          unknown, don't care or variable
+ *  nFrameHeight          : Height of frame to be used on port if
+ *                          uncompressed format is used. Use 0 for
+ *                          unknown, don't care or variable
+ *  nStride               : Number of bytes per span of an image (i.e.
+ *                          indicates the number of bytes to get from
+ *                          span N to span N+1, where negative stride
+ *                          indicates the image is bottom up
+ *  nSliceHeight          : Height used when encoding in slices
+ *  bFlagErrorConcealment : Turns on error concealment if it is supported by
+ *                          the OMX component
+ *  eCompressionFormat    : Compression format used in this instance of
+ *                          the component. When OMX_IMAGE_CodingUnused is
+ *                          specified, eColorFormat is valid
+ *  eColorFormat          : Decompressed format used by this component
+ *  pNativeWindow         : Platform specific reference for a window object if a
+ *                          display sink , otherwise this field is 0x0.
+ */
+typedef struct OMX_IMAGE_PORTDEFINITIONTYPE {
+    OMX_STRING cMIMEType;
+    OMX_NATIVE_DEVICETYPE pNativeRender;
+    OMX_U32 nFrameWidth;
+    OMX_U32 nFrameHeight;
+    OMX_S32 nStride;
+    OMX_U32 nSliceHeight;
+    OMX_BOOL bFlagErrorConcealment;
+    OMX_IMAGE_CODINGTYPE eCompressionFormat;
+    OMX_COLOR_FORMATTYPE eColorFormat;
+    OMX_NATIVE_WINDOWTYPE pNativeWindow;
+} OMX_IMAGE_PORTDEFINITIONTYPE;
+
+
+/**
+ * Port format parameter.  This structure is used to enumerate the various
+ * data input/output format supported by the port.
+ *
+ * STRUCT MEMBERS:
+ *  nSize              : Size of the structure in bytes
+ *  nVersion           : OMX specification version information
+ *  nPortIndex         : Indicates which port to set
+ *  nIndex             : Indicates the enumeration index for the format from
+ *                       0x0 to N-1
+ *  eCompressionFormat : Compression format used in this instance of the
+ *                       component. When OMX_IMAGE_CodingUnused is specified,
+ *                       eColorFormat is valid
+ *  eColorFormat       : Decompressed format used by this component
+ */
+typedef struct OMX_IMAGE_PARAM_PORTFORMATTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nIndex;
+    OMX_IMAGE_CODINGTYPE eCompressionFormat;
+    OMX_COLOR_FORMATTYPE eColorFormat;
+} OMX_IMAGE_PARAM_PORTFORMATTYPE;
+
+
+/**
+ * Flash control type
+ *
+ * ENUMS
+ *  Torch : Flash forced constantly on
+ */
+typedef enum OMX_IMAGE_FLASHCONTROLTYPE {
+    OMX_IMAGE_FlashControlOn = 0,
+    OMX_IMAGE_FlashControlOff,
+    OMX_IMAGE_FlashControlAuto,
+    OMX_IMAGE_FlashControlRedEyeReduction,
+    OMX_IMAGE_FlashControlFillin,
+    OMX_IMAGE_FlashControlTorch,
+    OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_IMAGE_FlashControlMax = 0x7FFFFFFF
+} OMX_IMAGE_FLASHCONTROLTYPE;
+
+
+/**
+ * Flash control configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize         : Size of the structure in bytes
+ *  nVersion      : OMX specification version information
+ *  nPortIndex    : Port that this structure applies to
+ *  eFlashControl : Flash control type
+ */
+typedef struct OMX_IMAGE_PARAM_FLASHCONTROLTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_IMAGE_FLASHCONTROLTYPE eFlashControl;
+} OMX_IMAGE_PARAM_FLASHCONTROLTYPE;
+
+
+/**
+ * Focus control type
+ */
+typedef enum OMX_IMAGE_FOCUSCONTROLTYPE {
+    OMX_IMAGE_FocusControlOn = 0,
+    OMX_IMAGE_FocusControlOff,
+    OMX_IMAGE_FocusControlAuto,
+    OMX_IMAGE_FocusControlAutoLock,
+    OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_IMAGE_FocusControlMax = 0x7FFFFFFF
+} OMX_IMAGE_FOCUSCONTROLTYPE;
+
+
+/**
+ * Focus control configuration
+ *
+ * STRUCT MEMBERS:
+ *  nSize           : Size of the structure in bytes
+ *  nVersion        : OMX specification version information
+ *  nPortIndex      : Port that this structure applies to
+ *  eFocusControl   : Focus control
+ *  nFocusSteps     : Focus can take on values from 0 mm to infinity.
+ *                    Interest is only in number of steps over this range.
+ *  nFocusStepIndex : Current focus step index
+ */
+typedef struct OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_IMAGE_FOCUSCONTROLTYPE eFocusControl;
+    OMX_U32 nFocusSteps;
+    OMX_U32 nFocusStepIndex;
+} OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE;
+
+
+/**
+ * Q Factor for JPEG compression, which controls the tradeoff between image
+ * quality and size.  Q Factor provides a more simple means of controlling
+ * JPEG compression quality, without directly programming Quantization
+ * tables for chroma and luma
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nQFactor   : JPEG Q factor value in the range of 1-100. A factor of 1
+ *               produces the smallest, worst quality images, and a factor
+ *               of 100 produces the largest, best quality images.  A
+ *               typical default is 75 for small good quality images
+ */
+typedef struct OMX_IMAGE_PARAM_QFACTORTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nQFactor;
+} OMX_IMAGE_PARAM_QFACTORTYPE;
+
+/**
+ * Quantization table type
+ */
+
+typedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE {
+    OMX_IMAGE_QuantizationTableLuma = 0,
+    OMX_IMAGE_QuantizationTableChroma,
+    OMX_IMAGE_QuantizationTableChromaCb,
+    OMX_IMAGE_QuantizationTableChromaCr,
+    OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF
+} OMX_IMAGE_QUANTIZATIONTABLETYPE;
+
+/**
+ * JPEG quantization tables are used to determine DCT compression for
+ * YUV data, as an alternative to specifying Q factor, providing exact
+ * control of compression
+ *
+ * STRUCT MEMBERS:
+ *  nSize                   : Size of the structure in bytes
+ *  nVersion                : OMX specification version information
+ *  nPortIndex              : Port that this structure applies to
+ *  eQuantizationTable      : Quantization table type
+ *  nQuantizationMatrix[64] : JPEG quantization table of coefficients stored
+ *                            in increasing columns then by rows of data (i.e.
+ *                            row 1, ... row 8). Quantization values are in
+ *                            the range 0-255 and stored in linear order
+ *                            (i.e. the component will zig-zag the
+ *                            quantization table data if required internally)
+ */
+typedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_IMAGE_QUANTIZATIONTABLETYPE eQuantizationTable;
+    OMX_U8 nQuantizationMatrix[64];
+} OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE;
+
+
+/**
+ * Huffman table type, the same Huffman table is applied for chroma and
+ * luma component
+ */
+typedef enum OMX_IMAGE_HUFFMANTABLETYPE {
+    OMX_IMAGE_HuffmanTableAC = 0,
+    OMX_IMAGE_HuffmanTableDC,
+    OMX_IMAGE_HuffmanTableACLuma,
+    OMX_IMAGE_HuffmanTableACChroma,
+    OMX_IMAGE_HuffmanTableDCLuma,
+    OMX_IMAGE_HuffmanTableDCChroma,
+    OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF
+} OMX_IMAGE_HUFFMANTABLETYPE;
+
+/**
+ * JPEG Huffman table
+ *
+ * STRUCT MEMBERS:
+ *  nSize                            : Size of the structure in bytes
+ *  nVersion                         : OMX specification version information
+ *  nPortIndex                       : Port that this structure applies to
+ *  eHuffmanTable                    : Huffman table type
+ *  nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each
+ *                                     possible length
+ *  nHuffmanTable[256]               : 0-255, the size used for AC and DC
+ *                                     HuffmanTable are 16 and 162
+ */
+typedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_IMAGE_HUFFMANTABLETYPE eHuffmanTable;
+    OMX_U8 nNumberOfHuffmanCodeOfLength[16];
+    OMX_U8 nHuffmanTable[256];
+} OMX_IMAGE_PARAM_HUFFMANTTABLETYPE;
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */

+ 260 - 0
soft_3rdpart/omx-il/include/khronos/OMX_Index.h

@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** @file OMX_Index.h - OpenMax IL version 1.1.2
+ *  The OMX_Index header file contains the definitions for both applications
+ *  and components .
+ */
+
+
+#ifndef OMX_Index_h
+#define OMX_Index_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Each OMX header must include all required header files to allow the
+ *  header to compile without errors.  The includes below are required
+ *  for this header file to compile successfully
+ */
+#include <OMX_Types.h>
+
+
+/** The OMX_INDEXTYPE enumeration is used to select a structure when either
+ *  getting or setting parameters and/or configuration data.  Each entry in
+ *  this enumeration maps to an OMX specified structure.  When the
+ *  OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods
+ *  are used, the second parameter will always be an entry from this enumeration
+ *  and the third entry will be the structure shown in the comments for the entry.
+ *  For example, if the application is initializing a cropping function, the
+ *  OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter
+ *  and would send a pointer to an initialized OMX_RECTTYPE structure as the
+ *  third parameter.
+ *
+ *  The enumeration entries named with the OMX_Config prefix are sent using
+ *  the OMX_SetConfig command and the enumeration entries named with the
+ *  OMX_PARAM_ prefix are sent using the OMX_SetParameter command.
+ */
+typedef enum OMX_INDEXTYPE {
+
+    OMX_IndexComponentStartUnused = 0x01000000,
+    OMX_IndexParamPriorityMgmt,             /**< reference: OMX_PRIORITYMGMTTYPE */
+    OMX_IndexParamAudioInit,                /**< reference: OMX_PORT_PARAM_TYPE */
+    OMX_IndexParamImageInit,                /**< reference: OMX_PORT_PARAM_TYPE */
+    OMX_IndexParamVideoInit,                /**< reference: OMX_PORT_PARAM_TYPE */
+    OMX_IndexParamOtherInit,                /**< reference: OMX_PORT_PARAM_TYPE */
+    OMX_IndexParamNumAvailableStreams,      /**< reference: OMX_PARAM_U32TYPE */
+    OMX_IndexParamActiveStream,             /**< reference: OMX_PARAM_U32TYPE */
+    OMX_IndexParamSuspensionPolicy,         /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */
+    OMX_IndexParamComponentSuspended,       /**< reference: OMX_PARAM_SUSPENSIONTYPE */
+    OMX_IndexConfigCapturing,               /**< reference: OMX_CONFIG_BOOLEANTYPE */
+    OMX_IndexConfigCaptureMode,             /**< reference: OMX_CONFIG_CAPTUREMODETYPE */
+    OMX_IndexAutoPauseAfterCapture,         /**< reference: OMX_CONFIG_BOOLEANTYPE */
+    OMX_IndexParamContentURI,               /**< reference: OMX_PARAM_CONTENTURITYPE */
+    OMX_IndexParamCustomContentPipe,        /**< reference: OMX_PARAM_CONTENTPIPETYPE */
+    OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */
+    OMX_IndexConfigMetadataItemCount,       /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */
+    OMX_IndexConfigContainerNodeCount,      /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */
+    OMX_IndexConfigMetadataItem,            /**< reference: OMX_CONFIG_METADATAITEMTYPE */
+    OMX_IndexConfigCounterNodeID,           /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */
+    OMX_IndexParamMetadataFilterType,       /**< reference: OMX_PARAM_METADATAFILTERTYPE */
+    OMX_IndexParamMetadataKeyFilter,        /**< reference: OMX_PARAM_METADATAFILTERTYPE */
+    OMX_IndexConfigPriorityMgmt,            /**< reference: OMX_PRIORITYMGMTTYPE */
+    OMX_IndexParamStandardComponentRole,    /**< reference: OMX_PARAM_COMPONENTROLETYPE */
+
+    OMX_IndexPortStartUnused = 0x02000000,
+    OMX_IndexParamPortDefinition,           /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */
+    OMX_IndexParamCompBufferSupplier,       /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */
+    OMX_IndexReservedStartUnused = 0x03000000,
+
+    /* Audio parameters and configurations */
+    OMX_IndexAudioStartUnused = 0x04000000,
+    OMX_IndexParamAudioPortFormat,          /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */
+    OMX_IndexParamAudioPcm,                 /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */
+    OMX_IndexParamAudioAac,                 /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */
+    OMX_IndexParamAudioRa,                  /**< reference: OMX_AUDIO_PARAM_RATYPE */
+    OMX_IndexParamAudioMp3,                 /**< reference: OMX_AUDIO_PARAM_MP3TYPE */
+    OMX_IndexParamAudioAdpcm,               /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */
+    OMX_IndexParamAudioG723,                /**< reference: OMX_AUDIO_PARAM_G723TYPE */
+    OMX_IndexParamAudioG729,                /**< reference: OMX_AUDIO_PARAM_G729TYPE */
+    OMX_IndexParamAudioAmr,                 /**< reference: OMX_AUDIO_PARAM_AMRTYPE */
+    OMX_IndexParamAudioWma,                 /**< reference: OMX_AUDIO_PARAM_WMATYPE */
+    OMX_IndexParamAudioSbc,                 /**< reference: OMX_AUDIO_PARAM_SBCTYPE */
+    OMX_IndexParamAudioMidi,                /**< reference: OMX_AUDIO_PARAM_MIDITYPE */
+    OMX_IndexParamAudioGsm_FR,              /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */
+    OMX_IndexParamAudioMidiLoadUserSound,   /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */
+    OMX_IndexParamAudioG726,                /**< reference: OMX_AUDIO_PARAM_G726TYPE */
+    OMX_IndexParamAudioGsm_EFR,             /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */
+    OMX_IndexParamAudioGsm_HR,              /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */
+    OMX_IndexParamAudioPdc_FR,              /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */
+    OMX_IndexParamAudioPdc_EFR,             /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */
+    OMX_IndexParamAudioPdc_HR,              /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */
+    OMX_IndexParamAudioTdma_FR,             /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */
+    OMX_IndexParamAudioTdma_EFR,            /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */
+    OMX_IndexParamAudioQcelp8,              /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */
+    OMX_IndexParamAudioQcelp13,             /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */
+    OMX_IndexParamAudioEvrc,                /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */
+    OMX_IndexParamAudioSmv,                 /**< reference: OMX_AUDIO_PARAM_SMVTYPE */
+    OMX_IndexParamAudioVorbis,              /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */
+
+    OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */
+    OMX_IndexConfigAudioMidiControl,        /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */
+    OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */
+    OMX_IndexConfigAudioMidiStatus,         /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */
+    OMX_IndexConfigAudioMidiMetaEvent,      /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */
+    OMX_IndexConfigAudioMidiMetaEventData,  /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */
+    OMX_IndexConfigAudioVolume,             /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */
+    OMX_IndexConfigAudioBalance,            /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */
+    OMX_IndexConfigAudioChannelMute,        /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */
+    OMX_IndexConfigAudioMute,               /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */
+    OMX_IndexConfigAudioLoudness,           /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */
+    OMX_IndexConfigAudioEchoCancelation,    /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */
+    OMX_IndexConfigAudioNoiseReduction,     /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */
+    OMX_IndexConfigAudioBass,               /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */
+    OMX_IndexConfigAudioTreble,             /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */
+    OMX_IndexConfigAudioStereoWidening,     /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */
+    OMX_IndexConfigAudioChorus,             /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */
+    OMX_IndexConfigAudioEqualizer,          /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */
+    OMX_IndexConfigAudioReverberation,      /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */
+    OMX_IndexConfigAudioChannelVolume,      /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */
+
+    /* Image specific parameters and configurations */
+    OMX_IndexImageStartUnused = 0x05000000,
+    OMX_IndexParamImagePortFormat,          /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */
+    OMX_IndexParamFlashControl,             /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */
+    OMX_IndexConfigFocusControl,            /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */
+    OMX_IndexParamQFactor,                  /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */
+    OMX_IndexParamQuantizationTable,        /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */
+    OMX_IndexParamHuffmanTable,             /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */
+    OMX_IndexConfigFlashControl,            /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */
+
+    /* Video specific parameters and configurations */
+    OMX_IndexVideoStartUnused = 0x06000000,
+    OMX_IndexParamVideoPortFormat,          /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */
+    OMX_IndexParamVideoQuantization,        /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */
+    OMX_IndexParamVideoFastUpdate,          /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */
+    OMX_IndexParamVideoBitrate,             /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */
+    OMX_IndexParamVideoMotionVector,        /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */
+    OMX_IndexParamVideoIntraRefresh,        /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */
+    OMX_IndexParamVideoErrorCorrection,     /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */
+    OMX_IndexParamVideoVBSMC,               /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */
+    OMX_IndexParamVideoMpeg2,               /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */
+    OMX_IndexParamVideoMpeg4,               /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */
+    OMX_IndexParamVideoWmv,                 /**< reference: OMX_VIDEO_PARAM_WMVTYPE */
+    OMX_IndexParamVideoRv,                  /**< reference: OMX_VIDEO_PARAM_RVTYPE */
+    OMX_IndexParamVideoAvc,                 /**< reference: OMX_VIDEO_PARAM_AVCTYPE */
+    OMX_IndexParamVideoH263,                /**< reference: OMX_VIDEO_PARAM_H263TYPE */
+    OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */
+    OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */
+    OMX_IndexConfigVideoBitrate,            /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */
+    OMX_IndexConfigVideoFramerate,          /**< reference: OMX_CONFIG_FRAMERATETYPE */
+    OMX_IndexConfigVideoIntraVOPRefresh,    /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */
+    OMX_IndexConfigVideoIntraMBRefresh,     /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */
+    OMX_IndexConfigVideoMBErrorReporting,   /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */
+    OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */
+    OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */
+    OMX_IndexParamVideoSliceFMO,            /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */
+    OMX_IndexConfigVideoAVCIntraPeriod,     /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */
+    OMX_IndexConfigVideoNalSize,            /**< reference: OMX_VIDEO_CONFIG_NALSIZE */
+
+    /* Image & Video common Configurations */
+    OMX_IndexCommonStartUnused = 0x07000000,
+    OMX_IndexParamCommonDeblocking,         /**< reference: OMX_PARAM_DEBLOCKINGTYPE */
+    OMX_IndexParamCommonSensorMode,         /**< reference: OMX_PARAM_SENSORMODETYPE */
+    OMX_IndexParamCommonInterleave,         /**< reference: OMX_PARAM_INTERLEAVETYPE */
+    OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */
+    OMX_IndexConfigCommonScale,             /**< reference: OMX_CONFIG_SCALEFACTORTYPE */
+    OMX_IndexConfigCommonImageFilter,       /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */
+    OMX_IndexConfigCommonColorEnhancement,  /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */
+    OMX_IndexConfigCommonColorKey,          /**< reference: OMX_CONFIG_COLORKEYTYPE */
+    OMX_IndexConfigCommonColorBlend,        /**< reference: OMX_CONFIG_COLORBLENDTYPE */
+    OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */
+    OMX_IndexConfigCommonRotate,            /**< reference: OMX_CONFIG_ROTATIONTYPE */
+    OMX_IndexConfigCommonMirror,            /**< reference: OMX_CONFIG_MIRRORTYPE */
+    OMX_IndexConfigCommonOutputPosition,    /**< reference: OMX_CONFIG_POINTTYPE */
+    OMX_IndexConfigCommonInputCrop,         /**< reference: OMX_CONFIG_RECTTYPE */
+    OMX_IndexConfigCommonOutputCrop,        /**< reference: OMX_CONFIG_RECTTYPE */
+    OMX_IndexConfigCommonDigitalZoom,       /**< reference: OMX_CONFIG_SCALEFACTORTYPE */
+    OMX_IndexConfigCommonOpticalZoom,       /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/
+    OMX_IndexConfigCommonWhiteBalance,      /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */
+    OMX_IndexConfigCommonExposure,          /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */
+    OMX_IndexConfigCommonContrast,          /**< reference: OMX_CONFIG_CONTRASTTYPE */
+    OMX_IndexConfigCommonBrightness,        /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */
+    OMX_IndexConfigCommonBacklight,         /**< reference: OMX_CONFIG_BACKLIGHTTYPE */
+    OMX_IndexConfigCommonGamma,             /**< reference: OMX_CONFIG_GAMMATYPE */
+    OMX_IndexConfigCommonSaturation,        /**< reference: OMX_CONFIG_SATURATIONTYPE */
+    OMX_IndexConfigCommonLightness,         /**< reference: OMX_CONFIG_LIGHTNESSTYPE */
+    OMX_IndexConfigCommonExclusionRect,     /**< reference: OMX_CONFIG_RECTTYPE */
+    OMX_IndexConfigCommonDithering,         /**< reference: OMX_CONFIG_DITHERTYPE */
+    OMX_IndexConfigCommonPlaneBlend,        /**< reference: OMX_CONFIG_PLANEBLENDTYPE */
+    OMX_IndexConfigCommonExposureValue,     /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */
+    OMX_IndexConfigCommonOutputSize,        /**< reference: OMX_FRAMESIZETYPE */
+    OMX_IndexParamCommonExtraQuantData,     /**< reference: OMX_OTHER_EXTRADATATYPE */
+    OMX_IndexConfigCommonFocusRegion,       /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */
+    OMX_IndexConfigCommonFocusStatus,       /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */
+    OMX_IndexConfigCommonTransitionEffect,  /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */
+
+    /* Reserved Configuration range */
+    OMX_IndexOtherStartUnused = 0x08000000,
+    OMX_IndexParamOtherPortFormat,          /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */
+    OMX_IndexConfigOtherPower,              /**< reference: OMX_OTHER_CONFIG_POWERTYPE */
+    OMX_IndexConfigOtherStats,              /**< reference: OMX_OTHER_CONFIG_STATSTYPE */
+
+
+    /* Reserved Time range */
+    OMX_IndexTimeStartUnused = 0x09000000,
+    OMX_IndexConfigTimeScale,               /**< reference: OMX_TIME_CONFIG_SCALETYPE */
+    OMX_IndexConfigTimeClockState,          /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */
+    OMX_IndexConfigTimeActiveRefClock,      /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */
+    OMX_IndexConfigTimeCurrentMediaTime,    /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */
+    OMX_IndexConfigTimeCurrentWallTime,     /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */
+    OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
+    OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
+    OMX_IndexConfigTimeMediaTimeRequest,    /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */
+    OMX_IndexConfigTimeClientStartTime,     /**<reference:  OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
+    OMX_IndexConfigTimePosition,            /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */
+    OMX_IndexConfigTimeSeekMode,            /**< reference: OMX_TIME_CONFIG_SEEKMODETYPE */
+
+
+    OMX_IndexKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    /* Vendor specific area */
+    OMX_IndexRockchipExtensions = 0x70000000, /**< Reserved region for introducing Rockchip Standard Extensions */
+    OMX_IndexParamVideoHDRRockchipExtensions,  /**< reference: OMX_EXTENSION_VIDEO_PARAM_HDR */
+    OMX_IndexVendorStartUnused = 0x7F000000,
+    /* Vendor specific structures should be in the range of 0x7F000000
+       to 0x7FFFFFFE.  This range is not broken out by vendor, so
+       private indexes are not guaranteed unique and therefore should
+       only be sent to the appropriate component. */
+
+    OMX_IndexMax = 0x7FFFFFFF
+
+} OMX_INDEXTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */

+ 105 - 0
soft_3rdpart/omx-il/include/khronos/OMX_IndexExt.h

@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** @file OMX_IndexExt.h - OpenMax IL version 1.1.2
+ * The OMX_IndexExt header file contains extensions to the definitions
+ * for both applications and components .
+ */
+
+#ifndef OMX_IndexExt_h
+#define OMX_IndexExt_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Each OMX header shall include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully
+ */
+#include <OMX_Index.h>
+
+
+/** Khronos standard extension indices.
+
+This enum lists the current Khronos extension indices to OpenMAX IL.
+*/
+typedef enum OMX_INDEXEXTTYPE {
+
+    /* Component parameters and configurations */
+    OMX_IndexExtComponentStartUnused = OMX_IndexKhronosExtensions + 0x00100000,
+    OMX_IndexConfigCallbackRequest,                 /**< reference: OMX_CONFIG_CALLBACKREQUESTTYPE */
+    OMX_IndexConfigCommitMode,                      /**< reference: OMX_CONFIG_COMMITMODETYPE */
+    OMX_IndexConfigCommit,                          /**< reference: OMX_CONFIG_COMMITTYPE */
+
+    /* Port parameters and configurations */
+    OMX_IndexExtPortStartUnused = OMX_IndexKhronosExtensions + 0x00200000,
+
+    /* Audio parameters and configurations */
+    OMX_IndexExtAudioStartUnused = OMX_IndexKhronosExtensions + 0x00400000,
+    OMX_IndexParamAudioAndroidAc3,                  /**< reference: OMX_AUDIO_PARAM_ANDROID_AC3TYPE */
+    OMX_IndexParamAudioAndroidOpus,                 /**< reference: OMX_AUDIO_PARAM_ANDROID_OPUSTYPE */
+    OMX_IndexParamAudioAndroidAacPresentation,      /**< reference: OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE */
+    OMX_IndexParamAudioAndroidEac3,                 /**< reference: OMX_AUDIO_PARAM_ANDROID_EAC3TYPE */
+    OMX_IndexParamAudioProfileQuerySupported,       /**< reference: OMX_AUDIO_PARAM_ANDROID_PROFILETYPE */
+
+    /* Image parameters and configurations */
+    OMX_IndexExtImageStartUnused = OMX_IndexKhronosExtensions + 0x00500000,
+
+    /* Video parameters and configurations */
+    OMX_IndexExtVideoStartUnused = OMX_IndexKhronosExtensions + 0x00600000,
+    OMX_IndexParamNalStreamFormatSupported,         /**< reference: OMX_NALSTREAMFORMATTYPE */
+    OMX_IndexParamNalStreamFormat,                  /**< reference: OMX_NALSTREAMFORMATTYPE */
+    OMX_IndexParamNalStreamFormatSelect,            /**< reference: OMX_NALSTREAMFORMATTYPE */
+    OMX_IndexParamVideoVp8,                         /**< reference: OMX_VIDEO_PARAM_VP8TYPE */
+    OMX_IndexConfigVideoVp8ReferenceFrame,          /**< reference: OMX_VIDEO_VP8REFERENCEFRAMETYPE */
+    OMX_IndexConfigVideoVp8ReferenceFrameType,      /**< reference: OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE */
+    OMX_IndexParamVideoAndroidVp8Encoder,           /**< reference: OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE */
+    OMX_IndexParamVideoHevc,                        /**< reference: OMX_VIDEO_PARAM_HEVCTYPE */
+    OMX_IndexParamSliceSegments,                    /**< reference: OMX_VIDEO_SLICESEGMENTSTYPE */
+    OMX_IndexConfigAndroidIntraRefresh,             /**< reference: OMX_VIDEO_CONFIG_ANDROID_INTRAREFRESHTYPE */
+    OMX_IndexParamAndroidVideoTemporalLayering,     /**< reference: OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE */
+    OMX_IndexConfigAndroidVideoTemporalLayering,    /**< reference: OMX_VIDEO_CONFIG_ANDROID_TEMPORALLAYERINGTYPE */
+
+    /* Image & Video common configurations */
+    OMX_IndexExtCommonStartUnused = OMX_IndexKhronosExtensions + 0x00700000,
+
+    /* Other configurations */
+    OMX_IndexExtOtherStartUnused = OMX_IndexKhronosExtensions + 0x00800000,
+    OMX_IndexConfigAutoFramerateConversion,         /**< reference: OMX_CONFIG_BOOLEANTYPE */
+    OMX_IndexConfigPriority,                        /**< reference: OMX_PARAM_U32TYPE */
+    OMX_IndexConfigOperatingRate,                   /**< reference: OMX_PARAM_U32TYPE in Q16 format for video and in Hz for audio */
+    OMX_IndexParamConsumerUsageBits,                /**< reference: OMX_PARAM_U32TYPE */
+
+    /* Time configurations */
+    OMX_IndexExtTimeStartUnused = OMX_IndexKhronosExtensions + 0x00900000,
+
+    OMX_IndexExtMax = 0x7FFFFFFF
+} OMX_INDEXEXTTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* OMX_IndexExt_h */
+/* File EOF */

+ 366 - 0
soft_3rdpart/omx-il/include/khronos/OMX_Other.h

@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** @file OMX_Other.h - OpenMax IL version 1.1.2
+ *  The structures needed by Other components to exchange
+ *  parameters and configuration data with the components.
+ */
+
+#ifndef OMX_Other_h
+#define OMX_Other_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Each OMX header must include all required header files to allow the
+ *  header to compile without errors.  The includes below are required
+ *  for this header file to compile successfully
+ */
+
+#include <OMX_Core.h>
+
+
+/**
+ * Enumeration of possible data types which match to multiple domains or no
+ * domain at all.  For types which are vendor specific, a value above
+ * OMX_OTHER_VENDORTSTART should be used.
+ */
+typedef enum OMX_OTHER_FORMATTYPE {
+    OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time,
+                                   time deltas, etc */
+                           OMX_OTHER_FormatPower,    /**< Perhaps used for enabling/disabling power
+                                   management, setting clocks? */
+                           OMX_OTHER_FormatStats,    /**< Could be things such as frame rate, frames
+                                   dropped, etc */
+                           OMX_OTHER_FormatBinary,   /**< Arbitrary binary data */
+                           OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific
+                                                formats */
+
+                                                            OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+                                                            OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+                                                            OMX_OTHER_FormatMax = 0x7FFFFFFF
+} OMX_OTHER_FORMATTYPE;
+
+/**
+ * Enumeration of seek modes.
+ */
+typedef enum OMX_TIME_SEEKMODETYPE {
+    OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation
+                                * of the requested seek position over
+                                * the actual seek position if it
+                                * results in a faster seek. */
+    OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek
+                                * position over an approximation
+                                * of the requested seek position even
+                                * if it results in a slower seek. */
+    OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_TIME_SeekModeMax = 0x7FFFFFFF
+} OMX_TIME_SEEKMODETYPE;
+
+/* Structure representing the seekmode of the component */
+typedef struct OMX_TIME_CONFIG_SEEKMODETYPE {
+    OMX_U32 nSize;                  /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
+    OMX_TIME_SEEKMODETYPE eType;    /**< The seek mode */
+} OMX_TIME_CONFIG_SEEKMODETYPE;
+
+/**
+ * colorspace 
+ */
+typedef enum OMX_ROCKCHIP_EXT_COLORSPACE {
+    OMX_RK_EXT_ColorspaceBT709 = 1,
+    OMX_RK_EXT_ColorspaceBT2020,
+    OMX_RK_EXT_ColorspaceMax = 0x7FFFFFFF
+} OMX_RK_EXT_COLORSPACE;
+
+/**
+ * dynamic range
+ */
+typedef enum OMX_ROCKCHIP_EXT_DYNCRANGE {
+    OMX_RK_EXT_DyncrangeSDR = 0,
+    OMX_RK_EXT_DyncrangeHDR10,
+    OMX_RK_EXT_DyncrangeHDRHLG,
+    OMX_RK_EXT_DyncrangeHDRDOLBY,
+    OMX_RK_EXT_DyncrangeMax = 0x7FFFFFFF
+} OMX_RK_EXT_DYNCRANGE;
+
+
+/* Structure Rockchip extension HDR param of the component */
+ typedef struct OMX_EXTENSION_VIDEO_PARAM_HDR {
+    OMX_U32 nSize;                  /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
+    OMX_RK_EXT_COLORSPACE eColorSpace;    /**< Color space */
+    OMX_RK_EXT_DYNCRANGE eDyncRange;    /**< dynamic range */
+} OMX_EXTENSION_VIDEO_PARAM_HDR;
+
+/** Structure representing a time stamp used with the following configs
+ * on the Clock Component (CC):
+ *
+ * OMX_IndexConfigTimeCurrentWallTime: query of the CC’s current wall
+ *     time
+ * OMX_IndexConfigTimeCurrentMediaTime: query of the CC’s current media
+ *     time
+ * OMX_IndexConfigTimeCurrentAudioReference and
+ * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference
+ *     clock sending SC its reference time
+ * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends
+ *     this structure to the Clock Component via a SetConfig on its
+ *     client port when it receives a buffer with
+ *     OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp
+ *     specified by that buffer for nStartTimestamp.
+ *
+ * It’s also used with the following config on components in general:
+ *
+ * OMX_IndexConfigTimePosition: IL client querying component position
+ * (GetConfig) or commanding a component to seek to the given location
+ * (SetConfig)
+ */
+typedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE {
+    OMX_U32 nSize;               /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;    /**< OMX specification version
+                                  *   information */
+    OMX_U32 nPortIndex;     /**< port that this structure applies to */
+    OMX_TICKS nTimestamp;        /**< timestamp .*/
+} OMX_TIME_CONFIG_TIMESTAMPTYPE;
+
+/** Enumeration of possible reference clocks to the media time. */
+typedef enum OMX_TIME_UPDATETYPE {
+    OMX_TIME_UpdateRequestFulfillment,    /**< Update is the fulfillment of a media time request. */
+    OMX_TIME_UpdateScaleChanged,          /**< Update was generated because the scale chagned. */
+    OMX_TIME_UpdateClockStateChanged,     /**< Update was generated because the clock state changed. */
+    OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_TIME_UpdateMax = 0x7FFFFFFF
+} OMX_TIME_UPDATETYPE;
+
+/** Enumeration of possible reference clocks to the media time. */
+typedef enum OMX_TIME_REFCLOCKTYPE {
+    OMX_TIME_RefClockNone,    /**< Use no references. */
+    OMX_TIME_RefClockAudio,   /**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */
+    OMX_TIME_RefClockVideo,   /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */
+    OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_TIME_RefClockMax = 0x7FFFFFFF
+} OMX_TIME_REFCLOCKTYPE;
+
+/** Enumeration of clock states. */
+typedef enum OMX_TIME_CLOCKSTATE {
+    OMX_TIME_ClockStateRunning,             /**< Clock running. */
+    OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the
+                                               *   prescribed clients emit their
+                                               *   start time. */
+    OMX_TIME_ClockStateStopped,             /**< Clock stopped. */
+    OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_TIME_ClockStateMax = 0x7FFFFFFF
+} OMX_TIME_CLOCKSTATE;
+
+/** Structure representing a media time request to the clock component.
+ *
+ *  A client component sends this structure to the Clock Component via a SetConfig
+ *  on its client port to specify a media timestamp the Clock Component
+ *  should emit.  The Clock Component should fulfill the request by sending a
+ *  OMX_TIME_MEDIATIMETYPE when its media clock matches the requested
+ *  timestamp.
+ *
+ *  The client may require a media time request be fulfilled slightly
+ *  earlier than the media time specified. In this case the client specifies
+ *  an offset which is equal to the difference between wall time corresponding
+ *  to the requested media time and the wall time when it will be
+ *  fulfilled.
+ *
+ *  A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to
+ *  time events according to timestamps. If a client must perform an operation O at
+ *  a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a
+ *  media time request at T (perhaps specifying an offset to ensure the request fulfillment
+ *  is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE
+ *  structure back to the client component, the client may perform operation O (perhaps having
+ *  to wait a slight amount more time itself as specified by the return values).
+ */
+
+typedef struct OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< port that this structure applies to */
+    OMX_PTR pClientPrivate;     /**< Client private data to disabiguate this media time
+                                 *   from others (e.g. the number of the frame to deliver).
+                                 *   Duplicated in the media time structure that fulfills
+                                 *   this request. A value of zero is reserved for time scale
+                                 *   updates. */
+    OMX_TICKS nMediaTimestamp;  /**< Media timestamp requested.*/
+    OMX_TICKS nOffset;          /**< Amount of wall clock time by which this
+                                 *   request should be fulfilled early */
+} OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE;
+
+/**< Structure sent from the clock component client either when fulfilling
+ *   a media time request or when the time scale has changed.
+ *
+ *   In the former case the Clock Component fills this structure and times its emission
+ *   to a client component (via the client port) according to the corresponding media
+ *   time request sent by the client. The Clock Component should time the emission to occur
+ *   when the requested timestamp matches the Clock Component's media time but also the
+ *   prescribed offset early.
+ *
+ *   Upon scale changes the clock component clears the nClientPrivate data, sends the current
+ *   media time and sets the nScale to the new scale via the client port. It emits a
+ *   OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to
+ *   alter processing to accomodate scaling. For instance a video component might skip inter-frames
+ *   in the case of extreme fastforward. Likewise an audio component might add or remove samples
+ *   from an audio frame to scale audio data.
+ *
+ *   It is expected that some clock components may not be able to fulfill requests
+ *   at exactly the prescribed time. This is acceptable so long as the request is
+ *   fulfilled at least as early as described and not later. This structure provides
+ *   fields the client may use to wait for the remaining time.
+ *
+ *   The client may use either the nOffset or nWallTimeAtMedia fields to determine the
+ *   wall time until the nMediaTimestamp actually occurs. In the latter case the
+ *   client can get a more accurate value for offset by getting the current wall
+ *   from the cloc component and subtracting it from nWallTimeAtMedia.
+ */
+
+typedef struct OMX_TIME_MEDIATIMETYPE {
+    OMX_U32 nSize;                  /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
+    OMX_U32 nClientPrivate;         /**< Client private data to disabiguate this media time
+                                     *   from others. Copied from the media time request.
+                                     *   A value of zero is reserved for time scale updates. */
+    OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */
+    OMX_TICKS nMediaTimestamp;      /**< Media time requested. If no media time was
+                                     *   requested then this is the current media time. */
+    OMX_TICKS nOffset;              /**< Amount of wall clock time by which this
+                                     *   request was actually fulfilled early */
+
+    OMX_TICKS nWallTimeAtMediaTime; /**< Wall time corresponding to nMediaTimeStamp.
+                                     *   A client may compare this value to current
+                                     *   media time obtained from the Clock Component to determine
+                                     *   the wall time until the media timestamp is really
+                                     *   current. */
+    OMX_S32 xScale;                 /**< Current media time scale in Q16 format. */
+    OMX_TIME_CLOCKSTATE eState;     /* Seeking Change. Added 7/12.*/
+    /**< State of the media time. */
+} OMX_TIME_MEDIATIMETYPE;
+
+/** Structure representing the current media time scale factor. Applicable only to clock
+ *  component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via
+ *  the clock component client ports. Upon recieving this config the clock component changes
+ *  the rate by which the media time increases or decreases effectively implementing trick modes.
+ */
+typedef struct OMX_TIME_CONFIG_SCALETYPE {
+    OMX_U32 nSize;                  /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
+    OMX_S32 xScale;                 /**< This is a value in Q16 format which is used for
+                                     * scaling the media time */
+} OMX_TIME_CONFIG_SCALETYPE;
+
+/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPE’s nWaitMask field */
+#define OMX_CLOCKPORT0 0x00000001
+#define OMX_CLOCKPORT1 0x00000002
+#define OMX_CLOCKPORT2 0x00000004
+#define OMX_CLOCKPORT3 0x00000008
+#define OMX_CLOCKPORT4 0x00000010
+#define OMX_CLOCKPORT5 0x00000020
+#define OMX_CLOCKPORT6 0x00000040
+#define OMX_CLOCKPORT7 0x00000080
+
+/** Structure representing the current mode of the media clock.
+ *  IL Client uses this config to change or query the mode of the
+ *  media clock of the clock component. Applicable only to clock
+ *  component.
+ *
+ *  On a SetConfig if eState is OMX_TIME_ClockStateRunning media time
+ *  starts immediately at the prescribed start time. If
+ *  OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores
+ *  the given nStartTime and waits for all clients specified in the
+ *  nWaitMask to send starttimes (via
+ *  OMX_IndexConfigTimeClientStartTime). The Clock Component then starts
+ *  the media clock using the earliest start time supplied. */
+typedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version
+                                 *   information */
+    OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */
+    OMX_TICKS nStartTime;       /**< Start time of the media time. */
+    OMX_TICKS nOffset;          /**< Time to offset the media time by
+                                 * (e.g. preroll). Media time will be
+                                 * reported to be nOffset ticks earlier.
+                                 */
+    OMX_U32 nWaitMask;          /**< Mask of OMX_CLOCKPORT values. */
+} OMX_TIME_CONFIG_CLOCKSTATETYPE;
+
+/** Structure representing the reference clock currently being used to
+ *  compute media time. IL client uses this config to change or query the
+ *  clock component's active reference clock */
+typedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE {
+    OMX_U32 nSize;                  /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
+    OMX_TIME_REFCLOCKTYPE eClock;   /**< Reference clock used to compute media time */
+} OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE;
+
+/** Descriptor for setting specifics of power type.
+ *  Note: this structure is listed for backwards compatibility. */
+typedef struct OMX_OTHER_CONFIG_POWERTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_BOOL bEnablePM;       /**< Flag to enable Power Management */
+} OMX_OTHER_CONFIG_POWERTYPE;
+
+
+/** Descriptor for setting specifics of stats type.
+ *  Note: this structure is listed for backwards compatibility. */
+typedef struct OMX_OTHER_CONFIG_STATSTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    /* what goes here */
+} OMX_OTHER_CONFIG_STATSTYPE;
+
+
+/**
+ * The PortDefinition structure is used to define all of the parameters
+ * necessary for the compliant component to setup an input or an output other
+ * path.
+ */
+typedef struct OMX_OTHER_PORTDEFINITIONTYPE {
+    OMX_OTHER_FORMATTYPE eFormat;  /**< Type of data expected for this channel */
+} OMX_OTHER_PORTDEFINITIONTYPE;
+
+/**  Port format parameter.  This structure is used to enumerate
+  *  the various data input/output format supported by the port.
+  */
+typedef struct OMX_OTHER_PARAM_PORTFORMATTYPE {
+    OMX_U32 nSize; /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex; /**< Indicates which port to set */
+    OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */
+    OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */
+} OMX_OTHER_PARAM_PORTFORMATTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */

+ 352 - 0
soft_3rdpart/omx-il/include/khronos/OMX_Types.h

@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_Types.h - OpenMax IL version 1.1.2
+ *  The OMX_Types header file contains the primitive type definitions used by
+ *  the core, the application and the component.  This file may need to be
+ *  modified to be used on systems that do not have "char" set to 8 bits,
+ *  "short" set to 16 bits and "long" set to 32 bits.
+ */
+
+#ifndef OMX_Types_h
+#define OMX_Types_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** The OMX_API and OMX_APIENTRY are platform specific definitions used
+ *  to declare OMX function prototypes.  They are modified to meet the
+ *  requirements for a particular platform */
+#ifdef __SYMBIAN32__
+#   ifdef __OMX_EXPORTS
+#       define OMX_API __declspec(dllexport)
+#   else
+#       ifdef _WIN32
+#           define OMX_API __declspec(dllexport)
+#       else
+#           define OMX_API __declspec(dllimport)
+#       endif
+#   endif
+#else
+#   ifdef _WIN32
+#      ifdef __OMX_EXPORTS
+#          define OMX_API __declspec(dllexport)
+#      else
+#          define OMX_API __declspec(dllimport)
+#      endif
+#   else
+#      ifdef __OMX_EXPORTS
+#          define OMX_API
+#      else
+#          define OMX_API extern
+#      endif
+#   endif
+#endif
+
+#ifndef OMX_APIENTRY
+#define OMX_APIENTRY
+#endif
+
+/** OMX_IN is used to identify inputs to an OMX function.  This designation
+    will also be used in the case of a pointer that points to a parameter
+    that is used as an output. */
+#ifndef OMX_IN
+#define OMX_IN
+#endif
+
+/** OMX_OUT is used to identify outputs from an OMX function.  This
+    designation will also be used in the case of a pointer that points
+    to a parameter that is used as an input. */
+#ifndef OMX_OUT
+#define OMX_OUT
+#endif
+
+
+/** OMX_INOUT is used to identify parameters that may be either inputs or
+    outputs from an OMX function at the same time.  This designation will
+    also be used in the case of a pointer that  points to a parameter that
+    is used both as an input and an output. */
+#ifndef OMX_INOUT
+#define OMX_INOUT
+#endif
+
+/** OMX_ALL is used to as a wildcard to select all entities of the same type
+ *  when specifying the index, or referring to a object by an index.  (i.e.
+ *  use OMX_ALL to indicate all N channels). When used as a port index
+ *  for a config or parameter this OMX_ALL denotes that the config or
+ *  parameter applies to the entire component not just one port. */
+#define OMX_ALL 0xFFFFFFFF
+
+/** In the following we define groups that help building doxygen documentation */
+
+/** @defgroup core OpenMAX IL core
+ * Functions and structure related to the OMX IL core
+ */
+
+/** @defgroup comp OpenMAX IL component
+* Functions and structure related to the OMX IL component
+*/
+
+/** @defgroup rpm Resource and Policy Management
+ * Structures for resource and policy management of components
+ */
+
+/** @defgroup buf Buffer Management
+ * Buffer handling functions and structures
+ */
+
+/** @defgroup tun Tunneling
+ * @ingroup core comp
+ * Structures and functions to manage tunnels among component ports
+ */
+
+/** @defgroup cp Content Pipes
+ *  @ingroup core
+ */
+
+/** @defgroup metadata Metadata handling
+ *
+ */
+
+/** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */
+typedef unsigned char OMX_U8;
+
+/** OMX_S8 is an 8 bit signed quantity that is byte aligned */
+typedef signed char OMX_S8;
+
+/** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */
+typedef unsigned short OMX_U16;
+
+/** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */
+typedef signed short OMX_S16;
+
+/** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */
+typedef unsigned long OMX_U32;
+
+/** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */
+typedef signed long OMX_S32;
+
+
+/* Users with compilers that cannot accept the "long long" designation should
+   define the OMX_SKIP64BIT macro.  It should be noted that this may cause
+   some components to fail to compile if the component was written to require
+   64 bit integral types.  However, these components would NOT compile anyway
+   since the compiler does not support the way the component was written.
+*/
+#ifndef OMX_SKIP64BIT
+#ifdef __SYMBIAN32__
+/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
+typedef unsigned long long OMX_U64;
+
+/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
+typedef signed long long OMX_S64;
+
+#elif defined(WIN32)
+
+/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
+typedef unsigned __int64  OMX_U64;
+
+/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
+typedef signed   __int64  OMX_S64;
+
+#else /* WIN32 */
+
+/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
+typedef unsigned long long OMX_U64;
+
+/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
+typedef signed long long OMX_S64;
+
+#endif /* WIN32 */
+#endif
+
+
+/** The OMX_BOOL type is intended to be used to represent a true or a false
+    value when passing parameters to and from the OMX core and components.  The
+    OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary.
+ */
+typedef enum OMX_BOOL {
+    OMX_FALSE = 0,
+    OMX_TRUE = !OMX_FALSE,
+    OMX_BOOL_MAX = 0x7FFFFFFF
+} OMX_BOOL;
+
+/** The OMX_PTR type is intended to be used to pass pointers between the OMX
+    applications and the OMX Core and components.  This is a 32 bit pointer and
+    is aligned on a 32 bit boundary.
+ */
+typedef void* OMX_PTR;
+
+/** The OMX_STRING type is intended to be used to pass "C" type strings between
+    the application and the core and component.  The OMX_STRING type is a 32
+    bit pointer to a zero terminated string.  The  pointer is word aligned and
+    the string is byte aligned.
+ */
+typedef char* OMX_STRING;
+
+/** The OMX_BYTE type is intended to be used to pass arrays of bytes such as
+    buffers between the application and the component and core.  The OMX_BYTE
+    type is a 32 bit pointer to a zero terminated string.  The  pointer is word
+    aligned and the string is byte aligned.
+ */
+typedef unsigned char* OMX_BYTE;
+
+/** OMX_UUIDTYPE is a very long unique identifier to uniquely identify
+    at runtime.  This identifier should be generated by a component in a way
+    that guarantees that every instance of the identifier running on the system
+    is unique. */
+typedef unsigned char OMX_UUIDTYPE[128];
+
+/** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or
+    an output port.  This enumeration is common across all component types.
+ */
+typedef enum OMX_DIRTYPE {
+    OMX_DirInput,              /**< Port is an input port */
+    OMX_DirOutput,             /**< Port is an output port */
+    OMX_DirMax = 0x7FFFFFFF
+} OMX_DIRTYPE;
+
+/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering
+    for numerical data (i.e. big endian, or little endian).
+ */
+typedef enum OMX_ENDIANTYPE {
+    OMX_EndianBig, /**< big endian */
+    OMX_EndianLittle, /**< little endian */
+    OMX_EndianMax = 0x7FFFFFFF
+} OMX_ENDIANTYPE;
+
+
+/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data
+    is signed or unsigned
+ */
+typedef enum OMX_NUMERICALDATATYPE {
+    OMX_NumericalDataSigned, /**< signed data */
+    OMX_NumericalDataUnsigned, /**< unsigned data */
+    OMX_NumercialDataMax = 0x7FFFFFFF
+} OMX_NUMERICALDATATYPE;
+
+
+/** Unsigned bounded value type */
+typedef struct OMX_BU32 {
+    OMX_U32 nValue; /**< actual value */
+    OMX_U32 nMin;   /**< minimum for value (i.e. nValue >= nMin) */
+    OMX_U32 nMax;   /**< maximum for value (i.e. nValue <= nMax) */
+} OMX_BU32;
+
+
+/** Signed bounded value type */
+typedef struct OMX_BS32 {
+    OMX_S32 nValue; /**< actual value */
+    OMX_S32 nMin;   /**< minimum for value (i.e. nValue >= nMin) */
+    OMX_S32 nMax;   /**< maximum for value (i.e. nValue <= nMax) */
+} OMX_BS32;
+
+
+/** Structure representing some time or duration in microseconds. This structure
+  *  must be interpreted as a signed 64 bit value. The quantity is signed to accommodate
+  *  negative deltas and preroll scenarios. The quantity is represented in microseconds
+  *  to accomodate high resolution timestamps (e.g. DVD presentation timestamps based
+  *  on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g.
+  *  individual audio samples delivered at 192 kHz). The quantity is 64 bit to
+  *  accommodate a large dynamic range (signed 32 bit values would allow only for plus
+  *  or minus 35 minutes).
+  *
+  *  Implementations with limited precision may convert the signed 64 bit value to
+  *  a signed 32 bit value internally but risk loss of precision.
+  */
+#ifndef OMX_SKIP64BIT
+typedef OMX_S64 OMX_TICKS;
+#else
+typedef struct OMX_TICKS {
+    OMX_U32 nLowPart;    /** low bits of the signed 64 bit tick value */
+    OMX_U32 nHighPart;   /** high bits of the signed 64 bit tick value */
+} OMX_TICKS;
+#endif
+#define OMX_TICKS_PER_SECOND 1000000
+
+/** Define the public interface for the OMX Handle.  The core will not use
+    this value internally, but the application should only use this value.
+ */
+typedef void* OMX_HANDLETYPE;
+
+typedef struct OMX_MARKTYPE {
+    OMX_HANDLETYPE hMarkTargetComponent;   /**< The component that will
+                                                generate a mark event upon
+                                                processing the mark. */
+    OMX_PTR pMarkData;   /**< Application specific data associated with
+                              the mark sent on a mark event to disambiguate
+                              this mark from others. */
+} OMX_MARKTYPE;
+
+
+/** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the
+ *  platform & operating specific object used to reference the display
+ *  or can be used by a audio port for native audio rendering */
+typedef void* OMX_NATIVE_DEVICETYPE;
+
+/** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the
+ *  platform & operating specific object used to reference the window */
+typedef void* OMX_NATIVE_WINDOWTYPE;
+
+
+/** Define the OMX IL version that corresponds to this set of header files.
+ *  We also define a combined version that can be used to write or compare
+ *  values of the 32bit nVersion field, assuming a little endian architecture */
+#define OMX_VERSION_MAJOR 1
+#define OMX_VERSION_MINOR 1
+#define OMX_VERSION_REVISION 2
+#define OMX_VERSION_STEP 0
+
+#define OMX_VERSION ((OMX_VERSION_STEP<<24) | (OMX_VERSION_REVISION<<16) | (OMX_VERSION_MINOR<<8) | OMX_VERSION_MAJOR)
+
+
+/** The OMX_VERSIONTYPE union is used to specify the version for
+    a structure or component.  For a component, the version is entirely
+    specified by the component vendor.  Components doing the same function
+    from different vendors may or may not have the same version.  For
+    structures, the version shall be set by the entity that allocates the
+    structure.  For structures specified in the OMX 1.1 specification, the
+    value of the version shall be set to 1.1.0.0 in all cases.  Access to the
+    OMX_VERSIONTYPE can be by a single 32 bit access (e.g. by nVersion) or
+    by accessing one of the structure elements to, for example, check only
+    the Major revision.
+ */
+typedef union OMX_VERSIONTYPE {
+    struct {
+        OMX_U8 nVersionMajor;   /**< Major version accessor element */
+        OMX_U8 nVersionMinor;   /**< Minor version accessor element */
+        OMX_U8 nRevision;       /**< Revision version accessor element */
+        OMX_U8 nStep;           /**< Step version accessor element */
+    } s;
+    OMX_U32 nVersion;           /**< 32 bit value to make accessing the
+                                    version easily done in a single word
+                                    size copy/compare operation */
+} OMX_VERSIONTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */

+ 1141 - 0
soft_3rdpart/omx-il/include/khronos/OMX_Video.h

@@ -0,0 +1,1141 @@
+/**
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ *  @file OMX_Video.h - OpenMax IL version 1.1.2
+ *  The structures is needed by Video components to exchange parameters
+ *  and configuration data with OMX components.
+ */
+#ifndef OMX_Video_h
+#define OMX_Video_h
+
+/** @defgroup video OpenMAX IL Video Domain
+ * @ingroup iv
+ * Structures for OpenMAX IL Video domain
+ * @{
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/**
+ * Each OMX header must include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully
+ */
+
+#include <OMX_IVCommon.h>
+
+
+/**
+ * Enumeration used to define the possible video compression codings.
+ * NOTE:  This essentially refers to file extensions. If the coding is
+ *        being used to specify the ENCODE type, then additional work
+ *        must be done to configure the exact flavor of the compression
+ *        to be used.  For decode cases where the user application can
+ *        not differentiate between MPEG-4 and H.264 bit streams, it is
+ *        up to the codec to handle this.
+ */
+typedef enum OMX_VIDEO_CODINGTYPE {
+    OMX_VIDEO_CodingUnused,     /**< Value when coding is N/A */
+    OMX_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */
+    OMX_VIDEO_CodingMPEG2,      /**< AKA: H.262 */
+    OMX_VIDEO_CodingH263,       /**< H.263 */
+    OMX_VIDEO_CodingMPEG4,      /**< MPEG-4 */
+    OMX_VIDEO_CodingWMV,        /**< all versions of Windows Media Video */
+    OMX_VIDEO_CodingRV,         /**< all versions of Real Video */
+    OMX_VIDEO_CodingAVC,        /**< H.264/AVC */
+    OMX_VIDEO_CodingMJPEG,      /**< Motion JPEG */
+    OMX_VIDEO_CodingVP8,        /**< Google VP8, formerly known as On2 VP8 */
+    OMX_VIDEO_CodingVP9,        /**< Google VP9 */
+    OMX_VIDEO_CodingHEVC,       /**< ITU H.265/HEVC */
+    OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_CodingMax = 0x7FFFFFFF
+} OMX_VIDEO_CODINGTYPE;
+
+
+/**
+ * Data structure used to define a video path.  The number of Video paths for
+ * input and output will vary by type of the Video component.
+ *
+ *    Input (aka Source) : zero Inputs, one Output,
+ *    Splitter           : one Input, 2 or more Outputs,
+ *    Processing Element : one Input, one output,
+ *    Mixer              : 2 or more inputs, one output,
+ *    Output (aka Sink)  : one Input, zero outputs.
+ *
+ * The PortDefinition structure is used to define all of the parameters
+ * necessary for the compliant component to setup an input or an output video
+ * path.  If additional vendor specific data is required, it should be
+ * transmitted to the component using the CustomCommand function.  Compliant
+ * components will prepopulate this structure with optimal values during the
+ * GetDefaultInitParams command.
+ *
+ * STRUCT MEMBERS:
+ *  cMIMEType             : MIME type of data for the port
+ *  pNativeRender         : Platform specific reference for a display if a
+ *                          sync, otherwise this field is 0
+ *  nFrameWidth           : Width of frame to be used on channel if
+ *                          uncompressed format is used.  Use 0 for unknown,
+ *                          don't care or variable
+ *  nFrameHeight          : Height of frame to be used on channel if
+ *                          uncompressed format is used. Use 0 for unknown,
+ *                          don't care or variable
+ *  nStride               : Number of bytes per span of an image
+ *                          (i.e. indicates the number of bytes to get
+ *                          from span N to span N+1, where negative stride
+ *                          indicates the image is bottom up
+ *  nSliceHeight          : Height used when encoding in slices
+ *  nBitrate              : Bit rate of frame to be used on channel if
+ *                          compressed format is used. Use 0 for unknown,
+ *                          don't care or variable
+ *  xFramerate            : Frame rate to be used on channel if uncompressed
+ *                          format is used. Use 0 for unknown, don't care or
+ *                          variable.  Units are Q16 frames per second.
+ *  bFlagErrorConcealment : Turns on error concealment if it is supported by
+ *                          the OMX component
+ *  eCompressionFormat    : Compression format used in this instance of the
+ *                          component. When OMX_VIDEO_CodingUnused is
+ *                          specified, eColorFormat is used
+ *  eColorFormat : Decompressed format used by this component
+ *  pNativeWindow : Platform specific reference for a window object if a
+ *                          display sink , otherwise this field is 0x0.
+ */
+typedef struct OMX_VIDEO_PORTDEFINITIONTYPE {
+    OMX_STRING cMIMEType;
+    OMX_NATIVE_DEVICETYPE pNativeRender;
+    OMX_U32 nFrameWidth;
+    OMX_U32 nFrameHeight;
+    OMX_S32 nStride;
+    OMX_U32 nSliceHeight;
+    OMX_U32 nBitrate;
+    OMX_U32 xFramerate;
+    OMX_BOOL bFlagErrorConcealment;
+    OMX_VIDEO_CODINGTYPE eCompressionFormat;
+    OMX_COLOR_FORMATTYPE eColorFormat;
+    OMX_NATIVE_WINDOWTYPE pNativeWindow;
+} OMX_VIDEO_PORTDEFINITIONTYPE;
+
+/**
+ * Port format parameter.  This structure is used to enumerate the various
+ * data input/output format supported by the port.
+ *
+ * STRUCT MEMBERS:
+ *  nSize              : Size of the structure in bytes
+ *  nVersion           : OMX specification version information
+ *  nPortIndex         : Indicates which port to set
+ *  nIndex             : Indicates the enumeration index for the format from
+ *                       0x0 to N-1
+ *  eCompressionFormat : Compression format used in this instance of the
+ *                       component. When OMX_VIDEO_CodingUnused is specified,
+ *                       eColorFormat is used
+ *  eColorFormat       : Decompressed format used by this component
+ *  xFrameRate         : Indicates the video frame rate in Q16 format
+ */
+typedef struct OMX_VIDEO_PARAM_PORTFORMATTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nIndex;
+    OMX_VIDEO_CODINGTYPE eCompressionFormat;
+    OMX_COLOR_FORMATTYPE eColorFormat;
+    OMX_U32 xFramerate;
+} OMX_VIDEO_PARAM_PORTFORMATTYPE;
+
+
+/**
+ * This is a structure for configuring video compression quantization
+ * parameter values.  Codecs may support different QP values for different
+ * frame types.
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version info
+ *  nPortIndex : Port that this structure applies to
+ *  nQpI       : QP value to use for index frames
+ *  nQpP       : QP value to use for P frames
+ *  nQpB       : QP values to use for bidirectional frames
+ */
+typedef struct OMX_VIDEO_PARAM_QUANTIZATIONTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nQpI;
+    OMX_U32 nQpP;
+    OMX_U32 nQpB;
+} OMX_VIDEO_PARAM_QUANTIZATIONTYPE;
+
+
+/**
+ * Structure for configuration of video fast update parameters.
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version info
+ *  nPortIndex : Port that this structure applies to
+ *  bEnableVFU : Enable/Disable video fast update
+ *  nFirstGOB  : Specifies the number of the first macroblock row
+ *  nFirstMB   : specifies the first MB relative to the specified first GOB
+ *  nNumMBs    : Specifies the number of MBs to be refreshed from nFirstGOB
+ *               and nFirstMB
+ */
+typedef struct OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bEnableVFU;
+    OMX_U32 nFirstGOB;
+    OMX_U32 nFirstMB;
+    OMX_U32 nNumMBs;
+} OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE;
+
+
+/**
+ * Enumeration of possible bitrate control types
+ */
+typedef enum OMX_VIDEO_CONTROLRATETYPE {
+    OMX_Video_ControlRateDisable,
+    OMX_Video_ControlRateVariable,
+    OMX_Video_ControlRateConstant,
+    OMX_Video_ControlRateVariableSkipFrames,
+    OMX_Video_ControlRateConstantSkipFrames,
+    OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_Video_ControlRateMax = 0x7FFFFFFF
+} OMX_VIDEO_CONTROLRATETYPE;
+
+
+/**
+ * Structure for configuring bitrate mode of a codec.
+ *
+ * STRUCT MEMBERS:
+ *  nSize          : Size of the struct in bytes
+ *  nVersion       : OMX spec version info
+ *  nPortIndex     : Port that this struct applies to
+ *  eControlRate   : Control rate type enum
+ *  nTargetBitrate : Target bitrate to encode with
+ */
+typedef struct OMX_VIDEO_PARAM_BITRATETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_CONTROLRATETYPE eControlRate;
+    OMX_U32 nTargetBitrate;
+} OMX_VIDEO_PARAM_BITRATETYPE;
+
+
+/**
+ * Enumeration of possible motion vector (MV) types
+ */
+typedef enum OMX_VIDEO_MOTIONVECTORTYPE {
+    OMX_Video_MotionVectorPixel,
+    OMX_Video_MotionVectorHalfPel,
+    OMX_Video_MotionVectorQuarterPel,
+    OMX_Video_MotionVectorEighthPel,
+    OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_Video_MotionVectorMax = 0x7FFFFFFF
+} OMX_VIDEO_MOTIONVECTORTYPE;
+
+
+/**
+ * Structure for configuring the number of motion vectors used as well
+ * as their accuracy.
+ *
+ * STRUCT MEMBERS:
+ *  nSize            : Size of the struct in bytes
+ *  nVersion         : OMX spec version info
+ *  nPortIndex       : port that this structure applies to
+ *  eAccuracy        : Enumerated MV accuracy
+ *  bUnrestrictedMVs : Allow unrestricted MVs
+ *  bFourMV          : Allow use of 4 MVs
+ *  sXSearchRange    : Search range in horizontal direction for MVs
+ *  sYSearchRange    : Search range in vertical direction for MVs
+ */
+typedef struct OMX_VIDEO_PARAM_MOTIONVECTORTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_MOTIONVECTORTYPE eAccuracy;
+    OMX_BOOL bUnrestrictedMVs;
+    OMX_BOOL bFourMV;
+    OMX_S32 sXSearchRange;
+    OMX_S32 sYSearchRange;
+} OMX_VIDEO_PARAM_MOTIONVECTORTYPE;
+
+
+/**
+ * Enumeration of possible methods to use for Intra Refresh
+ */
+typedef enum OMX_VIDEO_INTRAREFRESHTYPE {
+    OMX_VIDEO_IntraRefreshCyclic,
+    OMX_VIDEO_IntraRefreshAdaptive,
+    OMX_VIDEO_IntraRefreshBoth,
+    OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF
+} OMX_VIDEO_INTRAREFRESHTYPE;
+
+
+/**
+ * Structure for configuring intra refresh mode
+ *
+ * STRUCT MEMBERS:
+ *  nSize        : Size of the structure in bytes
+ *  nVersion     : OMX specification version information
+ *  nPortIndex   : Port that this structure applies to
+ *  eRefreshMode : Cyclic, Adaptive, or Both
+ *  nAirMBs      : Number of intra macroblocks to refresh in a frame when
+ *                 AIR is enabled
+ *  nAirRef      : Number of times a motion marked macroblock has to be
+ *                 intra coded
+ *  nCirMBs      : Number of consecutive macroblocks to be coded as "intra"
+ *                 when CIR is enabled
+ */
+typedef struct OMX_VIDEO_PARAM_INTRAREFRESHTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_INTRAREFRESHTYPE eRefreshMode;
+    OMX_U32 nAirMBs;
+    OMX_U32 nAirRef;
+    OMX_U32 nCirMBs;
+} OMX_VIDEO_PARAM_INTRAREFRESHTYPE;
+
+
+/**
+ * Structure for enabling various error correction methods for video
+ * compression.
+ *
+ * STRUCT MEMBERS:
+ *  nSize                   : Size of the structure in bytes
+ *  nVersion                : OMX specification version information
+ *  nPortIndex              : Port that this structure applies to
+ *  bEnableHEC              : Enable/disable header extension codes (HEC)
+ *  bEnableResync           : Enable/disable resynchronization markers
+ *  nResynchMarkerSpacing   : Resynch markers interval (in bits) to be
+ *                            applied in the stream
+ *  bEnableDataPartitioning : Enable/disable data partitioning
+ *  bEnableRVLC             : Enable/disable reversible variable length
+ *                            coding
+ */
+typedef struct OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bEnableHEC;
+    OMX_BOOL bEnableResync;
+    OMX_U32  nResynchMarkerSpacing;
+    OMX_BOOL bEnableDataPartitioning;
+    OMX_BOOL bEnableRVLC;
+} OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE;
+
+
+/**
+ * Configuration of variable block-size motion compensation (VBSMC)
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  b16x16     : Enable inter block search 16x16
+ *  b16x8      : Enable inter block search 16x8
+ *  b8x16      : Enable inter block search 8x16
+ *  b8x8       : Enable inter block search 8x8
+ *  b8x4       : Enable inter block search 8x4
+ *  b4x8       : Enable inter block search 4x8
+ *  b4x4       : Enable inter block search 4x4
+ */
+typedef struct OMX_VIDEO_PARAM_VBSMCTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL b16x16;
+    OMX_BOOL b16x8;
+    OMX_BOOL b8x16;
+    OMX_BOOL b8x8;
+    OMX_BOOL b8x4;
+    OMX_BOOL b4x8;
+    OMX_BOOL b4x4;
+} OMX_VIDEO_PARAM_VBSMCTYPE;
+
+
+/**
+ * H.263 profile types, each profile indicates support for various
+ * performance bounds and different annexes.
+ *
+ * ENUMS:
+ *  Baseline           : Baseline Profile: H.263 (V1), no optional modes
+ *  H320 Coding        : H.320 Coding Efficiency Backward Compatibility
+ *                       Profile: H.263+ (V2), includes annexes I, J, L.4
+ *                       and T
+ *  BackwardCompatible : Backward Compatibility Profile: H.263 (V1),
+ *                       includes annex F
+ *  ISWV2              : Interactive Streaming Wireless Profile: H.263+
+ *                       (V2), includes annexes I, J, K and T
+ *  ISWV3              : Interactive Streaming Wireless Profile: H.263++
+ *                       (V3), includes profile 3 and annexes V and W.6.3.8
+ *  HighCompression    : Conversational High Compression Profile: H.263++
+ *                       (V3), includes profiles 1 & 2 and annexes D and U
+ *  Internet           : Conversational Internet Profile: H.263++ (V3),
+ *                       includes profile 5 and annex K
+ *  Interlace          : Conversational Interlace Profile: H.263++ (V3),
+ *                       includes profile 5 and annex W.6.3.11
+ *  HighLatency        : High Latency Profile: H.263++ (V3), includes
+ *                       profile 6 and annexes O.1 and P.5
+ */
+typedef enum OMX_VIDEO_H263PROFILETYPE {
+    OMX_VIDEO_H263ProfileBaseline            = 0x01,
+    OMX_VIDEO_H263ProfileH320Coding          = 0x02,
+    OMX_VIDEO_H263ProfileBackwardCompatible  = 0x04,
+    OMX_VIDEO_H263ProfileISWV2               = 0x08,
+    OMX_VIDEO_H263ProfileISWV3               = 0x10,
+    OMX_VIDEO_H263ProfileHighCompression     = 0x20,
+    OMX_VIDEO_H263ProfileInternet            = 0x40,
+    OMX_VIDEO_H263ProfileInterlace           = 0x80,
+    OMX_VIDEO_H263ProfileHighLatency         = 0x100,
+    OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_H263ProfileMax                 = 0x7FFFFFFF
+} OMX_VIDEO_H263PROFILETYPE;
+
+
+/**
+ * H.263 level types, each level indicates support for various frame sizes,
+ * bit rates, decoder frame rates.
+ */
+typedef enum OMX_VIDEO_H263LEVELTYPE {
+    OMX_VIDEO_H263Level10  = 0x01,
+    OMX_VIDEO_H263Level20  = 0x02,
+    OMX_VIDEO_H263Level30  = 0x04,
+    OMX_VIDEO_H263Level40  = 0x08,
+    OMX_VIDEO_H263Level45  = 0x10,
+    OMX_VIDEO_H263Level50  = 0x20,
+    OMX_VIDEO_H263Level60  = 0x40,
+    OMX_VIDEO_H263Level70  = 0x80,
+    OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_H263LevelMax = 0x7FFFFFFF
+} OMX_VIDEO_H263LEVELTYPE;
+
+
+/**
+ * Specifies the picture type. These values should be OR'd to signal all
+ * pictures types which are allowed.
+ *
+ * ENUMS:
+ *  Generic Picture Types:          I, P and B
+ *  H.263 Specific Picture Types:   SI and SP
+ *  H.264 Specific Picture Types:   EI and EP
+ *  MPEG-4 Specific Picture Types:  S
+ */
+typedef enum OMX_VIDEO_PICTURETYPE {
+    OMX_VIDEO_PictureTypeI   = 0x01,
+    OMX_VIDEO_PictureTypeP   = 0x02,
+    OMX_VIDEO_PictureTypeB   = 0x04,
+    OMX_VIDEO_PictureTypeSI  = 0x08,
+    OMX_VIDEO_PictureTypeSP  = 0x10,
+    OMX_VIDEO_PictureTypeEI  = 0x11,
+    OMX_VIDEO_PictureTypeEP  = 0x12,
+    OMX_VIDEO_PictureTypeS   = 0x14,
+    OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF
+} OMX_VIDEO_PICTURETYPE;
+
+
+/**
+ * H.263 Params
+ *
+ * STRUCT MEMBERS:
+ *  nSize                    : Size of the structure in bytes
+ *  nVersion                 : OMX specification version information
+ *  nPortIndex               : Port that this structure applies to
+ *  nPFrames                 : Number of P frames between each I frame
+ *  nBFrames                 : Number of B frames between each I frame
+ *  eProfile                 : H.263 profile(s) to use
+ *  eLevel                   : H.263 level(s) to use
+ *  bPLUSPTYPEAllowed        : Indicating that it is allowed to use PLUSPTYPE
+ *                             (specified in the 1998 version of H.263) to
+ *                             indicate custom picture sizes or clock
+ *                             frequencies
+ *  nAllowedPictureTypes     : Specifies the picture types allowed in the
+ *                             bitstream
+ *  bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is
+ *                             not constrained. It is recommended to change
+ *                             the value of the RTYPE bit for each reference
+ *                             picture in error-free communication
+ *  nPictureHeaderRepetition : Specifies the frequency of picture header
+ *                             repetition
+ *  nGOBHeaderInterval       : Specifies the interval of non-empty GOB
+ *                             headers in units of GOBs
+ */
+typedef struct OMX_VIDEO_PARAM_H263TYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nPFrames;
+    OMX_U32 nBFrames;
+    OMX_VIDEO_H263PROFILETYPE eProfile;
+    OMX_VIDEO_H263LEVELTYPE eLevel;
+    OMX_BOOL bPLUSPTYPEAllowed;
+    OMX_U32 nAllowedPictureTypes;
+    OMX_BOOL bForceRoundingTypeToZero;
+    OMX_U32 nPictureHeaderRepetition;
+    OMX_U32 nGOBHeaderInterval;
+} OMX_VIDEO_PARAM_H263TYPE;
+
+
+/**
+ * MPEG-2 profile types, each profile indicates support for various
+ * performance bounds and different annexes.
+ */
+typedef enum OMX_VIDEO_MPEG2PROFILETYPE {
+    OMX_VIDEO_MPEG2ProfileSimple = 0,  /**< Simple Profile */
+    OMX_VIDEO_MPEG2ProfileMain,        /**< Main Profile */
+    OMX_VIDEO_MPEG2Profile422,         /**< 4:2:2 Profile */
+    OMX_VIDEO_MPEG2ProfileSNR,         /**< SNR Profile */
+    OMX_VIDEO_MPEG2ProfileSpatial,     /**< Spatial Profile */
+    OMX_VIDEO_MPEG2ProfileHigh,        /**< High Profile */
+    OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF
+} OMX_VIDEO_MPEG2PROFILETYPE;
+
+
+/**
+ * MPEG-2 level types, each level indicates support for various frame
+ * sizes, bit rates, decoder frame rates.  No need
+ */
+typedef enum OMX_VIDEO_MPEG2LEVELTYPE {
+    OMX_VIDEO_MPEG2LevelLL = 0,  /**< Low Level */
+    OMX_VIDEO_MPEG2LevelML,      /**< Main Level */
+    OMX_VIDEO_MPEG2LevelH14,     /**< High 1440 */
+    OMX_VIDEO_MPEG2LevelHL,      /**< High Level */
+    OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF
+} OMX_VIDEO_MPEG2LEVELTYPE;
+
+
+/**
+ * MPEG-2 params
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nPFrames   : Number of P frames between each I frame
+ *  nBFrames   : Number of B frames between each I frame
+ *  eProfile   : MPEG-2 profile(s) to use
+ *  eLevel     : MPEG-2 levels(s) to use
+ */
+typedef struct OMX_VIDEO_PARAM_MPEG2TYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nPFrames;
+    OMX_U32 nBFrames;
+    OMX_VIDEO_MPEG2PROFILETYPE eProfile;
+    OMX_VIDEO_MPEG2LEVELTYPE eLevel;
+} OMX_VIDEO_PARAM_MPEG2TYPE;
+
+
+/**
+ * MPEG-4 profile types, each profile indicates support for various
+ * performance bounds and different annexes.
+ *
+ * ENUMS:
+ *  - Simple Profile, Levels 1-3
+ *  - Simple Scalable Profile, Levels 1-2
+ *  - Core Profile, Levels 1-2
+ *  - Main Profile, Levels 2-4
+ *  - N-bit Profile, Level 2
+ *  - Scalable Texture Profile, Level 1
+ *  - Simple Face Animation Profile, Levels 1-2
+ *  - Simple Face and Body Animation (FBA) Profile, Levels 1-2
+ *  - Basic Animated Texture Profile, Levels 1-2
+ *  - Hybrid Profile, Levels 1-2
+ *  - Advanced Real Time Simple Profiles, Levels 1-4
+ *  - Core Scalable Profile, Levels 1-3
+ *  - Advanced Coding Efficiency Profile, Levels 1-4
+ *  - Advanced Core Profile, Levels 1-2
+ *  - Advanced Scalable Texture, Levels 2-3
+ */
+typedef enum OMX_VIDEO_MPEG4PROFILETYPE {
+    OMX_VIDEO_MPEG4ProfileSimple           = 0x01,
+    OMX_VIDEO_MPEG4ProfileSimpleScalable   = 0x02,
+    OMX_VIDEO_MPEG4ProfileCore             = 0x04,
+    OMX_VIDEO_MPEG4ProfileMain             = 0x08,
+    OMX_VIDEO_MPEG4ProfileNbit             = 0x10,
+    OMX_VIDEO_MPEG4ProfileScalableTexture  = 0x20,
+    OMX_VIDEO_MPEG4ProfileSimpleFace       = 0x40,
+    OMX_VIDEO_MPEG4ProfileSimpleFBA        = 0x80,
+    OMX_VIDEO_MPEG4ProfileBasicAnimated    = 0x100,
+    OMX_VIDEO_MPEG4ProfileHybrid           = 0x200,
+    OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400,
+    OMX_VIDEO_MPEG4ProfileCoreScalable     = 0x800,
+    OMX_VIDEO_MPEG4ProfileAdvancedCoding   = 0x1000,
+    OMX_VIDEO_MPEG4ProfileAdvancedCore     = 0x2000,
+    OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000,
+    OMX_VIDEO_MPEG4ProfileAdvancedSimple   = 0x8000,
+    OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_MPEG4ProfileMax              = 0x7FFFFFFF
+} OMX_VIDEO_MPEG4PROFILETYPE;
+
+
+/**
+ * MPEG-4 level types, each level indicates support for various frame
+ * sizes, bit rates, decoder frame rates.  No need
+ */
+typedef enum OMX_VIDEO_MPEG4LEVELTYPE {
+    OMX_VIDEO_MPEG4Level0  = 0x01,   /**< Level 0 */
+    OMX_VIDEO_MPEG4Level0b = 0x02,   /**< Level 0b */
+    OMX_VIDEO_MPEG4Level1  = 0x04,   /**< Level 1 */
+    OMX_VIDEO_MPEG4Level2  = 0x08,   /**< Level 2 */
+    OMX_VIDEO_MPEG4Level3  = 0x10,   /**< Level 3 */
+    OMX_VIDEO_MPEG4Level4  = 0x20,   /**< Level 4 */
+    OMX_VIDEO_MPEG4Level4a = 0x40,   /**< Level 4a */
+    OMX_VIDEO_MPEG4Level5  = 0x80,   /**< Level 5 */
+    OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF
+} OMX_VIDEO_MPEG4LEVELTYPE;
+
+
+/**
+ * MPEG-4 configuration.  This structure handles configuration options
+ * which are specific to MPEG4 algorithms
+ *
+ * STRUCT MEMBERS:
+ *  nSize                : Size of the structure in bytes
+ *  nVersion             : OMX specification version information
+ *  nPortIndex           : Port that this structure applies to
+ *  nSliceHeaderSpacing  : Number of macroblocks between slice header (H263+
+ *                         Annex K). Put zero if not used
+ *  bSVH                 : Enable Short Video Header mode
+ *  bGov                 : Flag to enable GOV
+ *  nPFrames             : Number of P frames between each I frame (also called
+ *                         GOV period)
+ *  nBFrames             : Number of B frames between each I frame
+ *  nIDCVLCThreshold     : Value of intra DC VLC threshold
+ *  bACPred              : Flag to use ac prediction
+ *  nMaxPacketSize       : Maximum size of packet in bytes.
+ *  nTimeIncRes          : Used to pass VOP time increment resolution for MPEG4.
+ *                         Interpreted as described in MPEG4 standard.
+ *  eProfile             : MPEG-4 profile(s) to use.
+ *  eLevel               : MPEG-4 level(s) to use.
+ *  nAllowedPictureTypes : Specifies the picture types allowed in the bitstream
+ *  nHeaderExtension     : Specifies the number of consecutive video packet
+ *                         headers within a VOP
+ *  bReversibleVLC       : Specifies whether reversible variable length coding
+ *                         is in use
+ */
+typedef struct OMX_VIDEO_PARAM_MPEG4TYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nSliceHeaderSpacing;
+    OMX_BOOL bSVH;
+    OMX_BOOL bGov;
+    OMX_U32 nPFrames;
+    OMX_U32 nBFrames;
+    OMX_U32 nIDCVLCThreshold;
+    OMX_BOOL bACPred;
+    OMX_U32 nMaxPacketSize;
+    OMX_U32 nTimeIncRes;
+    OMX_VIDEO_MPEG4PROFILETYPE eProfile;
+    OMX_VIDEO_MPEG4LEVELTYPE eLevel;
+    OMX_U32 nAllowedPictureTypes;
+    OMX_U32 nHeaderExtension;
+    OMX_BOOL bReversibleVLC;
+} OMX_VIDEO_PARAM_MPEG4TYPE;
+
+
+/**
+ * WMV Versions
+ */
+typedef enum OMX_VIDEO_WMVFORMATTYPE {
+    OMX_VIDEO_WMVFormatUnused = 0x01,   /**< Format unused or unknown */
+    OMX_VIDEO_WMVFormat7      = 0x02,   /**< Windows Media Video format 7 */
+    OMX_VIDEO_WMVFormat8      = 0x04,   /**< Windows Media Video format 8 */
+    OMX_VIDEO_WMVFormat9      = 0x08,   /**< Windows Media Video format 9 */
+    OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_WMVFormatMax    = 0x7FFFFFFF
+} OMX_VIDEO_WMVFORMATTYPE;
+
+
+/**
+ * WMV Params
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  eFormat    : Version of WMV stream / data
+ */
+typedef struct OMX_VIDEO_PARAM_WMVTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_WMVFORMATTYPE eFormat;
+} OMX_VIDEO_PARAM_WMVTYPE;
+
+
+/**
+ * Real Video Version
+ */
+typedef enum OMX_VIDEO_RVFORMATTYPE {
+    OMX_VIDEO_RVFormatUnused = 0, /**< Format unused or unknown */
+    OMX_VIDEO_RVFormat8,          /**< Real Video format 8 */
+    OMX_VIDEO_RVFormat9,          /**< Real Video format 9 */
+    OMX_VIDEO_RVFormatG2,         /**< Real Video Format G2 */
+    OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_RVFormatMax = 0x7FFFFFFF
+} OMX_VIDEO_RVFORMATTYPE;
+
+
+/**
+ * Real Video Params
+ *
+ * STUCT MEMBERS:
+ *  nSize              : Size of the structure in bytes
+ *  nVersion           : OMX specification version information
+ *  nPortIndex         : Port that this structure applies to
+ *  eFormat            : Version of RV stream / data
+ *  nBitsPerPixel      : Bits per pixel coded in the frame
+ *  nPaddedWidth       : Padded width in pixel of a video frame
+ *  nPaddedHeight      : Padded Height in pixels of a video frame
+ *  nFrameRate         : Rate of video in frames per second
+ *  nBitstreamFlags    : Flags which internal information about the bitstream
+ *  nBitstreamVersion  : Bitstream version
+ *  nMaxEncodeFrameSize: Max encoded frame size
+ *  bEnablePostFilter  : Turn on/off post filter
+ *  bEnableTemporalInterpolation : Turn on/off temporal interpolation
+ *  bEnableLatencyMode : When enabled, the decoder does not display a decoded
+ *                       frame until it has detected that no enhancement layer
+ *                       frames or dependent B frames will be coming. This
+ *                       detection usually occurs when a subsequent non-B
+ *                       frame is encountered
+ */
+typedef struct OMX_VIDEO_PARAM_RVTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_RVFORMATTYPE eFormat;
+    OMX_U16 nBitsPerPixel;
+    OMX_U16 nPaddedWidth;
+    OMX_U16 nPaddedHeight;
+    OMX_U32 nFrameRate;
+    OMX_U32 nBitstreamFlags;
+    OMX_U32 nBitstreamVersion;
+    OMX_U32 nMaxEncodeFrameSize;
+    OMX_BOOL bEnablePostFilter;
+    OMX_BOOL bEnableTemporalInterpolation;
+    OMX_BOOL bEnableLatencyMode;
+} OMX_VIDEO_PARAM_RVTYPE;
+
+
+/**
+ * AVC profile types, each profile indicates support for various
+ * performance bounds and different annexes.
+ */
+typedef enum OMX_VIDEO_AVCPROFILETYPE {
+    OMX_VIDEO_AVCProfileBaseline = 0x01,   /**< Baseline profile */
+    OMX_VIDEO_AVCProfileMain     = 0x02,   /**< Main profile */
+    OMX_VIDEO_AVCProfileExtended = 0x04,   /**< Extended profile */
+    OMX_VIDEO_AVCProfileHigh     = 0x08,   /**< High profile */
+    OMX_VIDEO_AVCProfileHigh10   = 0x10,   /**< High 10 profile */
+    OMX_VIDEO_AVCProfileHigh422  = 0x20,   /**< High 4:2:2 profile */
+    OMX_VIDEO_AVCProfileHigh444  = 0x40,   /**< High 4:4:4 profile */
+    OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_AVCProfileMax      = 0x7FFFFFFF
+} OMX_VIDEO_AVCPROFILETYPE;
+
+
+/**
+ * AVC level types, each level indicates support for various frame sizes,
+ * bit rates, decoder frame rates.  No need
+ */
+typedef enum OMX_VIDEO_AVCLEVELTYPE {
+    OMX_VIDEO_AVCLevel1   = 0x01,     /**< Level 1 */
+    OMX_VIDEO_AVCLevel1b  = 0x02,     /**< Level 1b */
+    OMX_VIDEO_AVCLevel11  = 0x04,     /**< Level 1.1 */
+    OMX_VIDEO_AVCLevel12  = 0x08,     /**< Level 1.2 */
+    OMX_VIDEO_AVCLevel13  = 0x10,     /**< Level 1.3 */
+    OMX_VIDEO_AVCLevel2   = 0x20,     /**< Level 2 */
+    OMX_VIDEO_AVCLevel21  = 0x40,     /**< Level 2.1 */
+    OMX_VIDEO_AVCLevel22  = 0x80,     /**< Level 2.2 */
+    OMX_VIDEO_AVCLevel3   = 0x100,    /**< Level 3 */
+    OMX_VIDEO_AVCLevel31  = 0x200,    /**< Level 3.1 */
+    OMX_VIDEO_AVCLevel32  = 0x400,    /**< Level 3.2 */
+    OMX_VIDEO_AVCLevel4   = 0x800,    /**< Level 4 */
+    OMX_VIDEO_AVCLevel41  = 0x1000,   /**< Level 4.1 */
+    OMX_VIDEO_AVCLevel42  = 0x2000,   /**< Level 4.2 */
+    OMX_VIDEO_AVCLevel5   = 0x4000,   /**< Level 5 */
+    OMX_VIDEO_AVCLevel51  = 0x8000,   /**< Level 5.1 */
+    OMX_VIDEO_AVCLevel52  = 0x10000,  /**< Level 5.2 */
+    OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF
+} OMX_VIDEO_AVCLEVELTYPE;
+
+
+/**
+ * AVC loop filter modes
+ *
+ * OMX_VIDEO_AVCLoopFilterEnable               : Enable
+ * OMX_VIDEO_AVCLoopFilterDisable              : Disable
+ * OMX_VIDEO_AVCLoopFilterDisableSliceBoundary : Disabled on slice boundaries
+ */
+typedef enum OMX_VIDEO_AVCLOOPFILTERTYPE {
+    OMX_VIDEO_AVCLoopFilterEnable = 0,
+    OMX_VIDEO_AVCLoopFilterDisable,
+    OMX_VIDEO_AVCLoopFilterDisableSliceBoundary,
+    OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF
+} OMX_VIDEO_AVCLOOPFILTERTYPE;
+
+
+/**
+ * AVC params
+ *
+ * STRUCT MEMBERS:
+ *  nSize                     : Size of the structure in bytes
+ *  nVersion                  : OMX specification version information
+ *  nPortIndex                : Port that this structure applies to
+ *  nSliceHeaderSpacing       : Number of macroblocks between slice header, put
+ *                              zero if not used
+ *  nPFrames                  : Number of P frames between each I frame
+ *  nBFrames                  : Number of B frames between each I frame
+ *  bUseHadamard              : Enable/disable Hadamard transform
+ *  nRefFrames                : Max number of reference frames to use for inter
+ *                              motion search (1-16)
+ *  nRefIdxTrailing           : Pic param set ref frame index (index into ref
+ *                              frame buffer of trailing frames list), B frame
+ *                              support
+ *  nRefIdxForward            : Pic param set ref frame index (index into ref
+ *                              frame buffer of forward frames list), B frame
+ *                              support
+ *  bEnableUEP                : Enable/disable unequal error protection. This
+ *                              is only valid of data partitioning is enabled.
+ *  bEnableFMO                : Enable/disable flexible macroblock ordering
+ *  bEnableASO                : Enable/disable arbitrary slice ordering
+ *  bEnableRS                 : Enable/disable sending of redundant slices
+ *  eProfile                  : AVC profile(s) to use
+ *  eLevel                    : AVC level(s) to use
+ *  nAllowedPictureTypes      : Specifies the picture types allowed in the
+ *                              bitstream
+ *  bFrameMBsOnly             : specifies that every coded picture of the
+ *                              coded video sequence is a coded frame
+ *                              containing only frame macroblocks
+ *  bMBAFF                    : Enable/disable switching between frame and
+ *                              field macroblocks within a picture
+ *  bEntropyCodingCABAC       : Entropy decoding method to be applied for the
+ *                              syntax elements for which two descriptors appear
+ *                              in the syntax tables
+ *  bWeightedPPrediction      : Enable/disable weighted prediction shall not
+ *                              be applied to P and SP slices
+ *  nWeightedBipredicitonMode : Default weighted prediction is applied to B
+ *                              slices
+ *  bconstIpred               : Enable/disable intra prediction
+ *  bDirect8x8Inference       : Specifies the method used in the derivation
+ *                              process for luma motion vectors for B_Skip,
+ *                              B_Direct_16x16 and B_Direct_8x8 as specified
+ *                              in subclause 8.4.1.2 of the AVC spec
+ *  bDirectSpatialTemporal    : Flag indicating spatial or temporal direct
+ *                              mode used in B slice coding (related to
+ *                              bDirect8x8Inference) . Spatial direct mode is
+ *                              more common and should be the default.
+ *  nCabacInitIdx             : Index used to init CABAC contexts
+ *  eLoopFilterMode           : Enable/disable loop filter
+ */
+typedef struct OMX_VIDEO_PARAM_AVCTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nSliceHeaderSpacing;
+    OMX_U32 nPFrames;
+    OMX_U32 nBFrames;
+    OMX_BOOL bUseHadamard;
+    OMX_U32 nRefFrames;
+    OMX_U32 nRefIdx10ActiveMinus1;
+    OMX_U32 nRefIdx11ActiveMinus1;
+    OMX_BOOL bEnableUEP;
+    OMX_BOOL bEnableFMO;
+    OMX_BOOL bEnableASO;
+    OMX_BOOL bEnableRS;
+    OMX_VIDEO_AVCPROFILETYPE eProfile;
+    OMX_VIDEO_AVCLEVELTYPE eLevel;
+    OMX_U32 nAllowedPictureTypes;
+    OMX_BOOL bFrameMBsOnly;
+    OMX_BOOL bMBAFF;
+    OMX_BOOL bEntropyCodingCABAC;
+    OMX_BOOL bWeightedPPrediction;
+    OMX_U32 nWeightedBipredicitonMode;
+    OMX_BOOL bconstIpred ;
+    OMX_BOOL bDirect8x8Inference;
+    OMX_BOOL bDirectSpatialTemporal;
+    OMX_U32 nCabacInitIdc;
+    OMX_VIDEO_AVCLOOPFILTERTYPE eLoopFilterMode;
+} OMX_VIDEO_PARAM_AVCTYPE;
+
+typedef struct OMX_VIDEO_PARAM_PROFILELEVELTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 eProfile;      /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE,
+                                 or OMX_VIDEO_MPEG4PROFILETYPE depending on context */
+    OMX_U32 eLevel;        /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE,
+                                 or OMX_VIDEO_MPEG4PROFILETYPE depending on context */
+    OMX_U32 nProfileIndex; /**< Used to query for individual profile support information,
+                               This parameter is valid only for
+                               OMX_IndexParamVideoProfileLevelQuerySupported index,
+                               For all other indices this parameter is to be ignored. */
+} OMX_VIDEO_PARAM_PROFILELEVELTYPE;
+
+/**
+ * Structure for dynamically configuring bitrate mode of a codec.
+ *
+ * STRUCT MEMBERS:
+ *  nSize          : Size of the struct in bytes
+ *  nVersion       : OMX spec version info
+ *  nPortIndex     : Port that this struct applies to
+ *  nEncodeBitrate : Target average bitrate to be generated in bps
+ */
+typedef struct OMX_VIDEO_CONFIG_BITRATETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nEncodeBitrate;
+} OMX_VIDEO_CONFIG_BITRATETYPE;
+
+/**
+ * Defines Encoder Frame Rate setting
+ *
+ * STRUCT MEMBERS:
+ *  nSize            : Size of the structure in bytes
+ *  nVersion         : OMX specification version information
+ *  nPortIndex       : Port that this structure applies to
+ *  xEncodeFramerate : Encoding framerate represented in Q16 format
+ */
+typedef struct OMX_CONFIG_FRAMERATETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 xEncodeFramerate; /* Q16 format */
+} OMX_CONFIG_FRAMERATETYPE;
+
+typedef struct OMX_CONFIG_INTRAREFRESHVOPTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL IntraRefreshVOP;
+} OMX_CONFIG_INTRAREFRESHVOPTYPE;
+
+typedef struct OMX_CONFIG_MACROBLOCKERRORMAPTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nErrMapSize;           /* Size of the Error Map in bytes */
+    OMX_U8  ErrMap[1];             /* Error map hint */
+} OMX_CONFIG_MACROBLOCKERRORMAPTYPE;
+
+typedef struct OMX_CONFIG_MBERRORREPORTINGTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bEnabled;
+} OMX_CONFIG_MBERRORREPORTINGTYPE;
+
+typedef struct OMX_PARAM_MACROBLOCKSTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nMacroblocks;
+} OMX_PARAM_MACROBLOCKSTYPE;
+
+
+#ifdef AVS80
+/**
+ * Aspects of color.
+ */
+
+// NOTE: this structure is expected to grow in the future if new color aspects are
+// added to codec bitstreams. OMX component should not require a specific nSize
+// though could verify that nSize is at least the size of the structure at the
+// time of implementation. All new fields will be added at the end of the structure
+// ensuring backward compatibility.
+
+typedef enum OMX_RANGE {
+    RangeUnspecified,
+    RangeFull,
+    RangeLimited,
+    RangeOther = 0xff,
+} OMX_RANGE;
+
+typedef enum OMX_PRIMARIES {
+    PrimariesUnspecified,
+    PrimariesBT709_5,		// Rec.ITU-R BT.709-5 or equivalent
+    PrimariesBT470_6M,		// Rec.ITU-R BT.470-6 System M or equivalent
+    PrimariesBT601_6_625,	// Rec.ITU-R BT.601-6 625 or equivalent
+    PrimariesBT601_6_525,	// Rec.ITU-R BT.601-6 525 or equivalent
+    PrimariesGenericFilm,	// Generic Film
+    PrimariesBT2020,		// Rec.ITU-R BT.2020 or equivalent
+    PrimariesOther = 0xff,
+} OMX_PRIMARIES;
+
+typedef enum OMX_TRANSFER {
+    TransferUnspecified,
+    TransferLinear, 		// Linear transfer characteristics
+    TransferSRGB,			// sRGB or equivalent
+    TransferSMPTE170M,		// SMPTE 170M or equivalent (e.g. BT.601/709/2020)
+    TransferGamma22,		// Assumed display gamma 2.2
+    TransferGamma28,		// Assumed display gamma 2.8
+    TransferST2084, 		// SMPTE ST 2084 for 10/12/14/16 bit systems
+    TransferHLG,			// ARIB STD-B67 hybrid-log-gamma
+    // transfers unlikely to be required by Android
+    TransferSMPTE240M = 0x40, // SMPTE 240M
+    TransferXvYCC,			// IEC 61966-2-4
+    TransferBT1361, 		// Rec.ITU-R BT.1361 extended gamut
+    TransferST428,			// SMPTE ST 428-1
+    TransferOther = 0xff,
+} OMX_TRANSFER;
+
+typedef enum OMX_MATRIXCOEFFS {
+    MatrixUnspecified,
+    MatrixBT709_5,			// Rec.ITU-R BT.709-5 or equivalent
+    MatrixBT470_6M, 		// KR=0.30, KB=0.11 or equivalent
+    MatrixBT601_6,			// Rec.ITU-R BT.601-6 625 or equivalent
+    MatrixSMPTE240M,		// SMPTE 240M or equivalent
+    MatrixBT2020,			// Rec.ITU-R BT.2020 non-constant luminance
+    MatrixBT2020Constant,	// Rec.ITU-R BT.2020 constant luminance
+    MatrixOther = 0xff,
+} OMX_MATRIXCOEFFS;
+
+typedef struct OMX_COLORASPECTS {
+    OMX_RANGE mRange;                // IN/OUT
+    OMX_PRIMARIES mPrimaries;        // IN/OUT
+    OMX_TRANSFER mTransfer;          // IN/OUT
+    OMX_MATRIXCOEFFS mMatrixCoeffs;  // IN/OUT
+} OMX_COLORASPECTS;
+
+typedef struct OMX_CONFIG_DESCRIBECOLORASPECTSPARAMS {
+    OMX_U32  nSize;                // IN
+    OMX_VERSIONTYPE nVersion;      // IN
+    OMX_U32  nPortIndex;           // IN
+    OMX_BOOL bRequestingDataSpace; // IN
+    OMX_BOOL bDataSpaceChanged;    // IN
+    OMX_U32  nPixelFormat;         // IN
+    OMX_U32  nDataSpace;           // OUT
+    OMX_COLORASPECTS sAspects;  // IN/OUT
+} OMX_CONFIG_DESCRIBECOLORASPECTSPARAMS;
+#endif
+
+/**
+ * AVC Slice Mode modes
+ *
+ * OMX_VIDEO_SLICEMODE_AVCDefault   : Normal frame encoding, one slice per frame
+ * OMX_VIDEO_SLICEMODE_AVCMBSlice   : NAL mode, number of MBs per frame
+ * OMX_VIDEO_SLICEMODE_AVCByteSlice : NAL mode, number of bytes per frame
+ */
+typedef enum OMX_VIDEO_AVCSLICEMODETYPE {
+    OMX_VIDEO_SLICEMODE_AVCDefault = 0,
+    OMX_VIDEO_SLICEMODE_AVCMBSlice,
+    OMX_VIDEO_SLICEMODE_AVCByteSlice,
+    OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF
+} OMX_VIDEO_AVCSLICEMODETYPE;
+
+/**
+ * AVC FMO Slice Mode Params
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nNumSliceGroups : Specifies the number of slice groups
+ *  nSliceGroupMapType : Specifies the type of slice groups
+ *  eSliceMode : Specifies the type of slice
+ */
+typedef struct OMX_VIDEO_PARAM_AVCSLICEFMO {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U8 nNumSliceGroups;
+    OMX_U8 nSliceGroupMapType;
+    OMX_VIDEO_AVCSLICEMODETYPE eSliceMode;
+} OMX_VIDEO_PARAM_AVCSLICEFMO;
+
+/**
+ * AVC IDR Period Configs
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nIDRPeriod : Specifies periodicity of IDR frames
+ *  nPFrames : Specifies internal of coding Intra frames
+ */
+typedef struct OMX_VIDEO_CONFIG_AVCINTRAPERIOD {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nIDRPeriod;
+    OMX_U32 nPFrames;
+} OMX_VIDEO_CONFIG_AVCINTRAPERIOD;
+
+/**
+ * AVC NAL Size Configs
+ *
+ * STRUCT MEMBERS:
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nNaluBytes : Specifies the NAL unit size
+ */
+typedef struct OMX_VIDEO_CONFIG_NALSIZE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nNaluBytes;
+} OMX_VIDEO_CONFIG_NALSIZE;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */
+

+ 401 - 0
soft_3rdpart/omx-il/include/khronos/OMX_VideoExt.h

@@ -0,0 +1,401 @@
+/*
+ * Copyright (c) 2010 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_VideoExt.h - OpenMax IL version 1.1.2
+ * The OMX_VideoExt header file contains extensions to the
+ * definitions used by both the application and the component to
+ * access video items.
+ */
+
+#ifndef OMX_VideoExt_h
+#define OMX_VideoExt_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Each OMX header shall include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully
+ */
+#include <OMX_Core.h>
+
+/** NALU Formats */
+typedef enum OMX_NALUFORMATSTYPE {
+    OMX_NaluFormatStartCodes = 1,
+    OMX_NaluFormatOneNaluPerBuffer = 2,
+    OMX_NaluFormatOneByteInterleaveLength = 4,
+    OMX_NaluFormatTwoByteInterleaveLength = 8,
+    OMX_NaluFormatFourByteInterleaveLength = 16,
+    OMX_NaluFormatCodingMax = 0x7FFFFFFF
+} OMX_NALUFORMATSTYPE;
+
+/** NAL Stream Format */
+typedef struct OMX_NALSTREAMFORMATTYPE{
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_NALUFORMATSTYPE eNaluFormat;
+} OMX_NALSTREAMFORMATTYPE;
+
+/** VP8 profiles */
+typedef enum OMX_VIDEO_VP8PROFILETYPE {
+    OMX_VIDEO_VP8ProfileMain = 0x01,
+    OMX_VIDEO_VP8ProfileUnknown = 0x6EFFFFFF,
+    OMX_VIDEO_VP8ProfileMax = 0x7FFFFFFF
+} OMX_VIDEO_VP8PROFILETYPE;
+
+/** VP8 levels */
+typedef enum OMX_VIDEO_VP8LEVELTYPE {
+    OMX_VIDEO_VP8Level_Version0 = 0x01,
+    OMX_VIDEO_VP8Level_Version1 = 0x02,
+    OMX_VIDEO_VP8Level_Version2 = 0x04,
+    OMX_VIDEO_VP8Level_Version3 = 0x08,
+    OMX_VIDEO_VP8LevelUnknown = 0x6EFFFFFF,
+    OMX_VIDEO_VP8LevelMax = 0x7FFFFFFF
+} OMX_VIDEO_VP8LEVELTYPE;
+
+/** VP9 profiles */
+typedef enum OMX_VIDEO_VP9PROFILETYPE {
+    OMX_VIDEO_VP9Profile0       = 0x1,
+    OMX_VIDEO_VP9Profile1       = 0x2,
+    OMX_VIDEO_VP9Profile2       = 0x4,
+    OMX_VIDEO_VP9Profile3       = 0x8,
+    // HDR profiles also support passing HDR metadata
+    OMX_VIDEO_VP9Profile2HDR    = 0x1000,
+    OMX_VIDEO_VP9Profile3HDR    = 0x2000,
+    OMX_VIDEO_VP9ProfileUnknown = 0x6EFFFFFF,
+    OMX_VIDEO_VP9ProfileMax     = 0x7FFFFFFF
+} OMX_VIDEO_VP9PROFILETYPE;
+
+/** VP9 levels */
+typedef enum OMX_VIDEO_VP9LEVELTYPE {
+    OMX_VIDEO_VP9Level1       = 0x1,
+    OMX_VIDEO_VP9Level11      = 0x2,
+    OMX_VIDEO_VP9Level2       = 0x4,
+    OMX_VIDEO_VP9Level21      = 0x8,
+    OMX_VIDEO_VP9Level3       = 0x10,
+    OMX_VIDEO_VP9Level31      = 0x20,
+    OMX_VIDEO_VP9Level4       = 0x40,
+    OMX_VIDEO_VP9Level41      = 0x80,
+    OMX_VIDEO_VP9Level5       = 0x100,
+    OMX_VIDEO_VP9Level51      = 0x200,
+    OMX_VIDEO_VP9Level52      = 0x400,
+    OMX_VIDEO_VP9Level6       = 0x800,
+    OMX_VIDEO_VP9Level61      = 0x1000,
+    OMX_VIDEO_VP9Level62      = 0x2000,
+    OMX_VIDEO_VP9LevelUnknown = 0x6EFFFFFF,
+    OMX_VIDEO_VP9LevelMax     = 0x7FFFFFFF
+} OMX_VIDEO_VP9LEVELTYPE;
+
+/** VP8 Param */
+typedef struct OMX_VIDEO_PARAM_VP8TYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_VP8PROFILETYPE eProfile;
+    OMX_VIDEO_VP8LEVELTYPE eLevel;
+    OMX_U32 nDCTPartitions;
+    OMX_BOOL bErrorResilientMode;
+} OMX_VIDEO_PARAM_VP8TYPE;
+
+/** Structure for configuring VP8 reference frames */
+typedef struct OMX_VIDEO_VP8REFERENCEFRAMETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bPreviousFrameRefresh;
+    OMX_BOOL bGoldenFrameRefresh;
+    OMX_BOOL bAlternateFrameRefresh;
+    OMX_BOOL bUsePreviousFrame;
+    OMX_BOOL bUseGoldenFrame;
+    OMX_BOOL bUseAlternateFrame;
+} OMX_VIDEO_VP8REFERENCEFRAMETYPE;
+
+/** Structure for querying VP8 reference frame type */
+typedef struct OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bIsIntraFrame;
+    OMX_BOOL bIsGoldenOrAlternateFrame;
+} OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE;
+
+/** Maximum number of VP8 temporal layers */
+#define OMX_VIDEO_ANDROID_MAXVP8TEMPORALLAYERS 3
+
+/** VP8 temporal layer patterns */
+typedef enum OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE {
+    OMX_VIDEO_VPXTemporalLayerPatternNone = 0,
+    OMX_VIDEO_VPXTemporalLayerPatternWebRTC = 1,
+    OMX_VIDEO_VPXTemporalLayerPatternMax = 0x7FFFFFFF
+} OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE;
+
+/**
+ * Android specific VP8 encoder params
+ *
+ * STRUCT MEMBERS:
+ *  nSize                      : Size of the structure in bytes
+ *  nVersion                   : OMX specification version information
+ *  nPortIndex                 : Port that this structure applies to
+ *  nKeyFrameInterval          : Key frame interval in frames
+ *  eTemporalPattern           : Type of temporal layer pattern
+ *  nTemporalLayerCount        : Number of temporal coding layers
+ *  nTemporalLayerBitrateRatio : Bitrate ratio allocation between temporal
+ *                               streams in percentage
+ *  nMinQuantizer              : Minimum (best quality) quantizer
+ *  nMaxQuantizer              : Maximum (worst quality) quantizer
+ */
+typedef struct OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nKeyFrameInterval;        // distance between consecutive key_frames (including one
+                                      // of the key_frames). 0 means interval is unspecified and
+                                      // can be freely chosen by the codec. 1 means a stream of
+                                      // only key_frames.
+
+    OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE eTemporalPattern;
+    OMX_U32 nTemporalLayerCount;
+    OMX_U32 nTemporalLayerBitrateRatio[OMX_VIDEO_ANDROID_MAXVP8TEMPORALLAYERS];
+    OMX_U32 nMinQuantizer;
+    OMX_U32 nMaxQuantizer;
+} OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE;
+
+/** HEVC Profile enum type */
+typedef enum OMX_VIDEO_HEVCPROFILETYPE {
+    OMX_VIDEO_HEVCProfileUnknown      = 0x0,
+    OMX_VIDEO_HEVCProfileMain         = 0x1,
+    OMX_VIDEO_HEVCProfileMain10       = 0x2,
+    // Main10 profile with HDR SEI support.
+    OMX_VIDEO_HEVCProfileMain10HDR10  = 0x1000,
+    OMX_VIDEO_HEVCProfileMax          = 0x7FFFFFFF
+} OMX_VIDEO_HEVCPROFILETYPE;
+
+/** HEVC Level enum type */
+typedef enum OMX_VIDEO_HEVCLEVELTYPE {
+    OMX_VIDEO_HEVCLevelUnknown    = 0x0,
+    OMX_VIDEO_HEVCMainTierLevel1  = 0x1,
+    OMX_VIDEO_HEVCHighTierLevel1  = 0x2,
+    OMX_VIDEO_HEVCMainTierLevel2  = 0x4,
+    OMX_VIDEO_HEVCHighTierLevel2  = 0x8,
+    OMX_VIDEO_HEVCMainTierLevel21 = 0x10,
+    OMX_VIDEO_HEVCHighTierLevel21 = 0x20,
+    OMX_VIDEO_HEVCMainTierLevel3  = 0x40,
+    OMX_VIDEO_HEVCHighTierLevel3  = 0x80,
+    OMX_VIDEO_HEVCMainTierLevel31 = 0x100,
+    OMX_VIDEO_HEVCHighTierLevel31 = 0x200,
+    OMX_VIDEO_HEVCMainTierLevel4  = 0x400,
+    OMX_VIDEO_HEVCHighTierLevel4  = 0x800,
+    OMX_VIDEO_HEVCMainTierLevel41 = 0x1000,
+    OMX_VIDEO_HEVCHighTierLevel41 = 0x2000,
+    OMX_VIDEO_HEVCMainTierLevel5  = 0x4000,
+    OMX_VIDEO_HEVCHighTierLevel5  = 0x8000,
+    OMX_VIDEO_HEVCMainTierLevel51 = 0x10000,
+    OMX_VIDEO_HEVCHighTierLevel51 = 0x20000,
+    OMX_VIDEO_HEVCMainTierLevel52 = 0x40000,
+    OMX_VIDEO_HEVCHighTierLevel52 = 0x80000,
+    OMX_VIDEO_HEVCMainTierLevel6  = 0x100000,
+    OMX_VIDEO_HEVCHighTierLevel6  = 0x200000,
+    OMX_VIDEO_HEVCMainTierLevel61 = 0x400000,
+    OMX_VIDEO_HEVCHighTierLevel61 = 0x800000,
+    OMX_VIDEO_HEVCMainTierLevel62 = 0x1000000,
+    OMX_VIDEO_HEVCHighTierLevel62 = 0x2000000,
+    OMX_VIDEO_HEVCHighTiermax     = 0x7FFFFFFF
+} OMX_VIDEO_HEVCLEVELTYPE;
+
+/** Structure for controlling HEVC video encoding */
+typedef struct OMX_VIDEO_PARAM_HEVCTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_HEVCPROFILETYPE eProfile;
+    OMX_VIDEO_HEVCLEVELTYPE eLevel;
+    OMX_U32 nKeyFrameInterval;        // distance between consecutive I-frames (including one
+                                      // of the I frames). 0 means interval is unspecified and
+                                      // can be freely chosen by the codec. 1 means a stream of
+                                      // only I frames.
+} OMX_VIDEO_PARAM_HEVCTYPE;
+
+/** Structure to define if dependent slice segments should be used */
+typedef struct OMX_VIDEO_SLICESEGMENTSTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bDepedentSegments;
+    OMX_BOOL bEnableLoopFilterAcrossSlices;
+} OMX_VIDEO_SLICESEGMENTSTYPE;
+
+/** Structure to return timestamps of rendered output frames as well as EOS
+ *  for tunneled components.
+ */
+typedef struct OMX_VIDEO_RENDEREVENTTYPE {
+    OMX_S64 nMediaTimeUs;  // timestamp of rendered video frame
+    OMX_S64 nSystemTimeNs; // system monotonic time at the time frame was rendered
+                           // Use INT64_MAX for nMediaTimeUs to signal that the EOS
+                           // has been reached. In this case, nSystemTimeNs MUST be
+                           // the system time when the last frame was rendered.
+                           // This MUST be done in addition to returning (and
+                           // following) the render information for the last frame.
+} OMX_VIDEO_RENDEREVENTTYPE;
+
+/** Dolby Vision Profile enum type */
+typedef enum OMX_VIDEO_DOLBYVISIONPROFILETYPE {
+    OMX_VIDEO_DolbyVisionProfileUnknown = 0x0,
+    OMX_VIDEO_DolbyVisionProfileDvavPer = 0x1,
+    OMX_VIDEO_DolbyVisionProfileDvavPen = 0x2,
+    OMX_VIDEO_DolbyVisionProfileDvheDer = 0x4,
+    OMX_VIDEO_DolbyVisionProfileDvheDen = 0x8,
+    OMX_VIDEO_DolbyVisionProfileDvheDtr = 0x10,
+    OMX_VIDEO_DolbyVisionProfileDvheStn = 0x20,
+    OMX_VIDEO_DolbyVisionProfileDvheDth = 0x40,
+    OMX_VIDEO_DolbyVisionProfileDvheDtb = 0x80,
+    OMX_VIDEO_DolbyVisionProfileMax     = 0x7FFFFFFF
+} OMX_VIDEO_DOLBYVISIONPROFILETYPE;
+
+/** Dolby Vision Level enum type */
+typedef enum OMX_VIDEO_DOLBYVISIONLEVELTYPE {
+    OMX_VIDEO_DolbyVisionLevelUnknown = 0x0,
+    OMX_VIDEO_DolbyVisionLevelHd24    = 0x1,
+    OMX_VIDEO_DolbyVisionLevelHd30    = 0x2,
+    OMX_VIDEO_DolbyVisionLevelFhd24   = 0x4,
+    OMX_VIDEO_DolbyVisionLevelFhd30   = 0x8,
+    OMX_VIDEO_DolbyVisionLevelFhd60   = 0x10,
+    OMX_VIDEO_DolbyVisionLevelUhd24   = 0x20,
+    OMX_VIDEO_DolbyVisionLevelUhd30   = 0x40,
+    OMX_VIDEO_DolbyVisionLevelUhd48   = 0x80,
+    OMX_VIDEO_DolbyVisionLevelUhd60   = 0x100,
+    OMX_VIDEO_DolbyVisionLevelmax     = 0x7FFFFFFF
+} OMX_VIDEO_DOLBYVISIONLEVELTYPE;
+
+/**
+ * Structure for configuring video compression intra refresh period
+ *
+ * STRUCT MEMBERS:
+ *  nSize               : Size of the structure in bytes
+ *  nVersion            : OMX specification version information
+ *  nPortIndex          : Port that this structure applies to
+ *  nRefreshPeriod      : Intra refreh period in frames. Value 0 means disable intra refresh
+ */
+typedef struct OMX_VIDEO_CONFIG_ANDROID_INTRAREFRESHTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nRefreshPeriod;
+} OMX_VIDEO_CONFIG_ANDROID_INTRAREFRESHTYPE;
+
+/** Maximum number of temporal layers supported by AVC/HEVC */
+#define OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS 8
+
+/** temporal layer patterns */
+typedef enum OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE {
+    OMX_VIDEO_AndroidTemporalLayeringPatternNone = 0,
+    // pattern as defined by WebRTC
+    OMX_VIDEO_AndroidTemporalLayeringPatternWebRTC = 1 << 0,
+    // pattern where frames in any layer other than the base layer only depend on at most the very
+    // last frame from each preceding layer (other than the base layer.)
+    OMX_VIDEO_AndroidTemporalLayeringPatternAndroid = 1 << 1,
+} OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE;
+
+/**
+ * Android specific param for configuration of temporal layering.
+ * Android only supports temporal layering where successive layers each double the
+ * previous layer's framerate.
+ * NOTE: Reading this parameter at run-time SHALL return actual run-time values.
+ *
+ *  nSize                      : Size of the structure in bytes
+ *  nVersion                   : OMX specification version information
+ *  nPortIndex                 : Port that this structure applies to (output port for encoders)
+ *  eSupportedPatterns         : A bitmask of supported layering patterns
+ *  nLayerCountMax             : Max number of temporal coding layers supported
+ *                               by the encoder (must be at least 1, 1 meaning temporal layering
+ *                               is NOT supported)
+ *  nBLayerCountMax            : Max number of layers that can contain B frames
+ *                               (0) to (nLayerCountMax - 1)
+ *  ePattern                   : Layering pattern.
+ *  nPLayerCountActual         : Number of temporal layers to be coded with non-B frames,
+ *                               starting from and including the base-layer.
+ *                               (1 to nLayerCountMax - nBLayerCountActual)
+ *                               If nPLayerCountActual is 1 and nBLayerCountActual is 0, temporal
+ *                               layering is disabled. Otherwise, it is enabled.
+ *  nBLayerCountActual         : Number of temporal layers to be coded with B frames,
+ *                               starting after non-B layers.
+ *                               (0 to nBLayerCountMax)
+ *  bBitrateRatiosSpecified    : Flag to indicate if layer-wise bitrate
+ *                               distribution is specified.
+ *  nBitrateRatios             : Bitrate ratio (100 based) per layer (index 0 is base layer).
+ *                               Honored if bBitrateRatiosSpecified is set.
+ *                               i.e for 4 layers with desired distribution (25% 25% 25% 25%),
+ *                               nBitrateRatio = {25, 50, 75, 100, ... }
+ *                               Values in indices not less than 'the actual number of layers
+ *                               minus 1' MAY be ignored and assumed to be 100.
+ */
+typedef struct OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE eSupportedPatterns;
+    OMX_U32 nLayerCountMax;
+    OMX_U32 nBLayerCountMax;
+    OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern;
+    OMX_U32 nPLayerCountActual;
+    OMX_U32 nBLayerCountActual;
+    OMX_BOOL bBitrateRatiosSpecified;
+    OMX_U32 nBitrateRatios[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS];
+} OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE;
+
+/**
+ * Android specific config for changing the temporal-layer count or
+ * bitrate-distribution at run-time.
+ *
+ *  nSize                      : Size of the structure in bytes
+ *  nVersion                   : OMX specification version information
+ *  nPortIndex                 : Port that this structure applies to (output port for encoders)
+ *  ePattern                   : Layering pattern.
+ *  nPLayerCountActual         : Number of temporal layers to be coded with non-B frames.
+ *                               (same OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE limits apply.)
+ *  nBLayerCountActual         : Number of temporal layers to be coded with B frames.
+ *                               (same OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE limits apply.)
+ *  bBitrateRatiosSpecified    : Flag to indicate if layer-wise bitrate
+ *                               distribution is specified.
+ *  nBitrateRatios             : Bitrate ratio (100 based, Q16 values) per layer (0 is base layer).
+ *                               Honored if bBitrateRatiosSpecified is set.
+ *                               (same OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE limits apply.)
+ */
+typedef struct OMX_VIDEO_CONFIG_ANDROID_TEMPORALLAYERINGTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern;
+    OMX_U32 nPLayerCountActual;
+    OMX_U32 nBLayerCountActual;
+    OMX_BOOL bBitrateRatiosSpecified;
+    OMX_U32 nBitrateRatios[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS];
+} OMX_VIDEO_CONFIG_ANDROID_TEMPORALLAYERINGTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* OMX_VideoExt_h */
+/* File EOF */

+ 146 - 0
soft_3rdpart/omx-il/tests/wave511test.c

@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 StarFive Technology Co., Ltd.
+ */
+#include <stdio.h>
+#include <signal.h>
+#include <OMX_Core.h>
+#include <OMX_Component.h>
+#include <OMX_Video.h>
+#include <OMX_IndexExt.h>
+#include <sys/time.h>
+
+#define OMX_INIT_STRUCTURE(a)         \
+    memset(&(a), 0, sizeof(a));       \
+    (a).nSize = sizeof(a);            \
+    (a).nVersion.nVersion = 1;        \
+    (a).nVersion.s.nVersionMajor = 1; \
+    (a).nVersion.s.nVersionMinor = 1; \
+    (a).nVersion.s.nRevision = 1;     \
+    (a).nVersion.s.nStep = 1
+
+OMX_BUFFERHEADERTYPE *pInputBuffer, *pOutputBuffer;
+static int g_is_run  = 0;
+static int numBuffer = 0;
+static OMX_ERRORTYPE event_handler(
+    OMX_HANDLETYPE hComponent,
+    OMX_PTR pAppData,
+    OMX_EVENTTYPE eEvent,
+    OMX_U32 nData1,
+    OMX_U32 nData2,
+    OMX_PTR pEventData)
+{
+
+    return OMX_ErrorNone;
+}
+
+static OMX_ERRORTYPE fill_output_buffer_done_handler(
+    OMX_HANDLETYPE hComponent,
+    OMX_PTR pAppData,
+    OMX_BUFFERHEADERTYPE *pBuffer)
+{
+    struct timeval tv;
+    gettimeofday(&tv,NULL);
+    printf("[%ld], frame = %d\n",tv.tv_sec*1000000 + tv.tv_usec, numBuffer);  //微秒
+    numBuffer ++;
+    //write to file
+    FILE *fb = fopen("./out.dat", "ab+");
+    fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, fb);
+    fclose(fb);
+    OMX_FillThisBuffer(hComponent, pOutputBuffer);
+    return OMX_ErrorNone;
+}
+
+static OMX_ERRORTYPE empty_buffer_done_handler(
+    OMX_HANDLETYPE hComponent,
+    OMX_PTR pAppData,
+    OMX_BUFFERHEADERTYPE *pBuffer)
+{
+    printf("%s:%d:!!!!!!!!!!!!!!!!!!\r\n",__FUNCTION__, __LINE__);
+    //write to file
+    return OMX_ErrorNone;
+}
+
+static void block_until_state_changed(OMX_HANDLETYPE hComponent, OMX_STATETYPE wanted_eState)
+{
+    OMX_STATETYPE eState;
+    while (eState != wanted_eState && g_is_run)
+    {
+        OMX_GetState(hComponent, &eState);
+        if (eState != wanted_eState)
+        {
+            printf("state = %d\r\n", eState);
+            usleep(10000 * 1000);
+        }
+    }
+}
+
+static void signal_handle(int sig)
+{ 
+    printf("[%s,%d]: receive sig=%d \n", __FUNCTION__, __LINE__, sig);
+    if (g_is_run) {
+        OMX_Deinit();
+        g_is_run = 0;
+    }
+}
+
+//TODO: callback, parameter, buffer
+int main(void)
+{
+    printf("=============================\r\n");
+    OMX_HANDLETYPE hComponentDecoder;
+
+    OMX_CALLBACKTYPE callbacks;
+    int ret = OMX_ErrorNone;
+
+    signal(SIGINT, signal_handle);
+
+    ret = OMX_Init();
+    if (ret != OMX_ErrorNone) {
+        printf("[%s,%d]: run OMX_Init failed. ret is %d \n", __FUNCTION__, __LINE__, ret);
+        return 1;
+    }
+    g_is_run = 1;
+
+    callbacks.EventHandler = event_handler;
+    callbacks.FillBufferDone = fill_output_buffer_done_handler;
+    callbacks.EmptyBufferDone = empty_buffer_done_handler;
+    OMX_GetHandle(&hComponentDecoder, "sf.dec.decoder", NULL, &callbacks);
+
+    if (hComponentDecoder == NULL)
+    {
+        printf("could not get handle\r\n");
+        return 0;
+    }
+
+    OMX_SetParameter(hComponentDecoder, OMX_IndexParamVideoHevc, NULL);
+
+    OMX_SendCommand(hComponentDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+
+    FILE *fb = fopen("./stream/hevc/akiyo.cfg_ramain_tv0.cfg.265", "r");
+    if (fb == NULL)
+    {
+        printf("%s:%d can not open file\r\n", __FUNCTION__, __LINE__);
+    }
+    int curpos = ftell(fb);
+    fseek(fb,0L,SEEK_END);
+    int size = ftell(fb);
+    fseek(fb,curpos,SEEK_SET);
+    printf("%s:%d size = %d\r\n", __FUNCTION__, __LINE__, size);
+    
+    OMX_AllocateBuffer(hComponentDecoder, &pInputBuffer, 0, NULL, size);
+    OMX_AllocateBuffer(hComponentDecoder, &pOutputBuffer, 0, NULL, 0x20000);
+
+    int len = fread(pInputBuffer->pBuffer, 1, size, fb);
+    printf("%s:%d:size = %d\r\n",__FUNCTION__, __LINE__, len);
+    
+    OMX_SendCommand(hComponentDecoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
+    OMX_EmptyThisBuffer(hComponentDecoder, pInputBuffer);
+    OMX_FillThisBuffer(hComponentDecoder, pOutputBuffer);
+    // OMX_FillThisBuffer(hComponentDecoder, pOutputBuffer);
+
+    block_until_state_changed(hComponentDecoder, OMX_StateIdle);
+
+    OMX_FreeHandle(hComponentDecoder);
+    return 0;
+}

+ 123 - 0
soft_3rdpart/omx-il/tests/wave521test.c

@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 StarFive Technology Co., Ltd.
+ */
+#include <stdio.h>
+#include <signal.h>
+#include <OMX_Core.h>
+#include <OMX_Component.h>
+#include <OMX_Video.h>
+
+#define OMX_INIT_STRUCTURE(a)         \
+    memset(&(a), 0, sizeof(a));       \
+    (a).nSize = sizeof(a);            \
+    (a).nVersion.nVersion = 1;        \
+    (a).nVersion.s.nVersionMajor = 1; \
+    (a).nVersion.s.nVersionMinor = 1; \
+    (a).nVersion.s.nRevision = 1;     \
+    (a).nVersion.s.nStep = 1
+
+static OMX_ERRORTYPE event_handler(
+    OMX_HANDLETYPE hComponent,
+    OMX_PTR pAppData,
+    OMX_EVENTTYPE eEvent,
+    OMX_U32 nData1,
+    OMX_U32 nData2,
+    OMX_PTR pEventData)
+{
+
+    return OMX_ErrorNone;
+}
+
+static OMX_ERRORTYPE fill_output_buffer_done_handler(
+    OMX_HANDLETYPE hComponent,
+    OMX_PTR pAppData,
+    OMX_BUFFERHEADERTYPE *pBuffer)
+{
+
+    return OMX_ErrorNone;
+}
+
+static void block_until_state_changed(OMX_HANDLETYPE hComponent, OMX_STATETYPE wanted_eState)
+{
+    OMX_STATETYPE eState;
+    while (eState != wanted_eState)
+    {
+        OMX_GetState(hComponent, &eState);
+        if (eState != wanted_eState)
+        {
+            printf("state = %d\r\n", eState);
+            usleep(1000 * 1000);
+        }
+    }
+}
+
+static int g_is_run  = 0;
+static void signal_handle(int sig)
+{ 
+    printf("[%s,%d]: receive sig=%d \n", __FUNCTION__, __LINE__, sig);
+    if (g_is_run) {
+        OMX_Deinit();
+        g_is_run = 0;
+    }
+}
+
+//TODO: callback, parameter, buffer
+int main(void)
+{
+    printf("=============================\r\n");
+    OMX_HANDLETYPE hComponentEncoder;
+    OMX_HANDLETYPE hComponentFeeder;
+    OMX_HANDLETYPE hComponentReader;
+    OMX_CALLBACKTYPE callbacks;
+    int ret = OMX_ErrorNone;
+
+    signal(SIGINT, signal_handle);
+
+    ret = OMX_Init();
+    if (ret != OMX_ErrorNone) {
+        printf("[%s,%d]: run OMX_Init failed. ret is %d \n", __FUNCTION__, __LINE__, ret);
+        return 1;
+    }
+    g_is_run = 1;
+
+    callbacks.EventHandler = event_handler;
+    callbacks.FillBufferDone = fill_output_buffer_done_handler;
+    OMX_GetHandle(&hComponentEncoder, "sf.enc.encoder", NULL, &callbacks);
+    OMX_GetHandle(&hComponentFeeder, "sf.enc.feeder", NULL, &callbacks);
+    OMX_GetHandle(&hComponentReader, "sf.enc.reader", NULL, &callbacks);
+    if (hComponentEncoder == NULL || hComponentFeeder == NULL || hComponentReader == NULL)
+    {
+        printf("could not get handle\r\n");
+        return 0;
+    }
+
+    OMX_SetParameter(hComponentFeeder, OMX_IndexConfigCommonInputCrop, "./yuv/mix_1920x1080_8b_9frm.yuv");
+
+    OMX_SetParameter(hComponentReader, OMX_IndexConfigCommonOutputCrop, "./output/inter_8b_11.cfg.265");
+
+    OMX_SetParameter(hComponentEncoder, OMX_IndexParamOtherPortFormat, "./cfg/hevc_fhd_inter_8b_11.cfg");
+    OMX_SetParameter(hComponentFeeder, OMX_IndexParamOtherPortFormat, "./cfg/hevc_fhd_inter_8b_11.cfg");
+    OMX_SetParameter(hComponentReader, OMX_IndexParamOtherPortFormat, "./cfg/hevc_fhd_inter_8b_11.cfg");
+
+    OMX_SendCommand(hComponentEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+    OMX_SendCommand(hComponentFeeder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+    OMX_SendCommand(hComponentReader, OMX_CommandStateSet, OMX_StateIdle, NULL);
+
+    OMX_SetupTunnel(hComponentFeeder, 0, hComponentEncoder, 0);
+    OMX_SetupTunnel(hComponentEncoder, 0, hComponentReader, 0);
+
+    OMX_SendCommand(hComponentFeeder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
+    OMX_SendCommand(hComponentEncoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
+    OMX_SendCommand(hComponentReader, OMX_CommandStateSet, OMX_StateExecuting, NULL);
+
+    block_until_state_changed(hComponentFeeder, OMX_StateIdle);
+    block_until_state_changed(hComponentEncoder, OMX_StateIdle);
+    block_until_state_changed(hComponentReader, OMX_StateIdle);
+
+    OMX_FreeHandle(hComponentFeeder);
+    OMX_FreeHandle(hComponentEncoder);
+    OMX_FreeHandle(hComponentReader);
+    OMX_Deinit();
+    return 0;
+}

+ 97 - 0
soft_3rdpart/wave511/README.md

@@ -0,0 +1,97 @@
+## 工程目录介绍
+
+1. code                             驱动、测试源码和各种脚本等
+2. doc                              设计文档相关
+3. firmware                         IP内部固件二进制程序
+4. media                            测试用多媒体视频源
+5. ffmpeg                           ffmpeg工程
+6. README.md                       本文件
+
+## 工程编译
+
+1. 运行 .  build_env.sh             编译环境设置
+2. make -f WaveDecDriver.mak        驱动编译
+3. make -f WaveDecode.mak           单路解码测试程序编译
+4. make -f WaveDecodeMult.mak       多路解码测试程序编译
+5. make -f WaveDecode-ffmpeg.mak    多媒体文件解码测试程序编译
+6. build_for_vdec.sh 	                           本工程一键编译脚本
+
+## 编译输出文件
+
+1. vpu.ko                           内核解码驱动程序
+2. dec_test                         单路解码测试程序
+3. multi_instance_dec_test          多路解码测试程序
+4. ffmpeg_dec_test                  带ffmpeg解析功能的解码测试程序
+
+## 运行调试流程如下
+
+1. 编译内核
+2. 设置tftp 服务器
+3. Freedom 中加载uboot,并且启动
+4. 在Uboot控制台中利用网络加载内核并启动,样例如下:
+   tftpboot 0xa0000000 192.168.70.220:image.fit
+   bootm start 0xa0000000
+   bootm loados 0xa0000000
+   go 0x80700000 0x86000000   
+5. 输入内核用户/密码(root/sifive),配置网络参数,样例如下:
+   ifconfig eth0 down
+   ifconfig eth0 192.168.70.250 netmask 255.255.255.0
+   route add default gw 192.168.70.1
+   ifconfig eth0 up
+5. 使用scp等工具,把调试用相关驱动、脚本和测试源下载到linux系统中
+   例如:scp x:\yyy\zzz root@192.168.70.250:~,可能的其他文件包括:
+     Vpu.ko                         驱动程序
+     load.sh                        驱动加载脚本
+     unload.sh                      驱动卸载脚本
+     chagall.bin                    firmware程序
+     dec_test                       单路测试程序
+     multi_instance_dec_test        多路测试程序
+     ffmpeg_dec_test                带容器解析功能的测试程序
+     bd_10b_01.cfg_0.264            码流文件
+     xxxx.mp4                       多媒体文件
+6. 运行 load.sh 加载驱动
+7. 运行 dec_test/multi_instance_dec_test/ffmpeg_dec_test 解码测试
+8. 取回yuv视频帧,并验证,样例如下:
+   scp root@192.168.70.250:~\zzz.yuv x:\yyy\
+
+## 测试程序命令行样例
+
+1. 单路解码
+./dec_test --output ./out.dat --input tv0.265 --codec 12
+
+2. 2路解码
+./multi_instance_dec_test --codec 0,0 --input bd_8b_01.cfg_0.264-0,bd_8b_01.cfg_0.264-1 --output bd_8b_01.cfg_0.yuv-0,bd_8b_01.cfg_0.yuv-1 --instance-num 2 --enable-wtl 1,1
+
+3. 4路解码
+./multi_instance_dec_test --codec 0,0,0,0 --input bd_8b_01.cfg_0.264-0,bd_8b_01.cfg_0.264-1,bd_8b_01.cfg_0.264-2,bd_8b_01.cfg_0.264-3 --output bd_8b_01.cfg_0.yuv-0,bd_8b_01.cfg_0.yuv-1,bd_8b_01.cfg_0.yuv-2,bd_8b_01.cfg_0.yuv-3 --instance-num 4 --enable-wtl 1,1,1,1
+
+4.支持ffmpeg parser/demuxer
+./ffmpeg_dec_test  --codec 12 --output hevc_fhd_inter_8b_11.cfg_0.yuv --input media/hevc_fhd_inter_8b_11.cfg_0.mkv
+
+## 备注
+
+1. VDEC默认使用cma方式从通用的CMA空间分配mem。如果想给VDEC指定特定的预留空间,可以在dts文件中做预留,同时,在文件code/vdi/linux/driver/vpu.c中,打开VPU_SUPPORT_RESERVED_VIDEO_MEMORY宏。预留方式简单示例:
+   
+	freedom-u-sdk/HiFive_U-Boot/arch\riscv/dts/hifive_u74_nvdla_iofpga.dts :
+	
+		reserved_memory: reserved-memory {
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			
+		    vpu_reserved: framebuffer@d8000000 {
+		        reg = <0x0 0xd8000000 0x0 0x20000000>;
+		    };
+		};
+		vpu_dec:vpu_dec@118F0000 {
+		    compatible = "c&m,cm511-vpu";
+		    reg = <0 0x118F0000 0 0x10000>;
+		    memory-region = <&vpu_reserved>;
+		    interrupt-parent = <&plic>;
+		    interrupts = <23>;
+		    clocks = <&vpuclk>;
+		    clock-names = "vcodec";
+		    status = "okay";
+		};
+	
+2. 驱动源码中有关模块时钟开启/关闭/复位等逻辑,作为临时代码,后期需要被内核相关接口替换。

+ 543 - 0
soft_3rdpart/wave511/code/TestMultiInstance.sh

@@ -0,0 +1,543 @@
+#!/bin/bash
+
+source common.sh
+
+g_product_name=""
+enc_prebuilt=""
+enable_wtl=0
+enable_sync=0
+enable_afbce=0
+enable_afbcd=0
+enable_scaler=0
+enable_cframe50d=0
+multi_random_cfg=0
+haps=0
+process_test="true"
+test_exec="./multi_instance_test"
+wiki_log_file="./log/multi_confluence.log"
+yuv_base="yuv/"
+bin_dir="./"
+bitfile=0
+first_sfs=0
+
+function help {
+    echo ""
+    echo "-------------------------------------------------------------------------------"
+    echo "Chips&Media conformance Tool v2.0"
+    echo "All copyright reserved by Chips&Media"
+    echo "-------------------------------------------------------------------------------"
+    echo "$0 OPTION streamlist_file"
+    echo "-h                    Help"
+    echo "--product             product name(coda960, coda980...)"
+}
+
+################################################################################
+# Parse arguments                                                              #
+################################################################################
+OPTSTRING="-o h -l product:"
+OPTS=`getopt $OPTSTRING -- "$@"`
+
+if [ $? -ne 0 ]; then
+    exit 1
+fi
+
+eval set -- "$OPTS"
+
+while true; do
+    case "$1" in
+        -h)
+            help
+            exit 1
+            shift;;
+        --product)
+            g_product_name=$2
+            shift 2;;
+#ifdef CNM_FPGA_PLATFROM
+        --bitfile)
+            bitfile=$2
+            shift 2;;
+        --haps)
+            haps=$2
+            shift 2;;
+        --vu440)
+            vu440=$2
+            shift 2;;
+#endif /* CNM_FPGA_PLATFORM */
+        --)
+            shift
+            break;;
+    esac
+done
+
+shift $(($OPTIND - 1))
+
+
+streamset_path=$1
+streamset_file=`basename ${streamset_path}`
+
+if [ ! -f "${streamset_path}" ]; then
+    echo "No such file: ${streamset_path}"
+    exit 1
+fi
+
+################################################################################
+# count stream number                                                          #
+################################################################################
+stream_command_array=()
+linenum=0
+while read -r line || [ -n "$line" ]; do
+    line=$(echo $line | tr -d '\n')
+    line=$(echo $line | tr -d '\r')
+    line="${line//\\//}" # replace backslash to slash
+    line=${line#*( )}    # remove front whitespace
+    firstchar=${line:0:1}
+    case "$firstchar" in
+        "@") break;;        # exit flag
+        "#") continue;;     # comment
+        ";") continue;;     # comment
+        "")  continue;;     # comment
+        *)
+    esac
+
+    stream_command_array[$linenum]="$line"
+    linenum=$(($linenum + 1))
+done < ${streamset_path}
+
+num_of_streams=${#stream_command_array[@]}
+
+success_count=0
+failure_count=0
+remain_count=2          # process test + thread test = 2
+if [ "$process_test" == "false" ]; then
+    remain_count=1      # only thread test
+fi
+basedir=${basedir//\/}  # remove last delimeter
+
+mkdir -p temp
+mkdir -p output
+mkdir -p log/multi_conformance
+conf_log_path="log/multi_conformance/${streamset_file}_r${revision}.log"
+conf_err_log_path="log/multi_conformance/${streamset_file}_error_r${revision}.log"
+temp_log_path="./temp/temp.log"
+# truncate contents of log file
+echo "" > $conf_log_path
+echo "" > $conf_err_log_path
+echo "" > $temp_log_path
+beginTime=$(date +%s%N)
+
+
+################################################################################
+# Read CMD File && Make test param                                             #
+################################################################################
+for ((i=0;i<$num_of_streams;i++)) do
+    ################################################################################
+    # SET DEFAULT VALUE                                                            #
+    ################################################################################
+    codec_std[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f1)
+    stream[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f2)
+    ref_file_path[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f3)
+    isEncoder[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f4)
+    main10[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f5)
+    pic_width[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f6)
+    pic_height[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f7)
+    afbce[$i]=0
+    afbcd[$i]=0
+    cframe50d[$i]=0
+    cframe50d_mbl[$i]=0
+    cframe50d_422[$i]=0
+    scaler[$i]=0
+    wtl[$i]=1
+    bsmode[$i]=0
+    match_mode[$i]=1
+    enable_mvc[$i]=0
+    core[$i]=0
+
+    case "${codec_std[$i]}" in
+        "0")  codec_name[$i]="avc";;
+        "1")  codec_name[$i]="vc1";;
+        "2")  codec_name[$i]="mp2";;
+        "3")  codec_name[$i]="mp4";;
+        "4")  codec_name[$i]="h263";;
+        "5")  codec_name[$i]="dv3";;
+        "6")  codec_name[$i]="rvx";;
+        "7")  codec_name[$i]="avs";;
+        "9")  codec_name[$i]="tho";;
+        "10") codec_name[$i]="vp3";;
+        "11") codec_name[$i]="vp8";;
+        "12") codec_name[$i]="hevc";;
+        "13") codec_name[$i]="vp9";;
+        "14") codec_name[$i]="avs2";;
+        "15") codec_name[$i]="svac";;
+        "16") codec_name[$i]="av1";;
+        *)
+            echo "unsupported codec_std: ${codec_std[$i]}"
+            help
+            exit 1
+            ;;
+    esac
+
+    if [ "${isEncoder[$i]}" = "1" ]; then
+        output[$i]="instance_${i}_output.bin"
+    else
+        output[$i]=""
+    fi
+
+    ################################################################################
+    # SET RANDOM VALUE                                                             #
+    ################################################################################
+    str=`echo ${stream[$i]} | grep "_MVC_\|MVCDS\|MVCICT\|MVCRP\|MVCSPS"` || echo ignore_error
+    if [ "${str}" != "" ]; then
+        enable_mvc[$i]=1
+    fi
+
+    if [ "${codec_name[$i]}" = "vp9" ] || [ "${codec_name[$i]}" = "dv3" ] || [ "${codec_name[$i]}" = "tho" ]; then
+        bsmode[$i]=2
+        ext=${stream[$i]##*.}
+        if [ "$ext" = "ivf" ] && [ "${codec_name[$i]}" != "vp9" ]; then
+            bsmode[$i]=0
+        fi
+    fi
+
+    if [ "${isEncoder[$i]}" = "1" ]; then
+        match_mode[$i]=3 # bitstream compare
+    fi
+
+    if [ "$enable_wtl" = "1" ]; then
+        wtl[$i]=$(get_random 0 1)
+    fi
+
+    if [ "${g_product_name}" = "coda960" ] || [ "${g_product_name}" = "coda980" ]; then
+        wtl[$i]=0
+    fi
+
+    if [ "${isEncoder[$i]}" = "1" ]; then
+        wtl[$i]=0
+    fi
+    if [ "$enable_scaler" = "1" ]; then
+        if [ "${i}" = "0" ]; then # at least one must use scaler.
+            scaler[$i]=1
+        else
+            scaler[$i]=$(get_random 0 1)
+        fi
+
+        if [ "${scaler[$i]}" == "1" ]; then
+            match_mode[$i]=1
+        else
+            match_mode[$i]=2
+        fi
+        wtl[$i]=1
+        if [ "${scaler[$i]}" = "1" ]; then
+            if [ "${pic_width[$i]}" = "" ] || [ "${pic_height[$i]}" = "" ]; then
+                echo "stream size are not specified in cmd file"
+                exit 1
+            fi
+            scaleWidth[$i]=$((${pic_width[$i]}/2))
+            scaleWidth[$i]=$(ceiling ${scaleWidth[$i]} 2)
+            scaleHeight[$i]=$((${pic_height[$i]}/2))
+            scaleHeight[$i]=$(ceiling ${scaleHeight[$i]} 2)
+        else
+            scaleWidth[$i]=0
+            scaleHeight[$i]=0
+        fi
+    fi
+    if [ "${g_product_name}" = "wave521c_dual" ]; then
+        core[$i]=$(get_random 1 2)
+        ring[$i]=$(get_random 0 1)
+        if [ ${ring[$i]} == 1 ]; then
+            ring[$i]=2
+        fi
+    fi
+done
+
+################################################################################
+# Generate compare file path                                                   #
+################################################################################
+for ((i=0;i<$num_of_streams;i++)) do
+    if [ "${isEncoder[$i]}" = "1" ]; then
+        echo "[A] path -> ${ref_file_path[$i]}"
+    else
+        codec=${codec_name[$i]}
+
+        if [ "${scaler[$i]}" = "1" ]; then
+            if [ "$g_product_name" == "wave512" ]; then
+                if [ "${codec_name[$i]}" = "vp9" ]; then
+                    bin_dir="../../../design/ref_c_vp9/bin/Linux"
+                elif [ "${codec_name[$i]}" = "hevc" ]; then
+                    bin_dir="../../../design/ref_c_hevc/bin/Linux"
+                    g_support_minipippen=1
+                fi
+            else
+                g_support_minipippen=1
+            fi
+
+            g_scaler="true"
+            g_oriw=${pic_width[$i]}
+            g_orih=${pic_height[$i]}
+            g_sclw=${scaleWidth[$i]}
+            g_sclh=${scaleHeight[$i]}
+            g_codec_index=${codec_std[$i]}
+            g_bsmode=${bsmode[$i]}
+            ref_file_path[$i]="temp/output_${i}.yuv"
+        fi
+        if [ "${match_mode[$i]}" == "1" ]; then
+            if [ "${main10[$i]}" == "1" ]; then
+                is_main10=1
+            fi
+            generate_yuv ${stream[$i]} ${ref_file_path[$i]}
+        fi
+    fi
+done
+
+################################################################################
+# Generate input file path                                                     #
+################################################################################
+for ((i=0;i<$num_of_streams;i++)) do
+    cframe50sd_tx16y[$i]=0
+    cframe50sd_tx16c[$i]=0
+    cframe50sd_lossless[$i]=0
+    g_cframe_422[$i]=0
+    if [ "${isEncoder[$i]}" = "1" ]; then
+        if [ "${cframe50d[$i]}" = "1" ]; then
+            # create cframe50 file.
+            yuv_name=$(grep 'InputFile' ${stream[$i]} | sed -e 's/\r//g' | cut -d' ' -f3)
+            src_width=$(grep 'SourceWidth' ${stream[$i]} | sed -e 's/\r//g' | cut -d' ' -f3)
+            src_height=$(grep 'SourceHeight' ${stream[$i]} | sed -e 's/\r//g' | cut -d' ' -f3)
+            yuv_dir=${yuv_base}${yuv_name}
+
+            echo ${yuv_dir}
+            cp ${yuv_dir} instance_${i}_input.yuv
+
+            bit_depth=8
+            if [ "${main10[$i]}" = "1" ]; then
+                bit_depth=10
+            fi
+
+            format_value=1
+            if [ "${cframe50d_422[$i]}" = "1" ]; then
+                format_value=2
+            fi
+
+            mbl_value=0
+            case "${cframe50d_mbl[$i]}" in
+            "0") mbl_value=16;;
+            "1") mbl_value=32;;
+            "2") mbl_value=64;;
+            "3") mbl_value=128;;
+            *) ;;
+            esac
+
+            ref_c_param="../../../design/cframe50_c/bin/cframe -i instance_${i}_input.yuv -b ${bit_depth} -w ${src_width} -h ${src_height} -f 1000 -min_burst_len ${mbl_value} -c refc_output_${i}.cf50 -format ${format_value} -convert422 ${cframe50d_422[$i]}"
+            echo ${ref_c_param}
+            ${ref_c_param}
+
+            cp refc_output_${i}.cf50 ${stream[$i]}.cf50
+        fi
+
+        if [ "${cframe50sd[$i]}" = "1" ]; then
+            # create cframe50s file.
+            cframe_c_exec=../../../design/cframe50_c/bin/cframe
+            if [ "$cfg_InputBitDepth" == "8" ]; then
+                g_cframetx16y=$(get_random 2 7)
+                g_cframetx16c=$(get_random 2 7)
+            else
+                g_cframetx16y=$(get_random 2 9)
+                g_cframetx16c=$(get_random 2 9)
+            fi
+            g_cframetx16y=$(($g_cframetx16y * 16))
+            g_cframetx16c=$(($g_cframetx16c * 16))
+            cframe50sd_tx16y[$i]=$g_cframetx16y
+            cframe50sd_tx16c[$i]=$g_cframetx16c
+
+            if [ "$g_product_name" = "wave521" ] ||  [ "$g_product_name" = "wave521c" ]; then
+                g_cframe_422[$i]=$(get_random 0 1)
+            fi
+
+            g_cframelossless=1 #test only lossless
+            cframe50sd_lossless[$i]=$g_cframelossless #test only lossless
+            read_cfg ${stream[$i]}
+            yuv_path="/nstream/qctool/img/${cfg_InputFile}"
+            if [ "${codec_name[$i]}" = "hevc" ]; then
+                codec_path=hevc
+            elif [ "${codec_name[$i]}" = "avc" ]; then
+                codec_path=avc
+            else
+                codec_path=svac
+            fi
+            cframe_input_dir=/nstream/qctool/work/ENC_REF_STREAM/WAVE521_CFRAME/${codec_path}/${cfg_base_path} #cfg_base_path
+            check_and_create_dir $cframe_input_dir
+            input_file=$(basename $cfg_InputFile)
+            input_dir=$(dirname $cfg_InputFile)
+            check_and_create_dir $input_dir
+            cframe_name=cframe_${input_file}_${cfg_width}_${cfg_height}_${g_cframelossless}_${g_cframetx16y}_${g_cframetx16c}.cf50s
+            cframe_path=$cframe_input_dir/$cframe_name
+
+            #run cframe cmodel if not exist
+            if [ "$g_product_name" = "wave521" ] ||  [ "$g_product_name" = "wave521c" ]; then
+                if [ ${g_cframe_422[$i]} == 1 ]; then
+                    PARAM="-i $yuv_path -o ${cfg_InputFile}.422 -c temp.cf50s_${i} -b $cfg_InputBitDepth -w $cfg_width -h $cfg_height -format 2 -tx16 $g_cframetx16y -tx16_chroma $g_cframetx16c -lossless $g_cframelossless -f $cfg_FramesToBeEncoded -convert422 1 -oo ${cfg_InputFile} "
+                else
+                    PARAM="-i $yuv_path -o $cfg_InputFile -c temp.cf50s_${i} -b $cfg_InputBitDepth -w $cfg_width -h $cfg_height -format 1 -tx16 $g_cframetx16y -tx16_chroma $g_cframetx16c -lossless $g_cframelossless -f $cfg_FramesToBeEncoded"
+                fi
+            else
+                PARAM="-i $yuv_path -o $cfg_InputFile -c temp.cf50s_${i} -b $cfg_InputBitDepth -w $cfg_width -h $cfg_height -format 1 -tx16 $g_cframetx16y -tx16_chroma $g_cframetx16c -lossless $g_cframelossless -f $cfg_FramesToBeEncoded"
+            fi
+            echo "$cframe_c_exec $PARAM"
+            $cframe_c_exec $PARAM
+            if [ -s temp.cf50s_${i} ]; then
+                #cp -v temp.cf50s_${i} $cframe_path
+                #chmod 666 $cframe_path
+                echo "cframe success"
+            else
+                echo "cframe error"
+                echo "cframe error"
+                echo "cframe error"
+                echo "cframe error"
+                echo "cframe error"
+                exit 1;
+            fi
+        fi
+    fi
+done
+
+
+################################################################################
+# Add test param                                                               #
+# Options of the each instance are seperated by ","                            #
+################################################################################
+test_param=""
+for ((i=0;i<$num_of_streams;i++)) do
+    if [ "$i" = "0" ]; then
+        codec_std_test_param="${codec_std[$i]}"
+        stream_test_param="${stream[$i]}"
+        if [ "${output[$i]}" != "" ]; then
+            output_test_param="${output[$i]}"
+        fi
+        wtl_test_param="${wtl[$i]}"
+        bsmode_test_param="${bsmode[$i]}"
+        match_mode_test_param="${match_mode[$i]}"
+        ref_file_path_test_param="${ref_file_path[$i]}"
+        enc_dec_param="${isEncoder[$i]}"
+        core_param="${core[$i]}"
+        ring_param="${ring[$i]}"
+        scaler_test_param="${scaler[$i]}"
+        scaleWidth_test_param="${scaleWidth[$i]}"
+        scaleHeight_test_param="${scaleHeight[$i]}"
+    else
+        codec_std_test_param="${codec_std_test_param},${codec_std[$i]}"
+        stream_test_param="${stream_test_param},${stream[$i]}"
+        if [ "${output[$i]}" != "" ]; then
+            output_test_param="${output_test_param},${output[$i]}"
+        fi
+        wtl_test_param="${wtl_test_param},${wtl[$i]}"
+        bsmode_test_param="${bsmode_test_param},${bsmode[$i]}"
+        match_mode_test_param="${match_mode_test_param},${match_mode[$i]}"
+        ref_file_path_test_param="${ref_file_path_test_param},${ref_file_path[$i]}"
+        enc_dec_param="${enc_dec_param},${isEncoder[$i]}"
+        core_param="${core_param},${core[$i]}"
+        ring_param="${ring_param},${ring[$i]}"
+        scaler_test_param="${scaler_test_param},${scaler[$i]}"
+        scaleWidth_test_param="${scaleWidth_test_param},${scaleWidth[$i]}"
+        scaleHeight_test_param="${scaleHeight_test_param},${scaleHeight[$i]}"
+    fi
+done
+
+################################################################################
+# make test param                                                               #
+################################################################################
+if [ "${output_test_param}" != "" ]; then
+    output_param="--output=${output_test_param}"
+fi
+
+test_param="--instance-num=${num_of_streams} -c ${match_mode_test_param} -e ${enc_dec_param} --codec=${codec_std_test_param}"
+test_param="$test_param --bsmode=${bsmode_test_param} --enable-wtl=${wtl_test_param}"
+test_param="$test_param --input=${stream_test_param} ${output_param} --ref_file_path=${ref_file_path_test_param}"
+
+if [ "$enable_scaler" = "1" ]; then
+    test_param="${test_param} --scaler=${scaler_test_param} --sclw=${scaleWidth_test_param} --sclh=${scaleHeight_test_param}"
+fi
+
+if [ "$g_product_name" = "wave521c_dual" ]; then
+    test_param="$test_param --cores=$core_param"
+    test_param="$test_param --ring=$ring_param"
+fi
+
+
+################################################################################
+# Test Mode Thread                                                             #
+################################################################################
+result=0
+log_conf "MultiInstance test : Thread" ${temp_log_path}
+log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
+for ((i=0;i<$num_of_streams;i++)) do
+    log_conf "[${i}/${num_of_streams}] ${stream[$i]}" ${temp_log_path}
+done
+log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
+cat $temp_log_path >> $conf_log_path
+
+echo "$test_exec $test_param"
+
+nice -n -5 $test_exec $test_param || result=$?
+
+if [ $result -eq 0 ]; then
+    log_conf "[RESULT] SUCCESS" $conf_log_path
+    success_count=$(($success_count + 1))
+else
+    log_conf "[RESULT] FAILURE" $conf_log_path
+    failure_count=$(($failure_count + 1))
+    cat $temp_log_path >> $conf_err_log_path
+    cat ./ErrorLog.txt >> $conf_err_log_path
+    echo "[RESULT] FAILURE" >> $conf_err_log_path
+    if [ $result -eq 10 ]; then
+        echo "Abnormal exit!!!"
+        break
+    fi
+fi
+
+# clear temp log
+echo "" > $temp_log_path
+
+remain_count=$(($remain_count - 1))
+
+################################################################################
+# Create Test Log                                                              #
+################################################################################
+endTime=$(date +%s%N)
+elapsed=$((($endTime - $beginTime) / 1000000000))
+elapsedH=$(($elapsed / 3600))
+elapsedS=$(($elapsed % 60))
+elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
+if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
+if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
+if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
+time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
+
+log_filename=$(basename $conf_log_path)
+log_err_filename=$(basename $conf_err_log_path)
+if [ $failure_count == 0 ] && [ $num_of_streams != 0 ]; then
+    pass=${PASS}
+    rm $conf_err_log_path
+    log_err_filename=""
+else
+    pass=${FAIL}
+fi
+
+wiki_log="| $streamset_file | 2 | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | Instacne Num = $num_of_streams |"
+log_filename="[^$log_filename]"
+if [ "$log_err_filename" != "" ]; then
+    log_err_filename="[^$log_err_filename]"
+fi
+wiki_log="| $streamset_file | 2 | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | [Jenkins|$jenkins] | | Instacne Num = $num_of_streams |"
+if [ "${haps}" = "1" ]; then
+    wiki_log="| $streamset_file | 1 | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | [Jenkins|$jenkins] | | Instacne Num = $num_of_streams |"
+fi
+
+echo $wiki_log
+echo $wiki_log >> $wiki_log_file
+
+if [ "$num_of_streams" == "0" ]; then
+    echo "num_of_streams: $num_of_streams = exit 1"
+    exit 1
+fi
+
+exit $failure_count
+

+ 20 - 0
soft_3rdpart/wave511/code/TestRunnerParamWave511Dec.txt

@@ -0,0 +1,20 @@
+default=0                        #Default Option test:
+                                 #default=0   off
+                                 #default=1   on
+                                 #-99 all random(be carefull of render)
+                                 
+secondary-axi=0                  #0 ~ 7,                                         -99(random)
+stream-endian=31                 #16 ~ 31                                        -99(random)
+frame-endian=31                  #16 ~ 31                                        -99(random)
+render=0                         #0:no_display, 1:display                        -99(random)
+bsmode=2                         #0:interrupt, 1:reserved, 2:pic_end             -99(random)
+cbcr_interleave_mode=0           #0:planar, 1:nv12, 2:nv21                       -99(random)
+enable-thumbnail=0               #0:disable, 1:enable                            -99(random)
+
+disable_wtl=0                    #0:enable wtl, 1:disable wtl                    -99(random)
+wtl-format=0                     #0:420, 5:16BIT_MSB, 6:16BIT_LSB, 7:32BIT_MSB, 8:32BIT_LSB  -99(random)
+output_hw=0                      #0:BWB, 1:AFBCE, 2:SCALER
+bwopt=0                          #1: enable bandwith optimazation when WTL on.
+
+
+

+ 25 - 0
soft_3rdpart/wave511/code/TestRunnerParamWave521CEnc.txt

@@ -0,0 +1,25 @@
+default=0                        #Default Option test:
+                                 #default=0   off
+                                 #default=1   on
+                                 #-99 all random
+                                 
+secondary-axi=0                  #0 ~ 3,(bitmask - 0x01:RDO, 0x02:LF),           -99(random)
+
+yuv_src_mode=0                   #0:planar, 1:nv12, 2:nv21, 3:YUYV(packed), 4:YVYU, 5:UYVY, 6:VYUY                     -99(random)
+srcFormat3p4b=0                  #three pixel four bytes                         -99(random)
+stream-endian=31                 #16 ~ 31,                                       -99(random)
+frame-endian=31                  #16 ~ 31,                                       -99(random)
+source-endian=31                 #16 ~ 31,                                       -99(random)
+rotAngle=0                       #0, 90, 180, 270,                               -99(random)
+mirDir=0                         #0 ~ 3,                                         -99(random)
+bsmode=1                         #0:ringbuffer, 1:linebuffer                     -99(random)
+
+cframe=0                         #for Vimicro fbc50s                             -99(random)
+cframelossless=1                 #for Vimicro fbc50s                             -99(random)
+cframetx16y=0                    #for Vimicro fbc50s                             -99(random)
+cframetx16c=0                    #for Vimicro fbc50s                             -99(random)
+
+lowLatencyMode=0                 #0~3                                            -99(random)
+
+MODE_COMP_ENCODED=1              #-c  compare between FPGA output & ref-c output
+

+ 618 - 0
soft_3rdpart/wave511/code/TestRunnerWave511Dec.sh

@@ -0,0 +1,618 @@
+#!/bin/bash
+
+source common.sh
+
+g_product_name="wave511"
+# Global varaibles for decoder option
+is_main10=0
+build_yuv=0
+fail_stop=0
+fake_test=0
+yuv_dir="./yuv"
+stream_dir="./stream"
+test_exec="./w5_dec_test"
+bin_dir="."
+wiki_log_file="./log/dec_confluence.log"
+enable_random=0;
+md5_path=""
+codec=vp9
+jenkins=""
+txt_param_switch=0
+
+simulation="false"
+
+ACLK_MIN=13
+BCLK_MIN=13
+CCLK_MIN=13
+
+ACLK_MAX=33
+BCLK_MAX=33
+CCLK_MAX=33
+
+RET_SUCCESS=0
+RET_HANGUP=2
+
+function build_golden_yuvs {
+    local src=$1
+    local wtl_fmt_indexes=(0)
+
+    if [ $is_main10 -eq 1 ]; then
+        wtl_fmt_indexes=(0 5 6 7 8)
+    fi
+
+    for i in ${wtl_fmt_indexes[@]}; do
+        g_wtl_format=$i
+        echo ""
+        echo "Generating ${g_yuv_fmt_list[$g_wtl_format]}..."
+        generate_golden_data_path $codec $streamset_path $src 
+        golden_yuv_path="$g_func_ret_str"
+        generate_yuv $stream $golden_yuv_path
+    done
+}
+
+rotAngle_temp=0
+mirDir_temp=0
+
+################################################################################
+# scaler test                                                                  #
+################################################################################
+function calc_scale_tot {
+    local min_x=0
+    local min_y=0
+
+    g_oriw=$ori_width
+    g_orih=$ori_height
+    g_ori_align_x=$ori_width 
+    g_ori_align_y=$ori_height
+
+    min_x=$(($g_ori_align_x / 8))
+    min_x=$(ceiling $min_x 8)
+    min_y=$(($g_ori_align_y / 8))
+    min_y=$(ceiling $min_y 8)
+
+    num_x_steps=$(($g_ori_align_x - $min_x))
+    num_x_steps=$(($num_x_steps/2 + 1))
+    num_y_steps=$(($g_ori_align_y - $min_y))
+    num_y_steps=$(($num_y_steps/2 + 1))
+
+    echo "orign_x = $g_ori_align_x, orign_y = $g_ori_align_y"
+    echo "min_x = $min_x, min_y = $min_y"
+    echo "num_x_steps = $num_x_steps num_y_steps = $num_y_steps"
+
+    tot_scaler_cnt=$(($num_x_steps * $num_y_steps))
+    g_min_scale_w=$min_x
+    g_min_scale_h=$min_y
+
+    echo "calculated_tot_scaler_cnt=$tot_scaler_cnt"
+}
+
+function calc_scale_val {
+    local x=0
+    local y=0
+    local min_x=$g_min_scale_w
+    local min_y=$g_min_scale_h
+    
+    echo "scaler_step_cnt_2: $scaler_step_cnt_2"
+    echo "min_x: $min_x"
+    echo "min_y: $min_y"
+    if [ $scaler_test_mode -eq 1 ]; then
+        if [ $num_x_steps -eq 0 ]; then
+            g_sclw=$ori_width
+        else
+            x=$(($scaler_step_cnt_2 % $num_x_steps))
+            g_sclw=$(($g_ori_align_x - $x * 2))
+        fi
+        if [ $num_y_steps -eq 0 ]; then
+            g_sclh=$ori_height
+        else
+            y=$(($scaler_step_cnt_2 % $num_y_steps))
+            g_sclh=$(($g_ori_align_y - $y * 2))
+        fi
+    elif [ $scaler_test_mode -eq 2 ]; then
+        if [ $num_x_steps -eq 0 ]; then
+            g_sclw=$ori_width
+        else
+            x=$(($scaler_step_cnt_2 % $num_x_steps))
+            g_sclw=$(($min_x + $x * 2))
+        fi
+        if [ $num_y_steps -eq 0 ]; then
+            g_sclh=$ori_height
+        else
+            y=$(($scaler_step_cnt_2 % $num_y_steps))
+            g_sclh=$(($min_y + $y * 2))
+        fi
+    elif [ $scaler_test_mode -eq 3 ]; then
+        g_sclw=$(get_random $min_x  $g_ori_align_x)
+        g_sclh=$(get_random $min_y  $g_ori_align_y)
+    elif [ $scaler_test_mode -eq 4 ]; then
+        g_sclw=$g_ori_align_x
+        g_sclh=$(get_random $min_y  $g_ori_align_y)
+    elif [ $scaler_test_mode -eq 5 ]; then
+        g_sclw=$min_x
+        g_sclh=$(get_random $min_y  $g_ori_align_y)
+    elif [ $scaler_test_mode -eq 6 ]; then
+        g_sclw=$(get_random $min_x  $g_ori_align_x)
+        g_sclh=$g_ori_align_y
+    elif [ $scaler_test_mode -eq 7 ]; then
+        g_sclw=$(get_random $min_x  $g_ori_align_x)
+        g_sclh=$min_y
+    fi
+    g_sclw=$(ceiling $g_sclw 2)
+    g_sclh=$(ceiling $g_sclh 2)
+    echo "x=$x y=$y"
+    echo "g_sclw=$g_sclw, g_sclh=$g_sclh"
+}
+
+function help {
+    echo ""
+    echo "-------------------------------------------------------------------------------"
+    echo "Chips&Media conformance Tool v2.0"
+    echo "All copyright reserved by Chips&Media"
+    echo "-------------------------------------------------------------------------------"
+    echo "$0 OPTION streamlist_file"
+    echo "-h                    help"
+    echo "-c                    codec. default: hevc"
+    echo "                      valid codec list: avc, hevc"
+    echo "--bsmode              [optional] interrupt or picend, default: interrupt mode"
+    echo "--bin-dir             ref-c directory"
+    echo "--enable-random       generate random option."
+    echo "--enable-thumbnail    enable thumbnail mode, default: off"
+    echo "--main10              true or false. Just use in conformance env."
+    echo "--stream-dir          stream directory"
+    echo "--yuv-dir             Golden yuv directory"
+    echo "--fail-stop           Stop testing if current test is failure"
+    echo "--build-yuv           Just generate golden YUV with Ref-C."
+    echo "--fbc-mode            Compressed mode: 0 ~ 0x3e"
+}
+
+################################################################################
+# Parse arguments                                                              #
+################################################################################
+OPTSTRING="-o hwc:n:f -l bsmode:,enable-random,stream-dir:,bin-dir:,match-mode:,test_bin_name:"
+OPTSTRING="${OPTSTRING},enable-thumbnail,main10,build-yuv,yuv-dir:,fbc-mode:,md5-dir:"
+OPTSTRING="${OPTSTRING},scaler-test-mode:,scaler-step-cnt:,ori-width:,enable-scaler,ori-height:"
+
+OPTS=`getopt $OPTSTRING -- "$@"`
+
+if [ $? -ne 0 ]; then
+    exit 1
+fi
+
+eval set -- "$OPTS"
+
+while true; do
+    case "$1" in
+        -h) 
+            help
+            exit 1
+            shift;;
+        -n) 
+            g_frame_num="-n $2"
+            g_refc_frame_num="-m $2"
+            shift 2;;
+        -c)
+            codec=$(echo $2 | tr '[:upper:]' '[:lower:]')
+            shift 2;;
+        -f) 
+            g_fpga_reset=1
+            shift;;
+        --bsmode)
+            g_bsmode=$2
+            g_bsmode_force=$2
+            shift 2;;
+        --bin-dir)
+            bin_dir=$2
+            shift 2;;
+        --enable-random)
+            enable_random=1
+            shift;;
+        --enable-thumbnail)
+            g_enable_thumbnail=1
+            shift;;
+        --md5-dir)
+            md5_dir=$2
+            shift 2;;
+        --match-mode)
+            g_match_mode=$2
+            shift 2;;
+        --stream-dir)
+            stream_dir=$2
+            shift 2;;
+        --main10)
+            is_main10=1
+            shift;;
+        --build-yuv)
+            build_yuv=1
+            shift;;
+        --yuv-dir)
+            yuv_dir=$2
+            shift 2;;
+        --fail-stop)
+            fail_stop=1
+            shift;;
+        --fbc-mode)
+            g_fbc_mode_temp=$2
+            g_force_fbc_mode=1
+            shift 2;;
+        --enable-scaler)
+            g_scaler="true"
+            shift;;
+        --scaler-test-mode)
+            g_scaler="true"
+            scaler_test_mode=$2
+            shift 2;;
+        --scaler-step-cnt)
+            g_scaler="true"
+            scaler_step_cnt=$2
+            shift 2;;
+        --ori-width)
+            ori_width=$2
+            shift 2;;
+        --ori-height)
+            ori_height=$2
+            shift 2;;
+        --test_bin_name)
+            test_exec="$2"
+            shift 2;;
+        --) 
+            shift
+            break;;
+    esac
+done
+
+shift $(($OPTIND - 1))
+
+case "${codec}" in
+    "hevc")  g_codec_index=12;;
+    "avc")   g_codec_index=0;;
+   *)
+        echo "unsupported codec: ${codec}"
+        help
+        exit 1
+        ;;
+esac
+
+
+################################################################################
+# Get param from target text file                                              #
+################################################################################
+name_value=()
+input_param_name=TestRunnerParamWave511Dec.txt
+if [ -f $input_param_name ] && [ $enable_random -eq 0 ]; then
+    while read line; do
+        # remove right comment
+        line="${line%%\#*}"
+
+        attr=$(echo $line | cut -d'=' -f1)
+        attr=$(echo $attr | tr -d ' ')
+
+        if [ "$attr" == "debug" ]; then
+            value=$(echo $line | sed 's/debug=//')
+        else
+            value=$(echo $line | cut -d '=' -f2)
+        fi
+
+        case "$attr" in
+            default)              default_opt="$value";;
+            n)                    g_frame_num="-n $value"
+                                  g_refc_frame_num="-m $value";;
+            secondary-axi)        secondary_axi_temp="$value";;
+            stream-endian)        stream_endian_temp="$value";;
+            frame-endian)         frame_endian_temp="$value";;                  
+            bsmode)               bsmode_temp="$value";;
+            match-mode)           g_match_mode="$value";;
+            cbcr_interleave_mode) g_yuv_mode_temp="$value";;
+            cbcr)                 g_yuv_mode_temp="$value";;
+            disable_wtl)          disable_wtl_temp="$value";;
+            wtl-format)           wtl_format_temp="$value";;
+            enable-thumbnail)     g_enable_thumbnail="$value";;
+            fpga-reset)           g_fpga_reset="$value";;
+            fbc-mode)             g_fbc_mode_temp="$value" 
+                                  g_force_fbc_mode=1;;
+            txt-param)            txt_param_switch=1;;
+            output_hw)            g_output_hw_temp="$value";;
+            bwopt)                g_bw_opt_temp="$value";;
+            *) ;;
+        esac
+    done < $input_param_name
+else
+    if [ ! -f $input_param_name ]; then
+        echo "$input_param_name file doesn't exist"; 
+    fi
+fi
+
+streamset_path=$1
+streamset_file=`basename ${streamset_path}`
+
+if [ ! -e "${streamset_path}" ]; then
+    echo "No such file: ${streamset_path}"
+    exit 1
+fi
+
+if [ "$wtl_format_temp" != "-99" ] && [ -z "$wtl_format_temp" ]; then
+    g_enable_wtl=1
+    g_wtl_format="$wtl_format_temp"
+fi
+
+################################################################################
+# scaler test                                                                  #
+################################################################################
+if [ ! -z "$scaler_test_mode" ]; then
+    g_enable_wtl=1
+    g_match_mode=1
+    calc_scale_tot
+    scaler_step_cnt_2=1
+    temp_path=scaler.cmd
+    if [ $scaler_step_cnt ] && [ "$scaler_step_cnt" != "ALL" ] ; then
+        tot_scaler_cnt=$scaler_step_cnt
+    fi
+    max=$(($tot_scaler_cnt + 1))
+    rm -rf $temp_path
+    for (( c=1; c< $max ; c++ )) do
+        echo `cat ${streamset_path}` >> ${temp_path}
+    done
+    streamset_path=$temp_path
+fi
+
+################################################################################
+# count stream number                                                          #
+################################################################################
+stream_file_array=()
+parse_streamset_file $streamset_path stream_file_array
+
+num_of_streams=${#stream_file_array[@]}
+
+#echo ${stream_file_array[@]}
+
+count=1
+success_count=0
+failure_count=0
+remain_count=${num_of_streams}
+basedir=${basedir//\/}  # remove last delimeter
+
+mkdir -p temp
+mkdir -p output
+mkdir -p log/decoder_conformance
+conf_log_path="log/decoder_conformance/${streamset_file}_r${g_revision}.log"
+conf_err_log_path="log/decoder_conformance/${streamset_file}_error_r${g_revision}.log"
+if [ "$g_scaler" == "true" ]; then
+conf_log_path="log/decoder_conformance/${stream_set_name}_r${g_revision}.log"
+conf_err_log_path="log/decoder_conformance/${stream_set_name}_error_r${g_revision}.log"
+fi
+temp_log_path="./temp/temp.log"
+# truncate contents of log file
+echo "" > $conf_log_path
+echo "" > $conf_err_log_path
+echo "" > $temp_log_path
+beginTime=$(date +%s%N)
+
+echo ""
+echo ""
+echo "##### PRESS 'q' for stop #####"
+echo ""
+echo ""
+
+log_conf "STREAM BASE DIR: ${stream_dir}" ${conf_log_path}
+
+################################################################################
+# read cmd file.                                                               #
+################################################################################
+force_reset=0
+for (( c=0; c< $num_of_streams ; c++ )) do
+    line=${stream_file_array[$c]}
+    # press 'q' for stop
+    read -t 1 -n 1 key
+    if [[ $key == q ]]; then
+        break;
+    fi
+
+    test_param=""
+    stream="${stream_dir}/${line}"
+    log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
+    log_conf "[${count}/${num_of_streams}] ${stream}" ${temp_log_path}
+    log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
+
+    if [ ! -f $stream ]; then
+        log_conf "Not found $stream" $temp_log_path
+        log_conf "[RESULT] FAILURE" $temp_log_path
+        failure_count=$(($failure_count + 1))
+        remain_count=$(($remain_count - 1))
+        count=$(($count + 1))
+        continue
+    fi
+
+    result=0
+    target_stream=$stream
+################################################################################
+# scaler test                                                                  #
+################################################################################
+    if [ ! -z "$scaler_test_mode" ]; then
+        g_match_mode=1 #0 : 1:1(same size)
+        calc_scale_val
+        echo "scaler_step_cnt_2 = $scaler_step_cnt_2, tot_scaler_cnt = $scaler_step_cnt"
+        g_frame_num="-n 2"
+		g_refc_frame_num="-m 2" #for HEVC ref-c
+        if [ $scaler_step_cnt_2 -gt $tot_scaler_cnt ]; then
+            echo "same value"
+            break;
+        else
+            scaler_step_cnt_2=$(($scaler_step_cnt_2 + 1))
+        fi
+    fi
+
+
+################################################################################
+# make argc & argv parameter                                                   #
+################################################################################
+    if [ "$g_match_mode" == "1" ]; then
+        disable_wtl_temp=0
+    fi
+    if [ $result -eq 0 ]; then
+        if [ $enable_random -eq 1 ] && [ $txt_param_switch -eq 0 ]; then
+            get_random_param 1 wave511
+        else
+            get_default_param 1 wave511
+        fi
+        
+        # FBC does not support the endianness.
+        if [ "$g_enable_wtl" == "0" ]; then
+            g_frame_endian=16
+        fi
+
+        if [ "$force_wtl" != "" ]; then
+            g_enable_wtl=1
+            g_wtl_format=$force_wtl
+        fi
+
+        # reset after hangup
+        backup=$g_fpga_reset
+        if [ $force_reset -eq 1 ]; then
+            g_fpga_reset=1
+            force_reset=0
+        fi
+        
+        #make argc & argv parameter
+        build_test_param 1
+        g_fpga_reset=$backup
+
+        test_param="$test_param $g_func_ret_str"
+        test_param="${test_param} $g_frame_num"
+
+################################################################################
+# make prebuilt stream                                                         #
+################################################################################
+        if [ $build_yuv -eq 1 ]; then
+            build_golden_yuvs $stream
+            remain_count=$(($remain_count - 1))
+            count=$(($count + 1))
+            continue
+        fi
+
+        output_filename="$(basename $line).yuv"
+
+        case $g_match_mode in
+            1)  generate_golden_data_path $codec $streamset_path $stream 
+                golden_yuv_path="$g_func_ret_str"
+                test_param="$test_param --ref-yuv=$golden_yuv_path";;
+        esac
+
+
+################################################################################
+# print information                                                            #
+################################################################################
+
+        if [ $result -eq 0 ]; then
+            log_conf "RANDOM TEST    : ${ON_OFF[$enable_random]}" $temp_log_path
+            log_conf "BITSTREAM MODE : ${DEC_BSMODE_NAME[$g_bsmode]}" $temp_log_path
+            log_conf "ENDIAN         : STREAM($g_stream_endian) FRAME($g_frame_endian)" $temp_log_path
+            log_conf "STANDARD       : ${CODEC_NAME[$g_codec_index]}" $temp_log_path
+            log_conf "REORDER        : ON" $temp_log_path
+            log_conf "MAP TYPE       : Compressed" $temp_log_path
+            log_conf "WTL MODE       : ${ON_OFF[$g_enable_wtl]}" $temp_log_path
+            if [ "$g_enable_wtl" == "1" ]; then
+                log_conf "WTL FORMAT     : ${g_yuv_fmt_list[$g_wtl_format]}" $temp_log_path
+            else
+                log_conf "WTL FORMAT     : NONE" $temp_log_path
+            fi
+            log_conf "CBCR interleave: ${ON_OFF[$g_cbcr_interleave]}" $temp_log_path
+            log_conf "NV21           : ${ON_OFF[$g_enable_nv21]}" $temp_log_path
+            log_conf "Secondary AXI  : ${g_secondary_axi}" $temp_log_path
+
+            test_param_print=$test_param
+            log_conf "Unix   : $test_exec $test_param_print --input=$stream" $temp_log_path
+            winexec=$(echo "$test_exec $test_param_print --input=$stream" | sed -e 's/\//\\/g')
+            log_conf "Windows: $winexec" $temp_log_path
+            cat $temp_log_path >> $conf_log_path
+
+            chmod 777 $test_exec
+            test_exec_param="$test_exec $test_param --input=$target_stream"
+            result=0
+            if [ "$simulation" == "true" ]; then
+                test_exec_param="$test_exec_param $g_w_param $g_fsdb_param $g_ius_param --TestRunner=1"
+                set -o pipefail; $test_exec_param 2>&1 | tee -a $conf_log_path || result=?
+            else
+                $test_exec_param || result=$?
+            fi
+            if [ $result -eq $RET_HANGUP ]; then
+                force_reset=1
+            fi
+        fi
+    else
+        cat $temp_log_path >> $conf_log_path
+    fi
+
+    if [ $result -eq 0 ]; then
+        log_conf "[RESULT] SUCCESS" $conf_log_path
+        success_count=$(($success_count + 1))
+    else
+        cat ./ErrorLog.txt >> $conf_log_path
+        log_conf "[RESULT] FAILURE" $conf_log_path
+        failure_count=$(($failure_count + 1))
+        cat $temp_log_path >> $conf_err_log_path
+        cat ./ErrorLog.txt >> $conf_err_log_path
+        echo "[RESULT] FAILURE" >> $conf_err_log_path
+        if [ $result -eq 10 ]; then
+            echo "Abnormal exit!!!"
+            break
+        fi
+
+        #############
+        # Error Stop
+        #############
+        if [ "$error_stop" == "1" ]; then
+            break;
+        fi
+    fi
+
+    remain_count=$(($remain_count - 1))
+    count=$(($count + 1))
+    # clear temp log
+    echo "" > $temp_log_path
+    # delete temporal input file
+    rm -f $g_copy_stream   
+    if [ $fail_stop -eq 1 ] && [ $result -ne 0 ]; then
+        break;
+    fi
+done 
+
+if [ $build_yuv -eq 1 ]; then
+    exit 0
+fi
+
+endTime=$(date +%s%N)
+elapsed=$((($endTime - $beginTime) / 1000000000))
+elapsedH=$(($elapsed / 3600))
+elapsedS=$(($elapsed % 60))
+elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
+if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
+if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
+if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
+
+if [ $elapsed -le 60 ]; then
+    time_hms="{color:red}*${elapsedH}:${elapsedM}:${elapsedS}*{color}"
+else
+    time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
+fi
+
+log_filename=$(basename $conf_log_path)
+log_err_filename=$(basename $conf_err_log_path)
+if [ $failure_count == 0 ] && [ $num_of_streams != 0 ]; then
+    pass=${PASS}
+    rm $conf_err_log_path
+    log_err_filename=""
+else
+    pass=${FAIL}
+fi
+
+wiki_log="| $streamset_file | $num_of_streams | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | |"
+
+echo "$wiki_log"
+echo "$wiki_log" >> $wiki_log_file
+
+if [ "$num_of_streams" == "0" ]; then
+    echo "num_of_streams: $num_of_streams = exit 1"
+    exit 1
+fi
+
+exit $failure_count
+ 

+ 600 - 0
soft_3rdpart/wave511/code/TestRunnerWave521CEnc.sh

@@ -0,0 +1,600 @@
+#!/bin/bash
+
+source common.sh
+
+# default values
+g_product_name="wave521c"
+test_exec="./w5_enc_test"
+wiki_log_file="./log/enc_confluence.log"
+enable_random=0;
+txt_param_switch=0;
+secondary_axi_def=3                     # bit0 : LF, bit1 : BIT
+build_stream=0
+cfg_dir=./cfg
+ref_dir=.
+yuv_base_path=./yuv
+if [ "${OS}" = "Windows_NT" ]; then
+    ref_c_exec=./hevc_enc.exe
+else
+    ref_c_exec=./hevc_enc
+fi
+cframe_c_exec=./cframe
+codec=hevc
+
+
+simulation="false"
+
+ACLK_MIN_2000T=6
+BCLK_MIN_2000T=6
+CCLK_MIN_2000T=6
+ACLK_AVC_MAX_2000T=15
+BCLK_AVC_MAX_2000T=15
+CCLK_AVC_MAX_2000T=15
+ACLK_HEVC_MAX_2000T=8
+BCLK_HEVC_MAX_2000T=8
+CCLK_HEVC_MAX_2000T=8
+
+ACLK_MIN_HAPS=1000 #min:300
+BCLK_MIN_HAPS=1000
+CCLK_MIN_HAPS=1000
+ACLK_MAX_HAPS=5000
+BCLK_MAX_HAPS=5000
+CCLK_MAX_HAPS=5000
+
+ACLK_MIN_VU440=5000 #min:300
+BCLK_MIN_VU440=5000
+CCLK_MIN_VU440=5000
+ACLK_MAX_VU440=50000
+BCLK_MAX_VU440=50000
+CCLK_MAX_VU440=50000
+
+RET_SUCCESS=0
+RET_HANGUP=2
+
+
+function help {
+    echo ""
+    echo "-------------------------------------------------------------------------------"
+    echo "Chips&Media conformance Tool v2.0"
+    echo "All copyright reserved by Chips&Media"
+    echo "-------------------------------------------------------------------------------"
+    echo "$0 OPTION streamlist_file"
+    echo "-h              help"
+    echo "-c              codec. default: hevc"
+    echo "                valid codec list: avc, hevc"
+    echo "--yuv-dir       input yuv directory"
+    echo "--ref-dir       ref-c directory"
+    echo "--bin-dir       ref-c directory"
+    echo "--enable-random [optional] generate random opton"
+    echo "--build-stream  Just generate golden stream with Ref-C."
+}
+
+
+OPTSTRING="-o hwn:c:"
+OPTSTRING="${OPTSTRING} -l jump-stream:,bsmode:,enable-random,md5-dir:"
+OPTSTRING="${OPTSTRING},yuv-dir:,build-stream,ref-dir:,wiki:,n:,cfg-dir:,bin-dir:,"
+OPTS=`getopt $OPTSTRING -- "$@"`
+
+if [ $? != 0 ]; then
+    exit 1;
+fi
+
+eval set -- "$OPTS"
+
+while true; do
+    case "$1" in
+        -h) 
+            help
+            exit 0
+            shift;;
+        -n) 
+            g_frame_num="-n $2"
+            if [ "$2" = "" ]; then
+                frame_num_refc=""
+            else
+                frame_num_refc="-f $2"
+            fi
+            shift 2;;
+        -c)
+            codec=$(echo $2 | tr '[:upper:]' '[:lower:]')
+            shift 2;;
+        --bin-dir)
+            bin_dir_user=$2
+            shift 2;;
+        --enable-random)
+            enable_random=1
+            shift;;
+        --yuv-dir)
+            yuv_dir_user=$2
+            shift 2;;
+        --cfg-dir)
+            cfg_dir_user=$2
+            shift 2;;
+        --ref-dir)
+            ref_dir=$2
+            shift 2;;
+        --build-stream)
+            build_stream=1;
+            shift;;
+        --wiki)
+            wiki_log_file=$2
+            shift 2;;
+        --) 
+            shift
+            break;;
+    esac
+done
+
+shift $(($OPTIND - 1))
+
+case "${codec}" in
+    "hevc")  g_codec_index=12;;
+    "avc")   g_codec_index=0
+             ref_c_exec=./avc_enc
+             ;;
+    *)
+        echo "unsupported codec: ${codec}"
+        help
+        exit 1
+        ;;
+esac
+
+if [ ! -z $yuv_dir_user ]; then
+    yuv_dir="$yuv_dir_user"
+    yuv_base_path="$yuv_dir_user"
+fi
+if [ ! -z $cfg_dir_user ]; then
+    cfg_dir="$cfg_dir_user"
+fi
+if [ ! -z $bin_dir_user ]; then
+    bin_dir="$bin_dir_user"
+fi
+
+################################################################################
+# Get param from target text file                                              #
+################################################################################
+input_param_name=TestRunnerParamWave521CEnc.txt
+if [ -f $input_param_name ] && [ $enable_random == 0 ]; then
+    echo "read $input_param_name"
+    while read line; do
+        # remove right comment
+        line=$(echo $line | tr -d '\n')
+        line=$(echo $line | tr -d '\r')
+        line="${line%%\#*}"
+
+        attr=$(echo $line | cut -d'=' -f1)
+        attr=$(echo $attr | tr -d ' ')
+        if [ "$attr" == "enable-cbcrInterleave" ]; then
+            value=$(echo $line | cut -d '=' -f3)
+        else
+            value=$(echo $line | cut -d'=' -f2)
+        fi
+        if [ "$attr" != "MODE_COMP" ]; then
+            value=$(echo $value | tr -d ' ')
+        fi
+
+        case "$attr" in
+            default)                default_opt="$value";;
+            product)                g_product_name="$value";;
+            core)                   g_num_cores_temp="$value"
+                                    g_multi_vcore=1;;
+            secondary-axi)          secondary_axi_temp="$value";;
+            enable-cbcrInterleave)  nv21_temp="$value";;
+            enable_nv21)            nv21_temp="$value";;
+            yuv_src_mode)           g_yuv_mode_temp="$value";;
+            srcFormat)              srcFormat_temp="$value";;
+            stream-endian)          stream_endian_temp="$value";;
+            source-endian)          source_endian_temp="$value";;
+            frame-endian)           frame_endian_temp="$value";;                  
+            bsmode)                 bsmode_temp="$value";;
+            rotAngle)               rotAngle_temp="$value";;
+            mirDir)                 mirDir_temp="$value";;
+            lowLatencyMode)         g_lowLatencyMode_temp="$value";;
+            cframe)                 g_cframe_temp="$value";;
+            cframelossless)         g_cframelossless_temp="$value";;
+            cframetx16y)            g_cframetx16y_temp="$value";;
+            cframetx16c)            g_cframetx16c_temp="$value";;
+            cframe_422)             g_cframe_422_temp="$value";;
+            MODE_COMP_ENCODED)      MODE_COMP_ENCODED_temp="$value";;
+            sfs)                    g_subFrameSync_temp="$value";;
+            ring)                   g_ringBuffer_temp="$value";;
+            n)                      g_frame_num="-n $value"
+                                    if [ "$value" = "0" ]; then
+                                        frame_num_refc=""
+                                    else
+                                        frame_num_refc="-f $value"
+                                    fi;;
+            txt-param)              txt_param_switch=1;;
+            *) ;;
+        esac
+    done < $input_param_name
+else
+    if [ ! -f "$input_param_name" ]; then
+        echo " $input_param_name file doesn't exist"; 
+    fi
+fi
+
+streamset_path=$1
+echo "streamset_path=$1"
+streamset_file=`basename ${streamset_path}`
+
+if [ ! -f "${streamset_path}" ]; then
+    echo "No such file: ${streamset_path}"
+    exit 1
+fi
+
+################################################################################
+# calculate stream number                                                      #
+################################################################################
+stream_file_array=()
+index=0
+num_of_streams=0
+while read line || [ -n "$line" ]; do
+    line=$(echo $line | tr -d '\n')
+    line=$(echo $line | tr -d '\r')
+    line=${line#*( )}   # remove front whitespace
+    line=$(echo $line | cut -d' ' -f1)
+    firstchar=${line:0:1}
+    case "$firstchar" in
+        "@") break;;        # exit flag
+        "#") continue;;     # comment
+        ";") continue;;     # comment
+        "")  continue;;     # comment
+        *)
+    esac
+    stream_file_array[$index]="$line"
+    index=$(($index + 1))
+done < ${streamset_path}
+
+
+num_of_streams=${#stream_file_array[@]}
+#echo ${stream_file_array[@]}
+
+count=1
+success_count=0
+failure_count=0
+remain_count=${num_of_streams}
+basedir=${basedir//\/}  # remove last delimeter
+
+mkdir -p temp
+mkdir -p output
+mkdir -p log/encoder_conformance
+conf_log_path="log/encoder_conformance/${streamset_file}_r${g_revision}.log"
+conf_err_log_path="log/encoder_conformance/${streamset_file}_error_r${g_revision}.log"
+
+temp_log_path="./temp/temp.log"
+# truncate contents of log file
+echo "" > $conf_log_path
+echo "" > $conf_err_log_path
+echo "" > $temp_log_path
+beginTime=$(date +%s%N)
+
+################################################################################
+# read cfg file.                                                               #
+################################################################################
+force_reset=0
+for line in ${stream_file_array[@]}; do
+    cfg_path="${cfg_dir}/${line}"
+    cfg_base_path=$(dirname $line)
+    cfg_base_name=$(basename $line)
+    if [ "$cfg_base_path" == "" ]; then
+        cfg_base_path="."
+    fi
+
+    test_param=""
+    if [ ! -f ${cfg_path} ]; then
+        echo "cfg not exist, cfg_path=$cfg_path" >> $conf_err_log_path
+        echo "[RESULT] FAILURE" >> $conf_err_log_path
+        count=$(($count + 1))
+        failure_count=$(($failure_count + 1))
+        remain_count=$(($remain_count - 1))
+        continue
+    fi
+
+    read_cfg $cfg_path
+
+#default value
+    MODE_COMP_ENCODED_temp=1            #MODE_COMP_ENCODED(bit_stream)
+    if [ "$haps" = "1" ]; then
+        ACLK_MIN=${ACLK_MIN_HAPS}
+        BCLK_MIN=${BCLK_MIN_HAPS}
+        CCLK_MIN=${CCLK_MIN_HAPS}
+        ACLK_MAX=${ACLK_MAX_HAPS}
+        BCLK_MAX=${BCLK_MAX_HAPS}
+        CCLK_MAX=${CCLK_MAX_HAPS}
+        KHz_clock=1
+    elif [ "board" == "vu440" ] || [ "board" == "haps" ]; then
+        ACLK_MIN=${ACLK_MIN_VU440}
+        BCLK_MIN=${BCLK_MIN_VU440}
+        CCLK_MIN=${CCLK_MIN_VU440}
+        ACLK_MAX=${ACLK_MAX_VU440}
+        BCLK_MAX=${BCLK_MAX_VU440}
+        CCLK_MAX=${CCLK_MAX_VU440}
+        KHz_clock=1
+    else
+        ACLK_MIN=${ACLK_MIN_2000T}
+        BCLK_MIN=${BCLK_MIN_2000T}
+        CCLK_MIN=${CCLK_MIN_2000T}
+        if [ "$g_codec_index" = "12" ]; then #hevc
+            ACLK_MAX=${ACLK_HEVC_MAX_2000T}
+            BCLK_MAX=${BCLK_HEVC_MAX_2000T}
+            CCLK_MAX=${CCLK_HEVC_MAX_2000T}
+        else
+            ACLK_MAX=${ACLK_AVC_MAX_2000T}
+            BCLK_MAX=${BCLK_AVC_MAX_2000T}
+            CCLK_MAX=${CCLK_AVC_MAX_2000T}
+        fi
+    fi
+
+    if [ $enable_random == 1 ] && [ $txt_param_switch == 0 ]; then
+        get_random_param 0 $g_product_name
+    else
+        get_default_param 0 $g_product_name
+    fi
+
+    g_secondary_axi=$(($g_secondary_axi >> 1))
+
+################################################################################
+# check minimum size with rotation                                             #
+################################################################################
+    if [ "$g_product_name" = "wave521c_dual" ]; then   
+        g_rotAngle=0
+        g_mirDir=0
+    fi
+    if [ "$g_rotAngle" == "90"  ] || [ "$g_rotAngle" == "270" ]; then
+        if [ "$cfg_height" -lt "256" ] || [ "$cfg_width" -lt "128" ]; then 
+            echo "width=$cfg_width, height=$cfg_height rot=$g_rotAngle"
+            echo "[ERR] Not support src_width < 128 || src_height < 256 with 90, 270 degree rotation"
+            echo "[ERR] change rotAngle value to 0"
+            g_rotAngle=0
+        fi
+    fi
+
+################################################################################
+# check dual_core condition
+################################################################################
+    if [ "$g_ringBuffer" == "1" ] || [ "$g_ringBuffer" == "2" ]; then
+        if [ $cfg_WaveFrontSynchro != 0 ]; then
+            echo "========================================================"
+            echo "disable ringBuffer(WaveFrontSynchro & ringbuffer enabled. not supported)"
+            echo "========================================================"
+            g_ringBuffer=0
+        fi
+    fi
+
+################################################################################
+# make argv parameter                                                          #
+################################################################################
+
+    #reset after hangup
+    backup=$g_fpga_reset
+    if [ $force_reset -eq 1 ]; then
+        g_fpga_reset=1
+        force_reset=0
+    fi
+
+    #make argc & argv parameter
+    build_test_param 0 
+    g_fpga_reset=$backup
+
+    test_param="${test_param} $g_func_ret_str"
+
+    if   [ "$g_rotAngle" == "0"   ] && [ "$g_mirDir" == "0" ]; then rot_arg=0
+    elif [ "$g_rotAngle" == "180" ] && [ "$g_mirDir" == "3" ]; then rot_arg=0
+    elif [ "$g_rotAngle" == "90"  ] && [ "$g_mirDir" == "0" ]; then rot_arg=1
+    elif [ "$g_rotAngle" == "270" ] && [ "$g_mirDir" == "3" ]; then rot_arg=1
+    elif [ "$g_rotAngle" == "180" ] && [ "$g_mirDir" == "0" ]; then rot_arg=2
+    elif [ "$g_rotAngle" == "0"   ] && [ "$g_mirDir" == "3" ]; then rot_arg=2
+    elif [ "$g_rotAngle" == "270" ] && [ "$g_mirDir" == "0" ]; then rot_arg=3
+    elif [ "$g_rotAngle" == "90"  ] && [ "$g_mirDir" == "3" ]; then rot_arg=3
+    elif [ "$g_rotAngle" == "0"   ] && [ "$g_mirDir" == "2" ]; then rot_arg=6
+    elif [ "$g_rotAngle" == "180" ] && [ "$g_mirDir" == "1" ]; then rot_arg=6
+    elif [ "$g_rotAngle" == "90"  ] && [ "$g_mirDir" == "2" ]; then rot_arg=7
+    elif [ "$g_rotAngle" == "270" ] && [ "$g_mirDir" == "1" ]; then rot_arg=7
+    elif [ "$g_rotAngle" == "180" ] && [ "$g_mirDir" == "2" ]; then rot_arg=4
+    elif [ "$g_rotAngle" == "0"   ] && [ "$g_mirDir" == "1" ]; then rot_arg=4
+    elif [ "$g_rotAngle" == "270" ] && [ "$g_mirDir" == "2" ]; then rot_arg=5
+    elif [ "$g_rotAngle" == "90"  ] && [ "$g_mirDir" == "1" ]; then rot_arg=5
+    fi
+
+    output_filename="$(basename $line).bin"
+    test_param="${test_param} --output=$output_filename --cfgFileName=$cfg_path"
+
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    if [[ "$cfg_path" == *"larc"* ]]; then
+        #set cfgFileName_larc_pass1
+        cfg_path_pass1=`echo ${cfg_path} | sed 's/pass2/pass1/'`
+        test_param="${test_param} --cfgFileName_larc_pass1=$cfg_path_pass1"
+
+    fi
+#endif
+    test_param="${test_param} $g_frame_num"
+    
+    yuv_path="${yuv_dir}/${cfg_InputFile}"
+
+
+    file_name=${cfg_BitstreamFile%.*}
+    file_ext=${cfg_BitstreamFile##*.}
+    
+    ref_stream_path="${ref_dir}/${cfg_base_path}/${file_name}_${rot_arg}.${file_ext}"
+    if [ "$simulation" == "true" ]; then
+         test_param="${test_param} --input=${yuv_path}"
+    fi
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    if [[ "$cfg_path" == *"larc"* ]]; then
+        test_param="${test_param} --input_larc_pass1=${larc_pass1_input_param}"
+    fi
+#endif
+    test_param="${test_param} --ref_stream_path=${ref_stream_path}"
+
+################################################################################
+# print information                                                            #
+################################################################################
+    log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
+    log_conf "[${count}/${num_of_streams}] ${cfg_path}" ${temp_log_path}
+    log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
+
+    log_conf "yuv_path          : $yuv_path" $temp_log_path
+    log_conf "ref_stream_path   : $ref_stream_path" $temp_log_path
+    log_conf "width X Height    : $cfg_width X $cfg_height" $temp_log_path
+    log_conf "BitstreamFile     : $cfg_BitstreamFile" $temp_log_path
+    log_conf "-------------------------------------------" $temp_log_path
+    log_conf "RANDOM TEST       : ${ON_OFF[$enable_random]}" $temp_log_path
+    log_conf "SEC AXI           : ${g_secondary_axi}, 0x01:RDO, 0x02:LF" $temp_log_path
+    log_conf "BITSTREAM MODE    : ${ENC_WAVE_BSMODE_NAME[$g_ringBuffer]}" $temp_log_path
+    log_conf "Endian            : ${g_stream_endian}, ${g_frame_endian}, ${g_source_endian}" $temp_log_path
+    log_conf "Standard          : ${CODEC_NAME[$g_codec_index]}" $temp_log_path
+    if  [ "$g_cframe" == "1" ]; then
+        log_conf "Input Format      : CFRAME " $temp_log_path
+        log_conf "      lossless    : $g_cframelossless " $temp_log_path
+        log_conf "      tx16 y      : $g_cframetx16y" $temp_log_path
+        log_conf "      tx16 c      : $g_cframetx16c" $temp_log_path
+        log_conf "      422         : $g_cframe_422" $temp_log_path
+    elif  [ "$g_packedFormat" == "1" ]; then
+        log_conf "Input Format      : (${g_packedFormat})YUYV" $temp_log_path
+    elif  [ "$g_packedFormat" == "2" ]; then
+        log_conf "Input Format      : (${g_packedFormat})YVYU" $temp_log_path
+    elif  [ "$g_packedFormat" == "3" ]; then
+        log_conf "Input Format      : (${g_packedFormat})UYVY" $temp_log_path
+    elif  [ "$g_packedFormat" == "4" ]; then
+        log_conf "Input Format      : (${g_packedFormat})VYUY" $temp_log_path
+    elif [ $g_cbcr_interleave -eq 1 ]; then
+        if [ "$g_enable_nv21" == "0" ] || [ "$g_enable_nv21" == "1" ]; then
+            log_conf "Input Format      : cbcrInterleave nv21=${g_enable_nv21}" $temp_log_path
+        fi
+    else
+        log_conf "Input Format      : 420 Planar" $temp_log_path
+    fi
+    log_conf "srcFormat         : ${SRC_FORMAT_NAME[$g_srcFormat]}" $temp_log_path
+    log_conf "Rotation          : ${g_rotAngle}" $temp_log_path
+    if [ "$g_mirDir" == "0" ]; then
+        log_conf "Mirror            : (${g_mirDir})NONE" $temp_log_path
+    elif [ "$g_mirDir" == "1" ]; then
+        log_conf "Mirror            : (${g_mirDir})Vertical" $temp_log_path
+    elif [ "$g_mirDir" == "2" ]; then
+        log_conf "Mirror            : (${g_mirDir})Horizontal" $temp_log_path
+    else
+        log_conf "Mirror            : (${g_mirDir})Vert-Horz" $temp_log_path
+    fi
+    log_conf "rot_arg           : $rot_arg" $temp_log_path
+    log_conf "LOW LATENCY       : ${g_lowLatencyMode}, 0x01:interrupt, 0x02:fast bitstream-packing" $temp_log_path
+    log_conf "--------------------------------------------------------------------------------" $temp_log_path
+
+################################################################################
+# make ref-prebuilt stream                                                     #
+################################################################################
+    if [ ! -f "$ref_stream_path" ] || [ $build_stream -eq 1 ]; then
+        ref_stream_base_dir=$(dirname $ref_stream_path)
+        if [ ! -d "$ref_stream_base_dir" ]; then
+            mkdir -p "$ref_stream_base_dir"
+	        chmod 755 "$ref_stream_base_dir"
+            echo "CREATE REF-STREAM DIR: $ref_stream_base_dir"
+        fi
+        if [ "$g_num_cores" == "2" ]; then
+            REF_C_EXEC_PARAM="-c $cfg_path -p ${yuv_base_path}/ -b temp.bin $extra_param $frame_num_refc --NumCores=2"
+        else
+            REF_C_EXEC_PARAM="-c $cfg_path -p ${yuv_base_path}/ -b temp.bin $extra_param $frame_num_refc"
+        fi
+        rm -rf temp.bin || echo ignore_err
+        echo "$ref_c_exec $REF_C_EXEC_PARAM"
+        result=0
+        $ref_c_exec $REF_C_EXEC_PARAM || result=1
+        if [ "$result" != "0" ]; then
+            echo "ref-c error"
+            remain_count=$(($remain_count - 1))
+            count=$(($count + 1))
+            continue
+        fi
+        if [ -s temp.bin ]; then
+            echo "cp -v temp.bin $ref_stream_path"
+            cp -v temp.bin $ref_stream_path
+        fi
+        if [ $build_stream -eq 1 ]; then
+            remain_count=$(($remain_count - 1))
+            count=$(($count + 1))
+            continue
+        fi
+    fi
+
+################################################################################
+# run Test                                                                     #
+################################################################################
+    result=0
+    test_param_print=$test_param
+    log_conf "$test_exec $test_param_print" $temp_log_path
+    cat $temp_log_path >> $conf_log_path
+
+    test_exec_param="$test_exec $test_param"
+
+    result=0
+    if [ "$simulation" == "true" ]; then
+        test_exec_param="$test_exec_param $g_w_param $g_fsdb_param $g_ius_param --TestRunner=1"
+        set -o pipefail; $test_exec_param 2>&1 | tee -a $conf_log_path || result=1
+    else
+        $test_exec_param || result=$?
+    fi
+    if [ $result -eq $RET_HANGUP ]; then
+        force_reset=1
+    fi
+
+    if [ "$result" == "0" ]; then
+        log_conf "[RESULT] SUCCESS" $conf_log_path
+        success_count=$(($success_count + 1))
+    else
+        cat ./ErrorLog.txt >> $conf_log_path 
+        log_conf "[RESULT] FAILURE" $conf_log_path
+        failure_count=$(($failure_count + 1))
+        cat $temp_log_path >> $conf_err_log_path
+        cat ./ErrorLog.txt >> $conf_err_log_path
+        echo "[RESULT] FAILURE" >> $conf_err_log_path
+        if [ $result -eq 10 ]; then
+            echo "Abnormal exit!!!"
+            break
+        fi
+    fi
+    remain_count=$(($remain_count - 1))
+    count=$(($count + 1))
+    # clear temp log
+    echo ${cfg_path}
+    echo "" > $temp_log_path
+done 
+
+
+endTime=$(date +%s%N)
+elapsed=$((($endTime - $beginTime) / 1000000000))
+elapsedH=$(($elapsed / 3600))
+elapsedS=$(($elapsed % 60))
+elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
+if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
+if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
+if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
+
+if [ $elapsed -le 30 ]; then
+    time_hms="{color:red}*${elapsedH}:${elapsedM}:${elapsedS}*{color}"
+else
+    time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
+fi
+
+log_filename=$(basename $conf_log_path)
+log_err_filename=$(basename $conf_err_log_path)
+if [ $failure_count == 0 ] && [ $num_of_streams != 0 ]; then
+    pass=${PASS}
+    rm $conf_err_log_path
+    log_err_filename=""
+else
+    pass=${FAIL}
+fi
+
+wiki_log="| $streamset_file | $num_of_streams | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | |"
+
+echo $wiki_log
+echo "$wiki_log" >> $wiki_log_file
+
+
+if [ "$num_of_streams" == "0" ]; then
+    echo "num_of_streams: $num_of_streams = exit 1"
+    exit 1
+fi
+
+exit $failure_count
+ 

+ 50 - 0
soft_3rdpart/wave511/code/WaveDecDriver.mak

@@ -0,0 +1,50 @@
+# Comment/uncomment the	following line to disable/enable debugging
+#DEBUG = y
+
+# Add your debugging flag (or not) to CFLAGS
+ifeq ($(DEBUG),y)
+  DEBFLAGS = -O	-g # "-O" is needed to expand inlines
+else
+  DEBFLAGS = -O2
+endif
+
+export CC="$(CROSS_COMPILE)gcc"
+export AR="$(CROSS_COMPILE)ar"
+export CXX="${CROSS_COMPILE}g++"
+export AS="${CROSS_COMPILE}as"
+export LD="${CROSS_COMPILE}ld"
+export RANLIB="${CROSS_COMPILE}ranlib"
+export READELF="${CROSS_COMPILE}readelf"
+export STRIP="${CROSS_COMPILE}strip"
+
+DRV_PATH  := $(PWD)/vdi/linux/driver
+EXTRA_CFLAGS +=	$(DEBFLAGS) -I$(LDDINCDIR) -Wno-unused-function
+
+ifneq ($(KERNELRELEASE),)
+# call from kernel build system
+
+obj-m	:= vdec.o
+
+else
+
+KERNELDIR := ../../../work/linux
+
+PWD	  := $(shell pwd)
+
+default:
+	$(MAKE)	-C $(KERNELDIR)	M=$(DRV_PATH) LDDINCDIR=$(DRV_PATH)/../include modules
+
+endif
+
+
+
+clean:
+	rm -rf $(DRV_PATH)/*.o $(DRV_PATH)/*~ $(DRV_PATH)/core $(DRV_PATH)/.depend $(DRV_PATH)/.*.cmd $(DRV_PATH)/*.ko $(DRV_PATH)/*.mod.c $(DRV_PATH)/modules.order $(DRV_PATH)/.tmp_versions $(DRV_PATH)/*.dwo $(DRV_PATH)/.*.dwo
+
+depend .depend dep:
+	$(CC) $(CFLAGS)	-M *.c > .depend
+
+
+ifeq (.depend,$(wildcard .depend))
+include	.depend
+endif

+ 41 - 0
soft_3rdpart/wave511/code/WaveDecDriver_buildroot.mak

@@ -0,0 +1,41 @@
+# Comment/uncomment the	following line to disable/enable debugging
+#DEBUG = y
+
+# Add your debugging flag (or not) to CFLAGS
+ifeq ($(DEBUG),y)
+  DEBFLAGS = -O	-g # "-O" is needed to expand inlines
+else
+  DEBFLAGS = -O2
+endif
+
+export ARCH=riscv
+export SUBARCH=riscv
+export CROSS_COMPILE=riscv64-buildroot-linux-gnu-
+
+DRV_PATH  := $(shell pwd)/vdi/linux/driver
+EXTRA_CFLAGS +=	$(DEBFLAGS) -I$(LDDINCDIR) -Wno-unused-function
+
+ifneq ($(KERNELRELEASE),)
+# call from kernel build system
+
+obj-m	:= vdec.o
+
+else
+
+default:
+	$(MAKE) -C $(KERNELDIR)	M=$(DRV_PATH) LDDINCDIR=$(DRV_PATH)/../include modules
+
+endif
+
+
+
+clean:
+	rm -rf $(DRV_PATH)/*.o $(DRV_PATH)/*~ $(DRV_PATH)/core $(DRV_PATH)/.depend $(DRV_PATH)/.*.cmd $(DRV_PATH)/*.ko $(DRV_PATH)/*.mod.c $(DRV_PATH)/modules.order $(DRV_PATH)/.tmp_versions $(DRV_PATH)/*.dwo $(DRV_PATH)/.*.dwo
+
+depend .depend dep:
+	$(CC) $(CFLAGS)	-M *.c > .depend
+
+
+ifeq (.depend,$(wildcard .depend))
+include	.depend
+endif

+ 184 - 0
soft_3rdpart/wave511/code/WaveDecode-ffmpeg.mak

@@ -0,0 +1,184 @@
+# ----------------------------------------------------------------------
+#
+# Project: C&M Video decoder sample
+#
+# ----------------------------------------------------------------------
+.PHONY: CREATE_DIR
+BUILD_CONFIGURATION := EmbeddedRiscvLinux
+
+PRODUCT := WAVE511
+PRODUCT := WAVE521C
+
+$(shell cp sample_v2/component_list_decoder.h sample_v2/component/component_list.h)
+
+USE_FFMPEG  = yes
+USE_PTHREAD = yes
+USE_RTL_SIM = no
+LINT_HOME   = etc/lint
+
+UNAME = $(shell uname -a)
+ifneq (,$(findstring i386, $(UNAME)))
+    USE_32BIT = yes
+endif
+
+ifeq ($(RTL_SIM), 1)
+USE_RTL_SIM = yes
+endif
+
+REFC    := 0
+
+ifeq ($(USE_32BIT), yes)
+PLATFORM    = nativelinux
+else
+PLATFORM    = nativelinux_64bit
+endif
+
+CROSS_CC_PREFIX =
+VDI_C           = vdi/linux/vdi.c
+VDI_OSAL_C      = vdi/linux/vdi_osal.c
+MM_C            =
+PLATFORM_FLAGS  =
+
+VDI_VPATH       = vdi/linux
+ifeq ("$(BUILD_CONFIGURATION)", "NonOS")
+    CROSS_CC_PREFIX = arm-none-eabi-
+    VDI_C           = vdi/nonos/vdi.c
+    VDI_OSAL_C      = vdi/nonos/vdi_osal.c
+    MM_C            = vdi/mm.c
+    USE_FFMPEG      = no
+    USE_PTHREAD     = no
+    PLATFORM        = none
+    DEFINES         = -DLIB_C_STUB
+    PLATFORM_FLAGS  =
+    VDI_VPATH       = vdi/nonos
+    NONOS_RULE      = options_nonos.lnt
+endif
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedLinux")
+    CROSS_CC_PREFIX = arm-none-linux-gnueabi-
+    PLATFORM        = armlinux
+endif
+
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedRiscvLinux")
+    CROSS_CC_PREFIX = riscv64-buildroot-linux-gnu-
+    PLATFORM        = riscvlinux
+endif
+CC  = $(CROSS_CC_PREFIX)gcc
+CXX = $(CROSS_CC_PREFIX)g++
+LINKER=$(CC)
+AR  = $(CROSS_CC_PREFIX)ar
+
+INCLUDES = -I./vpuapi -I./ffmpeg/include -I./sample_v2/helper -I./sample_v2/helper/misc -I./sample_v2/component -I./vdi
+INCLUDES += -I./sample_v2/component_decoder
+ifeq ($(USE_RTL_SIM), yes)
+DEFINES += -DCNM_SIM_PLATFORM -DCNM_SIM_DPI_INTERFACE -DSUPPORT_DECODER
+DEFINES += -D$(PRODUCT) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+else
+DEFINES += -D$(PRODUCT) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+endif	# USE_SIM_PLATFORM
+
+
+CFLAGS  += -g -I. -Wno-implicit-function-declaration -Wno-format -Wl,--fatal-warning $(INCLUDES) $(DEFINES) $(PLATFORM_FLAGS)
+ifeq ($(USE_RTL_SIM), yes)
+ifeq ($(IUS), 1)
+CFLAGS  += -fPIC # ncverilog is 64bit version
+endif
+endif
+ARFLAGS += cru
+
+LDFLAGS  = $(PLATFORM_FLAGS)
+
+
+ifeq ($(USE_FFMPEG), yes)
+CFLAGS  += -DSUPPORT_FFMPEG_DEMUX
+LDLIBS  += -lavformat -lavcodec -lavutil -lswresample
+LDFLAGS += -L./ffmpeg/lib/$(PLATFORM)
+ifneq ($(USE_32BIT), yes)
+#LDLIBS  += -lz
+endif #USE_32BIT
+endif #USE_FFMPEG
+
+ifeq ($(USE_PTHREAD), yes)
+LDLIBS  += -lpthread
+endif
+LDLIBS  += -lm
+
+BUILDLIST=DECTEST
+MAKEFILE=WaveDecode.mak
+ifeq ($(USE_FFMPEG), yes)
+DECTEST=ffmpeg_dec_test
+else
+DECTEST=dec_test
+endif
+
+OBJDIR=obj
+ALLOBJS=*.o
+ALLDEPS=*.dep
+ALLLIBS=*.a
+RM=rm -f
+MKDIR=mkdir -p
+
+SOURCES_COMMON =main_helper.c                   vpuhelper.c                 bitstreamfeeder.c           \
+                bitstreamreader.c               bsfeeder_fixedsize_impl.c   bsfeeder_framesize_impl.c   \
+                bsfeeder_size_plus_es_impl.c    bin_comparator_impl.c       comparator.c                \
+                md5_comparator_impl.c           yuv_comparator_impl.c       \
+                cfgParser.c                     decoder_listener.c          \
+                cnm_video_helper.c              container.c                 \
+                datastructure.c                 debug.c                     \
+                bw_monitor.c                    pf_monitor.c                \
+                cnm_app.c                       cnm_task.c                  component.c                 \
+                component_dec_decoder.c         component_dec_feeder.c      component_dec_renderer.c    \
+                product.c                       vpuapifunc.c                vpuapi.c                    \
+                coda9.c                         wave5.c                     \
+                $(VDI_C)                        $(VDI_OSAL_C)               $(MM_C)
+
+
+
+VPATH  = sample_v2:
+VPATH += sample_v2/component_encoder:
+VPATH += sample_v2/component_decoder:
+VPATH += sample_v2/helper:
+VPATH += sample_v2/helper/bitstream:
+VPATH += sample_v2/helper/comparator:
+VPATH += sample_v2/helper/display:sample_v2/helper/misc:sample_v2/helper/yuv:sample_v2/component:
+VPATH += vdi:
+VPATH += $(VDI_VPATH):vpuapi:vpuapi/coda9:vpuapi/wave
+
+VPATH2=$(patsubst %,-I%,$(subst :, ,$(VPATH)))
+
+OBJECTNAMES_COMMON=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES_COMMON)))
+OBJECTPATHS_COMMON=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_COMMON)))
+
+SOURCES_DECTEST = sample_v2/main_dec_test.c
+ifeq ($(USE_RTL_SIM), yes)
+	SOURCES_DECTEST += sample/main_sim.c
+endif
+
+OBJECTNAMES_DECTEST=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES_DECTEST)))
+OBJECTPATHS_DECTEST=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_DECTEST))) $(OBJECTPATHS_COMMON)
+
+all: $(BUILDLIST)
+
+ifeq ($(USE_RTL_SIM), yes)
+DECTEST: CREATE_DIR $(OBJECTPATHS_DECTEST)
+else
+DECTEST: CREATE_DIR $(OBJECTPATHS_DECTEST)
+	$(LINKER) -o $(DECTEST) $(LDFLAGS) -Wl,-gc-section -Wl,--start-group $(OBJECTPATHS_DECTEST) $(LDLIBS) -Wl,--end-group
+endif
+
+-include $(OBJECTPATHS:.o=.dep)
+
+clean:
+	$(RM) $(DECTEST)
+	$(RM) $(OBJDIR)/$(ALLOBJS)
+	$(RM) $(OBJDIR)/$(ALLDEPS)
+
+CREATE_DIR:
+	-mkdir -p $(OBJDIR)
+
+obj/%.o: %.c $(MAKEFILE)
+	$(CC) $(CFLAGS) -Wall -Werror -c $< -o $@ -MD -MF $(@:.o=.dep)
+
+
+lint:
+	"$(LINT_HOME)/flint" -i"$(LINT_HOME)" $(DEFINES) $(INCLUDES) $(VPATH2) linux_std.lnt $(HAPS_RULE) $(NONOS_RULE)  $(SOURCES_COMMON)
+

+ 168 - 0
soft_3rdpart/wave511/code/WaveDecode.mak

@@ -0,0 +1,168 @@
+# ----------------------------------------------------------------------
+#
+# Project: C&M Video decoder sample
+#
+# ----------------------------------------------------------------------
+.PHONY: CREATE_DIR
+BUILD_CONFIGURATION := EmbeddedRiscvLinux
+
+PRODUCT := WAVE511
+PRODUCT := WAVE521C
+
+$(shell cp sample_v2/component_list_decoder.h sample_v2/component/component_list.h)
+
+USE_PTHREAD = yes
+USE_RTL_SIM = no
+LINT_HOME   = etc/lint
+
+UNAME = $(shell uname -a)
+ifneq (,$(findstring i386, $(UNAME)))
+    USE_32BIT = yes
+endif
+
+ifeq ($(RTL_SIM), 1)
+USE_RTL_SIM = yes
+endif
+
+REFC    := 0
+
+ifeq ($(USE_32BIT), yes)
+PLATFORM    = nativelinux
+else
+PLATFORM    = nativelinux_64bit
+endif
+
+CROSS_CC_PREFIX =
+VDI_C           = vdi/linux/vdi.c
+VDI_OSAL_C      = vdi/linux/vdi_osal.c
+MM_C            =
+PLATFORM_FLAGS  =
+
+VDI_VPATH       = vdi/linux
+ifeq ("$(BUILD_CONFIGURATION)", "NonOS")
+    CROSS_CC_PREFIX = arm-none-eabi-
+    VDI_C           = vdi/nonos/vdi.c
+    VDI_OSAL_C      = vdi/nonos/vdi_osal.c
+    MM_C            = vdi/mm.c
+    USE_PTHREAD     = no
+    PLATFORM        = none
+    DEFINES         = -DLIB_C_STUB
+    PLATFORM_FLAGS  =
+    VDI_VPATH       = vdi/nonos
+    NONOS_RULE      = options_nonos.lnt
+endif
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedLinux")
+    CROSS_CC_PREFIX = arm-none-linux-gnueabi-
+    PLATFORM        = armlinux
+endif
+
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedRiscvLinux")
+    CROSS_CC_PREFIX = riscv64-buildroot-linux-gnu-
+    PLATFORM        = riscvlinux
+endif
+CC  = $(CROSS_CC_PREFIX)gcc
+CXX = $(CROSS_CC_PREFIX)g++
+LINKER=$(CC)
+AR  = $(CROSS_CC_PREFIX)ar
+
+INCLUDES = -I./vpuapi -I./ffmpeg/include -I./sample_v2/helper -I./sample_v2/helper/misc -I./sample_v2/component -I./vdi
+INCLUDES += -I./sample_v2/component_decoder
+ifeq ($(USE_RTL_SIM), yes)
+DEFINES += -DCNM_SIM_PLATFORM -DCNM_SIM_DPI_INTERFACE -DSUPPORT_DECODER
+DEFINES += -D$(PRODUCT) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+else
+DEFINES += -D$(PRODUCT) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+endif	# USE_SIM_PLATFORM
+
+
+CFLAGS  += -g -I. -Wno-implicit-function-declaration -Wno-format -Wl,--fatal-warning $(INCLUDES) $(DEFINES) $(PLATFORM_FLAGS)
+ifeq ($(USE_RTL_SIM), yes)
+ifeq ($(IUS), 1)
+CFLAGS  += -fPIC # ncverilog is 64bit version
+endif
+endif
+ARFLAGS += cru
+
+LDFLAGS  = $(PLATFORM_FLAGS)
+
+ifeq ($(USE_PTHREAD), yes)
+LDLIBS  += -lpthread
+endif
+LDLIBS  += -lm
+
+BUILDLIST=DECTEST
+MAKEFILE=WaveDecode.mak
+DECTEST=dec_test
+
+OBJDIR=obj
+ALLOBJS=*.o
+ALLDEPS=*.dep
+ALLLIBS=*.a
+RM=rm -f
+MKDIR=mkdir -p
+
+SOURCES_COMMON =main_helper.c                   vpuhelper.c                 bitstreamfeeder.c           \
+                bitstreamreader.c               bsfeeder_fixedsize_impl.c   bsfeeder_framesize_impl.c   \
+                bsfeeder_size_plus_es_impl.c    bin_comparator_impl.c       comparator.c                \
+                md5_comparator_impl.c           yuv_comparator_impl.c       \
+                cfgParser.c                     decoder_listener.c          \
+                cnm_video_helper.c              container.c                 \
+                datastructure.c                 debug.c                     \
+                bw_monitor.c                    pf_monitor.c                \
+                cnm_app.c                       cnm_task.c                  component.c                 \
+                component_dec_decoder.c         component_dec_feeder.c      component_dec_renderer.c    \
+                product.c                       vpuapifunc.c                vpuapi.c                    \
+                coda9.c                         wave5.c                     \
+                $(VDI_C)                        $(VDI_OSAL_C)               $(MM_C)
+
+
+
+VPATH  = sample_v2:
+VPATH += sample_v2/component_encoder:
+VPATH += sample_v2/component_decoder:
+VPATH += sample_v2/helper:
+VPATH += sample_v2/helper/bitstream:
+VPATH += sample_v2/helper/comparator:
+VPATH += sample_v2/helper/display:sample_v2/helper/misc:sample_v2/helper/yuv:sample_v2/component:
+VPATH += vdi:
+VPATH += $(VDI_VPATH):vpuapi:vpuapi/coda9:vpuapi/wave
+
+VPATH2=$(patsubst %,-I%,$(subst :, ,$(VPATH)))
+
+OBJECTNAMES_COMMON=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES_COMMON)))
+OBJECTPATHS_COMMON=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_COMMON)))
+
+SOURCES_DECTEST = sample_v2/main_dec_test.c
+ifeq ($(USE_RTL_SIM), yes)
+	SOURCES_DECTEST += sample/main_sim.c
+endif
+
+OBJECTNAMES_DECTEST=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES_DECTEST)))
+OBJECTPATHS_DECTEST=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_DECTEST))) $(OBJECTPATHS_COMMON)
+
+all: $(BUILDLIST)
+
+ifeq ($(USE_RTL_SIM), yes)
+DECTEST: CREATE_DIR $(OBJECTPATHS_DECTEST)
+else
+DECTEST: CREATE_DIR $(OBJECTPATHS_DECTEST)
+	$(LINKER) -o $(DECTEST) $(LDFLAGS) -Wl,-gc-section -Wl,--start-group $(OBJECTPATHS_DECTEST) $(LDLIBS) -Wl,--end-group
+endif
+
+-include $(OBJECTPATHS:.o=.dep)
+
+clean:
+	$(RM) $(DECTEST)
+	$(RM) $(OBJDIR)/$(ALLOBJS)
+	$(RM) $(OBJDIR)/$(ALLDEPS)
+
+CREATE_DIR:
+	-mkdir -p $(OBJDIR)
+
+obj/%.o: %.c $(MAKEFILE)
+	$(CC) $(CFLAGS) -Wall -Werror -c $< -o $@ -MD -MF $(@:.o=.dep)
+
+
+lint:
+	"$(LINT_HOME)/flint" -i"$(LINT_HOME)" $(DEFINES) $(INCLUDES) $(VPATH2) linux_std.lnt $(HAPS_RULE) $(NONOS_RULE)  $(SOURCES_COMMON)
+

+ 239 - 0
soft_3rdpart/wave511/code/WaveDecodeMult.mak

@@ -0,0 +1,239 @@
+# ----------------------------------------------------------------------
+#
+# Project: C&M Video multi instance sample
+#
+# ----------------------------------------------------------------------
+.PHONY: CREATE_DIR LIBTHEORA clean all
+
+BUILD_CONFIGURATION := EmbeddedRiscvLinux
+
+PRODUCT := WAVE511
+#PRODUCT := WAVE521C
+
+$(shell cp sample_v2/component_list_all.h sample_v2/component/component_list.h)
+
+USE_FFMPEG  = no
+USE_PTHREAD = yes
+USE_RTL_SIM = no
+
+UNAME = $(shell uname -a)
+ifneq (,$(findstring i386, $(UNAME)))
+    USE_32BIT = yes
+endif
+
+ifeq ($(RTL_SIM), 1)
+USE_RTL_SIM = yes
+endif
+
+ifeq ($(SINGLE_THREAD), 1)
+    USE_SINGLE_THREAD=yes
+endif
+
+
+ifeq ($(PRODUCT), CODA960)
+    USE_LIBTHEORA=yes
+endif
+ifeq ($(PRODUCT), CODA980)
+    USE_LIBTHEORA=yes
+endif
+
+ifeq ($(USE_32BIT), yes)
+PLATFORM    = nativelinux
+else
+PLATFORM    = nativelinux_64bit
+endif
+
+CROSS_CC_PREFIX =
+VDI_C           = vdi/linux/vdi.c
+VDI_OSAL_C      = vdi/linux/vdi_osal.c
+MM_C            =
+PLATFORM_FLAGS  =
+
+VDI_VPATH       = vdi/linux
+ifeq ("$(BUILD_CONFIGURATION)", "NonOS")
+    CROSS_CC_PREFIX = arm-none-eabi-
+    VDI_C           = vdi/nonos/vdi.c
+    VDI_OSAL_C      = vdi/nonos/vdi_osal.c
+    MM_C            = vdi/mm.c
+    USE_FFMPEG      = no
+    USE_PTHREAD     = no
+    PLATFORM        = none
+    DEFINES         = -DLIB_C_STUB
+    PLATFORM_FLAGS  =
+    VDI_VPATH       = vdi/nonos
+endif
+
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedLinux")
+    CROSS_CC_PREFIX = arm-none-linux-gnueabi-
+    PLATFORM        = armlinux
+endif
+
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedRiscvLinux")
+    CROSS_CC_PREFIX = riscv64-buildroot-linux-gnu-
+    PLATFORM        = riscvlinux
+endif
+
+
+CC  = $(CROSS_CC_PREFIX)gcc
+CXX = $(CROSS_CC_PREFIX)g++
+LINKER=$(CC)
+AR  = $(CROSS_CC_PREFIX)ar
+
+INCLUDES = -I./theoraparser/include -I./vpuapi -I./ffmpeg/include -I./sample_v2/helper -I./sample_v2/helper/misc -I./sample_v2/component -I./vdi
+INCLUDES += -I./sample_v2/component_decoder -I./sample_v2/component_encoder
+DEFINES += -D$(PRODUCT) -DSUPPORT_MULTI_INSTANCE_TEST
+
+ifeq ($(PRODUCT), WAVE521)
+    DEFINES += -DSUPPORT_ENCODER
+endif
+ifeq ($(PRODUCT), WAVE517)
+    DEFINES += -DSUPPORT_ENCODER
+endif
+
+ifeq ($(SCALER), 1)
+    DEFINES += -DSUPPORT_MINI_PIPPEN
+endif
+
+ifeq ($(USE_RTL_SIM), yes)
+    DEFINES += -DCNM_SIM_PLATFORM -DCNM_SIM_DPI_INTERFACE -DSUPPORT_MULTI_INSTANCE_TEST -DUSE_SINGLE_THREAD
+    USE_SINGLE_THREAD=yes
+MM_C            = vdi/mm.c
+else	# USE_RTL_SIM
+endif	# USE_RTL_SIM
+
+ifeq ($(USE_SINGLE_THREAD), yes)
+    DEFINES += -DUSE_SINGLE_THREAD
+endif
+
+ifeq ($(GDI),1)
+DEFINES += -DSUPPORT_WAVE511_GDI
+endif
+
+DEFINES += $(USER_DEFINES)
+CFLAGS  += -g -I. -Wno-implicit-function-declaration -Wno-format -Wl,--fatal-warning $(INCLUDES) $(DEFINES) $(PLATFORM_FLAGS)
+ifeq ($(USE_RTL_SIM), yes)
+ifeq ($(IUS), 1)
+CFLAGS  += -fPIC # ncverilog is 64bit version
+endif
+endif
+ARFLAGS += cru
+
+ifeq ($(USE_LIBTHEORA), yes)
+    LDFLAGS  += $(PLATFORM_FLAGS) -L./theoraparser/
+    LDLIBS   += -ltheoraparser
+endif
+
+ifeq ($(USE_FFMPEG), yes)
+LDLIBS  += -lavformat -lavcodec -lavutil -lswresample -laom
+LDFLAGS += -L./ffmpeg/lib/$(PLATFORM)
+ifneq ($(USE_32BIT), yes)
+LDLIBS  += -lz
+endif #USE_32BIT
+endif #USE_FFMPEG
+
+ifeq ($(USE_PTHREAD), yes)
+LDLIBS  += -lpthread
+endif
+LDLIBS  += -lm
+
+TARGET=multi_instance_dec_test
+MAKEFILE=WaveDecodeMult.mak
+OBJDIR=obj
+ALLOBJS=*.o
+ALLDEPS=*.dep
+ALLLIBS=*.a
+RM=rm -f
+MKDIR=mkdir -p
+
+SOURCES =  main_multi_instance_test.c
+SOURCES += component_enc_encoder.c      \
+          component_enc_feeder.c       \
+          component_enc_reader.c       \
+          encoder_listener.c           \
+           yuvfeeder.c                  \
+           yuvLoaderfeeder.c            \
+           yuvCfbcfeeder.c
+SOURCES += component_dec_decoder.c      \
+          component_dec_feeder.c       \
+          component_dec_renderer.c     \
+          decoder_listener.c           \
+          cnm_app.c                    \
+          cnm_task.c                   \
+          component.c                  \
+          main_helper.c                \
+          vpuhelper.c                  \
+          bitstreamfeeder.c            \
+          bitstreamreader.c            \
+          bsfeeder_fixedsize_impl.c    \
+          bsfeeder_framesize_impl.c    \
+          bsfeeder_size_plus_es_impl.c \
+          bin_comparator_impl.c        \
+          comparator.c                 \
+          md5_comparator_impl.c        \
+          yuv_comparator_impl.c        \
+          cfgParser.c                  \
+          cnm_video_helper.c           \
+          container.c                  \
+          datastructure.c              \
+          debug.c                      \
+          bw_monitor.c                 \
+          pf_monitor.c
+SOURCES += $(VDI_C)                                         \
+          $(VDI_OSAL_C)                                     \
+          $(MM_C)                                           \
+          vpuapi/product.c                                  \
+          vpuapi/vpuapifunc.c                               \
+          vpuapi/vpuapi.c                                   \
+          vpuapi/coda9/coda9.c                              \
+          vpuapi/wave/wave5.c
+
+VPATH  = sample_v2:
+VPATH += sample_v2/component_encoder:
+VPATH += sample_v2/component_decoder:
+VPATH += sample_v2/helper:
+VPATH += sample_v2/helper/bitstream:
+VPATH += sample_v2/helper/comparator:
+VPATH += sample_v2/helper/display:sample_v2/helper/misc:sample_v2/helper/yuv:sample_v2/component:
+VPATH += vdi:
+ifeq ($(HAPS), 1)
+VPATH += vdi/haps
+endif
+ifeq ($(HAPS), 2)
+VPATH += vdi/haps
+endif
+VPATH += $(VDI_VPATH):vpuapi:vpuapi/coda9:vpuapi/wave
+
+OBJECTNAMES=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES)))
+OBJECTPATHS=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES)))
+
+target_list = CREATE_DIR $(OBJECTPATHS)
+ifeq ($(USE_LIBTHEORA), yes)
+    target_list += LIBTHEORA
+endif
+
+ifeq ($(USE_RTL_SIM), yes)
+all: $(target_list)
+else
+all: $(target_list)
+	$(LINKER) -o $(TARGET) $(LDFLAGS) -Wl,-gc-section -Wl,--start-group $(OBJECTPATHS) $(LDLIBS) -Wl,--end-group
+endif
+
+-include $(OBJECTPATHS:.o=.dep)
+
+clean:
+	$(RM) $(TARGET)
+	$(RM) $(OBJDIR)/$(ALLOBJS)
+	$(RM) $(OBJDIR)/$(ALLDEPS)
+	$(RM) theoraparser/$(ALLOBJS)
+	$(RM) theoraparser/$(ALLLIBS)
+	$(RM) theoraparser/$(ALLDEPS)
+
+LIBTHEORA:
+	cd theoraparser; make clean; make
+
+CREATE_DIR:
+	-mkdir -p $(OBJDIR)
+
+obj/%.o: %.c $(MAKEFILE)
+	$(CC) $(CFLAGS) -Wall -Werror -c $< -o $@ -MD -MF $(@:.o=.dep)
+

+ 168 - 0
soft_3rdpart/wave511/code/WaveDecode_buildroot.mak

@@ -0,0 +1,168 @@
+# ----------------------------------------------------------------------
+#
+# Project: C&M Video decoder sample
+#
+# ----------------------------------------------------------------------
+.PHONY: CREATE_DIR
+BUILD_CONFIGURATION := EmbeddedRiscvLinux
+
+PRODUCT := WAVE511
+PRODUCT := WAVE521C
+
+$(shell cp sample_v2/component_list_decoder.h sample_v2/component/component_list.h)
+
+USE_PTHREAD = yes
+USE_RTL_SIM = no
+LINT_HOME   = etc/lint
+
+UNAME = $(shell uname -a)
+ifneq (,$(findstring i386, $(UNAME)))
+    USE_32BIT = yes
+endif
+
+ifeq ($(RTL_SIM), 1)
+USE_RTL_SIM = yes
+endif
+
+REFC    := 0
+
+ifeq ($(USE_32BIT), yes)
+PLATFORM    = nativelinux
+else
+PLATFORM    = nativelinux_64bit
+endif
+
+CROSS_CC_PREFIX =
+VDI_C           = vdi/linux/vdi.c
+VDI_OSAL_C      = vdi/linux/vdi_osal.c
+MM_C            =
+PLATFORM_FLAGS  =
+
+VDI_VPATH       = vdi/linux
+ifeq ("$(BUILD_CONFIGURATION)", "NonOS")
+    CROSS_CC_PREFIX = arm-none-eabi-
+    VDI_C           = vdi/nonos/vdi.c
+    VDI_OSAL_C      = vdi/nonos/vdi_osal.c
+    MM_C            = vdi/mm.c
+    USE_PTHREAD     = no
+    PLATFORM        = none
+    DEFINES         = -DLIB_C_STUB
+    PLATFORM_FLAGS  =
+    VDI_VPATH       = vdi/nonos
+    NONOS_RULE      = options_nonos.lnt
+endif
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedLinux")
+    CROSS_CC_PREFIX = arm-none-linux-gnueabi-
+    PLATFORM        = armlinux
+endif
+
+ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedRiscvLinux")
+    CROSS_CC_PREFIX = riscv64-buildroot-linux-gnu-
+    PLATFORM        = riscvlinux
+endif
+CC  = $(CROSS_CC_PREFIX)gcc
+CXX = $(CROSS_CC_PREFIX)g++
+LINKER=$(CC)
+AR  = $(CROSS_CC_PREFIX)ar
+
+INCLUDES = -I./vpuapi -I./ffmpeg/include -I./sample_v2/helper -I./sample_v2/helper/misc -I./sample_v2/component -I./vdi
+INCLUDES += -I./sample_v2/component_decoder
+ifeq ($(USE_RTL_SIM), yes)
+DEFINES += -DCNM_SIM_PLATFORM -DCNM_SIM_DPI_INTERFACE -DSUPPORT_DECODER
+DEFINES += -D$(PRODUCT) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+else
+DEFINES += -D$(PRODUCT) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+endif	# USE_SIM_PLATFORM
+DEFINES += -DUSE_FEEDING_METHOD_BUFFER
+
+CFLAGS  += -g -I. -Wno-implicit-function-declaration -Wno-format -Wl,--fatal-warning $(INCLUDES) $(DEFINES) $(PLATFORM_FLAGS)
+ifeq ($(USE_RTL_SIM), yes)
+ifeq ($(IUS), 1)
+CFLAGS  += -fPIC # ncverilog is 64bit version
+endif
+endif
+ARFLAGS += cru
+
+LDFLAGS  = $(PLATFORM_FLAGS)
+
+ifeq ($(USE_PTHREAD), yes)
+LDLIBS  += -lpthread
+endif
+LDLIBS  += -lm
+
+BUILDLIST=DECTEST
+MAKEFILE=WaveDecode.mak
+DECTEST=libsfdec.so
+
+OBJDIR=obj
+ALLOBJS=*.o
+ALLDEPS=*.dep
+ALLLIBS=*.a
+RM=rm -f
+MKDIR=mkdir -p
+
+SOURCES_COMMON =main_helper.c                   vpuhelper.c                 bitstreamfeeder.c           \
+                bitstreamreader.c               bsfeeder_fixedsize_impl.c   bsfeeder_framesize_impl.c   \
+                bsfeeder_size_plus_es_impl.c    bin_comparator_impl.c       comparator.c                \
+                md5_comparator_impl.c           yuv_comparator_impl.c       bsfeeder_buffer_impl.c   \
+                cfgParser.c                     decoder_listener.c          \
+                cnm_video_helper.c              container.c                 \
+                datastructure.c                 debug.c                     \
+                bw_monitor.c                    pf_monitor.c                \
+                cnm_app.c                       cnm_task.c                  component.c                 \
+                component_dec_decoder.c         component_dec_feeder.c      component_dec_renderer.c    \
+                product.c                       vpuapifunc.c                vpuapi.c                    \
+                coda9.c                         wave5.c                     \
+                $(VDI_C)                        $(VDI_OSAL_C)               $(MM_C)
+
+
+
+VPATH  = sample_v2:
+VPATH += sample_v2/component_encoder:
+VPATH += sample_v2/component_decoder:
+VPATH += sample_v2/helper:
+VPATH += sample_v2/helper/bitstream:
+VPATH += sample_v2/helper/comparator:
+VPATH += sample_v2/helper/display:sample_v2/helper/misc:sample_v2/helper/yuv:sample_v2/component:
+VPATH += vdi:
+VPATH += $(VDI_VPATH):vpuapi:vpuapi/coda9:vpuapi/wave
+
+VPATH2=$(patsubst %,-I%,$(subst :, ,$(VPATH)))
+
+OBJECTNAMES_COMMON=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES_COMMON)))
+OBJECTPATHS_COMMON=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_COMMON)))
+
+SOURCES_DECTEST = sample_v2/main_dec_test.c
+ifeq ($(USE_RTL_SIM), yes)
+	SOURCES_DECTEST += sample/main_sim.c
+endif
+
+OBJECTNAMES_DECTEST=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES_DECTEST)))
+OBJECTPATHS_DECTEST=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_DECTEST))) $(OBJECTPATHS_COMMON)
+
+all: $(BUILDLIST)
+
+ifeq ($(USE_RTL_SIM), yes)
+DECTEST: CREATE_DIR $(OBJECTPATHS_COMMON)
+else
+DECTEST: CREATE_DIR $(OBJECTPATHS_COMMON)
+	$(LINKER) -fPIC -shared -o $(DECTEST) $(LDFLAGS) -Wl,-gc-section -Wl,--start-group $(OBJECTPATHS_COMMON) $(LDLIBS) -Wl,--end-group
+endif
+
+-include $(OBJECTPATHS:.o=.dep)
+
+clean:
+	$(RM) $(DECTEST)
+	$(RM) $(OBJDIR)/$(ALLOBJS)
+	$(RM) $(OBJDIR)/$(ALLDEPS)
+
+CREATE_DIR:
+	-mkdir -p $(OBJDIR)
+
+obj/%.o: %.c $(MAKEFILE)
+	$(CC) -fPIC -shared $(CFLAGS) -Wall -Werror -c $< -o $@ -MD -MF $(@:.o=.dep)
+
+
+lint:
+	"$(LINT_HOME)/flint" -i"$(LINT_HOME)" $(DEFINES) $(INCLUDES) $(VPATH2) linux_std.lnt $(HAPS_RULE) $(NONOS_RULE)  $(SOURCES_COMMON)
+

+ 11 - 0
soft_3rdpart/wave511/code/build_env.sh

@@ -0,0 +1,11 @@
+PWD=`pwd`
+RISCV_TOOLCHAIN_BASE=${PWD}/../../../work/buildroot_initramfs/host
+echo $RISCV_TOOLCHAIN_BASE
+export PATH=${RISCV_TOOLCHAIN_BASE}/bin:$PATH
+export LD_LIBRARY_PATH=${RISCV_TOOLCHAIN_BASE}/lib:$LD_LIBRARY_PATH
+export ARCH=riscv
+export SUBARCH=riscv
+export CROSS_COMPILE=riscv64-buildroot-linux-gnu-
+
+
+

+ 39 - 0
soft_3rdpart/wave511/code/build_for_vdec.sh

@@ -0,0 +1,39 @@
+#!/bin/bash
+source set_env.sh
+CP="cp -rdvp"
+OUTPUT=vdec_driver
+DRI_OPT=$OUTPUT/driver
+DRI_SRC=./vdi/linux/driver/
+
+DEC_BIN=dec_test
+DEC_MULT_BIN=multi_instance_dec_test
+DEC_FFMPEG_BIN=ffmpeg_dec_test
+STEAM=./stream
+FIRMWARE=../firmware/chagall.bin
+MEDIA=../media
+
+if [ ! -d $DRI_OPT ];then
+		mkdir -p $DRI_OPT
+fi
+make -f WaveDecode-ffmpeg.mak
+$CP $DEC_FFMPEG_BIN $OUTPUT
+make -f WaveDecode-ffmpeg.mak clean
+
+make -f WaveDecDriver.mak
+$CP $DRI_SRC/vdec.ko $DRI_SRC/load.sh  $DRI_SRC/unload.sh $DRI_OPT
+make -f WaveDecDriver.mak clean
+
+make -f WaveDecode.mak
+$CP $DEC_BIN $OUTPUT
+make -f WaveDecode.mak clean
+
+make -f WaveDecodeMult.mak
+$CP $DEC_MULT_BIN $OUTPUT
+make -f WaveDecodeMult.mak clean
+
+
+$CP $FIRMWARE $OUTPUT
+$CP $STEAM $OUTPUT
+$CP $MEDIA $OUTPUT
+$CP script/* $OUTPUT
+mkdir -p $OUTPUT/output

+ 41 - 0
soft_3rdpart/wave511/code/build_lib.sh

@@ -0,0 +1,41 @@
+#!/bin/bash
+cc=gcc
+lib=vdec
+
+#
+if [ "x$1" == 'x' ];then
+	#path=`pwd`
+	path="."
+else
+	path=$1
+fi
+
+#
+dirs=$path
+for dir in $path/*;do
+	if [ -d $dir ];then
+		dirs=$dirs" "$dir
+	fi
+done
+echo $dirs
+
+
+#
+for inc in $dirs;do
+	INC_LD="$INC_LD  -I$inc"
+done
+echo $INC_LD
+
+for dir in $dirs;do
+	for file in $dir/*; do
+		if [ ${file##*.} = 'cpp' ] || [ ${file##*.} = 'c' ];then
+#			$cc $file $INC_LD  -o ${file%.*}.o  -c -fPIC
+			obj=$obj" "${file%.*}.o
+		fi
+
+	done
+done
+echo $obj
+#$cc -shared -fPIC -o lib${lib}.so $obj
+
+#rm -rf $obj

+ 59 - 0
soft_3rdpart/wave511/code/cfg/avc_inter_10b_03.cfg

@@ -0,0 +1,59 @@
+BitstreamFile : inter_10b_03.cfg.264
+InputFile : BasketballDrive_352x288_8b.yuv
+SourceWidth : 720
+SourceHeight : 288
+InputBitDepth : 10
+FrameRate : 30
+FrameSkip : 0
+FramesToBeEncoded : 9
+InternalBitDepth : 10
+IntraPeriod : 16
+IdrPeriod : 0
+GopPreset : 4
+ConstrainedIntraPred : 0
+IntraMbRefreshMode : 0
+IntraMbRefreshArg : 1
+RdoSkip : 1
+LambdaScaling : 1
+QP : 30
+CbQpOffset : 0
+CrQpOffset : 0
+ScalingList : 0
+ScalingListFile : /nstream/new_server/user_data/default_scaling_list.txt
+SliceMode : 0
+SliceArg : 0
+EnDBK : 1
+LFCrossSliceBoundaryFlag : 1
+DbkDisableIdc : 0
+BetaOffsetDiv2 : 0
+TcOffsetDiv2 : 0
+Transform8x8 : 1
+CABAC : 1
+UseAsLongTermRefPeriod : 0
+RefLongTermPeriod : 0
+RateControl : 0
+EncBitrate : 0
+VbvBufferSize : 3000
+MBLevelRateControl : 0
+EnHvsQp : 1
+HvsQpScaleDiv2 : 2
+MaxDeltaQp : 10
+BitAllocMode : 0
+RcInitialQp : -1
+MinQp : 8
+MaxQp : 51
+EnBgDetect : 0
+BgThDiff : 8
+BgThMeanDiff : 1
+BgLambdaQp : 32
+BgDeltaQp : 3
+WeightedPred : 0
+WpParamFile : ""
+EnRoi : 0
+EnModeMap : 0
+ModeMapFile : 0
+RoiQpMapFile : 0
+ConfWindSizeTop : 0
+ConfWindSizeBot : 0
+ConfWindSizeRight : 0
+ConfWindSizeLeft : 0

+ 58 - 0
soft_3rdpart/wave511/code/cfg/avc_inter_8b_02.cfg

@@ -0,0 +1,58 @@
+BitstreamFile : inter_8b_02.cfg.264
+InputFile : BasketballDrive_352x288_8b.yuv
+SourceWidth : 720
+SourceHeight : 288
+InputBitDepth : 8
+FrameRate : 30
+FrameSkip : 0
+FramesToBeEncoded : 9
+InternalBitDepth : 8
+IntraPeriod : 15
+IdrPeriod : 0
+GopPreset : 3
+ConstrainedIntraPred : 0
+IntraMbRefreshMode : 0
+IntraMbRefreshArg : 1
+RdoSkip : 1
+LambdaScaling : 1
+QP : 30
+CbQpOffset : 0
+CrQpOffset : 0
+ScalingList : 0
+ScalingListFile : /nstream/new_server/user_data/default_scaling_list.txt
+SliceMode : 0
+SliceArg : 0
+EnDBK : 1
+LFCrossSliceBoundaryFlag : 1
+BetaOffsetDiv2 : 0
+TcOffsetDiv2 : 0
+Transform8x8 : 1
+CABAC : 1
+UseAsLongTermRefPeriod : 0
+RefLongTermPeriod : 0
+RateControl : 0
+EncBitrate : 0
+VbvBufferSize : 3000
+MBLevelRateControl : 0
+EnHvsQp : 1
+HvsQpScaleDiv2 : 2
+MaxDeltaQp : 10
+BitAllocMode : 0
+RcInitialQp : -1
+MinQp : 8
+MaxQp : 51
+EnBgDetect : 0
+BgThDiff : 8
+BgThMeanDiff : 1
+BgLambdaQp : 32
+BgDeltaQp : 3
+WeightedPred : 0
+WpParamFile : ""
+EnRoi : 0
+EnModeMap : 0
+ModeMapFile : 0
+RoiQpMapFile : 0
+ConfWindSizeTop : 0
+ConfWindSizeBot : 0
+ConfWindSizeRight : 0
+ConfWindSizeLeft : 0

+ 58 - 0
soft_3rdpart/wave511/code/cfg/avc_uhd_cavlc_8b_04.cfg

@@ -0,0 +1,58 @@
+BitstreamFile : cavlc_8b_04.cfg.264
+InputFile : mix_4096x2160_8b_9frm.yuv
+SourceWidth : 4096
+SourceHeight : 2160
+InputBitDepth : 8
+FrameRate : 30
+FrameSkip : 0
+FramesToBeEncoded : 9 
+InternalBitDepth : 8
+IntraPeriod : 0
+IdrPeriod : 0
+GopPreset : 4
+ConstrainedIntraPred : 0
+IntraMbRefreshMode : 0
+IntraMbRefreshArg : 1
+RdoSkip : 1
+LambdaScaling : 1
+QP : 21
+CbQpOffset : 0
+CrQpOffset : 0
+ScalingList : 0
+ScalingListFile : /nstream/new_server/user_data/default_scaling_list.txt
+SliceMode : 0
+SliceArg : 0
+EnDBK : 1
+LFCrossSliceBoundaryFlag : 1
+BetaOffsetDiv2 : 0
+TcOffsetDiv2 : 0
+Transform8x8 : 0
+CABAC : 0
+UseAsLongTermRefPeriod : 0
+RefLongTermPeriod : 0
+RateControl : 0
+EncBitrate : 0
+VbvBufferSize : 3000
+MBLevelRateControl : 0
+EnHvsQp : 1
+HvsQpScaleDiv2 : 2
+MaxDeltaQp : 10
+BitAllocMode : 0
+RcInitialQp : -1
+MinQp : 8
+MaxQp : 51
+EnBgDetect : 0
+BgThDiff : 8
+BgThMeanDiff : 1
+BgLambdaQp : 32
+BgDeltaQp : 3
+WeightedPred : 0
+WpParamFile : ""
+EnRoi : 0
+EnModeMap : 0
+ModeMapFile : 0
+RoiQpMapFile : 0
+ConfWindSizeTop : 0
+ConfWindSizeBot : 0
+ConfWindSizeRight : 0
+ConfWindSizeLeft : 0

+ 76 - 0
soft_3rdpart/wave511/code/cfg/hevc_bg_8b_01.cfg

@@ -0,0 +1,76 @@
+BitstreamFile : bg_8b_01.cfg.265
+InputFile : BasketballDrive_352x288_8b.yuv
+SourceWidth : 720
+SourceHeight : 288
+InputBitDepth : 8
+FrameRate : 30
+FrameSkip : 0
+FramesToBeEncoded : 9
+IntraPeriod : 0
+DecodingRefreshType : 1
+GopPreset : 0
+GOPSize : 1
+Frame1: P 1 1 0 0
+IntraNxN : 1
+IntraTransSkip : 1
+StrongIntraSmoothing : 1
+ConstrainedIntraPred : 0
+IntraCtuRefreshMode : 0
+IntraCtuRefreshArg : 0
+MaxNumMerge : 2
+DisableCoefClear : 0
+EnTemporalMVP : 1
+QP : 30
+CbQpOffset : 0
+CrQpOffset : 0
+ScalingList : 0
+IndeSliceMode : 0
+IndeSliceArg : 0
+DeSliceMode : 0
+DeSliceArg : 0
+EnDBK : 1
+EnSAO : 1
+LFCrossSliceBoundaryFlag : 1
+BetaOffsetDiv2 : 0
+TcOffsetDiv2 : 0
+WaveFrontSynchro : 0
+LosslessCoding : 0
+UseAsLongTermRefPeriod : 0
+RefLongTermPeriod : 0
+RateControl : 0
+EncBitrate : 0
+VbvBufferSize : 3000
+CULevelRateControl : 1
+EnHvsQp : 1
+BitAllocMode : 0
+EnRoi : 0
+RcInitialQp : -1
+MinQp : 8
+MaxQp : 51
+RoiQpMapFile :  /nstream/new_server/ctu_mode/roi_map.dat
+EnNoiseReductionY : 0
+EnNoiseReductionCb : 0
+EnNoiseReductionCr : 0
+EnNoiseEst : 0
+NoiseSigmaY : 0
+NoiseSigmaCb : 0
+NoiseSigmaCr : 0
+IntraNoiseWeightY : 7
+IntraNoiseWeightCb : 7
+IntraNoiseWeightCr : 7
+InterNoiseWeightY : 4
+InterNoiseWeightCb : 4
+InterNoiseWeightCr : 4
+EnBgDetect : 1
+BgThDiff : 0
+BgThMeanDiff : 1
+BgLambdaQp : 32
+BgDeltaQp : 3
+TileNumColumns : 1
+TileNumRows : 1
+TileUniformSpace : 1
+WeightedPred : 0
+WpParamFile : ""
+ScalingListFile : /nstream/new_server/user_data/default_scaling_list.txt
+EnModeMap : 0
+ModeMapFile : 0

+ 74 - 0
soft_3rdpart/wave511/code/cfg/hevc_fhd_inter_8b_11.cfg

@@ -0,0 +1,74 @@
+BitstreamFile : inter_8b_11.cfg.265
+InputFile : mix_1920x1080_8b_9frm.yuv
+SourceWidth : 1920
+SourceHeight : 1080
+InputBitDepth : 8
+FrameRate : 30
+FrameSkip : 0
+FramesToBeEncoded : 9
+IntraPeriod : 0
+DecodingRefreshType : 1
+GopPreset : 4
+IntraNxN : 1
+IntraTransSkip : 1
+StrongIntraSmoothing : 1
+ConstrainedIntraPred : 0
+IntraCtuRefreshMode : 0
+IntraCtuRefreshArg : 0
+MaxNumMerge : 1
+DisableCoefClear : 0
+EnTemporalMVP : 1
+QP : 30
+CbQpOffset : 0
+CrQpOffset : 0
+ScalingList : 0
+IndeSliceMode : 0
+IndeSliceArg : 0
+DeSliceMode : 0
+DeSliceArg : 0
+EnDBK : 1
+EnSAO : 1
+LFCrossSliceBoundaryFlag : 1
+BetaOffsetDiv2 : 0
+TcOffsetDiv2 : 0
+WaveFrontSynchro : 0
+LosslessCoding : 0
+UseAsLongTermRefPeriod : 0
+RefLongTermPeriod : 0
+RateControl : 0
+EncBitrate : 0
+VbvBufferSize : 3000
+CULevelRateControl : 1
+EnHvsQp : 1
+BitAllocMode : 0
+EnRoi : 0
+RcInitialQp : -1
+MinQp : 8
+MaxQp : 51
+RoiQpMapFile :  /nstream/new_server/ctu_mode/roi_map.dat
+EnNoiseReductionY : 0
+EnNoiseReductionCb : 0
+EnNoiseReductionCr : 0
+EnNoiseEst : 0
+NoiseSigmaY : 0
+NoiseSigmaCb : 0
+NoiseSigmaCr : 0
+IntraNoiseWeightY : 7
+IntraNoiseWeightCb : 7
+IntraNoiseWeightCr : 7
+InterNoiseWeightY : 4
+InterNoiseWeightCb : 4
+InterNoiseWeightCr : 4
+EnBgDetect : 0
+BgThDiff : 8
+BgThMeanDiff : 1
+BgLambdaQp : 32
+BgDeltaQp : 3
+TileNumColumns : 1
+TileNumRows : 1
+TileUniformSpace : 1
+WeightedPred : 0
+WpParamFile : ""
+ScalingListFile : /nstream/new_server/user_data/default_scaling_list.txt
+EnModeMap : 0
+ModeMapFile : 0

+ 79 - 0
soft_3rdpart/wave511/code/cfg/hevc_inter_10b_01.cfg

@@ -0,0 +1,79 @@
+BitstreamFile : inter_10b_01.cfg.265
+InputFile : BasketballDrive_352x288_10b.yuv
+SourceWidth : 352
+SourceHeight : 288
+InputBitDepth : 10
+FrameRate : 30
+FrameSkip : 0
+FramesToBeEncoded : 9
+IntraPeriod : 0
+DecodingRefreshType : 1
+GopPreset : 0
+GOPSize : 1
+Frame1: P 1 1 0 0
+IntraNxN : 1
+IntraTransSkip : 1
+StrongIntraSmoothing : 1
+ConstrainedIntraPred : 0
+IntraCtuRefreshMode : 0
+IntraCtuRefreshArg : 0
+EnCu8x8 : 1
+EnCu16x16 : 1
+EnCu32x32 : 1
+MaxNumMerge : 2
+DisableCoefClear : 0
+EnTemporalMVP : 1
+QP : 30
+CbQpOffset : 0
+CrQpOffset : 0
+ScalingList : 0
+IndeSliceMode : 0
+IndeSliceArg : 0
+DeSliceMode : 0
+DeSliceArg : 0
+EnDBK : 1
+EnSAO : 1
+LFCrossSliceBoundaryFlag : 1
+BetaOffsetDiv2 : 0
+TcOffsetDiv2 : 0
+WaveFrontSynchro : 0
+LosslessCoding : 0
+UseAsLongTermRefPeriod : 0
+RefLongTermPeriod : 0
+RateControl : 0
+EncBitrate : 0
+InitialDelay : 3000
+InitBufLevelx8 : 1
+CULevelRateControl : 1
+EnHvsQp : 1
+BitAllocMode : 0
+EnRoi : 0
+RoiAvgQP : 0
+RcInitialQp : -1
+MinQp : 8
+MaxQp : 51
+RoiQpMapFile : /nstream/new_server/roi/BasketballPass_416x240_50.yuv.roi
+EnNoiseReductionY : 0
+EnNoiseReductionCb : 0
+EnNoiseReductionCr : 0
+EnNoiseEst : 0
+NoiseSigmaY : 0
+NoiseSigmaCb : 0
+NoiseSigmaCr : 0
+IntraNoiseWeightY : 7
+IntraNoiseWeightCb : 7
+IntraNoiseWeightCr : 7
+InterNoiseWeightY : 4
+InterNoiseWeightCb : 4
+InterNoiseWeightCr : 4
+EnBgDetect : 0
+BgThDiff : 8
+BgThMeanDiff : 1
+BgLambdaQp : 32
+BgDeltaQp : 3
+TileNumColumns : 1
+TileNumRows : 1
+TileUniformSpace : 1
+WeightedPred : 0
+WpParamFile : ""
+ScalingListFile : /nstream/new_server/user_data/default_scaling_list.txt

+ 5 - 0
soft_3rdpart/wave511/code/cmd/all_multi_8b.cmd

@@ -0,0 +1,5 @@
+# FORMAT
+# codec_std_no cfg_path(stream_path) prebuilt_path enc_dec(1:encoder, 0:decoder) main10(1:main10, 0:main) 
+# 
+0  cfg/avc_uhd_cavlc_8b_04.cfg stream/avc_uhd_cavlc_8b_04.cfg_0.264   1 0
+12 stream/hevc/akiyo.cfg_ramain_tv0.cfg.265 output_2.yuv  0 0

+ 1 - 0
soft_3rdpart/wave511/code/cmd/avc_main10_dec_test.cmd

@@ -0,0 +1 @@
+avc_main10/bd_10b_01.cfg_0.264

+ 1 - 0
soft_3rdpart/wave511/code/cmd/avc_main10_enc_test.cmd

@@ -0,0 +1 @@
+avc_inter_10b_03.cfg

+ 1 - 0
soft_3rdpart/wave511/code/cmd/avc_main_dec_test.cmd

@@ -0,0 +1 @@
+avc/bd_8b_01.cfg_0.264

+ 1 - 0
soft_3rdpart/wave511/code/cmd/avc_main_enc_test.cmd

@@ -0,0 +1 @@
+avc_inter_8b_02.cfg

+ 5 - 0
soft_3rdpart/wave511/code/cmd/dec_multi_8b.cmd

@@ -0,0 +1,5 @@
+# FORMAT
+# codec_std_no cfg_path(stream_path) prebuilt_path enc_dec(1:encoder, 0:decoder) main10(1:main10, 0:main) 
+#
+0  stream/avc/bd_8b_01.cfg_0.264 output_1.yuv            0 0
+12 stream/hevc/akiyo.cfg_ramain_tv0.cfg.265 output_2.yuv 0 0 

+ 5 - 0
soft_3rdpart/wave511/code/cmd/enc_multi_8b.cmd

@@ -0,0 +1,5 @@
+# FORMAT 
+# codec_std_no cfg_path(stream_path) prebuilt_path enc_dec(1:encoder, 0:decoder) main10(1:main10, 0:main) 
+#
+0  cfg/avc_uhd_cavlc_8b_04.cfg stream/avc_uhd_cavlc_8b_04.cfg_0.264   1 0
+12 cfg/hevc_fhd_inter_8b_11.cfg stream/hevc_fhd_inter_8b_11.cfg_0.265 1 0

+ 1 - 0
soft_3rdpart/wave511/code/cmd/hevc_main10_dec_test.cmd

@@ -0,0 +1 @@
+hevc_main10/small_size_128x128.yuv_main10_64.bin

+ 1 - 0
soft_3rdpart/wave511/code/cmd/hevc_main10_enc_test.cmd

@@ -0,0 +1 @@
+hevc_inter_10b_01.cfg

+ 1 - 0
soft_3rdpart/wave511/code/cmd/hevc_main_dec_test.cmd

@@ -0,0 +1 @@
+hevc/akiyo.cfg_ramain_tv0.cfg.265

+ 1 - 0
soft_3rdpart/wave511/code/cmd/hevc_main_enc_test.cmd

@@ -0,0 +1 @@
+hevc_bg_8b_01.cfg

+ 2022 - 0
soft_3rdpart/wave511/code/common.sh

@@ -0,0 +1,2022 @@
+###############################################################################
+# COMMON DATA
+###############################################################################
+ON_OFF=(
+    "OFF"
+    "ON"
+)
+
+readonly C_YUV_8B_P420=0
+readonly C_YUV_8B_P422=1
+readonly C_YUV_10B_MSB_P420=5
+readonly C_YUV_10B_LSB_P420=6
+readonly C_YUV_3P4B_MSB_P420=7          # each pixel 10bit
+readonly C_YUV_3P4B_LSB_P420=8          # each pixel 10bit
+readonly C_YUV_10B_MSB_P422=9
+readonly C_YUV_10B_LSB_P422=10
+readonly C_YUV_3P4B_MSB_P422=11         # each pixel 10bit
+readonly C_YUV_3P4B_LSB_P422=12         # each pixel 10bit
+
+readonly C_YUV_8B_YUYV=13
+readonly C_YUV_10B_MSB_YUYV=14
+readonly C_YUV_10B_LSB_YUYV=15
+readonly C_YUV_3P4B_MSB_YUYV=16
+readonly C_YUV_3P4B_LSB_YUYV=17
+
+readonly C_YUV_8B_YVYU=18
+readonly C_YUV_10B_MSB_YVYU=19
+readonly C_YUV_10B_LSB_YVYU=20
+readonly C_YUV_3P4B_MSB_YVYU=21
+readonly C_YUV_3P4B_LSB_YVYU=22
+
+readonly C_YUV_8B_UYVY=23
+readonly C_YUV_10B_MSB_UYVY=24
+readonly C_YUV_10B_LSB_UYVY=25
+readonly C_YUV_3P4B_MSB_UYVY=26
+readonly C_YUV_3P4B_LSB_UYVY=27
+
+readonly C_YUV_8B_VYUY=28
+readonly C_YUV_10B_MSB_VYUY=29
+readonly C_YUV_10B_LSB_VYUY=30
+readonly C_YUV_3P4B_MSB_VYUY=31
+readonly C_YUV_3P4B_LSB_VYUY=32
+
+readonly CODA_MIN_ENDIAN=0
+readonly CODA_MAX_ENDIAN=3
+readonly WAVE_MIN_ENDIAN=16
+readonly WAVE_MAX_ENDIAN=31
+
+readonly CODA_SEC_AXI_MAX=63
+readonly SCALER_SEC_AXI_MAX=15
+readonly BWB_SECONDARY_AXI_MAX=7
+readonly WAVE517_BWB_SECONDARY_AXI_MAX=3
+
+YUV_FORMAT_LIST=(
+    "FORMAT_420"
+    "RESERVED"
+    "RESERVED"
+    "RESERVED"
+    "RESERVED"
+    "FORMAT_420_P10_16BIT_MSB"
+    "FORMAT_420_P10_16BIT_LSB"
+    "FORMAT_420_P10_32BIT_MSB"
+    "FORMAT_420_P10_32BIT_LSB"
+)
+
+YUV_FORMAT_LIST_8BIT=(
+    "FORMAT_420"
+)
+
+# DO NOT CHANGE ORDER
+YUV_FORMAT_LIST_SCALER_10BIT=(
+    "FORMAT_420"
+    "FORMAT_422"
+    "RESERVED"
+    "RESERVED"
+    "RESERVED"
+    "FORMAT_420_P10_16BIT_MSB"
+    "FORMAT_420_P10_16BIT_LSB"
+    "FORMAT_420_P10_32BIT_MSB"
+    "FORMAT_420_P10_32BIT_LSB"
+    "FORMAT_422_P10_16BIT_MSB"
+    "FORMAT_422_P10_16BIT_LSB"
+    "FORMAT_422_P10_32BIT_MSB"
+    "FORMAT_422_P10_32BIT_LSB"
+)
+
+# DISABLED YUV422 CONVERSION UNTIL SCALER FIXED
+YUV_FORMAT_LIST_SCALER_8BIT=(
+    "FORMAT_420"
+    "FORMAT_422"
+)
+
+
+AFBCE_FORMAT_NAME=(
+    "NONE"
+    "AFBCE_FORMAT_8BIT"
+    "AFBCE_FORMAT_10BIT"
+)
+
+C9_ENDIAN_NAME=(
+    "VDI_64BIT_LE"
+    "VDI_64BIT_BE"
+    "VDI_32BIT_LE"
+    "VDI_32BIT_BE"
+)
+
+W4_ENDIAN_NAME=(
+    "VDI_128BIT_BIG_ENDIAN"
+    "VDI_128BIT_BE_BYTE_SWAP"
+    "VDI_128BIT_BE_WORD_SWAP"
+    "VDI_128BIT_BE_WORD_BYTE_SWAP"
+    "VDI_128BIT_BE_DWORD_SWAP"
+    "VDI_128BIT_BE_DWORD_BYTE_SWAP"
+    "VDI_128BIT_BE_DWORD_WORD_SWAP"
+    "VDI_128BIT_BE_DWORD_WORD_BYTE_SWAP"
+    "VDI_128BIT_LE_DWORD_WORD_BYTE_SWAP"
+    "VDI_128BIT_LE_DWORD_WORD_SWAP"
+    "VDI_128BIT_LE_DWORD_BYTE_SWAP"
+    "VDI_128BIT_LE_DWORD_SWAP"
+    "VDI_128BIT_LE_WORD_BYTE_SWAP"
+    "VDI_128BIT_LE_WORD_SWAP"
+    "VDI_128BIT_LE_BYTE_SWAP"
+    "VDI_128BIT_LITTLE_ENDIAN"
+)
+
+DEC_BSMODE_NAME=(
+    "Interrupt"
+    "Reserved"
+    "PicEnd"
+)
+
+ENC_BSMODE_NAME=(
+    "Ringbuffer"
+    "Linebuffer"
+)
+
+ENC_WAVE_BSMODE_NAME=(
+    "Linebuffer"
+    "Ringbuffer, Wrap On"
+    "Ringbuffer, Wrap Off"
+)
+
+CODA980_MAPTYPE_NAME=(
+    "LINEAR_FRAME"
+    "TILED_FRAME_V"
+    "TILED_FRAME_H"
+    "TILED_FIELD_V"
+    "TILED_MIXED_V"
+    "TILED_FRAME_MB_RASTER"
+    "TILED_FIELD_MB_RASTER"
+    "TILED_FRAME_NO_BANK"
+    "TILED_FIELD_NO_BANK"
+)
+
+CODA960_MAPTYPE_NAME=(
+    "LINEAR_FRAME"
+    "TILED_FRAME_V"
+    "TILED_FRAME_H"
+    "TILED_FIELD_V"
+    "TILED_MIXED_V"
+    "TILED_FRAME_MB_RASTER"
+    "TILED_FIELD_MB_RASTER"
+)
+
+MIRROR_NAME=(
+    "NONE"
+    "VERTICAL"
+    "HORIZONTAL"
+    "BOTH"
+)
+
+CODEC_NAME=(
+    "H.264"
+    "VC-1"
+    "MPEG-2"
+    "MPEG-4"
+    "H.263"
+    "DIVX3"
+    "RV"
+    "AVS"
+    "NONE"
+    "THEORA"
+    "NONE"
+    "VP8"
+    "HEVC"
+    "VP9"
+    "AVS2"
+    "SVAC"
+)
+
+SRC_FORMAT_NAME=(
+    "8BIT"
+    "10BIT - 1Pixel 2bytes MSB"
+    "10BIT - 1Pixel 2bytes LSB"
+    "10BIT - 3Pixel 4bytes MSB"
+    "10BIT - 3Pixel 4bytes LSB"
+)
+
+
+PASS="PASS"
+FAIL="FAIL"
+
+###############################################################################
+# GLOBAL VARIABLES
+###############################################################################
+g_fpga_reset=0                       # 1 : reset fpga every time
+g_multi_vcore=0
+g_force_num_cores=0
+
+######################## COMMON VARAIABLES FOR DECODER ########################
+g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
+g_match_mode=1                        # 0 - nomatch, 1 - yuv, 2 - md5
+g_secondary_axi=0
+g_stream_endian=0
+g_source_endian=0
+g_frame_endian=0
+g_bsmode=0
+g_enable_thumbnail=0
+g_cbcr_interleave=0
+g_enable_nv21=0
+g_enable_wtl=1
+g_wtl_format=0
+g_bs_size=0
+g_codec_index=0
+g_cframe_temp=0
+g_subFrameSync_temp=0
+g_cframe_422=0
+g_scaler="false"
+g_revision=""
+########################## WAVE5xx DECODER VARAIABLES #########################
+g_tid_test=0
+g_bw_opt=0
+g_afbce=0
+
+####################### CODA9&CODA7 DECODER VARAIABLES ########################
+g_maptype_index=0           # CODA9xx feature
+g_enable_tiled2linear=0
+g_enable_deblock=0
+g_enable_dering=0
+g_enable_mvc=0              # H.264 MVC
+g_mp4class=0
+g_maptype_num=1
+g_enable_ppu=1
+
+######################## VARAIABLES FOR WAVE5 ENCODER #########################
+g_subframe_sync=0
+g_lowLatencyMode=0
+g_packedFormat=0
+g_srcFormat=0
+######################## VARAIABLES FOR CODA9 ENCODER #########################
+g_enable_linear2tiled=0
+g_linebuf_int=0
+
+########################## VARAIABLES FOR PPU #################################
+g_rotAngle=0
+g_mirDir=0
+
+g_oriw=0
+g_orih=0
+g_sclw=0
+g_sclh=0
+g_min_scale_w=0
+g_min_scale_h=0
+
+###############################################################################
+# GLOBAL FUNCTIONS
+###############################################################################
+# ceiling function
+function ceiling {
+    local value=$1
+    local align=$2
+
+    echo "$(((($value+$align-1)/$align)*$align))"
+}
+
+# check_and_create_dir
+function check_and_create_dir {
+    CHECK_PATH=$1
+    if [ ! -d "$CHECK_PATH" ]; then
+        mkdir -p $CHECK_PATH
+        chmod 777 $CHECK_PATH
+        echo "create $CHECK_PATH"
+    else
+        echo "Already $CHECK_PATH Exist"
+    fi
+}
+
+# get_random start end
+# generate constraint random value with @start end @end.
+#
+function get_random {
+    start=$1
+    end=$2
+    size=$(($end - $start + 1))
+    val2=$RANDOM
+    val1=$(($val2 % size))
+    val=$(($start + $val1%$size))
+    echo "$val"
+}
+
+function get_random_min_max {
+    start=$1
+    end=$2
+
+    use_min_max_value=$(($RANDOM % 5))
+    size=$(($end - $start - 1))
+
+    if [ $use_min_max_value = 1 ] || [ $size -le 0 ]; then
+        val2=$RANDOM
+        val1=$(($val2 % 2))
+        if [ $val1 = 1 ]; then
+            val=$end
+        else
+            val=$start
+        fi
+    else
+        val2=$RANDOM
+        val1=$(($val2 % size))
+        val=$(($start + $val1%$size + 1))
+    fi
+
+    echo "$val"
+}
+
+# log_conf log_message log_file
+# write @log_message to @log_file
+#
+function log_conf {
+    echo "$1" | tee -a "$2"
+}
+
+# parse_streamset_file streamset_path *array
+# - parse streamset file and store data into @g_stream_file_array
+#
+function parse_streamset_file {
+    local f="$1"
+    local index=0
+    local line=""
+    while read -r line || [ -n "$line" ]; do
+        line="${line#*( )}"         # remove front whitespace
+        line="${line%%[ $'\t']*}"   # remove start of whitespace
+        line="${line//\\//}"        # replace backslash to slash
+        line="${line/$'\r'/}"       # remove carriage return
+        firstchar=${line:0:1}
+        case "$firstchar" in
+            "@") break;;        # exit flag
+            "#") continue;;     # comment
+            ";") continue;;     # comment
+            "")  continue;;     # comment
+            *)
+        esac
+        eval $2[$index]="$line"
+        index=$(($index + 1))
+    done < $f
+}
+
+function gen_val {
+    local min_val=$1
+    local max_val=$2
+    local default_val=$3
+    local val
+
+    if [ -z "$default_val" ] || [ "$default_val" == "-99" ]; then
+        # Generate random value
+        val=$(get_random $min_val $max_val)
+    else
+        val=$default_val
+    fi
+
+    echo "$val"
+}
+
+function gen_min_max_val {
+    local min_val=$1
+    local max_val=$2
+    local default_val=$3
+    local val
+
+    if [ -z "$default_val" ] || [ "$default_val" == "-99" ]; then
+        # Generate random value
+        val=$(get_random_min_max $min_val $max_val)
+    else
+        val=$default_val
+    fi
+
+    echo "$val"
+}
+
+
+function set_min_max_param {
+    if [[ $g_product_name =~ coda9* ]]; then
+        MIN_ENDIAN=$CODA_MIN_ENDIAN
+        MAX_ENDIAN=$CODA_MAX_ENDIAN
+        MAX_SEC_AXI=$CODA_SEC_AXI_MAX
+    else
+        MIN_ENDIAN=$WAVE_MIN_ENDIAN
+        MAX_ENDIAN=$WAVE_MAX_ENDIAN
+        if [ $g_scaler == "true" ]; then
+            MAX_SEC_AXI=$SCALER_SEC_AXI_MAX
+        else
+            MAX_SEC_AXI=$BWB_SECONDARY_AXI_MAX
+        fi
+        if [ "$g_product_name" == "wave517" ]; then
+            MAX_SEC_AXI=$WAVE517_BWB_SECONDARY_AXI_MAX
+        fi
+    fi
+}
+
+function set_yuv_mode_dual {
+    local max_val=$1
+    g_cbcr_interleave=0
+    g_enable_nv21=0
+    case $(gen_val 0 $max_val $g_yuv_mode_temp) in
+        0) g_cbcr_interleave=1        # NV12
+           g_enable_nv21=0;;
+        1) g_cbcr_interleave=1        # NV21
+           g_enable_nv21=1;;
+    esac
+}
+
+function set_yuv_mode {
+    local max_val=$1
+    g_cbcr_interleave=0
+    g_enable_nv21=0
+    g_packedFormat=0
+        case $(gen_val 0 $max_val $g_yuv_mode_temp) in
+            0) g_cbcr_interleave=0        # separate YUV
+               g_enable_nv21=0;;
+            1) g_cbcr_interleave=1        # NV12
+               g_enable_nv21=0;;
+            2) g_cbcr_interleave=1        # NV21
+               g_enable_nv21=1;;
+            3) g_packedFormat=1;;         #YUYV
+            4) g_packedFormat=2;;         #YVYU
+            5) g_packedFormat=3;;         #UYVY
+            6) g_packedFormat=4;;         #VYUY
+            *) g_cbcr_interleave=0
+               g_enable_nv21=0
+               g_packedFormat=0;;
+        esac
+}
+
+function set_bsmode {
+    g_bsmode=$(gen_val 0 1 $bsmode_temp)
+    if [ -n "$g_bsmode_force" ];  then #only coda
+        g_bsmode=$g_bsmode_force
+    fi
+
+    if [ "$g_bsmode" = "1" ]; then
+        g_bsmode=2;
+    fi
+
+    # VP9 constraint(PIC_END Mode)
+    if [ "$codec" = "vp9" ]; then
+        g_bsmode=2
+    fi
+
+    # av1 constraint(Interrupt Mode)
+    if [ "$codec" = "av1" ]; then
+        g_bsmode=0
+    fi
+}
+
+function set_rot_mir {
+    val=$(gen_val 0 3 $rotAngle_temp)
+    if [ "$val" -le "3" ]; then
+        g_rotAngle=$(expr $val \* 90)
+    else
+        g_rotAngle=$val
+    fi
+    g_mirDir=$(gen_val 0 3 $mirDir_temp)
+}
+
+function set_decoder_option_w511 {
+    local output_hw
+    g_enable_wtl=1
+    if [ "$g_scaler" = "true" ]; then
+        # DOWN SCALING TEST
+        output_hw="scaler"
+    else
+        if [ -n "$disable_wtl_temp" ]; then
+	    if [ "$disable_wtl_temp" == "0" ]; then
+                output_hw="bwb"
+	    else
+                output_hw="fbc"
+	    fi
+        else
+            val=$(gen_val 0 1)
+            if [ "$val" == "0" ]; then
+                output_hw="bwb"
+            else
+                output_hw="fbc"
+            fi
+        fi
+    fi
+
+    case $output_hw in
+    "bwb") # BWB
+        if [ "$is_main10" == "1" ]; then
+            g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
+        else
+            g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
+        fi
+        g_wtl_format=$(gen_wtl_format $wtl_format_temp)
+        ;;
+    "fbc") # FBC
+        # FBC IS A COMPRESSED FRAMEBUFFER FORMAT. DISABLE NV12/21
+        g_enable_wtl=0
+        g_cbcr_interleave=0
+        g_enable_nv21=0
+        ;;
+    "scaler")
+        g_wtl_format=0
+        # SCALER
+        if [ "$g_scaler" == "true" ]; then
+            if [ "$is_main10" == "1" ]; then
+                g_yuv_fmt_list=("${YUV_FORMAT_LIST_SCALER_10BIT[@]}")
+            else
+                g_yuv_fmt_list=("${YUV_FORMAT_LIST_SCALER_8BIT[@]}")
+            fi
+        else
+            if [ "$is_main10" == "1" ]; then
+                g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
+            else
+                g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
+            fi
+        fi
+        g_wtl_format=$(gen_wtl_format $wtl_format_temp)
+        ;;
+    esac
+
+    # BANDWIDTH OPTIMIZATION
+    if [ $g_enable_wtl -eq 1 ]; then
+        g_bw_opt=$(gen_val 0 1 $g_bw_opt_temp)
+    fi
+}
+
+function set_decoder_option_w512 {
+    # WAVE512 has three output H/W modules.
+    # 0 - BWB, 1 - AFBCE, 2 - DOWN-SCALER, 3 - DISABLE-WTL
+    # BWB, AFBCE AND DOWNSCALER NEED WTL FUNCTION
+    g_enable_wtl=1
+    g_afbce=0
+    if [ "$g_scaler" = "true" ]; then
+        # DOWN SCALING TEST
+        val=2
+    else
+        val=$(gen_val 0 3 $g_output_hw_temp)
+    fi
+
+    # WAVE515 do not support afbce
+    if [ "$g_product_name" = "wave515" ] && [ "$val" == "1" ]; then
+        val=0
+    fi
+    # WAVE511 do not support afbce
+    if [ "$g_product_name" = "wave511" ] && [ "$val" == "1" ]; then
+        val=0
+    fi
+
+    # WAVE521c_dual do not support afbce,
+    if [ "$g_product_name" = "wave521c_dual" ] && [ "$val" == "1" ]; then
+        val=0
+    fi
+
+    if [ -z "$wtl_format_temp" ]; then
+        val=0
+    fi
+    case $val in
+    0) # BWB
+        if [ "$is_main10" == "1" ]; then
+            g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
+        else
+            g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
+        fi
+        g_wtl_format=$(gen_wtl_format $wtl_format_temp)
+        ;;
+    1)
+        g_wtl_format=0
+        ;;
+    2)
+        g_wtl_format=0
+        # SCALER
+        if [ "$g_scaler" == "true" ]; then
+            if [ "$is_main10" == "1" ]; then
+                g_yuv_fmt_list=("${YUV_FORMAT_LIST_SCALER_10BIT[@]}")
+            else
+                g_yuv_fmt_list=("${YUV_FORMAT_LIST_SCALER_8BIT[@]}")
+            fi
+        else
+            if [ "$is_main10" == "1" ]; then
+                g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
+            else
+                g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
+            fi
+        fi
+        g_wtl_format=$(gen_wtl_format $wtl_format_temp)
+        ;;
+    3) # FBC
+        # FBC IS A COMPRESSED FRAMEBUFFER FORMAT. DISABLE NV12/21
+        g_enable_wtl=0
+        g_cbcr_interleave=0
+        g_enable_nv21=0
+        ;;
+    esac
+
+    # BANDWIDTH OPTIMIZATION
+    if [ $g_enable_wtl -eq 1 ]; then
+        g_bw_opt=$(gen_val 0 1 $g_bw_opt_temp)
+    fi
+}
+
+function set_decoder_option_w525 {
+    # WAVE512 has three output H/W modules.
+    # 0 - BWB, 1 - DISABLE-WTL
+    g_enable_wtl=1
+    val=$(gen_val 0 1 $g_output_hw_temp)
+
+    case $val in
+    0) # BWB
+        if [ "$is_main10" == "1" ]; then
+            g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
+        else
+            g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
+        fi
+        g_wtl_format=$(gen_wtl_format $wtl_format_temp)
+        ;;
+    1)
+        # FBC IS A COMPRESSED FRAMEBUFFER FORMAT. DISABLE NV12/21
+        g_enable_wtl=0
+        g_cbcr_interleave=0
+        g_enable_nv21=0
+        ;;
+    esac
+
+    # BANDWIDTH OPTIMIZATION
+    if [ $g_enable_wtl -eq 1 ]; then
+        g_bw_opt=$(gen_val 0 1 $g_bw_opt_temp)
+    fi
+}
+
+function set_decoder_option {
+    set_bsmode
+    set_yuv_mode 2 #2:without packedformat
+    # CODA9 features
+    if [[ $g_product_name =~ coda9* ]]; then
+        set_rot_mir
+        if [ "$codec" = "mp2" ] || [ "$codec" = "mp4" ]; then
+            g_enable_deblock=$(gen_val 0 1 $deblock_temp)
+            g_enable_dering=$(gen_val 0 1 $dering_temp)
+        else
+            g_enable_deblock=0
+            g_enable_dering=0
+        fi
+        g_maptype_index=$(gen_val 0 $(($g_maptype_num-1)) $maptype_temp)
+        # TILED2LINEAR
+        g_enable_wtl=0
+        g_enable_tiled2linear=0
+        if [ $g_maptype_index -gt 0 ]; then
+            local val=$(get_random 0 1)
+            if [ $val -eq 0 ]; then
+                g_enable_tiled2linear=1
+            else
+                g_enable_wtl=1
+            fi
+        fi
+
+        # check combination of parameters
+        if [ $g_enable_wtl -eq 1 ] || [ $g_enable_ppu -eq 0 ]; then
+            g_rotAngle=0
+            g_mirDir=0
+            g_enable_dering=0
+        fi
+    else
+        case $g_product_name in
+        wave511 | wave517)
+            set_decoder_option_w511;; #bwb, scaler, fbc
+        wave521c | wave512 | wave515 | wave521c_dual)
+            set_decoder_option_w512;; #bwb, afbce, scaler, fbc
+        *) echo "Unknown product name: $g_product_name"
+           exit 1;;
+        esac
+    fi
+}
+
+function set_encoder_option {
+    set_rot_mir
+    if [[ $g_product_name =~ coda9* ]]; then
+        set_yuv_mode 2 #2:without packedformat
+        g_maptype_index=$(gen_val 0 $(($g_maptype_num -1)) $maptype_temp)
+        g_enable_linear2tiled=$(gen_val 0 1 $linear2tiled_temp)
+        g_linebuf_int=$(gen_val 0 1 $linebuf_int_temp)
+        g_bsmode=$(gen_val 0 1 $bsmode_temp)
+    else
+        if [ "$g_product_name" = "wave521c_dual" ]; then #constraint
+            set_yuv_mode_dual 1 #nv12 and nv21 only
+        else
+            set_yuv_mode 6 #6:with packedFormat
+        fi
+        MODE_COMP_ENCODED=$(gen_val 0 1 $MODE_COMP_ENCODED_temp)
+        g_lowLatencyMode=$(gen_val 0 3 $g_lowLatencyMode_temp) #bit[1]: low latency interrupt enable, bit[0]: fast bitstream-packing enable
+        if [ "$g_product_name" = "wave521c_dual" ]; then #constraint
+            g_srcFormat=$(gen_val 3 4 $srcFormat_temp)
+            if [ "$g_srcFormat" == "1" ] || [ "$g_srcFormat" == "2" ]; then
+                g_srcFormat=$(get_random 3 4)
+            fi
+        else
+            g_srcFormat=$(gen_val 1 4 $srcFormat_temp)
+        fi
+        if [ $cfg_InputBitDepth == 8 ]; then
+            g_srcFormat=0
+        fi
+        g_ringBuffer=$(gen_val 0 2 $g_ringBuffer_temp)
+        g_cframe=$(gen_val 0 1 $g_cframe_temp)
+        if [ "$g_cframe" == "1" ]; then
+            if [ "$g_product_name" == "wave521" ] || [ "$g_product_name" == "wave521c" ];  then
+                g_cframelossless=$(gen_val 0 1 $g_cframelossless_temp)
+                if [ "$cfg_InputBitDepth" == "8" ]; then
+                    #32, 48, 64, 80, 96, 112
+                    g_cframetx16y=$(gen_val 2 7 $g_cframetx16y_temp)
+                    #32, 48, 64, 80, 96, 112
+                    g_cframetx16c=$(gen_val 2 7 $g_cframetx16c_temp)
+                else
+                    #32, 48, 64, 80, 96, 112, 128, 144
+                    g_cframetx16y=$(gen_val 2 9 $g_cframetx16y_temp)
+                    #32, 48, 64, 80, 96, 112, 128, 144
+                    g_cframetx16c=$(gen_val 2 9 $g_cframetx16c_temp)
+                fi
+                if [ $g_cframetx16y -le 10 ]; then
+                    g_cframetx16y=$(($g_cframetx16y * 16))
+                fi
+                if [ $g_cframetx16c -le 10 ]; then
+                    g_cframetx16c=$(($g_cframetx16c * 16))
+                fi
+            fi
+            if [ "$g_product_name" == "wave521" ] || [ "$g_product_name" == "wave521c" ];  then
+                g_cframe_422=$(gen_val 0 1 $g_cframe_422_temp)
+            fi
+        fi
+        g_subFrameSync=$(gen_val 0 1 $g_subFrameSync_temp)
+        if [ "$g_product_name" = "wave521c_dual" ]; then
+            g_rotAngle=0
+            g_mirDir=0
+        fi
+   fi
+}
+
+#set common options - fpga(clk, latency) , secAxi, endian
+function set_common_option {
+
+        set_min_max_param
+        g_secondary_axi=$(gen_val 0 $MAX_SEC_AXI $secondary_axi_temp)
+        g_stream_endian=$(gen_val $MIN_ENDIAN $MAX_ENDIAN $stream_endian_temp)
+        g_frame_endian=$(gen_val $MIN_ENDIAN $MAX_ENDIAN $frame_endian_temp)
+        g_source_endian=$(gen_val $MIN_ENDIAN $MAX_ENDIAN $source_endian_temp) #only for encoder
+}
+
+function get_default_option {
+    g_secondary_axi=0
+    g_stream_endian=0
+    g_source_endian=0
+    g_frame_endian=0
+    g_bsmode=0
+    g_cbcr_interleave=0
+    g_enable_nv21=0
+    g_rotAngle=0
+    g_mirDir=0
+    if [ $is_decoder -eq 1 ]; then
+        g_enable_thumbnail=0
+        g_enable_wtl=1
+        g_wtl_format=0
+        # CODA9 features
+        g_enable_deblock=0
+        g_enable_dering=0
+        g_maptype_index=0
+        if [[ $g_product_name =~ coda9* ]]; then
+            g_enable_wtl=0;
+        fi
+        # END CODA9
+    else
+        g_subframe_sync=0
+        g_lowLatencyMode=0
+        g_packedFormat=0
+    fi
+    if [ "$codec" = "vp9" ]; then
+        g_bsmode=2
+    fi
+}
+
+function get_default_param {
+    local is_decoder=$1
+    local g_product_name=$2
+
+    echo "default_opt=$default_opt"
+    if [ "$default_opt" = "0" ]; then
+        set_common_option
+        if [ $is_decoder -eq 1 ]; then
+            set_decoder_option
+        else
+            set_encoder_option
+        fi
+    else
+        get_default_option
+    fi
+}
+
+function gen_wtl_format {
+    local default_val=$1
+    local val
+
+    # g_yuv_fmt_list variable should be defined in TestRunnerXXX.sh
+    if [ -z "$default_val" ] || [ "$default_val" == "-99" ]; then
+        while : ; do
+            val=$(get_random 0 ${#g_yuv_fmt_list[@]}-1)
+            if [ "${g_yuv_fmt_list[$val]}" != "RESERVED" ]; then
+                break
+            fi
+        done
+    else
+        val=$default_val
+    fi
+    echo "$val"
+}
+
+function build_encoder_test_param {
+    # ENCODER
+    if [ "$MODE_COMP_ENCODED" == "1" ];  then param="${param} -c"; fi
+
+    param="$param $param2"
+
+    if [[ $g_product_name =~ coda9* ]]; then
+        if [ $g_enable_linear2tiled -eq 1 ]; then
+            param="$param --enable-linear2tiled"
+        fi
+        if [ $g_bsmode -eq 0 ]; then
+            param="$param --enable-ringBuffer"
+        else
+            param="$param --enable-lineBufInt"
+        fi
+        if [ $g_cbcr_interleave -eq 1 ]; then
+            param="$param --enable-cbcrInterleave"
+            if [ $g_enable_nv21 -eq 1 ]; then
+                param="$param --enable-nv21"
+            fi
+        fi
+        param="$param --rotate=$g_rotAngle"
+        param="$param --mirror=$g_mirDir"
+    else
+        ### WAVE5xx ###
+        param="$param --codec=$g_codec_index"
+        param="$param --source-endian=$g_source_endian"
+        param="$param --rotAngle=${g_rotAngle} --mirDir=${g_mirDir}"
+        if [ "$g_cframe" == "1" ] && [ "$g_rotAngle" == "0" ] && [ "$g_mirDir" == "0" ]; then
+            if [ "$g_product_name" == "wave521" ] || [ "$g_product_name" == "wave521c" ]; then
+                param="${param} --cframe50Enable=1 --cframe50Lossless=$g_cframelossless --cframe50Tx16Y=$g_cframetx16y --cframe50Tx16C=$g_cframetx16c --cframe50_422=$g_cframe_422"
+            fi
+            if [ $cfg_InputBitDepth == 8 ]; then
+                param="${param} --srcFormat=0"
+            else
+                param="${param} --srcFormat=${g_srcFormat}"
+            fi
+        else
+            if [ $cfg_InputBitDepth == 8 ]; then
+                param="${param} --srcFormat=0"
+            else
+                param="${param} --srcFormat=${g_srcFormat}"
+            fi
+            if  [ $g_packedFormat -ne 0 ]; then
+                param="${param} --packedFormat=${g_packedFormat}"
+            elif [ "$g_enable_nv21" == "0" ] && [ "$g_cbcr_interleave" == "1" ]; then
+                param="${param} --enable-cbcrInterleave --nv21=${g_enable_nv21}"
+            elif [ "$g_enable_nv21" == "1" ] && [ "$g_cbcr_interleave" == "1" ]; then
+                param="${param} --enable-cbcrInterleave --nv21=${g_enable_nv21}"
+            fi
+        fi
+
+        if [[ $g_product_name =~ wave5* ]]; then
+            param="${param} --lowLatencyMode=${g_lowLatencyMode}"
+        fi
+        if [ "$g_subFrameSync" == "1" ]; then
+            param="${param} --subFrameSyncEn=${g_subFrameSync}"
+        fi
+    fi
+}
+
+
+function build_decoder_test_param {
+    if [ "$g_match_mode" == "3" ]; then
+        param="$param -c 0"
+    else
+        param="$param -c $g_match_mode"
+    fi
+    param="$param --render 0"
+    param="$param --codec $g_codec_index"
+
+    # CODA9 features.
+    if [ $g_codec_index -eq 3 ]; then
+        param="$param --mp4class=$g_mp4class"
+    fi
+
+    if [ $g_enable_deblock -eq 1 ]; then
+        param="$param --enable-deblock"
+    fi
+    if [ $g_enable_mvc -eq 1 ]; then
+        param="$param --enable-mvc"
+    fi
+    # END and CODA9
+
+    param="$param $param2"
+
+    if [ $g_bsmode -gt 0 ]; then
+        param="$param --bsmode=$g_bsmode"
+    fi
+    if [ $g_enable_thumbnail -eq 1 ]; then
+        param="$param --enable-thumbnail"
+    fi
+
+    if [ $g_cbcr_interleave -eq 1 ]; then
+        param="$param --enable-cbcrinterleave"
+        if [ $g_enable_nv21 -eq 1 ]; then
+            param="$param --enable-nv21"
+        fi
+    fi
+
+    if [[ $g_product_name =~ coda9* ]]; then
+        if [ $g_enable_dering -eq 1 ]; then
+            param="$param --enable-dering"
+        fi
+        if [ $g_enable_wtl -eq 0 ] && [ $g_maptype_index -gt 0 ]; then
+            param="$param --disable-wtl"
+        fi
+        if [ $g_enable_tiled2linear -eq 1 ]; then
+            param="$param --enable-tiled2linear"
+        fi
+        if [ $g_rotAngle -gt 0 ]; then
+            param="$param --rotate=$g_rotAngle"
+        fi
+        if [ $g_mirDir -gt 0 ]; then
+            param="$param --mirror=$g_mirDir"
+        fi
+    else
+        if [ $g_enable_wtl -eq 0 ]; then
+            param="${param} --disable-wtl"
+        else
+            param="${param} --wtl-format=$g_wtl_format"
+            if [ $g_bw_opt -eq 1 ]; then
+                param="${param} --bwopt=1"
+            fi
+        fi
+        if [ "$g_pvric" == "1" ] || [ "$g_pvric" == "2" ]; then
+            param="$param --pvric=$g_pvric"
+            param="$param --ifbc_pad_y=$g_ifbc_pad_y"
+            param="$param --ifbc_pad_c=$g_ifbc_pad_c"
+        fi
+    fi
+
+    if [ $g_scaler == "true" ]; then
+        param="$param --sclw=$g_sclw --sclh=$g_sclh"
+    fi
+}
+
+function build_test_param {
+    local is_decoder=$1
+    local param=""
+    local param2=""
+
+
+    if [[ $g_product_name =~ coda9* ]]; then
+        if [ $g_maptype_index -gt 0 ]; then
+            param2="$param2 --maptype=$g_maptype_index"
+        fi
+    else
+        if [ "$g_fbc_mode" == "" ]; then
+            pram="$param --fbc-mode=0x0c"
+        else
+            param="$param --fbc-mode=$g_fbc_mode"
+        fi
+    fi
+
+    param2="$param2 --stream-endian=$g_stream_endian"
+    param2="$param2 --frame-endian=$g_frame_endian"
+    param2="$param2 --secondary-axi=$g_secondary_axi"
+    if [ $is_decoder -eq 1 ]; then
+        build_decoder_test_param
+    else
+        build_encoder_test_param
+    fi
+
+    g_func_ret_str="$param"
+}
+
+function get_random_param {
+    default_opt=0
+
+    aclk_freq_temp=-99
+    bclk_freq_temp=-99
+    cclk_freq_temp=-99
+
+    read_latency_temp=-99
+    write_latency_temp=-99
+
+    secondary_axi_temp=-99
+
+    stream_endian_temp=-99
+    frame_endian_temp=-99
+    source_endian_temp=-99
+
+    g_maptype_index_temp=-99 #coda960 & coda980
+
+    g_yuv_mode_temp=-99
+    if [ $is_decoder -eq 1 ]; then
+        bsmode_temp=-99
+        deblock_temp=-99
+        dering_temp=-99
+        rotAngle_temp=-99
+        mirDir_temp=-99
+
+        maptype_temp=-99
+        wtl_format_temp=-99
+        g_bw_opt_temp=-99
+    else
+        rotAngle_temp=-99
+        mirDir_temp=-99
+        if [[ $g_product_name =~ coda9* ]]; then
+            maptype_temp=-99
+            linear2tiled_temp=-99
+            linebuf_int_temp=-99
+            bsmode_temp=-99
+        else
+            lowLatencyMode_temp=-99
+        fi
+    fi
+
+    if [ "$g_product_name" = "wave512" ] || [ "$g_product_name" = "wave515" ] || [ "$g_product_name" = "wave511" ] || [ "$g_product_name" = "wave517" ]; then
+        g_output_hw_temp=-99
+    fi
+
+    get_default_param $1 $2
+
+    g_func_ret_str="$param"
+}
+
+function run_refc_scaler {
+    local input_path=$1
+    local output_path=$2
+    local fmt=$3
+
+    if [ -e $output_path ]; then
+        rm ${output_path}
+    fi
+
+    is_422=0
+    case $fmt in
+    FORMAT_420)
+        mode_index=0
+        ;;
+    FORMAT_422)
+        mode_index=0
+        is_422=1
+        ;;
+    FORMAT_422_P10_16BIT_MSB)
+        mode_index=1
+        is_422=1
+        ;;
+    FORMAT_422_P10_16BIT_LSB)
+        mode_index=1
+        is_422=1
+        ;;
+    FORMAT_422_P10_32BIT_MSB)
+        mode_index=1
+        is_422=1
+        ;;
+    FORMAT_422_P10_32BIT_LSB)
+        mode_index=1
+        is_422=1
+        ;;
+    *)
+        mode_index=1
+        ;;
+    esac
+
+    scaler_options="-i $input_path -x $g_oriw -y $g_orih -o $output_path -a $g_sclw -b $g_sclh -n 0"
+    if [ $mode_index -eq 0 ]; then
+        # refc output 8bit
+        if [ "$is_main10" == "1" ]; then
+            scaler_options="$scaler_options -g 2 -h 0"
+        else
+            scaler_options="$scaler_options -g 0 -h 0"
+        fi
+    else
+        # refc output 10bit
+        scaler_options="$scaler_options -g 2 -h 1"
+    fi
+
+    str_cmd="${bin_dir}/scaler ${scaler_options}"
+    echo "${str_cmd}"
+    ${str_cmd}
+
+    return $?
+}
+
+function run_refc_dec_av1 {
+    local stream_path="$1"
+    local output_path="$2"
+    local wtl_mode_index=0
+    local skip_option=0
+    local max_frames=""
+    local output_param=""
+    local file_ext=${stream_path##*.}
+    local stream_format_param="--ivf"
+
+    if [ "$file_ext" = "obu" ]; then
+        stream_format_param="--annexb"
+    elif [ "$file_ext" = "av1" ]; then
+        stream_format_param=""
+    fi
+
+    if [ $g_enable_thumbnail -eq 1 ]; then
+        skip_option=1
+    fi
+
+    output_param="-o $output_path"
+    if [ $g_match_mode -eq 2 ]; then
+        if [ $wtl_mode_index -ne 5 ]; then
+            wtl_mode_index=1
+        fi
+        if [ $is_main10 -eq 1 ] && [ $g_enable_wtl -eq 0 ]; then
+            wtl_mode_index=1
+        fi
+        str_opt="--codec av1_dec -i ${stream_path} -c -5 -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
+    elif [ $g_match_mode -eq 3 ]; then
+        if [ $g_wtl_format -eq 7 ] || [ $g_wtl_format -eq 8] ; then
+            wtl_mode_index=5
+        fi
+        str_opt="--codec av1_dec -i ${stream_path} $ref_stream_format_option -c -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
+    else
+        str_opt="--codec av1_dec -i ${stream_path} -c -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
+    fi
+
+    str_cmd="${bin_dir}/av1_dec ${str_opt} --sbs 46080 $stream_format_param"
+    echo "${str_cmd}"
+    ${str_cmd}
+
+    if [ "$?" != "0" ]; then
+        echo "Failed to ref-c"
+        return 1;
+    fi
+
+    return 0
+}
+
+function run_refc_dec_h265 {
+    local stream_path="$1"
+    local output_path="$2"
+    local wtl_mode_index=0
+    local skip_option=0
+    local max_frames=""
+    local output_param=""
+    local file_ext=${stream_path##*.}
+    if [ "$file_ext" = "mp4" ] || [ "$file_ext" = "mkv" ] || [ "$file_ext" = "avi" ]; then
+        cp ${bin_dir}/../../../util/bin/Linux/vcp ${bin_dir} || echo ingore_err
+        ${bin_dir}/vcp -i $stream_path output.bin
+        stream_path="output.bin"
+    fi
+
+    if [ $g_enable_thumbnail -eq 1 ]; then
+        skip_option=1
+    fi
+
+    if [ "$g_scaler" == "true" ]; then
+        scale_output_path="$output_path"
+        output_path="output_orig.yuv"
+    fi
+
+    output_param="-o $output_path"
+    if [ $g_match_mode -eq 2 ]; then
+        if [ $wtl_mode_index -ne 5 ]; then
+            wtl_mode_index=1
+        fi
+        if [ $is_main10 -eq 1 ] && [ $g_enable_wtl -eq 0 ]; then
+            wtl_mode_index=1
+        fi
+        str_opt="-i ${stream_path} -c -5 -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
+    else
+        local cmodel_wtl_mode=$wtl_mode_index
+        if [ $g_scaler == "true" ]; then
+            if [ "$is_main10" == "1" ]; then
+                wtl_mode_index=5
+            fi
+        fi
+        str_opt="-i ${stream_path} -c -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
+    fi
+
+    str_cmd="${bin_dir}/hevc_dec ${str_opt} --sbs 46080"
+    echo "${str_cmd}"
+    ${str_cmd}
+
+    if [ "$?" != "0" ]; then
+        echo "Failed to ref-c"
+        return 1;
+    fi
+
+    if [ $g_scaler == "true" ]; then
+        local fmt_name="${g_yuv_fmt_list[$g_wtl_format]}"
+        run_refc_scaler "output_orig.yuv" "${scale_output_path}" "$fmt_name"
+        if [ "$?" != "0" ]; then
+            echo "Failed to ref-c"
+            return 1;
+        fi
+    fi
+
+    return 0
+}
+
+function run_refc_dec_vp9 {
+    local stream_path="$1"
+    local output_path="$2"
+    local arg_cci=""
+    local wtl_mode_index=0
+    local max_frames=""
+
+    # VP9 refc only support wtl_format 0 and 5
+    if [ $g_wtl_format -eq 0 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 1 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 13 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 18 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 23 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 28 ]; then
+        wtl_mode_index=0;
+    else
+        wtl_mode_index=5;
+    fi
+
+    if [ $g_match_mode -eq 2 ]; then
+        if [ $wtl_mode_index -ne 0 ]; then
+            wtl_mode_index=5    # 16BIT MSB
+        fi
+        param="--input=${stream_path} --outmd5=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian --bsmode=$g_bsmode"
+    else
+        if [ $g_scaler == "true" ]; then
+            param="--input=${stream_path} --output=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian --bsmode=$g_bsmode --sclw $g_sclw --sclh $g_sclh"
+        else
+            param="--input=${stream_path} --output=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian --bsmode=$g_bsmode"
+        fi
+    fi
+
+
+    param="$param $g_frame_num "
+
+    if [ $g_bsmode -gt 0 ]; then
+        param="$param --bsmode=$g_bsmode"
+    fi
+    if [ $g_enable_thumbnail -eq 1 ]; then
+        param="$param --enable-thumbnail"
+    fi
+
+
+    if [ $g_enable_wtl -eq 0 ]; then
+        param="${param} --disable-wtl"
+    else
+        if [ "$g_product_name" = "wave512" ] || [ "$g_product_name" = "wave515" ] || [ "$g_product_name" = "wave511" ] || [ "$g_product_name" = "wave517" ]; then
+            param="${param} --wtl-format=${wtl_mode_index}"
+        else
+            param="${param} --wtl-format=$g_wtl_format"
+        fi
+    fi
+
+    if [ $g_cbcr_interleave -eq 1 ]; then
+        param="${param} --enable-cbcrinterleave"
+        if [ $g_enable_nv21 -eq 1 ]; then
+            param="${param} --enable-nv21"
+        fi
+
+    fi
+
+    str_cmd="${bin_dir}/vp9_dec_bwb ${param}"
+    if [ $g_scaler == "true" ]; then
+        str_cmd="${bin_dir}/vp9_dec_scaler ${param}"
+    fi
+
+    echo "${str_cmd}"
+    ${str_cmd}
+
+    if [ "$?" != "0" ]; then
+        echo "Failed to ref-c"
+        return 1;
+    fi
+    return 0
+}
+
+function run_refc_dec_avs2 {
+    local stream_path="$1"
+    local output_path="$2"
+    local wtl_mode_index=0
+
+    # AVS2 refc only support wtl_format 0 and 5
+    if [ $g_wtl_format -eq 0 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 1 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 13 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 18 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 23 ]; then
+        wtl_mode_index=0;
+    elif [ $g_wtl_format -eq 28 ]; then
+        wtl_mode_index=0;
+    else
+        wtl_mode_index=5;
+    fi
+
+    if [ $g_match_mode -eq 2 ]; then
+        if [ $wtl_mode_index -ne 0 ]; then
+            wtl_mode_index=5    # 16BIT MSB
+        fi
+        param="--input=${stream_path} --outmd5=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian"
+    else
+        param="--input=${stream_path} --output=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian"
+    fi
+
+    param="$param $g_frame_num "
+
+    if [ $g_enable_wtl -eq 0 ]; then
+        param="${param} --disable-wtl"
+    else
+        if [ $g_scaler == "true" ] && [ $is_main10 -eq 1 ]; then
+            param="${param} --wtl-format=5"
+        else
+            param="${param} --wtl-format=${wtl_mode_index}"
+        fi
+    fi
+
+    if [ $g_cbcr_interleave -eq 1 ]; then
+        param="${param} --enable-cbcrinterleave"
+        if [ $g_enable_nv21 -eq 1 ]; then
+            param="${param} --enable-nv21"
+        fi
+    fi
+
+    if [ $g_enable_thumbnail -eq 1 ]; then
+        param="$param --enable-thumbnail"
+    fi
+
+    str_cmd="${bin_dir}/avs2_dec_bwb ${param}"
+    echo "${str_cmd}"
+    ${str_cmd}
+
+    if [ "$?" != "0" ]; then
+        echo "Failed to ref-c"
+        return 1;
+    fi
+
+    if [ $g_scaler == "true" ]; then
+        if [ -z "$is_main10" ]; then
+            is_main10="0"
+        fi
+        run_refc_scaler "scaler_input.yuv" "${output_path}" "$g_wtl_format"
+        if [ "$?" != "0" ]; then
+            echo "Failed to ref-c"
+            return 1;
+        fi
+    fi
+
+    return 0
+}
+
+function run_refc_dec_svac {
+    local stream_path="$1"
+    local output_path="$2"
+    local wtl_mode_index=0
+    local output_param=""
+    local file_ext=${stream_path##*.}
+    if [ "$file_ext" = "mp4" ] || [ "$file_ext" = "mkv" ] || [ "$file_ext" = "avi" ]; then
+        cp ${bin_dir}/../../../util/bin/Linux/vcp ${bin_dir} || echo ingore_err
+        ${bin_dir}/vcp -i $stream_path output.bin
+        stream_path="output.bin"
+    fi
+
+    # Not implemented yet
+    if [ $g_enable_thumbnail -eq 1 ]; then
+        skip_option=1
+    fi
+
+    case $g_wtl_format in
+    0)  # 8BIT 420
+        wtl_mode_index=0;;
+    5)  # 16bit MSB
+        wtl_mode_index=1;;
+    6)  # 16bit LSB
+        wtl_mode_index=5;;
+    7)  # 32bit MSB
+        wtl_mode_index=2;;
+    8)  # 32bit LSB
+        wtl_mode_index=6;;
+    *) echo "Not supported WTL format: $g_wtl_format"
+       exit 1
+    esac
+    output_param="-o $output_path"
+
+    if [ $g_match_mode -eq 2 ]; then
+        if [ $wtl_mode_index -ne 0 ]; then
+            wtl_mode_index=1
+        fi
+        str_opt="-i ${stream_path} -c -5 -y ${wtl_mode_index} ${output_param}"
+    else
+        str_opt="-i ${stream_path} -c -y ${wtl_mode_index} ${output_param}"
+    fi
+
+    str_cmd="${bin_dir}/svac_dec ${str_opt}"
+    echo "${str_cmd}"
+    ${str_cmd}
+
+    if [ "$?" != "0" ]; then
+        echo "Failed to ref-c"
+        return 1;
+    fi
+    return 0
+}
+
+function run_refc_dec_avc {
+    local stream_path="$1"
+    local output_path="$2"
+    local wtl_mode_index=0
+    local output_param=""
+    local file_ext=${stream_path##*.}
+    if [ "$file_ext" = "mp4" ] || [ "$file_ext" = "mkv" ] || [ "$file_ext" = "avi" ]; then
+        cp ${bin_dir}/../../../util/bin/Linux/vcp ${bin_dir} || echo ingore_err
+        ${bin_dir}/vcp -i $stream_path output.bin
+        stream_path="output.bin"
+    fi
+
+    # Not implemented yet
+    if [ $g_enable_thumbnail -eq 1 ]; then
+        skip_option=1
+    fi
+
+
+    output_param="-o $output_path"
+    if [ "$g_scaler" == "true" ]; then
+        output_param="-o output_orig.yuv"
+    fi
+
+    if [ $g_match_mode -eq 2 ]; then
+        if [ $wtl_mode_index -ne 5 ]; then
+            wtl_mode_index=1
+        fi
+        if [ $is_main10 -eq 1 ] && [ $g_enable_wtl -eq 0 ]; then
+            wtl_mode_index=1
+        fi
+        str_opt="--codec avc_dec -i ${stream_path} -c  -5 -y ${wtl_mode_index} ${output_param}"
+    else
+        if [ "$g_scaler" == "true" ]; then
+            if [ "$is_main10" == "1" ]; then
+                wtl_mode_index=5
+            fi
+        fi
+        str_opt="--codec avc_dec -i ${stream_path} -c -y ${wtl_mode_index} ${output_param}"
+    fi
+
+    str_cmd="${bin_dir}/avc_dec ${str_opt}"
+    echo "${str_cmd}"
+
+    ${str_cmd}
+    if [ "$?" != "0" ]; then
+        echo "Failed to ref-c"
+        return 1;
+    fi
+
+    if [ $g_scaler == "true" ]; then
+        local fmt_name="${g_yuv_fmt_list[$g_wtl_format]}"
+        run_refc_scaler "output_orig.yuv" "${output_path}" "$fmt_name"
+        if [ "$?" != "0" ]; then
+            echo "Failed to ref-c"
+            return 1;
+        fi
+    fi
+
+    return 0
+}
+
+function run_refc_dec_coda9 {
+    local stream_path=$1
+    local output_yuv=$2
+    local ext=${stream_path##*.}
+
+    if [ "$ext" = "rmvb" ]; then
+        stream_path=${stream_path%.*}.rvf
+    fi
+
+    cmodel_param="-i $stream_path -o $output_yuv"
+    ext_param=""
+    shopt -s nocasematch
+    case "$codec" in
+        avc) if [ $g_enable_mvc -eq 1 ]; then
+                cmodel="RefMvcDec"
+             else
+                cmodel="RefAvcDec"
+             fi
+             ;;
+        vc1) cmodel="RefVc1Dec";;
+        mp2) cmodel="RefMp2Dec";;
+        mp4) cmodel="RefMp4Dec"
+             cmodel_param="$cmodel_param -s $g_mp4class";;
+        avs) cmodel="RefAvsDec";;
+        dv3) cmodel="RefDivDec"
+             cmodel_param="$cmodel_param -E host_div3_rtl_cmd.org"
+             if [ "$ext" = "ivf" ]; then
+                ext_param="-v"
+             fi
+             ;;
+        rvx) cmodel="RefRvxDec";;
+        vp8) cmodel="RefVpxDec"
+             cmodel_param="$cmodel_param --std 2";;
+        tho) cmodel="RefThoDec"
+             cmodel_param="$cmodel_param --make_stream --stream_filename temp/host_tho_rtl_cmd.org --stream_endian $g_stream_endian";;
+        *)    echo ""; return;;
+    esac
+    shopt -u nocasematch
+
+
+    ppu_option=0
+    if [ $g_match_mode -eq 1 ]; then
+        if [ $g_rotAngle -ne 0 ]; then
+            local index=$(($g_rotAngle/90))
+            ppu_option=$((0x10 | $index))
+        fi
+        if [ $g_mirDir -ne 0 ]; then
+            ppu_option=$(($ppu_option | 0x10 | ($g_mirDir<<2)))
+        fi
+        if [ $ppu_option -gt 0 ]; then
+            cmodel_param="$cmodel_param -g $ppu_option"
+        fi
+    fi
+    if [ $g_enable_dering -eq 1 ]; then
+        cmodel_param="$cmodel_param -p"
+    fi
+    if [ $g_enable_deblock -eq 1 ]; then
+        cmodel_param="$cmodel_param -d"
+    fi
+
+    exec_cmd="${bin_dir}/$cmodel $cmodel_param -l $ext_param -c"
+    echo "$exec_cmd"
+
+    $exec_cmd
+
+    return $?
+}
+
+function run_refc_enc_coda9 {
+    local val=0
+    local input=$1
+    local output=$2
+    local postfix=""
+
+    if [ "$g_product_name" = "coda980" ]; then
+        postfix="_980_rev"
+    fi
+
+    refc_exe="$bin_dir"
+    case $codec in
+    avc)
+        if [ $g_enable_mvc -eq 0 ]; then
+            refc_exe="$refc_exe/RefAvcEnc$postfix"
+        else
+            refc_exe="$refc_exe/RefMvcEnc$postfix"
+        fi
+        ;;
+    mp4)
+        refc_exe="$refc_exe/RefMp4Enc$postfix" ;;
+    *)
+        echo "run_refc_enc: Unknown codec $codec"
+        return 1;;
+    esac
+
+    refc_param="-i $input -o $output -p $yuv_dir/"
+
+    val=$(($g_rotAngle/90))
+    val=$(($val | ($g_mirDir<<2)))
+    if [ $val -ne 0 ]; then
+        refc_param="$refc_param -g $val"
+    fi
+
+    refc_param=$(echo $refc_param | sed -e 's/\\/\//g')
+
+    cmd="$refc_exe $refc_param"
+    echo $cmd
+    echo ""
+
+    $cmd
+
+    return $?
+}
+
+function generate_golden_data_path {
+    local codec=$1
+    local streamset=$2
+    local streamfile=$3
+    local layer=$4
+
+    codec_dir=""
+    shopt -s nocasematch
+    case "$codec" in
+        vp9)  codec_dir="vp9dec";;
+        hevc) codec_dir="hvcdec";;
+        avc)  codec_dir="avcdec";;
+        vc1)  codec_dir="vc1dec";;
+        mp2)  codec_dir="mp2dec";;
+        mp4)  codec_dir="mp4dec";;
+        h263) codec_dir="mp4dec";;
+        avs)  codec_dir="avsdec";;
+        dv3)  codec_dir="dv3dec";;
+        rvx)  codec_dir="rvxdec";;
+        vp8)  codec_dir="vp8dec";;
+        tho)  codec_dir="thodec";;
+        avs2) codec_dir="avs2dec";;
+        av1)  codec_dir="av1dec";;
+        *)    codec_dir="";;
+    esac
+    shopt -u nocasematch
+
+    if [ "$is_main10" = "" ]; then is_main10=0; fi
+
+    yuvext=""
+    if [ "$g_enable_wtl" == "1" ]; then
+        case "$codec" in
+        hevc | vp9 | avs2 | svac | avc | av1 )
+            if [ $is_main10 -eq 1 ]; then
+                if [ $g_wtl_format -eq 0 ]; then
+                    yuvext="_bwb_8"
+                elif [ $g_wtl_format -eq 1 ]; then
+                    # FORMAT_422
+                    yuvext="_422_8"
+                elif [ $g_wtl_format -gt 8 ] && [ $g_wtl_format -lt 13 ]; then
+                    # FORMAT_422_16BIT_XXX
+                    yuvext="_422"
+                elif [ $g_wtl_format -ge 13 ] && [ $g_wtl_format -le 17 ]; then
+                    if [ $g_wtl_format -eq 13 ]; then
+                        yuvext="_yuyv_8"
+                    else
+                        yuvext="_yuyv"
+                    fi
+                elif [ $g_wtl_format -ge 18 ] && [ $g_wtl_format -le 22 ]; then
+                    if [ $g_wtl_format -eq 18 ]; then
+                        yuvext="_yvyu_8"
+                    else
+                        yuvext="_yvyu"
+                    fi
+                elif [ $g_wtl_format -ge 23 ] && [ $g_wtl_format -le 27 ]; then
+                    if [ $g_wtl_format -eq 23 ]; then
+                        yuvext="_uyvy_8"
+                    else
+                        yuvext="_uyvy"
+                    fi
+                elif [ $g_wtl_format -ge 28 ] && [ $g_wtl_format -le 32 ]; then
+                    if [ $g_wtl_format -eq 28 ]; then
+                        yuvext="_vyuy_8"
+                    else
+                        yuvext="_vyuy"
+                    fi
+                fi
+            else
+                if [ $g_wtl_format -eq 1 ]; then
+                    yuvext="_422_8"
+                elif [ $g_wtl_format -eq 13 ]; then
+                    yuvext="_yuyv_8"
+                elif [ $g_wtl_format -eq 18 ]; then
+                    yuvext="_yvyu_8"
+                elif [ $g_wtl_format -eq 23 ]; then
+                    yuvext="_uyvy_8"
+                elif [ $g_wtl_format -eq 28 ]; then
+                    yuvext="_vyuy_8"
+                fi
+            fi
+            ;;
+        *)
+            ;;
+        esac
+    elif [ $g_afbce -eq 1 ]; then
+        case "$codec" in
+        hevc | vp9)
+            if [ $is_main10 -eq 1 ]; then
+                yuvext="_bwb_8"
+            fi
+        esac
+    fi
+
+
+    # CODA9xx & CODA7x features
+    local dering_str=""
+    if [ $g_enable_dering -eq 1 ]; then
+        dering_str="_dr"
+    fi
+    local deblk_str=""
+    if [ $g_enable_deblock -eq 1 ]; then
+        deblk_str="_dbk"
+    fi
+    # END CODA9xx & CODA7x
+
+    streamset_name=$(basename $streamset)
+    filename=$(basename $streamfile)
+
+    local target_base="$yuv_dir/$codec_dir"
+    local target_path=""
+
+    thumbnail_ext=""
+    if [ $g_enable_thumbnail -eq 1 ]; then
+        thumbnail_ext="_thumb"
+    fi
+
+    local wtl_format_ext=""
+    case $g_wtl_format in
+        0) wtl_format_ext="";;
+        5) wtl_format_ext="_16bit_msb";;
+        6) wtl_format_ext="_16bit_lsb";;
+        7) wtl_format_ext="_32bit_msb";;
+        8) wtl_format_ext="_32bit_lsb";;
+    esac
+
+    local rot_index=0
+    if [ $g_rotAngle -eq 0 ] && [ $g_mirDir -eq 0 ]; then
+        rot_index=0
+    fi
+    if [ $g_rotAngle -eq 180 ] && [ $g_mirDir -eq 3 ]; then
+        rot_index=0
+    fi
+    if [ $g_rotAngle -eq 90 ] && [ $g_mirDir -eq 0 ]; then
+        rot_index=1
+    fi
+    if [ $g_rotAngle -eq 270 ] && [ $g_mirDir -eq 3 ]; then
+        rot_index=1
+    fi
+    if [ $g_rotAngle -eq 180 ] && [ $g_mirDir -eq 0 ]; then
+        rot_index=2
+    fi
+    if [ $g_rotAngle -eq 0 ] && [ $g_mirDir -eq 3 ]; then
+        rot_index=2
+    fi
+    if [ $g_rotAngle -eq 270 ] && [ $g_mirDir -eq 0 ]; then
+        rot_index=3
+    fi
+    if [ $g_rotAngle -eq 90 ] && [ $g_mirDir -eq 3 ]; then
+        rot_index=3
+    fi
+    if [ $g_mirDir -eq 1 ] && [ $g_rotAngle -eq 0 ]; then
+        rot_index=4
+    fi
+    if [ $g_rotAngle -eq 180 ] && [ $g_mirDir -eq 2 ]; then
+        rot_index=4
+    fi
+    if [ $g_mirDir -eq 1 ] && [ $g_rotAngle -eq 90 ]; then
+        rot_index=5
+    fi
+    if [ $g_mirDir -eq 2 ] && [ $g_rotAngle -eq 270 ]; then
+        rot_index=5
+    fi
+    if [ $g_mirDir -eq 1 ] && [ $g_rotAngle -eq 180 ]; then
+        rot_index=6
+    fi
+    if [ $g_mirDir -eq 2 ] && [ $g_rotAngle -eq 0 ]; then
+        rot_index=6
+    fi
+    if [ $g_mirDir -eq 1 ] && [ $g_rotAngle -eq 270 ]; then
+        rot_index=7
+    fi
+    if [ $g_mirDir -eq 2 ] && [ $g_rotAngle -eq 90 ]; then
+        rot_index=7
+    fi
+
+    local target_ext="yuv"
+
+    svac_layer_name=""
+    if [ "$layer" == "1" ]; then
+        svac_layer_name="_BL"
+    elif [ "$layer" == "2" ]; then
+        svac_layer_name="_EL"
+    fi
+
+    if [ "$streamset_name" = "" ]; then
+        target_path="${target_base}/${filename}${wtl_format_ext}${deblk_str}${thumbnail_ext}${yuvext}_${rot_index}${svac_layer_name}.$target_ext"
+    else
+        # ex) xxxx_01.cmd -> xxxx.cmd
+        temp=`expr match "$streamset_name" '.*\(_[0-9]*\.cmd\)'`
+        if [ "$temp" != "" ]; then
+            streamset_name="${streamset_name%_[0-9]*\.cmd}.cmd"
+        fi
+        target_base="${target_base}/${streamset_name}"
+        target_path="${target_base}/${filename}${wtl_format_ext}${deblk_str}${dering_str}${thumbnail_ext}${yuvext}_${rot_index}${svac_layer_name}.$target_ext"
+    fi
+
+    if [ ! -d $target_base ]; then
+        mkdir -p $target_base
+    fi
+
+    g_func_ret_str="$target_path"
+}
+
+# execute the ref-c program to get the decoded image or md5
+# generate_yuv(stream_path, output_yuv_path)
+function generate_yuv {
+    local src=$1
+    local output=$2
+
+    case "$codec" in
+        av1)
+            echo "run_refc_dec_av1 $src $output"
+            run_refc_dec_av1 $src $output;;
+        vp9)
+            echo "run_refc_dec_vp9 $src $output"
+            run_refc_dec_vp9 $src $output;;
+        hevc)
+            echo "run_refc_dec_h265 $src $output"
+            run_refc_dec_h265 $src $output;;
+        avs2)
+            echo "run_refc_dec_avs2 $src $output"
+            run_refc_dec_avs2 $src $output;;
+        svac)
+            echo "run_refc_dec_svac $src $output"
+            run_refc_dec_svac $src $output;;
+        avc)
+            if [[ $g_product_name =~ coda9* ]]; then
+                echo "run_refc_dec_coda9 $src $output $codec"
+                run_refc_dec_coda9 $src $output $codec
+            else
+                echo "run_refc_dec_avc $src $output"
+                run_refc_dec_avc $src $output
+            fi
+            ;;
+        *)
+            echo "run_refc_dec_coda9 $src $output $codec"
+            run_refc_dec_coda9 $src $output $codec
+            ;;
+    esac
+    if [ $? != 0 ]; then
+        return 1;
+    fi
+}
+
+# generate_md5(stream_path, md5_path, force_run)
+function generate_md5 {
+    local src=$1
+    local _output_path=$2
+    local force_run=$3
+
+    local run=0
+
+    echo "dirname ${_output_path}"
+    basedir=`dirname ${_output_path}`
+    mkdir -p "${basedir}"
+
+    [ -e $_output_path ] || run=1
+
+    if [ "$force_run" != "" ];then
+        run=$force_run
+    fi
+
+    if [ $run -eq 1 ]; then
+        case "$codec" in
+        vp9)
+            run_refc_dec_vp9 ${src} md5_result.txt ;;     # generate linear md5
+        hevc)
+            run_refc_dec_h265 ${src} md5_result.txt ;;    # generate linear md5
+        svac)
+            run_refc_dec_svac ${src} md5_result.txt ;;    # generate linear md5
+        avs2)
+            run_refc_dec_avs2 ${src} md5_result.txt ;;    # generate linear md5
+        avc)
+            if [[ $g_product_name =~ coda9* ]]; then
+                run_refc_dec_coda9 $src md5_result.txt $codec
+                local npath=${_output_path%_[0-7].md5}
+                chmod 666 md5_result.txt_*.md5
+                for (( i=0; i<=7; i++ )); do
+                    cp --preserve=mode md5_result.txt_${i}.md5 ${npath}_${i}.md5
+                done
+                rm md5_result.txt_*.md5
+                return
+            else
+                run_refc_dec_avc  ${src} md5_result.txt     # generate linear md5
+            fi
+            ;;
+        *)
+            run_refc_dec_coda9 $src md5_result.txt $codec
+            local npath=${_output_path%_[0-7].md5}
+            chmod 666 md5_result.txt_*.md5
+            for (( i=0; i<=7; i++ )); do
+                cp --preserve=mode md5_result.txt_${i}.md5 ${npath}_${i}.md5
+            done
+            rm md5_result.txt_*.md5
+            return
+            ;;
+        esac
+        if [ "$?" != "0" ]; then
+            return 1;
+        fi
+        chmod 666 *.txt
+        echo "cp --preserve=mode md5_result.txt $_output_path"
+        cp --preserve=mode md5_result.txt $_output_path
+        rm md5_result.txt
+    fi
+}
+
+###############################################################################
+# ENCODER FUNCTIONS
+###############################################################################
+# void c9_parse_cfg(cfg_path, &w, &h, &field_flag)
+# desc: parse cfg file to get width, height and field_flag information
+function c9_parse_cfg {
+    local _cfg_path="$1"
+    local _width=$2
+    local _height=$3
+    local _is_field=$4
+    local _name=""
+    local _firstchar=""
+
+    shopt -s nocasematch
+    while read line; do
+    _firstchar=${line:0:1}
+    case "$_firstchar" in
+        "#") continue;;     # comment
+        ";") continue;;     # comment
+        "")  continue;;
+    esac
+    name=$(echo $line | cut -d' ' -f1)
+    if [ "$name" = "PICTURE_WIDTH" ]; then
+        eval $_width=$(echo $line | cut -d' ' -f2)
+    elif [ "$name" = "PICTURE_HEIGHT" ]; then
+        eval $_height=$(echo $line | cut -d' ' -f2)
+    elif [ "$name" = "INTERLACED_PIC" ]; then
+        eval $_is_field=$(echo $line | cut -d' ' -f2)
+    fi
+    done < $_cfg_path
+    shopt -u nocasematch
+}
+
+function read_cfg {
+    local _cfg_path="$1"
+    cfg_FramesToBeEncoded=0
+    cfg_InputFile=0
+    cfg_width=0
+    cfg_height=0
+    cfg_ScalingListFile=0
+    cfg_EnModeMap=0
+    cfg_ModeMapFile=0
+    cfg_EnLambdaMap=0
+    cfg_LambdaMapFile=0
+    cfg_EnCustomLambda=0
+    cfg_CustomLambdaFile=0
+    cfg_InputBitDepth=0
+    cfg_GopPreset=0
+    cfg_EnSVC=0
+    cfg_EnRoi=0
+    cfg_RoiFile=0
+    cfg_GopPreset=0
+    cfg_WeightedPred=0
+    cfg_BitstreamFile=""
+    cfg_EnBgDetect=0
+    cfg_RateControl=0
+    cfg_EnHvsQp=0
+    cfg_EnNoiseEst=0
+    cfg_CULevelRateControl=0
+    cfg_IntraCtuRefreshMode=0
+    cfg_WaveFrontSynchro=0
+    cfg_EncBitrate=0
+    cfg_LookAheadRcEnable=0
+    if [ -f ${_cfg_path} ]; then
+        while read line2; do
+            # remove right comment
+            line2=$(echo $line2 | tr -d '\n')
+            line2=$(echo $line2 | tr -d '\r')
+            line2="${line2%%\#*}"
+
+            attr=$(echo $line2 | cut -d':' -f1)
+            attr=$(echo $attr | tr -d ' ')
+
+            value=$(echo $line2 | cut -d':' -f2)
+            value=$(echo $value | tr -d ' ')
+
+            #echo "attr=$attr, value=${value},"
+
+            case "$attr" in
+                FramesToBeEncoded)       cfg_FramesToBeEncoded="$value";;
+                InputFile)               cfg_InputFile="$value";;
+                SourceWidth)             cfg_width="$value";;
+                SourceHeight)            cfg_height="$value";;
+                ScalingListFile)         cfg_ScalingListFile="$value";;
+                EnModeMap)               cfg_EnModeMap="$value";;
+                ModeMapFile)             cfg_ModeMapFile="$value";;
+                EnLambdaMap)             cfg_EnLambdaMap="$value";;
+                LambdaMapFile)           cfg_LambdaMapFile="$value";;
+                EnCustomLambda)          cfg_EnCustomLambda="$value";;
+                CustomLambdaFile)        cfg_CustomLambdaFile="$value";;
+                InputBitDepth)           cfg_InputBitDepth="$value";;
+                GopPreset)               cfg_GopPreset="$value";;
+                EnSVC)                   cfg_EnSVC="$value";;
+                EnRoi)                   cfg_EnRoi="$value";;
+                RoiFile)                 cfg_RoiFile="$value";;
+                GopPreset)               cfg_GopPreset="$value";;
+                WeightedPred)            cfg_WeightedPred="$value";;
+                BitstreamFile)           cfg_BitstreamFile="$value";;
+                EnBgDetect)              cfg_EnBgDetect="$value";;
+                RateControl)             cfg_RateControl="$value";;
+                EnHvsQp)                 cfg_EnHvsQp="$value";;
+                EnNoiseEst)              cfg_EnNoiseEst="$value";;
+                CULevelRateControl)      cfg_CULevelRateControl="$value";;
+                IntraCtuRefreshMode)     cfg_IntraCtuRefreshMode="$value";;
+                WaveFrontSynchro)        cfg_WaveFrontSynchro="$value";;
+                EncBitrate)              cfg_EncBitrate="$value";;
+                LookAheadRcEnable)       cfg_LookAheadRcEnable="$value";;
+                *) ;;
+            esac
+        done < $_cfg_path
+    else
+        echo "cfg not exist, cfg_path=$_cfg_path"
+    fi
+}
+
+
+

+ 107 - 0
soft_3rdpart/wave511/code/config.h

@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(WIN32) || defined(__MINGW32__)
+#	define PLATFORM_WIN32
+#elif defined(linux) || defined(__linux) || defined(ANDROID)
+#	define PLATFORM_LINUX
+#elif defined(unix) || defined(__unix)
+#   define PLATFORM_QNX
+#else
+#	define PLATFORM_NON_OS
+#endif
+
+#if defined(_MSC_VER)
+#	include <windows.h>
+#	define inline _inline
+#elif defined(__GNUC__)
+#elif defined(__ARMCC__)
+#else
+#  error "Unknown compiler."
+#endif
+
+#define API_VERSION_MAJOR       5
+#define API_VERSION_MINOR       5
+#define API_VERSION_PATCH       60
+#define API_VERSION             ((API_VERSION_MAJOR<<16) | (API_VERSION_MINOR<<8) | API_VERSION_PATCH)
+
+#if defined(PLATFORM_NON_OS) || defined (ANDROID) || defined(MFHMFT_EXPORTS) || defined(PLATFORM_QNX) || defined(CNM_SIM_PLATFORM)
+//#define SUPPORT_FFMPEG_DEMUX
+#else
+//#define SUPPORT_FFMPEG_DEMUX
+#endif
+
+//------------------------------------------------------------------------------
+// COMMON
+//------------------------------------------------------------------------------
+//#if defined(linux) || defined(__linux) || defined(ANDROID) || defined(CNM_FPGA_HAPS_INTERFACE)
+#define SUPPORT_MULTI_INST_INTR
+//#endif
+
+
+// do not define BIT_CODE_FILE_PATH in case of multiple product support. because wave410 and coda980 has different firmware binary format.
+#define CORE_0_BIT_CODE_FILE_PATH   "coda960.out"     // for coda960
+#define CORE_1_BIT_CODE_FILE_PATH   "coda980.out"     // for coda980
+#define CORE_2_BIT_CODE_FILE_PATH   "picasso.bin"     // for wave510
+#define CORE_4_BIT_CODE_FILE_PATH   "millet.bin"      // for wave520
+#define CORE_5_BIT_CODE_FILE_PATH   "kepler.bin"      // for wave515
+#define CORE_6_BIT_CODE_FILE_PATH   "chagall.bin"     // for wave521
+#define CORE_7_BIT_CODE_FILE_PATH "vincent.bin" // for wave517
+
+//------------------------------------------------------------------------------
+// OMX
+//------------------------------------------------------------------------------
+
+
+
+
+//------------------------------------------------------------------------------
+// WAVE521C
+//------------------------------------------------------------------------------
+
+
+//#define SUPPORT_LOOK_AHEAD_RC
+
+
+
+
+//------------------------------------------------------------------------------
+// WAVE511
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+// WAVE517
+//------------------------------------------------------------------------------
+
+
+//#define SUPPORT_SW_UART
+//#define SUPPORT_SW_UART_V2	// WAVE511 or WAVE521C
+#endif /* __CONFIG_H__ */
+
+

+ 2 - 0
soft_3rdpart/wave511/code/cp.sh

@@ -0,0 +1,2 @@
+#!/bin/bash
+sudo cp -rdvp vdec_driver/ /home/nfs/rootfs/root

+ 108 - 0
soft_3rdpart/wave511/code/sample_v2/component/cnm_app.c

@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "vdi_osal.h"
+#include "cnm_app.h"
+#include "cnm_app_internal.h"
+
+STATIC CNMAppContext appCtx;
+Int32 CnmErrorStatus = 0;
+void CNMAppInit(void)
+{
+    osal_memset((void*)&appCtx, 0x00, sizeof(CNMAppContext));
+
+    osal_init_keyboard();
+}
+
+BOOL CNMAppAdd(CNMTask task)
+{
+    CNMTaskContext* taskCtx = (CNMTaskContext*)task;
+    if (appCtx.numTasks >= MAX_TASKS_IN_APP) {
+        return FALSE;
+    }
+
+    taskCtx->oneTimeRun = TRUE;
+    appCtx.taskList[appCtx.numTasks++] = task;
+    return TRUE;
+}
+
+BOOL CNMAppRun(void)
+{
+    CNMTask             task;
+    Uint32              i;
+    BOOL                success;
+    Uint32              runningTask;
+
+    success     = TRUE;
+    runningTask = appCtx.numTasks;
+    for (i=0; i<appCtx.numTasks; i++) {
+        task=(CNMTask)appCtx.taskList[i];
+        if ( FALSE == CNMTaskRun((CNMTask)task))
+            return FALSE;
+    }
+
+    while (0 < runningTask) {
+        for (i=0; i<appCtx.numTasks; i++) {
+            if (NULL == (task=(CNMTask)appCtx.taskList[i])) continue;
+
+            if (FALSE == supportThread) {
+                if (FALSE == CNMTaskRun((CNMTask)task)) break;
+            }
+
+            if (CNM_TASK_RUNNING != CNMTaskWait(task)) {
+                success &= CNMTaskStop(task);
+                CNMTaskDestroy(task);
+                appCtx.taskList[i] = NULL;
+                runningTask--;
+            }
+        }
+    }
+
+    osal_memset((void*)&appCtx, 0x00, sizeof(CNMAppContext));
+
+    osal_close_keyboard();
+
+    return (0 == CnmErrorStatus) ? success : FALSE;
+}
+
+void CNMAppStop(void)
+{
+    Uint32 i;
+
+    for (i=0; i<appCtx.numTasks; i++) {
+        CNMTaskStop(appCtx.taskList[i]);
+    }
+}
+
+void CNMErrorSet(Int32 val)
+{
+   CnmErrorStatus = val;
+}
+
+Int32 CNMErrorGet(void)
+{
+    return CnmErrorStatus;
+}
+

+ 76 - 0
soft_3rdpart/wave511/code/sample_v2/component/cnm_app.h

@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#ifndef __CNM_APP_H__
+#define __CNM_APP_H__
+
+#include "vputypes.h"
+#include "component.h"
+
+typedef void*       CNMTask;
+
+typedef enum {
+    CNM_TASK_DONE,
+    CNM_TASK_RUNNING,
+    CNM_TASK_ERROR
+} CNMTaskWaitState;
+
+typedef void (*CNMTaskListener)(CNMTask task, void* context);
+
+typedef struct CNMAppConfig {
+    char            fwpath[256];
+} CNMAppConfig;
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void    CNMAppInit(void);
+BOOL    CNMAppAdd(CNMTask task);
+BOOL    CNMAppRun(void);
+void    CNMAppStop(void);
+
+CNMTask CNMTaskCreate(void);
+void    CNMTaskDestroy(CNMTask task);
+BOOL    CNMTaskAdd(CNMTask task, Component component);
+BOOL    CNMTaskRun(CNMTask task);
+CNMTaskWaitState CNMTaskWait(CNMTask task);
+BOOL    CNMTaskStop(CNMTask task);
+BOOL    CNMTaskIsTerminated(CNMTask task);
+
+enum {
+    CNM_ERROR_NONE,
+    CNM_ERROR_FAILURE,
+    CNM_ERROR_HANGUP,
+};
+void CNMErrorSet(Int32 val);
+Int32 CNMErrorGet();
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CNM_APP_H__ */
+

+ 58 - 0
soft_3rdpart/wave511/code/sample_v2/component/cnm_app_internal.h

@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#ifndef __CNM_APP_INTERNAL_H__
+#define __CNM_APP_INTERNAL_H__
+
+#include "vputypes.h"
+
+#define MAX_TASKS_IN_APP            8
+#define MAX_COMPONENTS_IN_TASK      6
+
+extern BOOL supportThread;
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct CNMTaskContext {
+    Uint32          numComponents;
+    void*           componentList[MAX_COMPONENTS_IN_TASK];
+    BOOL            stop;
+    BOOL            oneTimeRun;
+    BOOL            terminate;
+    BOOL            componentsConnected;
+} CNMTaskContext;
+
+typedef struct {
+    Uint32  numTasks;
+    CNMTask taskList[MAX_TASKS_IN_APP];
+} CNMAppContext;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CNM_APP_INTERNAL_H__ */
+

+ 198 - 0
soft_3rdpart/wave511/code/sample_v2/component/cnm_task.c

@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "vdi_osal.h"
+#include "cnm_app.h"
+#include "cnm_app_internal.h"
+
+CNMTask CNMTaskCreate(void)
+{
+    CNMTaskContext* ctx = (CNMTaskContext*)osal_malloc(sizeof(CNMTaskContext));
+
+    if (ctx == NULL) {
+        VLOG(ERR, "%s:%d Failed to allocate a memory\n", __FUNCTION__, __LINE__);
+        return NULL;
+    }
+
+    osal_memset((void*)ctx, 0x00, sizeof(CNMTaskContext));
+    ctx->oneTimeRun = supportThread;
+
+    return (CNMTask)ctx;
+}
+
+void CNMTaskDestroy(CNMTask task)
+{
+    CNMTaskContext* ctx = (CNMTaskContext*)task;
+    Uint32          i;
+
+    if (task == NULL) {
+        VLOG(WARN, "%s:%d HANDLE is NULL\n", __FUNCTION__, __LINE__);
+        return;
+    }
+
+    for (i=0; i<ctx->numComponents; i++) {
+        ComponentRelease(ctx->componentList[i]);
+    }
+
+    for (i=0; i<ctx->numComponents; i++) {
+        ComponentDestroy(ctx->componentList[i], NULL);
+    }
+
+    osal_free(task);
+
+    return;
+}
+
+BOOL CNMTaskAdd(CNMTask task, Component component)
+{
+    CNMTaskContext* ctx = (CNMTaskContext*)task;
+    Uint32 num = ctx->numComponents;
+
+    if (ctx->numComponents == MAX_COMPONENTS_IN_TASK) {
+        return FALSE;
+    }
+
+    ctx->componentList[num++] = (void*)component;
+    ctx->numComponents = num;
+
+    return TRUE;
+}
+
+BOOL CNMTaskRun(CNMTask task)
+{
+    CNMTaskContext* ctx = (CNMTaskContext*)task;
+    Uint32          i;
+    ComponentImpl*  com;
+    BOOL            terminate      = FALSE;
+    BOOL            stopComponents = FALSE;
+
+    if (ctx->componentsConnected == FALSE) {
+        for (i=0; i<ctx->numComponents-1; i++) {
+            Component from = (Component)ctx->componentList[i];
+            Component to   = (Component)ctx->componentList[i+1];
+            if (ComponentSetupTunnel(from, to) == FALSE) {
+                return FALSE;
+            }
+        }
+        ctx->componentsConnected = TRUE;
+    }
+
+    while (terminate == FALSE) {
+        terminate = TRUE;
+        for (i=0; i<ctx->numComponents; i++) {
+            if ((com=ctx->componentList[i]) == NULL) {
+                ctx->stop = TRUE;
+                break;
+            }
+            if (stopComponents == TRUE) {
+                /* Failure! stop all components */
+                ComponentStop(com);
+            }
+            else {
+                if (com->terminate == FALSE) {
+                    if (ComponentExecute(com) == COMPONENT_STATE_TERMINATED) {
+                        stopComponents = (com->success == FALSE);
+                        terminate     &= TRUE;
+                    }
+                    else {
+                        terminate     &= FALSE;
+                    }
+                }
+            }
+        }
+        if (ctx->oneTimeRun == TRUE) break;
+        osal_msleep(1); // For cross-debugging on non-thread environment.
+    }
+    ctx->terminate = (terminate || stopComponents);
+
+    return TRUE;
+}
+
+CNMTaskWaitState CNMTaskWait(CNMTask task)
+{
+    Uint32              i;
+    Uint32              doneCount = 0;
+    Int32               ret = CNM_TASK_ERROR;
+    ComponentImpl*      com;
+    CNMTaskContext*     ctx = (CNMTaskContext*)task;
+    BOOL                stopComponents = FALSE;
+
+    for (i=0; i<ctx->numComponents; i++) {
+        if ((com=(Component)ctx->componentList[i]) != NULL) {
+            if (stopComponents == TRUE) {
+                ComponentStop(com);
+                ret = ComponentWait(com);
+            }
+            else {
+                if ((ret=ComponentWait(com)) == 0) {
+                    stopComponents = (com->success == FALSE);
+                }
+            }
+        }
+        else {
+            ret = 0;    // A component might be terminated in the creating step.
+        }
+
+        if (ret == 0) doneCount++;
+    }
+
+    return (doneCount == ctx->numComponents) ? CNM_TASK_DONE : CNM_TASK_RUNNING;
+}
+
+BOOL CNMTaskStop(CNMTask task)
+{
+    CNMTaskContext* ctx = (CNMTaskContext*)task;
+    ComponentImpl*  com;
+    Uint32          i;
+    BOOL            success;
+
+    if (task == NULL) 
+        return TRUE;
+    
+    for (i=0; i<ctx->numComponents; i++) {
+        if (ctx->componentList[i]) ComponentStop(ctx->componentList[i]);
+    }
+
+    success = TRUE;
+    for (i=0; i<ctx->numComponents; i++) {
+        if ((com=(ComponentImpl*)ctx->componentList[i]) != NULL) {
+            if (com->success == FALSE) {
+                VLOG(WARN, "%s:%d <%s> returns FALSE\n", __FUNCTION__, __LINE__, com->name);
+            }
+            success &= com->success;
+        }
+        else success &= FALSE;
+    }
+
+    return success;
+}
+
+BOOL CNMTaskIsTerminated(CNMTask task)
+{
+    CNMTaskContext* ctx = (CNMTaskContext*)task;
+    
+    return ctx->terminate;
+}
+

+ 720 - 0
soft_3rdpart/wave511/code/sample_v2/component/component.c

@@ -0,0 +1,720 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include "component.h"
+#include "cnm_app.h"
+#include <sys/prctl.h>
+
+#ifdef PLATFORM_NON_OS
+BOOL supportThread = FALSE;
+#else
+BOOL supportThread = TRUE;
+#endif
+
+#define DEFAULT_NO_RESPONSE_TIMEOUT     720          // in second
+
+typedef struct ClockData {
+    BOOL    start;
+    Uint64  lastClock;          /* in millisecond */
+} ClockData;
+
+/*
+ * component_list.h is generated in the makefiles.
+ * See Wave5xxDecV2.mak or Wave5xxEncV2.mak.
+ */
+#include "component_list.h"
+
+static void SetupSinkPort(ComponentImpl* component, ComponentImpl* connectedComponent)
+{
+    component->sinkPort.connectedComponent = (Component)connectedComponent;
+}
+
+static void SetupSrcPort(ComponentImpl* component, ComponentImpl* connectedComponent, Port sinkPort)
+{
+    Port* srcPort = &component->srcPort;
+
+    component->srcPort.inputQ             = sinkPort.outputQ;
+    component->srcPort.outputQ            = sinkPort.inputQ;
+    component->srcPort.owner              = component;
+    component->srcPort.connectedComponent = connectedComponent;
+    component->usingQ = Queue_Create_With_Lock(srcPort->inputQ->size, srcPort->inputQ->itemSize);
+}
+
+Component ComponentCreate(const char* componentName, CNMComponentConfig* componentParam)
+{
+    ComponentImpl* instance = NULL;
+    ComponentImpl* com;
+    Uint32         i=0;
+
+    while ((com=componentList[i++])) {
+        if (strcmp(componentName, com->name) == 0) break;
+    }
+    if (com == NULL) {
+        VLOG(ERR, "%s:%d Can't find %s component\n", __FUNCTION__, __LINE__, componentName);
+        return NULL;
+    }
+
+    // Create an instance.
+    instance = (ComponentImpl*)osal_malloc(sizeof(ComponentImpl));
+    osal_memcpy(instance, com, sizeof(ComponentImpl));
+    if (instance->Create(instance, componentParam) == NULL) {
+        osal_free(instance);
+        instance= NULL;
+    }
+    else {
+        Port*  port = &instance->sinkPort;
+        Uint32 size = instance->containerSize;
+        void*  data = osal_malloc(size);
+
+        osal_memset((void*)data, 0x00, size);
+        ComponentPortCreate(port, instance, instance->numSinkPortQueue, size);
+        // Fill input queue
+        for (i=0; i<instance->numSinkPortQueue; i++) {
+            Queue_Enqueue(port->inputQ, data);
+        }
+        osal_free(data);
+
+        instance->state       = COMPONENT_STATE_CREATED;
+        instance->type        = CNM_COMPONENT_TYPE_ISOLATION;
+        if (instance->Hz) {
+            ClockData* clk = (ClockData*)osal_malloc(sizeof(ClockData));
+            clk->start     = FALSE;
+            clk->lastClock = 0ULL;
+            instance->internalData = (void*)clk;
+        }
+    }
+
+    return (Component)instance;
+}
+
+BOOL ComponentSetupTunnel(Component fromComponent, Component toComponent)
+{
+    ComponentImpl* src  = (ComponentImpl*)fromComponent;
+    ComponentImpl* sink = (ComponentImpl*)toComponent;
+    BOOL           hasComponent;
+
+    if (fromComponent == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    if (toComponent == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    SetupSinkPort(src, sink);
+    SetupSrcPort(sink, src, src->sinkPort);
+
+    hasComponent = (BOOL)(src->srcPort.connectedComponent != NULL);
+    src->type = (hasComponent == FALSE) ? CNM_COMPONENT_TYPE_SOURCE : CNM_COMPONENT_TYPE_FILTER;
+
+    hasComponent = (BOOL)(sink->sinkPort.connectedComponent != NULL);
+    sink->type = (hasComponent == FALSE) ? CNM_COMPONENT_TYPE_SINK : CNM_COMPONENT_TYPE_FILTER;
+
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    if ( !strcmp(src->name, "yuvfeeder") ) {
+        src->type = CNM_COMPONENT_TYPE_SOURCE;
+    }
+    if ( !strcmp(src->name, "reader") ) {
+        src->type = CNM_COMPONENT_TYPE_SINK;
+    }
+#endif
+    return TRUE;
+}
+
+void ComponentWaitState(Component component, ComponentState state)
+{
+    ComponentImpl* imp = (ComponentImpl*)component;
+
+    if (imp == NULL) return;
+
+    do {
+        osal_msleep(1);
+    } while (imp->state < state);
+}
+
+static void WaitReturningPortData(ComponentImpl* com)
+{
+    PortContainer* container;
+
+    while ((container=(PortContainer*)Queue_Dequeue(com->usingQ))) {
+        ComponentPortSetData(&com->srcPort, container);
+    }
+    while ((container=ComponentPortGetData(&com->srcPort))) {
+        ComponentPortSetData(&com->srcPort, container);
+    }
+}
+
+Int32 ComponentWait(Component component)
+{
+    ComponentImpl*  com = (ComponentImpl*)component;
+    Int32           ret;
+    Int32           retval;
+
+    if (supportThread == FALSE || com->thread == NULL) {
+        return (com->state != COMPONENT_STATE_TERMINATED) ? 2 : 0;
+    }
+
+    if ((ret=osal_thread_timedjoin(com->thread, (void**)&retval, 100)) == 0) {
+        com->thread = NULL;
+        WaitReturningPortData(com);
+    }
+
+    return ret;
+}
+
+static BOOL HasPortData(ComponentImpl* com, PortContainer** in, PortContainer** out)
+{
+    BOOL success = FALSE;
+
+    *in     = NULL;
+    *out    = NULL;
+    switch (com->type) {
+    case CNM_COMPONENT_TYPE_SOURCE:
+        if ((*out=ComponentPortPeekData(&com->sinkPort)) != NULL) {
+            success = TRUE;
+        }
+        break;
+    case CNM_COMPONENT_TYPE_FILTER:
+        *in=ComponentPortPeekData(&com->srcPort);
+        *out=ComponentPortPeekData(&com->sinkPort);
+        /* A filter component needs an container for output */
+        success = (BOOL)(*out != NULL);
+        break;
+    case CNM_COMPONENT_TYPE_SINK:
+        if ((*in=ComponentPortPeekData(&com->srcPort)) != NULL) {
+            success = TRUE;
+        }
+        break;
+    default:
+        /* SINGLE COMPONENT */
+        success = TRUE;
+        break;
+    }
+    if (*in)  (*in)->reuse  = TRUE;
+    if (*out) (*out)->reuse = TRUE;
+
+    return success;
+}
+
+static BOOL ReturnPortContainer(ComponentImpl* com, BOOL inputConsumed, BOOL hasOutput)
+{
+    BOOL  doReturn = FALSE;
+    BOOL  returned = FALSE;
+
+    switch (com->type) {
+    case CNM_COMPONENT_TYPE_FILTER:
+        doReturn = (BOOL)(hasOutput || inputConsumed);
+        break;
+    case CNM_COMPONENT_TYPE_SINK:
+        doReturn = inputConsumed;
+        break;
+    default:
+        doReturn = FALSE;
+        break;
+    }
+
+    if (doReturn) {
+        PortContainer* container;
+        Uint32          i, numItems = Queue_Get_Cnt(com->usingQ);
+        for (i=0; i<numItems; i++) {
+            container=(PortContainer*)Queue_Dequeue(com->usingQ);
+            if (container == NULL) break;
+            // Intentionally infinite loop to debug easily
+            ComponentGetParameter(NULL, com, GET_PARAM_COM_IS_CONTAINER_CONUSUMED, (void*)container);
+            if (container->consumed == TRUE) {
+                ComponentPortSetData(&com->srcPort, container);
+                // Return the used source data
+                returned = TRUE;
+                break;
+            }
+            else {
+                Queue_Enqueue(com->usingQ, container);
+            }
+        }
+    }
+
+    return returned;
+}
+
+static void SendClockSignal(ComponentImpl* com)
+{
+    if (com->Hz) {
+        PortContainerClock data;
+        ClockData*  clk  = (ClockData*)com->internalData;
+        BOOL        send = FALSE;
+
+        if (clk->start == FALSE) {
+            clk->start = TRUE;
+            clk->lastClock = osal_gettime();
+            send = TRUE;
+        }
+        else {
+            Uint32 diff = osal_gettime() - clk->lastClock;
+            send = (diff >= com->Hz);
+        }
+
+        if (send == TRUE) {
+            data.type = CNM_PORT_CONTAINER_TYPE_CLOCK;
+            com->Execute(com, (PortContainer*)&data, NULL);
+        }
+    }
+}
+
+static BOOL Execute(ComponentImpl* com)
+{
+    PortContainer* in      = NULL;
+    PortContainer* out     = NULL;
+    BOOL            success = TRUE;
+
+    SendClockSignal(com);
+
+    if (HasPortData(com, &in, &out) == TRUE) {
+        if ((success=com->Execute(com, in, out)) == FALSE) {
+            com->terminate = TRUE;
+        }
+
+        if (in && in->reuse == FALSE) {
+            Queue_Enqueue(com->usingQ, (void*)in);
+            // The "in" container still exists in a source port. It removes the container from the source port.
+            ComponentPortGetData(&com->srcPort);
+        }
+
+        if (out && out->reuse == FALSE) {
+            // The "out" container still exists in a sink port. It removes the container from the the sink port.
+            // If the container has no content, it has to be reused.
+            ComponentPortGetData(&com->sinkPort);
+            // Send data to the sink component
+            ComponentPortSetData(&com->sinkPort, out);
+        }
+        // Return a consumed container to the source port.
+        ReturnPortContainer(com, (in && in->consumed), (out && out->reuse == FALSE));
+    }
+
+    if (com->portFlush == TRUE) {
+        // Flush all data in the source port
+        void* data;
+
+        while ((data=Queue_Dequeue(com->usingQ))) {
+            ComponentPortSetData(&com->srcPort, data);
+        }
+
+        while ((data=ComponentPortGetData(&com->srcPort))) {
+            ComponentPortSetData(&com->srcPort, data);
+        }
+        com->portFlush = FALSE;
+    }
+
+    return success;
+}
+
+
+static void DoYourJob(ComponentImpl* com)
+{
+    BOOL            success;
+    BOOL            done = FALSE;
+    ComponentImpl*  sinkComponent;
+
+    if (CNMErrorGet() == CNM_ERROR_HANGUP) {
+        com->terminate = TRUE;
+    }
+    else {
+        switch (com->state) {
+        case COMPONENT_STATE_CREATED:
+            if ((success=com->Prepare(com, &done)) == TRUE) {
+                if (done == TRUE) com->state = COMPONENT_STATE_PREPARED;
+            }
+            break;
+        case COMPONENT_STATE_PREPARED:
+            if ((success=Execute(com)) == TRUE) {
+                com->state = COMPONENT_STATE_EXECUTED;
+            }
+            break;
+        case COMPONENT_STATE_EXECUTED:
+            success = Execute(com);
+            break;
+        default:
+            success = FALSE;
+            break;
+        }
+        if ((com->success=success) == FALSE) {
+            com->terminate = TRUE;
+        }
+    }
+    /* Check if connected components are terminated */
+    sinkComponent = (ComponentImpl*)com->sinkPort.connectedComponent;
+    if (sinkComponent && sinkComponent->terminate == TRUE) {
+        com->terminate = TRUE;
+    }
+
+    if (com->terminate == TRUE) {
+        com->state = COMPONENT_STATE_TERMINATED;
+    }
+}
+
+static void DoThreadWork(void* arg)
+{
+    ComponentImpl* com = (ComponentImpl*)arg;
+    prctl(PR_SET_NAME, com->name);
+    while (com->terminate == FALSE) {
+        DoYourJob(com);
+        osal_msleep(2); // To yield schedule
+    }
+
+    com->state = COMPONENT_STATE_TERMINATED;
+}
+
+ComponentState ComponentExecute(Component component)
+{
+    ComponentImpl* com   = (ComponentImpl*)component;
+
+    if (com == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return COMPONENT_STATE_TERMINATED;
+    }
+
+    if (supportThread) {
+        com->thread = osal_thread_create(DoThreadWork, (void*)com);
+    }
+    else {
+        DoYourJob(com);
+    }
+
+    return com->state;
+}
+
+void ComponentStop(Component component)
+{
+    ComponentImpl*  com   = (ComponentImpl*)component;
+
+    if (com->terminate == FALSE) {
+        com->terminate = TRUE;
+        if (supportThread == FALSE) {
+            com->state = COMPONENT_STATE_TERMINATED;
+            WaitReturningPortData(com);
+        }
+    }
+}
+
+void ComponentRelease(Component component)
+{
+    ComponentImpl*  impl = (ComponentImpl*)component;
+
+    if (impl) {
+        impl->Release(impl);
+    }
+
+    return;
+}
+
+BOOL ComponentDestroy(Component component, BOOL* ret)
+{
+    ComponentImpl*  impl = (ComponentImpl*)component;
+    BOOL            success;
+
+    if (impl == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    if (ret) {
+        *ret = impl->success;
+    }
+
+    ComponentPortDestroy(&impl->sinkPort);
+
+    success = impl->Destroy(impl);
+    Queue_Destroy(impl->usingQ);
+    if (impl->internalData) osal_free(impl->internalData);
+
+    osal_free(impl);
+
+    return success;
+}
+
+static char* getParamName[GET_PARAM_MAX] = {
+    "GET_PARAM_COM_STATE",
+    "GET_PARAM_FEEDER_BITSTREAM_BUF",
+    "GET_PARAM_DEC_HANDLE",
+    "GET_PARAM_DEC_CODEC_INFO",
+    "GET_PARAM_DEC_BITSTREAM_BUF_POS",
+    "GET_PARAM_DEC_FRAME_BUF_NUM",
+    "GET_PARAM_VPU_STATUS",
+    "GET_PARAM_RENDERER_FRAME_BUF",
+    "GET_PARAM_ENC_HANDLE",
+    "GET_PARAM_ENC_FRAME_BUF_NUM",
+    "GET_PARAM_ENC_FRAME_BUF_REGISTERED",
+    "GET_PARAM_YUVFEEDER_FRAME_BUF",
+    "GET_PARAM_READER_BITSTREAM_BUF",
+};
+
+CNMComponentParamRet ComponentGetParameter(Component from, Component to, GetParameterCMD commandType, void* data)
+{
+    ComponentImpl* com = (ComponentImpl*)to;
+    CNMComponentParamRet ret;
+
+    if (com == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle or the port closed\n", __FUNCTION__, __LINE__);
+        return CNM_COMPONENT_PARAM_FAILURE;
+    }
+
+    if (com->terminate == TRUE) {
+        return CNM_COMPONENT_PARAM_TERMINATED;
+    }
+    else {
+        if ((ret=com->GetParameter((ComponentImpl*)from, com, commandType, data)) == CNM_COMPONENT_PARAM_NOT_FOUND) {
+            // Redirect a command.
+            // Send a command other connected components.
+            if (com->srcPort.connectedComponent == from) {
+                // source component ----> current component -----> sink component
+                to = com->sinkPort.connectedComponent;
+            }
+            else {
+                // source component <---- current component <----- sink component
+                to = com->srcPort.connectedComponent;
+            }
+
+            if (to == NULL) {
+                VLOG(ERR, "%s:%d The command(%s) is not supported\n", __FUNCTION__, __LINE__, getParamName[commandType]);
+                return CNM_COMPONENT_PARAM_FAILURE;
+            }
+            from = com;
+            return ComponentGetParameter((Component*)from, to, commandType, data);
+        }
+    }
+
+    return ret;
+}
+
+void ComponentNotifyListeners(Component component, Uint64 event, void* data)
+{
+    ComponentImpl*          com = (ComponentImpl*)component;
+    Uint32                  i   = 0;
+    Uint64                  listeningEvents;
+    void*                   context;
+    ComponentListenerFunc   update  = NULL;
+
+    for (i=0; i<com->numListeners; i++) {
+        listeningEvents = com->listeners[i].events;
+        update          = com->listeners[i].update;
+        context         = com->listeners[i].context;
+        if (listeningEvents & event) {
+            update(component, event, data, context);
+        }
+    }
+}
+
+BOOL ComponentRegisterListener(Component component, Uint64 events, ComponentListenerFunc func, void* context)
+{
+    ComponentImpl*  com = (ComponentImpl*)component;
+    Uint32          num;
+
+    if (com == NULL) return FALSE;
+
+    num = com->numListeners;
+
+    if (num == MAX_NUM_LISTENERS) {
+        VLOG(ERR, "%s:%d Failed to ComponentRegisterListener\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    com->listeners[num].events  = events;
+    com->listeners[num].update  = func;
+    com->listeners[num].context = context;
+    com->numListeners           = num+1;
+
+    return TRUE;
+}
+
+CNMComponentParamRet ComponentSetParameter(Component from, Component to, SetParameterCMD commandType, void* data)
+{
+    ComponentImpl* com = (ComponentImpl*)to;
+
+    if (com == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle or the port closed\n", __FUNCTION__, __LINE__);
+        return CNM_COMPONENT_PARAM_FAILURE;
+    }
+
+    if (com->terminate == TRUE) {
+        return CNM_COMPONENT_PARAM_FAILURE;
+    }
+    else {
+        if (com->SetParameter((ComponentImpl*)from, com, commandType, data) == FALSE) {
+            // Redirect a command.
+            // Send a command other connected components.
+            if (com->srcPort.connectedComponent == from) {
+                // source component ----> current component -----> sink component
+                to = com->sinkPort.connectedComponent;
+            }
+            else {
+                // source component <---- current component <----- sink component
+                to = com->srcPort.connectedComponent;
+            }
+
+            if (to == NULL) {
+                VLOG(ERR, "%s:%d The command(%d) is not supported\n", __FUNCTION__, __LINE__, commandType);
+                return CNM_COMPONENT_PARAM_FAILURE;
+            }
+            from = com;
+            return ComponentSetParameter((Component*)from, to, commandType, data);
+        }
+    }
+
+    return CNM_COMPONENT_PARAM_SUCCESS;
+}
+
+void ComponentPortCreate(Port* port, Component owner, Uint32 depth, Uint32 size)
+{
+    // Release the queues which are created previously.
+    port->inputQ  = Queue_Create_With_Lock(depth, size);
+    port->outputQ = Queue_Create_With_Lock(depth, size);
+    port->owner   = owner;
+    port->sequenceNo = 0;
+}
+
+void ComponentPortSetData(Port* port, PortContainer* data)
+{
+    if (data == NULL) {
+        // Silent error
+        return;
+    }
+
+    data->consumed   = FALSE;
+    if (Queue_Enqueue(port->outputQ, (void*)data) == FALSE) {
+        VLOG(INFO, "%s FAILURE\n", __FUNCTION__);
+    }
+}
+
+PortContainer* ComponentPortPeekData(Port* port)
+{
+    PortContainer* c = Queue_Peek(port->inputQ);
+    if (c) {
+        c->packetNo = port->sequenceNo;
+    }
+    return c;
+}
+
+PortContainer* ComponentPortGetData(Port* port)
+{
+    PortContainer* c = Queue_Dequeue(port->inputQ);
+    if (c) {
+        port->sequenceNo++;
+    }
+
+    return c;
+}
+
+void* WaitBeforeComponentPortGetData(Port* port)
+{
+    BOOL  loop     = TRUE;
+    void* portData = NULL;
+
+    while (loop) {
+        if (Queue_Get_Cnt(port->inputQ) > 0) {
+            portData = Queue_Dequeue(port->inputQ);
+            loop = FALSE;
+        }
+    }
+
+    return portData;
+}
+
+void ComponentPortDestroy(Port* port)
+{
+    Queue_Destroy(port->inputQ);
+    Queue_Destroy(port->outputQ);
+    port->connectedComponent = NULL;
+}
+
+void ComponentPortWaitReadyStatus(Port* port)
+{
+    while (port->outputQ && Queue_Get_Cnt(port->outputQ) > 0) {
+        osal_msleep(1);
+    }
+}
+
+BOOL ComponentPortHasInputData(Port* port)
+{
+    return (Queue_Get_Cnt(port->inputQ) > 0);
+}
+
+Uint32 ComponentPortGetSize(Port* port)
+{
+    return port->inputQ->size;
+}
+
+void ComponentPortFlush(Component component)
+{
+    ComponentImpl* com = (ComponentImpl*)component;
+
+    com->portFlush = TRUE;
+}
+
+ComponentState ComponentGetState(Component component)
+{
+    ComponentImpl* com = (ComponentImpl*)component;
+
+    if (com == NULL) {
+        return COMPONENT_STATE_NONE;
+    }
+
+    return com->state;
+}
+
+BOOL ComponentChangeState(Component component, Uint32 state)
+{
+    ComponentImpl* com = (ComponentImpl*)component;
+
+    if (NULL != com) {
+        if (COMPONENT_STATE_NONE < state && COMPONENT_STATE_MAX > state) {
+            com->state = (ComponentState)state;
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+/* return TRUE  - Go next step
+ *        FALSE - Retry
+ */
+BOOL ComponentParamReturnTest(CNMComponentParamRet ret, BOOL* success)
+{
+    BOOL retry = TRUE;
+
+    switch (ret) {
+    case CNM_COMPONENT_PARAM_FAILURE:    retry = FALSE; *success = FALSE; break;
+    case CNM_COMPONENT_PARAM_SUCCESS:    retry = TRUE;  *success = TRUE;  break;
+    case CNM_COMPONENT_PARAM_NOT_READY:  retry = FALSE; *success = TRUE;  break;
+    case CNM_COMPONENT_PARAM_NOT_FOUND:  retry = FALSE; *success = FALSE; break;
+    case CNM_COMPONENT_PARAM_TERMINATED: retry = FALSE; *success = TRUE;  break;
+    default:                             retry = FALSE; *success = FALSE; break;
+    }
+
+    return retry;
+}
+

+ 593 - 0
soft_3rdpart/wave511/code/sample_v2/component/component.h

@@ -0,0 +1,593 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#ifndef _COMPONENT_H_
+#define _COMPONENT_H_
+
+#include "config.h"
+#include "vpuapifunc.h"
+#include "main_helper.h"
+
+#define MAX_QUEUE_NUM 5
+
+typedef void* Component;
+
+typedef enum {
+    GET_PARAM_COM_STATE,                    /*!<< It returns state of component. Param: ComponentState* */
+    GET_PARAM_COM_IS_CONTAINER_CONUSUMED,   /*!<< pointer of PortContainer */
+    GET_PARAM_FEEDER_BITSTREAM_BUF,         /*!<< to a feeder component  : ParamDecBitstreamBuffer */
+    GET_PARAM_FEEDER_EOS,                   /*!<< to a feeder component  : BOOL */
+    GET_PARAM_VPU_STATUS,                   /*!<< to a component. Get status information of the VPU : ParamVpuStatus. */
+    GET_PARAM_DEC_HANDLE,
+    GET_PARAM_DEC_CODEC_INFO,               /*!<< It returns a codec information. Param: DecInitialInfo */
+    GET_PARAM_DEC_BITSTREAM_BUF_POS,        /*!<< to a decoder component in ring-buffer mode. */
+    GET_PARAM_DEC_FRAME_BUF_NUM,            /*!<< to a decoder component : ParamDecNeedFrameBufferNum*/
+    GET_PARAM_RENDERER_FRAME_BUF,           /*!<< to a renderer component. ParamDecFrameBuffer */
+    GET_PARAM_RENDERER_PPU_FRAME_BUF,       /*!<< to a renderer component. ParamDecPPUFrameBuffer */
+    GET_PARAM_ENC_HANDLE,
+    GET_PARAM_ENC_FRAME_BUF_NUM,
+    GET_PARAM_ENC_FRAME_BUF_REGISTERED,
+    GET_PARAM_YUVFEEDER_FRAME_BUF,
+    GET_PARAM_READER_BITSTREAM_BUF,
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    GET_PARAM_ENC_LARC_INFO,
+#endif
+    GET_PARAM_MAX
+} GetParameterCMD;
+
+typedef enum {
+    // Common commands
+    SET_PARAM_COM_PAUSE,                        /*!<< Makes a component pause. A concrete component needs to implement its own pause state. */
+    // Decoder commands
+    SET_PARAM_DEC_SKIP_COMMAND,                 /*!<< Send a skip command to a decoder component. */
+    SET_PARAM_DEC_TARGET_TID,                   /*!<< Send a target temporal id to a decoder component.
+                                                      A parameter is pointer of ParamDecTargetTid structure. */
+    SET_PARAM_DEC_RESET,                        /*!<< Reset VPU */
+    SET_PARAM_DEC_FLUSH,                        /*!<< Flush command */
+    //Encoder commands
+    SET_PARAM_ENC_READ_BS_WHEN_FULL_INTERRUPT,  /*!<< Consume the bitstream buffer when the bitstream buffer full interrupt is asserted.
+                                                      The parameter is a pointer of BOOL(TRUE or FALSE)
+                                                 */
+    // Renderer commands
+    SET_PARAM_RENDERER_FLUSH,                   /*!<< Drop all frames in the internal queue depending on the ParamDecFlush struct*/
+    SET_PARAM_RENDERER_ALLOC_FRAMEBUFFERS,
+    SET_PARAM_RENDERER_REALLOC_FRAMEBUFFER,     /*!<< Re-allocate a framebuffer with given parameters.
+                                                      A component which is linked with a decoder as a sink component MUST implement this command. : ParamReallocFB
+                                                 */
+    SET_PARAM_RENDERER_FREE_FRAMEBUFFERS,       /*!<< A command to free framebuffers */
+    SET_PARAM_RENDERER_CHANGE_COM_STATE,        /*!<< A command to change a component state for renderer */
+    // Feeder commands
+    SET_PARAM_FEEDER_START_INJECT_ERROR,        /* The parameter is null. */
+    SET_PARAM_FEEDER_STOP_INJECT_ERROR,         /* The parameter is null. */
+    SET_PARAM_FEEDER_RESET,
+    SET_PARAM_MAX
+} SetParameterCMD;
+
+typedef enum {
+    COMPONENT_STATE_NONE,
+    COMPONENT_STATE_CREATED,
+    COMPONENT_STATE_PREPARED,
+    COMPONENT_STATE_EXECUTED,
+    COMPONENT_STATE_TERMINATED,
+    COMPONENT_STATE_MAX
+} ComponentState;
+
+typedef enum {
+    CNM_COMPONENT_PARAM_FAILURE,
+    CNM_COMPONENT_PARAM_SUCCESS,
+    CNM_COMPONENT_PARAM_NOT_READY,
+    CNM_COMPONENT_PARAM_NOT_FOUND,
+    CNM_COMPONENT_PARAM_TERMINATED,
+    CNM_COMPONENT_PARAM_MAX
+} CNMComponentParamRet;
+
+typedef enum {
+    CNM_COMPONENT_TYPE_NONE,
+    CNM_COMPONENT_TYPE_ISOLATION,
+    CNM_COMPONENT_TYPE_SOURCE,
+    CNM_COMPONENT_TYPE_FILTER,
+    CNM_COMPONENT_TYPE_SINK,
+} CNMComponentType;
+
+typedef enum {
+    CNM_PORT_CONTAINER_TYPE_DATA,
+    CNM_PORT_CONTAINER_TYPE_CLOCK,
+    CNM_PORT_CONTAINER_TYPE_MAX
+} CNMPortContainerType;
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct PortContainer {
+    Uint32  packetNo;
+    BOOL    consumed;
+    BOOL    reuse;
+    BOOL    last;
+    Uint32  type;
+} PortContainer;
+
+typedef struct PortContainerClock {
+    Uint32  packetNo;
+    BOOL    consumed;
+    BOOL    reuse;
+    BOOL    last;
+    Uint32  type;
+} PortContainerClock;
+
+/** @ingroup buf */
+typedef struct PortContainerExternal
+{
+    Uint32 nSize;              /**< size of the structure in bytes */
+    Uint8* pBuffer;            /**< Pointer to actual block of memory 
+                                     that is acting as the buffer */
+    Uint32 nAllocLen;          /**< size of the buffer allocated, in bytes */
+    Uint32 nFilledLen;         /**< number of bytes currently in the 
+                                     buffer */
+    Uint32 nOffset;            /**< start offset of valid data in bytes from
+                                     the start of the buffer */
+    void*  pAppPrivate;        /**< pointer to any data the application
+                                     wants to associate with this buffer */
+    Uint32 nTickCount;         /**< Optional entry that the component and
+                                     application can update with a tick count
+                                     when they access the component.  This
+                                     value should be in microseconds.  Since
+                                     this is a value relative to an arbitrary
+                                     starting point, this value cannot be used 
+                                     to determine absolute time.  This is an
+                                     optional entry and not all components
+                                     will update it.*/
+    Uint64 nTimeStamp;       /**< Timestamp corresponding to the sample 
+                                     starting at the first logical sample 
+                                     boundary in the buffer. Timestamps of 
+                                     successive samples within the buffer may
+                                     be inferred by adding the duration of the 
+                                     of the preceding buffer to the timestamp
+                                     of the preceding buffer.*/
+    Uint32  nFlags;           /**< buffer specific flags */
+} PortContainerExternal;
+
+typedef struct PortContainerES {
+    Uint32          packetNo;
+    BOOL            consumed;
+    BOOL            reuse;                  /*!<< If data in container wasn't consumed then @reuse is assigned to 1. */
+    BOOL            last;
+    Uint32          type;
+    /* ---- DO NOT TOUCH THE ABOVE FIELDS ---- */
+    vpu_buffer_t    buf;
+    Uint32          size;
+    Uint32          streamBufFull;
+    /* ---- Belows vairables are for ringbuffer ---- */
+    PhysicalAddress rdPtr;
+    PhysicalAddress wrPtr;
+    PhysicalAddress paBsBufStart;
+    PhysicalAddress paBsBufEnd;
+    vpu_buffer_t    newBsBuf;
+} PortContainerES;
+
+typedef struct PortContainerDisplay {
+    Uint32          packetNo;
+    BOOL            consumed;
+    BOOL            reuse;
+    BOOL            last;
+    Uint32          type;
+    /* ---- DO NOT TOUCH THE ABOVE FIELDS ---- */
+    DecOutputInfo   decInfo;
+} PortContainerDisplay;
+
+typedef struct ParamEncNeedFrameBufferNum {
+    Uint32  reconFbNum;
+    Uint32  srcFbNum;
+} ParamEncNeedFrameBufferNum;
+
+typedef struct ParamEncFrameBuffer {
+    Uint32               reconFbStride;
+    Uint32               reconFbHeight;
+    FrameBuffer*         reconFb;
+    FrameBuffer*         srcFb;
+    FrameBufferAllocInfo reconFbAllocInfo;
+    FrameBufferAllocInfo srcFbAllocInfo;
+} ParamEncFrameBuffer;
+
+typedef struct ParamEncBitstreamBuffer {
+    Uint32          num;
+    vpu_buffer_t*   bs;
+} ParamEncBitstreamBuffer;
+
+typedef struct {
+    BOOL ringBufferEnable;
+    Uint8* encodedStreamBuf;
+    Int32 encodedStreamBufSize;
+    Int32 encodedStreamBufLength;
+} EncodedStreamBufInfo;
+
+typedef struct {
+    Uint8* encodedHeaderBuf;
+    Int32 encodedHeaderBufSize;
+    osal_file_t     *fp;
+} EncodedHeaderBufInfo;
+
+typedef struct {
+    BOOL ret;
+    BOOL success;
+    BOOL isConnectedEnc;
+    ParamEncNeedFrameBufferNum fbCnt;
+} ParamRenderAllocInfo;
+
+
+typedef struct PortContainerYuv {
+    Uint32          packetNo;
+    BOOL            consumed;
+    BOOL            reuse;
+    BOOL            last;
+    Uint32          type;
+    /* ---- DO NOT TOUCH THE ABOVE FIELDS ---- */
+    FrameBuffer     fb;
+    FrameBuffer     fbOffsetTbl;
+    Int32           srcFbIndex;
+    BOOL            prevMapReuse;
+} PortContainerYuv;
+
+typedef struct ParamDecBitstreamBuffer {
+    Uint32          num;
+    vpu_buffer_t*   bs;
+} ParamDecBitstreamBuffer;
+
+typedef struct ParamDecNeedFrameBufferNum {
+    Uint32  linearNum;                       /*!<< the number of framebuffers which are used to decompress or converter to linear data */
+    Uint32  nonLinearNum;                   /*!<< the number of tiled or compressed framebuffers which are used as a reconstruction */
+} ParamDecNeedFrameBufferNum;
+
+typedef struct ParamDecFrameBuffer {
+    Uint32          stride;
+    Uint32          linearNum;               /*!<< the number of framebuffers which are used to decompress or converter to linear data */
+    Uint32          nonLinearNum;           /*!<< the number of tiled or compressed framebuffers which are used as a reconstruction */
+    FrameBuffer*    fb;
+} ParamDecFrameBuffer;
+
+typedef struct ParamDecPPUFrameBuffer {
+    BOOL            enablePPU;
+    Queue*          ppuQ;
+    FrameBuffer*    fb;
+} ParamDecPPUFrameBuffer;
+
+typedef struct ParamDecReallocFB {
+    Int32           linearIdx;
+    Int32           compressedIdx;
+    Uint32          width;                  /*!<< New picture width */
+    Uint32          height;                 /*!<< New picture hieght */
+    FrameBuffer     newFbs[2];              /*!<< Reallocated framebuffers. newFbs[0] for compressed fb, newFbs[1] for linear fb */
+} ParamDecReallocFB;
+
+/* ParamDecBitStreamBufPos is used to get or set read pointer and write pointer of a bitstream buffer.
+ */
+typedef struct ParamDecBitstreamBufPos {
+    PhysicalAddress rdPtr;
+    PhysicalAddress wrPtr;
+    Uint32          avail;                  /*!<< the available size */
+} ParamDecBitstreamBufPos;
+
+typedef struct ParamVpuStatus {
+    QueueStatusInfo  cq;                    /*!<< The command queue status */
+} ParamVpuStatus;
+
+typedef struct ParamDecTargetTid {
+    Int32           targetTid;
+    Int32           tidMode;                /*!<< 0 - targetTid is used as an absolute value, 1 - targetTid is used as an relative value */
+} ParamDecTargetTid;
+
+
+typedef struct ParamReallocFrameBuffer {
+    Uint32          tiledIndex;
+    Uint32          linearIndex;
+} FrameReallocFrameBuffer;
+
+typedef struct {
+    Queue*          inputQ;
+    Queue*          outputQ;
+    Component       owner;
+    Component       connectedComponent;     /*!<< NOTE: DO NOT ACCESS THIS VARIABLE DIRECTLY */
+    Uint32          sequenceNo;             /*!<< The sequential number of transferred data */
+} Port;
+
+
+typedef struct {
+    Uint8*          bitcode;
+    Uint32          sizeOfBitcode;                              /*!<< size of bitcode in word(2byte) */
+    TestDecConfig   testDecConfig;
+    DecOpenParam    decOpenParam;
+    TestEncConfig   testEncConfig;
+    EncOpenParam    encOpenParam;
+    ENC_CFG         encCfg;
+} CNMComponentConfig;
+
+
+#define COMPONENT_EVENT_NONE                    0
+/* ------------------------------------------------ */
+/* ---------------- COMMON  EVENTS ---------------- */
+/* ------------------------------------------------ */
+#define COMPONENT_EVENT_SLEEP                   (1ULL<<0)       /*!<< The third parameter of listener is NULL. */
+#define COMPONENT_EVENT_WAKEUP                  (1ULL<<1)       /*!<< The third parameter of listener is NULL. */
+#define COMPONENT_EVENT_COMMON_ALL              0xffffULL
+/* ------------------------------------------------ */
+/* ---------------- DECODER EVENTS ---------------- */
+/* ------------------------------------------------ */
+#define COMPONENT_EVENT_DEC_OPEN                (1ULL<<16)      /*!<< The third parameter of listener is a pointer of CNMComListenerDecOpen. */
+#define COMPONENT_EVENT_DEC_ISSUE_SEQ           (1ULL<<17)      /*!<< The third parameter of listener is a pointer of CNMComListenerDecIssueSeq */
+#define COMPONENT_EVENT_DEC_COMPLETE_SEQ        (1ULL<<18)      /*!<< The third parameter of listener is a pointer of CNMComListenerDecCompleteSeq */
+#define COMPONENT_EVENT_DEC_REGISTER_FB         (1ULL<<19)      /*!<< The third parameter of listener is a pointer of CNMComListenerDecRegisterFb */
+#define COMPONENT_EVENT_DEC_READY_ONE_FRAME     (1ULL<<20)      /*!<< The third parameter of listener is a pointer of CNMComListenerDecReadyOneFrame */
+#define COMPONENT_EVENT_DEC_START_ONE_FRAME     (1ULL<<21)      /*!<< The third parameter of listener is a pointer of CNMComListenerStartDecOneFrame. */
+#define COMPONENT_EVENT_DEC_INTERRUPT           (1ULL<<22)      /*!<< The third parameter of listener is a pointer of CNMComListenerHandlingInt */
+#define COMPONENT_EVENT_DEC_GET_OUTPUT_INFO     (1ULL<<23)      /*!<< The third parameter of listener is a pointer of CNMComListenerDecDone. */
+#define COMPONENT_EVENT_DEC_DECODED_ALL         (1ULL<<24)      /*!<< The third parameter of listener is a pointer of CNMComListenerDecClose . */
+#define COMPONENT_EVENT_DEC_CLOSE               (1ULL<<25)      /*!<< The third parameter of listener is NULL. */
+#define COMPONENT_EVENT_DEC_RESET_DONE          (1ULL<<26)      /*!<< The third parameter of listener is NULL. */
+#define COMPONENT_EVENT_DEC_EMPTY_BUFFER_DONE   (1ULL<<27)
+#define COMPONENT_EVENT_DEC_FILL_BUFFER_DONE    (1ULL<<28)
+#define COMPONENT_EVENT_DEC_ALL                 0xffff0000ULL
+
+/* ------------------------------------------------ */
+/* ---------------- RENDERER EVENTS ----------------*/
+/* ------------------------------------------------ */
+typedef enum {
+    COMPONENT_EVENT_RENDER_ALLOCATE_FRAMEBUFER  = (1<<0),
+    COMPONENT_EVENT_RENDER_ALL = 0xffffffff
+} ComponentEventRenderer;
+
+typedef struct CNMComListenerDecOpen {
+    DecHandle   handle;
+    RetCode     ret;
+} CNMComListenerDecOpen;
+
+typedef struct CNMComListenerDecIssueSeq {
+    DecHandle   handle;
+    RetCode     ret;
+} CNMComListenerDecIssueSeq;
+
+typedef struct CNMComListenerDecCompleteSeq {
+    DecInitialInfo*     initialInfo;
+    FrameBufferFormat   wtlFormat;
+    Uint32              cbcrInterleave;
+    CodStd              bitstreamFormat;
+    char                refYuvPath[MAX_FILE_PATH];
+    RetCode             ret;
+} CNMComListenerDecCompleteSeq;
+
+typedef struct CNMComListenerDecRegisterFb {
+    DecHandle       handle;
+    Uint32          numNonLinearFb;
+    Uint32          numLinearFb;
+} CNMComListenerDecRegisterFb;
+
+typedef struct CNMComListenerDecReadyOneFrame {
+    DecHandle       handle;
+} CNMComListenerDecReadyOneFrame;
+
+typedef struct CNMComListenerStartDecOneFrame {
+    DecHandle   handle;
+    RetCode     result;
+    DecParam    decParam;
+} CNMComListenerStartDecOneFrame;
+
+typedef struct CNMComListenerDecInt {
+    DecHandle       handle;
+    Int32           flag;
+    Uint32          decIndex;
+} CNMComListenerDecInt;
+
+typedef struct CNMComListenerDecDone {
+    DecHandle       handle;
+    RetCode         ret;
+    DecParam*       decParam;
+    DecOutputInfo*  output;
+    Uint32          numDecoded;
+    vpu_buffer_t    vbUser;
+    CodStd          bitstreamFormat;    /* codec */
+    BOOL            enableScaler;
+#if defined(SUPPORT_VCPU_FPGA) || defined(SUPPORT_VCORE_FPGA)
+    VcoreTestData*  vcoreData;
+#endif /* SUPPORT_VCPU_FPGA || SUPPORT_VCORE_FPGA */
+} CNMComListenerDecDone;
+
+typedef struct CNMComListenerDecClose {
+    DecHandle       handle;
+} CNMComListenerDecClose;
+
+/* ------------------------------------------------ */
+/* ---------------- ENCODER EVENTS ---------------- */
+/* ------------------------------------------------ */
+#define COMPONENT_EVENT_ENC_OPEN                    (1ULL<<32)      /*!<< The third parameter of listener is a pointer of CNMComListenerEncOpen. */
+#define COMPONENT_EVENT_ENC_ISSUE_SEQ               (1ULL<<33)      /*!<< The third parameter of listener is NULL */
+#define COMPONENT_EVENT_ENC_COMPLETE_SEQ            (1ULL<<34)      /*!<< The third parameter of listener is a pointer of CNMComListenerEncCompleteSeq */
+#define COMPONENT_EVENT_ENC_REGISTER_FB             (1ULL<<35)      /*!<< The third parameter of listener is NULL */
+#define COMPONENT_EVENT_ENC_READY_ONE_FRAME         (1ULL<<36)      /*!<< The third parameter of listener is a pointer of CNMComListenerEncReadyOneFrame  */
+#define COMPONENT_EVENT_ENC_START_ONE_FRAME         (1ULL<<37)      /*!<< The third parameter of listener is a pointer of CNMComListenerEncStartOneFrame */
+#define COMPONENT_EVENT_ENC_HANDLING_INT            (1ULL<<38)      /*!<< The third parameter of listener is a pointer of CNMComListenerHandlingInt */
+#define COMPONENT_EVENT_ENC_GET_OUTPUT_INFO         (1ULL<<39)      /*!<< The third parameter of listener is a pointer of CNMComListenerEncDone. */
+#define COMPONENT_EVENT_ENC_CLOSE                   (1ULL<<40)      /*!<< The third parameter of listener is a pointer of CNMComListenerEncClose. */
+#define COMPONENT_EVENT_ENC_FULL_INTERRUPT          (1ULL<<41)      /*!<< The third parameter of listener is a pointer of CNMComListenerEncFull . */
+#define COMPONENT_EVENT_ENC_ENCODED_ALL             (1ULL<<42)      /*!<< The third parameter of listener is a pointer of EncHandle. */
+#define COMPONENT_EVENT_ENC_RESET                   (1ULL<<43)      /*!<< The third parameter of listener is a pointer of EncHandle. */
+#define COMPONENT_EVENT_CODA9_ENC_MAKE_HEADER       (1ULL<<44)      /*!<< The third parameter of listener is a pointer of CNMComListenerEncDone. */
+#define COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE       (1ULL<<45)
+#define COMPONENT_EVENT_ENC_FILL_BUFFER_DONE        (1ULL<<46)
+#define COMPONENT_EVENT_ENC_ALL                     0xffff00000000ULL
+
+/* ------------------------------------------------ */
+/* ---------------- ENC FEEDER EVENTS ----------------*/
+/* ------------------------------------------------ */
+typedef enum {
+    COMPONENT_EVENT_ENC_FEEDER_PREPARE              = (1<<0),
+    COMPONENT_EVENT_ENC_FEEDER_ALL                  = 0xffffffff
+} ComponentEventEncFeeder;
+
+typedef struct CNMComListenerEncOpen{
+    EncHandle       handle;
+} CNMComListenerEncOpen;
+
+typedef struct CNMComListenerEncCompleteSeq {
+    EncHandle       handle;
+} CNMComListenerEncCompleteSeq;
+
+typedef struct CNMComListenerHandlingInt {
+    EncHandle       handle;
+} CNMComListenerHandlingInt;
+
+typedef struct CNMComListenerEncMakeHeader{
+    EncHandle       handle;
+    EncodedHeaderBufInfo encHeaderInfo;
+} CNMComListenerEncMakeHeader;
+
+typedef struct CNMComListenerEncReadyOneFrame{
+    EncHandle       handle;
+    RetCode         result;
+} CNMComListenerEncReadyOneFrame;
+
+typedef struct CNMComListenerEncStartOneFrame{
+    EncHandle       handle;
+    RetCode         result;
+} CNMComListenerEncStartOneFrame;
+
+typedef struct CNMComListenerEncDone {
+    EncHandle       handle;
+    EncOutputInfo*  output;
+    BOOL            fullInterrupted;
+    EncodedStreamBufInfo encodedStreamInfo;
+    PhysicalAddress bitstreamBuffer;
+    Uint32          bitstreamBufferSize;
+} CNMComListenerEncDone;
+
+typedef struct CNMComListenerEncFull {
+    EncHandle       handle;
+} CNMComListenerEncFull;
+
+typedef struct CNMComListenerEncClose {
+    EncHandle       handle;
+} CNMComListenerEncClose;
+
+typedef Int32 (*ListenerFuncType)(Component, Port*, void*);
+typedef void (*ComponentListenerFunc)(Component com, Uint64 event, void* data, void* context);
+typedef struct {
+    Uint64                  events;         /*!<< See COMPONENT_EVENT_XXXX, It can be ORed with other events. */
+    ComponentListenerFunc   update;
+    void*                   context;
+} ComponentListener;
+#define MAX_NUM_LISTENERS                       32
+
+typedef struct ComponentImpl {
+    char*                name;
+    void*                context;
+    Port                 sinkPort;
+    Port                 srcPort;
+    Uint32               containerSize;
+    Uint32               numSinkPortQueue;
+    Component            (*Create)(struct ComponentImpl*, CNMComponentConfig*);
+    CNMComponentParamRet (*GetParameter)(struct ComponentImpl*, struct ComponentImpl*, GetParameterCMD, void*);
+    CNMComponentParamRet (*SetParameter)(struct ComponentImpl*, struct ComponentImpl*, SetParameterCMD, void*);
+    BOOL                 (*Prepare)(struct ComponentImpl*, BOOL*);
+    /* \brief   process input data and return output.
+     * \return  TRUE - process done
+     */
+    BOOL                 (*Execute)(struct ComponentImpl*, PortContainer*, PortContainer*);
+    /* \brief   release all memories that are allocated by vdi_dma_allocate_memory().
+     */
+    void                 (*Release)(struct ComponentImpl*);
+    BOOL                 (*Destroy)(struct ComponentImpl*);
+    BOOL                 success;
+    osal_thread_t        thread;
+    ComponentState       state;
+    BOOL                 terminate;
+    ComponentListener    listeners[MAX_NUM_LISTENERS];
+    Uint32               numListeners;
+    Queue*               usingQ;                /*<<! NOTE: DO NOT USE Enqueue() AND Dequeue() IN YOUR COMPONENT.
+                                                            BUT, YOU CAN USE Peek() FUNCTION.
+                                                 */
+    CNMComponentType     type;
+    Uint32               updateTime;
+    Uint32               Hz;                    /* Use clock signal ex) 30Hz, A component will receive 30 clock signals per second. */
+    void*                internalData;
+    BOOL                 pause;
+    BOOL                 portFlush;
+} ComponentImpl;
+
+Component ComponentCreate(const char* componentName, CNMComponentConfig* componentParam);
+BOOL      ComponentSetupTunnel(Component fromComponent, Component toComponent);
+ComponentState ComponentExecute(Component component);
+/* @return  0 - done
+ *          1 - running
+ *          2 - error
+ */
+Int32     ComponentWait(Component component);
+void      ComponentStop(Component component);
+void      ComponentRelease(Component component);
+BOOL      ComponentChangeState(Component component, Uint32 state);
+/* \brief   Release all resources of the component
+ * \param   ret     The output variable that has status of success or failure.
+ */
+BOOL      ComponentDestroy(Component component, BOOL* ret);
+CNMComponentParamRet ComponentGetParameter(Component from, Component to, GetParameterCMD commandType, void* data);
+CNMComponentParamRet ComponentSetParameter(Component from, Component to, SetParameterCMD commandType, void* data);
+void      ComponentNotifyListeners(Component component, Uint64 event, void* data);
+BOOL      ComponentRegisterListener(Component component, Uint64 events, ComponentListenerFunc func, void* context);
+/* \brief   Create a port
+ * \param   size        The size of PortStruct of the component
+ *          depth       The size of internal input queue and output queue.
+ */
+void      ComponentPortCreate(Port* port, Component owner, Uint32 depth, Uint32 size);
+/* \brief   Fill data into the output queue.
+ */
+void      ComponentPortSetData(Port* port, PortContainer* portData);
+/* \brief   Peek data from the input queue.
+ */
+PortContainer* ComponentPortPeekData(Port* port);
+/* \brief   Get data from the input queue.
+ */
+PortContainer* ComponentPortGetData(Port* port);
+/* \brief   Wait before get data from the input queue.
+ */
+void*     WaitBeforeComponentPortGetData(Port* port);
+/* \brief   Ready status: the output queue is empty.
+ */
+void      ComponentPortWaitReadyStatus(Port* port);
+/* \brief   Destroy port instance
+ */
+void      ComponentPortDestroy(Port* port);
+/* \brief   If a port has input data, it returns true.
+ */
+BOOL      ComponentPortHasInputData(Port* port);
+Uint32    ComponentPortGetSize(Port* port);
+/* \brief   Clear input data
+ */
+void      ComponentPortFlush(Component component);
+ComponentState ComponentGetState(Component component);
+BOOL      ComponentParamReturnTest(CNMComponentParamRet ret, BOOL* retry);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif // _COMPONENT_H_
+

+ 43 - 0
soft_3rdpart/wave511/code/sample_v2/component/component_list.h

@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#ifndef __COMPONENT_LIST_H__
+#define __COMPONENT_LIST_H__
+
+//Common components
+extern ComponentImpl feederComponentImpl;
+extern ComponentImpl rendererComponentImpl;
+
+extern ComponentImpl waveDecoderComponentImpl; 
+
+static ComponentImpl* componentList[] = {
+    &feederComponentImpl,
+    &rendererComponentImpl,
+    //WAVE series
+    &waveDecoderComponentImpl,
+    NULL
+};
+#endif
+

+ 113 - 0
soft_3rdpart/wave511/code/sample_v2/component/component_template.c

@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include "component.h"
+
+typedef struct {
+    Uint32  dummy;
+} ExampleContext;
+
+static CNMComponentParamRet GetParameterExample(ComponentImpl* from, ComponentImpl* my, GetParameterCMD commandType, void* data) 
+{
+    BOOL            result  = TRUE;
+    PortContainer* container;
+
+    switch(commandType) {
+    case GET_PARAM_COM_IS_CONTAINER_CONUSUMED:
+        container = (PortContainer*)data;
+        container->consumed = TRUE;
+        break;
+    default:
+        result = FALSE;
+        break;
+    }
+
+    if (result == TRUE) return CNM_COMPONENT_PARAM_SUCCESS;
+    else                return CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static CNMComponentParamRet SetParameterExample(ComponentImpl* from, ComponentImpl* my, SetParameterCMD commandType, void* data) 
+{
+    BOOL        result  = TRUE;
+
+    switch(commandType) {
+    default:
+        result = FALSE;
+        break;
+    }
+
+    if (result == TRUE) return CNM_COMPONENT_PARAM_SUCCESS;
+    else                return CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static BOOL PrepareExample(ComponentImpl* com, BOOL* done)
+{
+    *done = TRUE;
+    return TRUE;
+}
+
+static BOOL ExecuteExample(ComponentImpl* com, PortContainer* in, PortContainer* out) 
+{
+    return TRUE;
+}
+
+static BOOL DestroyExample(ComponentImpl* com) 
+{
+    ExampleContext* myParam = (ExampleContext*)com->context;
+
+    osal_free(myParam);
+
+    return TRUE;
+}
+
+static Component CreateExample(ComponentImpl* com, CNMComponentConfig* componentParam) 
+{
+    com->context = (ExampleContext*)osal_malloc(sizeof(ExampleContext));
+    osal_memset(com->context, 0, sizeof(ExampleContext));
+
+    return (Component)com;
+}
+
+static void ReleaseExample(ComponentImpl* com)
+{
+}
+
+ComponentImpl exampleComponentImpl = {
+    "example",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainer),
+    5,
+    CreateExample,
+    GetParameterExample,
+    SetParameterExample,
+    PrepareExample,
+    ExecuteExample,
+    ReleaseExample,
+    DestroyExample
+};
+

+ 1162 - 0
soft_3rdpart/wave511/code/sample_v2/component_decoder/coda9/component_coda9_dec_decoder.c

@@ -0,0 +1,1162 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include "component.h"
+#include "cnm_app.h"
+#include "misc/debug.h"
+#include "misc/bw_monitor.h"
+#include "sys/time.h"
+
+#define EXTRA_FRAME_BUFFER_NUM 1
+#define INDEX_FRAME_DIS_QUEUE_SIZE 255
+#define MAX_SIZE_HEADER_DATA 255
+
+typedef enum {
+    DEC_INT_STATUS_NONE,        // Interrupt not asserted yet
+    DEC_INT_STATUS_EMPTY,       // Need more es
+    DEC_INT_STATUS_DONE,        // Interrupt asserted
+    DEC_INT_STATUS_TIMEOUT,     // Interrupt not asserted during given time.
+    DEC_INT_STATUS_FIELD,       // One filed picture(top or bottom) was decoded(need a next field picture)
+} DEC_INT_STATUS;
+
+typedef enum {
+    DEC_STATE_NONE,
+    DEC_STATE_OPEN_DECODER,
+    DEC_STATE_INIT_SEQ,
+    DEC_STATE_REGISTER_FB,
+    DEC_STATE_DECODING,
+    DEC_STATE_CLOSE,
+} DecoderState;
+
+typedef struct {
+    BOOL    isHdrData;
+    Int32   hdrDataSize;
+    Uint8   hdrData[MAX_SIZE_HEADER_DATA];
+} HeaderData;
+
+typedef struct {
+    TestDecConfig               testDecConfig;
+    DecOpenParam                decOpenParam;
+    DecParam                    decParam;
+    FrameBufferFormat           wtlFormat;
+    DecHandle                   handle;
+    Uint64                      startTimeout;
+    vpu_buffer_t                vbUserData;
+    BOOL                        doFlush;
+    BOOL                        stateDoing;
+    DecoderState                state;
+    DecInitialInfo              initialInfo;
+    Uint32                      numDecoded;             /*!<< The number of decoded frames */
+    Uint32                      numOutput;
+    PhysicalAddress             decodedAddr;
+    Uint32                      frameNumToStop;
+    BOOL                        doReset;
+    Uint32                      cyclePerTick;
+    ParamDecPPUFrameBuffer      ppuFbParam;
+    Queue*                      idxFrameDisQ;
+    BOOL                        needMoreStream;
+    Int32                       linearFbCnt;
+    BOOL                        seqChangeReqest;
+    Int32                       seqChangedStreamEndFlag;
+    Int32                       seqChangedRdPtr;
+    Int32                       seqChangedWrPtr;
+    BOOL                        prevScaleX;
+    BOOL                        prevScaleY;
+    BOOL                        isTheoraHeader;
+    BOOL                        oneFiledDecoded;
+    BOOL                        chunkReuseRequired;
+    BOOL                        isDecodedFlag; // only used in pic_enc_mode
+    HeaderData                  hdrInfo;
+    ParamDecBitstreamBufPos     bsPos;
+} DecoderContext;
+
+void AppendPicHeaderData(DecoderContext* ctx, PortContainerES* streamData) {
+    PhysicalAddress rdPtr, wrPtr;
+    Uint32          room;
+    Uint8*          pStreamBuffer = NULL;
+    Int32           totalBufSize = 0;
+    Int32           coreIdx = ctx->testDecConfig.coreIdx;
+
+    //Append PPS data to bistreambuffer which will be decoded.
+    VPU_DecGetBitstreamBuffer(ctx->handle ,&rdPtr, &wrPtr, &room);
+
+    if (ctx->hdrInfo.hdrDataSize < room) {
+        totalBufSize = (wrPtr - rdPtr) + ctx->hdrInfo.hdrDataSize;
+        pStreamBuffer = (Uint8*)osal_malloc(totalBufSize+1);
+
+        if (NULL != pStreamBuffer) {
+            osal_memset(pStreamBuffer, 0x00, totalBufSize+1);
+            osal_memcpy(pStreamBuffer, ctx->hdrInfo.hdrData, ctx->hdrInfo.hdrDataSize);
+            vdi_read_memory(coreIdx, rdPtr, pStreamBuffer+ctx->hdrInfo.hdrDataSize, wrPtr - rdPtr,ctx->testDecConfig.streamEndian);
+            vdi_write_memory(coreIdx, rdPtr, pStreamBuffer, totalBufSize,  ctx->testDecConfig.streamEndian);
+
+            VPU_DecUpdateBitstreamBuffer(ctx->handle, ctx->hdrInfo.hdrDataSize);
+        }
+    }
+
+    if (NULL != pStreamBuffer) {
+        osal_free(pStreamBuffer);
+    }
+}
+
+BOOL CheckConsumedHeaderStream(DecoderContext* ctx)
+{
+    PhysicalAddress rdPtr =0, wrPtr =0;
+    Uint32          room =0;
+
+    if (NULL == ctx->handle) {
+        return FALSE;
+    }
+
+    VPU_DecGetBitstreamBuffer(ctx->handle, &rdPtr, &wrPtr, &room);
+
+    if (wrPtr != rdPtr) {
+        return FALSE;
+    }
+    return TRUE;
+}
+
+void AlignPictureSize(DecoderContext* ctx, CNMComListenerDecDone* lsnpPicDone)
+{
+    TestDecConfig*  decConfig = NULL;
+
+    if (NULL == ctx || NULL == lsnpPicDone) {
+        VLOG(INFO, "%s:%d NULL pointer exception\n", __FUNCTION__, __LINE__);
+        return;
+    }
+
+    decConfig = &(ctx->testDecConfig);
+
+    if (0 > lsnpPicDone->output->indexFrameDisplay) {
+        return;
+    }
+
+    switch (decConfig->compareType) {
+    default :
+        break;
+    }
+}
+
+static BOOL RegisterFrameBuffers(ComponentImpl* com)
+{
+    DecoderContext*         ctx               = (DecoderContext*)com->context;
+    FrameBuffer*            pFrame            = NULL;
+    Uint32                  framebufStride    = 0;
+    ParamDecFrameBuffer     paramFb;
+    RetCode                 result;
+    DecInitialInfo*         codecInfo         = &ctx->initialInfo;
+    BOOL                    success;
+    CNMComponentParamRet    ret;
+    CNMComListenerDecRegisterFb  lsnpRegisterFb;
+    MaverickCacheConfig     cacheCfg;
+
+    ctx->stateDoing = TRUE;
+
+    ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_RENDERER_FRAME_BUF, (void*)&paramFb);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) {
+        return success;
+    }
+
+    MaverickCache2Config(&cacheCfg, TRUE /*Decoder*/, ctx->testDecConfig.cbcrInterleave,
+                         ctx->testDecConfig.coda9.frameCacheBypass,
+                         ctx->testDecConfig.coda9.frameCacheBurst,
+                         ctx->testDecConfig.coda9.frameCacheMerge,
+                         ctx->testDecConfig.mapType,
+                         ctx->testDecConfig.coda9.frameCacheWayShape);
+    VPU_DecGiveCommand(ctx->handle, SET_CACHE_CONFIG, &cacheCfg);
+
+
+    pFrame               = paramFb.fb;
+    framebufStride       = paramFb.stride;
+
+    VLOG(INFO, "<%s> LINEAR: %d, Tiled: %d\n", __FUNCTION__, paramFb.linearNum, paramFb.nonLinearNum);
+    ctx->linearFbCnt = paramFb.linearNum;
+
+    result = VPU_DecRegisterFrameBuffer(ctx->handle, pFrame, paramFb.linearNum, framebufStride, codecInfo->picHeight, ctx->testDecConfig.mapType);
+
+    lsnpRegisterFb.handle          = ctx->handle;
+    lsnpRegisterFb.numLinearFb     = paramFb.linearNum;
+    lsnpRegisterFb.numNonLinearFb = paramFb.nonLinearNum;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_REGISTER_FB, (void*)&lsnpRegisterFb);
+
+    if (result != RETCODE_SUCCESS) {
+        VLOG(ERR, "%s:%d Failed to VPU_DecRegisterFrameBufferEx(%d)\n", __FUNCTION__, __LINE__, result);
+        return FALSE;
+    }
+
+    ctx->stateDoing = FALSE;
+
+    ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_RENDERER_PPU_FRAME_BUF, &(ctx->ppuFbParam));
+    if (ComponentParamReturnTest(ret, &success) == FALSE) {
+        return FALSE;
+    }
+
+    if(TRUE == ctx->ppuFbParam.enablePPU) {
+        if(NULL != ctx->ppuFbParam.fb) {
+            VPU_DecGiveCommand(ctx->handle, SET_ROTATOR_OUTPUT, ctx->ppuFbParam.fb);
+            if (ctx->testDecConfig.coda9.rotate > 0) {
+                VPU_DecGiveCommand(ctx->handle, ENABLE_ROTATION, NULL);
+            }
+            if (ctx->testDecConfig.coda9.mirror > 0) {
+                VPU_DecGiveCommand(ctx->handle, ENABLE_MIRRORING, NULL);
+            }
+            if (ctx->testDecConfig.coda9.enableDering == TRUE) {
+                VPU_DecGiveCommand(ctx->handle, ENABLE_DERING, NULL);
+            }
+        } else {
+            VLOG(ERR, "%s:%d NULL pointer Exception - ppuFb\n", __FUNCTION__, __LINE__);
+            return FALSE;
+        }
+    }
+
+    PrepareDecoderTest(ctx->handle);
+
+    return TRUE;
+}
+
+static BOOL PreSequenceChange(ComponentImpl* com, DecOutputInfo* outputInfo)
+{
+    DecoderContext* ctx               = (DecoderContext*)com->context;
+    RetCode         ret;
+
+    VLOG(INFO, "-----PRE SEQUENCE CHANGED -----\n");
+
+    ctx->seqChangedRdPtr = outputInfo->rdPtr;
+    ctx->seqChangedWrPtr = outputInfo->wrPtr;
+
+    VLOG(INFO, "seqChangeRdPtr: 0x%08x, WrPtr: 0x%08x\n", ctx->seqChangedRdPtr, ctx->seqChangedWrPtr);
+
+    if (RETCODE_SUCCESS != (ret=VPU_DecSetRdPtr(ctx->handle, ctx->seqChangedRdPtr, TRUE))) {
+        VLOG(ERR, "%s:%d Failed to VPU_DecSetRdPtr(%d), ret(%d)\n", __FUNCTION__, __LINE__, ctx->seqChangedRdPtr, ret);
+        return FALSE;
+    }
+    ctx->seqChangedStreamEndFlag = outputInfo->streamEndFlag; //BIT_BIT_STREAM_PARAM(0x114)
+    VPU_DecUpdateBitstreamBuffer(ctx->handle, 1); // let f/w to know stream end condition in bitstream buffer. force to know that bitstream buffer will be empty.
+    VPU_DecUpdateBitstreamBuffer(ctx->handle, STREAM_END_SET_FLAG); // set to stream end condition to pump out a delayed framebuffer.
+
+    return TRUE;
+}
+
+static BOOL SequenceChange(ComponentImpl* com, DecOutputInfo* outputInfo)
+{
+    DecoderContext* ctx               = (DecoderContext*)com->context;
+    DecInitialInfo  initialInfo;
+    ParamDecBitstreamBuffer bsBuf;
+    BOOL            resOf = TRUE;
+    Uint32          comState = COMPONENT_STATE_NONE;
+
+    VLOG(INFO, "----- SEQUENCE CHANGED -----\n");
+    // Get current(changed) sequence information.
+    VPU_DecGiveCommand(ctx->handle, DEC_GET_SEQ_INFO, &initialInfo);
+    // Flush all remaining framebuffers of previous sequence.
+
+    VLOG(INFO, "sequenceChanged : %x\n", outputInfo->sequenceChanged);
+    VLOG(INFO, "SEQUENCE NO     : %d\n", initialInfo.sequenceNo);
+    VLOG(INFO, "DPB COUNT       : %d\n", initialInfo.minFrameBufferCount);
+    VLOG(INFO, "BITDEPTH        : LUMA(%d), CHROMA(%d)\n", initialInfo.lumaBitdepth, initialInfo.chromaBitdepth);
+    VLOG(INFO, "SIZE            : WIDTH(%d), HEIGHT(%d)\n", initialInfo.picWidth, initialInfo.picHeight);
+
+    ComponentSetParameter(com, com->sinkPort.connectedComponent, SET_PARAM_RENDERER_FREE_FRAMEBUFFERS, (void*)&outputInfo->frameDisplayFlag);
+
+    VPU_DecGiveCommand(ctx->handle, DEC_RESET_FRAMEBUF_INFO, NULL);
+
+    VPU_DecSetRdPtr(ctx->handle, ctx->seqChangedRdPtr, TRUE);
+
+    if (ctx->seqChangedStreamEndFlag == 1) { // No more bitstream in the buffer.
+        VPU_DecUpdateBitstreamBuffer(ctx->handle, STREAM_END_SET_FLAG);
+    }
+    else {
+        VPU_DecUpdateBitstreamBuffer(ctx->handle, STREAM_END_CLEAR_FLAG);
+    }
+    if (ctx->seqChangedWrPtr >= ctx->seqChangedRdPtr) {
+        resOf = (RETCODE_SUCCESS == VPU_DecUpdateBitstreamBuffer(ctx->handle, ctx->seqChangedWrPtr - ctx->seqChangedRdPtr));
+    }
+    else {
+        ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_FEEDER_BITSTREAM_BUF, &bsBuf);
+        resOf = (RETCODE_SUCCESS == VPU_DecUpdateBitstreamBuffer(ctx->handle, (bsBuf.bs->phys_addr + bsBuf.bs->size) - ctx->seqChangedRdPtr +
+            (ctx->seqChangedWrPtr - bsBuf.bs->phys_addr)));
+    }
+
+    //ctx->state = DEC_STATE_REGISTER_FB;
+    ctx->state = DEC_STATE_INIT_SEQ;
+    osal_memcpy((void*)&ctx->initialInfo, (void*)&initialInfo, sizeof(DecInitialInfo));
+
+    comState = COMPONENT_STATE_CREATED;
+    ComponentSetParameter(com, com->sinkPort.connectedComponent, SET_PARAM_RENDERER_CHANGE_COM_STATE, (void*)&comState);
+
+    VLOG(INFO, "----------------------------\n");
+
+    return resOf;
+}
+
+static BOOL CheckAndDoSequenceChange(ComponentImpl* com, DecOutputInfo* outputInfo)
+{
+    DecoderContext* ctx = (DecoderContext*)com->context;
+    BOOL resOf = TRUE;
+
+    if (0 != outputInfo->sequenceChanged) {
+        ctx->seqChangeReqest = TRUE;
+        resOf = PreSequenceChange(com, outputInfo);
+    }
+
+    if (TRUE == ctx->seqChangeReqest && DISPLAY_IDX_FLAG_SEQ_END == outputInfo->indexFrameDisplay) {
+        resOf = SequenceChange(com, outputInfo);
+    }
+
+    return resOf;
+}
+
+static DEC_INT_STATUS HandlingInterruptFlagNoCQ(ComponentImpl* com, InterruptBit waitInterrptFlag)
+{
+    DecoderContext*      ctx               = (DecoderContext*)com->context;
+    DecHandle            handle            = ctx->handle;
+    Int32                interruptFlag     = 0;
+    Uint32               interruptWaitTime = VPU_WAIT_TIME_OUT;
+    Uint32               interruptTimeout  = VPU_DEC_TIMEOUT;
+    DEC_INT_STATUS       status            = DEC_INT_STATUS_NONE;
+    CNMComListenerDecInt lsn;
+    BOOL                 repeat            = TRUE;
+
+    ctx->startTimeout = osal_gettime();
+
+    do {
+        interruptFlag = VPU_WaitInterruptEx(handle, interruptWaitTime);
+        if (INTERRUPT_TIMEOUT_VALUE == interruptFlag) {
+            Uint64   currentTimeout = osal_gettime();
+            if ((currentTimeout - ctx->startTimeout) > interruptTimeout) {
+                VLOG(ERR, "\n INSNTANCE #%d INTERRUPT TIMEOUT.\n", handle->instIndex);
+                status = DEC_INT_STATUS_TIMEOUT;
+                break;
+            }
+            interruptFlag = 0;
+        }
+
+        if (interruptFlag < 0) {
+            VLOG(ERR, "<%s:%d> interruptFlag is negative value! %08x\n", __FUNCTION__, __LINE__, interruptFlag);
+            status = DEC_INT_STATUS_NONE;
+        }
+
+        if (interruptFlag & (1 << INT_BIT_DEC_FIELD)) {
+            if (BS_MODE_PIC_END == ctx->testDecConfig.bitstreamMode) {
+                status = DEC_INT_STATUS_FIELD;
+                break;
+            }
+        }
+
+        if (interruptFlag) {
+            VPU_ClearInterruptEx(handle, interruptFlag);
+        }
+
+        if (interruptFlag & (1 << waitInterrptFlag)) {
+            status = DEC_INT_STATUS_DONE;
+            repeat = FALSE;
+        }
+
+        if (interruptFlag & (1 << INT_BIT_BIT_BUF_EMPTY)) {
+            status = DEC_INT_STATUS_EMPTY;
+            break;
+        }
+
+    } while (repeat);
+
+    lsn.handle = handle;
+    lsn.flag   = interruptFlag;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_INTERRUPT, (void*)&lsn);
+
+    return status;
+}
+
+static BOOL DoReset(ComponentImpl* com)
+{
+    DecoderContext* ctx    = (DecoderContext*)com->context;
+    BitStreamMode   bsMode = ctx->decOpenParam.bitstreamMode;
+    DecHandle       handle = ctx->handle;
+    Uint32          timeoutCount;
+
+    VLOG(INFO, "========== %s ==========\n", __FUNCTION__);
+
+    VLOG(INFO, "> FLUSH RENDERER\n");
+    /* Send the renderer the signal to drop all frames. */
+    ComponentSetParameter(com, com->sinkPort.connectedComponent, SET_PARAM_RENDERER_FLUSH, NULL);
+
+    VLOG(INFO, "> EXPLICIT_END_SET_FLAG\n");
+    // In order to stop processing bitstream.
+    VPU_DecUpdateBitstreamBuffer(handle, EXPLICIT_END_SET_FLAG);
+
+    // Clear DPB
+    timeoutCount = 0;
+    VLOG(INFO, "> Flush VPU internal buffer\n");
+    while (VPU_DecFrameBufferFlush(handle, NULL, NULL) == RETCODE_VPU_STILL_RUNNING) {
+        if (timeoutCount >= VPU_DEC_TIMEOUT) {
+            VLOG(ERR, "NO RESPONSE FROM VPU_DecFrameBufferFlush()\n");
+            return FALSE;
+        }
+        timeoutCount++;
+    }
+
+    VLOG(INFO, "> Reset VPU\n");
+    if (VPU_SWReset(handle->coreIdx, SW_RESET_SAFETY, handle) != RETCODE_SUCCESS) {
+        VLOG(ERR, "<%s:%d> Failed to VPU_SWReset()\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    // Clear CPB
+    if (bsMode == BS_MODE_INTERRUPT) {
+        PhysicalAddress curWrPtr;
+        VLOG(INFO, "> Clear CPB\n");
+        VPU_DecGetBitstreamBuffer(handle, NULL, &curWrPtr, NULL);
+        VPU_DecSetRdPtr(handle, curWrPtr, TRUE);
+    }
+
+    VLOG(INFO, "> STREAM_END_CLEAR_FLAG\n");
+    // Clear stream-end flag
+    VPU_DecUpdateBitstreamBuffer(handle, STREAM_END_CLEAR_FLAG);
+
+    VLOG(INFO, "========== %s ==========\n", __FUNCTION__);
+
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_RESET_DONE, NULL);
+
+    ctx->doReset      = FALSE;
+    ctx->startTimeout = 0ULL;
+    return TRUE;
+}
+
+static BOOL Decode(ComponentImpl* com, PortContainerES* in, PortContainerDisplay* out)
+{
+    DecoderContext*                 ctx           = (DecoderContext*)com->context;
+    DecOutputInfo                   decOutputInfo;
+    DEC_INT_STATUS                  intStatus = DEC_INT_STATUS_NONE;
+    CNMComListenerStartDecOneFrame  lsnpPicStart;
+    BitStreamMode                   bsMode        = ctx->decOpenParam.bitstreamMode;
+    RetCode                         result;
+    CNMComListenerDecDone           lsnpPicDone;
+    CNMComListenerDecReadyOneFrame  lsnpReadyOneFrame = {0,};
+    BOOL                            doDecode;
+
+    lsnpReadyOneFrame.handle = ctx->handle;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_READY_ONE_FRAME, (void*)&lsnpReadyOneFrame);
+
+    ctx->stateDoing = TRUE;
+
+    /* decode a frame except when the bitstream mode is PIC_END and no data */
+    doDecode  = !(bsMode == BS_MODE_PIC_END && in == NULL);
+    if (FALSE == doDecode) {
+        return TRUE;
+    }
+
+    if (TRUE == com->pause) {
+        return TRUE;
+    }
+
+    if (BS_MODE_PIC_END == bsMode) {
+        if (TRUE == ctx->hdrInfo.isHdrData) {
+            ctx->hdrInfo.isHdrData = FALSE;
+            AppendPicHeaderData(ctx, in);
+        }
+    }
+
+    if (ctx->needMoreStream == FALSE) {
+        /* Empty interrupt wasn't asserted */
+
+        result = VPU_DecStartOneFrame(ctx->handle, &ctx->decParam);
+
+        lsnpPicStart.handle   = ctx->handle;
+        lsnpPicStart.result   = result;
+        lsnpPicStart.decParam = ctx->decParam;
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_START_ONE_FRAME, (void*)&lsnpPicStart);
+
+        if (result != RETCODE_SUCCESS) {
+            return FALSE;
+        }
+    }
+
+    if (TRUE == ctx->oneFiledDecoded && BS_MODE_PIC_END == ctx->testDecConfig.bitstreamMode) {
+        VPU_ClearInterrupt(ctx->testDecConfig.coreIdx);
+        ctx->oneFiledDecoded = FALSE;
+    }
+
+    ctx->needMoreStream = FALSE;
+
+    intStatus = HandlingInterruptFlagNoCQ(com, INT_BIT_PIC_RUN);
+    if ((DEC_INT_STATUS_TIMEOUT == intStatus)) {
+        HandleDecoderError(ctx->handle, ctx->numDecoded, NULL);
+        PrintDecVpuStatus(ctx->handle);
+        DoReset(com);
+        return FALSE;
+    }
+    else if (DEC_INT_STATUS_EMPTY == intStatus) {
+        ctx->needMoreStream = TRUE;
+        return TRUE;
+    }
+    else if (DEC_INT_STATUS_FIELD == intStatus) {
+        ctx->needMoreStream = TRUE;
+        ctx->oneFiledDecoded = TRUE;
+        if(out) out->reuse = TRUE;
+        return TRUE;
+    }
+
+    //default value - chunkReuseRequired
+    ctx->chunkReuseRequired = FALSE;
+    ctx->isDecodedFlag = FALSE;
+
+    // Get data from the sink component.
+    if ((result=VPU_DecGetOutputInfo(ctx->handle, &decOutputInfo)) == RETCODE_SUCCESS) {
+        DisplayDecodedInformation(ctx->handle, ctx->decOpenParam.bitstreamFormat, ctx->numDecoded, &decOutputInfo, ctx->testDecConfig.performance, ctx->cyclePerTick);
+    }
+
+
+    if (TRUE == ctx->ppuFbParam.enablePPU) {
+        if (decOutputInfo.indexFrameDisplay >= 0) {
+            Queue_Enqueue(ctx->idxFrameDisQ, &(decOutputInfo.indexFrameDisplay));
+            if(1 == ctx->idxFrameDisQ->count) {
+                if (TRUE == decOutputInfo.chunkReuseRequired) {
+                    ctx->chunkReuseRequired = TRUE;
+                    if (0 <= decOutputInfo.indexFrameDecoded) ctx->isDecodedFlag = TRUE;
+                    if (in) in->reuse = TRUE;
+                }
+                return TRUE;
+            }
+        }
+    }
+
+
+    lsnpPicDone.handle     = ctx->handle;
+    lsnpPicDone.ret        = result;
+    lsnpPicDone.decParam   = &ctx->decParam;
+    lsnpPicDone.output     = &decOutputInfo;
+    lsnpPicDone.numDecoded = ctx->numDecoded;
+    lsnpPicDone.vbUser     = ctx->vbUserData;
+
+    AlignPictureSize(ctx, &lsnpPicDone);
+
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_GET_OUTPUT_INFO, (void*)&lsnpPicDone);
+
+    if (result == RETCODE_REPORT_NOT_READY) {
+        return TRUE; // Not decoded yet. Try again
+    }
+    else if (result != RETCODE_SUCCESS) {
+        /* ERROR */
+        VLOG(ERR, "Failed to decode error : %d \n", result);
+        return FALSE;
+    }
+
+    if ((decOutputInfo.decodingSuccess & 0x01) == 0) {
+        VLOG(ERR, "VPU_DecGetOutputInfo decode fail framdIdx %d error(0x%08x) reason(0x%08x), reasonExt(0x%08x)\n",
+            ctx->numDecoded, decOutputInfo.decodingSuccess, decOutputInfo.errorReason, decOutputInfo.errorReasonExt);
+        return FALSE;
+    }
+
+    if (FALSE == CheckAndDoSequenceChange(com, &decOutputInfo)) {
+        return FALSE;
+    }
+    else {
+        if (TRUE == ctx->seqChangeReqest && DISPLAY_IDX_FLAG_SEQ_END == decOutputInfo.indexFrameDisplay) {
+            ctx->seqChangeReqest = FALSE;
+            ctx->stateDoing = FALSE; //Go back to DecodeHeader()
+            return TRUE;
+        }
+    }
+
+    if (decOutputInfo.indexFrameDecoded >= 0) {
+        // Return a used data to a source port.
+        ctx->numDecoded++;
+        out->reuse = FALSE;
+    }
+
+    if ((decOutputInfo.indexFrameDisplay >= 0) || (decOutputInfo.indexFrameDisplay == DISPLAY_IDX_FLAG_SEQ_END)) {
+        ctx->numOutput++;
+        out->last  = (BOOL)(decOutputInfo.indexFrameDisplay == DISPLAY_IDX_FLAG_SEQ_END);
+        out->reuse = FALSE;
+    }
+    if (decOutputInfo.indexFrameDisplay == DISPLAY_IDX_FLAG_SEQ_END) {
+        ctx->stateDoing = FALSE;
+        com->terminate  = TRUE;
+    }
+
+    if (BS_MODE_PIC_END == ctx->testDecConfig.bitstreamMode) {
+        if (DECODED_IDX_FLAG_NO_FB == decOutputInfo.indexFrameDecoded) {
+            //reuse a chunk of bitstream
+            if (in) in->reuse = TRUE;
+        }
+    }
+
+    if (TRUE == decOutputInfo.chunkReuseRequired) {
+        //reuse a chunk of bitstream
+        if (in) in->reuse = TRUE;
+        ctx->chunkReuseRequired = TRUE;
+        if (0 <= decOutputInfo.indexFrameDecoded) {
+            ctx->isDecodedFlag = TRUE;
+        }
+    }
+
+    if (out->reuse == FALSE) {
+        osal_memcpy((void*)&out->decInfo, (void*)&decOutputInfo, sizeof(DecOutputInfo));
+        if (ctx->ppuFbParam.enablePPU && 1 < ctx->idxFrameDisQ->count) {
+            if (NULL != Queue_Peek(ctx->idxFrameDisQ)) {
+                out->decInfo.indexFrameDisplay = *((Int32*)Queue_Dequeue(ctx->idxFrameDisQ));
+            }
+        }
+    }
+    else { // TRUE == out->reuse
+        if (ctx->ppuFbParam.enablePPU && 1 < ctx->idxFrameDisQ->count) {
+            if (NULL != Queue_Peek(ctx->idxFrameDisQ) && DECODED_IDX_FLAG_NO_FB == decOutputInfo.indexFrameDecoded) {
+                out->decInfo.indexFrameDisplay = *((Int32*)Queue_Dequeue(ctx->idxFrameDisQ));
+                VPU_DecClrDispFlag(ctx->handle, out->decInfo.indexFrameDisplay);
+            }
+        }
+    }
+
+    if (ctx->frameNumToStop > 0) {
+        if (ctx->frameNumToStop == ctx->numOutput) {
+            com->terminate = TRUE;
+        }
+    }
+
+    return TRUE;
+}
+
+static CNMComponentParamRet GetParameterDecoder(ComponentImpl* from, ComponentImpl* com, GetParameterCMD commandType, void* data)
+{
+    DecoderContext*             ctx     = (DecoderContext*)com->context;
+    BOOL                        result  = TRUE;
+    ParamDecNeedFrameBufferNum* fbNum;
+    ParamVpuStatus*             status;
+    QueueStatusInfo             cqInfo;
+    PortContainerES*            container;
+    vpu_buffer_t                vb;
+    Int32                       productID = -1;
+
+    if (NULL == ctx) {
+        VLOG(ERR, "%s:%d NULL Pointer Exception\n", __FUNCTION__, __LINE__);
+        return CNM_COMPONENT_PARAM_FAILURE;
+    }
+
+    productID = ctx->testDecConfig.productId;
+
+    if (ctx->handle == NULL)  return CNM_COMPONENT_PARAM_NOT_READY;
+    if (ctx->doReset == TRUE) return CNM_COMPONENT_PARAM_NOT_READY;
+
+    switch(commandType) {
+    case GET_PARAM_COM_IS_CONTAINER_CONUSUMED:
+        // This query command is sent from the comonponent core.
+        // If input data are consumed in sequence, it should return TRUE through PortContainer::consumed.
+        container = (PortContainerES*)data;
+        vb = container->buf;
+        if (vb.phys_addr <= ctx->decodedAddr && ctx->decodedAddr < (vb.phys_addr+vb.size)) {
+            container->consumed = TRUE;
+            ctx->decodedAddr = 0;
+        }
+        break;
+    case GET_PARAM_DEC_HANDLE:
+        *(DecHandle*)data = ctx->handle;
+        break;
+    case GET_PARAM_DEC_FRAME_BUF_NUM:
+        if (ctx->state <= DEC_STATE_INIT_SEQ) return CNM_COMPONENT_PARAM_NOT_READY;
+        fbNum = (ParamDecNeedFrameBufferNum*)data;
+        if (PRODUCT_ID_960 == productID || PRODUCT_ID_980 == productID) {
+            //linear Buffer
+            fbNum->linearNum = ctx->initialInfo.minFrameBufferCount + EXTRA_FRAME_BUFFER_NUM;   // max_dec_pic_buffering
+            if(ctx->testDecConfig.enableWTL) {
+                //num of tiled buffers are same with num of linear buffers
+                //CODA series do not use compressed buffers,
+                //In this case, compressNum means number of tiled buffers
+                fbNum->nonLinearNum = fbNum->linearNum;
+            }
+            else {
+                fbNum->nonLinearNum =0;
+            }
+        }
+        break;
+    case GET_PARAM_DEC_BITSTREAM_BUF_POS:
+        if (0 == ctx->bsPos.rdPtr && 0 == ctx->bsPos.wrPtr) return CNM_COMPONENT_PARAM_NOT_READY;
+        *(ParamDecBitstreamBufPos*)data = ctx->bsPos;
+        break;
+    case GET_PARAM_DEC_CODEC_INFO:
+        if (ctx->state <= DEC_STATE_INIT_SEQ) return CNM_COMPONENT_PARAM_NOT_READY;
+        VPU_DecGiveCommand(ctx->handle, DEC_GET_SEQ_INFO, data);
+        break;
+    case GET_PARAM_VPU_STATUS:
+        if (ctx->state != DEC_STATE_DECODING) return CNM_COMPONENT_PARAM_NOT_READY;
+        VPU_DecGiveCommand(ctx->handle, DEC_GET_QUEUE_STATUS, &cqInfo);
+        status = (ParamVpuStatus*)data;
+        status->cq = cqInfo;
+        break;
+    default:
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static CNMComponentParamRet SetParameterDecoder(ComponentImpl* from, ComponentImpl* com, SetParameterCMD commandType, void* data)
+{
+    BOOL            result = TRUE;
+    DecoderContext* ctx    = (DecoderContext*)com->context;
+    Int32           skipCmd;
+
+    switch(commandType) {
+    case SET_PARAM_COM_PAUSE:
+        com->pause   = *(BOOL*)data;
+        break;
+    case SET_PARAM_DEC_SKIP_COMMAND:
+        skipCmd = *(Int32*)data;
+        ctx->decParam.skipframeMode = skipCmd;
+        if (skipCmd == WAVE_SKIPMODE_NON_IRAP) {
+            Uint32 userDataMask = (1<<H265_USERDATA_FLAG_RECOVERY_POINT);
+            ctx->decParam.craAsBlaFlag = TRUE;
+            /* For finding recovery point */
+            VPU_DecGiveCommand(ctx->handle, ENABLE_REP_USERDATA, &userDataMask);
+        }
+        else {
+            ctx->decParam.craAsBlaFlag = FALSE;
+        }
+        if (ctx->numDecoded > 0) {
+            ctx->doFlush = (BOOL)(ctx->decParam.skipframeMode == WAVE_SKIPMODE_NON_IRAP);
+        }
+        break;
+    case SET_PARAM_DEC_RESET:
+        ctx->doReset = TRUE;
+        break;
+    default:
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static BOOL UpdateBitstream(DecoderContext* ctx, PortContainerES* in)
+{
+    RetCode         ret    = RETCODE_SUCCESS;
+    BitStreamMode   bsMode = ctx->decOpenParam.bitstreamMode;
+    BOOL            update = TRUE;
+    Uint32          updateSize;
+    PhysicalAddress rdPtr, wrPtr;
+    Uint32          room;
+
+    if (NULL == in) return TRUE;
+
+    if (BS_MODE_PIC_END == bsMode) {
+        if (TRUE == ctx->isTheoraHeader) {
+            //Theora decoder need to parse bitstream before decoding
+            ctx->isTheoraHeader = FALSE;
+            in->reuse = FALSE;
+            return TRUE;
+        }
+
+        if (FALSE == ctx->chunkReuseRequired) {
+            VPU_DecSetRdPtr(ctx->handle, in->buf.phys_addr, TRUE);
+        }
+        else if (TRUE == ctx->chunkReuseRequired && FALSE == ctx->isDecodedFlag) {
+            VPU_DecSetRdPtr(ctx->handle, in->buf.phys_addr, TRUE);
+        }
+    }
+    else {
+        if (in->size > 0) {
+            VPU_DecGetBitstreamBuffer(ctx->handle, &rdPtr, &wrPtr, &room);
+            if (room < in->size) {
+                in->reuse = TRUE;
+                return TRUE;
+            }
+        }
+    }
+
+    if (TRUE == in->last) {
+        updateSize = (in->size == 0) ? STREAM_END_SET_FLAG : in->size;
+    }
+    else {
+        updateSize = in->size;
+        update     = (in->size > 0 && in->last == FALSE);
+    }
+
+    if (TRUE == update && FALSE == ctx->seqChangeReqest) {
+        if ((ret=VPU_DecUpdateBitstreamBuffer(ctx->handle, updateSize)) != RETCODE_SUCCESS) {
+            VLOG(INFO, "<%s:%d> Failed to VPU_DecUpdateBitstreamBuffer() ret(%d)\n", __FUNCTION__, __LINE__, ret);
+            return FALSE;
+        }
+        if (TRUE == in->last) {
+            VPU_DecUpdateBitstreamBuffer(ctx->handle, STREAM_END_SET_FLAG);
+        }
+    }
+
+    in->reuse = FALSE;
+
+    return TRUE;
+}
+
+static BOOL OpenDecoder(ComponentImpl* com)
+{
+    DecoderContext*         ctx     = (DecoderContext*)com->context;
+    ParamDecBitstreamBuffer bsBuf;
+    CNMComponentParamRet    ret;
+    CNMComListenerDecOpen   lspn    = {0};
+    BOOL                    success = FALSE;
+    RetCode                 retCode;
+    VpuReportConfig_t       decReportCfg;
+
+    ctx->stateDoing = TRUE;
+    ret = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_FEEDER_BITSTREAM_BUF, &bsBuf);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) {
+        return success;
+    }
+
+    ctx->decOpenParam.bitstreamBuffer     = bsBuf.bs->phys_addr;
+    ctx->decOpenParam.bitstreamBufferSize = bsBuf.bs->size * bsBuf.num;
+
+    retCode = VPU_DecOpen(&ctx->handle, &ctx->decOpenParam);
+
+    lspn.handle = ctx->handle;
+    lspn.ret    = retCode;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_OPEN, (void*)&lspn);
+
+    if (retCode != RETCODE_SUCCESS) {
+        VLOG(ERR, "<%s:%d> Failed to VPU_DecOpen(ret:%d)\n", __FUNCTION__, __LINE__, retCode);
+        HandleDecoderError(NULL, 0, NULL);
+        return FALSE;
+    }
+
+    //Enable Register logs
+    //VPU_DecGiveCommand(ctx->handle, ENABLE_LOGGING, 0);
+
+    osal_memset((void*)&decReportCfg, 0x00, sizeof(VpuReportConfig_t));
+    decReportCfg.userDataEnable     = ctx->testDecConfig.enableUserData;
+    decReportCfg.userDataReportMode = 1;
+    OpenDecReport(ctx->testDecConfig.coreIdx, &decReportCfg);
+    ConfigDecReport(ctx->testDecConfig.coreIdx, ctx->handle, ctx->testDecConfig.bitFormat);
+
+    if (ctx->testDecConfig.thumbnailMode == TRUE) {
+        VPU_DecGiveCommand(ctx->handle, ENABLE_DEC_THUMBNAIL_MODE, NULL);
+    }
+
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL DecodeHeader(ComponentImpl* com, PortContainerES* in, PortContainerDisplay* out)
+{
+    DecoderContext*                 ctx     = (DecoderContext*)com->context;
+    DecHandle                       handle  = ctx->handle;
+    Uint32                          coreIdx = ctx->testDecConfig.coreIdx;
+    RetCode                         ret     = RETCODE_SUCCESS;
+    DEC_INT_STATUS                  status;
+    DecInitialInfo*                 initialInfo = &ctx->initialInfo;
+    SecAxiUse                       secAxiUse;
+    CNMComListenerDecCompleteSeq    lsnpCompleteSeq;
+    CodStd                          bitFormat = ctx->testDecConfig.bitFormat;
+    PhysicalAddress                 rdPtr, wrPtr;
+    Uint32                          room;
+
+    if (FALSE == ctx->stateDoing) {
+        ret = VPU_DecIssueSeqInit(handle);
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_ISSUE_SEQ, NULL);
+        if (ret != RETCODE_SUCCESS) {
+            VLOG(ERR, "%s:%d Failed to VPU_DecIssueSeqInit() ret(%d)\n", __FUNCTION__, __LINE__, ret);
+            return FALSE;
+        }
+    }
+
+    ctx->stateDoing = TRUE;
+
+    if (FALSE == com->terminate) {
+        status=HandlingInterruptFlagNoCQ(com, INT_BIT_SEQ_INIT);
+        if (status == DEC_INT_STATUS_TIMEOUT) {
+            VPU_DecUpdateBitstreamBuffer(handle, STREAM_END_SIZE);
+            VPU_SWReset(coreIdx, SW_RESET_FORCE, handle);
+            VPU_DecUpdateBitstreamBuffer(handle, STREAM_END_CLEAR_FLAG);    // To finish bitstream empty status
+            return FALSE;
+        }
+        else if (status == DEC_INT_STATUS_DONE) {
+            VLOG(INFO, "[INT] INT_BIT_SEQ_INIT \n");
+        }
+        else if (status == DEC_INT_STATUS_NONE) {
+            //just re-try
+            return TRUE;
+        }
+        else if (status == DEC_INT_STATUS_EMPTY) {
+            //it occurs only when the total picture size is smaller than chunk size.
+            return TRUE;
+        }
+        else {
+            VLOG(INFO, "%s:%d Unknown interrupt status: %d\n", __FUNCTION__, __LINE__, status);
+            return FALSE;
+        }
+    }
+
+    ret = VPU_DecCompleteSeqInit(handle, initialInfo);
+
+    strcpy(lsnpCompleteSeq.refYuvPath, ctx->testDecConfig.refYuvPath);
+    lsnpCompleteSeq.ret             = ret;
+    lsnpCompleteSeq.initialInfo     = initialInfo;
+    lsnpCompleteSeq.wtlFormat       = ctx->wtlFormat;
+    lsnpCompleteSeq.cbcrInterleave  = ctx->decOpenParam.cbcrInterleave;
+    lsnpCompleteSeq.bitstreamFormat = ctx->decOpenParam.bitstreamFormat;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_COMPLETE_SEQ, (void*)&lsnpCompleteSeq);
+
+    if (ret != RETCODE_SUCCESS) {
+        VLOG(ERR, "%s:%d FAILED TO DEC_PIC_HDR: ret(%d), SEQERR(%08x)\n", __FUNCTION__, __LINE__, ret, initialInfo->seqInitErrReason);
+        return FALSE;
+    }
+
+    if (BS_MODE_PIC_END == ctx->testDecConfig.bitstreamMode) {
+        // first picture includes a coded frame in sequence header of Theora, ffmpeg
+        if (STD_THO != bitFormat && STD_H263 != bitFormat && STD_RV != bitFormat && STD_VP8 !=bitFormat) {
+            //Parsing of Header has been done.
+            if (FALSE == CheckConsumedHeaderStream(ctx)) {
+                ctx->hdrInfo.isHdrData = TRUE;
+                osal_memset(ctx->hdrInfo.hdrData, 0x00, MAX_SIZE_HEADER_DATA);
+                VPU_DecGetBitstreamBuffer(ctx->handle ,&rdPtr, &wrPtr, &room);
+                ctx->hdrInfo.hdrDataSize = wrPtr - rdPtr;
+                if (MAX_SIZE_HEADER_DATA < ctx->hdrInfo.hdrDataSize) {
+                    ctx->hdrInfo.hdrDataSize = 0;
+                    ctx->hdrInfo.isHdrData = FALSE;
+                } else {
+                    vdi_read_memory(ctx->testDecConfig.coreIdx, rdPtr,  ctx->hdrInfo.hdrData, wrPtr - rdPtr,ctx->testDecConfig.streamEndian);
+                    if (in) {
+                        in->reuse = FALSE;
+                        in->consumed = TRUE;
+                    }
+                }
+            } else {
+                if (in) {
+                    in->reuse = FALSE;
+                    in->consumed = TRUE;
+                }
+            }
+
+        }
+    }
+
+    if (STD_THO == bitFormat) {
+        // first picture includes a coded frame in sequence header of Theora, ffmpeg
+        ctx->isTheoraHeader = TRUE;
+    }
+
+    if (ctx->decOpenParam.wtlEnable == TRUE) {
+        VPU_DecGiveCommand(ctx->handle, DEC_SET_WTL_FRAME_FORMAT, &ctx->wtlFormat);
+    }
+
+   /* Setting up the secondary AXI is depending on H/W configuration.
+    * Note that turn off all the secondary AXI configuration
+    * if target ASIC has no memory only for IP, LF and BIT.
+    */
+
+    osal_memset(&secAxiUse,     0x00, sizeof(SecAxiUse));
+    secAxiUse.u.coda9.useBitEnable  = (ctx->testDecConfig.secondaryAXI>>0) & 0x01;
+    secAxiUse.u.coda9.useIpEnable   = (ctx->testDecConfig.secondaryAXI>>1) & 0x01;
+    secAxiUse.u.coda9.useDbkYEnable = (ctx->testDecConfig.secondaryAXI>>2) & 0x01;
+    secAxiUse.u.coda9.useDbkCEnable = (ctx->testDecConfig.secondaryAXI>>3) & 0x01;
+    secAxiUse.u.coda9.useOvlEnable  = (ctx->testDecConfig.secondaryAXI>>4) & 0x01;
+    secAxiUse.u.coda9.useBtpEnable  = (ctx->testDecConfig.secondaryAXI>>5) & 0x01;
+
+    VPU_DecGiveCommand(ctx->handle, SET_SEC_AXI, &secAxiUse);
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL ExecuteDecoder(ComponentImpl* com, PortContainer* in, PortContainer* out)
+{
+    DecoderContext* ctx    = (DecoderContext*)com->context;
+    BOOL            ret    = FALSE;
+    BitStreamMode   bsMode = ctx->decOpenParam.bitstreamMode;
+
+    if (ctx->doReset == TRUE) {
+        if (DoReset(com) == FALSE) return FALSE;
+    }
+
+    if (ctx->state == DEC_STATE_INIT_SEQ || ctx->state == DEC_STATE_DECODING) {
+        if (UpdateBitstream(ctx, (PortContainerES*)in) == FALSE) {
+            return FALSE;
+        }
+        if (in) {
+            // In ring-buffer mode, it has to return back a container immediately.
+            if (bsMode == BS_MODE_PIC_END) {
+                if (ctx->state == DEC_STATE_INIT_SEQ) {
+                    in->reuse = TRUE;
+                }
+                in->consumed = (in->reuse == FALSE);
+            }
+            else {
+                in->consumed = (in->reuse == FALSE);
+            }
+        } else { // NULL == in
+            if (BS_MODE_PIC_END == bsMode) {
+                if (DEC_STATE_INIT_SEQ == ctx->state || DEC_STATE_DECODING == ctx->state) {
+                    return TRUE;
+                }
+            }
+            else {
+                if (DEC_STATE_INIT_SEQ == ctx->state) {
+                    return TRUE;
+                }
+            }
+        }
+    }
+
+    switch (ctx->state) {
+    case DEC_STATE_OPEN_DECODER:
+        ret = OpenDecoder(com);
+        if (ctx->stateDoing == FALSE) ctx->state = DEC_STATE_INIT_SEQ;
+        break;
+    case DEC_STATE_INIT_SEQ:
+        ret = DecodeHeader(com, (PortContainerES*)in, (PortContainerDisplay*)out);
+        if (ctx->stateDoing == FALSE) ctx->state = DEC_STATE_REGISTER_FB;
+        break;
+    case DEC_STATE_REGISTER_FB:
+        ret = RegisterFrameBuffers(com);
+        if (ctx->stateDoing == FALSE) {
+            ctx->state = DEC_STATE_DECODING;
+            DisplayDecodedInformation(ctx->handle, ctx->decOpenParam.bitstreamFormat, 0, NULL, ctx->testDecConfig.performance, 0);
+        }
+        break;
+    case DEC_STATE_DECODING:
+        ret = Decode(com, (PortContainerES*)in, (PortContainerDisplay*)out);
+        break;
+    default:
+        ret = FALSE;
+        break;
+    }
+
+    if (ctx->handle) {
+        PhysicalAddress rdPtr, wrPtr;
+        Uint32          room;
+
+        VPU_DecGetBitstreamBuffer(ctx->handle, &rdPtr, &wrPtr, &room);
+        ctx->bsPos.rdPtr = rdPtr;
+        ctx->bsPos.wrPtr = wrPtr;
+        ctx->bsPos.avail = room;
+    }
+
+    if (ret == FALSE || com->terminate == TRUE) {
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_DECODED_ALL, (void*)ctx->handle);
+        if (out) {
+            out->reuse = FALSE;
+            out->last  = TRUE;
+        }
+    }
+
+    return ret;
+}
+
+static BOOL PrepareDecoder(ComponentImpl* com, BOOL* done)
+{
+    *done = TRUE;
+
+    return TRUE;
+}
+
+static void ReleaseDecoder(ComponentImpl* com)
+{
+}
+
+static BOOL DestroyDecoder(ComponentImpl* com)
+{
+    DecoderContext* ctx         = (DecoderContext*)com->context;
+    BOOL            success     = TRUE;
+    RetCode         ret         = RETCODE_SUCCESS;
+
+    CloseDecReport (ctx->handle);
+
+    VPU_DecUpdateBitstreamBuffer(ctx->handle, STREAM_END_SET_FLAG);
+
+    ret = VPU_DecClose(ctx->handle);
+    if (RETCODE_SUCCESS != ret) {
+        VLOG(ERR, "%s:%d FAILED TO VPU_DecClose() ret(%d)\n", __FUNCTION__, __LINE__, ret);
+    }
+
+    Queue_Destroy(ctx->idxFrameDisQ);
+
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_CLOSE, NULL);
+
+    if (ctx->vbUserData.size) {
+        vdi_free_dma_memory(ctx->testDecConfig.coreIdx, &ctx->vbUserData, DEC_ETC, ctx->handle->instIndex);
+    }
+
+    VPU_DeInit(ctx->decOpenParam.coreIdx);
+
+    osal_free(ctx);
+
+    return success;
+}
+
+static Component CreateDecoder(ComponentImpl* com, CNMComponentConfig* componentParam)
+{
+    DecoderContext* ctx;
+    Uint32          coreIdx      = componentParam->testDecConfig.coreIdx;
+    Uint16*         firmware     = (Uint16*)componentParam->bitcode;
+    Uint32          firmwareSize = componentParam->sizeOfBitcode;
+    RetCode         retCode;
+    Int32           productId = PRODUCT_ID_NONE;
+
+    retCode = VPU_InitWithBitcode(coreIdx, firmware, firmwareSize);
+    if (retCode != RETCODE_SUCCESS && retCode != RETCODE_CALLED_BEFORE) {
+        VLOG(INFO, "%s:%d Failed to VPU_InitiWithBitcode, ret(%08x)\n", __FUNCTION__, __LINE__, retCode);
+        return FALSE;
+    }
+
+    com->context = (DecoderContext*)osal_malloc(sizeof(DecoderContext));
+    osal_memset(com->context, 0, sizeof(DecoderContext));
+    ctx = (DecoderContext*)com->context;
+
+    productId = VPU_GetProductId(coreIdx);
+    VLOG(INFO, "PRODUCT ID: %d\n", productId);
+
+    PrintVpuVersionInfo(coreIdx);
+
+    memcpy(&(ctx->decOpenParam), &(componentParam->decOpenParam), sizeof(DecOpenParam));
+
+    ctx->wtlFormat                          = componentParam->testDecConfig.wtlFormat;
+    ctx->frameNumToStop                     = componentParam->testDecConfig.forceOutNum;
+    ctx->testDecConfig                      = componentParam->testDecConfig;
+    ctx->state                              = DEC_STATE_OPEN_DECODER;
+    ctx->stateDoing                         = FALSE;
+
+    ctx->idxFrameDisQ = Queue_Create(INDEX_FRAME_DIS_QUEUE_SIZE, sizeof(Int32));
+
+    return (Component)com;
+}
+
+ComponentImpl coda9DecoderComponentImpl = {
+    "coda9_decoder",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainerDisplay),
+    5,
+    CreateDecoder,
+    GetParameterDecoder,
+    SetParameterDecoder,
+    PrepareDecoder,
+    ExecuteDecoder,
+    ReleaseDecoder,
+    DestroyDecoder
+};
+
+

+ 1070 - 0
soft_3rdpart/wave511/code/sample_v2/component_decoder/component_dec_decoder.c

@@ -0,0 +1,1070 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include "component.h"
+#include "cnm_app.h"
+#include "misc/debug.h"
+
+
+#define EXTRA_FRAME_BUFFER_NUM 1
+
+typedef enum {
+    DEC_INT_STATUS_NONE,        // Interrupt not asserted yet
+    DEC_INT_STATUS_EMPTY,       // Need more es
+    DEC_INT_STATUS_DONE,        // Interrupt asserted
+    DEC_INT_STATUS_TIMEOUT,     // Interrupt not asserted during given time.
+} DEC_INT_STATUS;
+
+typedef enum {
+    DEC_STATE_NONE,
+    DEC_STATE_OPEN_DECODER,
+    DEC_STATE_INIT_SEQ,
+    DEC_STATE_REGISTER_FB,
+    DEC_STATE_DECODING,
+    DEC_STATE_CLOSE,
+} DecoderState;
+
+typedef struct {
+    TestDecConfig       testDecConfig;
+    DecOpenParam        decOpenParam;
+    DecParam            decParam;
+    FrameBufferFormat   wtlFormat;
+    DecHandle           handle;
+    Uint64              startTimeout;
+    vpu_buffer_t        vbUserData;
+    BOOL                doFlush;
+    BOOL                stateDoing;
+    DecoderState        state;
+    DecInitialInfo      initialInfo;
+    Uint32              numDecoded;             /*!<< The number of decoded frames */
+    Uint32              numOutput;
+    PhysicalAddress     decodedAddr;
+    Uint32              frameNumToStop;
+    BOOL                doReset;
+    Uint32              cyclePerTick;
+    VpuAttr             attr;
+    struct {
+        BOOL    enable;
+        Uint32  skipCmd;                        /*!<< a skip command to be restored */
+    }                   autoErrorRecovery;
+} DecoderContext;
+
+static BOOL RegisterFrameBuffers(ComponentImpl* com)
+{
+    DecoderContext*         ctx               = (DecoderContext*)com->context;
+    FrameBuffer*            pFrame            = NULL;
+    Uint32                  framebufStride    = 0;
+    ParamDecFrameBuffer     paramFb;
+    RetCode                 result;
+    DecInitialInfo*         codecInfo         = &ctx->initialInfo;
+    BOOL                    success;
+    CNMComponentParamRet    ret;
+    CNMComListenerDecRegisterFb  lsnpRegisterFb;
+
+    ctx->stateDoing = TRUE;
+    ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_RENDERER_FRAME_BUF, (void*)&paramFb);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) {
+        return success;
+    }
+
+    pFrame               = paramFb.fb;
+    framebufStride       = paramFb.stride;
+    VLOG(TRACE, "<%s> COMPRESSED: %d, LINEAR: %d\n", __FUNCTION__, paramFb.nonLinearNum, paramFb.linearNum);
+
+    if (ctx->attr.productId == PRODUCT_ID_521 && ctx->attr.supportDualCore == TRUE) {
+        if (ctx->initialInfo.lumaBitdepth == 8 && ctx->initialInfo.chromaBitdepth == 8)
+            result = VPU_DecRegisterFrameBufferEx(ctx->handle, pFrame, paramFb.nonLinearNum, paramFb.linearNum, framebufStride, codecInfo->picHeight, COMPRESSED_FRAME_MAP_DUAL_CORE_8BIT);
+        else
+            result = VPU_DecRegisterFrameBufferEx(ctx->handle, pFrame, paramFb.nonLinearNum, paramFb.linearNum, framebufStride, codecInfo->picHeight, COMPRESSED_FRAME_MAP_DUAL_CORE_10BIT);
+    }
+    else {
+        result = VPU_DecRegisterFrameBufferEx(ctx->handle, pFrame, paramFb.nonLinearNum, paramFb.linearNum, framebufStride, codecInfo->picHeight, COMPRESSED_FRAME_MAP);
+    }
+
+    lsnpRegisterFb.handle          = ctx->handle;
+    lsnpRegisterFb.numNonLinearFb  = paramFb.nonLinearNum;
+    lsnpRegisterFb.numLinearFb     = paramFb.linearNum;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_REGISTER_FB, (void*)&lsnpRegisterFb);
+
+    if (result != RETCODE_SUCCESS) {
+        VLOG(ERR, "%s:%d Failed to VPU_DecRegisterFrameBufferEx(%d)\n", __FUNCTION__, __LINE__, result);
+        ChekcAndPrintDebugInfo(ctx->handle, FALSE, result);
+        return FALSE;
+    }
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL SequenceChange(ComponentImpl* com, DecOutputInfo* outputInfo)
+{
+    DecoderContext* ctx               = (DecoderContext*)com->context;
+    BOOL            dpbChanged, sizeChanged, bitDepthChanged;
+    Uint32          sequenceChangeFlag = outputInfo->sequenceChanged;
+
+    dpbChanged      = (sequenceChangeFlag&SEQ_CHANGE_ENABLE_DPB_COUNT) ? TRUE : FALSE;
+    sizeChanged     = (sequenceChangeFlag&SEQ_CHANGE_ENABLE_SIZE)      ? TRUE : FALSE;
+    bitDepthChanged = (sequenceChangeFlag&SEQ_CHANGE_ENABLE_BITDEPTH)  ? TRUE : FALSE;
+
+    if (dpbChanged || sizeChanged || bitDepthChanged) {
+        DecInitialInfo  initialInfo;
+
+        VLOG(INFO, "----- SEQUENCE CHANGED -----\n");
+        // Get current(changed) sequence information.
+        VPU_DecGiveCommand(ctx->handle, DEC_GET_SEQ_INFO, &initialInfo);
+        // Flush all remaining framebuffers of previous sequence.
+
+        VLOG(INFO, "sequenceChanged : %x\n", sequenceChangeFlag);
+        VLOG(INFO, "SEQUENCE NO     : %d\n", initialInfo.sequenceNo);
+        VLOG(INFO, "DPB COUNT       : %d\n", initialInfo.minFrameBufferCount);
+        VLOG(INFO, "BITDEPTH        : LUMA(%d), CHROMA(%d)\n", initialInfo.lumaBitdepth, initialInfo.chromaBitdepth);
+        VLOG(INFO, "SIZE            : WIDTH(%d), HEIGHT(%d)\n", initialInfo.picWidth, initialInfo.picHeight);
+
+        ComponentSetParameter(com, com->sinkPort.connectedComponent, SET_PARAM_RENDERER_FREE_FRAMEBUFFERS, (void*)&outputInfo->frameDisplayFlag);
+
+        VPU_DecGiveCommand(ctx->handle, DEC_RESET_FRAMEBUF_INFO, NULL);
+
+        if (ctx->testDecConfig.scaleDownWidth > 0 || ctx->testDecConfig.scaleDownHeight > 0) {
+            ScalerInfo sclInfo = {0};
+
+            sclInfo.scaleWidth  = CalcScaleDown(initialInfo.picWidth, ctx->testDecConfig.scaleDownWidth);
+            sclInfo.scaleHeight = CalcScaleDown(initialInfo.picHeight, ctx->testDecConfig.scaleDownHeight);
+            VLOG(INFO, "[SCALE INFO] %dx%d to %dx%d\n", initialInfo.picWidth, initialInfo.picHeight, sclInfo.scaleWidth, sclInfo.scaleHeight);
+            sclInfo.enScaler    = TRUE;
+            if (VPU_DecGiveCommand(ctx->handle, DEC_SET_SCALER_INFO, (void*)&sclInfo) != RETCODE_SUCCESS) {
+                VLOG(ERR, "Failed to VPU_DecGiveCommand(DEC_SET_SCALER_INFO)\n");
+                return FALSE;
+            }
+        }
+        ctx->state = DEC_STATE_REGISTER_FB;
+        osal_memcpy((void*)&ctx->initialInfo, (void*)&initialInfo, sizeof(DecInitialInfo));
+        ComponentSetParameter(com, com->sinkPort.connectedComponent, SET_PARAM_RENDERER_ALLOC_FRAMEBUFFERS, NULL);
+
+        VLOG(INFO, "----------------------------\n");
+    }
+
+    return TRUE;
+}
+
+static BOOL CheckAndDoSequenceChange(ComponentImpl* com, DecOutputInfo* outputInfo)
+{
+    if (outputInfo->sequenceChanged == 0) {
+        return TRUE;
+    }
+    else {
+        return SequenceChange(com, outputInfo);
+    }
+}
+
+static void ClearDpb(ComponentImpl* com, BOOL backupDpb)
+{
+    DecoderContext* ctx             = (DecoderContext*)com->context;
+    Uint32          timeoutCount;
+    Int32           intReason;
+    DecOutputInfo   outputInfo;
+    BOOL            pause;
+    Uint32          idx;
+    Uint32          flushedFbs      = 0;
+    QueueStatusInfo cqInfo;
+    const Uint32    flushTimeout    = 100;
+
+    if (TRUE == backupDpb) {
+        pause = TRUE;
+        ComponentSetParameter(com, com->sinkPort.connectedComponent, SET_PARAM_COM_PAUSE, (void*)&pause);
+    }
+
+    /* Send the renderer the signal to drop all frames.
+     * VPU_DecClrDispFlag() is called in SE_PARAM_RENDERER_FLUSH.
+     */
+    ComponentSetParameter(com, com->sinkPort.connectedComponent, SET_PARAM_RENDERER_FLUSH, (void*)&flushedFbs);
+
+    while (RETCODE_SUCCESS == VPU_DecGetOutputInfo(ctx->handle, &outputInfo)) {
+        if (0 <= outputInfo.indexFrameDisplay) {
+            flushedFbs |= outputInfo.indexFrameDisplay;
+            VPU_DecClrDispFlag(ctx->handle, outputInfo.indexFrameDisplay);
+            VLOG(INFO, "<%s> FLUSH DPB INDEX: %d\n", __FUNCTION__, outputInfo.indexFrameDisplay);
+        }
+        osal_msleep(1);
+    }
+
+    VLOG(INFO, "========== FLUSH FRAMEBUFFER & CMDs ========== \n");
+    timeoutCount = 0;
+    while (VPU_DecFrameBufferFlush(ctx->handle, NULL, NULL) == RETCODE_VPU_STILL_RUNNING) {
+        /* Clear an interrupt */
+        if (0 < (intReason=VPU_WaitInterruptEx(ctx->handle, VPU_WAIT_TIME_OUT_CQ))) {
+            VPU_ClearInterruptEx(ctx->handle, intReason);
+            VPU_DecGetOutputInfo(ctx->handle, &outputInfo);  // ignore the return value and outputinfo
+            if (0 <= outputInfo.indexFrameDisplay) {
+                flushedFbs |= outputInfo.indexFrameDisplay;
+                VPU_DecClrDispFlag(ctx->handle, outputInfo.indexFrameDisplay);
+            }
+        }
+
+        if (timeoutCount >= flushTimeout) {
+            VLOG(ERR, "NO RESPONSE FROM VPU_DecFrameBufferFlush()\n");
+            return;
+        }
+        timeoutCount++;
+    }
+
+    VPU_DecGetOutputInfo(ctx->handle, &outputInfo);
+    VPU_DecGiveCommand(ctx->handle, DEC_GET_QUEUE_STATUS, &cqInfo);
+    VLOG(INFO, "<%s> REPORT_QUEUE(%d), INSTANCE_QUEUE(%d)\n", __FUNCTION__, cqInfo.reportQueueCount, cqInfo.instanceQueueCount);
+
+    if (TRUE == backupDpb) {
+        for (idx=0; idx<32; idx++) {
+            if (flushedFbs & (1<<idx)) {
+                VLOG(INFO, "SET DISPLAY FLAG : %d\n", idx);
+                VPU_DecGiveCommand(ctx->handle, DEC_SET_DISPLAY_FLAG , &idx);
+            }
+        }
+        pause = FALSE;
+        ComponentSetParameter(com, com->sinkPort.connectedComponent, SET_PARAM_COM_PAUSE, (void*)&pause);
+    }
+}
+
+static void ClearCpb(ComponentImpl* com)
+{
+    DecoderContext* ctx = (DecoderContext*)com->context;
+    PhysicalAddress curRdPtr, curWrPtr;
+
+    if (BS_MODE_INTERRUPT == ctx->decOpenParam.bitstreamMode) {
+        /* Clear CPB */
+        // In order to stop processing bitstream.
+        VLOG(INFO, "CLEAR CPB\n");
+        VPU_DecUpdateBitstreamBuffer(ctx->handle, EXPLICIT_END_SET_FLAG);
+        VPU_DecGetBitstreamBuffer(ctx->handle, &curRdPtr, &curWrPtr, NULL);
+        VPU_DecSetRdPtr(ctx->handle, curWrPtr, TRUE);
+    }
+}
+
+static BOOL PrepareSkip(ComponentImpl* com)
+{
+    DecoderContext*   ctx = (DecoderContext*)com->context;
+
+    // Flush the decoder
+    if (ctx->doFlush == TRUE) {
+        ClearDpb(com, FALSE);
+        ClearCpb(com);
+        ctx->doFlush = FALSE;
+    }
+
+    return TRUE;
+}
+
+static DEC_INT_STATUS HandlingInterruptFlag(ComponentImpl* com)
+{
+    DecoderContext*      ctx               = (DecoderContext*)com->context;
+    DecHandle            handle            = ctx->handle;
+    Int32                interruptFlag     = 0;
+    Uint32               interruptWaitTime = VPU_WAIT_TIME_OUT_CQ;
+    Uint32               interruptTimeout  = VPU_DEC_TIMEOUT;
+    DEC_INT_STATUS       status            = DEC_INT_STATUS_NONE;
+    CNMComListenerDecInt lsn;
+
+    if (ctx->startTimeout == 0ULL) {
+        ctx->startTimeout = osal_gettime();
+    }
+    do {
+        interruptFlag = VPU_WaitInterruptEx(handle, interruptWaitTime);
+        if (INTERRUPT_TIMEOUT_VALUE == interruptFlag) {
+            Uint64   currentTimeout = osal_gettime();
+            if (0 < interruptTimeout && (currentTimeout - ctx->startTimeout) > interruptTimeout) {
+                VLOG(ERR, "\n INSNTANCE #%d INTERRUPT TIMEOUT.\n", handle->instIndex);
+                status = DEC_INT_STATUS_TIMEOUT;
+                break;
+            }
+            interruptFlag = 0;
+        }
+
+        if (interruptFlag < 0) {
+            VLOG(ERR, "<%s:%d> interruptFlag is negative value! %08x\n", __FUNCTION__, __LINE__, interruptFlag);
+        }
+
+        if (interruptFlag > 0) {
+            VPU_ClearInterruptEx(handle, interruptFlag);
+            ctx->startTimeout = 0ULL;
+            status = DEC_INT_STATUS_DONE;
+            if (interruptFlag & (1<<INT_WAVE5_INIT_SEQ)) {
+                break;
+            }
+
+            if (interruptFlag & (1<<INT_WAVE5_DEC_PIC)) {
+                break;
+            }
+
+            if (interruptFlag & (1<<INT_WAVE5_BSBUF_EMPTY)) {
+                status = DEC_INT_STATUS_EMPTY;
+                break;
+            }
+        }
+    } while (FALSE);
+
+    if (interruptFlag != 0) {
+        lsn.handle   = handle;
+        lsn.flag     = interruptFlag;
+        lsn.decIndex = ctx->numDecoded;
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_INTERRUPT, (void*)&lsn);
+    }
+
+    return status;
+}
+
+static BOOL DoReset(ComponentImpl* com)
+{
+    DecoderContext* ctx    = (DecoderContext*)com->context;
+    DecHandle       handle = ctx->handle;
+    BOOL            pause  = TRUE;
+
+
+    VLOG(INFO, "========== %s ==========\n", __FUNCTION__);
+
+    ComponentSetParameter(com, com->srcPort.connectedComponent, SET_PARAM_COM_PAUSE, (void*)&pause);
+    ComponentSetParameter(com, com->srcPort.connectedComponent, SET_PARAM_FEEDER_RESET, (void*)&pause);
+
+    ClearDpb(com, FALSE);
+
+    VLOG(INFO, "> Reset VPU\n");
+    if (VPU_SWReset(handle->coreIdx, SW_RESET_SAFETY, handle) != RETCODE_SUCCESS) {
+        VLOG(ERR, "<%s:%d> Failed to VPU_SWReset()\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    ClearCpb(com);
+
+    VLOG(INFO, "========== %s ==========\n", __FUNCTION__);
+
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_RESET_DONE, NULL);
+
+    VLOG(INFO, "> FLUSH INPUT PORT\n");
+    ComponentPortFlush(com);
+
+    pause = FALSE;
+    ComponentSetParameter(com, com->srcPort.connectedComponent, SET_PARAM_COM_PAUSE, (void*)&pause);
+
+    ctx->doReset                    = FALSE;
+    ctx->startTimeout               = 0ULL;
+    ctx->autoErrorRecovery.enable   = TRUE;
+    ctx->autoErrorRecovery.skipCmd  = ctx->decParam.skipframeMode;
+    ctx->decParam.skipframeMode     = WAVE_SKIPMODE_NON_IRAP;
+
+    return TRUE;
+}
+
+
+static BOOL Decode(ComponentImpl* com, PortContainerES* in, PortContainerDisplay* out)
+{
+    DecoderContext*                 ctx           = (DecoderContext*)com->context;
+    DecOutputInfo                   decOutputInfo;
+    DEC_INT_STATUS                  intStatus;
+    CNMComListenerStartDecOneFrame  lsnpPicStart;
+    BitStreamMode                   bsMode        = ctx->decOpenParam.bitstreamMode;
+    RetCode                         result;
+    CNMComListenerDecDone           lsnpPicDone;
+    CNMComListenerDecReadyOneFrame  lsnpReadyOneFrame = {0,};
+    BOOL                            doDecode;
+    QueueStatusInfo                 qStatus;
+
+    lsnpReadyOneFrame.handle = ctx->handle;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_READY_ONE_FRAME, (void*)&lsnpReadyOneFrame);
+
+    ctx->stateDoing = TRUE;
+
+    if (PrepareSkip(com) == FALSE) {
+        return FALSE;
+    }
+
+    /* decode a frame except when the bitstream mode is PIC_END and no data */
+    doDecode  = !(bsMode == BS_MODE_PIC_END && in == NULL);
+    doDecode &= (BOOL)(com->pause == FALSE);
+
+    VPU_DecGiveCommand(ctx->handle, DEC_GET_QUEUE_STATUS, &qStatus);
+    if (COMMAND_QUEUE_DEPTH == qStatus.instanceQueueCount) {
+        doDecode = FALSE;
+    }
+
+
+    /* The simple load balancer : To use this function, call InitLoadBalancer() before decoding process. */
+    if (TRUE == doDecode) {
+        doDecode = LoadBalancerGetMyTurn(ctx->handle->instIndex);
+    }
+
+    if (TRUE == doDecode) {
+        result = VPU_DecStartOneFrame(ctx->handle, &ctx->decParam);
+
+        lsnpPicStart.result   = result;
+        lsnpPicStart.decParam = ctx->decParam;
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_START_ONE_FRAME, (void*)&lsnpPicStart);
+
+        if (result == RETCODE_SUCCESS) {
+            /* The simple load balancer : pass its turn */
+            LoadBalancerSetNextTurn();
+        }
+        else if (result == RETCODE_QUEUEING_FAILURE) {
+            // Just retry
+            if (in) in->reuse = (bsMode == BS_MODE_PIC_END);
+            VPU_DecGiveCommand(ctx->handle, DEC_GET_QUEUE_STATUS, (void*)&qStatus);
+        }
+        else if (result == RETCODE_VPU_RESPONSE_TIMEOUT) {
+            VLOG(INFO, "<%s:%d> Failed to VPU_DecStartOneFrame() ret(%d)\n", __FUNCTION__, __LINE__, result);
+            CNMErrorSet(CNM_ERROR_HANGUP);
+            HandleDecoderError(ctx->handle, ctx->numDecoded, NULL);
+            return FALSE;
+        }
+        else {
+            ChekcAndPrintDebugInfo(ctx->handle, FALSE, result);
+            return FALSE;
+        }
+    }
+    else {
+        if (in) in->reuse = (bsMode == BS_MODE_PIC_END);
+    }
+
+    intStatus=HandlingInterruptFlag(com);
+    switch (intStatus) {
+    case DEC_INT_STATUS_TIMEOUT:
+        DoReset(com);
+        return FALSE;
+    case DEC_INT_STATUS_EMPTY:
+    case DEC_INT_STATUS_NONE:
+        return TRUE;
+    default:
+        break;
+    }
+
+    // Get data from the sink component.
+    if ((result=VPU_DecGetOutputInfo(ctx->handle, &decOutputInfo)) == RETCODE_SUCCESS) {
+        DisplayDecodedInformation(ctx->handle, ctx->decOpenParam.bitstreamFormat, ctx->numDecoded, &decOutputInfo, ctx->testDecConfig.performance, ctx->cyclePerTick);
+    }
+
+    lsnpPicDone.handle     = ctx->handle;
+    lsnpPicDone.ret        = result;
+    lsnpPicDone.decParam   = &ctx->decParam;
+    lsnpPicDone.output     = &decOutputInfo;
+    lsnpPicDone.numDecoded = ctx->numDecoded;
+    lsnpPicDone.vbUser     = ctx->vbUserData;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_GET_OUTPUT_INFO, (void*)&lsnpPicDone);
+
+    if (result == RETCODE_REPORT_NOT_READY) {
+        return TRUE; // Not decoded yet. Try again
+    }
+    else if (result != RETCODE_SUCCESS) {
+        /* ERROR */
+        VLOG(ERR, "Failed to decode error\n");
+        ChekcAndPrintDebugInfo(ctx->handle, FALSE, result);
+        return FALSE;
+    }
+
+    if ((decOutputInfo.decodingSuccess & 0x01) == 0) {
+        VLOG(ERR, "VPU_DecGetOutputInfo decode fail framdIdx %d error(0x%08x) reason(0x%08x), reasonExt(0x%08x)\n",
+            ctx->numDecoded, decOutputInfo.decodingSuccess, decOutputInfo.errorReason, decOutputInfo.errorReasonExt);
+        if (WAVE5_SYSERR_WATCHDOG_TIMEOUT == decOutputInfo.errorReason || WAVE5_SYSERR_DEC_VLC_BUF_FULL == decOutputInfo.errorReason) {
+            VLOG(ERR, "WAVE5_SYSERR_WATCHDOG_TIMEOUT\n");
+        }
+        else if ( WAVE5_SYSERR_DEC_VLC_BUF_FULL == decOutputInfo.errorReason) {
+            VLOG(ERR, "VLC_BUFFER FULL\n");
+        }
+        else if (decOutputInfo.errorReason == WAVE5_SPECERR_OVER_PICTURE_WIDTH_SIZE || decOutputInfo.errorReason == WAVE5_SPECERR_OVER_PICTURE_HEIGHT_SIZE) {
+            VLOG(ERR, "Not supported Width or Height(%dx%d)\n", decOutputInfo.decPicWidth, decOutputInfo.decPicHeight);
+            return FALSE;
+        }
+    }
+    else {
+        if (TRUE == ctx->autoErrorRecovery.enable) {
+            ctx->decParam.skipframeMode     = ctx->autoErrorRecovery.skipCmd;
+            ctx->autoErrorRecovery.enable   = FALSE;
+            ctx->autoErrorRecovery.skipCmd  = WAVE_SKIPMODE_WAVE_NONE;
+        }
+    }
+
+    if (CheckAndDoSequenceChange(com, &decOutputInfo) == FALSE) {
+        return FALSE;
+    }
+
+    if (decOutputInfo.indexFrameDecoded >= 0 || decOutputInfo.indexFrameDecoded == DECODED_IDX_FLAG_SKIP) {
+        // Return a used data to a source port.
+        ctx->numDecoded++;
+        ctx->decodedAddr = decOutputInfo.bytePosFrameStart;
+        out->reuse = FALSE;
+    }
+
+    if ((decOutputInfo.indexFrameDisplay >= 0) || (decOutputInfo.indexFrameDisplay == DISPLAY_IDX_FLAG_SEQ_END)) {
+        ctx->numOutput++;
+        out->last  = (BOOL)(decOutputInfo.indexFrameDisplay == DISPLAY_IDX_FLAG_SEQ_END);
+        out->reuse = FALSE;
+    }
+    if (decOutputInfo.indexFrameDisplay == DISPLAY_IDX_FLAG_SEQ_END) {
+        ctx->stateDoing = FALSE;
+        com->terminate  = TRUE;
+    }
+    if (out->reuse == FALSE) {
+        osal_memcpy((void*)&out->decInfo, (void*)&decOutputInfo, sizeof(DecOutputInfo));
+    }
+
+    if (ctx->frameNumToStop > 0) {
+        if (ctx->frameNumToStop == ctx->numOutput) {
+            com->terminate = TRUE;
+        }
+    }
+
+    return TRUE;
+}
+
+static CNMComponentParamRet GetParameterDecoder(ComponentImpl* from, ComponentImpl* com, GetParameterCMD commandType, void* data)
+{
+    DecoderContext*             ctx     = (DecoderContext*)com->context;
+    BOOL                        result  = TRUE;
+    PhysicalAddress             rdPtr, wrPtr;
+    Uint32                      room;
+    ParamDecBitstreamBufPos*    bsPos   = NULL;
+    ParamDecNeedFrameBufferNum* fbNum;
+    ParamVpuStatus*             status;
+    QueueStatusInfo             cqInfo;
+    PortContainerES*            container;
+    vpu_buffer_t                vb;
+
+    if (ctx->handle == NULL)  return CNM_COMPONENT_PARAM_NOT_READY;
+    if (ctx->doReset == TRUE) return CNM_COMPONENT_PARAM_NOT_READY;
+
+    switch(commandType) {
+    case GET_PARAM_COM_IS_CONTAINER_CONUSUMED:
+        // This query command is sent from the comonponent core.
+        // If input data are consumed in sequence, it should return TRUE through PortContainer::consumed.
+        container = (PortContainerES*)data;
+        vb = container->buf;
+        if (vb.phys_addr <= ctx->decodedAddr && ctx->decodedAddr < (vb.phys_addr+vb.size)) {
+            container->consumed = TRUE;
+            ctx->decodedAddr = 0;
+        }
+        break;
+    case GET_PARAM_DEC_HANDLE:
+        *(DecHandle*)data = ctx->handle;
+        break;
+    case GET_PARAM_DEC_FRAME_BUF_NUM:
+        if (ctx->state <= DEC_STATE_INIT_SEQ) return CNM_COMPONENT_PARAM_NOT_READY;
+        fbNum = (ParamDecNeedFrameBufferNum*)data;
+        fbNum->nonLinearNum = ctx->initialInfo.minFrameBufferCount + EXTRA_FRAME_BUFFER_NUM;   // max_dec_pic_buffering
+        if (ctx->decOpenParam.wtlEnable == TRUE) {
+            fbNum->linearNum = (ctx->initialInfo.frameBufDelay+1) + EXTRA_FRAME_BUFFER_NUM;     // The frameBufDelay can be zero.
+            if ((ctx->decOpenParam.bitstreamFormat == STD_VP9) || (ctx->decOpenParam.bitstreamFormat == STD_AVS2) || (ctx->decOpenParam.bitstreamFormat == STD_AV1)) {
+                fbNum->linearNum = fbNum->nonLinearNum;
+            }
+            if (ctx->testDecConfig.performance == TRUE) {
+                if ((ctx->decOpenParam.bitstreamFormat == STD_VP9) || (ctx->decOpenParam.bitstreamFormat == STD_AVS2)) {
+                    fbNum->linearNum++;
+                    fbNum->nonLinearNum++;
+                } else if (ctx->decOpenParam.bitstreamFormat == STD_AV1) {
+                    fbNum->linearNum++;
+                    fbNum->nonLinearNum++;
+                }
+                else {
+                    fbNum->linearNum += 3;
+                }
+            }
+
+        }
+        else {
+            fbNum->linearNum = 0;
+        }
+        break;
+    case GET_PARAM_DEC_BITSTREAM_BUF_POS:
+        if (ctx->state < DEC_STATE_INIT_SEQ) return CNM_COMPONENT_PARAM_NOT_READY;
+        VPU_DecGetBitstreamBuffer(ctx->handle, &rdPtr, &wrPtr, &room);
+        bsPos = (ParamDecBitstreamBufPos*)data;
+        bsPos->rdPtr = rdPtr;
+        bsPos->wrPtr = wrPtr;
+        bsPos->avail = room;
+        break;
+    case GET_PARAM_DEC_CODEC_INFO:
+        if (ctx->state <= DEC_STATE_INIT_SEQ) return CNM_COMPONENT_PARAM_NOT_READY;
+        VPU_DecGiveCommand(ctx->handle, DEC_GET_SEQ_INFO, data);
+        break;
+    case GET_PARAM_VPU_STATUS:
+        if (ctx->state != DEC_STATE_DECODING) return CNM_COMPONENT_PARAM_NOT_READY;
+        VPU_DecGiveCommand(ctx->handle, DEC_GET_QUEUE_STATUS, &cqInfo);
+        status = (ParamVpuStatus*)data;
+        status->cq = cqInfo;
+        break;
+    default:
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static CNMComponentParamRet SetParameterDecoder(ComponentImpl* from, ComponentImpl* com, SetParameterCMD commandType, void* data)
+{
+    BOOL                result  = TRUE;
+    DecoderContext*     ctx     = (DecoderContext*)com->context;
+    Int32               skipCmd;
+    ParamDecTargetTid*  tid     = NULL;
+
+    switch(commandType) {
+    case SET_PARAM_COM_PAUSE:
+        com->pause   = *(BOOL*)data;
+        break;
+    case SET_PARAM_DEC_SKIP_COMMAND:
+        skipCmd = *(Int32*)data;
+        ctx->decParam.skipframeMode = skipCmd;
+        if (skipCmd == WAVE_SKIPMODE_NON_IRAP) {
+            Uint32 userDataMask = (1<<H265_USERDATA_FLAG_RECOVERY_POINT);
+            ctx->decParam.craAsBlaFlag = TRUE;
+            /* For finding recovery point */
+            VPU_DecGiveCommand(ctx->handle, ENABLE_REP_USERDATA, &userDataMask);
+        }
+        else {
+            ctx->decParam.craAsBlaFlag = FALSE;
+        }
+        if (ctx->numDecoded > 0) {
+            ctx->doFlush = (BOOL)(ctx->decParam.skipframeMode == WAVE_SKIPMODE_NON_IRAP);
+        }
+        break;
+    case SET_PARAM_DEC_RESET:
+        ctx->doReset = TRUE;
+        break;
+    case SET_PARAM_DEC_TARGET_TID:
+        tid = (ParamDecTargetTid*)data;
+        /*! NOTE: DO NOT CHANGE THE ORDER OF COMMANDS BELOW. */
+        VPU_DecGiveCommand(ctx->handle, DEC_SET_TEMPORAL_ID_MODE,   (void*)&tid->tidMode);
+        VPU_DecGiveCommand(ctx->handle, DEC_SET_TARGET_TEMPORAL_ID, (void*)&tid->targetTid);
+        break;
+    case SET_PARAM_DEC_FLUSH:
+        ClearDpb(com, TRUE);
+        break;
+    default:
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static BOOL UpdateBitstream(DecoderContext* ctx, PortContainerES* in)
+{
+    RetCode       ret    = RETCODE_SUCCESS;
+    BitStreamMode bsMode = ctx->decOpenParam.bitstreamMode;
+    BOOL          update = TRUE;
+    Uint32        updateSize;
+
+    if (in == NULL) return TRUE;
+
+    if (bsMode == BS_MODE_PIC_END) {
+        VPU_DecSetRdPtr(ctx->handle, in->buf.phys_addr, TRUE);
+    }
+    else {
+        if (in->size > 0) {
+            PhysicalAddress rdPtr, wrPtr;
+            Uint32          room;
+            VPU_DecGetBitstreamBuffer(ctx->handle, &rdPtr, &wrPtr, &room);
+            if ((Int32)room < in->size) {
+                in->reuse = TRUE;
+                return TRUE;
+            }
+        }
+    }
+
+    if (in->last == TRUE) {
+        updateSize = (in->size == 0) ? STREAM_END_SET_FLAG : in->size;
+    }
+    else {
+        updateSize = in->size;
+        update     = (in->size > 0 && in->last == FALSE);
+    }
+
+    if (update == TRUE) {
+        if ((ret=VPU_DecUpdateBitstreamBuffer(ctx->handle, updateSize)) != RETCODE_SUCCESS) {
+            VLOG(INFO, "<%s:%d> Failed to VPU_DecUpdateBitstreamBuffer() ret(%d)\n", __FUNCTION__, __LINE__, ret);
+            ChekcAndPrintDebugInfo(ctx->handle, FALSE, ret);
+            return FALSE;
+        }
+        if (in->last == TRUE) {
+            VPU_DecUpdateBitstreamBuffer(ctx->handle, STREAM_END_SET_FLAG);
+        }
+    }
+
+    in->reuse = FALSE;
+
+    return TRUE;
+}
+
+static BOOL OpenDecoder(ComponentImpl* com)
+{
+    DecoderContext*         ctx     = (DecoderContext*)com->context;
+    ParamDecBitstreamBuffer bsBuf;
+    CNMComponentParamRet    ret;
+    CNMComListenerDecOpen   lspn    = {0};
+    BOOL                    success = FALSE;
+    BitStreamMode           bsMode  = ctx->decOpenParam.bitstreamMode;
+    vpu_buffer_t            vbUserData;
+    RetCode                 retCode;
+
+    ctx->stateDoing = TRUE;
+    ret = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_FEEDER_BITSTREAM_BUF, &bsBuf);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) {
+        return success;
+    }
+
+    ctx->decOpenParam.bitstreamBuffer     = (bsMode == BS_MODE_PIC_END) ? 0 : bsBuf.bs->phys_addr;
+    ctx->decOpenParam.bitstreamBufferSize = (bsMode == BS_MODE_PIC_END) ? 0 : bsBuf.bs->size;
+    retCode = VPU_DecOpen(&ctx->handle, &ctx->decOpenParam);
+
+
+    lspn.handle = ctx->handle;
+    lspn.ret    = retCode;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_OPEN, (void*)&lspn);
+
+    if (retCode != RETCODE_SUCCESS) {
+        VLOG(ERR, "<%s:%d> Failed to VPU_DecOpen(ret:%d)\n", __FUNCTION__, __LINE__, retCode);
+        if ( retCode == RETCODE_VPU_RESPONSE_TIMEOUT)
+            CNMErrorSet(CNM_ERROR_HANGUP);
+
+        return FALSE;
+    }
+    LoadBalancerAddInstance(ctx->handle->instIndex);
+    // VPU_DecGiveCommand(ctx->handle, ENABLE_LOGGING, 0);
+
+    if (ctx->vbUserData.size == 0) {
+        vbUserData.size = (1320*1024);  /* 40KB * (queue_depth + report_queue_depth+1) = 40KB * (16 + 16 +1) */
+        vdi_allocate_dma_memory(ctx->testDecConfig.coreIdx, &vbUserData, DEC_ETC, ctx->handle->instIndex);
+    }
+    VPU_DecGiveCommand(ctx->handle, SET_ADDR_REP_USERDATA, (void*)&vbUserData.phys_addr);
+    VPU_DecGiveCommand(ctx->handle, SET_SIZE_REP_USERDATA, (void*)&vbUserData.size);
+    VPU_DecGiveCommand(ctx->handle, ENABLE_REP_USERDATA,   (void*)&ctx->testDecConfig.enableUserData);
+
+    VPU_DecGiveCommand(ctx->handle, SET_CYCLE_PER_TICK,   (void*)&ctx->cyclePerTick);
+    if (ctx->testDecConfig.thumbnailMode == TRUE) {
+        VPU_DecGiveCommand(ctx->handle, ENABLE_DEC_THUMBNAIL_MODE, NULL);
+    }
+
+
+    ctx->vbUserData = vbUserData;
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL DecodeHeader(ComponentImpl* com, PortContainerES* in, BOOL* done)
+{
+    DecoderContext*                ctx     = (DecoderContext*)com->context;
+    DecHandle                      handle  = ctx->handle;
+    Uint32                         coreIdx = ctx->testDecConfig.coreIdx;
+    RetCode                        ret     = RETCODE_SUCCESS;
+    DEC_INT_STATUS                 status;
+    DecInitialInfo*                initialInfo = &ctx->initialInfo;
+    SecAxiUse                      secAxiUse;
+    CNMComListenerDecCompleteSeq   lsnpCompleteSeq;
+    DecInfo*                       pDecInfo = VPU_HANDLE_TO_DECINFO(ctx->handle);
+
+    *done = FALSE;
+
+    if (BS_MODE_PIC_END == ctx->decOpenParam.bitstreamMode && NULL == in) {
+        return TRUE;
+    }
+
+    if (ctx->stateDoing == FALSE) {
+        /* previous state done */
+        ret = VPU_DecIssueSeqInit(handle);
+        if (RETCODE_QUEUEING_FAILURE == ret) {
+            return TRUE; // Try again
+        }
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_ISSUE_SEQ, NULL);
+        if (ret != RETCODE_SUCCESS) {
+            ChekcAndPrintDebugInfo(ctx->handle, FALSE, ret);
+            VLOG(ERR, "%s:%d Failed to VPU_DecIssueSeqInit() ret(%d)\n", __FUNCTION__, __LINE__, ret);
+            return FALSE;
+        }
+    }
+
+    ctx->stateDoing = TRUE;
+
+    while (com->terminate == FALSE) {
+        if ((status=HandlingInterruptFlag(com)) == DEC_INT_STATUS_DONE) {
+            break;
+        }
+        else if (status == DEC_INT_STATUS_TIMEOUT) {
+            HandleDecoderError(ctx->handle, 0, NULL);
+            VPU_DecUpdateBitstreamBuffer(handle, STREAM_END_SIZE);    /* To finish bitstream empty status */
+            VPU_SWReset(coreIdx, SW_RESET_SAFETY, handle);
+            VPU_DecUpdateBitstreamBuffer(handle, STREAM_END_CLEAR_FLAG);    /* To finish bitstream empty status */
+            return FALSE;
+        }
+        else if (status == DEC_INT_STATUS_EMPTY) {
+            return TRUE;
+        }
+        else if (status == DEC_INT_STATUS_NONE) {
+            return TRUE;
+        }
+        else {
+            VLOG(INFO, "%s:%d Unknown interrupt status: %d\n", __FUNCTION__, __LINE__, status);
+            return FALSE;
+        }
+    }
+
+    ret = VPU_DecCompleteSeqInit(handle, initialInfo);
+    if (pDecInfo->productCode == WAVE521C_DUAL_CODE) {
+        if ( initialInfo->lumaBitdepth == 8 && initialInfo->chromaBitdepth == 8) {
+            ctx->testDecConfig.mapType = COMPRESSED_FRAME_MAP_DUAL_CORE_8BIT;
+        }
+        else {
+            ctx->testDecConfig.mapType = COMPRESSED_FRAME_MAP_DUAL_CORE_10BIT;
+        }
+    }
+
+    strcpy(lsnpCompleteSeq.refYuvPath, ctx->testDecConfig.refYuvPath);
+    lsnpCompleteSeq.ret             = ret;
+    lsnpCompleteSeq.initialInfo     = initialInfo;
+    lsnpCompleteSeq.wtlFormat       = ctx->wtlFormat;
+    lsnpCompleteSeq.cbcrInterleave  = ctx->decOpenParam.cbcrInterleave;
+    lsnpCompleteSeq.bitstreamFormat = ctx->decOpenParam.bitstreamFormat;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_COMPLETE_SEQ, (void*)&lsnpCompleteSeq);
+
+    if (ret != RETCODE_SUCCESS) {
+        VLOG(ERR, "%s:%d FAILED TO DEC_PIC_HDR: ret(%d), SEQERR(%08x)\n", __FUNCTION__, __LINE__, ret, initialInfo->seqInitErrReason);
+        ChekcAndPrintDebugInfo(ctx->handle, FALSE, ret);
+        return FALSE;
+    }
+
+    if (ctx->decOpenParam.wtlEnable == TRUE) {
+        VPU_DecGiveCommand(ctx->handle, DEC_SET_WTL_FRAME_FORMAT, &ctx->wtlFormat);
+    }
+
+   /* Set up the secondary AXI is depending on H/W configuration.
+    * Note that turn off all the secondary AXI configuration
+    * if target ASIC has no memory only for IP, LF and BIT.
+    */
+    secAxiUse.u.wave.useIpEnable    = (ctx->testDecConfig.secondaryAXI&0x01) ? TRUE : FALSE;
+    secAxiUse.u.wave.useLfRowEnable = (ctx->testDecConfig.secondaryAXI&0x02) ? TRUE : FALSE;
+    secAxiUse.u.wave.useBitEnable   = (ctx->testDecConfig.secondaryAXI&0x04) ? TRUE : FALSE;
+    secAxiUse.u.wave.useSclEnable   = (ctx->testDecConfig.secondaryAXI&0x08) ? TRUE : FALSE;
+    VPU_DecGiveCommand(ctx->handle, SET_SEC_AXI, &secAxiUse);
+    // Set up scale
+    if (ctx->testDecConfig.scaleDownWidth > 0 || ctx->testDecConfig.scaleDownHeight > 0) {
+        ScalerInfo sclInfo = {0};
+
+        sclInfo.scaleWidth  = ctx->testDecConfig.scaleDownWidth;
+        sclInfo.scaleHeight = ctx->testDecConfig.scaleDownHeight;
+        VLOG(INFO, "[SCALE INFO] %dx%d\n", sclInfo.scaleWidth, sclInfo.scaleHeight);
+        sclInfo.enScaler    = TRUE;
+        if (VPU_DecGiveCommand(ctx->handle, DEC_SET_SCALER_INFO, (void*)&sclInfo) != RETCODE_SUCCESS) {
+            VLOG(ERR, "Failed to VPU_DecGiveCommand(DEC_SET_SCALER_INFO)\n");
+            return FALSE;
+        }
+    }
+
+    ctx->stateDoing = FALSE;
+    *done = TRUE;
+
+    return TRUE;
+}
+
+static BOOL ExecuteDecoder(ComponentImpl* com, PortContainer* in , PortContainer* out)
+{
+    DecoderContext* ctx    = (DecoderContext*)com->context;
+    BOOL            ret    = FALSE;;
+    BitStreamMode   bsMode = ctx->decOpenParam.bitstreamMode;
+    BOOL            done   = FALSE;
+
+    if (in)  in->reuse = TRUE;
+    if (out) out->reuse = TRUE;
+    if (ctx->state == DEC_STATE_INIT_SEQ || ctx->state == DEC_STATE_DECODING) {
+        if (UpdateBitstream(ctx, (PortContainerES*)in) == FALSE) {
+            return FALSE;
+        }
+        if (in) {
+            // In ring-buffer mode, it has to return back a container immediately.
+            if (bsMode == BS_MODE_PIC_END) {
+                if (ctx->state == DEC_STATE_INIT_SEQ) {
+                    in->reuse = TRUE;
+                }
+                in->consumed = FALSE;
+            }
+            else {
+                in->consumed = (in->reuse == FALSE);
+            }
+        }
+    }
+
+    if (ctx->doReset == TRUE) {
+        if (in) in->reuse = FALSE;
+        return DoReset(com);
+    }
+
+    switch (ctx->state) {
+    case DEC_STATE_OPEN_DECODER:
+        ret = OpenDecoder(com);
+        if (ctx->stateDoing == FALSE) ctx->state = DEC_STATE_INIT_SEQ;
+        break;
+    case DEC_STATE_INIT_SEQ:
+        ret = DecodeHeader(com, (PortContainerES*)in, &done);
+        if (TRUE == done) ctx->state = DEC_STATE_REGISTER_FB;
+        break;
+    case DEC_STATE_REGISTER_FB:
+        ret = RegisterFrameBuffers(com);
+        if (ctx->stateDoing == FALSE) {
+            ctx->state = DEC_STATE_DECODING;
+            DisplayDecodedInformation(ctx->handle, ctx->decOpenParam.bitstreamFormat, 0, NULL, ctx->testDecConfig.performance, 0);
+        }
+        break;
+    case DEC_STATE_DECODING:
+        ret = Decode(com, (PortContainerES*)in, (PortContainerDisplay*)out);
+        break;
+    default:
+        ret = FALSE;
+        break;
+    }
+
+    if (ret == FALSE || com->terminate == TRUE) {
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_DECODED_ALL, (void*)ctx->handle);
+        if (out) {
+            out->reuse = FALSE;
+            out->last  = TRUE;
+        }
+    }
+
+    return ret;
+}
+
+static BOOL PrepareDecoder(ComponentImpl* com, BOOL* done)
+{
+    *done = TRUE;
+
+    return TRUE;
+}
+
+static void ReleaseDecoder(ComponentImpl* com)
+{
+    // Nothing to do
+}
+
+static BOOL DestroyDecoder(ComponentImpl* com)
+{
+    DecoderContext* ctx         = (DecoderContext*)com->context;
+    DEC_INT_STATUS  intStatus;
+    BOOL            success     = TRUE;
+    Uint32          timeout     = 0;
+    Uint32          i           = 0;
+
+    if (NULL != ctx->handle) {
+        LoadBalancerRemoveInstance(ctx->handle->instIndex);
+        VPU_DecUpdateBitstreamBuffer(ctx->handle, STREAM_END_SET_FLAG);
+        while (VPU_DecClose(ctx->handle) == RETCODE_VPU_STILL_RUNNING) {
+            if ((intStatus=HandlingInterruptFlag(com)) == DEC_INT_STATUS_TIMEOUT) {
+                HandleDecoderError(ctx->handle, ctx->numDecoded, NULL);
+                VLOG(ERR, "<%s:%d> NO RESPONSE FROM VPU_DecClose()\n", __FUNCTION__, __LINE__);
+                success = FALSE;
+                break;
+            }
+            else if (intStatus == DEC_INT_STATUS_DONE) {
+                DecOutputInfo outputInfo;
+                VLOG(INFO, "VPU_DecClose() : CLEAR REMAIN INTERRUPT\n");
+                VPU_DecGetOutputInfo(ctx->handle, &outputInfo);
+                continue;
+            }
+
+            if (timeout > VPU_BUSY_CHECK_TIMEOUT) {
+                VLOG(ERR, "<%s:%d> Failed to VPU_DecClose\n", __FUNCTION__, __LINE__);
+            }
+
+            for (i=0; i<MAX_REG_FRAME; i++) {
+                VPU_DecClrDispFlag(ctx->handle, i);
+            }
+
+            timeout++;
+        }
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_CLOSE, NULL);
+    }
+
+    if (ctx->vbUserData.size) {
+        vdi_free_dma_memory(ctx->testDecConfig.coreIdx, &ctx->vbUserData, DEC_ETC, ctx->handle->instIndex);
+    }
+
+
+    VPU_DeInit(ctx->decOpenParam.coreIdx);
+
+    osal_free(ctx);
+
+    return success;
+}
+
+static Component CreateDecoder(ComponentImpl* com, CNMComponentConfig* componentParam)
+{
+    DecoderContext* ctx;
+    Uint32          coreIdx      = componentParam->testDecConfig.coreIdx;
+    Uint16*         firmware     = (Uint16*)componentParam->bitcode;
+    Uint32          firmwareSize = componentParam->sizeOfBitcode;
+    RetCode         retCode;
+
+    retCode = VPU_InitWithBitcode(coreIdx, firmware, firmwareSize);
+    if (retCode != RETCODE_SUCCESS && retCode != RETCODE_CALLED_BEFORE) {
+        VLOG(INFO, "%s:%d Failed to VPU_InitiWithBitcode, ret(%08x)\n", __FUNCTION__, __LINE__, retCode);
+        return FALSE;
+    }
+
+    com->context = (DecoderContext*)osal_malloc(sizeof(DecoderContext));
+    osal_memset(com->context, 0, sizeof(DecoderContext));
+    ctx = (DecoderContext*)com->context;
+
+    retCode = PrintVpuProductInfo(coreIdx, &ctx->attr);
+    if (retCode == RETCODE_VPU_RESPONSE_TIMEOUT ) {
+        CNMErrorSet(CNM_ERROR_HANGUP);
+        VLOG(INFO, "<%s:%d> Failed to PrintVpuProductInfo()\n", __FUNCTION__, __LINE__);
+        HandleDecoderError(ctx->handle, ctx->numDecoded, NULL);
+        return FALSE;
+    }
+    ctx->cyclePerTick = 32768;
+    if (TRUE == ctx->attr.supportNewTimer)
+        ctx->cyclePerTick = 256;
+
+    memcpy(&(ctx->decOpenParam), &(componentParam->decOpenParam), sizeof(DecOpenParam));
+
+    ctx->wtlFormat                    = componentParam->testDecConfig.wtlFormat;
+    ctx->frameNumToStop               = componentParam->testDecConfig.forceOutNum;
+    ctx->testDecConfig                = componentParam->testDecConfig;
+    ctx->state                        = DEC_STATE_OPEN_DECODER;
+    ctx->stateDoing                   = FALSE;
+    VLOG(INFO, "PRODUCT ID: %d\n", ctx->attr.productId);
+
+    return (Component)com;
+}
+
+ComponentImpl waveDecoderComponentImpl = {
+    "wave_decoder",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainerDisplay),
+    5,
+    CreateDecoder,
+    GetParameterDecoder,
+    SetParameterDecoder,
+    PrepareDecoder,
+    ExecuteDecoder,
+    ReleaseDecoder,
+    DestroyDecoder
+};
+

+ 422 - 0
soft_3rdpart/wave511/code/sample_v2/component_decoder/component_dec_feeder.c

@@ -0,0 +1,422 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include <time.h>
+#include "component.h"
+
+#define STREAM_BUF_SIZE_HEVC                (10*1024*1024)  // max bitstream size(HEVC:10MB,VP9:not specified)
+#define STREAM_BUF_SIZE_VP9                 (20*1024*1024)  // max bitstream size(HEVC:10MB,VP9:not specified)
+#define STREAM_BUF_SIZE                     0x700000
+#define FEEDING_SIZE                        0x20000
+
+typedef struct {
+    TestDecConfig   config;
+    vpu_buffer_t*   bsBuffer;
+    Uint32          numBuffers;
+    BSFeeder        feeder;
+    PhysicalAddress nextWrPtr;
+    Uint32          bsMargin;
+    Uint32          loopCount;
+    Uint32          dropCount;
+    DecHandle       handle;
+} FeederContext;
+
+static BOOL IsStartCode(Uint8* pData)
+{
+    // find 00 00 00 01
+    if (pData[0] == 0x00 && pData[1] == 0x00 && pData[2] == 0x00 && pData[3] == 0x01)
+        return TRUE;
+    else
+        return FALSE;
+}
+
+static BOOL FindSPSAndPPS(Uint8* pData, Uint32 size)
+{
+    Uint32 k;
+    Uint32 nalUnitType = 0;
+
+    for (k = 0; k < size; k += 4) {
+        if (IsStartCode((pData + k)) == TRUE) {
+            nalUnitType = (pData[k+4] >> 1) & 0x3F;
+            if (nalUnitType == 33 || nalUnitType == 34) {
+                VLOG(ERR, "Find SPS/PPS : %d\n", nalUnitType);
+                return TRUE;
+            }
+        }
+    }
+    return FALSE;
+}
+
+static void InjectErrorEvery188(BSFeeder bsf, void* data, Uint32 size, void* arg)
+{
+    Uint8*      pData = (Uint8*)data;
+    Uint8       val;
+    Uint32      pos;
+    Uint32      i, nchunk, blockSize;
+
+    UNREFERENCED_PARAMETER(bsf);
+
+    if (randomSeed == 0) {
+        randomSeed = (Uint32)time(NULL);
+        srand(randomSeed);
+        VLOG(INFO, "RANDOM SEED: %d\n", randomSeed);
+    }
+
+    if (size == 0) {
+        return;
+    }
+
+    blockSize = (size < 188) ? size : 188;
+
+    nchunk = (size + blockSize -1) / blockSize;
+    for (i=0; i<nchunk; i++) {
+        pos = GetRandom(0, blockSize-1);
+        pData = ((Uint8*)data + i*blockSize);
+        if (FindSPSAndPPS(pData, blockSize) == FALSE) {
+            /* size is 188 */
+            val = pData[pos];
+            val = ~val;
+            pData[pos] = val;
+            pos = (pos+1) % blockSize;
+        }
+        else {
+            // if find SPS or PPS, skip current chunk and next chunk.
+            i++;
+        }
+    }
+    //VLOG(TRACE, "CREATE ERROR BIT!!!\n");
+}
+
+static CNMComponentParamRet GetParameterFeeder(ComponentImpl* from, ComponentImpl* com, GetParameterCMD commandType, void* data)
+{
+    FeederContext*              ctx     = (FeederContext*)com->context;
+    ParamDecBitstreamBuffer*    bsBuf   = NULL;
+    PortContainer*              container;
+
+    switch(commandType) {
+    case GET_PARAM_COM_IS_CONTAINER_CONUSUMED:
+        // This query command is sent from the comonponent core.
+        // If input data are consumed in sequence, it should return TRUE through PortContainer::consumed.
+        container = (PortContainer*)data;
+        container->consumed = TRUE;
+        break;
+    case GET_PARAM_FEEDER_BITSTREAM_BUF:
+        if (ctx->bsBuffer == NULL) return CNM_COMPONENT_PARAM_NOT_READY;
+        bsBuf = (ParamDecBitstreamBuffer*)data;
+        bsBuf->num = ctx->numBuffers;
+        bsBuf->bs  = ctx->bsBuffer;
+        break;
+    case GET_PARAM_FEEDER_EOS:
+        if (ctx->feeder == NULL) return CNM_COMPONENT_PARAM_NOT_READY;
+        *(BOOL*)data = BitstreamFeeder_IsEos(ctx->feeder);
+        break;
+    default:
+        return CNM_COMPONENT_PARAM_NOT_FOUND;
+    }
+
+    return CNM_COMPONENT_PARAM_SUCCESS;
+}
+
+static CNMComponentParamRet SetParameterFeeder(ComponentImpl* from, ComponentImpl* com, SetParameterCMD commandType, void* data)
+{
+    CNMComponentParamRet ret = CNM_COMPONENT_PARAM_SUCCESS;
+    FeederContext*       ctx = (FeederContext*)com->context;
+
+    switch(commandType) {
+    case SET_PARAM_COM_PAUSE:
+        com->pause = *(BOOL*)data;
+        break;
+    case SET_PARAM_FEEDER_START_INJECT_ERROR:
+        BitstreamFeeder_SetHook(ctx->feeder, InjectErrorEvery188, NULL);
+        break;
+    case SET_PARAM_FEEDER_STOP_INJECT_ERROR:
+        BitstreamFeeder_SetHook(ctx->feeder, NULL, NULL);
+        break;
+    case SET_PARAM_FEEDER_RESET:
+        ctx->nextWrPtr = ctx->bsBuffer[0].phys_addr;
+        ctx->dropCount = 2;     /* Drop remaining error injected packets */
+        break;
+    default:
+        ret = CNM_COMPONENT_PARAM_NOT_FOUND;
+        break;
+    }
+
+    return ret;
+}
+
+static BOOL PrepareFeeder(ComponentImpl* com, BOOL *done)
+{
+    FeederContext*  ctx    = (FeederContext*)com->context;
+    TestDecConfig*  config = &ctx->config;
+    Uint32          i;
+    vpu_buffer_t*   bsBuffer;
+
+    bsBuffer = (vpu_buffer_t*)osal_malloc(com->numSinkPortQueue*sizeof(vpu_buffer_t));
+    for (i=0; i<ctx->numBuffers; i++) {
+        bsBuffer[i].size = config->bsSize;
+        if (vdi_allocate_dma_memory(config->coreIdx, &bsBuffer[i], DEC_BS, 0) < 0) {    // can't know instIdx now.
+            VLOG(ERR, "%s:%d fail to allocate bitstream buffer\n", __FUNCTION__, __LINE__);
+            return FALSE;
+        }
+    }
+
+    if (config->bitstreamMode == BS_MODE_INTERRUPT) {
+        ctx->nextWrPtr = bsBuffer[0].phys_addr;
+    }
+    else {
+        Queue* srcQ  = com->sinkPort.inputQ;
+        Queue* tempQ = Queue_Copy(NULL, srcQ);
+        PortContainerES* out;
+
+        // Flush all data.
+        Queue_Flush(srcQ);
+
+        for (i=0; i<ctx->numBuffers; i++) {
+            out = (PortContainerES*)Queue_Dequeue(tempQ);
+            out->buf = bsBuffer[i];
+            Queue_Enqueue(srcQ, (void*)out);
+        }
+        Queue_Destroy(tempQ);
+    }
+    ctx->bsBuffer = bsBuffer;
+    *done = TRUE;
+
+    return TRUE;
+}
+
+static BOOL ExecuteFeeder(ComponentImpl* com, PortContainer* in, PortContainer* out)
+{
+    FeederContext*          ctx       = (FeederContext*)com->context;
+    vpu_buffer_t*           bsBuffer  = ctx->bsBuffer;
+    BSFeeder                bsFeeder  = ctx->feeder;
+    TestDecConfig*          config    = &ctx->config;
+    PortContainerES*        container = (PortContainerES*)out;
+    PhysicalAddress         wrPtr;
+    Int32                   room;
+    BOOL                    eos         = FALSE;
+
+
+    if (com->pause) return TRUE;
+
+#ifdef USE_FEEDING_METHOD_BUFFER
+extern void BSFeederBuffer_SetData(
+    void*       feeder,
+    char*       address,
+    Uint32       size);
+extern void*  BitstreamFeeder_GetActualFeeder(void *feeder);
+extern void BSFeederBuffer_SetEos(void* feeder);
+extern BOOL BSFeederBuffer_GetEos(void* feeder);
+
+    void *actualFeeder = BitstreamFeeder_GetActualFeeder(bsFeeder);
+    PortContainerExternal *input = NULL;
+    if (BSFeederBuffer_GetEos(actualFeeder) == FALSE) {
+        input = (PortContainerExternal *)ComponentPortPeekData(&com->srcPort);
+        if (input == NULL) {
+            return TRUE;
+        }
+        BSFeederBuffer_SetData(actualFeeder, (char *)input->pBuffer, input->nFilledLen);
+        if ((input->nFlags & 0x1) == 0x1)
+        {
+            BSFeederBuffer_SetEos(actualFeeder);
+        }
+    } else {
+        BSFeederBuffer_SetData(actualFeeder, 0, 0);
+    }
+#endif
+
+    eos = BitstreamFeeder_IsEos(bsFeeder);
+
+    if (config->bitstreamMode == BS_MODE_PIC_END) {
+        bsBuffer = &container->buf;
+        wrPtr    = bsBuffer->phys_addr;
+        room     = bsBuffer->size;
+        container->size = BitstreamFeeder_Act(bsFeeder, bsBuffer, wrPtr, (Uint32)room, &ctx->nextWrPtr);
+#ifdef USE_FEEDING_METHOD_BUFFER
+        if (input != NULL) {
+            ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_EMPTY_BUFFER_DONE, (void *)input);
+            ComponentPortGetData(&com->srcPort);
+        }
+#endif
+    }
+    else {
+        ParamDecBitstreamBufPos bsPos;
+        BOOL                    success;
+        if (eos == FALSE) {
+            CNMComponentParamRet ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_DEC_BITSTREAM_BUF_POS, (void*)&bsPos);
+            if (ComponentParamReturnTest(ret, &success) == FALSE) {
+                if (success == FALSE) VLOG(ERR, "%s:%d return FALSE\n", __FUNCTION__, __LINE__);
+                return success;
+            }
+            bsBuffer = &bsBuffer[0];
+
+            wrPtr = (ctx->nextWrPtr > 0) ? ctx->nextWrPtr :  bsPos.wrPtr;
+
+            if (wrPtr >= bsPos.rdPtr) {
+                room  = (bsBuffer->phys_addr + bsBuffer->size) - wrPtr;
+                room += (bsPos.rdPtr - bsBuffer->phys_addr - 1) - ctx->bsMargin;
+            }
+            else {
+                room = bsPos.rdPtr - wrPtr - ctx->bsMargin - 1;
+            }
+            if (room < 0) room = 0;
+            container->size = BitstreamFeeder_Act(bsFeeder, bsBuffer, wrPtr, (Uint32)room, &ctx->nextWrPtr);
+            if (ctx->dropCount > 0) {
+                container->size = 0;
+                ctx->dropCount--;
+                ctx->nextWrPtr = wrPtr;
+            }
+#ifdef USE_FEEDING_METHOD_BUFFER
+            eos = BitstreamFeeder_IsEos(bsFeeder);
+            if (eos == TRUE) {
+                ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_EMPTY_BUFFER_DONE, (void *)input);
+                ComponentPortGetData(&com->srcPort);
+            }
+#endif
+        }
+        else {
+            if (ctx->loopCount > 0) {
+                eos = FALSE;
+                BitstreamFeeder_Rewind(bsFeeder);
+                ctx->loopCount--;
+            }
+            container->size = 0;
+        }
+    }
+
+    container->last  = (config->streamEndFlag == TRUE) ? TRUE : eos;
+    container->buf   = *bsBuffer;
+    container->reuse = (container->size == 0 && container->last == FALSE);
+
+    /* To stop sending an element stream.
+       A user will clear pause state when he gets the stream-end flag form the VPU */
+
+    com->pause = config->streamEndFlag;
+
+    return TRUE;
+}
+
+static void ReleaseFeeder(ComponentImpl* com)
+{
+    FeederContext* ctx    = (FeederContext*)com->context;
+    TestDecConfig* config = &ctx->config;
+    Uint32 i = 0;
+
+    if (NULL != ctx->bsBuffer) {
+        for (i = 0; i < ctx->numBuffers; i++) {
+            vdi_free_dma_memory(config->coreIdx, &ctx->bsBuffer[i], DEC_BS, 0);
+        }
+    }
+}
+
+static BOOL DestroyFeeder(ComponentImpl* com) {
+    FeederContext* ctx = (FeederContext*)com->context;
+
+    if (ctx->bsBuffer != NULL) osal_free(ctx->bsBuffer);
+
+    BitstreamFeeder_Destroy(ctx->feeder);
+
+    osal_free(ctx);
+
+    return TRUE;
+}
+
+static Component CreateFeeder(ComponentImpl* com, CNMComponentConfig* comConfig)
+{
+    FeederContext*  ctx;
+    BSFeeder        feeder;
+    TestDecConfig*  config;
+
+    com->context = osal_malloc(sizeof(FeederContext));
+    ctx = (FeederContext*)com->context;
+    osal_memset((void*)ctx, 0, sizeof(FeederContext));
+
+    config = &ctx->config;
+    osal_memcpy((void*)config, (void*)&comConfig->testDecConfig, sizeof(TestDecConfig));
+
+    if (PRODUCT_ID_W_SERIES(config->productId)) {
+        ctx->numBuffers = (config->bitstreamMode == BS_MODE_PIC_END) ? com->numSinkPortQueue: 1;
+    } else {
+        ctx->numBuffers = 1;
+    }
+
+    if (config->bsSize == 0) {
+        if(PRODUCT_ID_W_SERIES(config->productId)) {
+            config->bsSize = (config->bitFormat == STD_VP9) ? STREAM_BUF_SIZE_VP9 : STREAM_BUF_SIZE_HEVC;
+        } else {
+            config->bsSize = STREAM_BUF_SIZE;
+        }
+    }
+
+    ctx->bsMargin  = PRODUCT_ID_W_SERIES(config->productId) ? 0 : 2048; /* 2048 = GBU_SIZE x 2 */
+    ctx->loopCount = (config->loopCount > 0) ? (config->loopCount-1) : 0;
+
+    if (PRODUCT_ID_NOT_W_SERIES(config->productId)) {
+        if (BS_MODE_PIC_END == config->bitstreamMode || STD_THO == config->bitFormat) {
+            config->feedingMode = FEEDING_METHOD_FRAME_SIZE;
+        }
+    }
+
+    if ((feeder=BitstreamFeeder_Create(config->coreIdx, config->inputPath, config->bitFormat, config->feedingMode, config->streamEndian)) == NULL) {
+        return NULL;
+    }
+
+    BitstreamFeeder_SetFeedingSize(feeder, config->feedingSize);
+
+#ifdef SUPPORT_FFMPEG_DEMUX
+#endif /* SUPPORT_FFMPEG_DEMUX */
+    if (config->streamEndFlag == TRUE) {
+        BitstreamFeeder_SetFillMode(feeder, BSF_FILLING_RINGBUFFER_WITH_ENDFLAG);
+    }
+    else {
+        BitstreamFeeder_SetFillMode(feeder, (config->bitstreamMode == BS_MODE_PIC_END) ? BSF_FILLING_LINEBUFFER : BSF_FILLING_RINGBUFFER);
+    }
+
+    if (config->errorInject == TRUE) {
+        BitstreamFeeder_SetHook(feeder, InjectErrorEvery188, NULL);
+    }
+
+
+    ctx->feeder = feeder;
+
+    return (Component)com;
+}
+
+ComponentImpl feederComponentImpl = {
+    "feeder",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainerES),
+    5,
+    CreateFeeder,
+    GetParameterFeeder,
+    SetParameterFeeder,
+    PrepareFeeder,
+    ExecuteFeeder,
+    ReleaseFeeder,
+    DestroyFeeder
+};
+

+ 517 - 0
soft_3rdpart/wave511/code/sample_v2/component_decoder/component_dec_renderer.c

@@ -0,0 +1,517 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include "component.h"
+
+typedef struct {
+    DecHandle                   handle;                 /*!<< A decoder handle */
+    osal_thread_t               threadHandle;
+    TestDecConfig               testDecConfig;
+    Uint32                      framebufStride;
+    Uint32                      displayPeriodTime;
+    FrameBuffer                 pFrame[MAX_REG_FRAME];
+    vpu_buffer_t                pFbMem[MAX_REG_FRAME];
+    BOOL                        enablePPU;
+    FrameBuffer                 pPPUFrame[MAX_REG_FRAME];
+    vpu_buffer_t                pPPUFbMem[MAX_REG_FRAME];
+    Queue*                      ppuQ;
+    BOOL                        fbAllocated;
+    ParamDecNeedFrameBufferNum  fbCount;
+    Queue*                      seqMemQ;
+    osal_mutex_t                lock;
+    char                        outputPath[256];
+    FILE*                       fpOutput[OUTPUT_FP_NUMBER];
+} RendererContext;
+
+typedef struct SequenceMemInfo {
+    Uint32              nonLinearNum;
+    Uint32              linearNum;
+    Uint32              remainingCount;
+    Uint32              sequenceNo;
+    vpu_buffer_t        pFbMem[MAX_REG_FRAME];
+    vpu_buffer_t        vbFbcYTbl[MAX_REG_FRAME];
+    vpu_buffer_t        vbFbcCTbl[MAX_REG_FRAME];
+    vpu_buffer_t        vbTask;
+} SequenceMemInfo;
+
+static void FreeFrameBuffer(DecHandle handle, Uint32 idx, SequenceMemInfo* info)
+{
+    Int32 coreIdx = handle->coreIdx;
+    if (info->pFbMem[idx].size > 0) {
+        if (idx < info->nonLinearNum)
+            vdi_free_dma_memory(coreIdx, &info->pFbMem[idx], DEC_FBC, handle->instIndex);
+        else
+            vdi_free_dma_memory(coreIdx, &info->pFbMem[idx], DEC_FB_LINEAR, handle->instIndex);
+        osal_memset((void*)&info->pFbMem[idx], 0x00, sizeof(vpu_buffer_t));
+    }
+
+    if (info->vbFbcYTbl[idx].size > 0) {
+        vdi_free_dma_memory(coreIdx, &info->vbFbcYTbl[idx], DEC_FBCY_TBL, handle->instIndex);
+        osal_memset((void*)&info->vbFbcYTbl[idx], 0x00, sizeof(vpu_buffer_t));
+    }
+
+    if (info->vbFbcCTbl[idx].size > 0) {
+        vdi_free_dma_memory(coreIdx, &info->vbFbcCTbl[idx], DEC_FBCC_TBL, handle->instIndex);
+        osal_memset((void*)&info->vbFbcCTbl[idx], 0x00, sizeof(vpu_buffer_t));
+    }
+    if (info->vbTask.size > 0) {
+        vdi_free_dma_memory(coreIdx, &info->vbTask, DEC_TASK, handle->instIndex);
+        osal_memset((void*)&info->vbTask, 0x00, sizeof(vpu_buffer_t));
+    }
+}
+
+static BOOL SetParamFreeFrameBuffers(ComponentImpl* com, Uint32 fbFlags)
+{
+    RendererContext*    ctx          = (RendererContext*)com->context;
+    BOOL                remainingFbs[MAX_REG_FRAME] = {0};
+    Uint32              idx;
+    Uint32              fbIndex;
+    BOOL                wtlEnable    = ctx->testDecConfig.enableWTL;
+    DecGetFramebufInfo  curFbInfo;
+    Uint32              coreIdx      = ctx->testDecConfig.coreIdx;
+    SequenceMemInfo     seqMem       = {0};
+
+    osal_mutex_lock(ctx->lock);
+    VPU_DecGiveCommand(ctx->handle, DEC_GET_FRAMEBUF_INFO, (void*)&curFbInfo);
+
+    if (PRODUCT_ID_W_SERIES(ctx->testDecConfig.productId)) {
+        for (idx=0; idx<MAX_GDI_IDX; idx++) {
+            fbIndex = idx;
+            if ((fbFlags>>idx) & 0x01) {
+                if (wtlEnable == TRUE) {
+                    fbIndex = VPU_CONVERT_WTL_INDEX(ctx->handle, idx);
+                }
+                seqMem.remainingCount++;
+                remainingFbs[fbIndex] = TRUE;
+            }
+        }
+    }
+
+    seqMem.nonLinearNum = ctx->fbCount.nonLinearNum;
+    seqMem.linearNum    = ctx->fbCount.linearNum;
+    osal_memcpy((void*)seqMem.pFbMem,    ctx->pFbMem,         sizeof(ctx->pFbMem));
+    osal_memcpy((void*)seqMem.vbFbcYTbl, curFbInfo.vbFbcYTbl, sizeof(curFbInfo.vbFbcYTbl));
+    osal_memcpy((void*)seqMem.vbFbcCTbl, curFbInfo.vbFbcCTbl, sizeof(curFbInfo.vbFbcCTbl));
+    osal_memcpy((void*)&seqMem.vbTask,  &curFbInfo.vbTask,    sizeof(curFbInfo.vbTask));
+
+    for (idx=0; idx<MAX_REG_FRAME; idx++) {
+        if (remainingFbs[idx] == FALSE) {
+            FreeFrameBuffer(ctx->handle, idx, &seqMem);
+        }
+        // Free a mvcol buffer
+        if(curFbInfo.vbMvCol[idx].size > 0) {
+            vdi_free_dma_memory(coreIdx, &curFbInfo.vbMvCol[idx], DEC_MV, ctx->handle->instIndex);
+        }
+    }
+
+    if (seqMem.remainingCount > 0) {
+        Queue_Enqueue(ctx->seqMemQ, (void*)&seqMem);
+    }
+
+    ctx->fbAllocated = FALSE;
+    osal_mutex_unlock(ctx->lock);
+
+    return TRUE;
+}
+
+static BOOL ReallocateFrameBuffers(ComponentImpl* com, ParamDecReallocFB* param)
+{
+    RendererContext* ctx        = (RendererContext*)com->context;
+    Int32            fbcIndex    = param->compressedIdx;
+    Int32            linearIndex = param->linearIdx;
+    vpu_buffer_t*    pFbMem      = ctx->pFbMem;
+    FrameBuffer*     pFrame      = ctx->pFrame;
+    FrameBuffer*     newFbs      = param->newFbs;
+
+    if (fbcIndex >= 0) {
+        /* Release the FBC framebuffer */
+        vdi_free_dma_memory(ctx->testDecConfig.coreIdx, &pFbMem[fbcIndex], DEC_FBC, ctx->handle->instIndex);
+        osal_memset((void*)&pFbMem[fbcIndex], 0x00, sizeof(vpu_buffer_t));
+    }
+
+    if (linearIndex >= 0) {
+        /* Release the linear framebuffer */
+        vdi_free_dma_memory(ctx->testDecConfig.coreIdx, &pFbMem[linearIndex], DEC_FB_LINEAR, ctx->handle->instIndex);
+        osal_memset((void*)&pFbMem[linearIndex], 0x00, sizeof(vpu_buffer_t));
+    }
+
+    if (fbcIndex >= 0) {
+        newFbs[0].myIndex = fbcIndex;
+        newFbs[0].width   = param->width;
+        newFbs[0].height  = param->height;
+        pFrame[fbcIndex]  = newFbs[0];
+    }
+
+    if (linearIndex >= 0) {
+        newFbs[1].myIndex = linearIndex;
+        newFbs[1].width   = param->width;
+        newFbs[1].height  = param->height;
+        pFrame[linearIndex]  = newFbs[1];
+    }
+
+    return TRUE;
+}
+
+static void DisplayFrame(RendererContext* ctx, DecOutputInfo* result)
+{
+    Int32 productID = ctx->testDecConfig.productId;
+
+    osal_mutex_lock(ctx->lock);
+
+    if (result->indexFrameDisplay >= 0) {
+        DecInitialInfo  initialInfo;
+        VPU_DecGiveCommand(ctx->handle, DEC_GET_SEQ_INFO, &initialInfo);
+        // No renderer device
+        if (PRODUCT_ID_W_SERIES(productID) && initialInfo.sequenceNo != result->sequenceNo) {
+            // Free a framebuffer of previous sequence
+            SequenceMemInfo* memInfo = Queue_Peek(ctx->seqMemQ);
+            if (memInfo != NULL) {
+                FreeFrameBuffer(ctx->handle, result->indexFrameDisplay, memInfo);
+                if (memInfo->remainingCount == 0) {
+                    VLOG(ERR, "%s:%d remainingCout must be greater than zero\n", __FUNCTION__, __LINE__);
+                }
+                memInfo->remainingCount--;
+                if (memInfo->remainingCount == 0) {
+                    Queue_Dequeue(ctx->seqMemQ);
+                }
+            }
+        }
+        else {
+            VPU_DecClrDispFlag(ctx->handle, result->indexFrameDisplay);
+        }
+    }
+    osal_mutex_unlock(ctx->lock);
+}
+
+static BOOL FlushFrameBuffers(ComponentImpl* com, Uint32* flushedIndexes)
+{
+    PortContainerDisplay*   srcData;
+    RendererContext*        ctx = (RendererContext*)com->context;
+    Int32                   idx = 0;
+
+    osal_mutex_lock(ctx->lock);
+    if (flushedIndexes) *flushedIndexes = 0;
+    while ((srcData=(PortContainerDisplay*)ComponentPortGetData(&com->srcPort)) != NULL) {
+        idx = srcData->decInfo.indexFrameDisplay;
+        if (0 <= idx) {
+            VPU_DecClrDispFlag(ctx->handle, idx);
+            if (flushedIndexes) *flushedIndexes |= (1<<idx);
+        }
+        ComponentPortSetData(&com->srcPort, (PortContainer*)srcData);
+    }
+    osal_mutex_unlock(ctx->lock);
+
+    return TRUE;
+}
+static BOOL AllocateFrameBuffer(ComponentImpl* com)
+{
+    RendererContext*     ctx            = (RendererContext*)com->context;
+    BOOL                 success;
+    Uint32               compressedNum;
+    Uint32               linearNum;
+    CNMComponentParamRet ret;
+
+    ret = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_DEC_FRAME_BUF_NUM, &ctx->fbCount);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) {
+        return success;
+    }
+
+    osal_memset((void*)ctx->pFbMem, 0x00, sizeof(ctx->pFbMem));
+    osal_memset((void*)ctx->pFrame, 0x00, sizeof(ctx->pFrame));
+
+    compressedNum  = ctx->fbCount.nonLinearNum;
+    linearNum      = ctx->fbCount.linearNum;
+
+    if (compressedNum == 0 && linearNum == 0) {
+        VLOG(ERR, "%s:%d The number of framebuffers are zero. compressed %d, linear: %d\n",
+            __FUNCTION__, __LINE__, compressedNum, linearNum);
+        return FALSE;
+    }
+
+    if (AllocateDecFrameBuffer(ctx->handle, &ctx->testDecConfig, compressedNum, linearNum, ctx->pFrame, ctx->pFbMem, &ctx->framebufStride) == FALSE) {
+        VLOG(INFO, "%s:%d Failed to AllocateDecFrameBuffer()\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+    ctx->fbAllocated = TRUE;
+
+    return TRUE;
+}
+
+static BOOL AllocatePPUFrameBuffer(ComponentImpl* com)
+{
+    RendererContext*        ctx = (RendererContext*)com->context;
+    TestDecConfig*          decConfig = &(ctx->testDecConfig);
+    BOOL                    resOf = FALSE;
+
+    osal_memset((void*)ctx->pPPUFbMem, 0x00, sizeof(ctx->pPPUFbMem));
+    osal_memset((void*)ctx->pPPUFrame, 0x00, sizeof(ctx->pPPUFrame));
+
+    if(PRODUCT_ID_960 == decConfig->productId || PRODUCT_ID_980 == decConfig->productId) {
+        if (FALSE == Coda9AllocateDecPPUFrameBuffer(&(ctx->enablePPU), ctx->handle, &ctx->testDecConfig, ctx->pPPUFrame, ctx->pPPUFbMem, ctx->ppuQ)) {
+            VLOG(INFO, "%s:%d Failed to Coda9AllocateDecPPUFrameBuffer()\n", __FUNCTION__, __LINE__);
+        }
+        resOf = TRUE;
+    }
+
+    return resOf;
+}
+
+static CNMComponentParamRet GetParameterRenderer(ComponentImpl* from, ComponentImpl* com, GetParameterCMD commandType, void* data)
+{
+    RendererContext*        ctx     = (RendererContext*)com->context;
+    ParamDecFrameBuffer*    allocFb = NULL;
+    ParamDecPPUFrameBuffer* allocPPUFb = NULL;
+    PortContainer*         container;
+
+    if (ctx->fbAllocated == FALSE) return CNM_COMPONENT_PARAM_NOT_READY;
+
+    switch(commandType) {
+    case GET_PARAM_COM_IS_CONTAINER_CONUSUMED:
+        // This query command is sent from the comonponent core.
+        // If input data are consumed in sequence, it should return TRUE through PortContainer::consumed.
+        container = (PortContainer*)data;
+        container->consumed = TRUE;
+        break;
+    case GET_PARAM_RENDERER_FRAME_BUF:
+        allocFb = (ParamDecFrameBuffer*)data;
+        allocFb->stride        = ctx->framebufStride;
+        allocFb->linearNum     = ctx->fbCount.linearNum;
+        allocFb->nonLinearNum   = ctx->fbCount.nonLinearNum;
+        allocFb->fb            = ctx->pFrame;
+        break;
+    case GET_PARAM_RENDERER_PPU_FRAME_BUF:
+        allocPPUFb = (ParamDecPPUFrameBuffer*)data;
+        if (TRUE == AllocatePPUFrameBuffer(com)) {
+            allocPPUFb->enablePPU   = ctx->enablePPU;
+            allocPPUFb->ppuQ        = ctx->ppuQ;
+            allocPPUFb->fb          = ctx->pPPUFrame;
+        }
+        else {
+            allocPPUFb->enablePPU   = FALSE;
+            allocPPUFb->ppuQ        = NULL;
+            allocPPUFb->fb          = NULL;
+        }
+        break;
+    default:
+        return CNM_COMPONENT_PARAM_NOT_FOUND;
+    }
+
+    return CNM_COMPONENT_PARAM_SUCCESS;
+}
+
+static CNMComponentParamRet SetParameterRenderer(ComponentImpl* from, ComponentImpl* com, SetParameterCMD commandType, void* data)
+{
+    RendererContext*    ctx    = (RendererContext*)com->context;
+    BOOL                result = TRUE;
+
+    UNREFERENCED_PARAMETER(ctx);
+    switch(commandType) {
+    case SET_PARAM_RENDERER_REALLOC_FRAMEBUFFER:
+        result = ReallocateFrameBuffers(com, (ParamDecReallocFB*)data);
+        break;
+    case SET_PARAM_RENDERER_FREE_FRAMEBUFFERS:
+        result = SetParamFreeFrameBuffers(com, *(Uint32*)data);
+        break;
+    case SET_PARAM_RENDERER_FLUSH:
+        result = FlushFrameBuffers(com, (Uint32*)data);
+        break;
+    case SET_PARAM_RENDERER_ALLOC_FRAMEBUFFERS:
+        result = AllocateFrameBuffer(com);
+        break;
+    case SET_PARAM_RENDERER_CHANGE_COM_STATE:
+        result = ComponentChangeState(com, *(Uint32*)data);
+        break;
+    default:
+        return CNM_COMPONENT_PARAM_NOT_FOUND;
+    }
+
+    if (result == TRUE) return CNM_COMPONENT_PARAM_SUCCESS;
+    else                return CNM_COMPONENT_PARAM_FAILURE;
+}
+
+
+
+static BOOL ExecuteRenderer(ComponentImpl* com, PortContainer* in, PortContainer* out)
+{
+    RendererContext*        ctx               = (RendererContext*)com->context;
+    PortContainerDisplay*   srcData           = (PortContainerDisplay*)in;
+    Int32                   indexFrameDisplay;
+    TestDecConfig*          decConfig         = &ctx->testDecConfig;
+
+    if (TRUE == com->pause) {
+        return TRUE;
+    }
+#ifdef USE_FEEDING_METHOD_BUFFER
+    PortContainerExternal *output = (PortContainerExternal*)ComponentPortPeekData(&com->sinkPort);
+    if (output == NULL) {
+        return TRUE;
+    }
+#endif
+    in->reuse = TRUE;
+
+    indexFrameDisplay = srcData->decInfo.indexFrameDisplay;
+
+    if (indexFrameDisplay == DISPLAY_IDX_FLAG_SEQ_END) {
+        com->terminate = TRUE;
+    }
+    else if (indexFrameDisplay >= 0) {
+        VpuRect      rcDisplay  = {0,};
+        TiledMapType mapType    = srcData->decInfo.dispFrame.mapType;
+
+        rcDisplay.right  = srcData->decInfo.dispPicWidth;
+        rcDisplay.bottom = srcData->decInfo.dispPicHeight;
+
+#ifdef USE_FEEDING_METHOD_BUFFER
+        Uint32 width, height, bpp;
+        size_t sizeYuv;
+        (void)decConfig;
+        if (FALSE ==GetYUVFromFrameBuffer2(output->pBuffer, output->nFilledLen, ctx->handle, &srcData->decInfo.dispFrame, rcDisplay, &width, &height, &bpp, &sizeYuv)) {
+            VLOG(ERR, "GetYUVFromFrameBuffer2 FAIL!\n");
+        }
+        (void)mapType;
+        output->nFilledLen = sizeYuv;
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_FILL_BUFFER_DONE, (void *)output);
+        ComponentPortGetData(&com->sinkPort);
+#else
+        if (decConfig->scaleDownWidth > 0 || decConfig->scaleDownHeight > 0) {
+            rcDisplay.right  = VPU_CEIL(srcData->decInfo.dispPicWidth, 16);
+        }
+
+        if (strlen((const char*)decConfig->outputPath) > 0) {
+            if (ctx->fpOutput[0] == NULL) {
+                if (OpenDisplayBufferFile(decConfig->bitFormat, decConfig->outputPath, rcDisplay, mapType, ctx->fpOutput) == FALSE) {
+                    return FALSE;
+                }
+            }
+            SaveDisplayBufferToFile(ctx->handle, decConfig->bitFormat, srcData->decInfo.dispFrame, rcDisplay, ctx->fpOutput);
+        }
+#endif
+        DisplayFrame(ctx, &srcData->decInfo);
+        //osal_msleep(ctx->displayPeriodTime);
+    }
+
+    srcData->consumed = TRUE;
+    srcData->reuse    = FALSE;
+
+    if (srcData->last == TRUE) {
+        com->terminate = TRUE;
+    }
+
+    return TRUE;
+}
+
+static BOOL PrepareRenderer(ComponentImpl* com, BOOL* done)
+{
+    RendererContext* ctx = (RendererContext*)com->context;
+    BOOL             ret;
+
+    if (ctx->handle == NULL) {
+        CNMComponentParamRet paramRet;
+        BOOL                 success;
+        paramRet = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_DEC_HANDLE, &ctx->handle);
+        if (ComponentParamReturnTest(paramRet, &success) == FALSE) {
+            return success;
+        }
+    }
+
+    if ((ret=AllocateFrameBuffer(com)) == FALSE || ctx->fbAllocated == FALSE) {
+        return ret;
+    }
+    // Nothing to do
+    *done = TRUE;
+    return TRUE;
+}
+
+static void ReleaseRenderer(ComponentImpl* com)
+{
+    RendererContext* ctx = (RendererContext*)com->context;
+    Uint32           coreIdx = ctx->testDecConfig.coreIdx;
+    Uint32           i;
+
+    for (i=0; i<MAX_REG_FRAME; i++) {
+        if (ctx->pFbMem[i].size) {
+            if (i < ctx->fbCount.linearNum)
+                vdi_free_dma_memory(coreIdx, &ctx->pFbMem[i], DEC_FBC, ctx->handle->instIndex);
+            else
+                vdi_free_dma_memory(coreIdx, &ctx->pFbMem[i], DEC_FB_LINEAR, ctx->handle->instIndex);
+        }
+    }
+
+    for (i=0; i<MAX_REG_FRAME; i++) {
+        if (ctx->pPPUFrame[i].size) vdi_free_dma_memory(coreIdx, &ctx->pPPUFbMem[i], DEC_ETC, ctx->handle->instIndex);
+    }
+}
+
+static BOOL DestroyRenderer(ComponentImpl* com)
+{
+    RendererContext* ctx = (RendererContext*)com->context;
+
+    CloseDisplayBufferFile(ctx->fpOutput);
+    Queue_Destroy(ctx->seqMemQ);
+    Queue_Destroy(ctx->ppuQ);
+    osal_mutex_destroy(ctx->lock);
+    osal_free(ctx);
+
+    return TRUE;
+}
+
+static Component CreateRenderer(ComponentImpl* com, CNMComponentConfig* componentParam)
+{
+    RendererContext*    ctx;
+
+    com->context = (RendererContext*)osal_malloc(sizeof(RendererContext));
+    osal_memset(com->context, 0, sizeof(RendererContext));
+    ctx = com->context;
+
+    osal_memcpy((void*)&ctx->testDecConfig, (void*)&componentParam->testDecConfig, sizeof(TestDecConfig));
+    if (componentParam->testDecConfig.fps > 0)
+        ctx->displayPeriodTime = (1000 / componentParam->testDecConfig.fps);
+    else
+        ctx->displayPeriodTime = 1000/30;
+    ctx->fbAllocated       = FALSE;
+    ctx->seqMemQ           = Queue_Create(10, sizeof(SequenceMemInfo));
+    ctx->lock              = osal_mutex_create();
+    ctx->ppuQ              = Queue_Create(MAX_REG_FRAME, sizeof(FrameBuffer));
+
+    return (Component)com;
+}
+
+ComponentImpl rendererComponentImpl = {
+    "renderer",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainer),     /* No output */
+    5,
+    CreateRenderer,
+    GetParameterRenderer,
+    SetParameterRenderer,
+    PrepareRenderer,
+    ExecuteRenderer,
+    ReleaseRenderer,
+    DestroyRenderer
+};
+

+ 552 - 0
soft_3rdpart/wave511/code/sample_v2/component_decoder/decoder_listener.c

@@ -0,0 +1,552 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "cnm_app.h"
+#include "decoder_listener.h"
+#include "misc/debug.h"
+#include "misc/bw_monitor.h"
+
+static BOOL IsDifferentResolution(DecGetFramebufInfo* fbInfo, FrameBuffer* srcFb)
+{
+    FrameBuffer* dstFb = &fbInfo->framebufPool[srcFb->myIndex];
+
+    return (dstFb->width != srcFb->width || dstFb->height != srcFb->height);
+}
+
+static void PrintH265UserData(Uint8* pBase, Uint32 iFlags, vpu_buffer_t* vb)
+{
+    user_data_entry_t*  pEntry = NULL;
+    user_data_entry_t*  item   = NULL;
+
+    pEntry = (user_data_entry_t*)pBase;
+    if (iFlags & (1<<H265_USERDATA_FLAG_VUI)) {
+        h265_vui_param_t*  vui = (h265_vui_param_t*)(pBase + pEntry[H265_USERDATA_FLAG_VUI].offset);
+        VLOG(INFO, "[VUI]\n");
+        VLOG(INFO, "vui::aspect_ratio_idc              > %d\n", vui->aspect_ratio_idc);
+        VLOG(INFO, "vui::video_signal_type_present_flag> %d\n", vui->video_signal_type_present_flag);
+        VLOG(INFO, "vui::video_format                  > %d\n", vui->video_format);
+        VLOG(INFO, "vui::vui_timing_info_present_flag  > %d\n", vui->vui_timing_info_present_flag);
+        VLOG(INFO, "vui::vui_num_units_in_tick         > %d\n", vui->vui_num_units_in_tick);
+        VLOG(INFO, "vui::vui_time_scale                > %d\n", vui->vui_time_scale);
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_PIC_TIMING)) {
+        h265_sei_pic_timing_t* picTiming = (h265_sei_pic_timing_t*)(pBase + pEntry[H265_USERDATA_FLAG_PIC_TIMING].offset);
+        VLOG(INFO, "[SEI::PIC_TIMING]\n");
+        VLOG(INFO, "sei::pic_timing::pic_struct        > %d\n", picTiming->pic_struct);
+        VLOG(INFO, "sei::pic_timing::source_scan_type  > %d\n", picTiming->source_scan_type);
+        VLOG(INFO, "sei::pic_timing::duplicate_flag    > %d\n", picTiming->duplicate_flag);
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_MASTERING_COLOR_VOL)) {
+        h265_mastering_display_colour_volume_t* mastering;
+        mastering = (h265_mastering_display_colour_volume_t*)(pBase + pEntry[H265_USERDATA_FLAG_MASTERING_COLOR_VOL].offset);
+        VLOG(INFO, "[SEI::MASTERING DISPLAY COLOR VOLUME]\n");
+        VLOG(INFO, "sei::mastering_display_colour_volume::display_primaries_x[0]          > %d\n", mastering->display_primaries_x[0]);
+        VLOG(INFO, "sei::mastering_display_colour_volume::display_primaries_y[0]          > %d\n", mastering->display_primaries_y[0]);
+        VLOG(INFO, "sei::mastering_display_colour_volume::display_primaries_x[1]          > %d\n", mastering->display_primaries_x[1]);
+        VLOG(INFO, "sei::mastering_display_colour_volume::display_primaries_y[1]          > %d\n", mastering->display_primaries_y[1]);
+        VLOG(INFO, "sei::mastering_display_colour_volume::display_primaries_x[2]          > %d\n", mastering->display_primaries_x[2]);
+        VLOG(INFO, "sei::mastering_display_colour_volume::display_primaries_y[2]          > %d\n", mastering->display_primaries_y[2]);
+        VLOG(INFO, "sei::mastering_display_colour_volume::white_point_x                   > %d\n", mastering->white_point_x);
+        VLOG(INFO, "sei::mastering_display_colour_volume::white_point_y                   > %d\n", mastering->white_point_y);
+        VLOG(INFO, "sei::mastering_display_colour_volume::max_display_mastering_luminance > %d%s\n", mastering->max_display_mastering_luminance);
+        VLOG(INFO, "sei::mastering_display_colour_volume::min_display_mastering_luminance > %d %s\n", mastering->min_display_mastering_luminance);
+    }
+    if (iFlags & (1<<H265_USERDATA_FLAG_ITU_T_T35_PRE)) {
+        Uint8* pData    = NULL;
+        item  = &pEntry[H265_USERDATA_FLAG_ITU_T_T35_PRE];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H265::SEI::USER_DATA_REGISTERED_ITU_T_T35 (PREFIX)]\n");
+        DisplayHex(pData, item->size, "H265 ITU-T-T35");
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_ITU_T_T35_PRE_1)) {
+        Uint8* pData    = NULL;
+        item  = &pEntry[H265_USERDATA_FLAG_ITU_T_T35_PRE_1];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H265::SEI::USER_DATA_REGISTERED_ITU_T_T35 (PREFIX1)]\n");
+        DisplayHex(pData, item->size, "H265 ITU-T-T35");
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_ITU_T_T35_PRE_2)) {
+        Uint8* pData    = NULL;
+        item  = &pEntry[H265_USERDATA_FLAG_ITU_T_T35_PRE_2];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H265::SEI::USER_DATA_REGISTERED_ITU_T_T35 (PREFIX2)]\n");
+        DisplayHex(pData, item->size, "H265 ITU-T-T35");
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_ITU_T_T35_SUF)) {
+        Uint8* pData        = NULL;
+        item  = &pEntry[H265_USERDATA_FLAG_ITU_T_T35_SUF];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H265::SEI::USER_DATA_REGISTERED_ITU_T_T35 (SUFFIX)]\n");
+        DisplayHex(pData, item->size, "H265 ITU-T-T35");
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_ITU_T_T35_SUF_1)) {
+        Uint8* pData    = NULL;
+        item  = &pEntry[H265_USERDATA_FLAG_ITU_T_T35_SUF_1];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H265::SEI::USER_DATA_REGISTERED_ITU_T_T35 (SUFFIX 1)]\n");
+        DisplayHex(pData, item->size, "H265 ITU-T-T35");
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_ITU_T_T35_SUF_2)) {
+        Uint8* pData    = NULL;
+        item  = &pEntry[H265_USERDATA_FLAG_ITU_T_T35_SUF_2];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H265::SEI::USER_DATA_REGISTERED_ITU_T_T35 (SUFFIX 2)]\n");
+        DisplayHex(pData, item->size, "H265 ITU-T-T35");
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_UNREGISTERED_PRE)) {
+        Uint8* pData = NULL;
+        item  = &pEntry[H265_USERDATA_FLAG_UNREGISTERED_PRE];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H265::SEI::USER_DATA_UNREGISTERED (PREFIX)]\n");
+        DisplayHex(pData, item->size, "H265 ITU-T-T35");
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_CHROMA_RESAMPLING_FILTER_HINT)) {
+        h265_chroma_resampling_filter_hint_t* pData = (h265_chroma_resampling_filter_hint_t*)(pBase + pEntry[H265_USERDATA_FLAG_CHROMA_RESAMPLING_FILTER_HINT].offset);
+
+        VLOG(INFO, "[H265::SEI::CHROMA_RESAMPLING_FILTER_HINT]\n");
+        VLOG(INFO, "sei::chroma_resampling_filter_hint::ver_chroma_filter_idc               > %d\n", pData->ver_chroma_filter_idc);
+        VLOG(INFO, "sei::chroma_resampling_filter_hint::hor_chroma_filter_idc               > %d\n", pData->hor_chroma_filter_idc);
+        VLOG(INFO, "sei::chroma_resampling_filter_hint::ver_filtering_filed_processing_flag > %d\n", pData->ver_filtering_field_processing_flag);
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_KNEE_FUNCTION_INFO)) {
+        h265_knee_function_info_t* pData = (h265_knee_function_info_t*)(pBase + pEntry[H265_USERDATA_FLAG_KNEE_FUNCTION_INFO].offset);
+        VLOG(INFO, "[H265::SEI::KNEE_FUNCTION_INFO]\n");
+        VLOG(INFO, "sei::knee_function_info::knee_function_id          > %d\n", pData->knee_function_id);
+        VLOG(INFO, "sei::knee_function_info::knee_function_cancel_flag > %d\n", pData->knee_function_cancel_flag);
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_UNREGISTERED_SUF)) {
+        Uint8* pData = NULL;
+        item  = &pEntry[H265_USERDATA_FLAG_UNREGISTERED_SUF];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[SEI::USER_DATA_UNREGISTERED (PREFIX OR SUFFIX)]\n");
+        DisplayHex(pData, item->size, "H265 USERDATA_UNREGISTERED");
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_CONTENT_LIGHT_LEVEL_INFO)) {
+        h265_content_light_level_info_t* pData = (h265_content_light_level_info_t*)(pBase + pEntry[H265_USERDATA_FLAG_CONTENT_LIGHT_LEVEL_INFO].offset);
+        VLOG(INFO, "[SEI::CONTENT_LIGHT_LEVEL_INFO(PREFIX)]\n");
+        VLOG(INFO, "sei::content_light_level_info::max_content_light_level     > %04x\n", pData->max_content_light_level);
+        VLOG(INFO, "sei::content_light_level_info::max_pic_average_light_level > %04x\n", pData->max_pic_average_light_level);
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_FILM_GRAIN_CHARACTERISTICS_INFO)) {
+        h265_film_grain_characteristics_t* pData = (h265_film_grain_characteristics_t*)(pBase + pEntry[H265_USERDATA_FLAG_FILM_GRAIN_CHARACTERISTICS_INFO].offset);
+        VLOG(INFO, "[SEI::FILM_GRAIN_CHARACTERISTICS_INFO(REFIX)]\n");
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_characteristics_cancel_flag   > %04x\n", pData->film_grain_characteristics_cancel_flag);
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_model_id                      > %04x\n", pData->film_grain_model_id);
+        VLOG(INFO, "sei::film_grain_characteristics_info::separate_colour_description_present_flag > %04x\n", pData->separate_colour_description_present_flag);
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_bit_depth_luma_minus8         > %04x\n", pData->film_grain_bit_depth_luma_minus8);
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_bit_depth_chroma_minus8       > %04x\n", pData->film_grain_bit_depth_chroma_minus8);
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_full_range_flag               > %04x\n", pData->film_grain_full_range_flag);
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_colour_primaries              > %04x\n", pData->film_grain_colour_primaries);
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_transfer_characteristics      > %04x\n", pData->film_grain_transfer_characteristics);
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_matrix_coeffs                 > %04x\n", pData->film_grain_matrix_coeffs);
+        VLOG(INFO, "sei::film_grain_characteristics_info::blending_model_id                        > %04x\n", pData->blending_mode_id);
+        VLOG(INFO, "sei::film_grain_characteristics_info::log2_scale_factor                        > %04x\n", pData->log2_scale_factor);
+        VLOG(INFO, "sei::film_grain_characteristics_info::comp_model_present_flag[0]               > %04x\n", pData->comp_model_present_flag[0]);
+        VLOG(INFO, "sei::film_grain_characteristics_info::comp_model_present_flag[1]               > %04x\n", pData->comp_model_present_flag[1]);
+        VLOG(INFO, "sei::film_grain_characteristics_info::comp_model_present_flag[2]               > %04x\n", pData->comp_model_present_flag[2]);
+        VLOG(INFO, "sei::film_grain_characteristics_info::film_grain_characterics_persistence_flag > %04x\n", pData->film_grain_characteristics_persistence_flag);
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_TONE_MAPPING_INFO)) {
+        h265_tone_mapping_info_t* pData = (h265_tone_mapping_info_t*)(pBase + pEntry[H265_USERDATA_FLAG_TONE_MAPPING_INFO].offset);
+        VLOG(INFO, "sei::tone_mapping_info::tone_map_id          > %04x\n", pData->tone_map_id);
+        VLOG(INFO, "sei::tone_mapping_info::tone_map_cancel_flag > %04x\n", pData->tone_map_cancel_flag);
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_COLOUR_REMAPPING_INFO)) {
+        h265_colour_remapping_info_t* pData = (h265_colour_remapping_info_t*)(pBase + pEntry[H265_USERDATA_FLAG_COLOUR_REMAPPING_INFO].offset);
+        VLOG(INFO, "sei::tone_mapping_info::colour_remap_id          > %04x\n", pData->colour_remap_id);
+        VLOG(INFO, "sei::tone_mapping_info::colour_rempa_cancel_flag > %04x\n", pData->colour_remap_cancel_flag);
+    }
+
+    return;
+}
+
+static void PrintH264UserData(Uint8* pBase, Uint32 iFlags, vpu_buffer_t* vb)
+{
+    user_data_entry_t*  pEntry = NULL;
+    user_data_entry_t*  item   = NULL;
+
+    pEntry = (user_data_entry_t*)pBase;
+    if (iFlags & (1UL<<H264_USERDATA_FLAG_VUI)) {
+        avc_vui_info_t*  vui = (avc_vui_info_t*)(pBase + pEntry[H265_USERDATA_FLAG_VUI].offset);
+        VLOG(INFO, "[VUI]\n");
+        VLOG(INFO, "vui::aspect_ration_info_present_flag > %d\n", vui->aspect_ratio_info_present_flag);
+        VLOG(INFO, "vui::aspect_ratio_idc                > %d\n", vui->aspect_ratio_idc);
+        VLOG(INFO, "vui::overscan_info_present_flag      > %d\n", vui->overscan_info_present_flag);
+        VLOG(INFO, "vui::video_signal_type_present_flag  > %d\n", vui->video_signal_type_present_flag);
+        VLOG(INFO, "vui::vui_timing_info_present_flag    > %d\n", vui->vui_timing_info_present_flag);
+        VLOG(INFO, "vui::vui_num_units_in_tick           > %d\n", vui->vui_num_units_in_tick);
+        VLOG(INFO, "vui::vui_time_scale                  > %d\n", vui->vui_time_scale);
+        VLOG(INFO, "vui::nal_hrd_parmeters_present_flag  > %d\n", vui->nal_hrd_parameters_present_flag);
+        VLOG(INFO, "vui::cpb_cnt                         > %d\n", vui->nal_hrd.cpb_cnt);
+        VLOG(INFO, "vui::bit_rate_value                  > %d\n", vui->nal_hrd.bit_rate_value[0]);
+        VLOG(INFO, "vui::cpb_size_value                  > %d\n", vui->nal_hrd.cpb_size_value[0]);
+        VLOG(INFO, "vui::initial_cpb_removal_delay_length> %d\n", vui->nal_hrd.initial_cpb_removal_delay_length);
+        VLOG(INFO, "vui::cpb_removal_delay_length        > %d\n", vui->nal_hrd.cpb_removal_delay_length);
+        VLOG(INFO, "vui::dpb_output_delay_length         > %d\n", vui->nal_hrd.dpb_output_delay_length);
+        VLOG(INFO, "vui::vcl_hrd_parmeters_present_flag  > %d\n", vui->vcl_hrd_parameters_present_flag);
+        VLOG(INFO, "vui::cpb_cnt                         > %d\n", vui->vcl_hrd.cpb_cnt);
+        VLOG(INFO, "vui::bit_rate_value                  > %d\n", vui->vcl_hrd.bit_rate_value[0]);
+        VLOG(INFO, "vui::cpb_size_value                  > %d\n", vui->vcl_hrd.cpb_size_value[0]);
+        VLOG(INFO, "vui::initial_cpb_removal_delay_length> %d\n", vui->vcl_hrd.initial_cpb_removal_delay_length);
+        VLOG(INFO, "vui::cpb_removal_delay_length        > %d\n", vui->vcl_hrd.cpb_removal_delay_length);
+        VLOG(INFO, "vui::dpb_output_delay_length         > %d\n", vui->vcl_hrd.dpb_output_delay_length);
+    }
+    if (iFlags & (1UL<<H264_USERDATA_FLAG_PIC_TIMING)) {
+        avc_sei_pic_timing_t* picTiming = (avc_sei_pic_timing_t*)(pBase + pEntry[H264_USERDATA_FLAG_PIC_TIMING].offset);
+        VLOG(INFO, "[SEI::PIC_TIMING]\n");
+        VLOG(INFO, "sei::pic_timing::cpb_removal_delay   > %d\n", picTiming->cpb_removal_delay);
+        VLOG(INFO, "sei::pic_timing::dpb_output_delay    > %d\n", picTiming->dpb_output_delay);
+        VLOG(INFO, "sei::pic_timing::pic_struct          > %d\n", picTiming->pic_struct);
+        VLOG(INFO, "sei::pic_timing::num_clock_ts        > %d\n", picTiming->num_clock_ts);
+    }
+    if (iFlags & (1<<H264_USERDATA_FLAG_ITU_T_T35)) {
+        Uint8* pData    = NULL;
+        item  = &pEntry[H264_USERDATA_FLAG_ITU_T_T35];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H264::SEI::USER_DATA_REGISTERED_ITU_T_T35]\n");
+        DisplayHex(pData, item->size, "ITU-T-T35");
+    }
+    if (iFlags & (1<<H264_USERDATA_FLAG_ITU_T_T35_1)) {
+        Uint8* pData    = NULL;
+        item  = &pEntry[H264_USERDATA_FLAG_ITU_T_T35_1];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H264::SEI::USER_DATA_REGISTERED_ITU_T_T35_1]\n");
+        DisplayHex(pData, item->size, "ITU-T-T35_1");
+    }
+    if (iFlags & (1<<H264_USERDATA_FLAG_ITU_T_T35_2)) {
+        Uint8* pData    = NULL;
+        item  = &pEntry[H264_USERDATA_FLAG_ITU_T_T35_2];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[H264::SEI::USER_DATA_REGISTERED_ITU_T_T35_2]\n");
+        DisplayHex(pData, item->size, "ITU-T-T35_2");
+    }
+    if (iFlags & (1UL<<H264_USERDATA_FLAG_UNREGISTERED)) {
+        Uint8* pData = NULL;
+        item  = &pEntry[H264_USERDATA_FLAG_UNREGISTERED];
+        pData = (Uint8*)(pBase + item->offset);
+        VLOG(INFO, "[AVC::SEI::USER_DATA_UNREGISTERED]\n");
+        DisplayHex(pData, item->size, "UNREGISTERED");
+    }
+    if (iFlags & (1UL<<H264_USERDATA_FLAG_FILM_GRAIN_CHARACTERISTICS_INFO)) {
+        avc_sei_film_grain_t* pData = (avc_sei_film_grain_t*)(pBase + pEntry[H264_USERDATA_FLAG_FILM_GRAIN_CHARACTERISTICS_INFO].offset);
+        VLOG(INFO, "[SEI::FILM_GRAIN_CHARACTERISTICS]\n");
+        VLOG(INFO, "sei::film_grain_characteristics::film_grain_characteristics_cancel_flag   > %04x\n", pData->film_grain_characteristics_cancel_flag);
+        VLOG(INFO, "sei::film_grain_characteristics::film_grain_model_id                      > %04x\n", pData->film_grain_model_id);
+        VLOG(INFO, "sei::film_grain_characteristics::separate_colour_description_present_flag > %04x\n", pData->separate_colour_description_present_flag);
+        VLOG(INFO, "sei::film_grain_characteristics::blending_model_id                        > %04x\n", pData->blending_mode_id);
+        VLOG(INFO, "sei::film_grain_characteristics::log2_scale_factor                        > %04x\n", pData->log2_scale_factor);
+        VLOG(INFO, "sei::film_grain_characteristics::comp_model_present_flag[0]               > %04x\n", pData->comp_model_present_flag[0]);
+        VLOG(INFO, "sei::film_grain_characteristics::comp_model_present_flag[1]               > %04x\n", pData->comp_model_present_flag[1]);
+        VLOG(INFO, "sei::film_grain_characteristics::comp_model_present_flag[2]               > %04x\n", pData->comp_model_present_flag[2]);
+    }
+    if (iFlags & (1UL<<H264_USERDATA_FLAG_TONE_MAPPING_INFO)) {
+        avc_sei_tone_mapping_info_t* pData = (avc_sei_tone_mapping_info_t*)(pBase + pEntry[H265_USERDATA_FLAG_TONE_MAPPING_INFO].offset);
+        VLOG(INFO, "[SEI::TONE_MAPPING_INFO]\n");
+        VLOG(INFO, "sei::tone_mapping_info::tone_map_id                > %04x\n", pData->tone_map_id);
+        VLOG(INFO, "sei::tone_mapping_info::tone_map_cancel_flag       > %04x\n", pData->tone_map_cancel_flag);
+        VLOG(INFO, "sei::tone_mapping_info::tone_map_repetition_period > %04x\n", pData->tone_map_repetition_period);
+        VLOG(INFO, "sei::tone_mapping_info::coded_data_bit_depth       > %04x\n", pData->coded_data_bit_depth);
+        VLOG(INFO, "sei::tone_mapping_info::target_bit_depth           > %04x\n", pData->target_bit_depth);
+        VLOG(INFO, "sei::tone_mapping_info::tone_map_model_id          > %04x\n", pData->tone_map_model_id);
+        VLOG(INFO, "sei::tone_mapping_info::min_value                  > %08x\n", pData->min_value);
+        VLOG(INFO, "sei::tone_mapping_info::max_value                  > %08x\n", pData->max_value);
+    }
+    if (iFlags & (1UL<<H265_USERDATA_FLAG_COLOUR_REMAPPING_INFO)) {
+        avc_sei_colour_remap_info_t* pData = (avc_sei_colour_remap_info_t*)(pBase + pEntry[H265_USERDATA_FLAG_COLOUR_REMAPPING_INFO].offset);
+        VLOG(INFO, "[SEI::COLOR_MAPPING_INFO]\n");
+        VLOG(INFO, "sei::tone_mapping_info::colour_remap_id          > %04x\n", pData->colour_remap_id);
+        VLOG(INFO, "sei::tone_mapping_info::colour_rempa_cancel_flag > %04x\n", pData->colour_cancel_flag);
+    }
+
+    return;
+}
+
+static void PrintUserData(DecListenerContext* ctx, CNMComListenerDecDone*  lsnpDecDone)
+{
+    vpu_buffer_t*       vbUser    = NULL;
+    DecOutputExtData*   ext       = NULL;
+    Uint32              numFlags  = 0;
+    Uint32              flags     = 0;
+    Uint8*              pBase     = NULL;
+
+    ext      = &lsnpDecDone->output->decOutputExtData;
+    flags    = ext->userDataHeader;
+    numFlags = ext->userDataNum;
+    vbUser   = &lsnpDecDone->vbUser;
+
+    if (0 == numFlags) {
+        return;
+    }
+    VLOG(INFO, "----------------------------------------------------------------\n");
+    VLOG(INFO, "- %d USERDATA(VUI, SEI)\n", numFlags);
+    VLOG(INFO, "----------------------------------------------------------------\n");
+    pBase  = (Uint8*)osal_malloc(vbUser->size);
+    if (pBase == NULL) {
+        VLOG(ERR, "%s failed to allocate memory\n", __FUNCTION__);
+        return;
+    }
+    VpuReadMem(lsnpDecDone->handle->coreIdx, vbUser->phys_addr, pBase, vbUser->size, VPU_USER_DATA_ENDIAN);
+
+    switch (lsnpDecDone->bitstreamFormat) {
+    case STD_HEVC:
+        PrintH265UserData(pBase, flags, vbUser);
+        break;
+    case STD_AVC:
+        PrintH264UserData(pBase, flags, vbUser);
+        break;
+    default:
+        VLOG(ERR, "Not supported yet!!!\n");
+        break;
+    }
+
+    osal_free(pBase);
+
+    return;
+}
+
+
+void HandleDecCompleteSeqEvent(Component com, CNMComListenerDecCompleteSeq* param, DecListenerContext* ctx)
+{
+    if (ctx->compareType == YUV_COMPARE) {
+        Uint32 width  = param->initialInfo->picWidth;
+        Uint32 height = param->initialInfo->picHeight;
+
+        if (ctx->enableScaler == TRUE) {
+            width  = VPU_CEIL(width, 16);
+            height = VPU_CEIL(height, 4);
+        }
+        if ((ctx->comparator = Comparator_Create(YUV_COMPARE, param->refYuvPath, width, height, param->wtlFormat,
+                                                 param->cbcrInterleave, param->bitstreamFormat==STD_VP9)) == NULL) {
+            VLOG(ERR, "%s:%d Failed to Comparator_Create(%s)\n", __FUNCTION__, __LINE__, param->refYuvPath);
+            CNMErrorSet(CNM_ERROR_FAILURE);
+            CNMAppStop();
+            return ;
+        }
+    }
+
+}
+
+void HandleDecRegisterFbEvent(Component com, CNMComListenerDecRegisterFb* param, DecListenerContext* ctx)
+{
+    Uint32 fps = (ctx->fps == 0) ? 30 : ctx->fps;
+    //SimpleRenderer_SetFrameRate(ctx->renderer, 0);
+    if ( ctx->bandwidth ) {
+        ctx->bwCtx = BWMonitorSetup(param->handle, TRUE, GetBasename((const char *)ctx->inputPath));
+    }
+    if ( ctx->performance ) {
+        ctx->pfCtx = PFMonitorSetup(param->handle->coreIdx, param->handle->instIndex, ctx->pfClock, fps, GetBasename((const char *)ctx->inputPath), 0);
+    }
+}
+
+static void HandleDecInterruptEvent(Component com, CNMComListenerDecInt* param, DecListenerContext* ctx)
+{
+    if ((1<<INT_WAVE5_DEC_PIC) == param->flag) {
+        if (ctx->bwCtx != NULL) {
+            BWMonitorUpdate(ctx->bwCtx, ctx->numVCores);
+            BWMonitorReset(ctx->bwCtx);
+        }
+    }
+}
+
+void HandleDecGetOutputEvent(Component com, CNMComListenerDecDone* param, DecListenerContext* ctx)
+{
+    DecOutputInfo*          output          = param->output;
+    FrameBuffer*            pFb             = &output->dispFrame;
+    void*                   decodedData     = NULL;
+    Uint8*                  pYuv            = NULL;
+    Uint32                  decodedDataSize = 0;
+    VpuRect                 rcDisplay       = {0,};
+    Uint32                  width=0, height = 0, Bpp;
+    size_t                  frameSizeInByte = 0;
+    if (param->ret != RETCODE_SUCCESS) return;
+
+    if (ctx->pfCtx != NULL) {
+        if (output->indexFrameDecoded >= 0) {
+            if (ctx->productId == PRODUCT_ID_517) {
+                PFMonitorUpdate(param->handle->coreIdx, ctx->pfCtx, output->frameCycle, output->seekCycle, output->parseCycle, output->DecodedCycle);
+            } else {
+                PFMonitorUpdate(param->handle->coreIdx, ctx->pfCtx, output->frameCycle);
+            }
+        }
+    }
+    if (ctx->bwCtx != NULL) {
+        BWMonitorUpdatePrint(ctx->bwCtx, output->picType);
+    }
+
+
+
+    // Finished decoding a frame
+    if (output->indexFrameDecoded >= 0) {
+        PrintUserData(ctx, param);
+        ctx->notDecodedCount = 0;
+    }
+    else {
+        ctx->notDecodedCount++;
+        if (ctx->notDecodedCount == MAX_NOT_DEC_COUNT) {
+            VLOG(ERR, "Continuous not-decoded-count is %d\nThere is something problem in DPB control.\n", ctx->notDecodedCount);
+            CNMAppStop();
+        }
+    }
+
+    if (output->indexFrameDisplay < 0) {
+        return;
+    }
+
+    if (ctx->lastSeqNo < pFb->sequenceNo || IsDifferentResolution(&ctx->fbInfo, pFb)) {
+        /* When the video sequence or the resolution of picture was changed. */
+        ctx->lastSeqNo  = pFb->sequenceNo;
+        VPU_DecGiveCommand(param->handle, DEC_GET_FRAMEBUF_INFO, (void*)&ctx->fbInfo);
+    }
+
+    if (ctx->compareType == YUV_COMPARE) {
+        rcDisplay.right  = output->dispPicWidth;
+        rcDisplay.bottom = output->dispPicHeight;
+        if (ctx->enableScaler == TRUE) {
+           rcDisplay.right  = VPU_CEIL(rcDisplay.right, 16);
+           rcDisplay.bottom = VPU_CEIL(rcDisplay.bottom, 2);
+        }
+        if (TRUE == PRODUCT_ID_W_SERIES(ctx->productId)) {
+            pYuv = GetYUVFromFrameBuffer(param->handle, &output->dispFrame, rcDisplay, &width, &height, &Bpp, &frameSizeInByte);
+        }
+        decodedData     = (void*)pYuv;
+        decodedDataSize = frameSizeInByte;
+    }
+
+    if (ctx->comparator) {
+        if ((ctx->match=Comparator_Act(ctx->comparator, decodedData, decodedDataSize)) == FALSE) {
+        }
+    }
+
+    if (ctx->compareType == YUV_COMPARE) {
+        osal_free(decodedData);
+    }
+
+
+    if (ctx->match == FALSE) CNMAppStop();
+}
+
+void HandleDecCloseEvent(Component com, CNMComListenerDecClose* param, DecListenerContext* ctx)
+{
+    if (ctx->bwCtx != NULL)
+        BWMonitorRelease(ctx->bwCtx);
+    if (ctx->pfCtx != NULL)
+        PFMonitorRelease(ctx->pfCtx);
+}
+
+void DecoderListener(Component com, Uint64 event, void* data, void* context)
+{
+#if defined(SUPPORT_MULTI_INSTANCE_TEST) || defined(SUPPORT_LOOK_AHEAD_RC)
+#else
+    /* int key=0;
+    if (osal_kbhit()) {
+        key = osal_getch();
+        osal_flush_ch();
+
+        switch (key) {
+        case 'q':
+        case 'Q':
+            CNMAppStop();
+            return;
+        case 'f':
+        case 'F':
+            ComponentSetParameter(NULL, com, SET_PARAM_DEC_FLUSH, NULL);
+            break;
+        default:
+            break;
+        }
+    } */
+#endif
+    switch (event) {
+    case COMPONENT_EVENT_DEC_OPEN:
+        break;
+    case COMPONENT_EVENT_DEC_ISSUE_SEQ:
+        break;
+    case COMPONENT_EVENT_DEC_COMPLETE_SEQ:
+        HandleDecCompleteSeqEvent(com, (CNMComListenerDecCompleteSeq*)data, (DecListenerContext*)context);
+        break;
+    case COMPONENT_EVENT_DEC_REGISTER_FB:
+        HandleDecRegisterFbEvent(com, (CNMComListenerDecRegisterFb*)data, (DecListenerContext*)context);
+        break;
+    case COMPONENT_EVENT_DEC_READY_ONE_FRAME:
+        break;
+    case COMPONENT_EVENT_DEC_START_ONE_FRAME:
+        break;
+    case COMPONENT_EVENT_DEC_INTERRUPT:
+        HandleDecInterruptEvent(com, (CNMComListenerDecInt*)data, (DecListenerContext*)context);
+        break;
+    case COMPONENT_EVENT_DEC_GET_OUTPUT_INFO:
+        HandleDecGetOutputEvent(com, (CNMComListenerDecDone*)data, (DecListenerContext*)context);
+        break;
+    case COMPONENT_EVENT_DEC_DECODED_ALL:
+        break;
+    case COMPONENT_EVENT_DEC_CLOSE:
+        HandleDecCloseEvent(com, (CNMComListenerDecClose*)data, (DecListenerContext*)context);
+        break;
+    default:
+        break;
+    }
+}
+
+BOOL SetupDecListenerContext(DecListenerContext* ctx, CNMComponentConfig* config, Component renderer)
+{
+    TestDecConfig* decConfig = &config->testDecConfig;
+    Int32 md5Size = 0;
+
+    osal_memset((void*)ctx, 0x00, sizeof(DecListenerContext));
+
+    md5Size = PRODUCT_ID_W_SERIES(decConfig->productId) ? 12 : 8 ;
+
+    if (decConfig->compareType == MD5_COMPARE) {
+        if ((ctx->comparator=Comparator_Create(MD5_COMPARE, decConfig->md5Path, md5Size)) == NULL) {
+            VLOG(ERR, "%s:%d Failed to Comparator_Create(%s)\n", __FUNCTION__, __LINE__, decConfig->md5Path);
+            return FALSE;
+        }
+    }
+
+
+    ctx->renderer      = renderer;
+    ctx->lastSeqNo     = -1;
+    ctx->compareType   = decConfig->compareType;
+    ctx->match         = TRUE;
+
+    ctx->performance   = decConfig->performance;
+    ctx->bandwidth     = decConfig->bandwidth;
+    ctx->fps           = decConfig->fps;
+    ctx->pfClock       = decConfig->pfClock;
+    ctx->numVCores     = decConfig->wave.numVCores;
+    ctx->bitFormat     = decConfig->bitFormat;
+    ctx->productId     = decConfig->productId;
+    ctx->enableScaler  = (decConfig->scaleDownWidth > 0 || decConfig->scaleDownHeight > 0);
+    osal_memcpy(ctx->inputPath, decConfig->inputPath, sizeof(ctx->inputPath));
+
+    return TRUE;
+}
+
+void ClearDecListenerContext(DecListenerContext* ctx)
+{
+    if (ctx->comparator)    Comparator_Destroy(ctx->comparator);
+}
+
+

+ 68 - 0
soft_3rdpart/wave511/code/sample_v2/component_decoder/decoder_listener.h

@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "cnm_app.h"
+#include "misc/bw_monitor.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct DecListenerContext {
+    Component           renderer;
+    Comparator          comparator;
+    Int32               lastSeqNo;
+    DecGetFramebufInfo  fbInfo;
+    Uint32              compareType;
+    BOOL                match;
+    Uint32              notDecodedCount;
+
+    /* performance & bandwidth */
+    BOOL                performance;
+    BOOL                bandwidth;
+    PFCtx               pfCtx;
+    BWCtx*              bwCtx;
+    Uint32              fps;
+    Uint32              pfClock;
+    char                inputPath[MAX_FILE_PATH];
+    Uint32              numVCores;
+    CodStd              bitFormat;
+    Int32               productId;
+    BOOL                enableScaler;
+} DecListenerContext;
+
+void DecoderListener(Component com, Uint64 event, void* data, void* context);
+BOOL SetupDecListenerContext(DecListenerContext* ctx, CNMComponentConfig* config, Component renderer);
+void ClearDecListenerContext(DecListenerContext* ctx);
+void HandleDecCompleteSeqEvent(Component com, CNMComListenerDecCompleteSeq* param, DecListenerContext* ctx);
+void HandleDecRegisterFbEvent(Component com, CNMComListenerDecRegisterFb* param, DecListenerContext* ctx);
+void HandleDecGetOutputEvent(Component com, CNMComListenerDecDone* param, DecListenerContext* ctx);
+void HandleDecCloseEvent(Component com, CNMComListenerDecClose* param, DecListenerContext* ctx);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+

+ 920 - 0
soft_3rdpart/wave511/code/sample_v2/component_encoder/coda9/component_coda9_enc_encoder.c

@@ -0,0 +1,920 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+#include "cnm_app.h"
+#include "component.h"
+#include "misc/debug.h"
+#include "misc/bw_monitor.h"
+
+#ifndef min
+#define min(a,b)            (((a) < (b)) ? (a) : (b))
+#endif
+#ifndef max
+#define max(a,b)            (((a) > (b)) ? (a) : (b))
+#endif
+
+#define DEFAULT_READ_SIZE 1460 // = MTU(ethernet) - (IP_HEADER+TCP_HEADER)
+#define MAX_SIZE_ENC_HEADER 256
+#define MAX_SIZE_ENCODED_STREAM_BUF 0x700000 // only for RingBuffer
+
+typedef enum {
+    ENC_INT_STATUS_NONE,        // Interrupt not asserted yet
+    ENC_INT_STATUS_FULL,        // Need more buffer
+    ENC_INT_STATUS_DONE,        // Interrupt asserted
+    ENC_INT_STATUS_LOW_LATENCY,
+    ENC_INT_STATUS_TIMEOUT,     // Interrupt not asserted during given time.
+    ENC_INT_STATUS_BUF_FULL,
+} ENC_INT_STATUS;
+
+typedef enum {
+    ENCODER_STATE_OPEN,
+    ENCODER_STATE_INIT_SEQ,
+    ENCODER_STATE_REGISTER_FB,
+    ENCODER_STATE_ENCODE_HEADER,
+    ENCODER_STATE_ENCODING,
+} EncoderState;
+
+
+typedef struct {
+    BOOL                        fieldDone;
+    Int32                       iPicCnt;
+    ENC_CFG                     encCfg;
+    BOOL                        isDroppedPic;
+} CODA980Ctx;
+
+typedef struct {
+    EncHandle                   handle;
+    TestEncConfig               testEncConfig;
+    EncOpenParam                encOpenParam;
+    ParamEncNeedFrameBufferNum  fbCount;
+    Uint32                      frameIdx;
+    vpu_buffer_t                vbCustomLambda;
+    vpu_buffer_t                vbScalingList;
+    Uint32                      customLambda[NUM_CUSTOM_LAMBDA];
+    UserScalingList             scalingList;
+    vpu_buffer_t                vbCustomMap[MAX_REG_FRAME];
+    EncoderState                state;
+    BOOL                        stateDoing;
+    EncInitialInfo              initialInfo;
+    Queue*                      encOutQ;
+    EncParam                    encParam;
+    Int32                       encodedReConFrmIdx;
+    ParamEncBitstreamBuffer     bsBuf;
+    BOOL                        fullInterrupt;
+    Uint32                      changedCount;
+    Uint64                      startTimeout;
+    EncodedStreamBufInfo        encStreamBufInfo;
+    Int32                       encHeaderSize;
+    Uint8*                      encHeaderBuf; //EncodedHeaderBufInfo
+
+    //CODA980 variable
+    CODA980Ctx                  ctx980;
+    Uint32                      cyclePerTick;
+    BOOL                        readBsWhenFullInterrupt;
+} EncoderContext;
+
+BOOL HandleEncFullInterrupt(ComponentImpl* com, EncoderContext* ctx, PortContainerES* out)
+{
+    Int32 streamSize =0;
+    PhysicalAddress paRdPtr;
+    PhysicalAddress paWrPtr;
+    Uint32 fullStreamSize = 0;
+    EncInfo* encInfo    = NULL;
+
+    VPU_EncGetBitstreamBuffer(ctx->handle, &paRdPtr, &paWrPtr, &streamSize);
+    VLOG(TRACE, "<%s:%d> INT_BSBUF_FULL %p, %p\n", __FUNCTION__, __LINE__, paRdPtr, paWrPtr);
+
+    fullStreamSize = streamSize;
+
+    encInfo = VPU_HANDLE_TO_ENCINFO(ctx->handle);
+
+    if (NULL == encInfo) {
+        VLOG(ERR, "<%s:%d> NULL point exception\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+
+    out->paBsBufStart   = encInfo->streamBufStartAddr;
+    out->paBsBufEnd     = encInfo->streamBufEndAddr;
+    out->rdPtr          = paRdPtr;
+    out->wrPtr          = paWrPtr;
+    out->size           = fullStreamSize;
+
+    return TRUE;
+}
+
+
+BOOL MakeEncHeader(EncoderContext* ctx, EncHeaderParam encHeaderParam) {
+
+    if ((MAX_SIZE_ENC_HEADER-1) < ctx->encHeaderSize + encHeaderParam.size) {
+        VLOG(WARN, "Enc Header Buffer overrun\n");
+        return FALSE;
+    }
+
+    if (NULL != ctx->encHeaderBuf) {
+        vdi_read_memory(ctx->testEncConfig.coreIdx, encHeaderParam.buf, ctx->encHeaderBuf+ctx->encHeaderSize, encHeaderParam.size, ctx->testEncConfig.stream_endian);
+        ctx->encHeaderSize = ctx->encHeaderSize + encHeaderParam.size;
+    } else {
+        VLOG(ERR, "%s:%d NULL point Exception: %s\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+static BOOL FindEsBuffer(EncoderContext* ctx, PhysicalAddress addr, vpu_buffer_t* bs)
+{
+    Uint32 i;
+
+    for (i=0; i<ctx->bsBuf.num; i++) {
+        if (addr == ctx->bsBuf.bs[i].phys_addr) {
+            *bs = ctx->bsBuf.bs[i];
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+//The name of function should be renamed appropriately.
+//only for CODA980
+
+static void SetEncPicParam(ComponentImpl* com, PortContainerYuv* in, EncParam* encParam)
+{
+    EncoderContext* ctx             = (EncoderContext*)com->context;
+    vpu_buffer_t* buf               = (vpu_buffer_t*)Queue_Peek(ctx->encOutQ);
+    EncInfo* pEncInfo               = VPU_HANDLE_TO_ENCINFO(ctx->handle);
+
+    encParam->picStreamBufferAddr = buf->phys_addr;
+    encParam->picStreamBufferSize = buf->size;
+
+    encParam->srcIdx                             = in->srcFbIndex;
+    encParam->srcEndFlag                         = in->last;
+    encParam->sourceFrame                        = &in->fb;
+    encParam->sourceFrame->sourceLBurstEn        = FALSE;
+
+    encParam->sourceFrame->endian           = ctx->encOpenParam.frameEndian;
+    encParam->sourceFrame->cbcrInterleave   = ctx->encOpenParam.cbcrInterleave;
+    encParam->skipPicture                        = 0;
+
+    if (FALSE == ctx->testEncConfig.ringBufferEnable) {
+        pEncInfo->streamBufStartAddr    = buf->phys_addr;
+        pEncInfo->streamBufEndAddr      = buf->phys_addr + ctx->encOpenParam.bitstreamBufferSize;
+    }
+}
+
+static BOOL RegisterFrameBuffers(ComponentImpl* com)
+{
+    EncoderContext*         ctx= (EncoderContext*)com->context;
+    FrameBuffer*            pReconFb      = NULL;
+    FrameBuffer*            pSrcFb        = NULL;
+    FrameBufferAllocInfo    srcFbAllocInfo;
+    FrameBufferAllocInfo    reconFbAllocInfo;
+    Uint32                  reconFbStride = 0;
+    Uint32                  reconFbHeight = 0;
+    ParamEncFrameBuffer     paramFb;
+    RetCode                 result;
+    CNMComponentParamRet    ret;
+    BOOL                    success;
+
+    ctx->stateDoing = TRUE;
+    ret = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_YUVFEEDER_FRAME_BUF, (void*)&paramFb);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) return success;
+
+    //Reconstructed frame buffers
+    pReconFb      = paramFb.reconFb;
+    reconFbStride = paramFb.reconFbAllocInfo.stride;
+    reconFbHeight = paramFb.reconFbAllocInfo.height;
+    reconFbAllocInfo = paramFb.reconFbAllocInfo;
+
+    if(0 != reconFbStride && 0 !=reconFbHeight) {
+        if (VPU_EncAllocateFrameBuffer(ctx->handle, reconFbAllocInfo, pReconFb) != RETCODE_SUCCESS) {
+            VLOG(ERR, "VPU_EncAllocateFrameBuffer fail to allocate reconstructed frame buffers\n");
+            return FALSE;
+        }
+    }
+
+    result = VPU_EncRegisterFrameBuffer(ctx->handle, pReconFb, ctx->fbCount.reconFbNum, reconFbStride, reconFbHeight, (TiledMapType)reconFbAllocInfo.mapType);
+
+    if (result != RETCODE_SUCCESS) {
+        VLOG(ERR, "%s:%d Failed to VPU_EncRegisterFrameBuffer(%d)\n", __FUNCTION__, __LINE__, result);
+        return FALSE;
+    }
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_REGISTER_FB, NULL);
+
+    //Reference frame buffers
+    pSrcFb         = paramFb.srcFb;
+    srcFbAllocInfo = paramFb.srcFbAllocInfo;
+
+    if(0 != srcFbAllocInfo.stride && 0 !=srcFbAllocInfo.height ) {
+        if (VPU_EncAllocateFrameBuffer(ctx->handle, srcFbAllocInfo, pSrcFb) != RETCODE_SUCCESS) {
+            VLOG(ERR, "VPU_EncAllocateFrameBuffer fail to allocate source frame buffers\n");
+            return FALSE;
+        }
+    }
+
+
+
+    if (NULL == ctx->encStreamBufInfo.encodedStreamBuf) {
+        ctx->encStreamBufInfo.encodedStreamBufSize = MAX_SIZE_ENCODED_STREAM_BUF;
+        //ctx->encStreamBufInfo.encodedStreamBufSize = ctx->encOpenParam.bitstreamBufferSize;
+        ctx->encStreamBufInfo.encodedStreamBuf = (Uint8 *)osal_malloc(ctx->encStreamBufInfo.encodedStreamBufSize);
+        if (NULL != ctx->encStreamBufInfo.encodedStreamBuf) {
+            osal_memset(ctx->encStreamBufInfo.encodedStreamBuf, 0x00, ctx->encStreamBufInfo.encodedStreamBufSize);
+        }
+        else {
+            VLOG(WARN, "%s:%d NULL point exception :: encodedStreamBuf\n",__FUNCTION__, __LINE__);
+        }
+    }
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static CNMComponentParamRet GetParameterEncoder(ComponentImpl* from, ComponentImpl* com, GetParameterCMD commandType, void* data)
+{
+    EncoderContext*             ctx = (EncoderContext*)com->context;
+    BOOL                        result  = TRUE;
+    ParamEncNeedFrameBufferNum* fbCount;
+    PortContainerYuv*           container;
+
+    switch(commandType) {
+    case GET_PARAM_COM_IS_CONTAINER_CONUSUMED:
+        container = (PortContainerYuv*)data;
+        if (0 <= ctx->encodedReConFrmIdx) {
+            container->consumed = TRUE;
+        }
+        break;
+    case GET_PARAM_ENC_HANDLE:
+        if (ctx->handle == NULL) return CNM_COMPONENT_PARAM_NOT_READY;
+        *(EncHandle*)data = ctx->handle;
+        break;
+    case GET_PARAM_ENC_FRAME_BUF_NUM:
+        if (ctx->fbCount.srcFbNum == 0) return CNM_COMPONENT_PARAM_NOT_READY;
+        fbCount = (ParamEncNeedFrameBufferNum*)data;
+        fbCount->reconFbNum = ctx->fbCount.reconFbNum;
+        fbCount->srcFbNum   = ctx->fbCount.srcFbNum;
+        break;
+    case GET_PARAM_ENC_FRAME_BUF_REGISTERED:
+        if (ctx->state <= ENCODER_STATE_REGISTER_FB) return CNM_COMPONENT_PARAM_NOT_READY;
+        *(BOOL*)data = TRUE;
+        break;
+    default:
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static CNMComponentParamRet SetParameterEncoder(ComponentImpl* from, ComponentImpl* com, SetParameterCMD commandType, void* data)
+{
+    BOOL result = TRUE;
+    EncoderContext* ctx = (EncoderContext*)com->context;
+    switch(commandType) {
+    case SET_PARAM_COM_PAUSE:
+        com->pause   = *(BOOL*)data;
+        break;
+    case SET_PARAM_ENC_READ_BS_WHEN_FULL_INTERRUPT:
+        ctx->readBsWhenFullInterrupt = *(BOOL*)data;
+        break;
+    default:
+        VLOG(ERR, "Unknown SetParameterCMD Type : %d\n", commandType);
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static ENC_INT_STATUS HandlingInterruptFlagNoCQ(ComponentImpl* com, InterruptBit waitInterrptFlag)
+{
+    EncoderContext*      ctx               = (EncoderContext*)com->context;
+    EncHandle            handle            = ctx->handle;
+    Int32                interruptFlag     = 0;
+    Uint32               interruptWaitTime = VPU_WAIT_TIME_OUT;
+    Uint32               interruptTimeout  = VPU_ENC_TIMEOUT;
+    ENC_INT_STATUS       status            = ENC_INT_STATUS_NONE;
+    BOOL                 repeat            = TRUE;
+
+    ctx->startTimeout = osal_gettime();
+
+    do {
+        interruptFlag = VPU_WaitInterruptEx(handle, interruptWaitTime);
+        if (INTERRUPT_TIMEOUT_VALUE == interruptFlag) {
+            Uint64   currentTimeout = osal_gettime();
+            if ((currentTimeout - ctx->startTimeout) > interruptTimeout) {
+                CNMErrorSet(CNM_ERROR_HANGUP);
+                VLOG(ERR, "\n INSNTANCE #%d INTERRUPT TIMEOUT.\n", handle->instIndex);
+                status = ENC_INT_STATUS_TIMEOUT;
+                break;
+            }
+            interruptFlag = 0;
+        }
+
+        if (0 > interruptFlag) {
+            VLOG(ERR, "<%s:%d> interruptFlag is negative value! %08x\n", __FUNCTION__, __LINE__, interruptFlag);
+            status = ENC_INT_STATUS_NONE;
+        }
+
+        if (interruptFlag & (1<<INT_BIT_BIT_BUF_FULL)) {
+            status = ENC_INT_STATUS_BUF_FULL;
+            break;
+        }
+
+        if (0 < interruptFlag) {
+            VPU_ClearInterruptEx(handle, interruptFlag);
+        }
+
+        if (interruptFlag & (1 << waitInterrptFlag)) {
+            status = ENC_INT_STATUS_DONE;
+            repeat = FALSE;
+        }
+
+    } while (repeat);
+
+    return status;
+}
+
+static BOOL SetSequenceInfo(ComponentImpl* com)
+{
+    EncoderContext* ctx = (EncoderContext*)com->context;
+    EncHandle       handle  = ctx->handle;
+    RetCode         ret     = RETCODE_SUCCESS;
+    EncInitialInfo* initialInfo = &ctx->initialInfo;
+    CNMComListenerEncCompleteSeq lsnpCompleteSeq   = {0};
+    MaverickCacheConfig     encCacheConfig;
+
+    ret = VPU_EncGetInitialInfo(handle, initialInfo);
+    if (ret != RETCODE_SUCCESS) {
+        VLOG(ERR, "%s:%d FAILED TO ENC_PIC_HDR: ret(%d) \n", __FUNCTION__, __LINE__, ret);
+        return FALSE;
+    }
+
+    osal_memset(&encCacheConfig, 0x00, sizeof(MaverickCacheConfig));
+
+
+    MaverickCache2Config(
+        &encCacheConfig,
+        0,                    //encoder
+        ctx->encOpenParam.cbcrInterleave, // cb cr interleave
+        0,                    /* bypass */
+        0,                    /* burst  */
+        3,                    /* merge mode */
+        ctx->testEncConfig.mapType,
+        15 /* shape */);
+
+    VPU_EncGiveCommand(handle, SET_CACHE_CONFIG, &encCacheConfig);
+
+    lsnpCompleteSeq.handle = handle;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_COMPLETE_SEQ, (void*)&lsnpCompleteSeq);
+
+    ctx->fbCount.reconFbNum = initialInfo->minFrameBufferCount;
+    ctx->fbCount.srcFbNum = ENC_SRC_BUF_NUM; //2
+
+    if ( ctx->encOpenParam.sourceBufCount > ctx->fbCount.srcFbNum) {
+        //if you want to change the number of source buffers,
+        //use a variable sourceBufCount of encOpenParam
+        //ctx->fbCount.srcFbNum = ctx->encOpenParam.sourceBufCount;
+    }
+
+    VLOG(INFO, "[ENCODER] Required  reconFbCount=%d, srcFbCount=%d, outNum=%d, %dx%d\n",
+        ctx->fbCount.reconFbNum, ctx->fbCount.srcFbNum, ctx->testEncConfig.outNum, ctx->encOpenParam.picWidth, ctx->encOpenParam.picHeight);
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL EncodeHeader(ComponentImpl* com)
+{
+    EncoderContext*         ctx = (EncoderContext*)com->context;
+    EncHandle               handle  = ctx->handle;
+    RetCode                 ret     = RETCODE_SUCCESS;
+    EncHeaderParam          encHeaderParam;
+    vpu_buffer_t*           buf;
+    Int32                   ringBufEnable =ctx->encOpenParam.ringBufferEnable;
+
+    ctx->stateDoing = TRUE;
+
+    ctx->encParam.forceIPicture = 0;
+    ctx->encParam.skipPicture = 0;
+    ctx->encParam.quantParam = ctx->testEncConfig.picQpY;
+
+    if (FALSE == ringBufEnable && NULL == ctx->encHeaderBuf) {
+        ctx->encHeaderSize =0;
+        ctx->encHeaderBuf = (Uint8 *)osal_malloc(MAX_SIZE_ENC_HEADER);
+        if (NULL != ctx->encHeaderBuf) {
+            osal_memset(ctx->encHeaderBuf, 0x00, MAX_SIZE_ENC_HEADER);
+        }
+        else {
+            VLOG(WARN, "%s:%d NULL point exception :: encHeaderBuf\n",__FUNCTION__, __LINE__);
+        }
+    }
+
+    buf = Queue_Peek(ctx->encOutQ);
+    osal_memset(&encHeaderParam, 0x00, sizeof(EncHeaderParam));
+    encHeaderParam.zeroPaddingEnable = 0;
+
+    encHeaderParam.buf  = buf->phys_addr;
+    encHeaderParam.size = buf->size;
+
+    if (ctx->encOpenParam.bitstreamFormat == STD_MPEG4) {
+        encHeaderParam.headerType = 0;
+        if((ret =VPU_EncGiveCommand(handle, ENC_PUT_VIDEO_HEADER, &encHeaderParam)) != RETCODE_SUCCESS) {
+            VLOG(ERR, "VPU_EncGiveCommand ( ENC_PUT_VIDEO_HEADER ) for VOL_HEADER failed Error code is 0x%x \n", ret);
+            return FALSE;
+        }
+        if (FALSE == ringBufEnable) {
+            MakeEncHeader(ctx, encHeaderParam);
+        }
+#ifdef MP4_ENC_VOL_HEADER
+        encHeaderParam.headerType = VOL_HEADER;
+        if ((ret=VPU_EncGiveCommand(handle, ENC_PUT_VIDEO_HEADER, &encHeaderParam)) != RETCODE_SUCCESS) {
+            VLOG(ERR, "VPU_EncGiveCommand ( ENC_PUT_VIDEO_HEADER ) for VOL_HEADER failed Error code is 0x%x \n", ret);
+            return FALSE;
+        }
+        if (FALSE == ringBufEnable) {
+            MakeEncHeader(ctx, encHeaderParam);
+        }
+#endif
+    }
+    else if(ctx->encOpenParam.bitstreamFormat == STD_AVC) {
+        encHeaderParam.headerType = SPS_RBSP;
+        encHeaderParam.size = buf->size;
+        if ((ret=VPU_EncGiveCommand(handle, ENC_PUT_VIDEO_HEADER, &encHeaderParam)) != RETCODE_SUCCESS) {
+            VLOG(ERR, "VPU_EncGiveCommand ( ENC_PUT_VIDEO_HEADER ) for SPS_RBSP failed Error code is 0x%x \n", ret);
+            return FALSE;
+        }
+        if (FALSE == ringBufEnable) {
+            MakeEncHeader(ctx, encHeaderParam);
+        }
+        encHeaderParam.headerType = PPS_RBSP;
+        encHeaderParam.size = buf->size;
+        if ((ret =VPU_EncGiveCommand(handle, ENC_PUT_VIDEO_HEADER, &encHeaderParam))!= RETCODE_SUCCESS) {
+            VLOG(ERR, "VPU_EncGiveCommand ( ENC_PUT_VIDEO_HEADER ) for PPS_RBSP failed Error code is 0x%x \n", ret);
+            return FALSE;
+        }
+        if (FALSE == ringBufEnable) {
+            MakeEncHeader(ctx, encHeaderParam);
+        }
+
+    }
+
+    DisplayEncodedInformation(ctx->handle, ctx->encOpenParam.bitstreamFormat, 0, NULL, 0, 0, ctx->testEncConfig.performance, 0);
+
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL Encode(ComponentImpl* com, PortContainerYuv* in, PortContainerES* out)
+{
+    EncoderContext*                 ctx = (EncoderContext*)com->context;
+    BOOL                            doEncode = FALSE;
+    EncParam*                       encParam = &ctx->encParam;
+    EncOutputInfo                   encOutputInfo;
+    ENC_INT_STATUS                  intStatus = ENC_INT_STATUS_NONE;
+    RetCode                         result;
+    CNMComListenerHandlingInt       lsnpHandlingInt = {0};
+    CNMComListenerEncDone           lsnpPicDone = {0};
+    CNMComListenerEncStartOneFrame  lsn;
+    PhysicalAddress                 rdPrt;
+    PhysicalAddress                 wrPtr;
+    Int32                           lengthOfStream;
+    EncInfo* encInfo                = NULL;
+
+    if (NULL == in) {
+        //Just retry
+        return TRUE;
+    }
+
+    lsnpPicDone.handle = ctx->handle;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_READY_ONE_FRAME, &lsnpPicDone);
+
+    ctx->stateDoing = TRUE;
+
+    if (out->buf.phys_addr != 0) {
+        Queue_Enqueue(ctx->encOutQ, (void*)&out->buf);
+        out->buf.phys_addr = 0;
+        out->buf.size      = 0;
+    }
+
+    if (FALSE == ctx->fullInterrupt) {
+        if (encParam->srcEndFlag == TRUE) {
+            doEncode = (BOOL)(Queue_Get_Cnt(ctx->encOutQ) > 0);
+        }
+
+        if (Queue_Get_Cnt(ctx->encOutQ) > 0) {
+            SetEncPicParam(com, in, encParam);
+            doEncode = TRUE;
+            in->prevMapReuse = TRUE;
+        }
+        if(TRUE == in->last) {
+            if (out) out->last  = TRUE;
+            if (out) out->reuse = FALSE;
+            if (out) out->size = 0;
+            ctx->stateDoing    = FALSE;
+            com->terminate     = TRUE;
+            VLOG(INFO, "End of YUV stream.\n");
+            return TRUE;
+        }
+    } else {
+        doEncode = FALSE;
+    }
+
+    if (TRUE == doEncode) {
+
+
+        result = VPU_EncStartOneFrame(ctx->handle, encParam);
+        if (RETCODE_SUCCESS == result) {
+            if (in)  in->prevMapReuse = FALSE;
+            Queue_Dequeue(ctx->encOutQ);
+            //ctx->frameIdx++;
+            in->reuse = FALSE;
+            out->reuse = FALSE;
+            if(TRUE == ctx->testEncConfig.ringBufferEnable && NULL != ctx->encStreamBufInfo.encodedStreamBuf) {
+                osal_memset(ctx->encStreamBufInfo.encodedStreamBuf, 0x00, ctx->encStreamBufInfo.encodedStreamBufSize);
+                ctx->encStreamBufInfo.encodedStreamBufLength = 0;
+            }
+        }
+        else { // Error
+            VLOG(ERR, "VPU_EncStartOneFrame failed Error code is 0x%x \n", result);
+            HandleEncoderError(ctx->handle, ctx->frameIdx, NULL);
+            return FALSE;
+        }
+        lsn.handle = ctx->handle;
+        lsn.result = result;
+        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_START_ONE_FRAME, (void*)&lsn);
+    } else {
+        if (FALSE == ctx->fullInterrupt) {
+            //VLOG(TRACE, "waiting for reader!!! \n");
+            out->reuse = FALSE;
+            return TRUE;
+        }
+    }
+
+    ctx->fullInterrupt = FALSE;
+    {
+        if ((intStatus = HandlingInterruptFlagNoCQ(com, INT_BIT_PIC_RUN)) == ENC_INT_STATUS_TIMEOUT) {
+            VLOG(ERR, "failed to HandlingInterruptFlagNoCQ() \n");
+            HandleEncoderError(ctx->handle, ctx->frameIdx, NULL);
+            VPU_SWReset(ctx->testEncConfig.coreIdx, SW_RESET_FORCE, ctx->handle);
+            return FALSE;
+        }
+        else if (ENC_INT_STATUS_BUF_FULL == intStatus) {
+            if (FALSE == HandleEncFullInterrupt(com, ctx, out) )
+            {
+                VLOG(ERR, "failed to HandleEncFullInterrupt() \n");
+                return FALSE;
+            }
+
+            out->reuse          = FALSE;
+            out->streamBufFull  = TRUE;
+            in->reuse           = TRUE;
+            ctx->fullInterrupt  = TRUE;
+            return TRUE; //Go back to execution
+        }
+        else if (ENC_INT_STATUS_NONE == intStatus) {
+            out->size  = 0;
+            out->reuse = FALSE;
+            return TRUE; /* Try again */
+        }
+        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_HANDLING_INT, (void*)&lsnpHandlingInt);
+    }
+
+
+    osal_memset(&encOutputInfo, 0x00, sizeof(EncOutputInfo));
+    encOutputInfo.result = VPU_EncGetOutputInfo(ctx->handle, &encOutputInfo);
+    if (encOutputInfo.result == RETCODE_REPORT_NOT_READY) {
+        return TRUE; /* Not encoded yet */
+    }
+    else if (encOutputInfo.result == RETCODE_VLC_BUF_FULL) {
+        VLOG(ERR, "VLC BUFFER FULL!!! ALLOCATE MORE TASK BUFFER(%d)!!!\n", ONE_TASKBUF_SIZE_FOR_CQ);
+    }
+    else if (encOutputInfo.result != RETCODE_SUCCESS) {
+        /* ERROR */
+        HandleEncoderError(ctx->handle, encOutputInfo.encPicCnt, &encOutputInfo);
+        VPU_SWReset(ctx->testEncConfig.coreIdx, SW_RESET_FORCE, ctx->handle);
+        VLOG(ERR, "Failed to encode error = %d\n", encOutputInfo.result);
+        return FALSE;
+    }
+    else {;
+    /* SUCCESS */
+    }
+
+
+    DisplayEncodedInformation(ctx->handle, ctx->encOpenParam.bitstreamFormat, ctx->frameIdx, &encOutputInfo, encParam->srcEndFlag, encParam->srcIdx, ctx->testEncConfig.performance, ctx->cyclePerTick);
+
+    if (FALSE  == ctx->testEncConfig.ringBufferEnable && encOutputInfo.bitstreamWrapAround) {
+        // If LineBuffer interrupt is set to 1, it is ok to work.
+        VLOG(WARN, "Warning!! BitStream buffer wrap-arounded. prepare more large buffer. Consumed all remained stream\n");
+    }
+
+
+    lsnpPicDone.handle = ctx->handle;
+    lsnpPicDone.output = &encOutputInfo;
+    lsnpPicDone.fullInterrupted = ctx->fullInterrupt;
+
+    if (TRUE == ctx->testEncConfig.ringBufferEnable) {
+        ctx->encStreamBufInfo.ringBufferEnable = ctx->testEncConfig.ringBufferEnable;
+        osal_memcpy(&(lsnpPicDone.encodedStreamInfo), &(ctx->encStreamBufInfo), sizeof(EncodedStreamBufInfo));
+    }
+
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_GET_OUTPUT_INFO, (void*)&lsnpPicDone);
+    if ( encOutputInfo.result != RETCODE_SUCCESS )
+        return FALSE;
+
+    ctx->encodedReConFrmIdx = encOutputInfo.encSrcIdx;
+    if (0 > ctx->encodedReConFrmIdx) {
+        VLOG(WARN, "negative value of encodedReConFrmIdx : %d\n", ctx->encodedReConFrmIdx);
+    }
+
+    ctx->fullInterrupt      = FALSE;
+
+    if (out) {
+        encInfo = VPU_HANDLE_TO_ENCINFO(ctx->handle);
+        VPU_EncGetBitstreamBuffer(ctx->handle, &rdPrt, &wrPtr, &lengthOfStream);
+        if (in) in->reuse = FALSE;
+        out->rdPtr = rdPrt;
+        out->wrPtr = wrPtr;
+        out->paBsBufStart = encInfo->streamBufStartAddr;
+        out->paBsBufEnd = encInfo->streamBufEndAddr;
+        if (TRUE == ctx->testEncConfig.ringBufferEnable) {
+            out->buf.phys_addr = ctx->encOpenParam.bitstreamBuffer;
+            out->size = lengthOfStream;
+            //VLOG(TRACE, "addr : %x\n", out->rdPtr);
+        } else {
+            out->size = lengthOfStream;
+            if (FALSE == FindEsBuffer(ctx, encOutputInfo.bitstreamBuffer, &out->buf)) {
+                VLOG(ERR, "%s:%d Failed to find buffer(%p)\n", __FUNCTION__, __LINE__, encOutputInfo.bitstreamBuffer);
+                return FALSE;
+            }
+        }
+        out->reuse = (BOOL)(out->size == 0);
+    }
+
+    // Finished encoding a frame
+    if(ctx->testEncConfig.outNum != -1 && ctx->frameIdx > (ctx->testEncConfig.outNum-1)) {
+        if (ctx->testEncConfig.outNum != ctx->frameIdx) {
+            VLOG(ERR, "outnum(%d) != encoded cnt(%d)\n", ctx->testEncConfig.outNum, ctx->frameIdx);
+            return FALSE;
+        }
+        if(out) out->last  = TRUE;  // Send finish signal
+        if(out) out->reuse = FALSE;
+        ctx->stateDoing    = FALSE;
+        com->terminate     = TRUE;
+    }
+
+    ctx->frameIdx++;
+
+    return TRUE;
+}
+
+static BOOL OpenEncoder(ComponentImpl* com)
+{
+    EncoderContext*         ctx = (EncoderContext*)com->context;
+    SecAxiUse               secAxiUse;
+    MirrorDirection         mirrorDirection;
+    RetCode                 result;
+    CNMComListenerEncOpen   lspn    = {0};
+
+    ctx->stateDoing = TRUE;
+    ctx->encOpenParam.bitstreamBuffer     = ctx->bsBuf.bs[0].phys_addr;
+    ctx->encOpenParam.bitstreamBufferSize = ctx->bsBuf.bs[0].size;
+
+    if ((result = VPU_EncOpen(&ctx->handle, &ctx->encOpenParam)) != RETCODE_SUCCESS) {
+        VLOG(ERR, "VPU_EncOpen failed Error code is 0x%x \n", result);
+        if ( result == RETCODE_VPU_RESPONSE_TIMEOUT ) {
+            CNMErrorSet(CNM_ERROR_HANGUP);
+        }
+        CNMAppStop();
+        return FALSE;
+    }
+
+    lspn.handle = ctx->handle;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_OPEN, (void*)&lspn);
+
+    //Show register Logs
+    //VPU_DecGiveCommand(ctx->handle, ENABLE_LOGGING, 0);
+
+    if (ctx->testEncConfig.rotAngle != 0 || ctx->testEncConfig.mirDir != 0) {
+        VPU_EncGiveCommand(ctx->handle, ENABLE_ROTATION, 0);
+        VPU_EncGiveCommand(ctx->handle, ENABLE_MIRRORING, 0);
+        VPU_EncGiveCommand(ctx->handle, SET_ROTATION_ANGLE, &ctx->testEncConfig.rotAngle);
+        mirrorDirection = (MirrorDirection)ctx->testEncConfig.mirDir;
+        VPU_EncGiveCommand(ctx->handle, SET_MIRROR_DIRECTION, &mirrorDirection);
+    }
+
+    osal_memset(&secAxiUse,   0x00, sizeof(SecAxiUse));
+
+    secAxiUse.u.coda9.useBitEnable  = (ctx->testEncConfig.secondaryAXI>>0) & 0x01;
+    secAxiUse.u.coda9.useIpEnable   = (ctx->testEncConfig.secondaryAXI>>1) & 0x01;
+    secAxiUse.u.coda9.useDbkYEnable = (ctx->testEncConfig.secondaryAXI>>2) & 0x01;
+    secAxiUse.u.coda9.useDbkCEnable = (ctx->testEncConfig.secondaryAXI>>3) & 0x01;
+    secAxiUse.u.coda9.useBtpEnable  = (ctx->testEncConfig.secondaryAXI>>4) & 0x01;
+    secAxiUse.u.coda9.useOvlEnable  = (ctx->testEncConfig.secondaryAXI>>5) & 0x01;
+
+    VPU_EncGiveCommand(ctx->handle, SET_SEC_AXI, &secAxiUse);
+
+
+
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL ExecuteEncoder(ComponentImpl* com, PortContainer* in, PortContainer* out)
+{
+    EncoderContext* ctx             = (EncoderContext*)com->context;
+    BOOL            ret;
+
+    switch (ctx->state) {
+    case ENCODER_STATE_OPEN:
+        ret = OpenEncoder(com);
+        if (ctx->stateDoing == FALSE) ctx->state = ENCODER_STATE_INIT_SEQ;
+        break;
+    case ENCODER_STATE_INIT_SEQ:
+        ret = SetSequenceInfo(com);
+        if (ctx->stateDoing == FALSE) ctx->state = ENCODER_STATE_REGISTER_FB;
+        break;
+    case ENCODER_STATE_REGISTER_FB:
+        ret = RegisterFrameBuffers(com);
+        if (ctx->stateDoing == FALSE) ctx->state = ENCODER_STATE_ENCODE_HEADER;
+        break;
+    case ENCODER_STATE_ENCODE_HEADER:
+        ret = EncodeHeader(com);
+        if (ctx->stateDoing == FALSE) ctx->state = ENCODER_STATE_ENCODING;
+        break;
+    case ENCODER_STATE_ENCODING:
+        ret = Encode(com, (PortContainerYuv*)in, (PortContainerES*)out);
+        break;
+    default:
+        ret = FALSE;
+        break;
+    }
+
+    if (ret == FALSE || com->terminate == TRUE) {
+        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_ENCODED_ALL, (void*)ctx->handle);
+        if (out != NULL) {
+            out->reuse = FALSE;
+            out->last  = TRUE;
+        }
+    }
+    return ret;
+}
+
+static BOOL PrepareEncoder(ComponentImpl* com, BOOL* done)
+{
+    EncoderContext*         ctx       = (EncoderContext*)com->context;
+    CNMComponentParamRet    ret;
+    BOOL                    success;
+    Uint32                  idx =0;
+    Uint32                  jdx =0;
+    Uint32                  num = 0;
+
+    num = ComponentPortGetSize(&com->sinkPort);
+
+    *done = FALSE;
+
+    ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_READER_BITSTREAM_BUF, &ctx->bsBuf);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) return success;
+
+    if (num < ctx->bsBuf.num) {
+        VLOG(ERR, "number of port is less than number of bitstream.\n");
+        return FALSE;
+    }
+
+    ctx->encOutQ = Queue_Create(num, sizeof(vpu_buffer_t));
+
+    if (1 == ctx->bsBuf.num) { //Ring-Buffer
+        Queue_Enqueue(ctx->encOutQ, (void*)&ctx->bsBuf.bs[0]);
+    } else {
+        for (idx=0; idx<num; idx++) { //Line-Buffer
+            if (jdx > (ctx->bsBuf.num - 1)) {
+                jdx =0;
+            }
+            Queue_Enqueue(ctx->encOutQ, (void*)&ctx->bsBuf.bs[jdx]);
+            jdx++;
+        }
+    }
+
+
+    *done = TRUE;
+
+    return TRUE;
+}
+
+static void ReleaseEncoder(ComponentImpl* com)
+{
+}
+
+static BOOL DestroyEncoder(ComponentImpl* com)
+{
+    EncoderContext* ctx = (EncoderContext*)com->context;
+    Uint32          i   = 0;
+    BOOL            success = TRUE;
+
+    VPU_EncClose(ctx->handle);
+
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_CLOSE, NULL);
+
+    for (i = 0; i < ctx->fbCount.srcFbNum; i++) {
+        if (ctx->vbCustomMap[i].size)
+            vdi_free_dma_memory(ctx->testEncConfig.coreIdx, &ctx->vbCustomMap[i], ENC_ETC, ctx->handle->instIndex);
+    }
+
+    if (ctx->encOutQ) Queue_Destroy(ctx->encOutQ);
+
+    VPU_DeInit(ctx->testEncConfig.coreIdx);
+
+    if (NULL != ctx->encHeaderBuf) {
+        osal_free(ctx->encHeaderBuf);
+    }
+    if (NULL != ctx->encStreamBufInfo.encodedStreamBuf) {
+        osal_free(ctx->encStreamBufInfo.encodedStreamBuf);
+    }
+
+    osal_free(ctx);
+
+    return success;
+}
+
+static Component CreateEncoder(ComponentImpl* com, CNMComponentConfig* componentParam)
+{
+    EncoderContext* ctx;
+    RetCode         retCode;
+    Uint32          coreIdx      = componentParam->testEncConfig.coreIdx;
+    Uint16*         firmware     = (Uint16*)componentParam->bitcode;
+    Uint32          firmwareSize = componentParam->sizeOfBitcode;
+
+    retCode = VPU_InitWithBitcode(coreIdx, firmware, firmwareSize);
+    if (retCode != RETCODE_SUCCESS && retCode != RETCODE_CALLED_BEFORE) {
+        VLOG(INFO, "%s:%d Failed to VPU_InitWidthBitCode, ret(%08x)\n", __FUNCTION__, __LINE__, retCode);
+        return FALSE;
+    }
+
+    com->context = osal_malloc(sizeof(EncoderContext));
+    ctx     = (EncoderContext*)com->context;
+    osal_memset((void*)ctx, 0, sizeof(EncoderContext));
+
+    ctx->handle                 = NULL;
+    ctx->frameIdx               = 0;
+    ctx->fbCount.reconFbNum     = 0;
+    ctx->fbCount.srcFbNum       = 0;
+    ctx->testEncConfig          = componentParam->testEncConfig;
+    ctx->encOpenParam           = componentParam->encOpenParam;
+    ctx->encHeaderSize          = 0;
+    ctx->encHeaderBuf           = NULL;
+    ctx->encodedReConFrmIdx     = 0;
+    ctx->ctx980.encCfg          = componentParam->encCfg;
+    osal_memset(&(ctx->encStreamBufInfo), 0x00, sizeof(EncodedStreamBufInfo));
+    ctx->ctx980.fieldDone        = FALSE;
+
+
+    return (Component)com;
+}
+
+ComponentImpl coda9EncoderComponentImpl = {
+    "coda9_encoder",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainerES),
+    5,                       /* encoder's numSinkPortQueue(related to streambufcount) */
+    CreateEncoder,
+    GetParameterEncoder,
+    SetParameterEncoder,
+    PrepareEncoder,
+    ExecuteEncoder,
+    ReleaseEncoder,
+    DestroyEncoder
+};
+

+ 1225 - 0
soft_3rdpart/wave511/code/sample_v2/component_encoder/component_enc_encoder.c

@@ -0,0 +1,1225 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+#include "cnm_app.h"
+#include "component.h"
+#include "misc/debug.h"
+
+#ifndef min
+#define min(a,b)            (((a) < (b)) ? (a) : (b))
+#endif
+#ifndef max
+#define max(a,b)            (((a) > (b)) ? (a) : (b))
+#endif
+
+
+typedef enum {
+    ENC_INT_STATUS_NONE,        // Interrupt not asserted yet
+    ENC_INT_STATUS_FULL,        // Need more buffer
+    ENC_INT_STATUS_DONE,        // Interrupt asserted
+    ENC_INT_STATUS_LOW_LATENCY,
+    ENC_INT_STATUS_TIMEOUT,     // Interrupt not asserted during given time.
+    ENC_INT_STATUS_SRC_RELEASED,
+} ENC_INT_STATUS;
+
+typedef enum {
+    ENCODER_STATE_OPEN,
+    ENCODER_STATE_INIT_SEQ,
+    ENCODER_STATE_REGISTER_FB,
+    ENCODER_STATE_ENCODE_HEADER,
+    ENCODER_STATE_ENCODING,
+} EncoderState;
+
+typedef struct {
+    EncHandle                   handle;
+    TestEncConfig               testEncConfig;
+    EncOpenParam                encOpenParam;
+    ParamEncNeedFrameBufferNum  fbCount;
+    Uint32                      fbCountValid;
+    Uint32                      frameIdx;
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    Uint32                      encPicCnt;
+#endif
+    vpu_buffer_t                vbCustomLambda;
+    vpu_buffer_t                vbScalingList;
+    Uint32                      customLambda[NUM_CUSTOM_LAMBDA];
+    UserScalingList             scalingList;
+    vpu_buffer_t                vbCustomMap[MAX_REG_FRAME];
+    EncoderState                state;
+    BOOL                        stateDoing;
+    EncInitialInfo              initialInfo;
+    Queue*                      encOutQ;
+    EncParam                    encParam;
+    Int32                       encodedSrcFrmIdxArr[ENC_SRC_BUF_NUM];
+    ParamEncBitstreamBuffer     bsBuf;
+    BOOL                        fullInterrupt;
+    Uint32                      changedCount;
+    Uint64                      startTimeout;
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    int                         larcEnable;
+    int                         larcPass;
+    int                         larcSize;
+    EncLarcInfo                 larcInfo;
+    int                         larcPass2Started;
+    int                         larcPass1Finish;
+#endif
+    Uint32                      cyclePerTick;
+    vpu_buffer_t                *bsBuffer[20];
+} EncoderContext;
+
+static BOOL FindEsBuffer(EncoderContext* ctx, PhysicalAddress addr, vpu_buffer_t* bs)
+{
+    Uint32 i;
+
+    for (i=0; i<ctx->bsBuf.num; i++) {
+        if (addr == ctx->bsBuf.bs[i].phys_addr) {
+            *bs = ctx->bsBuf.bs[i];
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+static void SetEncPicParam(ComponentImpl* com, PortContainerYuv* in, EncParam* encParam)
+{
+    EncoderContext* ctx           = (EncoderContext*)com->context;
+    TestEncConfig   testEncConfig = ctx->testEncConfig;
+    Uint32          frameIdx      = ctx->frameIdx;
+    Int32           srcFbWidth    = VPU_ALIGN8(ctx->encOpenParam.picWidth);
+    Int32           srcFbHeight   = VPU_ALIGN8(ctx->encOpenParam.picHeight);
+    Uint32          productId;
+    vpu_buffer_t*   buf           = (vpu_buffer_t*)Queue_Peek(ctx->encOutQ);
+
+    productId = VPU_GetProductId(ctx->encOpenParam.coreIdx);
+
+    encParam->picStreamBufferAddr                = buf->phys_addr;
+    encParam->picStreamBufferSize                = buf->size;
+    encParam->srcIdx                             = in->srcFbIndex;
+    encParam->srcEndFlag                         = in->last;
+    encParam->sourceFrame                        = &in->fb;
+    encParam->sourceFrame->sourceLBurstEn        = 0;
+    if (testEncConfig.useAsLongtermPeriod > 0 && testEncConfig.refLongtermPeriod > 0) {
+        encParam->useCurSrcAsLongtermPic         = (frameIdx % testEncConfig.useAsLongtermPeriod) == 0 ? 1 : 0;
+        encParam->useLongtermRef                 = (frameIdx % testEncConfig.refLongtermPeriod)   == 0 ? 1 : 0;
+    }
+    encParam->skipPicture                        = 0;
+    encParam->forceAllCtuCoefDropEnable	         = 0;
+
+    encParam->forcePicQpEnable		             = 0;
+    encParam->forcePicQpI			             = 0;
+    encParam->forcePicQpP			             = 0;
+    encParam->forcePicQpB			             = 0;
+    encParam->forcePicTypeEnable	             = 0;
+    encParam->forcePicType			             = 0;
+
+    if (testEncConfig.forceIdrPicIdx == frameIdx) {
+        encParam->forcePicTypeEnable = 1;
+        encParam->forcePicType = 3;    // IDR
+    }
+
+    // FW will encode header data implicitly when changing the header syntaxes
+    encParam->codeOption.implicitHeaderEncode    = 1;
+    encParam->codeOption.encodeAUD               = testEncConfig.encAUD;
+    encParam->codeOption.encodeEOS               = testEncConfig.encEOS;
+    encParam->codeOption.encodeEOB               = testEncConfig.encEOB;
+
+    // set custom map param
+    if (productId != PRODUCT_ID_521)
+        encParam->customMapOpt.roiAvgQp		     = testEncConfig.roi_avg_qp;
+    encParam->customMapOpt.customLambdaMapEnable = testEncConfig.lambda_map_enable;
+    encParam->customMapOpt.customModeMapEnable	 = testEncConfig.mode_map_flag & 0x1;
+    encParam->customMapOpt.customCoefDropEnable  = (testEncConfig.mode_map_flag & 0x2) >> 1;
+    encParam->customMapOpt.customRoiMapEnable    = testEncConfig.roi_enable;
+
+    if (in->prevMapReuse == FALSE) {
+        // packaging roi/lambda/mode data to custom map buffer.
+        if (encParam->customMapOpt.customRoiMapEnable  || encParam->customMapOpt.customLambdaMapEnable ||
+            encParam->customMapOpt.customModeMapEnable || encParam->customMapOpt.customCoefDropEnable) {
+                SetMapData(testEncConfig.coreIdx, testEncConfig, ctx->encOpenParam, encParam, srcFbWidth, srcFbHeight, ctx->vbCustomMap[encParam->srcIdx].phys_addr);
+        }
+
+        // host should set proper value.
+        // set weighted prediction param.
+        if ((testEncConfig.wp_param_flag & 0x1)) {
+            char lineStr[256] = {0,};
+            Uint32 meanY, meanCb, meanCr, sigmaY, sigmaCb, sigmaCr;
+            Uint32 maxMean  = (ctx->encOpenParam.bitstreamFormat == STD_AVC) ? 0xffff : ((1 << ctx->encOpenParam.EncStdParam.waveParam.internalBitDepth) - 1);
+            Uint32 maxSigma = (ctx->encOpenParam.bitstreamFormat == STD_AVC) ? 0xffff : ((1 << (ctx->encOpenParam.EncStdParam.waveParam.internalBitDepth + 6)) - 1);
+            fgets(lineStr, 256, testEncConfig.wp_param_file);
+            sscanf(lineStr, "%d %d %d %d %d %d\n", &meanY, &meanCb, &meanCr, &sigmaY, &sigmaCb, &sigmaCr);
+
+            meanY	= max(min(maxMean, meanY), 0);
+            meanCb	= max(min(maxMean, meanCb), 0);
+            meanCr	= max(min(maxMean, meanCr), 0);
+            sigmaY	= max(min(maxSigma, sigmaY), 0);
+            sigmaCb = max(min(maxSigma, sigmaCb), 0);
+            sigmaCr = max(min(maxSigma, sigmaCr), 0);
+
+            // set weighted prediction param.
+            encParam->wpPixSigmaY	= sigmaY;
+            encParam->wpPixSigmaCb	= sigmaCb;
+            encParam->wpPixSigmaCr	= sigmaCr;
+            encParam->wpPixMeanY    = meanY;
+            encParam->wpPixMeanCb	= meanCb;
+            encParam->wpPixMeanCr	= meanCr;
+        }
+    }
+}
+
+static BOOL RegisterFrameBuffers(ComponentImpl* com)
+{
+    EncoderContext*         ctx= (EncoderContext*)com->context;
+    FrameBuffer*            pReconFb      = NULL;
+    FrameBuffer*            pSrcFb        = NULL;
+    FrameBufferAllocInfo    srcFbAllocInfo;
+    Uint32                  reconFbStride = 0;
+    Uint32                  reconFbHeight = 0;
+    ParamEncFrameBuffer     paramFb;
+    RetCode                 result;
+    CNMComponentParamRet    ret;
+    BOOL                    success;
+    Uint32                  idx;
+    EncInfo*                pEncInfo = VPU_HANDLE_TO_ENCINFO(ctx->handle);
+
+    ctx->stateDoing = TRUE;
+    ret = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_YUVFEEDER_FRAME_BUF, (void*)&paramFb);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) return success;
+
+    pReconFb      = paramFb.reconFb;
+    reconFbStride = paramFb.reconFbAllocInfo.stride;
+    reconFbHeight = paramFb.reconFbAllocInfo.height;
+
+    if (pEncInfo->productCode == WAVE521C_DUAL_CODE) {
+        TiledMapType        mapType = ctx->encOpenParam.EncStdParam.waveParam.internalBitDepth==8?COMPRESSED_FRAME_MAP_DUAL_CORE_8BIT:COMPRESSED_FRAME_MAP_DUAL_CORE_10BIT;
+        result = VPU_EncRegisterFrameBuffer(ctx->handle, pReconFb, ctx->fbCount.reconFbNum, reconFbStride, reconFbHeight, mapType);
+    }
+    else
+        result = VPU_EncRegisterFrameBuffer(ctx->handle, pReconFb, ctx->fbCount.reconFbNum, reconFbStride, reconFbHeight, COMPRESSED_FRAME_MAP);
+    if (result != RETCODE_SUCCESS) {
+        VLOG(ERR, "%s:%d Failed to VPU_EncRegisterFrameBuffer(%d)\n", __FUNCTION__, __LINE__, result);
+        ChekcAndPrintDebugInfo(ctx->handle, TRUE, result);
+        return FALSE;
+    }
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_REGISTER_FB, NULL);
+
+    pSrcFb         = paramFb.srcFb;
+    srcFbAllocInfo = paramFb.srcFbAllocInfo;
+    result = VPU_EncAllocateFrameBuffer(ctx->handle, srcFbAllocInfo, pSrcFb);
+    if (result != RETCODE_SUCCESS) {
+        VLOG(ERR, "VPU_EncAllocateFrameBuffer fail to allocate source frame buffer\n");
+        ChekcAndPrintDebugInfo(ctx->handle, TRUE, result);
+        return FALSE;
+    }
+
+    if (ctx->testEncConfig.roi_enable || ctx->testEncConfig.lambda_map_enable || ctx->testEncConfig.mode_map_flag) {
+        for (idx = 0; idx < ctx->fbCount.srcFbNum; idx++) {
+            ctx->vbCustomMap[idx].size = (ctx->encOpenParam.bitstreamFormat == STD_AVC) ? MAX_MB_NUM : MAX_CTU_NUM * 8;
+            if (vdi_allocate_dma_memory(ctx->testEncConfig.coreIdx, &ctx->vbCustomMap[idx], ENC_ETC, ctx->handle->instIndex) < 0) {
+                VLOG(ERR, "fail to allocate ROI buffer\n");
+                return FALSE;
+            }
+        }
+    }
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static CNMComponentParamRet GetParameterEncoder(ComponentImpl* from, ComponentImpl* com, GetParameterCMD commandType, void* data)
+{
+    EncoderContext*             ctx = (EncoderContext*)com->context;
+    BOOL                        result  = TRUE;
+    ParamEncNeedFrameBufferNum* fbCount;
+    PortContainerYuv*           container;
+    ParamVpuStatus*             status;
+    QueueStatusInfo             cqInfo;
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    EncLarcInfo                 *larcInfo;
+#endif
+
+    switch(commandType) {
+    case GET_PARAM_COM_IS_CONTAINER_CONUSUMED:
+        container = (PortContainerYuv*)data;
+        if (ctx->encodedSrcFrmIdxArr[container->srcFbIndex]) {
+            ctx->encodedSrcFrmIdxArr[container->srcFbIndex] = 0;
+            container->consumed = TRUE;
+        }
+        break;
+    case GET_PARAM_ENC_HANDLE:
+        if (ctx->handle == NULL) return CNM_COMPONENT_PARAM_NOT_READY;
+        *(EncHandle*)data = ctx->handle;
+        break;
+    case GET_PARAM_ENC_FRAME_BUF_NUM:
+        if (ctx->fbCountValid == FALSE) return CNM_COMPONENT_PARAM_NOT_READY;
+        fbCount = (ParamEncNeedFrameBufferNum*)data;
+        fbCount->reconFbNum = ctx->fbCount.reconFbNum;
+        fbCount->srcFbNum   = ctx->fbCount.srcFbNum;
+        break;
+    case GET_PARAM_ENC_FRAME_BUF_REGISTERED:
+        if (ctx->state <= ENCODER_STATE_REGISTER_FB) return CNM_COMPONENT_PARAM_NOT_READY;
+        *(BOOL*)data = TRUE;
+        break;
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    case GET_PARAM_ENC_LARC_INFO:
+        if ( ctx->larcEnable == FALSE ) {
+            result = FALSE;
+            break;
+        }
+        larcInfo = (EncLarcInfo*)data;
+        if ( ctx->larcPass  == LOOK_AHEAD_RC_PASS1 ) {
+            larcInfo->Pass1encPicCnt   = ctx->encPicCnt;
+            larcInfo->larcPass1Finish = ctx->larcPass1Finish;
+            osal_memcpy(larcInfo->larcData, ctx->larcInfo.larcData, sizeof(larcInfo->larcData));
+        }
+        else {
+            larcInfo->Pass2encPicCnt  = ctx->encPicCnt;
+        }
+        break;
+#endif
+    case GET_PARAM_VPU_STATUS:
+        if (ctx->state != ENCODER_STATE_ENCODING) return CNM_COMPONENT_PARAM_NOT_READY;
+        VPU_EncGiveCommand(ctx->handle, ENC_GET_QUEUE_STATUS, &cqInfo);
+        status = (ParamVpuStatus*)data;
+        status->cq = cqInfo;
+        break;
+    default:
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static CNMComponentParamRet SetParameterEncoder(ComponentImpl* from, ComponentImpl* com, SetParameterCMD commandType, void* data)
+{
+    BOOL result = TRUE;
+
+    switch (commandType) {
+    case SET_PARAM_COM_PAUSE:
+        com->pause   = *(BOOL*)data;
+        break;
+    default:
+        VLOG(ERR, "Unknown SetParameterCMD Type : %d\n", commandType);
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static ENC_INT_STATUS HandlingInterruptFlag(ComponentImpl* com)
+{
+    EncoderContext*   ctx               = (EncoderContext*)com->context;
+    EncHandle       handle                = ctx->handle;
+    Int32           interruptFlag         = 0;
+    Uint32          interruptWaitTime     = VPU_WAIT_TIME_OUT_CQ;
+    Uint32          interruptTimeout      = VPU_ENC_TIMEOUT;
+    ENC_INT_STATUS  status                = ENC_INT_STATUS_NONE;
+
+    if (ctx->startTimeout == 0ULL) {
+        ctx->startTimeout = osal_gettime();
+    }
+    do {
+        interruptFlag = VPU_WaitInterruptEx(handle, interruptWaitTime);
+        if (INTERRUPT_TIMEOUT_VALUE == interruptFlag) {
+            Uint64   currentTimeout = osal_gettime();
+
+            if ((currentTimeout - ctx->startTimeout) > interruptTimeout) {
+                VLOG(ERR, "<%s:%d> startTimeout(%lld) currentTime(%lld) diff(%d)\n",
+                    __FUNCTION__, __LINE__, ctx->startTimeout, currentTimeout, (Uint32)(currentTimeout - ctx->startTimeout));
+                CNMErrorSet(CNM_ERROR_HANGUP);
+                status = ENC_INT_STATUS_TIMEOUT;
+                break;
+            }
+            interruptFlag = 0;
+        }
+
+        if (interruptFlag < 0) {
+            VLOG(ERR, "<%s:%d> interruptFlag is negative value! %08x\n", __FUNCTION__, __LINE__, interruptFlag);
+        }
+
+        if (interruptFlag > 0) {
+            VPU_ClearInterruptEx(handle, interruptFlag);
+            ctx->startTimeout = 0ULL;
+
+            if (interruptFlag & (1<<INT_WAVE5_ENC_SET_PARAM)) {
+                status = ENC_INT_STATUS_DONE;
+                break;
+            }
+
+            if (interruptFlag & (1<<INT_WAVE5_ENC_PIC)) {
+                status = ENC_INT_STATUS_DONE;
+                break;
+            }
+
+            if (interruptFlag & (1<<INT_WAVE5_BSBUF_FULL)) {
+                status = ENC_INT_STATUS_FULL;
+                break;
+            }
+
+            if (interruptFlag & (1<<INT_WAVE5_ENC_LOW_LATENCY)) {
+                status = ENC_INT_STATUS_LOW_LATENCY;
+            }
+#ifdef SUPPORT_SOURCE_RELEASE_INTERRUPT
+            if (interruptFlag & (1 << INT_WAVE5_ENC_SRC_RELEASE)) {
+                status = ENC_INT_STATUS_SRC_RELEASED;
+            }
+#endif
+        }
+    } while (FALSE);
+
+    return status;
+}
+
+static BOOL SetSequenceInfo(ComponentImpl* com)
+{
+    EncoderContext* ctx = (EncoderContext*)com->context;
+    EncHandle       handle  = ctx->handle;
+    RetCode         ret     = RETCODE_SUCCESS;
+    ENC_INT_STATUS  status;
+    EncInitialInfo* initialInfo = &ctx->initialInfo;
+    CNMComListenerEncCompleteSeq lsnpCompleteSeq   = {0};
+
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    if ( ctx->larcPass  == LOOK_AHEAD_RC_PASS2 && ctx->larcPass2Started == FALSE) {
+        BOOL                    success;
+        ret = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_ENC_LARC_INFO, &ctx->larcInfo);
+        if (ComponentParamReturnTest(ret, &success) == FALSE) {
+            return success;
+        }
+        ctx->stateDoing = FALSE;
+        if ( ctx->larcInfo.Pass1encPicCnt < ctx->larcSize  && FALSE == ctx->larcInfo.larcPass1Finish) {
+            ctx->stateDoing = TRUE;
+            return success;
+        }
+        if (ctx->larcInfo.larcPass1Finish == TRUE)
+            ctx->larcInfo.larcData[ctx->larcInfo.Pass1encPicCnt][0] = -1;
+        ctx->larcPass2Started = TRUE;
+        if ( ctx->larcPass  == LOOK_AHEAD_RC_PASS2 ) {
+            VPU_EncGiveCommand(handle, ENC_SET_LARC_DATA, &ctx->larcInfo);
+        }
+    }
+#endif
+
+    if (ctx->stateDoing == FALSE) {
+        do {
+            ret = VPU_EncIssueSeqInit(handle);
+        } while (ret == RETCODE_QUEUEING_FAILURE && com->terminate == FALSE);
+
+        if (ret != RETCODE_SUCCESS) {
+            VLOG(ERR, "%s:%d Failed to VPU_EncIssueSeqInit() ret(%d)\n", __FUNCTION__, __LINE__, ret);
+            ChekcAndPrintDebugInfo(ctx->handle, TRUE, ret);
+            return FALSE;
+        }
+        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_ISSUE_SEQ, NULL);
+    }
+    ctx->stateDoing = TRUE;
+
+    while (com->terminate == FALSE) {
+        if ((status=HandlingInterruptFlag(com)) == ENC_INT_STATUS_DONE) {
+            break;
+        }
+        else if (status == ENC_INT_STATUS_NONE) {
+            return TRUE;
+        }
+        else if (status == ENC_INT_STATUS_TIMEOUT) {
+            VLOG(INFO, "%s:%d INSTANCE #%d INTERRUPT TIMEOUT\n", __FUNCTION__, __LINE__, handle->instIndex);
+            HandleEncoderError(ctx->handle, ctx->frameIdx, NULL);
+            return FALSE;
+        }
+        else {
+            VLOG(INFO, "%s:%d Unknown interrupt status: %d\n", __FUNCTION__, __LINE__, status);
+            return FALSE;
+        }
+    }
+
+    if ((ret=VPU_EncCompleteSeqInit(handle, initialInfo)) != RETCODE_SUCCESS) {
+        VLOG(ERR, "%s:%d FAILED TO ENC_PIC_HDR: ret(%d), SEQERR(%08x)\n",
+            __FUNCTION__, __LINE__, ret, initialInfo->seqInitErrReason);
+        ChekcAndPrintDebugInfo(ctx->handle, TRUE, ret);
+        return FALSE;
+    }
+
+    lsnpCompleteSeq.handle = handle;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_COMPLETE_SEQ, (void*)&lsnpCompleteSeq);
+
+    ctx->fbCount.reconFbNum = initialInfo->minFrameBufferCount;
+    ctx->fbCount.srcFbNum   = initialInfo->minSrcFrameCount + COMMAND_QUEUE_DEPTH + EXTRA_SRC_BUFFER_NUM;
+
+    if ( ctx->encOpenParam.sourceBufCount > ctx->fbCount.srcFbNum)
+        ctx->fbCount.srcFbNum = ctx->encOpenParam.sourceBufCount;
+
+    ctx->fbCountValid = TRUE;
+
+    VLOG(INFO, "[ENCODER] Required  reconFbCount=%d, srcFbCount=%d, outNum=%d, %dx%d\n",
+        ctx->fbCount.reconFbNum, ctx->fbCount.srcFbNum, ctx->testEncConfig.outNum, ctx->encOpenParam.picWidth, ctx->encOpenParam.picHeight);
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL EncodeHeader(ComponentImpl* com)
+{
+    EncoderContext*         ctx = (EncoderContext*)com->context;
+    EncHandle               handle  = ctx->handle;
+    RetCode                 ret     = RETCODE_SUCCESS;
+    EncHeaderParam          encHeaderParam;
+    vpu_buffer_t*           buf;
+
+    ctx->stateDoing = TRUE;
+    buf = Queue_Dequeue(ctx->encOutQ);
+    osal_memset(&encHeaderParam, 0x00, sizeof(EncHeaderParam));
+
+    encHeaderParam.buf  = buf->phys_addr;
+    encHeaderParam.size = buf->size;
+
+    if (ctx->encOpenParam.bitstreamFormat == STD_HEVC) {
+        encHeaderParam.headerType = CODEOPT_ENC_VPS | CODEOPT_ENC_SPS | CODEOPT_ENC_PPS;
+    }
+    else {
+        // H.264
+        encHeaderParam.headerType = CODEOPT_ENC_SPS | CODEOPT_ENC_PPS;
+    }
+
+    while(1) {
+        ret = VPU_EncGiveCommand(handle, ENC_PUT_VIDEO_HEADER, &encHeaderParam);
+        if ( ret != RETCODE_QUEUEING_FAILURE )
+            break;
+#if defined(HAPS_SIM) || defined(CNM_SIM_DPI_INTERFACE)
+        osal_msleep(1);
+#endif
+    }
+
+    DisplayEncodedInformation(ctx->handle, ctx->encOpenParam.bitstreamFormat, 0, NULL, 0, 0, ctx->testEncConfig.performance);
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL Encode(ComponentImpl* com, PortContainerYuv* in, PortContainerES* out)
+{
+    EncoderContext*         ctx             = (EncoderContext*)com->context;
+    BOOL                    doEncode        = FALSE;
+    BOOL                    doChangeParam   = FALSE;
+    EncParam*               encParam        = &ctx->encParam;
+    EncOutputInfo           encOutputInfo;
+    ENC_INT_STATUS          intStatus;
+    RetCode                 result;
+    CNMComListenerHandlingInt lsnpHandlingInt   = {0};
+    CNMComListenerEncDone   lsnpPicDone     = {0};
+    CNMComListenerDecReadyOneFrame  lsnpReadyOneFrame = {0,};
+    ENC_QUERY_WRPTR_SEL     encWrPtrSel     = GET_ENC_PIC_DONE_WRPTR;
+    QueueStatusInfo         qStatus;
+    int i=0;
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    CNMComponentParamRet    ret;
+    BOOL                    success;
+#endif
+
+    lsnpReadyOneFrame.handle = ctx->handle;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_READY_ONE_FRAME, &lsnpReadyOneFrame);
+
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    if ( ctx->larcPass  == LOOK_AHEAD_RC_PASS1 ) {
+        ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_ENC_LARC_INFO, &ctx->larcInfo);
+        if (ComponentParamReturnTest(ret, &success) == FALSE) {
+            if (in)  in->reuse  = TRUE;
+            if (out) out->reuse = TRUE;
+            return success;
+        }
+        if (!(ctx->larcInfo.Pass2encPicCnt + LOOK_AHEAD_RC_DATA_SIZE > ctx->frameIdx)) {
+            if (in)  in->reuse  = TRUE;
+            if (out) out->reuse = TRUE;
+            return TRUE;
+        }
+    }
+
+    if ( ctx->larcPass  == LOOK_AHEAD_RC_PASS2 ) {
+        ret = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_ENC_LARC_INFO, &ctx->larcInfo);
+        if (ComponentParamReturnTest(ret, &success) == FALSE) {
+            return success;
+        }
+        if ( !(ctx->larcInfo.Pass1encPicCnt > ctx->frameIdx + ctx->larcSize) && ctx->larcInfo.larcPass1Finish == FALSE) {
+            if (in)  in->reuse  = TRUE;
+            if (out) out->reuse = TRUE;
+            return TRUE;
+        }
+
+        for (i = 0; i < 3; i++) {
+            if ( ctx->larcInfo.larcPass1Finish == TRUE && ctx->larcInfo.Pass1encPicCnt <= ctx->frameIdx + ctx->larcSize - 1) {//-larcSize-1:already set in Wave5VpuEncSetLarcData
+                encParam->larcData[i] = -1;
+                break;
+            }
+            else
+                encParam->larcData[i] = ctx->larcInfo.larcData[(ctx->frameIdx+ctx->larcSize-1) % LOOK_AHEAD_RC_DATA_SIZE][i];
+        }
+    }
+#endif
+
+    ctx->stateDoing = TRUE;
+    if (out) {
+        if (out->buf.phys_addr != 0) {
+            Queue_Enqueue(ctx->encOutQ, (void*)&out->buf);
+            out->buf.phys_addr = 0;
+            out->buf.size      = 0;
+        }
+        if (encParam->srcEndFlag == TRUE) {
+            doEncode = (BOOL)(Queue_Get_Cnt(ctx->encOutQ) > 0);
+        }
+    }
+    if (in) {
+        if (Queue_Get_Cnt(ctx->encOutQ) > 0) {
+            SetEncPicParam(com, in, encParam);
+            doEncode = TRUE;
+            in->prevMapReuse = TRUE;
+        }
+    }
+
+    if (TRUE == com->pause)
+        doEncode = FALSE;
+
+    VPU_EncGiveCommand(ctx->handle, ENC_GET_QUEUE_STATUS, &qStatus);
+    if (COMMAND_QUEUE_DEPTH == qStatus.instanceQueueCount) {
+        doEncode = FALSE;
+    }
+
+    if ((ctx->testEncConfig.numChangeParam > ctx->changedCount) &&
+        (ctx->testEncConfig.changeParam[ctx->changedCount].setParaChgFrmNum == ctx->frameIdx)) {
+        doChangeParam = TRUE;
+    }
+
+    if (doChangeParam == TRUE) {
+        result = SetChangeParam(ctx->handle, ctx->testEncConfig, ctx->encOpenParam, ctx->changedCount);
+        if (result == RETCODE_SUCCESS) {
+            VLOG(TRACE, "ENC_SET_PARA_CHANGE queue success\n");
+            ctx->changedCount++;
+        }
+        else if (result == RETCODE_QUEUEING_FAILURE) { // Just retry
+            VLOG(INFO, "ENC_SET_PARA_CHANGE Queue Full\n");
+            doEncode  = FALSE;
+        }
+        else { // Error
+            VLOG(ERR, "VPU_EncGiveCommand[ENC_SET_PARA_CHANGE] failed Error code is 0x%x \n", result);
+            ChekcAndPrintDebugInfo(ctx->handle, TRUE, result);
+            return FALSE;
+        }
+    }
+
+    /* The simple load balancer : To use this function, call InitLoadBalancer() before decoding process. */
+    if (TRUE == doEncode) {
+        if (in) in->reuse = TRUE;
+        doEncode = LoadBalancerGetMyTurn(ctx->handle->instIndex);
+    }
+
+    if (doEncode == TRUE) {
+        CNMComListenerEncStartOneFrame lsn;
+        result = VPU_EncStartOneFrame(ctx->handle, encParam);
+        if (result == RETCODE_SUCCESS) {
+            /* The simple load balancer : pass its turn */
+            LoadBalancerSetNextTurn();
+
+            if (in) in->prevMapReuse = FALSE;
+            Queue_Dequeue(ctx->encOutQ);
+            ctx->frameIdx++;
+            if (in) in->reuse = FALSE;
+            if (out) out->reuse = FALSE;
+        }
+        else if (result == RETCODE_QUEUEING_FAILURE) { // Just retry
+            // Just retry
+            VPU_EncGiveCommand(ctx->handle, ENC_GET_QUEUE_STATUS, (void*)&qStatus);
+            if (qStatus.instanceQueueCount == 0) {
+                VLOG(ERR, "<%s:%d> The queue is empty but it can't add a command\n", __FUNCTION__, __LINE__);
+                return FALSE;
+            }
+        }
+        else { // Error
+            VLOG(ERR, "VPU_EncStartOneFrame failed Error code is 0x%x \n", result);
+            ChekcAndPrintDebugInfo(ctx->handle, TRUE, result);
+            CNMErrorSet(CNM_ERROR_HANGUP);
+            HandleEncoderError(ctx->handle, ctx->frameIdx, NULL);
+            return FALSE;
+        }
+        lsn.handle = ctx->handle;
+        lsn.result = result;
+        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_START_ONE_FRAME, (void*)&lsn);
+#ifdef SUPPORT_TESTCASE_CQ_16
+        if (lsn.result == COMMAND_QUEUE_NOT_FULL) {
+            if (out) {
+                out->size  = 0;
+                out->reuse = FALSE;
+            }
+            return TRUE; /* Try again */
+        }
+#endif
+    }
+
+    if ((intStatus=HandlingInterruptFlag(com)) == ENC_INT_STATUS_TIMEOUT) {
+        HandleEncoderError(ctx->handle, ctx->frameIdx, NULL);
+        VPU_SWReset(ctx->testEncConfig.coreIdx, SW_RESET_SAFETY, ctx->handle);
+        return FALSE;
+    }
+    else if (intStatus == ENC_INT_STATUS_FULL || intStatus == ENC_INT_STATUS_LOW_LATENCY) {
+        CNMComListenerEncFull   lsnpFull;
+        PhysicalAddress         paRdPtr;
+        PhysicalAddress         paWrPtr;
+        int                     size;
+
+        encWrPtrSel = (intStatus==ENC_INT_STATUS_FULL) ? GET_ENC_BSBUF_FULL_WRPTR : GET_ENC_LOW_LATENCY_WRPTR;
+        VPU_EncGiveCommand(ctx->handle, ENC_WRPTR_SEL, &encWrPtrSel);
+        VPU_EncGetBitstreamBuffer(ctx->handle, &paRdPtr, &paWrPtr, &size);
+        VLOG(TRACE, "<%s:%d> INT_BSBUF_FULL inst=%d, %p, %p\n", __FUNCTION__, __LINE__, ctx->handle->instIndex, paRdPtr, paWrPtr);
+
+
+        lsnpFull.handle = ctx->handle;
+        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_FULL_INTERRUPT, (void*)&lsnpFull);
+
+        if ( out ) {
+            if (ctx->encOpenParam.ringBufferEnable ==  TRUE) {
+                out->buf.phys_addr = paRdPtr;
+                out->buf.size = size;
+                out->size  = size;
+                out->reuse = FALSE;
+                out->streamBufFull = TRUE;
+                out->rdPtr = paRdPtr;
+                out->wrPtr = paWrPtr;
+                out->paBsBufStart = ctx->encOpenParam.bitstreamBuffer;
+                out->paBsBufEnd = ctx->encOpenParam.bitstreamBuffer + ctx->encOpenParam.bitstreamBufferSize;
+            }
+            else {
+                if (FindEsBuffer(ctx, paRdPtr, &out->buf) == FALSE) {
+                    VLOG(ERR, "%s:%d Failed to find buffer(%p)\n", __FUNCTION__, __LINE__, paRdPtr);
+                    return FALSE;
+                }
+                out->size  = size;
+                out->reuse = FALSE;
+                out->streamBufFull = TRUE;
+            }
+        }
+        ctx->fullInterrupt = TRUE;
+        return TRUE;
+    }
+#ifdef SUPPORT_SOURCE_RELEASE_INTERRUPT
+    else if (intStatus == ENC_INT_STATUS_SRC_RELEASED) {
+        Uint32 srcBufFlag = 0;
+        VPU_EncGiveCommand(ctx->handle, ENC_GET_SRC_BUF_FLAG, &srcBufFlag);
+        for (i = 0; i < ctx->fbCount.srcFbNum; i++) {
+            if ( (srcBufFlag >> i) & 0x01) {
+                ctx->encodedSrcFrmIdxArr[i] = 1;
+            }
+        }
+        return TRUE;
+    }
+#endif
+    else if (intStatus == ENC_INT_STATUS_NONE) {
+        if (out) {
+            out->size  = 0;
+            out->reuse = FALSE;
+        }
+        return TRUE; /* Try again */
+    }
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_HANDLING_INT, (void*)&lsnpHandlingInt);
+
+    VPU_EncGiveCommand(ctx->handle, ENC_WRPTR_SEL, &encWrPtrSel);
+    osal_memset(&encOutputInfo, 0x00, sizeof(EncOutputInfo));
+    encOutputInfo.result = VPU_EncGetOutputInfo(ctx->handle, &encOutputInfo);
+    if (encOutputInfo.result == RETCODE_REPORT_NOT_READY) {
+        return TRUE; /* Not encoded yet */
+    }
+    else if (encOutputInfo.result == RETCODE_VLC_BUF_FULL) {
+        VLOG(ERR, "VLC BUFFER FULL!!! ALLOCATE MORE TASK BUFFER(%d)!!!\n", ONE_TASKBUF_SIZE_FOR_CQ);
+    }
+    else if (encOutputInfo.result != RETCODE_SUCCESS) {
+        /* ERROR */
+        VLOG(ERR, "Failed to encode error = %d, %x\n", encOutputInfo.result, encOutputInfo.errorReason);
+        ChekcAndPrintDebugInfo(ctx->handle, TRUE, encOutputInfo.result);
+        HandleEncoderError(ctx->handle, encOutputInfo.encPicCnt, &encOutputInfo);
+        VPU_SWReset(ctx->testEncConfig.coreIdx, SW_RESET_SAFETY, ctx->handle);
+        return FALSE;
+    }
+    else {
+        ;/* SUCCESS */
+    }
+
+    if (encOutputInfo.reconFrameIndex == RECON_IDX_FLAG_CHANGE_PARAM) {
+        VLOG(TRACE, "CHANGE PARAMETER!\n");
+        return TRUE; /* Try again */
+    }
+    else {
+        DisplayEncodedInformation(ctx->handle, ctx->encOpenParam.bitstreamFormat, ctx->frameIdx, &encOutputInfo, encParam->srcEndFlag, encParam->srcIdx, ctx->testEncConfig.performance);
+    }
+    lsnpPicDone.handle = ctx->handle;
+    lsnpPicDone.output = &encOutputInfo;
+    lsnpPicDone.fullInterrupted = ctx->fullInterrupt;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_GET_OUTPUT_INFO, (void*)&lsnpPicDone);
+    if ( encOutputInfo.result != RETCODE_SUCCESS )
+        return FALSE;
+
+    for (i = 0; i < ctx->fbCount.srcFbNum; i++) {
+        if ( (encOutputInfo.releaseSrcFlag >> i) & 0x01) {
+            ctx->encodedSrcFrmIdxArr[i] = 1;
+        }
+    }
+
+    ctx->fullInterrupt      = FALSE;
+
+    if ( out ) {
+        if (ctx->encOpenParam.ringBufferEnable ==  TRUE) {
+            out->buf.phys_addr = encOutputInfo.rdPtr;
+            out->size  = encOutputInfo.bitstreamSize;
+            out->reuse = (BOOL)(out->size == 0);
+        }
+        else {
+            if (FindEsBuffer(ctx, encOutputInfo.bitstreamBuffer, &out->buf) == FALSE) {
+                VLOG(ERR, "%s:%d Failed to find buffer(%p)\n", __FUNCTION__, __LINE__, encOutputInfo.bitstreamBuffer);
+                return FALSE;
+            }
+            out->size  = encOutputInfo.bitstreamSize;
+            out->reuse = (BOOL)(out->size == 0);
+        }
+    }
+
+    // Finished encoding a frame
+    if (encOutputInfo.reconFrameIndex == RECON_IDX_FLAG_ENC_END) {
+        if (ctx->testEncConfig.outNum != encOutputInfo.encPicCnt && ctx->testEncConfig.outNum != -1) {
+            VLOG(ERR, "outnum(%d) != encoded cnt(%d)\n", ctx->testEncConfig.outNum, encOutputInfo.encPicCnt);
+            return FALSE;
+        }
+#ifdef SUPPORT_LOOK_AHEAD_RC
+        if (TRUE == ctx->larcEnable && ctx->larcPass  == LOOK_AHEAD_RC_PASS1) {
+            //no terminate here. PASS2 will terminate PASS1 component
+            ctx->larcPass1Finish = TRUE;
+            if (out) out->reuse = FALSE;
+            ctx->stateDoing    = FALSE;
+        }
+        else {
+#endif
+        if(out) out->last  = TRUE;  // Send finish signal
+        if(out) out->reuse = FALSE;
+        ctx->stateDoing    = FALSE;
+        com->terminate     = TRUE;
+#ifdef SUPPORT_LOOK_AHEAD_RC
+        }
+#endif
+        //to read remain data
+        if (ctx->encOpenParam.ringBufferEnable ==  TRUE && ctx->encOpenParam.ringBufferWrapEnable == FALSE) {
+            if(out) out->rdPtr = encOutputInfo.rdPtr;
+            if(out) out->wrPtr = encOutputInfo.wrPtr;
+            if(out) out->size = encOutputInfo.wrPtr - encOutputInfo.rdPtr;
+        }
+    }
+
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    ctx->encPicCnt = encOutputInfo.encPicCnt;
+    if (ctx->larcPass  == LOOK_AHEAD_RC_PASS1
+        && encOutputInfo.reconFrameIndex != RECON_IDX_FLAG_HEADER_ONLY
+        && encOutputInfo.bitstreamSize > 0) {
+            for (i = 0; i < 3; i++) {
+                ctx->larcInfo.larcData[(ctx->encPicCnt-1) % LOOK_AHEAD_RC_DATA_SIZE][i] = encOutputInfo.larcData[i];
+            }
+    }
+#endif
+
+    return TRUE;
+}
+
+static BOOL AllocateCustomBuffer(EncHandle handle, ComponentImpl* com)
+{
+    EncoderContext* ctx       = (EncoderContext*)com->context;
+    TestEncConfig testEncConfig = ctx->testEncConfig;
+    EncInfo*        pEncInfo;
+    EncOpenParam*   pOpenParam;
+    EncWaveParam*   pParam;
+
+    pEncInfo    = &handle->CodecInfo->encInfo;
+    pOpenParam  = &pEncInfo->openParam;
+    pParam      = &pOpenParam->EncStdParam.waveParam;
+
+    /* Allocate Buffer and Set Data */
+    if (pParam->scalingListEnable) {
+        ctx->vbScalingList.size = 0x1000;
+        if (vdi_allocate_dma_memory(testEncConfig.coreIdx, &ctx->vbScalingList, ENC_ETC, ctx->handle->instIndex) < 0) {
+            VLOG(ERR, "fail to allocate scaling list buffer\n");
+            return FALSE;
+        }
+        pParam->userScalingListAddr = ctx->vbScalingList.phys_addr;
+
+        parse_user_scaling_list(&ctx->scalingList, testEncConfig.scaling_list_file, testEncConfig.stdMode);
+        vdi_write_memory(testEncConfig.coreIdx, ctx->vbScalingList.phys_addr, (unsigned char*)&ctx->scalingList, ctx->vbScalingList.size, VDI_LITTLE_ENDIAN);
+    }
+
+    if (pParam->customLambdaEnable) {
+        ctx->vbCustomLambda.size = 0x200;
+        if (vdi_allocate_dma_memory(testEncConfig.coreIdx, &ctx->vbCustomLambda, ENC_ETC, ctx->handle->instIndex) < 0) {
+            VLOG(ERR, "fail to allocate Lambda map buffer\n");
+            return FALSE;
+        }
+        pParam->customLambdaAddr = ctx->vbCustomLambda.phys_addr;
+
+        parse_custom_lambda(ctx->customLambda, testEncConfig.custom_lambda_file);
+        vdi_write_memory(testEncConfig.coreIdx, ctx->vbCustomLambda.phys_addr, (unsigned char*)&ctx->customLambda[0], ctx->vbCustomLambda.size, VDI_LITTLE_ENDIAN);
+    }
+
+
+    return TRUE;
+}
+
+static BOOL OpenEncoder(ComponentImpl* com)
+{
+    EncoderContext*         ctx = (EncoderContext*)com->context;
+    SecAxiUse               secAxiUse;
+    MirrorDirection         mirrorDirection;
+    RetCode                 result;
+    CNMComListenerEncOpen   lspn    = {0};
+
+    ctx->stateDoing = TRUE;
+
+    ctx->encOpenParam.bitstreamBuffer     = ctx->bsBuf.bs[0].phys_addr;
+    ctx->encOpenParam.bitstreamBufferSize = ctx->bsBuf.bs[0].size;
+
+    if ((result = VPU_EncOpen(&ctx->handle, &ctx->encOpenParam)) != RETCODE_SUCCESS) {
+        VLOG(ERR, "VPU_EncOpen failed Error code is 0x%x \n", result);
+        if ( result == RETCODE_VPU_RESPONSE_TIMEOUT ) {
+            CNMErrorSet(CNM_ERROR_HANGUP);
+        }
+        CNMAppStop();
+        return FALSE;
+    }
+    //VPU_EncGiveCommand(ctx->handle, ENABLE_LOGGING, 0);
+    LoadBalancerAddInstance(ctx->handle->instIndex);
+
+    if (AllocateCustomBuffer(ctx->handle, com) == FALSE) return FALSE;
+    lspn.handle = ctx->handle;
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_OPEN, (void*)&lspn);
+
+    if (ctx->testEncConfig.rotAngle != 0 || ctx->testEncConfig.mirDir != 0) {
+        VPU_EncGiveCommand(ctx->handle, ENABLE_ROTATION, 0);
+        VPU_EncGiveCommand(ctx->handle, ENABLE_MIRRORING, 0);
+        VPU_EncGiveCommand(ctx->handle, SET_ROTATION_ANGLE, &ctx->testEncConfig.rotAngle);
+        mirrorDirection = (MirrorDirection)ctx->testEncConfig.mirDir;
+        VPU_EncGiveCommand(ctx->handle, SET_MIRROR_DIRECTION, &mirrorDirection);
+    }
+
+    osal_memset(&secAxiUse,   0x00, sizeof(SecAxiUse));
+    secAxiUse.u.wave.useEncRdoEnable = (ctx->testEncConfig.secondaryAXI & 0x1) ? TRUE : FALSE;  //USE_RDO_INTERNAL_BUF
+    secAxiUse.u.wave.useEncLfEnable  = (ctx->testEncConfig.secondaryAXI & 0x2) ? TRUE : FALSE;  //USE_LF_INTERNAL_BUF
+    VPU_EncGiveCommand(ctx->handle, SET_SEC_AXI, &secAxiUse);
+    VPU_EncGiveCommand(ctx->handle, SET_CYCLE_PER_TICK,   (void*)&ctx->cyclePerTick);
+
+    ctx->stateDoing = FALSE;
+
+    return TRUE;
+}
+
+static BOOL ExecuteEncoder(ComponentImpl* com, PortContainer* in, PortContainer* out)
+{
+    EncoderContext* ctx             = (EncoderContext*)com->context;
+    BOOL            ret;
+
+    switch (ctx->state) {
+    case ENCODER_STATE_OPEN:
+        ret = OpenEncoder(com);
+        if (ctx->stateDoing == FALSE) ctx->state = ENCODER_STATE_INIT_SEQ;
+        break;
+    case ENCODER_STATE_INIT_SEQ:
+        ret = SetSequenceInfo(com);
+        if (ctx->stateDoing == FALSE) ctx->state = ENCODER_STATE_REGISTER_FB;
+        break;
+    case ENCODER_STATE_REGISTER_FB:
+        ret = RegisterFrameBuffers(com);
+        if (ctx->stateDoing == FALSE) ctx->state = ENCODER_STATE_ENCODE_HEADER;
+        break;
+    case ENCODER_STATE_ENCODE_HEADER:
+        ret = EncodeHeader(com);
+        if (ctx->stateDoing == FALSE) ctx->state = ENCODER_STATE_ENCODING;
+        break;
+    case ENCODER_STATE_ENCODING:
+        ret = Encode(com, (PortContainerYuv*)in, (PortContainerES*)out);
+        break;
+    default:
+        ret = FALSE;
+        break;
+    }
+
+    if (ret == FALSE || com->terminate == TRUE) {
+        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_ENCODED_ALL, (void*)ctx->handle);
+        if (out != NULL) {
+            out->reuse = FALSE;
+            out->last  = TRUE;
+        }
+    }
+    return ret;
+}
+
+static BOOL PrepareEncoder(ComponentImpl* com, BOOL* done)
+{
+    EncoderContext*      ctx       = (EncoderContext*)com->context;
+    TestEncConfig*       testEncConfig = &ctx->testEncConfig;
+    CNMComponentParamRet ret;
+    BOOL                 success;
+    Uint32               i;
+
+    *done = FALSE;
+
+    ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_READER_BITSTREAM_BUF, &ctx->bsBuf);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) return success;
+
+    if (ctx->encOpenParam.ringBufferEnable ==  TRUE) {
+        ctx->encOutQ = Queue_Create(com->numSinkPortQueue, sizeof(vpu_buffer_t));
+        for (i=0; i<com->numSinkPortQueue; i++) {
+            if ( i < ctx->bsBuf.num) {
+                ctx->bsBuffer[i] = &ctx->bsBuf.bs[i]; }
+            else {
+                ctx->bsBuffer[i] = osal_malloc(sizeof(vpu_buffer_t));
+                osal_memcpy(ctx->bsBuffer[i], ctx->bsBuffer[0], sizeof(vpu_buffer_t));
+            }
+
+            Queue_Enqueue(ctx->encOutQ, (void*)&ctx->bsBuffer[i]);//same addr enqueue
+        }
+    } else {
+        ctx->encOutQ = Queue_Create(ctx->bsBuf.num, sizeof(vpu_buffer_t));
+        for (i=0; i<ctx->bsBuf.num; i++) {
+            Queue_Enqueue(ctx->encOutQ, (void*)&ctx->bsBuf.bs[i]);
+        }
+    }
+
+    /* Open Data File*/
+    if (ctx->encOpenParam.EncStdParam.waveParam.scalingListEnable) {
+        if (testEncConfig->scaling_list_fileName) {
+            ChangePathStyle(testEncConfig->scaling_list_fileName);
+            if ((testEncConfig->scaling_list_file = osal_fopen(testEncConfig->scaling_list_fileName, "r")) == NULL) {
+                VLOG(ERR, "fail to open scaling list file, %s\n", testEncConfig->scaling_list_fileName);
+                return FALSE;
+            }
+        }
+    }
+
+    if (ctx->encOpenParam.EncStdParam.waveParam.customLambdaEnable) {
+        if (testEncConfig->custom_lambda_fileName) {
+            ChangePathStyle(testEncConfig->custom_lambda_fileName);
+            if ((testEncConfig->custom_lambda_file = osal_fopen(testEncConfig->custom_lambda_fileName, "r")) == NULL) {
+                VLOG(ERR, "fail to open custom lambda file, %s\n", testEncConfig->custom_lambda_fileName);
+                return FALSE;
+            }
+        }
+    }
+
+    if (testEncConfig->roi_enable) {
+        if (testEncConfig->roi_file_name) {
+            ChangePathStyle(testEncConfig->roi_file_name);
+            if ((testEncConfig->roi_file = osal_fopen(testEncConfig->roi_file_name, "r")) == NULL) {
+                VLOG(ERR, "fail to open ROI file, %s\n", testEncConfig->roi_file_name);
+                return FALSE;
+            }
+        }
+    }
+
+    if (testEncConfig->lambda_map_enable) {
+        if (testEncConfig->lambda_map_fileName) {
+            ChangePathStyle(testEncConfig->lambda_map_fileName);
+            if ((testEncConfig->lambda_map_file = osal_fopen(testEncConfig->lambda_map_fileName, "r")) == NULL) {
+                VLOG(ERR, "fail to open lambda map file, %s\n", testEncConfig->lambda_map_fileName);
+                return FALSE;
+            }
+        }
+    }
+
+    if (testEncConfig->mode_map_flag) {
+        if (testEncConfig->mode_map_fileName) {
+            ChangePathStyle(testEncConfig->mode_map_fileName);
+            if ((testEncConfig->mode_map_file = osal_fopen(testEncConfig->mode_map_fileName, "r")) == NULL) {
+                VLOG(ERR, "fail to open custom mode map file, %s\n", testEncConfig->mode_map_fileName);
+                return FALSE;
+            }
+        }
+    }
+
+    if (testEncConfig->wp_param_flag & 0x1) {
+        if (testEncConfig->wp_param_fileName) {
+            ChangePathStyle(testEncConfig->wp_param_fileName);
+            if ((testEncConfig->wp_param_file = osal_fopen(testEncConfig->wp_param_fileName, "r")) == NULL) {
+                VLOG(ERR, "fail to open Weight Param file, %s\n", testEncConfig->wp_param_fileName);
+                return FALSE;
+            }
+        }
+    }
+
+
+    *done = TRUE;
+
+    return TRUE;
+}
+
+static void ReleaseEncoder(ComponentImpl* com)
+{
+    // Nothing to do
+}
+
+static BOOL DestroyEncoder(ComponentImpl* com)
+{
+    EncoderContext* ctx = (EncoderContext*)com->context;
+    Uint32          i   = 0;
+    BOOL            success = TRUE;
+    ENC_INT_STATUS  intStatus;
+
+    if ( NULL == ctx )
+        return FALSE;
+    if ( ctx && ctx->handle) {
+        LoadBalancerRemoveInstance(ctx->handle->instIndex);
+    }
+
+    while (VPU_EncClose(ctx->handle) == RETCODE_VPU_STILL_RUNNING) {
+        if ((intStatus = HandlingInterruptFlag(com)) == ENC_INT_STATUS_TIMEOUT) {
+            HandleEncoderError(ctx->handle, ctx->frameIdx, NULL);
+            VLOG(ERR, "NO RESPONSE FROM VPU_EncClose2()\n");
+            success = FALSE;
+            break;
+        }
+        else if (intStatus == ENC_INT_STATUS_DONE) {
+            EncOutputInfo   outputInfo;
+            VLOG(INFO, "VPU_EncClose() : CLEAR REMAIN INTERRUPT\n");
+            VPU_EncGetOutputInfo(ctx->handle, &outputInfo);
+            continue;
+        }
+
+        osal_msleep(10);
+    }
+
+    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_CLOSE, NULL);
+
+    for (i = 0; i < ctx->fbCount.srcFbNum; i++) {
+        if (ctx->vbCustomMap[i].size)
+            vdi_free_dma_memory(ctx->testEncConfig.coreIdx, &ctx->vbCustomMap[i], ENC_ETC, ctx->handle->instIndex);
+    }
+    if (ctx->vbCustomLambda.size)
+        vdi_free_dma_memory(ctx->testEncConfig.coreIdx, &ctx->vbCustomLambda, ENC_ETC, ctx->handle->instIndex);
+    if (ctx->vbScalingList.size)
+        vdi_free_dma_memory(ctx->testEncConfig.coreIdx, &ctx->vbScalingList, ENC_ETC, ctx->handle->instIndex);
+
+    if (ctx->testEncConfig.roi_file)
+        osal_fclose(ctx->testEncConfig.roi_file);
+    if (ctx->testEncConfig.lambda_map_file)
+        osal_fclose(ctx->testEncConfig.lambda_map_file);
+    if (ctx->testEncConfig.mode_map_file)
+        osal_fclose(ctx->testEncConfig.mode_map_file);
+    if (ctx->testEncConfig.scaling_list_file)
+        osal_fclose(ctx->testEncConfig.scaling_list_file);
+    if (ctx->testEncConfig.custom_lambda_file)
+        osal_fclose(ctx->testEncConfig.custom_lambda_file);
+    if (ctx->testEncConfig.wp_param_file)
+        osal_fclose(ctx->testEncConfig.wp_param_file);
+
+    if (ctx->encOutQ) Queue_Destroy(ctx->encOutQ);
+
+    VPU_DeInit(ctx->testEncConfig.coreIdx);
+
+    osal_free(ctx);
+
+    return success;
+}
+
+static Component CreateEncoder(ComponentImpl* com, CNMComponentConfig* componentParam)
+{
+    EncoderContext* ctx;
+    RetCode         retCode;
+    Uint32          coreIdx      = componentParam->testEncConfig.coreIdx;
+    Uint16*         firmware     = (Uint16*)componentParam->bitcode;
+    Uint32          firmwareSize = componentParam->sizeOfBitcode;
+    Uint32          i;
+    VpuAttr         productInfo;
+
+    retCode = VPU_InitWithBitcode(coreIdx, firmware, firmwareSize);
+    if (retCode != RETCODE_SUCCESS && retCode != RETCODE_CALLED_BEFORE) {
+        VLOG(INFO, "%s:%d Failed to VPU_InitWidthBitCode, ret(%08x)\n", __FUNCTION__, __LINE__, retCode);
+        return FALSE;
+    }
+
+    com->context = osal_malloc(sizeof(EncoderContext));
+    ctx     = (EncoderContext*)com->context;
+    osal_memset((void*)ctx, 0, sizeof(EncoderContext));
+
+    retCode = PrintVpuProductInfo(coreIdx, &productInfo);
+    if (retCode == RETCODE_VPU_RESPONSE_TIMEOUT ) {
+        CNMErrorSet(CNM_ERROR_HANGUP);
+        VLOG(INFO, "<%s:%d> Failed to PrintVpuProductInfo()\n", __FUNCTION__, __LINE__);
+        HandleEncoderError(ctx->handle, 0, NULL);
+        return FALSE;
+    }
+    ctx->cyclePerTick = 32768;
+    if (TRUE == productInfo.supportNewTimer)
+        ctx->cyclePerTick = 256;
+
+    ctx->handle                      = NULL;
+    ctx->frameIdx                    = 0;
+    ctx->fbCount.reconFbNum          = 0;
+    ctx->fbCount.srcFbNum            = 0;
+    ctx->testEncConfig               = componentParam->testEncConfig;
+    ctx->encOpenParam                = componentParam->encOpenParam;
+    for (i=0; i<ENC_SRC_BUF_NUM ; i++ ) {
+        ctx->encodedSrcFrmIdxArr[i] = 0;
+    }
+    osal_memset(&ctx->vbCustomLambda,  0x00, sizeof(vpu_buffer_t));
+    osal_memset(&ctx->vbScalingList,   0x00, sizeof(vpu_buffer_t));
+    osal_memset(&ctx->scalingList,     0x00, sizeof(UserScalingList));
+    osal_memset(&ctx->customLambda[0], 0x00, sizeof(ctx->customLambda));
+    osal_memset(ctx->vbCustomMap,      0x00, sizeof(ctx->vbCustomMap));
+    if (ctx->encOpenParam.ringBufferEnable)
+        com->numSinkPortQueue = 10;
+    else
+        com->numSinkPortQueue = componentParam->encOpenParam.streamBufCount;
+
+#ifdef SUPPORT_LOOK_AHEAD_RC
+    ctx->larcEnable = ctx->encOpenParam.EncStdParam.waveParam.larcEnable;
+    if (TRUE == ctx->larcEnable) {
+        ctx->larcPass   = ctx->encOpenParam.EncStdParam.waveParam.larcPass;
+        ctx->larcSize   = ctx->encOpenParam.EncStdParam.waveParam.larcSize;
+        osal_memset((void*)ctx->larcInfo.larcData, -1, sizeof(ctx->larcInfo.larcData));
+    }
+#endif
+
+    return (Component)com;
+}
+
+ComponentImpl waveEncoderComponentImpl = {
+    "wave_encoder",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainerES),
+    5,                       /* encoder's numSinkPortQueue(relates to streambufcount) */
+    CreateEncoder,
+    GetParameterEncoder,
+    SetParameterEncoder,
+    PrepareEncoder,
+    ExecuteEncoder,
+    ReleaseEncoder,
+    DestroyEncoder
+};
+

+ 424 - 0
soft_3rdpart/wave511/code/sample_v2/component_encoder/component_enc_feeder.c

@@ -0,0 +1,424 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include "component.h"
+
+typedef enum {
+    SRC_FB_TYPE_YUV,
+    SRC_FB_TYPE_CFRAME
+} SRC_FB_TYPE;
+
+typedef enum {
+    YUV_FEEDER_STATE_WAIT,
+    YUV_FEEDER_STATE_FEEDING
+} YuvFeederState;
+
+typedef struct {
+    EncHandle                   handle;
+    char                        inputPath[MAX_FILE_PATH];
+    EncOpenParam                encOpenParam;
+    Int32                       rotAngle;
+    Int32                       mirDir;
+    Int32                       frameOutNum;
+    Int32                       yuvMode;
+    FrameBufferAllocInfo        srcFbAllocInfo;
+    FrameBufferAllocInfo        reconFbAllocInfo;
+    BOOL                        fbAllocated;
+    ParamEncNeedFrameBufferNum  fbCount;
+    FrameBuffer                 pFbRecon[MAX_REG_FRAME];
+    vpu_buffer_t                pFbReconMem[MAX_REG_FRAME];
+    FrameBuffer                 pFbSrc[ENC_SRC_BUF_NUM];
+    vpu_buffer_t                pFbSrcMem[ENC_SRC_BUF_NUM];
+    FrameBuffer                 pFbOffsetTbl[ENC_SRC_BUF_NUM];
+    vpu_buffer_t                pFbOffsetTblMem[ENC_SRC_BUF_NUM];
+    YuvFeeder                   yuvFeeder;
+    BOOL                        last;
+    YuvFeederState              state;
+    BOOL                        stateDoing;
+    Int32                       feedingNum;
+    TiledMapConfig              mapConfig;
+    Int32                       productID;
+} YuvFeederContext;
+
+static void InitYuvFeederContext(YuvFeederContext* ctx, CNMComponentConfig* componentParam) 
+{
+    osal_memset((void*)ctx, 0, sizeof(YuvFeederContext));
+    strcpy(ctx->inputPath, componentParam->testEncConfig.yuvFileName);
+
+    ctx->fbAllocated        = FALSE;
+    ctx->encOpenParam       = componentParam->encOpenParam;
+    ctx->yuvMode            = componentParam->testEncConfig.yuv_mode;
+    ctx->fbCount.reconFbNum = 0;
+    ctx->fbCount.srcFbNum   = 0;
+    ctx->frameOutNum        = componentParam->testEncConfig.outNum;
+    ctx->rotAngle           = componentParam->testEncConfig.rotAngle;
+    ctx->mirDir             = componentParam->testEncConfig.mirDir;
+
+    osal_memset(&ctx->srcFbAllocInfo,          0x00, sizeof(FrameBufferAllocInfo));
+    osal_memset(&ctx->reconFbAllocInfo,        0x00, sizeof(FrameBufferAllocInfo));
+    osal_memset((void*)ctx->pFbRecon,          0x00, sizeof(ctx->pFbRecon));
+    osal_memset((void*)ctx->pFbReconMem,       0x00, sizeof(ctx->pFbReconMem));
+    osal_memset((void*)ctx->pFbSrc,            0x00, sizeof(ctx->pFbSrc));
+    osal_memset((void*)ctx->pFbSrcMem,         0x00, sizeof(ctx->pFbSrcMem));
+    osal_memset((void*)ctx->pFbOffsetTbl,      0x00, sizeof(ctx->pFbOffsetTbl));
+    osal_memset((void*)ctx->pFbOffsetTblMem,   0x00, sizeof(ctx->pFbOffsetTblMem));
+}
+
+static CNMComponentParamRet GetParameterYuvFeeder(ComponentImpl* from, ComponentImpl* com, GetParameterCMD commandType, void* data) 
+{
+    YuvFeederContext*    ctx = (YuvFeederContext*)com->context;
+    BOOL                 result  = TRUE;
+    ParamEncFrameBuffer* allocFb = NULL;
+
+    switch(commandType) {
+    case GET_PARAM_YUVFEEDER_FRAME_BUF:
+        if (ctx->fbAllocated == FALSE) return CNM_COMPONENT_PARAM_NOT_READY;
+        allocFb = (ParamEncFrameBuffer*)data;
+        allocFb->reconFb          = ctx->pFbRecon;
+        allocFb->srcFb            = ctx->pFbSrc;
+        allocFb->reconFbAllocInfo = ctx->reconFbAllocInfo;
+        allocFb->srcFbAllocInfo   = ctx->srcFbAllocInfo;
+        break;
+    default:
+        return CNM_COMPONENT_PARAM_NOT_FOUND;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static CNMComponentParamRet SetParameterYuvFeeder(ComponentImpl* from, ComponentImpl* com, SetParameterCMD commandType, void* data) 
+{
+    BOOL result = TRUE;
+
+    switch(commandType) {
+    default:
+        VLOG(ERR, "Unknown SetParameterCMD Type : %d\n", commandType);
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static BOOL AllocateFrameBuffer(ComponentImpl* com) {
+    YuvFeederContext*       ctx = (YuvFeederContext*)com->context;
+    EncOpenParam            encOpenParam = ctx->encOpenParam;
+    Uint32                  fbWidth = 0;
+    Uint32                  fbHeight = 0;
+    Uint32                  fbStride = 0;
+    Uint32                  fbSize = 0;
+    SRC_FB_TYPE             srcFbType = SRC_FB_TYPE_YUV;
+    DRAMConfig              dramConfig;
+    DRAMConfig*             pDramConfig = NULL;
+    TiledMapType            mapType;
+    FrameBufferAllocInfo    fbAllocInfo;
+
+    osal_memset(&fbAllocInfo, 0x00, sizeof(FrameBufferAllocInfo));
+    osal_memset(&dramConfig, 0x00, sizeof(DRAMConfig));
+
+    //Buffers for source frames
+    if (PRODUCT_ID_W_SERIES(ctx->productID)) {
+        fbWidth = VPU_ALIGN8(encOpenParam.picWidth);
+        fbHeight = VPU_ALIGN8(encOpenParam.picHeight);
+        fbAllocInfo.endian  = encOpenParam.sourceEndian;
+    } else {
+        //CODA
+        fbWidth = VPU_ALIGN16(encOpenParam.picWidth);
+        fbHeight = VPU_ALIGN16(encOpenParam.picHeight);
+        fbAllocInfo.endian  = encOpenParam.frameEndian;
+        VPU_EncGiveCommand(ctx->handle, GET_DRAM_CONFIG, &dramConfig);
+        pDramConfig = &dramConfig;
+    }
+
+
+    if (SRC_FB_TYPE_YUV == srcFbType) {
+        mapType = LINEAR_FRAME_MAP;
+    }
+    fbStride = CalcStride(fbWidth, fbHeight, (FrameBufferFormat)encOpenParam.srcFormat, encOpenParam.cbcrInterleave, mapType, FALSE);
+    fbSize = VPU_GetFrameBufSize(ctx->handle, encOpenParam.coreIdx, fbStride, fbHeight, mapType, (FrameBufferFormat)encOpenParam.srcFormat, encOpenParam.cbcrInterleave, pDramConfig);
+
+    fbAllocInfo.format  = (FrameBufferFormat)encOpenParam.srcFormat;
+    fbAllocInfo.cbcrInterleave = encOpenParam.cbcrInterleave;
+    fbAllocInfo.mapType = mapType;
+    fbAllocInfo.stride  = fbStride;
+    fbAllocInfo.height  = fbHeight;
+    fbAllocInfo.size    = fbSize;
+    fbAllocInfo.type    = FB_TYPE_PPU;
+    fbAllocInfo.num     = ctx->fbCount.srcFbNum;
+    fbAllocInfo.nv21    = encOpenParam.nv21;
+
+    if (PRODUCT_ID_NOT_W_SERIES(ctx->productID)) {
+        fbAllocInfo.lumaBitDepth = 8;
+        fbAllocInfo.chromaBitDepth = 8;
+    }
+
+    if (FALSE == AllocFBMemory(encOpenParam.coreIdx, ctx->pFbSrcMem, ctx->pFbSrc, fbSize, ctx->fbCount.srcFbNum, ENC_SRC, ctx->handle->instIndex)) {
+        VLOG(ERR, "failed to allocate source buffers\n");
+        return FALSE;
+    }
+    ctx->srcFbAllocInfo = fbAllocInfo;
+
+    //Buffers for reconstructed frames
+    osal_memset(&fbAllocInfo, 0x00, sizeof(FrameBufferAllocInfo));
+
+    if (PRODUCT_ID_W_SERIES(ctx->productID)) {
+        pDramConfig = NULL;
+        if (ctx->encOpenParam.bitstreamFormat == STD_AVC) {
+            fbWidth  = VPU_ALIGN16(encOpenParam.picWidth);
+            fbHeight = VPU_ALIGN16(encOpenParam.picHeight);
+        } else {
+            fbWidth  = VPU_ALIGN8(encOpenParam.picWidth);
+            fbHeight = VPU_ALIGN8(encOpenParam.picHeight);
+        }
+
+        if ((ctx->rotAngle != 0 || ctx->mirDir != 0) && !(ctx->rotAngle == 180 && ctx->mirDir == MIRDIR_HOR_VER)) {
+            fbWidth  = VPU_ALIGN32(encOpenParam.picWidth);
+            fbHeight = VPU_ALIGN32(encOpenParam.picHeight);
+        }
+        //TODO if --> else if
+        if (ctx->rotAngle == 90 || ctx->rotAngle == 270) {
+            fbWidth  = VPU_ALIGN32(encOpenParam.picHeight);
+            fbHeight = VPU_ALIGN32(encOpenParam.picWidth);
+        }
+
+        if (WAVE521C_DUAL_CODE == (VPU_HANDLE_TO_ENCINFO(ctx->handle)->productCode)) {
+            mapType = encOpenParam.EncStdParam.waveParam.internalBitDepth==8?COMPRESSED_FRAME_MAP_DUAL_CORE_8BIT:COMPRESSED_FRAME_MAP_DUAL_CORE_10BIT;
+        } else {
+            mapType = COMPRESSED_FRAME_MAP;
+        }
+    } else {
+        //CODA
+        pDramConfig = &dramConfig;
+        fbWidth = encOpenParam.picWidth;
+        fbHeight = encOpenParam.picHeight;
+        if (90 == ctx->rotAngle || 270 == ctx->rotAngle) {
+            fbWidth = encOpenParam.picHeight;
+            fbHeight = encOpenParam.picWidth;
+        }
+        fbWidth     = VPU_ALIGN16(fbWidth);
+        fbHeight    = VPU_ALIGN32(fbHeight); 
+        mapType     = mapType;
+    }
+
+    fbStride = CalcStride(fbWidth, fbHeight, (FrameBufferFormat)encOpenParam.outputFormat, encOpenParam.cbcrInterleave, mapType, FALSE);
+    fbSize   = VPU_GetFrameBufSize(ctx->handle, encOpenParam.coreIdx, fbStride, fbHeight, mapType, (FrameBufferFormat)encOpenParam.outputFormat, encOpenParam.cbcrInterleave, pDramConfig);
+
+    if (FALSE == AllocFBMemory(encOpenParam.coreIdx, ctx->pFbReconMem, ctx->pFbRecon, fbSize, ctx->fbCount.reconFbNum, ENC_FBC, ctx->handle->instIndex)) {
+        VLOG(ERR, "failed to allocate recon buffers\n");
+        return FALSE;
+    }
+
+    fbAllocInfo.stride  = fbStride;
+    fbAllocInfo.height  = fbHeight;
+    fbAllocInfo.type    = FB_TYPE_CODEC;
+    fbAllocInfo.num     = ctx->fbCount.reconFbNum;
+
+    ctx->reconFbAllocInfo = fbAllocInfo;
+
+    return TRUE;
+}
+
+static BOOL PrepareYuvFeeder(ComponentImpl* com, BOOL* done) 
+{
+    CNMComponentParamRet    ret;
+    YuvFeederContext*       ctx = (YuvFeederContext*)com->context;
+    EncOpenParam*           encOpenParam = &ctx->encOpenParam;
+    BOOL                    success;
+    Uint32                  i;
+    YuvFeeder               yuvFeeder    = NULL;
+    YuvInfo                 yuvFeederInfo;
+
+    *done = FALSE;
+    // wait signal GET_PARAM_ENC_FRAME_BUF_NUM
+    ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_ENC_FRAME_BUF_NUM, &ctx->fbCount);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) {
+        return success;
+    }
+
+    ret = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_ENC_HANDLE, &ctx->handle);
+    if (ComponentParamReturnTest(ret, &success) == FALSE) {
+        return success;
+    }
+
+    if (FALSE == AllocateFrameBuffer(com)) {
+        VLOG(ERR, "AllocateFramBuffer() error\n");
+        return FALSE;
+    }
+
+    osal_memset(&yuvFeederInfo,   0x00, sizeof(YuvInfo));
+
+    yuvFeederInfo.cbcrInterleave = encOpenParam->cbcrInterleave;
+    yuvFeederInfo.nv21           = encOpenParam->nv21;
+    yuvFeederInfo.packedFormat   = encOpenParam->packedFormat;
+    yuvFeederInfo.srcFormat      = encOpenParam->srcFormat;
+    yuvFeederInfo.srcPlanar      = TRUE;
+    yuvFeederInfo.srcStride      = ctx->srcFbAllocInfo.stride;
+    yuvFeederInfo.srcHeight      = VPU_CEIL(encOpenParam->picHeight, 8);
+    yuvFeeder = YuvFeeder_Create(ctx->yuvMode, ctx->inputPath, yuvFeederInfo);
+    if (yuvFeeder == NULL) {
+        VLOG(ERR, "YuvFeeder_Create Error\n");
+        return FALSE;
+    }
+
+    ((AbstractYuvFeeder*)yuvFeeder)->impl->handle = ctx->handle;
+    ctx->yuvFeeder = yuvFeeder;
+
+    // Fill data into the input queue of the sink port.
+    // The empty input queue of the sink port occurs a hangup problem in this example.
+    while (Queue_Dequeue(com->sinkPort.inputQ) != NULL);
+    for (i = 0; i < com->sinkPort.inputQ->size; i++) {
+        PortContainerYuv defaultData; 
+
+        osal_memset(&defaultData, 0x00, sizeof(PortContainerYuv));
+        defaultData.srcFbIndex   = -1;
+        if (i<ctx->fbCount.srcFbNum) {
+            defaultData.srcFbIndex   = i;
+            Queue_Enqueue(com->sinkPort.inputQ, (void*)&defaultData);
+        }
+    }
+
+    if (PRODUCT_ID_NOT_W_SERIES(ctx->productID)) {
+        VPU_EncGiveCommand(ctx->handle, GET_TILEDMAP_CONFIG, &(ctx->mapConfig));
+    }
+
+    ctx->fbAllocated = TRUE;
+
+    *done = TRUE;
+
+    return TRUE;
+}
+
+static BOOL ExecuteYuvFeeder(ComponentImpl* com, PortContainer* in, PortContainer* out) 
+{
+    YuvFeederContext*   ctx          = (YuvFeederContext*)com->context;
+    EncOpenParam*       encOpenParam = &ctx->encOpenParam;
+    int                 ret          = 0;
+    PortContainerYuv*   sinkData     = (PortContainerYuv*)out;
+    void*               extraFeedingInfo = NULL;
+
+    out->reuse = FALSE;
+    if (ctx->state == YUV_FEEDER_STATE_WAIT) {
+        CNMComponentParamRet ParamRet;
+        BOOL                 success, done = FALSE;
+
+        out->reuse = TRUE;
+        ParamRet = ComponentGetParameter(com, com->sinkPort.connectedComponent, GET_PARAM_ENC_FRAME_BUF_REGISTERED, &done);
+        if (ComponentParamReturnTest(ParamRet, &success) == FALSE) {
+            return success;
+        }
+        if (done == FALSE) return TRUE;
+        ctx->state = YUV_FEEDER_STATE_FEEDING;
+        out->reuse = FALSE;
+    }
+
+    if ( ctx->last ) {
+        sinkData->last = TRUE;
+        return TRUE;
+    }
+
+    sinkData->fb              = ctx->pFbSrc[sinkData->srcFbIndex];
+
+    if (PRODUCT_ID_NOT_W_SERIES(ctx->productID)) {
+        extraFeedingInfo = &(ctx->mapConfig);
+    }
+
+    ctx->feedingNum++;
+    if (ctx->feedingNum > ctx->frameOutNum && ctx->frameOutNum != -1) {
+        ctx->last = sinkData->last = TRUE;
+        return TRUE;
+    }
+    ret = YuvFeeder_Feed(ctx->yuvFeeder, encOpenParam->coreIdx, &sinkData->fb, encOpenParam->picWidth, encOpenParam->picHeight, sinkData->srcFbIndex, extraFeedingInfo);
+
+    if (ret == FALSE) {
+        ctx->last = sinkData->last = TRUE;
+    }
+
+
+    return TRUE;
+}
+
+static void ReleaseYuvFeeder(ComponentImpl* com)
+{
+    YuvFeederContext* ctx = (YuvFeederContext*)com->context;
+    Uint32          i   = 0;
+
+    for (i = 0; i < ctx->fbCount.reconFbNum*2; i++) {
+        if (ctx->pFbReconMem[i].size)
+            vdi_free_dma_memory(ctx->encOpenParam.coreIdx, &ctx->pFbReconMem[i], ENC_FBC, ctx->handle->instIndex);
+    }
+    for (i = 0; i < ctx->fbCount.srcFbNum; i++) {
+        if (ctx->pFbSrcMem[i].size)
+            vdi_free_dma_memory(ctx->encOpenParam.coreIdx, &ctx->pFbSrcMem[i], ENC_SRC, ctx->handle->instIndex);
+        if (ctx->pFbOffsetTblMem[i].size)
+            vdi_free_dma_memory(ctx->encOpenParam.coreIdx, &ctx->pFbOffsetTblMem[i], ENC_FBCY_TBL, ctx->handle->instIndex);
+    }
+}
+
+static BOOL DestroyYuvFeeder(ComponentImpl* com) 
+{
+    YuvFeederContext* ctx = (YuvFeederContext*)com->context;
+
+    if (ctx->yuvFeeder)   YuvFeeder_Destroy(ctx->yuvFeeder);
+
+    osal_free(ctx);
+
+    return TRUE;
+}
+
+static Component CreateYuvFeeder(ComponentImpl* com, CNMComponentConfig* componentParam) 
+{
+    YuvFeederContext*   ctx; 
+
+    com->context = osal_malloc(sizeof(YuvFeederContext));
+    ctx          = (YuvFeederContext*)com->context;
+
+    InitYuvFeederContext(ctx, componentParam);
+
+    if ( ctx->encOpenParam.sourceBufCount > com->numSinkPortQueue )
+        com->numSinkPortQueue = ctx->encOpenParam.sourceBufCount;//set requested sourceBufCount
+
+
+    ctx->productID = componentParam->testEncConfig.productId;
+
+    return (Component)com;
+}
+
+ComponentImpl yuvFeederComponentImpl = {
+    "yuvfeeder",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainerYuv),
+    ENC_SRC_BUF_NUM,              /* minimum feeder's numSinkPortQueue(relates to source buffer count)*/
+    CreateYuvFeeder,
+    GetParameterYuvFeeder,
+    SetParameterYuvFeeder,
+    PrepareYuvFeeder,
+    ExecuteYuvFeeder,
+    ReleaseYuvFeeder,
+    DestroyYuvFeeder
+};
+

+ 285 - 0
soft_3rdpart/wave511/code/sample_v2/component_encoder/component_enc_reader.c

@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <string.h>
+#include "component.h"
+
+typedef enum {
+    READER_STATE_OPEN,
+    READER_STATE_READING,
+} EncReaderState;
+
+typedef struct {
+    EncHandle       handle;
+    Uint32          streamBufCount;
+    Uint32          streamBufSize;
+    vpu_buffer_t*   bsBuffer;
+    Uint32          coreIdx;
+    EndianMode      streamEndian;
+    EncReaderState  state;
+    char            bitstreamFileName[MAX_FILE_PATH];
+    BitstreamReader bsReader;
+    osal_file_t     fp;
+    BOOL            ringBuffer;
+    BOOL            ringBufferWrapEnable;
+    Int32           productID;
+} ReaderContext;
+
+static CNMComponentParamRet GetParameterReader(ComponentImpl* from, ComponentImpl* com, GetParameterCMD commandType, void* data) 
+{
+    ReaderContext*           ctx    = (ReaderContext*)com->context;
+    BOOL                     result = TRUE;
+    ParamEncBitstreamBuffer* bsBuf  = NULL;
+    PortContainer*          container;
+
+    switch(commandType) {
+    case GET_PARAM_COM_IS_CONTAINER_CONUSUMED:
+        container = (PortContainer*)data;
+        container->consumed = TRUE;
+        break;
+    case GET_PARAM_READER_BITSTREAM_BUF:
+        if (ctx->bsBuffer == NULL) return CNM_COMPONENT_PARAM_NOT_READY;
+        bsBuf      = (ParamEncBitstreamBuffer*)data;
+        bsBuf->bs  = ctx->bsBuffer;
+        bsBuf->num = ctx->streamBufCount;
+        break;
+    default:
+        return CNM_COMPONENT_PARAM_NOT_FOUND;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static CNMComponentParamRet SetParameterReader(ComponentImpl* from, ComponentImpl* com, SetParameterCMD commandType, void* data) 
+{
+    BOOL result = TRUE;
+
+    switch(commandType) {
+    default:
+        result = FALSE;
+        break;
+    }
+
+    return (result == TRUE) ? CNM_COMPONENT_PARAM_SUCCESS : CNM_COMPONENT_PARAM_FAILURE;
+}
+
+static BOOL ExecuteReader(ComponentImpl* com, PortContainer* in, PortContainer* out) 
+{
+    ReaderContext*          ctx     = (ReaderContext*)com->context;
+    PortContainerES*        srcData = (PortContainerES*)in;
+    BOOL                    success = TRUE;
+    CNMComponentParamRet    ret;
+
+    srcData->reuse = FALSE;
+
+    switch (ctx->state) {
+    case READER_STATE_OPEN:
+        ret = ComponentGetParameter(com, com->srcPort.connectedComponent, GET_PARAM_ENC_HANDLE, &ctx->handle); 
+        if (ComponentParamReturnTest(ret, &success) == FALSE) {
+            return success;
+        }
+        if ( ctx->bitstreamFileName[0] != 0) {
+            ctx->bsReader = BitstreamReader_Create(BUFFER_MODE_TYPE_LINEBUFFER, ctx->bitstreamFileName, ctx->streamEndian, &ctx->handle);
+            if (ctx->bsReader == NULL) {
+                VLOG(ERR, "%s:%d Failed to BitstreamReader_Create\n", __FUNCTION__, __LINE__);
+                return FALSE;
+            }
+        }
+    ctx->state = READER_STATE_READING;
+        srcData->reuse  = TRUE;
+        
+        break;
+    case READER_STATE_READING:
+        if (srcData->size > 0 || 
+            (ctx->ringBuffer == TRUE && ctx->ringBufferWrapEnable == FALSE && srcData->last == TRUE) ) {
+            if ( ctx->ringBuffer == TRUE) {
+                Uint8* buf = (Uint8*)osal_malloc(srcData->size);
+                PhysicalAddress rd, paBsBufStart, paBsBufEnd;
+                Int32           readSize;
+                Uint32          room;
+
+                rd = srcData->rdPtr;
+                paBsBufStart = srcData->paBsBufStart;
+                paBsBufEnd   = srcData->paBsBufEnd;
+                readSize = srcData->size;
+
+                if (ctx->ringBufferWrapEnable == TRUE ) {
+                    if (ctx->bsReader != 0) {
+                        if ((rd+readSize) > paBsBufEnd) {
+                            room = paBsBufEnd - rd;
+                            vdi_read_memory(ctx->coreIdx, rd, buf, room,  ctx->streamEndian);
+                            vdi_read_memory(ctx->coreIdx, paBsBufStart, buf+room, (readSize-room), ctx->streamEndian);
+                        } 
+                        else {
+                            vdi_read_memory(ctx->coreIdx, rd, buf, readSize, ctx->streamEndian);
+                        }
+                    }
+                    VPU_EncUpdateBitstreamBuffer(ctx->handle, readSize);
+                    if (ctx->fp) {
+                        osal_fwrite(buf, readSize, 1, ctx->fp);
+                    }
+                }
+                else { //ring=1, wrap=0
+                    if (srcData->streamBufFull == TRUE || srcData->last == TRUE) { // read whole data at once and no UpdateBS
+                        if (ctx->bsReader != 0) {
+                            vdi_read_memory(ctx->coreIdx, rd, buf, readSize, ctx->streamEndian);
+                        }
+                        if (ctx->fp) {
+                            osal_fwrite(buf, readSize, 1, ctx->fp);
+                        }
+                    }
+                }
+                if (srcData->streamBufFull == TRUE) {
+                    if (ctx->ringBufferWrapEnable == FALSE) {
+                        vdi_free_dma_memory(ctx->coreIdx, &srcData->buf, ENC_BS, ctx->handle->instIndex);
+                        osal_memcpy(ctx->bsBuffer, &srcData->newBsBuf, sizeof(*ctx->bsBuffer));
+                    }
+                    srcData->buf.size = 0;
+                }
+                osal_free(buf);
+            }
+            else { /* line buffer mode */
+                Uint8* buf = (Uint8*)osal_malloc(srcData->size);
+                if (ctx->bsReader != 0) {
+                    //buf = (Uint8*)osal_malloc(srcData->size);
+                    BitstreamReader_Act(ctx->bsReader, srcData->buf.phys_addr, srcData->buf.size, srcData->size, NULL);
+
+                    if(PRODUCT_ID_NOT_W_SERIES(ctx->productID) && TRUE == srcData->streamBufFull) {
+                        VPU_ClearInterrupt(ctx->coreIdx);
+                    }
+                }
+                if (srcData->streamBufFull == TRUE) {
+                    srcData->buf.phys_addr = 0;
+                }
+                if (ctx->fp) {
+                    osal_fwrite(buf, srcData->size, 1, ctx->fp);
+                }
+                if(buf)
+                    osal_free(buf);
+            }
+            if (TRUE == srcData->streamBufFull) {
+                srcData->streamBufFull = FALSE;
+            }
+        }
+
+        srcData->consumed = TRUE;
+        com->terminate    = srcData->last;
+        break;
+    default:
+        success = FALSE;
+        break;
+    }
+
+    return success;
+}
+
+static BOOL PrepareReader(ComponentImpl* com, BOOL* done)
+{
+    ReaderContext*       ctx = (ReaderContext*)com->context;
+    Uint32               i;
+    vpu_buffer_t*        bsBuffer;
+    Uint32               num = ctx->streamBufCount;
+ 
+    *done = FALSE;
+
+    bsBuffer = (vpu_buffer_t*)osal_malloc(num*sizeof(vpu_buffer_t));
+    for (i = 0; i < num; i++) {
+        bsBuffer[i].size = ctx->streamBufSize;
+        if (vdi_allocate_dma_memory(ctx->coreIdx, &bsBuffer[i], ENC_BS, /*ctx->handle->instIndex*/0) < 0) {
+            VLOG(ERR, "%s:%d fail to allocate bitstream buffer\n", __FUNCTION__, __LINE__);
+            osal_free(bsBuffer);
+            return FALSE;
+        }
+    }
+    ctx->bsBuffer   = bsBuffer;
+    ctx->state      = READER_STATE_OPEN;
+
+    *done = TRUE;
+
+    return TRUE;
+}
+
+static void ReleaseReader(ComponentImpl* com)
+{
+    ReaderContext*  ctx = (ReaderContext*)com->context;
+    Uint32          i   = 0;
+
+    if (ctx->bsBuffer != NULL) {
+        for (i = 0; i < ctx->streamBufCount ; i++) {
+            if (ctx->bsBuffer[i].size)
+                vdi_free_dma_memory(ctx->coreIdx, &ctx->bsBuffer[i], ENC_BS, 0);
+        }
+    }
+}
+
+static BOOL DestroyReader(ComponentImpl* com) 
+{
+    ReaderContext*  ctx = (ReaderContext*)com->context;
+
+    if (ctx->bsBuffer != NULL) osal_free(ctx->bsBuffer);
+    if (ctx->fp) osal_fclose(ctx->fp);
+    osal_free(ctx);
+
+    return TRUE;
+}
+
+static Component CreateReader(ComponentImpl* com, CNMComponentConfig* componentParam) 
+{
+    ReaderContext* ctx;
+
+    com->context = osal_malloc(sizeof(ReaderContext));
+    ctx = (ReaderContext*)com->context;
+    osal_memset((void*)ctx, 0, sizeof(ReaderContext));
+
+    strcpy(ctx->bitstreamFileName, componentParam->testEncConfig.bitstreamFileName);
+    ctx->handle       = NULL;
+    ctx->coreIdx      = componentParam->testEncConfig.coreIdx;
+    ctx->productID    = componentParam->testEncConfig.productId;
+    ctx->streamEndian = (EndianMode)componentParam->testEncConfig.stream_endian;
+
+    ctx->streamBufCount = componentParam->encOpenParam.streamBufCount;
+    ctx->streamBufSize  = componentParam->encOpenParam.streamBufSize;
+    ctx->ringBuffer     = componentParam->encOpenParam.ringBufferEnable;
+    ctx->ringBufferWrapEnable = componentParam->encOpenParam.ringBufferWrapEnable;
+
+    return (Component)com;
+}
+
+ComponentImpl readerComponentImpl = {
+    "reader",
+    NULL,
+    {0,},
+    {0,},
+    sizeof(PortContainer),
+    5,
+    CreateReader,
+    GetParameterReader,
+    SetParameterReader,
+    PrepareReader,
+    ExecuteReader,
+    ReleaseReader,
+    DestroyReader,
+};
+

+ 258 - 0
soft_3rdpart/wave511/code/sample_v2/component_encoder/encoder_listener.c

@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "cnm_app.h"
+#include "encoder_listener.h"
+#include "misc/debug.h"
+#include "misc/bw_monitor.h"
+
+
+
+static void HandleEncHandlingIntEvent(Component com, CNMComListenerHandlingInt* param, EncListenerContext* ctx)
+{
+    if (ctx->bwCtx != NULL) {
+        BWMonitorUpdate(ctx->bwCtx, 1);
+    }
+}
+
+void HandleEncFullEvent(Component com, CNMComListenerEncFull* param, EncListenerContext* ctx)
+{
+}
+
+void HandleEncGetEncCloseEvent(Component com, CNMComListenerEncClose* param, EncListenerContext* ctx)
+{
+    if (ctx->pfCtx != NULL) {
+        PFMonitorRelease(ctx->pfCtx);
+    }
+    if (ctx->bwCtx != NULL) {
+        BWMonitorRelease(ctx->bwCtx);
+    }
+}
+
+void HandleEncCompleteSeqEvent(Component com, CNMComListenerEncCompleteSeq* param, EncListenerContext* ctx)
+{
+    if (ctx->performance == TRUE) {
+        Uint32 fps = (ctx->fps == 0) ? 30 : ctx->fps;
+        ctx->pfCtx = PFMonitorSetup(ctx->coreIdx, 0, ctx->pfClock, fps, GetBasename((const char *)ctx->cfgFileName), 1);
+    }
+    if (ctx->bandwidth == TRUE) {
+        ctx->bwCtx = BWMonitorSetup(param->handle, TRUE, GetBasename((const char *)ctx->cfgFileName));
+    }
+}
+
+void HandleEncGetOutputEvent(Component com, CNMComListenerEncDone* param, EncListenerContext* ctx)
+{
+    EncOutputInfo* output = param->output;
+    if (output->reconFrameIndex == RECON_IDX_FLAG_ENC_END)
+        return;
+
+
+    if (ctx->pfCtx != NULL) {
+        PFMonitorUpdate(ctx->coreIdx, ctx->pfCtx, output->frameCycle, output->encPrepareEndTick - output->encPrepareStartTick,
+            output->encProcessingEndTick - output->encProcessingStartTick, output->encEncodeEndTick- output->encEncodeStartTick);
+    }
+    if (ctx->bwCtx != NULL) {
+        BWMonitorUpdatePrint(ctx->bwCtx, output->picType);
+    }
+
+    if (ctx->headerEncDone[param->handle->instIndex] == FALSE) {
+        ctx->headerEncDone[param->handle->instIndex] = TRUE;
+    }
+
+    if (ctx->match == FALSE) CNMAppStop();
+}
+
+void Coda9HandleEncGetOutputEvent(Component com, CNMComListenerEncDone* param, EncListenerContext* ctx)
+{
+    EncOutputInfo* output = param->output;
+    EncHandle      handle = param->handle;
+
+    if (output->reconFrameIndex == RECON_IDX_FLAG_ENC_END) return;
+
+    if (ctx->pfCtx != NULL) {
+        PFMonitorUpdate(ctx->coreIdx, ctx->pfCtx, output->frameCycle, output->encPrepareEndTick - output->encPrepareStartTick,
+            output->encProcessingEndTick - output->encProcessingStartTick, output->encEncodeEndTick- output->encEncodeStartTick);
+    }
+    if (ctx->bwCtx != NULL) {
+        BWMonitorUpdatePrint(ctx->bwCtx, output->picType);
+    }
+
+    if (output->bitstreamSize > 0) {
+        if (ctx->es != NULL) {
+            Uint8*          buf      = NULL;
+            int             compSize = output->bitstreamSize;
+            PhysicalAddress addr;
+
+            if (param->fullInterrupted == TRUE) {
+                PhysicalAddress rd, wr;
+                VPU_EncGetBitstreamBuffer(param->handle, &rd, &wr, &compSize);
+                addr     = rd;
+            }
+            else {
+                addr     = output->bitstreamBuffer;
+                compSize = output->bitstreamSize;
+            }
+
+            buf = (Uint8*)osal_malloc(compSize);
+            vdi_read_memory(ctx->coreIdx, addr, buf, compSize, ctx->streamEndian);
+
+            if ( ctx->es != NULL ) {
+                if ((ctx->match=Comparator_Act(ctx->es, buf, compSize)) == FALSE) {
+                    VLOG(ERR, "<%s:%d> INSTANCE #%d Bitstream Mismatch\n", __FUNCTION__, __LINE__, handle->instIndex);
+                }
+            }
+            osal_free(buf);
+        }
+    }
+    else if (TRUE == param->encodedStreamInfo.ringBufferEnable && NULL != param->encodedStreamInfo.encodedStreamBuf) {
+
+        if ( ctx->es != NULL ) {
+            if ((ctx->match=Comparator_Act(ctx->es, param->encodedStreamInfo.encodedStreamBuf, param->encodedStreamInfo.encodedStreamBufLength)) == FALSE) {
+                VLOG(ERR, "<%s:%d> INSTANCE #%d Bitstream Mismatch\n", __FUNCTION__, __LINE__, handle->instIndex);
+            }
+        }
+    }
+
+    if (ctx->headerEncDone[param->handle->instIndex] == FALSE) {
+        ctx->headerEncDone[param->handle->instIndex] = TRUE;
+    }
+
+    if (ctx->match == FALSE) CNMAppStop();
+}
+
+void Coda9HandleEncMakeHeaderEvent(Component com, CNMComListenerEncMakeHeader* param, EncListenerContext* ctx)
+{
+    EncodedHeaderBufInfo encHeaderInfo = param->encHeaderInfo;
+    if (0 < encHeaderInfo.encodedHeaderBufSize && NULL != encHeaderInfo.encodedHeaderBuf) {
+        if (NULL != ctx->es) {
+                if ((ctx->match=Comparator_Act(ctx->es, encHeaderInfo.encodedHeaderBuf, encHeaderInfo.encodedHeaderBufSize)) == FALSE) {
+                    VLOG(ERR, "<%s:%d> Header Mismatch\n", __FUNCTION__, __LINE__, param->handle->instIndex);
+                    VLOG(ERR, "<%s:%d> INSTANCE #%d Bitstream Mismatch\n", __FUNCTION__, __LINE__, param->handle->instIndex);
+                }
+        }
+        if (encHeaderInfo.fp) {
+            osal_fwrite(encHeaderInfo.encodedHeaderBuf, encHeaderInfo.encodedHeaderBufSize, 1, encHeaderInfo.fp);
+            osal_fflush(encHeaderInfo.fp);
+        }
+    } else {
+        VLOG(WARN, "<%s:%d> INSTANCE #%d Empty Header\n", __FUNCTION__, __LINE__, param->handle->instIndex);
+    }
+
+    if (ctx->match == FALSE) CNMAppStop();
+}
+
+void EncoderListener(Component com, Uint64 event, void* data, void* context)
+{
+    int         productId;
+    EncHandle   handle;
+#if defined(SUPPORT_MULTI_INSTANCE_TEST) || defined(SUPPORT_LOOK_AHEAD_RC)
+#else
+    /* int         key=0;
+
+    if (osal_kbhit()) {
+        key = osal_getch();
+        osal_flush_ch();
+        if (key) {
+            if (key == 'q' || key == 'Q') {
+                CNMAppStop();
+                return;
+            }
+        }
+    } */
+#endif
+    switch (event) {
+    case COMPONENT_EVENT_ENC_OPEN:
+        break;
+    case COMPONENT_EVENT_ENC_ISSUE_SEQ:
+        break;
+    case COMPONENT_EVENT_ENC_COMPLETE_SEQ:
+        HandleEncCompleteSeqEvent(com, (CNMComListenerEncCompleteSeq*)data, (EncListenerContext*)context);
+        break;
+    case COMPONENT_EVENT_ENC_REGISTER_FB:
+        break;
+    case COMPONENT_EVENT_CODA9_ENC_MAKE_HEADER:
+        Coda9HandleEncMakeHeaderEvent(com, (CNMComListenerEncMakeHeader*)data, (EncListenerContext*)context);
+        break;
+    case COMPONENT_EVENT_ENC_READY_ONE_FRAME:
+        break;
+    case COMPONENT_EVENT_ENC_START_ONE_FRAME:
+        break;
+    case COMPONENT_EVENT_ENC_HANDLING_INT:
+        HandleEncHandlingIntEvent(com, (CNMComListenerHandlingInt*)data, (EncListenerContext*)context);
+        break;
+    case COMPONENT_EVENT_ENC_GET_OUTPUT_INFO:
+        handle = ((CNMComListenerEncDone*)data)->handle;
+        productId = VPU_GetProductId(VPU_HANDLE_CORE_INDEX(handle));
+        if (TRUE == PRODUCT_ID_W_SERIES(productId)) {
+            HandleEncGetOutputEvent(com, (CNMComListenerEncDone*)data, (EncListenerContext*)context);
+        }
+        else {
+            Coda9HandleEncGetOutputEvent(com, (CNMComListenerEncDone*)data, (EncListenerContext*)context);
+        }
+        break;
+    case COMPONENT_EVENT_ENC_ENCODED_ALL:
+        break;
+    case COMPONENT_EVENT_ENC_CLOSE:
+        HandleEncGetEncCloseEvent(com, (CNMComListenerEncClose*)data, (EncListenerContext*)context);
+        break;
+    case COMPONENT_EVENT_ENC_FULL_INTERRUPT:
+        HandleEncFullEvent(com, (CNMComListenerEncFull*)data, (EncListenerContext*)context);
+        break;
+    default:
+        break;
+    }
+}
+
+BOOL SetupEncListenerContext(EncListenerContext* ctx, CNMComponentConfig* config)
+{
+    TestEncConfig* encConfig = &config->testEncConfig;
+
+    osal_memset((void*)ctx, 0x00, sizeof(EncListenerContext));
+
+    if (encConfig->compareType & (1 << MODE_COMP_ENCODED)) {
+        if ((ctx->es=Comparator_Create(STREAM_COMPARE, encConfig->ref_stream_path, encConfig->cfgFileName)) == NULL) {
+            VLOG(ERR, "%s:%d Failed to Comparator_Create(%s)\n", __FUNCTION__, __LINE__, encConfig->ref_stream_path);
+            return FALSE;
+        }
+    }
+    ctx->coreIdx       = encConfig->coreIdx;
+    ctx->streamEndian  = encConfig->stream_endian;
+    ctx->match         = TRUE;
+    ctx->matchOtherInfo= TRUE;
+    ctx->performance   = encConfig->performance;
+    ctx->bandwidth     = encConfig->bandwidth;
+    ctx->pfClock       = encConfig->pfClock;
+    osal_memcpy(ctx->cfgFileName, encConfig->cfgFileName, sizeof(ctx->cfgFileName));
+    ctx->ringBufferEnable     = encConfig->ringBufferEnable;
+    ctx->ringBufferWrapEnable = encConfig->ringBufferWrapEnable;
+
+    return TRUE;
+}
+
+void ClearEncListenerContext(EncListenerContext* ctx)
+{
+    if (ctx->es)    Comparator_Destroy(ctx->es);
+}
+

+ 98 - 0
soft_3rdpart/wave511/code/sample_v2/component_encoder/encoder_listener.h

@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "cnm_app.h"
+#include "misc/bw_monitor.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct EncListenerContext {
+    Uint32      coreIdx;
+    Comparator  es;
+    BOOL        match;
+    BOOL        matchOtherInfo;
+    EndianMode  streamEndian;
+    Uint32      reconWidth;
+    Uint32      reconHeight;
+
+    /* performance & bandwidth */
+    BOOL        performance;
+    BOOL        bandwidth;
+    PFCtx       pfCtx;
+    BWCtx*      bwCtx;
+    Uint32      fps;
+    Uint32      pfClock;
+    char        cfgFileName[MAX_FILE_PATH];
+    BOOL        headerEncDone[MAX_NUM_INSTANCE];
+    BOOL        ringBufferEnable;
+    BOOL        ringBufferWrapEnable;
+} EncListenerContext;
+
+
+void EncoderListener(
+    Component   com,
+    Uint64      event,
+    void*       data,
+    void*       context
+    );
+
+BOOL SetupEncListenerContext(
+    EncListenerContext* ctx,
+    CNMComponentConfig* config
+    );
+
+void ClearEncListenerContext(
+    EncListenerContext* ctx
+    );
+
+void HandleEncFullEvent(
+    Component com, 
+    CNMComListenerEncFull* param, 
+    EncListenerContext* ctx
+    );
+
+void HandleEncGetOutputEvent(
+    Component               com,
+    CNMComListenerEncDone*  param,
+    EncListenerContext*     ctx
+    );
+
+void HandleEncCompleteSeqEvent(
+    Component                       com,
+    CNMComListenerEncCompleteSeq*   param,
+    EncListenerContext*             ctx
+    );
+
+void HandleEncGetEncCloseEvent(
+    Component               com,
+    CNMComListenerEncClose* param,
+    EncListenerContext*     ctx
+    );
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+

+ 55 - 0
soft_3rdpart/wave511/code/sample_v2/component_list_all.h

@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#ifndef __COMPONENT_LIST_H__
+#define __COMPONENT_LIST_H__
+
+//Common components
+extern ComponentImpl feederComponentImpl;
+extern ComponentImpl rendererComponentImpl;
+
+extern ComponentImpl waveDecoderComponentImpl; 
+extern ComponentImpl exampleComponentImpl;
+
+//Common components
+extern ComponentImpl yuvFeederComponentImpl;
+extern ComponentImpl readerComponentImpl;
+
+extern ComponentImpl waveEncoderComponentImpl;
+
+
+static ComponentImpl* componentList[] = {
+    &feederComponentImpl,
+    &rendererComponentImpl,
+    //WAVE series
+    &waveDecoderComponentImpl,
+    &readerComponentImpl,
+    &yuvFeederComponentImpl,
+    &waveEncoderComponentImpl,
+
+    NULL
+};
+#endif
+

+ 43 - 0
soft_3rdpart/wave511/code/sample_v2/component_list_decoder.h

@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#ifndef __COMPONENT_LIST_H__
+#define __COMPONENT_LIST_H__
+
+//Common components
+extern ComponentImpl feederComponentImpl;
+extern ComponentImpl rendererComponentImpl;
+
+extern ComponentImpl waveDecoderComponentImpl; 
+
+static ComponentImpl* componentList[] = {
+    &feederComponentImpl,
+    &rendererComponentImpl,
+    //WAVE series
+    &waveDecoderComponentImpl,
+    NULL
+};
+#endif
+

+ 43 - 0
soft_3rdpart/wave511/code/sample_v2/component_list_encoder.h

@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#ifndef __COMPONENT_LIST_H__
+#define __COMPONENT_LIST_H__
+
+//Common components
+extern ComponentImpl yuvFeederComponentImpl;
+extern ComponentImpl readerComponentImpl;
+
+
+extern ComponentImpl waveEncoderComponentImpl;
+
+static ComponentImpl* componentList[] = {
+    &yuvFeederComponentImpl,
+    &readerComponentImpl,
+    &waveEncoderComponentImpl,
+    NULL
+};
+#endif
+

+ 515 - 0
soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bitstreamfeeder.c

@@ -0,0 +1,515 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <time.h>
+
+#include "vpuapifunc.h"
+#include "main_helper.h"
+
+typedef struct {
+    FeedingMethod   method;
+    Uint8*          remainData;
+    Uint32          remainDataSize;
+    void*           actualFeeder;
+    Uint32          coreIdx;
+    Uint32          room;
+    Uint32          fillingMode;
+    BOOL            eos;
+    DecHandle       decHandle;
+    EndianMode      endian;
+    BSFeederHook    observer;
+    void*           observerArg;
+    vpu_buffer_t    bitBuffer;
+    int             sequenceHeaderSize;
+} BitstreamFeeder;
+
+void*  BitstreamFeeder_GetActualFeeder(void *feeder)
+{
+    BitstreamFeeder*    handle = (BitstreamFeeder*) feeder;
+    return handle->actualFeeder;
+}
+
+static void BitstreamFeeder_DummyObserver(
+    void*   handle,
+    void*   es,
+    Uint32  size,
+    void*   arg
+    )
+{
+    UNREFERENCED_PARAMETER(handle);
+    UNREFERENCED_PARAMETER(es);
+    UNREFERENCED_PARAMETER(size);
+    UNREFERENCED_PARAMETER(arg);
+}
+
+extern void* BSFeederFixedSize_Create(
+    const char* path,
+    CodStd      codecId
+    );
+
+extern BOOL BSFeederFixedSize_Destroy(
+    void* feeder
+    );
+
+extern Int32 BSFeederFixedSize_Act(
+    void*       feeder,
+    BSChunk*    chunk
+    );
+
+extern BOOL BSFeederFixedSize_Rewind(
+    void*       feeder
+    );
+
+extern void BSFeederFixedSize_SetFeedingSize(
+    void*   feeder,
+    Uint32  feedingSize
+    );
+
+extern void* BSFeederFrameSize_Create(
+    const char* path,
+    CodStd      codec
+    );
+
+extern BOOL BSFeederFrameSize_Destroy(
+    void*   feeder
+    );
+
+extern Int32 BSFeederFrameSize_Act(
+    void*       feeder,
+    BSChunk*    packet
+    );
+
+extern BOOL BSFeederFrameSize_Rewind(
+    void*       feeder
+    );
+
+extern void* BSFeederSizePlusEs_Create(
+    const char* path,
+    CodStd      codecId
+    );
+
+extern BOOL BSFeederSizePlusEs_Destroy(
+    void* feeder
+    );
+
+extern Int32 BSFeederSizePlusEs_Act(
+    void*       feeder,
+    BSChunk*    chunk
+    );
+
+extern BOOL BSFeederSizePlusEs_Rewind(
+    void*       feeder
+    );
+
+extern Int32 BSFeederFrameSize_GetStandard(
+    void*       feeder
+    );
+
+extern void* BSFeederBuffer_Create(
+    const char* path,
+    CodStd      codecId
+    );
+
+extern BOOL BSFeederBuffer_Destroy(
+    void* feeder
+    );
+
+extern Int32 BSFeederBuffer_Act(
+    void*       feeder,
+    BSChunk*    chunk
+    );
+
+extern BOOL BSFeederBuffer_Rewind(
+    void*       feeder
+    );
+
+extern void BSFeederBuffer_SetFeedingSize(
+    void*   feeder,
+    Uint32  feedingSize
+    );
+
+/**
+* Abstract Bitstream Feeader Functions
+*/
+void* BitstreamFeeder_Create(
+    Uint32          coreIdx,
+    const char*     path,
+    CodStd          codecId,
+    FeedingMethod   method,
+    EndianMode      endian
+    )
+{
+    /*lint -esym(438, ap) */
+    BitstreamFeeder*    handle = NULL;
+    void*               feeder = NULL;
+
+    switch (method) {
+    case FEEDING_METHOD_FIXED_SIZE:
+        feeder = BSFeederFixedSize_Create(path, codecId);
+        break;
+    case FEEDING_METHOD_FRAME_SIZE:
+        feeder = BSFeederFrameSize_Create(path, codecId);
+        break;
+    case FEEDING_METHOD_SIZE_PLUS_ES:
+        feeder = BSFeederSizePlusEs_Create(path, codecId);
+        break;
+#ifdef USE_FEEDING_METHOD_BUFFER
+    case FEEDING_METHOD_BUFFER:
+        feeder = BSFeederBuffer_Create(path, codecId);
+        break;
+#endif
+    default:
+        feeder = NULL;
+        break;
+    }
+
+    if (feeder != NULL) {
+        if ((handle=(BitstreamFeeder*)osal_malloc(sizeof(BitstreamFeeder))) == NULL) {
+            VLOG(ERR, "%s:%d Failed to allocate memory\n", __FUNCTION__, __LINE__);
+            return NULL;
+        }
+        handle->actualFeeder = feeder;
+        handle->method       = method;
+        handle->remainData   = NULL;
+        handle->remainDataSize = 0;
+        handle->fillingMode  = (method == FEEDING_METHOD_FIXED_SIZE) ? BSF_FILLING_RINGBUFFER : BSF_FILLING_LINEBUFFER;
+        handle->eos          = FALSE;
+        handle->observer     = (BSFeederHook)BitstreamFeeder_DummyObserver;
+        handle->observerArg  = NULL;
+        handle->endian       = endian;
+        handle->coreIdx      = coreIdx;
+    }
+
+    return handle;
+    /*lint +esym(438, ap) */
+}
+
+void BitstreamFeeder_SetFillMode(
+    BSFeeder    feeder,
+    Uint32      mode
+    )
+{
+    BitstreamFeeder* bsf = (BitstreamFeeder*)feeder;
+
+    switch (mode) {
+    case BSF_FILLING_AUTO:
+        bsf->fillingMode  = (bsf->method == FEEDING_METHOD_FIXED_SIZE) ? BSF_FILLING_RINGBUFFER : BSF_FILLING_LINEBUFFER;
+        break;
+    case BSF_FILLING_RINGBUFFER:
+    case BSF_FILLING_LINEBUFFER:
+    case BSF_FILLING_RINGBUFFER_WITH_ENDFLAG:
+        bsf->fillingMode = mode;
+        break;
+    default:
+        VLOG(INFO, "%s Not supported mode %d\n", __FUNCTION__, mode);
+        break;
+    }
+}
+
+BOOL BitstreamFeeder_SetFeedingSize(
+    BSFeeder    feeder,
+    Uint32      size
+    )
+{
+    BitstreamFeeder* bsf = (BitstreamFeeder*)feeder;
+    BOOL             ret = FALSE;
+
+    if (bsf->method == FEEDING_METHOD_FIXED_SIZE) {
+        BSFeederFixedSize_SetFeedingSize(bsf->actualFeeder, size);
+        ret = TRUE;
+    }
+
+    return ret;
+}
+
+Uint32 BitstreamFeeder_Act(
+    BSFeeder            feeder,
+    vpu_buffer_t*       bsBuffer,
+    PhysicalAddress     wrPtr,
+    Uint32              room,
+    PhysicalAddress*    newWrPtr
+    )
+{
+    BitstreamFeeder* bsf = (BitstreamFeeder*)feeder;
+    Int32            feedingSize = 0;
+    BSChunk          chunk = {0};
+    EndianMode       endian;
+
+    if (bsf == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return 0;
+    }
+
+    endian = bsf->endian;
+
+    if (bsf->remainData == NULL) {
+        chunk.size = bsBuffer->size;
+        chunk.data = osal_malloc(chunk.size);
+        chunk.eos  = FALSE;
+        if (chunk.data == NULL) {
+            VLOG(ERR, "%s:%d failed to allocate memory\n", __FUNCTION__, __LINE__);
+            return 0;
+        }
+        switch (bsf->method) {
+        case FEEDING_METHOD_FIXED_SIZE:
+            feedingSize = BSFeederFixedSize_Act(bsf->actualFeeder, &chunk);
+            break;
+        case FEEDING_METHOD_FRAME_SIZE:
+            feedingSize = BSFeederFrameSize_Act(bsf->actualFeeder, &chunk);
+            break;
+        case FEEDING_METHOD_SIZE_PLUS_ES:
+            feedingSize = BSFeederSizePlusEs_Act(bsf->actualFeeder, &chunk);
+            break;
+#ifdef USE_FEEDING_METHOD_BUFFER
+        case FEEDING_METHOD_BUFFER:
+            feedingSize = BSFeederBuffer_Act(bsf->actualFeeder, &chunk);
+            break;
+#endif
+        default:
+            VLOG(ERR, "%s:%d Invalid method(%d)\n", __FUNCTION__, __LINE__, bsf->method);
+            osal_free(chunk.data);
+            return 0;
+        }
+    }
+    else {
+        chunk.data  = bsf->remainData;
+        feedingSize = bsf->remainDataSize;
+    }
+
+    bsf->observer((void*)bsf, chunk.data, feedingSize, bsf->observerArg);
+
+    if (feedingSize < 0) {
+        VLOG(ERR, "feeding size is negative value: %d\n", feedingSize);
+        osal_free(chunk.data);
+        return 0;
+    }
+
+    if (feedingSize > 0) {
+        Uint32          rightSize=0, leftSize=feedingSize;
+        PhysicalAddress base = bsBuffer->phys_addr;
+        Uint32          size = bsBuffer->size;
+
+        if ((Int32)room < feedingSize) {
+            bsf->remainData     = chunk.data;
+            bsf->remainDataSize = feedingSize;
+            return 0;
+        }
+
+        if (bsf->fillingMode == BSF_FILLING_RINGBUFFER || bsf->fillingMode == BSF_FILLING_RINGBUFFER_WITH_ENDFLAG) {
+            if ((wrPtr+feedingSize) >= (base+size)) {
+                PhysicalAddress endAddr = base+size;
+                rightSize = endAddr-wrPtr;
+                leftSize  = (wrPtr+feedingSize) - endAddr;
+                if (rightSize > 0) {
+                    VpuWriteMem(bsf->coreIdx, wrPtr, (unsigned char*)chunk.data, rightSize, (int)endian);
+                    VLOG(TRACE, "<%s:%d> WRPTR: %p SIZE: %x\n", __FUNCTION__, __LINE__, wrPtr, rightSize);
+                }
+                wrPtr = base;
+            }
+        }
+
+        VpuWriteMem(bsf->coreIdx, wrPtr, (unsigned char*)chunk.data+rightSize, leftSize, (int)endian);
+        *newWrPtr = wrPtr + leftSize;
+    }
+
+    bsf->eos = chunk.eos;
+    bsf->sequenceHeaderSize = chunk.seqHeaderSize;
+    osal_free(chunk.data);
+
+    bsf->remainData     = NULL;
+    bsf->remainDataSize = 0;
+
+    return feedingSize;
+}
+
+BOOL BitstreamFeeder_IsEos(
+    BSFeeder    feeder
+    )
+{
+    BitstreamFeeder* bsf = (BitstreamFeeder*)feeder;
+
+    if (bsf == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    return bsf->eos;
+}
+
+Uint32 BitstreamFeeder_GetSeqHeaderSize(
+	BSFeeder    feeder
+	)
+{
+	BitstreamFeeder* bsf = (BitstreamFeeder*)feeder;
+
+	if (bsf == NULL) {
+		VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+		return FALSE;
+	}
+	return bsf->sequenceHeaderSize;
+}
+
+Int32 BitstreamFeeder_GetStandard(
+    BSFeeder    feeder
+    )
+{
+    BitstreamFeeder* bsf = (BitstreamFeeder*)feeder;
+    Int32 standard = -1;
+
+    if (bsf == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    switch (bsf->method) {
+    case FEEDING_METHOD_FRAME_SIZE:
+        standard = BSFeederFrameSize_GetStandard(bsf->actualFeeder);
+        break;
+    case FEEDING_METHOD_FIXED_SIZE:
+    case FEEDING_METHOD_SIZE_PLUS_ES:
+#ifdef USE_FEEDING_METHOD_BUFFER
+    case FEEDING_METHOD_BUFFER:
+#endif
+    default:
+        VLOG(ERR, "%s:%d Invalid return value (%d),  method(%d)\n", __FUNCTION__, __LINE__, -1, bsf->method);
+        break;
+    }
+    return standard;
+}
+
+void BitstreamFeeder_Stop(
+    BSFeeder    feeder
+    )
+{
+    BitstreamFeeder* bsf = (BitstreamFeeder*)feeder;
+
+    if (bsf == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return;
+    }
+}
+
+BOOL BitstreamFeeder_Destroy(
+    BSFeeder feeder
+    )
+{
+    BitstreamFeeder* bsf = (BitstreamFeeder*)feeder;
+
+    if (bsf == NULL) {
+        return FALSE;
+    }
+
+    switch (bsf->method) {
+    case FEEDING_METHOD_FIXED_SIZE:
+        BSFeederFixedSize_Destroy(bsf->actualFeeder);
+        break;
+    case FEEDING_METHOD_FRAME_SIZE:
+        BSFeederFrameSize_Destroy(bsf->actualFeeder);
+        break;
+    case FEEDING_METHOD_SIZE_PLUS_ES:
+        BSFeederSizePlusEs_Destroy(bsf->actualFeeder);
+        break;
+#ifdef USE_FEEDING_METHOD_BUFFER
+    case FEEDING_METHOD_BUFFER:
+        BSFeederBuffer_Destroy(bsf->actualFeeder);
+        break;
+#endif
+    default:
+        VLOG(ERR, "%s:%d Invalid method(%d)\n", __FUNCTION__, __LINE__, bsf->method);
+        break;
+    }
+
+    if (bsf->remainData) {
+        osal_free(bsf->remainData);
+    }
+
+    osal_free(bsf);
+
+    return TRUE;
+}
+
+BOOL BitstreamFeeder_Rewind(
+    BSFeeder feeder
+    )
+{
+    BitstreamFeeder*    bsf = (BitstreamFeeder*)feeder;
+    BOOL                success = FALSE;
+
+    if (bsf == NULL) {
+        VLOG(ERR, "%s:%d handle is NULL\n", __FUNCTION__, __LINE__);
+        return success;
+    }
+
+    switch (bsf->method) {
+    case FEEDING_METHOD_FIXED_SIZE:
+        success = BSFeederFixedSize_Rewind(bsf->actualFeeder);
+        break;
+    case FEEDING_METHOD_FRAME_SIZE:
+        success = BSFeederFrameSize_Rewind(bsf->actualFeeder);
+        break;
+    case FEEDING_METHOD_SIZE_PLUS_ES:
+        success = BSFeederSizePlusEs_Rewind(bsf->actualFeeder);
+        break;
+#ifdef USE_FEEDING_METHOD_BUFFER
+    case FEEDING_METHOD_BUFFER:
+#endif
+    default:
+        VLOG(ERR, "%s:%d Invalid method(%d)\n", __FUNCTION__, __LINE__, bsf->method);
+        break;
+    }
+
+    if (success == TRUE) {
+        bsf->eos = FALSE;
+    }
+
+    return success;
+}
+
+BOOL BitstreamFeeder_SetHook(
+    BSFeeder        feeder,
+    BSFeederHook    hookFunc,
+    void*           hookArg
+    )
+{
+    BitstreamFeeder*    bsf = (BitstreamFeeder*)feeder;
+
+    if (bsf == NULL) {
+        VLOG(ERR, "%s:%d handle is NULL\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    if (hookFunc == NULL) {
+        bsf->observer = (BSFeederHook)BitstreamFeeder_DummyObserver;
+    }
+    else {
+        bsf->observer = hookFunc;
+    }
+    bsf->observerArg  = hookArg;
+
+    return TRUE;
+}
+

+ 173 - 0
soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bitstreamreader.c

@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "main_helper.h"
+
+
+typedef struct {
+    Uint32                  type;
+    EndianMode              endian;
+    BitstreamReaderImpl*    impl;
+    osal_file_t*            fp;
+    EncHandle*              handle;
+} AbstractBitstreamReader;
+
+BitstreamReader BitstreamReader_Create(
+    Uint32      type,
+    char*       path,
+    EndianMode  endian,
+    EncHandle*  handle
+    )
+{
+    AbstractBitstreamReader* reader;
+    osal_file_t *fp=NULL;
+
+    if ( path[0] != 0) {
+        if ((fp=osal_fopen(path, "wb")) == NULL) {
+            VLOG(ERR, "%s:%d failed to open bin file: %s\n", __FUNCTION__, __LINE__, path);
+            return FALSE;
+        }
+        VLOG(INFO, "output bin file: %s\n", path);
+    }
+    else
+        VLOG(ERR, "%s:%d Bitstream File path is NULL : no save\n", __FUNCTION__, __LINE__);
+
+    reader = (AbstractBitstreamReader*)osal_malloc(sizeof(AbstractBitstreamReader));
+
+    reader->fp      = fp;
+    reader->handle  = handle;
+    reader->type    = type;
+    reader->endian  = endian;
+
+    return reader;
+}
+
+BOOL BitstreamReader_Act(
+    BitstreamReader reader,
+    PhysicalAddress bitstreamBuffer,
+    Uint32          bitstreamBufferSize,
+    Uint32          streamReadSize,
+    Comparator      comparator
+    )
+{
+    AbstractBitstreamReader* absReader = (AbstractBitstreamReader*)reader;
+    osal_file_t     *fp;
+    EncHandle       *handle;
+    RetCode         ret = RETCODE_SUCCESS;
+    PhysicalAddress paRdPtr;
+    PhysicalAddress paWrPtr;
+    int             size = 0;
+    Int32           loadSize = 0;
+    PhysicalAddress paBsBufStart = bitstreamBuffer;
+    PhysicalAddress paBsBufEnd   = bitstreamBuffer+bitstreamBufferSize;
+    Uint8*          buf          = NULL;
+    Uint32          coreIdx;
+    BOOL            success      = TRUE;
+
+    if (reader == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+    if (streamReadSize == 0) {
+        return TRUE;
+    }
+    fp = absReader->fp;
+    handle = absReader->handle;
+    coreIdx = VPU_HANDLE_CORE_INDEX(*handle);
+    
+    ret = VPU_EncGetBitstreamBuffer(*handle, &paRdPtr, &paWrPtr, &size);
+    if (size > 0) {
+        if (streamReadSize > 0) {
+            if ((Uint32)size < streamReadSize) {
+                loadSize = size;
+            } 
+            else {
+                loadSize = streamReadSize;
+            }
+        }
+        else {
+            loadSize = size;
+        }
+
+        buf = (Uint8*)osal_malloc(loadSize);
+        if (buf == NULL) {
+            return FALSE;
+        }
+
+        if (absReader->type == BUFFER_MODE_TYPE_RINGBUFFER) {
+            if ((paRdPtr+loadSize) > paBsBufEnd) {
+                Uint32   room = paBsBufEnd - paRdPtr;
+                vdi_read_memory(coreIdx, paRdPtr, buf, room,  absReader->endian);
+                vdi_read_memory(coreIdx, paBsBufStart, buf+room, (loadSize-room), absReader->endian);
+            } 
+            else {
+                vdi_read_memory(coreIdx, paRdPtr, buf, loadSize, absReader->endian); 
+            }
+        } 
+        else {
+            /* Linebuffer */
+            vdi_read_memory(coreIdx, paRdPtr, buf, loadSize, absReader->endian); 
+        }
+
+        if (fp != NULL) {
+            osal_fwrite((void *)buf, sizeof(Uint8), loadSize, fp);
+            osal_fflush(fp);
+        }
+
+        if (comparator != NULL) {
+            if (Comparator_Act(comparator, buf, loadSize) == FALSE) {
+                success = FALSE;
+            }
+        }
+
+        osal_free(buf);
+
+        ret = VPU_EncUpdateBitstreamBuffer(*handle, loadSize);
+        if( ret != RETCODE_SUCCESS ) {
+            VLOG(ERR, "VPU_EncUpdateBitstreamBuffer failed Error code is 0x%x \n", ret );
+            success = FALSE;
+        }
+    }
+
+    return success;
+}
+
+BOOL BitstreamReader_Destroy(
+    BitstreamReader reader
+    )
+{
+    AbstractBitstreamReader* absReader = (AbstractBitstreamReader*)reader;
+
+    if (absReader == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    osal_fclose(absReader->fp);
+    osal_free(absReader);
+
+    return TRUE;
+}
+

+ 125 - 0
soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bsfeeder_buffer_impl.c

@@ -0,0 +1,125 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include "vpuapifunc.h"
+#include "main_helper.h"
+
+#define MAX_FEEDING_SIZE        0x400000        /* 4MBytes */
+#define DEFAULT_FEEDING_SIZE    0x20000         /* 128KBytes */
+
+typedef struct FeederFixedContext {
+    void*           address;
+    Uint32          size;
+    Uint32          offset;
+    Uint32          feedingSize;
+    BOOL            eos;
+} FeederFixedContext;
+
+void* BSFeederBuffer_Create(
+    const char* path,
+    CodStd      codecId
+    )
+{
+    FeederFixedContext*  context=NULL;
+
+    UNREFERENCED_PARAMETER(codecId);
+
+    context = (FeederFixedContext*)osal_malloc(sizeof(FeederFixedContext));
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d failed to allocate memory\n", __FUNCTION__, __LINE__);
+        return NULL;
+    }
+
+    context->feedingSize = DEFAULT_FEEDING_SIZE;
+    context->eos         = FALSE;
+    context->offset = 0;
+    return (void*)context;
+}
+
+BOOL BSFeederBuffer_Destroy(
+    void* feeder
+    )
+{
+    FeederFixedContext* context = (FeederFixedContext*)feeder;
+
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    osal_free(context);
+
+    return TRUE;
+}
+
+void BSFeederBuffer_SetData(
+    void*       feeder,
+    char*       address,
+    Uint32       size)
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+    context->address = address;
+    context->size = size;
+}
+
+void BSFeederBuffer_SetEos(void*       feeder)
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+    context->eos = TRUE;
+}
+
+BOOL BSFeederBuffer_GetEos(void*       feeder)
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+    return context->eos;
+}
+
+Int32 BSFeederBuffer_Act(
+    void*       feeder,
+    BSChunk*    chunk
+    )
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return 0;
+    }
+    // Due to memory performance, memset is temporarily commented
+    // osal_memset(chunk->data, 0x00, chunk->size);
+    if (context->size == 0) {
+        chunk->eos = TRUE;
+        return 0;
+    }
+
+    do {
+        osal_memcpy(chunk->data, context->address, context->size);
+    } while (FALSE);
+
+    return context->size;
+}
+
+BOOL BSFeederBuffer_Rewind(
+    void*       feeder
+    )
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+
+    context->eos = FALSE;
+
+    return TRUE;
+}
+
+void BSFeederBuffer_SetFeedingSize(
+    void*   feeder,
+    Uint32  feedingSize
+    )
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+    if (feedingSize > 0) {
+        context->feedingSize = feedingSize;
+    }
+}
+

+ 168 - 0
soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bsfeeder_fixedsize_impl.c

@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include "vpuapifunc.h"
+#include "main_helper.h"
+
+#define MAX_FEEDING_SIZE        0x400000        /* 4MBytes */
+#define DEFAULT_FEEDING_SIZE    0x20000         /* 128KBytes */
+
+typedef struct FeederFixedContext {
+    osal_file_t*    fp;
+    Uint32          feedingSize;
+    BOOL            eos;
+} FeederFixedContext;
+
+void* BSFeederFixedSize_Create(
+    const char* path,
+    CodStd      codecId
+    )
+{
+    osal_file_t*    fp = NULL;
+    FeederFixedContext*  context=NULL;
+
+    UNREFERENCED_PARAMETER(codecId);
+
+    if ((fp=osal_fopen(path, "rb")) == NULL) {
+        VLOG(ERR, "%s:%d failed to open %s\n", __FUNCTION__, __LINE__, path);
+        return NULL;
+    }
+
+    context = (FeederFixedContext*)osal_malloc(sizeof(FeederFixedContext));
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d failed to allocate memory\n", __FUNCTION__, __LINE__);
+        osal_fclose(fp);
+        return NULL;
+    }
+
+    context->fp          = fp;
+    context->feedingSize = DEFAULT_FEEDING_SIZE;
+    context->eos         = FALSE;
+
+    return (void*)context;
+}
+
+BOOL BSFeederFixedSize_Destroy(
+    void* feeder
+    )
+{
+    FeederFixedContext* context = (FeederFixedContext*)feeder;
+
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    if (context->fp) 
+        osal_fclose(context->fp);
+
+    osal_free(context);
+
+    return TRUE;
+}
+
+Int32 BSFeederFixedSize_Act(
+    void*       feeder,
+    BSChunk*    chunk
+    )
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+    size_t          nRead;
+    Uint32          size;
+    Uint32          feedingSize;
+
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return 0;
+    }
+
+    if (context->eos == TRUE) {
+        chunk->eos = TRUE;
+        return 0;
+    }
+
+    feedingSize = context->feedingSize;
+    if (feedingSize == 0) {
+        Uint32  KB = 1024;
+        BOOL    probability10;
+
+        srand((Uint32)time(NULL));
+        feedingSize   = rand() % MAX_FEEDING_SIZE;
+        probability10 = (BOOL)((feedingSize%100) < 10);
+        if (feedingSize < KB) {
+            if (probability10 == FALSE) 
+                feedingSize *= 100;
+        }
+    }
+
+    size = (chunk->size < feedingSize) ? chunk->size : feedingSize;
+
+    do {
+        nRead = osal_fread(chunk->data, 1, size, context->fp);
+        if ((Int32)nRead < 0) {
+            VLOG(ERR, "%s:%d failed to read bitstream(errno: %d)\n", __FUNCTION__, __LINE__, errno);
+            return 0;
+        } 
+        else if (nRead < size) {
+            context->eos = TRUE;
+            chunk->eos   = TRUE;
+        }
+    } while (FALSE);
+
+    return nRead;
+}
+
+BOOL BSFeederFixedSize_Rewind(
+    void*       feeder
+    )
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+    Int32           ret;
+
+    if ((ret=osal_fseek(context->fp, 0, SEEK_SET)) != 0) {
+        VLOG(ERR, "%s:%d Failed to fseek(ret: %d)\n", __FUNCTION__, __LINE__, ret);
+        return FALSE;
+    }
+    context->eos = FALSE;
+
+    return TRUE;
+}
+
+void BSFeederFixedSize_SetFeedingSize(
+    void*   feeder,
+    Uint32  feedingSize
+    )
+{
+    FeederFixedContext*  context = (FeederFixedContext*)feeder;
+    if (feedingSize > 0) {
+        context->feedingSize = feedingSize;
+    }
+}
+

+ 1158 - 0
soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bsfeeder_framesize_impl.c

@@ -0,0 +1,1158 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "main_helper.h"
+#ifdef SUPPORT_LIB_THEORA
+#include "theora_parser.h"
+#endif /* SUPPORT_LIB_THEORA */
+#ifdef SUPPORT_FFMPEG_DEMUX
+#include <libavformat/avformat.h>
+
+#define RCV_V2
+#define IS_VP9_SUPERFRAME(__header)     ((__header & 0xe0) == 0xc0)
+#define MAX_VP9_SUPERFRAME_INDEX_SIZE   34
+#define VP9_MAX_SUBFRAMES               8
+
+typedef struct VP9Superframe {
+    Uint32  nframes;
+    Uint32  frameSize[VP9_MAX_SUBFRAMES];
+    void*   frames[VP9_MAX_SUBFRAMES];   /* A superframe has multiple frames up to 8 frames. */
+    Uint32  currentIndex;
+} VP9Superframe;
+
+static BOOL initFFmpeg;
+
+typedef struct FeederFrameContext {
+    AVFormatContext*    avContext;
+    BOOL                isFirstPacket;
+    Uint32              videoIndex;
+    Uint32              standard;
+    Uint32              mp4ClassId;
+    Uint8*              tempBuffer;
+    Uint32              tempRdPtr;
+    Uint32              tempWrPtr;
+    VP9Superframe       superframe;
+#ifdef SUPPORT_LIB_THEORA
+    tho_parser_t*       theora;
+#endif /* SUPPORT_LIB_THEORA */
+} FeederFrameContext;
+
+static Uint32 u_bytes(
+    Uint8*  data,
+    Uint32  len
+    )
+{
+    Uint32  i;
+    Uint32  val=0;
+
+    for (i=0; i<len; i++) {
+        val |= data[i] << (i*8);
+    }
+
+    return val;
+}
+
+static BOOL VP9ParseSuperframe(
+    void*           chunk,
+    Uint32          size,
+    VP9Superframe*  superframe
+    )
+{
+    Uint32  startPos;
+    Uint32  frameSizeLength = 0;
+    Uint32  numFrames, totalSubframeSize = 0;
+    Uint32  i;
+    Uint8*  pData = NULL, superframeMarker;
+
+    startPos = size - 1;
+
+    pData = (Uint8*)chunk;
+    pData = &pData[startPos];
+    superframeMarker = *pData;
+
+    frameSizeLength = ((*pData>>3) & 0x03) + 1;
+    numFrames       = (*pData&0x07) + 1;
+    pData           -= frameSizeLength * numFrames + 1;
+    /* Check first SUPERFRAME_MARKER */
+    if (*pData != superframeMarker) {
+        VLOG(ERR, "INVALID POST SUPERFRAME_MARKER\n");
+        return FALSE;
+    }
+    pData++;
+
+    for (i=0; i<numFrames; i++) {
+        superframe->frameSize[i] = u_bytes(pData, frameSizeLength);
+        pData += frameSizeLength;
+    }
+
+    /* Check size */
+    for (i=0; i<numFrames; i++) {
+        totalSubframeSize += superframe->frameSize[i];
+    }
+    if (totalSubframeSize >= size) {
+        VLOG(ERR, "TOTAL SIZE OF SUBFRAMES IS BIGGER THAN CHUNK SIZE\n");
+        return FALSE;
+    }
+
+    pData = (Uint8*)chunk;
+    for (i=0; i<numFrames; i++) {
+        superframe->frames[i] = (void*)osal_malloc(superframe->frameSize[i]);
+        osal_memcpy(superframe->frames[i], (void*)pData, superframe->frameSize[i]);
+        pData += superframe->frameSize[i];
+    }
+    superframe->currentIndex = 0;
+    superframe->nframes      = numFrames;
+
+    return TRUE;
+}
+
+static Int32 BuildSeqHeader(
+    Uint8*        pbHeader,
+    const CodStd    codStd,
+    const AVStream* st,
+    Int32*        sizelength
+    )
+{
+    /*lint -save -e438 */
+    AVCodecParameters* avc = st->codecpar;
+
+    Uint8*        pbMetaData = avc->extradata;
+    Int32         nMetaData = avc->extradata_size;
+    Uint8* p =    pbMetaData;
+    Uint8 *a =    p + 4 - ((long) p & 3);
+    Uint8* t =    pbHeader;
+    Int32         size;
+    Int32         fourcc;
+    Int32         sps, pps, i, nal;
+    Int32         frameRate = 0;
+
+    fourcc = avc->codec_tag;
+    if (!fourcc)
+        fourcc = ConvCodecIdToFourcc(avc->codec_id);
+
+    if (st->avg_frame_rate.den && st->avg_frame_rate.num)
+        frameRate = (Int32)((double)st->avg_frame_rate.num/(double)st->avg_frame_rate.den);
+
+    size = 0;
+    *sizelength = 4; // default size length(in bytes) = 4
+    if (codStd == STD_AVC || codStd == STD_AVS) {
+        if (nMetaData > 1 && pbMetaData && pbMetaData[0] == 0x01) {
+            // check mov/mo4 file format stream
+            p += 4;
+            *sizelength = (*p++ & 0x3) + 1;
+            sps = (*p & 0x1f); // Number of sps
+            p++;
+            for (i = 0; i < sps; i++) {
+                nal = (*p << 8) + *(p + 1) + 2;
+                PUT_BYTE(t, 0x00);
+                PUT_BYTE(t, 0x00);
+                PUT_BYTE(t, 0x00);
+                PUT_BYTE(t, 0x01);
+                PUT_BUFFER(t, p+2, nal-2);
+                p += nal;
+                size += (nal - 2 + 4); // 4 => length of start code to be inserted
+            }
+
+            pps = *(p++); // number of pps
+            for (i = 0; i < pps; i++)
+            {
+                nal = (*p << 8) + *(p + 1) + 2;
+                PUT_BYTE(t, 0x00);
+                PUT_BYTE(t, 0x00);
+                PUT_BYTE(t, 0x00);
+                PUT_BYTE(t, 0x01);
+                PUT_BUFFER(t, p+2, nal-2);
+                p += nal;
+                size += (nal - 2 + 4); // 4 => length of start code to be inserted
+            }
+        }
+        else if(nMetaData > 3) {
+            size = -1;// return to meaning of invalid stream data;
+            for (; p < a; p++) {
+                if (p[0] == 0 && p[1] == 0 && p[2] == 1)  {
+                    // find startcode
+                    size = avc->extradata_size;
+                    if (!pbHeader || !pbMetaData)
+                        return 0;
+                    PUT_BUFFER(pbHeader, pbMetaData, size);
+                    break;
+                }
+            }
+        }
+    }
+    else if (codStd == STD_HEVC) {
+        if (nMetaData > 1 && pbMetaData && pbMetaData[0] == 0x01) {
+            static const Uint8 nalu_header[4] = { 0, 0, 0, 1 };
+            Int32 numOfArrays = 0;
+            Uint16 numNalus = 0;
+            Uint16 nalUnitLength = 0;
+            Uint32 offset = 0;
+
+            p += 21;
+            *sizelength = (*p++ & 0x3) + 1;
+            numOfArrays = *p++;
+
+            while(numOfArrays--) {
+                p++;   // NAL type
+                numNalus = (*p << 8) + *(p + 1);
+                p+=2;
+                for(i = 0;i < numNalus;i++)
+                {
+                    nalUnitLength = (*p << 8) + *(p + 1);
+                    p+=2;
+                    //if(i == 0)
+                    {
+                        osal_memcpy(pbHeader + offset, nalu_header, 4);
+                        offset += 4;
+                        osal_memcpy(pbHeader + offset, p, nalUnitLength);
+                        offset += nalUnitLength;
+                    }
+                    p += nalUnitLength;
+                }
+            }
+
+            size = offset;
+        }
+        else if(nMetaData > 3)
+        {
+            size = -1;// return to meaning of invalid stream data;
+
+            for (; p < a; p++)
+            {
+                if (p[0] == 0 && p[1] == 0 && p[2] == 1) // find startcode
+                {
+                    size = avc->extradata_size;
+                    if (!pbHeader || !pbMetaData)
+                        return 0;
+                    PUT_BUFFER(pbHeader, pbMetaData, size);
+                    break;
+                }
+            }
+        }
+    }
+    else if (codStd == STD_VC1)
+    {
+        if (!fourcc)
+            return -1;
+        if (fourcc == MKTAG('W', 'V', 'C', '1') || fourcc == MKTAG('W', 'M', 'V', 'A'))	//VC AP
+        {
+            size = nMetaData;
+            PUT_BUFFER(pbHeader, pbMetaData, size);
+            //if there is no seq startcode in pbMetatData. VPU will be failed at seq_init stage.
+        }
+        else
+        {
+#ifdef RCV_V2
+            PUT_LE32(pbHeader, ((0xC5 << 24)|0));
+            size += 4; //version
+            PUT_LE32(pbHeader, nMetaData);
+            size += 4;
+            PUT_BUFFER(pbHeader, pbMetaData, nMetaData);
+            size += nMetaData;
+            PUT_LE32(pbHeader, avc->height);
+            size += 4;
+            PUT_LE32(pbHeader, avc->width);
+            size += 4;
+            PUT_LE32(pbHeader, 12);
+            size += 4;
+            PUT_LE32(pbHeader, 2 << 29 | 1 << 28 | 0x80 << 24 | 1 << 0);
+            size += 4; // STRUCT_B_FRIST (LEVEL:3|CBR:1:RESERVE:4:HRD_BUFFER|24)
+            PUT_LE32(pbHeader, avc->bit_rate);
+            size += 4; // hrd_rate
+            PUT_LE32(pbHeader, frameRate);
+            size += 4; // frameRate
+#else	//RCV_V1
+            PUT_LE32(pbHeader, (0x85 << 24) | 0x00);
+            size += 4; //frames count will be here
+            PUT_LE32(pbHeader, nMetaData);
+            size += 4;
+            PUT_BUFFER(pbHeader, pbMetaData, nMetaData);
+            size += nMetaData;
+            PUT_LE32(pbHeader, avc->height);
+            size += 4;
+            PUT_LE32(pbHeader, avc->width);
+            size += 4;
+#endif
+        }
+    }
+    else if (codStd == STD_RV)
+    {
+        Int32 st_size =0;
+
+        if (!fourcc)
+            return -1;
+        if (fourcc != MKTAG('R','V','3','0') && fourcc != MKTAG('R','V','4','0'))
+            return -1;
+
+        size = 26 + nMetaData;
+        PUT_BE32(pbHeader, size); //Length
+        PUT_LE32(pbHeader, MKTAG('V', 'I', 'D', 'O')); //MOFTag
+        PUT_LE32(pbHeader, fourcc); //SubMOFTagl
+        PUT_BE16(pbHeader, avc->width);
+        PUT_BE16(pbHeader, avc->height);
+        PUT_BE16(pbHeader, 0x0c); //BitCount;
+        PUT_BE16(pbHeader, 0x00); //PadWidth;
+        PUT_BE16(pbHeader, 0x00); //PadHeight;
+
+        PUT_LE32(pbHeader, frameRate);
+        PUT_BUFFER(pbHeader, pbMetaData, nMetaData); //OpaqueDatata
+        size += st_size; //add for startcode pattern.
+    }
+    else if (codStd == STD_DIV3) {
+        // not implemented yet
+        if (!nMetaData) {
+            PUT_LE32(pbHeader, MKTAG('C', 'N', 'M', 'V')); //signature 'CNMV'
+            PUT_LE16(pbHeader, 0x00);                      //version
+            PUT_LE16(pbHeader, 0x20);                      //length of header in bytes
+            PUT_LE32(pbHeader, MKTAG('D', 'I', 'V', '3')); //codec FourCC
+            PUT_LE16(pbHeader, avc->width);                //width
+            PUT_LE16(pbHeader, avc->height);               //height
+            PUT_LE32(pbHeader, st->avg_frame_rate.num);      //frame rate
+            PUT_LE32(pbHeader, st->avg_frame_rate.den);      //time scale(?)
+            PUT_LE32(pbHeader, st->nb_index_entries);      //number of frames in file
+            PUT_LE32(pbHeader, 0); //unused
+            size += 32;
+            return size;
+        }
+
+        PUT_BE32(pbHeader, nMetaData);
+        size += 4;
+
+        PUT_BUFFER(pbHeader, pbMetaData, nMetaData);
+        size += nMetaData;
+    }
+
+    else if (codStd == STD_VP8) {
+        PUT_LE32(pbHeader, MKTAG('D', 'K', 'I', 'F')); //signature 'DKIF'
+        PUT_LE16(pbHeader, 0x00);                      //version
+        PUT_LE16(pbHeader, 0x20);                      //length of header in bytes
+        PUT_LE32(pbHeader, MKTAG('V', 'P', '8', '0')); //codec FourCC
+        PUT_LE16(pbHeader, avc->width);                //width
+        PUT_LE16(pbHeader, avc->height);               //height
+        PUT_LE32(pbHeader, st->avg_frame_rate.num);      //frame rate
+        PUT_LE32(pbHeader, st->avg_frame_rate.den);      //time scale(?)
+        PUT_LE32(pbHeader, st->nb_index_entries);      //number of frames in file
+        PUT_LE32(pbHeader, 0); //unused
+        size += 32;
+    }
+    else if (codStd == STD_VP9) {
+        size = 0; // no header is needed because VP9 doesn't support interrupt mode.
+    }
+    else {
+        PUT_BUFFER(pbHeader, pbMetaData, nMetaData);
+        size = nMetaData;
+    }
+
+    return size;
+    /*lint -restore */
+}
+
+static Int32 BuildPicHeader(
+    Uint8*        pbHeader,
+    const CodStd    codStd,
+    const AVStream* st,
+    const AVPacket* pkt,
+    Int32         sizelength
+    )
+{
+    AVCodecParameters* avc = st->codecpar;
+    Int64         frame_number = st->nb_frames;
+    Uint8*        pbChunk = pkt->data;
+    Int32         size = 0;
+    Int32         fourcc;
+    Int32         cSlice, nSlice;
+    Int32         i, val, offset;
+    BOOL          hasStartCode = 0;
+
+    size = 0;
+    offset = 0;
+    fourcc = avc->codec_tag;
+    if (!fourcc)
+        fourcc = ConvCodecIdToFourcc(avc->codec_id);
+
+    if (codStd == STD_VC1) {
+        if (!fourcc)
+            return -1;
+
+        if (fourcc == MKTAG('W', 'V', 'C', '1') || fourcc == MKTAG('W', 'M', 'V', 'A')) {
+            if (pbChunk[0] != 0 || pbChunk[1] != 0 || pbChunk[2] != 1) {
+                // check start code as prefix (0x00, 0x00, 0x01)
+                pbHeader[0] = 0x00;
+                pbHeader[1] = 0x00;
+                pbHeader[2] = 0x01;
+                pbHeader[3] = 0x0D;	// replace to the correct picture header to indicate as frame
+
+                size += 4;
+            }
+        }
+        else {
+            PUT_LE32(pbHeader, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
+            size += 4;
+#ifdef RCV_V2
+            if (AV_NOPTS_VALUE == pkt->pts) {
+                PUT_LE32(pbHeader, 0);
+            }
+            else {
+                PUT_LE32(pbHeader, (int)((double)(pkt->pts/st->time_base.den))); // milli_sec
+            }
+            size += 4;
+#endif
+        }
+    }
+    else if (codStd == STD_HEVC) {
+        if(pkt->size < 5)
+            return 0;
+
+        if (!(avc->extradata_size > 1 && avc->extradata && avc->extradata[0] == 0x01))
+        {
+            const Uint8 *pbEnd = pbChunk + 4 - ((intptr_t)pbChunk & 3);
+
+            for (; pbChunk < pbEnd ; pbChunk++) {
+                if (pbChunk[0] == 0 && pbChunk[1] == 0 && pbChunk[2] == 1) {
+                    hasStartCode = TRUE;
+                    break;
+                }
+            }
+        }
+
+        if ((!hasStartCode && avc->extradata[0] == 0x01) ||
+            (avc->extradata_size > 1 && avc->extradata && avc->extradata[0] == 0x01)) {
+            // check sequence metadata if the stream is mov/mo4 file format.
+            pbChunk = pkt->data;
+            while (offset < pkt->size) {
+                if(sizelength == 3) {
+                    nSlice = pbChunk[offset] << 16 | pbChunk[offset+1] << 8 | pbChunk[offset+2];
+
+                    pbChunk[offset] = 0x00;
+                    pbChunk[offset+1] = 0x00;
+                    pbChunk[offset+2] = 0x01;
+
+                    offset += 3;
+                }
+                else {// sizeLength = 4
+                    nSlice = pbChunk[offset] << 24 | pbChunk[offset+1] << 16 | pbChunk[offset+2] << 8 | pbChunk[offset+3];
+
+                    pbChunk[offset] = 0x00;
+                    pbChunk[offset+1] = 0x00;
+                    pbChunk[offset+2] = 0x00;
+                    pbChunk[offset+3] = 0x01;		//replace size to startcode
+
+                    offset += 4;
+                }
+
+                switch ((pbChunk[offset]&0x7E)>>1) { /* NAL unit */
+                case 39: /* PREFIX SEI */
+                case 40: /* SUFFIX SEI */
+                case 32: /* VPS */
+                case 33: /* SPS */
+                case 34: /* PPS */
+                    /* check next */
+                    break;
+                }
+
+                offset += nSlice;
+            }
+        }
+    }
+    else if (codStd == STD_RV) {
+        int st_size = 0;
+
+        if (!fourcc)
+            return -1;
+        if (fourcc != MKTAG('R','V','3','0') && fourcc != MKTAG('R','V','4','0')) // RV version 8, 9 , 10
+            return -1;
+
+        cSlice = pbChunk[0] + 1;
+        nSlice =  pkt->size - 1 - (cSlice * 8);
+        size = 20 + (cSlice*8);
+
+        PUT_BE32(pbHeader, nSlice);
+        if (AV_NOPTS_VALUE == pkt->pts) {
+            PUT_LE32(pbHeader, 0);
+        }
+        else {
+            PUT_LE32(pbHeader, (int)((double)(pkt->pts/st->time_base.den))); // milli_sec
+        }
+
+        PUT_BE16(pbHeader, frame_number);
+        PUT_BE16(pbHeader, 0x02); //Flags
+        PUT_BE32(pbHeader, 0x00); //LastPacket
+        PUT_BE32(pbHeader, cSlice); //NumSegments
+        offset = 1;
+        for (i = 0; i < (int) cSlice; i++)
+        {
+            val = (pbChunk[offset+3] << 24) | (pbChunk[offset+2] << 16) | (pbChunk[offset+1] << 8) | pbChunk[offset];
+            PUT_BE32(pbHeader, val); //isValid
+            offset += 4;
+            val = (pbChunk[offset+3] << 24) | (pbChunk[offset+2] << 16) | (pbChunk[offset+1] << 8) | pbChunk[offset];
+            PUT_BE32(pbHeader, val); //Offset
+            offset += 4;
+        }
+
+        size += st_size;
+    }
+    else if (codStd == STD_AVC) {
+        if(pkt->size < 5)
+            return 0;
+
+        if (!(avc->extradata_size > 1 && avc->extradata && avc->extradata[0] == 0x01)) {
+            const Uint8 *pbEnd = pbChunk + 4 - ((intptr_t)pbChunk & 3);
+
+            for (; pbChunk < pbEnd ; pbChunk++) {
+                if (pbChunk[0] == 0 && pbChunk[1] == 0 && pbChunk[2] == 1) {
+                    hasStartCode = 1;
+                    break;
+                }
+            }
+        }
+
+        if ((!hasStartCode && avc->extradata[0] == 0x01) ||
+            (avc->extradata_size > 1 && avc->extradata && avc->extradata[0] == 0x01)) {
+            // check sequence metadata if the stream is mov/mo4 file format.
+            pbChunk = pkt->data;
+
+            while (offset < pkt->size) {
+                if(sizelength == 3) {
+                    nSlice = pbChunk[offset] << 16 | pbChunk[offset+1] << 8 | pbChunk[offset+2];
+                    pbChunk[offset] = 0x00;
+                    pbChunk[offset+1] = 0x00;
+                    pbChunk[offset+2] = 0x01;
+                    offset += 3;
+                }
+                else {  // size length = 4
+                    nSlice = pbChunk[offset] << 24 | pbChunk[offset+1] << 16 | pbChunk[offset+2] << 8 | pbChunk[offset+3];
+                    pbChunk[offset] = 0x00;
+                    pbChunk[offset+1] = 0x00;
+                    pbChunk[offset+2] = 0x00;
+                    pbChunk[offset+3] = 0x01;		//replace size to startcode
+                    offset += 4;
+                }
+
+                switch (pbChunk[offset]&0x1f) { /* NAL unit */
+                case 6: /* SEI */
+                case 7: /* SPS */
+                case 8: /* PPS */
+                case 9: /* AU */
+                    /* check next */
+                    break;
+                }
+
+                offset += nSlice;
+            }
+        }
+    }
+    else if(codStd == STD_AVS) {
+        const Uint8* pbEnd;
+
+        if(pkt->size < 5)
+            return 0;
+
+        pbEnd = pbChunk + 4 - ((intptr_t)pbChunk & 3);
+
+        for (; pbChunk < pbEnd ; pbChunk++) {
+            if (pbChunk[0] == 0 && pbChunk[1] == 0 && pbChunk[2] == 1) {
+                hasStartCode = 1;
+                break;
+            }
+        }
+
+        if(hasStartCode == 0) {
+            pbChunk = pkt->data;
+
+            while (offset < pkt->size) {
+                nSlice = pbChunk[offset] << 24 | pbChunk[offset+1] << 16 | pbChunk[offset+2] << 8 | pbChunk[offset+3];
+
+                pbChunk[offset]   = 0x00;
+                pbChunk[offset+1] = 0x00;
+                pbChunk[offset+2] = 0x00;
+                pbChunk[offset+3] = 0x00;		//replace size to startcode
+                pbChunk[offset+4] = 0x01;
+
+                offset += 4;
+
+                switch (pbChunk[offset]&0x1f) /* NAL unit */
+                {
+                case 6: /* SEI */
+                case 7: /* SPS */
+                case 8: /* PPS */
+                case 9: /* AU */
+                    /* check next */
+                    break;
+                }
+
+                offset += nSlice;
+            }
+        }
+    }
+    else if (codStd == STD_DIV3 || codStd == STD_VP8) {
+        PUT_LE32(pbHeader,pkt->size);
+        PUT_LE32(pbHeader,0);
+        PUT_LE32(pbHeader,0);
+        size += 12;
+    }
+    return size;
+}
+
+#ifdef SUPPORT_LIB_THEORA
+static Int32 MakeupTheoraPacket(
+    tho_parser_t*   theora,
+    BSChunk*        packet,
+    AVPacket*       avPacket,
+    Uint32        seqSize
+    )
+{
+    size_t size;
+    Int32 ret;
+    Uint8* stream = (Uint8*)packet->data;
+
+    ret = theora->read_frame(theora->handle, avPacket->data, avPacket->size);
+    if (ret < 0) {
+        VLOG(ERR, "%s:%d failed to read theora frame\n", __FUNCTION__, __LINE__);
+        return -1;
+    }
+
+    size = theora_make_stream(theora->handle, stream+seqSize, PIC_RUN);
+
+    return (size + seqSize);
+}
+#endif
+
+
+void* BSFeederFrameSize_Create(
+    const char* path,
+    CodStd      codecId
+    )
+{
+    /*lint -esym(438, avContext) */
+    FeederFrameContext* ffmpegReader = NULL;
+    AVFormatContext*    avContext    = NULL;
+    AVCodecParameters*  codec        = NULL;
+    AVInputFormat*    fmt          = NULL;
+    Int32             error;
+    Int32             videoIndex;
+    Uint32            mp4ClassId;
+    Int32             standard;
+
+
+    vdi_lock(0);
+    if (initFFmpeg == FALSE) {
+        initFFmpeg = TRUE;
+    }
+    vdi_unlock(0);
+
+    if ((avContext=avformat_alloc_context()) == NULL) {
+        return NULL;
+    }
+
+    avContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+    if ((error=avformat_open_input(&avContext, path, fmt, NULL))) {
+        VLOG(ERR, "%s:%d failed to av_open_input_file error(%d), %s\n",
+             __FILE__, __LINE__, error, path);
+        goto __failed_to_end;
+    }
+
+    if ((error=avformat_find_stream_info(avContext, NULL)) < 0) {
+        VLOG(ERR, "%s:%d failed to avformat_find_stream_info. error(%d)\n",
+            __FUNCTION__, __LINE__, error);
+        goto __failed_to_end;
+    }
+
+    videoIndex = av_find_best_stream(avContext, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
+    if (videoIndex < 0) {
+        VLOG(ERR, "%s:%d failed to av_find_best_stream.\n", __FUNCTION__, __LINE__);
+        goto __failed_to_end;
+    }
+
+    codec = avContext->streams[videoIndex]->codecpar;
+    standard = ConvFOURCCToCodStd(codec->codec_tag);
+
+    if (standard == -1)
+        standard = ConvCodecIdToCodStd(codec->codec_id);
+
+    mp4ClassId = ConvFOURCCToMp4Class(codec->codec_tag);
+    if (mp4ClassId == (Uint32)-1)
+        mp4ClassId = ConvCodecIdToMp4Class(codec->codec_id);
+
+    if (standard != STD_MPEG4) {
+        mp4ClassId = 0;
+    }
+
+    if ((ffmpegReader=(FeederFrameContext*)osal_malloc(sizeof(FeederFrameContext))) == NULL)
+        goto __failed_to_end;
+
+    ffmpegReader->standard      = standard;
+    ffmpegReader->mp4ClassId    = mp4ClassId;
+    ffmpegReader->avContext     = avContext;
+    ffmpegReader->videoIndex    = videoIndex;
+    ffmpegReader->isFirstPacket = TRUE;
+    ffmpegReader->tempBuffer    = NULL;
+    ffmpegReader->tempRdPtr     = 0;
+    ffmpegReader->tempWrPtr     = 0;
+    osal_memset((void*)&ffmpegReader->superframe, 0x00, sizeof(VP9Superframe));
+
+#ifdef SUPPORT_LIB_THEORA
+    ffmpegReader->theora        = NULL;
+    if (standard == STD_THO || standard == STD_VP3) {
+        theora_parser_init((void**)&ffmpegReader->theora);
+    }
+#endif /* SUPPORT_LIB_THEORA */
+
+    return (void*)ffmpegReader;
+
+__failed_to_end:
+    if (avContext) {
+        avformat_free_context(avContext);
+        avContext = NULL;
+    }
+
+    if (ffmpegReader) {
+#ifdef SUPPORT_LIB_THEORA
+        if (ffmpegReader->theora)
+            ffmpegReader->theora->close(ffmpegReader->theora);
+#endif /* SUPPORT_LIB_THEORA */
+        osal_free(ffmpegReader);
+    }
+
+    return NULL;
+    /*lint +esym(438, avContext) */
+}
+
+BOOL BSFeederFrameSize_Destroy(
+    void*   feeder
+    )
+{
+    FeederFrameContext*  ctx = (FeederFrameContext*)feeder;
+    Uint32          i;
+
+
+    if (ctx == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    if (ctx->avContext)
+        avformat_close_input(&ctx->avContext);
+
+#ifdef SUPPORT_LIB_THEORA
+    if (ctx->theora)
+        ctx->theora->close(ctx->theora);
+#endif /* SUPPORT_LIB_THEORA */
+
+    for (i=0; i<ctx->superframe.nframes; i++) {
+        if (ctx->superframe.frames[i] != NULL) {
+            osal_free(ctx->superframe.frames[i]);
+        }
+    }
+
+    osal_free(ctx);
+
+    return TRUE;
+}
+
+Int32 BSFeederFrameSize_Act(
+    void*       feeder,
+    BSChunk*    packet
+    )
+{
+    FeederFrameContext* ffmpegReader = (FeederFrameContext*)feeder;
+    AVFormatContext*    avFormatContext = ffmpegReader->avContext;
+    AVPacket            avpacket;
+    Int32               error;
+    Uint8*              seqHeader = NULL;
+    Uint8*              picHeader = NULL;
+    Uint8*              ptr;
+    Int32               seqHeaderSize;
+    Int32               picHeaderSize;
+    Uint32              vindex, size;
+    Int32               retSize = -1;
+    Int32               packetSize = -1;
+#ifdef SUPPORT_LIB_THEORA
+    Uint32              thoSeqSize = 0;
+#endif
+
+
+    if (ffmpegReader->tempBuffer) {
+        goto __consume_tempBuffer;
+    }
+
+    if (ffmpegReader->standard == STD_VP9) {
+        VP9Superframe* superframe = &ffmpegReader->superframe;
+        if (superframe->nframes > 0) {
+            Uint32 idx = superframe->currentIndex;
+            if (idx < superframe->nframes) {
+                osal_memcpy(packet->data, superframe->frames[idx], superframe->frameSize[idx]);
+                packet->size = superframe->frameSize[idx];
+                superframe->currentIndex++;
+                return packet->size;
+            }
+            else {
+                Uint32 i;
+                for (i=0; i<VP9_MAX_SUBFRAMES; i++) {
+                    if (superframe->frames[i] != NULL) {
+                        osal_free(superframe->frames[i]);
+                    }
+                }
+                osal_memset((void*)superframe, 0x00, sizeof(VP9Superframe));
+            }
+        }
+    }
+
+    seqHeaderSize = 0;
+    picHeaderSize = 0;
+
+    av_init_packet(&avpacket);
+    while (TRUE) {
+        error = av_read_frame(avFormatContext, &avpacket);
+        if (error < 0) {
+            if (error == AVERROR_EOF || avFormatContext->pb->eof_reached == TRUE) {
+                packet->eos = TRUE;
+                return 0;
+            }
+            else {
+                VLOG(ERR, "%s:%d failed to av_read_frame error(0x%08x)\n",
+                    __FUNCTION__, __LINE__, error);
+                goto __end_read;
+            }
+        }
+
+        if (avpacket.stream_index != ffmpegReader->videoIndex)
+            continue;
+
+        break;
+    }
+
+    if (avpacket.size == 0)
+        return 0;
+
+    if (avpacket.size >= (signed)packet->size )
+    {
+        VLOG(ERR, "one packet size(%d) is bigger than STREAM_BUF_SIZE(%d)\n", avpacket.size, packet->size);
+        return -1;
+    }
+
+    osal_memset(packet->data, 0x00, packet->size);
+
+    vindex = ffmpegReader->videoIndex;
+
+    if (ffmpegReader->isFirstPacket) {
+        AVCodecParameters* codec;
+
+        codec = ffmpegReader->avContext->streams[vindex]->codecpar;
+        seqHeader = (Uint8*)osal_malloc(codec->extradata_size + 1024);
+        if (seqHeader == NULL) {
+            goto __end_read;
+        }
+        osal_memset((void*)seqHeader, 0x00, codec->extradata_size + 1024);
+
+        seqHeaderSize = BuildSeqHeader(seqHeader, (CodStd)ffmpegReader->standard,
+                                       ffmpegReader->avContext->streams[vindex], &retSize);
+        if (seqHeaderSize < 0) {
+            VLOG(ERR, "%s:%d Can't make sequence header!\n", __FUNCTION__, __LINE__);
+            packetSize = -1;
+            goto __end_read;
+        }
+
+#ifdef SUPPORT_LIB_THEORA
+        if (ffmpegReader->standard == STD_THO || ffmpegReader->standard == STD_VP3) {
+            struct {
+                int frameWidth     ;
+                int frameHeight    ;
+                int picWidth       ;
+                int picHeight      ;
+                int picOffsetX     ;
+                int picOffsetY     ;
+            } theoraScaleInfo;
+            tho_parser_t*   theora = ffmpegReader->theora;
+            Int32           ret;
+
+            size = seqHeaderSize;
+            if (ffmpegReader->standard == STD_VP3) {
+                size = 0;
+            }
+
+            ret = theora->open(theora->handle, seqHeader, size, (Int32*)&theoraScaleInfo);
+            if (ret < 0) {
+                VLOG(ERR, "%s:%d failed to open theora parser error(%d)\n", __FUNCTION__, __LINE__, ret);
+                goto __end_read;
+            }
+
+            thoSeqSize = theora_make_stream(theora->handle, (Uint8*)packet->data, DEC_SEQ_INIT);
+
+            osal_free(seqHeader);
+            seqHeader     = NULL;
+            seqHeaderSize = 0;
+        }
+#endif /* SUPPORT_LIB_THEORA */
+        packet->seqHeaderSize = seqHeaderSize;
+        ffmpegReader->isFirstPacket = FALSE;
+    }
+
+    picHeader     = (Uint8*)osal_malloc(1024);
+    picHeaderSize = BuildPicHeader(picHeader, (CodStd)ffmpegReader->standard,
+                                   ffmpegReader->avContext->streams[vindex], &avpacket, 0);
+    if (picHeaderSize < 0) {
+        VLOG(ERR, "%s:%d failed to build picture header\n", __FUNCTION__, __LINE__);
+        goto __end_read;
+    }
+
+    ptr  = avpacket.data;
+    size = avpacket.size;
+    switch (ffmpegReader->standard) {
+#if 1
+    case STD_AVC:
+    case STD_HEVC:
+        if(seqHeaderSize){
+            osal_memcpy((char*)packet->data, seqHeader, seqHeaderSize);       
+        }
+        if (picHeaderSize){
+            osal_memcpy((char*)packet->data+seqHeaderSize, picHeader, picHeaderSize);
+        }
+        osal_memcpy((char*)packet->data+seqHeaderSize+picHeaderSize, ptr, size);
+        packetSize = seqHeaderSize + picHeaderSize + size;
+        VLOG(INFO,"seqHeader[%d] picHeader[%d] bsframe[%d]\n",seqHeaderSize,picHeaderSize,size);
+        break;
+#endif
+    case STD_RV:
+        if (seqHeaderSize) {
+            if ( !seqHeader )
+                goto __end_read;
+            osal_memcpy((char*)packet->data, seqHeader, seqHeaderSize);
+        }
+
+        if (picHeaderSize)
+            osal_memcpy((char*)packet->data+seqHeaderSize, picHeader, picHeaderSize);
+
+        if (ffmpegReader->standard == STD_RV) {
+            int cSlice = ptr[0] + 1;
+            int nSlice = avpacket.size - 1 - (cSlice*8);
+            ptr += (1+(cSlice*8));
+            size = nSlice;
+        }
+
+        osal_memcpy((char*)packet->data+seqHeaderSize+picHeaderSize, ptr, size);
+        packetSize = seqHeaderSize + picHeaderSize + size;
+        break;
+#ifdef SUPPORT_LIB_THEORA
+    case STD_THO:
+    case STD_VP3:
+        packetSize = MakeupTheoraPacket(ffmpegReader->theora, packet, &avpacket, thoSeqSize);
+        break;
+#endif /* SUPPORT_LIB_THEORA */
+    case STD_VP9:
+        packet->size    = size;
+        osal_memcpy((char *)packet->data, ptr, size);
+        packetSize      = size;
+        break;
+    default:
+        if (picHeaderSize)
+            osal_memcpy((char*)packet->data, picHeader, picHeaderSize);
+
+        osal_memcpy((char*)packet->data+picHeaderSize, ptr, size);
+        packetSize = picHeaderSize + size;
+        break;
+    }
+
+    if (avFormatContext->pb->eof_reached && avpacket.size <= 0) {
+        packet->eos = TRUE;
+    }
+
+    // Sequence header data should be only one chunk data unit.
+    // In case of RV, 1st chunk should be Sequence header + 1st frame.
+    if (ffmpegReader->standard != STD_VP9 && ffmpegReader->standard != STD_RV && ffmpegReader->standard != STD_VP8) {
+        if (seqHeaderSize > 0) {
+            ffmpegReader->tempBuffer = (Uint8*)osal_malloc(packetSize);
+            if (!ffmpegReader->tempBuffer)
+                goto __end_read;
+            ffmpegReader->tempWrPtr  = packetSize;
+            osal_memcpy(ffmpegReader->tempBuffer, (Uint8*)(packet->data), packetSize);
+            if ( !seqHeader)
+                goto __end_read;
+            osal_memcpy(packet->data, seqHeader, seqHeaderSize);
+            if (!seqHeader)
+                goto __end_read;
+            packetSize = seqHeaderSize;
+            goto __end_read;
+        }
+    }
+    else if (ffmpegReader->standard == STD_VP9) {
+        Uint8*  pData = (Uint8*)packet->data;
+        Uint32  lastIndex = packet->size - 1;
+
+        if (IS_VP9_SUPERFRAME(pData[lastIndex]) == TRUE) {
+            VP9Superframe*  superframe = &ffmpegReader->superframe;
+            if (VP9ParseSuperframe(pData, packet->size, superframe) == TRUE) {
+                osal_memcpy(packet->data, superframe->frames[0], superframe->frameSize[0]);
+                packet->size = superframe->frameSize[0];
+                packetSize   = packet->size;
+                superframe->currentIndex++;
+            }
+        }
+    }
+
+__end_read:
+    av_packet_unref(&avpacket);
+
+    if (picHeader)
+        osal_free(picHeader);
+    if (seqHeader)
+        osal_free(seqHeader);
+
+    return packetSize;
+
+__consume_tempBuffer:
+    if (ffmpegReader->tempBuffer != NULL) {
+        osal_memcpy(packet->data, ffmpegReader->tempBuffer, ffmpegReader->tempWrPtr);
+        packetSize = ffmpegReader->tempWrPtr;
+        osal_free(ffmpegReader->tempBuffer);
+        ffmpegReader->tempBuffer = NULL;
+        ffmpegReader->tempWrPtr  = 0;
+        ffmpegReader->tempRdPtr  = 0;
+    }
+
+    return packetSize;
+}
+
+BOOL BSFeederFrameSize_Rewind(
+    void* feeder
+    )
+{
+    FeederFrameContext*      ffmpegReader = (FeederFrameContext*)feeder;
+    AVFormatContext*    avFormatContext = ffmpegReader->avContext;
+    Int32               ret;
+
+    if ((ret=av_seek_frame(avFormatContext, ffmpegReader->videoIndex, 0, 0)) < 0) {
+        VLOG(ERR, "%s:%d Failed to av_seek_frame:(ret:%d)\n", __FUNCTION__, __LINE__, ret);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+Int32 BSFeederFrameSize_GetStandard(
+    void* feeder
+    )
+{
+    FeederFrameContext*      ffmpegReader = (FeederFrameContext*)feeder;
+    if (NULL != ffmpegReader) {
+        return ffmpegReader->standard;
+    }
+    return -1;
+}
+
+CodStd BSFeederFrameSize_GetDirectFormat(const char* path)
+{
+    AVFormatContext* avContext = NULL;
+    AVCodecParameters*  codec  = NULL;
+    CodStd rtn=STD_MAX;
+    Int32  error,videoIndex;   
+
+    avContext=avformat_alloc_context();
+    if(avContext==NULL){
+        return STD_MAX;
+    }
+
+    avContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+    error=avformat_open_input(&avContext, path, NULL, NULL);
+    if(error){
+        avformat_free_context(avContext);
+        return STD_MAX;
+    }
+    
+    videoIndex = av_find_best_stream(avContext, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
+    if (videoIndex < 0) {
+        avformat_free_context(avContext);
+        return STD_MAX;
+    }
+
+    codec = avContext->streams[videoIndex]->codecpar;
+    rtn   = ConvFOURCCToCodStd(codec->codec_tag);
+    if(rtn == -1){
+        rtn = ConvCodecIdToCodStd(codec->codec_id);
+    }
+
+    avformat_free_context(avContext);
+
+    return rtn==-1?STD_MAX:rtn;
+}
+
+#else
+void* BSFeederFrameSize_Create(
+    const char* path,
+    CodStd  codecId
+    )
+{
+    UNREFERENCED_PARAMETER(path);
+    UNREFERENCED_PARAMETER(codecId);
+
+    VLOG(ERR, "PLEASE PORT THIS %s ON YOUR ANDROID SYSTEM\n", __FUNCTION__);
+
+    return NULL;
+}
+
+BOOL BSFeederFrameSize_Destroy(
+    void*   feeder
+    )
+{
+    UNREFERENCED_PARAMETER(feeder);
+
+    VLOG(ERR, "PLEASE PORT THIS %s ON YOUR ANDROID SYSTEM\n", __FUNCTION__);
+
+    return FALSE;
+}
+
+Int32 BSFeederFrameSize_Act(
+    void*       feeder,
+    BSChunk*    packet
+    )
+{
+    UNREFERENCED_PARAMETER(feeder);
+    UNREFERENCED_PARAMETER(packet);
+
+    VLOG(ERR, "PLEASE PORT THIS %s ON YOUR ANDROID SYSTEM\n", __FUNCTION__);
+
+    return -1;
+}
+
+BOOL BSFeederFrameSize_Rewind(
+    void* feeder
+    )
+{
+    VLOG(ERR, "PLEASE PORT THIS %s ON YOUR ANDROID SYSTEM\n", __FUNCTION__);
+
+    return FALSE;
+
+}
+
+Int32 BSFeederFrameSize_GetStandard(
+    void* feeder
+    )
+{
+    UNREFERENCED_PARAMETER(feeder);
+    VLOG(ERR, "PLEASE PORT THIS %s ON YOUR ANDROID SYSTEM\n", __FUNCTION__);
+
+    return -1;
+}
+#endif /* SUPPORT_FFMPEG_DEMUX */
+

+ 137 - 0
soft_3rdpart/wave511/code/sample_v2/helper/bitstream/bsfeeder_size_plus_es_impl.c

@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include "vpuapifunc.h"
+#include "main_helper.h"
+
+#define MAX_FEEDING_SIZE        0x400000        /* 4MBytes */
+
+typedef struct FeederEsContext {
+    osal_file_t fp;
+    Uint32      feedingSize;
+    BOOL        eos;
+} FeederEsContext;
+
+void* BSFeederSizePlusEs_Create(
+    const char* path,
+    CodStd      codecId
+    )
+{
+    osal_file_t     fp = NULL;
+    FeederEsContext*  context=NULL;
+
+    UNREFERENCED_PARAMETER(codecId);
+
+    if ((fp=osal_fopen(path, "rb")) == NULL) {
+        VLOG(ERR, "%s:%d failed to open %s\n", __FUNCTION__, __LINE__, path);
+        return NULL;
+    }
+
+    context = (FeederEsContext*)osal_malloc(sizeof(FeederEsContext));
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d failed to allocate memory\n", __FUNCTION__, __LINE__);
+        osal_fclose(fp);
+        return NULL;
+    }
+
+    context->fp          = fp;
+    context->feedingSize = 0;
+    context->eos         = FALSE;
+
+    return (void*)context;
+}
+
+BOOL BSFeederSizePlusEs_Destroy(
+    void* feeder
+    )
+{
+    FeederEsContext* context = (FeederEsContext*)feeder;
+
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    if (context->fp) 
+        osal_fclose(context->fp);
+
+    osal_free(context);
+
+    return TRUE;
+}
+
+Int32 BSFeederSizePlusEs_Act(
+    void*       feeder,
+    BSChunk*    chunk
+    )
+{
+    FeederEsContext*  context = (FeederEsContext*)feeder;
+    size_t          nRead;
+    Uint32          chunkSize = 0;
+
+    if (context == NULL) {
+        VLOG(ERR, "%s:%d Null handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    if (context->eos == TRUE) {
+        return 0;
+    }
+
+    osal_fread(&chunkSize, 1, 4, context->fp);
+
+    nRead = osal_fread(chunk->data, 1, chunkSize, context->fp);
+    if ((Int32)nRead < 0) {
+        VLOG(ERR, "%s:%d failed to read bitstream(errno: %d)\n", __FUNCTION__, __LINE__, errno);
+        return 0;
+    } 
+    else if (nRead < chunkSize) {
+        context->eos = TRUE;
+    }
+    chunk->size = chunkSize;
+
+    return nRead;
+}
+
+BOOL BSFeederSizePlusEs_Rewind(
+    void*       feeder
+    )
+{
+    FeederEsContext*  context = (FeederEsContext*)feeder;
+    Int32           ret;
+
+    if ((ret=osal_fseek(context->fp, 0, SEEK_SET)) != 0) {
+        VLOG(ERR, "%s:%d failed osal_fseek(ret:%d)\n", __FUNCTION__, __LINE__, ret);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+

+ 145 - 0
soft_3rdpart/wave511/code/sample_v2/helper/comparator/bin_comparator_impl.c

@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include "config.h"
+#include "main_helper.h"
+
+typedef struct {
+    FILE*       fp;
+} binCompContext;
+
+BOOL BinComparator_Create(
+    ComparatorImpl* impl,
+    char*           path
+    )
+{
+    binCompContext*    ctx;
+    FILE*       fp;
+
+    if ((fp=osal_fopen(path, "rb")) == NULL) {
+        VLOG(ERR, "%s:%d failed to open bin file: %s\n", __FUNCTION__, __LINE__, path);
+        return FALSE;
+    }
+
+    if ((ctx=(binCompContext*)osal_malloc(sizeof(binCompContext))) == NULL) {
+        osal_fclose(fp);
+        return FALSE;
+    }
+
+    ctx->fp        = fp;
+    impl->context  = ctx;
+    impl->eof      = FALSE;
+
+    return TRUE;
+}
+
+BOOL BinComparator_Destroy(
+    ComparatorImpl*  impl
+    )
+{
+    binCompContext*    ctx = (binCompContext*)impl->context;
+
+    osal_fclose(ctx->fp);
+    osal_free(ctx);
+
+    return TRUE;
+}
+
+BOOL BinComparator_Compare(
+    ComparatorImpl* impl,
+    void*           data,
+    PhysicalAddress size
+    )
+{
+    Uint8*      pBin = NULL;
+    binCompContext*    ctx = (binCompContext*)impl->context;
+    BOOL        match = FALSE;
+
+    pBin = (Uint8*)osal_malloc(size);
+        
+    osal_fread(pBin, size, 1, ctx->fp);
+
+    if (IsEndOfFile(ctx->fp) == TRUE)
+        impl->eof = TRUE;
+    else
+        impl->numOfFrames++;
+
+    match = (osal_memcmp(data, (void*)pBin, size) == 0 ? TRUE : FALSE);
+    if (match == FALSE) {
+        FILE* fpGolden;
+        FILE* fpOutput;
+        char tmp[200];
+
+
+        sprintf(tmp, "./golden_%s_%05d.bin", GetBasename(impl->filename), impl->curIndex-1);
+        if ((fpGolden=osal_fopen(tmp, "wb")) == NULL) {
+            VLOG(ERR, "Faild to create %s\n", tmp);
+            osal_free(pBin);
+            return FALSE;
+        }
+        VLOG(ERR, "Saving... Golden Bin at %s\n", tmp);
+        osal_fwrite(pBin, size, 1, fpGolden);
+        osal_fclose(fpGolden);
+
+        sprintf(tmp, "./encoded_%s_%05d.bin", GetBasename(impl->filename), impl->curIndex-1);
+        if ((fpOutput=osal_fopen(tmp, "wb")) == NULL) {
+            VLOG(ERR, "Faild to create %s\n", tmp);
+            osal_free(pBin);
+            return FALSE;
+        }
+        VLOG(ERR, "Saving... encoded Bin at %s\n", tmp);
+        osal_fwrite(data, size, 1, fpOutput);
+        osal_fclose(fpOutput);
+    }
+
+    osal_free(pBin);
+
+    return match;
+}
+
+BOOL BinComparator_Configure(
+    ComparatorImpl*     impl,
+    ComparatorConfType  type,
+    void*               val
+    )
+{
+    UNREFERENCED_PARAMETER(impl);
+    UNREFERENCED_PARAMETER(type);
+    UNREFERENCED_PARAMETER(val);
+    return FALSE;
+}
+
+ComparatorImpl binComparatorImpl = {
+    NULL,
+    NULL,
+    0,
+    0,
+    BinComparator_Create,
+    BinComparator_Destroy,
+    BinComparator_Compare,
+    BinComparator_Configure,
+    FALSE,
+};
+ 

+ 28 - 0
soft_3rdpart/wave511/code/sample_v2/helper/comparator/byframe_comparator_impl.c

@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <errno.h>
+#include "main_helper.h"
+ 

+ 389 - 0
soft_3rdpart/wave511/code/sample_v2/helper/comparator/comparator.c

@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 2019, Chips&Media
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. 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 OWNER 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.
+*/
+
+#include <stdarg.h>
+#include <string.h>
+#include "main_helper.h"
+
+
+extern ComparatorImpl binComparatorImpl;
+extern ComparatorImpl yuvComparatorImpl;
+
+static BOOL NullComparator_Create(
+    ComparatorImpl* impl,
+    char*           path
+    )
+{
+    UNREFERENCED_PARAMETER(impl);
+    UNREFERENCED_PARAMETER(path);
+    return TRUE;
+}
+
+static BOOL NullComparator_Destroy(
+    ComparatorImpl*  impl
+    )
+{
+    UNREFERENCED_PARAMETER(impl);
+
+    return TRUE;
+}
+
+static BOOL NullComparator_Compare(
+    ComparatorImpl* impl,
+    void*           data,
+    PhysicalAddress size
+    )
+{
+    UNREFERENCED_PARAMETER(impl);
+    UNREFERENCED_PARAMETER(data);
+    UNREFERENCED_PARAMETER(size);
+    return TRUE;
+}
+
+static BOOL NullComparator_Configure(
+    ComparatorImpl*     impl,
+    ComparatorConfType  cmd,
+    void*               val
+    )
+{
+    UNREFERENCED_PARAMETER(impl);
+    UNREFERENCED_PARAMETER(cmd);
+    UNREFERENCED_PARAMETER(val);
+
+    return TRUE;
+}
+
+static BOOL NullComparator_Rewind(
+    ComparatorImpl*     impl
+    )
+{
+    UNREFERENCED_PARAMETER(impl);
+    return TRUE;
+}
+
+ComparatorImpl nullComparatorImpl = {
+    NULL,
+    NULL,
+    0, 
+    0,
+    NullComparator_Create,
+    NullComparator_Destroy,
+    NullComparator_Compare,
+    NullComparator_Configure,
+    NullComparator_Rewind
+};
+
+BOOL BinComparator_Create(
+    ComparatorImpl* impl,
+    char*           path
+);
+
+BOOL BinComparator_Destroy(
+    ComparatorImpl*  impl
+);
+
+BOOL BinComparator_Compare(
+    ComparatorImpl* impl,
+    void*           data,
+    PhysicalAddress size
+);
+
+BOOL BinComparator_Configure(
+    ComparatorImpl*     impl,
+    ComparatorConfType  type,
+    void*               val
+);
+
+BOOL YUVComparator_Create(
+    ComparatorImpl* impl,
+    char*           path
+);
+
+BOOL YUVComparator_Destroy(
+    ComparatorImpl*  impl
+);
+
+BOOL YUVComparator_Compare(
+    ComparatorImpl* impl,
+    void*           data,
+    PhysicalAddress size
+);
+
+BOOL YUVComparator_Configure(
+    ComparatorImpl*    impl,
+    ComparatorConfType cmd,
+    void*              val
+);
+
+BOOL YUVComparator_Rewind(
+    ComparatorImpl*     impl
+    );
+
+Comparator Comparator_Create(
+    Uint32      type,
+    char*       goldenPath,
+    ...
+    )
+{
+    /*lint -esym(438, ap) */
+    AbstractComparator* comp;
+    ComparatorImpl* impl = NULL;
+    va_list         ap;
+    BOOL            success = FALSE;
+    char*           p;
+
+    if (type != NO_COMPARE && goldenPath == NULL) {
+        VLOG(ERR, "%s:%d golden path is NULL\n", __FUNCTION__, __LINE__);
+        return NULL;
+    }
+
+    switch (type) {
+    case NO_COMPARE:
+        impl = (ComparatorImpl*)osal_malloc(sizeof(ComparatorImpl));
+        osal_memset((void*)impl, 0x00, sizeof(ComparatorImpl));
+        impl->Create    = NullComparator_Create;
+        impl->Compare   = NullComparator_Compare;
+        impl->Destroy   = NullComparator_Destroy;
+        impl->Configure = NullComparator_Configure;
+        impl->Rewind    = NullComparator_Rewind;
+        success = impl->Create(impl, goldenPath);
+        break;
+    case YUV_COMPARE:
+        impl = (ComparatorImpl*)osal_malloc(sizeof(ComparatorImpl));
+        osal_memset((void*)impl, 0x00, sizeof(ComparatorImpl));
+        impl->Create    = YUVComparator_Create;
+        impl->Compare   = YUVComparator_Compare;
+        impl->Destroy   = YUVComparator_Destroy;
+        impl->Configure = YUVComparator_Configure;
+        impl->Rewind    = YUVComparator_Rewind;
+        if ((success=impl->Create(impl, goldenPath)) == TRUE) {
+            PictureInfo picInfo;
+            va_start(ap, goldenPath);
+            picInfo.width  = va_arg(ap, Uint32);
+            picInfo.height = va_arg(ap, Uint32);
+            picInfo.format = (FrameBufferFormat)va_arg(ap, Uint32);
+            picInfo.cbcrInterleave = va_arg(ap, BOOL);
+            picInfo.isVp9  = va_arg(ap, BOOL);
+            va_end(ap);
+            impl->Configure(impl, COMPARATOR_CONF_SET_PICINFO, (void*)&picInfo);
+        }
+        break;
+    case STREAM_COMPARE:
+        impl = osal_malloc(sizeof(ComparatorImpl));
+        osal_memset((void*)impl, 0x00, sizeof(ComparatorImpl));
+        impl->Create = BinComparator_Create;
+        impl->Compare = BinComparator_Compare;
+        impl->Destroy = BinComparator_Destroy;
+        impl->Configure = BinComparator_Configure;
+        impl->filename  = (char*)osal_malloc(512);
+        va_start(ap, goldenPath);
+        p = va_arg(ap, char*);
+        va_end(ap);
+        strcpy(impl->filename, p);
+        success = impl->Create(impl, goldenPath);
+        break;
+    default:
+        VLOG(ERR, "Invalid comparison type:%d\n", type);
+        return NULL;
+    }
+
+    if (success == FALSE) 
+        return NULL;
+
+    comp = (AbstractComparator*)osal_malloc(sizeof(AbstractComparator));
+    impl->curIndex      = 0;
+    comp->impl          = impl;
+    comp->totalFrames   = impl->numOfFrames;
+
+    return comp;
+    /*lint +esym(438, ap) */
+}
+
+BOOL Comparator_Destroy(
+    Comparator  comp
+    )
+{
+    ComparatorImpl*     impl = NULL;
+    AbstractComparator* absComp = (AbstractComparator*)comp;
+
+    if (comp == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    impl = absComp->impl;
+
+    if (impl->filename) osal_free(impl->filename);
+    impl->Destroy(impl);
+
+    osal_free(impl);
+    osal_free(comp);
+
+    return TRUE;
+}
+
+BOOL Comparator_Act(
+    Comparator  comp,
+    void*       data,
+    Uint32      size
+    )
+{
+    ComparatorImpl*     impl = NULL;
+    AbstractComparator* absComp = (AbstractComparator*)comp;
+
+    if (comp == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    impl = absComp->impl;
+    impl->curIndex++;
+    if (impl->usePrevDataOneTime == TRUE)
+        impl->curIndex--;
+
+    return impl->Compare(impl, data, size);
+}
+
+BOOL Comparator_CheckFrameCount(
+    Comparator  comp
+    )
+{
+    ComparatorImpl*     impl = NULL;
+    AbstractComparator* absComp = (AbstractComparator*)comp;
+    BOOL                match = TRUE;
+
+    if (absComp == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    impl = absComp->impl;
+
+    if (impl->curIndex != absComp->totalFrames) {
+        VLOG(ERR, "MISMATCH FRAME COUNT: GOLDEN(%d) DECODED(%d)\n", 
+            impl->numOfFrames, impl->curIndex);
+        match = FALSE;
+    }
+
+    return match;
+}
+
+Uint32 Comparator_GetFrameCount(
+    Comparator comp
+    )
+{
+    ComparatorImpl*     impl = NULL;
+    AbstractComparator* absComp = (AbstractComparator*)comp;
+
+    if (absComp == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    impl = absComp->impl;
+
+    return impl->numOfFrames;
+}
+
+/* \brief       When scan mode is enable, Comparator_Act() tries to find data matched with decoded result 
+ *              by scanning all data
+ */
+BOOL Comparator_SetScanMode(
+    Comparator  comp,
+    BOOL        enable
+    )
+{
+    AbstractComparator* absComp = (AbstractComparator*)comp;
+    ComparatorImpl*     impl = NULL;
+
+    if (absComp == NULL) {
+        return FALSE;
+    }
+    impl = absComp->impl;
+
+    impl->enableScanMode = enable;
+
+    return TRUE;
+}
+
+BOOL Comparator_Rewind(
+    Comparator  comp
+    )
+{
+    AbstractComparator* absComp = (AbstractComparator*)comp;
+    ComparatorImpl*     impl = NULL;
+
+    if (absComp == NULL) {
+        return FALSE;
+    }
+    impl                  = absComp->impl;
+    absComp->totalFrames += impl->numOfFrames;
+
+    return impl->Rewind(impl);
+}
+
+BOOL Comparator_CheckEOF(
+    Comparator  comp
+    )
+{
+    ComparatorImpl*     impl     = NULL;
+    AbstractComparator* absComp  = (AbstractComparator*)comp;
+    BOOL                match    = TRUE;
+
+    if (comp == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    impl = absComp->impl;
+
+    if (impl->eof == FALSE) {
+        VLOG(ERR, "It is not the end of file.\n");
+        match = FALSE;
+    }
+
+    return match;
+}
+
+BOOL Comparator_Configure(
+    Comparator  comp,
+    ComparatorConfType        cmd,
+    void*                     val
+    )
+{
+    ComparatorImpl*     impl     = NULL;
+    AbstractComparator* absComp  = (AbstractComparator*)comp;
+
+    if (comp == NULL) {
+        VLOG(ERR, "%s:%d Invalid handle\n", __FUNCTION__, __LINE__);
+        return FALSE;
+    }
+
+    impl = absComp->impl;
+    impl->Configure(impl, cmd, val);
+
+    return TRUE;
+}
+

Some files were not shown because too many files changed in this diff