Merge "MediaPlayer2: call close when reset"
diff --git a/camera/ndk/include/camera/NdkCameraDevice.h b/camera/ndk/include/camera/NdkCameraDevice.h
index 61deb46..c0eb5c1 100644
--- a/camera/ndk/include/camera/NdkCameraDevice.h
+++ b/camera/ndk/include/camera/NdkCameraDevice.h
@@ -251,6 +251,36 @@
      * @see ACameraDevice_createCaptureRequest
      */
     TEMPLATE_MANUAL = 6,
+
+    /**
+     * A template for selecting camera parameters that match TEMPLATE_PREVIEW as closely as
+     * possible while improving the camera output for motion tracking use cases.
+     *
+     * <p>This template is best used by applications that are frequently switching between motion
+     * tracking use cases and regular still capture use cases, to minimize the IQ changes
+     * when swapping use cases.</p>
+     *
+     * <p>This template is guaranteed to be supported on camera devices that support the
+     * {@link ACAMERA_REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING} capability.</p>
+     *
+     * @see ACameraDevice_createCaptureRequest
+     */
+    TEMPLATE_MOTION_TRACKING_PREVIEW = 7,
+
+    /**
+     * A template for selecting camera parameters that maximize the quality of camera output for
+     * motion tracking use cases.
+     *
+     * <p>This template is best used by applications dedicated to motion tracking applications,
+     * which aren't concerned about fast switches between motion tracking and other use cases.</p>
+     *
+     * <p>This template is guaranteed to be supported on camera devices that support the
+     * {@link ACAMERA_REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING} capability.</p>
+     *
+     * @see ACameraDevice_createCaptureRequest
+     */
+    TEMPLATE_MOTION_TRACKING_BEST = 8,
+
 } ACameraDevice_request_template;
 
 /**
@@ -760,4 +790,3 @@
 #endif /* _NDK_CAMERA_DEVICE_H */
 
 /** @} */
-
diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h
index 80d460f..2c144b7 100644
--- a/camera/ndk/include/camera/NdkCameraMetadataTags.h
+++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h
@@ -837,10 +837,13 @@
      *
      * <p>This control (except for MANUAL) is only effective if
      * <code>ACAMERA_CONTROL_MODE != OFF</code> and any 3A routine is active.</p>
-     * <p>ZERO_SHUTTER_LAG will be supported if ACAMERA_REQUEST_AVAILABLE_CAPABILITIES
-     * contains PRIVATE_REPROCESSING or YUV_REPROCESSING. MANUAL will be supported if
-     * ACAMERA_REQUEST_AVAILABLE_CAPABILITIES contains MANUAL_SENSOR. Other intent values are
-     * always supported.</p>
+     * <p>All intents are supported by all devices, except that:
+     *   * ZERO_SHUTTER_LAG will be supported if ACAMERA_REQUEST_AVAILABLE_CAPABILITIES contains
+     * PRIVATE_REPROCESSING or YUV_REPROCESSING.
+     *   * MANUAL will be supported if ACAMERA_REQUEST_AVAILABLE_CAPABILITIES contains
+     * MANUAL_SENSOR.
+     *   * MOTION_TRACKING will be supported if ACAMERA_REQUEST_AVAILABLE_CAPABILITIES contains
+     * MOTION_TRACKING.</p>
      *
      * @see ACAMERA_CONTROL_MODE
      * @see ACAMERA_REQUEST_AVAILABLE_CAPABILITIES
@@ -2235,34 +2238,31 @@
      * </ul></p>
      *
      * <p>The position of the camera device's lens optical center,
-     * as a three-dimensional vector <code>(x,y,z)</code>, relative to the
-     * optical center of the largest camera device facing in the
-     * same direction as this camera, in the <a href="https://developer.android.com/reference/android/hardware/SensorEvent.html">Android sensor coordinate
-     * axes</a>. Note that only the axis definitions are shared with
-     * the sensor coordinate system, but not the origin.</p>
-     * <p>If this device is the largest or only camera device with a
-     * given facing, then this position will be <code>(0, 0, 0)</code>; a
-     * camera device with a lens optical center located 3 cm from
-     * the main sensor along the +X axis (to the right from the
-     * user's perspective) will report <code>(0.03, 0, 0)</code>.</p>
-     * <p>To transform a pixel coordinates between two cameras
-     * facing the same direction, first the source camera
-     * ACAMERA_LENS_RADIAL_DISTORTION must be corrected for.  Then
-     * the source camera ACAMERA_LENS_INTRINSIC_CALIBRATION needs
-     * to be applied, followed by the ACAMERA_LENS_POSE_ROTATION
-     * of the source camera, the translation of the source camera
-     * relative to the destination camera, the
-     * ACAMERA_LENS_POSE_ROTATION of the destination camera, and
-     * finally the inverse of ACAMERA_LENS_INTRINSIC_CALIBRATION
-     * of the destination camera. This obtains a
-     * radial-distortion-free coordinate in the destination
-     * camera pixel coordinates.</p>
-     * <p>To compare this against a real image from the destination
-     * camera, the destination camera image then needs to be
-     * corrected for radial distortion before comparison or
-     * sampling.</p>
+     * as a three-dimensional vector <code>(x,y,z)</code>.</p>
+     * <p>Prior to Android P, or when ACAMERA_LENS_POSE_REFERENCE is PRIMARY_CAMERA, this position
+     * is relative to the optical center of the largest camera device facing in the same
+     * direction as this camera, in the <a href="https://developer.android.com/reference/android/hardware/SensorEvent.html">Android sensor
+     * coordinate axes</a>. Note that only the axis definitions are shared with the sensor
+     * coordinate system, but not the origin.</p>
+     * <p>If this device is the largest or only camera device with a given facing, then this
+     * position will be <code>(0, 0, 0)</code>; a camera device with a lens optical center located 3 cm
+     * from the main sensor along the +X axis (to the right from the user's perspective) will
+     * report <code>(0.03, 0, 0)</code>.</p>
+     * <p>To transform a pixel coordinates between two cameras facing the same direction, first
+     * the source camera ACAMERA_LENS_RADIAL_DISTORTION must be corrected for.  Then the source
+     * camera ACAMERA_LENS_INTRINSIC_CALIBRATION needs to be applied, followed by the
+     * ACAMERA_LENS_POSE_ROTATION of the source camera, the translation of the source camera
+     * relative to the destination camera, the ACAMERA_LENS_POSE_ROTATION of the destination
+     * camera, and finally the inverse of ACAMERA_LENS_INTRINSIC_CALIBRATION of the destination
+     * camera. This obtains a radial-distortion-free coordinate in the destination camera pixel
+     * coordinates.</p>
+     * <p>To compare this against a real image from the destination camera, the destination camera
+     * image then needs to be corrected for radial distortion before comparison or sampling.</p>
+     * <p>When ACAMERA_LENS_POSE_REFERENCE is GYROSCOPE, then this position is relative to
+     * the center of the primary gyroscope on the device.</p>
      *
      * @see ACAMERA_LENS_INTRINSIC_CALIBRATION
+     * @see ACAMERA_LENS_POSE_REFERENCE
      * @see ACAMERA_LENS_POSE_ROTATION
      * @see ACAMERA_LENS_RADIAL_DISTORTION
      */
@@ -2433,6 +2433,26 @@
      */
     ACAMERA_LENS_RADIAL_DISTORTION =                            // float[6]
             ACAMERA_LENS_START + 11,
+    /**
+     * <p>The origin for ACAMERA_LENS_POSE_TRANSLATION.</p>
+     *
+     * @see ACAMERA_LENS_POSE_TRANSLATION
+     *
+     * <p>Type: byte (acamera_metadata_enum_android_lens_pose_reference_t)</p>
+     *
+     * <p>This tag may appear in:
+     * <ul>
+     *   <li>ACameraMetadata from ACameraManager_getCameraCharacteristics</li>
+     * </ul></p>
+     *
+     * <p>Different calibration methods and use cases can produce better or worse results
+     * depending on the selected coordinate origin.</p>
+     * <p>For devices designed to support the MOTION_TRACKING capability, the GYROSCOPE origin
+     * makes device calibration and later usage by applications combining camera and gyroscope
+     * information together simpler.</p>
+     */
+    ACAMERA_LENS_POSE_REFERENCE =                               // byte (acamera_metadata_enum_android_lens_pose_reference_t)
+            ACAMERA_LENS_START + 12,
     ACAMERA_LENS_END,
 
     /**
@@ -2895,7 +2915,7 @@
      * time-consuming hardware re-configuration or internal camera pipeline
      * change. For performance reasons we advise clients to pass their initial
      * values as part of
-     * {@link ACameraDevice_createCaptureSessionWithSessionParameters }.i
+     * {@link ACameraDevice_createCaptureSessionWithSessionParameters }.
      * Once the camera capture session is enabled it is also recommended to avoid
      * changing them from their initial values set in
      * {@link ACameraDevice_createCaptureSessionWithSessionParameters }.
@@ -4908,6 +4928,23 @@
      */
     ACAMERA_INFO_SUPPORTED_HARDWARE_LEVEL =                     // byte (acamera_metadata_enum_android_info_supported_hardware_level_t)
             ACAMERA_INFO_START,
+    /**
+     * <p>A short string for manufacturer version information about the camera device, such as
+     * ISP hardware, sensors, etc.</p>
+     *
+     * <p>Type: byte</p>
+     *
+     * <p>This tag may appear in:
+     * <ul>
+     *   <li>ACameraMetadata from ACameraManager_getCameraCharacteristics</li>
+     * </ul></p>
+     *
+     * <p>This can be used in <a href="https://developer.android.com/reference/android/media/ExifInterface.html#TAG_IMAGE_DESCRIPTION">TAG_IMAGE_DESCRIPTION</a>
+     * in jpeg EXIF. This key may be absent if no version information is available on the
+     * device.</p>
+     */
+    ACAMERA_INFO_VERSION =                                      // byte
+            ACAMERA_INFO_START + 1,
     ACAMERA_INFO_END,
 
     /**
@@ -5700,6 +5737,15 @@
      */
     ACAMERA_CONTROL_CAPTURE_INTENT_MANUAL                            = 6,
 
+    /**
+     * <p>This request is for a motion tracking use case, where
+     * the application will use camera and inertial sensor data to
+     * locate and track objects in the world.</p>
+     * <p>The camera device auto-exposure routine will limit the exposure time
+     * of the camera to no more than 20 milliseconds, to minimize motion blur.</p>
+     */
+    ACAMERA_CONTROL_CAPTURE_INTENT_MOTION_TRACKING                   = 7,
+
 } acamera_metadata_enum_android_control_capture_intent_t;
 
 // ACAMERA_CONTROL_EFFECT_MODE
@@ -6411,6 +6457,28 @@
 
 } acamera_metadata_enum_android_lens_state_t;
 
+// ACAMERA_LENS_POSE_REFERENCE
+typedef enum acamera_metadata_enum_acamera_lens_pose_reference {
+    /**
+     * <p>The value of ACAMERA_LENS_POSE_TRANSLATION is relative to the optical center of
+     * the largest camera device facing the same direction as this camera.</p>
+     * <p>This default value for API levels before Android P.</p>
+     *
+     * @see ACAMERA_LENS_POSE_TRANSLATION
+     */
+    ACAMERA_LENS_POSE_REFERENCE_PRIMARY_CAMERA                       = 0,
+
+    /**
+     * <p>The value of ACAMERA_LENS_POSE_TRANSLATION is relative to the position of the
+     * primary gyroscope of this Android device.</p>
+     * <p>This is the value reported by all devices that support the MOTION_TRACKING capability.</p>
+     *
+     * @see ACAMERA_LENS_POSE_TRANSLATION
+     */
+    ACAMERA_LENS_POSE_REFERENCE_GYROSCOPE                            = 1,
+
+} acamera_metadata_enum_android_lens_pose_reference_t;
+
 
 // ACAMERA_LENS_INFO_FOCUS_DISTANCE_CALIBRATION
 typedef enum acamera_metadata_enum_acamera_lens_info_focus_distance_calibration {
@@ -6743,6 +6811,7 @@
      * </ul>
      * </li>
      * <li>The ACAMERA_DEPTH_DEPTH_IS_EXCLUSIVE entry is listed by this device.</li>
+     * <li>As of Android P, the ACAMERA_LENS_POSE_REFERENCE entry is listed by this device.</li>
      * <li>A LIMITED camera with only the DEPTH_OUTPUT capability does not have to support
      *   normal YUV_420_888, JPEG, and PRIV-format outputs. It only has to support the DEPTH16
      *   format.</li>
@@ -6758,12 +6827,57 @@
      * @see ACAMERA_DEPTH_DEPTH_IS_EXCLUSIVE
      * @see ACAMERA_LENS_FACING
      * @see ACAMERA_LENS_INTRINSIC_CALIBRATION
+     * @see ACAMERA_LENS_POSE_REFERENCE
      * @see ACAMERA_LENS_POSE_ROTATION
      * @see ACAMERA_LENS_POSE_TRANSLATION
      * @see ACAMERA_LENS_RADIAL_DISTORTION
      */
     ACAMERA_REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT              = 8,
 
+    /**
+     * <p>The device supports controls and metadata required for accurate motion tracking for
+     * use cases such as augmented reality, electronic image stabilization, and so on.</p>
+     * <p>This means this camera device has accurate optical calibration and timestamps relative
+     * to the inertial sensors.</p>
+     * <p>This capability requires the camera device to support the following:</p>
+     * <ul>
+     * <li>Capture request templates <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#TEMPLATE_MOTION_TRACKING_PREVIEW">CameraDevice#TEMPLATE_MOTION_TRACKING_PREVIEW</a> and <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#TEMPLATE_MOTION_TRACKING_BEST">CameraDevice#TEMPLATE_MOTION_TRACKING_BEST</a> are defined.</li>
+     * <li>The stream configurations listed in <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession">CameraDevice#createCaptureSession</a> for MOTION_TRACKING are
+     *   supported, either at 30 or 60fps maximum frame rate.</li>
+     * <li>The following camera characteristics and capture result metadata are provided:<ul>
+     * <li>ACAMERA_LENS_INTRINSIC_CALIBRATION</li>
+     * <li>ACAMERA_LENS_RADIAL_DISTORTION</li>
+     * <li>ACAMERA_LENS_POSE_ROTATION</li>
+     * <li>ACAMERA_LENS_POSE_TRANSLATION</li>
+     * <li>ACAMERA_LENS_POSE_REFERENCE with value GYROSCOPE</li>
+     * </ul>
+     * </li>
+     * <li>The ACAMERA_SENSOR_INFO_TIMESTAMP_SOURCE field has value <code>REALTIME</code>. When compared to
+     *   timestamps from the device's gyroscopes, the clock difference for events occuring at
+     *   the same actual time instant will be less than 1 ms.</li>
+     * <li>The value of the ACAMERA_SENSOR_ROLLING_SHUTTER_SKEW field is accurate to within 1 ms.</li>
+     * <li>The value of ACAMERA_SENSOR_EXPOSURE_TIME is guaranteed to be available in the
+     *   capture result.</li>
+     * <li>The ACAMERA_CONTROL_CAPTURE_INTENT control supports MOTION_TRACKING to limit maximum
+     *   exposure to 20 milliseconds.</li>
+     * <li>The stream configurations required for MOTION_TRACKING (listed at <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession">CameraDevice#createCaptureSession</a>) can operate at least at
+     *   30fps; optionally, they can operate at 60fps, and '[60, 60]' is listed in
+     *   ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES.</li>
+     * </ul>
+     *
+     * @see ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
+     * @see ACAMERA_CONTROL_CAPTURE_INTENT
+     * @see ACAMERA_LENS_INTRINSIC_CALIBRATION
+     * @see ACAMERA_LENS_POSE_REFERENCE
+     * @see ACAMERA_LENS_POSE_ROTATION
+     * @see ACAMERA_LENS_POSE_TRANSLATION
+     * @see ACAMERA_LENS_RADIAL_DISTORTION
+     * @see ACAMERA_SENSOR_EXPOSURE_TIME
+     * @see ACAMERA_SENSOR_INFO_TIMESTAMP_SOURCE
+     * @see ACAMERA_SENSOR_ROLLING_SHUTTER_SKEW
+     */
+    ACAMERA_REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING           = 10,
+
 } acamera_metadata_enum_android_request_available_capabilities_t;
 
 
diff --git a/drm/mediadrm/plugins/clearkey/DrmPlugin.cpp b/drm/mediadrm/plugins/clearkey/DrmPlugin.cpp
index 7c43994..944002d 100644
--- a/drm/mediadrm/plugins/clearkey/DrmPlugin.cpp
+++ b/drm/mediadrm/plugins/clearkey/DrmPlugin.cpp
@@ -142,25 +142,24 @@
     ssize_t index = mByteArrayProperties.indexOfKey(name);
     if (index < 0) {
         ALOGE("App requested unknown property: %s", name.string());
-        return android::BAD_VALUE;
+        return android::ERROR_DRM_CANNOT_HANDLE;
     }
     value = mByteArrayProperties.valueAt(index);
     return android::OK;
 }
 
 status_t DrmPlugin::setPropertyByteArray(
-        const String8& name, const Vector<uint8_t>& value) {
+        const String8& name, const Vector<uint8_t>& value)
+{
+    UNUSED(value);
     if (0 == name.compare(kDeviceIdKey)) {
         ALOGD("Cannot set immutable property: %s", name.string());
-        return android::BAD_VALUE;
+        return android::ERROR_DRM_CANNOT_HANDLE;
     }
 
-    ssize_t status = mByteArrayProperties.replaceValueFor(name, value);
-    if (status >= 0) {
-        return android::OK;
-    }
+    // Setting of undefined properties is not supported
     ALOGE("Failed to set property byte array, key=%s", name.string());
-    return android::BAD_VALUE;
+    return android::ERROR_DRM_CANNOT_HANDLE;
 }
 
 status_t DrmPlugin::getPropertyString(
@@ -168,7 +167,7 @@
     ssize_t index = mStringProperties.indexOfKey(name);
     if (index < 0) {
         ALOGE("App requested unknown property: %s", name.string());
-        return android::BAD_VALUE;
+        return android::ERROR_DRM_CANNOT_HANDLE;
     }
     value = mStringProperties.valueAt(index);
     return android::OK;
@@ -182,12 +181,18 @@
             kVendorKey.string(), kVersionKey.string());
     if (immutableKeys.contains(name.string())) {
         ALOGD("Cannot set immutable property: %s", name.string());
-        return android::BAD_VALUE;
+        return android::ERROR_DRM_CANNOT_HANDLE;
+    }
+
+    ssize_t index = mStringProperties.indexOfKey(name);
+    if (index < 0) {
+        ALOGE("Cannot set undefined property string, key=%s", name.string());
+        return android::ERROR_DRM_CANNOT_HANDLE;
     }
 
     if (mStringProperties.add(name, value) < 0) {
         ALOGE("Failed to set property string, key=%s", name.string());
-        return android::BAD_VALUE;
+        return android::ERROR_DRM_UNKNOWN;
     }
     return android::OK;
 }
diff --git a/media/extractors/mp4/MPEG4Extractor.cpp b/media/extractors/mp4/MPEG4Extractor.cpp
index 8823c79..938bd5d 100644
--- a/media/extractors/mp4/MPEG4Extractor.cpp
+++ b/media/extractors/mp4/MPEG4Extractor.cpp
@@ -5375,11 +5375,6 @@
     return NULL;
 }
 
