Explorar el Código

Merge tag 'JH7110_MM_v5.9.0' into vf2-devel

Andy Hu hace 6 meses
padre
commit
0592035408
Se han modificado 28 ficheros con 9333 adiciones y 4533 borrados
  1. 0 1109
      package/libcamera/0001-add-starfive-pipeline.patch
  2. 0 182
      package/libcamera/0002-add-sensor-ctrls.patch
  3. 0 537
      package/libcamera/0003-add-Meta-and-starfive-ipa-dummy.patch
  4. 0 74
      package/libcamera/0004-update-toV4L2PixelFormat.patch
  5. 0 30
      package/libcamera/0005-fix-build-gen-version-error.patch
  6. 0 32
      package/libcamera/0006-fix-yuy2-format-unsupported.patch
  7. 0 318
      package/libcamera/0007-add-list-controls-and-properties.patch
  8. 0 249
      package/libcamera/0008-support-use-yaml-file-to-config-sensor-pipeline.patch
  9. 0 271
      package/libcamera/0009-csi0-csi1-can-be-configured-to-the-same-ISP.patch
  10. 0 254
      package/libcamera/0010-libcamera-add-framerate-for-request-pad-src.patch
  11. 0 195
      package/libcamera/0011-libcamera-support-isp-driver.patch
  12. 0 63
      package/libcamera/0012-Adjust-StarFive-pipeline-video-device-entity-name.patch
  13. 0 158
      package/libcamera/0013-Removed-isp1-config-from-pipeline-modified-imx219-co.patch
  14. 0 41
      package/libcamera/0014-libcamera-Open-drm-device-by-module-name-starfive.patch
  15. 22 5
      package/libcamera/Config.in
  16. 1 14
      package/libcamera/libcamera.hash
  17. 78 10
      package/libcamera/libcamera.mk
  18. 284 0
      package/starfive/libcamera-apps/0001-Make-libcamera-hello-run-normally.patch
  19. 0 489
      package/starfive/libcamera-apps/0001-add-starfive-support.patch
  20. 222 0
      package/starfive/libcamera-apps/0002-Make-libcamera-jpeg-run-normally.patch
  21. 0 92
      package/starfive/libcamera-apps/0002-add-select-camera-options.patch
  22. 204 0
      package/starfive/libcamera-apps/0003-Make-libcamera-still-run-normally.patch
  23. 0 224
      package/starfive/libcamera-apps/0003-add-FbPreview-support-YUYV-YVYU-display.patch
  24. 8519 0
      package/starfive/libcamera-apps/0004-Make-libcamera-vid-run-normally.patch
  25. 0 153
      package/starfive/libcamera-apps/0004-add-DrmPreview-support-NV12-display.patch
  26. 0 28
      package/starfive/libcamera-apps/0005-libcamera-apps-Open-drm-device-by-module-name-starfi.patch
  27. 1 3
      package/starfive/libcamera-apps/libcamera-apps.hash
  28. 2 2
      package/starfive/libcamera-apps/libcamera-apps.mk

+ 0 - 1109
package/libcamera/0001-add-starfive-pipeline.patch

@@ -1,1109 +0,0 @@
-From d936cae7ba6ab3ae4665ac889bcef4c90354c36b Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Sat, 9 Oct 2021 18:09:44 +0800
-Subject: [PATCH 01/10] add starfive pipeline
-
----
- include/libcamera/internal/v4l2_subdevice.h  |   1 +
- include/linux/v4l2-subdev.h                  |   9 +
- meson_options.txt                            |   2 +-
- src/gstreamer/gstlibcamera-utils.cpp         |   7 +
- src/gstreamer/gstlibcamerasrc.cpp            |  16 +-
- src/libcamera/pipeline/starfive/meson.build  |   5 +
- src/libcamera/pipeline/starfive/starfive.cpp | 940 +++++++++++++++++++
- src/libcamera/v4l2_subdevice.cpp             |  12 +
- 8 files changed, 990 insertions(+), 2 deletions(-)
- create mode 100644 src/libcamera/pipeline/starfive/meson.build
- create mode 100644 src/libcamera/pipeline/starfive/starfive.cpp
-
-diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h
-index 97b89fb9..fe8835bd 100644
---- a/include/libcamera/internal/v4l2_subdevice.h
-+++ b/include/libcamera/internal/v4l2_subdevice.h
-@@ -63,6 +63,7 @@ public:
- 
- 	static std::unique_ptr<V4L2Subdevice>
- 	fromEntityName(const MediaDevice *media, const std::string &entity);
-+	int ioctlPrivate(unsigned long request, void *argp);
- 
- protected:
- 	std::string logPrefix() const override;
-diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
-index a38454d9..4c9af64d 100644
---- a/include/linux/v4l2-subdev.h
-+++ b/include/linux/v4l2-subdev.h
-@@ -206,4 +206,13 @@ struct v4l2_subdev_capability {
- #define VIDIOC_SUBDEV_QUERY_DV_TIMINGS		_IOR('V', 99, struct v4l2_dv_timings)
- #define VIDIOC_SUBDEV_DV_TIMINGS_CAP		_IOWR('V', 100, struct v4l2_dv_timings_cap)
- 
-+#define STF_ISPFW_FILENAME_MAX_LEN  30
-+
-+struct stfisp_fw_info {
-+	char filename[STF_ISPFW_FILENAME_MAX_LEN];
-+};
-+
-+#define VIDIOC_STFISP_LOAD_FW \
-+	_IOW('V', BASE_VIDIOC_PRIVATE + 1, struct stfisp_fw_info)
-+
- #endif
-diff --git a/meson_options.txt b/meson_options.txt
-index 2c80ad8b..14baa7ef 100644
---- a/meson_options.txt
-+++ b/meson_options.txt
-@@ -37,7 +37,7 @@ option('lc-compliance',
- 
- option('pipelines',
-         type : 'array',
--        choices : ['ipu3', 'raspberrypi', 'rkisp1', 'simple', 'uvcvideo', 'vimc'],
-+        choices : ['ipu3', 'raspberrypi', 'rkisp1', 'simple', 'uvcvideo', 'vimc', 'starfive'],
-         description : 'Select which pipeline handlers to include')
- 
- option('qcam',
-diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
-index 3f242286..bce4960a 100644
---- a/src/gstreamer/gstlibcamera-utils.cpp
-+++ b/src/gstreamer/gstlibcamera-utils.cpp
-@@ -139,6 +139,12 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg
- 			  "width", G_TYPE_INT, stream_cfg.size.width,
- 			  "height", G_TYPE_INT, stream_cfg.size.height,
- 			  nullptr);
-+
-+	// Add framerate negotiation support
-+	// the range will be [ 0/1, 2147483647/1 ] as there is not any args 
-+	// required from driver for the time being.
-+	gst_structure_set(s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
-+
- 	gst_caps_append_structure(caps, s);
- 
- 	return caps;
-@@ -230,6 +236,7 @@ gst_libcamera_resume_task(GstTask *task)
- 	/* We only want to resume the task if it's paused. */
- 	GLibLocker lock(GST_OBJECT(task));
- 	if (GST_TASK_STATE(task) == GST_TASK_PAUSED) {
-+		GST_DEBUG("gst_libcamera_resume_task");
- 		GST_TASK_STATE(task) = GST_TASK_STARTED;
- 		GST_TASK_SIGNAL(task);
- 	}
-diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
-index 812ba7a2..1dd0e807 100644
---- a/src/gstreamer/gstlibcamerasrc.cpp
-+++ b/src/gstreamer/gstlibcamerasrc.cpp
-@@ -46,6 +46,7 @@ using namespace libcamera;
- 
- GST_DEBUG_CATEGORY_STATIC(source_debug);
- #define GST_CAT_DEFAULT source_debug
-+#define TASK_PAUSE_COUNT_MAX 2
- 
- struct RequestWrap {
- 	RequestWrap(std::unique_ptr<Request> request);
-@@ -125,6 +126,7 @@ struct _GstLibcameraSrc {
- 	GstLibcameraSrcState *state;
- 	GstLibcameraAllocator *allocator;
- 	GstFlowCombiner *flow_combiner;
-+	guint task_pause_count;
- };
- 
- enum {
-@@ -340,8 +342,20 @@ gst_libcamera_src_task_run(gpointer user_data)
- 			}
- 		}
- 
--		if (do_pause)
-+		if (do_pause){
-+			self->task_pause_count ++;
-+			GST_DEBUG_OBJECT(self, "task_pause_count: %d'", self->task_pause_count);
-+		} else {
-+			self->task_pause_count = 0;
-+			GST_DEBUG_OBJECT(self, "reset task_pause_count ");
-+		}
-+
-+		if ( self->task_pause_count > TASK_PAUSE_COUNT_MAX)
-+		{
-+			GST_DEBUG_OBJECT(self, "gst_task_pause");
- 			gst_task_pause(self->task);
-+		}
-+
- 	}
- }
- 
-diff --git a/src/libcamera/pipeline/starfive/meson.build b/src/libcamera/pipeline/starfive/meson.build
-new file mode 100644
-index 00000000..2f2d2a75
---- /dev/null
-+++ b/src/libcamera/pipeline/starfive/meson.build
-@@ -0,0 +1,5 @@
-+# SPDX-License-Identifier: CC0-1.0
-+
-+libcamera_sources += files([
-+    'starfive.cpp',
-+])
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-new file mode 100644
-index 00000000..8797bdcb
---- /dev/null
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -0,0 +1,940 @@
-+/* SPDX-License-Identifier: LGPL-2.1-or-later */
-+/*
-+ * starfive.cpp - Pipeline handler for starfive devices
-+ */
-+#include <algorithm>
-+#include <assert.h>
-+#include <fcntl.h>
-+#include <mutex>
-+#include <queue>
-+#include <sys/mman.h>
-+#include <math.h>
-+
-+#include <libcamera/camera.h>
-+#include <libcamera/control_ids.h>
-+#include <libcamera/file_descriptor.h>
-+#include <libcamera/formats.h>
-+#include <libcamera/logging.h>
-+#include <libcamera/property_ids.h>
-+#include <libcamera/request.h>
-+#include <libcamera/stream.h>
-+#include <linux/media-bus-format.h>
-+
-+#include <linux/videodev2.h>
-+#include <linux/v4l2-subdev.h>
-+
-+#include "libcamera/internal/camera.h"
-+#include "libcamera/internal/camera_sensor.h"
-+#include "libcamera/internal/device_enumerator.h"
-+#include "libcamera/internal/ipa_manager.h"
-+#include "libcamera/internal/media_device.h"
-+#include "libcamera/internal/pipeline_handler.h"
-+// #include "libcamera/internal/utils.h"
-+// #include "libcamera/internal/v4l2_controls.h"
-+#include "libcamera/internal/v4l2_videodevice.h"
-+
-+#define STF_MAX_CAMERAS   3
-+
-+namespace libcamera {
-+
-+LOG_DEFINE_CATEGORY(STARFIVE)
-+
-+static constexpr unsigned int BUFFER_COUNT = 4;
-+static constexpr unsigned int MAX_STREAMS = 2;
-+static const Size OUTPUT_MIN_SIZE = { 8, 8 };
-+static const Size OUTPUT_MAX_SIZE = { 8192, 8192 };
-+
-+namespace {
-+
-+typedef enum {
-+	DVP_YUV = 0,
-+	MIPICSI0_YUV,
-+	MIPICSI1_YUV,
-+	DVP_ISP0,    // ISP0
-+	MIPICSI0_ISP0,
-+	MIPICSI1_ISP0,
-+	DVP_ISP1,    // ISP1
-+	MIPICSI0_ISP1,
-+	MIPICSI1_ISP1,
-+	SENSORTYPE_MAX
-+} SensorType;
-+
-+typedef struct {
-+	std::string sensorEntityName_;
-+	std::string sensorFwImageName_;
-+	SensorType sensorType_;
-+} SensorConfig;
-+
-+const std::vector<SensorConfig> sensorConfigs = {
-+	{ "imx219 0-0010", "stf_isp0_fw_dump.bin", MIPICSI0_ISP0 },
-+	{ "imx219 2-0010", "stf_isp0_fw_dump.bin", MIPICSI1_ISP1 },
-+};
-+
-+typedef struct {
-+	std::string source;
-+	std::string link;
-+} PipelineConfigLink;
-+
-+const std::vector<PipelineConfigLink> dvpyuvConfig = {
-+	{"stf_dvp0", "stf_vin0_wr"},
-+};
-+
-+const std::vector<PipelineConfigLink> mipicsi0yuvConfig = {
-+	{"stf_csiphy0", "stf_csi0"},
-+	{"stf_csi0", "stf_vin0_wr"}
-+};
-+
-+const std::vector<PipelineConfigLink> mipicsi1yuvConfig = {
-+	{"stf_csiphy1", "stf_csi1"},
-+	{"stf_csi1", "stf_vin0_wr"}
-+};
-+
-+const std::vector<PipelineConfigLink> dvpraw0Config = {
-+	{"stf_dvp0", "stf_isp0"},
-+	{"stf_isp0", "stf_vin0_isp0"}
-+};
-+
-+const std::vector<PipelineConfigLink> mipicsi0raw0Config = {
-+	{"stf_csiphy0", "stf_csi0"},
-+	{"stf_csi0", "stf_isp0"},
-+	{"stf_isp0", "stf_vin0_isp0"}
-+};
-+
-+const std::vector<PipelineConfigLink> mipicsi1raw0Config = {
-+	{"stf_csiphy1", "stf_csi1"},
-+	{"stf_csi1", "stf_isp0"},
-+	{"stf_isp0", "stf_vin0_isp0"}
-+};
-+
-+const std::vector<PipelineConfigLink> dvpraw1Config = {
-+	{"stf_dvp0", "stf_isp1"},
-+	{"stf_isp1", "stf_vin0_isp1"}
-+};
-+
-+const std::vector<PipelineConfigLink> mipicsi0raw1Config = {
-+	{"stf_csiphy0", "stf_csi0"},
-+	{"stf_csi0", "stf_isp1"},
-+	{"stf_isp1", "stf_vin0_isp1"}
-+};
-+
-+const std::vector<PipelineConfigLink> mipicsi1raw1Config = {
-+	{"stf_csiphy1", "stf_csi1"},
-+	{"stf_csi1", "stf_isp1"},
-+	{"stf_isp1", "stf_vin0_isp1"}
-+};
-+
-+const std::vector<PipelineConfigLink> pipelineConfigs[SENSORTYPE_MAX] = {
-+	dvpyuvConfig,
-+	mipicsi0yuvConfig,
-+	mipicsi1yuvConfig,
-+	dvpraw0Config,
-+	mipicsi0raw0Config,
-+	mipicsi1raw0Config,
-+	dvpraw1Config,
-+	mipicsi0raw1Config,
-+	mipicsi1raw1Config,
-+};
-+
-+const std::map<uint32_t, PixelFormat> mbusCodesToPixelFormat = {
-+	{ MEDIA_BUS_FMT_SBGGR10_1X10, formats::SBGGR12 },
-+	{ MEDIA_BUS_FMT_SGBRG10_1X10, formats::SGBRG12 },
-+	{ MEDIA_BUS_FMT_SGRBG10_1X10, formats::SGRBG12 },
-+	{ MEDIA_BUS_FMT_SRGGB10_1X10, formats::SRGGB12 },
-+};
-+
-+} /* namespace */
-+
-+class StarFiveCameraData : public Camera::Private
-+{
-+public:
-+	StarFiveCameraData(PipelineHandler *pipe, MediaDevice *media,
-+			std::string entityName,
-+			std::string sensorEntityName)
-+		: Camera::Private(pipe), media_(media)
-+	{
-+		LOG(STARFIVE, Debug) << __func__;
-+		sensorEntityName_ = sensorEntityName;
-+		videoEntityName_ = entityName;
-+		if ( videoEntityName_ == "stf_vin0_isp0_video1")
-+			ispEntityName_ = "stf_isp0";
-+		else if (videoEntityName_ == "stf_vin0_isp1_video2")
-+			ispEntityName_ = "stf_isp1";
-+		else
-+			ispEntityName_ = "unknow";
-+
-+		video_ = nullptr;
-+		raw_ = nullptr;
-+		sensor_ = nullptr;
-+		ispSubDev_ = nullptr;
-+		haveRaw_ = false;
-+		rawActive_= false;
-+	}
-+
-+	~StarFiveCameraData()
-+	{
-+		LOG(STARFIVE, Debug) << __func__;
-+		delete sensor_;
-+		delete video_;
-+		if (raw_ != nullptr)
-+			delete raw_;
-+		if (ispSubDev_ != nullptr)
-+			delete ispSubDev_;
-+	}
-+
-+	int init();
-+	void bufferReady(FrameBuffer *buffer);
-+	bool haveRaw() const { return haveRaw_; }
-+	bool rawActive() const { return rawActive_; }
-+	void setRawActive(bool val) { rawActive_ = val; }
-+	std::vector<SizeRange> sensorSizes() const;
-+	std::vector<PixelFormat> sensorFormats() const;
-+	std::vector<PixelFormat> videoFormats() const;
-+
-+	MediaDevice *media_;
-+	V4L2VideoDevice *video_;
-+	V4L2VideoDevice *raw_;
-+	V4L2Subdevice *ispSubDev_;
-+	CameraSensor *sensor_;
-+	Stream outStream_;
-+	Stream rawStream_;
-+
-+private:
-+	bool haveRaw_;
-+	bool rawActive_;
-+	std::string videoEntityName_;
-+	std::string sensorEntityName_;
-+	std::string ispEntityName_;
-+	std::string getRawVideoEntityName()
-+	{
-+		LOG(STARFIVE, Debug) << __func__;
-+		if ( videoEntityName_ == "stf_vin0_isp0_video1")
-+			return "stf_vin0_isp0_raw_video3";
-+		else if (videoEntityName_ == "stf_vin0_isp1_video2")
-+			return "stf_vin0_isp1_raw_video4";
-+		else
-+			return "unknow";
-+	}
-+	int ispLoadFW(const char *filename);
-+};
-+
-+std::vector<PixelFormat> StarFiveCameraData::videoFormats() const
-+{
-+	if (!video_)
-+		return {};
-+
-+	std::vector<PixelFormat> formats;
-+	for (auto it : video_->formats()) {
-+		formats.push_back(it.first.toPixelFormat());
-+	}
-+
-+	return formats;
-+}
-+
-+std::vector<PixelFormat> StarFiveCameraData::sensorFormats() const
-+{
-+	if (!sensor_)
-+		return {};
-+
-+	std::vector<PixelFormat> formats;
-+	for (unsigned int code : sensor_->mbusCodes()) {
-+		auto it = mbusCodesToPixelFormat.find(code);
-+		if (it != mbusCodesToPixelFormat.end())
-+			formats.push_back(it->second);
-+	}
-+
-+	return formats;
-+}
-+
-+std::vector<SizeRange> StarFiveCameraData::sensorSizes() const
-+{
-+	if (!sensor_)
-+		return {};
-+
-+	std::vector<SizeRange> sizes;
-+	for (const Size &size : sensor_->sizes(sensor_->mbusCodes().at(0)))
-+		sizes.emplace_back(size, size);
-+
-+	return sizes;
-+}
-+
-+int StarFiveCameraData::ispLoadFW(const char *filename)
-+{
-+	struct stfisp_fw_info fw_info = {0};
-+
-+	if (!ispSubDev_)
-+		return -ENODEV;
-+
-+	if (filename && (strlen(filename) < STF_ISPFW_FILENAME_MAX_LEN))
-+		memcpy(fw_info.filename, filename, strlen(filename) + 1);
-+	else
-+		return -EINVAL;
-+
-+	LOG(STARFIVE, Debug)
-+		<< "VIDIOC_STFISP_LOAD_FW: " << VIDIOC_STFISP_LOAD_FW
-+		<< " filename: " << filename
-+		<< " struct size: " << sizeof(struct stfisp_fw_info);
-+
-+	if (ispSubDev_->ioctlPrivate(VIDIOC_STFISP_LOAD_FW, &fw_info) < 0)
-+		LOG(STARFIVE, Error) << "Load ISP fw failed" ;
-+
-+	return 0;
-+}
-+
-+class StarFiveCameraConfiguration : public CameraConfiguration
-+{
-+public:
-+	StarFiveCameraConfiguration(StarFiveCameraData *data);
-+
-+	Status validate() override;
-+
-+private:
-+	StarFiveCameraData *data_;
-+};
-+
-+int StarFiveCameraData::init()
-+{
-+	int ret;
-+
-+	LOG(STARFIVE, Debug) << __func__;
-+	if (sensorEntityName_ != "unknow") {
-+		sensor_ =
-+		  new CameraSensor(media_->getEntityByName(sensorEntityName_));
-+		ret = sensor_->init();
-+		if (ret)
-+			return ret;
-+		LOG(STARFIVE, Debug) << "sensor id: " << sensor_->id();
-+	} else {
-+		LOG(STARFIVE, Debug) << " Can't find sensorEntityName!";
-+		return -ENODEV;
-+	}
-+
-+	if (ispEntityName_ != "unknow") {
-+		ispSubDev_ =
-+			new V4L2Subdevice(media_->getEntityByName(ispEntityName_));
-+		LOG(STARFIVE, Debug) << "ispEntityName: " << ispEntityName_;
-+		if (ispSubDev_->open())
-+			return -ENODEV;
-+
-+		for (SensorConfig it : sensorConfigs) {
-+			if (it.sensorEntityName_ == sensorEntityName_) {
-+				ispLoadFW(it.sensorFwImageName_.c_str());
-+				break;
-+			}
-+		}
-+	}
-+
-+	video_ = new V4L2VideoDevice(media_->getEntityByName(videoEntityName_));
-+	LOG(STARFIVE, Debug) << "videoEntityName: " << videoEntityName_;
-+	if (video_->open())
-+		return -ENODEV;
-+
-+	video_->bufferReady.connect(this, &StarFiveCameraData::bufferReady);
-+	LOG(STARFIVE, Debug) << "driverName: " << video_->driverName();
-+
-+	std::string rawVideoEntityName = getRawVideoEntityName();
-+	if (rawVideoEntityName != "unknow") {
-+		raw_ =
-+		  new V4L2VideoDevice(media_->getEntityByName(rawVideoEntityName));
-+		LOG(STARFIVE, Debug)
-+			<< "rawEntityName: " << rawVideoEntityName;
-+		if (raw_->open()) {
-+			LOG(STARFIVE, Debug) << "No raw data capture!!!";
-+			haveRaw_ = false;
-+		} else {
-+			haveRaw_ = true;
-+			raw_->bufferReady.connect(this,
-+					&StarFiveCameraData::bufferReady);
-+		}
-+	}
-+	
-+	return 0;
-+}
-+
-+class PipelineHandlerStarFive : public PipelineHandler
-+{
-+public:
-+	PipelineHandlerStarFive(CameraManager *manager);
-+	
-+	CameraConfiguration *generateConfiguration(Camera *camera,
-+	const StreamRoles &roles) override;
-+	int configure(Camera *camera, CameraConfiguration *config) override;
-+	
-+	int exportFrameBuffers(Camera *camera, Stream *stream,
-+	std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;
-+	
-+	int start(Camera *camera, const ControlList *controls) override;
-+	void stop(Camera *camera) override;
-+	
-+	int queueRequestDevice(Camera *camera, Request *request) override;
-+	
-+	bool match(DeviceEnumerator *enumerator) override;
-+
-+private:
-+	int processControls(StarFiveCameraData *data, Request *request);
-+
-+	StarFiveCameraData *cameraData(Camera *camera)
-+	{
-+		return static_cast<StarFiveCameraData *>(camera->_d());
-+	}
-+
-+	int registerCameras();
-+	std::string getVideoEntityNameById(unsigned int id);
-+	std::string findSensorEntityName(std::string entityName);
-+	int enableLinks(std::vector<PipelineConfigLink> config);
-+
-+	MediaDevice *starFiveMediaDev_;
-+};
-+
-+StarFiveCameraConfiguration::StarFiveCameraConfiguration(StarFiveCameraData *data)
-+	: CameraConfiguration(), data_(data)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+}
-+
-+CameraConfiguration::Status StarFiveCameraConfiguration::validate()
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+	Status status = Valid;
-+
-+	if (config_.empty())
-+		return Invalid;
-+
-+	LOG(STARFIVE, Debug) << "config_.size " << config_.size();
-+	/* Cap the number of entries to the available streams. */
-+	if (config_.size() > MAX_STREAMS) {
-+		config_.resize(MAX_STREAMS);
-+		status = Adjusted;
-+	}
-+
-+	for (unsigned int i = 0; i < config_.size(); ++i) {
-+		const PixelFormatInfo &info =
-+			PixelFormatInfo::info(config_[i].pixelFormat);
-+		StreamConfiguration &cfg = config_[i];
-+
-+		LOG(STARFIVE, Debug)
-+			<< "Validating stream: " << config_[i].toString();
-+
-+		const Size size = cfg.size;
-+
-+		cfg.size.width = std::max(OUTPUT_MIN_SIZE.width,
-+				std::min(OUTPUT_MAX_SIZE.width, cfg.size.width));
-+		cfg.size.height = std::max(OUTPUT_MIN_SIZE.height,
-+				std::min(OUTPUT_MAX_SIZE.height, cfg.size.height));
-+
-+		if (cfg.size != size) {
-+			LOG(STARFIVE, Debug)
-+				<< "Adjusting size to " << cfg.size.toString();
-+			status = Adjusted;
-+		}
-+
-+		cfg.bufferCount = BUFFER_COUNT;
-+
-+		if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW
-+				&& data_->haveRaw()) {
-+			V4L2DeviceFormat format = {};
-+			format.fourcc =
-+				data_->raw_->toV4L2PixelFormat(cfg.pixelFormat);
-+			format.size = cfg.size;
-+
-+			int ret = data_->raw_->tryFormat(&format);
-+			if (ret)
-+				return Invalid;
-+
-+			cfg.stride = format.planes[0].bpl;
-+			cfg.frameSize = format.planes[0].size;
-+
-+			cfg.setStream(&data_->rawStream_);
-+		} else {
-+			V4L2DeviceFormat format = {};
-+			format.fourcc =
-+				data_->video_->toV4L2PixelFormat(cfg.pixelFormat);
-+			format.size = cfg.size;
-+
-+			int ret = data_->video_->tryFormat(&format);
-+			if (ret)
-+				return Invalid;
-+
-+			cfg.stride = format.planes[0].bpl;
-+			cfg.frameSize = format.planes[0].size;
-+
-+			cfg.setStream(&data_->outStream_);
-+		}
-+	}
-+
-+	return status;
-+}
-+
-+PipelineHandlerStarFive::PipelineHandlerStarFive(CameraManager *manager)
-+	: PipelineHandler(manager)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+}
-+
-+CameraConfiguration *
-+PipelineHandlerStarFive::generateConfiguration(Camera *camera,
-+					const StreamRoles &roles)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+	StarFiveCameraData *data = cameraData(camera);
-+	StarFiveCameraConfiguration *config =
-+		new StarFiveCameraConfiguration(data);
-+
-+	if (roles.empty())
-+		return config;
-+
-+	for (const StreamRole role : roles) {
-+		std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
-+		unsigned int bufferCount;
-+		PixelFormat pixelFormat;
-+		Size size;
-+
-+		LOG(STARFIVE, Debug) << "role: " << role;
-+		size = data->sensor_->resolution();
-+		switch (role) {
-+		case StreamRole::StillCapture:
-+		case StreamRole::Viewfinder:
-+		case StreamRole::VideoRecording:
-+			for (const auto &pixelformat : data->videoFormats()) {
-+				streamFormats[pixelformat] = data->sensorSizes();
-+			}
-+			pixelFormat = data->videoFormats().at(0);
-+			bufferCount = BUFFER_COUNT;
-+
-+			break;
-+
-+		case StreamRole::Raw: {
-+			std::vector<unsigned int> mbusCodes =
-+				utils::map_keys(mbusCodesToPixelFormat);
-+
-+			V4L2SubdeviceFormat sensorFormat =
-+				data->sensor_->getFormat(mbusCodes, size);
-+			if (!sensorFormat.mbus_code) {
-+				LOG(STARFIVE, Error)
-+					<< "Sensor does not support mbus code";
-+				break;
-+			}
-+
-+			pixelFormat =
-+				mbusCodesToPixelFormat.at(sensorFormat.mbus_code);
-+			size = sensorFormat.size;
-+			bufferCount = BUFFER_COUNT;
-+
-+			streamFormats[pixelFormat] = data->sensorSizes();
-+
-+			break;
-+		}
-+		default:
-+			LOG(STARFIVE, Error)
-+				<< "Requested stream role not supported: "
-+				<< role;
-+			break;
-+		}
-+
-+		StreamFormats formats(streamFormats);
-+		StreamConfiguration cfg(formats);
-+		cfg.size = size;
-+		cfg.pixelFormat = pixelFormat;
-+		cfg.bufferCount = bufferCount;
-+		config->addConfiguration(cfg);
-+	}
-+
-+	if (config->validate() == CameraConfiguration::Invalid)
-+		return {};
-+
-+	return config;
-+}
-+
-+int PipelineHandlerStarFive::configure(Camera *camera, CameraConfiguration *c)
-+{
-+	StarFiveCameraConfiguration *config =
-+		static_cast<StarFiveCameraConfiguration *>(c);
-+	StarFiveCameraData *data = cameraData(camera);
-+	int ret;
-+
-+	LOG(STARFIVE, Debug) << __func__
-+		<< " config->size: " << config->size();
-+
-+	for (unsigned int i = 0; i < config->size(); ++i) {
-+		StreamConfiguration &cfg = (*config)[i];
-+		Stream *stream = cfg.stream();
-+
-+		LOG(STARFIVE, Debug)
-+			<< "config stream: " << cfg.toString();
-+
-+		if (stream == &data->rawStream_) {
-+			V4L2DeviceFormat format = {};
-+			format.fourcc =
-+				data->raw_->toV4L2PixelFormat(cfg.pixelFormat);
-+			format.size = cfg.size;
-+
-+			ret = data->raw_->setFormat(&format);
-+			if (ret)
-+				return ret;
-+
-+			if (format.size != cfg.size ||
-+			    format.fourcc !=
-+			    data->raw_->toV4L2PixelFormat(cfg.pixelFormat))
-+				return -EINVAL;
-+
-+		} else if (stream == &data->outStream_) {
-+			V4L2DeviceFormat format = {};
-+			format.fourcc =
-+				data->video_->toV4L2PixelFormat(cfg.pixelFormat);
-+			format.size = cfg.size;
-+
-+			ret = data->video_->setFormat(&format);
-+			if (ret)
-+				return ret;
-+
-+			if (format.size != cfg.size ||
-+			    format.fourcc !=
-+			    data->video_->toV4L2PixelFormat(cfg.pixelFormat))
-+				return -EINVAL;
-+		}
-+	}
-+
-+	return 0;
-+}
-+
-+int PipelineHandlerStarFive::exportFrameBuffers(Camera *camera, Stream *stream,
-+			std::vector<std::unique_ptr<FrameBuffer>> *buffers)
-+{
-+	StarFiveCameraData *data = cameraData(camera);
-+	unsigned int count = stream->configuration().bufferCount;
-+
-+	LOG(STARFIVE, Debug) << __func__ << " bufferCount: " << count;
-+
-+	if (stream == &data->outStream_)
-+		return data->video_->exportBuffers(count, buffers);
-+	else if (stream == &data->rawStream_)
-+		return data->raw_->exportBuffers(count, buffers);
-+
-+	return -EINVAL;
-+}
-+
-+int PipelineHandlerStarFive::start(Camera *camera, const ControlList *controls)
-+{
-+	StarFiveCameraData *data = cameraData(camera);
-+	unsigned int count = data->outStream_.configuration().bufferCount;
-+	int ret = -EINVAL;
-+	
-+	LOG(STARFIVE, Debug) << __func__ << " bufferCount: " << count;
-+
-+	ret = data->video_->importBuffers(count);
-+	if (ret < 0)
-+		return ret;
-+
-+	ret = data->video_->streamOn();
-+	if (ret < 0)
-+		goto error;
-+
-+	if (data->haveRaw()) {
-+		count = data->rawStream_.configuration().bufferCount;
-+
-+		LOG(STARFIVE, Debug) << "rawbufferCount: " << count;
-+		if (count) {
-+			ret = data->raw_->importBuffers(count);
-+			if (ret < 0) {
-+				data->setRawActive(false);
-+				LOG(STARFIVE, Debug)
-+					<< "raw video importBuffers failed!";
-+				goto error;
-+			}
-+			ret = data->raw_->streamOn();
-+			if (ret < 0) {
-+				data->setRawActive(false);
-+				data->raw_->releaseBuffers();
-+				LOG(STARFIVE, Debug)
-+					<< "raw video streamOn failed!";
-+				goto error;
-+			}
-+			data->setRawActive(true);
-+		}
-+	}
-+
-+	return ret;
-+error:
-+	data->video_->releaseBuffers();
-+	return ret;
-+}
-+
-+void PipelineHandlerStarFive::stop(Camera *camera)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+
-+	StarFiveCameraData *data = cameraData(camera);
-+	data->video_->streamOff();
-+	data->video_->releaseBuffers();
-+	if (data->rawActive()) {
-+		data->raw_->streamOff();
-+		data->raw_->releaseBuffers();
-+		data->setRawActive(false);
-+	}
-+}
-+
-+int PipelineHandlerStarFive::processControls(StarFiveCameraData *data, Request *request)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+
-+	ControlList controls(data->sensor_->controls());
-+
-+	for (auto it : request->controls()) {
-+		unsigned int id = it.first;
-+		unsigned int offset;
-+		uint32_t cid;
-+
-+		if (id == controls::Brightness) {
-+			cid = V4L2_CID_BRIGHTNESS;
-+			offset = 128;
-+		} else if (id == controls::Contrast) {
-+			cid = V4L2_CID_CONTRAST;
-+			offset = 0;
-+		} else if (id == controls::Saturation) {
-+			cid = V4L2_CID_SATURATION;
-+			offset = 0;
-+		} else {
-+			continue;
-+		}
-+
-+		int32_t value = lroundf(it.second.get<float>() * 128 + offset);
-+		controls.set(cid, std::clamp(value, 0, 255));
-+	}
-+
-+	for (const auto &ctrl : controls)
-+		LOG(STARFIVE, Debug)
-+			<< "Setting control " << utils::hex(ctrl.first)
-+			<< " to " << ctrl.second.toString();
-+
-+	int ret = data->sensor_->setControls(&controls);
-+	if (ret) {
-+		LOG(STARFIVE, Debug)
-+			<< "Failed to set controls: " << ret;
-+		return ret < 0 ? ret : -EINVAL;
-+	}
-+
-+	return ret;
-+}
-+
-+int PipelineHandlerStarFive::queueRequestDevice(Camera *camera, Request *request)
-+{
-+	StarFiveCameraData *data = cameraData(camera);
-+	int error = 0;
-+
-+	LOG(STARFIVE, Debug) << __func__;
-+	int ret = processControls(data, request);
-+	if (ret < 0)
-+		return ret;
-+
-+	for (auto it : request->buffers()) {
-+		const Stream *stream = it.first;
-+		FrameBuffer *buffer = it.second;
-+		int ret;
-+
-+		LOG(STARFIVE, Debug)
-+			<< "stream queueBuffer : " << stream->configuration().toString();
-+
-+		if (stream == &data->outStream_)
-+			ret = data->video_->queueBuffer(buffer);
-+		else if (stream == &data->rawStream_)
-+			ret = data->raw_->queueBuffer(buffer);
-+		else
-+			continue;
-+
-+		if (ret < 0)
-+			error = ret;
-+	}
-+
-+	return error;
-+}
-+
-+std::string PipelineHandlerStarFive::getVideoEntityNameById(unsigned int id)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+	switch (id) {
-+	case 0:
-+		return "stf_vin0_wr_video0";
-+	case 1:
-+		return "stf_vin0_isp0_video1";
-+	case 2:
-+		return "stf_vin0_isp1_video2";
-+	case 3:
-+		return "stf_vin0_isp0_raw_video3";
-+	case 4:
-+		return "stf_vin0_isp1_raw_video4";
-+	default:
-+		return "unknow";
-+	}
-+
-+	return "unknow";
-+}
-+
-+std::string PipelineHandlerStarFive::findSensorEntityName(std::string entityName)
-+{
-+	std::string sensorEntityName;
-+	bool found = false;
-+	MediaEntity *sensorEntity = starFiveMediaDev_->getEntityByName(entityName);
-+
-+	while (1) {
-+		LOG(STARFIVE, Debug) << "findSensorEntityName: " << sensorEntity->name();
-+		const std::vector<MediaPad *> &pads = sensorEntity->pads();
-+
-+		if (pads.empty())
-+			break;
-+
-+		MediaPad *sink = pads[0];
-+		MediaLink *link;
-+		bool found_enable_link = false;
-+
-+		for (MediaLink *it : sink->links()) {
-+			if (it->flags() & MEDIA_LNK_FL_ENABLED) {
-+				found_enable_link = true;
-+				link = it;
-+				break;
-+			}
-+		}
-+
-+		if (!found_enable_link)
-+			break;
-+
-+		sensorEntity = link->source()->entity();
-+		if (sensorEntity->function() == MEDIA_ENT_F_CAM_SENSOR) {
-+			found = true;
-+			break;
-+		}
-+	}
-+
-+	if (found)
-+		sensorEntityName = sensorEntity->name();
-+	else
-+		sensorEntityName = "unknow";
-+
-+	LOG(STARFIVE, Debug) << "sensorEntityName: " << sensorEntityName;
-+	return sensorEntityName;
-+}
-+
-+int PipelineHandlerStarFive::registerCameras()
-+{
-+	unsigned int numCameras = 0;
-+
-+	LOG(STARFIVE, Debug) << __func__;
-+	for (unsigned int id = 0;
-+			id < STF_MAX_CAMERAS 
-+			&& numCameras < STF_MAX_CAMERAS; ++id) {
-+		std::string videoEntiryName;
-+		videoEntiryName = getVideoEntityNameById(id);
-+		if (videoEntiryName == "unknow")
-+			continue;
-+
-+		std::string sensorEntityName;
-+		sensorEntityName = findSensorEntityName(videoEntiryName);
-+		if (sensorEntityName == "unknow")
-+			continue;
-+
-+		std::unique_ptr<StarFiveCameraData> data =
-+			std::make_unique<StarFiveCameraData>(this, starFiveMediaDev_,
-+					videoEntiryName, sensorEntityName);
-+
-+		/* Locate and open the capture video node. */
-+		if (data->init())
-+			continue;
-+
-+		/* Create and register the camera. */
-+		LOG(STARFIVE, Debug) << "register deviceName: "
-+				     << videoEntiryName;
-+		if (data->haveRaw()) {
-+			std::set<Stream *> streams{ &data->outStream_,
-+						&data->rawStream_ };
-+			std::shared_ptr<Camera> camera =
-+				Camera::create(std::move(data), videoEntiryName, streams);
-+			registerCamera(std::move(camera));
-+		} else {
-+			std::set<Stream *> streams{ &data->outStream_ };
-+			std::shared_ptr<Camera> camera =
-+				Camera::create(std::move(data), videoEntiryName, streams);
-+			registerCamera(std::move(camera));
-+		}
-+		numCameras++;
-+	}
-+
-+	return numCameras;
-+}
-+
-+int PipelineHandlerStarFive::enableLinks(std::vector<PipelineConfigLink> config)
-+{
-+	int ret = 0;
-+
-+	LOG(STARFIVE, Debug) << __func__;
-+	for (PipelineConfigLink it : config) {
-+		MediaLink *link = starFiveMediaDev_->link(it.source, 1, it.link, 0);
-+		if (!link)
-+			return -ENODEV;
-+
-+		ret = link->setEnabled(true);
-+		if (ret < 0)
-+			return ret;
-+	}
-+
-+	return ret;
-+}
-+
-+bool PipelineHandlerStarFive::match(DeviceEnumerator *enumerator)
-+{
-+	int numCameras = 0;
-+
-+	DeviceMatch dm("stf-vin");
-+	dm.add("stf_vin0_wr_video0");
-+	dm.add("stf_vin0_isp0_video1");
-+	dm.add("stf_vin0_isp1_video2");
-+
-+	LOG(STARFIVE, Debug) << __func__;
-+	starFiveMediaDev_ = acquireMediaDevice(enumerator, dm);
-+	if (!starFiveMediaDev_)
-+		return false;
-+
-+	if (starFiveMediaDev_->disableLinks())
-+		return false;
-+
-+	for (SensorConfig it : sensorConfigs) {
-+		MediaEntity *sensorEntity =
-+			starFiveMediaDev_->getEntityByName(it.sensorEntityName_);
-+		int ret;
-+
-+		if (sensorEntity != nullptr) {
-+			if (it.sensorType_ < DVP_YUV
-+				|| it.sensorType_ >= SENSORTYPE_MAX)
-+				continue;
-+			ret = enableLinks(pipelineConfigs[it.sensorType_]);
-+			if (ret < 0) {
-+				LOG(STARFIVE, Error)
-+					<< it.sensorEntityName_
-+					<< " enableLinks failed!";
-+				continue;
-+			}
-+		}
-+	}
-+
-+	numCameras = registerCameras();
-+	if (numCameras)
-+		LOG(STARFIVE, Debug)
-+			<< "StarFive " << numCameras
-+			<< " Device Identified";
-+
-+	return numCameras != 0;
-+}
-+
-+void StarFiveCameraData::bufferReady(FrameBuffer *buffer)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+	PipelineHandlerStarFive *pipe =
-+		static_cast<PipelineHandlerStarFive *>(this->pipe());
-+	Request *request = buffer->request();
-+
-+	if (!pipe->completeBuffer(request, buffer))
-+		return;
-+
-+	pipe->completeRequest(request);
-+}
-+
-+REGISTER_PIPELINE_HANDLER(PipelineHandlerStarFive)
-+
-+} /* namespace libcamera */
-diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
-index 023e2328..bc7cbfec 100644
---- a/src/libcamera/v4l2_subdevice.cpp
-+++ b/src/libcamera/v4l2_subdevice.cpp
-@@ -525,4 +525,16 @@ std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,
- 	return sizes;
- }
- 
-+int V4L2Subdevice::ioctlPrivate(unsigned long request, void *argp)
-+{
-+	/*
-+	 * Printing out an error message is usually better performed
-+	 * in the caller, which can provide more context.
-+	 */
-+	if (V4L2Device::ioctl(request, argp) < 0)
-+		return -errno;
-+
-+	return 0;
-+}
-+
- } /* namespace libcamera */
--- 
-2.25.1
-