-void MPEG4Extractor::populateMetrics() {
-    ALOGV("MPEG4Extractor::populateMetrics");
-    // write into mAnalyticsItem
-}
-
 static bool LegacySniffMPEG4(
         const sp<DataSource> &source, String8 *mimeType, float *confidence) {
     uint8_t header[8];
diff --git a/media/extractors/mp4/MPEG4Extractor.h b/media/extractors/mp4/MPEG4Extractor.h
index 76b549d..8bfecaa 100644
--- a/media/extractors/mp4/MPEG4Extractor.h
+++ b/media/extractors/mp4/MPEG4Extractor.h
@@ -69,8 +69,6 @@
 protected:
     virtual ~MPEG4Extractor();
 
-    virtual void populateMetrics();
-
 private:
 
     struct PsshInfo {
diff --git a/media/libaaudio/examples/loopback/Android.bp b/media/libaaudio/examples/loopback/Android.bp
index fa8fdc9..5b7d956 100644
--- a/media/libaaudio/examples/loopback/Android.bp
+++ b/media/libaaudio/examples/loopback/Android.bp
@@ -3,6 +3,10 @@
     gtest: false,
     srcs: ["src/loopback.cpp"],
     cflags: ["-Wall", "-Werror"],
-    shared_libs: ["libaaudio"],
+    static_libs: ["libsndfile"],
+    shared_libs: [
+        "libaaudio",
+        "libaudioutils",
+        ],
     header_libs: ["libaaudio_example_utils"],
 }
diff --git a/media/libaaudio/examples/loopback/jni/Android.mk b/media/libaaudio/examples/loopback/jni/Android.mk
index 1fe3def..aebe877 100644
--- a/media/libaaudio/examples/loopback/jni/Android.mk
+++ b/media/libaaudio/examples/loopback/jni/Android.mk
@@ -10,6 +10,7 @@
 # NDK recommends using this kind of relative path instead of an absolute path.
 LOCAL_SRC_FILES:= ../src/loopback.cpp
 LOCAL_CFLAGS := -Wall -Werror
-LOCAL_SHARED_LIBRARIES := libaaudio
+LOCAL_STATIC_LIBRARIES := libsndfile
+LOCAL_SHARED_LIBRARIES := libaaudio libaudioutils
 LOCAL_MODULE := aaudio_loopback
 include $(BUILD_EXECUTABLE)
diff --git a/media/libaaudio/examples/loopback/src/LoopbackAnalyzer.h b/media/libaaudio/examples/loopback/src/LoopbackAnalyzer.h
index 276b45f..b83851a 100644
--- a/media/libaaudio/examples/loopback/src/LoopbackAnalyzer.h
+++ b/media/libaaudio/examples/loopback/src/LoopbackAnalyzer.h
@@ -30,6 +30,8 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <audio_utils/sndfile.h>
+
 // Tag for machine readable results as property = value pairs
 #define LOOPBACK_RESULT_TAG      "RESULT: "
 #define LOOPBACK_SAMPLE_RATE     48000
@@ -37,6 +39,7 @@
 #define MILLIS_PER_SECOND        1000
 
 #define MAX_ZEROTH_PARTIAL_BINS  40
+constexpr double MAX_ECHO_GAIN = 10.0; // based on experiments, otherwise autocorrelation too noisy
 
 static const float s_Impulse[] = {
         0.0f, 0.0f, 0.0f, 0.0f, 0.2f, // silence on each side of the impulse
@@ -156,6 +159,8 @@
                             const float *needle, int needleSize,
                             LatencyReport *report) {
     const double threshold = 0.1;
+    printf("measureLatencyFromEchos: haystackSize = %d, needleSize = %d\n",
+           haystackSize, needleSize);
 
     // Find first peak
     int first = (int) (findFirstMatch(haystack,
@@ -173,7 +178,7 @@
                                       needleSize,
                                       threshold) + 0.5);
 
-    printf("first = %d, again at %d\n", first, again);
+    printf("measureLatencyFromEchos: first = %d, again at %d\n", first, again);
     first = again;
 
     // Allocate results array
@@ -270,37 +275,60 @@
         return mData;
     }
 
+    void setSampleRate(int32_t sampleRate) {
+        mSampleRate = sampleRate;
+    }
+
+    int32_t getSampleRate() {
+        return mSampleRate;
+    }
+
     int save(const char *fileName, bool writeShorts = true) {
+        SNDFILE *sndFile = nullptr;
         int written = 0;
-        const int chunkSize = 64;
-        FILE *fid = fopen(fileName, "wb");
-        if (fid == NULL) {
+        SF_INFO info = {
+                .frames = mFrameCounter,
+                .samplerate = mSampleRate,
+                .channels = 1,
+                .format = SF_FORMAT_WAV | (writeShorts ? SF_FORMAT_PCM_16 : SF_FORMAT_FLOAT)
+        };
+
+        sndFile = sf_open(fileName, SFM_WRITE, &info);
+        if (sndFile == nullptr) {
+            printf("AudioRecording::save(%s) failed to open file\n", fileName);
             return -errno;
         }
 
-        if (writeShorts) {
-            int16_t buffer[chunkSize];
-            int32_t framesLeft = mFrameCounter;
-            int32_t cursor = 0;
-            while (framesLeft) {
-                int32_t framesToWrite = framesLeft < chunkSize ? framesLeft : chunkSize;
-                for (int i = 0; i < framesToWrite; i++) {
-                    buffer[i] = (int16_t) (mData[cursor++] * 32767);
-                }
-                written += fwrite(buffer, sizeof(int16_t), framesToWrite, fid);
-                framesLeft -= framesToWrite;
-            }
-        } else {
-            written = (int) fwrite(mData, sizeof(float), mFrameCounter, fid);
-        }
-        fclose(fid);
+        written = sf_writef_float(sndFile, mData, mFrameCounter);
+
+        sf_close(sndFile);
         return written;
     }
 
+    int load(const char *fileName) {
+        SNDFILE *sndFile = nullptr;
+        SF_INFO info;
+
+        sndFile = sf_open(fileName, SFM_READ, &info);
+        if (sndFile == nullptr) {
+            printf("AudioRecording::load(%s) failed to open file\n", fileName);
+            return -errno;
+        }
+
+        assert(info.channels == 1);
+
+        allocate(info.frames);
+        mFrameCounter = sf_readf_float(sndFile, mData, info.frames);
+
+        sf_close(sndFile);
+        return mFrameCounter;
+    }
+
 private:
     float  *mData = nullptr;
     int32_t mFrameCounter = 0;
     int32_t mMaxFrames = 0;
+    int32_t mSampleRate = 48000; // common default
 };
 
 // ====================================================================================
@@ -320,11 +348,25 @@
 
     virtual void printStatus() {};
 
+    virtual int getResult() {
+        return -1;
+    }
+
     virtual bool isDone() {
         return false;
     }
 
-    void setSampleRate(int32_t sampleRate) {
+    virtual int save(const char *fileName) {
+        (void) fileName;
+        return AAUDIO_ERROR_UNIMPLEMENTED;
+    }
+
+    virtual int load(const char *fileName) {
+        (void) fileName;
+        return AAUDIO_ERROR_UNIMPLEMENTED;
+    }
+
+    virtual void setSampleRate(int32_t sampleRate) {
         mSampleRate = sampleRate;
     }
 
@@ -395,7 +437,13 @@
 public:
 
     EchoAnalyzer() : LoopbackProcessor() {
-        audioRecorder.allocate(2 * LOOPBACK_SAMPLE_RATE);
+        mAudioRecording.allocate(2 * getSampleRate());
+        mAudioRecording.setSampleRate(getSampleRate());
+    }
+
+    void setSampleRate(int32_t sampleRate) override {
+        LoopbackProcessor::setSampleRate(sampleRate);
+        mAudioRecording.setSampleRate(sampleRate);
     }
 
     void reset() override {
@@ -406,8 +454,12 @@
         mState = STATE_INITIAL_SILENCE;
     }
 
+    virtual int getResult() {
+        return mState == STATE_DONE ? 0 : -1;
+    }
+
     virtual bool isDone() {
-        return mState == STATE_DONE;
+        return mState == STATE_DONE || mState == STATE_FAILED;
     }
 
     void setGain(float gain) {
@@ -423,31 +475,24 @@
         printf("EchoAnalyzer ---------------\n");
         printf(LOOPBACK_RESULT_TAG "measured.gain          = %f\n", mMeasuredLoopGain);
         printf(LOOPBACK_RESULT_TAG "echo.gain              = %f\n", mEchoGain);
-        printf(LOOPBACK_RESULT_TAG "frame.count            = %d\n", mFrameCounter);
         printf(LOOPBACK_RESULT_TAG "test.state             = %d\n", mState);
         if (mMeasuredLoopGain >= 0.9999) {
             printf("   ERROR - clipping, turn down volume slightly\n");
         } else {
             const float *needle = s_Impulse;
             int needleSize = (int) (sizeof(s_Impulse) / sizeof(float));
-            float *haystack = audioRecorder.getData();
-            int haystackSize = audioRecorder.size();
-            measureLatencyFromEchos(haystack, haystackSize, needle, needleSize, &latencyReport);
-            if (latencyReport.confidence < 0.01) {
-                printf("   ERROR - confidence too low = %f\n", latencyReport.confidence);
+            float *haystack = mAudioRecording.getData();
+            int haystackSize = mAudioRecording.size();
+            measureLatencyFromEchos(haystack, haystackSize, needle, needleSize, &mLatencyReport);
+            if (mLatencyReport.confidence < 0.01) {
+                printf("   ERROR - confidence too low = %f\n", mLatencyReport.confidence);
             } else {
-                double latencyMillis = 1000.0 * latencyReport.latencyInFrames / getSampleRate();
-                printf(LOOPBACK_RESULT_TAG "latency.frames        = %8.2f\n", latencyReport.latencyInFrames);
+                double latencyMillis = 1000.0 * mLatencyReport.latencyInFrames / getSampleRate();
+                printf(LOOPBACK_RESULT_TAG "latency.frames        = %8.2f\n", mLatencyReport.latencyInFrames);
                 printf(LOOPBACK_RESULT_TAG "latency.msec          = %8.2f\n", latencyMillis);
-                printf(LOOPBACK_RESULT_TAG "latency.confidence    = %8.6f\n", latencyReport.confidence);
+                printf(LOOPBACK_RESULT_TAG "latency.confidence    = %8.6f\n", mLatencyReport.confidence);
             }
         }
-
-        {
-#define ECHO_FILENAME "/data/oboe_echo.raw"
-            int written = audioRecorder.save(ECHO_FILENAME);
-            printf("Echo wrote %d mono samples to %s on Android device\n", written, ECHO_FILENAME);
-        }
     }
 
     void printStatus() override {
@@ -491,13 +536,18 @@
                 // If we get several in a row then go to next state.
                 if (peak > mPulseThreshold) {
                     if (mDownCounter-- <= 0) {
-                        nextState = STATE_WAITING_FOR_SILENCE;
                         //printf("%5d: switch to STATE_WAITING_FOR_SILENCE, measured peak = %f\n",
                         //       mLoopCounter, peak);
                         mDownCounter = 8;
                         mMeasuredLoopGain = peak;  // assumes original pulse amplitude is one
                         // Calculate gain that will give us a nice decaying echo.
                         mEchoGain = mDesiredEchoGain / mMeasuredLoopGain;
+                        if (mEchoGain > MAX_ECHO_GAIN) {
+                            printf("ERROR - loop gain too low. Increase the volume.\n");
+                            nextState = STATE_FAILED;
+                        } else {
+                            nextState = STATE_WAITING_FOR_SILENCE;
+                        }
                     }
                 } else {
                     mDownCounter = 8;
@@ -524,14 +574,14 @@
                 break;
 
             case STATE_SENDING_PULSE:
-                audioRecorder.write(inputData, inputChannelCount, numFrames);
+                mAudioRecording.write(inputData, inputChannelCount, numFrames);
                 sendImpulse(outputData, outputChannelCount);
                 nextState = STATE_GATHERING_ECHOS;
                 //printf("%5d: switch to STATE_GATHERING_ECHOS\n", mLoopCounter);
                 break;
 
             case STATE_GATHERING_ECHOS:
-                numWritten = audioRecorder.write(inputData, inputChannelCount, numFrames);
+                numWritten = mAudioRecording.write(inputData, inputChannelCount, numFrames);
                 peak = measurePeakAmplitude(inputData, inputChannelCount, numFrames);
                 if (peak > mMeasuredLoopGain) {
                     mMeasuredLoopGain = peak;  // AGC might be raising gain so adjust it on the fly.
@@ -565,6 +615,14 @@
         mLoopCounter++;
     }
 
+    int save(const char *fileName) override {
+        return mAudioRecording.save(fileName);
+    }
+
+    int load(const char *fileName) override {
+        return mAudioRecording.load(fileName);
+    }
+
 private:
 
     enum echo_state_t {
@@ -573,22 +631,22 @@
         STATE_WAITING_FOR_SILENCE,
         STATE_SENDING_PULSE,
         STATE_GATHERING_ECHOS,
-        STATE_DONE
+        STATE_DONE,
+        STATE_FAILED
     };
 
-    int           mDownCounter = 500;
-    int           mLoopCounter = 0;
-    float         mPulseThreshold = 0.02f;
-    float         mSilenceThreshold = 0.002f;
-    float         mMeasuredLoopGain = 0.0f;
-    float         mDesiredEchoGain = 0.95f;
-    float         mEchoGain = 1.0f;
-    echo_state_t  mState = STATE_INITIAL_SILENCE;
-    int32_t       mFrameCounter = 0;
+    int             mDownCounter = 500;
+    int             mLoopCounter = 0;
+    float           mPulseThreshold = 0.02f;
+    float           mSilenceThreshold = 0.002f;
+    float           mMeasuredLoopGain = 0.0f;
+    float           mDesiredEchoGain = 0.95f;
+    float           mEchoGain = 1.0f;
+    echo_state_t    mState = STATE_INITIAL_SILENCE;
 
-    AudioRecording     audioRecorder;
-    LatencyReport      latencyReport;
-    PeakDetector       mPeakDetector;
+    AudioRecording  mAudioRecording; // contains only the input after the gain detection burst
+    LatencyReport   mLatencyReport;
+    // PeakDetector    mPeakDetector;
 };
 
 
@@ -602,6 +660,10 @@
 class SineAnalyzer : public LoopbackProcessor {
 public:
 
+    virtual int getResult() {
+        return mState == STATE_LOCKED ? 0 : -1;
+    }
+
     void report() override {
         printf("SineAnalyzer ------------------\n");
         printf(LOOPBACK_RESULT_TAG "peak.amplitude     = %7.5f\n", mPeakAmplitude);
diff --git a/media/libaaudio/examples/loopback/src/loopback.cpp b/media/libaaudio/examples/loopback/src/loopback.cpp
index ac6024e..d23d907 100644
--- a/media/libaaudio/examples/loopback/src/loopback.cpp
+++ b/media/libaaudio/examples/loopback/src/loopback.cpp
@@ -37,10 +37,10 @@
 
 // Tag for machine readable results as property = value pairs
 #define RESULT_TAG              "RESULT: "
-#define SAMPLE_RATE             48000
 #define NUM_SECONDS             5
 #define NUM_INPUT_CHANNELS      1
-#define FILENAME                "/data/oboe_input.raw"
+#define FILENAME_ALL            "/data/loopback_all.wav"
+#define FILENAME_ECHOS          "/data/loopback_echos.wav"
 #define APP_VERSION             "0.1.22"
 
 struct LoopbackData {
@@ -61,7 +61,7 @@
 
     SineAnalyzer       sineAnalyzer;
     EchoAnalyzer       echoAnalyzer;
-    AudioRecording     audioRecorder;
+    AudioRecording     audioRecording;
     LoopbackProcessor *loopbackProcessor;
 };
 
@@ -126,7 +126,7 @@
             result = AAUDIO_CALLBACK_RESULT_STOP;
         } else if (framesRead > 0) {
 
-            myData->audioRecorder.write(myData->inputData,
+            myData->audioRecording.write(myData->inputData,
                                         myData->actualInputChannelCount,
                                         numFrames);
 
@@ -176,7 +176,8 @@
     printf("              p for _POWER_SAVING\n");
     printf("          -t{test}          select test mode\n");
     printf("              m for sine magnitude\n");
-    printf("              e for echo latency (default)\n\n");
+    printf("              e for echo latency (default)\n");
+    printf("              f for file latency, analyzes %s\n\n", FILENAME_ECHOS);
     printf("          -x                use EXCLUSIVE mode for output\n");
     printf("          -X                use EXCLUSIVE mode for input\n");
     printf("Example:  aaudio_loopback -n2 -pl -Pl -x\n");
@@ -205,6 +206,7 @@
 enum {
     TEST_SINE_MAGNITUDE = 0,
     TEST_ECHO_LATENCY,
+    TEST_FILE_LATENCY,
 };
 
 static int parseTestMode(char c) {
@@ -217,6 +219,9 @@
         case 'e':
             testMode = TEST_ECHO_LATENCY;
             break;
+        case 'f':
+            testMode = TEST_FILE_LATENCY;
+            break;
         default:
             printf("ERROR in value test mode %c\n", c);
             break;
@@ -254,13 +259,13 @@
 int main(int argc, const char **argv)
 {
 
-    AAudioArgsParser     argParser;
-    AAudioSimplePlayer   player;
-    AAudioSimpleRecorder recorder;
-    LoopbackData         loopbackData;
-    AAudioStream        *outputStream = nullptr;
+    AAudioArgsParser      argParser;
+    AAudioSimplePlayer    player;
+    AAudioSimpleRecorder  recorder;
+    LoopbackData          loopbackData;
+    AAudioStream         *outputStream = nullptr;
 
-    aaudio_result_t      result = AAUDIO_OK;
+    aaudio_result_t       result = AAUDIO_OK;
     aaudio_sharing_mode_t requestedInputSharingMode     = AAUDIO_SHARING_MODE_SHARED;
     int                   requestedInputChannelCount = NUM_INPUT_CHANNELS;
     const aaudio_format_t requestedInputFormat = AAUDIO_FORMAT_PCM_I16;
@@ -268,6 +273,7 @@
     aaudio_format_t       actualInputFormat;
     aaudio_format_t       actualOutputFormat;
     aaudio_performance_mode_t inputPerformanceLevel = AAUDIO_PERFORMANCE_MODE_LOW_LATENCY;
+    int32_t               actualSampleRate = 0;
 
     int testMode = TEST_ECHO_LATENCY;
     double gain = 1.0;
@@ -324,7 +330,6 @@
 
     int32_t requestedDuration = argParser.getDurationSeconds();
     int32_t recordingDuration = std::min(60, requestedDuration);
-    loopbackData.audioRecorder.allocate(recordingDuration * SAMPLE_RATE);
 
     switch(testMode) {
         case TEST_SINE_MAGNITUDE:
@@ -334,6 +339,16 @@
             loopbackData.echoAnalyzer.setGain(gain);
             loopbackData.loopbackProcessor = &loopbackData.echoAnalyzer;
             break;
+        case TEST_FILE_LATENCY: {
+            loopbackData.echoAnalyzer.setGain(gain);
+
+            loopbackData.loopbackProcessor = &loopbackData.echoAnalyzer;
+            int read = loopbackData.loopbackProcessor->load(FILENAME_ECHOS);
+            printf("main() read %d mono samples from %s on Android device\n", read, FILENAME_ECHOS);
+            loopbackData.loopbackProcessor->report();
+            return 0;
+        }
+            break;
         default:
             exit(1);
             break;
@@ -344,7 +359,7 @@
     result = player.open(argParser, MyDataCallbackProc, MyErrorCallbackProc, &loopbackData);
     if (result != AAUDIO_OK) {
         fprintf(stderr, "ERROR -  player.open() returned %d\n", result);
-        goto finish;
+        exit(1);
     }
     outputStream = player.getStream();
     argParser.compareWithStream(outputStream);
@@ -352,6 +367,10 @@
     actualOutputFormat = AAudioStream_getFormat(outputStream);
     assert(actualOutputFormat == AAUDIO_FORMAT_PCM_FLOAT);
 
+    actualSampleRate = AAudioStream_getSampleRate(outputStream);
+    loopbackData.audioRecording.allocate(recordingDuration * actualSampleRate);
+    loopbackData.audioRecording.setSampleRate(actualSampleRate);
+
     printf("INPUT stream ----------------------------------------\n");
     // Use different parameters for the input.
     argParser.setNumberOfBursts(AAUDIO_UNSPECIFIED);
@@ -380,7 +399,7 @@
 
     // Allocate a buffer for the audio data.
     loopbackData.inputFramesMaximum = 32 * framesPerBurst;
-    loopbackData.inputBuffersToDiscard = 100;
+    loopbackData.inputBuffersToDiscard = 200;
 
     loopbackData.inputData = new int16_t[loopbackData.inputFramesMaximum
                                          * loopbackData.actualInputChannelCount];
@@ -436,25 +455,31 @@
         }
     }
 
-    printf("input error = %d = %s\n",
-                loopbackData.inputError, AAudio_convertResultToText(loopbackData.inputError));
+    if (loopbackData.loopbackProcessor->getResult() < 0) {
+        printf("Test failed!\n");
+    } else {
+        printf("input error = %d = %s\n",
+               loopbackData.inputError, AAudio_convertResultToText(loopbackData.inputError));
 
-    printf("AAudioStream_getXRunCount %d\n", AAudioStream_getXRunCount(outputStream));
-    printf("framesRead    = %8d\n", (int) AAudioStream_getFramesRead(outputStream));
-    printf("framesWritten = %8d\n", (int) AAudioStream_getFramesWritten(outputStream));
-    printf("min numFrames = %8d\n", (int) loopbackData.minNumFrames);
-    printf("max numFrames = %8d\n", (int) loopbackData.maxNumFrames);
+        printf("AAudioStream_getXRunCount %d\n", AAudioStream_getXRunCount(outputStream));
+        printf("framesRead    = %8d\n", (int) AAudioStream_getFramesRead(outputStream));
+        printf("framesWritten = %8d\n", (int) AAudioStream_getFramesWritten(outputStream));
+        printf("min numFrames = %8d\n", (int) loopbackData.minNumFrames);
+        printf("max numFrames = %8d\n", (int) loopbackData.maxNumFrames);
 
-    if (loopbackData.inputError == AAUDIO_OK) {
-        if (testMode == TEST_SINE_MAGNITUDE) {
-            printAudioGraph(loopbackData.audioRecorder, 200);
+        if (loopbackData.inputError == AAUDIO_OK) {
+            if (testMode == TEST_SINE_MAGNITUDE) {
+                printAudioGraph(loopbackData.audioRecording, 200);
+            }
+            loopbackData.loopbackProcessor->report();
         }
-        loopbackData.loopbackProcessor->report();
-    }
 
-    {
-        int written = loopbackData.audioRecorder.save(FILENAME);
-        printf("main() wrote %d mono samples to %s on Android device\n", written, FILENAME);
+        int written = loopbackData.loopbackProcessor->save(FILENAME_ECHOS);
+        printf("main() wrote %d mono samples to %s on Android device\n", written,
+               FILENAME_ECHOS);
+        printf("main() loopbackData.audioRecording.getSampleRate() = %d\n", loopbackData.audioRecording.getSampleRate());
+        written = loopbackData.audioRecording.save(FILENAME_ALL);
+        printf("main() wrote %d mono samples to %s on Android device\n", written, FILENAME_ALL);
     }
 
 finish:
diff --git a/media/libaaudio/examples/utils/AAudioSimplePlayer.h b/media/libaaudio/examples/utils/AAudioSimplePlayer.h
index 3fafecf..54b77ba 100644
--- a/media/libaaudio/examples/utils/AAudioSimplePlayer.h
+++ b/media/libaaudio/examples/utils/AAudioSimplePlayer.h
@@ -170,7 +170,6 @@
 
     aaudio_result_t close() {
         if (mStream != nullptr) {
-            printf("call AAudioStream_close(%p)\n", mStream);  fflush(stdout);
             AAudioStream_close(mStream);
             mStream = nullptr;
         }
diff --git a/media/libaaudio/examples/utils/AAudioSimpleRecorder.h b/media/libaaudio/examples/utils/AAudioSimpleRecorder.h
index 1344273..869fad0 100644
--- a/media/libaaudio/examples/utils/AAudioSimpleRecorder.h
+++ b/media/libaaudio/examples/utils/AAudioSimpleRecorder.h
@@ -178,7 +178,6 @@
 
     aaudio_result_t close() {
         if (mStream != nullptr) {
-            printf("call AAudioStream_close(%p)\n", mStream);  fflush(stdout);
             AAudioStream_close(mStream);
             mStream = nullptr;
         }
diff --git a/media/libeffects/config/src/EffectsConfig.cpp b/media/libeffects/config/src/EffectsConfig.cpp
index 18c406d..4ed3ba8 100644
--- a/media/libeffects/config/src/EffectsConfig.cpp
+++ b/media/libeffects/config/src/EffectsConfig.cpp
@@ -255,8 +255,8 @@
     XMLDocument doc;
     doc.LoadFile(path);
     if (doc.Error()) {
-        ALOGE("Failed to parse %s: Tinyxml2 error (%d): %s %s", path,
-              doc.ErrorID(), doc.GetErrorStr1(), doc.GetErrorStr2());
+        ALOGE("Failed to parse %s: Tinyxml2 error (%d): %s", path,
+              doc.ErrorID(), doc.ErrorStr());
         return {nullptr, 0, path};
     }
 
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index c33f9f5..807f24d 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -594,7 +594,9 @@
                     deltaSmpl = CAPTURE_BUF_SIZE;
                 }
 
-                int32_t capturePoint = (int32_t)pContext->mCaptureIdx - deltaSmpl;
+                int32_t capturePoint;
+                //capturePoint = (int32_t)pContext->mCaptureIdx - deltaSmpl;
+                __builtin_sub_overflow((int32_t)pContext->mCaptureIdx, deltaSmpl, &capturePoint);
                 // a negative capturePoint means we wrap the buffer.
                 if (capturePoint < 0) {
                     uint32_t size = -capturePoint;
diff --git a/media/libmedia/nuplayer2/HTTPLiveSource.cpp b/media/libmedia/nuplayer2/HTTPLiveSource.cpp
index 14b67cad..e0e3df9 100644
--- a/media/libmedia/nuplayer2/HTTPLiveSource.cpp
+++ b/media/libmedia/nuplayer2/HTTPLiveSource.cpp
@@ -103,7 +103,8 @@
     if (mLiveLooper == NULL) {
         mLiveLooper = new ALooper;
         mLiveLooper->setName("http live");
-        mLiveLooper->start();
+        mLiveLooper->start(false, /* runOnCallingThread */
+                           true /* canCallJava */);
 
         mLiveLooper->registerHandler(this);
     }
diff --git a/media/libmedia/omx/1.0/WOmxNode.cpp b/media/libmedia/omx/1.0/WOmxNode.cpp
index 0b40e8d..2cd8b76 100644
--- a/media/libmedia/omx/1.0/WOmxNode.cpp
+++ b/media/libmedia/omx/1.0/WOmxNode.cpp
@@ -151,7 +151,8 @@
                     hidl_handle const& outNativeHandle) {
                 fnStatus = toStatusT(status);
                 *buffer = outBuffer;
-                *native_handle = NativeHandle::create(
+                *native_handle = outNativeHandle.getNativeHandle() == nullptr ?
+                        nullptr : NativeHandle::create(
                         native_handle_clone(outNativeHandle), true);
             }));
     return transStatus == NO_ERROR ? fnStatus : transStatus;
diff --git a/media/libmediaextractor/Android.bp b/media/libmediaextractor/Android.bp
index c57cd41..dcdb320 100644
--- a/media/libmediaextractor/Android.bp
+++ b/media/libmediaextractor/Android.bp
@@ -1,5 +1,6 @@
 cc_library_shared {
     name: "libmediaextractor",
+
     include_dirs: [
         "frameworks/av/include",
         "frameworks/av/media/libmediaextractor/include",
@@ -14,7 +15,6 @@
     ],
 
     shared_libs: [
-        "libmediametrics",
         "libstagefright_foundation",
         "libutils",
         "libcutils",
diff --git a/media/libmediaextractor/MediaExtractor.cpp b/media/libmediaextractor/MediaExtractor.cpp
index 6ba7c0e..2241567 100644
--- a/media/libmediaextractor/MediaExtractor.cpp
+++ b/media/libmediaextractor/MediaExtractor.cpp
@@ -19,68 +19,26 @@
 #include <utils/Log.h>
 #include <pwd.h>
 
-#include <media/MediaAnalyticsItem.h>
 #include <media/MediaExtractor.h>
 #include <media/stagefright/foundation/ADebug.h>
 #include <media/stagefright/MetaData.h>
 
 namespace android {
 
-// key for media statistics
-static const char *kKeyExtractor = "extractor";
-
 MediaExtractor::MediaExtractor() {
     if (!LOG_NDEBUG) {
         uid_t uid = getuid();
         struct passwd *pw = getpwuid(uid);
         ALOGV("extractor created in uid: %d (%s)", getuid(), pw->pw_name);
     }
-
-    mAnalyticsItem = NULL;
-    if (MEDIA_LOG) {
-        mAnalyticsItem = new MediaAnalyticsItem(kKeyExtractor);
-        (void) mAnalyticsItem->generateSessionID();
-    }
 }
 
-MediaExtractor::~MediaExtractor() {
-
-    // log the current record, provided it has some information worth recording
-    if (MEDIA_LOG) {
-        if (mAnalyticsItem != NULL) {
-            if (mAnalyticsItem->count() > 0) {
-                mAnalyticsItem->setFinalized(true);
-                mAnalyticsItem->selfrecord();
-            }
-        }
-    }
-    if (mAnalyticsItem != NULL) {
-        delete mAnalyticsItem;
-        mAnalyticsItem = NULL;
-    }
-}
+MediaExtractor::~MediaExtractor() {}
 
 sp<MetaData> MediaExtractor::getMetaData() {
     return new MetaData;
 }
 
-status_t MediaExtractor::getMetrics(Parcel *reply) {
-
-    if (mAnalyticsItem == NULL || reply == NULL) {
-        return UNKNOWN_ERROR;
-    }
-
-    populateMetrics();
-    mAnalyticsItem->writeToParcel(reply);
-
-    return OK;
-}
-
-void MediaExtractor::populateMetrics() {
-    ALOGV("MediaExtractor::populateMetrics");
-    // normally overridden in subclasses
-}
-
 uint32_t MediaExtractor::flags() const {
     return CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_PAUSE | CAN_SEEK;
 }
diff --git a/media/libmediaextractor/include/media/MediaExtractor.h b/media/libmediaextractor/include/media/MediaExtractor.h
index 2dcced3..f197b5e 100644
--- a/media/libmediaextractor/include/media/MediaExtractor.h
+++ b/media/libmediaextractor/include/media/MediaExtractor.h
@@ -24,14 +24,10 @@
 #include <utils/Errors.h>
 #include <utils/RefBase.h>
 
-// still doing some on/off toggling here.
-#define MEDIA_LOG       1
-
 namespace android {
 
 class DataSource;
 class IMediaSource;
-class MediaAnalyticsItem;
 class MediaExtractorFactory;
 class MetaData;
 class Parcel;
@@ -55,8 +51,6 @@
     // returns an empty metadata object.
     virtual sp<MetaData> getMetaData();
 
-    status_t getMetrics(Parcel *reply);
-
     enum Flags {
         CAN_SEEK_BACKWARD  = 1,  // the "seek 10secs back button"
         CAN_SEEK_FORWARD   = 2,  // the "seek 10secs forward button"
@@ -123,14 +117,9 @@
     MediaExtractor();
     virtual ~MediaExtractor();
 
-    MediaAnalyticsItem *mAnalyticsItem;
-
-    virtual void populateMetrics();
-
 private:
     MediaExtractor(const MediaExtractor &);
     MediaExtractor &operator=(const MediaExtractor &);
-    friend class MediaExtractorFactory;
 };
 
 // purposely not defined anywhere so that this will fail to link if
diff --git a/media/libstagefright/CCodecBufferChannel.cpp b/media/libstagefright/CCodecBufferChannel.cpp
index 9868cd4..61f3f3c 100644
--- a/media/libstagefright/CCodecBufferChannel.cpp
+++ b/media/libstagefright/CCodecBufferChannel.cpp
@@ -98,7 +98,7 @@
         status_t err = mAlloc->fetchLinearBlock(
                 // TODO: proper max input size
                 65536,
-                { 0, C2MemoryUsage::kSoftwareWrite },
+                { 0, C2MemoryUsage::CPU_WRITE },
                 &block);
         if (err != OK) {
             return false;
diff --git a/media/libstagefright/MediaExtractorFactory.cpp b/media/libstagefright/MediaExtractorFactory.cpp
index e1e04eb..8a90e93 100644
--- a/media/libstagefright/MediaExtractorFactory.cpp
+++ b/media/libstagefright/MediaExtractorFactory.cpp
@@ -37,11 +37,6 @@
 
 namespace android {
 
-// attrs for media statistics
-static const char *kExtractorMime = "android.media.mediaextractor.mime";
-static const char *kExtractorTracks = "android.media.mediaextractor.ntrk";
-static const char *kExtractorFormat = "android.media.mediaextractor.fmt";
-
 // static
 sp<IMediaExtractor> MediaExtractorFactory::Create(
         const sp<DataSource> &source, const char *mime) {
@@ -133,31 +128,6 @@
          mime, confidence);
 
     MediaExtractor *ret = creator(source, meta);
-
-    if (ret != NULL) {
-        // track the container format (mpeg, aac, wvm, etc)
-        if (MEDIA_LOG) {
-            if (ret->mAnalyticsItem != NULL) {
-                size_t ntracks = ret->countTracks();
-                ret->mAnalyticsItem->setCString(kExtractorFormat,  ret->name());
-                // tracks (size_t)
-                ret->mAnalyticsItem->setInt32(kExtractorTracks,  ntracks);
-                // metadata
-                sp<MetaData> pMetaData = ret->getMetaData();
-                if (pMetaData != NULL) {
-                    String8 xx = pMetaData->toString();
-                    // 'titl' -- but this verges into PII
-                    // 'mime'
-                    const char *mime = NULL;
-                    if (pMetaData->findCString(kKeyMIMEType, &mime)) {
-                        ret->mAnalyticsItem->setCString(kExtractorMime,  mime);
-                    }
-                    // what else is interesting and not already available?
-                }
-            }
-        }
-    }
-
     return ret;
 }
 
diff --git a/media/libstagefright/RemoteMediaExtractor.cpp b/media/libstagefright/RemoteMediaExtractor.cpp
index 1dd7986..2a16e16 100644
--- a/media/libstagefright/RemoteMediaExtractor.cpp
+++ b/media/libstagefright/RemoteMediaExtractor.cpp
@@ -14,16 +14,71 @@
  * limitations under the License.
  */
 
+//#define LOG_NDEBUG 0
+#define LOG_TAG "RemoteMediaExtractor"
+#include <utils/Log.h>
+
 #include <media/stagefright/InterfaceUtils.h>
+#include <media/MediaAnalyticsItem.h>
 #include <media/MediaSource.h>
 #include <media/stagefright/RemoteMediaExtractor.h>
 
+// still doing some on/off toggling here.
+#define MEDIA_LOG       1
+
 namespace android {
 
-RemoteMediaExtractor::RemoteMediaExtractor(const sp<MediaExtractor> &extractor)
-    :mExtractor(extractor) {}
+// key for media statistics
+static const char *kKeyExtractor = "extractor";
 
-RemoteMediaExtractor::~RemoteMediaExtractor() {}
+// attrs for media statistics
+static const char *kExtractorMime = "android.media.mediaextractor.mime";
+static const char *kExtractorTracks = "android.media.mediaextractor.ntrk";
+static const char *kExtractorFormat = "android.media.mediaextractor.fmt";
+
+RemoteMediaExtractor::RemoteMediaExtractor(const sp<MediaExtractor> &extractor)
+    :mExtractor(extractor) {
+
+    mAnalyticsItem = nullptr;
+    if (MEDIA_LOG) {
+        mAnalyticsItem = new MediaAnalyticsItem(kKeyExtractor);
+        (void) mAnalyticsItem->generateSessionID();
+
+        // track the container format (mpeg, aac, wvm, etc)
+        size_t ntracks = extractor->countTracks();
+        mAnalyticsItem->setCString(kExtractorFormat, extractor->name());
+        // tracks (size_t)
+        mAnalyticsItem->setInt32(kExtractorTracks, ntracks);
+        // metadata
+        sp<MetaData> pMetaData = extractor->getMetaData();
+        if (pMetaData != nullptr) {
+            String8 xx = pMetaData->toString();
+            // 'titl' -- but this verges into PII
+            // 'mime'
+            const char *mime = nullptr;
+            if (pMetaData->findCString(kKeyMIMEType, &mime)) {
+                mAnalyticsItem->setCString(kExtractorMime,  mime);
+            }
+            // what else is interesting and not already available?
+        }
+    }
+}
+
+RemoteMediaExtractor::~RemoteMediaExtractor() {
+    // log the current record, provided it has some information worth recording
+    if (MEDIA_LOG) {
+        if (mAnalyticsItem != nullptr) {
+            if (mAnalyticsItem->count() > 0) {
+                mAnalyticsItem->setFinalized(true);
+                mAnalyticsItem->selfrecord();
+            }
+        }
+    }
+    if (mAnalyticsItem != nullptr) {
+        delete mAnalyticsItem;
+        mAnalyticsItem = nullptr;
+    }
+}
 
 size_t RemoteMediaExtractor::countTracks() {
     return mExtractor->countTracks();
@@ -43,7 +98,12 @@
 }
 
 status_t RemoteMediaExtractor::getMetrics(Parcel *reply) {
-    return mExtractor->getMetrics(reply);
+    if (mAnalyticsItem == nullptr || reply == nullptr) {
+        return UNKNOWN_ERROR;
+    }
+
+    mAnalyticsItem->writeToParcel(reply);
+    return OK;
 }
 
 uint32_t RemoteMediaExtractor::flags() const {
diff --git a/media/libstagefright/codec2/include/C2.h b/media/libstagefright/codec2/include/C2.h
index a01d674..fd99cce 100644
--- a/media/libstagefright/codec2/include/C2.h
+++ b/media/libstagefright/codec2/include/C2.h
@@ -191,16 +191,25 @@
 #define C2_INTERNAL __attribute__((internal_linkage))
 
 #define DEFINE_OTHER_COMPARISON_OPERATORS(type) \
-    inline bool operator!=(const type &other) { return !(*this == other); } \
-    inline bool operator<=(const type &other) { return (*this == other) || (*this < other); } \
-    inline bool operator>=(const type &other) { return !(*this < other); } \
-    inline bool operator>(const type &other) { return !(*this < other) && !(*this == other); }
+    inline bool operator!=(const type &other) const { return !(*this == other); } \
+    inline bool operator<=(const type &other) const { return (*this == other) || (*this < other); } \
+    inline bool operator>=(const type &other) const { return !(*this < other); } \
+    inline bool operator>(const type &other) const { return !(*this < other) && !(*this == other); }
 
 #define DEFINE_FIELD_BASED_COMPARISON_OPERATORS(type, field) \
     inline bool operator<(const type &other) const { return field < other.field; } \
     inline bool operator==(const type &other) const { return field == other.field; } \
     DEFINE_OTHER_COMPARISON_OPERATORS(type)
 
+#define DEFINE_FIELD_AND_MASK_BASED_COMPARISON_OPERATORS(type, field, mask) \
+    inline bool operator<(const type &other) const { \
+        return (field & mask) < (other.field & (mask)); \
+    } \
+    inline bool operator==(const type &other) const { \
+        return (field & mask) == (other.field & (mask)); \
+    } \
+    DEFINE_OTHER_COMPARISON_OPERATORS(type)
+
 /// \cond INTERNAL
 
 /// \defgroup utils_internal
@@ -213,7 +222,7 @@
 struct c2_types<T> {
     typedef typename std::decay<T>::type wide_type;
     typedef wide_type narrow_type;
-    typedef wide_type mintype;
+    typedef wide_type min_type; // type for min(T...)
 };
 
 /** specialization for two types */
@@ -229,7 +238,7 @@
     typedef typename std::decay<
             typename std::conditional<sizeof(T) < sizeof(U), T, U>::type>::type narrow_type;
     typedef typename std::conditional<
-            std::is_signed<T>::value, wide_type, narrow_type>::type mintype;
+            std::is_signed<T>::value, wide_type, narrow_type>::type min_type;
 };
 
 /// @}
@@ -249,7 +258,7 @@
     /** Narrowest type of the template parameter types. */
     typedef typename c2_types<typename c2_types<T, U>::narrow_type, V...>::narrow_type narrow_type;
     /** Type that accommodates the minimum value for any input for the template parameter types. */
-    typedef typename c2_types<typename c2_types<T, U>::mintype, V...>::mintype mintype;
+    typedef typename c2_types<typename c2_types<T, U>::min_type, V...>::min_type min_type;
 };
 
 /**
@@ -282,11 +291,11 @@
  *  \ingroup utils_internal
  * specialization for two values */
 template<typename T, typename U>
-inline constexpr typename c2_types<T, U>::mintype c2_min(const T a, const U b) {
+inline constexpr typename c2_types<T, U>::min_type c2_min(const T a, const U b) {
     typedef typename c2_types<T, U>::wide_type wide_type;
     return ({
         wide_type a_(a), b_(b);
-        static_cast<typename c2_types<T, U>::mintype>(a_ < b_ ? a_ : b_);
+        static_cast<typename c2_types<T, U>::min_type>(a_ < b_ ? a_ : b_);
     });
 }
 
@@ -302,12 +311,12 @@
  * @return the smallest of the input arguments.
  */
 template<typename T, typename U, typename... V>
-constexpr typename c2_types<T, U, V...>::mintype c2_min(const T a, const U b, const V ... c) {
-    typedef typename c2_types<U, V...>::mintype rest_type;
+constexpr typename c2_types<T, U, V...>::min_type c2_min(const T a, const U b, const V ... c) {
+    typedef typename c2_types<U, V...>::min_type rest_type;
     typedef typename c2_types<T, rest_type>::wide_type wide_type;
     return ({
         wide_type a_(a), b_(c2_min(b, c...));
-        static_cast<typename c2_types<T, rest_type>::mintype>(a_ < b_ ? a_ : b_);
+        static_cast<typename c2_types<T, rest_type>::min_type>(a_ < b_ ? a_ : b_);
     });
 }
 
diff --git a/media/libstagefright/codec2/include/C2Buffer.h b/media/libstagefright/codec2/include/C2Buffer.h
index d978e42..df9362c 100644
--- a/media/libstagefright/codec2/include/C2Buffer.h
+++ b/media/libstagefright/codec2/include/C2Buffer.h
@@ -23,8 +23,6 @@
 #include <list>
 #include <memory>
 
-typedef int C2Fence;
-
 #ifdef __ANDROID__
 
 // #include <system/window.h>
@@ -738,20 +736,20 @@
 /// \name Planar capacity interface
 /// @{
 public:
-    inline uint32_t width() const { return mWidth; }
-    inline uint32_t height() const { return mHeight; }
+    inline uint32_t width() const { return _mWidth; }
+    inline uint32_t height() const { return _mHeight; }
 
 protected:
     inline _C2PlanarCapacityAspect(uint32_t width, uint32_t height)
-      : mWidth(width), mHeight(height) { }
+      : _mWidth(width), _mHeight(height) { }
 
     inline _C2PlanarCapacityAspect(const _C2PlanarCapacityAspect *parent)
-        : mWidth(parent == nullptr ? 0 : parent->width()),
-          mHeight(parent == nullptr ? 0 : parent->height()) { }
+        : _mWidth(parent == nullptr ? 0 : parent->width()),
+          _mHeight(parent == nullptr ? 0 : parent->height()) { }
 
 private:
-    const uint32_t mWidth;
-    const uint32_t mHeight;
+    const uint32_t _mWidth;
+    const uint32_t _mHeight;
 /// @}
 };
 
@@ -762,25 +760,25 @@
  */
 struct C2Rect {
 // public:
-    uint32_t mLeft;
-    uint32_t mTop;
-    uint32_t mWidth;
-    uint32_t mHeight;
+    uint32_t left;
+    uint32_t top;
+    uint32_t width;
+    uint32_t height;
 
-    constexpr inline C2Rect(uint32_t width, uint32_t height)
-        : C2Rect(width, height, 0, 0) { }
+    constexpr inline C2Rect(uint32_t width_, uint32_t height_)
+        : C2Rect(width_, height_, 0, 0) { }
 
-    constexpr inline C2Rect(uint32_t width, uint32_t height, uint32_t left, uint32_t top)
-        : mLeft(left), mTop(top), mWidth(width), mHeight(height) { }
+    constexpr inline C2Rect(uint32_t width_, uint32_t height_, uint32_t left_, uint32_t top_)
+        : left(left_), top(top_), width(width_), height(height_) { }
 
     // utility methods
 
     inline bool isEmpty() const {
-        return mWidth == 0 || mHeight == 0;
+        return width == 0 || height == 0;
     }
 
     inline bool isValid() const {
-        return mLeft <= ~mWidth && mTop <= ~mHeight;
+        return left <= ~width && top <= ~height;
     }
 
     inline operator bool() const {
@@ -797,9 +795,9 @@
         } else if (other.isEmpty()) {
             return true;
         } else {
-            return mLeft <= other.mLeft && mTop <= other.mTop
-                    && mLeft + mWidth >= other.mLeft + other.mWidth
-                    && mTop + mHeight >= other.mTop + other.mHeight;
+            return left <= other.left && top <= other.top
+                    && left + width >= other.left + other.width
+                    && top + height >= other.top + other.height;
         }
     }
 
@@ -809,8 +807,8 @@
         } else if (isEmpty()) {
             return other.isEmpty();
         } else {
-            return mLeft == other.mLeft && mTop == other.mTop
-                    && mWidth == other.mWidth && mHeight == other.mHeight;
+            return left == other.left && top == other.top
+                    && width == other.width && height == other.height;
         }
     }
 
@@ -836,78 +834,104 @@
 };
 
 /**
- * C2PlaneInfo: information on the layout of flexible planes.
+ * C2PlaneInfo: information on the layout of a singe flexible plane.
  *
  * Public fields without getters/setters.
  */
 struct C2PlaneInfo {
-// public:
-    enum Channel : uint32_t {
-        Y,
-        R,
-        G,
-        B,
-        A,
-        Cr,
-        Cb,
-    } mChannel;
+//public:
+    enum channel_t : uint32_t {
+        CHANNEL_Y,  ///< luma
+        CHANNEL_R,  ///< red
+        CHANNEL_G,  ///< green
+        CHANNEL_B,  ///< blue
+        CHANNEL_A,  ///< alpha
+        CHANNEL_CR, ///< Cr
+        CHANNEL_CB, ///< Cb
+    } channel;
 
-    int32_t mColInc;               // column increment in bytes. may be negative
-    int32_t mRowInc;               // row increment in bytes. may be negative
-    uint32_t mHorizSubsampling;    // subsampling compared to width
-    uint32_t mVertSubsampling;     // subsampling compared to height
+    int32_t colInc;       ///< column increment in bytes. may be negative
+    int32_t rowInc;       ///< row increment in bytes. may be negative
+    uint32_t colSampling; ///< subsampling compared to width (must be a power of 2)
+    uint32_t rowSampling; ///< subsampling compared to height (must be a power of 2)
 
-    uint32_t mBitDepth;
-    uint32_t mAllocatedDepth;
+    uint32_t allocatedDepth; ///< size of each sample (must be a multiple of 8)
+    uint32_t bitDepth;       ///< significant bits per sample
+    /**
+     * the right shift of the significant bits in the sample. E.g. if a 10-bit significant
+     * value is laid out in a 16-bit allocation aligned to LSB (values 0-1023), rightShift
+     * would be 0 as the 16-bit value read from the sample does not need to be right shifted
+     * and can be used as is (after applying a 10-bit mask of 0x3FF).
+     *
+     * +--------+--------+
+     * |      VV|VVVVVVVV|
+     * +--------+--------+
+     *  15     8 7      0
+     *
+     * If the value is laid out aligned to MSB, rightShift would be 6, as the value read
+     * from the allocated sample must be right-shifted by 6 to get the actual sample value.
+     *
+     * +--------+--------+
+     * |VVVVVVVV|VV      |
+     * +--------+--------+
+     *  15     8 7      0
+     */
+    uint32_t rightShift;
+
+    enum endianness_t : uint32_t {
+        NATIVE,
+        LITTLE_END, // LITTLE_ENDIAN is reserved macro
+        BIG_END,    // BIG_ENDIAN is a reserved macro
+    } endianness; ///< endianness of the samples
 
     inline ssize_t minOffset(uint32_t width, uint32_t height) {
         ssize_t offs = 0;
-        if (width > 0 && mColInc < 0) {
-            offs += mColInc * (ssize_t)(width - 1);
+        if (width > 0 && colInc < 0) {
+            offs += colInc * (ssize_t)(width - 1);
         }
-        if (height > 0 && mRowInc < 0) {
-            offs += mRowInc * (ssize_t)(height - 1);
+        if (height > 0 && rowInc < 0) {
+            offs += rowInc * (ssize_t)(height - 1);
         }
         return offs;
     }
 
     inline ssize_t maxOffset(uint32_t width, uint32_t height, uint32_t allocatedDepth) {
         ssize_t offs = (allocatedDepth + 7) >> 3;
-        if (width > 0 && mColInc > 0) {
-            offs += mColInc * (ssize_t)(width - 1);
+        if (width > 0 && colInc > 0) {
+            offs += colInc * (ssize_t)(width - 1);
         }
-        if (height > 0 && mRowInc > 0) {
-            offs += mRowInc * (ssize_t)(height - 1);
+        if (height > 0 && rowInc > 0) {
+            offs += rowInc * (ssize_t)(height - 1);
         }
         return offs;
     }
 };
 
-struct C2PlaneLayout {
-public:
-    enum Type : uint32_t {
-        MEDIA_IMAGE_TYPE_UNKNOWN = 0,
-        MEDIA_IMAGE_TYPE_YUV = 0x100,
-        MEDIA_IMAGE_TYPE_YUVA,
-        MEDIA_IMAGE_TYPE_RGB,
-        MEDIA_IMAGE_TYPE_RGBA,
+struct C2PlanarLayout {
+//public:
+    enum type_t : uint32_t {
+        TYPE_UNKNOWN = 0,
+        TYPE_YUV = 0x100,
+        TYPE_YUVA,
+        TYPE_RGB,
+        TYPE_RGBA,
     };
 
-    Type mType;
-    uint32_t mNumPlanes;               // number of planes
+    type_t type;
+    uint32_t numPlanes;               // number of planes
 
-    enum PlaneIndex : uint32_t {
-        Y = 0,
-        U = 1,
-        V = 2,
-        R = 0,
-        G = 1,
-        B = 2,
-        A = 3,
+    enum plane_index_t : uint32_t {
+        PLANE_Y = 0,
+        PLANE_U = 1,
+        PLANE_V = 2,
+        PLANE_R = 0,
+        PLANE_G = 1,
+        PLANE_B = 2,
+        PLANE_A = 3,
         MAX_NUM_PLANES = 4,
     };
 
-    C2PlaneInfo mPlanes[MAX_NUM_PLANES];
+    C2PlaneInfo planes[MAX_NUM_PLANES];
 };
 
 /**
@@ -927,11 +951,11 @@
      *  Sets crop to crop intersected with [(0,0) .. (width, height)]
      */
     inline void setCrop_be(const C2Rect &crop) {
-        mCrop.mLeft = std::min(width(), crop.mLeft);
-        mCrop.mTop = std::min(height(), crop.mTop);
-        // It's guaranteed that mCrop.mLeft <= width() && mCrop.mTop <= height()
-        mCrop.mWidth = std::min(width() - mCrop.mLeft, crop.mWidth);
-        mCrop.mHeight = std::min(height() - mCrop.mTop, crop.mHeight);
+        mCrop.left = std::min(width(), crop.left);
+        mCrop.top = std::min(height(), crop.top);
+        // It's guaranteed that mCrop.left <= width() && mCrop.top <= height()
+        mCrop.width = std::min(width() - mCrop.left, crop.width);
+        mCrop.height = std::min(height() - mCrop.top, crop.height);
     }
 
     /**
@@ -940,8 +964,8 @@
      * \return true iff crop is within the dimensions of this object
      */
     inline bool setCrop(const C2Rect &crop) {
-        if (width() < crop.mWidth || height() < crop.mHeight
-                || width() - crop.mWidth < crop.mLeft || height() - crop.mHeight < crop.mTop) {
+        if (width() < crop.width || height() < crop.height
+                || width() - crop.width < crop.left || height() - crop.height < crop.top) {
             return false;
         }
         mCrop = crop;
@@ -1001,7 +1025,7 @@
     /**
      * \return layout of the graphic block to interpret the returned data.
      */
-    const C2PlaneLayout layout() const;
+    const C2PlanarLayout layout() const;
 
     /**
      * Returns a section of this view.
@@ -1022,7 +1046,7 @@
     C2GraphicView(
             const _C2PlanarCapacityAspect *parent,
             uint8_t *const *data,
-            const C2PlaneLayout& layout);
+            const C2PlanarLayout& layout);
     explicit C2GraphicView(c2_status_t error);
 
 private:
@@ -1327,25 +1351,26 @@
 // public:
     // TODO: match these to gralloc1.h
     enum Consumer : uint64_t {
-        kSoftwareRead        = GRALLOC_USAGE_SW_READ_OFTEN,
-        kRenderScriptRead    = GRALLOC_USAGE_RENDERSCRIPT,
-        kTextureRead         = GRALLOC_USAGE_HW_TEXTURE,
-        kHardwareComposer    = GRALLOC_USAGE_HW_COMPOSER,
-        kHardwareEncoder     = GRALLOC_USAGE_HW_VIDEO_ENCODER,
-        kProtectedRead       = GRALLOC_USAGE_PROTECTED,
+        // \todo do we need to distinguish often from rarely?
+        CPU_READ          = GRALLOC_USAGE_SW_READ_OFTEN,
+        RENDERSCRIPT_READ = GRALLOC_USAGE_RENDERSCRIPT,
+        HW_TEXTURE_READ   = GRALLOC_USAGE_HW_TEXTURE,
+        HW_COMPOSER_READ  = GRALLOC_USAGE_HW_COMPOSER,
+        HW_CODEC_READ     = GRALLOC_USAGE_HW_VIDEO_ENCODER,
+        READ_PROTECTED    = GRALLOC_USAGE_PROTECTED,
     };
 
     enum Producer : uint64_t {
-        kSoftwareWrite       = GRALLOC_USAGE_SW_WRITE_OFTEN,
-        kRenderScriptWrite   = GRALLOC_USAGE_RENDERSCRIPT,
-        kTextureWrite        = GRALLOC_USAGE_HW_RENDER,
-        kCompositionTarget   = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER,
-        kHardwareDecoder     = GRALLOC_USAGE_HW_VIDEO_ENCODER,
-        kProtectedWrite      = GRALLOC_USAGE_PROTECTED,
+        CPU_WRITE          = GRALLOC_USAGE_SW_WRITE_OFTEN,
+        RENDERSCRIPT_WRITE = GRALLOC_USAGE_RENDERSCRIPT,
+        HW_TEXTURE_WRITE   = GRALLOC_USAGE_HW_RENDER,
+        HW_COMPOSER_WRITE  = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER,
+        HW_CODEC_WRITE     = GRALLOC_USAGE_HW_VIDEO_ENCODER,
+        WRITE_PROTECTED    = GRALLOC_USAGE_PROTECTED,
     };
 
-    uint64_t mConsumer; // e.g. input
-    uint64_t mProducer; // e.g. output
+    uint64_t consumer; // e.g. input
+    uint64_t producer; // e.g. output
 };
 
 /**
@@ -1475,7 +1500,7 @@
     virtual c2_status_t map(
             C2Rect rect, C2MemoryUsage usage, int *fenceFd,
             // TODO: return <addr, size> buffers with plane sizes
-            C2PlaneLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) = 0;
+            C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) = 0;
 
     /**
      * Unmaps the last mapped rectangular section.
diff --git a/media/libstagefright/codec2/include/C2Config.h b/media/libstagefright/codec2/include/C2Config.h
index 0568432..bbbf338 100644
--- a/media/libstagefright/codec2/include/C2Config.h
+++ b/media/libstagefright/codec2/include/C2Config.h
@@ -41,7 +41,7 @@
 enum name : type { __VA_ARGS__ }; \
 DEFINE_C2_ENUM_VALUE_CUSTOM_HELPER(name, type, names, __VA_ARGS__)
 
-enum C2ParamIndexKind : C2Param::ParamIndex {
+enum C2ParamIndexKind : C2Param::type_index_t {
     /// domain
     kParamIndexDomain,
 
@@ -232,12 +232,12 @@
 //   - critical parameters? (interlaced? profile? level?)
 
 struct C2VideoSizeStruct {
-    int32_t mWidth;     ///< video width
-    int32_t mHeight;    ///< video height
+    int32_t width;     ///< video width
+    int32_t height;    ///< video height
 
     DEFINE_AND_DESCRIBE_BASE_C2STRUCT(VideoSize)
-    C2FIELD(mWidth, "width")
-    C2FIELD(mHeight, "height")
+    C2FIELD(width, "width")
+    C2FIELD(height, "height")
 };
 
 // video size for video decoder [OUT]
diff --git a/media/libstagefright/codec2/include/C2Param.h b/media/libstagefright/codec2/include/C2Param.h
index f0b92a3..2a8c1b2 100644
--- a/media/libstagefright/codec2/include/C2Param.h
+++ b/media/libstagefright/codec2/include/C2Param.h
@@ -52,6 +52,9 @@
  *   - must be POD struct, e.g. no vtable (no virtual destructor)
  *   - must have the same size in 64-bit and 32-bit mode (no size_t)
  *   - as such, no pointer members
+ *   - some common member field names are reserved as they are defined as methods for all
+ *     parameters:
+ *     they are: size, type, kind, index and stream
  *
  * Behavior:
  * - Params can be global (not related to input or output), related to input or output,
@@ -94,17 +97,21 @@
 struct C2Param {
     // param index encompasses the following:
     //
-    // - type (setting, tuning, info, struct)
-    // - vendor extension flag
-    // - flexible parameter flag
-    // - direction (global, input, output)
-    // - stream flag
-    // - stream ID (usually 0)
+    // - kind (setting, tuning, info, struct)
+    // - scope
+    //   - direction (global, input, output)
+    //   - stream flag
+    //   - stream ID (usually 0)
+    // - and the parameter's type (core index)
+    //   - flexible parameter flag
+    //   - vendor extension flag
+    //   - type index (this includes the vendor extension flag)
     //
     // layout:
     //
+    //        kind : <------- scope -------> : <----- core index ----->
     //      +------+-----+---+------+--------+----|------+--------------+
-    //      | kind | dir | - |stream|streamID|flex|vendor|  core index  |
+    //      | kind | dir | - |stream|streamID|flex|vendor|  type index  |
     //      +------+-----+---+------+--------+----+------+--------------+
     //  bit: 31..30 29.28       25   24 .. 17  16    15   14    ..     0
     //
@@ -112,7 +119,7 @@
     /**
      * C2Param kinds, usable as bitmaps.
      */
-    enum Kind : uint32_t {
+    enum kind_t : uint32_t {
         NONE    = 0,
         STRUCT  = (1 << 0),
         INFO    = (1 << 1),
@@ -121,124 +128,141 @@
     };
 
     /**
-     * Parameter index is associated with each parameter. It is used to identify and distinguish
-     * global parameters, and also parameters on a given port or stream. They must be unique for the
-     * set of global parameters, as well as for the set of parameters on each port or each stream,
-     * but the same parameter index can be used for parameters on different streams or ports, as
-     * well as for global parameters and port/stream parameters.
+     * The parameter type index specifies the underlying parameter type of a parameter as
+     * an integer value.
      *
-     * Parameter index is also used to describe the layout of the parameter structures. Multiple
-     * parameter types can share the same layout, but the layout for all parameters with the same
-     * parameter index across all components must be identical.
+     * Parameter types are divided into two groups: platform types and vendor types.
+     *
+     * Platform types are defined by the platform and are common for all implementations.
+     *
+     * Vendor types are defined by each vendors, so they may differ between implementations.
+     * It is recommended that vendor types be the same for all implementations by a specific
+     * vendor.
      */
-    typedef uint32_t ParamIndex;
+    typedef uint32_t type_index_t;
+    enum : uint32_t {
+            TYPE_INDEX_VENDOR_START = 0x00008000, ///< vendor indices SHALL start after this
+    };
 
     /**
-     * base index (including the vendor extension bit) is a global index for
-     * C2 parameter structs. (e.g. the same indices cannot be reused for different
-     * structs for different components).
+     * Core index is the underlying parameter type for a parameter. It is used to describe the
+     * layout of the parameter structure regardless of the component or parameter kind/scope.
+     *
+     * It is used to identify and distinguish global parameters, and also parameters on a given
+     * port or stream. They must be unique for the set of global parameters, as well as for the
+     * set of parameters on each port or each stream, but the same core index can be used for
+     * parameters on different streams or ports, as well as for global parameters and port/stream
+     * parameters.
+     *
+     * Multiple parameter types can share the same layout.
+     *
+     * \note The layout for all parameters with the same core index across all components must
+     * be identical.
      */
-    struct BaseIndex {
+    struct CoreIndex {
+    //public:
+        enum : uint32_t {
+            IS_FLEX_FLAG = 0x00010000,
+        };
+
     protected:
         enum : uint32_t {
-            kTypeMask      = 0xC0000000,
-            kTypeStruct    = 0x00000000,
-            kTypeTuning    = 0x40000000,
-            kTypeSetting   = 0x80000000,
-            kTypeInfo      = 0xC0000000,
+            KIND_MASK      = 0xC0000000,
+            KIND_STRUCT    = 0x00000000,
+            KIND_TUNING    = 0x40000000,
+            KIND_SETTING   = 0x80000000,
+            KIND_INFO      = 0xC0000000,
 
-            kDirMask       = 0x30000000,
-            kDirGlobal     = 0x20000000,
-            kDirUndefined  = 0x30000000, // MUST have all bits set
-            kDirInput      = 0x00000000,
-            kDirOutput     = 0x10000000,
+            DIR_MASK       = 0x30000000,
+            DIR_GLOBAL     = 0x20000000,
+            DIR_UNDEFINED  = DIR_MASK, // MUST have all bits set
+            DIR_INPUT      = 0x00000000,
+            DIR_OUTPUT     = 0x10000000,
 
-            kStreamFlag    = 0x02000000,
-            kStreamIdMask  = 0x01FE0000,
-            kStreamIdShift = 17,
-            kStreamIdMax   = kStreamIdMask >> kStreamIdShift,
-            kStreamMask    = kStreamFlag | kStreamIdMask,
+            IS_STREAM_FLAG  = 0x02000000,
+            STREAM_ID_MASK  = 0x01FE0000,
+            STREAM_ID_SHIFT = 17,
+            MAX_STREAM_ID   = STREAM_ID_MASK >> STREAM_ID_SHIFT,
+            STREAM_MASK     = IS_STREAM_FLAG | STREAM_ID_MASK,
 
-            kFlexibleFlag  = 0x00010000,
-            kVendorFlag    = 0x00008000,
-            kParamMask     = 0x0000FFFF,
-            kCoreMask      = kParamMask | kFlexibleFlag,
+            IS_VENDOR_FLAG  = 0x00008000,
+            TYPE_INDEX_MASK = 0x0000FFFF,
+            CORE_MASK       = TYPE_INDEX_MASK | IS_FLEX_FLAG,
         };
 
     public:
-        enum : uint32_t {
-            kVendorStart = kVendorFlag, ///< vendor structs SHALL start after this
-            _kFlexibleFlag = kFlexibleFlag, // TODO: this is only needed for testing
-        };
-
         /// constructor/conversion from uint32_t
-        inline BaseIndex(uint32_t index) : mIndex(index) { }
+        inline CoreIndex(uint32_t index) : mIndex(index) { }
 
         // no conversion from uint64_t
-        inline BaseIndex(uint64_t index) = delete;
+        inline CoreIndex(uint64_t index) = delete;
 
         /// returns true iff this is a vendor extension parameter
-        inline bool isVendor() const { return mIndex & kVendorFlag; }
+        inline bool isVendor() const { return mIndex & IS_VENDOR_FLAG; }
 
         /// returns true iff this is a flexible parameter (with variable size)
-        inline bool isFlexible() const { return mIndex & kFlexibleFlag; }
+        inline bool isFlexible() const { return mIndex & IS_FLEX_FLAG; }
 
-        /// returns the core parameter type (index) for the underlying struct.
-        /// This is the combination of the parameter index and the flexible flag.
-        inline unsigned int coreIndex() const { return mIndex & kCoreMask; }
+        /// returns the core index
+        /// This is the combination of the parameter type index and the flexible flag.
+        inline uint32_t coreIndex() const { return mIndex & CORE_MASK; }
 
-        /// returns the parameter index for the underlying struct
-        inline ParamIndex paramIndex() const { return mIndex & kParamMask; }
+        /// returns the parameter type index
+        inline type_index_t typeIndex() const { return mIndex & TYPE_INDEX_MASK; }
 
-        DEFINE_FIELD_BASED_COMPARISON_OPERATORS(BaseIndex, mIndex)
+        DEFINE_FIELD_AND_MASK_BASED_COMPARISON_OPERATORS(CoreIndex, mIndex, CORE_MASK)
 
     protected:
         uint32_t mIndex;
     };
 
     /**
-     * type encompasses the parameter kind (tuning, setting, info), whether the
-     * parameter is global, input or output, and whether it is for a stream.
+     * Type encompasses the parameter's kind (tuning, setting, info), its scope (whether the
+     * parameter is global, input or output, and whether it is for a stream) and the its base
+     * index (which also determines its layout).
      */
-    struct Type : public BaseIndex {
+    struct Type : public CoreIndex {
+    //public:
         /// returns true iff this is a global parameter (not for input nor output)
-        inline bool isGlobal() const { return (mIndex & kDirMask) == kDirGlobal; }
+        inline bool isGlobal() const { return (mIndex & DIR_MASK) == DIR_GLOBAL; }
         /// returns true iff this is an input or input stream parameter
-        inline bool forInput() const { return (mIndex & kDirMask) == kDirInput; }
+        inline bool forInput() const { return (mIndex & DIR_MASK) == DIR_INPUT; }
         /// returns true iff this is an output or output stream parameter
-        inline bool forOutput() const { return (mIndex & kDirMask) == kDirOutput; }
+        inline bool forOutput() const { return (mIndex & DIR_MASK) == DIR_OUTPUT; }
 
         /// returns true iff this is a stream parameter
-        inline bool forStream() const { return mIndex & kStreamFlag; }
+        inline bool forStream() const { return mIndex & IS_STREAM_FLAG; }
         /// returns true iff this is a port (input or output) parameter
         inline bool forPort() const   { return !forStream() && !isGlobal(); }
 
         /// returns the parameter type: the parameter index without the stream ID
-        inline uint32_t type() const { return mIndex & (~kStreamIdMask); }
+        inline uint32_t type() const { return mIndex & (~STREAM_ID_MASK); }
 
-        /// return the kind of this param
-        inline Kind kind() const {
-            switch (mIndex & kTypeMask) {
-                case kTypeStruct: return STRUCT;
-                case kTypeInfo: return INFO;
-                case kTypeSetting: return SETTING;
-                case kTypeTuning: return TUNING;
+        /// return the kind (struct, info, setting or tuning) of this param
+        inline kind_t kind() const {
+            switch (mIndex & KIND_MASK) {
+                case KIND_STRUCT: return STRUCT;
+                case KIND_INFO: return INFO;
+                case KIND_SETTING: return SETTING;
+                case KIND_TUNING: return TUNING;
                 default: return NONE; // should not happen
             }
         }
 
         /// constructor/conversion from uint32_t
-        inline Type(uint32_t index) : BaseIndex(index) { }
+        inline Type(uint32_t index) : CoreIndex(index) { }
 
         // no conversion from uint64_t
         inline Type(uint64_t index) = delete;
 
+        DEFINE_FIELD_AND_MASK_BASED_COMPARISON_OPERATORS(Type, mIndex, ~STREAM_ID_MASK)
+
     private:
         friend struct C2Param;   // for setPort()
-        friend struct C2Tuning;  // for kTypeTuning
-        friend struct C2Setting; // for kTypeSetting
-        friend struct C2Info;    // for kTypeInfo
-        // for kDirGlobal
+        friend struct C2Tuning;  // for KIND_TUNING
+        friend struct C2Setting; // for KIND_SETTING
+        friend struct C2Info;    // for KIND_INFO
+        // for DIR_GLOBAL
         template<typename T, typename S, int I, class F> friend struct C2GlobalParam;
         template<typename T, typename S, int I, class F> friend struct C2PortParam;   // for kDir*
         template<typename T, typename S, int I, class F> friend struct C2StreamParam; // for kDir*
@@ -252,7 +276,7 @@
             if (isGlobal()) {
                 return false;
             } else {
-                mIndex = (mIndex & ~kDirMask) | (output ? kDirOutput : kDirInput);
+                mIndex = (mIndex & ~DIR_MASK) | (output ? DIR_OUTPUT : DIR_INPUT);
                 return true;
             }
         }
@@ -276,6 +300,8 @@
             return forStream() ? rawStream() : ~0U;
         }
 
+        DEFINE_FIELD_BASED_COMPARISON_OPERATORS(Index, mIndex)
+
     private:
         friend struct C2Param;           // for setStream, makeStreamId, isValid
         friend struct _C2ParamInspector; // for testing
@@ -287,23 +313,23 @@
         inline bool isValid() const {
             // there is no Type::isValid (even though some of this check could be
             // performed on types) as this is only used on index...
-            return (forStream() ? rawStream() < kStreamIdMax : rawStream() == 0)
-                    && (mIndex & kDirMask) != kDirUndefined;
+            return (forStream() ? rawStream() < MAX_STREAM_ID : rawStream() == 0)
+                    && (mIndex & DIR_MASK) != DIR_UNDEFINED;
         }
 
         /// returns the raw stream ID field
         inline unsigned rawStream() const {
-            return (mIndex & kStreamIdMask) >> kStreamIdShift;
+            return (mIndex & STREAM_ID_MASK) >> STREAM_ID_SHIFT;
         }
 
         /// returns the streamId bitfield for a given |stream|. If stream is invalid,
         /// returns an invalid bitfield.
         inline static uint32_t makeStreamId(unsigned stream) {
             // saturate stream ID (max value is invalid)
-            if (stream > kStreamIdMax) {
-                stream = kStreamIdMax;
+            if (stream > MAX_STREAM_ID) {
+                stream = MAX_STREAM_ID;
             }
-            return (stream << kStreamIdShift) & kStreamIdMask;
+            return (stream << STREAM_ID_SHIFT) & STREAM_ID_MASK;
         }
 
         /**
@@ -312,8 +338,8 @@
          */
         inline bool setStream(unsigned stream) {
             if (forStream()) {
-                mIndex = (mIndex & ~kStreamIdMask) | makeStreamId(stream);
-                return this->stream() < kStreamIdMax;
+                mIndex = (mIndex & ~STREAM_ID_MASK) | makeStreamId(stream);
+                return this->stream() < MAX_STREAM_ID;
             }
             return false;
         }
@@ -342,14 +368,17 @@
     inline unsigned stream() const { return _mIndex.stream(); }
 
     /// returns the parameter type: the parameter index without the stream ID
-    inline uint32_t type() const { return _mIndex.type(); }
+    inline Type type() const { return _mIndex.type(); }
 
     /// returns the index of this parameter
     /// \todo: should we restrict this to C2ParamField?
     inline uint32_t index() const { return (uint32_t)_mIndex; }
 
+    /// returns the core index of this parameter
+    inline CoreIndex coreIndex() const { return _mIndex.coreIndex(); }
+
     /// returns the kind of this parameter
-    inline Kind kind() const { return _mIndex.kind(); }
+    inline kind_t kind() const { return _mIndex.kind(); }
 
     /// returns the size of the parameter or 0 if the parameter is invalid
     inline size_t size() const { return _mSize; }
@@ -439,7 +468,7 @@
         } else if (o->_mIndex.isGlobal()) {
             return nullptr;
         } else {
-            return ((o->_mIndex.type() ^ type.mIndex) & ~Type::kDirMask) ? nullptr : o;
+            return ((o->_mIndex.type() ^ type.mIndex) & ~Type::DIR_MASK) ? nullptr : o;
         }
     }
 
@@ -467,10 +496,6 @@
 private:
     friend struct _C2ParamInspector; // for testing
 
-    /// returns the base type: the index for the underlying struct (for testing
-    /// as this can be gotten by the coreIndex enum)
-    inline uint32_t _coreIndex() const { return _mIndex.coreIndex(); }
-
     /// returns true iff |o| has the same size and index as this. This performs the
     /// basic check for equality.
     inline bool equals(const C2Param &o) const {
@@ -496,7 +521,7 @@
     template<typename ...Args>
     inline C2Setting(const Args(&... args)) : C2Param(args...) { }
 public: // TODO
-    enum : uint32_t { indexFlags = Type::kTypeSetting };
+    enum : uint32_t { PARAM_KIND = Type::KIND_SETTING };
 };
 
 /**
@@ -507,7 +532,7 @@
     template<typename ...Args>
     inline C2Tuning(const Args(&... args)) : C2Setting(args...) { }
 public: // TODO
-    enum : uint32_t { indexFlags = Type::kTypeTuning };
+    enum : uint32_t { PARAM_KIND = Type::KIND_TUNING };
 };
 
 /**
@@ -518,7 +543,7 @@
     template<typename ...Args>
     inline C2Info(const Args(&... args)) : C2Param(args...) { }
 public: // TODO
-    enum : uint32_t { indexFlags = Type::kTypeInfo };
+    enum : uint32_t { PARAM_KIND = Type::KIND_INFO };
 };
 
 /**
@@ -726,7 +751,7 @@
         template<typename T> const T &ref() const;
     };
 
-    enum Type {
+    enum type_t : uint32_t {
         NO_INIT,
         INT32,
         UINT32,
@@ -735,28 +760,28 @@
         FLOAT,
     };
 
-    template<typename T> static constexpr Type typeFor();
+    template<typename T> static constexpr type_t typeFor();
 
     // constructors - implicit
     template<typename T>
-    C2Value(T value)  : mType(typeFor<T>()), mValue(value) { }
+    C2Value(T value)  : _mType(typeFor<T>()), _mValue(value) { }
 
-    C2Value() : mType(NO_INIT) { }
+    C2Value() : _mType(NO_INIT) { }
 
-    inline Type type() const { return mType; }
+    inline type_t type() const { return _mType; }
 
     template<typename T>
     inline bool get(T *value) const {
-        if (mType == typeFor<T>()) {
-            *value = mValue.ref<T>();
+        if (_mType == typeFor<T>()) {
+            *value = _mValue.ref<T>();
             return true;
         }
         return false;
     }
 
 private:
-    Type mType;
-    Primitive mValue;
+    type_t _mType;
+    Primitive _mValue;
 };
 
 template<> inline const int32_t &C2Value::Primitive::ref<int32_t>() const { return i32; }
@@ -765,11 +790,11 @@
 template<> inline const uint64_t &C2Value::Primitive::ref<uint64_t>() const { return u64; }
 template<> inline const float &C2Value::Primitive::ref<float>() const { return fp; }
 
-template<> constexpr C2Value::Type C2Value::typeFor<int32_t>() { return INT32; }
-template<> constexpr C2Value::Type C2Value::typeFor<int64_t>() { return INT64; }
-template<> constexpr C2Value::Type C2Value::typeFor<uint32_t>() { return UINT32; }
-template<> constexpr C2Value::Type C2Value::typeFor<uint64_t>() { return UINT64; }
-template<> constexpr C2Value::Type C2Value::typeFor<float>() { return FLOAT; }
+template<> constexpr C2Value::type_t C2Value::typeFor<int32_t>() { return INT32; }
+template<> constexpr C2Value::type_t C2Value::typeFor<int64_t>() { return INT64; }
+template<> constexpr C2Value::type_t C2Value::typeFor<uint32_t>() { return UINT32; }
+template<> constexpr C2Value::type_t C2Value::typeFor<uint64_t>() { return UINT64; }
+template<> constexpr C2Value::type_t C2Value::typeFor<float>() { return FLOAT; }
 
 /**
  * field descriptor. A field is uniquely defined by an index into a parameter.
@@ -784,7 +809,7 @@
      * \note: only 32-bit and 64-bit fields are supported (e.g. no boolean, as that
      * is represented using INT32).
      */
-    enum Type : uint32_t {
+    enum type_t : uint32_t {
         // primitive types
         INT32   = C2Value::INT32,  ///< 32-bit signed integer
         UINT32  = C2Value::UINT32, ///< 32-bit unsigned integer
@@ -798,7 +823,7 @@
                         ///< however, bytes cannot be individually addressed by clients.
 
         // complex types
-        STRUCT_FLAG = 0x10000, ///< structs. Marked with this flag in addition to their coreIndex.
+        STRUCT_FLAG = 0x20000, ///< structs. Marked with this flag in addition to their coreIndex.
     };
 
     typedef std::pair<C2String, C2Value::Primitive> named_value_type;
@@ -816,7 +841,7 @@
     static named_values_type namedValuesFor(const B &);
 
     inline C2FieldDescriptor(uint32_t type, uint32_t length, C2StringLiteral name, size_t offset, size_t size)
-        : _mType((Type)type), _mLength(length), _mName(name), _mFieldId(offset, size) { }
+        : _mType((type_t)type), _mLength(length), _mName(name), _mFieldId(offset, size) { }
 
     template<typename T, class B=typename std::remove_extent<T>::type>
     inline C2FieldDescriptor(const T* offset, const char *name)
@@ -844,7 +869,7 @@
           _mFieldId(&(((S*)0)->*field)) {}
 
     /// returns the type of this field
-    inline Type type() const { return _mType; }
+    inline type_t type() const { return _mType; }
     /// returns the length of the field in case it is an array. Returns 0 for
     /// T[] arrays, returns 1 for T[1] arrays as well as if the field is not an array.
     inline size_t length() const { return _mLength; }
@@ -860,7 +885,7 @@
 #endif
 
 private:
-    const Type _mType;
+    const type_t _mType;
     const uint32_t _mLength; // the last member can be arbitrary length if it is T[] array,
                        // extending to the end of the parameter (this is marked with
                        // 0). T[0]-s are not fields.
@@ -874,27 +899,27 @@
     // 2) this is at parameter granularity.
 
     // type resolution
-    inline static Type getType(int32_t*)  { return INT32; }
-    inline static Type getType(uint32_t*) { return UINT32; }
-    inline static Type getType(int64_t*)  { return INT64; }
-    inline static Type getType(uint64_t*) { return UINT64; }
-    inline static Type getType(float*)    { return FLOAT; }
-    inline static Type getType(char*)     { return STRING; }
-    inline static Type getType(uint8_t*)  { return BLOB; }
+    inline static type_t getType(int32_t*)  { return INT32; }
+    inline static type_t getType(uint32_t*) { return UINT32; }
+    inline static type_t getType(int64_t*)  { return INT64; }
+    inline static type_t getType(uint64_t*) { return UINT64; }
+    inline static type_t getType(float*)    { return FLOAT; }
+    inline static type_t getType(char*)     { return STRING; }
+    inline static type_t getType(uint8_t*)  { return BLOB; }
 
     template<typename T,
              class=typename std::enable_if<std::is_enum<T>::value>::type>
-    inline static Type getType(T*) {
+    inline static type_t getType(T*) {
         typename std::underlying_type<T>::type underlying(0);
         return getType(&underlying);
     }
 
-    // verify C2Struct by having a fieldList and a coreIndex.
+    // verify C2Struct by having a FIELD_LIST and a CORE_INDEX.
     template<typename T,
-             class=decltype(T::coreIndex + 1), class=decltype(T::fieldList)>
-    inline static Type getType(T*) {
+             class=decltype(T::CORE_INDEX + 1), class=decltype(T::FIELD_LIST)>
+    inline static type_t getType(T*) {
         static_assert(!std::is_base_of<C2Param, T>::value, "cannot use C2Params as fields");
-        return (Type)(T::coreIndex | STRUCT_FLAG);
+        return (type_t)(T::CORE_INDEX | STRUCT_FLAG);
     }
 };
 
@@ -918,33 +943,33 @@
  */
 struct C2StructDescriptor {
 public:
-    /// Returns the parameter type
-    inline C2Param::BaseIndex coreIndex() const { return _mType.coreIndex(); }
+    /// Returns the core index of the struct
+    inline C2Param::CoreIndex coreIndex() const { return _mType.coreIndex(); }
 
-    // Returns the number of fields in this param (not counting any recursive fields).
-    // Must be at least 1 for valid params.
+    // Returns the number of fields in this struct (not counting any recursive fields).
+    // Must be at least 1 for valid structs.
     inline size_t numFields() const { return _mFields.size(); }
 
-    // Returns the list of immediate fields (not counting any recursive fields).
+    // Returns the list of direct fields (not counting any recursive fields).
     typedef std::vector<const C2FieldDescriptor>::const_iterator field_iterator;
     inline field_iterator cbegin() const { return _mFields.cbegin(); }
     inline field_iterator cend() const { return _mFields.cend(); }
 
-    // only supplying const iterator - but these are needed for range based loops
+    // only supplying const iterator - but these names are needed for range based loops
     inline field_iterator begin() const { return _mFields.cbegin(); }
     inline field_iterator end() const { return _mFields.cend(); }
 
     template<typename T>
     inline C2StructDescriptor(T*)
-        : C2StructDescriptor(T::coreIndex, T::fieldList) { }
+        : C2StructDescriptor(T::CORE_INDEX, T::FIELD_LIST) { }
 
     inline C2StructDescriptor(
-            C2Param::BaseIndex type,
+            C2Param::CoreIndex type,
             std::initializer_list<const C2FieldDescriptor> fields)
         : _mType(type), _mFields(fields) { }
 
 private:
-    const C2Param::BaseIndex _mType;
+    const C2Param::CoreIndex _mType;
     const std::vector<const C2FieldDescriptor> _mFields;
 };
 
@@ -984,7 +1009,7 @@
         : _mIsRequired(isRequired),
           _mIsPersistent(true),
           _mName(name),
-          _mType(T::typeIndex) { }
+          _mType(T::PARAM_TYPE) { }
 
     inline C2ParamDescriptor(
             bool isRequired, C2StringLiteral name, C2Param::Type type)
@@ -1001,29 +1026,29 @@
 };
 
 /// \ingroup internal
-/// Define a structure without coreIndex.
+/// Define a structure without CORE_INDEX.
 #define DEFINE_BASE_C2STRUCT(name) \
 public: \
     typedef C2##name##Struct _type; /**< type name shorthand */ \
-    const static std::initializer_list<const C2FieldDescriptor> fieldList; /**< structure fields */
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST; /**< structure fields */
 
-/// Define a structure with matching coreIndex.
+/// Define a structure with matching CORE_INDEX.
 #define DEFINE_C2STRUCT(name) \
 public: \
-    enum : uint32_t { coreIndex = kParamIndex##name }; \
+    enum : uint32_t { CORE_INDEX = kParamIndex##name }; \
     DEFINE_BASE_C2STRUCT(name)
 
-/// Define a flexible structure without coreIndex.
+/// Define a flexible structure without CORE_INDEX.
 #define DEFINE_BASE_FLEX_C2STRUCT(name, flexMember) \
 public: \
     FLEX(C2##name##Struct, flexMember) \
     DEFINE_BASE_C2STRUCT(name)
 
-/// Define a flexible structure with matching coreIndex.
+/// Define a flexible structure with matching CORE_INDEX.
 #define DEFINE_FLEX_C2STRUCT(name, flexMember) \
 public: \
     FLEX(C2##name##Struct, flexMember) \
-    enum : uint32_t { coreIndex = kParamIndex##name | C2Param::BaseIndex::_kFlexibleFlag }; \
+    enum : uint32_t { CORE_INDEX = kParamIndex##name | C2Param::CoreIndex::IS_FLEX_FLAG }; \
     DEFINE_BASE_C2STRUCT(name)
 
 #ifdef __C2_GENERATE_GLOBAL_VARS__
@@ -1031,12 +1056,12 @@
 /// Describe a structure of a templated structure.
 #define DESCRIBE_TEMPLATED_C2STRUCT(strukt, list) \
     template<> \
-    const std::initializer_list<const C2FieldDescriptor> strukt::fieldList = list;
+    const std::initializer_list<const C2FieldDescriptor> strukt::FIELD_LIST = list;
 
 /// \deprecated
 /// Describe the fields of a structure using an initializer list.
 #define DESCRIBE_C2STRUCT(name, list) \
-    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::fieldList = list;
+    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::FIELD_LIST = list;
 #else
 /// \if 0
 #define DESCRIBE_TEMPLATED_C2STRUCT(strukt, list)
@@ -1052,26 +1077,26 @@
  *
  *  ~~~~~~~~~~~~~ (.cpp)
  *  struct C2VideoWidthStruct {
- *      int32_t mWidth;
+ *      int32_t width;
  *      C2VideoWidthStruct() {} // optional default constructor
- *      C2VideoWidthStruct(int32_t _width) : mWidth(_width) {}
+ *      C2VideoWidthStruct(int32_t _width) : width(_width) {}
  *
  *      DEFINE_AND_DESCRIBE_C2STRUCT(VideoWidth)
- *      C2FIELD(mWidth, "width")
+ *      C2FIELD(width, "width")
  *  };
  *  ~~~~~~~~~~~~~
  *
  *  ~~~~~~~~~~~~~ (.cpp)
  *  struct C2VideoWidthStruct {
- *      int32_t mWidth;
+ *      int32_t width;
  *      C2VideoWidthStruct() = default; // optional default constructor
- *      C2VideoWidthStruct(int32_t _width) : mWidth(_width) {}
+ *      C2VideoWidthStruct(int32_t _width) : width(_width) {}
  *
  *      DEFINE_C2STRUCT(VideoWidth)
  *  } C2_PACK;
  *
  *  DESCRIBE_C2STRUCT(VideoWidth, {
- *      C2FIELD(mWidth, "width")
+ *      C2FIELD(width, "width")
  *  })
  *  ~~~~~~~~~~~~~
  *
@@ -1079,7 +1104,7 @@
  *
  *  ~~~~~~~~~~~~~ (.cpp)
  *  struct C2VideoFlexWidthsStruct {
- *      int32_t mWidths[];
+ *      int32_t widths[];
  *      C2VideoFlexWidthsStruct(); // must have a default constructor
  *
  *  private:
@@ -1088,7 +1113,7 @@
  *      //   C2VideoFlexWidthsGlobalParam::alloc_unique(size_t, int32_t);
  *      C2VideoFlexWidthsStruct(size_t flexCount, int32_t value) {
  *          for (size_t i = 0; i < flexCount; ++i) {
- *              mWidths[i] = value;
+ *              widths[i] = value;
  *          }
  *      }
  *
@@ -1099,12 +1124,12 @@
  *      template<unsigned N>
  *      C2VideoFlexWidthsStruct(size_t flexCount, const int32_t(&init)[N]) {
  *          for (size_t i = 0; i < flexCount; ++i) {
- *              mWidths[i] = init[i];
+ *              widths[i] = init[i];
  *          }
  *      }
  *
- *      DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(VideoFlexWidths, mWidths)
- *      C2FIELD(mWidths, "widths")
+ *      DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(VideoFlexWidths, widths)
+ *      C2FIELD(widths, "widths")
  *  };
  *  ~~~~~~~~~~~~~
  *
@@ -1130,29 +1155,29 @@
 #define C2SOLE_FIELD(member, name) \
   C2FieldDescriptor(&_type::member, name, 0)
 
-/// Define a structure with matching coreIndex and start describing its fields.
+/// Define a structure with matching CORE_INDEX and start describing its fields.
 /// This must be at the end of the structure definition.
 #define DEFINE_AND_DESCRIBE_C2STRUCT(name) \
     DEFINE_C2STRUCT(name) } C2_PACK; \
-    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::fieldList = {
+    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::FIELD_LIST = {
 
-/// Define a flexible structure with matching coreIndex and start describing its fields.
+/// Define a flexible structure with matching CORE_INDEX and start describing its fields.
 /// This must be at the end of the structure definition.
 #define DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(name, flexMember) \
     DEFINE_FLEX_C2STRUCT(name, flexMember) } C2_PACK; \
-    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::fieldList = {
+    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::FIELD_LIST = {
 
-/// Define a base structure (with no coreIndex) and start describing its fields.
+/// Define a base structure (with no CORE_INDEX) and start describing its fields.
 /// This must be at the end of the structure definition.
 #define DEFINE_AND_DESCRIBE_BASE_C2STRUCT(name) \
     DEFINE_BASE_C2STRUCT(name) } C2_PACK; \
-    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::fieldList = {
+    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::FIELD_LIST = {
 
-/// Define a flexible base structure (with no coreIndex) and start describing its fields.
+/// Define a flexible base structure (with no CORE_INDEX) and start describing its fields.
 /// This must be at the end of the structure definition.
 #define DEFINE_AND_DESCRIBE_BASE_FLEX_C2STRUCT(name, flexMember) \
     DEFINE_BASE_FLEX_C2STRUCT(name, flexMember) } C2_PACK; \
-    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::fieldList = {
+    const std::initializer_list<const C2FieldDescriptor> C2##name##Struct::FIELD_LIST = {
 
 #else
 /// \if 0
@@ -1162,19 +1187,19 @@
 #define C2FIELD(member, name)
 /// \deprecated
 #define C2SOLE_FIELD(member, name)
-/// Define a structure with matching coreIndex and start describing its fields.
+/// Define a structure with matching CORE_INDEX and start describing its fields.
 /// This must be at the end of the structure definition.
 #define DEFINE_AND_DESCRIBE_C2STRUCT(name) \
     DEFINE_C2STRUCT(name) }  C2_PACK; namespace ignored {
-/// Define a flexible structure with matching coreIndex and start describing its fields.
+/// Define a flexible structure with matching CORE_INDEX and start describing its fields.
 /// This must be at the end of the structure definition.
 #define DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(name, flexMember) \
     DEFINE_FLEX_C2STRUCT(name, flexMember) } C2_PACK; namespace ignored {
-/// Define a base structure (with no coreIndex) and start describing its fields.
+/// Define a base structure (with no CORE_INDEX) and start describing its fields.
 /// This must be at the end of the structure definition.
 #define DEFINE_AND_DESCRIBE_BASE_C2STRUCT(name) \
     DEFINE_BASE_C2STRUCT(name) } C2_PACK; namespace ignored {
-/// Define a flexible base structure (with no coreIndex) and start describing its fields.
+/// Define a flexible base structure (with no CORE_INDEX) and start describing its fields.
 /// This must be at the end of the structure definition.
 #define DEFINE_AND_DESCRIBE_BASE_FLEX_C2STRUCT(name, flexMember) \
     DEFINE_BASE_FLEX_C2STRUCT(name, flexMember) } C2_PACK; namespace ignored {
@@ -1194,7 +1219,7 @@
     /**
      *  Describes a parameter structure.
      *
-     *  \param[in] coreIndex the base index of the parameter structure containing at least the
+     *  \param[in] coreIndex the core index of the parameter structure containing at least the
      *  core index
      *
      *  \return the description of the parameter structure
@@ -1208,7 +1233,7 @@
      *  descriptions, but we want to conserve memory if client only wants the description
      *  of a few indices.
      */
-    virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::BaseIndex coreIndex) = 0;
+    virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex coreIndex) = 0;
 
 protected:
     virtual ~C2ParamReflector() = default;
@@ -1225,14 +1250,14 @@
  */
 struct C2FieldSupportedValues {
 //public:
-    enum Type {
+    enum type_t {
         EMPTY,      ///< no supported values
         RANGE,      ///< a numeric range that can be continuous or discrete
         VALUES,     ///< a list of values
         FLAGS       ///< a list of flags that can be OR-ed
     };
 
-    Type type;
+    type_t type;
 
     typedef C2Value::Primitive Primitive;
 
diff --git a/media/libstagefright/codec2/include/C2ParamDef.h b/media/libstagefright/codec2/include/C2ParamDef.h
index 8656629..b5834f2 100644
--- a/media/libstagefright/codec2/include/C2ParamDef.h
+++ b/media/libstagefright/codec2/include/C2ParamDef.h
@@ -59,33 +59,33 @@
                         || decltype(_C2Comparable_impl::__testNE<S>(0))::value> {
 };
 
-///  Helper class that checks if a type has a coreIndex constant.
+///  Helper class that checks if a type has a CORE_INDEX constant.
 struct C2_HIDE _C2CoreIndexHelper_impl
 {
-    template<typename S, int=S::coreIndex>
+    template<typename S, int=S::CORE_INDEX>
     static std::true_type __testCoreIndex(int);
     template<typename>
     static std::false_type __testCoreIndex(...);
 };
 
-/// Helper template that verifies a type's coreIndex and creates it if the type does not have one.
+/// Helper template that verifies a type's CORE_INDEX and creates it if the type does not have one.
 template<typename S, int CoreIndex,
         bool HasBase=decltype(_C2CoreIndexHelper_impl::__testCoreIndex<S>(0))::value>
 struct C2_HIDE C2CoreIndexOverride {
-    // TODO: what if we allow structs without coreIndex?
-    static_assert(CoreIndex == S::coreIndex, "coreIndex differs from structure");
+    // TODO: what if we allow structs without CORE_INDEX?
+    static_assert(CoreIndex == S::CORE_INDEX, "CORE_INDEX differs from structure");
 };
 
-/// Specialization for types without a coreIndex.
+/// Specialization for types without a CORE_INDEX.
 template<typename S, int CoreIndex>
 struct C2_HIDE C2CoreIndexOverride<S, CoreIndex, false> {
 public:
     enum : uint32_t {
-        coreIndex = CoreIndex, ///< coreIndex override.
+        CORE_INDEX = CoreIndex, ///< CORE_INDEX override.
     };
 };
 
-/// Helper template that adds a coreIndex to a type if it does not have one.
+/// Helper template that adds a CORE_INDEX to a type if it does not have one.
 template<typename S, int CoreIndex>
 struct C2_HIDE C2AddCoreIndex : public S, public C2CoreIndexOverride<S, CoreIndex> {};
 
@@ -94,9 +94,9 @@
  *
  * Features:
  *  - verify default constructor, no virtual methods, and no equality operators.
- *  - expose typeIndex, and non-flex flexSize.
+ *  - expose PARAM_TYPE, and non-flex FLEX_SIZE.
  */
-template<typename S, int CoreIndex, unsigned TypeIndex>
+template<typename S, int CoreIndex, unsigned TypeFlags>
 struct C2_HIDE C2StructCheck {
     static_assert(
             std::is_default_constructible<S>::value, "C2 structure must have default constructor");
@@ -105,31 +105,31 @@
 
 public:
     enum : uint32_t {
-        typeIndex = CoreIndex | TypeIndex
+        PARAM_TYPE = CoreIndex | TypeFlags
     };
 
 protected:
     enum : uint32_t {
-        flexSize = 0, // TODO: is this still needed? this may be confusing.
+        FLEX_SIZE = 0, // TODO: is this still needed? this may be confusing.
     };
 };
 
-/// Helper class that checks if a type has an integer flexSize member.
+/// Helper class that checks if a type has an integer FLEX_SIZE member.
 struct C2_HIDE _C2Flexible_impl {
-    /// specialization for types that have a flexSize member
-    template<typename S, unsigned=S::flexSize>
+    /// specialization for types that have a FLEX_SIZE member
+    template<typename S, unsigned=S::FLEX_SIZE>
     static std::true_type __testFlexSize(int);
     template<typename>
     static std::false_type __testFlexSize(...);
 };
 
-/// Helper template that returns if a type has an integer flexSize member.
+/// Helper template that returns if a type has an integer FLEX_SIZE member.
 template<typename S>
 struct C2_HIDE _C2Flexible
     : public std::integral_constant<bool, decltype(_C2Flexible_impl::__testFlexSize<S>(0))::value> {
 };
 
-/// Macro to test if a type is flexible (has a flexSize member).
+/// Macro to test if a type is flexible (has a FLEX_SIZE member).
 #define IF_FLEXIBLE(S) ENABLE_IF(_C2Flexible<S>::value)
 /// Shorthand for std::enable_if
 #define ENABLE_IF(cond) typename std::enable_if<cond>::type
@@ -137,76 +137,76 @@
 /// Helper template that exposes the flexible subtype of a struct.
 template<typename S, typename E=void>
 struct C2_HIDE _C2FlexHelper {
-    typedef void flexType;
-    enum : uint32_t { flexSize = 0 };
+    typedef void FlexType;
+    enum : uint32_t { FLEX_SIZE = 0 };
 };
 
 /// Specialization for flexible types.
 template<typename S>
 struct C2_HIDE _C2FlexHelper<S,
         typename std::enable_if<!std::is_void<typename S::flexMemberType>::value>::type> {
-    typedef typename _C2FlexHelper<typename S::flexMemberType>::flexType flexType;
-    enum : uint32_t { flexSize = _C2FlexHelper<typename S::flexMemberType>::flexSize };
+    typedef typename _C2FlexHelper<typename S::flexMemberType>::FlexType FlexType;
+    enum : uint32_t { FLEX_SIZE = _C2FlexHelper<typename S::flexMemberType>::FLEX_SIZE };
 };
 
 /// Specialization for flex arrays.
 template<typename S>
 struct C2_HIDE _C2FlexHelper<S[],
-        typename std::enable_if<std::is_void<typename _C2FlexHelper<S>::flexType>::value>::type> {
-    typedef S flexType;
-    enum : uint32_t { flexSize = sizeof(S) };
+        typename std::enable_if<std::is_void<typename _C2FlexHelper<S>::FlexType>::value>::type> {
+    typedef S FlexType;
+    enum : uint32_t { FLEX_SIZE = sizeof(S) };
 };
 
 /**
  * \brief Helper class to check flexible struct requirements and add common operations.
  *
  * Features:
- *  - expose coreIndex and fieldList (this is normally inherited from the struct, but flexible
+ *  - expose CORE_INDEX and FIELD_LIST (this is normally inherited from the struct, but flexible
  *    structs cannot be base classes and thus inherited from)
  *  - disable copy assignment and construction (TODO: this is already done in the FLEX macro for the
  *    flexible struct, so may not be needed here)
  */
-template<typename S, int ParamIndex, unsigned TypeIndex>
+template<typename S, int ParamIndex, unsigned TypeFlags>
 struct C2_HIDE C2FlexStructCheck :
-// add flexible flag as C2StructCheck defines typeIndex
-        public C2StructCheck<S, ParamIndex | C2Param::BaseIndex::_kFlexibleFlag, TypeIndex> {
+// add flexible flag as C2StructCheck defines PARAM_TYPE
+        public C2StructCheck<S, ParamIndex | C2Param::CoreIndex::IS_FLEX_FLAG, TypeFlags> {
 public:
     enum : uint32_t {
         /// \hideinitializer
-        coreIndex = ParamIndex | C2Param::BaseIndex::_kFlexibleFlag, ///< flexible struct core-index
+        CORE_INDEX = ParamIndex | C2Param::CoreIndex::IS_FLEX_FLAG, ///< flexible struct core-index
     };
 
-    const static std::initializer_list<const C2FieldDescriptor> fieldList; // TODO assign here
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST; // TODO assign here
 
     // default constructor needed because of the disabled copy constructor
     inline C2FlexStructCheck() = default;
 
 protected:
     // cannot copy flexible params
-    C2FlexStructCheck(const C2FlexStructCheck<S, ParamIndex, TypeIndex> &) = delete;
-    C2FlexStructCheck& operator= (const C2FlexStructCheck<S, ParamIndex, TypeIndex> &) = delete;
+    C2FlexStructCheck(const C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
+    C2FlexStructCheck& operator= (const C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
 
     // constants used for helper methods
     enum : uint32_t {
         /// \hideinitializer
-        flexSize = _C2FlexHelper<S>::flexSize, ///< size of flexible type
+        FLEX_SIZE = _C2FlexHelper<S>::FLEX_SIZE, ///< size of flexible type
         /// \hideinitializer
-        maxSize = (uint32_t)std::min((size_t)UINT32_MAX, SIZE_MAX), // TODO: is this always u32 max?
+        MAX_SIZE = (uint32_t)std::min((size_t)UINT32_MAX, SIZE_MAX), // TODO: is this always u32 max?
         /// \hideinitializer
-        baseSize = sizeof(S) + sizeof(C2Param), ///< size of the base param
+        BASE_SIZE = sizeof(S) + sizeof(C2Param), ///< size of the base param
     };
 
     /// returns the allocated size of this param with flexCount, or 0 if it would overflow.
-    inline static size_t calcSize(size_t flexCount, size_t size = baseSize) {
-        if (flexCount <= (maxSize - size) / S::flexSize) {
-            return size + S::flexSize * flexCount;
+    inline static size_t calcSize(size_t flexCount, size_t size = BASE_SIZE) {
+        if (flexCount <= (MAX_SIZE - size) / S::FLEX_SIZE) {
+            return size + S::FLEX_SIZE * flexCount;
         }
         return 0;
     }
 
     /// dynamic new operator usable for params of type S
     inline void* operator new(size_t size, size_t flexCount) noexcept {
-        // TODO: assert(size == baseSize);
+        // TODO: assert(size == BASE_SIZE);
         size = calcSize(flexCount, size);
         if (size > 0) {
             return ::operator new(size);
@@ -216,22 +216,22 @@
 };
 
 // TODO: this probably does not work.
-/// Expose fieldList from subClass;
-template<typename S, int ParamIndex, unsigned TypeIndex>
+/// Expose FIELD_LIST from subClass;
+template<typename S, int ParamIndex, unsigned TypeFlags>
 const std::initializer_list<const C2FieldDescriptor>
-C2FlexStructCheck<S, ParamIndex, TypeIndex>::fieldList = S::fieldList;
+C2FlexStructCheck<S, ParamIndex, TypeFlags>::FIELD_LIST = S::FIELD_LIST;
 
 /// Define From() cast operators for params.
-#define DEFINE_CAST_OPERATORS(_type) \
-    inline static _type* From(C2Param *other) { \
-        return (_type*)C2Param::ifSuitable( \
-                other, sizeof(_type),_type::typeIndex, _type::flexSize, \
-                (_type::typeIndex & T::Index::kDirUndefined) != T::Index::kDirUndefined); \
+#define DEFINE_CAST_OPERATORS(_Type) \
+    inline static _Type* From(C2Param *other) { \
+        return (_Type*)C2Param::ifSuitable( \
+                other, sizeof(_Type),_Type::PARAM_TYPE, _Type::FLEX_SIZE, \
+                (_Type::PARAM_TYPE & T::Index::DIR_UNDEFINED) != T::Index::DIR_UNDEFINED); \
     } \
-    inline static const _type* From(const C2Param *other) { \
-        return const_cast<const _type*>(From(const_cast<C2Param *>(other))); \
+    inline static const _Type* From(const C2Param *other) { \
+        return const_cast<const _Type*>(From(const_cast<C2Param *>(other))); \
     } \
-    inline static _type* From(std::nullptr_t) { return nullptr; } \
+    inline static _Type* From(std::nullptr_t) { return nullptr; } \
 
 /**
  * Define flexible allocators (alloc_shared or alloc_unique) for flexible params.
@@ -241,38 +241,38 @@
  *  - P::alloc_xyz(args..., std::initializer_list<T>): allocate for size of (and with) initializer
  *    list.
  */
-#define DEFINE_FLEXIBLE_ALLOC(_type, S, ptr) \
+#define DEFINE_FLEXIBLE_ALLOC(_Type, S, ptr) \
     template<typename ...Args> \
-    inline static std::ptr##_ptr<_type> alloc_##ptr(size_t flexCount, const Args(&... args)) { \
-        return std::ptr##_ptr<_type>(new(flexCount) _type(flexCount, args...)); \
+    inline static std::ptr##_ptr<_Type> alloc_##ptr(size_t flexCount, const Args(&... args)) { \
+        return std::ptr##_ptr<_Type>(new(flexCount) _Type(flexCount, args...)); \
     } \
     /* NOTE: unfortunately this is not supported by clang yet */ \
-    template<typename ...Args, typename U=typename S::flexType, unsigned N> \
-    inline static std::ptr##_ptr<_type> alloc_##ptr(const Args(&... args), const U(&init)[N]) { \
-        return std::ptr##_ptr<_type>(new(N) _type(N, args..., init)); \
+    template<typename ...Args, typename U=typename S::FlexType, unsigned N> \
+    inline static std::ptr##_ptr<_Type> alloc_##ptr(const Args(&... args), const U(&init)[N]) { \
+        return std::ptr##_ptr<_Type>(new(N) _Type(N, args..., init)); \
     } \
     /* so for now, specialize for no args */ \
-    template<typename U=typename S::flexType, unsigned N> \
-    inline static std::ptr##_ptr<_type> alloc_##ptr(const U(&init)[N]) { \
-        return std::ptr##_ptr<_type>(new(N) _type(N, init)); \
+    template<typename U=typename S::FlexType, unsigned N> \
+    inline static std::ptr##_ptr<_Type> alloc_##ptr(const U(&init)[N]) { \
+        return std::ptr##_ptr<_Type>(new(N) _Type(N, init)); \
     } \
-    template<typename ...Args, typename U=typename S::flexType> \
-    inline static std::ptr##_ptr<_type> alloc_##ptr( \
+    template<typename ...Args, typename U=typename S::FlexType> \
+    inline static std::ptr##_ptr<_Type> alloc_##ptr( \
             const Args(&... args), const std::initializer_list<U> &init) { \
-        return std::ptr##_ptr<_type>(new(init.size()) _type(init.size(), args..., init)); \
+        return std::ptr##_ptr<_Type>(new(init.size()) _Type(init.size(), args..., init)); \
     } \
 
 /**
  * Define flexible methods alloc_shared, alloc_unique and flexCount.
  */
-#define DEFINE_FLEXIBLE_METHODS(_type, S) \
-    DEFINE_FLEXIBLE_ALLOC(_type, S, shared) \
-    DEFINE_FLEXIBLE_ALLOC(_type, S, unique) \
+#define DEFINE_FLEXIBLE_METHODS(_Type, S) \
+    DEFINE_FLEXIBLE_ALLOC(_Type, S, shared) \
+    DEFINE_FLEXIBLE_ALLOC(_Type, S, unique) \
     inline size_t flexCount() const { \
-        static_assert(sizeof(_type) == _type::baseSize, "incorrect baseSize"); \
+        static_assert(sizeof(_Type) == _Type::BASE_SIZE, "incorrect BASE_SIZE"); \
         size_t sz = this->size(); \
-        if (sz >= sizeof(_type)) { \
-            return (sz - sizeof(_type)) / _type::flexSize; \
+        if (sz >= sizeof(_Type)) { \
+            return (sz - sizeof(_Type)) / _Type::FLEX_SIZE; \
         } \
         return 0; \
     } \
@@ -289,11 +289,11 @@
     typedef decltype(m) flexMemberType; \
 public: \
     /* constexpr static flexMemberType cls::* flexMember = &cls::m; */ \
-    typedef typename _C2FlexHelper<flexMemberType>::flexType flexType; \
+    typedef typename _C2FlexHelper<flexMemberType>::FlexType FlexType; \
     static_assert(\
-            !std::is_void<flexType>::value, \
+            !std::is_void<FlexType>::value, \
             "member is not flexible, or a flexible array of a flexible type"); \
-    enum : uint32_t { flexSize = _C2FlexHelper<flexMemberType>::flexSize }; \
+    enum : uint32_t { FLEX_SIZE = _C2FlexHelper<flexMemberType>::FLEX_SIZE }; \
     /** \endif */ \
 
 /// @}
@@ -313,18 +313,18 @@
  * \tparam ParamIndex optional parameter index override. Must be specified for base/reused
  * structures.
  */
-template<typename T, typename S, int ParamIndex=S::coreIndex, class Flex=void>
+template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
 struct C2_HIDE C2GlobalParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
-        public C2StructCheck<S, ParamIndex, T::indexFlags | T::Type::kDirGlobal> {
+        public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
 private:
-    typedef C2GlobalParam<T, S, ParamIndex> _type;
+    typedef C2GlobalParam<T, S, ParamIndex> _Type;
 
 public:
     /// Wrapper around base structure's constructor.
     template<typename ...Args>
-    inline C2GlobalParam(const Args(&... args)) : T(sizeof(_type), _type::typeIndex), S(args...) { }
+    inline C2GlobalParam(const Args(&... args)) : T(sizeof(_Type), _Type::PARAM_TYPE), S(args...) { }
 
-    DEFINE_CAST_OPERATORS(_type)
+    DEFINE_CAST_OPERATORS(_Type)
 };
 
 /**
@@ -344,20 +344,20 @@
  */
 template<typename T, typename S, int ParamIndex>
 struct C2_HIDE C2GlobalParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
-    : public T, public C2FlexStructCheck<S, ParamIndex, T::indexFlags | T::Type::kDirGlobal> {
+    : public T, public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
 private:
-    typedef C2GlobalParam<T, S, ParamIndex> _type;
+    typedef C2GlobalParam<T, S, ParamIndex> _Type;
 
     /// Wrapper around base structure's constructor.
     template<typename ...Args>
     inline C2GlobalParam(size_t flexCount, const Args(&... args))
-        : T(_type::calcSize(flexCount), _type::typeIndex), m(flexCount, args...) { }
+        : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE), m(flexCount, args...) { }
 
 public:
     S m; ///< wrapped flexible structure
 
-    DEFINE_FLEXIBLE_METHODS(_type, S)
-    DEFINE_CAST_OPERATORS(_type)
+    DEFINE_FLEXIBLE_METHODS(_Type, S)
+    DEFINE_CAST_OPERATORS(_Type)
 };
 
 /**
@@ -379,30 +379,30 @@
  * There are 3 flavors of port parameters: unspecified, input and output. Parameters with
  * unspecified port expose a setPort method, and add an initial port parameter to the constructor.
  */
-template<typename T, typename S, int ParamIndex=S::coreIndex, class Flex=void>
+template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
 struct C2_HIDE C2PortParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
-        private C2StructCheck<S, ParamIndex, T::indexFlags | T::Index::kDirUndefined> {
+        private C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_UNDEFINED> {
 private:
-    typedef C2PortParam<T, S, ParamIndex> _type;
+    typedef C2PortParam<T, S, ParamIndex> _Type;
 
 public:
     /// Default constructor.
-    inline C2PortParam() : T(sizeof(_type), _type::typeIndex) { }
+    inline C2PortParam() : T(sizeof(_Type), _Type::PARAM_TYPE) { }
     template<typename ...Args>
     /// Wrapper around base structure's constructor while specifying port/direction.
     inline C2PortParam(bool _output, const Args(&... args))
-        : T(sizeof(_type), _output ? output::typeIndex : input::typeIndex), S(args...) { }
+        : T(sizeof(_Type), _output ? output::PARAM_TYPE : input::PARAM_TYPE), S(args...) { }
     /// Set port/direction.
     inline void setPort(bool output) { C2Param::setPort(output); }
 
-    DEFINE_CAST_OPERATORS(_type)
+    DEFINE_CAST_OPERATORS(_Type)
 
     /// Specialization for an input port parameter.
     struct input : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
-            public C2StructCheck<S, ParamIndex, T::indexFlags | T::Index::kDirInput> {
+            public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
         /// Wrapper around base structure's constructor.
         template<typename ...Args>
-        inline input(const Args(&... args)) : T(sizeof(_type), input::typeIndex), S(args...) { }
+        inline input(const Args(&... args)) : T(sizeof(_Type), input::PARAM_TYPE), S(args...) { }
 
         DEFINE_CAST_OPERATORS(input)
 
@@ -410,10 +410,10 @@
 
     /// Specialization for an output port parameter.
     struct output : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
-            public C2StructCheck<S, ParamIndex, T::indexFlags | T::Index::kDirOutput> {
+            public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
         /// Wrapper around base structure's constructor.
         template<typename ...Args>
-        inline output(const Args(&... args)) : T(sizeof(_type), output::typeIndex), S(args...) { }
+        inline output(const Args(&... args)) : T(sizeof(_Type), output::PARAM_TYPE), S(args...) { }
 
         DEFINE_CAST_OPERATORS(output)
     };
@@ -440,16 +440,16 @@
  */
 template<typename T, typename S, int ParamIndex>
 struct C2_HIDE C2PortParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
-    : public T, public C2FlexStructCheck<S, ParamIndex, T::indexFlags | T::Type::kDirUndefined> {
+    : public T, public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_UNDEFINED> {
 private:
-    typedef C2PortParam<T, S, ParamIndex> _type;
+    typedef C2PortParam<T, S, ParamIndex> _Type;
 
     /// Default constructor for basic allocation: new(flexCount) P.
-    inline C2PortParam(size_t flexCount) : T(_type::calcSize(flexCount), _type::typeIndex) { }
+    inline C2PortParam(size_t flexCount) : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE) { }
     template<typename ...Args>
     /// Wrapper around base structure's constructor while also specifying port/direction.
     inline C2PortParam(size_t flexCount, bool _output, const Args(&... args))
-        : T(_type::calcSize(flexCount), _output ? output::typeIndex : input::typeIndex),
+        : T(_Type::calcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE),
           m(flexCount, args...) { }
 
 public:
@@ -458,17 +458,17 @@
 
     S m; ///< wrapped flexible structure
 
-    DEFINE_FLEXIBLE_METHODS(_type, S)
-    DEFINE_CAST_OPERATORS(_type)
+    DEFINE_FLEXIBLE_METHODS(_Type, S)
+    DEFINE_CAST_OPERATORS(_Type)
 
     /// Specialization for an input port parameter.
     struct input : public T,
-            public C2FlexStructCheck<S, ParamIndex, T::indexFlags | T::Index::kDirInput> {
+            public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
     private:
         /// Wrapper around base structure's constructor while also specifying port/direction.
         template<typename ...Args>
         inline input(size_t flexCount, const Args(&... args))
-            : T(_type::calcSize(flexCount), input::typeIndex), m(flexCount, args...) { }
+            : T(_Type::calcSize(flexCount), input::PARAM_TYPE), m(flexCount, args...) { }
 
     public:
         S m; ///< wrapped flexible structure
@@ -479,12 +479,12 @@
 
     /// Specialization for an output port parameter.
     struct output : public T,
-            public C2FlexStructCheck<S, ParamIndex, T::indexFlags | T::Index::kDirOutput> {
+            public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
     private:
         /// Wrapper around base structure's constructor while also specifying port/direction.
         template<typename ...Args>
         inline output(size_t flexCount, const Args(&... args))
-            : T(_type::calcSize(flexCount), output::typeIndex), m(flexCount, args...) { }
+            : T(_Type::calcSize(flexCount), output::PARAM_TYPE), m(flexCount, args...) { }
 
     public:
         S m; ///< wrapped flexible structure
@@ -515,39 +515,39 @@
  * parameters with unspecified port expose a setPort method, and add an additional initial port
  * parameter to the constructor.
  */
-template<typename T, typename S, int ParamIndex=S::coreIndex, class Flex=void>
+template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
 struct C2_HIDE C2StreamParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
         private C2StructCheck<S, ParamIndex,
-                T::indexFlags | T::Index::kStreamFlag | T::Index::kDirUndefined> {
+                T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Index::DIR_UNDEFINED> {
 private:
-    typedef C2StreamParam<T, S, ParamIndex> _type;
+    typedef C2StreamParam<T, S, ParamIndex> _Type;
 
 public:
     /// Default constructor. Port/direction and stream-ID is undefined.
-    inline C2StreamParam() : T(sizeof(_type), _type::typeIndex) { }
+    inline C2StreamParam() : T(sizeof(_Type), _Type::PARAM_TYPE) { }
     /// Wrapper around base structure's constructor while also specifying port/direction and
     /// stream-ID.
     template<typename ...Args>
     inline C2StreamParam(bool _output, unsigned stream, const Args(&... args))
-        : T(sizeof(_type), _output ? output::typeIndex : input::typeIndex, stream),
+        : T(sizeof(_Type), _output ? output::PARAM_TYPE : input::PARAM_TYPE, stream),
           S(args...) { }
     /// Set port/direction.
     inline void setPort(bool output) { C2Param::setPort(output); }
     /// Set stream-id. \retval true if the stream-id was successfully set.
     inline bool setStream(unsigned stream) { return C2Param::setStream(stream); }
 
-    DEFINE_CAST_OPERATORS(_type)
+    DEFINE_CAST_OPERATORS(_Type)
 
     /// Specialization for an input stream parameter.
     struct input : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
             public C2StructCheck<S, ParamIndex,
-                    T::indexFlags | T::Index::kStreamFlag | T::Type::kDirInput> {
+                    T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> {
         /// Default constructor. Stream-ID is undefined.
-        inline input() : T(sizeof(_type), input::typeIndex) { }
+        inline input() : T(sizeof(_Type), input::PARAM_TYPE) { }
         /// Wrapper around base structure's constructor while also specifying stream-ID.
         template<typename ...Args>
         inline input(unsigned stream, const Args(&... args))
-            : T(sizeof(_type), input::typeIndex, stream), S(args...) { }
+            : T(sizeof(_Type), input::PARAM_TYPE, stream), S(args...) { }
         /// Set stream-id. \retval true if the stream-id was successfully set.
         inline bool setStream(unsigned stream) { return C2Param::setStream(stream); }
 
@@ -557,13 +557,13 @@
     /// Specialization for an output stream parameter.
     struct output : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
             public C2StructCheck<S, ParamIndex,
-                    T::indexFlags | T::Index::kStreamFlag | T::Type::kDirOutput> {
+                    T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> {
         /// Default constructor. Stream-ID is undefined.
-        inline output() : T(sizeof(_type), output::typeIndex) { }
+        inline output() : T(sizeof(_Type), output::PARAM_TYPE) { }
         /// Wrapper around base structure's constructor while also specifying stream-ID.
         template<typename ...Args>
         inline output(unsigned stream, const Args(&... args))
-            : T(sizeof(_type), output::typeIndex, stream), S(args...) { }
+            : T(sizeof(_Type), output::PARAM_TYPE, stream), S(args...) { }
         /// Set stream-id. \retval true if the stream-id was successfully set.
         inline bool setStream(unsigned stream) { return C2Param::setStream(stream); }
 
@@ -596,16 +596,16 @@
 struct C2_HIDE C2StreamParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
     : public T,
       public C2FlexStructCheck<S, ParamIndex,
-              T::indexFlags | T::Index::kStreamFlag | T::Index::kDirUndefined> {
+              T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Index::DIR_UNDEFINED> {
 private:
-    typedef C2StreamParam<T, S, ParamIndex> _type;
+    typedef C2StreamParam<T, S, ParamIndex> _Type;
     /// Default constructor. Port/direction and stream-ID is undefined.
-    inline C2StreamParam(size_t flexCount) : T(_type::calcSize(flexCount), _type::typeIndex, 0u) { }
+    inline C2StreamParam(size_t flexCount) : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE, 0u) { }
     /// Wrapper around base structure's constructor while also specifying port/direction and
     /// stream-ID.
     template<typename ...Args>
     inline C2StreamParam(size_t flexCount, bool _output, unsigned stream, const Args(&... args))
-        : T(_type::calcSize(flexCount), _output ? output::typeIndex : input::typeIndex, stream),
+        : T(_Type::calcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE, stream),
           m(flexCount, args...) { }
 
 public:
@@ -616,20 +616,20 @@
     /// Set stream-id. \retval true if the stream-id was successfully set.
     inline bool setStream(unsigned stream) { return C2Param::setStream(stream); }
 
-    DEFINE_FLEXIBLE_METHODS(_type, S)
-    DEFINE_CAST_OPERATORS(_type)
+    DEFINE_FLEXIBLE_METHODS(_Type, S)
+    DEFINE_CAST_OPERATORS(_Type)
 
     /// Specialization for an input stream parameter.
     struct input : public T,
             public C2FlexStructCheck<S, ParamIndex,
-                    T::indexFlags | T::Index::kStreamFlag | T::Type::kDirInput> {
+                    T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> {
     private:
         /// Default constructor. Stream-ID is undefined.
-        inline input(size_t flexCount) : T(_type::calcSize(flexCount), input::typeIndex) { }
+        inline input(size_t flexCount) : T(_Type::calcSize(flexCount), input::PARAM_TYPE) { }
         /// Wrapper around base structure's constructor while also specifying stream-ID.
         template<typename ...Args>
         inline input(size_t flexCount, unsigned stream, const Args(&... args))
-            : T(_type::calcSize(flexCount), input::typeIndex, stream), m(flexCount, args...) { }
+            : T(_Type::calcSize(flexCount), input::PARAM_TYPE, stream), m(flexCount, args...) { }
 
     public:
         S m; ///< wrapped flexible structure
@@ -644,14 +644,14 @@
     /// Specialization for an output stream parameter.
     struct output : public T,
             public C2FlexStructCheck<S, ParamIndex,
-                    T::indexFlags | T::Index::kStreamFlag | T::Type::kDirOutput> {
+                    T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> {
     private:
         /// Default constructor. Stream-ID is undefined.
-        inline output(size_t flexCount) : T(_type::calcSize(flexCount), output::typeIndex) { }
+        inline output(size_t flexCount) : T(_Type::calcSize(flexCount), output::PARAM_TYPE) { }
         /// Wrapper around base structure's constructor while also specifying stream-ID.
         template<typename ...Args>
         inline output(size_t flexCount, unsigned stream, const Args(&... args))
-            : T(_type::calcSize(flexCount), output::typeIndex, stream), m(flexCount, args...) { }
+            : T(_Type::calcSize(flexCount), output::PARAM_TYPE, stream), m(flexCount, args...) { }
 
     public:
         S m; ///< wrapped flexible structure
@@ -672,11 +672,11 @@
  */
 template<typename T>
 struct C2SimpleValueStruct {
-    T mValue; ///< simple value of the structure
+    T value; ///< simple value of the structure
     // Default constructor.
     inline C2SimpleValueStruct() = default;
     // Constructor with an initial value.
-    inline C2SimpleValueStruct(T value) : mValue(value) {}
+    inline C2SimpleValueStruct(T value) : value(value) {}
     DEFINE_BASE_C2STRUCT(SimpleValue)
 };
 
@@ -704,16 +704,16 @@
  */
 template<typename T>
 struct C2ConstMemoryBlock : public C2MemoryBlock<T> {
-    virtual const T * data() const { return mData; }
-    virtual size_t size() const { return mSize; }
+    virtual const T * data() const { return _mData; }
+    virtual size_t size() const { return _mSize; }
 
     /// Constructor.
     template<unsigned N>
-    inline constexpr C2ConstMemoryBlock(const T(&init)[N]) : mData(init), mSize(N) {}
+    inline constexpr C2ConstMemoryBlock(const T(&init)[N]) : _mData(init), _mSize(N) {}
 
 private:
-    const T *mData;
-    const size_t mSize;
+    const T *_mData;
+    const size_t _mSize;
 };
 
 /// \addtogroup internal
@@ -770,30 +770,30 @@
  * constructed on its own as it's size is 0.
  *
  * \internal This is different from C2SimpleArrayStruct<T[]> simply because its member has the name
- * as mValue to reflect this is a single value.
+ * as value to reflect this is a single value.
  */
 template<typename T>
 struct C2SimpleValueStruct<T[]> {
     static_assert(std::is_same<T, char>::value || std::is_same<T, uint8_t>::value,
                   "C2SimpleValueStruct<T[]> is only for BLOB or STRING");
-    T mValue[];
+    T value[];
 
     inline C2SimpleValueStruct() = default;
     DEFINE_BASE_C2STRUCT(SimpleValue)
-    FLEX(C2SimpleValueStruct, mValue)
+    FLEX(C2SimpleValueStruct, value)
 
 private:
     inline C2SimpleValueStruct(size_t flexCount, const C2MemoryBlock<T> &block) {
-        _C2ValueArrayHelper::init(mValue, flexCount, block);
+        _C2ValueArrayHelper::init(value, flexCount, block);
     }
 
     inline C2SimpleValueStruct(size_t flexCount, const std::initializer_list<T> &init) {
-        _C2ValueArrayHelper::init(mValue, flexCount, init);
+        _C2ValueArrayHelper::init(value, flexCount, init);
     }
 
     template<unsigned N>
     inline C2SimpleValueStruct(size_t flexCount, const T(&init)[N]) {
-        _C2ValueArrayHelper::init(mValue, flexCount, init);
+        _C2ValueArrayHelper::init(value, flexCount, init);
     }
 };
 
@@ -812,30 +812,30 @@
     static_assert(!std::is_same<T, char>::value && !std::is_same<T, uint8_t>::value,
                   "use C2SimpleValueStruct<T[]> is for BLOB or STRING");
 
-    T mValues[]; ///< array member
+    T values[]; ///< array member
     /// Default constructor
     inline C2SimpleArrayStruct() = default;
-    DEFINE_BASE_FLEX_C2STRUCT(SimpleArray, mValues)
-    //FLEX(C2SimpleArrayStruct, mValues)
+    DEFINE_BASE_FLEX_C2STRUCT(SimpleArray, values)
+    //FLEX(C2SimpleArrayStruct, values)
 
 private:
     /// Construct from a C2MemoryBlock.
     /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
     inline C2SimpleArrayStruct(size_t flexCount, const C2MemoryBlock<T> &block) {
-        _C2ValueArrayHelper::init(mValues, flexCount, block);
+        _C2ValueArrayHelper::init(values, flexCount, block);
     }
 
     /// Construct from an initializer list.
     /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
     inline C2SimpleArrayStruct(size_t flexCount, const std::initializer_list<T> &init) {
-        _C2ValueArrayHelper::init(mValues, flexCount, init);
+        _C2ValueArrayHelper::init(values, flexCount, init);
     }
 
     /// Construct from another flexible array.
     /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
     template<unsigned N>
     inline C2SimpleArrayStruct(size_t flexCount, const T(&init)[N]) {
-        _C2ValueArrayHelper::init(mValues, flexCount, init);
+        _C2ValueArrayHelper::init(values, flexCount, init);
     }
 };
 
@@ -851,54 +851,54 @@
  *   typedef C2PortParam<C2Tuning, C2Int32Value, kParamIndexMyIntegerPortParam>
  *           C2MyIntegerPortParamTuning;
  *
- * They contain a single member (mValue or mValues) that is described as "value" or "values".
+ * They contain a single member (value or values) that is described as "value" or "values".
  */
-/// A 32-bit signed integer parameter in mValue, described as "value"
+/// A 32-bit signed integer parameter in value, described as "value"
 typedef C2SimpleValueStruct<int32_t> C2Int32Value;
-/// A 32-bit signed integer array parameter in mValues, described as "values"
+/// A 32-bit signed integer array parameter in values, described as "values"
 typedef C2SimpleArrayStruct<int32_t> C2Int32Array;
-/// A 32-bit unsigned integer parameter in mValue, described as "value"
+/// A 32-bit unsigned integer parameter in value, described as "value"
 typedef C2SimpleValueStruct<uint32_t> C2Uint32Value;
-/// A 32-bit unsigned integer array parameter in mValues, described as "values"
+/// A 32-bit unsigned integer array parameter in values, described as "values"
 typedef C2SimpleArrayStruct<uint32_t> C2Uint32Array;
-/// A 64-bit signed integer parameter in mValue, described as "value"
+/// A 64-bit signed integer parameter in value, described as "value"
 typedef C2SimpleValueStruct<int64_t> C2Int64Value;
-/// A 64-bit signed integer array parameter in mValues, described as "values"
+/// A 64-bit signed integer array parameter in values, described as "values"
 typedef C2SimpleArrayStruct<int64_t> C2Int64Array;
-/// A 64-bit unsigned integer parameter in mValue, described as "value"
+/// A 64-bit unsigned integer parameter in value, described as "value"
 typedef C2SimpleValueStruct<uint64_t> C2Uint64Value;
-/// A 64-bit unsigned integer array parameter in mValues, described as "values"
+/// A 64-bit unsigned integer array parameter in values, described as "values"
 typedef C2SimpleArrayStruct<uint64_t> C2Uint64Array;
-/// A float parameter in mValue, described as "value"
+/// A float parameter in value, described as "value"
 typedef C2SimpleValueStruct<float> C2FloatValue;
-/// A float array parameter in mValues, described as "values"
+/// A float array parameter in values, described as "values"
 typedef C2SimpleArrayStruct<float> C2FloatArray;
-/// A blob flexible parameter in mValue, described as "value"
+/// A blob flexible parameter in value, described as "value"
 typedef C2SimpleValueStruct<uint8_t[]> C2BlobValue;
-/// A string flexible parameter in mValue, described as "value"
+/// A string flexible parameter in value, described as "value"
 typedef C2SimpleValueStruct<char[]> C2StringValue;
 
 #if 1
 template<typename T>
-const std::initializer_list<const C2FieldDescriptor> C2SimpleValueStruct<T>::fieldList = { C2FIELD(mValue, "value") };
+const std::initializer_list<const C2FieldDescriptor> C2SimpleValueStruct<T>::FIELD_LIST = { C2FIELD(value, "value") };
 template<typename T>
-const std::initializer_list<const C2FieldDescriptor> C2SimpleValueStruct<T[]>::fieldList = { C2FIELD(mValue, "value") };
+const std::initializer_list<const C2FieldDescriptor> C2SimpleValueStruct<T[]>::FIELD_LIST = { C2FIELD(value, "value") };
 template<typename T>
-const std::initializer_list<const C2FieldDescriptor> C2SimpleArrayStruct<T>::fieldList = { C2FIELD(mValues, "values") };
+const std::initializer_list<const C2FieldDescriptor> C2SimpleArrayStruct<T>::FIELD_LIST = { C2FIELD(values, "values") };
 #else
 // This seem to be able to be handled by the template above
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<int32_t>, { C2FIELD(mValue, "value") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<uint32_t>, { C2FIELD(mValue, "value") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<int64_t>, { C2FIELD(mValue, "value") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<uint64_t>, { C2FIELD(mValue, "value") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<float>, { C2FIELD(mValue, "value") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<uint8_t[]>, { C2FIELD(mValue, "value") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<char[]>, { C2FIELD(mValue, "value") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<int32_t>, { C2FIELD(mValues, "values") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<uint32_t>, { C2FIELD(mValues, "values") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<int64_t>, { C2FIELD(mValues, "values") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<uint64_t>, { C2FIELD(mValues, "values") });
-DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<float>, { C2FIELD(mValues, "values") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<int32_t>, { C2FIELD(value, "value") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<uint32_t>, { C2FIELD(value, "value") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<int64_t>, { C2FIELD(value, "value") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<uint64_t>, { C2FIELD(value, "value") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<float>, { C2FIELD(value, "value") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<uint8_t[]>, { C2FIELD(value, "value") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleValueStruct<char[]>, { C2FIELD(value, "value") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<int32_t>, { C2FIELD(values, "values") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<uint32_t>, { C2FIELD(values, "values") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<int64_t>, { C2FIELD(values, "values") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<uint64_t>, { C2FIELD(values, "values") });
+DESCRIBE_TEMPLATED_C2STRUCT(C2SimpleArrayStruct<float>, { C2FIELD(values, "values") });
 #endif
 
 /// @}
diff --git a/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp b/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
index 8333fb8..339f927 100644
--- a/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
+++ b/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
@@ -38,7 +38,7 @@
 template <class T> std::unique_ptr<T> alloc_unique_cstr(const char *cstr) {
     size_t len = strlen(cstr);
     std::unique_ptr<T> ptr = T::alloc_unique(len);
-    memcpy(ptr->m.mValue, cstr, len);
+    memcpy(ptr->m.value, cstr, len);
     return ptr;
 }
 
@@ -202,7 +202,7 @@
 template <typename T>
 c2_status_t C2CompIntfTest::queryOnHeap(
         const T &p, std::vector<std::unique_ptr<C2Param>> *const heapParams) {
-    uint32_t index = p.type();
+    uint32_t index = p.index() & ~0x03FE0000;
     if (p.forStream()) {
         index |= ((p.stream() << 17) & 0x01FE0000) | 0x02000000;
     }
@@ -369,12 +369,12 @@
     const auto &c2FSV = validValueInfos;
 
     switch (c2FSV.type) {
-    case C2FieldSupportedValues::Type::EMPTY: {
+    case C2FieldSupportedValues::type_t::EMPTY: {
         invalidValues->emplace_back(TField(0));
         // TODO(hiroh) : Should other invalid values be tested?
         break;
     }
-    case C2FieldSupportedValues::Type::RANGE: {
+    case C2FieldSupportedValues::type_t::RANGE: {
         const auto &range = c2FSV.range;
         auto rmin = prim2Value(range.min);
         auto rmax = prim2Value(range.max);
@@ -448,7 +448,7 @@
         }
         break;
     }
-    case C2FieldSupportedValues::Type::VALUES: {
+    case C2FieldSupportedValues::type_t::VALUES: {
         for (const C2Value::Primitive &prim : c2FSV.values) {
             validValues->emplace_back(prim2Value(prim));
         }
@@ -462,7 +462,7 @@
         }
         break;
     }
-    case C2FieldSupportedValues::Type::FLAGS: {
+    case C2FieldSupportedValues::type_t::FLAGS: {
         // TODO(hiroh) : Implement the case that param.type is FLAGS.
         break;
     }
@@ -605,21 +605,21 @@
 
 #define TEST_VSSTRUCT_WRITABLE_FIELD(TParam_, field_type_name_)         \
     do {                                                                \
-        TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, mWidth); \
-        TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, mHeight);\
+        TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, width);  \
+        TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, height); \
     } while (0)
 
 #define TEST_U32_WRITABLE_FIELD(TParam_, field_type_name_)              \
-  TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, mValue)
+  TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, value)
 
 #define TEST_ENUM_WRITABLE_FIELD(TParam_, field_type_name_)             \
-  TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, mValue)
+  TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, value)
 
 // TODO(hiroh): Support parameters based on char[] and uint32_t[].
 //#define TEST_STRING_WRITABLE_FIELD(TParam_, field_type_name_)
-// TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, m.mValue)
+// TEST_GENERAL_WRITABLE_FIELD(TParam_, field_type_name_, m.value)
 //#define TEST_U32ARRAY_WRITABLE_FIELD(Tparam_, field_type_name_)
-// TEST_GENERAL_WRITABLE_FIELD(Tparam_, uint32_t[], field_type_name_, mValues)
+// TEST_GENERAL_WRITABLE_FIELD(Tparam_, uint32_t[], field_type_name_, values)
 
 #define EACH_TEST(TParam_, field_type_name_, test_name)                 \
     do {                                                                \
diff --git a/media/libstagefright/codec2/tests/C2Param_test.cpp b/media/libstagefright/codec2/tests/C2Param_test.cpp
index 05f8a96..8ebc584 100644
--- a/media/libstagefright/codec2/tests/C2Param_test.cpp
+++ b/media/libstagefright/codec2/tests/C2Param_test.cpp
@@ -57,11 +57,11 @@
     *os << "*" << fd.length() << ")";
 }
 
-enum C2ParamIndexType {
+enum C2ParamIndexType : C2Param::type_index_t {
     kParamIndexNumber,
     kParamIndexNumbers,
     kParamIndexNumber2,
-    kParamIndexVendorStart = C2Param::BaseIndex::kVendorStart,
+    kParamIndexVendorStart = C2Param::TYPE_INDEX_VENDOR_START,
     kParamIndexVendorNumbers,
 };
 
@@ -91,11 +91,11 @@
 };
 
 struct C2SizeStruct {
-    int32_t mNumber;
-    int32_t mHeight;
-    enum : uint32_t { coreIndex = kParamIndexSize };                        // <= needed for C2FieldDescriptor
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;  // <= needed for C2FieldDescriptor
-    const static FD::Type TYPE = (FD::Type)(coreIndex | FD::STRUCT_FLAG);
+    int32_t width;
+    int32_t height;
+    enum : uint32_t { CORE_INDEX = kParamIndexSize };                        // <= needed for C2FieldDescriptor
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;  // <= needed for C2FieldDescriptor
+    const static FD::type_t TYPE = (FD::type_t)(CORE_INDEX | FD::STRUCT_FLAG);
 };
 
 DEFINE_NO_NAMED_VALUES_FOR(C2SizeStruct)
@@ -110,22 +110,22 @@
 }
 
 struct C2TestStruct_A {
-    int32_t mSigned32;
-    int64_t mSigned64[2];
-    uint32_t mUnsigned32[1];
-    uint64_t mUnsigned64;
-    float mFloat;
-    C2SizeStruct mSize[3];
-    uint8_t mBlob[100];
-    char mString[100];
-    bool mYesNo[100];
+    int32_t signed32;
+    int64_t signed64[2];
+    uint32_t unsigned32[1];
+    uint64_t unsigned64;
+    float fp32;
+    C2SizeStruct sz[3];
+    uint8_t blob[100];
+    char string[100];
+    bool yesNo[100];
 
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;
-    // enum : uint32_t { coreIndex = kParamIndexTest };
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;
+    // enum : uint32_t { CORE_INDEX = kParamIndexTest };
     // typedef C2TestStruct_A _type;
 } __attribute__((packed));
 
-const std::initializer_list<const C2FieldDescriptor> C2TestStruct_A::fieldList =
+const std::initializer_list<const C2FieldDescriptor> C2TestStruct_A::FIELD_LIST =
     { { FD::INT32,    1, "s32",   0, 4 },
       { FD::INT64,    2, "s64",   4, 8 },
       { FD::UINT32,   1, "u32",  20, 4 },
@@ -137,7 +137,7 @@
       { FD::BLOB,   100, "y-n", 260, 1 } };
 
 TEST_P(C2ParamTest_ParamFieldList, VerifyStruct) {
-    std::vector<const C2FieldDescriptor> fields = GetParam(), expected = C2TestStruct_A::fieldList;
+    std::vector<const C2FieldDescriptor> fields = GetParam(), expected = C2TestStruct_A::FIELD_LIST;
 
     // verify first field descriptor
     EXPECT_EQ(FD::INT32, fields[0].type());
@@ -158,34 +158,34 @@
     }
 }
 
-INSTANTIATE_TEST_CASE_P(InitializerList, C2ParamTest_ParamFieldList, ::testing::Values(C2TestStruct_A::fieldList));
+INSTANTIATE_TEST_CASE_P(InitializerList, C2ParamTest_ParamFieldList, ::testing::Values(C2TestStruct_A::FIELD_LIST));
 
 // define fields using C2FieldDescriptor pointer constructor
 const std::initializer_list<const C2FieldDescriptor> C2TestStruct_A_FD_PTR_fieldList =
-    { C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mSigned32,   "s32"),
-      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mSigned64,   "s64"),
-      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mUnsigned32, "u32"),
-      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mUnsigned64, "u64"),
-      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mFloat,      "fp"),
-      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mSize,       "size"),
-      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mBlob,       "blob"),
-      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mString,     "str"),
-    //  C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->mYesNo,      "y-n")
+    { C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->signed32,   "s32"),
+      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->signed64,   "s64"),
+      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->unsigned32, "u32"),
+      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->unsigned64, "u64"),
+      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->fp32,      "fp"),
+      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->sz,       "size"),
+      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->blob,       "blob"),
+      C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->string,     "str"),
+    //  C2FieldDescriptor(&((C2TestStruct_A*)(nullptr))->yesNo,      "y-n")
     };
 
 INSTANTIATE_TEST_CASE_P(PointerConstructor, C2ParamTest_ParamFieldList, ::testing::Values(C2TestStruct_A_FD_PTR_fieldList));
 
 // define fields using C2FieldDescriptor member-pointer constructor
 const std::initializer_list<const C2FieldDescriptor> C2TestStruct_A_FD_MEM_PTR_fieldList =
-    { C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mSigned32,   "s32"),
-      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mSigned64,   "s64"),
-      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mUnsigned32, "u32"),
-      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mUnsigned64, "u64"),
-      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mFloat,      "fp"),
-      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mSize,       "size"),
-      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mBlob,       "blob"),
-      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mString,     "str"),
-    //  C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::mYesNo,      "y-n")
+    { C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::signed32,   "s32"),
+      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::signed64,   "s64"),
+      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::unsigned32, "u32"),
+      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::unsigned64, "u64"),
+      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::fp32,      "fp"),
+      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::sz,       "size"),
+      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::blob,       "blob"),
+      C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::string,     "str"),
+    //  C2FieldDescriptor((C2TestStruct_A*)0, &C2TestStruct_A::yesNo,      "y-n")
     };
 
 INSTANTIATE_TEST_CASE_P(MemberPointerConstructor, C2ParamTest_ParamFieldList, ::testing::Values(C2TestStruct_A_FD_MEM_PTR_fieldList));
@@ -193,75 +193,75 @@
 // Test 2. define a structure with two-step helper methods
 
 struct C2TestAStruct {
-    int32_t mSigned32;
-    int64_t mSigned64[2];
-    uint32_t mUnsigned32[1];
-    uint64_t mUnsigned64;
-    float mFloat;
-    C2SizeStruct mSize[3];
-    uint8_t mBlob[100];
-    char mString[100];
-    bool mYesNo[100];
+    int32_t signed32;
+    int64_t signed64[2];
+    uint32_t unsigned32[1];
+    uint64_t unsigned64;
+    float fp32;
+    C2SizeStruct sz[3];
+    uint8_t blob[100];
+    char string[100];
+    bool yesNo[100];
 
 private: // test access level
     DEFINE_C2STRUCT(TestA)
 } C2_PACK;
 
 DESCRIBE_C2STRUCT(TestA, {
-    C2FIELD(mSigned32, "s32")
-    C2FIELD(mSigned64, "s64")
-    C2FIELD(mUnsigned32, "u32")
-    C2FIELD(mUnsigned64, "u64")
-    C2FIELD(mFloat, "fp")
-    C2FIELD(mSize, "size")
-    C2FIELD(mBlob, "blob")
-    C2FIELD(mString, "str")
-    // C2FIELD(mYesNo, "y-n")
+    C2FIELD(signed32, "s32")
+    C2FIELD(signed64, "s64")
+    C2FIELD(unsigned32, "u32")
+    C2FIELD(unsigned64, "u64")
+    C2FIELD(fp32, "fp")
+    C2FIELD(sz, "size")
+    C2FIELD(blob, "blob")
+    C2FIELD(string, "str")
+    // C2FIELD(yesNo, "y-n")
 }) // ; optional
 
-INSTANTIATE_TEST_CASE_P(DescribeStruct2Step, C2ParamTest_ParamFieldList, ::testing::Values(C2TestAStruct::fieldList));
+INSTANTIATE_TEST_CASE_P(DescribeStruct2Step, C2ParamTest_ParamFieldList, ::testing::Values(C2TestAStruct::FIELD_LIST));
 
 // Test 3. define a structure with one-step helper method
 
 struct C2TestBStruct {
-    int32_t mSigned32;
-    int64_t mSigned64[2];
-    uint32_t mUnsigned32[1];
-    uint64_t mUnsigned64;
-    float mFloat;
-    C2SizeStruct mSize[3];
-    uint8_t mBlob[100];
-    char mString[100];
-    bool mYesNo[100];
+    int32_t signed32;
+    int64_t signed64[2];
+    uint32_t unsigned32[1];
+    uint64_t unsigned64;
+    float fp32;
+    C2SizeStruct sz[3];
+    uint8_t blob[100];
+    char string[100];
+    bool yesNo[100];
 
 private: // test access level
     DEFINE_AND_DESCRIBE_C2STRUCT(TestB)
 
-    C2FIELD(mSigned32, "s32")
-    C2FIELD(mSigned64, "s64")
-    C2FIELD(mUnsigned32, "u32")
-    C2FIELD(mUnsigned64, "u64")
-    C2FIELD(mFloat, "fp")
-    C2FIELD(mSize, "size")
-    C2FIELD(mBlob, "blob")
-    C2FIELD(mString, "str")
-    // C2FIELD(mYesNo, "y-n")
+    C2FIELD(signed32, "s32")
+    C2FIELD(signed64, "s64")
+    C2FIELD(unsigned32, "u32")
+    C2FIELD(unsigned64, "u64")
+    C2FIELD(fp32, "fp")
+    C2FIELD(sz, "size")
+    C2FIELD(blob, "blob")
+    C2FIELD(string, "str")
+    // C2FIELD(yesNo, "y-n")
 };
 
-INSTANTIATE_TEST_CASE_P(DescribeStruct1Step, C2ParamTest_ParamFieldList, ::testing::Values(C2TestBStruct::fieldList));
+INSTANTIATE_TEST_CASE_P(DescribeStruct1Step, C2ParamTest_ParamFieldList, ::testing::Values(C2TestBStruct::FIELD_LIST));
 
 // Test 4. flexible members
 
 template<typename T>
 class C2ParamTest_FlexParamFieldList : public ::testing::Test {
 protected:
-    using Type=FD::Type;
+    using type_t=FD::type_t;
 
     // static std::initializer_list<std::initializer_list<const C2FieldDescriptor>>
     static std::vector<std::vector<const C2FieldDescriptor>>
             GetLists();
 
-    constexpr static Type flexType =
+    constexpr static type_t FlexType =
             std::is_same<T, int32_t>::value ? FD::INT32 :
             std::is_same<T, int64_t>::value ? FD::INT64 :
             std::is_same<T, uint32_t>::value ? FD::UINT32 :
@@ -269,8 +269,8 @@
             std::is_same<T, float>::value ? FD::FLOAT :
             std::is_same<T, uint8_t>::value ? FD::BLOB :
             std::is_same<T, char>::value ? FD::STRING :
-            std::is_same<T, C2SizeStruct>::value ? C2SizeStruct::TYPE : (Type)0;
-    constexpr static size_t flexSize = sizeof(T);
+            std::is_same<T, C2SizeStruct>::value ? C2SizeStruct::TYPE : (type_t)0;
+    constexpr static size_t FLEX_SIZE = sizeof(T);
 };
 
 typedef ::testing::Types<int32_t, int64_t, C2SizeStruct> FlexTypes;
@@ -282,11 +282,11 @@
         if (fields.size() > 1) {
             EXPECT_EQ(2u, fields.size());
             EXPECT_EQ(C2FieldDescriptor(FD::INT32, 1, "s32", 0, 4), fields[0]);
-            EXPECT_EQ(C2FieldDescriptor(this->flexType, 0, "flex", 4, this->flexSize),
+            EXPECT_EQ(C2FieldDescriptor(this->FlexType, 0, "flex", 4, this->FLEX_SIZE),
                       fields[1]);
         } else {
             EXPECT_EQ(1u, fields.size());
-            EXPECT_EQ(C2FieldDescriptor(this->flexType, 0, "flex", 0, this->flexSize),
+            EXPECT_EQ(C2FieldDescriptor(this->FlexType, 0, "flex", 0, this->FLEX_SIZE),
                       fields[0]);
         }
     }
@@ -295,33 +295,33 @@
 struct C2TestStruct_FlexS32 {
     int32_t mFlex[];
 
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;
-    // enum : uint32_t { coreIndex = kParamIndexTestFlex, flexSize = 4 };
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;
+    // enum : uint32_t { CORE_INDEX = kParamIndexTestFlex, FLEX_SIZE = 4 };
     // typedef C2TestStruct_FlexS32 _type;
-    // typedef int32_t flexType;
+    // typedef int32_t FlexType;
 };
 
-const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexS32::fieldList = {
+const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexS32::FIELD_LIST = {
     { FD::INT32, 0, "flex", 0, 4 }
 };
 
 struct C2TestStruct_FlexEndS32 {
-    int32_t mSigned32;
+    int32_t signed32;
     int32_t mFlex[];
 
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;
-    // enum : uint32_t { coreIndex = kParamIndexTestFlexEnd, flexSize = 4 };
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;
+    // enum : uint32_t { CORE_INDEX = kParamIndexTestFlexEnd, FLEX_SIZE = 4 };
     // typedef C2TestStruct_FlexEnd _type;
-    // typedef int32_t flexType;
+    // typedef int32_t FlexType;
 };
 
-const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexEndS32::fieldList = {
+const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexEndS32::FIELD_LIST = {
     { FD::INT32, 1, "s32", 0, 4 },
     { FD::INT32, 0, "flex", 4, 4 },
 };
 
 const static std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexEndS32_ptr_fieldList = {
-    C2FieldDescriptor(&((C2TestStruct_FlexEndS32*)0)->mSigned32, "s32"),
+    C2FieldDescriptor(&((C2TestStruct_FlexEndS32*)0)->signed32, "s32"),
     C2FieldDescriptor(&((C2TestStruct_FlexEndS32*)0)->mFlex, "flex"),
 };
 
@@ -335,7 +335,7 @@
 };
 
 struct C2TestFlexEndS32Struct {
-    int32_t mSigned32;
+    int32_t signed32;
     int32_t mFlexSigned32[];
 private: // test access level
     C2TestFlexEndS32Struct() {}
@@ -344,7 +344,7 @@
 } C2_PACK;
 
 DESCRIBE_C2STRUCT(TestFlexEndS32, {
-    C2FIELD(mSigned32, "s32")
+    C2FIELD(signed32, "s32")
     C2FIELD(mFlexSigned32, "flex")
 }) // ; optional
 
@@ -353,38 +353,38 @@
 //std::initializer_list<std::initializer_list<const C2FieldDescriptor>>
 C2ParamTest_FlexParamFieldList<int32_t>::GetLists() {
     return {
-        C2TestStruct_FlexS32::fieldList,
-        C2TestStruct_FlexEndS32::fieldList,
+        C2TestStruct_FlexS32::FIELD_LIST,
+        C2TestStruct_FlexEndS32::FIELD_LIST,
         C2TestStruct_FlexEndS32_ptr_fieldList,
-        C2TestFlexS32Struct::fieldList,
-        C2TestFlexEndS32Struct::fieldList,
+        C2TestFlexS32Struct::FIELD_LIST,
+        C2TestFlexEndS32Struct::FIELD_LIST,
     };
 }
 
 struct C2TestStruct_FlexS64 {
     int64_t mFlexSigned64[];
 
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;
-    // enum : uint32_t { coreIndex = kParamIndexTestFlexS64, flexSize = 8 };
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;
+    // enum : uint32_t { CORE_INDEX = kParamIndexTestFlexS64, FLEX_SIZE = 8 };
     // typedef C2TestStruct_FlexS64 _type;
-    // typedef int64_t flexType;
+    // typedef int64_t FlexType;
 };
 
-const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexS64::fieldList = {
+const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexS64::FIELD_LIST = {
     { FD::INT64, 0, "flex", 0, 8 }
 };
 
 struct C2TestStruct_FlexEndS64 {
-    int32_t mSigned32;
+    int32_t signed32;
     int64_t mSigned64Flex[];
 
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;
-    // enum : uint32_t { coreIndex = C2TestStruct_FlexEndS64, flexSize = 8 };
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;
+    // enum : uint32_t { CORE_INDEX = C2TestStruct_FlexEndS64, FLEX_SIZE = 8 };
     // typedef C2TestStruct_FlexEndS64 _type;
-    // typedef int64_t flexType;
+    // typedef int64_t FlexType;
 };
 
-const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexEndS64::fieldList = {
+const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexEndS64::FIELD_LIST = {
     { FD::INT32, 1, "s32", 0, 4 },
     { FD::INT64, 0, "flex", 4, 8 },
 };
@@ -398,7 +398,7 @@
 };
 
 struct C2TestFlexEndS64Struct {
-    int32_t mSigned32;
+    int32_t signed32;
     int64_t mFlexSigned64[];
     C2TestFlexEndS64Struct() {}
 
@@ -406,7 +406,7 @@
 } C2_PACK;
 
 DESCRIBE_C2STRUCT(TestFlexEndS64, {
-    C2FIELD(mSigned32, "s32")
+    C2FIELD(signed32, "s32")
     C2FIELD(mFlexSigned64, "flex")
 }) // ; optional
 
@@ -415,37 +415,37 @@
 //std::initializer_list<std::initializer_list<const C2FieldDescriptor>>
 C2ParamTest_FlexParamFieldList<int64_t>::GetLists() {
     return {
-        C2TestStruct_FlexS64::fieldList,
-        C2TestStruct_FlexEndS64::fieldList,
-        C2TestFlexS64Struct::fieldList,
-        C2TestFlexEndS64Struct::fieldList,
+        C2TestStruct_FlexS64::FIELD_LIST,
+        C2TestStruct_FlexEndS64::FIELD_LIST,
+        C2TestFlexS64Struct::FIELD_LIST,
+        C2TestFlexEndS64Struct::FIELD_LIST,
     };
 }
 
 struct C2TestStruct_FlexSize {
     C2SizeStruct mFlexSize[];
 
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;
-    // enum : uint32_t { coreIndex = kParamIndexTestFlexSize, flexSize = 8 };
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;
+    // enum : uint32_t { CORE_INDEX = kParamIndexTestFlexSize, FLEX_SIZE = 8 };
     // typedef C2TestStruct_FlexSize _type;
-    // typedef C2SizeStruct flexType;
+    // typedef C2SizeStruct FlexType;
 };
 
-const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexSize::fieldList = {
+const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexSize::FIELD_LIST = {
     { C2SizeStruct::TYPE, 0, "flex", 0, sizeof(C2SizeStruct) }
 };
 
 struct C2TestStruct_FlexEndSize {
-    int32_t mSigned32;
+    int32_t signed32;
     C2SizeStruct mSizeFlex[];
 
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;
-    // enum : uint32_t { coreIndex = C2TestStruct_FlexEndSize, flexSize = 8 };
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;
+    // enum : uint32_t { CORE_INDEX = C2TestStruct_FlexEndSize, FLEX_SIZE = 8 };
     // typedef C2TestStruct_FlexEndSize _type;
-    // typedef C2SizeStruct flexType;
+    // typedef C2SizeStruct FlexType;
 };
 
-const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexEndSize::fieldList = {
+const std::initializer_list<const C2FieldDescriptor> C2TestStruct_FlexEndSize::FIELD_LIST = {
     { FD::INT32, 1, "s32", 0, 4 },
     { C2SizeStruct::TYPE, 0, "flex", 4, sizeof(C2SizeStruct) },
 };
@@ -459,7 +459,7 @@
 };
 
 struct C2TestFlexEndSizeStruct {
-    int32_t mSigned32;
+    int32_t signed32;
     C2SizeStruct mFlexSize[];
     C2TestFlexEndSizeStruct() {}
 
@@ -467,12 +467,12 @@
 } C2_PACK;
 
 DESCRIBE_C2STRUCT(TestFlexEndSize, {
-    C2FIELD(mSigned32, "s32")
+    C2FIELD(signed32, "s32")
     C2FIELD(mFlexSize, "flex")
 }) // ; optional
 
 struct C2TestBaseFlexEndSizeStruct {
-    int32_t mSigned32;
+    int32_t signed32;
     C2SizeStruct mFlexSize[];
     C2TestBaseFlexEndSizeStruct() {}
 
@@ -480,17 +480,17 @@
 } C2_PACK;
 
 DESCRIBE_C2STRUCT(TestBaseFlexEndSize, {
-    C2FIELD(mSigned32, "s32")
+    C2FIELD(signed32, "s32")
     C2FIELD(mFlexSize, "flex")
 }) // ; optional
 
 struct C2TestBaseFlexEndSize2Struct {
-    int32_t mSigned32;
+    int32_t signed32;
     C2SizeStruct mFlexSize[];
     C2TestBaseFlexEndSize2Struct() {}
 
     DEFINE_AND_DESCRIBE_BASE_FLEX_C2STRUCT(TestBaseFlexEndSize2, mFlexSize)
-    C2FIELD(mSigned32, "s32")
+    C2FIELD(signed32, "s32")
     C2FIELD(mFlexSize, "flex")
 };
 
@@ -499,65 +499,65 @@
 //std::initializer_list<std::initializer_list<const C2FieldDescriptor>>
 C2ParamTest_FlexParamFieldList<C2SizeStruct>::GetLists() {
     return {
-        C2TestStruct_FlexSize::fieldList,
-        C2TestStruct_FlexEndSize::fieldList,
-        C2TestFlexSizeStruct::fieldList,
-        C2TestFlexEndSizeStruct::fieldList,
-        C2TestBaseFlexEndSizeStruct::fieldList,
-        C2TestBaseFlexEndSize2Struct::fieldList,
+        C2TestStruct_FlexSize::FIELD_LIST,
+        C2TestStruct_FlexEndSize::FIELD_LIST,
+        C2TestFlexSizeStruct::FIELD_LIST,
+        C2TestFlexEndSizeStruct::FIELD_LIST,
+        C2TestBaseFlexEndSizeStruct::FIELD_LIST,
+        C2TestBaseFlexEndSize2Struct::FIELD_LIST,
     };
 }
 
 TEST_F(C2ParamTest, FieldId) {
     // pointer constructor
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&((C2TestStruct_A*)0)->mSigned32));
-    EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId(&((C2TestStruct_A*)0)->mSigned64));
-    EXPECT_EQ(_C2FieldId(20, 4), _C2FieldId(&((C2TestStruct_A*)0)->mUnsigned32));
-    EXPECT_EQ(_C2FieldId(24, 8), _C2FieldId(&((C2TestStruct_A*)0)->mUnsigned64));
-    EXPECT_EQ(_C2FieldId(32, 4), _C2FieldId(&((C2TestStruct_A*)0)->mFloat));
-    EXPECT_EQ(_C2FieldId(36, 8), _C2FieldId(&((C2TestStruct_A*)0)->mSize));
-    EXPECT_EQ(_C2FieldId(60, 1), _C2FieldId(&((C2TestStruct_A*)0)->mBlob));
-    EXPECT_EQ(_C2FieldId(160, 1), _C2FieldId(&((C2TestStruct_A*)0)->mString));
-    EXPECT_EQ(_C2FieldId(260, 1), _C2FieldId(&((C2TestStruct_A*)0)->mYesNo));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&((C2TestStruct_A*)0)->signed32));
+    EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId(&((C2TestStruct_A*)0)->signed64));
+    EXPECT_EQ(_C2FieldId(20, 4), _C2FieldId(&((C2TestStruct_A*)0)->unsigned32));
+    EXPECT_EQ(_C2FieldId(24, 8), _C2FieldId(&((C2TestStruct_A*)0)->unsigned64));
+    EXPECT_EQ(_C2FieldId(32, 4), _C2FieldId(&((C2TestStruct_A*)0)->fp32));
+    EXPECT_EQ(_C2FieldId(36, 8), _C2FieldId(&((C2TestStruct_A*)0)->sz));
+    EXPECT_EQ(_C2FieldId(60, 1), _C2FieldId(&((C2TestStruct_A*)0)->blob));
+    EXPECT_EQ(_C2FieldId(160, 1), _C2FieldId(&((C2TestStruct_A*)0)->string));
+    EXPECT_EQ(_C2FieldId(260, 1), _C2FieldId(&((C2TestStruct_A*)0)->yesNo));
 
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&((C2TestFlexEndSizeStruct*)0)->mSigned32));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&((C2TestFlexEndSizeStruct*)0)->signed32));
     EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId(&((C2TestFlexEndSizeStruct*)0)->mFlexSize));
 
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&((C2TestBaseFlexEndSizeStruct*)0)->mSigned32));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&((C2TestBaseFlexEndSizeStruct*)0)->signed32));
     EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId(&((C2TestBaseFlexEndSizeStruct*)0)->mFlexSize));
 
     // member pointer constructor
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mSigned32));
-    EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mSigned64));
-    EXPECT_EQ(_C2FieldId(20, 4), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mUnsigned32));
-    EXPECT_EQ(_C2FieldId(24, 8), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mUnsigned64));
-    EXPECT_EQ(_C2FieldId(32, 4), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mFloat));
-    EXPECT_EQ(_C2FieldId(36, 8), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mSize));
-    EXPECT_EQ(_C2FieldId(60, 1), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mBlob));
-    EXPECT_EQ(_C2FieldId(160, 1), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mString));
-    EXPECT_EQ(_C2FieldId(260, 1), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::mYesNo));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::signed32));
+    EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::signed64));
+    EXPECT_EQ(_C2FieldId(20, 4), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::unsigned32));
+    EXPECT_EQ(_C2FieldId(24, 8), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::unsigned64));
+    EXPECT_EQ(_C2FieldId(32, 4), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::fp32));
+    EXPECT_EQ(_C2FieldId(36, 8), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::sz));
+    EXPECT_EQ(_C2FieldId(60, 1), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::blob));
+    EXPECT_EQ(_C2FieldId(160, 1), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::string));
+    EXPECT_EQ(_C2FieldId(260, 1), _C2FieldId((C2TestStruct_A*)0, &C2TestStruct_A::yesNo));
 
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId((C2TestFlexEndSizeStruct*)0, &C2TestFlexEndSizeStruct::mSigned32));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId((C2TestFlexEndSizeStruct*)0, &C2TestFlexEndSizeStruct::signed32));
     EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId((C2TestFlexEndSizeStruct*)0, &C2TestFlexEndSizeStruct::mFlexSize));
 
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId((C2TestBaseFlexEndSizeStruct*)0, &C2TestBaseFlexEndSizeStruct::mSigned32));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId((C2TestBaseFlexEndSizeStruct*)0, &C2TestBaseFlexEndSizeStruct::signed32));
     EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId((C2TestBaseFlexEndSizeStruct*)0, &C2TestBaseFlexEndSizeStruct::mFlexSize));
 
     // member pointer sans type pointer
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&C2TestStruct_A::mSigned32));
-    EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId(&C2TestStruct_A::mSigned64));
-    EXPECT_EQ(_C2FieldId(20, 4), _C2FieldId(&C2TestStruct_A::mUnsigned32));
-    EXPECT_EQ(_C2FieldId(24, 8), _C2FieldId(&C2TestStruct_A::mUnsigned64));
-    EXPECT_EQ(_C2FieldId(32, 4), _C2FieldId(&C2TestStruct_A::mFloat));
-    EXPECT_EQ(_C2FieldId(36, 8), _C2FieldId(&C2TestStruct_A::mSize));
-    EXPECT_EQ(_C2FieldId(60, 1), _C2FieldId(&C2TestStruct_A::mBlob));
-    EXPECT_EQ(_C2FieldId(160, 1), _C2FieldId(&C2TestStruct_A::mString));
-    EXPECT_EQ(_C2FieldId(260, 1), _C2FieldId(&C2TestStruct_A::mYesNo));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&C2TestStruct_A::signed32));
+    EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId(&C2TestStruct_A::signed64));
+    EXPECT_EQ(_C2FieldId(20, 4), _C2FieldId(&C2TestStruct_A::unsigned32));
+    EXPECT_EQ(_C2FieldId(24, 8), _C2FieldId(&C2TestStruct_A::unsigned64));
+    EXPECT_EQ(_C2FieldId(32, 4), _C2FieldId(&C2TestStruct_A::fp32));
+    EXPECT_EQ(_C2FieldId(36, 8), _C2FieldId(&C2TestStruct_A::sz));
+    EXPECT_EQ(_C2FieldId(60, 1), _C2FieldId(&C2TestStruct_A::blob));
+    EXPECT_EQ(_C2FieldId(160, 1), _C2FieldId(&C2TestStruct_A::string));
+    EXPECT_EQ(_C2FieldId(260, 1), _C2FieldId(&C2TestStruct_A::yesNo));
 
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&C2TestFlexEndSizeStruct::mSigned32));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&C2TestFlexEndSizeStruct::signed32));
     EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId(&C2TestFlexEndSizeStruct::mFlexSize));
 