+ 0 - 182
package/libcamera/0002-add-sensor-ctrls.patch

@@ -1,182 +0,0 @@
-From a3756db6257742587da7e97546aa330ad363bfd1 Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Tue, 26 Oct 2021 12:29:30 +0800
-Subject: [PATCH 02/10] add sensor ctrls
-
----
- src/libcamera/pipeline/starfive/starfive.cpp | 118 ++++++++++++++++---
- 1 file changed, 99 insertions(+), 19 deletions(-)
-
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index 8797bdcb..f63af910 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -370,7 +370,7 @@ public:
- 	bool match(DeviceEnumerator *enumerator) override;
- 
- private:
--	int processControls(StarFiveCameraData *data, Request *request);
-+	int processControls(StarFiveCameraData *data, const ControlList &controls);
- 
- 	StarFiveCameraData *cameraData(Camera *camera)
- 	{
-@@ -620,6 +620,13 @@ int PipelineHandlerStarFive::start(Camera *camera, const ControlList *controls)
- 	
- 	LOG(STARFIVE, Debug) << __func__ << " bufferCount: " << count;
- 
-+	if (controls != nullptr) {
-+		ret = processControls(data, *controls);
-+		if (ret < 0)
-+			return ret;
-+	} else
-+		LOG(STARFIVE, Debug) << __func__ << " start no controls";
-+
- 	ret = data->video_->importBuffers(count);
- 	if (ret < 0)
- 		return ret;
-@@ -672,43 +679,116 @@ void PipelineHandlerStarFive::stop(Camera *camera)
- 	}
- }
- 
--int PipelineHandlerStarFive::processControls(StarFiveCameraData *data, Request *request)
-+int PipelineHandlerStarFive::processControls(StarFiveCameraData *data, const ControlList &controls)
- {
--	LOG(STARFIVE, Debug) << __func__;
-+	LOG(STARFIVE, Debug) << __func__ << ": test1 controls";
-+	const ControlInfoMap &SensorControlsInfoMap = data->sensor_->controls();
-+	ControlList SensorControls(SensorControlsInfoMap);
- 
--	ControlList controls(data->sensor_->controls());
--
--	for (auto it : request->controls()) {
-+	for (auto it : controls) {
- 		unsigned int id = it.first;
--		unsigned int offset;
--		uint32_t cid;
-+		unsigned int offset = 0;
-+		uint32_t cid = 0;
-+		int32_t value = 0;
- 
--		if (id == controls::Brightness) {
-+		switch (id) {
-+		case controls::BRIGHTNESS:
- 			cid = V4L2_CID_BRIGHTNESS;
- 			offset = 128;
--		} else if (id == controls::Contrast) {
-+			value = lroundf(it.second.get<float>() * 128 + offset);
-+			LOG(STARFIVE, Debug) << "Brightness controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		case controls::CONTRAST:
- 			cid = V4L2_CID_CONTRAST;
- 			offset = 0;
--		} else if (id == controls::Saturation) {
-+			value = lroundf(it.second.get<float>() * 128 + offset);
-+			LOG(STARFIVE, Debug) << "Contrast controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		case controls::SATURATION:
- 			cid = V4L2_CID_SATURATION;
- 			offset = 0;
--		} else {
--			continue;
-+			value = lroundf(it.second.get<float>() * 128 + offset);
-+			LOG(STARFIVE, Debug) << "Saturation controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		case controls::SHARPNESS:
-+			cid = V4L2_CID_SHARPNESS;
-+			offset = 0;
-+			value = lroundf(it.second.get<float>() * 128 + offset);
-+			LOG(STARFIVE, Debug) << "Sharpness controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		case controls::COLOUR_GAINS:
-+			cid = V4L2_CID_RED_BALANCE;
-+			offset = 0;
-+			value = lroundf(it.second.get<Span<const float>>()[0]);
-+			LOG(STARFIVE, Debug) << "ColourGains controls: " << id
-+				<< ", COLOUR_GAINS RED value: " << value;
-+			if (SensorControlsInfoMap.find(cid) != SensorControlsInfoMap.end())
-+				SensorControls.set(cid, value);
-+			else
-+				LOG(STARFIVE, Debug)
-+					<< "SensorControls not supported controls: " << id;
-+			cid = V4L2_CID_BLUE_BALANCE;
-+			value = lroundf(it.second.get<Span<const float>>()[1]);
-+			LOG(STARFIVE, Debug) << "COLOUR_GAINS BLUE value: " << value;
-+			break;
-+		case controls::AWB_ENABLE:
-+			cid = V4L2_CID_AUTO_WHITE_BALANCE;
-+			value = it.second.get<bool>();
-+			LOG(STARFIVE, Debug) << "AwbMode controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		case controls::EXPOSURE_VALUE:
-+			cid = V4L2_CID_EXPOSURE;
-+			offset = 0;
-+			value = lroundf(it.second.get<float>());
-+			LOG(STARFIVE, Debug) << "ExposureValue controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		case controls::AE_ENABLE:
-+			cid = V4L2_CID_EXPOSURE_AUTO;
-+			value = it.second.get<bool>();
-+			LOG(STARFIVE, Debug) << "AeExposureMode controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		case controls::ANALOGUE_GAIN:
-+			cid = V4L2_CID_ANALOGUE_GAIN;
-+			offset = 0;
-+			value = lroundf(it.second.get<float>());
-+			LOG(STARFIVE, Debug) << "AnalogueGain controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		case controls::DIGITAL_GAIN:
-+			cid = V4L2_CID_GAIN;
-+			offset = 0;
-+			value = lroundf(it.second.get<float>());
-+			LOG(STARFIVE, Debug) << "AnalogueGain controls: " << id
-+				<< ", value: " << value;
-+			break;
-+		default:
-+			LOG(STARFIVE, Debug) << "default controls: " << id;
-+			break;
- 		}
- 
--		int32_t value = lroundf(it.second.get<float>() * 128 + offset);
--		controls.set(cid, std::clamp(value, 0, 255));
-+		if (SensorControlsInfoMap.find(cid) != SensorControlsInfoMap.end())
-+			SensorControls.set(cid, value);
-+		else
-+			LOG(STARFIVE, Debug) << "SensorControls not supported controls: " << id;
-+
- 	}
- 
--	for (const auto &ctrl : controls)
-+	for (const auto &ctrl : SensorControls)
- 		LOG(STARFIVE, Debug)
- 			<< "Setting control " << utils::hex(ctrl.first)
- 			<< " to " << ctrl.second.toString();
- 
--	int ret = data->sensor_->setControls(&controls);
-+	int ret = data->sensor_->setControls(&SensorControls);
- 	if (ret) {
- 		LOG(STARFIVE, Debug)
--			<< "Failed to set controls: " << ret;
-+			<< "Failed to set sensor controls: " << ret;
- 		return ret < 0 ? ret : -EINVAL;
- 	}
- 
-@@ -721,7 +801,7 @@ int PipelineHandlerStarFive::queueRequestDevice(Camera *camera, Request *request
- 	int error = 0;
- 
- 	LOG(STARFIVE, Debug) << __func__;
--	int ret = processControls(data, request);
-+	int ret = processControls(data, request->controls());
- 	if (ret < 0)
- 		return ret;
- 
--- 
-2.25.1
-

+ 0 - 537
package/libcamera/0003-add-Meta-and-starfive-ipa-dummy.patch

@@ -1,537 +0,0 @@
-From 26127511bf0b6d2f016c16956d04332858bd8d7f Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Thu, 13 Jan 2022 13:52:11 +0800
-Subject: [PATCH 03/10] libcamera: 1. add caps for src templ            2. add
- starfive ipa (dummy)
-
----
- include/libcamera/ipa/meson.build            |   1 +
- include/libcamera/ipa/starfive.mojom         |  45 +++++
- meson_options.txt                            |   2 +-
- src/gstreamer/gstlibcamerasrc.cpp            |  11 +-
- src/ipa/starfive/data/meson.build            |   8 +
- src/ipa/starfive/data/starfive.conf          |   3 +
- src/ipa/starfive/meson.build                 |  23 +++
- src/ipa/starfive/starfive.cpp                | 200 +++++++++++++++++++
- src/libcamera/ipa_manager.cpp                |   4 +-
- src/libcamera/pipeline/starfive/starfive.cpp |  56 +++++-
- src/meson.build                              |   1 +
- 11 files changed, 350 insertions(+), 4 deletions(-)
- create mode 100644 include/libcamera/ipa/starfive.mojom
- create mode 100644 src/ipa/starfive/data/meson.build
- create mode 100644 src/ipa/starfive/data/starfive.conf
- create mode 100644 src/ipa/starfive/meson.build
- create mode 100644 src/ipa/starfive/starfive.cpp
-
-diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
-index 6ea94fb5..b84358a6 100644
---- a/include/libcamera/ipa/meson.build
-+++ b/include/libcamera/ipa/meson.build
-@@ -65,6 +65,7 @@ ipa_mojom_files = [
-     'raspberrypi.mojom',
-     'rkisp1.mojom',
-     'vimc.mojom',
-+	'starfive.mojom',
- ]
- 
- ipa_mojoms = []
-diff --git a/include/libcamera/ipa/starfive.mojom b/include/libcamera/ipa/starfive.mojom
-new file mode 100644
-index 00000000..b302b609
---- /dev/null
-+++ b/include/libcamera/ipa/starfive.mojom
-@@ -0,0 +1,45 @@
-+/* SPDX-License-Identifier: LGPL-2.1-or-later */
-+
-+/*
-+ * \todo Document the interface and remove the related EXCLUDE_PATTERNS entry.
-+ */
-+
-+module ipa.starfive;
-+
-+import "include/libcamera/ipa/core.mojom";
-+
-+const string StarfiveIPAFIFOPath = "/tmp/libcamera_ipa_starfive_fifo";
-+
-+enum IPAOperationCode {
-+	IPAOperationNone,
-+	IPAOperationInit,
-+	IPAOperationStart,
-+	IPAOperationStop,
-+};
-+
-+interface IPAStarfiveInterface {
-+	init(libcamera.IPASettings settings) => (int32 ret);
-+
-+	configure(libcamera.IPACameraSensorInfo sensorInfo,
-+		  map<uint32, libcamera.IPAStream> streamConfig,
-+		  map<uint32, libcamera.ControlInfoMap> entityControls) => (int32 ret);
-+
-+	start() => (int32 ret);
-+	stop();
-+
-+	mapBuffers(array<libcamera.IPABuffer> buffers);
-+	unmapBuffers(array<uint32> ids);
-+
-+	/*
-+	 * The starfive driver doesn't use parameters buffers. To maximize coverage
-+	 * of unit tests that rely on the starfive pipeline handler, we still define
-+	 * interface functions that mimick how other pipeline handlers typically
-+	 * handle parameters at runtime.
-+	 */
-+	[async] fillParams(uint32 frame, uint32 bufferId);
-+	[async] processControls(uint32 frame, libcamera.ControlList controls);
-+};
-+
-+interface IPAStarfiveEventInterface {
-+	paramsFilled(uint32 bufferId);
-+};
-diff --git a/meson_options.txt b/meson_options.txt
-index 14baa7ef..ba4ecb0b 100644
---- a/meson_options.txt
-+++ b/meson_options.txt
-@@ -27,7 +27,7 @@ option('gstreamer',
- 
- option('ipas',
-         type : 'array',
--        choices : ['ipu3', 'raspberrypi', 'rkisp1', 'vimc'],
-+        choices : ['ipu3', 'raspberrypi', 'rkisp1', 'vimc' ,'starfive'],
-         description : 'Select which IPA modules to build')
- 
- option('lc-compliance',
-diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
-index 1dd0e807..6329b01a 100644
---- a/src/gstreamer/gstlibcamerasrc.cpp
-+++ b/src/gstreamer/gstlibcamerasrc.cpp
-@@ -140,9 +140,18 @@ G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT,
- 
- #define TEMPLATE_CAPS GST_STATIC_CAPS("video/x-raw; image/jpeg")
- 
-+#define TEMPLATE_CAPS_SRC GST_STATIC_CAPS("video/x-raw, "\
-+		"format = { (string)BG24,(string)RG24,(string)BA24, \
-+			(string)NV12, (string)NV21, (string)NV16, \
-+			(string)NV61, (string)NV24, (string)UYVY, \
-+			(string)VYUY, (string)YUYV, (string)YVYU}, "\
-+			"width = " GST_VIDEO_SIZE_RANGE ", "\
-+			"height = " GST_VIDEO_SIZE_RANGE ", "\
-+			"framerate = " GST_VIDEO_FPS_RANGE ";"\
-+)
- /* For the simple case, we have a src pad that is always present. */
- GstStaticPadTemplate src_template = {
--	"src", GST_PAD_SRC, GST_PAD_ALWAYS, TEMPLATE_CAPS
-+	"src", GST_PAD_SRC, GST_PAD_ALWAYS, TEMPLATE_CAPS_SRC
- };
- 
- /* More pads can be requested in state < PAUSED */
-diff --git a/src/ipa/starfive/data/meson.build b/src/ipa/starfive/data/meson.build
-new file mode 100644
-index 00000000..0ce6a9b4
---- /dev/null
-+++ b/src/ipa/starfive/data/meson.build
-@@ -0,0 +1,8 @@
-+# SPDX-License-Identifier: CC0-1.0
-+
-+conf_files = files([
-+    'starfive.conf',
-+])
-+
-+install_data(conf_files,
-+             install_dir : ipa_data_dir / 'starfive')
-diff --git a/src/ipa/starfive/data/starfive.conf b/src/ipa/starfive/data/starfive.conf
-new file mode 100644
-index 00000000..6b74f622
---- /dev/null
-+++ b/src/ipa/starfive/data/starfive.conf
-@@ -0,0 +1,3 @@
-+# SPDX-License-Identifier: LGPL-2.1-or-later
-+#
-+# Dummy configuration file for the starfive IPA.
-diff --git a/src/ipa/starfive/meson.build b/src/ipa/starfive/meson.build
-new file mode 100644
-index 00000000..c93bd058
---- /dev/null
-+++ b/src/ipa/starfive/meson.build
-@@ -0,0 +1,23 @@
-+# SPDX-License-Identifier: CC0-1.0
-+
-+ipa_name = 'ipa_starfive'
-+
-+mod = shared_module(ipa_name,
-+                    ['starfive.cpp', libcamera_generated_ipa_headers],
-+                    name_prefix : '',
-+                    include_directories : [ipa_includes, libipa_includes],
-+                    dependencies : libcamera_private,
-+                    link_with : libipa,
-+                    install : true,
-+                    install_dir : ipa_install_dir)
-+
-+if ipa_sign_module
-+    custom_target(ipa_name + '.so.sign',
-+                  input : mod,
-+                  output : ipa_name + '.so.sign',
-+                  command : [ipa_sign, ipa_priv_key, '@INPUT@', '@OUTPUT@'],
-+                  install : false,
-+                  build_by_default : true)
-+endif
-+
-+subdir('data')
-diff --git a/src/ipa/starfive/starfive.cpp b/src/ipa/starfive/starfive.cpp
-new file mode 100644
-index 00000000..e1207606
---- /dev/null
-+++ b/src/ipa/starfive/starfive.cpp
-@@ -0,0 +1,200 @@
-+/* SPDX-License-Identifier: LGPL-2.1-or-later */
-+/*
-+ * Copyright (C) 2019, Google Inc.
-+ *
-+ * ipa_starfive.cpp - Starfive Image Processing Algorithm module
-+ */
-+#include <libcamera/ipa/starfive_ipa_interface.h>
-+
-+#include <fcntl.h>
-+#include <string.h>
-+#include <sys/stat.h>
-+#include <unistd.h>
-+
-+#include <iostream>
-+
-+#include <libcamera/base/file.h>
-+#include <libcamera/base/log.h>
-+
-+#include <libcamera/ipa/ipa_interface.h>
-+#include <libcamera/ipa/ipa_module_info.h>
-+
-+#include "libcamera/internal/mapped_framebuffer.h"
-+
-+namespace libcamera {
-+
-+LOG_DEFINE_CATEGORY(IPAStarfive)
-+
-+class IPAStarfive : public ipa::starfive::IPAStarfiveInterface
-+{
-+public:
-+	IPAStarfive();
-+	~IPAStarfive();
-+
-+	int init(const IPASettings &settings) override;
-+
-+	int start() override;
-+	void stop() override;
-+
-+	int configure(const IPACameraSensorInfo &sensorInfo,
-+		      const std::map<unsigned int, IPAStream> &streamConfig,
-+		      const std::map<unsigned int, ControlInfoMap> &entityControls) override;
-+
-+	void mapBuffers(const std::vector<IPABuffer> &buffers) override;
-+	void unmapBuffers(const std::vector<unsigned int> &ids) override;
-+
-+	void fillParams(uint32_t frame, uint32_t bufferId) override;
-+	void processControls(uint32_t frame, const ControlList &controls) override;
-+
-+private:
-+	void initTrace();
-+	void trace(enum ipa::starfive::IPAOperationCode operation);
-+
-+	int fd_;
-+	std::map<unsigned int, MappedFrameBuffer> buffers_;
-+};
-+
-+IPAStarfive::IPAStarfive()
-+	: fd_(-1)
-+{
-+	initTrace();
-+}
-+
-+IPAStarfive::~IPAStarfive()
-+{
-+	if (fd_ != -1)
-+		::close(fd_);
-+}
-+
-+int IPAStarfive::init(const IPASettings &settings)
-+{
-+	trace(ipa::starfive::IPAOperationInit);
-+
-+	LOG(IPAStarfive, Debug)
-+		<< "initializing starfive IPA with configuration file "
-+		<< settings.configurationFile;
-+
-+	File conf(settings.configurationFile);
-+	if (!conf.open(File::OpenModeFlag::ReadOnly)) {
-+		LOG(IPAStarfive, Error) << "Failed to open configuration file";
-+		return -EINVAL;
-+	}
-+
-+	return 0;
-+}
-+
-+int IPAStarfive::start()
-+{
-+	trace(ipa::starfive::IPAOperationStart);
-+
-+	LOG(IPAStarfive, Debug) << "start starfive IPA!";
-+
-+	return 0;
-+}
-+
-+void IPAStarfive::stop()
-+{
-+	trace(ipa::starfive::IPAOperationStop);
-+
-+	LOG(IPAStarfive, Debug) << "stop starfive IPA!";
-+}
-+
-+int IPAStarfive::configure([[maybe_unused]] const IPACameraSensorInfo &sensorInfo,
-+			[[maybe_unused]] const std::map<unsigned int, IPAStream> &streamConfig,
-+			[[maybe_unused]] const std::map<unsigned int, ControlInfoMap> &entityControls)
-+{
-+	LOG(IPAStarfive, Debug) << "configure()";
-+
-+	return 0;
-+}
-+
-+void IPAStarfive::mapBuffers(const std::vector<IPABuffer> &buffers)
-+{
-+	LOG(IPAStarfive, Debug) << "mapBuffers()";
-+	for (const IPABuffer &buffer : buffers) {
-+		const FrameBuffer fb(buffer.planes);
-+		buffers_.emplace(std::piecewise_construct,
-+				 std::forward_as_tuple(buffer.id),
-+				 std::forward_as_tuple(&fb, MappedFrameBuffer::MapFlag::Read));
-+	}
-+}
-+
-+void IPAStarfive::unmapBuffers(const std::vector<unsigned int> &ids)
-+{
-+	LOG(IPAStarfive, Debug) << "unmapBuffers()";
-+	for (unsigned int id : ids) {
-+		auto it = buffers_.find(id);
-+		if (it == buffers_.end())
-+			continue;
-+
-+		buffers_.erase(it);
-+	}
-+}
-+
-+void IPAStarfive::fillParams([[maybe_unused]] uint32_t frame, uint32_t bufferId)
-+{
-+	auto it = buffers_.find(bufferId);
-+	if (it == buffers_.end()) {
-+		LOG(IPAStarfive, Error) << "Could not find parameter buffer";
-+		return;
-+	}
-+
-+	paramsFilled.emit(bufferId);
-+}
-+
-+void IPAStarfive::processControls([[maybe_unused]] uint32_t frame,
-+			      [[maybe_unused]] const ControlList &controls)
-+{
-+	LOG(IPAStarfive,Debug) << "IPA ProcessControl";
-+}
-+
-+void IPAStarfive::initTrace()
-+{
-+	struct stat fifoStat;
-+	int ret = stat(ipa::starfive::StarfiveIPAFIFOPath.c_str(), &fifoStat);
-+	if (ret)
-+		return;
-+
-+	ret = ::open(ipa::starfive::StarfiveIPAFIFOPath.c_str(), O_WRONLY);
-+	if (ret < 0) {
-+		ret = errno;
-+		LOG(IPAStarfive, Error) << "Failed to open starfive IPA test FIFO: "
-+				    << strerror(ret);
-+		return;
-+	}
-+
-+	fd_ = ret;
-+}
-+
-+void IPAStarfive::trace(enum ipa::starfive::IPAOperationCode operation)
-+{
-+	if (fd_ < 0)
-+		return;
-+
-+	int ret = ::write(fd_, &operation, sizeof(operation));
-+	if (ret < 0) {
-+		ret = errno;
-+		LOG(IPAStarfive, Error) << "Failed to write to starfive IPA test FIFO: "
-+				    << strerror(ret);
-+	}
-+}
-+
-+/*
-+ * External IPA module interface
-+ */
-+
-+extern "C" {
-+const struct IPAModuleInfo ipaModuleInfo = {
-+	IPA_MODULE_API_VERSION,
-+	0,
-+	"PipelineHandlerStarFive",
-+	"starfive",
-+};
-+
-+IPAInterface *ipaCreate()
-+{
-+	return new IPAStarfive();
-+}
-+}
-+
-+} /* namespace libcamera */
-diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp
-index ec966045..634cbb8d 100644
---- a/src/libcamera/ipa_manager.cpp
-+++ b/src/libcamera/ipa_manager.cpp
-@@ -276,7 +276,9 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,
- 
- bool IPAManager::isSignatureValid([[maybe_unused]] IPAModule *ipa) const
- {
--#if HAVE_IPA_PUBKEY
-+#if SKIP_SIGN_VERIFY
-+	return true;
-+#elif HAVE_IPA_PUBKEY
- 	char *force = utils::secure_getenv("LIBCAMERA_IPA_FORCE_ISOLATION");
- 	if (force && force[0] != '\0') {
- 		LOG(IPAManager, Debug)
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index f63af910..bc82a062 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -23,6 +23,10 @@
- #include <linux/videodev2.h>
- #include <linux/v4l2-subdev.h>
- 
-+#include <libcamera/ipa/ipa_interface.h>
-+#include <libcamera/ipa/ipa_module_info.h>
-+#include <libcamera/ipa/starfive_ipa_interface.h>
-+#include <libcamera/ipa/starfive_ipa_proxy.h>
- #include "libcamera/internal/camera.h"
- #include "libcamera/internal/camera_sensor.h"
- #include "libcamera/internal/device_enumerator.h"
-@@ -189,6 +193,7 @@ public:
- 	std::vector<SizeRange> sensorSizes() const;
- 	std::vector<PixelFormat> sensorFormats() const;
- 	std::vector<PixelFormat> videoFormats() const;
-+	void paramsFilled(unsigned int id){}
- 
- 	MediaDevice *media_;
- 	V4L2VideoDevice *video_;
-@@ -197,6 +202,8 @@ public:
- 	CameraSensor *sensor_;
- 	Stream outStream_;
- 	Stream rawStream_;
-+	std::unique_ptr<ipa::starfive::IPAProxyStarfive> ipa_;
-+	std::vector<std::unique_ptr<FrameBuffer>> mockIPABufs_;
- 
- private:
- 	bool haveRaw_;
-@@ -591,6 +598,22 @@ int PipelineHandlerStarFive::configure(Camera *camera, CameraConfiguration *c)
- 			    data->video_->toV4L2PixelFormat(cfg.pixelFormat))
- 				return -EINVAL;
- 		}
-+
-+		if (data->ipa_) {
-+		/* Inform IPA of stream configuration and sensor controls. */
-+		std::map<unsigned int, IPAStream> streamConfig;
-+		streamConfig.emplace(std::piecewise_construct,
-+					std::forward_as_tuple(0),
-+					std::forward_as_tuple(cfg.pixelFormat, cfg.size));
-+
-+		std::map<unsigned int, ControlInfoMap> entityControls;
-+		entityControls.emplace(0, data->sensor_->controls());
-+
-+		IPACameraSensorInfo sensorInfo;
-+		data->sensor_->sensorInfo(&sensorInfo);
-+
-+		data->ipa_->configure(sensorInfo, streamConfig, entityControls);
-+		}
- 	}
- 
- 	return 0;
-@@ -630,6 +653,17 @@ int PipelineHandlerStarFive::start(Camera *camera, const ControlList *controls)
- 	ret = data->video_->importBuffers(count);
- 	if (ret < 0)
- 		return ret;
-+	
-+	/* Map the mock IPA buffers to VIMC IPA to exercise IPC code paths. */
-+	std::vector<IPABuffer> ipaBuffers;
-+	for (auto [i, buffer] : utils::enumerate(data->mockIPABufs_)) {
-+		buffer->setCookie(i + 1);
-+		ipaBuffers.emplace_back(buffer->cookie(), buffer->planes());
-+	}
-+	data->ipa_->mapBuffers(ipaBuffers);
-+	ret = data->ipa_->start();
-+	if(ret < 0)
-+		goto error;
- 
- 	ret = data->video_->streamOn();
- 	if (ret < 0)
-@@ -661,6 +695,7 @@ int PipelineHandlerStarFive::start(Camera *camera, const ControlList *controls)
- 
- 	return ret;
- error:
-+	data->ipa_->stop();
- 	data->video_->releaseBuffers();
- 	return ret;
- }
-@@ -671,6 +706,12 @@ void PipelineHandlerStarFive::stop(Camera *camera)
- 
- 	StarFiveCameraData *data = cameraData(camera);
- 	data->video_->streamOff();
-+	std::vector<unsigned int> ids;
-+	for (const std::unique_ptr<FrameBuffer> &buffer : data->mockIPABufs_)
-+		ids.push_back(buffer->cookie());
-+	data->ipa_->unmapBuffers(ids);
-+	data->ipa_->stop();
-+
- 	data->video_->releaseBuffers();
- 	if (data->rawActive()) {
- 		data->raw_->streamOff();
-@@ -813,8 +854,11 @@ int PipelineHandlerStarFive::queueRequestDevice(Camera *camera, Request *request
- 		LOG(STARFIVE, Debug)
- 			<< "stream queueBuffer : " << stream->configuration().toString();
- 
--		if (stream == &data->outStream_)
-+		if (stream == &data->outStream_){
- 			ret = data->video_->queueBuffer(buffer);
-+			data->ipa_->processControls(request->sequence(), request->controls());
-+		}
-+
- 		else if (stream == &data->rawStream_)
- 			ret = data->raw_->queueBuffer(buffer);
- 		else
-@@ -918,6 +962,16 @@ int PipelineHandlerStarFive::registerCameras()
- 		if (data->init())
- 			continue;
- 
-+		/*create ipa module*/
-+		data->ipa_ = IPAManager::createIPA<ipa::starfive::IPAProxyStarfive>(this, 0, 0);
-+		if (!data->ipa_) {
-+			LOG(STARFIVE, Error) << "no matching IPA found";
-+			return false;
-+		}
-+		data->ipa_->paramsFilled.connect(data.get(), &StarFiveCameraData::paramsFilled);
-+		std::string conf = data->ipa_->configurationFile("starfive.conf");
-+		data->ipa_->init(IPASettings{ conf, data->sensor_->model() });
-+
- 		/* Create and register the camera. */
- 		LOG(STARFIVE, Debug) << "register deviceName: "
- 				     << videoEntiryName;
-diff --git a/src/meson.build b/src/meson.build
-index e0ea9c35..8ae89b5b 100644
---- a/src/meson.build
-+++ b/src/meson.build
-@@ -20,6 +20,7 @@ if openssl.found()
-                                  output : ['ipa-priv-key.pem'],
-                                  command : [gen_ipa_priv_key, '@OUTPUT@'])
-     config_h.set('HAVE_IPA_PUBKEY', 1)
-+    config_h.set('SKIP_SIGN_VERIFY',1)
-     ipa_sign_module = true
- else
-     ipa_sign_module = false
--- 
-2.25.1
-

+ 0 - 74
package/libcamera/0004-update-toV4L2PixelFormat.patch

@@ -1,74 +0,0 @@
-From eb7bd9dc15d8a2636d12d4e8cec219946fea353d Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Tue, 16 Nov 2021 17:23:17 +0800
-Subject: [PATCH 04/10] update toV4L2PixelFormat
-
----
- src/libcamera/pipeline/starfive/starfive.cpp | 18 ++++++++++++------
- 1 file changed, 12 insertions(+), 6 deletions(-)
-
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index bc82a062..58e1f55a 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -440,7 +440,8 @@ CameraConfiguration::Status StarFiveCameraConfiguration::validate()
- 				&& data_->haveRaw()) {
- 			V4L2DeviceFormat format = {};
- 			format.fourcc =
--				data_->raw_->toV4L2PixelFormat(cfg.pixelFormat);
-+				V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat,
-+						data_->raw_->caps().isMultiplanar());
- 			format.size = cfg.size;
- 
- 			int ret = data_->raw_->tryFormat(&format);
-@@ -454,7 +455,8 @@ CameraConfiguration::Status StarFiveCameraConfiguration::validate()
- 		} else {
- 			V4L2DeviceFormat format = {};
- 			format.fourcc =
--				data_->video_->toV4L2PixelFormat(cfg.pixelFormat);
-+				V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat,
-+						data_->video_->caps().isMultiplanar());
- 			format.size = cfg.size;
- 
- 			int ret = data_->video_->tryFormat(&format);
-@@ -571,7 +573,8 @@ int PipelineHandlerStarFive::configure(Camera *camera, CameraConfiguration *c)
- 		if (stream == &data->rawStream_) {
- 			V4L2DeviceFormat format = {};
- 			format.fourcc =
--				data->raw_->toV4L2PixelFormat(cfg.pixelFormat);
-+				V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat,
-+						data->raw_->caps().isMultiplanar());
- 			format.size = cfg.size;
- 
- 			ret = data->raw_->setFormat(&format);
-@@ -580,13 +583,15 @@ int PipelineHandlerStarFive::configure(Camera *camera, CameraConfiguration *c)
- 
- 			if (format.size != cfg.size ||
- 			    format.fourcc !=
--			    data->raw_->toV4L2PixelFormat(cfg.pixelFormat))
-+			    V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat,
-+				    data->raw_->caps().isMultiplanar()))
- 				return -EINVAL;
- 
- 		} else if (stream == &data->outStream_) {
- 			V4L2DeviceFormat format = {};
- 			format.fourcc =
--				data->video_->toV4L2PixelFormat(cfg.pixelFormat);
-+				V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat,
-+						data->video_->caps().isMultiplanar());
- 			format.size = cfg.size;
- 
- 			ret = data->video_->setFormat(&format);
-@@ -595,7 +600,8 @@ int PipelineHandlerStarFive::configure(Camera *camera, CameraConfiguration *c)
- 
- 			if (format.size != cfg.size ||
- 			    format.fourcc !=
--			    data->video_->toV4L2PixelFormat(cfg.pixelFormat))
-+			    V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat,
-+				    data->video_->caps().isMultiplanar()))
- 				return -EINVAL;
- 		}
- 
--- 
-2.25.1
-

+ 0 - 30
package/libcamera/0005-fix-build-gen-version-error.patch

@@ -1,30 +0,0 @@
-From 4810d94989891c7bb825ab5847b7e01e9db5e14d Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Wed, 17 Nov 2021 10:07:35 +0800
-Subject: [PATCH 05/10] fix build gen version error
-
----
- utils/gen-version.sh | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/utils/gen-version.sh b/utils/gen-version.sh
-index eb7c7268..ef548100 100755
---- a/utils/gen-version.sh
-+++ b/utils/gen-version.sh
-@@ -3,6 +3,8 @@
- # SPDX-License-Identifier: GPL-2.0-or-later
- # Generate a version string using git describe
- 
-+workdir=$PWD
-+cd ../../../../buildroot/dl/libcamera/git/
- build_dir="$1"
- src_dir="$2"
- 
-@@ -48,3 +50,4 @@ git diff-index --quiet HEAD || version="$version-dirty ($(date --iso-8601=second
- version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 2-)
- 
- echo "$version"
-+cd $workdir
--- 
-2.25.1
-

+ 0 - 32
package/libcamera/0006-fix-yuy2-format-unsupported.patch

@@ -1,32 +0,0 @@
-From 652fa5837d0c54c4b850b6b2a2171dc94aab3c1f Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Thu, 13 Jan 2022 13:57:12 +0800
-Subject: [PATCH 06/10] libcamera: pixel formats supported should move to
- request pads
-
----
- src/gstreamer/gstlibcamerasrc.cpp | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
-index 6329b01a..53247c3f 100644
---- a/src/gstreamer/gstlibcamerasrc.cpp
-+++ b/src/gstreamer/gstlibcamerasrc.cpp
-@@ -151,12 +151,12 @@ G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT,
- )
- /* For the simple case, we have a src pad that is always present. */
- GstStaticPadTemplate src_template = {
--	"src", GST_PAD_SRC, GST_PAD_ALWAYS, TEMPLATE_CAPS_SRC
-+	"src", GST_PAD_SRC, GST_PAD_ALWAYS, TEMPLATE_CAPS
- };
- 
- /* More pads can be requested in state < PAUSED */
- GstStaticPadTemplate request_src_template = {
--	"src_%u", GST_PAD_SRC, GST_PAD_REQUEST, TEMPLATE_CAPS
-+	"src_%u", GST_PAD_SRC, GST_PAD_REQUEST, TEMPLATE_CAPS_SRC
- };
- 
- void
--- 
-2.25.1
-

+ 0 - 318
package/libcamera/0007-add-list-controls-and-properties.patch

@@ -1,318 +0,0 @@
-From 5e558d4454fa476cc9e0670a30d631a1174b55a2 Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Tue, 23 Nov 2021 10:44:04 +0800
-Subject: [PATCH 07/10] add list controls and properties
-
----
- src/libcamera/pipeline/starfive/starfive.cpp | 219 ++++++++++++++-----
- 1 file changed, 165 insertions(+), 54 deletions(-)
-
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index 58e1f55a..b91a85a4 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -185,7 +185,9 @@ public:
- 			delete ispSubDev_;
- 	}
- 
--	int init();
-+	int init(MediaDevice *media);
-+	void addControl(uint32_t cid, const ControlInfo &v4l2Info,
-+				ControlInfoMap::Map *ctrls);
- 	void bufferReady(FrameBuffer *buffer);
- 	bool haveRaw() const { return haveRaw_; }
- 	bool rawActive() const { return rawActive_; }
-@@ -298,7 +300,7 @@ private:
- 	StarFiveCameraData *data_;
- };
- 
--int StarFiveCameraData::init()
-+int StarFiveCameraData::init(MediaDevice *media)
- {
- 	int ret;
- 
-@@ -353,7 +355,38 @@ int StarFiveCameraData::init()
- 					&StarFiveCameraData::bufferReady);
- 		}
- 	}
--	
-+
-+	// properties_.set(properties::Location, properties::CameraLocationExternal);
-+	properties_.set(properties::Model, utils::toAscii(media->model()));
-+
-+	/*
-+	 * Get the current format in order to initialize the sensor array
-+	 * properties.
-+	 */
-+	Size resolution;
-+	for (const auto &it : video_->formats()) {
-+		const std::vector<SizeRange> &sizeRanges = it.second;
-+		for (const SizeRange &sizeRange : sizeRanges) {
-+			if (sizeRange.max > resolution)
-+				resolution = sizeRange.max;
-+		}
-+	}
-+
-+	properties_.set(properties::PixelArraySize, resolution);
-+	properties_.set(properties::PixelArrayActiveAreas, { Rectangle(resolution) });
-+
-+	/* Initialise the supported controls. */
-+	ControlInfoMap::Map ctrls;
-+
-+	for (const auto &ctrl : sensor_->controls()) {
-+		uint32_t cid = ctrl.first->id();
-+		const ControlInfo &info = ctrl.second;
-+
-+		addControl(cid, info, &ctrls);
-+	}
-+
-+	controlInfo_ = ControlInfoMap(std::move(ctrls), controls::controls);
-+
- 	return 0;
- }
- 
-@@ -734,97 +767,89 @@ int PipelineHandlerStarFive::processControls(StarFiveCameraData *data, const Con
- 
- 	for (auto it : controls) {
- 		unsigned int id = it.first;
--		unsigned int offset = 0;
- 		uint32_t cid = 0;
- 		int32_t value = 0;
- 
- 		switch (id) {
- 		case controls::BRIGHTNESS:
- 			cid = V4L2_CID_BRIGHTNESS;
--			offset = 128;
--			value = lroundf(it.second.get<float>() * 128 + offset);
--			LOG(STARFIVE, Debug) << "Brightness controls: " << id
--				<< ", value: " << value;
- 			break;
- 		case controls::CONTRAST:
- 			cid = V4L2_CID_CONTRAST;
--			offset = 0;
--			value = lroundf(it.second.get<float>() * 128 + offset);
--			LOG(STARFIVE, Debug) << "Contrast controls: " << id
--				<< ", value: " << value;
- 			break;
- 		case controls::SATURATION:
- 			cid = V4L2_CID_SATURATION;
--			offset = 0;
--			value = lroundf(it.second.get<float>() * 128 + offset);
--			LOG(STARFIVE, Debug) << "Saturation controls: " << id
--				<< ", value: " << value;
- 			break;
- 		case controls::SHARPNESS:
- 			cid = V4L2_CID_SHARPNESS;
--			offset = 0;
--			value = lroundf(it.second.get<float>() * 128 + offset);
--			LOG(STARFIVE, Debug) << "Sharpness controls: " << id
--				<< ", value: " << value;
- 			break;
- 		case controls::COLOUR_GAINS:
- 			cid = V4L2_CID_RED_BALANCE;
--			offset = 0;
--			value = lroundf(it.second.get<Span<const float>>()[0]);
--			LOG(STARFIVE, Debug) << "ColourGains controls: " << id
--				<< ", COLOUR_GAINS RED value: " << value;
--			if (SensorControlsInfoMap.find(cid) != SensorControlsInfoMap.end())
--				SensorControls.set(cid, value);
--			else
--				LOG(STARFIVE, Debug)
--					<< "SensorControls not supported controls: " << id;
--			cid = V4L2_CID_BLUE_BALANCE;
--			value = lroundf(it.second.get<Span<const float>>()[1]);
--			LOG(STARFIVE, Debug) << "COLOUR_GAINS BLUE value: " << value;
- 			break;
- 		case controls::AWB_ENABLE:
- 			cid = V4L2_CID_AUTO_WHITE_BALANCE;
--			value = it.second.get<bool>();
--			LOG(STARFIVE, Debug) << "AwbMode controls: " << id
--				<< ", value: " << value;
- 			break;
- 		case controls::EXPOSURE_VALUE:
- 			cid = V4L2_CID_EXPOSURE;
--			offset = 0;
--			value = lroundf(it.second.get<float>());
--			LOG(STARFIVE, Debug) << "ExposureValue controls: " << id
--				<< ", value: " << value;
- 			break;
- 		case controls::AE_ENABLE:
- 			cid = V4L2_CID_EXPOSURE_AUTO;
--			value = it.second.get<bool>();
--			LOG(STARFIVE, Debug) << "AeExposureMode controls: " << id
--				<< ", value: " << value;
- 			break;
- 		case controls::ANALOGUE_GAIN:
- 			cid = V4L2_CID_ANALOGUE_GAIN;
--			offset = 0;
--			value = lroundf(it.second.get<float>());
--			LOG(STARFIVE, Debug) << "AnalogueGain controls: " << id
--				<< ", value: " << value;
- 			break;
- 		case controls::DIGITAL_GAIN:
--			cid = V4L2_CID_GAIN;
--			offset = 0;
--			value = lroundf(it.second.get<float>());
--			LOG(STARFIVE, Debug) << "AnalogueGain controls: " << id
--				<< ", value: " << value;
-+			cid = V4L2_CID_DIGITAL_GAIN;
- 			break;
- 		default:
--			LOG(STARFIVE, Debug) << "default controls: " << id;
-+			continue;
-+		}
-+
-+		if (SensorControlsInfoMap.find(cid) == SensorControlsInfoMap.end()) {
-+			LOG(STARFIVE, Debug) << "SensorControls not supported controls: " << id;
-+			continue;
-+		}
-+
-+		const ControlInfo &v4l2Info = SensorControlsInfoMap.at(cid);
-+		int32_t min = v4l2Info.min().get<int32_t>();
-+		int32_t def = v4l2Info.def().get<int32_t>();
-+		int32_t max = v4l2Info.max().get<int32_t>();
-+
-+		switch (id) {
-+		case controls::SATURATION:
-+		case controls::SHARPNESS:
-+		case controls::CONTRAST:
-+		case controls::EXPOSURE_VALUE:
-+		case controls::ANALOGUE_GAIN:
-+		case controls::DIGITAL_GAIN:
-+		case controls::BRIGHTNESS: {
-+			value = static_cast<int32_t>(lroundf(it.second.get<float>()));
-+			break;
-+		}
-+		case controls::COLOUR_GAINS: {
-+			value = static_cast<int32_t>(lroundf(it.second.get<float>()));
-+			LOG(STARFIVE, Debug) << "ColourGains controls: " << id
-+				<< ", COLOUR_GAINS RED value: " << value;
-+			SensorControls.set(cid, value);
-+			cid = V4L2_CID_BLUE_BALANCE;
-+			value = static_cast<int32_t>(lroundf(it.second.get<float>()));
-+			LOG(STARFIVE, Debug) << "COLOUR_GAINS BLUE value: " << value;
-+			break;
-+		}
-+		case controls::AWB_ENABLE:
-+		case controls::AE_ENABLE:
-+			value = it.second.get<bool>();
- 			break;
-+		default:
-+			LOG(STARFIVE, Debug) << "default controls: " << id;
-+			continue;
- 		}
- 
-+		LOG(STARFIVE, Debug) << "controls: " << id << ", value: " << value;
- 		if (SensorControlsInfoMap.find(cid) != SensorControlsInfoMap.end())
- 			SensorControls.set(cid, value);
- 		else
- 			LOG(STARFIVE, Debug) << "SensorControls not supported controls: " << id;
--
- 	}
- 
- 	for (const auto &ctrl : SensorControls)
-@@ -965,7 +990,7 @@ int PipelineHandlerStarFive::registerCameras()
- 					videoEntiryName, sensorEntityName);
- 
- 		/* Locate and open the capture video node. */
--		if (data->init())
-+		if (data->init(starFiveMediaDev_))
- 			continue;
- 
- 		/*create ipa module*/
-@@ -1075,6 +1100,92 @@ void StarFiveCameraData::bufferReady(FrameBuffer *buffer)
- 	pipe->completeRequest(request);
- }
- 
-+void StarFiveCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,
-+				ControlInfoMap::Map *ctrls)
-+{
-+	const ControlId *id;
-+	ControlInfo info;
-+
-+	LOG(STARFIVE, Debug) << __func__ << " cid: " << utils::hex(cid);
-+	/* Map the control ID. */
-+	switch (cid) {
-+	case V4L2_CID_BRIGHTNESS:
-+		id = &controls::Brightness;
-+		break;
-+	case V4L2_CID_CONTRAST:
-+		id = &controls::Contrast;
-+		break;
-+	case V4L2_CID_SATURATION:
-+		id = &controls::Saturation;
-+		break;
-+	case V4L2_CID_SHARPNESS:
-+		id = &controls::Sharpness;
-+		break;
-+	case V4L2_CID_RED_BALANCE:
-+	case V4L2_CID_BLUE_BALANCE:
-+		id = &controls::ColourGains;
-+		break;
-+	case V4L2_CID_AUTO_WHITE_BALANCE:
-+		id = &controls::AwbMode;
-+		break;
-+	case V4L2_CID_EXPOSURE:
-+		id = &controls::ExposureValue;
-+		break;
-+	case V4L2_CID_EXPOSURE_AUTO:
-+		id = &controls::AeExposureMode;
-+		break;
-+	case V4L2_CID_ANALOGUE_GAIN:
-+		id = &controls::AnalogueGain;
-+		break;
-+	case V4L2_CID_DIGITAL_GAIN:
-+		id = &controls::DigitalGain;
-+		break;
-+	default:
-+		LOG(STARFIVE, Debug) << __func__ << " unsupport cid: " << utils::hex(cid);
-+		return;
-+	}
-+
-+	/* Map the control info. */
-+	int32_t min = v4l2Info.min().get<int32_t>();
-+	int32_t max = v4l2Info.max().get<int32_t>();
-+	int32_t def = v4l2Info.def().get<int32_t>();
-+
-+	switch (cid) {
-+	case V4L2_CID_SATURATION:
-+	case V4L2_CID_SHARPNESS:
-+	case V4L2_CID_CONTRAST:
-+	case V4L2_CID_EXPOSURE:
-+	case V4L2_CID_ANALOGUE_GAIN:
-+	case V4L2_CID_DIGITAL_GAIN:
-+	case V4L2_CID_BRIGHTNESS: {
-+		info = ControlInfo{
-+			{ static_cast<float>(min) },
-+			{ static_cast<float>(max) },
-+			{ static_cast<float>(def) },
-+		};
-+		break;
-+	}
-+
-+	case V4L2_CID_EXPOSURE_AUTO:
-+		info = ControlInfo{ false, true, true };
-+		break;
-+
-+	case V4L2_CID_EXPOSURE_ABSOLUTE:
-+		info = ControlInfo{
-+			{ min * 100 },
-+			{ max * 100 },
-+			{ def * 100 }
-+		};
-+		break;
-+
-+	default:
-+		info = v4l2Info;
-+		break;
-+	}
-+
-+	ctrls->emplace(id, info);
-+}
-+
- REGISTER_PIPELINE_HANDLER(PipelineHandlerStarFive)
- 
- } /* namespace libcamera */
--- 
-2.25.1
-

+ 0 - 249
package/libcamera/0008-support-use-yaml-file-to-config-sensor-pipeline.patch