-    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&C2TestBaseFlexEndSizeStruct::mSigned32));
+    EXPECT_EQ(_C2FieldId(0, 4), _C2FieldId(&C2TestBaseFlexEndSizeStruct::signed32));
     EXPECT_EQ(_C2FieldId(4, 8), _C2FieldId(&C2TestBaseFlexEndSizeStruct::mFlexSize));
 
     typedef C2GlobalParam<C2Info, C2TestAStruct> C2TestAInfo;
@@ -565,38 +565,38 @@
     typedef C2GlobalParam<C2Info, C2TestBaseFlexEndSizeStruct, kParamIndexTestFlexEndSize> C2TestFlexEndSizeInfoFromBase;
 
     // pointer constructor in C2Param
-    EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&((C2TestAInfo*)0)->mSigned32));
-    EXPECT_EQ(_C2FieldId(12, 8), _C2FieldId(&((C2TestAInfo*)0)->mSigned64));
-    EXPECT_EQ(_C2FieldId(28, 4), _C2FieldId(&((C2TestAInfo*)0)->mUnsigned32));
-    EXPECT_EQ(_C2FieldId(32, 8), _C2FieldId(&((C2TestAInfo*)0)->mUnsigned64));
-    EXPECT_EQ(_C2FieldId(40, 4), _C2FieldId(&((C2TestAInfo*)0)->mFloat));
-    EXPECT_EQ(_C2FieldId(44, 8), _C2FieldId(&((C2TestAInfo*)0)->mSize));
-    EXPECT_EQ(_C2FieldId(68, 1), _C2FieldId(&((C2TestAInfo*)0)->mBlob));
-    EXPECT_EQ(_C2FieldId(168, 1), _C2FieldId(&((C2TestAInfo*)0)->mString));
-    EXPECT_EQ(_C2FieldId(268, 1), _C2FieldId(&((C2TestAInfo*)0)->mYesNo));
+    EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&((C2TestAInfo*)0)->signed32));
+    EXPECT_EQ(_C2FieldId(12, 8), _C2FieldId(&((C2TestAInfo*)0)->signed64));
+    EXPECT_EQ(_C2FieldId(28, 4), _C2FieldId(&((C2TestAInfo*)0)->unsigned32));
+    EXPECT_EQ(_C2FieldId(32, 8), _C2FieldId(&((C2TestAInfo*)0)->unsigned64));
+    EXPECT_EQ(_C2FieldId(40, 4), _C2FieldId(&((C2TestAInfo*)0)->fp32));
+    EXPECT_EQ(_C2FieldId(44, 8), _C2FieldId(&((C2TestAInfo*)0)->sz));
+    EXPECT_EQ(_C2FieldId(68, 1), _C2FieldId(&((C2TestAInfo*)0)->blob));
+    EXPECT_EQ(_C2FieldId(168, 1), _C2FieldId(&((C2TestAInfo*)0)->string));
+    EXPECT_EQ(_C2FieldId(268, 1), _C2FieldId(&((C2TestAInfo*)0)->yesNo));
 
-    EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&((C2TestFlexEndSizeInfo*)0)->m.mSigned32));
+    EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&((C2TestFlexEndSizeInfo*)0)->m.signed32));
     EXPECT_EQ(_C2FieldId(12, 8), _C2FieldId(&((C2TestFlexEndSizeInfo*)0)->m.mFlexSize));
 
-    EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&((C2TestFlexEndSizeInfoFromBase*)0)->m.mSigned32));
+    EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&((C2TestFlexEndSizeInfoFromBase*)0)->m.signed32));
     EXPECT_EQ(_C2FieldId(12, 8), _C2FieldId(&((C2TestFlexEndSizeInfoFromBase*)0)->m.mFlexSize));
 
     // member pointer in C2Param
-    EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mSigned32));
-    EXPECT_EQ(_C2FieldId(12, 8), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mSigned64));
-    EXPECT_EQ(_C2FieldId(28, 4), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mUnsigned32));
-    EXPECT_EQ(_C2FieldId(32, 8), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mUnsigned64));
-    EXPECT_EQ(_C2FieldId(40, 4), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mFloat));
-    EXPECT_EQ(_C2FieldId(44, 8), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mSize));
-    EXPECT_EQ(_C2FieldId(68, 1), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mBlob));
-    EXPECT_EQ(_C2FieldId(168, 1), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mString));
-    EXPECT_EQ(_C2FieldId(268, 1), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::mYesNo));
+    EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::signed32));
+    EXPECT_EQ(_C2FieldId(12, 8), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::signed64));
+    EXPECT_EQ(_C2FieldId(28, 4), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::unsigned32));
+    EXPECT_EQ(_C2FieldId(32, 8), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::unsigned64));
+    EXPECT_EQ(_C2FieldId(40, 4), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::fp32));
+    EXPECT_EQ(_C2FieldId(44, 8), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::sz));
+    EXPECT_EQ(_C2FieldId(68, 1), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::blob));
+    EXPECT_EQ(_C2FieldId(168, 1), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::string));
+    EXPECT_EQ(_C2FieldId(268, 1), _C2FieldId((C2TestAInfo*)0, &C2TestAInfo::yesNo));
 
     // NOTE: cannot use a member pointer for flex params due to introduction of 'm'