@@ -1,249 +0,0 @@
-From 4c51694d5f3fbb23423f60165f928e50e7d9c3a3 Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Wed, 15 Dec 2021 17:13:58 +0800
-Subject: [PATCH 08/10] support use yaml file to config sensor pipeline
-
----
- src/libcamera/meson.build                     |   3 +
- .../pipeline/starfive/sensors_pipeline.yaml   |  35 ++++++
- src/libcamera/pipeline/starfive/starfive.cpp  | 106 ++++++++++++++++--
- 3 files changed, 132 insertions(+), 12 deletions(-)
- create mode 100644 src/libcamera/pipeline/starfive/sensors_pipeline.yaml
-
-diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
-index 6727a777..39c44d42 100644
---- a/src/libcamera/meson.build
-+++ b/src/libcamera/meson.build
-@@ -113,6 +113,8 @@ if ipa_sign_module
-     libcamera_sources += ipa_pub_key_cpp
- endif
- 
-+libyamlcpp = cc.find_library('yaml-cpp', required : true)
-+
- libcamera_deps = [
-     libatomic,
-     libcamera_base,
-@@ -121,6 +123,7 @@ libcamera_deps = [
-     libgnutls,
-     liblttng,
-     libudev,
-+    libyamlcpp,
- ]
- 
- # We add '/' to the build_rpath as a 'safe' path to act as a boolean flag.
-diff --git a/src/libcamera/pipeline/starfive/sensors_pipeline.yaml b/src/libcamera/pipeline/starfive/sensors_pipeline.yaml
-new file mode 100644
-index 00000000..3446b0ac
---- /dev/null
-+++ b/src/libcamera/pipeline/starfive/sensors_pipeline.yaml
-@@ -0,0 +1,35 @@
-+# SPDX-License-Identifier: LGPL-2.1-or-later
-+#
-+# Copyright (C) 2020, Google Inc.
-+#
-+%YAML 1.2
-+# description:
-+# sensors:
-+#   - sensorentity: "imx219 0-0010"
-+#       ispfwimage: "stf_isp0_fw_dump.bin"  isp fw image name
-+#       sensortype: 4
-+#
-+#       sensortype value:
-+#               {
-+#               	DVP_YUV = 0,
-+#               	MIPICSI0_YUV = 1,
-+#               	MIPICSI1_YUV = 2,
-+#               	DVP_ISP0 = 3,    // ISP0
-+#               	MIPICSI0_ISP0 = 4,
-+#               	MIPICSI1_ISP0 = 5,
-+#               	DVP_ISP1 = 6,    // ISP1
-+#               	MIPICSI0_ISP1 = 7,
-+#               	MIPICSI1_ISP1 = 8,
-+#               	SENSORTYPE_MAX
-+#               }
-+#
-+---
-+sensors:
-+  - sensorentity: "imx219 0-0010"
-+    ispfwimage: "stf_isp0_fw_dump.bin"
-+    sensortype: 4
-+
-+  - sensorentity: "imx219 2-0010"
-+    ispfwimage: "stf_isp0_fw_dump.bin"
-+    sensortype: 8
-+...
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index b91a85a4..864addfa 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -9,6 +9,8 @@
- #include <queue>
- #include <sys/mman.h>
- #include <math.h>
-+#include <yaml-cpp/yaml.h>
-+#include <yaml-cpp/node/parse.h>
- 
- #include <libcamera/camera.h>
- #include <libcamera/control_ids.h>
-@@ -39,14 +41,7 @@
- 
- #define STF_MAX_CAMERAS   3
- 
--namespace libcamera {
--
--LOG_DEFINE_CATEGORY(STARFIVE)
--
--static constexpr unsigned int BUFFER_COUNT = 4;
--static constexpr unsigned int MAX_STREAMS = 2;
--static const Size OUTPUT_MIN_SIZE = { 8, 8 };
--static const Size OUTPUT_MAX_SIZE = { 8192, 8192 };
-+#define PIPELINE_CONFIG_FILENAME "/etc/starfive/sensors_pipeline.yaml"
- 
- namespace {
- 
-@@ -66,14 +61,16 @@ typedef enum {
- typedef struct {
- 	std::string sensorEntityName_;
- 	std::string sensorFwImageName_;
--	SensorType sensorType_;
-+	int sensorType_;
- } SensorConfig;
- 
--const std::vector<SensorConfig> sensorConfigs = {
-+const std::vector<SensorConfig> defaultSensorConfigs = {
- 	{ "imx219 0-0010", "stf_isp0_fw_dump.bin", MIPICSI0_ISP0 },
- 	{ "imx219 2-0010", "stf_isp0_fw_dump.bin", MIPICSI1_ISP1 },
- };
- 
-+std::vector<SensorConfig> sensorConfigs;
-+
- typedef struct {
- 	std::string source;
- 	std::string link;
-@@ -139,6 +136,40 @@ const std::vector<PipelineConfigLink> pipelineConfigs[SENSORTYPE_MAX] = {
- 	mipicsi1raw1Config,
- };
- 
-+} /* namespace */
-+
-+namespace YAML {
-+	template<>
-+	struct convert<SensorConfig> {
-+		static Node encode(const SensorConfig& sensor) {
-+			Node node;
-+			node.push_back(sensor.sensorEntityName_);
-+			node.push_back(sensor.sensorFwImageName_);
-+			node.push_back(sensor.sensorType_);
-+			return node;
-+		}
-+
-+		static bool decode(const Node& node, SensorConfig& sensor) {
-+			if(node.size() != 3)
-+				return false;
-+
-+			sensor.sensorEntityName_ = node["sensorentity"].as<std::string>();
-+			sensor.sensorFwImageName_ = node["ispfwimage"].as<std::string>();
-+			sensor.sensorType_ = node["sensortype"].as<int>();
-+			return true;
-+		}
-+	};
-+}
-+
-+namespace libcamera {
-+
-+LOG_DEFINE_CATEGORY(STARFIVE)
-+
-+static constexpr unsigned int BUFFER_COUNT = 4;
-+static constexpr unsigned int MAX_STREAMS = 2;
-+static const Size OUTPUT_MIN_SIZE = { 8, 8 };
-+static const Size OUTPUT_MAX_SIZE = { 8192, 8192 };
-+
- const std::map<uint32_t, PixelFormat> mbusCodesToPixelFormat = {
- 	{ MEDIA_BUS_FMT_SBGGR10_1X10, formats::SBGGR12 },
- 	{ MEDIA_BUS_FMT_SGBRG10_1X10, formats::SGBRG12 },
-@@ -146,8 +177,6 @@ const std::map<uint32_t, PixelFormat> mbusCodesToPixelFormat = {
- 	{ MEDIA_BUS_FMT_SRGGB10_1X10, formats::SRGGB12 },
- };
- 
--} /* namespace */
--
- class StarFiveCameraData : public Camera::Private
- {
- public:
-@@ -423,6 +452,7 @@ private:
- 	int enableLinks(std::vector<PipelineConfigLink> config);
- 
- 	MediaDevice *starFiveMediaDev_;
-+	int parserPipelineConfig(const char *filename);
- };
- 
- StarFiveCameraConfiguration::StarFiveCameraConfiguration(StarFiveCameraData *data)
-@@ -1042,6 +1072,56 @@ int PipelineHandlerStarFive::enableLinks(std::vector<PipelineConfigLink> config)
- 	return ret;
- }
- 
-+static void loaddefaultSensorConfig(void)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+	sensorConfigs.clear();
-+	for (SensorConfig it : defaultSensorConfigs)
-+		sensorConfigs.push_back(it);
-+}
-+
-+static void printSensorConfig(void)
-+{
-+	for (SensorConfig it : sensorConfigs)
-+		LOG(STARFIVE, Debug)
-+			<< " sensorEntityName: " << it.sensorEntityName_
-+			<< ", ispLoadFW: " << it.sensorFwImageName_
-+			<< ", sensorType: " << it.sensorType_;
-+}
-+
-+int PipelineHandlerStarFive::parserPipelineConfig(const char *filename)
-+{
-+	LOG(STARFIVE, Debug) << __func__;
-+	try {
-+		YAML::Node config = YAML::LoadFile(PIPELINE_CONFIG_FILENAME);
-+
-+		if (config["sensors"]) {
-+			std::vector<SensorConfig> sensors =
-+				config["sensors"].as<std::vector<SensorConfig>>();
-+			int found = 0;
-+
-+			for (SensorConfig it : sensors) {
-+				found = 0;
-+				for (SensorConfig its : sensorConfigs) {
-+					if (its.sensorEntityName_ == it.sensorEntityName_) {
-+						found = 1;
-+						break;
-+					}
-+				}
-+				if (!found)
-+					sensorConfigs.push_back(it);
-+			}
-+		}
-+	} catch(std::exception const & e) {
-+		LOG(STARFIVE, Debug) << PIPELINE_CONFIG_FILENAME
-+			<< " yaml file error, use default config!!!";
-+		loaddefaultSensorConfig();
-+	}
-+
-+	printSensorConfig();
-+	return 0;
-+}
-+
- bool PipelineHandlerStarFive::match(DeviceEnumerator *enumerator)
- {
- 	int numCameras = 0;
-@@ -1059,6 +1139,8 @@ bool PipelineHandlerStarFive::match(DeviceEnumerator *enumerator)
- 	if (starFiveMediaDev_->disableLinks())
- 		return false;
- 
-+	parserPipelineConfig(PIPELINE_CONFIG_FILENAME);
-+
- 	for (SensorConfig it : sensorConfigs) {
- 		MediaEntity *sensorEntity =
- 			starFiveMediaDev_->getEntityByName(it.sensorEntityName_);
--- 
-2.25.1
-

+ 0 - 271
package/libcamera/0009-csi0-csi1-can-be-configured-to-the-same-ISP.patch

@@ -1,271 +0,0 @@
-From a24624e164f041e86d9c864a4eb83ab8c2befee4 Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Thu, 16 Dec 2021 17:46:03 +0800
-Subject: [PATCH 09/10] csi0/csi1 can be configured to the same ISP
-
----
- src/libcamera/pipeline/starfive/starfive.cpp | 146 +++++++++++--------
- 1 file changed, 89 insertions(+), 57 deletions(-)
-
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index 864addfa..61a2ddc6 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -182,11 +182,11 @@ class StarFiveCameraData : public Camera::Private
- public:
- 	StarFiveCameraData(PipelineHandler *pipe, MediaDevice *media,
- 			std::string entityName,
--			std::string sensorEntityName)
-+			SensorConfig sensorConfig)
- 		: Camera::Private(pipe), media_(media)
- 	{
- 		LOG(STARFIVE, Debug) << __func__;
--		sensorEntityName_ = sensorEntityName;
-+		sensorConfig_ = sensorConfig;
- 		videoEntityName_ = entityName;
- 		if ( videoEntityName_ == "stf_vin0_isp0_video1")
- 			ispEntityName_ = "stf_isp0";
-@@ -221,10 +221,12 @@ public:
- 	bool haveRaw() const { return haveRaw_; }
- 	bool rawActive() const { return rawActive_; }
- 	void setRawActive(bool val) { rawActive_ = val; }
-+	SensorConfig getSensorConfig() {return sensorConfig_; }
- 	std::vector<SizeRange> sensorSizes() const;
- 	std::vector<PixelFormat> sensorFormats() const;
- 	std::vector<PixelFormat> videoFormats() const;
- 	void paramsFilled(unsigned int id){}
-+	int ispLoadFW(const char *filename);
- 
- 	MediaDevice *media_;
- 	V4L2VideoDevice *video_;
-@@ -240,8 +242,8 @@ private:
- 	bool haveRaw_;
- 	bool rawActive_;
- 	std::string videoEntityName_;
--	std::string sensorEntityName_;
- 	std::string ispEntityName_;
-+	SensorConfig sensorConfig_;
- 	std::string getRawVideoEntityName()
- 	{
- 		LOG(STARFIVE, Debug) << __func__;
-@@ -252,7 +254,6 @@ private:
- 		else
- 			return "unknow";
- 	}
--	int ispLoadFW(const char *filename);
- };
- 
- std::vector<PixelFormat> StarFiveCameraData::videoFormats() const
-@@ -334,17 +335,12 @@ int StarFiveCameraData::init(MediaDevice *media)
- 	int ret;
- 
- 	LOG(STARFIVE, Debug) << __func__;
--	if (sensorEntityName_ != "unknow") {
--		sensor_ =
--		  new CameraSensor(media_->getEntityByName(sensorEntityName_));
--		ret = sensor_->init();
--		if (ret)
--			return ret;
--		LOG(STARFIVE, Debug) << "sensor id: " << sensor_->id();
--	} else {
--		LOG(STARFIVE, Debug) << " Can't find sensorEntityName!";
--		return -ENODEV;
--	}
-+	sensor_ =
-+	  new CameraSensor(media_->getEntityByName(sensorConfig_.sensorEntityName_));
-+	ret = sensor_->init();
-+	if (ret)
-+		return ret;
-+	LOG(STARFIVE, Debug) << "sensor id: " << sensor_->id();
- 
- 	if (ispEntityName_ != "unknow") {
- 		ispSubDev_ =
-@@ -352,13 +348,6 @@ int StarFiveCameraData::init(MediaDevice *media)
- 		LOG(STARFIVE, Debug) << "ispEntityName: " << ispEntityName_;
- 		if (ispSubDev_->open())
- 			return -ENODEV;
--
--		for (SensorConfig it : sensorConfigs) {
--			if (it.sensorEntityName_ == sensorEntityName_) {
--				ispLoadFW(it.sensorFwImageName_.c_str());
--				break;
--			}
--		}
- 	}
- 
- 	video_ = new V4L2VideoDevice(media_->getEntityByName(videoEntityName_));
-@@ -550,10 +539,20 @@ PipelineHandlerStarFive::generateConfiguration(Camera *camera,
- 	StarFiveCameraData *data = cameraData(camera);
- 	StarFiveCameraConfiguration *config =
- 		new StarFiveCameraConfiguration(data);
-+	SensorConfig sensorConfig = data->getSensorConfig();
- 
- 	if (roles.empty())
- 		return config;
- 
-+	int ret = enableLinks(pipelineConfigs[sensorConfig.sensorType_]);
-+	if (ret < 0) {
-+		LOG(STARFIVE, Error)
-+			<< sensorConfig.sensorEntityName_
-+			<< " enableLinks failed!";
-+		return config;
-+	}
-+	data->ispLoadFW(sensorConfig.sensorFwImageName_.c_str());
-+
- 	for (const StreamRole role : roles) {
- 		std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
- 		unsigned int bufferCount;
-@@ -1002,9 +1001,43 @@ int PipelineHandlerStarFive::registerCameras()
- 	unsigned int numCameras = 0;
- 
- 	LOG(STARFIVE, Debug) << __func__;
--	for (unsigned int id = 0;
--			id < STF_MAX_CAMERAS 
--			&& numCameras < STF_MAX_CAMERAS; ++id) {
-+	for (SensorConfig it : sensorConfigs) {
-+		std::string cameraName;
-+		int id = 0;
-+
-+		switch (it.sensorType_) {
-+		case DVP_YUV:
-+		case MIPICSI0_YUV:
-+		case MIPICSI1_YUV:
-+			id = 0;
-+			break;
-+		case DVP_ISP0:
-+		case MIPICSI0_ISP0:
-+		case MIPICSI1_ISP0:
-+			id = 1;
-+			break;
-+		case DVP_ISP1:
-+		case MIPICSI0_ISP1:
-+		case MIPICSI1_ISP1:
-+			id = 2;
-+			break;
-+		default:
-+			continue;
-+		}
-+
-+		MediaEntity *sensorEntity =
-+			starFiveMediaDev_->getEntityByName(it.sensorEntityName_);
-+		if (sensorEntity != nullptr) {
-+			int ret = enableLinks(pipelineConfigs[it.sensorType_]);
-+			if (ret < 0) {
-+				LOG(STARFIVE, Error)
-+					<< it.sensorEntityName_
-+					<< " enableLinks failed!";
-+				continue;
-+			}
-+		} else
-+			continue;
-+
- 		std::string videoEntiryName;
- 		videoEntiryName = getVideoEntityNameById(id);
- 		if (videoEntiryName == "unknow")
-@@ -1012,12 +1045,17 @@ int PipelineHandlerStarFive::registerCameras()
- 
- 		std::string sensorEntityName;
- 		sensorEntityName = findSensorEntityName(videoEntiryName);
--		if (sensorEntityName == "unknow")
--			continue;
-+		if (sensorEntityName != it.sensorEntityName_)
-+		        continue;
-+
-+		if (id != 0)
-+			cameraName = it.sensorEntityName_ + " isp" + std::to_string(id - 1);
-+		else
-+			cameraName = it.sensorEntityName_ + " wr";
- 
- 		std::unique_ptr<StarFiveCameraData> data =
- 			std::make_unique<StarFiveCameraData>(this, starFiveMediaDev_,
--					videoEntiryName, sensorEntityName);
-+					videoEntiryName, it);
- 
- 		/* Locate and open the capture video node. */
- 		if (data->init(starFiveMediaDev_))
-@@ -1034,18 +1072,17 @@ int PipelineHandlerStarFive::registerCameras()
- 		data->ipa_->init(IPASettings{ conf, data->sensor_->model() });
- 
- 		/* Create and register the camera. */
--		LOG(STARFIVE, Debug) << "register deviceName: "
--				     << videoEntiryName;
-+		LOG(STARFIVE, Debug) << "register deviceName: " << cameraName;
- 		if (data->haveRaw()) {
- 			std::set<Stream *> streams{ &data->outStream_,
- 						&data->rawStream_ };
- 			std::shared_ptr<Camera> camera =
--				Camera::create(std::move(data), videoEntiryName, streams);
-+				Camera::create(std::move(data), cameraName, streams);
- 			registerCamera(std::move(camera));
- 		} else {
- 			std::set<Stream *> streams{ &data->outStream_ };
- 			std::shared_ptr<Camera> camera =
--				Camera::create(std::move(data), videoEntiryName, streams);
-+				Camera::create(std::move(data), cameraName, streams);
- 			registerCamera(std::move(camera));
- 		}
- 		numCameras++;
-@@ -1064,9 +1101,26 @@ int PipelineHandlerStarFive::enableLinks(std::vector<PipelineConfigLink> config)
- 		if (!link)
- 			return -ENODEV;
- 
--		ret = link->setEnabled(true);
--		if (ret < 0)
--			return ret;
-+		MediaEntity *remote = link->sink()->entity();
-+		for (MediaPad *pad : remote->pads()) {
-+			for (MediaLink *e : pad->links()) {
-+				if (link == e)
-+					continue;
-+
-+				if ((e->flags() & MEDIA_LNK_FL_ENABLED) &&
-+				    !(e->flags() & MEDIA_LNK_FL_IMMUTABLE)) {
-+					ret = e->setEnabled(false);
-+					if (ret < 0)
-+						return ret;
-+				}
-+			}
-+		}
-+
-+		if (!(link->flags() & MEDIA_LNK_FL_ENABLED)) {
-+			ret = link->setEnabled(true);
-+			if (ret < 0)
-+				return ret;
-+		}
- 	}
- 
- 	return ret;
-@@ -1136,30 +1190,8 @@ bool PipelineHandlerStarFive::match(DeviceEnumerator *enumerator)
- 	if (!starFiveMediaDev_)
- 		return false;
- 
--	if (starFiveMediaDev_->disableLinks())
--		return false;
--
- 	parserPipelineConfig(PIPELINE_CONFIG_FILENAME);
- 
--	for (SensorConfig it : sensorConfigs) {
--		MediaEntity *sensorEntity =
--			starFiveMediaDev_->getEntityByName(it.sensorEntityName_);
--		int ret;
--
--		if (sensorEntity != nullptr) {
--			if (it.sensorType_ < DVP_YUV
--				|| it.sensorType_ >= SENSORTYPE_MAX)
--				continue;
--			ret = enableLinks(pipelineConfigs[it.sensorType_]);
--			if (ret < 0) {
--				LOG(STARFIVE, Error)
--					<< it.sensorEntityName_
--					<< " enableLinks failed!";
--				continue;
--			}
--		}
--	}
--
- 	numCameras = registerCameras();
- 	if (numCameras)
- 		LOG(STARFIVE, Debug)
--- 
-2.25.1
-

+ 0 - 254
package/libcamera/0010-libcamera-add-framerate-for-request-pad-src.patch

@@ -1,254 +0,0 @@
-From 4d84bab2e88580bb96a24343051f2ea8132dc4e3 Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Thu, 13 Jan 2022 14:44:18 +0800
-Subject: [PATCH 10/10] libcamera: add framerate for request pad src.
-
----
- include/libcamera/internal/v4l2_videodevice.h |  7 +-
- include/libcamera/stream.h                    |  8 +++
- src/gstreamer/gstlibcamera-utils.cpp          | 16 +++--
- src/libcamera/pipeline/starfive/starfive.cpp  | 37 ++++++++++
- src/libcamera/v4l2_videodevice.cpp            | 68 +++++++++++++++++++
- 5 files changed, 131 insertions(+), 5 deletions(-)
-
-diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h
-index a1c458e4..650da22d 100644
---- a/include/libcamera/internal/v4l2_videodevice.h
-+++ b/include/libcamera/internal/v4l2_videodevice.h
-@@ -35,6 +35,11 @@ class FileDescriptor;
- class MediaDevice;
- class MediaEntity;
- 
-+struct V4L2Framerate {
-+	uint32_t num = 0;
-+	uint32_t denom = 0;
-+};
-+
- struct V4L2Capability final : v4l2_capability {
- 	const char *driver() const
- 	{
-@@ -215,7 +220,7 @@ public:
- 
- 	static std::unique_ptr<V4L2VideoDevice>
- 	fromEntityName(const MediaDevice *media, const std::string &entity);
--
-+	std::vector<V4L2Framerate> getFramerates(uint32_t pixelformat, uint32_t width, uint32_t height);
- protected:
- 	std::string logPrefix() const override;
- 
-diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
-index 0c55e716..2e06d7d8 100644
---- a/include/libcamera/stream.h
-+++ b/include/libcamera/stream.h
-@@ -36,6 +36,11 @@ private:
- 	std::map<PixelFormat, std::vector<SizeRange>> formats_;
- };
- 
-+struct Framerate {
-+	uint32_t num = 0;
-+	uint32_t denom = 0;
-+};
-+
- struct StreamConfiguration {
- 	StreamConfiguration();
- 	StreamConfiguration(const StreamFormats &formats);
-@@ -51,11 +56,14 @@ struct StreamConfiguration {
- 	void setStream(Stream *stream) { stream_ = stream; }
- 	const StreamFormats &formats() const { return formats_; }
- 
-+	void setframeRates(std::vector<Framerate> framerates) { rates = framerates; }
-+	const std::vector<Framerate> getframeRates() const { return rates; }
- 	std::string toString() const;
- 
- private:
- 	Stream *stream_;
- 	StreamFormats formats_;
-+	std::vector<Framerate> rates;
- };
- 
- enum StreamRole {
-diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
-index bce4960a..4cd07508 100644
---- a/src/gstreamer/gstlibcamera-utils.cpp
-+++ b/src/gstreamer/gstlibcamera-utils.cpp
-@@ -140,10 +140,18 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg
- 			  "height", G_TYPE_INT, stream_cfg.size.height,
- 			  nullptr);
- 
--	// Add framerate negotiation support
--	// the range will be [ 0/1, 2147483647/1 ] as there is not any args 
--	// required from driver for the time being.
--	gst_structure_set(s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
-+	std::vector<libcamera::Framerate> rates = stream_cfg.getframeRates();
-+	guint index = 0;
-+	for (libcamera::Framerate it : rates) {
-+		libcamera::Framerate rate = it;
-+		gst_structure_set (s, "framerate", GST_TYPE_FRACTION, rate.denom, rate.num, NULL);
-+                //truncate rates. only remain the first one.
-+		if ( index == 0)
-+		{
-+			break;
-+		}
-+		index++;
-+	}
- 
- 	gst_caps_append_structure(caps, s);
- 
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index 61a2ddc6..997d9835 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -43,6 +43,9 @@
- 
- #define PIPELINE_CONFIG_FILENAME "/etc/starfive/sensors_pipeline.yaml"
- 
-+#define DEFAULT_FRAMERATE_NUM 25;
-+#define DEFAULT_FRAMERATE_DENOM 1;
-+
- namespace {
- 
- typedef enum {
-@@ -225,6 +228,8 @@ public:
- 	std::vector<SizeRange> sensorSizes() const;
- 	std::vector<PixelFormat> sensorFormats() const;
- 	std::vector<PixelFormat> videoFormats() const;
-+	std::vector<Framerate> videoFrameRates(unsigned int pixelformat, unsigned int width, unsigned int height) const;
-+
- 	void paramsFilled(unsigned int id){}
- 	int ispLoadFW(const char *filename);
- 
-@@ -269,6 +274,24 @@ std::vector<PixelFormat> StarFiveCameraData::videoFormats() const
- 	return formats;
- }
- 
-+std::vector<Framerate> StarFiveCameraData::videoFrameRates(unsigned int pixelformat, unsigned int width, unsigned int height) const
-+{
-+	if (!video_)
-+		return {};
-+
-+	std::vector<Framerate> framerates;
-+	for (auto it : video_->getFramerates(pixelformat, width, height)) {
-+		V4L2Framerate v4l2_framerate = (V4L2Framerate)it;
-+		libcamera::Framerate rate;
-+		rate.num = v4l2_framerate.num;
-+		rate.denom = v4l2_framerate.denom;
-+		LOG(STARFIVE, Debug) << "videoFrameRates framerate:  rate.num=" << rate.num << " rate.denom= " << rate.denom;
-+		framerates.push_back(rate);
-+	}
-+
-+	return framerates;
-+}
-+
- std::vector<PixelFormat> StarFiveCameraData::sensorFormats() const
- {
- 	if (!sensor_)
-@@ -480,6 +503,20 @@ CameraConfiguration::Status StarFiveCameraConfiguration::validate()
- 		cfg.size.height = std::max(OUTPUT_MIN_SIZE.height,
- 				std::min(OUTPUT_MAX_SIZE.height, cfg.size.height));
- 
-+		std::vector<Framerate> rates;
-+		rates = data_->videoFrameRates(cfg.pixelFormat,size.width, size.height);
-+		if (rates.size() > 0){
-+			cfg.setframeRates(rates);
-+		} else {
-+			LOG(STARFIVE, Debug)
-+				<< "fail to obtian framerate, use default one ";
-+			Framerate rate;
-+			rate.num = DEFAULT_FRAMERATE_NUM;
-+			rate.denom = DEFAULT_FRAMERATE_DENOM;
-+			rates.emplace_back(rate);
-+			cfg.setframeRates(rates);
-+		}
-+
- 		if (cfg.size != size) {
- 			LOG(STARFIVE, Debug)
- 				<< "Adjusting size to " << cfg.size.toString();
-diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
-index 4f04212d..5ccf70d9 100644
---- a/src/libcamera/v4l2_videodevice.cpp
-+++ b/src/libcamera/v4l2_videodevice.cpp
-@@ -31,6 +31,7 @@
- #include "libcamera/internal/framebuffer.h"
- #include "libcamera/internal/media_device.h"
- #include "libcamera/internal/media_object.h"
-+#include <limits.h>
- 
- /**
-  * \file v4l2_videodevice.h
-@@ -1847,6 +1848,73 @@ V4L2VideoDevice::fromEntityName(const MediaDevice *media,
- 	return std::make_unique<V4L2VideoDevice>(mediaEntity);
- }
- 
-+std::vector<V4L2Framerate> V4L2VideoDevice::getFramerates(uint32_t pixelformat, uint32_t width, uint32_t height)
-+{
-+	struct v4l2_frmivalenum ival;
-+	uint32_t num, denom;
-+
-+	memset (&ival, 0, sizeof (struct v4l2_frmivalenum));
-+	ival.index = 0;
-+	ival.pixel_format = pixelformat;
-+	ival.width = width;
-+	ival.height = height;
-+	std::vector<V4L2Framerate> rates;
-+	LOG(V4L2, Debug) << "getFramerates: width: " << width << " height: " << height << " pixelformat " << pixelformat;
-+
-+	if (ioctl (VIDIOC_ENUM_FRAMEINTERVALS, &ival) < 0){
-+		LOG(V4L2, Error) << "fail to ioctl: VIDIOC_ENUM_FRAMEINTERVALS";
-+		goto enum_frameintervals_failed;
-+	}
-+
-+	if (ival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
-+		struct V4L2Framerate rate;
-+		do {
-+			num = ival.discrete.numerator;
-+			denom = ival.discrete.denominator;
-+
-+			if (num > INT_MAX || denom > INT_MAX) {
-+				/* let us hope we don't get here... */
-+				LOG(V4L2, Error) << "num or denom is beyond INT_MAX";
-+				goto enum_frameintervals_failed;
-+			}
-+
-+			// /* swap to get the framerate */
-+			// gst_value_set_fraction (&rate, denom, num);
-+			rate.denom = denom;
-+			rate.num = num;
-+			LOG(V4L2, Debug) << "gstFramerates adding discrete framerate: " << denom << "/" << num;
-+			rates.emplace_back(rate);
-+			ival.index++;
-+		} while (ioctl (VIDIOC_ENUM_FRAMEINTERVALS, &ival) >= 0);
-+	} else if (ival.type == V4L2_FRMIVAL_TYPE_STEPWISE){
-+		//TODO 
-+		goto enum_frameintervals_unimplemented;
-+	} else if (ival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) {
-+		num = ival.stepwise.min.numerator;
-+		denom = ival.stepwise.min.denominator;
-+		if (num > INT_MAX || denom > INT_MAX) {
-+			LOG(V4L2, Error) << "continuous frame interval: num or denom is beyond INT_MAX";
-+			goto enum_frameintervals_failed;
-+		}
-+
-+		struct V4L2Framerate rate;
-+		rate.denom = denom;
-+		rate.num = num;
-+		LOG(V4L2, Debug) << "gstFramerates continuous frame interval: " << denom << "/" <<num;
-+		rates.emplace_back(rate);
-+	}
-+
-+	return rates;
-+
-+enum_frameintervals_failed:
-+enum_frameintervals_unimplemented:
-+{
-+	LOG(V4L2, Error) << "fail to obtain framerate !!!";
-+	return rates;
-+}
-+
-+}
-+
- /**
-  * \class V4L2M2MDevice
-  * \brief Memory-to-Memory video device
--- 
-2.25.1
-

+ 0 - 195
package/libcamera/0011-libcamera-support-isp-driver.patch

@@ -1,195 +0,0 @@
-From 43ac4b2e62f6998a24b6b42e2ce25917f674b18b Mon Sep 17 00:00:00 2001
-From: liuxl0327 <liuxl0327@starfivetech.com>
-Date: Fri, 8 Apr 2022 09:27:55 +0800
-Subject: [PATCH] libcamera support isp driver
-
----
- src/libcamera/pipeline/starfive/starfive.cpp | 94 ++++++++++++++------
- 1 file changed, 65 insertions(+), 29 deletions(-)
-
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index 0de22f2c..1689ad9d 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -73,55 +73,61 @@ std::vector<SensorConfig> sensorConfigs;
- 
- typedef struct {
- 	std::string source;
--	std::string link;
-+	unsigned int sourceIdx;
-+	std::string sink;
-+	unsigned int sinkIdx;
- } PipelineConfigLink;
- 
- const std::vector<PipelineConfigLink> dvpyuvConfig = {
--	{"stf_dvp0", "stf_vin0_wr"},
-+	{"stf_dvp0", 1, "stf_vin0_wr", 0},
- };
- 
- const std::vector<PipelineConfigLink> mipicsi0yuvConfig = {
--	{"stf_csiphy0", "stf_csi0"},
--	{"stf_csi0", "stf_vin0_wr"}
-+	{"stf_csiphy0", 1, "stf_csi0", 0},
-+	{"stf_csi0", 1, "stf_vin0_wr", 0}
- };
- 
- const std::vector<PipelineConfigLink> mipicsi1yuvConfig = {
--	{"stf_csiphy1", "stf_csi1"},
--	{"stf_csi1", "stf_vin0_wr"}
-+	{"stf_csiphy1", 1, "stf_csi1", 0},
-+	{"stf_csi1", 1, "stf_vin0_wr", 0}
- };
- 
- const std::vector<PipelineConfigLink> dvpraw0Config = {
--	{"stf_dvp0", "stf_isp0"},
--	{"stf_isp0", "stf_vin0_isp0"}
-+	{"stf_dvp0", 1, "stf_isp0", 0},
- };
- 
- const std::vector<PipelineConfigLink> mipicsi0raw0Config = {
--	{"stf_csiphy0", "stf_csi0"},
--	{"stf_csi0", "stf_isp0"},
--	{"stf_isp0", "stf_vin0_isp0"}
-+	{"stf_csiphy0", 1, "stf_csi0", 0},
-+	{"stf_csi0", 1, "stf_isp0", 0},
- };
- 
- const std::vector<PipelineConfigLink> mipicsi1raw0Config = {
--	{"stf_csiphy1", "stf_csi1"},
--	{"stf_csi1", "stf_isp0"},
--	{"stf_isp0", "stf_vin0_isp0"}
-+	{"stf_csiphy1", 1, "stf_csi1", 0},
-+	{"stf_csi1", 1, "stf_isp0", 0},
- };
- 
- const std::vector<PipelineConfigLink> dvpraw1Config = {
--	{"stf_dvp0", "stf_isp1"},
--	{"stf_isp1", "stf_vin0_isp1"}
-+	{"stf_dvp0", 1, "stf_isp1", 0},
- };
- 
- const std::vector<PipelineConfigLink> mipicsi0raw1Config = {
--	{"stf_csiphy0", "stf_csi0"},
--	{"stf_csi0", "stf_isp1"},
--	{"stf_isp1", "stf_vin0_isp1"}
-+	{"stf_csiphy0", 1, "stf_csi0", 0},
-+	{"stf_csi0", 1, "stf_isp1", 0},
- };
- 
- const std::vector<PipelineConfigLink> mipicsi1raw1Config = {
--	{"stf_csiphy1", "stf_csi1"},
--	{"stf_csi1", "stf_isp1"},
--	{"stf_isp1", "stf_vin0_isp1"}
-+	{"stf_csiphy1", 1, "stf_csi1", 0},
-+	{"stf_csi1", 1, "stf_isp1", 0},
-+};
-+
-+const std::vector<PipelineConfigLink> isp0Config = {
-+	{"stf_isp0", 1, "stf_vin0_isp0", 0},
-+	{"stf_isp0", 6, "stf_vin0_isp0_raw", 0}
-+};
-+
-+const std::vector<PipelineConfigLink> isp1Config = {
-+	{"stf_isp1", 1, "stf_vin0_isp1", 0},
-+	{"stf_isp1", 6, "stf_vin0_isp1_raw", 0}
- };
- 
- const std::vector<PipelineConfigLink> pipelineConfigs[SENSORTYPE_MAX] = {
-@@ -248,9 +254,9 @@ private:
- 	{
- 		LOG(STARFIVE, Debug) << __func__;
- 		if ( videoEntityName_ == "stf_vin0_isp0_video1")
--			return "stf_vin0_isp0_raw_video3";
-+			return "stf_vin0_isp0_raw_video11";
- 		else if (videoEntityName_ == "stf_vin0_isp1_video2")
--			return "stf_vin0_isp1_raw_video4";
-+			return "stf_vin0_isp1_raw_video12";
- 		else
- 			return "unknow";
- 	}
-@@ -438,6 +444,7 @@ private:
- 	int registerCameras();
- 	std::string getVideoEntityNameById(unsigned int id);
- 	std::string findSensorEntityName(std::string entityName);
-+	int enableLinks(int sensorType);
- 	int enableLinks(std::vector<PipelineConfigLink> config);
- 
- 	MediaDevice *starFiveMediaDev_;
-@@ -544,7 +551,7 @@ PipelineHandlerStarFive::generateConfiguration(Camera *camera,
- 	if (roles.empty())
- 		return config;
- 
--	int ret = enableLinks(pipelineConfigs[sensorConfig.sensorType_]);
-+	int ret = enableLinks(sensorConfig.sensorType_);
- 	if (ret < 0) {
- 		LOG(STARFIVE, Error)
- 			<< sensorConfig.sensorEntityName_
-@@ -942,9 +949,9 @@ std::string PipelineHandlerStarFive::getVideoEntityNameById(unsigned int id)
- 	case 2:
- 		return "stf_vin0_isp1_video2";
- 	case 3:
--		return "stf_vin0_isp0_raw_video3";
-+		return "stf_vin0_isp0_raw_video11";
- 	case 4:
--		return "stf_vin0_isp1_raw_video4";
-+		return "stf_vin0_isp1_raw_video12";
- 	default:
- 		return "unknow";
- 	}
-@@ -1028,7 +1035,7 @@ int PipelineHandlerStarFive::registerCameras()
- 		MediaEntity *sensorEntity =
- 			starFiveMediaDev_->getEntityByName(it.sensorEntityName_);
- 		if (sensorEntity != nullptr) {
--			int ret = enableLinks(pipelineConfigs[it.sensorType_]);
-+			int ret = enableLinks(it.sensorType_);
- 			if (ret < 0) {
- 				LOG(STARFIVE, Error)
- 					<< it.sensorEntityName_
-@@ -1097,7 +1104,7 @@ int PipelineHandlerStarFive::enableLinks(std::vector<PipelineConfigLink> config)
- 
- 	LOG(STARFIVE, Debug) << __func__;
- 	for (PipelineConfigLink it : config) {
--		MediaLink *link = starFiveMediaDev_->link(it.source, 1, it.link, 0);
-+		MediaLink *link = starFiveMediaDev_->link(it.source, it.sourceIdx, it.sink, it.sinkIdx);
- 		if (!link)
- 			return -ENODEV;
- 
-@@ -1126,6 +1133,35 @@ int PipelineHandlerStarFive::enableLinks(std::vector<PipelineConfigLink> config)
- 	return ret;
- }
- 
-+int PipelineHandlerStarFive::enableLinks(int sensorType)
-+{
-+	int ret = 0;
-+
-+	LOG(STARFIVE, Debug) << __func__;
-+	if (sensorType > SENSORTYPE_MAX || sensorType < DVP_YUV)
-+		return -ENODEV;
-+
-+	ret = enableLinks(pipelineConfigs[sensorType]);
-+	if (ret)
-+		return ret;
-+	switch (sensorType) {
-+		case DVP_ISP0:
-+		case MIPICSI0_ISP0:
-+		case MIPICSI1_ISP0:
-+			ret = enableLinks(isp0Config);
-+			break;
-+		case DVP_ISP1:
-+		case MIPICSI0_ISP1:
-+		case MIPICSI1_ISP1:
-+			ret = enableLinks(isp1Config);
-+			break;
-+		default:
-+			break;
-+	}
-+
-+	return ret;
-+}
-+
- static void loaddefaultSensorConfig(void)
- {
- 	LOG(STARFIVE, Debug) << __func__;
--- 
-2.17.1
-

+ 0 - 63
package/libcamera/0012-Adjust-StarFive-pipeline-video-device-entity-name.patch

@@ -1,63 +0,0 @@
-From 6d4c962f44084b0e01ec49d37818fcdd10e9c01d Mon Sep 17 00:00:00 2001
-From: "Kevin.xie" <kevin.xie@starfivetech.com>
-Date: Wed, 8 Jun 2022 14:38:08 +0800
-Subject: [PATCH] Adjust StarFive pipeline video device entity name
-
-Signed-off-by: Kevin.xie <kevin.xie@starfivetech.com>
----
- src/libcamera/pipeline/starfive/starfive.cpp | 16 ++++++++--------
- 1 file changed, 8 insertions(+), 8 deletions(-)
-
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index 7f02baf..03f0949 100755
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -199,7 +199,7 @@ public:
- 		videoEntityName_ = entityName;
- 		if ( videoEntityName_ == "stf_vin0_isp0_video1")
- 			ispEntityName_ = "stf_isp0";
--		else if (videoEntityName_ == "stf_vin0_isp1_video2")
-+		else if (videoEntityName_ == "stf_vin0_isp1_video8")
- 			ispEntityName_ = "stf_isp1";
- 		else
- 			ispEntityName_ = "unknow";
-@@ -258,9 +258,9 @@ private:
- 	{
- 		LOG(STARFIVE, Debug) << __func__;
- 		if ( videoEntityName_ == "stf_vin0_isp0_video1")
--			return "stf_vin0_isp0_raw_video11";
--		else if (videoEntityName_ == "stf_vin0_isp1_video2")
--			return "stf_vin0_isp1_raw_video12";
-+			return "stf_vin0_isp0_raw_video6";
-+		else if (videoEntityName_ == "stf_vin0_isp1_video8")
-+			return "stf_vin0_isp1_raw_video13";
- 		else
- 			return "unknow";
- 	}
-@@ -983,11 +983,11 @@ std::string PipelineHandlerStarFive::getVideoEntityNameById(unsigned int id)
- 	case 1:
- 		return "stf_vin0_isp0_video1";
- 	case 2:
--		return "stf_vin0_isp1_video2";
-+		return "stf_vin0_isp1_video8";
- 	case 3:
--		return "stf_vin0_isp0_raw_video11";
-+		return "stf_vin0_isp0_raw_video6";
- 	case 4:
--		return "stf_vin0_isp1_raw_video12";
-+		return "stf_vin0_isp1_raw_video13";
- 	default:
- 		return "unknow";
- 	}
-@@ -1255,7 +1255,7 @@ bool PipelineHandlerStarFive::match(DeviceEnumerator *enumerator)
- 	DeviceMatch dm("stf-vin");
- 	dm.add("stf_vin0_wr_video0");
- 	dm.add("stf_vin0_isp0_video1");
--	dm.add("stf_vin0_isp1_video2");
-+	dm.add("stf_vin0_isp1_video8");
- 
- 	LOG(STARFIVE, Debug) << __func__;
- 	starFiveMediaDev_ = acquireMediaDevice(enumerator, dm);
--- 
-2.17.1
-

+ 0 - 158
package/libcamera/0013-Removed-isp1-config-from-pipeline-modified-imx219-co.patch

@@ -1,158 +0,0 @@
-From 3c0db39c0acd04c9ddfd37279efb9bf47bf1f74c Mon Sep 17 00:00:00 2001
-From: "Kevin.xie" <kevin.xie@starfivetech.com>
-Date: Thu, 9 Jun 2022 19:08:14 +0800
-Subject: [PATCH] Removed isp1 config from pipeline & modified imx219 config
-
-Signed-off-by: Kevin.xie <kevin.xie@starfivetech.com>
----
- .../pipeline/starfive/sensors_pipeline.yaml   |  6 +--
- src/libcamera/pipeline/starfive/starfive.cpp  | 47 +------------------
- 2 files changed, 2 insertions(+), 51 deletions(-)
-
-diff --git a/src/libcamera/pipeline/starfive/sensors_pipeline.yaml b/src/libcamera/pipeline/starfive/sensors_pipeline.yaml
-index 3446b0a..dc4fc63 100644
---- a/src/libcamera/pipeline/starfive/sensors_pipeline.yaml
-+++ b/src/libcamera/pipeline/starfive/sensors_pipeline.yaml
-@@ -25,11 +25,7 @@
- #
- ---
- sensors:
--  - sensorentity: "imx219 0-0010"
-+  - sensorentity: "imx219 6-0010"
-     ispfwimage: "stf_isp0_fw_dump.bin"
-     sensortype: 4
--
--  - sensorentity: "imx219 2-0010"
--    ispfwimage: "stf_isp0_fw_dump.bin"
--    sensortype: 8
- ...
-diff --git a/src/libcamera/pipeline/starfive/starfive.cpp b/src/libcamera/pipeline/starfive/starfive.cpp
-index cc4cd1e..7f97069 100644
---- a/src/libcamera/pipeline/starfive/starfive.cpp
-+++ b/src/libcamera/pipeline/starfive/starfive.cpp
-@@ -55,9 +55,6 @@ typedef enum {
- 	DVP_ISP0,    // ISP0
- 	MIPICSI0_ISP0,
- 	MIPICSI1_ISP0,
--	DVP_ISP1,    // ISP1
--	MIPICSI0_ISP1,
--	MIPICSI1_ISP1,
- 	SENSORTYPE_MAX
- } SensorType;
- 
-@@ -68,8 +65,7 @@ typedef struct {
- } SensorConfig;
- 
- const std::vector<SensorConfig> defaultSensorConfigs = {
--	{ "imx219 0-0010", "stf_isp0_fw_dump.bin", MIPICSI0_ISP0 },
--	{ "imx219 2-0010", "stf_isp0_fw_dump.bin", MIPICSI1_ISP1 },
-+	{ "imx219 6-0010", "stf_isp0_fw_dump.bin", MIPICSI0_ISP0 },
- };
- 
- std::vector<SensorConfig> sensorConfigs;
-@@ -109,30 +105,11 @@ const std::vector<PipelineConfigLink> mipicsi1raw0Config = {
- 	{"stf_csi1", 1, "stf_isp0", 0},
- };
- 
--const std::vector<PipelineConfigLink> dvpraw1Config = {
--	{"stf_dvp0", 1, "stf_isp1", 0},
--};
--
--const std::vector<PipelineConfigLink> mipicsi0raw1Config = {
--	{"stf_csiphy0", 1, "stf_csi0", 0},
--	{"stf_csi0", 1, "stf_isp1", 0},
--};
--
--const std::vector<PipelineConfigLink> mipicsi1raw1Config = {
--	{"stf_csiphy1", 1, "stf_csi1", 0},
--	{"stf_csi1", 1, "stf_isp1", 0},
--};
--
- const std::vector<PipelineConfigLink> isp0Config = {
- 	{"stf_isp0", 1, "stf_vin0_isp0", 0},
- 	{"stf_isp0", 6, "stf_vin0_isp0_raw", 0}
- };
- 
--const std::vector<PipelineConfigLink> isp1Config = {
--	{"stf_isp1", 1, "stf_vin0_isp1", 0},
--	{"stf_isp1", 6, "stf_vin0_isp1_raw", 0}
--};
--
- const std::vector<PipelineConfigLink> pipelineConfigs[SENSORTYPE_MAX] = {
- 	dvpyuvConfig,
- 	mipicsi0yuvConfig,
-@@ -140,9 +117,6 @@ const std::vector<PipelineConfigLink> pipelineConfigs[SENSORTYPE_MAX] = {
- 	dvpraw0Config,
- 	mipicsi0raw0Config,
- 	mipicsi1raw0Config,
--	dvpraw1Config,
--	mipicsi0raw1Config,
--	mipicsi1raw1Config,
- };
- 
- } /* namespace */
-@@ -199,8 +173,6 @@ public:
- 		videoEntityName_ = entityName;
- 		if ( videoEntityName_ == "stf_vin0_isp0_video1")
- 			ispEntityName_ = "stf_isp0";
--		else if (videoEntityName_ == "stf_vin0_isp1_video8")
--			ispEntityName_ = "stf_isp1";
- 		else
- 			ispEntityName_ = "unknow";
- 
-@@ -260,8 +232,6 @@ private:
- 		LOG(STARFIVE, Debug) << __func__;
- 		if ( videoEntityName_ == "stf_vin0_isp0_video1")
- 			return "stf_vin0_isp0_raw_video6";
--		else if (videoEntityName_ == "stf_vin0_isp1_video8")
--			return "stf_vin0_isp1_raw_video13";
- 		else
- 			return "unknow";
- 	}
-@@ -984,11 +954,7 @@ std::string PipelineHandlerStarFive::getVideoEntityNameById(unsigned int id)
- 	case 1:
- 		return "stf_vin0_isp0_video1";
- 	case 2:
--		return "stf_vin0_isp1_video8";
--	case 3:
- 		return "stf_vin0_isp0_raw_video6";
--	case 4:
--		return "stf_vin0_isp1_raw_video13";
- 	default:
- 		return "unknow";
- 	}
-@@ -1060,11 +1026,6 @@ int PipelineHandlerStarFive::registerCameras()
- 		case MIPICSI1_ISP0:
- 			id = 1;
- 			break;
--		case DVP_ISP1:
--		case MIPICSI0_ISP1:
--		case MIPICSI1_ISP1:
--			id = 2;
--			break;
- 		default:
- 			continue;
- 		}
-@@ -1187,11 +1148,6 @@ int PipelineHandlerStarFive::enableLinks(int sensorType)
- 		case MIPICSI1_ISP0:
- 			ret = enableLinks(isp0Config);
- 			break;
--		case DVP_ISP1:
--		case MIPICSI0_ISP1:
--		case MIPICSI1_ISP1:
--			ret = enableLinks(isp1Config);
--			break;
- 		default:
- 			break;
- 	}
-@@ -1256,7 +1212,6 @@ bool PipelineHandlerStarFive::match(DeviceEnumerator *enumerator)
- 	DeviceMatch dm("stf-vin");
- 	dm.add("stf_vin0_wr_video0");
- 	dm.add("stf_vin0_isp0_video1");
--	dm.add("stf_vin0_isp1_video8");
- 
- 	LOG(STARFIVE, Debug) << __func__;
- 	starFiveMediaDev_ = acquireMediaDevice(enumerator, dm);
--- 
-2.17.1
-

+ 0 - 41
package/libcamera/0014-libcamera-Open-drm-device-by-module-name-starfive.patch

@@ -1,41 +0,0 @@
-From b04b58f1eea0b2fe417205846beef663c89275b7 Mon Sep 17 00:00:00 2001
-From: "Kevin.xie" <kevin.xie@starfivetech.com>
-Date: Wed, 3 Aug 2022 16:26:26 +0800
-Subject: [PATCH] libcamera: Open drm device by module name 'starfive'
-
-Signed-off-by: Kevin.xie <kevin.xie@starfivetech.com>
----
- src/cam/drm.cpp | 10 ++++++----
- 1 file changed, 6 insertions(+), 4 deletions(-)
-
-diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp
-index f253009..72c64c9 100644
---- a/src/cam/drm.cpp
-+++ b/src/cam/drm.cpp
-@@ -393,8 +393,8 @@ Device::~Device()
- 
- int Device::init()
- {
--	constexpr size_t NODE_NAME_MAX = sizeof("/dev/dri/card255");
--	char name[NODE_NAME_MAX];
-+	//constexpr size_t NODE_NAME_MAX = sizeof("/dev/dri/card255");
-+	//char name[NODE_NAME_MAX];
- 	int ret;
- 
- 	/*
-@@ -404,8 +404,10 @@ int Device::init()
- 	 * from drmOpen() is of no practical use as any modern system will
- 	 * handle that through udev or an equivalent component.
- 	 */
--	snprintf(name, sizeof(name), "/dev/dri/card%u", 0);
--	fd_ = open(name, O_RDWR | O_CLOEXEC);
-+	//snprintf(name, sizeof(name), "/dev/dri/card%u", 0);
-+	//fd_ = open(name, O_RDWR | O_CLOEXEC);
-+	const char *name = "starfive";
-+	fd_ = drmOpen(name, NULL);
- 	if (fd_ < 0) {
- 		ret = -errno;
- 		std::cerr
--- 
-2.17.1
-

+ 22 - 5
package/libcamera/Config.in

@@ -12,12 +12,8 @@ menuconfig BR2_PACKAGE_LIBCAMERA
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # C++17
 	depends on !BR2_STATIC_LIBS # gnutls
 	depends on BR2_USE_WCHAR # gnutls
-	depends on BR2_PACKAGE_LIBEVENT # libevent
-	depends on BR2_PACKAGE_PYTHON3
-	select BR2_PACKAGE_PYTHON_JINJA2
-	select BR2_PACKAGE_PYTHON_PLY
-	select BR2_PACKAGE_PYTHON_PYYAML
 	select BR2_PACKAGE_GNUTLS
+	select BR2_PACKAGE_LIBYAML
 	select BR2_PACKAGE_LIBCAMERA_PIPELINE_UVCVIDEO if !BR2_PACKAGE_LIBCAMERA_HAS_PIPELINE
 	help
 	  libcamera provides a software stack to support
@@ -38,12 +34,14 @@ config BR2_PACKAGE_LIBCAMERA_HAS_PIPELINE
 
 config BR2_PACKAGE_LIBCAMERA_PIPELINE_IPU3
 	bool "ipu3 pipeline"
+	depends on BR2_i386 || BR2_x86_64
 	select BR2_PACKAGE_LIBCAMERA_HAS_PIPELINE
 	help
 	  Pipeline for Intel IPU3.
 
 config BR2_PACKAGE_LIBCAMERA_PIPELINE_RASPBERRYPI
 	bool "raspberrypi pipeline"
+	depends on BR2_arm || BR2_aarch64
 	depends on BR2_USE_WCHAR # boost (already enforced for gnutls)
 	select BR2_PACKAGE_BOOST
 	select BR2_PACKAGE_LIBCAMERA_HAS_PIPELINE
@@ -52,6 +50,7 @@ config BR2_PACKAGE_LIBCAMERA_PIPELINE_RASPBERRYPI
 
 config BR2_PACKAGE_LIBCAMERA_PIPELINE_RKISP1
 	bool "rkisp1 pipeline"
+	depends on BR2_arm || BR2_aarch64
 	select BR2_PACKAGE_LIBCAMERA_HAS_PIPELINE
 	help
 	  Pipeline for Rockchip ISP1.
@@ -80,6 +79,24 @@ config BR2_PACKAGE_LIBCAMERA_PIPELINE_STARFIVE
 	help
 	  Pipeline for the starfive device.
 
+config BR2_PACKAGE_LIBCAMERA_COMPLIANCE
+	bool "lc-compliance test application"
+	depends on BR2_USE_WCHAR # gtest
+	depends on BR2_TOOLCHAIN_HAS_THREADS # gtest
+	depends on BR2_INSTALL_LIBSTDCPP # gtest
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # gtest
+	depends on BR2_USE_MMU # gtest
+	select BR2_PACKAGE_GTEST
+	select BR2_PACKAGE_LIBEVENT
+	help
+	  lc-compliance test application
+
+comment "lc-compliance test application needs a toolchain w/ C++, wchar, threads, gcc >= 4.9"
+	depends on BR2_USE_MMU
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || \
+		!BR2_INSTALL_LIBSTDCPP || \
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
+
 endif # BR2_PACKAGE_LIBCAMERA
 
 comment "libcamera needs a toolchain w/ C++, threads, wchar, dynamic library, gcc >= 7"

+ 1 - 14
package/libcamera/libcamera.hash

@@ -1,15 +1,2 @@
-sha256  a7800b54584dee321874610ef70b1b7690c79d8340c5b134ea35176657681e29  libcamera-e59713c68678f3eb6b6ebe97cabdc88c7042567f.tar.gz
-sha256  5bca8bc504318da05fd238ca48a2519e71721d3417ff6f014b42146d270281a8  libcamera-06e53199c2563105030bda4c72752b853da7edc8.tar.gz
-sha256  9369e7cbc138cd31f782325a4361f4163909d09c7475a1f99e938504c191d5f2  libcamera-d6f4abeead1e86d89dc376e8a303849bdb98d5fd.tar.gz
-sha256  111c99661b1c04bd1f6d0630caf910f36f213ab74a0c1966f0592547d3a86b41 libcamera-d6f4abeead1e86d89dc376e8a303849bdb98d5fd-br1.tar.gz
+sha256  f66c16878e335012f0ce5ba1cd47296aa69392bf449b90a1098a16723d1d0ac7  libcamera-a10863152a7ca4b98304e345db3c9f9e0034d8f9-br1.tar.gz
 
-# license files
-sha256  fd38b2c053c0cce46d9c5ef3545a6e34d157a240ba99c9b8dca5d37a8147da6c  LICENSES/BSD-2-Clause.txt
-sha256  e11af671c491efac2f94c1d752bea92f4308ca2450c7d11e582e4b48c40e4de1  LICENSES/BSD-3-Clause.txt
-sha256  6a573fb2f9082662978cf21fb153096df0a1981deaea7dbc10a11046fe005d9f  LICENSES/CC0-1.0.txt
-sha256  ec3732087acf8c52429a020d6bba362ff578705bdb53365a21744485ec15b0e6  LICENSES/CC-BY-SA-4.0.txt
-sha256  8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643  LICENSES/GPL-2.0-only.txt
-sha256  606aa26338f69ce178f1cbc648b7574aec4b5bbaeb20f4df36ff49010cb8fbbd  LICENSES/GPL-2.0-or-later.txt
-sha256  1ccf09bf2f598308df4bed9cd8e9657dc5cd0973d2800318f2e241486e2edf3f  LICENSES/LGPL-2.1-or-later.txt
-sha256  3f9e477523febab58de8b716ccfbcf02e6ef1c8e7728953905e8558637abe2a9  LICENSES/Linux-syscall-note.txt
-sha256  8f25018489d6fe0dec34a352314c38dc146247b7de65735790f4398a92afa84b  LICENSES/MIT.txt

+ 78 - 10
package/libcamera/libcamera.mk

@@ -4,17 +4,18 @@
 #
 ################################################################################
 
-LIBCAMERA_SITE = https://git.linuxtv.org/libcamera.git
-# LIBCAMERA_VERSION = e59713c68678f3eb6b6ebe97cabdc88c7042567f
-# LIBCAMERA_VERSION = 06e53199c2563105030bda4c72752b853da7edc8
-LIBCAMERA_VERSION = d6f4abeead1e86d89dc376e8a303849bdb98d5fd
+LIBCAMERA_VERSION = a10863152a7ca4b98304e345db3c9f9e0034d8f9
+LIBCAMERA_SITE = https://github.com/starfive-tech/libcamera
 LIBCAMERA_SITE_METHOD = git
+
 LIBCAMERA_DEPENDENCIES = \
 	host-openssl \
 	host-pkgconf \
 	host-python3-pyyaml \
 	host-python-jinja2 \
 	host-python-ply \
+	host-patchelf \
+	libyaml \
 	gnutls
 LIBCAMERA_CONF_OPTS = \
 	-Dandroid=disabled \
@@ -64,6 +65,13 @@ LIBCAMERA_PIPELINES-$(BR2_PACKAGE_LIBCAMERA_PIPELINE_STARFIVE) += starfive
 
 LIBCAMERA_CONF_OPTS += -Dpipelines=$(subst $(space),$(comma),$(LIBCAMERA_PIPELINES-y))
 
+ifeq ($(BR2_PACKAGE_LIBCAMERA_COMPLIANCE),y)
+LIBCAMERA_DEPENDENCIES += gtest libevent
+LIBCAMERA_CONF_OPTS += -Dlc-compliance=enabled
+else
+LIBCAMERA_CONF_OPTS += -Dlc-compliance=disabled
+endif
+
 # gstreamer-video-1.0, gstreamer-allocators-1.0
 ifeq ($(BR2_PACKAGE_GSTREAMER1)$(BR2_PACKAGE_GST1_PLUGINS_BASE),yy)
 LIBCAMERA_CONF_OPTS += -Dgstreamer=enabled
@@ -80,6 +88,13 @@ else
 LIBCAMERA_CONF_OPTS += -Dqcam=disabled
 endif
 
+ifeq ($(BR2_PACKAGE_LIBEVENT),y)
+LIBCAMERA_CONF_OPTS += -Dcam=enabled
+LIBCAMERA_DEPENDENCIES += libevent
+else
+LIBCAMERA_CONF_OPTS += -Dcam=disabled
+endif
+
 ifeq ($(BR2_PACKAGE_TIFF),y)
 LIBCAMERA_DEPENDENCIES += tiff
 endif
@@ -88,18 +103,71 @@ ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
 LIBCAMERA_DEPENDENCIES += udev
 endif
 
-ifeq ($(BR2_PACKAGE_LIBEVENT),y)
-LIBCAMERA_DEPENDENCIES += libevent
+ifeq ($(BR2_PACKAGE_LTTNG_LIBUST),y)
+LIBCAMERA_CONF_OPTS += -Dtracing=enabled
+LIBCAMERA_DEPENDENCIES += lttng-libust
+else
+LIBCAMERA_CONF_OPTS += -Dtracing=disabled
+endif
+
+ifeq ($(BR2_PACKAGE_LIBEXECINFO),y)
+LIBCAMERA_DEPENDENCIES += libexecinfo
+LIBCAMERA_LDFLAGS = $(TARGET_LDFLAGS) -lexecinfo
 endif
 
 ifeq ($(BR2_PACKAGE_LIBCAMERA_PIPELINE_STARFIVE),y)
 LIBCAMERA_DEPENDENCIES += yaml-cpp
 endif
 
-define LIBCAMERA_HOOK_EXTRA
-	mkdir -p $(TARGET_DIR)/etc/starfive
-	$(INSTALL) -D -m 0644 $(@D)/src/libcamera/pipeline/starfive/sensors_pipeline.yaml $(TARGET_DIR)/etc/starfive/sensors_pipeline.yaml
+# Open-Source IPA shlibs need to be signed in order to be runnable within the
+# same process, otherwise they are deemed Closed-Source and run in another
+# process and communicate over IPC.
+# Buildroot sanitizes RPATH in a post build process. meson gets rid of rpath
+# while installing so we don't need to do it manually here.
+# Buildroot may strip symbols, so we need to do the same before signing
+# otherwise the signature won't match the shlib on the rootfs. Since meson
+# install target is signing the shlibs, we need to strip them before.
+LIBCAMERA_STRIP_FIND_CMD = \
+	find $(@D)/build/src/ipa \
+	$(if $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)), \
+		-not \( $(call findfileclauses,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) ) \
+	-type f -name 'ipa_*.so' -print0
+
+define LIBCAMERA_BUILD_STRIP_IPA_SO
+	$(LIBCAMERA_STRIP_FIND_CMD) | xargs --no-run-if-empty -0 $(STRIPCMD)
+endef
+
+# LIBCAMERA_POST_BUILD_HOOKS += LIBCAMERA_BUILD_STRIP_IPA_SO
+
+## replace with the starfive full feature ipa library which is closed source when post build
+define LIBCAMERA_BUILD_REPLACE_STARFIVE_IPA
+	@echo "LIBCAMERA_POST_BUILD_HOOKS !!!!"
+	$(if $(wildcard $(@D)/starfive_post_script/replace_and_sign_ipa_starfive_lib.sh),
+		$(@D)/starfive_post_script/replace_and_sign_ipa_starfive_lib.sh)
+endef
+LIBCAMERA_POST_BUILD_HOOKS += LIBCAMERA_BUILD_REPLACE_STARFIVE_IPA
+
+
+## replace with the starfive full feature ipa library which is closed source when post install to stage
+define LIBCAMERA_INSTALL_STAGING_REPLACE_STARFIVE_IPA
+	@echo "LIBCAMERA_POST_INSTALL_STAGING_HOOKS !!!!"
+	$(if $(wildcard $(@D)/starfive_post_script/replace_and_sign_ipa_starfive_lib.sh),
+		$(@D)/starfive_post_script/replace_and_sign_ipa_starfive_lib.sh $(STAGING_DIR)/usr/lib/libcamera)
+endef
+LIBCAMERA_POST_INSTALL_STAGING_HOOKS += LIBCAMERA_INSTALL_STAGING_REPLACE_STARFIVE_IPA
+
+## replace with the starfive full feature ipa library which is closed source when post install to target
+## consider the support/scripts/fix-rpath will always change the rpath in library when make rootfs, so try to run it before sign
+define LIBCAMERA_TARGET_INSTALL_REPLACE_STARFIVE_IPA
+	@echo "LIBCAMERA_POST_INSTALL_TARGET_HOOKS !!!!"
+	$(if $(wildcard $(@D)/starfive_post_script/replace_and_sign_ipa_starfive_lib.sh),
+		$(@D)/starfive_post_script/replace_and_sign_ipa_starfive_lib.sh $(TARGET_DIR)/usr/lib/libcamera; \
+		$(@D)/starfive_post_script/replace_and_sign_ipa_starfive_lib.sh)
+	PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) $(TOPDIR)/support/scripts/fix-rpath target
+	$(@D)/src/ipa/ipa-sign-install.sh $(@D)/build/src/ipa-priv-key.pem $(TARGET_DIR)/usr/lib/libcamera/ipa_starfive.so
+	@echo "$(@D)/src/ipa/ipa-sign-install.sh $(@D)/build/src/ipa-priv-key.pem $(TARGET_DIR)/usr/lib/libcamera/ipa_starfive.so"
+
 endef
-LIBCAMERA_POST_INSTALL_TARGET_HOOKS = LIBCAMERA_HOOK_EXTRA
+LIBCAMERA_POST_INSTALL_TARGET_HOOKS += LIBCAMERA_TARGET_INSTALL_REPLACE_STARFIVE_IPA
 
 $(eval $(meson-package))

+ 284 - 0
package/starfive/libcamera-apps/0001-Make-libcamera-hello-run-normally.patch

@@ -0,0 +1,284 @@
+From 2982813d58c13077c06d1c3c44cd60b0b93d1f4e Mon Sep 17 00:00:00 2001
+From: "zejian.su" <zejian.su@starfivetech.com>
+Date: Thu, 12 Oct 2023 11:54:09 +0800
+Subject: [PATCH 1/4] Make libcamera-hello run normally
+
+---
+ core/libcamera_app.cpp  | 53 ++++++++++++++------------
+ preview/drm_preview.cpp | 84 +++++++++++++++++++++++++++++++++++------
+ 2 files changed, 100 insertions(+), 37 deletions(-)
+
+diff --git a/core/libcamera_app.cpp b/core/libcamera_app.cpp
+index d3a6b63..cc76e9b 100644
+--- a/core/libcamera_app.cpp
++++ b/core/libcamera_app.cpp
+@@ -247,23 +247,24 @@ void LibcameraApp::ConfigureViewfinder()
+ 	if (!configuration_)
+ 		throw std::runtime_error("failed to generate viewfinder configuration");
+ 
+-	Size size(1280, 960);
+-	auto area = camera_->properties().get(properties::PixelArrayActiveAreas);
++	//Size size(1280, 960);
++	Size size = configuration_->at(0).size;
++	//auto area = camera_->properties().get(properties::PixelArrayActiveAreas);
+ 	if (options_->viewfinder_width && options_->viewfinder_height)
+ 		size = Size(options_->viewfinder_width, options_->viewfinder_height);
+-	else if (area)
+-	{
+-		// The idea here is that most sensors will have a 2x2 binned mode that
+-		// we can pick up. If it doesn't, well, you can always specify the size
+-		// you want exactly with the viewfinder_width/height options_->
+-		size = (*area)[0].size() / 2;
+-		// If width and height were given, we might be switching to capture
+-		// afterwards - so try to match the field of view.
+-		if (options_->width && options_->height)
+-			size = size.boundedToAspectRatio(Size(options_->width, options_->height));
+-		size.alignDownTo(2, 2); // YUV420 will want to be even
+-		LOG(2, "Viewfinder size chosen is " << size.toString());
+-	}
++	//else if (area)
++	//{
++	//	// The idea here is that most sensors will have a 2x2 binned mode that
++	//	// we can pick up. If it doesn't, well, you can always specify the size
++	//	// you want exactly with the viewfinder_width/height options_->
++	//	size = (*area)[0].size() / 2;
++	//	// If width and height were given, we might be switching to capture
++	//	// afterwards - so try to match the field of view.
++	//	if (options_->width && options_->height)
++	//		size = size.boundedToAspectRatio(Size(options_->width, options_->height));
++	//	size.alignDownTo(2, 2); // YUV420 will want to be even
++	//	LOG(2, "Viewfinder size chosen is " << size.toString());
++	//}
+ 
+ 	// Finally trim the image size to the largest that the preview can handle.
+ 	Size max_size;
+@@ -275,7 +276,7 @@ void LibcameraApp::ConfigureViewfinder()
+ 	}
+ 
+ 	// Now we get to override any of the default settings from the options_->
+-	configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
++	//configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
+ 	configuration_->at(0).size = size;
+ 	if (options_->viewfinder_buffer_count > 0)
+ 		configuration_->at(0).bufferCount = options_->viewfinder_buffer_count;
+@@ -286,7 +287,7 @@ void LibcameraApp::ConfigureViewfinder()
+ 		lores_size.alignDownTo(2, 2);
+ 		if (lores_size.width > size.width || lores_size.height > size.height)
+ 			throw std::runtime_error("Low res image larger than viewfinder");
+-		configuration_->at(lores_stream_num).pixelFormat = libcamera::formats::YUV420;
++		//configuration_->at(lores_stream_num).pixelFormat = libcamera::formats::YUV420;
+ 		configuration_->at(lores_stream_num).size = lores_size;
+ 		configuration_->at(lores_stream_num).bufferCount = configuration_->at(0).bufferCount;
+ 	}
+@@ -297,7 +298,7 @@ void LibcameraApp::ConfigureViewfinder()
+ 	if (have_raw_stream)
+ 	{
+ 		configuration_->at(raw_stream_num).size = options_->viewfinder_mode.Size();
+-		configuration_->at(raw_stream_num).pixelFormat = mode_to_pixel_format(options_->viewfinder_mode);
++		//configuration_->at(raw_stream_num).pixelFormat = mode_to_pixel_format(options_->viewfinder_mode);
+ 		configuration_->at(raw_stream_num).bufferCount = configuration_->at(0).bufferCount;
+ 	}
+ 
+@@ -335,8 +336,9 @@ void LibcameraApp::ConfigureStill(unsigned int flags)
+ 		configuration_->at(0).pixelFormat = libcamera::formats::BGR888;
+ 	else if (flags & FLAG_STILL_RGB)
+ 		configuration_->at(0).pixelFormat = libcamera::formats::RGB888;
+-	else
+-		configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
++	else {
++		//configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
++	}
+ 	if ((flags & FLAG_STILL_BUFFER_MASK) == FLAG_STILL_DOUBLE_BUFFER)
+ 		configuration_->at(0).bufferCount = 2;
+ 	else if ((flags & FLAG_STILL_BUFFER_MASK) == FLAG_STILL_TRIPLE_BUFFER)
+@@ -358,8 +360,8 @@ void LibcameraApp::ConfigureStill(unsigned int flags)
+ 		configuration_->at(1).pixelFormat = mode_to_pixel_format(options_->mode);
+ 	}
+ 	configuration_->at(1).bufferCount = configuration_->at(0).bufferCount;
+-
+ 	configureDenoise(options_->denoise == "auto" ? "cdn_hq" : options_->denoise);
++
+ 	setupCapture();
+ 
+ 	streams_["still"] = configuration_->at(0).stream();
+@@ -392,7 +394,7 @@ void LibcameraApp::ConfigureVideo(unsigned int flags)
+ 
+ 	// Now we get to override any of the default settings from the options_->
+ 	StreamConfiguration &cfg = configuration_->at(0);
+-	cfg.pixelFormat = libcamera::formats::YUV420;
++	//cfg.pixelFormat = libcamera::formats::YUV420;
+ 	cfg.bufferCount = 6; // 6 buffers is better than 4
+ 	if (options_->buffer_count > 0)
+ 		cfg.bufferCount = options_->buffer_count;
+@@ -431,7 +433,7 @@ void LibcameraApp::ConfigureVideo(unsigned int flags)
+ 		if (lores_size.width > configuration_->at(0).size.width ||
+ 			lores_size.height > configuration_->at(0).size.height)
+ 			throw std::runtime_error("Low res image larger than video");
+-		configuration_->at(lores_index).pixelFormat = libcamera::formats::YUV420;
++		//configuration_->at(lores_index).pixelFormat = libcamera::formats::YUV420;
+ 		configuration_->at(lores_index).size = lores_size;
+ 		configuration_->at(lores_index).bufferCount = configuration_->at(0).bufferCount;
+ 	}
+@@ -959,8 +961,9 @@ void LibcameraApp::previewThread()
+ 				preview_cond_var_.wait(lock);
+ 		}
+ 
+-		if (item.stream->configuration().pixelFormat != libcamera::formats::YUV420)
+-			throw std::runtime_error("Preview windows only support YUV420");
++		if (item.stream->configuration().pixelFormat != libcamera::formats::YUV420 &&
++			item.stream->configuration().pixelFormat != libcamera::formats::NV12)
++			throw std::runtime_error("Preview windows only support YUV420 and NV12");
+ 
+ 		StreamInfo info = GetStreamInfo(item.stream);
+ 		FrameBuffer *buffer = item.completed_request->buffers[item.stream];
+diff --git a/preview/drm_preview.cpp b/preview/drm_preview.cpp
+index 4d6cf0d..38fc6a2 100644
+--- a/preview/drm_preview.cpp
++++ b/preview/drm_preview.cpp
+@@ -10,6 +10,8 @@
+ #include <drm_mode.h>
+ #include <xf86drm.h>
+ #include <xf86drmMode.h>
++#include <fcntl.h>
++#include <libcamera/formats.h>
+ 
+ #include "core/options.hpp"
+ 
+@@ -48,6 +50,7 @@ private:
+ 	void findPlane();
+ 	int drmfd_;
+ 	int conId_;
++	drmModeConnector *con_;
+ 	uint32_t crtcId_;
+ 	int crtcIdx_;
+ 	uint32_t planeId_;
+@@ -93,10 +96,21 @@ void DrmPreview::findCrtc()
+ 			if (con->encoder_id)
+ 			{
+ 				enc = drmModeGetEncoder(drmfd_, con->encoder_id);
+-				if (enc->crtc_id)
+-				{
+-					crtc = drmModeGetCrtc(drmfd_, enc->crtc_id);
+-				}
++				//if (enc->crtc_id)
++				//{
++				//	crtc = drmModeGetCrtc(drmfd_, enc->crtc_id);
++				//}
++			} else
++			{
++				enc = drmModeGetEncoder(drmfd_, con->encoders[0]);
++			}
++
++			if (enc->crtc_id)
++			{
++				crtc = drmModeGetCrtc(drmfd_, enc->crtc_id);
++			} else
++			{
++				crtc = drmModeGetCrtc(drmfd_, res->crtcs[0]);
+ 			}
+ 
+ 			if (!conId_ && crtc)
+@@ -158,6 +172,8 @@ void DrmPreview::findCrtc()
+ 		throw std::runtime_error("connector supports no mode");
+ 	}
+ 
++	con_ = c;
++
+ 	if (options_->fullscreen || width_ == 0 || height_ == 0)
+ 	{
+ 		drmModeCrtc *crtc = drmModeGetCrtc(drmfd_, crtcId_);
+@@ -225,10 +241,13 @@ void DrmPreview::findPlane()
+ 
+ DrmPreview::DrmPreview(Options const *options) : Preview(options), last_fd_(-1), first_time_(true)
+ {
+-	drmfd_ = drmOpen("vc4", NULL);
++	//drmfd_ = drmOpen("vc4", NULL);
++	drmfd_ = drmOpen("starfive", NULL);
+ 	if (drmfd_ < 0)
+ 		throw std::runtime_error("drmOpen failed: " + std::string(ERRSTR));
+ 
++	drmSetClientCap(drmfd_, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
++
+ 	x_ = options_->preview_x;
+ 	y_ = options_->preview_y;
+ 	width_ = options_->preview_width;
+@@ -243,7 +262,8 @@ DrmPreview::DrmPreview(Options const *options) : Preview(options), last_fd_(-1),
+ 
+ 		conId_ = 0;
+ 		findCrtc();
+-		out_fourcc_ = DRM_FORMAT_YUV420;
++		//out_fourcc_ = DRM_FORMAT_YUV420;
++		out_fourcc_ = DRM_FORMAT_NV12;
+ 		findPlane();
+ 	}
+ 	catch (std::exception const &e)
+@@ -347,6 +367,7 @@ static void setup_colour_space(int fd, int plane_id, std::optional<libcamera::Co
+ 
+ void DrmPreview::makeBuffer(int fd, size_t size, StreamInfo const &info, Buffer &buffer)
+ {
++	unsigned int width = info.width, height = info.height, stride = info.stride;
+ 	if (first_time_)
+ 	{
+ 		first_time_ = false;
+@@ -361,13 +382,52 @@ void DrmPreview::makeBuffer(int fd, size_t size, StreamInfo const &info, Buffer
+ 	if (drmPrimeFDToHandle(drmfd_, fd, &buffer.bo_handle))
+ 		throw std::runtime_error("drmPrimeFDToHandle failed for fd " + std::to_string(fd));
+ 
+-	uint32_t offsets[4] =
+-		{ 0, info.stride * info.height, info.stride * info.height + (info.stride / 2) * (info.height / 2) };
+-	uint32_t pitches[4] = { info.stride, info.stride / 2, info.stride / 2 };
+-	uint32_t bo_handles[4] = { buffer.bo_handle, buffer.bo_handle, buffer.bo_handle };
+-
+-	if (drmModeAddFB2(drmfd_, info.width, info.height, out_fourcc_, bo_handles, pitches, offsets, &buffer.fb_handle, 0))
++	if (out_fourcc_ == DRM_FORMAT_YUV420) {
++		uint32_t offsets[4] = { 0, stride * height, stride * height + (stride / 2) * (height / 2) };
++		uint32_t pitches[4] = { stride, stride / 2, stride / 2 };
++		uint32_t bo_handles[4] = { buffer.bo_handle, buffer.bo_handle, buffer.bo_handle };
++
++		if (drmModeAddFB2(drmfd_, width, height, out_fourcc_, bo_handles, pitches, offsets, &buffer.fb_handle, 0))
++			throw std::runtime_error("YUV420 drmModeAddFB2 failed: " + std::string(ERRSTR));
++	} else if (out_fourcc_ == DRM_FORMAT_NV12 || out_fourcc_ == DRM_FORMAT_NV21) {
++		uint32_t offsets[4] = { 0, stride * height};
++		uint32_t pitches[4] = { stride, stride};
++		uint32_t bo_handles[4] = { buffer.bo_handle, buffer.bo_handle};
++
++		if (drmModeAddFB2(drmfd_, width, height, out_fourcc_, bo_handles, pitches, offsets, &buffer.fb_handle, 0))
++			throw std::runtime_error("NV12/21 drmModeAddFB2 failed: " + std::string(ERRSTR));
++	} else
+ 		throw std::runtime_error("drmModeAddFB2 failed: " + std::string(ERRSTR));
++
++	/* find preferred mode */
++	drmModeModeInfo *modeptr = NULL, *preferred = NULL;
++	for (int m = 0; m < con_->count_modes; m++) {
++		modeptr = &con_->modes[m];
++		if (modeptr->hdisplay == width && modeptr->vdisplay == height) {
++			preferred = modeptr;
++			std::cout << "find the matched mode, modes index= "
++				<< m << ", " << width << "x" << height << std::endl;
++			break;
++		}
++		if (modeptr->type & DRM_MODE_TYPE_PREFERRED) {
++			preferred = modeptr;
++			std::cout << "find perferred mode, modes index= " << m << std::endl;
++		}
++	}
++
++	if (!preferred)
++		preferred = &con_->modes[0];
++
++	// set default
++	if (drmModeSetCrtc(drmfd_, crtcId_, buffer.fb_handle, 0, 0,
++	        (uint32_t *)&conId_, 1, preferred)) {
++		throw std::runtime_error("drmModeSetCrtc() failed");
++	}
++
++	screen_width_ = preferred->hdisplay;
++	screen_height_ = preferred->vdisplay;
++	width_ = width;
++	height_ = height;
+ }
+ 
+ void DrmPreview::Show(int fd, libcamera::Span<uint8_t> span, StreamInfo const &info)
+-- 
+2.34.1
+

+ 0 - 489
package/starfive/libcamera-apps/0001-add-starfive-support.patch

@@ -1,489 +0,0 @@
-From 6abadc7414f0fdfea160374326cea32bd2b40d7d Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Fri, 15 Oct 2021 10:55:01 +0800
-Subject: [PATCH] add starfive support
-
----
- CMakeLists.txt         |   2 +-
- core/CMakeLists.txt    |   2 +-
- core/libcamera_app.cpp |  38 ++++--
- core/options.hpp       |   3 +
- preview/CMakeLists.txt |   9 ++
- preview/fb_preview.cpp | 289 +++++++++++++++++++++++++++++++++++++++++
- preview/preview.cpp    |   7 +-
- 7 files changed, 338 insertions(+), 12 deletions(-)
- create mode 100644 preview/fb_preview.cpp
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 2293211..253ec8d 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -12,7 +12,7 @@ endif()
- set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
- set (CMAKE_CXX_STANDARD 17)
- set (CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-unused-parameter -faligned-new")
--add_definitions(-Werror)
-+# add_definitions(-Werror)
- add_definitions(-Wfatal-errors)
- add_definitions(-D_FILE_OFFSET_BITS=64)
- 
-diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
-index 1618541..84316b2 100644
---- a/core/CMakeLists.txt
-+++ b/core/CMakeLists.txt
-@@ -11,6 +11,6 @@ add_library(libcamera_app libcamera_app.cpp post_processor.cpp version.cpp)
- add_dependencies(libcamera_app VersionCpp)
- 
- set_target_properties(libcamera_app PROPERTIES PREFIX "" IMPORT_PREFIX "")
--target_link_libraries(libcamera_app pthread preview ${LIBCAMERA_LINK_LIBRARIES} ${Boost_LIBRARIES} post_processing_stages)
-+target_link_libraries(libcamera_app pthread preview ${LIBCAMERA_LIBRARIES} ${Boost_LIBRARIES} post_processing_stages)
- 
- install(TARGETS libcamera_app LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
-diff --git a/core/libcamera_app.cpp b/core/libcamera_app.cpp
-index 7d4e28f..3c4d862 100644
---- a/core/libcamera_app.cpp
-+++ b/core/libcamera_app.cpp
-@@ -134,7 +134,12 @@ void LibcameraApp::ConfigureViewfinder()
- 	}
- 
- 	// Now we get to override any of the default settings from the options_->
--	configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
-+	std::cout << "viewfinder pixelformat: " << options_->pixelformat << std::endl;
-+	if (options_->pixelformat.length())
-+		configuration_->at(0).pixelFormat =
-+			libcamera::PixelFormat::fromString(options_->pixelformat);
-+	else
-+		configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
- 	configuration_->at(0).size = size;
- 
- 	if (have_lores_stream)
-@@ -143,7 +148,11 @@ void LibcameraApp::ConfigureViewfinder()
- 		lores_size.alignDownTo(2, 2);
- 		if (lores_size.width > size.width || lores_size.height > size.height)
- 			throw std::runtime_error("Low res image larger than viewfinder");
--		configuration_->at(1).pixelFormat = libcamera::formats::YUV420;
-+		if (options_->pixelformat.length())
-+			configuration_->at(0).pixelFormat =
-+				libcamera::PixelFormat::fromString(options_->pixelformat);
-+		else
-+			configuration_->at(1).pixelFormat = libcamera::formats::YUV420;
- 		configuration_->at(1).size = lores_size;
- 		configuration_->at(1).bufferCount = configuration_->at(0).bufferCount;
- 	}
-@@ -186,8 +195,13 @@ void LibcameraApp::ConfigureStill(unsigned int flags)
- 		configuration_->at(0).pixelFormat = libcamera::formats::BGR888;
- 	else if (flags & FLAG_STILL_RGB)
- 		configuration_->at(0).pixelFormat = libcamera::formats::RGB888;
--	else
--		configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
-+	else {
-+		if (options_->pixelformat.length())
-+			configuration_->at(0).pixelFormat =
-+				libcamera::PixelFormat::fromString(options_->pixelformat);
-+		else
-+			configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
-+	}
- 	if ((flags & FLAG_STILL_BUFFER_MASK) == FLAG_STILL_DOUBLE_BUFFER)
- 		configuration_->at(0).bufferCount = 2;
- 	else if ((flags & FLAG_STILL_BUFFER_MASK) == FLAG_STILL_TRIPLE_BUFFER)
-@@ -241,7 +255,11 @@ void LibcameraApp::ConfigureVideo(unsigned int flags)
- 		throw std::runtime_error("failed to generate video configuration");
- 
- 	// Now we get to override any of the default settings from the options_->
--	configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
-+	if (options_->pixelformat.length())
-+		configuration_->at(0).pixelFormat =
-+			libcamera::PixelFormat::fromString(options_->pixelformat);
-+	else
-+		configuration_->at(0).pixelFormat = libcamera::formats::YUV420;
- 	configuration_->at(0).bufferCount = 6; // 6 buffers is better than 4
- 	if (options_->width)
- 		configuration_->at(0).size.width = options_->width;
-@@ -267,7 +285,11 @@ void LibcameraApp::ConfigureVideo(unsigned int flags)
- 		if (lores_size.width > configuration_->at(0).size.width ||
- 			lores_size.height > configuration_->at(0).size.height)
- 			throw std::runtime_error("Low res image larger than video");
--		configuration_->at(lores_index).pixelFormat = libcamera::formats::YUV420;
-+		if (options_->pixelformat.length())
-+			configuration_->at(0).pixelFormat =
-+				libcamera::PixelFormat::fromString(options_->pixelformat);
-+		else
-+			configuration_->at(lores_index).pixelFormat = libcamera::formats::YUV420;
- 		configuration_->at(lores_index).size = lores_size;
- 		configuration_->at(lores_index).bufferCount = configuration_->at(0).bufferCount;
- 	}
-@@ -713,8 +735,8 @@ void LibcameraApp::previewThread()
- 				preview_cond_var_.wait(lock);
- 		}
- 
--		if (item.stream->configuration().pixelFormat != libcamera::formats::YUV420)
--			throw std::runtime_error("Preview windows only support YUV420");
-+		// if (item.stream->configuration().pixelFormat != libcamera::formats::YUV420)
-+		// 	throw std::runtime_error("Preview windows only support YUV420");
- 
- 		unsigned int w, h, stride;
- 		StreamDimensions(item.stream, &w, &h, &stride);
-diff --git a/core/options.hpp b/core/options.hpp
-index 447983f..5c68088 100644
---- a/core/options.hpp
-+++ b/core/options.hpp
-@@ -43,6 +43,8 @@ struct Options
- 			 "Set the output image width (0 = use default value)")
- 			("height", value<unsigned int>(&height)->default_value(0),
- 			 "Set the output image height (0 = use default value)")
-+			("pixelformat", value<std::string>(&pixelformat),
-+			 "Set the pixelformat name")
- 			("timeout,t", value<uint64_t>(&timeout)->default_value(5000),
- 			 "Time (in ms) for which program runs")
- 			("output,o", value<std::string>(&output),
-@@ -119,6 +121,7 @@ struct Options
- 	std::string post_process_file;
- 	unsigned int width;
- 	unsigned int height;
-+	std::string pixelformat;
- 	bool rawfull;
- 	bool nopreview;
- 	std::string preview;
-diff --git a/preview/CMakeLists.txt b/preview/CMakeLists.txt
-index 1a7481f..a772e14 100644
---- a/preview/CMakeLists.txt
-+++ b/preview/CMakeLists.txt
-@@ -63,6 +63,15 @@ else()
-     message(STATUS "QT display mode will be unavailable!")
- endif()
- 
-+set(ENABLE_FB 1)
-+if (ENABLE_FB)
-+    set(SRC ${SRC} fb_preview.cpp)
-+    set(FB_FOUND 1)
-+    message(STATUS "FB display mode enabled")
-+else()
-+    message(STATUS "FB display mode will be unavailable!")
-+endif()
-+
- add_library(preview null_preview.cpp ${SRC})
- target_link_libraries(preview ${TARGET_LIBS})
- 
-diff --git a/preview/fb_preview.cpp b/preview/fb_preview.cpp
-new file mode 100644
-index 0000000..1a88b79
---- /dev/null
-+++ b/preview/fb_preview.cpp
-@@ -0,0 +1,289 @@
-+/* SPDX-License-Identifier: BSD-2-Clause */
-+/*
-+ * Copyright (C) 2021, Raspberry Pi (Trading) Ltd.
-+ *
-+ * null_preview.cpp - dummy "show nothing" preview window.
-+ */
-+
-+#include <iostream>
-+#include <sys/mman.h>
-+#include <stdio.h>
-+#include <unistd.h>
-+#include <errno.h>
-+#include <malloc.h>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
-+#include <sys/ioctl.h>
-+#include <linux/fb.h>
-+#include <string.h>
-+#include <malloc.h>
-+#include <linux/videodev2.h>
-+#include <libcamera/formats.h>
-+#include <chrono>
-+
-+#include "core/options.hpp"
-+
-+#include "preview.hpp"
-+
-+#define FBIOPAN_GET_PP_MODE        0x4609
-+#define FBIOPAN_SET_PP_MODE        0x460a
-+
-+enum COLOR_FORMAT {
-+	COLOR_YUV422_UYVY = 0,  // 00={Y1,V0,Y0,U0}
-+	COLOR_YUV422_VYUY = 1,  // 01={Y1,U0,Y0,V0}
-+	COLOR_YUV422_YUYV = 2,  // 10={V0,Y1,U0,Y0}
-+	COLOR_YUV422_YVYU = 3,  // 11={U0,Y1,V0,Y0}
-+
-+	COLOR_YUV420P,          // 4
-+	COLOR_YUV420_NV21,      // 5
-+	COLOR_YUV420_NV12,      // 6
-+
-+	COLOR_RGB888_ARGB,      // 7
-+	COLOR_RGB888_ABGR,      // 8
-+	COLOR_RGB888_RGBA,      // 9
-+	COLOR_RGB888_BGRA,      // 10
-+	COLOR_RGB565,           // 11
-+};
-+
-+struct pp_video_mode {
-+	enum COLOR_FORMAT format;
-+	unsigned int height;
-+	unsigned int width;
-+	unsigned int addr;
-+};
-+
-+struct pp_mode {
-+	char pp_id;
-+	bool bus_out;        /*out to ddr*/
-+	bool fifo_out;        /*out to lcdc*/
-+	bool inited;
-+	struct pp_video_mode src;
-+	struct pp_video_mode dst;
-+};
-+
-+class FbPreview : public Preview
-+{
-+public:
-+	FbPreview(Options const *options);
-+	~FbPreview();
-+	void SetInfoText(const std::string &text) override 
-+	{ 
-+		std::cout << "Camera fps: " << text << std::endl;
-+	}
-+	// Display the buffer. You get given the fd back in the BufferDoneCallback
-+	// once its available for re-use.
-+	virtual void Show(int fd, libcamera::Span<uint8_t> span, int width, int height, int stride) override;
-+	// Reset the preview window, clearing the current buffers and being ready to
-+	// show new ones.
-+	void Reset() override {}
-+	// Return the maximum image size allowed. Zeroes mean "no limit".
-+	virtual void MaxImageSize(unsigned int &w, unsigned int &h) const override { w = h = 0; }
-+
-+private:
-+	int NVResize(unsigned char *inBuf,
-+		unsigned char *outBuf, int imgWidth, int imgHeight);
-+	int g_fb_fd;
-+	int g_stfbc_fd;
-+	struct fb_var_screeninfo g_vinfo;
-+	struct fb_fix_screeninfo g_finfo;
-+	unsigned char *g_fb_buf;
-+	unsigned char *tmpBuf;
-+	unsigned int g_screensize;
-+	enum COLOR_FORMAT pixformat;
-+};
-+
-+static enum COLOR_FORMAT v4l2fmt_to_fbfmt(unsigned int format)
-+{
-+	enum COLOR_FORMAT pixformat = COLOR_RGB565;
-+
-+	switch (format) {
-+	case V4L2_PIX_FMT_RGB565:
-+		pixformat = COLOR_RGB565;
-+		break;
-+	case V4L2_PIX_FMT_RGB24:
-+		pixformat = COLOR_RGB888_ARGB;
-+		break;
-+	case V4L2_PIX_FMT_YUV420:
-+		pixformat = COLOR_YUV420P;
-+		break;
-+	case V4L2_PIX_FMT_YUYV:
-+		pixformat = COLOR_YUV422_YUYV;
-+		break;
-+	case V4L2_PIX_FMT_NV21:
-+		pixformat = COLOR_YUV420_NV21;
-+		break;
-+	case V4L2_PIX_FMT_NV12:
-+		pixformat = COLOR_YUV420_NV12;
-+		break;
-+	case V4L2_PIX_FMT_YVYU:
-+		pixformat = COLOR_YUV422_YVYU;
-+		break;
-+	default:
-+		pixformat = COLOR_RGB565;
-+		break;
-+	}
-+
-+	return pixformat;
-+}
-+
-+FbPreview::FbPreview(Options const *options) : Preview(options)
-+{
-+	g_fb_fd = open("/dev/fb0", O_RDWR);
-+	if (g_fb_fd == -1)
-+		throw std::runtime_error("Couldn't open fb display");
-+	g_stfbc_fd = open("/dev/stfbcdev", O_RDWR);
-+	if (g_stfbc_fd == -1)
-+		throw std::runtime_error("Couldn't open stfbcdev display");
-+
-+	struct pp_mode pp_info[3];
-+	libcamera::PixelFormat pixelFormat =
-+		libcamera::PixelFormat::fromString(options_->pixelformat);
-+
-+	if (pixelFormat.fourcc() != V4L2_PIX_FMT_NV12)
-+		throw std::runtime_error("FB onlu support NV12 display");
-+
-+	pixformat = v4l2fmt_to_fbfmt(pixelFormat.fourcc());
-+	if (-1 == ioctl(g_stfbc_fd, FBIOPAN_GET_PP_MODE, &pp_info[0]))
-+		throw std::runtime_error("Error reading variable information.");
-+
-+	std::cout << "get pp format : "
-+		<< pp_info[1].src.format
-+		<< std::endl;
-+	
-+	pp_info[1].src.format = pixformat;
-+	
-+	if (-1 == ioctl(g_stfbc_fd, FBIOPAN_SET_PP_MODE, &pp_info[0]))
-+		throw std::runtime_error("Error reading variable information.");
-+	
-+	if (-1 == ioctl(g_stfbc_fd, FBIOPAN_GET_PP_MODE, &pp_info[0]))
-+		throw std::runtime_error("Error reading variable information.");
-+
-+	std::cout << "get pp format : "
-+		<< pp_info[1].src.format
-+		<< std::endl;
-+
-+	pixformat = pp_info[1].src.format;
-+	
-+	// Get fixed screen information
-+	if (-1 == ioctl(g_fb_fd, FBIOGET_FSCREENINFO, &g_finfo))
-+		throw std::runtime_error("Error reading fixed information.");
-+	
-+	// Get variable screen information
-+	if (-1 == ioctl(g_fb_fd, FBIOGET_VSCREENINFO, &g_vinfo))
-+		throw std::runtime_error("Error reading variable information.");
-+	
-+	std::cout << "g_vinfo.xres = " << g_vinfo.xres
-+		<< ", g_vinfo.yres = " << g_vinfo.yres
-+		<< ", grayscale = " << g_vinfo.grayscale
-+		<< std::endl;
-+	std::cout << "g_vinfo.xoffset = " << g_vinfo.xoffset
-+		<< ", g_vinfo.yoffset = " << g_vinfo.yoffset
-+		<< std::endl;
-+	std::cout << "g_vinfo.bits_per_pixel = " << g_vinfo.bits_per_pixel
-+		<< ", g_finfo.line_length = " << g_finfo.line_length
-+		<< std::endl;
-+	
-+	g_screensize = g_vinfo.xres * g_vinfo.yres * g_vinfo.bits_per_pixel / 8;
-+	g_fb_buf = (unsigned char *)mmap(NULL, g_screensize, PROT_READ | PROT_WRITE, MAP_SHARED, g_fb_fd, 0);
-+	if (g_fb_buf == (void *)(-1))
-+		throw std::runtime_error("Error: failed to map framebuffer device to memory.");
-+
-+	memset(g_fb_buf, 0x00, g_screensize);
-+	tmpBuf = static_cast<unsigned char *>(malloc(g_screensize));
-+	if (!tmpBuf)
-+		throw std::runtime_error("Error: failed to malloc memory.");
-+	memset(tmpBuf, 0x00, g_screensize);
-+
-+	if (options->verbose)
-+		std::cout << "Running fb preview window" << std::endl;
-+}
-+
-+FbPreview::~FbPreview()
-+{
-+	free(tmpBuf);
-+	munmap((void *)g_fb_buf, g_screensize);
-+	close(g_fb_fd);
-+	close(g_stfbc_fd);
-+	std::cout << "fb preview window ~FbPreview" << std::endl;
-+}
-+
-+int FbPreview::NVResize(unsigned char *inBuf,
-+		unsigned char *outBuf, int imgWidth, int imgHeight)
-+{
-+	int rows, cols;
-+	unsigned char *OutNVdata, *InNVdata;
-+	int Ypos, Upos, Vpos;
-+	int fb_Ypos, fb_Upos, fb_Vpos;
-+	int width, height;
-+	int x_offset, y_offset;
-+	unsigned int start_timems;
-+	unsigned int end_timems;
-+	struct timeval ts_start, ts_end;
-+
-+	width = imgWidth > g_vinfo.xres ? g_vinfo.xres : imgWidth;
-+	height = imgHeight > g_vinfo.yres ? g_vinfo.yres : imgHeight;
-+	x_offset = (g_vinfo.xres - width) / 2;
-+	y_offset = (g_vinfo.yres - height) / 2;
-+
-+	InNVdata = inBuf;
-+	OutNVdata = tmpBuf;
-+
-+	if (imgWidth == g_vinfo.xres) {
-+		fb_Ypos = y_offset * g_vinfo.xres + x_offset;
-+		fb_Upos = (y_offset / 2 * g_vinfo.xres / 2 + x_offset / 2) * 2;
-+		fb_Upos = g_vinfo.xres * g_vinfo.yres + fb_Upos;
-+		Upos = imgWidth * imgHeight;
-+		memcpy(&tmpBuf[fb_Ypos], inBuf, imgWidth * height);
-+		memcpy(&tmpBuf[fb_Upos], &inBuf[Upos], imgWidth * height / 2);
-+		memcpy(&outBuf[fb_Ypos], &tmpBuf[fb_Ypos], imgWidth * height * 2);
-+		memcpy(&outBuf[fb_Upos], &tmpBuf[fb_Upos], imgWidth * height / 2);
-+		return 0;
-+	}
-+
-+	/* two bytes for every pixels */
-+	for(rows = 0; rows < height; rows+=2)
-+	{
-+		// g_vinfo.xres, g_vinfo.yres g_vinfo.bits_per_pixel
-+		fb_Ypos = ((rows + y_offset) * g_vinfo.xres + x_offset);
-+		fb_Upos = ((rows + y_offset) / 2 * g_vinfo.xres / 2 + x_offset / 2) * 2;
-+		fb_Upos = g_vinfo.xres * g_vinfo.yres + fb_Upos;
-+		fb_Vpos = fb_Upos + 1;
-+
-+		Ypos = rows * imgWidth;
-+		Upos = imgWidth * imgHeight + Ypos / 2;
-+		Vpos = Upos + 1;
-+		memcpy(&OutNVdata[fb_Ypos], &InNVdata[Ypos], width);
-+		memcpy(&OutNVdata[fb_Ypos+g_vinfo.xres], &InNVdata[Ypos+imgWidth], width);
-+
-+		memcpy(&OutNVdata[fb_Upos], &InNVdata[Upos], width);
-+	}
-+
-+	memcpy(outBuf, tmpBuf, g_screensize);
-+
-+	return 0;
-+}
-+
-+void FbPreview::Show(int fd, libcamera::Span<uint8_t> span, int width, int height, int stride)
-+{
-+	int imgsize = stride * height + stride * height / 2;
-+	auto startTime = std::chrono::high_resolution_clock::now();
-+
-+	if (pixformat == COLOR_YUV420_NV21 || pixformat == COLOR_YUV420_NV12)
-+		NVResize(span.data(), g_fb_buf, width, height);
-+	else
-+		std::cout << "FbPreview unsupport pixformat: " << pixformat << std::endl;
-+
-+	auto endTime = std::chrono::high_resolution_clock::now();
-+
-+	std::chrono::duration<double,std::ratio<1,1000000>> duration_mcs =
-+		std::chrono::duration_cast<std::chrono::duration<double,std::ratio<1,1000000>>>(endTime-startTime);
-+	std::cout << "FbPreview copy fps " << 1000000 / duration_mcs.count() << "." << std::endl;
-+
-+	done_callback_(fd);
-+}
-+
-+Preview *make_fb_preview(Options const *options)
-+{
-+	return new FbPreview(options);
-+}
-diff --git a/preview/preview.cpp b/preview/preview.cpp
-index 68d193a..0086d83 100644
---- a/preview/preview.cpp
-+++ b/preview/preview.cpp
-@@ -13,6 +13,7 @@ Preview *make_null_preview(Options const *options);
- Preview *make_egl_preview(Options const *options);
- Preview *make_drm_preview(Options const *options);
- Preview *make_qt_preview(Options const *options);
-+Preview *make_fb_preview(Options const *options);
- 
- Preview *make_preview(Options const *options)
- {
-@@ -48,8 +49,10 @@ Preview *make_preview(Options const *options)
- 			}
- 			catch (std::exception const &e)
- 			{
--				std::cout << "Preview window unavailable" << std::endl;
--				return make_null_preview(options);
-+				std::cout << "FB Preview window." << std::endl;
-+				return make_fb_preview(options);
-+				// std::cout << "Preview window unavailable" << std::endl;
-+				// return make_null_preview(options);
- 			}
- 		}
- 	}
--- 
-2.17.1
-

+ 222 - 0
package/starfive/libcamera-apps/0002-Make-libcamera-jpeg-run-normally.patch

@@ -0,0 +1,222 @@
+From d02d3b3a6c0abdfd8a89ee92447df7d8d48639d5 Mon Sep 17 00:00:00 2001
+From: "zejian.su" <zejian.su@starfivetech.com>
+Date: Thu, 12 Oct 2023 11:55:47 +0800
+Subject: [PATCH 2/4] Make libcamera-jpeg run normally
+
+---
+ apps/libcamera_jpeg.cpp   |  28 +++++----
+ core/CMakeLists.txt       |   2 +-
+ core/cvt_color_format.cpp | 119 ++++++++++++++++++++++++++++++++++++++
+ image/jpeg.cpp            |   1 +
+ 4 files changed, 134 insertions(+), 16 deletions(-)
+ create mode 100755 core/cvt_color_format.cpp
+
+diff --git a/apps/libcamera_jpeg.cpp b/apps/libcamera_jpeg.cpp
+index 05a632b..b791960 100644
+--- a/apps/libcamera_jpeg.cpp
++++ b/apps/libcamera_jpeg.cpp
+@@ -15,6 +15,8 @@
+ using namespace std::placeholders;
+ using libcamera::Stream;
+ 
++void NV12ToYUV420(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &yuv420, StreamInfo &info);
++
+ class LibcameraJpegApp : public LibcameraApp
+ {
+ public:
+@@ -61,10 +63,19 @@ static void event_loop(LibcameraJpegApp &app)
+ 			auto now = std::chrono::high_resolution_clock::now();
+ 			if (options->timeout && now - start_time > std::chrono::milliseconds(options->timeout))
+ 			{
++				Stream *stream = app.ViewfinderStream();
++				StreamInfo info = app.GetStreamInfo(stream);
++				CompletedRequestPtr &payload = std::get<CompletedRequestPtr>(msg.payload);
++				const std::vector<libcamera::Span<uint8_t>> mem = app.Mmap(payload->buffers[stream]);
++				std::vector<libcamera::Span<uint8_t>> yuv420;
++
++				NV12ToYUV420(mem[0], yuv420, info);
+ 				app.StopCamera();
+ 				app.Teardown();
+-				app.ConfigureStill();
+-				app.StartCamera();
++				
++				jpeg_save(yuv420, info, payload->metadata, options->output, app.CameraModel(), options);
++				delete[] yuv420[0].data();
++				return;
+ 			}
+ 			else
+ 			{
+@@ -72,19 +83,6 @@ static void event_loop(LibcameraJpegApp &app)
+ 				app.ShowPreview(completed_request, app.ViewfinderStream());
+ 			}
+ 		}
+-		// In still capture mode, save a jpeg and quit.
+-		else if (app.StillStream())
+-		{
+-			app.StopCamera();
+-			LOG(1, "Still capture image received");
+-
+-			Stream *stream = app.StillStream();
+-			StreamInfo info = app.GetStreamInfo(stream);
+-			CompletedRequestPtr &payload = std::get<CompletedRequestPtr>(msg.payload);
+-			const std::vector<libcamera::Span<uint8_t>> mem = app.Mmap(payload->buffers[stream]);
+-			jpeg_save(mem, info, payload->metadata, options->output, app.CameraModel(), options);
+-			return;
+-		}
+ 	}
+ }
+ 
+diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
+index b601538..5d9ee30 100644
+--- a/core/CMakeLists.txt
++++ b/core/CMakeLists.txt
+@@ -7,7 +7,7 @@ find_package(Boost REQUIRED COMPONENTS program_options)
+ add_custom_target(VersionCpp ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -P ${CMAKE_CURRENT_LIST_DIR}/version.cmake)
+ set_source_files_properties(version.cpp PROPERTIES GENERATED 1)
+ 
+-add_library(libcamera_app libcamera_app.cpp post_processor.cpp version.cpp options.cpp)
++add_library(libcamera_app libcamera_app.cpp post_processor.cpp version.cpp options.cpp cvt_color_format.cpp)
+ add_dependencies(libcamera_app VersionCpp)
+ 
+ set_target_properties(libcamera_app PROPERTIES PREFIX "" IMPORT_PREFIX "" VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
+diff --git a/core/cvt_color_format.cpp b/core/cvt_color_format.cpp
+new file mode 100755
+index 0000000..9ff2b6b
+--- /dev/null
++++ b/core/cvt_color_format.cpp
+@@ -0,0 +1,119 @@
++/* SPDX-License-Identifier: BSD-2-Clause */
++/*
++ * Copyright (C) 2023, Starfive Technology Co., Ltd.
++ *
++ * cvt_color_format.cpp - convert other format to yuv420.
++ */
++
++#include <stdio.h>
++#include <unistd.h>
++#include <sys/types.h>
++#include "core/still_options.hpp"
++
++void NV12ToYUV420(const uint8_t *mem, uint8_t *dst, const StreamInfo &info)
++{
++	const uint8_t *src = mem;
++	uint32_t width = info.width, height = info.height, stride = info.stride;
++	uint8_t *u = dst + height * stride;
++	uint8_t *v = u + ((height * width) >> 2);
++	uint32_t i;
++
++	memcpy(dst, src, height * stride);
++
++	src += height * stride;
++	for(i = 0; i < (height * width) >> 2; i++, src += 2)
++		u[i] = src[0], v[i] = src[1];
++}
++
++void NV12ToYUV420(const libcamera::Span<uint8_t> &mem, uint8_t *dst, const StreamInfo &info)
++{
++	NV12ToYUV420((const uint8_t *)(mem.data()), dst, info);
++/*	
++	const uint8_t *src = mem.data();
++	uint32_t width = info.width, height = info.height, stride = info.stride;
++	uint8_t *u = dst + height * stride;
++	uint8_t *v = u + ((height * width) >> 2);
++	uint32_t i;
++
++	memcpy(dst, src, height * stride);
++
++	src += height * stride;
++	for(i = 0; i < (height * width) >> 2; i++, src += 2)
++		u[i] = src[0], v[i] = src[1];
++*/
++}
++
++void NV12ToYUV420(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &yuv420, StreamInfo &info)
++{
++	uint32_t imgBufSize = info.height * info.stride + ((info.height * info.width) >> 1);
++	uint8_t * yuv420Buf = new uint8_t[imgBufSize];
++
++	if(!yuv420Buf)
++		throw std::runtime_error("fail to apply memory");
++	
++	yuv420.push_back(libcamera::Span<uint8_t>(yuv420Buf, imgBufSize));
++
++	NV12ToYUV420(mem, yuv420Buf, info);
++	info.pixel_format = libcamera::formats::YUV420;
++}
++
++template<int R>
++void NV12ToRGB888(const libcamera::Span<uint8_t> &mem, uint8_t *dst, const StreamInfo &info)
++{
++	uint32_t width = info.width, height = info.height, stride = info.stride;
++	const uint8_t *yRow = mem.data();
++	const uint8_t *uv = yRow + height * stride;
++	int ri = R ? 2 : 0;
++	
++	for(uint32_t i = 0; i < height; i++, yRow += stride, dst += 3 * width)
++	{
++		const uint8_t * curUV = uv;
++		uint8_t * curDst = dst;
++		for(uint32_t j = 0; j < width; j++, curDst += 3)
++		{
++			int32_t y = (int32_t)yRow[j] - 16;
++			int32_t u = (int32_t)curUV[0] - 128;
++			int32_t v = (int32_t)curUV[1] - 128;
++			int32_t val;
++
++			val = (1192 * y + 2066 * u - v) >> 10;
++			curDst[ri] = val < 0 ? 0 : (val > 255 ? 255 : (uint8_t)val);
++			val = (1192 * y - 401 * u - 833 * v) >> 10;
++			curDst[1] = val < 0 ? 0 : (val > 255 ? 255 : (uint8_t)val);
++			val = (1192 * y - 2 * u + 1634 * v) >> 10;
++			curDst[2 - ri] = val < 0 ? 0 : (val > 255 ? 255 : (uint8_t)val);
++
++			if(j & 1)
++				curUV += 2;
++		}
++		if(i & 1)
++			uv += width;
++	}
++}
++
++template<int R>
++void RGB888FromNV12(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &rgb888, StreamInfo &info)
++{
++	uint32_t imgBufSize = info.height * info.width * 3;
++	uint8_t * rgb888Buf = new uint8_t[imgBufSize];
++
++	if(!rgb888Buf)
++		throw std::runtime_error("fail to apply memory");
++	
++	rgb888.push_back(libcamera::Span<uint8_t>(rgb888Buf, imgBufSize));
++
++	NV12ToRGB888<R>(mem, rgb888Buf, info);
++	info.stride = 3 * info.width;
++}
++
++void NV12ToRGB888(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &rgb888, StreamInfo &info)
++{
++	RGB888FromNV12<0>(mem, rgb888, info);
++	info.pixel_format = libcamera::formats::RGB888;
++}
++
++void NV12ToBGR888(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &rgb888, StreamInfo &info)
++{
++	RGB888FromNV12<2>(mem, rgb888, info);
++	info.pixel_format = libcamera::formats::BGR888;
++}
+\ No newline at end of file
+diff --git a/image/jpeg.cpp b/image/jpeg.cpp
+index e3516ef..872f5c6 100644
+--- a/image/jpeg.cpp
++++ b/image/jpeg.cpp
+@@ -447,6 +447,7 @@ static void create_exif_data(std::vector<libcamera::Span<uint8_t>> const &mem, S
+ 		exif = exif_data_new();
+ 		if (!exif)
+ 			throw std::runtime_error("failed to allocate EXIF data");
++
+ 		exif_data_set_byte_order(exif, exif_byte_order);
+ 
+ 		// First add some fixed EXIF tags.
+-- 
+2.34.1
+

+ 0 - 92
package/starfive/libcamera-apps/0002-add-select-camera-options.patch

@@ -1,92 +0,0 @@
-From aec56c70bdc7f037a88deaa4cc84854ec2c961e9 Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Mon, 22 Nov 2021 10:16:15 +0800
-Subject: [PATCH] add select camera options
-
----
- core/libcamera_app.cpp | 29 +++++++++++++++++++++--------
- core/options.hpp       |  5 +++++
- 2 files changed, 26 insertions(+), 8 deletions(-)
-
-diff --git a/core/libcamera_app.cpp b/core/libcamera_app.cpp
-index 3c4d862..22896a7 100644
---- a/core/libcamera_app.cpp
-+++ b/core/libcamera_app.cpp
-@@ -58,17 +58,30 @@ void LibcameraApp::OpenCamera()
- 	if (camera_manager_->cameras().size() == 0)
- 		throw std::runtime_error("no cameras available");
- 
--	std::string const &cam_id = camera_manager_->cameras()[0]->id();
--	camera_ = camera_manager_->get(cam_id);
--	if (!camera_)
--		throw std::runtime_error("failed to find camera " + cam_id);
--
--	if (camera_->acquire())
--		throw std::runtime_error("failed to acquire camera " + cam_id);
-+	if (options_->camera_name.length()) {
-+		char *endptr;
-+		unsigned long index = strtoul(options_->camera_name.c_str(), &endptr, 10);
-+		std::cout << "Acquired camera name:  " << options_->camera_name << std::endl;
-+		if (*endptr == '\0' && index > 0 && index <= camera_manager_->cameras().size())
-+			camera_ = camera_manager_->cameras()[index - 1];
-+		else
-+			camera_ = camera_manager_->get(options_->camera_name);
-+		if (!camera_)
-+			throw std::runtime_error("failed to find camera " + options_->camera_name);
-+		if (camera_->acquire())
-+			throw std::runtime_error("failed to acquire camera " + options_->camera_name);
-+	} else {
-+		std::string const &cam_id = camera_manager_->cameras()[0]->id();
-+		camera_ = camera_manager_->get(cam_id);
-+		if (!camera_)
-+			throw std::runtime_error("failed to find camera " + cam_id);
-+		if (camera_->acquire())
-+			throw std::runtime_error("failed to acquire camera " + cam_id);
-+	}
- 	camera_acquired_ = true;
- 
- 	if (options_->verbose)
--		std::cout << "Acquired camera " << cam_id << std::endl;
-+		std::cout << "Acquired camera " << camera_->id() << std::endl;
- 
- 	if (!options_->post_process_file.empty())
- 		post_processor_.Read(options_->post_process_file);
-diff --git a/core/options.hpp b/core/options.hpp
-index 5c68088..de49beb 100644
---- a/core/options.hpp
-+++ b/core/options.hpp
-@@ -30,6 +30,8 @@ struct Options
- 			 "Displays the build version number")
- 			("verbose,v", value<bool>(&verbose)->default_value(false)->implicit_value(true),
- 			 "Output extra debug and diagnostics")
-+			("camera", value<std::string>(&camera_name),
-+			 "Specify which camera to operate on, by id or by index")
- 			("config,c", value<std::string>(&config_file)->implicit_value("config.txt"),
- 			 "Read the options from a file. If no filename is specified, default to config.txt. "
- 			 "In case of duplicate options, the ones provided on the command line will be used. "
-@@ -115,6 +117,7 @@ struct Options
- 	bool help;
- 	bool version;
- 	bool verbose;
-+	std::string camera_name;
- 	uint64_t timeout; // in ms
- 	std::string config_file;
- 	std::string output;
-@@ -259,12 +262,14 @@ struct Options
- 	{
- 		std::cout << "Options:" << std::endl;
- 		std::cout << "    verbose: " << verbose << std::endl;
-+		std::cout << "    camera_name: " << camera_name << std::endl;
- 		if (!config_file.empty())
- 			std::cout << "    config file: " << config_file << std::endl;
- 		std::cout << "    info_text:" << info_text << std::endl;
- 		std::cout << "    timeout: " << timeout << std::endl;
- 		std::cout << "    width: " << width << std::endl;
- 		std::cout << "    height: " << height << std::endl;
-+		std::cout << "    pixelformat: " << pixelformat << std::endl;
- 		std::cout << "    output: " << output << std::endl;
- 		std::cout << "    post_process_file: " << post_process_file << std::endl;
- 		std::cout << "    rawfull: " << rawfull << std::endl;
--- 
-2.17.1
-

+ 204 - 0
package/starfive/libcamera-apps/0003-Make-libcamera-still-run-normally.patch

@@ -0,0 +1,204 @@
+From f79f0914c3f8e740cf653da0dd14e5664760188d Mon Sep 17 00:00:00 2001
+From: "zejian.su" <zejian.su@starfivetech.com>
+Date: Thu, 12 Oct 2023 11:56:48 +0800
+Subject: [PATCH 3/4] Make libcamera-still run normally
+
+---
+ apps/libcamera_still.cpp | 137 +++++++++++++++++++++++++--------------
+ image/dng.cpp            |   1 -
+ 2 files changed, 88 insertions(+), 50 deletions(-)
+
+diff --git a/apps/libcamera_still.cpp b/apps/libcamera_still.cpp
+index 856f1be..bd44818 100644
+--- a/apps/libcamera_still.cpp
++++ b/apps/libcamera_still.cpp
+@@ -74,22 +74,79 @@ static void update_latest_link(std::string const &filename, StillOptions const *
+ 	}
+ }
+ 
++void cvtRawData(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &packRaw, StreamInfo &info)
++{
++	const uint8_t *src = (uint8_t *)mem.data();
++	uint32_t width = info.width, height = info.height;
++	uint32_t bufSize = (width * height) + ((width * height) >> 1);
++	uint8_t * dstBuf = new uint8_t[bufSize];
++	uint8_t * dst = dstBuf;
++	uint32_t srcStride = ((width * 12 / 8 + 8 * 16 - 1) / (8 * 16)) * 128;
++
++	if(!dst)
++		throw std::runtime_error("fail to apply memory");
++
++	for(uint32_t i = 0; i < height; i++, src += srcStride, dst += (3 * width) >> 1) {
++		const uint8_t *srcRow = src;
++		uint8_t * dstRow = dst;
++		for(uint32_t j = 0; j < width; j += 2, srcRow += 3, dstRow += 3) {
++			dstRow[0] = ((srcRow[1] & 0xf) << 4) | (srcRow[0] >> 4);
++			dstRow[1] = srcRow[2];
++			dstRow[2] = (srcRow[1] & 0xf0) | (srcRow[0] & 0xf);
++		}
++	}
++
++	packRaw.push_back(libcamera::Span<uint8_t>(dstBuf, bufSize));
++
++	if(libcamera::formats::SRGGB12 == info.pixel_format)
++		info.pixel_format = libcamera::formats::SRGGB12_CSI2P;
++	else if(libcamera::formats::SGRBG12 == info.pixel_format)
++		info.pixel_format = libcamera::formats::SGRBG12_CSI2P;
++	else if(libcamera::formats::SBGGR12 == info.pixel_format)
++		info.pixel_format = libcamera::formats::SBGGR12_CSI2P;
++	else if(libcamera::formats::SGBRG12 == info.pixel_format)
++		info.pixel_format = libcamera::formats::SGBRG12_CSI2P;
++	else
++		throw std::runtime_error("unsupported Bayer format");
++	info.stride = (3 * width) >> 1;
++}
++
++void NV12ToYUV420(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &yuv420, StreamInfo &info);
++void NV12ToRGB888(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &rgb888, StreamInfo &info);
++void NV12ToBGR888(const libcamera::Span<uint8_t> &mem, std::vector<libcamera::Span<uint8_t>> &rgb888, StreamInfo &info);
++
+ static void save_image(LibcameraStillApp &app, CompletedRequestPtr &payload, Stream *stream,
+ 					   std::string const &filename)
+ {
+ 	StillOptions const *options = app.GetOptions();
+ 	StreamInfo info = app.GetStreamInfo(stream);
+ 	const std::vector<libcamera::Span<uint8_t>> mem = app.Mmap(payload->buffers[stream]);
+-	if (stream == app.RawStream())
+-		dng_save(mem, info, payload->metadata, filename, app.CameraModel(), options);
+-	else if (options->encoding == "jpg")
+-		jpeg_save(mem, info, payload->metadata, filename, app.CameraModel(), options);
+-	else if (options->encoding == "png")
+-		png_save(mem, info, filename, options);
+-	else if (options->encoding == "bmp")
+-		bmp_save(mem, info, filename, options);
+-	else
+-		yuv_save(mem, info, filename, options);
++	if (stream == app.RawStream()) {
++		std::vector<libcamera::Span<uint8_t>> packRaw;
++		cvtRawData(mem[0], packRaw, info);
++		dng_save(packRaw, info, payload->metadata, filename, app.CameraModel(), options);
++		delete[] packRaw[0].data();
++	} else if (options->encoding == "jpg") {
++		std::vector<libcamera::Span<uint8_t>> yuv420;
++		NV12ToYUV420(mem[0], yuv420, info);
++		jpeg_save(yuv420, info, payload->metadata, filename, app.CameraModel(), options);
++		delete[] yuv420[0].data();
++	} else if (options->encoding == "png") {
++		std::vector<libcamera::Span<uint8_t>> rgb888;
++		NV12ToBGR888(mem[0], rgb888, info);
++		png_save(rgb888, info, filename, options);
++		delete[] rgb888[0].data();
++	} else if (options->encoding == "bmp") {
++		std::vector<libcamera::Span<uint8_t>> rgb888;
++		NV12ToRGB888(mem[0], rgb888, info);
++		bmp_save(rgb888, info, filename, options);
++		delete[] rgb888[0].data();
++	} else {
++		std::vector<libcamera::Span<uint8_t>> yuv420;
++		NV12ToYUV420(mem[0], yuv420, info);
++		yuv_save(yuv420, info, filename, options);
++		delete[] yuv420[0].data();
++	}
+ 	LOG(2, "Saved image " << info.width << " x " << info.height << " to file " << filename);
+ }
+ 
+@@ -193,7 +250,7 @@ static void event_loop(LibcameraStillApp &app)
+ 		}
+ 	}
+ 	else
+-		app.ConfigureViewfinder();
++		app.ConfigureStill();
+ 	app.StartCamera();
+ 	auto start_time = std::chrono::high_resolution_clock::now();
+ 	auto timelapse_time = start_time;
+@@ -234,7 +291,7 @@ static void event_loop(LibcameraStillApp &app)
+ 		// In viewfinder mode, run until the timeout or keypress. When that happens,
+ 		// if the "--autofocus-on-capture" option was set, trigger an AF scan and wait
+ 		// for it to complete. Then switch to capture mode if an output was requested.
+-		if (app.ViewfinderStream())
++		if (app.StillStream())
+ 		{
+ 			LOG(2, "Viewfinder frame " << count);
+ 			timelapse_frames++;
+@@ -280,47 +337,29 @@ static void event_loop(LibcameraStillApp &app)
+ 				keypressed = false;
+ 				af_wait_state = AF_WAIT_NONE;
+ 				timelapse_time = std::chrono::high_resolution_clock::now();
++
++				save_images(app, completed_request);
++				if (!options->metadata.empty())
++					save_metadata(options, completed_request->metadata);
++
+ 				app.StopCamera();
+ 				app.Teardown();
+-				app.ConfigureStill(still_flags);
+-				if (options->af_on_capture)
+-				{
+-					libcamera::ControlList cl;
+-					cl.set(libcamera::controls::AfMode, libcamera::controls::AfModeAuto);
+-					cl.set(libcamera::controls::AfTrigger, libcamera::controls::AfTriggerCancel);
+-					app.SetControls(cl);
+-				}
+-				app.StartCamera();
+-			}
+-			else
+-				app.ShowPreview(completed_request, app.ViewfinderStream());
+-		}
+-		// In still capture mode, save a jpeg. Go back to viewfinder if in timelapse mode,
+-		// otherwise quit.
+-		else if (app.StillStream())
+-		{
+-			app.StopCamera();
+-			LOG(1, "Still capture image received");
+-			save_images(app, completed_request);
+-			if (!options->metadata.empty())
+-				save_metadata(options, completed_request->metadata);
+-			timelapse_frames = 0;
+-			if (!options->immediate && (options->timelapse || options->signal || options->keypress))
+-			{
+-				app.Teardown();
+-				app.ConfigureViewfinder();
+-				if (options->af_on_capture && options->afMode_index == -1)
+-				{
+-					libcamera::ControlList cl;
+-					cl.set(libcamera::controls::AfMode, libcamera::controls::AfModeAuto);
+-					cl.set(libcamera::controls::AfTrigger, libcamera::controls::AfTriggerCancel);
+-					app.SetControls(cl);
+-				}
+-				app.StartCamera();
+-				af_wait_state = AF_WAIT_NONE;
++				if (!options->immediate && (options->timelapse || options->signal || options->keypress)){
++					app.ConfigureStill(still_flags);
++					if (options->af_on_capture)
++					{
++						libcamera::ControlList cl;
++						cl.set(libcamera::controls::AfMode, libcamera::controls::AfModeAuto);
++						cl.set(libcamera::controls::AfTrigger, libcamera::controls::AfTriggerCancel);
++						app.SetControls(cl);
++					}
++					app.StartCamera();
++				} 
++				else
++					return;
+ 			}
+ 			else
+-				return;
++				app.ShowPreview(completed_request, app.StillStream());
+ 		}
+ 	}
+ }
+diff --git a/image/dng.cpp b/image/dng.cpp
+index fbc02bb..98cb5e7 100644
+--- a/image/dng.cpp
++++ b/image/dng.cpp
+@@ -151,7 +151,6 @@ void dng_save(std::vector<libcamera::Span<uint8_t>> const &mem, StreamInfo const
+ 			  std::string const &filename, std::string const &cam_model, StillOptions const *options)
+ {
+ 	// Check the Bayer format and unpack it to u16.
+-
+ 	auto it = bayer_formats.find(info.pixel_format);
+ 	if (it == bayer_formats.end())
+ 		throw std::runtime_error("unsupported Bayer format");
+-- 
+2.34.1
+

+ 0 - 224
package/starfive/libcamera-apps/0003-add-FbPreview-support-YUYV-YVYU-display.patch

@@ -1,224 +0,0 @@
-From 4fd0d73ae92f4e0f49c9d0f9f7e559e55e4fe2a8 Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Mon, 22 Nov 2021 15:28:17 +0800
-Subject: [PATCH] add FbPreview support YUYV/YVYU display
-
----
- preview/fb_preview.cpp | 123 +++++++++++++++++++++++++++++++++++------
- preview/preview.cpp    |  15 +++--
- 2 files changed, 118 insertions(+), 20 deletions(-)
-
-diff --git a/preview/fb_preview.cpp b/preview/fb_preview.cpp
-index 1a88b79..0b42ad1 100644
---- a/preview/fb_preview.cpp
-+++ b/preview/fb_preview.cpp
-@@ -44,6 +44,7 @@ enum COLOR_FORMAT {
- 	COLOR_RGB888_RGBA,      // 9
- 	COLOR_RGB888_BGRA,      // 10
- 	COLOR_RGB565,           // 11
-+	COLOR_UNKOWN,           // unkown
- };
- 
- struct pp_video_mode {
-@@ -83,6 +84,10 @@ public:
- private:
- 	int NVResize(unsigned char *inBuf,
- 		unsigned char *outBuf, int imgWidth, int imgHeight);
-+	int YUYVResize(unsigned char *inBuf,
-+		unsigned char *outBuf, int imgWidth, int imgHeight);
-+	void setPixformat(unsigned int format);
-+	unsigned int getPixformat(void);
- 	int g_fb_fd;
- 	int g_stfbc_fd;
- 	struct fb_var_screeninfo g_vinfo;
-@@ -93,10 +98,8 @@ private:
- 	enum COLOR_FORMAT pixformat;
- };
- 
--static enum COLOR_FORMAT v4l2fmt_to_fbfmt(unsigned int format)
-+void FbPreview::setPixformat(unsigned int format)
- {
--	enum COLOR_FORMAT pixformat = COLOR_RGB565;
--
- 	switch (format) {
- 	case V4L2_PIX_FMT_RGB565:
- 		pixformat = COLOR_RGB565;
-@@ -120,11 +123,43 @@ static enum COLOR_FORMAT v4l2fmt_to_fbfmt(unsigned int format)
- 		pixformat = COLOR_YUV422_YVYU;
- 		break;
- 	default:
--		pixformat = COLOR_RGB565;
-+		pixformat = COLOR_UNKOWN;
- 		break;
- 	}
-+}
- 
--	return pixformat;
-+unsigned int FbPreview::getPixformat(void)
-+{
-+	unsigned int format;
-+
-+	switch (pixformat) {
-+	case COLOR_RGB565:
-+		format = V4L2_PIX_FMT_RGB565;
-+		break;
-+	case COLOR_RGB888_ARGB:
-+		format = V4L2_PIX_FMT_RGB24;
-+		break;
-+	case COLOR_YUV420P:
-+		format = V4L2_PIX_FMT_YUV420;
-+		break;
-+	case COLOR_YUV422_YUYV:
-+		format = V4L2_PIX_FMT_YUYV;
-+		break;
-+	case COLOR_YUV420_NV21:
-+		format = V4L2_PIX_FMT_NV21;
-+		break;
-+	case COLOR_YUV420_NV12:
-+		format = V4L2_PIX_FMT_NV12;
-+		break;
-+	case COLOR_YUV422_YVYU:
-+		format = V4L2_PIX_FMT_YVYU;
-+		break;
-+	default:
-+		format = 0;
-+		break;
-+	}
-+
-+	return format;
- }
- 
- FbPreview::FbPreview(Options const *options) : Preview(options)
-@@ -140,10 +175,10 @@ FbPreview::FbPreview(Options const *options) : Preview(options)
- 	libcamera::PixelFormat pixelFormat =
- 		libcamera::PixelFormat::fromString(options_->pixelformat);
- 
--	if (pixelFormat.fourcc() != V4L2_PIX_FMT_NV12)
--		throw std::runtime_error("FB onlu support NV12 display");
-+	setPixformat(pixelFormat.fourcc());
-+	if (pixformat == COLOR_UNKOWN)
-+		throw std::runtime_error("FB unsupport format display.");
- 
--	pixformat = v4l2fmt_to_fbfmt(pixelFormat.fourcc());
- 	if (-1 == ioctl(g_stfbc_fd, FBIOPAN_GET_PP_MODE, &pp_info[0]))
- 		throw std::runtime_error("Error reading variable information.");
- 
-@@ -217,9 +252,6 @@ int FbPreview::NVResize(unsigned char *inBuf,
- 	int fb_Ypos, fb_Upos, fb_Vpos;
- 	int width, height;
- 	int x_offset, y_offset;
--	unsigned int start_timems;
--	unsigned int end_timems;
--	struct timeval ts_start, ts_end;
- 
- 	width = imgWidth > g_vinfo.xres ? g_vinfo.xres : imgWidth;
- 	height = imgHeight > g_vinfo.yres ? g_vinfo.yres : imgHeight;
-@@ -264,15 +296,74 @@ int FbPreview::NVResize(unsigned char *inBuf,
- 	return 0;
- }
- 
-+int FbPreview::YUYVResize(unsigned char *inBuf,
-+		unsigned char *outBuf, int imgWidth, int imgHeight)
-+{
-+	int rows, cols;
-+	unsigned char *OutNVdata, *InNVdata;
-+	int Ypos, fb_Ypos;
-+	int width, height;
-+	int x_offset, y_offset;
-+
-+	width = imgWidth > g_vinfo.xres ? g_vinfo.xres : imgWidth;
-+	height = imgHeight > g_vinfo.yres ? g_vinfo.yres : imgHeight;
-+	x_offset = (g_vinfo.xres - width) / 2;
-+	y_offset = (g_vinfo.yres - height) / 2;
-+	x_offset &= ~0x1;
-+
-+	InNVdata = inBuf;
-+	OutNVdata = tmpBuf;
-+
-+	if (imgWidth == g_vinfo.xres) {
-+		fb_Ypos = y_offset * g_vinfo.xres + x_offset;
-+		memcpy(&tmpBuf[fb_Ypos], inBuf, imgWidth * height * 2);
-+		memcpy(&outBuf[fb_Ypos], &tmpBuf[fb_Ypos], imgWidth * height * 2);
-+		return 0;
-+	}
-+
-+	/* two bytes for every pixels */
-+	for(rows = 0; rows < height; rows++)
-+	{
-+		// g_vinfo.xres, g_vinfo.yres g_vinfo.bits_per_pixel
-+		fb_Ypos = ((rows + y_offset) * g_vinfo.xres + x_offset) * 2;
-+		Ypos = rows * imgWidth * 2;
-+		memcpy(&OutNVdata[fb_Ypos], &InNVdata[Ypos], width * 2);
-+	}
-+
-+	memcpy(outBuf, tmpBuf, g_screensize);
-+
-+	return 0;
-+}
-+
- void FbPreview::Show(int fd, libcamera::Span<uint8_t> span, int width, int height, int stride)
- {
--	int imgsize = stride * height + stride * height / 2;
- 	auto startTime = std::chrono::high_resolution_clock::now();
-+	int size_valid = 0;
-+	int imgsize;
-+
-+	if (pixformat == COLOR_YUV420_NV21 || pixformat == COLOR_YUV420_NV12) {
-+		imgsize = stride * height + stride * height / 2;
-+		if (imgsize == span.size()) {
-+			size_valid = 1;
-+			NVResize(span.data(), g_fb_buf, width, height);
-+		}
-+	} else if (pixformat == COLOR_YUV422_YVYU || pixformat == COLOR_YUV422_YUYV) {
-+		imgsize = stride * height;
-+		if (imgsize == span.size()) {
-+			size_valid = 1;
-+			YUYVResize(span.data(), g_fb_buf, width, height);
-+		}
-+	}
- 
--	if (pixformat == COLOR_YUV420_NV21 || pixformat == COLOR_YUV420_NV12)
--		NVResize(span.data(), g_fb_buf, width, height);
--	else
--		std::cout << "FbPreview unsupport pixformat: " << pixformat << std::endl;
-+	if (!size_valid) {
-+		std::cout << "FbPreview unsupport pixformat: " << pixformat
-+			<< " fb need size: " << imgsize
-+			<< " width: " << width
-+			<< " height: " << height
-+			<< " stride: " << stride
-+			<< " size: " << span.size() << std::endl;
-+		throw std::runtime_error("Error FbPreview unsupport pixformat.");
-+	}
- 
- 	auto endTime = std::chrono::high_resolution_clock::now();
- 
-diff --git a/preview/preview.cpp b/preview/preview.cpp
-index 0086d83..17118d4 100644
---- a/preview/preview.cpp
-+++ b/preview/preview.cpp
-@@ -49,10 +49,17 @@ Preview *make_preview(Options const *options)
- 			}
- 			catch (std::exception const &e)
- 			{
--				std::cout << "FB Preview window." << std::endl;
--				return make_fb_preview(options);
--				// std::cout << "Preview window unavailable" << std::endl;
--				// return make_null_preview(options);
-+				try {
-+					std::cout << "FB Preview window." << std::endl;
-+					return make_fb_preview(options);
-+					if (options->verbose)
-+						std::cout << "Made FB Preview window." << std::endl;
-+				}
-+				catch (std::exception const &e)
-+				{
-+					std::cout << "Preview window unavailable" << std::endl;
-+					return make_null_preview(options);
-+				}
- 			}
- 		}
- 	}
--- 
-2.17.1
-