-    // EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&C2TestFlexEndSizeInfo::m.mSigned32));
+    // EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&C2TestFlexEndSizeInfo::m.signed32));
     // EXPECT_EQ(_C2FieldId(12, 8), _C2FieldId(&C2TestFlexEndSizeInfo::m.mFlexSize));
 
-    // EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&C2TestFlexEndSizeInfoFromBase::m.mSigned32));
+    // EXPECT_EQ(_C2FieldId(8, 4), _C2FieldId(&C2TestFlexEndSizeInfoFromBase::m.signed32));
     // EXPECT_EQ(_C2FieldId(12, 8), _C2FieldId(&C2TestFlexEndSizeInfoFromBase::m.mFlexSize));
 
 
@@ -631,33 +631,33 @@
 };
 
 void compiledStatic_arrayTypePropagationTest() {
-    (void)S32(&((C2TestFlexEndS32Struct *)0)->mSigned32);
+    (void)S32(&((C2TestFlexEndS32Struct *)0)->signed32);
     (void)FLX(&((C2TestFlexEndS32Struct *)0)->mFlexSigned32, (int32_t*)0);
     (void)FLX(&((C2TestFlexS32Struct *)0)->mFlexSigned32, (int32_t*)0);
 
     typedef C2GlobalParam<C2Info, C2TestAStruct> C2TestAInfo;
 
     // TRICKY: &derivedClass::baseMember has type of baseClass::*
-    static_assert(std::is_same<decltype(&C2TestAInfo::mSigned32), int32_t C2TestAStruct::*>::value,
+    static_assert(std::is_same<decltype(&C2TestAInfo::signed32), int32_t C2TestAStruct::*>::value,
                   "base member pointer should have base class in type");
 
     // therefore, member pointer expands to baseClass::* in templates
-    (void)MP(&C2TestAInfo::mSigned32,
+    (void)MP(&C2TestAInfo::signed32,
              (C2TestAStruct*)0 /* expected */, (C2TestAInfo*)0 /* unexpected */);
     // but can be cast to derivedClass::*
-    (void)MP((int32_t C2TestAInfo::*)&C2TestAInfo::mSigned32,
+    (void)MP((int32_t C2TestAInfo::*)&C2TestAInfo::signed32,
              (C2TestAInfo*)0 /* expected */, (C2TestAStruct*)0 /* unexpected */);
 
     // TRICKY: baseClass::* does not autoconvert to derivedClass::* even in templates
-    // (void)MP(&C2TestAInfo::mSigned32, (C2TestAInfo*)0);
+    // (void)MP(&C2TestAInfo::signed32, (C2TestAInfo*)0);
 }
 
 TEST_F(C2ParamTest, MemberPointerCast) {
     typedef C2GlobalParam<C2Info, C2TestAStruct> C2TestAInfo;
 
-    static_assert(offsetof(C2TestAInfo, mSigned32) == 8, "offset should be 8");
-    constexpr int32_t C2TestAStruct::* s32ptr = &C2TestAInfo::mSigned32;
-    constexpr int32_t C2TestAInfo::* s32ptr_derived = (int32_t C2TestAStruct::*)&C2TestAInfo::mSigned32;
+    static_assert(offsetof(C2TestAInfo, signed32) == 8, "offset should be 8");
+    constexpr int32_t C2TestAStruct::* s32ptr = &C2TestAInfo::signed32;
+    constexpr int32_t C2TestAInfo::* s32ptr_derived = (int32_t C2TestAStruct::*)&C2TestAInfo::signed32;
     constexpr int32_t C2TestAInfo::* s32ptr_cast2derived = (int32_t C2TestAInfo::*)s32ptr;
     C2TestAInfo *info = (C2TestAInfo *)256;
     C2TestAStruct *strukt = (C2TestAStruct *)info;
@@ -674,11 +674,11 @@
     EXPECT_EQ(264u, (uintptr_t)strukt_s32);
 
     typedef C2GlobalParam<C2Info, C2TestFlexEndSizeStruct> C2TestFlexEndSizeInfo;
-    static_assert(offsetof(C2TestFlexEndSizeInfo, m.mSigned32) == 8, "offset should be 8");
+    static_assert(offsetof(C2TestFlexEndSizeInfo, m.signed32) == 8, "offset should be 8");
     static_assert(offsetof(C2TestFlexEndSizeInfo, m.mFlexSize) == 12, "offset should be 12");
 
     typedef C2GlobalParam<C2Info, C2TestBaseFlexEndSizeStruct, kParamIndexTestFlexEndSize> C2TestFlexEndSizeInfoFromBase;
-    static_assert(offsetof(C2TestFlexEndSizeInfoFromBase, m.mSigned32) == 8, "offset should be 8");
+    static_assert(offsetof(C2TestFlexEndSizeInfoFromBase, m.signed32) == 8, "offset should be 8");
     static_assert(offsetof(C2TestFlexEndSizeInfoFromBase, m.mFlexSize) == 12, "offset should be 12");
 }
 
@@ -711,6 +711,8 @@
 };
 static_assert(sizeof(C2NumbersStruct) == 0, "C2NumbersStruct has incorrect size");
 
+typedef C2GlobalParam<C2Info, C2NumberStruct> C2NumberInfo;
+
 typedef C2GlobalParam<C2Tuning, C2NumberStruct> C2NumberTuning;
 typedef   C2PortParam<C2Tuning, C2NumberStruct> C2NumberPortTuning;
 typedef C2StreamParam<C2Tuning, C2NumberStruct> C2NumberStreamTuning;
@@ -724,7 +726,7 @@
 
 void test() {
     C2NumberStruct s(10);
-    (void)C2NumberStruct::fieldList;
+    (void)C2NumberStruct::FIELD_LIST;
 };
 
 typedef C2StreamParam<C2Tuning, C2Int64Value, kParamIndexNumberB> C2NumberConfig4;
@@ -733,19 +735,19 @@
 
 void test3() {
     C2NumberConfig3 s(10);
-    s.mValue = 11;
+    s.value = 11;
     s = 12;
-    (void)C2NumberConfig3::fieldList;
+    (void)C2NumberConfig3::FIELD_LIST;
     std::shared_ptr<C2VideoNameConfig> n = C2VideoNameConfig::alloc_shared(25);
-    strcpy(n->m.mValue, "lajos");
+    strcpy(n->m.value, "lajos");
     C2NumberConfig4 t(false, 0, 11);
-    t.mValue = 15;
+    t.value = 15;
 };
 
 struct C2NumbersStruct {
     int32_t mNumbers[];
-    enum { coreIndex = kParamIndexNumber };
-    const static std::initializer_list<const C2FieldDescriptor> fieldList;
+    enum { CORE_INDEX = kParamIndexNumber };
+    const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST;
     C2NumbersStruct() {}
 
     FLEX(C2NumbersStruct, mNumbers);
@@ -756,13 +758,13 @@
 
 typedef C2GlobalParam<C2Info, C2NumbersStruct> C2NumbersInfo;
 
-const std::initializer_list<const C2FieldDescriptor> C2NumbersStruct::fieldList =
+const std::initializer_list<const C2FieldDescriptor> C2NumbersStruct::FIELD_LIST =
 //    { { FD::INT32, 0, "widths" } };
     { C2FieldDescriptor(&((C2NumbersStruct*)(nullptr))->mNumbers, "number") };
 
 typedef C2PortParam<C2Tuning, C2NumberStruct> C2NumberConfig;
 
-std::list<const C2FieldDescriptor> myList = C2NumberConfig::fieldList;
+std::list<const C2FieldDescriptor> myList = C2NumberConfig::FIELD_LIST;
 
     std::unique_ptr<android::C2ParamDescriptor> __test_describe(uint32_t paramType) {
         std::list<const C2FieldDescriptor> fields = describeC2Params<C2NumberConfig>();
@@ -778,7 +780,7 @@
 
         C2Param::Index index(paramType);
         switch (paramType) {
-        case C2NumberConfig::coreIndex:
+        case C2NumberConfig::CORE_INDEX:
             return std::unique_ptr<C2ParamDescriptor>(new C2ParamDescriptor{
                 true /* isRequired */,
                 "number",
@@ -836,13 +838,13 @@
 void _C2ParamInspector::StaticTest() {
     typedef C2Param::Index I;
 
-    // C2NumberStruct: coreIndex = kIndex                          (args)
-    static_assert(C2NumberStruct::coreIndex == kParamIndexNumber, "bad index");
+    // C2NumberStruct: CORE_INDEX = kIndex                          (args)
+    static_assert(C2NumberStruct::CORE_INDEX == kParamIndexNumber, "bad index");
     static_assert(sizeof(C2NumberStruct) == 4, "bad size");
 
     // C2NumberTuning:             kIndex | tun | global           (args)
-    static_assert(C2NumberTuning::coreIndex == kParamIndexNumber, "bad index");
-    static_assert(C2NumberTuning::typeIndex == (kParamIndexNumber | I::kTypeTuning | I::kDirGlobal), "bad index");
+    static_assert(C2NumberTuning::CORE_INDEX == kParamIndexNumber, "bad index");
+    static_assert(C2NumberTuning::PARAM_TYPE == (kParamIndexNumber | I::KIND_TUNING | I::DIR_GLOBAL), "bad index");
     static_assert(sizeof(C2NumberTuning) == 12, "bad size");
 
     static_assert(offsetof(C2NumberTuning, _mSize) == 0, "bad size");
@@ -853,14 +855,14 @@
     static_assert(sizeof(C2NumberPortTuning) == 12, "bad size");
     // C2NumberPortTuning::input:  kIndex | tun | port | input     (args)
     // C2NumberPortTuning::output: kIndex | tun | port | output    (args)
-    static_assert(C2NumberPortTuning::input::coreIndex ==
+    static_assert(C2NumberPortTuning::input::CORE_INDEX ==
                   kParamIndexNumber, "bad index");
-    static_assert(C2NumberPortTuning::input::typeIndex ==
-                  (kParamIndexNumber | I::kTypeTuning | I::kDirInput), "bad index");
-    static_assert(C2NumberPortTuning::output::coreIndex ==
+    static_assert(C2NumberPortTuning::input::PARAM_TYPE ==
+                  (kParamIndexNumber | I::KIND_TUNING | I::DIR_INPUT), "bad index");
+    static_assert(C2NumberPortTuning::output::CORE_INDEX ==
                   kParamIndexNumber, "bad index");
-    static_assert(C2NumberPortTuning::output::typeIndex ==
-                  (kParamIndexNumber | I::kTypeTuning | I::kDirOutput), "bad index");
+    static_assert(C2NumberPortTuning::output::PARAM_TYPE ==
+                  (kParamIndexNumber | I::KIND_TUNING | I::DIR_OUTPUT), "bad index");
     static_assert(sizeof(C2NumberPortTuning::input) == 12, "bad size");
     static_assert(sizeof(C2NumberPortTuning::output) == 12, "bad size");
     static_assert(offsetof(C2NumberPortTuning::input, _mSize) == 0, "bad size");
@@ -874,14 +876,14 @@
     static_assert(sizeof(C2NumberStreamTuning) == 12u, "bad size");
     // C2NumberStreamTuning::input kIndex | tun | str | input      (int, args)
     // C2NumberStreamTuning::output kIx   | tun | str | output     (int, args)
-    static_assert(C2NumberStreamTuning::input::coreIndex ==
+    static_assert(C2NumberStreamTuning::input::CORE_INDEX ==
                   kParamIndexNumber, "bad index");
-    static_assert(C2NumberStreamTuning::input::typeIndex ==
-                  (kParamIndexNumber | I::kTypeTuning | I::kDirInput | I::kStreamFlag), "bad index");
-    static_assert(C2NumberStreamTuning::output::coreIndex ==
+    static_assert(C2NumberStreamTuning::input::PARAM_TYPE ==
+                  (kParamIndexNumber | I::KIND_TUNING | I::DIR_INPUT | I::IS_STREAM_FLAG), "bad index");
+    static_assert(C2NumberStreamTuning::output::CORE_INDEX ==
                   kParamIndexNumber, "bad index");
-    static_assert(C2NumberStreamTuning::output::typeIndex ==
-                  (kParamIndexNumber | I::kTypeTuning | I::kDirOutput | I::kStreamFlag), "bad index");
+    static_assert(C2NumberStreamTuning::output::PARAM_TYPE ==
+                  (kParamIndexNumber | I::KIND_TUNING | I::DIR_OUTPUT | I::IS_STREAM_FLAG), "bad index");
     static_assert(sizeof(C2NumberStreamTuning::input) == 12u, "bad size");
     static_assert(sizeof(C2NumberStreamTuning::output) == 12u, "bad size");
     static_assert(offsetof(C2NumberStreamTuning::input, _mSize) == 0, "bad size");
@@ -901,13 +903,13 @@
 
     typedef C2Param::Index I;
 
-    // C2MyStruct has no coreIndex
-    //static_assert(C2MyStruct::coreIndex == kParamIndexMy, "bad index");
+    // C2MyStruct has no CORE_INDEX
+    //static_assert(C2MyStruct::CORE_INDEX == kParamIndexMy, "bad index");
     static_assert(sizeof(C2MyStruct) == 4, "bad size");
 
     // C2MySetting:             kIndex | tun | global           (args)
-    static_assert(C2MySetting::coreIndex == kParamIndexMy, "bad index");
-    static_assert(C2MySetting::typeIndex == (kParamIndexMy | I::kTypeSetting | I::kDirGlobal), "bad index");
+    static_assert(C2MySetting::CORE_INDEX == kParamIndexMy, "bad index");
+    static_assert(C2MySetting::PARAM_TYPE == (kParamIndexMy | I::KIND_SETTING | I::DIR_GLOBAL), "bad index");
     static_assert(sizeof(C2MySetting) == 12, "bad size");
 
     static_assert(offsetof(C2MySetting, _mSize) == 0, "bad size");
@@ -918,14 +920,14 @@
     static_assert(sizeof(C2MyPortSetting) == 12, "bad size");
     // C2MyPortSetting::input:  kIndex | tun | port | input     (args)
     // C2MyPortSetting::output: kIndex | tun | port | output    (args)
-    static_assert(C2MyPortSetting::input::coreIndex ==
+    static_assert(C2MyPortSetting::input::CORE_INDEX ==
                   kParamIndexMy, "bad index");
-    static_assert(C2MyPortSetting::input::typeIndex ==
-                  (kParamIndexMy | I::kTypeSetting | I::kDirInput), "bad index");
-    static_assert(C2MyPortSetting::output::coreIndex ==
+    static_assert(C2MyPortSetting::input::PARAM_TYPE ==
+                  (kParamIndexMy | I::KIND_SETTING | I::DIR_INPUT), "bad index");
+    static_assert(C2MyPortSetting::output::CORE_INDEX ==
                   kParamIndexMy, "bad index");
-    static_assert(C2MyPortSetting::output::typeIndex ==
-                  (kParamIndexMy | I::kTypeSetting | I::kDirOutput), "bad index");
+    static_assert(C2MyPortSetting::output::PARAM_TYPE ==
+                  (kParamIndexMy | I::KIND_SETTING | I::DIR_OUTPUT), "bad index");
     static_assert(sizeof(C2MyPortSetting::input) == 12, "bad size");
     static_assert(sizeof(C2MyPortSetting::output) == 12, "bad size");
     static_assert(offsetof(C2MyPortSetting::input, _mSize) == 0, "bad size");
@@ -939,14 +941,14 @@
     static_assert(sizeof(C2MyStreamSetting) == 12u, "bad size");
     // C2MyStreamSetting::input kIndex | tun | str | input      (int, args)
     // C2MyStreamSetting::output kIx   | tun | str | output     (int, args)
-    static_assert(C2MyStreamSetting::input::coreIndex ==
+    static_assert(C2MyStreamSetting::input::CORE_INDEX ==
                   kParamIndexMy, "bad index");
-    static_assert(C2MyStreamSetting::input::typeIndex ==
-                  (kParamIndexMy | I::kTypeSetting | I::kDirInput | I::kStreamFlag), "bad index");
-    static_assert(C2MyStreamSetting::output::coreIndex ==
+    static_assert(C2MyStreamSetting::input::PARAM_TYPE ==
+                  (kParamIndexMy | I::KIND_SETTING | I::DIR_INPUT | I::IS_STREAM_FLAG), "bad index");
+    static_assert(C2MyStreamSetting::output::CORE_INDEX ==
                   kParamIndexMy, "bad index");
-    static_assert(C2MyStreamSetting::output::typeIndex ==
-                  (kParamIndexMy | I::kTypeSetting | I::kDirOutput | I::kStreamFlag), "bad index");
+    static_assert(C2MyStreamSetting::output::PARAM_TYPE ==
+                  (kParamIndexMy | I::KIND_SETTING | I::DIR_OUTPUT | I::IS_STREAM_FLAG), "bad index");
     static_assert(sizeof(C2MyStreamSetting::input) == 12u, "bad size");
     static_assert(sizeof(C2MyStreamSetting::output) == 12u, "bad size");
     static_assert(offsetof(C2MyStreamSetting::input, _mSize) == 0, "bad size");
@@ -960,13 +962,13 @@
 void _C2ParamInspector::StaticFlexTest() {
     typedef C2Param::Index I;
 
-    // C2NumbersStruct: coreIndex = kIndex                          (args)
-    static_assert(C2NumbersStruct::coreIndex == (I::kFlexibleFlag | kParamIndexNumbers), "bad index");
+    // C2NumbersStruct: CORE_INDEX = kIndex                          (args)
+    static_assert(C2NumbersStruct::CORE_INDEX == (I::IS_FLEX_FLAG | kParamIndexNumbers), "bad index");
     static_assert(sizeof(C2NumbersStruct) == 0, "bad size");
 
     // C2NumbersTuning:             kIndex | tun | global           (args)
-    static_assert(C2NumbersTuning::coreIndex == (I::kFlexibleFlag | kParamIndexNumbers), "bad index");
-    static_assert(C2NumbersTuning::typeIndex == (I::kFlexibleFlag | kParamIndexNumbers | I::kTypeTuning | I::kDirGlobal), "bad index");
+    static_assert(C2NumbersTuning::CORE_INDEX == (I::IS_FLEX_FLAG | kParamIndexNumbers), "bad index");
+    static_assert(C2NumbersTuning::PARAM_TYPE == (I::IS_FLEX_FLAG | kParamIndexNumbers | I::KIND_TUNING | I::DIR_GLOBAL), "bad index");
     static_assert(sizeof(C2NumbersTuning) == 8, "bad size");
 
     static_assert(offsetof(C2NumbersTuning, _mSize) == 0, "bad size");
@@ -977,14 +979,14 @@
     static_assert(sizeof(C2NumbersPortTuning) == 8, "bad size");
     // C2NumbersPortTuning::input:  kIndex | tun | port | input     (args)
     // C2NumbersPortTuning::output: kIndex | tun | port | output    (args)
-    static_assert(C2NumbersPortTuning::input::coreIndex ==
-                  (I::kFlexibleFlag | kParamIndexNumbers), "bad index");
-    static_assert(C2NumbersPortTuning::input::typeIndex ==
-                  (I::kFlexibleFlag | kParamIndexNumbers | I::kTypeTuning | I::kDirInput), "bad index");
-    static_assert(C2NumbersPortTuning::output::coreIndex ==
-                  (I::kFlexibleFlag | kParamIndexNumbers), "bad index");
-    static_assert(C2NumbersPortTuning::output::typeIndex ==
-                  (I::kFlexibleFlag | kParamIndexNumbers | I::kTypeTuning | I::kDirOutput), "bad index");
+    static_assert(C2NumbersPortTuning::input::CORE_INDEX ==
+                  (I::IS_FLEX_FLAG | kParamIndexNumbers), "bad index");
+    static_assert(C2NumbersPortTuning::input::PARAM_TYPE ==
+                  (I::IS_FLEX_FLAG | kParamIndexNumbers | I::KIND_TUNING | I::DIR_INPUT), "bad index");
+    static_assert(C2NumbersPortTuning::output::CORE_INDEX ==
+                  (I::IS_FLEX_FLAG | kParamIndexNumbers), "bad index");
+    static_assert(C2NumbersPortTuning::output::PARAM_TYPE ==
+                  (I::IS_FLEX_FLAG | kParamIndexNumbers | I::KIND_TUNING | I::DIR_OUTPUT), "bad index");
     static_assert(sizeof(C2NumbersPortTuning::input) == 8, "bad size");
     static_assert(sizeof(C2NumbersPortTuning::output) == 8, "bad size");
     static_assert(offsetof(C2NumbersPortTuning::input, _mSize) == 0, "bad size");
@@ -998,14 +1000,14 @@
     static_assert(sizeof(C2NumbersStreamTuning) == 8, "bad size");
     // C2NumbersStreamTuning::input kIndex | tun | str | input      (int, args)
     // C2NumbersStreamTuning::output kIx   | tun | str | output     (int, args)
-    static_assert(C2NumbersStreamTuning::input::coreIndex ==
-                  (I::kFlexibleFlag | kParamIndexNumbers), "bad index");
-    static_assert(C2NumbersStreamTuning::input::typeIndex ==
-                  (I::kFlexibleFlag | kParamIndexNumbers | I::kTypeTuning | I::kDirInput | I::kStreamFlag), "bad index");
-    static_assert(C2NumbersStreamTuning::output::coreIndex ==
-                  (I::kFlexibleFlag | kParamIndexNumbers), "bad index");
-    static_assert(C2NumbersStreamTuning::output::typeIndex ==
-                  (I::kFlexibleFlag | kParamIndexNumbers | I::kTypeTuning | I::kDirOutput | I::kStreamFlag), "bad index");
+    static_assert(C2NumbersStreamTuning::input::CORE_INDEX ==
+                  (I::IS_FLEX_FLAG | kParamIndexNumbers), "bad index");
+    static_assert(C2NumbersStreamTuning::input::PARAM_TYPE ==
+                  (I::IS_FLEX_FLAG | kParamIndexNumbers | I::KIND_TUNING | I::DIR_INPUT | I::IS_STREAM_FLAG), "bad index");
+    static_assert(C2NumbersStreamTuning::output::CORE_INDEX ==
+                  (I::IS_FLEX_FLAG | kParamIndexNumbers), "bad index");
+    static_assert(C2NumbersStreamTuning::output::PARAM_TYPE ==
+                  (I::IS_FLEX_FLAG | kParamIndexNumbers | I::KIND_TUNING | I::DIR_OUTPUT | I::IS_STREAM_FLAG), "bad index");
     static_assert(sizeof(C2NumbersStreamTuning::input) == 8, "bad size");
     static_assert(sizeof(C2NumbersStreamTuning::output) == 8, "bad size");
     static_assert(offsetof(C2NumbersStreamTuning::input, _mSize) == 0, "bad size");
@@ -1034,60 +1036,60 @@
 
     typedef C2Param::Index I;
 
-    // C2MyStruct has no coreIndex
-    //static_assert(C2MyStruct::coreIndex == (I::kFlexibleFlag | kParamIndexMy), "bad index");
+    // C2MyStruct has no CORE_INDEX
+    //static_assert(C2MyStruct::CORE_INDEX == (I::IS_FLEX_FLAG | kParamIndexMy), "bad index");
     static_assert(sizeof(C2MyStruct) == 4, "bad size");
 
     // C2MyInfo:             kIndex | tun | global           (args)
-    static_assert_equals(C2MyInfo::coreIndex, (I::kFlexibleFlag | kParamIndexMy), "bad index");
-    static_assert_equals(C2MyInfo::typeIndex, (I::kFlexibleFlag | kParamIndexMy | I::kTypeInfo | I::kDirGlobal), "bad index");
+    static_assert_equals(C2MyInfo::CORE_INDEX, (I::IS_FLEX_FLAG | kParamIndexMy), "bad index");
+    static_assert_equals(C2MyInfo::PARAM_TYPE, (I::IS_FLEX_FLAG | kParamIndexMy | I::KIND_INFO | I::DIR_GLOBAL), "bad index");
     static_assert(sizeof(C2MyInfo) == 12, "bad size");
 
     static_assert(offsetof(C2MyInfo, _mSize) == 0, "bad size");
     static_assert(offsetof(C2MyInfo, _mIndex) == 4, "bad offset");
-    static_assert(offsetof(C2MyInfo, m.mSigned32) == 8, "bad offset");
+    static_assert(offsetof(C2MyInfo, m.signed32) == 8, "bad offset");
 
     // C2MyPortInfo:         kIndex | tun | port             (bool, args)
     static_assert(sizeof(C2MyPortInfo) == 12, "bad size");
     // C2MyPortInfo::input:  kIndex | tun | port | input     (args)
     // C2MyPortInfo::output: kIndex | tun | port | output    (args)
-    static_assert(C2MyPortInfo::input::coreIndex ==
-                  (I::kFlexibleFlag | kParamIndexMy), "bad index");
-    static_assert(C2MyPortInfo::input::typeIndex ==
-                  (I::kFlexibleFlag | kParamIndexMy | I::kTypeInfo | I::kDirInput), "bad index");
-    static_assert(C2MyPortInfo::output::coreIndex ==
-                  (I::kFlexibleFlag | kParamIndexMy), "bad index");
-    static_assert(C2MyPortInfo::output::typeIndex ==
-                  (I::kFlexibleFlag | kParamIndexMy | I::kTypeInfo | I::kDirOutput), "bad index");
+    static_assert(C2MyPortInfo::input::CORE_INDEX ==
+                  (I::IS_FLEX_FLAG | kParamIndexMy), "bad index");
+    static_assert(C2MyPortInfo::input::PARAM_TYPE ==
+                  (I::IS_FLEX_FLAG | kParamIndexMy | I::KIND_INFO | I::DIR_INPUT), "bad index");
+    static_assert(C2MyPortInfo::output::CORE_INDEX ==
+                  (I::IS_FLEX_FLAG | kParamIndexMy), "bad index");
+    static_assert(C2MyPortInfo::output::PARAM_TYPE ==
+                  (I::IS_FLEX_FLAG | kParamIndexMy | I::KIND_INFO | I::DIR_OUTPUT), "bad index");
     static_assert(sizeof(C2MyPortInfo::input) == 12, "bad size");
     static_assert(sizeof(C2MyPortInfo::output) == 12, "bad size");
     static_assert(offsetof(C2MyPortInfo::input, _mSize) == 0, "bad size");
     static_assert(offsetof(C2MyPortInfo::input, _mIndex) == 4, "bad offset");
-    static_assert(offsetof(C2MyPortInfo::input, m.mSigned32) == 8, "bad offset");
+    static_assert(offsetof(C2MyPortInfo::input, m.signed32) == 8, "bad offset");
     static_assert(offsetof(C2MyPortInfo::output, _mSize) == 0, "bad size");
     static_assert(offsetof(C2MyPortInfo::output, _mIndex) == 4, "bad offset");
-    static_assert(offsetof(C2MyPortInfo::output, m.mSigned32) == 8, "bad offset");
+    static_assert(offsetof(C2MyPortInfo::output, m.signed32) == 8, "bad offset");
 
     // C2MyStreamInfo:       kIndex | tun | str              (bool, uint, args)
     static_assert(sizeof(C2MyStreamInfo) == 12, "bad size");
     // C2MyStreamInfo::input kIndex | tun | str | input      (int, args)
     // C2MyStreamInfo::output kIx   | tun | str | output     (int, args)
-    static_assert(C2MyStreamInfo::input::coreIndex ==
-                  (I::kFlexibleFlag | kParamIndexMy), "bad index");
-    static_assert(C2MyStreamInfo::input::typeIndex ==
-                  (I::kFlexibleFlag | kParamIndexMy | I::kTypeInfo | I::kDirInput | I::kStreamFlag), "bad index");
-    static_assert(C2MyStreamInfo::output::coreIndex ==
-                  (I::kFlexibleFlag | kParamIndexMy), "bad index");
-    static_assert(C2MyStreamInfo::output::typeIndex ==
-                  (I::kFlexibleFlag | kParamIndexMy | I::kTypeInfo | I::kDirOutput | I::kStreamFlag), "bad index");
+    static_assert(C2MyStreamInfo::input::CORE_INDEX ==
+                  (I::IS_FLEX_FLAG | kParamIndexMy), "bad index");
+    static_assert(C2MyStreamInfo::input::PARAM_TYPE ==
+                  (I::IS_FLEX_FLAG | kParamIndexMy | I::KIND_INFO | I::DIR_INPUT | I::IS_STREAM_FLAG), "bad index");
+    static_assert(C2MyStreamInfo::output::CORE_INDEX ==
+                  (I::IS_FLEX_FLAG | kParamIndexMy), "bad index");
+    static_assert(C2MyStreamInfo::output::PARAM_TYPE ==
+                  (I::IS_FLEX_FLAG | kParamIndexMy | I::KIND_INFO | I::DIR_OUTPUT | I::IS_STREAM_FLAG), "bad index");
     static_assert(sizeof(C2MyStreamInfo::input) == 12, "bad size");
     static_assert(sizeof(C2MyStreamInfo::output) == 12, "bad size");
     static_assert(offsetof(C2MyStreamInfo::input, _mSize) == 0, "bad size");
     static_assert(offsetof(C2MyStreamInfo::input, _mIndex) == 4, "bad offset");
-    static_assert(offsetof(C2MyStreamInfo::input, m.mSigned32) == 8, "bad offset");
+    static_assert(offsetof(C2MyStreamInfo::input, m.signed32) == 8, "bad offset");
     static_assert(offsetof(C2MyStreamInfo::output, _mSize) == 0, "bad size");
     static_assert(offsetof(C2MyStreamInfo::output, _mIndex) == 4, "bad offset");
-    static_assert(offsetof(C2MyStreamInfo::output, m.mSigned32) == 8, "bad offset");
+    static_assert(offsetof(C2MyStreamInfo::output, m.signed32) == 8, "bad offset");
 }
 
 TEST_F(C2ParamTest, ParamOpsTest) {
@@ -1098,17 +1100,27 @@
         EXPECT_EQ(100, str.mNumber);
         bstr.mNumber = 100;
 
-        C2Param::BaseIndex index = C2NumberStruct::coreIndex;
+        C2Param::CoreIndex index = C2NumberStruct::CORE_INDEX;
         EXPECT_FALSE(index.isVendor());
         EXPECT_FALSE(index.isFlexible());
         EXPECT_EQ(index.coreIndex(), kParamIndexNumber);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumber);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumber);
     }
 
     const C2NumberTuning tun(100);
     C2NumberTuning btun;
 
     {
+      C2NumberInfo inf(100);
+      std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::alloc_unique(1);
+
+      EXPECT_EQ(tun.coreIndex(), inf.coreIndex());
+      EXPECT_NE(tun.coreIndex(), tun_->coreIndex());
+      EXPECT_NE(tun.type(), inf.type());
+      EXPECT_NE(tun.type(), tun_->type());
+    }
+
+    {
         // flags & invariables
         for (const auto &p : { tun, btun }) {
             EXPECT_TRUE((bool)p);
@@ -1135,18 +1147,18 @@
         EXPECT_EQ(tun, btun);
 
         // index
-        EXPECT_EQ(C2Param::Type(tun.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(tun.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(tun.type(), C2NumberTuning::typeIndex);
+        EXPECT_EQ(C2Param::Type(tun.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(tun.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(tun.type(), C2NumberTuning::PARAM_TYPE);
         EXPECT_EQ(tun.stream(), ~0u);
 
-        C2Param::BaseIndex index = C2NumberTuning::coreIndex;
+        C2Param::CoreIndex index = C2NumberTuning::CORE_INDEX;
         EXPECT_FALSE(index.isVendor());
         EXPECT_FALSE(index.isFlexible());
         EXPECT_EQ(index.coreIndex(), kParamIndexNumber);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumber);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumber);
 
-        C2Param::Type type = C2NumberTuning::typeIndex;
+        C2Param::Type type = C2NumberTuning::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_FALSE(type.isFlexible());
         EXPECT_TRUE(type.isGlobal());
@@ -1176,6 +1188,22 @@
     const C2NumberPortTuning::output outp2(100);
     C2NumberPortTuning::output boutp2;
 
+    EXPECT_EQ(inp1.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(outp1.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(binp1.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(boutp1.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(inp2.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(outp2.coreIndex(), tun.coreIndex());
+
+    EXPECT_EQ(inp1.type(), inp2.type());
+    EXPECT_EQ(outp1.type(), outp2.type());
+    EXPECT_NE(inp1.type(), outp1.type());
+    EXPECT_NE(inp2.type(), outp2.type());
+    EXPECT_NE(inp1.type(), binp1.type());
+    EXPECT_NE(outp1.type(), boutp1.type());
+    EXPECT_NE(inp1.type(), tun.type());
+    EXPECT_NE(inp2.type(), tun.type());
+
     {
         static_assert(canCallSetPort(binp3), "should be able to");
         static_assert(canCallSetPort(binp1), "should be able to");
@@ -1289,39 +1317,39 @@
         EXPECT_TRUE(inp1 == boutp1);
 
         // index
-        EXPECT_EQ(C2Param::Type(inp1.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(inp1.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(inp1.type(), C2NumberPortTuning::input::typeIndex);
+        EXPECT_EQ(C2Param::Type(inp1.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(inp1.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(inp1.type(), C2NumberPortTuning::input::PARAM_TYPE);
         EXPECT_EQ(inp1.stream(), ~0u);
 
-        EXPECT_EQ(C2Param::Type(inp2.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(inp2.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(inp2.type(), C2NumberPortTuning::input::typeIndex);
+        EXPECT_EQ(C2Param::Type(inp2.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(inp2.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(inp2.type(), C2NumberPortTuning::input::PARAM_TYPE);
         EXPECT_EQ(inp2.stream(), ~0u);
 
-        EXPECT_EQ(C2Param::Type(outp1.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(outp1.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(outp1.type(), C2NumberPortTuning::output::typeIndex);
+        EXPECT_EQ(C2Param::Type(outp1.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(outp1.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(outp1.type(), C2NumberPortTuning::output::PARAM_TYPE);
         EXPECT_EQ(outp1.stream(), ~0u);
 
-        EXPECT_EQ(C2Param::Type(outp2.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(outp2.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(outp2.type(), C2NumberPortTuning::output::typeIndex);
+        EXPECT_EQ(C2Param::Type(outp2.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(outp2.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(outp2.type(), C2NumberPortTuning::output::PARAM_TYPE);
         EXPECT_EQ(outp2.stream(), ~0u);
 
-        C2Param::BaseIndex index = C2NumberPortTuning::input::typeIndex;
+        C2Param::CoreIndex index = C2NumberPortTuning::input::PARAM_TYPE;
         EXPECT_FALSE(index.isVendor());
         EXPECT_FALSE(index.isFlexible());
         EXPECT_EQ(index.coreIndex(), kParamIndexNumber);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumber);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumber);
 
-        index = C2NumberPortTuning::output::typeIndex;
+        index = C2NumberPortTuning::output::PARAM_TYPE;
         EXPECT_FALSE(index.isVendor());
         EXPECT_FALSE(index.isFlexible());
         EXPECT_EQ(index.coreIndex(), kParamIndexNumber);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumber);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumber);
 
-        C2Param::Type type = C2NumberPortTuning::input::typeIndex;
+        C2Param::Type type = C2NumberPortTuning::input::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_FALSE(type.isFlexible());
         EXPECT_FALSE(type.isGlobal());
@@ -1330,7 +1358,7 @@
         EXPECT_FALSE(type.forStream());
         EXPECT_TRUE(type.forPort());
 
-        type = C2NumberPortTuning::output::typeIndex;
+        type = C2NumberPortTuning::output::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_FALSE(type.isFlexible());
         EXPECT_FALSE(type.isGlobal());
@@ -1384,6 +1412,24 @@
     const C2NumberStreamTuning::output outs2(1u, 100);
     C2NumberStreamTuning::output bouts2;
 
+    EXPECT_EQ(ins1.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(outs1.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(bins1.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(bouts1.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(ins2.coreIndex(), tun.coreIndex());
+    EXPECT_EQ(outs2.coreIndex(), tun.coreIndex());
+
+    EXPECT_EQ(ins1.type(), ins2.type());
+    EXPECT_EQ(ins1.type(), bins2.type());
+    EXPECT_EQ(outs1.type(), outs2.type());
+    EXPECT_EQ(outs1.type(), bouts2.type());
+    EXPECT_NE(ins1.type(), outs1.type());
+    EXPECT_NE(ins2.type(), outs2.type());
+    EXPECT_NE(ins1.type(), bins1.type());
+    EXPECT_NE(outs1.type(), bouts1.type());
+    EXPECT_NE(ins1.type(), tun.type());
+    EXPECT_NE(ins2.type(), tun.type());
+
     {
         static_assert(canCallSetPort(bins3), "should be able to");
         static_assert(canCallSetPort(bins1), "should be able to");
@@ -1509,35 +1555,35 @@
         EXPECT_TRUE(ins1 == bouts1);
 
         // index
-        EXPECT_EQ(C2Param::Type(ins1.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(ins1.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(ins1.type(), C2NumberStreamTuning::input::typeIndex);
+        EXPECT_EQ(C2Param::Type(ins1.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(ins1.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(ins1.type(), C2NumberStreamTuning::input::PARAM_TYPE);
 
-        EXPECT_EQ(C2Param::Type(ins2.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(ins2.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(ins2.type(), C2NumberStreamTuning::input::typeIndex);
+        EXPECT_EQ(C2Param::Type(ins2.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(ins2.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(ins2.type(), C2NumberStreamTuning::input::PARAM_TYPE);
 
-        EXPECT_EQ(C2Param::Type(outs1.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(outs1.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(outs1.type(), C2NumberStreamTuning::output::typeIndex);
+        EXPECT_EQ(C2Param::Type(outs1.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(outs1.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(outs1.type(), C2NumberStreamTuning::output::PARAM_TYPE);
 
-        EXPECT_EQ(C2Param::Type(outs2.type()).coreIndex(), C2NumberStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(outs2.type()).paramIndex(), kParamIndexNumber);
-        EXPECT_EQ(outs2.type(), C2NumberStreamTuning::output::typeIndex);
+        EXPECT_EQ(C2Param::Type(outs2.type()).coreIndex(), C2NumberStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(outs2.type()).typeIndex(), kParamIndexNumber);
+        EXPECT_EQ(outs2.type(), C2NumberStreamTuning::output::PARAM_TYPE);
 
-        C2Param::BaseIndex index = C2NumberStreamTuning::input::typeIndex;
+        C2Param::CoreIndex index = C2NumberStreamTuning::input::PARAM_TYPE;
         EXPECT_FALSE(index.isVendor());
         EXPECT_FALSE(index.isFlexible());
         EXPECT_EQ(index.coreIndex(), kParamIndexNumber);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumber);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumber);
 
-        index = C2NumberStreamTuning::output::typeIndex;
+        index = C2NumberStreamTuning::output::PARAM_TYPE;
         EXPECT_FALSE(index.isVendor());
         EXPECT_FALSE(index.isFlexible());
         EXPECT_EQ(index.coreIndex(), kParamIndexNumber);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumber);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumber);
 
-        C2Param::Type type = C2NumberStreamTuning::input::typeIndex;
+        C2Param::Type type = C2NumberStreamTuning::input::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_FALSE(type.isFlexible());
         EXPECT_FALSE(type.isGlobal());
@@ -1546,7 +1592,7 @@
         EXPECT_TRUE(type.forStream());
         EXPECT_FALSE(type.forPort());
 
-        type = C2NumberStreamTuning::output::typeIndex;
+        type = C2NumberStreamTuning::output::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_FALSE(type.isFlexible());
         EXPECT_FALSE(type.isGlobal());
@@ -1594,11 +1640,11 @@
     }
 
     {
-        uint32_t videoWidth[] = { 12u, C2NumberStreamTuning::output::typeIndex, 100 };
+        uint32_t videoWidth[] = { 12u, C2NumberStreamTuning::output::PARAM_TYPE, 100 };
         C2Param *p1 = C2Param::From(videoWidth, sizeof(videoWidth));
         EXPECT_NE(p1, nullptr);
         EXPECT_EQ(12u, p1->size());
-        EXPECT_EQ(p1->type(), C2NumberStreamTuning::output::typeIndex);
+        EXPECT_EQ(p1->type(), C2NumberStreamTuning::output::PARAM_TYPE);
 
         p1 = C2Param::From(videoWidth, sizeof(videoWidth) + 2);
         EXPECT_EQ(p1, nullptr);
@@ -1616,9 +1662,9 @@
 
 void StaticTestAddCoreIndex() {
     struct nobase {};
-    struct base { enum : uint32_t { coreIndex = 1 }; };
-    static_assert(C2AddCoreIndex<nobase, 2>::coreIndex == 2, "should be 2");
-    static_assert(C2AddCoreIndex<base, 1>::coreIndex == 1, "should be 1");
+    struct base { enum : uint32_t { CORE_INDEX = 1 }; };
+    static_assert(C2AddCoreIndex<nobase, 2>::CORE_INDEX == 2, "should be 2");
+    static_assert(C2AddCoreIndex<base, 1>::CORE_INDEX == 1, "should be 1");
 }
 
 class TestFlexHelper {
@@ -1640,11 +1686,11 @@
 
 
     static void StaticTest() {
-        static_assert(std::is_same<_C2FlexHelper<char>::flexType, void>::value, "should be void");
-        static_assert(std::is_same<_C2FlexHelper<char[]>::flexType, char>::value, "should be char");
-        static_assert(std::is_same<_C2FlexHelper<_Flex>::flexType, char>::value, "should be char");
+        static_assert(std::is_same<_C2FlexHelper<char>::FlexType, void>::value, "should be void");
+        static_assert(std::is_same<_C2FlexHelper<char[]>::FlexType, char>::value, "should be char");
+        static_assert(std::is_same<_C2FlexHelper<_Flex>::FlexType, char>::value, "should be char");
 
-        static_assert(std::is_same<_C2FlexHelper<_BoFlex>::flexType, char>::value, "should be void");
+        static_assert(std::is_same<_C2FlexHelper<_BoFlex>::FlexType, char>::value, "should be void");
 
         static_assert(_C2Flexible<_Flex>::value, "should be flexible");
         static_assert(!_C2Flexible<_NonFlex>::value, "should not be flexible");
@@ -1658,11 +1704,11 @@
 //        EXPECT_EQ(100, str->m.mNumbers[0]);
         (void)&bstr.mNumbers[0];
 
-        C2Param::BaseIndex index = C2NumbersStruct::coreIndex;
+        C2Param::CoreIndex index = C2NumbersStruct::CORE_INDEX;
         EXPECT_FALSE(index.isVendor());
         EXPECT_TRUE(index.isFlexible());
-        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::BaseIndex::_kFlexibleFlag);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumbers);
+        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::CoreIndex::IS_FLEX_FLAG);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumbers);
     }
 
     std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::alloc_unique(1);
@@ -1698,18 +1744,18 @@
         EXPECT_EQ(*tun, *btun);
 
         // index
-        EXPECT_EQ(C2Param::Type(tun->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(tun->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(tun->type(), C2NumbersTuning::typeIndex);
+        EXPECT_EQ(C2Param::Type(tun->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(tun->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(tun->type(), C2NumbersTuning::PARAM_TYPE);
         EXPECT_EQ(tun->stream(), ~0u);
 
-        C2Param::BaseIndex index = C2NumbersTuning::coreIndex;
+        C2Param::CoreIndex index = C2NumbersTuning::CORE_INDEX;
         EXPECT_FALSE(index.isVendor());
         EXPECT_TRUE(index.isFlexible());
-        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::BaseIndex::_kFlexibleFlag);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumbers);
+        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::CoreIndex::IS_FLEX_FLAG);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumbers);
 
-        C2Param::Type type = C2NumbersTuning::typeIndex;
+        C2Param::Type type = C2NumbersTuning::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_TRUE(type.isFlexible());
         EXPECT_TRUE(type.isGlobal());
@@ -1867,39 +1913,39 @@
         EXPECT_TRUE(*inp1 == *boutp1);
 
         // index
-        EXPECT_EQ(C2Param::Type(inp1->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(inp1->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(inp1->type(), C2NumbersPortTuning::input::typeIndex);
+        EXPECT_EQ(C2Param::Type(inp1->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(inp1->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(inp1->type(), C2NumbersPortTuning::input::PARAM_TYPE);
         EXPECT_EQ(inp1->stream(), ~0u);
 
-        EXPECT_EQ(C2Param::Type(inp2->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(inp2->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(inp2->type(), C2NumbersPortTuning::input::typeIndex);
+        EXPECT_EQ(C2Param::Type(inp2->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(inp2->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(inp2->type(), C2NumbersPortTuning::input::PARAM_TYPE);
         EXPECT_EQ(inp2->stream(), ~0u);
 
-        EXPECT_EQ(C2Param::Type(outp1->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(outp1->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(outp1->type(), C2NumbersPortTuning::output::typeIndex);
+        EXPECT_EQ(C2Param::Type(outp1->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(outp1->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(outp1->type(), C2NumbersPortTuning::output::PARAM_TYPE);
         EXPECT_EQ(outp1->stream(), ~0u);
 
-        EXPECT_EQ(C2Param::Type(outp2->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(outp2->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(outp2->type(), C2NumbersPortTuning::output::typeIndex);
+        EXPECT_EQ(C2Param::Type(outp2->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(outp2->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(outp2->type(), C2NumbersPortTuning::output::PARAM_TYPE);
         EXPECT_EQ(outp2->stream(), ~0u);
 
-        C2Param::BaseIndex index = C2NumbersPortTuning::input::typeIndex;
+        C2Param::CoreIndex index = C2NumbersPortTuning::input::PARAM_TYPE;
         EXPECT_FALSE(index.isVendor());
         EXPECT_TRUE(index.isFlexible());
-        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::BaseIndex::_kFlexibleFlag);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumbers);
+        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::CoreIndex::IS_FLEX_FLAG);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumbers);
 
-        index = C2NumbersPortTuning::output::typeIndex;
+        index = C2NumbersPortTuning::output::PARAM_TYPE;
         EXPECT_FALSE(index.isVendor());
         EXPECT_TRUE(index.isFlexible());
-        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::BaseIndex::_kFlexibleFlag);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumbers);
+        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::CoreIndex::IS_FLEX_FLAG);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumbers);
 
-        C2Param::Type type = C2NumbersPortTuning::input::typeIndex;
+        C2Param::Type type = C2NumbersPortTuning::input::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_TRUE(type.isFlexible());
         EXPECT_FALSE(type.isGlobal());
@@ -1908,7 +1954,7 @@
         EXPECT_FALSE(type.forStream());
         EXPECT_TRUE(type.forPort());
 
-        type = C2NumbersPortTuning::output::typeIndex;
+        type = C2NumbersPortTuning::output::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_TRUE(type.isFlexible());
         EXPECT_FALSE(type.isGlobal());
@@ -2104,35 +2150,35 @@
         EXPECT_TRUE(*ins1 == *bouts1);
 
         // index
-        EXPECT_EQ(C2Param::Type(ins1->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(ins1->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(ins1->type(), C2NumbersStreamTuning::input::typeIndex);
+        EXPECT_EQ(C2Param::Type(ins1->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(ins1->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(ins1->type(), C2NumbersStreamTuning::input::PARAM_TYPE);
 
-        EXPECT_EQ(C2Param::Type(ins2->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(ins2->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(ins2->type(), C2NumbersStreamTuning::input::typeIndex);
+        EXPECT_EQ(C2Param::Type(ins2->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(ins2->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(ins2->type(), C2NumbersStreamTuning::input::PARAM_TYPE);
 
-        EXPECT_EQ(C2Param::Type(outs1->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(outs1->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(outs1->type(), C2NumbersStreamTuning::output::typeIndex);
+        EXPECT_EQ(C2Param::Type(outs1->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(outs1->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(outs1->type(), C2NumbersStreamTuning::output::PARAM_TYPE);
 
-        EXPECT_EQ(C2Param::Type(outs2->type()).coreIndex(), C2NumbersStruct::coreIndex);
-        EXPECT_EQ(C2Param::Type(outs2->type()).paramIndex(), kParamIndexNumbers);
-        EXPECT_EQ(outs2->type(), C2NumbersStreamTuning::output::typeIndex);
+        EXPECT_EQ(C2Param::Type(outs2->type()).coreIndex(), C2NumbersStruct::CORE_INDEX);
+        EXPECT_EQ(C2Param::Type(outs2->type()).typeIndex(), kParamIndexNumbers);
+        EXPECT_EQ(outs2->type(), C2NumbersStreamTuning::output::PARAM_TYPE);
 
-        C2Param::BaseIndex index = C2NumbersStreamTuning::input::typeIndex;
+        C2Param::CoreIndex index = C2NumbersStreamTuning::input::PARAM_TYPE;
         EXPECT_FALSE(index.isVendor());
         EXPECT_TRUE(index.isFlexible());
-        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::BaseIndex::_kFlexibleFlag);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumbers);
+        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::CoreIndex::IS_FLEX_FLAG);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumbers);
 
-        index = C2NumbersStreamTuning::output::typeIndex;
+        index = C2NumbersStreamTuning::output::PARAM_TYPE;
         EXPECT_FALSE(index.isVendor());
         EXPECT_TRUE(index.isFlexible());
-        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::BaseIndex::_kFlexibleFlag);
-        EXPECT_EQ(index.paramIndex(), kParamIndexNumbers);
+        EXPECT_EQ(index.coreIndex(), kParamIndexNumbers | C2Param::CoreIndex::IS_FLEX_FLAG);
+        EXPECT_EQ(index.typeIndex(), kParamIndexNumbers);
 
-        C2Param::Type type = C2NumbersStreamTuning::input::typeIndex;
+        C2Param::Type type = C2NumbersStreamTuning::input::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_TRUE(type.isFlexible());
         EXPECT_FALSE(type.isGlobal());
@@ -2141,7 +2187,7 @@
         EXPECT_TRUE(type.forStream());
         EXPECT_FALSE(type.forPort());
 
-        type = C2NumbersStreamTuning::output::typeIndex;
+        type = C2NumbersStreamTuning::output::PARAM_TYPE;
         EXPECT_FALSE(type.isVendor());
         EXPECT_TRUE(type.isFlexible());
         EXPECT_FALSE(type.isGlobal());
@@ -2190,9 +2236,9 @@
 
     {
         C2Int32Value int32Value(INT32_MIN);
-        static_assert(std::is_same<decltype(int32Value.mValue), int32_t>::value, "should be int32_t");
-        EXPECT_EQ(INT32_MIN, int32Value.mValue);
-        std::list<const C2FieldDescriptor> fields = int32Value.fieldList;
+        static_assert(std::is_same<decltype(int32Value.value), int32_t>::value, "should be int32_t");
+        EXPECT_EQ(INT32_MIN, int32Value.value);
+        std::list<const C2FieldDescriptor> fields = int32Value.FIELD_LIST;
         EXPECT_EQ(1u, fields.size());
         EXPECT_EQ(FD::INT32, fields.cbegin()->type());
         EXPECT_EQ(1u, fields.cbegin()->length());
@@ -2201,9 +2247,9 @@
 
     {
         C2Uint32Value uint32Value(UINT32_MAX);
-        static_assert(std::is_same<decltype(uint32Value.mValue), uint32_t>::value, "should be uint32_t");
-        EXPECT_EQ(UINT32_MAX, uint32Value.mValue);
-        std::list<const C2FieldDescriptor> fields = uint32Value.fieldList;
+        static_assert(std::is_same<decltype(uint32Value.value), uint32_t>::value, "should be uint32_t");
+        EXPECT_EQ(UINT32_MAX, uint32Value.value);
+        std::list<const C2FieldDescriptor> fields = uint32Value.FIELD_LIST;
         EXPECT_EQ(1u, fields.size());
         EXPECT_EQ(FD::UINT32, fields.cbegin()->type());
         EXPECT_EQ(1u, fields.cbegin()->length());
@@ -2212,9 +2258,9 @@
 
     {
         C2Int64Value int64Value(INT64_MIN);
-        static_assert(std::is_same<decltype(int64Value.mValue), int64_t>::value, "should be int64_t");
-        EXPECT_EQ(INT64_MIN, int64Value.mValue);
-        std::list<const C2FieldDescriptor> fields = int64Value.fieldList;
+        static_assert(std::is_same<decltype(int64Value.value), int64_t>::value, "should be int64_t");
+        EXPECT_EQ(INT64_MIN, int64Value.value);
+        std::list<const C2FieldDescriptor> fields = int64Value.FIELD_LIST;
         EXPECT_EQ(1u, fields.size());
         EXPECT_EQ(FD::INT64, fields.cbegin()->type());
         EXPECT_EQ(1u, fields.cbegin()->length());
@@ -2223,9 +2269,9 @@
 
     {
         C2Uint64Value uint64Value(UINT64_MAX);
-        static_assert(std::is_same<decltype(uint64Value.mValue), uint64_t>::value, "should be uint64_t");
-        EXPECT_EQ(UINT64_MAX, uint64Value.mValue);
-        std::list<const C2FieldDescriptor> fields = uint64Value.fieldList;
+        static_assert(std::is_same<decltype(uint64Value.value), uint64_t>::value, "should be uint64_t");
+        EXPECT_EQ(UINT64_MAX, uint64Value.value);
+        std::list<const C2FieldDescriptor> fields = uint64Value.FIELD_LIST;
         EXPECT_EQ(1u, fields.size());
         EXPECT_EQ(FD::UINT64, fields.cbegin()->type());
         EXPECT_EQ(1u, fields.cbegin()->length());
@@ -2234,9 +2280,9 @@
 
     {
         C2FloatValue floatValue(123.4f);
-        static_assert(std::is_same<decltype(floatValue.mValue), float>::value, "should be float");
-        EXPECT_EQ(123.4f, floatValue.mValue);
-        std::list<const C2FieldDescriptor> fields = floatValue.fieldList;
+        static_assert(std::is_same<decltype(floatValue.value), float>::value, "should be float");
+        EXPECT_EQ(123.4f, floatValue.value);
+        std::list<const C2FieldDescriptor> fields = floatValue.FIELD_LIST;
         EXPECT_EQ(1u, fields.size());
         EXPECT_EQ(FD::FLOAT, fields.cbegin()->type());
         EXPECT_EQ(1u, fields.cbegin()->length());
@@ -2247,17 +2293,17 @@
         uint8_t initValue[] = "ABCD";
         typedef C2GlobalParam<C2Setting, C2BlobValue, 0> BlobSetting;
         std::unique_ptr<BlobSetting> blobValue = BlobSetting::alloc_unique(6, C2ConstMemoryBlock<uint8_t>(initValue));
-        static_assert(std::is_same<decltype(blobValue->m.mValue), uint8_t[]>::value, "should be uint8_t[]");
-        EXPECT_EQ(0, memcmp(blobValue->m.mValue, "ABCD\0", 6));
+        static_assert(std::is_same<decltype(blobValue->m.value), uint8_t[]>::value, "should be uint8_t[]");
+        EXPECT_EQ(0, memcmp(blobValue->m.value, "ABCD\0", 6));
         EXPECT_EQ(6u, blobValue->flexCount());
-        std::list<const C2FieldDescriptor> fields = blobValue->fieldList;
+        std::list<const C2FieldDescriptor> fields = blobValue->FIELD_LIST;
         EXPECT_EQ(1u, fields.size());
         EXPECT_EQ(FD::BLOB, fields.cbegin()->type());
         EXPECT_EQ(0u, fields.cbegin()->length());
         EXPECT_EQ(C2String("value"), fields.cbegin()->name());
 
         blobValue = BlobSetting::alloc_unique(3, C2ConstMemoryBlock<uint8_t>(initValue));
-        EXPECT_EQ(0, memcmp(blobValue->m.mValue, "ABC", 3));
+        EXPECT_EQ(0, memcmp(blobValue->m.value, "ABC", 3));
         EXPECT_EQ(3u, blobValue->flexCount());
     }
 
@@ -2266,38 +2312,38 @@
         typedef C2GlobalParam<C2Setting, C2StringValue, 0> StringSetting;
         std::unique_ptr<StringSetting> stringValue = StringSetting::alloc_unique(6, C2ConstMemoryBlock<char>(initValue));
         stringValue = StringSetting::alloc_unique(6, initValue);
-        static_assert(std::is_same<decltype(stringValue->m.mValue), char[]>::value, "should be char[]");
-        EXPECT_EQ(0, memcmp(stringValue->m.mValue, "ABCD\0", 6));
+        static_assert(std::is_same<decltype(stringValue->m.value), char[]>::value, "should be char[]");
+        EXPECT_EQ(0, memcmp(stringValue->m.value, "ABCD\0", 6));
         EXPECT_EQ(6u, stringValue->flexCount());
-        std::list<const C2FieldDescriptor> fields = stringValue->fieldList;
+        std::list<const C2FieldDescriptor> fields = stringValue->FIELD_LIST;
         EXPECT_EQ(1u, fields.size());
         EXPECT_EQ(FD::STRING, fields.cbegin()->type());
         EXPECT_EQ(0u, fields.cbegin()->length());
         EXPECT_EQ(C2String("value"), fields.cbegin()->name());
 
         stringValue = StringSetting::alloc_unique(3, C2ConstMemoryBlock<char>(initValue));
-        EXPECT_EQ(0, memcmp(stringValue->m.mValue, "AB", 3));
+        EXPECT_EQ(0, memcmp(stringValue->m.value, "AB", 3));
         EXPECT_EQ(3u, stringValue->flexCount());
 
         stringValue = StringSetting::alloc_unique(11, "initValue");
-        EXPECT_EQ(0, memcmp(stringValue->m.mValue, "initValue\0", 11));
+        EXPECT_EQ(0, memcmp(stringValue->m.value, "initValue\0", 11));
         EXPECT_EQ(11u, stringValue->flexCount());
 
         stringValue = StringSetting::alloc_unique(initValue);
-        EXPECT_EQ(0, memcmp(stringValue->m.mValue, "ABCD", 5));
+        EXPECT_EQ(0, memcmp(stringValue->m.value, "ABCD", 5));
         EXPECT_EQ(5u, stringValue->flexCount());
 
         stringValue = StringSetting::alloc_unique({ 'A', 'B', 'C', 'D' });
-        EXPECT_EQ(0, memcmp(stringValue->m.mValue, "ABC", 4));
+        EXPECT_EQ(0, memcmp(stringValue->m.value, "ABC", 4));
         EXPECT_EQ(4u, stringValue->flexCount());
     }
 
     {
-        uint32_t videoWidth[] = { 12u, C2NumbersStreamTuning::output::typeIndex, 100 };
+        uint32_t videoWidth[] = { 12u, C2NumbersStreamTuning::output::PARAM_TYPE, 100 };
         C2Param *p1 = C2Param::From(videoWidth, sizeof(videoWidth));
         EXPECT_NE(nullptr, p1);
         EXPECT_EQ(12u, p1->size());
-        EXPECT_EQ(C2NumbersStreamTuning::output::typeIndex, p1->type());
+        EXPECT_EQ(p1->type(), C2NumbersStreamTuning::output::PARAM_TYPE);
 
         C2NumbersStreamTuning::output *vst = C2NumbersStreamTuning::output::From(p1);
         EXPECT_NE(nullptr, vst);
@@ -2320,12 +2366,12 @@
     }
 
     {
-        uint32_t videoWidth[] = { 16u, C2NumbersPortTuning::input::typeIndex, 101, 102 };
+        uint32_t videoWidth[] = { 16u, C2NumbersPortTuning::input::PARAM_TYPE, 101, 102 };
 
         C2Param *p1 = C2Param::From(videoWidth, sizeof(videoWidth));
         EXPECT_NE(nullptr, p1);
         EXPECT_EQ(16u, p1->size());
-        EXPECT_EQ(C2NumbersPortTuning::input::typeIndex, p1->type());
+        EXPECT_EQ(p1->type(), C2NumbersPortTuning::input::PARAM_TYPE);
 
         C2NumbersPortTuning::input *vpt = C2NumbersPortTuning::input::From(p1);
         EXPECT_NE(nullptr, vpt);
@@ -2375,18 +2421,18 @@
 };
 
 struct C2VideoConfigStruct {
-    int32_t mWidth;
-    uint32_t mHeight;
-    MetadataType mMetadataType;
-    int32_t mSupportedFormats[];
+    int32_t width;
+    uint32_t height;
+    MetadataType metadataType;
+    int32_t supportedFormats[];
 
     C2VideoConfigStruct() {}
 
-    DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(VideoConfig, mSupportedFormats)
-    C2FIELD(mWidth, "width")
-    C2FIELD(mHeight, "height")
-    C2FIELD(mMetadataType, "metadata-type")
-    C2FIELD(mSupportedFormats, "formats")
+    DEFINE_AND_DESCRIBE_FLEX_C2STRUCT(VideoConfig, supportedFormats)
+    C2FIELD(width, "width")
+    C2FIELD(height, "height")
+    C2FIELD(metadataType, "metadata-type")
+    C2FIELD(supportedFormats, "formats")
 };
 
 typedef C2PortParam<C2Tuning, C2VideoConfigStruct> C2VideoConfigPortTuning;
@@ -2430,11 +2476,11 @@
             }
 
             // note: this does not handle stream params (should use index...)
-            if (!mMyParams.count(param->type())) {
+            if (!mMyParams.count(param->index())) {
                 continue; // not my param
             }
 
-            C2Param & myParam = mMyParams.find(param->type())->second;
+            C2Param & myParam = mMyParams.find(param->index())->second;
             if (myParam.size() != param->size()) { // incorrect size
                 param->invalidate();
                 continue;
@@ -2459,7 +2505,7 @@
     C2ComponentDomainInfo mDomainInfo;
 
     MyComponentInstance() {
-        mMyParams.insert({mDomainInfo.type(), mDomainInfo});
+        mMyParams.insert({mDomainInfo.index(), mDomainInfo});
     }
 
     virtual c2_status_t releaseTunnel_sm(c2_node_id_t targetComponent) override {
@@ -2473,13 +2519,13 @@
     public:
         MyParamReflector(const MyComponentInstance *i) : instance(i) { }
 
-        virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::BaseIndex paramIndex) override {
-            switch (paramIndex.coreIndex()) {
-            case decltype(instance->mDomainInfo)::coreIndex:
+        virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex paramIndex) override {
+            switch (paramIndex.typeIndex()) {
+            case decltype(instance->mDomainInfo)::CORE_INDEX:
             default:
                 return std::unique_ptr<C2StructDescriptor>(new C2StructDescriptor{
                     instance->mDomainInfo.type(),
-                    decltype(instance->mDomainInfo)::fieldList,
+                    decltype(instance->mDomainInfo)::FIELD_LIST,
                 });
             }
             return nullptr;
@@ -2491,10 +2537,10 @@
             c2_blocking_t mayBlock) const override {
         (void)mayBlock;
         for (C2FieldSupportedValuesQuery &query : fields) {
-            if (query.field == C2ParamField(&mDomainInfo, &C2ComponentDomainInfo::mValue)) {
+            if (query.field == C2ParamField(&mDomainInfo, &C2ComponentDomainInfo::value)) {
                 query.values = C2FieldSupportedValues(
                     false /* flag */,
-                    &mDomainInfo.mValue
+                    &mDomainInfo.value
                     //,
                     //{(int32_t)C2DomainVideo}
                 );
@@ -2611,7 +2657,7 @@
         cout << "Flex";
     }
 
-    cout << type.paramIndex();
+    cout << type.typeIndex();
 
     switch (type.kind()) {
     case C2Param::INFO: cout << "Info"; break;
@@ -2622,17 +2668,17 @@
     }
 }
 
-void dumpType(C2Param::BaseIndex type) {
+void dumpType(C2Param::CoreIndex type) {
     using namespace std;
     cout << (type.isVendor() ? "Vendor" : "C2");
     if (type.isFlexible()) {
         cout << "Flex";
     }
 
-    cout << type.paramIndex() << "Struct";
+    cout << type.typeIndex() << "Struct";
 }
 
-void dumpType(FD::Type type) {
+void dumpType(FD::type_t type) {
     using namespace std;
     switch (type) {
     case FD::BLOB: cout << "blob "; break;
@@ -2700,21 +2746,21 @@
     std::shared_ptr<C2ComponentInterface> comp = myComp;
 
     std::unique_ptr<C2StructDescriptor> desc{
-        myComp->getParamReflector()->describe(C2ComponentDomainInfo::indexFlags)};
+        myComp->getParamReflector()->describe(C2ComponentDomainInfo::CORE_INDEX)};
     dumpStruct(*desc);
 
     std::vector<C2FieldSupportedValuesQuery> query = {
-        { C2ParamField(&domainInfo, &C2ComponentDomainInfo::mValue),
+        { C2ParamField(&domainInfo, &C2ComponentDomainInfo::value),
           C2FieldSupportedValuesQuery::CURRENT },
-        C2FieldSupportedValuesQuery(C2ParamField(&domainInfo, &C2ComponentDomainInfo::mValue),
+        C2FieldSupportedValuesQuery(C2ParamField(&domainInfo, &C2ComponentDomainInfo::value),
           C2FieldSupportedValuesQuery::CURRENT),
-        C2FieldSupportedValuesQuery::Current(C2ParamField(&domainInfo, &C2ComponentDomainInfo::mValue)),
+        C2FieldSupportedValuesQuery::Current(C2ParamField(&domainInfo, &C2ComponentDomainInfo::value)),
     };
 
     EXPECT_EQ(C2_OK, comp->querySupportedValues_vb(query, C2_DONT_BLOCK));
 
     for (const C2FieldSupportedValuesQuery &q : query) {
-        dumpFSV(q.values, &domainInfo.mValue);
+        dumpFSV(q.values, &domainInfo.value);
     }
 }
 
@@ -2730,7 +2776,7 @@
     values.push_back(C2FieldSupportedValues(false, v));  // flags, std::vector
 
     for (const C2FieldSupportedValues &sv : values) {
-        dumpFSV(sv, &t.mValue);
+        dumpFSV(sv, &t.value);
     }
 }
 
diff --git a/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp b/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
index 1bcf070..f6e6478 100644
--- a/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
+++ b/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
@@ -40,7 +40,7 @@
     void allocateLinear(size_t capacity) {
         c2_status_t err = mLinearAllocator->newLinearAllocation(
                 capacity,
-                { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+                { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
                 &mLinearAllocation);
         if (err != C2_OK) {
             mLinearAllocation.reset();
@@ -53,7 +53,7 @@
         c2_status_t err = mLinearAllocation->map(
                 offset,
                 size,
-                { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+                { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
                 // TODO: fence
                 nullptr,
                 &mAddr);
@@ -86,7 +86,7 @@
                 width,
                 height,
                 HAL_PIXEL_FORMAT_YCBCR_420_888,
-                { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+                { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
                 &mGraphicAllocation);
         if (err != C2_OK) {
             mGraphicAllocation.reset();
@@ -94,19 +94,19 @@
         }
     }
 
-    void mapGraphic(C2Rect rect, C2PlaneLayout *layout, uint8_t **addr) {
+    void mapGraphic(C2Rect rect, C2PlanarLayout *layout, uint8_t **addr) {
         ASSERT_TRUE(mGraphicAllocation);
         c2_status_t err = mGraphicAllocation->map(
                 rect,
-                { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+                { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
                 // TODO: fence
                 nullptr,
                 layout,
                 addr);
         if (err != C2_OK) {
-            addr[C2PlaneLayout::Y] = nullptr;
-            addr[C2PlaneLayout::U] = nullptr;
-            addr[C2PlaneLayout::V] = nullptr;
+            addr[C2PlanarLayout::PLANE_Y] = nullptr;
+            addr[C2PlanarLayout::PLANE_U] = nullptr;
+            addr[C2PlanarLayout::PLANE_V] = nullptr;
             FAIL() << "C2GraphicAllocation::map() failed: " << err;
         }
     }
@@ -163,7 +163,7 @@
     std::shared_ptr<C2LinearBlock> block;
     ASSERT_EQ(C2_OK, blockPool->fetchLinearBlock(
             kCapacity,
-            { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+            { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
             &block));
     ASSERT_TRUE(block);
 
@@ -210,20 +210,20 @@
 }
 
 void fillPlane(const C2Rect rect, const C2PlaneInfo info, uint8_t *addr, uint8_t value) {
-    for (uint32_t row = 0; row < rect.mHeight / info.mVertSubsampling; ++row) {
-        int32_t rowOffset = (row + rect.mTop / info.mVertSubsampling) * info.mRowInc;
-        for (uint32_t col = 0; col < rect.mWidth / info.mHorizSubsampling; ++col) {
-            int32_t colOffset = (col + rect.mLeft / info.mHorizSubsampling) * info.mColInc;
+    for (uint32_t row = 0; row < rect.height / info.rowSampling; ++row) {
+        int32_t rowOffset = (row + rect.top / info.rowSampling) * info.rowInc;
+        for (uint32_t col = 0; col < rect.width / info.colSampling; ++col) {
+            int32_t colOffset = (col + rect.left / info.colSampling) * info.colInc;
             addr[rowOffset + colOffset] = value;
         }
     }
 }
 
 bool verifyPlane(const C2Rect rect, const C2PlaneInfo info, const uint8_t *addr, uint8_t value) {
-    for (uint32_t row = 0; row < rect.mHeight / info.mVertSubsampling; ++row) {
-        int32_t rowOffset = (row + rect.mTop / info.mVertSubsampling) * info.mRowInc;
-        for (uint32_t col = 0; col < rect.mWidth / info.mHorizSubsampling; ++col) {
-            int32_t colOffset = (col + rect.mLeft / info.mHorizSubsampling) * info.mColInc;
+    for (uint32_t row = 0; row < rect.height / info.rowSampling; ++row) {
+        int32_t rowOffset = (row + rect.top / info.rowSampling) * info.rowInc;
+        for (uint32_t col = 0; col < rect.width / info.colSampling; ++col) {
+            int32_t colOffset = (col + rect.left / info.colSampling) * info.colInc;
             if (addr[rowOffset + colOffset] != value) {
                 return false;
             }
@@ -238,20 +238,20 @@
 
     allocateGraphic(kWidth, kHeight);
 
-    uint8_t *addr[C2PlaneLayout::MAX_NUM_PLANES];
+    uint8_t *addr[C2PlanarLayout::MAX_NUM_PLANES];
     C2Rect rect{ 0, 0, kWidth, kHeight };
-    C2PlaneLayout layout;
+    C2PlanarLayout layout;
     mapGraphic(rect, &layout, addr);
-    ASSERT_NE(nullptr, addr[C2PlaneLayout::Y]);
-    ASSERT_NE(nullptr, addr[C2PlaneLayout::U]);
-    ASSERT_NE(nullptr, addr[C2PlaneLayout::V]);
+    ASSERT_NE(nullptr, addr[C2PlanarLayout::PLANE_Y]);
+    ASSERT_NE(nullptr, addr[C2PlanarLayout::PLANE_U]);
+    ASSERT_NE(nullptr, addr[C2PlanarLayout::PLANE_V]);
 
-    uint8_t *y = addr[C2PlaneLayout::Y];
-    C2PlaneInfo yInfo = layout.mPlanes[C2PlaneLayout::Y];
-    uint8_t *u = addr[C2PlaneLayout::U];
-    C2PlaneInfo uInfo = layout.mPlanes[C2PlaneLayout::U];
-    uint8_t *v = addr[C2PlaneLayout::V];
-    C2PlaneInfo vInfo = layout.mPlanes[C2PlaneLayout::V];
+    uint8_t *y = addr[C2PlanarLayout::PLANE_Y];
+    C2PlaneInfo yInfo = layout.planes[C2PlanarLayout::PLANE_Y];
+    uint8_t *u = addr[C2PlanarLayout::PLANE_U];
+    C2PlaneInfo uInfo = layout.planes[C2PlanarLayout::PLANE_U];
+    uint8_t *v = addr[C2PlanarLayout::PLANE_V];
+    C2PlaneInfo vInfo = layout.planes[C2PlanarLayout::PLANE_V];
 
     fillPlane(rect, yInfo, y, 0);
     fillPlane(rect, uInfo, u, 0);
@@ -263,16 +263,16 @@
     unmapGraphic();
 
     mapGraphic(rect, &layout, addr);
-    ASSERT_NE(nullptr, addr[C2PlaneLayout::Y]);
-    ASSERT_NE(nullptr, addr[C2PlaneLayout::U]);
-    ASSERT_NE(nullptr, addr[C2PlaneLayout::V]);
+    ASSERT_NE(nullptr, addr[C2PlanarLayout::PLANE_Y]);
+    ASSERT_NE(nullptr, addr[C2PlanarLayout::PLANE_U]);
+    ASSERT_NE(nullptr, addr[C2PlanarLayout::PLANE_V]);
 
-    y = addr[C2PlaneLayout::Y];
-    yInfo = layout.mPlanes[C2PlaneLayout::Y];
-    u = addr[C2PlaneLayout::U];
-    uInfo = layout.mPlanes[C2PlaneLayout::U];
-    v = addr[C2PlaneLayout::V];
-    vInfo = layout.mPlanes[C2PlaneLayout::V];
+    y = addr[C2PlanarLayout::PLANE_Y];
+    yInfo = layout.planes[C2PlanarLayout::PLANE_Y];
+    u = addr[C2PlanarLayout::PLANE_U];
+    uInfo = layout.planes[C2PlanarLayout::PLANE_U];
+    v = addr[C2PlanarLayout::PLANE_V];
+    vInfo = layout.planes[C2PlanarLayout::PLANE_V];
 
     ASSERT_TRUE(verifyPlane({ kWidth / 4, kHeight / 4, kWidth / 2, kHeight / 2 }, yInfo, y, 0x12));
     ASSERT_TRUE(verifyPlane({ kWidth / 4, kHeight / 4, kWidth / 2, kHeight / 2 }, uInfo, u, 0x34));
@@ -296,7 +296,7 @@
             kWidth,
             kHeight,
             HAL_PIXEL_FORMAT_YCBCR_420_888,
-            { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+            { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
             &block));
     ASSERT_TRUE(block);
 
@@ -307,15 +307,15 @@
     ASSERT_EQ(kHeight, graphicView.height());
 
     uint8_t *const *data = graphicView.data();
-    C2PlaneLayout layout = graphicView.layout();
+    C2PlanarLayout layout = graphicView.layout();
     ASSERT_NE(nullptr, data);
 
-    uint8_t *y = data[C2PlaneLayout::Y];
-    C2PlaneInfo yInfo = layout.mPlanes[C2PlaneLayout::Y];
-    uint8_t *u = data[C2PlaneLayout::U];
-    C2PlaneInfo uInfo = layout.mPlanes[C2PlaneLayout::U];
-    uint8_t *v = data[C2PlaneLayout::V];
-    C2PlaneInfo vInfo = layout.mPlanes[C2PlaneLayout::V];
+    uint8_t *y = data[C2PlanarLayout::PLANE_Y];
+    C2PlaneInfo yInfo = layout.planes[C2PlanarLayout::PLANE_Y];
+    uint8_t *u = data[C2PlanarLayout::PLANE_U];
+    C2PlaneInfo uInfo = layout.planes[C2PlanarLayout::PLANE_U];
+    uint8_t *v = data[C2PlanarLayout::PLANE_V];
+    C2PlaneInfo vInfo = layout.planes[C2PlanarLayout::PLANE_V];
 
     fillPlane({ 0, 0, kWidth, kHeight }, yInfo, y, 0);
     fillPlane({ 0, 0, kWidth, kHeight }, uInfo, u, 0);
@@ -339,12 +339,12 @@
     layout = graphicView.layout();
     ASSERT_NE(nullptr, constData);
 
-    const uint8_t *cy = constData[C2PlaneLayout::Y];
-    yInfo = layout.mPlanes[C2PlaneLayout::Y];
-    const uint8_t *cu = constData[C2PlaneLayout::U];
-    uInfo = layout.mPlanes[C2PlaneLayout::U];
-    const uint8_t *cv = constData[C2PlaneLayout::V];
-    vInfo = layout.mPlanes[C2PlaneLayout::V];
+    const uint8_t *cy = constData[C2PlanarLayout::PLANE_Y];
+    yInfo = layout.planes[C2PlanarLayout::PLANE_Y];
+    const uint8_t *cu = constData[C2PlanarLayout::PLANE_U];
+    uInfo = layout.planes[C2PlanarLayout::PLANE_U];
+    const uint8_t *cv = constData[C2PlanarLayout::PLANE_V];
+    vInfo = layout.planes[C2PlanarLayout::PLANE_V];
 
     ASSERT_TRUE(verifyPlane({ kWidth / 4, kHeight / 4, kWidth / 2, kHeight / 2 }, yInfo, cy, 0x12));
     ASSERT_TRUE(verifyPlane({ kWidth / 4, kHeight / 4, kWidth / 2, kHeight / 2 }, uInfo, cu, 0x34));
@@ -386,11 +386,11 @@
     std::shared_ptr<C2LinearBlock> linearBlock2;
     ASSERT_EQ(C2_OK, linearBlockPool->fetchLinearBlock(
             kCapacity1,
-            { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+            { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
             &linearBlock1));
     ASSERT_EQ(C2_OK, linearBlockPool->fetchLinearBlock(
             kCapacity2,
-            { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+            { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
             &linearBlock2));
     std::shared_ptr<C2GraphicBlock> graphicBlock1;
     std::shared_ptr<C2GraphicBlock> graphicBlock2;
@@ -398,13 +398,13 @@
             kWidth1,
             kHeight1,
             HAL_PIXEL_FORMAT_YCBCR_420_888,
-            { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+            { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
             &graphicBlock1));
     ASSERT_EQ(C2_OK, graphicBlockPool->fetchGraphicBlock(
             kWidth2,
             kHeight2,
             HAL_PIXEL_FORMAT_YCBCR_420_888,
-            { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+            { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
             &graphicBlock2));
 
     std::shared_ptr<C2BufferData> data(new BufferData({ linearBlock1->share(0, kCapacity1, C2Fence()) }));
@@ -460,7 +460,7 @@
 
     ASSERT_EQ(C2_OK, alloc->fetchLinearBlock(
             kCapacity,
-            { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+            { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
             &block));
 
     std::atomic_bool destroyed(false);
diff --git a/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp b/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
index da8372c..b5ca90d 100644
--- a/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
+++ b/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
@@ -56,7 +56,7 @@
 
     virtual c2_status_t map(
             C2Rect rect, C2MemoryUsage usage, int *fenceFd,
-            C2PlaneLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) override;
+            C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) override;
     virtual c2_status_t unmap(C2Fence *fenceFd /* nullable */) override;
     virtual bool isValid() const override { return true; }
     virtual const C2Handle *handle() const override { return mHandle; }
@@ -102,7 +102,7 @@
 
 c2_status_t C2AllocationGralloc::map(
         C2Rect rect, C2MemoryUsage usage, int *fenceFd,
-        C2PlaneLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
+        C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
     // TODO
     (void) fenceFd;
     (void) usage;
@@ -133,7 +133,7 @@
         mMapper->lockYCbCr(
                 const_cast<native_handle_t *>(mBuffer),
                 BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN,
-                { (int32_t)rect.mLeft, (int32_t)rect.mTop, (int32_t)rect.mWidth, (int32_t)rect.mHeight },
+                { (int32_t)rect.left, (int32_t)rect.top, (int32_t)rect.width, (int32_t)rect.height },
                 // TODO: fence
                 hidl_handle(),
                 [&err, &ycbcrLayout](const auto &maperr, const auto &mapLayout) {
@@ -145,44 +145,50 @@
         if (err != C2_OK) {
             return err;
         }
-        addr[C2PlaneLayout::Y] = (uint8_t *)ycbcrLayout.y;
-        addr[C2PlaneLayout::U] = (uint8_t *)ycbcrLayout.cb;
-        addr[C2PlaneLayout::V] = (uint8_t *)ycbcrLayout.cr;
-        layout->mType = C2PlaneLayout::MEDIA_IMAGE_TYPE_YUV;
-        layout->mNumPlanes = 3;
-        layout->mPlanes[C2PlaneLayout::Y] = {
-            C2PlaneInfo::Y,                 // mChannel
-            1,                              // mColInc
-            (int32_t)ycbcrLayout.yStride,   // mRowInc
-            1,                              // mHorizSubsampling
-            1,                              // mVertSubsampling
-            8,                              // mBitDepth
-            8,                              // mAllocatedDepth
+        addr[C2PlanarLayout::PLANE_Y] = (uint8_t *)ycbcrLayout.y;
+        addr[C2PlanarLayout::PLANE_U] = (uint8_t *)ycbcrLayout.cb;
+        addr[C2PlanarLayout::PLANE_V] = (uint8_t *)ycbcrLayout.cr;
+        layout->type = C2PlanarLayout::TYPE_YUV;
+        layout->numPlanes = 3;
+        layout->planes[C2PlanarLayout::PLANE_Y] = {
+            C2PlaneInfo::CHANNEL_Y,         // channel
+            1,                              // colInc
+            (int32_t)ycbcrLayout.yStride,   // rowInc
+            1,                              // mColSampling
+            1,                              // mRowSampling
+            8,                              // allocatedDepth
+            8,                              // bitDepth
+            0,                              // rightShift
+            C2PlaneInfo::NATIVE,            // endianness
         };
-        layout->mPlanes[C2PlaneLayout::U] = {
-            C2PlaneInfo::Cb,                  // mChannel
-            (int32_t)ycbcrLayout.chromaStep,  // mColInc
-            (int32_t)ycbcrLayout.cStride,     // mRowInc
-            2,                                // mHorizSubsampling
-            2,                                // mVertSubsampling
-            8,                                // mBitDepth
-            8,                                // mAllocatedDepth
+        layout->planes[C2PlanarLayout::PLANE_U] = {
+            C2PlaneInfo::CHANNEL_CB,          // channel
+            (int32_t)ycbcrLayout.chromaStep,  // colInc
+            (int32_t)ycbcrLayout.cStride,     // rowInc
+            2,                                // mColSampling
+            2,                                // mRowSampling
+            8,                                // allocatedDepth
+            8,                                // bitDepth
+            0,                                // rightShift
+            C2PlaneInfo::NATIVE,              // endianness
         };
-        layout->mPlanes[C2PlaneLayout::V] = {
-            C2PlaneInfo::Cr,                  // mChannel
-            (int32_t)ycbcrLayout.chromaStep,  // mColInc
-            (int32_t)ycbcrLayout.cStride,     // mRowInc
-            2,                                // mHorizSubsampling
-            2,                                // mVertSubsampling
-            8,                                // mBitDepth
-            8,                                // mAllocatedDepth
+        layout->planes[C2PlanarLayout::PLANE_V] = {
+            C2PlaneInfo::CHANNEL_CR,          // channel
+            (int32_t)ycbcrLayout.chromaStep,  // colInc
+            (int32_t)ycbcrLayout.cStride,     // rowInc
+            2,                                // mColSampling
+            2,                                // mRowSampling
+            8,                                // allocatedDepth
+            8,                                // bitDepth
+            0,                                // rightShift
+            C2PlaneInfo::NATIVE,              // endianness
         };
     } else {
         void *pointer = nullptr;
         mMapper->lock(
                 const_cast<native_handle_t *>(mBuffer),
                 BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN,
-                { (int32_t)rect.mLeft, (int32_t)rect.mTop, (int32_t)rect.mWidth, (int32_t)rect.mHeight },
+                { (int32_t)rect.left, (int32_t)rect.top, (int32_t)rect.width, (int32_t)rect.height },
                 // TODO: fence
                 hidl_handle(),
                 [&err, &pointer](const auto &maperr, const auto &mapPointer) {
diff --git a/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp b/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
index acd69af..3a95118 100644
--- a/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
+++ b/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
@@ -147,10 +147,10 @@
         *addr = nullptr;
         int prot = PROT_NONE;
         int flags = MAP_PRIVATE;
-        if (usage.mConsumer & GRALLOC_USAGE_SW_READ_MASK) {
+        if (usage.consumer & C2MemoryUsage::CPU_READ) {
             prot |= PROT_READ;
         }
-        if (usage.mProducer & GRALLOC_USAGE_SW_WRITE_MASK) {
+        if (usage.producer & C2MemoryUsage::CPU_WRITE) {
             prot |= PROT_WRITE;
             flags = MAP_SHARED;
         }
diff --git a/media/libstagefright/codec2/vndk/C2Buffer.cpp b/media/libstagefright/codec2/vndk/C2Buffer.cpp
index d9bde7a..65a271e 100644
--- a/media/libstagefright/codec2/vndk/C2Buffer.cpp
+++ b/media/libstagefright/codec2/vndk/C2Buffer.cpp
@@ -227,7 +227,7 @@
         if (mBase == nullptr) {
             void *base = nullptr;
             mError = mAllocation->map(
-                    offset, size, { C2MemoryUsage::kSoftwareRead, 0 }, nullptr, &base);
+                    offset, size, { C2MemoryUsage::CPU_READ, 0 }, nullptr, &base);
             // TODO: fence
             if (mError == C2_OK) {
                 mBase = (uint8_t *)base;
@@ -291,7 +291,7 @@
             mError = mAllocation->map(
                     0u,
                     capacity,
-                    { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+                    { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
                     nullptr,
                     &base);
             if (mError == C2_OK) {
@@ -390,24 +390,24 @@
 
 class C2GraphicView::Impl {
 public:
-    Impl(uint8_t *const *data, const C2PlaneLayout &layout)
+    Impl(uint8_t *const *data, const C2PlanarLayout &layout)
         : mData(data), mLayout(layout), mError(C2_OK) {}
     explicit Impl(c2_status_t error) : mData(nullptr), mError(error) {}
 
     uint8_t *const *data() const { return mData; }
-    const C2PlaneLayout &layout() const { return mLayout; }
+    const C2PlanarLayout &layout() const { return mLayout; }
     c2_status_t error() const { return mError; }
 
 private:
     uint8_t *const *mData;
-    C2PlaneLayout mLayout;
+    C2PlanarLayout mLayout;
     c2_status_t mError;
 };
 
 C2GraphicView::C2GraphicView(
         const _C2PlanarCapacityAspect *parent,
         uint8_t *const *data,
-        const C2PlaneLayout& layout)
+        const C2PlanarLayout& layout)
     : _C2PlanarSection(parent), mImpl(new Impl(data, layout)) {}
 
 C2GraphicView::C2GraphicView(c2_status_t error)
@@ -421,7 +421,7 @@
     return mImpl->data();
 }
 
-const C2PlaneLayout C2GraphicView::layout() const {
+const C2PlanarLayout C2GraphicView::layout() const {
     return mImpl->layout();
 }
 
@@ -460,7 +460,7 @@
         }
         c2_status_t err = mAllocation->map(
                 rect,
-                { C2MemoryUsage::kSoftwareRead, 0 },
+                { C2MemoryUsage::CPU_READ, 0 },
                 nullptr,
                 &mLayout,
                 mData);
@@ -480,12 +480,12 @@
         return mData[0] == nullptr ? nullptr : &mData[0];
     }
 
-    const C2PlaneLayout &layout() const { return mLayout; }
+    const C2PlanarLayout &layout() const { return mLayout; }
 
 private:
     std::shared_ptr<C2GraphicAllocation> mAllocation;
-    C2PlaneLayout mLayout;
-    uint8_t *mData[C2PlaneLayout::MAX_NUM_PLANES];
+    C2PlanarLayout mLayout;
+    uint8_t *mData[C2PlanarLayout::MAX_NUM_PLANES];
 };
 
 C2ConstGraphicBlock::C2ConstGraphicBlock(
@@ -523,10 +523,10 @@
             // Already mapped.
             return C2_OK;
         }
-        uint8_t *data[C2PlaneLayout::MAX_NUM_PLANES];
+        uint8_t *data[C2PlanarLayout::MAX_NUM_PLANES];
         c2_status_t err = mAllocation->map(
                 rect,
-                { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+                { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
                 nullptr,
                 &mLayout,
                 data);
@@ -548,12 +548,12 @@
         return mData[0] == nullptr ? nullptr : mData;
     }
 
-    const C2PlaneLayout &layout() const { return mLayout; }
+    const C2PlanarLayout &layout() const { return mLayout; }
 
 private:
     std::shared_ptr<C2GraphicAllocation> mAllocation;
-    C2PlaneLayout mLayout;
-    uint8_t *mData[C2PlaneLayout::MAX_NUM_PLANES];
+    C2PlanarLayout mLayout;
+    uint8_t *mData[C2PlanarLayout::MAX_NUM_PLANES];
 };
 
 C2GraphicBlock::C2GraphicBlock(const std::shared_ptr<C2GraphicAllocation> &alloc)
@@ -708,7 +708,7 @@
 private:
     C2Buffer * const mThis;
     C2DefaultBufferData mData;
-    std::map<uint32_t, std::shared_ptr<C2Info>> mInfos;
+    std::map<C2Param::Type, std::shared_ptr<C2Info>> mInfos;
     std::list<std::pair<OnDestroyNotify, void *>> mNotify;
 };
 
diff --git a/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h b/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
index 5ce6071..81c5495 100644
--- a/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
+++ b/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
@@ -278,9 +278,9 @@
 C2_HIDE
 void addC2Params(std::list<const C2FieldDescriptor> &fields, _C2Tuple<T, Params...> *)
 {
-    //C2Param::index_t index = T::coreIndex;
+    //C2Param::CodeIndex index = T::CORE_INDEX;
     //(void)index;
-    fields.insert(fields.end(), T::fieldList);
+    fields.insert(fields.end(), T::FIELD_LIST);
     addC2Params(fields, (_C2Tuple<Params...> *)nullptr);
 }
 
diff --git a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
index ac8e1de..01d120e 100644
--- a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
+++ b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
@@ -73,11 +73,6 @@
 
 using SupportedValuesWithFields = C2SoftAvcDecIntf::SupportedValuesWithFields;
 
-uint32_t restoreIndex(const C2Param *param) {
-    return (param->forStream() ? (0x02000000 | ((param->stream() << 17) & 0x01FE0000)) : 0)
-            | param->type();
-}
-
 struct ValidateParam {
     explicit ValidateParam(
             const std::map<C2ParamField, SupportedValuesWithFields> &supportedValues)
@@ -156,9 +151,9 @@
 
     std::unique_ptr<C2SettingResult> operator() (C2Param *c2param) {
         T* param = (T*)c2param;
-        C2ParamField field(param, &T::mValue);
+        C2ParamField field(param, &T::value);
         const C2FieldSupportedValues &supportedValues = mSupportedValues.at(field).supported;
-        if (!validateField(supportedValues, param->mValue)) {
+        if (!validateField(supportedValues, param->value)) {
             return std::unique_ptr<C2SettingResult>(
                     new C2SettingResult {C2SettingResult::BAD_VALUE, {field, nullptr}, {}});
         }
@@ -174,15 +169,15 @@
 
     std::unique_ptr<C2SettingResult> operator() (C2Param *c2param) {
         T* param = (T*)c2param;
-        C2ParamField field(param, &T::mWidth);
+        C2ParamField field(param, &T::width);
         const C2FieldSupportedValues &supportedWidth = mSupportedValues.at(field).supported;
-        if (!validateField(supportedWidth, param->mWidth)) {
+        if (!validateField(supportedWidth, param->width)) {
             return std::unique_ptr<C2SettingResult>(
                     new C2SettingResult {C2SettingResult::BAD_VALUE, {field, nullptr}, {}});
         }
-        field = C2ParamField(param, &T::mHeight);
+        field = C2ParamField(param, &T::height);
         const C2FieldSupportedValues &supportedHeight = mSupportedValues.at(field).supported;
-        if (!validateField(supportedHeight, param->mHeight)) {
+        if (!validateField(supportedHeight, param->height)) {
             return std::unique_ptr<C2SettingResult>(
                     new C2SettingResult {C2SettingResult::BAD_VALUE, {field, nullptr}, {}});
         }
@@ -196,7 +191,7 @@
 
     std::unique_ptr<C2SettingResult> operator() (C2Param *c2param) {
         T* param = (T*)c2param;
-        if (strncmp(param->m.mValue, mExpected, param->flexCount()) != 0) {
+        if (strncmp(param->m.value, mExpected, param->flexCount()) != 0) {
             return std::unique_ptr<C2SettingResult>(
                     new C2SettingResult {C2SettingResult::BAD_VALUE, {C2ParamField(param, &T::m), nullptr}, {}});
         }
@@ -216,13 +211,13 @@
 }  // namespace
 
 #define CASE(member) \
-    case decltype(component->member)::coreIndex: \
+    case decltype(component->member)::CORE_INDEX: \
         return std::unique_ptr<C2StructDescriptor>(new C2StructDescriptor( \
                 static_cast<decltype(component->member) *>(nullptr)))
 
 class C2SoftAvcDecIntf::ParamReflector : public C2ParamReflector {
 public:
-    virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::BaseIndex coreIndex) override {
+    virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex coreIndex) override {
         constexpr C2SoftAvcDecIntf *component = nullptr;
         switch (coreIndex.coreIndex()) {
         CASE(mDomainInfo);
@@ -233,7 +228,7 @@
         CASE(mMaxVideoSizeHint);
 
         // port mime configs are stored as unique_ptr.
-        case C2PortMimeConfig::coreIndex:
+        case C2PortMimeConfig::CORE_INDEX:
             return std::unique_ptr<C2StructDescriptor>(new C2StructDescriptor(
                     static_cast<C2PortMimeConfig *>(nullptr)));
         }
@@ -264,104 +259,104 @@
       mParamReflector(new ParamReflector) {
     ALOGV("in %s", __func__);
     mInputPortMime = C2PortMimeConfig::input::alloc_unique(strlen(CODEC_MIME_TYPE) + 1);
-    strcpy(mInputPortMime->m.mValue, CODEC_MIME_TYPE);
+    strcpy(mInputPortMime->m.value, CODEC_MIME_TYPE);
     mOutputPortMime = C2PortMimeConfig::output::alloc_unique(strlen(MEDIA_MIMETYPE_VIDEO_RAW) + 1);
-    strcpy(mOutputPortMime->m.mValue, MEDIA_MIMETYPE_VIDEO_RAW);
+    strcpy(mOutputPortMime->m.value, MEDIA_MIMETYPE_VIDEO_RAW);
 
-    mVideoSize.mWidth = 320;
-    mVideoSize.mHeight = 240;
-    mBlockSize.mWidth = 16;
-    mBlockSize.mHeight = 16;
-    mAlignment.mWidth = 2;
-    mAlignment.mHeight = 2;
+    mVideoSize.width = 320;
+    mVideoSize.height = 240;
+    mBlockSize.width = 16;
+    mBlockSize.height = 16;
+    mAlignment.width = 2;
+    mAlignment.height = 2;
 
-    mMaxVideoSizeHint.mWidth = H264_MAX_FRAME_WIDTH;
-    mMaxVideoSizeHint.mHeight = H264_MAX_FRAME_HEIGHT;
+    mMaxVideoSizeHint.width = H264_MAX_FRAME_WIDTH;
+    mMaxVideoSizeHint.height = H264_MAX_FRAME_HEIGHT;
 
     mOutputBlockPools = C2PortBlockPoolsTuning::output::alloc_unique({});
 
     auto insertParam = [&params = mParams] (C2Param *param) {
-        params[restoreIndex(param)] = param;
+        params[param->index()] = param;
     };
 
     auto markReadOnly = [&supported = mSupportedValues] (auto *param) {
         supported.emplace(
-                C2ParamField(param, &std::remove_pointer<decltype(param)>::type::mValue),
+                C2ParamField(param, &std::remove_pointer<decltype(param)>::type::value),
                 C2FieldSupportedValues(false /* flags */, {}));
     };
 
     auto markReadOnlyVideoSize = [&supported = mSupportedValues] (auto *param) {
         supported.emplace(
-                C2ParamField(param, &std::remove_pointer<decltype(param)>::type::mWidth),
+                C2ParamField(param, &std::remove_pointer<decltype(param)>::type::width),
                 C2FieldSupportedValues(false /* flags */, {}));
         supported.emplace(
-                C2ParamField(param, &std::remove_pointer<decltype(param)>::type::mHeight),
+                C2ParamField(param, &std::remove_pointer<decltype(param)>::type::height),
                 C2FieldSupportedValues(false /* flags */, {}));
     };
 
     insertParam(&mDomainInfo);
     markReadOnly(&mDomainInfo);
-    mFieldVerifiers[restoreIndex(&mDomainInfo)] =
+    mFieldVerifiers[mDomainInfo.index()] =
             ValidateSimpleParam<decltype(mDomainInfo)>(mSupportedValues);
 
     insertParam(mInputPortMime.get());
-    mFieldVerifiers[restoreIndex(mInputPortMime.get())] =
+    mFieldVerifiers[mInputPortMime->index()] =
             ValidateCString<std::remove_reference<decltype(*mInputPortMime)>::type>(CODEC_MIME_TYPE);
 
     insertParam(&mInputStreamCount);
     markReadOnly(&mInputStreamCount);
-    mFieldVerifiers[restoreIndex(&mInputStreamCount)] =
+    mFieldVerifiers[mInputStreamCount.index()] =
             ValidateSimpleParam<decltype(mInputStreamCount)>(mSupportedValues);
 
     insertParam(mOutputPortMime.get());
-    mFieldVerifiers[restoreIndex(mOutputPortMime.get())] =
+    mFieldVerifiers[mOutputPortMime->index()] =
             ValidateCString<std::remove_reference<decltype(*mOutputPortMime)>::type>(MEDIA_MIMETYPE_VIDEO_RAW);
 
     insertParam(&mOutputStreamCount);
     markReadOnly(&mOutputStreamCount);
-    mFieldVerifiers[restoreIndex(&mOutputStreamCount)] =
+    mFieldVerifiers[mOutputStreamCount.index()] =
             ValidateSimpleParam<decltype(mOutputStreamCount)>(mSupportedValues);
 
     insertParam(&mInputStreamFormat);
     markReadOnly(&mInputStreamFormat);
-    mFieldVerifiers[restoreIndex(&mInputStreamFormat)] =
+    mFieldVerifiers[mInputStreamFormat.index()] =
             ValidateSimpleParam<decltype(mInputStreamFormat)>(mSupportedValues);
 
     insertParam(&mOutputStreamFormat);
     markReadOnly(&mOutputStreamFormat);
-    mFieldVerifiers[restoreIndex(&mOutputStreamFormat)] =
+    mFieldVerifiers[mOutputStreamFormat.index()] =
             ValidateSimpleParam<decltype(mOutputStreamFormat)>(mSupportedValues);
 
     insertParam(&mVideoSize);
     markReadOnlyVideoSize(&mVideoSize);
-    mFieldVerifiers[restoreIndex(&mVideoSize)] =
+    mFieldVerifiers[mVideoSize.index()] =
             ValidateVideoSize<decltype(mVideoSize)>(mSupportedValues);
 
     insertParam(&mMaxVideoSizeHint);
     mSupportedValues.emplace(
-            C2ParamField(&mMaxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mWidth),
-            C2FieldSupportedValues(H264_MIN_FRAME_WIDTH, H264_MAX_FRAME_WIDTH, mAlignment.mWidth));
+            C2ParamField(&mMaxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::width),
+            C2FieldSupportedValues(H264_MIN_FRAME_WIDTH, H264_MAX_FRAME_WIDTH, mAlignment.width));
     mSupportedValues.emplace(
-            C2ParamField(&mMaxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mHeight),
-            C2FieldSupportedValues(H264_MIN_FRAME_HEIGHT, H264_MAX_FRAME_HEIGHT, mAlignment.mHeight));
-    mFieldVerifiers[restoreIndex(&mMaxVideoSizeHint)] =
+            C2ParamField(&mMaxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::height),
+            C2FieldSupportedValues(H264_MIN_FRAME_HEIGHT, H264_MAX_FRAME_HEIGHT, mAlignment.height));
+    mFieldVerifiers[mMaxVideoSizeHint.index()] =
             ValidateVideoSize<decltype(mMaxVideoSizeHint)>(mSupportedValues);
 
     insertParam(&mProfile);
     mSupportedValues.emplace(
-            C2ParamField(&mProfile, &C2AvcProfileInfo::mValue),
+            C2ParamField(&mProfile, &C2AvcProfileInfo::value),
             C2FieldSupportedValues(false /* flags */, {
                 kAvcProfileUnknown,
                 kAvcProfileBaseline,
                 kAvcProfileMain,
                 kAvcProfileHigh,
             }));
-    mFieldVerifiers[restoreIndex(&mProfile)] =
+    mFieldVerifiers[mProfile.index()] =
             ValidateSimpleParam<decltype(mProfile)>(mSupportedValues);
 
     insertParam(&mLevel);
     mSupportedValues.emplace(
-            C2ParamField(&mLevel, &C2AvcLevelInfo::mValue),
+            C2ParamField(&mLevel, &C2AvcLevelInfo::value),
             C2FieldSupportedValues(false /* flags */, {
                 kAvcLevelUnknown,
                 kAvcLevel10,
@@ -382,31 +377,31 @@
                 kAvcLevel51,
                 kAvcLevel52,
             }));
-    mFieldVerifiers[restoreIndex(&mLevel)] =
+    mFieldVerifiers[mLevel.index()] =
             ValidateSimpleParam<decltype(mLevel)>(mSupportedValues);
 
     insertParam(&mBlockSize);
     markReadOnlyVideoSize(&mBlockSize);
-    mFieldVerifiers[restoreIndex(&mBlockSize)] =
+    mFieldVerifiers[mBlockSize.index()] =
             ValidateVideoSize<decltype(mBlockSize)>(mSupportedValues);
 
     insertParam(&mAlignment);
     markReadOnlyVideoSize(&mAlignment);
-    mFieldVerifiers[restoreIndex(&mAlignment)] =
+    mFieldVerifiers[mAlignment.index()] =
             ValidateVideoSize<decltype(mAlignment)>(mSupportedValues);
 
     insertParam(&mFrameRate);
     mSupportedValues.emplace(
-            C2ParamField(&mFrameRate, &C2FrameRateInfo::mValue),
+            C2ParamField(&mFrameRate, &C2FrameRateInfo::value),
             C2FieldSupportedValues(0, 240));
-    mFieldVerifiers[restoreIndex(&mFrameRate)] =
+    mFieldVerifiers[mFrameRate.index()] =
             ValidateSimpleParam<decltype(mFrameRate)>(mSupportedValues);
 
     insertParam(&mBlocksPerSecond);
     mSupportedValues.emplace(
-            C2ParamField(&mFrameRate, &C2BlocksPerSecondInfo::mValue),
+            C2ParamField(&mFrameRate, &C2BlocksPerSecondInfo::value),
             C2FieldSupportedValues(0, 244800));
-    mFieldVerifiers[restoreIndex(&mBlocksPerSecond)] =
+    mFieldVerifiers[mBlocksPerSecond.index()] =
             ValidateSimpleParam<decltype(mBlocksPerSecond)>(mSupportedValues);
 
     mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
@@ -454,7 +449,7 @@
             continue;
         }
 
-        uint32_t index = restoreIndex(param);
+        uint32_t index = param->index();
         if (!mParams.count(index)) {
             // TODO: add support for output-block-pools (this will be done when we move all
             // config to shared ptr)
@@ -487,7 +482,7 @@
     (void)mayBlock;
     c2_status_t err = C2_OK;
     for (C2Param *param : params) {
-        uint32_t index = restoreIndex(param);
+        uint32_t index = param->index();
         if (param->index() == mOutputBlockPools.get()->index()) {
             // setting output block pools
             mOutputBlockPools.reset(
@@ -557,7 +552,7 @@
     // cf: Rec. ITU-T H.264 A.3
     int maxFrameRate = 172;
     std::vector<C2ParamField> fields;
-    if (mLevel.mValue != kAvcLevelUnknown) {
+    if (mLevel.value != kAvcLevelUnknown) {
         // cf: Rec. ITU-T H.264 Table A-1
         constexpr int MaxFS[] = {
         //  0       1       2       3       4       5       6       7       8       9
@@ -579,27 +574,27 @@
         };
 
         // cf: Rec. ITU-T H.264 A.3.1
-        maxWidth = std::min(maxWidth, floor32(std::sqrt(MaxFS[mLevel.mValue] * 8)) * MB_SIZE);
-        maxHeight = std::min(maxHeight, floor32(std::sqrt(MaxFS[mLevel.mValue] * 8)) * MB_SIZE);
-        int32_t MBs = ((mVideoSize.mWidth + 15) / 16) * ((mVideoSize.mHeight + 15) / 16);
-        maxFrameRate = std::min(maxFrameRate, MaxMBPS[mLevel.mValue] / MBs);
-        fields.push_back(C2ParamField(&mLevel, &C2AvcLevelInfo::mValue));
+        maxWidth = std::min(maxWidth, floor32(std::sqrt(MaxFS[mLevel.value] * 8)) * MB_SIZE);
+        maxHeight = std::min(maxHeight, floor32(std::sqrt(MaxFS[mLevel.value] * 8)) * MB_SIZE);
+        int32_t MBs = ((mVideoSize.width + 15) / 16) * ((mVideoSize.height + 15) / 16);
+        maxFrameRate = std::min(maxFrameRate, MaxMBPS[mLevel.value] / MBs);
+        fields.push_back(C2ParamField(&mLevel, &C2AvcLevelInfo::value));
     }
 
     SupportedValuesWithFields &maxWidthVals = mSupportedValues.at(
-            C2ParamField(&mMaxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mWidth));
+            C2ParamField(&mMaxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::width));
     maxWidthVals.supported.range.max = maxWidth;
     maxWidthVals.restrictingFields.clear();
     maxWidthVals.restrictingFields.insert(fields.begin(), fields.end());
 
     SupportedValuesWithFields &maxHeightVals = mSupportedValues.at(
-            C2ParamField(&mMaxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mHeight));
+            C2ParamField(&mMaxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::height));
     maxHeightVals.supported.range.max = maxHeight;
     maxHeightVals.restrictingFields.clear();
     maxHeightVals.restrictingFields.insert(fields.begin(), fields.end());
 
     SupportedValuesWithFields &frameRate = mSupportedValues.at(
-            C2ParamField(&mFrameRate, &C2FrameRateInfo::mValue));
+            C2ParamField(&mFrameRate, &C2FrameRateInfo::value));
     frameRate.supported.range.max = maxFrameRate;
     frameRate.restrictingFields.clear();
     frameRate.restrictingFields.insert(fields.begin(), fields.end());
@@ -1043,8 +1038,7 @@
         work->worklets.front()->output.ordinal = work->input.ordinal;
     };
     if (buffer.capacity() == 0) {
-        ALOGV("empty input: %" PRIu64, work->input.ordinal.frame_index);
-
+        ALOGV("empty input: %llu", (long long)work->input.ordinal.frame_index);
         // TODO: result?
         fillEmptyWork(work);
         if ((work->input.flags & C2BufferPack::FLAG_END_OF_STREAM)) {
@@ -1052,7 +1046,7 @@
         }
         done = true;
     } else if (work->input.flags & C2BufferPack::FLAG_END_OF_STREAM) {
-        ALOGV("input EOS: %" PRIu64, work->input.ordinal.frame_index);
+        ALOGV("input EOS: %llu", (long long)work->input.ordinal.frame_index);
         eos = true;
     }
 
@@ -1088,7 +1082,7 @@
             // TODO: error handling
             // TODO: format & usage
             uint32_t format = HAL_PIXEL_FORMAT_YV12;
-            C2MemoryUsage usage = { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite };
+            C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE };
             ALOGV("using allocator %u", pool->getAllocatorId());
 
             (void)pool->fetchGraphicBlock(
diff --git a/media/libstagefright/codecs/cmds/codec2.cpp b/media/libstagefright/codecs/cmds/codec2.cpp
index ad58871..5a225f1 100644
--- a/media/libstagefright/codecs/cmds/codec2.cpp
+++ b/media/libstagefright/codecs/cmds/codec2.cpp
@@ -337,7 +337,7 @@
         std::shared_ptr<C2LinearBlock> block;
         mLinearPool->fetchLinearBlock(
                 size,
-                { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
+                { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE },
                 &block);
         C2WriteView view = block->map().get();
         if (view.error() != C2_OK) {
diff --git a/media/libstagefright/codecs/on2/enc/SoftVP9Encoder.cpp b/media/libstagefright/codecs/on2/enc/SoftVP9Encoder.cpp
index 4c7290d..1ea1c85 100644
--- a/media/libstagefright/codecs/on2/enc/SoftVP9Encoder.cpp
+++ b/media/libstagefright/codecs/on2/enc/SoftVP9Encoder.cpp
@@ -69,6 +69,13 @@
               codecReturn);
         return codecReturn;
     }
+    codecReturn = vpx_codec_control(mCodecContext, VP9E_SET_ROW_MT, 1);
+    if (codecReturn != VPX_CODEC_OK) {
+        ALOGE("Error setting VP9E_SET_ROW_MT to 1. vpx_codec_control() "
+              "returned %d", codecReturn);
+        return codecReturn;
+    }
+
     // For VP9, we always set CPU_USED to 8 (because the realtime default is 0
     // which is too slow).
     codecReturn = vpx_codec_control(mCodecContext, VP8E_SET_CPUUSED, 8);
diff --git a/media/libstagefright/codecs/tests/C2SoftAvcDec_test.cpp b/media/libstagefright/codecs/tests/C2SoftAvcDec_test.cpp
index 78e82b3..ca26a1d 100644
--- a/media/libstagefright/codecs/tests/C2SoftAvcDec_test.cpp
+++ b/media/libstagefright/codecs/tests/C2SoftAvcDec_test.cpp
@@ -31,7 +31,7 @@
 template <class T>
 std::unique_ptr<T> alloc_unique_cstr(const char *cstr) {
     std::unique_ptr<T> ptr = T::alloc_unique(strlen(cstr) + 1);
-    strcpy(ptr->m.mValue, cstr);
+    strcpy(ptr->m.value, cstr);
     return ptr;
 }
 
@@ -85,10 +85,7 @@
 void C2SoftAvcDecTest::testReadOnlyParamOnHeap(const T *expected, const T *invalid) {
     std::vector<std::unique_ptr<C2Param>> heapParams;
 
-    uint32_t index = expected->type();
-    if (expected->forStream()) {
-        index |= ((expected->stream() << 17) & 0x01FE0000) | 0x02000000;
-    }
+    uint32_t index = expected->index();
 
     ASSERT_EQ(C2_OK, mIntf->query_vb({}, {index}, C2_DONT_BLOCK, &heapParams));
     ASSERT_EQ(1u, heapParams.size());
@@ -110,10 +107,7 @@
         const std::unique_ptr<T> &expected, const std::unique_ptr<T> &invalid) {
     std::vector<std::unique_ptr<C2Param>> heapParams;
 
-    uint32_t index = expected->type();
-    if (expected->forStream()) {
-        index |= ((expected->stream() << 17) & 0x01FE0000) | 0x02000000;
-    }
+    uint32_t index = expected->index();
 
     ASSERT_EQ(C2_OK, mIntf->query_vb({}, {index}, C2_DONT_BLOCK, &heapParams));
     ASSERT_EQ(1u, heapParams.size());
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 1e2e684..7eff8eb 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -1014,7 +1014,8 @@
         mFetcherLooper = new ALooper();
 
         mFetcherLooper->setName("Fetcher");
-        mFetcherLooper->start(false, false);
+        mFetcherLooper->start(false, /* runOnCallingThread */
+                              true  /* canCallJava */);
     }
 
     // create fetcher to fetch the master playlist
diff --git a/media/libstagefright/include/media/stagefright/RemoteMediaExtractor.h b/media/libstagefright/include/media/stagefright/RemoteMediaExtractor.h
index b5a4b34..98b8b4d 100644
--- a/media/libstagefright/include/media/stagefright/RemoteMediaExtractor.h
+++ b/media/libstagefright/include/media/stagefright/RemoteMediaExtractor.h
@@ -22,6 +22,8 @@
 
 namespace android {
 
+class MediaAnalyticsItem;
+
 // IMediaExtractor wrapper to the MediaExtractor.
 class RemoteMediaExtractor : public BnMediaExtractor {
 public:
@@ -43,6 +45,8 @@
 private:
     sp<MediaExtractor> mExtractor;
 
+    MediaAnalyticsItem *mAnalyticsItem;
+
     explicit RemoteMediaExtractor(const sp<MediaExtractor> &extractor);
 
     DISALLOW_EVIL_CONSTRUCTORS(RemoteMediaExtractor);
diff --git a/media/libstagefright/omx/1.0/WOmxNode.cpp b/media/libstagefright/omx/1.0/WOmxNode.cpp
index 9f82283..1dc7c7b 100644
--- a/media/libstagefright/omx/1.0/WOmxNode.cpp
+++ b/media/libstagefright/omx/1.0/WOmxNode.cpp
@@ -154,7 +154,8 @@
                     hidl_handle const& outNativeHandle) {
                 fnStatus = toStatusT(status);
                 *buffer = outBuffer;
-                *native_handle = NativeHandle::create(
+                *native_handle = outNativeHandle.getNativeHandle() == nullptr ?
+                        nullptr : NativeHandle::create(
                         native_handle_clone(outNativeHandle), true);
             }));
     return transStatus == NO_ERROR ? fnStatus : transStatus;
diff --git a/media/libstagefright/omx/include/media/stagefright/omx/1.0/Conversion.h b/media/libstagefright/omx/include/media/stagefright/omx/1.0/Conversion.h
index 8d8a2d9..a79d403 100644
--- a/media/libstagefright/omx/include/media/stagefright/omx/1.0/Conversion.h
+++ b/media/libstagefright/omx/include/media/stagefright/omx/1.0/Conversion.h
@@ -1862,7 +1862,8 @@
 inline size_t getFlattenedSize(HGraphicBufferProducer::QueueBufferInput const& t) {
     return minFlattenedSize(t) +
             getFenceFlattenedSize(t.fence) +
-            getFlattenedSize(t.surfaceDamage);
+            getFlattenedSize(t.surfaceDamage) +
+            sizeof(HdrMetadata::validTypes);
 }
 
 /**
@@ -1916,7 +1917,12 @@
     if (status != NO_ERROR) {
         return status;
     }
-    return flatten(t.surfaceDamage, buffer, size);
+    status = flatten(t.surfaceDamage, buffer, size);
+    if (status != NO_ERROR) {
+        return status;
+    }
+    FlattenableUtils::write(buffer, size, decltype(HdrMetadata::validTypes)(0));
+    return NO_ERROR;
 }
 
 /**
@@ -1968,6 +1974,7 @@
     if (status != NO_ERROR) {
         return status;
     }
+    // HdrMetadata ignored
     return unflatten(&(t->surfaceDamage), buffer, size);
 }
 
diff --git a/packages/MediaUpdate/Android.mk b/packages/MediaUpdate/Android.mk
index e757098..4a71401 100644
--- a/packages/MediaUpdate/Android.mk
+++ b/packages/MediaUpdate/Android.mk
@@ -25,4 +25,10 @@
 # TODO: create a separate key for this package.
 LOCAL_CERTIFICATE := platform
 
+# TODO: Use System SDK once public APIs are approved
+# LOCAL_SDK_VERSION := system_current
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
+
 include $(BUILD_PACKAGE)
diff --git a/packages/MediaUpdate/proguard.cfg b/packages/MediaUpdate/proguard.cfg
new file mode 100644
index 0000000..874dbf5
--- /dev/null
+++ b/packages/MediaUpdate/proguard.cfg
@@ -0,0 +1,20 @@
+#
+# Copyright 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Keep entry point for updatable Java classes
+-keep public class com.android.media.update.ApiFactory {
+   public static java.lang.Object initialize(android.content.Context);
+}
diff --git a/packages/MediaUpdate/src/com/android/media/update/ApiFactory.java b/packages/MediaUpdate/src/com/android/media/update/ApiFactory.java
new file mode 100644
index 0000000..1cdd177
--- /dev/null
+++ b/packages/MediaUpdate/src/com/android/media/update/ApiFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.media.update;
+
+import android.content.Context;
+import android.media.update.MediaController2Provider;
+import android.media.update.StaticProvider;
+import android.media.update.ViewProvider;
+import android.widget.MediaController2;
+
+import com.android.widget.MediaController2Impl;
+
+public class ApiFactory implements StaticProvider {
+    private final Context mContext;
+
+    public ApiFactory(Context context) {
+        mContext = context;
+    }
+
+    public static Object initialize(Context context) throws ReflectiveOperationException {
+        return new ApiFactory(context);
+    }
+
+    @Override
+    public MediaController2Provider createMediaController2(
+            MediaController2 instance, ViewProvider superProvider) {
+        return new MediaController2Impl(instance, superProvider);
+    }
+}
diff --git a/packages/MediaUpdate/src/com/android/widget/MediaController2Impl.java b/packages/MediaUpdate/src/com/android/widget/MediaController2Impl.java
new file mode 100644
index 0000000..d322a20
--- /dev/null
+++ b/packages/MediaUpdate/src/com/android/widget/MediaController2Impl.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.widget;
+
+import android.graphics.Canvas;
+import android.media.session.MediaController;
+import android.media.update.MediaController2Provider;
+import android.media.update.ViewProvider;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.MediaController2;
+
+public class MediaController2Impl implements MediaController2Provider {
+    private final MediaController2 mInstance;
+    private final ViewProvider mSuperProvider;
+
+    public MediaController2Impl(MediaController2 instance, ViewProvider superProvider) {
+        mInstance = instance;
+        mSuperProvider = superProvider;
+
+        // TODO: Implement
+    }
+
+    @Override
+    public void setController_impl(MediaController controller) {
+        // TODO: Implement
+    }
+
+    @Override
+    public void setAnchorView_impl(View view) {
+        // TODO: Implement
+    }
+
+    @Override
+    public void show_impl() {
+        // TODO: Implement
+    }
+
+    @Override
+    public void show_impl(int timeout) {
+        // TODO: Implement
+    }
+
+    @Override
+    public boolean isShowing_impl() {
+        // TODO: Implement
+        return false;
+    }
+
+    @Override
+    public void hide_impl() {
+        // TODO: Implement
+    }
+
+    @Override
+    public void setPrevNextListeners_impl(OnClickListener next, OnClickListener prev) {
+        // TODO: Implement
+    }
+
+    @Override
+    public void showCCButton_impl() {
+        // TODO: Implement
+    }
+
+    @Override
+    public boolean isPlaying_impl() {
+        // TODO: Implement
+        return false;
+    }
+
+    @Override
+    public int getCurrentPosition_impl() {
+        // TODO: Implement
+        return 0;
+    }
+
+    @Override
+    public int getBufferPercentage_impl() {
+        // TODO: Implement
+        return 0;
+    }
+
+    @Override
+    public boolean canPause_impl() {
+        // TODO: Implement
+        return false;
+    }
+
+    @Override
+    public boolean canSeekBackward_impl() {
+        // TODO: Implement
+        return false;
+    }
+
+    @Override
+    public boolean canSeekForward_impl() {
+        // TODO: Implement
+        return false;
+    }
+
+    @Override
+    public void showSubtitle_impl() {
+        // TODO: Implement
+    }
+
+    @Override
+    public void hideSubtitle_impl() {
+        // TODO: Implement
+    }
+
+    @Override
+    public void onAttachedToWindow_impl() {
+        mSuperProvider.onAttachedToWindow_impl();
+        // TODO: Implement
+    }
+
+    @Override
+    public void onDetachedFromWindow_impl() {
+        mSuperProvider.onDetachedFromWindow_impl();
+        // TODO: Implement
+    }
+
+    @Override
+    public void onLayout_impl(boolean changed, int left, int top, int right, int bottom) {
+        mSuperProvider.onLayout_impl(changed, left, top, right, bottom);
+        // TODO: Implement
+    }
+
+    @Override
+    public void draw_impl(Canvas canvas) {
+        mSuperProvider.draw_impl(canvas);
+        // TODO: Implement
+    }
+
+    @Override
+    public CharSequence getAccessibilityClassName_impl() {
+        // TODO: Implement
+        return MediaController2.class.getName();
+    }
+
+    @Override
+    public boolean onTouchEvent_impl(MotionEvent ev) {
+        // TODO: Implement
+        return mSuperProvider.onTouchEvent_impl(ev);
+    }
+
+    @Override
+    public boolean onTrackballEvent_impl(MotionEvent ev) {
+        // TODO: Implement
+        return mSuperProvider.onTrackballEvent_impl(ev);
+    }
+
+    @Override
+    public boolean onKeyDown_impl(int keyCode, KeyEvent event) {
+        // TODO: Implement
+        return mSuperProvider.onKeyDown_impl(keyCode, event);
+    }
+
+    @Override
+    public void onFinishInflate_impl() {
+        mSuperProvider.onFinishInflate_impl();
+        // TODO: Implement
+    }
+
+    @Override
+    public boolean dispatchKeyEvent_impl(KeyEvent event) {
+        // TODO: Implement
+        return mSuperProvider.dispatchKeyEvent_impl(event);
+    }
+
+    @Override
+    public void setEnabled_impl(boolean enabled) {
+        mSuperProvider.setEnabled_impl(enabled);
+        // TODO: Implement
+    }
+}
diff --git a/services/audioflinger/FastThread.cpp b/services/audioflinger/FastThread.cpp
index 85865b7..dc15487 100644
--- a/services/audioflinger/FastThread.cpp
+++ b/services/audioflinger/FastThread.cpp
@@ -297,7 +297,8 @@
                     size_t i = mBounds & (mDumpState->mSamplingN - 1);
                     mBounds = (mBounds & 0xFFFF0000) | ((mBounds + 1) & 0xFFFF);
                     if (mFull) {
-                        mBounds += 0x10000;
+                        //mBounds += 0x10000;
+                        __builtin_add_overflow(mBounds, 0x10000, &mBounds);
                     } else if (!(mBounds & (mDumpState->mSamplingN - 1))) {
                         mFull = true;
                     }
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index ae3bbc1..2ff200d 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -643,6 +643,14 @@
             dprintf(fd, "  API2 camera characteristics:\n");
             info2.dump(fd, /*verbosity*/ 2, /*indentation*/ 4);
         }
+
+        dprintf(fd, "== Camera HAL device %s (v%d.%d) dumpState: ==\n", device->mName.c_str(),
+                device->mVersion.get_major(), device->mVersion.get_minor());
+        res = device->dumpState(fd);
+        if (res != OK) {
+            dprintf(fd, "   <Error dumping device %s state: %s (%d)>\n",
+                    device->mName.c_str(), strerror(-res), res);
+        }
     }
     return OK;
 }
@@ -908,6 +916,17 @@
     return OK;
 }
 
+status_t CameraProviderManager::ProviderInfo::DeviceInfo1::dumpState(int fd) const {
+    native_handle_t* handle = native_handle_create(1,0);
+    handle->data[0] = fd;
+    hardware::Return<Status> s = mInterface->dumpState(handle);
+    native_handle_delete(handle);
+    if (!s.isOk()) {
+        return INVALID_OPERATION;
+    }
+    return mapToStatusT(s);
+}
+
 CameraProviderManager::ProviderInfo::DeviceInfo3::DeviceInfo3(const std::string& name,
         const metadata_vendor_id_t tagId, const std::string &id,
         uint16_t minorVersion,
@@ -1011,6 +1030,17 @@
     return isBackwardCompatible;
 }
 
+status_t CameraProviderManager::ProviderInfo::DeviceInfo3::dumpState(int fd) const {
+    native_handle_t* handle = native_handle_create(1,0);
+    handle->data[0] = fd;
+    auto ret = mInterface->dumpState(handle);
+    native_handle_delete(handle);
+    if (!ret.isOk()) {
+        return INVALID_OPERATION;
+    }
+    return OK;
+}
+
 status_t CameraProviderManager::ProviderInfo::DeviceInfo3::getCameraCharacteristics(
         CameraMetadata *characteristics) const {
     if (characteristics == nullptr) return BAD_VALUE;
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.h b/services/camera/libcameraservice/common/CameraProviderManager.h
index e82282f..0f1f07b 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.h
+++ b/services/camera/libcameraservice/common/CameraProviderManager.h
@@ -293,6 +293,7 @@
             virtual status_t setTorchMode(bool enabled) = 0;
             virtual status_t getCameraInfo(hardware::CameraInfo *info) const = 0;
             virtual bool isAPI1Compatible() const = 0;
+            virtual status_t dumpState(int fd) const = 0;
             virtual status_t getCameraCharacteristics(CameraMetadata *characteristics) const {
                 (void) characteristics;
                 return INVALID_OPERATION;
@@ -326,6 +327,7 @@
             virtual status_t getCameraInfo(hardware::CameraInfo *info) const override;
             //In case of Device1Info assume that we are always API1 compatible
             virtual bool isAPI1Compatible() const override { return true; }
+            virtual status_t dumpState(int fd) const override;
             DeviceInfo1(const std::string& name, const metadata_vendor_id_t tagId,
                     const std::string &id, uint16_t minorVersion,
                     const hardware::camera::common::V1_0::CameraResourceCost& resourceCost,
@@ -343,6 +345,7 @@
             virtual status_t setTorchMode(bool enabled) override;
             virtual status_t getCameraInfo(hardware::CameraInfo *info) const override;
             virtual bool isAPI1Compatible() const override;
+            virtual status_t dumpState(int fd) const override;
             virtual status_t getCameraCharacteristics(
                     CameraMetadata *characteristics) const override;