+ 8519 - 0
package/starfive/libcamera-apps/0004-Make-libcamera-vid-run-normally.patch

@@ -0,0 +1,8519 @@
+From 687ce90d3cccfef1ef6207e4856212d244fddabc Mon Sep 17 00:00:00 2001
+From: "zejian.su" <zejian.su@starfivetech.com>
+Date: Thu, 12 Oct 2023 13:59:07 +0800
+Subject: [PATCH 4/4] Make libcamera-vid run normally
+
+---
+ encoder/CMakeLists.txt                     |    7 +-
+ encoder/encoder.cpp                        |    6 +-
+ encoder/h265_encoder.cpp                   |  422 ++++++
+ encoder/h265_encoder.hpp                   |   78 ++
+ encoder/include/khronos/OMX_Audio.h        | 1310 ++++++++++++++++++
+ encoder/include/khronos/OMX_Component.h    |  569 ++++++++
+ encoder/include/khronos/OMX_ComponentExt.h |   61 +
+ encoder/include/khronos/OMX_ContentPipe.h  |  193 +++
+ encoder/include/khronos/OMX_Core.h         | 1422 ++++++++++++++++++++
+ encoder/include/khronos/OMX_CoreExt.h      |   73 +
+ encoder/include/khronos/OMX_IVCommon.h     |  993 ++++++++++++++
+ encoder/include/khronos/OMX_Image.h        |  328 +++++
+ encoder/include/khronos/OMX_ImageExt.h     |   55 +
+ encoder/include/khronos/OMX_Index.h        |  260 ++++
+ encoder/include/khronos/OMX_IndexExt.h     |  105 ++
+ encoder/include/khronos/OMX_Other.h        |  366 +++++
+ encoder/include/khronos/OMX_Types.h        |  361 +++++
+ encoder/include/khronos/OMX_Video.h        | 1141 ++++++++++++++++
+ encoder/include/khronos/OMX_VideoExt.h     |  401 ++++++
+ encoder/mjpeg_encoder.cpp                  |   19 +-
+ encoder/yuv420_encoder.cpp                 |   80 ++
+ encoder/yuv420_encoder.hpp                 |   41 +
+ 22 files changed, 8287 insertions(+), 4 deletions(-)
+ create mode 100755 encoder/h265_encoder.cpp
+ create mode 100755 encoder/h265_encoder.hpp
+ create mode 100755 encoder/include/khronos/OMX_Audio.h
+ create mode 100755 encoder/include/khronos/OMX_Component.h
+ create mode 100755 encoder/include/khronos/OMX_ComponentExt.h
+ create mode 100755 encoder/include/khronos/OMX_ContentPipe.h
+ create mode 100755 encoder/include/khronos/OMX_Core.h
+ create mode 100755 encoder/include/khronos/OMX_CoreExt.h
+ create mode 100755 encoder/include/khronos/OMX_IVCommon.h
+ create mode 100755 encoder/include/khronos/OMX_Image.h
+ create mode 100755 encoder/include/khronos/OMX_ImageExt.h
+ create mode 100755 encoder/include/khronos/OMX_Index.h
+ create mode 100755 encoder/include/khronos/OMX_IndexExt.h
+ create mode 100755 encoder/include/khronos/OMX_Other.h
+ create mode 100755 encoder/include/khronos/OMX_Types.h
+ create mode 100755 encoder/include/khronos/OMX_Video.h
+ create mode 100755 encoder/include/khronos/OMX_VideoExt.h
+ create mode 100755 encoder/yuv420_encoder.cpp
+ create mode 100755 encoder/yuv420_encoder.hpp
+
+diff --git a/encoder/CMakeLists.txt b/encoder/CMakeLists.txt
+index a426a45..4f36270 100644
+--- a/encoder/CMakeLists.txt
++++ b/encoder/CMakeLists.txt
+@@ -6,9 +6,12 @@ if (NOT DEFINED ENABLE_LIBAV)
+     set(ENABLE_LIBAV 1)
+ endif()
+ 
++find_library(SF_OMX_IL_LIBRARY sf-omx-il REQUIRED)
++include_directories(./include/khronos)
++
+ set(LIBAV_PRESENT 0)
+-set(SRC encoder.cpp null_encoder.cpp h264_encoder.cpp mjpeg_encoder.cpp)
+-set(TARGET_LIBS images)
++set(SRC encoder.cpp null_encoder.cpp h264_encoder.cpp mjpeg_encoder.cpp h265_encoder.cpp yuv420_encoder.cpp)
++set(TARGET_LIBS images sf-omx-il)
+ 
+ if (ENABLE_LIBAV)
+     message(STATUS "Checking for libavcodec")
+diff --git a/encoder/encoder.cpp b/encoder/encoder.cpp
+index a0622ed..ce47d97 100644
+--- a/encoder/encoder.cpp
++++ b/encoder/encoder.cpp
+@@ -11,6 +11,8 @@
+ #include "h264_encoder.hpp"
+ #include "mjpeg_encoder.hpp"
+ #include "null_encoder.hpp"
++#include "h265_encoder.hpp"
++#include "yuv420_encoder.hpp"
+ 
+ #if LIBAV_PRESENT
+ #include "libav_encoder.hpp"
+@@ -19,7 +21,7 @@
+ Encoder *Encoder::Create(VideoOptions const *options, const StreamInfo &info)
+ {
+ 	if (strcasecmp(options->codec.c_str(), "yuv420") == 0)
+-		return new NullEncoder(options);
++		return new YUV420Encoder(options);
+ 	else if (strcasecmp(options->codec.c_str(), "h264") == 0)
+ 		return new H264Encoder(options, info);
+ #if LIBAV_PRESENT
+@@ -28,5 +30,7 @@ Encoder *Encoder::Create(VideoOptions const *options, const StreamInfo &info)
+ #endif
+ 	else if (strcasecmp(options->codec.c_str(), "mjpeg") == 0)
+ 		return new MjpegEncoder(options);
++	else if (strcasecmp(options->codec.c_str(), "h265") == 0)
++		return new H265Encoder(options, info);
+ 	throw std::runtime_error("Unrecognised codec " + options->codec);
+ }
+diff --git a/encoder/h265_encoder.cpp b/encoder/h265_encoder.cpp
+new file mode 100755
+index 0000000..37c3b15
+--- /dev/null
++++ b/encoder/h265_encoder.cpp
+@@ -0,0 +1,422 @@
++/* SPDX-License-Identifier: BSD-2-Clause */
++/*
++ * Copyright (C) 2023, Starfive Technology Co., Ltd.
++ *
++ * h265_encoder.cpp - h265 video encoder.
++ */
++
++#include <fcntl.h>
++#include <poll.h>
++#include <sys/ioctl.h>
++#include <sys/mman.h>
++#include <sys/msg.h>
++
++#include <linux/videodev2.h>
++
++#include <chrono>
++#include <iostream>
++
++#include "h265_encoder.hpp"
++
++#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
++
++typedef struct Message
++{
++    long msg_type;
++    OMX_S32 msg_flag;
++    OMX_BUFFERHEADERTYPE *pBuffer;
++} Message;
++
++static OMX_ERRORTYPE eventHandler(
++    OMX_HANDLETYPE hComponent,
++    OMX_PTR pAppData,
++    OMX_EVENTTYPE eEvent,
++    OMX_U32 nData1,
++    OMX_U32 nData2,
++    OMX_PTR pEventData)
++{
++    H265Encoder::EncodeContext *pEncodeContext = (H265Encoder::EncodeContext *)pAppData;
++
++    switch (eEvent)
++    {
++    case OMX_EventPortSettingsChanged:
++    {
++        OMX_PARAM_PORTDEFINITIONTYPE pOutputPortDefinition;
++        OMX_INIT_STRUCTURE(pOutputPortDefinition);
++        pOutputPortDefinition.nPortIndex = 1;
++        OMX_GetParameter(pEncodeContext->hComponentEncoder, OMX_IndexParamPortDefinition, &pOutputPortDefinition);
++        OMX_U32 nOutputBufferSize = pOutputPortDefinition.nBufferSize;
++        OMX_U32 nOutputBufferCount = pOutputPortDefinition.nBufferCountMin;
++
++        LOG(2, "enable output port and alloc buffer");
++        OMX_SendCommand(pEncodeContext->hComponentEncoder, OMX_CommandPortEnable, 1, NULL);
++
++        for (OMX_U32 i = 0; i < nOutputBufferCount; i++)
++        {
++            OMX_BUFFERHEADERTYPE *pBuffer = NULL;
++            OMX_AllocateBuffer(hComponent, &pBuffer, 1, NULL, nOutputBufferSize);
++            pEncodeContext->pOutputBufferArray[i] = pBuffer;
++            OMX_FillThisBuffer(hComponent, pBuffer);
++        }
++    }
++    break;
++    case OMX_EventBufferFlag:
++    {
++        Message data;
++        data.msg_type = 1;
++        data.msg_flag = -1;
++        if (msgsnd(pEncodeContext->msgid, (void *)&data, sizeof(data) - sizeof(data.msg_type), 0) == -1)
++        {
++            LOG_ERROR("msgsnd failed");
++        }
++    }
++    break;
++    case OMX_EventCmdComplete:
++    {
++        switch ((OMX_COMMANDTYPE)(nData1))
++        {
++        case OMX_CommandStateSet:
++        {
++            pEncodeContext->comState = (OMX_STATETYPE)(nData2);
++        }
++		break;
++        case OMX_CommandPortDisable:
++        {
++            if (nData2 == 1)
++                pEncodeContext->disableEVnt = OMX_TRUE;
++        }
++        break;
++        default:
++        break;
++        }
++    }
++    break;
++    case OMX_EventError:
++    {
++        LOG_ERROR("receive err event " + std::to_string(nData1) + std::to_string(nData2));
++        pEncodeContext->justQuit = OMX_TRUE;
++    }
++    break;
++    default:
++        break;
++    }
++    return OMX_ErrorNone;
++}
++
++static OMX_ERRORTYPE fillOutputBufferDoneHandler(
++    OMX_HANDLETYPE hComponent,
++    OMX_PTR pAppData,
++    OMX_BUFFERHEADERTYPE *pBuffer)
++{
++    H265Encoder::EncodeContext *pEncodeContext = (H265Encoder::EncodeContext *)pAppData;
++
++    Message data;
++    data.msg_type = 1;
++    if (pBuffer->nFlags & OMX_BUFFERFLAG_EOS)
++    {
++        data.msg_flag = -1;
++    }
++    else
++    {
++        data.msg_flag = 1;
++        data.pBuffer = pBuffer;
++    }
++    if (msgsnd(pEncodeContext->msgid, (void *)&data, sizeof(data) - sizeof(data.msg_type), 0) == -1)
++    {
++        LOG_ERROR("msgsnd failed");
++    }
++
++    return OMX_ErrorNone;
++}
++
++static OMX_ERRORTYPE emptyBufferDoneHandler(
++    OMX_HANDLETYPE hComponent,
++    OMX_PTR pAppData,
++    OMX_BUFFERHEADERTYPE *pBuffer)
++{
++    H265Encoder::EncodeContext *pEncodeContext = (H265Encoder::EncodeContext *)pAppData;
++    Message data;
++    data.msg_type = 1;
++    data.msg_flag = 0;
++    data.pBuffer = pBuffer;
++    if (msgsnd(pEncodeContext->msgid, (void *)&data, sizeof(data) - sizeof(data.msg_type), 0) == -1)
++    {
++        LOG_ERROR("msgsnd failed");
++    }
++
++    return OMX_ErrorNone;
++}
++
++void H265Encoder::initOMX()
++{
++	if(encoderCxt.hComponentEncoder)
++	{
++		OMX_FreeHandle(encoderCxt.hComponentEncoder);
++		encoderCxt.hComponentEncoder = 0;
++    	OMX_Deinit();
++	}
++
++	int ret = OMX_Init();
++	if(OMX_ErrorNone != ret)
++		throw std::runtime_error("run OMX_Init failed. ret is " + std::to_string(ret));
++}
++
++void H265Encoder::configOMX(StreamInfo const &info)
++{
++	// Config callbacks
++	OMX_CALLBACKTYPE &callbacks = callbacks_;
++	callbacks.EventHandler = eventHandler;
++    callbacks.FillBufferDone = fillOutputBufferDoneHandler;
++    callbacks.EmptyBufferDone = emptyBufferDoneHandler;
++
++	// Get OMX handle
++	OMX_HANDLETYPE hComponentEncoder = NULL;
++	{
++	char encName[] = "OMX.sf.video_encoder.hevc";
++
++	OMX_GetHandle(&hComponentEncoder, encName, &encoderCxt, &callbacks);
++	if(!hComponentEncoder)
++		throw std::runtime_error("Can not get OMX handle.");
++	}
++	encoderCxt.hComponentEncoder = hComponentEncoder;
++
++	// Config input
++	OMX_PARAM_PORTDEFINITIONTYPE pInputPortDefinition;
++    OMX_INIT_STRUCTURE(pInputPortDefinition);
++    pInputPortDefinition.nPortIndex = 0;
++    OMX_GetParameter(hComponentEncoder, OMX_IndexParamPortDefinition, &pInputPortDefinition);
++    pInputPortDefinition.format.video.nFrameWidth = info.width;
++    pInputPortDefinition.format.video.nFrameHeight = info.height;
++	pInputPortDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
++	pInputPortDefinition.format.video.xFramerate = encoderCxt.nFrameRate;
++	OMX_SetParameter(hComponentEncoder, OMX_IndexParamPortDefinition, &pInputPortDefinition);
++    OMX_GetParameter(hComponentEncoder, OMX_IndexParamPortDefinition, &pInputPortDefinition);
++
++	// Config output
++	OMX_PARAM_PORTDEFINITIONTYPE pOutputPortDefinition;
++    OMX_INIT_STRUCTURE(pOutputPortDefinition);
++    pOutputPortDefinition.nPortIndex = 1;
++    OMX_GetParameter(hComponentEncoder, OMX_IndexParamPortDefinition, &pOutputPortDefinition);
++    pOutputPortDefinition.format.video.nFrameWidth = info.width;
++    pOutputPortDefinition.format.video.nFrameHeight = info.height;
++    pOutputPortDefinition.format.video.nBitrate = encoderCxt.nBitrate;
++    OMX_SetParameter(hComponentEncoder, OMX_IndexParamPortDefinition, &pOutputPortDefinition);
++
++	if(encoderCxt.nNumPFrame)
++	{
++		OMX_VIDEO_PARAM_HEVCTYPE hevcType;
++		OMX_INIT_STRUCTURE(hevcType);
++		hevcType.nPortIndex = 1;
++		OMX_GetParameter(hComponentEncoder, static_cast<OMX_INDEXTYPE>(OMX_IndexParamVideoHevc), &hevcType);
++		hevcType.nKeyFrameInterval = encoderCxt.nNumPFrame;
++		OMX_SetParameter(hComponentEncoder, static_cast<OMX_INDEXTYPE>(OMX_IndexParamVideoHevc), &hevcType);
++	}
++
++	// Allocate input buffer
++	OMX_SendCommand(hComponentEncoder, OMX_CommandPortDisable, 1, NULL);
++	LOG(1, "wait for output port disable");
++    while (!encoderCxt.disableEVnt && !encoderCxt.justQuit);
++    if (encoderCxt.justQuit)
++	{
++        freeResource();
++		return;
++	}
++    LOG(1, "output port disabled");
++
++	OMX_SendCommand(hComponentEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
++
++	OMX_U32 nInputBufferSize = pInputPortDefinition.nBufferSize;
++    OMX_U32 nInputBufferCount = pInputPortDefinition.nBufferCountActual;
++	for (OMX_U32 i = 0; i < nInputBufferCount; i++)
++    {
++        OMX_BUFFERHEADERTYPE *pBuffer = NULL;
++        OMX_AllocateBuffer(hComponentEncoder, &pBuffer, 0, NULL, nInputBufferSize);
++        encoderCxt.pInputBufferArray[i] = pBuffer;
++		input_buffers_available_.push(pBuffer);
++    }
++	encoderCxt.nInputBufferCount = nInputBufferCount;
++
++	LOG(1, "wait for Component idle");
++    while (encoderCxt.comState != OMX_StateIdle && !encoderCxt.justQuit);
++    if (encoderCxt.justQuit)
++    {
++        freeResource();
++		return;
++	}
++    LOG(1, "Component in idle");
++}
++
++H265Encoder::H265Encoder(VideoOptions const *options, StreamInfo const &info)
++	: Encoder(options)
++{
++	memset(&encoderCxt, 0, sizeof(EncodeContext));
++
++	// Apply any options->
++	encoderCxt.nBitrate = options->bitrate ? options->bitrate : 3000000;
++	encoderCxt.nNumPFrame = options->intra ? options->intra - 1 : 14;
++	encoderCxt.nFrameRate = 30;
++	encoderCxt.nFrameBufferSize = info.width * info.height * 3 / 2;
++
++	encoderCxt.disableEVnt = OMX_FALSE;
++	encoderCxt.justQuit = OMX_FALSE;
++
++	OMX_S32 msgid = -1;
++    msgid = msgget(IPC_PRIVATE, 0666 | IPC_CREAT);
++    if (msgid < 0)
++        throw std::runtime_error("get ipc_id error");
++    encoderCxt.msgid = msgid;
++
++	// Initialize OMX
++	initOMX();
++
++	// Config OMX
++	configOMX(info);
++
++    abortOutput_ = false;
++	output_thread_ = std::thread(&H265Encoder::outputThread, this);
++    abortPoll_ = false;
++	poll_thread_ = std::thread(&H265Encoder::pollThread, this);
++}
++
++H265Encoder::~H265Encoder()
++{
++	freeResource();
++
++    abortPoll_ = true;
++
++    Message data;
++    data.msg_type = 1;
++    data.msg_flag = -1;
++    if (msgsnd(encoderCxt.msgid, (void *)&data, sizeof(data) - sizeof(data.msg_type), 0) == -1)
++    {
++        LOG_ERROR("msgsnd failed");
++    }
++
++	poll_thread_.join();
++    abortOutput_ = true;
++	output_thread_.join();
++}
++
++void H265Encoder::freeResource()
++{
++	if (encoderCxt.comState == OMX_StateExecuting)
++    {
++        OMX_SendCommand(encoderCxt.hComponentEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
++        LOG(1, "wait for Component idle");
++        while (encoderCxt.comState != OMX_StateIdle && !encoderCxt.justQuit);
++        LOG(1, "Component in idle");
++    }
++
++	if(encoderCxt.hComponentEncoder)
++	{
++		OMX_FreeHandle(encoderCxt.hComponentEncoder);
++		OMX_Deinit();
++	}
++}
++
++void H265Encoder::EncodeBuffer(int fd, size_t size, void *mem, StreamInfo const &info, int64_t timestamp_us)
++{
++	OMX_BUFFERHEADERTYPE *pInputBuffer = nullptr;
++	{
++		std::lock_guard<std::mutex> lock(input_buffers_available_mutex_);
++		if (input_buffers_available_.empty())
++			throw std::runtime_error("no buffers available to queue codec input");
++
++		pInputBuffer = input_buffers_available_.front();
++		input_buffers_available_.pop();
++
++        output_timestamps_.push(timestamp_us);
++	}
++
++	memcpy(pInputBuffer->pBuffer, mem, encoderCxt.nFrameBufferSize);
++	pInputBuffer->nFlags = 0x10;
++    pInputBuffer->nFilledLen = encoderCxt.nFrameBufferSize;
++
++	input_done_callback_(nullptr);
++
++	OMX_EmptyThisBuffer(encoderCxt.hComponentEncoder, pInputBuffer);
++}
++
++void H265Encoder::pollThread()
++{
++	LOG(1, "start process");
++    OMX_SendCommand(encoderCxt.hComponentEncoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
++
++	Message data;
++    while (OMX_TRUE)
++    {
++        ssize_t ret = msgrcv(encoderCxt.msgid, (void *)&data, BUFSIZ, 0, 0);
++        if (ret == -1)
++            throw std::runtime_error("msgrcv failed with errno: " + std::to_string(errno));
++        
++        switch (data.msg_flag)
++        {
++        case 0:
++        {
++			std::lock_guard<std::mutex> lock(input_buffers_available_mutex_);
++			input_buffers_available_.push(data.pBuffer);
++        }
++        break;
++        case 1:
++        {
++			{
++				std::lock_guard<std::mutex> lock(output_mutex_);
++                output_queue_.push(data.pBuffer);
++                output_cond_var_.notify_one();
++			}
++ 		}
++        break;
++        case -1:
++        {
++            if(abortPoll_)
++                return;
++        }
++        break;
++        default:
++            break;
++        }
++        if(abortPoll_)
++            return;
++    }
++}
++
++void H265Encoder::outputThread()
++{
++    while (true)
++    {
++        int64_t timestamp = 0;
++        OMX_BUFFERHEADERTYPE *pBuffer = nullptr;
++        {
++            std::unique_lock<std::mutex> lock(output_mutex_);
++            if (output_queue_.empty())
++            {
++                if(abortOutput_)
++                    return;
++                else
++                    output_cond_var_.wait_for(lock, 200ms);
++            } else
++            {
++                pBuffer = output_queue_.front();
++                output_queue_.pop();
++                if(!output_timestamps_.empty())
++                {
++                    timestamp = output_timestamps_.front();
++                    output_timestamps_.pop();
++                }
++            }
++        }
++
++        if(pBuffer)
++        {
++            output_ready_callback_(pBuffer->pBuffer, pBuffer->nFilledLen, timestamp, true);
++            OMX_FillThisBuffer(encoderCxt.hComponentEncoder, pBuffer);
++        }
++    }
++}
+\ No newline at end of file
+diff --git a/encoder/h265_encoder.hpp b/encoder/h265_encoder.hpp
+new file mode 100755
+index 0000000..a1844cb
+--- /dev/null
++++ b/encoder/h265_encoder.hpp
+@@ -0,0 +1,78 @@
++/* SPDX-License-Identifier: BSD-2-Clause */
++/*
++ * Copyright (C) 2023, Starfive Technology Co., Ltd.
++ *
++ * h265_encoder.hpp - h265 video encoder.
++ */
++
++#pragma once
++
++#include <condition_variable>
++#include <mutex>
++#include <queue>
++#include <thread>
++
++#include "encoder.hpp"
++
++#include <OMX_Core.h>
++#include <OMX_Component.h>
++#include <OMX_Video.h>
++#include <OMX_VideoExt.h>
++#include <OMX_IndexExt.h>
++
++class H265Encoder : public Encoder
++{
++public:
++	H265Encoder(VideoOptions const *options, StreamInfo const &info);
++	~H265Encoder();
++	// Encode the given DMABUF.
++	void EncodeBuffer(int fd, size_t size, void *mem, StreamInfo const &info, int64_t timestamp_us) override;
++
++	struct EncodeContext
++	{
++		OMX_HANDLETYPE hComponentEncoder;
++		OMX_U32 nFrameBufferSize;
++		OMX_U32 nBitrate;
++		OMX_U32 nFrameRate;
++		OMX_U32 nNumPFrame;
++		OMX_STATETYPE comState;
++		OMX_U32 nInputBufferCount;
++		OMX_BUFFERHEADERTYPE *pInputBufferArray[64];
++		OMX_BUFFERHEADERTYPE *pOutputBufferArray[64];
++		int msgid;
++
++		OMX_BOOL disableEVnt;
++		OMX_BOOL justQuit;
++	};
++private:
++	struct EncodeContext encoderCxt;
++
++	void initOMX();
++	void configOMX(StreamInfo const &info);
++	void freeResource();
++
++	OMX_CALLBACKTYPE callbacks_;
++
++	std::mutex input_buffers_available_mutex_;
++	std::queue<OMX_BUFFERHEADERTYPE *> input_buffers_available_;
++
++	std::mutex output_mutex_;
++	std::queue<int64_t> output_timestamps_;
++
++	// This thread just sits waiting for the encoder to finish stuff. It will either:
++	// * receive "output" buffers (codec inputs), which we must return to the caller
++	// * receive encoded buffers, which we pass to the application.
++	void pollThread();
++	std::thread poll_thread_;
++
++	// Handle the output buffers in another thread so as not to block the encoder. The
++	// application can take its time, after which we return this buffer to the encoder for
++	// re-use.
++	void outputThread();
++	std::thread output_thread_;
++	std::queue<OMX_BUFFERHEADERTYPE *> output_queue_;
++
++	bool abortPoll_;
++	std::condition_variable output_cond_var_;
++	bool abortOutput_;
++};
+diff --git a/encoder/include/khronos/OMX_Audio.h b/encoder/include/khronos/OMX_Audio.h
+new file mode 100755
+index 0000000..7205319
+--- /dev/null
++++ b/encoder/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 */
++
+diff --git a/encoder/include/khronos/OMX_Component.h b/encoder/include/khronos/OMX_Component.h
+new file mode 100755
+index 0000000..56fd37e
+--- /dev/null
++++ b/encoder/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 */
+diff --git a/encoder/include/khronos/OMX_ComponentExt.h b/encoder/include/khronos/OMX_ComponentExt.h
+new file mode 100755
+index 0000000..24ec20c
+--- /dev/null
++++ b/encoder/include/khronos/OMX_ComponentExt.h
+@@ -0,0 +1,61 @@
++/*
++ * Copyright (c) 2016 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_ComponentExt.h - OpenMax IL version 1.1.2
++ * The OMX_ComponentExt header file contains extensions to the definitions used
++ * by both the application and the component to access common items.
++ */
++
++#ifndef OMX_ComponentExt_h
++#define OMX_ComponentExt_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>
++
++
++/** Set/query the commit mode */
++typedef struct OMX_CONFIG_COMMITMODETYPE {
++    OMX_U32 nSize;
++    OMX_VERSIONTYPE nVersion;
++    OMX_BOOL bDeferred;
++} OMX_CONFIG_COMMITMODETYPE;
++
++/** Explicit commit */
++typedef struct OMX_CONFIG_COMMITTYPE {
++    OMX_U32 nSize;
++    OMX_VERSIONTYPE nVersion;
++} OMX_CONFIG_COMMITTYPE;
++
++
++#ifdef __cplusplus
++}
++#endif /* __cplusplus */
++
++#endif /* OMX_ComponentExt_h */
+diff --git a/encoder/include/khronos/OMX_ContentPipe.h b/encoder/include/khronos/OMX_ContentPipe.h
+new file mode 100755
+index 0000000..843cb7a
+--- /dev/null
++++ b/encoder/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
++
+diff --git a/encoder/include/khronos/OMX_Core.h b/encoder/include/khronos/OMX_Core.h
+new file mode 100755
+index 0000000..c8f3c4b
+--- /dev/null
++++ b/encoder/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 */
++
+diff --git a/encoder/include/khronos/OMX_CoreExt.h b/encoder/include/khronos/OMX_CoreExt.h
+new file mode 100755
+index 0000000..e2e21cc
+--- /dev/null
++++ b/encoder/include/khronos/OMX_CoreExt.h
+@@ -0,0 +1,73 @@
++/*
++ * Copyright (c) 2016 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_CoreExt.h - OpenMax IL version 1.1.2
++ * The OMX_CoreExt header file contains extensions to the definitions used
++ * by both the application and the component to access common items.
++ */
++
++#ifndef OMX_CoreExt_h
++#define OMX_CoreExt_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>
++
++/** Extensions to the standard IL errors. */ 
++typedef enum OMX_ERROREXTTYPE 
++{
++    OMX_ErrorInvalidMode = (OMX_S32) (OMX_ErrorKhronosExtensions + 0x00000001),
++    OMX_ErrorExtMax = 0x7FFFFFFF
++} OMX_ERROREXTTYPE;
++
++
++/** Event type extensions. */
++typedef enum OMX_EVENTEXTTYPE
++{
++    OMX_EventIndexSettingChanged = OMX_EventKhronosExtensions, /**< component signals the IL client of a change
++                                                                    in a param, config, or extension */
++    OMX_EventExtMax = 0x7FFFFFFF
++} OMX_EVENTEXTTYPE;
++
++
++/** Enable or disable a callback event. */
++typedef struct OMX_CONFIG_CALLBACKREQUESTTYPE {
++    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_INDEXTYPE nIndex;       /**< the index the callback is requested for */
++    OMX_BOOL bEnable;           /**< enable (OMX_TRUE) or disable (OMX_FALSE) the callback */
++} OMX_CONFIG_CALLBACKREQUESTTYPE;
++
++#ifdef __cplusplus
++}
++#endif /* __cplusplus */
++
++#endif /* OMX_CoreExt_h */
++/* File EOF */
+diff --git a/encoder/include/khronos/OMX_IVCommon.h b/encoder/include/khronos/OMX_IVCommon.h
+new file mode 100755
+index 0000000..9aad7e9
+--- /dev/null
++++ b/encoder/include/khronos/OMX_IVCommon.h
+@@ -0,0 +1,993 @@
++/**
++ * 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 */
++
++    /* Starfive extensions */
++    /* I420 */
++    OMX_COLOR_FormatYUV420Planar_P10_16BIT_MSB,
++    OMX_COLOR_FormatYUV420Planar_P10_16BIT_LSB,
++    OMX_COLOR_FormatYUV420Planar_P12_16BIT_MSB,
++    OMX_COLOR_FormatYUV420Planar_P12_16BIT_LSB,
++    /* NV12 */
++    OMX_COLOR_FormatYUV420SemiPlanar_P10_16BIT_MSB,
++    OMX_COLOR_FormatYUV420SemiPlanar_P10_16BIT_LSB,
++    OMX_COLOR_FormatYUV420SemiPlanar_P12_16BIT_MSB,
++    OMX_COLOR_FormatYUV420SemiPlanar_P12_16BIT_LSB,
++    /* NV21 */
++    OMX_COLOR_FormatYVU420SemiPlanar,
++    OMX_COLOR_FormatYVU420SemiPlanar_P10_16BIT_MSB,
++    OMX_COLOR_FormatYVU420SemiPlanar_P10_16BIT_LSB,
++    OMX_COLOR_FormatYVU420SemiPlanar_P12_16BIT_MSB,
++    OMX_COLOR_FormatYVU420SemiPlanar_P12_16BIT_LSB,
++    /* I422 */
++    OMX_COLOR_FormatYUV422Planar_P10_16BIT_MSB,
++    OMX_COLOR_FormatYUV422Planar_P10_16BIT_LSB,
++    OMX_COLOR_FormatYUV422Planar_P12_16BIT_MSB,
++    OMX_COLOR_FormatYUV422Planar_P12_16BIT_LSB,
++    /* NV16 */
++    OMX_COLOR_FormatYUV422SemiPlanar_P10_16BIT_MSB,
++    OMX_COLOR_FormatYUV422SemiPlanar_P10_16BIT_LSB,
++    OMX_COLOR_FormatYUV422SemiPlanar_P12_16BIT_MSB,
++    OMX_COLOR_FormatYUV422SemiPlanar_P12_16BIT_LSB,
++    /* NV61 */
++    OMX_COLOR_FormatYVU422SemiPlanar,
++    OMX_COLOR_FormatYVU422SemiPlanar_P10_16BIT_MSB,
++    OMX_COLOR_FormatYVU422SemiPlanar_P10_16BIT_LSB,
++    OMX_COLOR_FormatYVU422SemiPlanar_P12_16BIT_MSB,
++    OMX_COLOR_FormatYVU422SemiPlanar_P12_16BIT_LSB,
++    /* YUYV */
++    OMX_COLOR_FormatYCbYCr_P10_16BIT_MSB,
++    OMX_COLOR_FormatYCbYCr_P10_16BIT_LSB,
++    OMX_COLOR_FormatYCbYCr_P12_16BIT_MSB,
++    OMX_COLOR_FormatYCbYCr_P12_16BIT_LSB,
++    /* YVYU */
++    OMX_COLOR_FormatYCrYCb_P10_16BIT_MSB,
++    OMX_COLOR_FormatYCrYCb_P10_16BIT_LSB,
++    OMX_COLOR_FormatYCrYCb_P12_16BIT_MSB,
++    OMX_COLOR_FormatYCrYCb_P12_16BIT_LSB,
++    /* UYVY */
++    OMX_COLOR_FormatCbYCrY_P10_16BIT_MSB,
++    OMX_COLOR_FormatCbYCrY_P10_16BIT_LSB,
++    OMX_COLOR_FormatCbYCrY_P12_16BIT_MSB,
++    OMX_COLOR_FormatCbYCrY_P12_16BIT_LSB,
++    /* VYUY */
++    OMX_COLOR_FormatCrYCbY_P10_16BIT_MSB,
++    OMX_COLOR_FormatCrYCbY_P10_16BIT_LSB,
++    OMX_COLOR_FormatCrYCbY_P12_16BIT_MSB,
++    OMX_COLOR_FormatCrYCbY_P12_16BIT_LSB,
++    /* I444 */
++    OMX_COLOR_FormatYUV444Planar,
++    OMX_COLOR_FormatYUV444Planar_P10_16BIT_MSB,
++    OMX_COLOR_FormatYUV444Planar_P10_16BIT_LSB,
++    OMX_COLOR_FormatYUV444Planar_P12_16BIT_MSB,
++    OMX_COLOR_FormatYUV444Planar_P12_16BIT_LSB,
++    /* YUV444PACKED */
++    OMX_COLOR_FormatYUV444Interleaved_P10_16BIT_MSB,
++    OMX_COLOR_FormatYUV444Interleaved_P10_16BIT_LSB,
++    OMX_COLOR_FormatYUV444Interleaved_P12_16BIT_MSB,
++    OMX_COLOR_FormatYUV444Interleaved_P12_16BIT_LSB,
++    /* YUV400 */
++    OMX_COLOR_FormatYUV400,
++    OMX_COLOR_FormatYUV400_P10_16BIT_MSB,
++    OMX_COLOR_FormatYUV400_P10_16BIT_LSB,
++    OMX_COLOR_FormatYUV400_P12_16BIT_MSB,
++    OMX_COLOR_FormatYUV400_P12_16BIT_LSB,
++    /* Starfive extensions end */
++
++    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 */
+diff --git a/encoder/include/khronos/OMX_Image.h b/encoder/include/khronos/OMX_Image.h
+new file mode 100755
+index 0000000..ca64882
+--- /dev/null
++++ b/encoder/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 */
+diff --git a/encoder/include/khronos/OMX_ImageExt.h b/encoder/include/khronos/OMX_ImageExt.h
+new file mode 100755
+index 0000000..e7cae02
+--- /dev/null
++++ b/encoder/include/khronos/OMX_ImageExt.h
+@@ -0,0 +1,55 @@
++/*
++ * Copyright (c) 2016 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_ImageExt.h - OpenMax IL version 1.1.2
++ * The OMX_ImageExt header file contains extensions to the
++ * definitions used by both the application and the component to
++ * access image items.
++ */
++
++#ifndef OMX_ImageExt_h
++#define OMX_ImageExt_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>
++
++/** Enum for standard image codingtype extensions */
++typedef enum OMX_IMAGE_CODINGEXTTYPE {
++    OMX_IMAGE_CodingExtUnused = OMX_IMAGE_CodingKhronosExtensions,
++    OMX_IMAGE_CodingWEBP,         /**< WebP image format */
++} OMX_IMAGE_CODINGEXTTYPE;
++
++
++#ifdef __cplusplus
++}
++#endif /* __cplusplus */
++
++#endif /* OMX_ImageExt_h */
++/* File EOF */
+diff --git a/encoder/include/khronos/OMX_Index.h b/encoder/include/khronos/OMX_Index.h
+new file mode 100755
+index 0000000..20a109c
+--- /dev/null
++++ b/encoder/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 */
+diff --git a/encoder/include/khronos/OMX_IndexExt.h b/encoder/include/khronos/OMX_IndexExt.h
+new file mode 100755
+index 0000000..b688d1d
+--- /dev/null
++++ b/encoder/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 */
+diff --git a/encoder/include/khronos/OMX_Other.h b/encoder/include/khronos/OMX_Other.h
+new file mode 100755
+index 0000000..8aa67b7
+--- /dev/null
++++ b/encoder/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 */
+diff --git a/encoder/include/khronos/OMX_Types.h b/encoder/include/khronos/OMX_Types.h
+new file mode 100755
+index 0000000..527ba23
+--- /dev/null
++++ b/encoder/include/khronos/OMX_Types.h
+@@ -0,0 +1,361 @@
++/*
++ * Copyright (c) 2016 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
++
++#include <stdint.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 uint8_t OMX_U8;
++
++/** OMX_S8 is an 8 bit signed quantity that is byte aligned */
++typedef int8_t OMX_S8;
++
++/** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */
++typedef uint16_t OMX_U16;
++
++/** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */
++typedef int16_t OMX_S16;
++
++/** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */
++typedef uint32_t OMX_U32;
++
++/** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */
++typedef int32_t 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 uint64_t OMX_U64;
++
++/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
++typedef int64_t 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 */
+diff --git a/encoder/include/khronos/OMX_Video.h b/encoder/include/khronos/OMX_Video.h
+new file mode 100755
+index 0000000..6fa2626
+--- /dev/null
++++ b/encoder/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 */
++
+diff --git a/encoder/include/khronos/OMX_VideoExt.h b/encoder/include/khronos/OMX_VideoExt.h
+new file mode 100755
+index 0000000..2c02431
+--- /dev/null
++++ b/encoder/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 */
+diff --git a/encoder/mjpeg_encoder.cpp b/encoder/mjpeg_encoder.cpp
+index 52757ce..cf54f8f 100644
+--- a/encoder/mjpeg_encoder.cpp
++++ b/encoder/mjpeg_encoder.cpp
+@@ -45,6 +45,21 @@ void MjpegEncoder::EncodeBuffer(int fd, size_t size, void *mem, StreamInfo const
+ 	encode_cond_var_.notify_all();
+ }
+ 
++void NV12ToYUV420(const uint8_t *mem, uint8_t *dst, const StreamInfo &info);
++static uint8_t *getYUV420Format(const uint8_t *mem, const StreamInfo &info)
++{
++	uint32_t width = info.width;
++	uint32_t height = info.height;
++	int32_t buf_size = width * height + ((height * width) >> 1);
++	uint8_t *buffer = new uint8_t[buf_size];
++
++	if(!buffer)
++		throw std::runtime_error("fail to apply memory.");
++	NV12ToYUV420(mem, buffer, info);
++
++	return buffer;
++}
++
+ void MjpegEncoder::encodeJPEG(struct jpeg_compress_struct &cinfo, EncodeItem &item, uint8_t *&encoded_buffer,
+ 							  size_t &buffer_len)
+ {
+@@ -65,7 +80,8 @@ void MjpegEncoder::encodeJPEG(struct jpeg_compress_struct &cinfo, EncodeItem &it
+ 	jpeg_start_compress(&cinfo, TRUE);
+ 
+ 	int stride2 = item.info.stride / 2;
+-	uint8_t *Y = (uint8_t *)item.mem;
++	uint8_t *yuv420 = getYUV420Format((uint8_t *)item.mem, item.info);
++	uint8_t *Y = yuv420;
+ 	uint8_t *U = (uint8_t *)Y + item.info.stride * item.info.height;
+ 	uint8_t *V = (uint8_t *)U + stride2 * (item.info.height / 2);
+ 	uint8_t *Y_max = U - item.info.stride;
+@@ -89,6 +105,7 @@ void MjpegEncoder::encodeJPEG(struct jpeg_compress_struct &cinfo, EncodeItem &it
+ 
+ 	jpeg_finish_compress(&cinfo);
+ 	buffer_len = jpeg_mem_len;
++	delete[] yuv420;
+ }
+ 
+ void MjpegEncoder::encodeThread(int num)
+diff --git a/encoder/yuv420_encoder.cpp b/encoder/yuv420_encoder.cpp
+new file mode 100755
+index 0000000..cbfd276
+--- /dev/null
++++ b/encoder/yuv420_encoder.cpp
+@@ -0,0 +1,80 @@
++/* SPDX-License-Identifier: BSD-2-Clause */
++/*
++ * Copyright (C) 2023, Starfive Technology Co., Ltd.
++ *
++ * yuv420_encoder.cpp - yuv420 video encoder.
++ */
++
++#include <chrono>
++#include <iostream>
++#include <stdexcept>
++
++#include "yuv420_encoder.hpp"
++
++void NV12ToYUV420(const uint8_t *mem, uint8_t *dst, const StreamInfo &info);
++
++YUV420Encoder::YUV420Encoder(VideoOptions const *options) : Encoder(options), abort_(false)
++{
++	LOG(2, "Opened YUV420Encoder");
++	output_thread_ = std::thread(&YUV420Encoder::outputThread, this);
++}
++
++YUV420Encoder::~YUV420Encoder()
++{
++	abort_ = true;
++	output_thread_.join();
++	LOG(2, "YUV420Encoder closed");
++}
++
++// Push the buffer onto the output queue to be "encoded" and returned.
++void YUV420Encoder::EncodeBuffer(int fd, size_t size, void *mem, StreamInfo const &info, int64_t timestamp_us)
++{
++	if(!streamInfo_.width || !streamInfo_.height || !streamInfo_.stride)
++		streamInfo_ = info;
++	std::lock_guard<std::mutex> lock(output_mutex_);
++	OutputItem item = { mem, size, timestamp_us };
++	output_queue_.push(item);
++	output_cond_var_.notify_one();
++}
++
++// Realistically we would probably want more of a queue as the caller's number
++// of buffers limits the amount of queueing possible here...
++void YUV420Encoder::outputThread()
++{
++	OutputItem item;
++	while (true)
++	{
++		{
++			std::unique_lock<std::mutex> lock(output_mutex_);
++			while (true)
++			{
++				using namespace std::chrono_literals;
++				if (!output_queue_.empty())
++				{
++					item = output_queue_.front();
++					output_queue_.pop();
++					break;
++				}
++				else
++					output_cond_var_.wait_for(lock, 200ms);
++				if (abort_)
++					return;
++			}
++		}
++		// Ensure the input done callback happens before the output ready callback.
++		// This is needed as the metadata queue gets pushed in the former, and popped
++		// in the latter.
++		input_done_callback_(nullptr);
++
++		if(streamInfo_.width && streamInfo_.height && streamInfo_.stride)
++		{
++			uint8_t *yuv420 = new uint8_t[streamInfo_.width * streamInfo_.height + ((streamInfo_.height * streamInfo_.width) >> 1)];
++			if(!yuv420)
++				throw std::runtime_error("fail to apply memory.");
++			NV12ToYUV420((uint8_t *)(item.mem), yuv420, streamInfo_);
++			output_ready_callback_(yuv420, item.length, item.timestamp_us, true);
++			delete[] yuv420;
++		} else
++			output_ready_callback_(item.mem, item.length, item.timestamp_us, true);
++	}
++}
+diff --git a/encoder/yuv420_encoder.hpp b/encoder/yuv420_encoder.hpp
+new file mode 100755
+index 0000000..7f3c680
+--- /dev/null
++++ b/encoder/yuv420_encoder.hpp
+@@ -0,0 +1,41 @@
++/* SPDX-License-Identifier: BSD-2-Clause */
++/*
++ * Copyright (C) 2023, Starfive Technology Co., Ltd.
++ *
++ * yuv420_encoder.hpp - yuv420 video encoder.
++ */
++
++#pragma once
++
++#include <condition_variable>
++#include <mutex>
++#include <queue>
++#include <thread>
++
++#include "core/video_options.hpp"
++#include "encoder.hpp"
++
++class YUV420Encoder : public Encoder
++{
++public:
++	YUV420Encoder(VideoOptions const *options);
++	~YUV420Encoder();
++	void EncodeBuffer(int fd, size_t size, void *mem, StreamInfo const &info, int64_t timestamp_us) override;
++
++private:
++	StreamInfo streamInfo_;
++	void outputThread();
++
++	bool abort_;
++	VideoOptions options_;
++	struct OutputItem
++	{
++		void *mem;
++		size_t length;
++		int64_t timestamp_us;
++	};
++	std::queue<OutputItem> output_queue_;
++	std::mutex output_mutex_;
++	std::condition_variable output_cond_var_;
++	std::thread output_thread_;
++};
+-- 
+2.34.1
+

+ 0 - 153
package/starfive/libcamera-apps/0004-add-DrmPreview-support-NV12-display.patch

@@ -1,153 +0,0 @@
-From 30ce74f6cc34ddb310cee72280d9e1e00aa4e459 Mon Sep 17 00:00:00 2001
-From: sw.multimedia <sw.multimedia@starfivetech.com>
-Date: Thu, 25 Nov 2021 14:57:09 +0800
-Subject: [PATCH] add DrmPreview support NV12 display
-
----
- preview/drm_preview.cpp | 84 +++++++++++++++++++++++++++++++++++------
- 1 file changed, 73 insertions(+), 11 deletions(-)
-
-diff --git a/preview/drm_preview.cpp b/preview/drm_preview.cpp
-index c444918..a969358 100644
---- a/preview/drm_preview.cpp
-+++ b/preview/drm_preview.cpp
-@@ -10,6 +10,8 @@
- #include <drm_mode.h>
- #include <xf86drm.h>
- #include <xf86drmMode.h>
-+#include <fcntl.h>
-+#include <libcamera/formats.h>
- 
- #include "core/options.hpp"
- 
-@@ -50,6 +52,7 @@ private:
- 	void findPlane();
- 	int drmfd_;
- 	int conId_;
-+	drmModeConnector *con_;
- 	uint32_t crtcId_;
- 	int crtcIdx_;
- 	uint32_t planeId_;
-@@ -95,10 +98,19 @@ void DrmPreview::findCrtc()
- 			if (con->encoder_id)
- 			{
- 				enc = drmModeGetEncoder(drmfd_, con->encoder_id);
--				if (enc->crtc_id)
--				{
--					crtc = drmModeGetCrtc(drmfd_, enc->crtc_id);
--				}
-+			}
-+			else
-+			{
-+				enc = drmModeGetEncoder(drmfd_, con->encoders[0]);
-+			}
-+
-+			if (enc->crtc_id)
-+			{
-+				crtc = drmModeGetCrtc(drmfd_, enc->crtc_id);
-+			}
-+			else
-+			{
-+				crtc = drmModeGetCrtc(drmfd_, res->crtcs[0]);
- 			}
- 
- 			if (!conId_ && crtc)
-@@ -161,6 +173,8 @@ void DrmPreview::findCrtc()
- 		throw std::runtime_error("connector supports no mode");
- 	}
- 
-+	con_ = c;
-+
- 	if (options_->fullscreen || width_ == 0 || height_ == 0)
- 	{
- 		drmModeCrtc *crtc = drmModeGetCrtc(drmfd_, crtcId_);
-@@ -227,10 +241,13 @@ void DrmPreview::findPlane()
- 
- DrmPreview::DrmPreview(Options const *options) : Preview(options), last_fd_(-1)
- {
--	drmfd_ = drmOpen("vc4", NULL);
-+	// drmfd_ = drmOpen("vc4", NULL);
-+	drmfd_ = open("/dev/dri/card0", O_RDWR | O_CLOEXEC);
- 	if (drmfd_ < 0)
- 		throw std::runtime_error("drmOpen failed: " + std::string(ERRSTR));
- 
-+	drmSetClientCap(drmfd_, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
-+
- 	x_ = options_->preview_x;
- 	y_ = options_->preview_y;
- 	width_ = options_->preview_width;
-@@ -245,7 +262,12 @@ DrmPreview::DrmPreview(Options const *options) : Preview(options), last_fd_(-1)
- 
- 		conId_ = 0;
- 		findCrtc();
--		out_fourcc_ = DRM_FORMAT_YUV420;
-+		if (options_->pixelformat.length()) {
-+			libcamera::PixelFormat pixelFormat =
-+				libcamera::PixelFormat::fromString(options_->pixelformat);
-+			out_fourcc_ = pixelFormat.fourcc();
-+		} else
-+			out_fourcc_ = DRM_FORMAT_YUV420;
- 		findPlane();
- 	}
- 	catch (std::exception const &e)
-@@ -281,12 +303,52 @@ void DrmPreview::makeBuffer(int fd, size_t size, unsigned int width, unsigned in
- 	if (drmPrimeFDToHandle(drmfd_, fd, &buffer.bo_handle))
- 		throw std::runtime_error("drmPrimeFDToHandle failed for fd " + std::to_string(fd));
- 
--	uint32_t offsets[4] = { 0, stride * height, stride * height + (stride / 2) * (height / 2) };
--	uint32_t pitches[4] = { stride, stride / 2, stride / 2 };
--	uint32_t bo_handles[4] = { buffer.bo_handle, buffer.bo_handle, buffer.bo_handle };
--
--	if (drmModeAddFB2(drmfd_, width, height, out_fourcc_, bo_handles, pitches, offsets, &buffer.fb_handle, 0))
-+	if (out_fourcc_ == DRM_FORMAT_YUV420) {
-+		uint32_t offsets[4] = { 0, stride * height, stride * height + (stride / 2) * (height / 2) };
-+		uint32_t pitches[4] = { stride, stride / 2, stride / 2 };
-+		uint32_t bo_handles[4] = { buffer.bo_handle, buffer.bo_handle, buffer.bo_handle };
-+
-+		if (drmModeAddFB2(drmfd_, width, height, out_fourcc_, bo_handles, pitches, offsets, &buffer.fb_handle, 0))
-+			throw std::runtime_error("YUV420 drmModeAddFB2 failed: " + std::string(ERRSTR));
-+	} else if (out_fourcc_ == DRM_FORMAT_NV12 || out_fourcc_ == DRM_FORMAT_NV21) {
-+		uint32_t offsets[4] = { 0, stride * height};
-+		uint32_t pitches[4] = { stride, stride};
-+		uint32_t bo_handles[4] = { buffer.bo_handle, buffer.bo_handle};
-+
-+		if (drmModeAddFB2(drmfd_, width, height, out_fourcc_, bo_handles, pitches, offsets, &buffer.fb_handle, 0))
-+			throw std::runtime_error("NV12/21 drmModeAddFB2 failed: " + std::string(ERRSTR));
-+	} else
- 		throw std::runtime_error("drmModeAddFB2 failed: " + std::string(ERRSTR));
-+
-+	/* find preferred mode */
-+	drmModeModeInfo *modeptr = NULL, *preferred = NULL;
-+	for (int m = 0; m < con_->count_modes; m++) {
-+		modeptr = &con_->modes[m];
-+		if (modeptr->hdisplay == width && modeptr->vdisplay == height) {
-+			preferred = modeptr;
-+			std::cout << "find the matched mode, modes index= "
-+				<< m << ", " << width << "x" << height << std::endl;
-+			break;
-+		}
-+		if (modeptr->type & DRM_MODE_TYPE_PREFERRED) {
-+			preferred = modeptr;
-+			std::cout << "find perferred mode, modes index= " << m << std::endl;
-+		}
-+	}
-+
-+	if (!preferred)
-+		preferred = &con_->modes[0];
-+
-+	// set default
-+	if (drmModeSetCrtc(drmfd_, crtcId_, buffer.fb_handle, 0, 0,
-+	        (uint32_t *)&conId_, 1, preferred)) {
-+		throw std::runtime_error("drmModeSetCrtc() failed");
-+	}
-+
-+	screen_width_ = preferred->hdisplay;
-+	screen_height_ = preferred->vdisplay;
-+	width_ = width;
-+	height_ = height;
- }
- 
- void DrmPreview::Show(int fd, libcamera::Span<uint8_t> span, int width, int height, int stride)
--- 
-2.17.1
-

+ 0 - 28
package/starfive/libcamera-apps/0005-libcamera-apps-Open-drm-device-by-module-name-starfi.patch

@@ -1,28 +0,0 @@
-From 5021e32ddc68459c1d96a5ddb8c4225e82023130 Mon Sep 17 00:00:00 2001
-From: "Kevin.xie" <kevin.xie@starfivetech.com>
-Date: Thu, 4 Aug 2022 13:55:56 +0800
-Subject: [PATCH] libcamera-apps: Open drm device by module name 'starfive'
-
-Signed-off-by: Kevin.xie <kevin.xie@starfivetech.com>
----
- preview/drm_preview.cpp | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/preview/drm_preview.cpp b/preview/drm_preview.cpp
-index a969358..df6bfb5 100644
---- a/preview/drm_preview.cpp
-+++ b/preview/drm_preview.cpp
-@@ -241,8 +241,8 @@ void DrmPreview::findPlane()
- 
- DrmPreview::DrmPreview(Options const *options) : Preview(options), last_fd_(-1)
- {
--	// drmfd_ = drmOpen("vc4", NULL);
--	drmfd_ = open("/dev/dri/card0", O_RDWR | O_CLOEXEC);
-+	drmfd_ = drmOpen("starfive", NULL);
-+	// drmfd_ = open("/dev/dri/card0", O_RDWR | O_CLOEXEC);
- 	if (drmfd_ < 0)
- 		throw std::runtime_error("drmOpen failed: " + std::string(ERRSTR));
- 
--- 
-2.17.1
-

+ 1 - 3
package/starfive/libcamera-apps/libcamera-apps.hash

@@ -1,3 +1 @@
-sha256  5600c4289457c03a5062001f5942c77fabe4fcef8877b67cfaeed5bae5672756  libcamera-apps-main.tar.gz
-sha256  3fe6e9e343f268c518652a00260791c55f18cd5902fd5de578005b9c6ec9785b  libcamera-apps-87f807f4eacf7d62021e3b4061348e64b2ecadc3.tar.gz
-sha256  09a169037dfba889bc9f449aaefc18c210fdf4eb7ea02cffd4a36c383b71583c  libcamera-apps-87f807f4eacf7d62021e3b4061348e64b2ecadc3-br1.tar.gz
+sha256  add2d80450f3b61de275c6505689b0984d29c9dde94f0cf381c4209620c96263  libcamera-apps-54a781dffdd101954dcfa6acd0bd80006f67da83-br1.tar.gz

+ 2 - 2
package/starfive/libcamera-apps/libcamera-apps.mk

@@ -5,10 +5,10 @@
 ################################################################################
 
 LIBCAMERA_APPS_SITE = https://github.com/raspberrypi/libcamera-apps.git
-LIBCAMERA_APPS_VERSION = 87f807f4eacf7d62021e3b4061348e64b2ecadc3
+LIBCAMERA_APPS_VERSION = 54a781dffdd101954dcfa6acd0bd80006f67da83
 LIBCAMERA_APPS_SITE_METHOD = git
 LIBCAMERA_APPS_INSTALL_STAGING = YES
 
-LIBCAMERA_APPS_DEPENDENCIES = libcamera libexif tiff boost host-pkgconf
+LIBCAMERA_APPS_DEPENDENCIES = libcamera libexif tiff boost host-pkgconf jpeg libpng sf-omx-il
 
 $(eval $(cmake-package))