Merge "Check the buffer index from acquireBuffer" into klp-dev am: d050902155 am: 668b7f4b8f am: 54f81e8fe7 am: 8cb7994cbf am: fa0b15cf8f am: d158da44d5 -s ours am: eb7c508001 -s ours am: 8342e031ba -s ours am: 26151c1ac2 -s ours am: e4f5cdce47 -s ours am: 8b6cd3c1c6 -s ours am: f105e6ad23 -s ours am: 57c05dd9fb -s ours am: 5e128aa3d3 -s ours
am: cf3434f441 -s ours
Change-Id: I3adaa3b3c40c887ad7c43eede7165d4328b466b2
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..b207a96
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,7 @@
+subdirs = [
+ "camera",
+ "drm/*",
+ "media/*",
+ "radio",
+ "soundtrigger",
+]
diff --git a/CleanSpec.mk b/CleanSpec.mk
index d0890fe..c8e3c09 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -59,6 +59,16 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libaudiopolicymanager.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libaudiopolicyservice_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libaudiopolicymanager_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libeffects.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/libeffects.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libeffects_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/soundfx/libeffectproxy.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/soundfx/libldnhncr.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/soundfx/libdownmix.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/soundfx/libvisualizer.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/soundfx/libreverbwrapper.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/soundfx/libbundlewrapper.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/soundfx/libaudiopreprocessing.so)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/camera/Android.bp b/camera/Android.bp
new file mode 100644
index 0000000..7ff3e89
--- /dev/null
+++ b/camera/Android.bp
@@ -0,0 +1,78 @@
+// Copyright 2010 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.
+
+subdirs = ["ndk"]
+
+cc_library_shared {
+ name: "libcamera_client",
+
+ aidl: {
+ export_aidl_headers: true,
+ local_include_dirs: ["aidl"],
+ include_dirs: [
+ "frameworks/base/core/java",
+ "frameworks/native/aidl/gui",
+ ],
+ },
+
+ srcs: [
+ // AIDL files for camera interfaces
+ // The headers for these interfaces will be available to any modules that
+ // include libcamera_client, at the path "aidl/package/path/BnFoo.h"
+ "aidl/android/hardware/ICameraService.aidl",
+ "aidl/android/hardware/ICameraServiceListener.aidl",
+ "aidl/android/hardware/camera2/ICameraDeviceCallbacks.aidl",
+ "aidl/android/hardware/camera2/ICameraDeviceUser.aidl",
+
+ // Source for camera interface parcelables, and manually-written interfaces
+ "Camera.cpp",
+ "CameraMetadata.cpp",
+ "CameraParameters.cpp",
+ "CaptureResult.cpp",
+ "CameraParameters2.cpp",
+ "ICamera.cpp",
+ "ICameraClient.cpp",
+ "ICameraServiceProxy.cpp",
+ "ICameraRecordingProxy.cpp",
+ "ICameraRecordingProxyListener.cpp",
+ "camera2/CaptureRequest.cpp",
+ "camera2/OutputConfiguration.cpp",
+ "camera2/SubmitInfo.cpp",
+ "CameraBase.cpp",
+ "CameraUtils.cpp",
+ "VendorTagDescriptor.cpp",
+ ],
+
+ shared_libs: [
+ "libcutils",
+ "libutils",
+ "liblog",
+ "libbinder",
+ "libgui",
+ "libcamera_metadata",
+ ],
+
+ include_dirs: [
+ "system/media/private/camera/include",
+ "frameworks/native/include/media/openmax",
+ ],
+ export_include_dirs: ["include/camera"],
+ export_shared_lib_headers: ["libcamera_metadata"],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ "-Wextra",
+ ],
+}
diff --git a/camera/Android.mk b/camera/Android.mk
index 1a3382f..d9068c0 100644
--- a/camera/Android.mk
+++ b/camera/Android.mk
@@ -12,69 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-CAMERA_CLIENT_LOCAL_PATH:= $(call my-dir)
include $(call all-subdir-makefiles)
-include $(CLEAR_VARS)
-
-LOCAL_PATH := $(CAMERA_CLIENT_LOCAL_PATH)
-
-LOCAL_AIDL_INCLUDES := \
- frameworks/av/camera/aidl \
- frameworks/base/core/java \
- frameworks/native/aidl/gui
-
-# AIDL files for camera interfaces
-# The headers for these interfaces will be available to any modules that
-# include libcamera_client, at the path "aidl/package/path/BnFoo.h"
-
-LOCAL_SRC_FILES := \
- aidl/android/hardware/ICameraService.aidl \
- aidl/android/hardware/ICameraServiceListener.aidl \
- aidl/android/hardware/camera2/ICameraDeviceCallbacks.aidl \
- aidl/android/hardware/camera2/ICameraDeviceUser.aidl
-
-# Source for camera interface parcelables, and manually-written interfaces
-
-LOCAL_SRC_FILES += \
- Camera.cpp \
- CameraMetadata.cpp \
- CameraParameters.cpp \
- CaptureResult.cpp \
- CameraParameters2.cpp \
- ICamera.cpp \
- ICameraClient.cpp \
- ICameraServiceProxy.cpp \
- ICameraRecordingProxy.cpp \
- ICameraRecordingProxyListener.cpp \
- camera2/CaptureRequest.cpp \
- camera2/OutputConfiguration.cpp \
- camera2/SubmitInfo.cpp \
- CameraBase.cpp \
- CameraUtils.cpp \
- VendorTagDescriptor.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- liblog \
- libbinder \
- libhardware \
- libui \
- libgui \
- libcamera_metadata \
-
-LOCAL_C_INCLUDES += \
- system/media/camera/include \
- system/media/private/camera/include \
- frameworks/native/include/media/openmax \
- frameworks/av/include/camera
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
- system/media/camera/include \
- frameworks/av/include/camera
-
-LOCAL_CFLAGS += -Werror -Wall -Wextra
-
-LOCAL_MODULE:= libcamera_client
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/camera/CameraBase.cpp b/camera/CameraBase.cpp
index 8a18d2f..2d291a8 100644
--- a/camera/CameraBase.cpp
+++ b/camera/CameraBase.cpp
@@ -138,7 +138,7 @@
c->mStatus = NO_ERROR;
} else {
ALOGW("An error occurred while connecting to camera %d: %s", cameraId,
- (cs != nullptr) ? "Service not available" : ret.toString8().string());
+ (cs == nullptr) ? "Service not available" : ret.toString8().string());
c.clear();
}
return c;
diff --git a/camera/CameraUtils.cpp b/camera/CameraUtils.cpp
index 1676be1..67fc116 100644
--- a/camera/CameraUtils.cpp
+++ b/camera/CameraUtils.cpp
@@ -45,7 +45,7 @@
}
camera_metadata_ro_entry_t entryFacing = staticInfo.find(ANDROID_LENS_FACING);
- if (entry.count == 0) {
+ if (entryFacing.count == 0) {
ALOGE("%s: Can't find android.lens.facing in static metadata!", __FUNCTION__);
return INVALID_OPERATION;
}
diff --git a/camera/ICamera.cpp b/camera/ICamera.cpp
index 0680d7c..2bf956d 100644
--- a/camera/ICamera.cpp
+++ b/camera/ICamera.cpp
@@ -60,7 +60,7 @@
class BpCamera: public BpInterface<ICamera>
{
public:
- BpCamera(const sp<IBinder>& impl)
+ explicit BpCamera(const sp<IBinder>& impl)
: BpInterface<ICamera>(impl)
{
}
diff --git a/camera/ICameraClient.cpp b/camera/ICameraClient.cpp
index 68cbfb8..1b6fac4 100644
--- a/camera/ICameraClient.cpp
+++ b/camera/ICameraClient.cpp
@@ -37,7 +37,7 @@
class BpCameraClient: public BpInterface<ICameraClient>
{
public:
- BpCameraClient(const sp<IBinder>& impl)
+ explicit BpCameraClient(const sp<IBinder>& impl)
: BpInterface<ICameraClient>(impl)
{
}
diff --git a/camera/ICameraRecordingProxy.cpp b/camera/ICameraRecordingProxy.cpp
index 63c4b1d..c9f8b5c 100644
--- a/camera/ICameraRecordingProxy.cpp
+++ b/camera/ICameraRecordingProxy.cpp
@@ -38,7 +38,7 @@
class BpCameraRecordingProxy: public BpInterface<ICameraRecordingProxy>
{
public:
- BpCameraRecordingProxy(const sp<IBinder>& impl)
+ explicit BpCameraRecordingProxy(const sp<IBinder>& impl)
: BpInterface<ICameraRecordingProxy>(impl)
{
}
diff --git a/camera/ICameraRecordingProxyListener.cpp b/camera/ICameraRecordingProxyListener.cpp
index fa4dfd8..8529d3e 100644
--- a/camera/ICameraRecordingProxyListener.cpp
+++ b/camera/ICameraRecordingProxyListener.cpp
@@ -33,7 +33,7 @@
class BpCameraRecordingProxyListener: public BpInterface<ICameraRecordingProxyListener>
{
public:
- BpCameraRecordingProxyListener(const sp<IBinder>& impl)
+ explicit BpCameraRecordingProxyListener(const sp<IBinder>& impl)
: BpInterface<ICameraRecordingProxyListener>(impl)
{
}
diff --git a/camera/ICameraServiceProxy.cpp b/camera/ICameraServiceProxy.cpp
index 694e9c3..a9d0836 100644
--- a/camera/ICameraServiceProxy.cpp
+++ b/camera/ICameraServiceProxy.cpp
@@ -26,7 +26,8 @@
class BpCameraServiceProxy: public BpInterface<ICameraServiceProxy> {
public:
- BpCameraServiceProxy(const sp<IBinder>& impl) : BpInterface<ICameraServiceProxy>(impl) {}
+ explicit BpCameraServiceProxy(const sp<IBinder>& impl)
+ : BpInterface<ICameraServiceProxy>(impl) {}
virtual void pingForUserUpdate() {
Parcel data;
diff --git a/camera/VendorTagDescriptor.cpp b/camera/VendorTagDescriptor.cpp
index 02ece14..f3b3dbb 100644
--- a/camera/VendorTagDescriptor.cpp
+++ b/camera/VendorTagDescriptor.cpp
@@ -192,7 +192,7 @@
// Set up reverse mapping
for (size_t i = 0; i < static_cast<size_t>(tagCount); ++i) {
uint32_t tag = allTags[i];
- String8 sectionString = mSections[mTagToSectionMap.valueFor(tag)];
+ const String8& sectionString = mSections[mTagToSectionMap.valueFor(tag)];
ssize_t reverseIndex = -1;
if ((reverseIndex = mReverseMapping.indexOfKey(sectionString)) < 0) {
@@ -284,7 +284,7 @@
return &mSections;
}
-status_t VendorTagDescriptor::lookupTag(String8 name, String8 section, /*out*/uint32_t* tag) const {
+status_t VendorTagDescriptor::lookupTag(const String8& name, const String8& section, /*out*/uint32_t* tag) const {
ssize_t index = mReverseMapping.indexOfKey(section);
if (index < 0) {
ALOGE("%s: Section '%s' does not exist.", __FUNCTION__, section.string());
diff --git a/camera/cameraserver/Android.mk b/camera/cameraserver/Android.mk
index 7e36c5e..888862a 100644
--- a/camera/cameraserver/Android.mk
+++ b/camera/cameraserver/Android.mk
@@ -21,10 +21,10 @@
LOCAL_SHARED_LIBRARIES := \
libcameraservice \
+ liblog \
libcutils \
libutils \
libbinder \
- libcamera_client
LOCAL_MODULE:= cameraserver
LOCAL_32_BIT_ONLY := true
diff --git a/include/camera/Camera.h b/camera/include/camera/Camera.h
similarity index 98%
rename from include/camera/Camera.h
rename to camera/include/camera/Camera.h
index be793a2..57dc228 100644
--- a/include/camera/Camera.h
+++ b/camera/include/camera/Camera.h
@@ -170,7 +170,7 @@
class RecordingProxy : public BnCameraRecordingProxy
{
public:
- RecordingProxy(const sp<Camera>& camera);
+ explicit RecordingProxy(const sp<Camera>& camera);
// ICameraRecordingProxy interface
virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener);
@@ -183,7 +183,7 @@
};
protected:
- Camera(int cameraId);
+ explicit Camera(int cameraId);
Camera(const Camera&);
Camera& operator=(const Camera);
diff --git a/include/camera/CameraBase.h b/camera/include/camera/CameraBase.h
similarity index 100%
rename from include/camera/CameraBase.h
rename to camera/include/camera/CameraBase.h
diff --git a/include/camera/CameraMetadata.h b/camera/include/camera/CameraMetadata.h
similarity index 100%
rename from include/camera/CameraMetadata.h
rename to camera/include/camera/CameraMetadata.h
diff --git a/include/camera/CameraParameters.h b/camera/include/camera/CameraParameters.h
similarity index 100%
rename from include/camera/CameraParameters.h
rename to camera/include/camera/CameraParameters.h
diff --git a/include/camera/CameraParameters2.h b/camera/include/camera/CameraParameters2.h
similarity index 98%
rename from include/camera/CameraParameters2.h
rename to camera/include/camera/CameraParameters2.h
index 88ad812..f691cd6 100644
--- a/include/camera/CameraParameters2.h
+++ b/camera/include/camera/CameraParameters2.h
@@ -151,7 +151,7 @@
}
ssize_t removeItem(const KeyT& key) {
- size_t vectorIdx = (size_t) indexOfKey(key);
+ ssize_t vectorIdx = indexOfKey(key);
if (vectorIdx < 0) {
return vectorIdx;
diff --git a/include/camera/CameraUtils.h b/camera/include/camera/CameraUtils.h
similarity index 100%
rename from include/camera/CameraUtils.h
rename to camera/include/camera/CameraUtils.h
diff --git a/include/camera/CaptureResult.h b/camera/include/camera/CaptureResult.h
similarity index 100%
rename from include/camera/CaptureResult.h
rename to camera/include/camera/CaptureResult.h
diff --git a/include/camera/ICameraRecordingProxy.h b/camera/include/camera/ICameraRecordingProxy.h
similarity index 100%
rename from include/camera/ICameraRecordingProxy.h
rename to camera/include/camera/ICameraRecordingProxy.h
diff --git a/include/camera/ICameraRecordingProxyListener.h b/camera/include/camera/ICameraRecordingProxyListener.h
similarity index 100%
rename from include/camera/ICameraRecordingProxyListener.h
rename to camera/include/camera/ICameraRecordingProxyListener.h
diff --git a/include/camera/ICameraServiceProxy.h b/camera/include/camera/ICameraServiceProxy.h
similarity index 100%
rename from include/camera/ICameraServiceProxy.h
rename to camera/include/camera/ICameraServiceProxy.h
diff --git a/include/camera/VendorTagDescriptor.h b/camera/include/camera/VendorTagDescriptor.h
similarity index 97%
rename from include/camera/VendorTagDescriptor.h
rename to camera/include/camera/VendorTagDescriptor.h
index 60e2d2d..bfc8c96 100644
--- a/include/camera/VendorTagDescriptor.h
+++ b/camera/include/camera/VendorTagDescriptor.h
@@ -91,7 +91,7 @@
*
* Returns OK on success, or a negative error code.
*/
- status_t lookupTag(String8 name, String8 section, /*out*/uint32_t* tag) const;
+ status_t lookupTag(const String8& name, const String8& section, /*out*/uint32_t* tag) const;
/**
* Dump the currently configured vendor tags to a file descriptor.
diff --git a/include/camera/android/hardware/ICamera.h b/camera/include/camera/android/hardware/ICamera.h
similarity index 100%
rename from include/camera/android/hardware/ICamera.h
rename to camera/include/camera/android/hardware/ICamera.h
diff --git a/include/camera/android/hardware/ICameraClient.h b/camera/include/camera/android/hardware/ICameraClient.h
similarity index 100%
rename from include/camera/android/hardware/ICameraClient.h
rename to camera/include/camera/android/hardware/ICameraClient.h
diff --git a/include/camera/camera2/CaptureRequest.h b/camera/include/camera/camera2/CaptureRequest.h
similarity index 100%
rename from include/camera/camera2/CaptureRequest.h
rename to camera/include/camera/camera2/CaptureRequest.h
diff --git a/include/camera/camera2/OutputConfiguration.h b/camera/include/camera/camera2/OutputConfiguration.h
similarity index 100%
rename from include/camera/camera2/OutputConfiguration.h
rename to camera/include/camera/camera2/OutputConfiguration.h
diff --git a/include/camera/camera2/SubmitInfo.h b/camera/include/camera/camera2/SubmitInfo.h
similarity index 100%
rename from include/camera/camera2/SubmitInfo.h
rename to camera/include/camera/camera2/SubmitInfo.h
diff --git a/camera/ndk/Android.bp b/camera/ndk/Android.bp
new file mode 100644
index 0000000..97cf6bf
--- /dev/null
+++ b/camera/ndk/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+// Headers module is in frameworks/av/Android.bp because modules are not allowed
+// to refer to headers in parent directories and the headers live in
+// frameworks/av/include.
+
+ndk_library {
+ name: "libcamera2ndk",
+ symbol_file: "libcamera2ndk.map.txt",
+ first_version: "24",
+ unversioned_until: "current",
+}
+
+ndk_headers {
+ name: "libcamera2ndk_headers",
+ from: "include/camera",
+ to: "camera",
+ srcs: ["include/camera/**/*.h"],
+ license: "NOTICE",
+}
diff --git a/camera/ndk/Android.mk b/camera/ndk/Android.mk
index 40dbeef..f5ff69d 100644
--- a/camera/ndk/Android.mk
+++ b/camera/ndk/Android.mk
@@ -33,9 +33,8 @@
LOCAL_MODULE:= libcamera2ndk
-LOCAL_C_INCLUDES := \
- frameworks/av/include/camera/ndk \
- frameworks/av/include/ndk
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_CFLAGS += -fvisibility=hidden -D EXPORT='__attribute__ ((visibility ("default")))'
LOCAL_CFLAGS += -Wall -Wextra -Werror
@@ -49,9 +48,8 @@
libcamera_client \
libstagefright_foundation \
libcutils \
- libcamera_metadata
-
-LOCAL_CLANG := true
+ libcamera_metadata \
+ libmediandk
include $(BUILD_SHARED_LIBRARY)
diff --git a/camera/ndk/NOTICE b/camera/ndk/NOTICE
new file mode 100644
index 0000000..152be20
--- /dev/null
+++ b/camera/ndk/NOTICE
@@ -0,0 +1,324 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Android-specific code. ==
+ =========================================================================
+
+Android Code
+Copyright 2005-2008 The Android Open Source Project
+
+This product includes software developed as part of
+The Android Open Source Project (http://source.android.com).
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for Apache Commons code. ==
+ =========================================================================
+
+Apache Commons
+Copyright 1999-2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for Jakarta Commons Logging. ==
+ =========================================================================
+
+Jakarta Commons Logging (JCL)
+Copyright 2005,2006 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Nuance code. ==
+ =========================================================================
+
+These files are Copyright 2007 Nuance Communications, but released under
+the Apache2 License.
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Media Codecs code. ==
+ =========================================================================
+
+Media Codecs
+These files are Copyright 1998 - 2009 PacketVideo, but released under
+the Apache2 License.
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the TagSoup code. ==
+ =========================================================================
+
+This file is part of TagSoup and is Copyright 2002-2008 by John Cowan.
+
+TagSoup is licensed under the Apache License,
+Version 2.0. You may obtain a copy of this license at
+http://www.apache.org/licenses/LICENSE-2.0 . You may also have
+additional legal rights not granted by this license.
+
+TagSoup is distributed in the hope that it will be useful, but
+unless required by applicable law or agreed to in writing, TagSoup
+is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, either express or implied; not even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for Additional Codecs code. ==
+ =========================================================================
+
+Additional Codecs
+These files are Copyright 2003-2010 VisualOn, but released under
+the Apache2 License.
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Audio Effects code. ==
+ =========================================================================
+
+Audio Effects
+These files are Copyright (C) 2004-2010 NXP Software and
+Copyright (C) 2010 The Android Open Source Project, but released under
+the Apache2 License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+
+
+UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
+
+Unicode Data Files include all data files under the directories
+http://www.unicode.org/Public/, http://www.unicode.org/reports/,
+and http://www.unicode.org/cldr/data/ . Unicode Software includes any
+source code published in the Unicode Standard or under the directories
+http://www.unicode.org/Public/, http://www.unicode.org/reports/, and
+http://www.unicode.org/cldr/data/.
+
+NOTICE TO USER: Carefully read the following legal agreement. BY
+DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA
+FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY
+ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF
+THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY,
+DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
+
+COPYRIGHT AND PERMISSION NOTICE
+
+Copyright © 1991-2008 Unicode, Inc. All rights reserved. Distributed
+under the Terms of Use in http://www.unicode.org/copyright.html.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Unicode data files and any associated documentation (the
+"Data Files") or Unicode software and any associated documentation (the
+"Software") to deal in the Data Files or Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, and/or sell copies of the Data Files or Software,
+and to permit persons to whom the Data Files or Software are furnished to
+do so, provided that (a) the above copyright notice(s) and this permission
+notice appear with all copies of the Data Files or Software, (b) both the
+above copyright notice(s) and this permission notice appear in associated
+documentation, and (c) there is clear notice in each modified Data File
+or in the Software as well as in the documentation associated with the
+Data File(s) or Software that the data or software has been modified.
+
+THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in these Data Files or Software without prior written
+authorization of the copyright holder.
diff --git a/camera/ndk/NdkCameraCaptureSession.cpp b/camera/ndk/NdkCameraCaptureSession.cpp
index d6eff24..2a6b182 100644
--- a/camera/ndk/NdkCameraCaptureSession.cpp
+++ b/camera/ndk/NdkCameraCaptureSession.cpp
@@ -23,9 +23,9 @@
#include <utils/StrongPointer.h>
#include <utils/Trace.h>
-#include "NdkCameraDevice.h"
-#include <NdkCaptureRequest.h>
-#include <NdkCameraCaptureSession.h>
+#include <camera/NdkCameraDevice.h>
+#include <camera/NdkCaptureRequest.h>
+#include <camera/NdkCameraCaptureSession.h>
#include "impl/ACameraCaptureSession.h"
using namespace android;
diff --git a/camera/ndk/NdkCameraDevice.cpp b/camera/ndk/NdkCameraDevice.cpp
index 281d3e7..9f6d1f7 100644
--- a/camera/ndk/NdkCameraDevice.cpp
+++ b/camera/ndk/NdkCameraDevice.cpp
@@ -21,7 +21,7 @@
#include <utils/Log.h>
#include <utils/Trace.h>
-#include <NdkCameraDevice.h>
+#include <camera/NdkCameraDevice.h>
#include "impl/ACameraCaptureSession.h"
using namespace android;
diff --git a/camera/ndk/NdkCameraManager.cpp b/camera/ndk/NdkCameraManager.cpp
index ff15263..60b4763 100644
--- a/camera/ndk/NdkCameraManager.cpp
+++ b/camera/ndk/NdkCameraManager.cpp
@@ -21,7 +21,7 @@
#include <utils/Log.h>
#include <utils/Trace.h>
-#include <NdkCameraManager.h>
+#include <camera/NdkCameraManager.h>
#include "impl/ACameraManager.h"
using namespace android;
diff --git a/camera/ndk/NdkCameraMetadata.cpp b/camera/ndk/NdkCameraMetadata.cpp
index 85fe75b..65de81f 100644
--- a/camera/ndk/NdkCameraMetadata.cpp
+++ b/camera/ndk/NdkCameraMetadata.cpp
@@ -21,7 +21,7 @@
#include <utils/Log.h>
#include <utils/Trace.h>
-#include "NdkCameraMetadata.h"
+#include <camera/NdkCameraMetadata.h>
#include "impl/ACameraMetadata.h"
using namespace android;
diff --git a/camera/ndk/NdkCaptureRequest.cpp b/camera/ndk/NdkCaptureRequest.cpp
index 77b9a33..5b4c180 100644
--- a/camera/ndk/NdkCaptureRequest.cpp
+++ b/camera/ndk/NdkCaptureRequest.cpp
@@ -21,7 +21,7 @@
#include <utils/Log.h>
#include <utils/Trace.h>
-#include "NdkCaptureRequest.h"
+#include <camera/NdkCaptureRequest.h>
#include "impl/ACameraMetadata.h"
#include "impl/ACaptureRequest.h"
@@ -51,8 +51,13 @@
ACaptureRequest* req, const ACameraOutputTarget* target) {
ATRACE_CALL();
if (req == nullptr || req->targets == nullptr || target == nullptr) {
+ void* req_targets;
+ if (req != nullptr)
+ req_targets = req->targets;
+ else
+ req_targets = nullptr;
ALOGE("%s: Error: invalid input: req %p, req-targets %p, target %p",
- __FUNCTION__, req, req->targets, target);
+ __FUNCTION__, req, req_targets, target);
return ACAMERA_ERROR_INVALID_PARAMETER;
}
auto pair = req->targets->mOutputs.insert(*target);
@@ -67,8 +72,13 @@
ACaptureRequest* req, const ACameraOutputTarget* target) {
ATRACE_CALL();
if (req == nullptr || req->targets == nullptr || target == nullptr) {
+ void* req_targets;
+ if (req != nullptr)
+ req_targets = req->targets;
+ else
+ req_targets = nullptr;
ALOGE("%s: Error: invalid input: req %p, req-targets %p, target %p",
- __FUNCTION__, req, req->targets, target);
+ __FUNCTION__, req, req_targets, target);
return ACAMERA_ERROR_INVALID_PARAMETER;
}
req->targets->mOutputs.erase(*target);
diff --git a/camera/ndk/impl/ACameraCaptureSession.h b/camera/ndk/impl/ACameraCaptureSession.h
index 58428e6..339c665 100644
--- a/camera/ndk/impl/ACameraCaptureSession.h
+++ b/camera/ndk/impl/ACameraCaptureSession.h
@@ -18,13 +18,13 @@
#include <set>
#include <hardware/camera3.h>
-#include <NdkCameraDevice.h>
+#include <camera/NdkCameraDevice.h>
#include "ACameraDevice.h"
using namespace android;
struct ACaptureSessionOutput {
- ACaptureSessionOutput(ANativeWindow* window) : mWindow(window) {};
+ explicit ACaptureSessionOutput(ANativeWindow* window) : mWindow(window) {};
bool operator == (const ACaptureSessionOutput& other) const {
return mWindow == other.mWindow;
diff --git a/camera/ndk/impl/ACameraDevice.h b/camera/ndk/impl/ACameraDevice.h
index 71e364d..27c7498 100644
--- a/camera/ndk/impl/ACameraDevice.h
+++ b/camera/ndk/impl/ACameraDevice.h
@@ -36,7 +36,7 @@
#include <camera/camera2/OutputConfiguration.h>
#include <camera/camera2/CaptureRequest.h>
-#include <NdkCameraDevice.h>
+#include <camera/NdkCameraDevice.h>
#include "ACameraMetadata.h"
namespace android {
@@ -65,7 +65,7 @@
// Callbacks from camera service
class ServiceCallback : public hardware::camera2::BnCameraDeviceCallbacks {
public:
- ServiceCallback(CameraDevice* device) : mDevice(device) {}
+ explicit ServiceCallback(CameraDevice* device) : mDevice(device) {}
binder::Status onDeviceError(int32_t errorCode,
const CaptureResultExtras& resultExtras) override;
binder::Status onDeviceIdle() override;
diff --git a/camera/ndk/impl/ACameraManager.h b/camera/ndk/impl/ACameraManager.h
index 3f2262f..fc22b3a 100644
--- a/camera/ndk/impl/ACameraManager.h
+++ b/camera/ndk/impl/ACameraManager.h
@@ -17,7 +17,7 @@
#ifndef _ACAMERA_MANAGER_H
#define _ACAMERA_MANAGER_H
-#include "NdkCameraManager.h"
+#include <camera/NdkCameraManager.h>
#include <android/hardware/ICameraService.h>
#include <android/hardware/BnCameraServiceListener.h>
@@ -60,7 +60,7 @@
class DeathNotifier : public IBinder::DeathRecipient {
public:
- DeathNotifier(CameraManagerGlobal* cm) : mCameraManager(cm) {}
+ explicit DeathNotifier(CameraManagerGlobal* cm) : mCameraManager(cm) {}
protected:
// IBinder::DeathRecipient implementation
virtual void binderDied(const wp<IBinder>& who);
@@ -71,7 +71,7 @@
class CameraServiceListener final : public hardware::BnCameraServiceListener {
public:
- CameraServiceListener(CameraManagerGlobal* cm) : mCameraManager(cm) {}
+ explicit CameraServiceListener(CameraManagerGlobal* cm) : mCameraManager(cm) {}
virtual binder::Status onStatusChanged(int32_t status, int32_t cameraId);
// Torch API not implemented yet
@@ -86,7 +86,7 @@
// Wrapper of ACameraManager_AvailabilityCallbacks so we can store it in std::set
struct Callback {
- Callback(const ACameraManager_AvailabilityCallbacks *callback) :
+ explicit Callback(const ACameraManager_AvailabilityCallbacks *callback) :
mAvailable(callback->onCameraAvailable),
mUnavailable(callback->onCameraUnavailable),
mContext(callback->context) {}
diff --git a/camera/ndk/impl/ACameraMetadata.cpp b/camera/ndk/impl/ACameraMetadata.cpp
index ab99e38..d5d56d6 100644
--- a/camera/ndk/impl/ACameraMetadata.cpp
+++ b/camera/ndk/impl/ACameraMetadata.cpp
@@ -20,7 +20,7 @@
#include "ACameraMetadata.h"
#include <utils/Vector.h>
#include <system/graphics.h>
-#include "NdkImage.h"
+#include <media/NdkImage.h>
using namespace android;
diff --git a/camera/ndk/impl/ACameraMetadata.h b/camera/ndk/impl/ACameraMetadata.h
index 8d050c4..143efc7 100644
--- a/camera/ndk/impl/ACameraMetadata.h
+++ b/camera/ndk/impl/ACameraMetadata.h
@@ -24,7 +24,7 @@
#include <utils/Vector.h>
#include <camera/CameraMetadata.h>
-#include "NdkCameraMetadata.h"
+#include <camera/NdkCameraMetadata.h>
using namespace android;
diff --git a/camera/ndk/impl/ACaptureRequest.h b/camera/ndk/impl/ACaptureRequest.h
index 6bd8406..e5b453e 100644
--- a/camera/ndk/impl/ACaptureRequest.h
+++ b/camera/ndk/impl/ACaptureRequest.h
@@ -16,13 +16,13 @@
#ifndef _ACAPTURE_REQUEST_H
#define _ACAPTURE_REQUEST_H
-#include "NdkCaptureRequest.h"
+#include <camera/NdkCaptureRequest.h>
#include <set>
using namespace android;
struct ACameraOutputTarget {
- ACameraOutputTarget(ANativeWindow* window) : mWindow(window) {};
+ explicit ACameraOutputTarget(ANativeWindow* window) : mWindow(window) {};
bool operator == (const ACameraOutputTarget& other) const {
return mWindow == other.mWindow;
diff --git a/include/camera/ndk/NdkCameraCaptureSession.h b/camera/ndk/include/camera/NdkCameraCaptureSession.h
similarity index 98%
rename from include/camera/ndk/NdkCameraCaptureSession.h
rename to camera/ndk/include/camera/NdkCameraCaptureSession.h
index 7b314e9..d96f538 100644
--- a/include/camera/ndk/NdkCameraCaptureSession.h
+++ b/camera/ndk/include/camera/NdkCameraCaptureSession.h
@@ -32,6 +32,8 @@
* Do not reference types that are not part of the NDK.
* Do not #include files that aren't part of the NDK.
*/
+#include <sys/cdefs.h>
+
#include <android/native_window.h>
#include "NdkCameraError.h"
#include "NdkCameraMetadata.h"
@@ -39,9 +41,9 @@
#ifndef _NDK_CAMERA_CAPTURE_SESSION_H
#define _NDK_CAMERA_CAPTURE_SESSION_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
+
+#if __ANDROID_API__ >= 24
/**
* ACameraCaptureSession is an opaque type that manages frame captures of a camera device.
@@ -587,11 +589,10 @@
*/
camera_status_t ACameraCaptureSession_abortCaptures(ACameraCaptureSession* session);
+#endif /* __ANDROID_API__ >= 24 */
-#ifdef __cplusplus
-} // extern "C"
-#endif
+__END_DECLS
-#endif // _NDK_CAMERA_CAPTURE_SESSION_H
+#endif /* _NDK_CAMERA_CAPTURE_SESSION_H */
/** @} */
diff --git a/include/camera/ndk/NdkCameraDevice.h b/camera/ndk/include/camera/NdkCameraDevice.h
similarity index 99%
rename from include/camera/ndk/NdkCameraDevice.h
rename to camera/ndk/include/camera/NdkCameraDevice.h
index 9011cb6..9b7f6f4 100644
--- a/include/camera/ndk/NdkCameraDevice.h
+++ b/camera/ndk/include/camera/NdkCameraDevice.h
@@ -32,6 +32,7 @@
* Do not reference types that are not part of the NDK.
* Do not #include files that aren't part of the NDK.
*/
+#include <sys/cdefs.h>
#include <android/native_window.h>
#include "NdkCameraError.h"
@@ -41,9 +42,9 @@
#ifndef _NDK_CAMERA_DEVICE_H
#define _NDK_CAMERA_DEVICE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
+
+#if __ANDROID_API__ >= 24
/**
* ACameraDevice is opaque type that provides access to a camera device.
@@ -658,11 +659,11 @@
const ACameraCaptureSession_stateCallbacks* callbacks,
/*out*/ACameraCaptureSession** session);
-#ifdef __cplusplus
-} // extern "C"
-#endif
+#endif /* __ANDROID_API__ >= 24 */
-#endif // _NDK_CAMERA_DEVICE_H
+__END_DECLS
+
+#endif /* _NDK_CAMERA_DEVICE_H */
/** @} */
diff --git a/include/camera/ndk/NdkCameraError.h b/camera/ndk/include/camera/NdkCameraError.h
similarity index 96%
rename from include/camera/ndk/NdkCameraError.h
rename to camera/ndk/include/camera/NdkCameraError.h
index 36251fc..6b58155 100644
--- a/include/camera/ndk/NdkCameraError.h
+++ b/camera/ndk/include/camera/NdkCameraError.h
@@ -36,9 +36,11 @@
#ifndef _NDK_CAMERA_ERROR_H
#define _NDK_CAMERA_ERROR_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+#if __ANDROID_API__ >= 24
typedef enum {
ACAMERA_OK = 0,
@@ -130,11 +132,10 @@
ACAMERA_ERROR_PERMISSION_DENIED = ACAMERA_ERROR_BASE - 13,
} camera_status_t;
+#endif /* __ANDROID_API__ >= 24 */
-#ifdef __cplusplus
-} // extern "C"
-#endif
+__END_DECLS
-#endif // _NDK_CAMERA_ERROR_H
+#endif /* _NDK_CAMERA_ERROR_H */
/** @} */
diff --git a/include/camera/ndk/NdkCameraManager.h b/camera/ndk/include/camera/NdkCameraManager.h
similarity index 98%
rename from include/camera/ndk/NdkCameraManager.h
rename to camera/ndk/include/camera/NdkCameraManager.h
index 9188e94..5b5c98b 100644
--- a/include/camera/ndk/NdkCameraManager.h
+++ b/camera/ndk/include/camera/NdkCameraManager.h
@@ -36,13 +36,15 @@
#ifndef _NDK_CAMERA_MANAGER_H
#define _NDK_CAMERA_MANAGER_H
+#include <sys/cdefs.h>
+
#include "NdkCameraError.h"
#include "NdkCameraMetadata.h"
#include "NdkCameraDevice.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
+
+#if __ANDROID_API__ >= 24
/**
* ACameraManager is opaque type that provides access to camera service.
@@ -271,10 +273,10 @@
ACameraDevice_StateCallbacks* callback,
/*out*/ACameraDevice** device);
-#ifdef __cplusplus
-} // extern "C"
-#endif
+#endif /* __ANDROID_API__ >= 24 */
-#endif //_NDK_CAMERA_MANAGER_H
+__END_DECLS
+
+#endif /* _NDK_CAMERA_MANAGER_H */
/** @} */
diff --git a/include/camera/ndk/NdkCameraMetadata.h b/camera/ndk/include/camera/NdkCameraMetadata.h
similarity index 97%
rename from include/camera/ndk/NdkCameraMetadata.h
rename to camera/ndk/include/camera/NdkCameraMetadata.h
index d929854..f2aec98 100644
--- a/include/camera/ndk/NdkCameraMetadata.h
+++ b/camera/ndk/include/camera/NdkCameraMetadata.h
@@ -36,12 +36,14 @@
#ifndef _NDK_CAMERA_METADATA_H
#define _NDK_CAMERA_METADATA_H
+#include <sys/cdefs.h>
+
#include "NdkCameraError.h"
#include "NdkCameraMetadataTags.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
+
+#if __ANDROID_API__ >= 24
/**
* ACameraMetadata is opaque type that provides access to read-only camera metadata like camera
@@ -226,10 +228,10 @@
*/
void ACameraMetadata_free(ACameraMetadata* metadata);
-#ifdef __cplusplus
-} // extern "C"
-#endif
+#endif /* __ANDROID_API__ >= 24 */
-#endif //_NDK_CAMERA_METADATA_H
+__END_DECLS
+
+#endif /* _NDK_CAMERA_METADATA_H */
/** @} */
diff --git a/include/camera/ndk/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h
similarity index 99%
rename from include/camera/ndk/NdkCameraMetadataTags.h
rename to camera/ndk/include/camera/NdkCameraMetadataTags.h
index e7f6989..0fec983 100644
--- a/include/camera/ndk/NdkCameraMetadataTags.h
+++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h
@@ -36,6 +36,12 @@
#ifndef _NDK_CAMERA_METADATA_TAGS_H
#define _NDK_CAMERA_METADATA_TAGS_H
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+#if __ANDROID_API__ >= 24
+
typedef enum acamera_metadata_section {
ACAMERA_COLOR_CORRECTION,
ACAMERA_CONTROL,
@@ -6901,8 +6907,10 @@
} acamera_metadata_enum_android_depth_depth_is_exclusive_t;
+#endif /* __ANDROID_API__ >= 24 */
+__END_DECLS
-#endif //_NDK_CAMERA_METADATA_TAGS_H
+#endif /* _NDK_CAMERA_METADATA_TAGS_H */
/** @} */
diff --git a/include/camera/ndk/NdkCaptureRequest.h b/camera/ndk/include/camera/NdkCaptureRequest.h
similarity index 98%
rename from include/camera/ndk/NdkCaptureRequest.h
rename to camera/ndk/include/camera/NdkCaptureRequest.h
index cd97f4d..c62ba2c 100644
--- a/include/camera/ndk/NdkCaptureRequest.h
+++ b/camera/ndk/include/camera/NdkCaptureRequest.h
@@ -32,6 +32,9 @@
* Do not reference types that are not part of the NDK.
* Do not #include files that aren't part of the NDK.
*/
+
+#include <sys/cdefs.h>
+
#include <android/native_window.h>
#include "NdkCameraError.h"
#include "NdkCameraMetadata.h"
@@ -39,9 +42,9 @@
#ifndef _NDK_CAPTURE_REQUEST_H
#define _NDK_CAPTURE_REQUEST_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
+
+#if __ANDROID_API__ >= 24
// Container for output targets
typedef struct ACameraOutputTargets ACameraOutputTargets;
@@ -300,10 +303,10 @@
*/
void ACaptureRequest_free(ACaptureRequest* request);
-#ifdef __cplusplus
-} // extern "C"
-#endif
+#endif /* __ANDROID_API__ >= 24 */
-#endif // _NDK_CAPTURE_REQUEST_H
+__END_DECLS
+
+#endif /* _NDK_CAPTURE_REQUEST_H */
/** @} */
diff --git a/camera/ndk/libcamera2ndk.map.txt b/camera/ndk/libcamera2ndk.map.txt
new file mode 100644
index 0000000..41bb22b
--- /dev/null
+++ b/camera/ndk/libcamera2ndk.map.txt
@@ -0,0 +1,46 @@
+LIBCAMERA2NDK {
+ global:
+ ACameraCaptureSession_abortCaptures;
+ ACameraCaptureSession_capture;
+ ACameraCaptureSession_close;
+ ACameraCaptureSession_getDevice;
+ ACameraCaptureSession_setRepeatingRequest;
+ ACameraCaptureSession_stopRepeating;
+ ACameraDevice_close;
+ ACameraDevice_createCaptureRequest;
+ ACameraDevice_createCaptureSession;
+ ACameraDevice_getId;
+ ACameraManager_create;
+ ACameraManager_delete;
+ ACameraManager_deleteCameraIdList;
+ ACameraManager_getCameraCharacteristics;
+ ACameraManager_getCameraIdList;
+ ACameraManager_openCamera;
+ ACameraManager_registerAvailabilityCallback;
+ ACameraManager_unregisterAvailabilityCallback;
+ ACameraMetadata_copy;
+ ACameraMetadata_free;
+ ACameraMetadata_getAllTags;
+ ACameraMetadata_getConstEntry;
+ ACameraOutputTarget_create;
+ ACameraOutputTarget_free;
+ ACaptureRequest_addTarget;
+ ACaptureRequest_free;
+ ACaptureRequest_getAllTags;
+ ACaptureRequest_getConstEntry;
+ ACaptureRequest_removeTarget;
+ ACaptureRequest_setEntry_double;
+ ACaptureRequest_setEntry_float;
+ ACaptureRequest_setEntry_i32;
+ ACaptureRequest_setEntry_i64;
+ ACaptureRequest_setEntry_rational;
+ ACaptureRequest_setEntry_u8;
+ ACaptureSessionOutputContainer_add;
+ ACaptureSessionOutputContainer_create;
+ ACaptureSessionOutputContainer_free;
+ ACaptureSessionOutputContainer_remove;
+ ACaptureSessionOutput_create;
+ ACaptureSessionOutput_free;
+ local:
+ *;
+};
diff --git a/camera/tests/Android.mk b/camera/tests/Android.mk
index 8019999..0978a81 100644
--- a/camera/tests/Android.mk
+++ b/camera/tests/Android.mk
@@ -21,6 +21,7 @@
CameraBinderTests.cpp
LOCAL_SHARED_LIBRARIES := \
+ liblog \
libutils \
libcutils \
libcamera_metadata \
diff --git a/cmds/screenrecord/Android.mk b/cmds/screenrecord/Android.mk
index 6747e60..6f210e6 100644
--- a/cmds/screenrecord/Android.mk
+++ b/cmds/screenrecord/Android.mk
@@ -31,7 +31,7 @@
LOCAL_C_INCLUDES := \
frameworks/av/media/libstagefright \
frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/native/include/media/openmax \
+ frameworks/native/include/media/openmax \
external/jpeg
LOCAL_CFLAGS += -Wno-multichar
diff --git a/cmds/stagefright/Android.mk b/cmds/stagefright/Android.mk
index 9e15a81..d952428 100644
--- a/cmds/stagefright/Android.mk
+++ b/cmds/stagefright/Android.mk
@@ -14,11 +14,10 @@
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/native/include/media/openmax \
+ frameworks/native/include/media/openmax \
external/jpeg \
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
@@ -39,11 +38,10 @@
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/native/include/media/hardware
+ frameworks/native/include/media/openmax \
+ frameworks/native/include/media/hardware
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
@@ -64,11 +62,10 @@
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/native/include/media/hardware
+ frameworks/native/include/media/openmax \
+ frameworks/native/include/media/hardware
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
@@ -90,10 +87,9 @@
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
+ frameworks/native/include/media/openmax
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
@@ -114,10 +110,9 @@
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
+ frameworks/native/include/media/openmax
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
@@ -134,14 +129,13 @@
LOCAL_SHARED_LIBRARIES := \
libstagefright liblog libutils libbinder libstagefright_foundation \
- libmedia libgui libcutils libui
+ libmedia libgui libcutils
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
+ frameworks/native/include/media/openmax
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
@@ -159,14 +153,13 @@
LOCAL_SHARED_LIBRARIES := \
libstagefright liblog libutils libbinder libstagefright_foundation \
- libmedia libgui libcutils libui
+ libmedia libaudioclient libgui libcutils
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
+ frameworks/native/include/media/openmax
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
@@ -193,14 +186,13 @@
libmedia \
libgui \
libcutils \
- libui \
libRScpp \
LOCAL_C_INCLUDES:= \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/rs/cpp \
- $(TOP)/frameworks/rs \
+ frameworks/av/media/libstagefright \
+ frameworks/native/include/media/openmax \
+ frameworks/rs/cpp \
+ frameworks/rs \
intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
LOCAL_C_INCLUDES += $(intermediates)
@@ -209,7 +201,6 @@
libstagefright_mediafilter
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
@@ -226,14 +217,13 @@
LOCAL_SHARED_LIBRARIES := \
libstagefright liblog libutils libbinder libstagefright_foundation \
- libmedia libgui libcutils libui libc
+ libcutils libc
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
+ frameworks/native/include/media/openmax
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
LOCAL_MODULE_TAGS := optional
diff --git a/cmds/stagefright/SimplePlayer.h b/cmds/stagefright/SimplePlayer.h
index ae9dfd2..0d8c74a 100644
--- a/cmds/stagefright/SimplePlayer.h
+++ b/cmds/stagefright/SimplePlayer.h
@@ -22,7 +22,7 @@
struct ABuffer;
struct ALooper;
-struct AudioTrack;
+class AudioTrack;
class IGraphicBufferProducer;
struct MediaCodec;
struct NuMediaExtractor;
diff --git a/cmds/stagefright/mediafilter.cpp b/cmds/stagefright/mediafilter.cpp
index 1183112..d829df0 100644
--- a/cmds/stagefright/mediafilter.cpp
+++ b/cmds/stagefright/mediafilter.cpp
@@ -69,7 +69,7 @@
namespace android {
struct SaturationRSFilter : RenderScriptWrapper::RSFilterCallback {
- void init(RSC::sp<RSC::RS> context) {
+ void init(const RSC::sp<RSC::RS> &context) {
mScript = new ScriptC_saturation(context);
mScript->set_gSaturation(3.f);
}
@@ -90,7 +90,7 @@
};
struct NightVisionRSFilter : RenderScriptWrapper::RSFilterCallback {
- void init(RSC::sp<RSC::RS> context) {
+ void init(const RSC::sp<RSC::RS> &context) {
mScript = new ScriptC_nightvision(context);
}
@@ -110,7 +110,7 @@
};
struct ARGBToRGBARSFilter : RenderScriptWrapper::RSFilterCallback {
- void init(RSC::sp<RSC::RS> context) {
+ void init(const RSC::sp<RSC::RS> &context) {
mScript = new ScriptC_argbtorgba(context);
}
diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp
index ca68722..08d2064 100644
--- a/cmds/stagefright/stagefright.cpp
+++ b/cmds/stagefright/stagefright.cpp
@@ -159,7 +159,7 @@
1,
mbuf->range_length(),
out),
- (ssize_t)mbuf->range_length());
+ mbuf->range_length());
mbuf->release();
mbuf = NULL;
@@ -401,7 +401,7 @@
////////////////////////////////////////////////////////////////////////////////
struct DetectSyncSource : public MediaSource {
- DetectSyncSource(const sp<IMediaSource> &source);
+ explicit DetectSyncSource(const sp<IMediaSource> &source);
virtual status_t start(MetaData *params = NULL);
virtual status_t stop();
diff --git a/cmds/stagefright/stream.cpp b/cmds/stagefright/stream.cpp
index bca3832..16ff39d 100644
--- a/cmds/stagefright/stream.cpp
+++ b/cmds/stagefright/stream.cpp
@@ -45,7 +45,7 @@
struct MyStreamSource : public BnStreamSource {
// Object assumes ownership of fd.
- MyStreamSource(int fd);
+ explicit MyStreamSource(int fd);
virtual void setListener(const sp<IStreamListener> &listener);
virtual void setBuffers(const Vector<sp<IMemory> > &buffers);
@@ -125,7 +125,7 @@
////////////////////////////////////////////////////////////////////////////////
struct MyConvertingStreamSource : public BnStreamSource {
- MyConvertingStreamSource(const char *filename);
+ explicit MyConvertingStreamSource(const char *filename);
virtual void setListener(const sp<IStreamListener> &listener);
virtual void setBuffers(const Vector<sp<IMemory> > &buffers);
diff --git a/drm/common/Android.bp b/drm/common/Android.bp
new file mode 100644
index 0000000..0098c89
--- /dev/null
+++ b/drm/common/Android.bp
@@ -0,0 +1,39 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_library_static {
+ name: "libdrmframeworkcommon",
+
+ srcs: [
+ "DrmConstraints.cpp",
+ "DrmMetadata.cpp",
+ "DrmConvertedStatus.cpp",
+ "DrmEngineBase.cpp",
+ "DrmInfo.cpp",
+ "DrmInfoRequest.cpp",
+ "DrmInfoStatus.cpp",
+ "DrmRights.cpp",
+ "DrmSupportInfo.cpp",
+ "IDrmManagerService.cpp",
+ "IDrmServiceListener.cpp",
+ "DrmInfoEvent.cpp",
+ "ReadWriteUtils.cpp",
+ ],
+
+ static_libs: ["libbinder"],
+
+ export_include_dirs: ["include"],
+}
diff --git a/drm/common/Android.mk b/drm/common/Android.mk
deleted file mode 100644
index db67534..0000000
--- a/drm/common/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- DrmConstraints.cpp \
- DrmMetadata.cpp \
- DrmConvertedStatus.cpp \
- DrmEngineBase.cpp \
- DrmInfo.cpp \
- DrmInfoRequest.cpp \
- DrmInfoStatus.cpp \
- DrmRights.cpp \
- DrmSupportInfo.cpp \
- IDrmManagerService.cpp \
- IDrmServiceListener.cpp \
- DrmInfoEvent.cpp \
- ReadWriteUtils.cpp
-
-LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/av/include \
- $(TOP)/frameworks/av/drm/libdrmframework/include \
- $(TOP)/frameworks/av/drm/libdrmframework/plugins/common/include
-
-LOCAL_MODULE:= libdrmframeworkcommon
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/drm/common/DrmInfoEvent.cpp b/drm/common/DrmInfoEvent.cpp
index 27a5a2d..703e363 100644
--- a/drm/common/DrmInfoEvent.cpp
+++ b/drm/common/DrmInfoEvent.cpp
@@ -19,7 +19,7 @@
using namespace android;
-DrmInfoEvent::DrmInfoEvent(int uniqueId, int infoType, const String8 message)
+DrmInfoEvent::DrmInfoEvent(int uniqueId, int infoType, const String8 &message)
: mUniqueId(uniqueId),
mInfoType(infoType),
mMessage(message) {
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp
index caae75f..44f98dd 100644
--- a/drm/common/IDrmManagerService.cpp
+++ b/drm/common/IDrmManagerService.cpp
@@ -33,7 +33,7 @@
#include "IDrmManagerService.h"
-#define INVALID_BUFFER_LENGTH -1
+#define INVALID_BUFFER_LENGTH (-1)
#define MAX_BINDER_TRANSACTION_SIZE ((1*1024*1024)-(4096*2))
using namespace android;
diff --git a/drm/common/ReadWriteUtils.cpp b/drm/common/ReadWriteUtils.cpp
index d696f16..16b5b34 100644
--- a/drm/common/ReadWriteUtils.cpp
+++ b/drm/common/ReadWriteUtils.cpp
@@ -30,7 +30,7 @@
using namespace android;
-#define FAILURE -1
+#define FAILURE (-1)
String8 ReadWriteUtils::readBytes(const String8& filePath) {
FILE* file = NULL;
diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/common/include/DrmEngineBase.h
similarity index 100%
rename from drm/libdrmframework/plugins/common/include/DrmEngineBase.h
rename to drm/common/include/DrmEngineBase.h
diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/common/include/IDrmEngine.h
similarity index 100%
rename from drm/libdrmframework/plugins/common/include/IDrmEngine.h
rename to drm/common/include/IDrmEngine.h
diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/common/include/IDrmManagerService.h
similarity index 98%
rename from drm/libdrmframework/include/IDrmManagerService.h
rename to drm/common/include/IDrmManagerService.h
index fe55650..0376b49 100644
--- a/drm/libdrmframework/include/IDrmManagerService.h
+++ b/drm/common/include/IDrmManagerService.h
@@ -169,7 +169,7 @@
class BpDrmManagerService: public BpInterface<IDrmManagerService>
{
public:
- BpDrmManagerService(const sp<IBinder>& impl)
+ explicit BpDrmManagerService(const sp<IBinder>& impl)
: BpInterface<IDrmManagerService>(impl) {}
virtual int addUniqueId(bool isNative);
diff --git a/drm/libdrmframework/include/IDrmServiceListener.h b/drm/common/include/IDrmServiceListener.h
similarity index 96%
rename from drm/libdrmframework/include/IDrmServiceListener.h
rename to drm/common/include/IDrmServiceListener.h
index 7f7109f..78c5d1a 100644
--- a/drm/libdrmframework/include/IDrmServiceListener.h
+++ b/drm/common/include/IDrmServiceListener.h
@@ -49,7 +49,7 @@
class BpDrmServiceListener: public BpInterface<IDrmServiceListener>
{
public:
- BpDrmServiceListener(const sp<IBinder>& impl)
+ explicit BpDrmServiceListener(const sp<IBinder>& impl)
: BpInterface<IDrmServiceListener>(impl) {}
virtual status_t notify(const DrmInfoEvent& event);
diff --git a/drm/libdrmframework/include/ReadWriteUtils.h b/drm/common/include/ReadWriteUtils.h
similarity index 100%
rename from drm/libdrmframework/include/ReadWriteUtils.h
rename to drm/common/include/ReadWriteUtils.h
diff --git a/drm/drmserver/Android.bp b/drm/drmserver/Android.bp
new file mode 100644
index 0000000..c25a0a1
--- /dev/null
+++ b/drm/drmserver/Android.bp
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_binary {
+ name: "drmserver",
+
+ srcs: [
+ "main_drmserver.cpp",
+ "DrmManager.cpp",
+ "DrmManagerService.cpp",
+ ],
+
+ shared_libs: [
+ "libmedia",
+ "libutils",
+ "liblog",
+ "libbinder",
+ "libdl",
+ "libselinux",
+ ],
+
+ static_libs: ["libdrmframeworkcommon"],
+
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+
+ compile_multilib: "32",
+
+ init_rc: ["drmserver.rc"],
+}
diff --git a/drm/drmserver/Android.mk b/drm/drmserver/Android.mk
deleted file mode 100644
index 3b8bb04..0000000
--- a/drm/drmserver/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- main_drmserver.cpp \
- DrmManager.cpp \
- DrmManagerService.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libmedia \
- libutils \
- liblog \
- libbinder \
- libdl \
- libselinux
-
-LOCAL_STATIC_LIBRARIES := libdrmframeworkcommon
-
-LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/av/include \
- $(TOP)/frameworks/av/drm/libdrmframework/include \
- $(TOP)/frameworks/av/drm/libdrmframework/plugins/common/include
-
-LOCAL_CFLAGS += -Wall -Wextra -Werror
-
-LOCAL_MODULE:= drmserver
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_32_BIT_ONLY := true
-
-LOCAL_INIT_RC := drmserver.rc
-
-include $(BUILD_EXECUTABLE)
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index e168ba2..1d835f9 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -33,7 +33,7 @@
#include "DrmManager.h"
#include "ReadWriteUtils.h"
-#define DECRYPT_FILE_ERROR -1
+#define DECRYPT_FILE_ERROR (-1)
using namespace android;
@@ -413,7 +413,7 @@
handle->decryptId = mDecryptSessionId + 1;
for (size_t index = 0; index < plugInIdList.size(); index++) {
- String8 plugInId = plugInIdList.itemAt(index);
+ const String8& plugInId = plugInIdList.itemAt(index);
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length, mime);
@@ -441,7 +441,7 @@
handle->decryptId = mDecryptSessionId + 1;
for (size_t index = 0; index < plugInIdList.size(); index++) {
- String8 plugInId = plugInIdList.itemAt(index);
+ const String8& plugInId = plugInIdList.itemAt(index);
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.openDecryptSession(uniqueId, handle, uri, mime);
@@ -470,7 +470,7 @@
handle->decryptId = mDecryptSessionId + 1;
for (size_t index = 0; index < plugInIdList.size(); index++) {
- String8 plugInId = plugInIdList.itemAt(index);
+ const String8& plugInId = plugInIdList.itemAt(index);
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.openDecryptSession(uniqueId, handle, buf, mimeType);
diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/drmserver/DrmManager.h
similarity index 100%
rename from drm/libdrmframework/include/DrmManager.h
rename to drm/drmserver/DrmManager.h
diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/drmserver/DrmManagerService.h
similarity index 100%
rename from drm/libdrmframework/include/DrmManagerService.h
rename to drm/drmserver/DrmManagerService.h
diff --git a/drm/libdrmframework/include/PlugInManager.h b/drm/drmserver/PlugInManager.h
similarity index 100%
rename from drm/libdrmframework/include/PlugInManager.h
rename to drm/drmserver/PlugInManager.h
diff --git a/drm/libdrmframework/Android.bp b/drm/libdrmframework/Android.bp
new file mode 100644
index 0000000..43ba72b
--- /dev/null
+++ b/drm/libdrmframework/Android.bp
@@ -0,0 +1,42 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_library_shared {
+ name: "libdrmframework",
+
+ srcs: [
+ "DrmManagerClientImpl.cpp",
+ "DrmManagerClient.cpp",
+ "NoOpDrmManagerClientImpl.cpp",
+ ],
+
+ shared_libs: [
+ "libutils",
+ "libcutils",
+ "liblog",
+ "libbinder",
+ "libdl",
+ ],
+
+ static_libs: ["libdrmframeworkcommon"],
+
+ export_include_dirs: ["include"],
+ export_static_lib_headers: ["libdrmframeworkcommon"],
+
+ cflags: ["-Werror"],
+}
+
+subdirs = ["plugins/*"]
diff --git a/drm/libdrmframework/Android.mk b/drm/libdrmframework/Android.mk
deleted file mode 100644
index cafcb94..0000000
--- a/drm/libdrmframework/Android.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- DrmManagerClientImpl.cpp \
- DrmManagerClient.cpp \
- NoOpDrmManagerClientImpl.cpp
-
-LOCAL_MODULE:= libdrmframework
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libcutils \
- liblog \
- libbinder \
- libdl
-
-LOCAL_STATIC_LIBRARIES := \
- libdrmframeworkcommon
-
-LOCAL_C_INCLUDES += \
- $(TOP)/frameworks/av/drm/libdrmframework/include \
- $(TOP)/frameworks/av/include
-
-LOCAL_CFLAGS += -Werror
-
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp
index cbd013e..c047eb1 100644
--- a/drm/libdrmframework/DrmManagerClientImpl.cpp
+++ b/drm/libdrmframework/DrmManagerClientImpl.cpp
@@ -28,7 +28,7 @@
using namespace android;
-#define INVALID_VALUE -1
+#define INVALID_VALUE (-1)
Mutex DrmManagerClientImpl::sMutex;
sp<IDrmManagerService> DrmManagerClientImpl::sDrmManagerService;
diff --git a/drm/libdrmframework/plugins/Android.mk b/drm/libdrmframework/plugins/Android.mk
deleted file mode 100644
index 9ee7961..0000000
--- a/drm/libdrmframework/plugins/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-include $(call all-subdir-makefiles)
diff --git a/drm/libdrmframework/plugins/common/Android.bp b/drm/libdrmframework/plugins/common/Android.bp
new file mode 100644
index 0000000..213e57f
--- /dev/null
+++ b/drm/libdrmframework/plugins/common/Android.bp
@@ -0,0 +1 @@
+subdirs = ["util"]
diff --git a/drm/libdrmframework/plugins/common/Android.mk b/drm/libdrmframework/plugins/common/Android.mk
deleted file mode 100644
index 9ee7961..0000000
--- a/drm/libdrmframework/plugins/common/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-include $(call all-subdir-makefiles)
diff --git a/drm/libdrmframework/plugins/common/util/Android.bp b/drm/libdrmframework/plugins/common/util/Android.bp
new file mode 100644
index 0000000..0c0b6f2
--- /dev/null
+++ b/drm/libdrmframework/plugins/common/util/Android.bp
@@ -0,0 +1,23 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_library_static {
+ name: "libdrmutility",
+
+ srcs: ["src/MimeTypeUtil.cpp"],
+
+ export_include_dirs: ["include"],
+}
diff --git a/drm/libdrmframework/plugins/common/util/Android.mk b/drm/libdrmframework/plugins/common/util/Android.mk
deleted file mode 100644
index 2a7b01f..0000000
--- a/drm/libdrmframework/plugins/common/util/Android.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/MimeTypeUtil.cpp
-
-LOCAL_MODULE := libdrmutility
-
-base := frameworks/av
-
-LOCAL_C_INCLUDES += \
- $(base)/include \
- $(base)/include/drm \
- $(base)/include/drm/plugins \
- $(LOCAL_PATH)/include
-
-
-ifneq ($(TARGET_BUILD_VARIANT),user)
-LOCAL_C_INCLUDES += \
- $(LOCAL_PATH)/tools
-
-endif
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/drm/libdrmframework/plugins/common/util/src/MimeTypeUtil.cpp b/drm/libdrmframework/plugins/common/util/src/MimeTypeUtil.cpp
index 4bd1adb..3b1566f 100644
--- a/drm/libdrmframework/plugins/common/util/src/MimeTypeUtil.cpp
+++ b/drm/libdrmframework/plugins/common/util/src/MimeTypeUtil.cpp
@@ -115,7 +115,7 @@
* replacement mimetype otherwise the original mimetype
* is returned.
*
- * If the mimetype is of unsupported group i.e. application / *
+ * If the mimetype is of unsupported group i.e. application/...
* then "unsupported/drm.mimetype" will be returned.
*
* @param mimeType - mimetype in lower case to convert.
diff --git a/drm/libdrmframework/plugins/forward-lock/Android.bp b/drm/libdrmframework/plugins/forward-lock/Android.bp
new file mode 100644
index 0000000..f884c14
--- /dev/null
+++ b/drm/libdrmframework/plugins/forward-lock/Android.bp
@@ -0,0 +1,4 @@
+subdirs = [
+ "FwdLockEngine",
+ "internal-format",
+]
diff --git a/drm/libdrmframework/plugins/forward-lock/Android.mk b/drm/libdrmframework/plugins/forward-lock/Android.mk
deleted file mode 100644
index 9ee7961..0000000
--- a/drm/libdrmframework/plugins/forward-lock/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-include $(call all-subdir-makefiles)
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp
new file mode 100644
index 0000000..3f0f5f7
--- /dev/null
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp
@@ -0,0 +1,50 @@
+//
+// Copyright (C) 2010 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
+//2
+// 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.
+//
+
+cc_library_shared {
+ name: "libfwdlockengine",
+
+ cflags: [
+ "-DUSE_64BIT_DRM_API",
+ // The flag below turns on local debug printouts
+ //"-DDRM_OMA_FL_ENGINE_DEBUG",
+ ],
+
+ srcs: ["src/FwdLockEngine.cpp"],
+
+ shared_libs: [
+ "libicui18n",
+ "libicuuc",
+ "libutils",
+ "liblog",
+ "libdl",
+ "libcrypto",
+ "libssl",
+ "libdrmframework",
+ ],
+
+ static_libs: [
+ "libdrmutility",
+ "libdrmframeworkcommon",
+ "libfwdlock-common",
+ "libfwdlock-converter",
+ "libfwdlock-decoder",
+ ],
+
+ local_include_dirs: ["include"],
+
+ relative_install_path: "drm",
+}
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk
deleted file mode 100644
index 933464f..0000000
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# The flag below turns on local debug printouts
-#LOCAL_CFLAGS += -DDRM_OMA_FL_ENGINE_DEBUG
-
-base := frameworks/av
-
-# Determine whether the DRM framework uses 64-bit data types for file offsets and do the same.
-ifneq ($(shell grep -c 'off64_t offset' $(base)/drm/libdrmframework/plugins/common/include/IDrmEngine.h), 0)
-LOCAL_CFLAGS += -DUSE_64BIT_DRM_API
-endif
-
-LOCAL_SRC_FILES:= \
- src/FwdLockEngine.cpp
-
-LOCAL_MODULE := libfwdlockengine
-
-LOCAL_SHARED_LIBRARIES := \
- libicui18n \
- libicuuc \
- libutils \
- liblog \
- libdl \
- libcrypto \
- libssl \
- libdrmframework
-
-LOCAL_STATIC_LIBRARIES := \
- libdrmutility \
- libdrmframeworkcommon \
- libfwdlock-common \
- libfwdlock-converter \
- libfwdlock-decoder
-
-
-
-LOCAL_C_INCLUDES += \
- $(base)/include/drm \
- $(base)/drm/libdrmframework/plugins/common/include \
- $(base)/drm/libdrmframework/plugins/common/util/include \
- $(base)/drm/libdrmframework/plugins/forward-lock/internal-format/common \
- $(base)/drm/libdrmframework/plugins/forward-lock/internal-format/converter \
- $(base)/drm/libdrmframework/plugins/forward-lock/internal-format/decoder \
- $(LOCAL_PATH)/include
-
-LOCAL_MODULE_RELATIVE_PATH := drm
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h
index a31b951..a571b3a 100644
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h
@@ -18,14 +18,14 @@
#define __FWDLOCKENGINE_H__
#include <DrmEngineBase.h>
-#include <DrmConstraints.h>
-#include <DrmRights.h>
-#include <DrmInfo.h>
-#include <DrmInfoStatus.h>
-#include <DrmConvertedStatus.h>
-#include <DrmInfoRequest.h>
-#include <DrmSupportInfo.h>
-#include <DrmInfoEvent.h>
+#include <drm/DrmConstraints.h>
+#include <drm/DrmRights.h>
+#include <drm/DrmInfo.h>
+#include <drm/DrmInfoStatus.h>
+#include <drm/DrmConvertedStatus.h>
+#include <drm/DrmInfoRequest.h>
+#include <drm/DrmSupportInfo.h>
+#include <drm/DrmInfoEvent.h>
#include "SessionMap.h"
#include "FwdLockConv.h"
@@ -539,7 +539,7 @@
offset = 0;
}
- DecodeSession(int fd) {
+ explicit DecodeSession(int fd) {
fileDesc = fd;
offset = 0;
}
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
index a495616..830def9 100644
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
@@ -20,17 +20,17 @@
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
-#include "drm_framework_common.h"
+#include <drm/drm_framework_common.h>
#include <fcntl.h>
#include <limits.h>
-#include <DrmRights.h>
-#include <DrmConstraints.h>
-#include <DrmMetadata.h>
-#include <DrmInfo.h>
-#include <DrmInfoStatus.h>
-#include <DrmInfoRequest.h>
-#include <DrmSupportInfo.h>
-#include <DrmConvertedStatus.h>
+#include <drm/DrmRights.h>
+#include <drm/DrmConstraints.h>
+#include <drm/DrmMetadata.h>
+#include <drm/DrmInfo.h>
+#include <drm/DrmInfoStatus.h>
+#include <drm/DrmInfoRequest.h>
+#include <drm/DrmSupportInfo.h>
+#include <drm/DrmConvertedStatus.h>
#include <utils/String8.h>
#include "FwdLockConv.h"
#include "FwdLockFile.h"
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/Android.bp b/drm/libdrmframework/plugins/forward-lock/internal-format/Android.bp
new file mode 100644
index 0000000..9f58e26
--- /dev/null
+++ b/drm/libdrmframework/plugins/forward-lock/internal-format/Android.bp
@@ -0,0 +1,5 @@
+subdirs = [
+ "common",
+ "converter",
+ "decoder",
+]
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/Android.mk b/drm/libdrmframework/plugins/forward-lock/internal-format/Android.mk
deleted file mode 100644
index 9ee7961..0000000
--- a/drm/libdrmframework/plugins/forward-lock/internal-format/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-include $(call all-subdir-makefiles)
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.bp b/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.bp
new file mode 100644
index 0000000..698f278
--- /dev/null
+++ b/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.bp
@@ -0,0 +1,25 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_library_static {
+ name: "libfwdlock-common",
+
+ srcs: ["FwdLockGlue.c"],
+
+ shared_libs: ["libcrypto"],
+
+ export_include_dirs: ["."],
+}
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.mk b/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.mk
deleted file mode 100644
index 3b4c8b4..0000000
--- a/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- FwdLockGlue.c
-
-LOCAL_SHARED_LIBRARIES := libcrypto
-
-LOCAL_MODULE := libfwdlock-common
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.bp b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.bp
new file mode 100644
index 0000000..33f2fe0
--- /dev/null
+++ b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.bp
@@ -0,0 +1,26 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_library_static {
+ name: "libfwdlock-converter",
+
+ srcs: ["FwdLockConv.c"],
+
+ shared_libs: ["libcrypto"],
+ static_libs: ["libfwdlock-common"],
+
+ export_include_dirs: ["."],
+}
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.mk b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.mk
deleted file mode 100644
index 2f51f0c..0000000
--- a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- FwdLockConv.c
-
-LOCAL_C_INCLUDES := \
- frameworks/av/drm/libdrmframework/plugins/forward-lock/internal-format/common
-
-LOCAL_SHARED_LIBRARIES := libcrypto
-
-LOCAL_MODULE := libfwdlock-converter
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.bp b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.bp
new file mode 100644
index 0000000..b6d7a06
--- /dev/null
+++ b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.bp
@@ -0,0 +1,26 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_library_static {
+ name: "libfwdlock-decoder",
+
+ srcs: ["FwdLockFile.c"],
+
+ shared_libs: ["libcrypto"],
+ static_libs: ["libfwdlock-common"],
+
+ export_include_dirs: ["."],
+}
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.mk b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.mk
deleted file mode 100644
index 3399ae5..0000000
--- a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- FwdLockFile.c
-
-LOCAL_C_INCLUDES := \
- frameworks/av/drm/libdrmframework/plugins/forward-lock/internal-format/common
-
-LOCAL_SHARED_LIBRARIES := libcrypto
-
-LOCAL_MODULE := libfwdlock-decoder
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/drm/libdrmframework/plugins/passthru/Android.bp b/drm/libdrmframework/plugins/passthru/Android.bp
new file mode 100644
index 0000000..1dcf89c
--- /dev/null
+++ b/drm/libdrmframework/plugins/passthru/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_library_shared {
+ name: "libdrmpassthruplugin",
+
+ srcs: ["src/DrmPassthruPlugIn.cpp"],
+
+ static_libs: ["libdrmframeworkcommon"],
+
+ shared_libs: [
+ "libutils",
+ "liblog",
+ "libdl",
+ ],
+
+ local_include_dirs: ["include"],
+
+ cflags: [
+ // Set the following flag to enable the decryption passthru flow
+ //"-DENABLE_PASSTHRU_DECRYPTION",
+ ],
+}
diff --git a/drm/libdrmframework/plugins/passthru/Android.mk b/drm/libdrmframework/plugins/passthru/Android.mk
deleted file mode 100644
index cb3a2e2..0000000
--- a/drm/libdrmframework/plugins/passthru/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- src/DrmPassthruPlugIn.cpp
-
-LOCAL_MODULE := libdrmpassthruplugin
-
-LOCAL_STATIC_LIBRARIES := libdrmframeworkcommon
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- liblog \
- libdl
-
-
-LOCAL_C_INCLUDES += \
- $(TOP)/frameworks/av/drm/libdrmframework/include \
- $(TOP)/frameworks/av/drm/libdrmframework/plugins/passthru/include \
- $(TOP)/frameworks/av/drm/libdrmframework/plugins/common/include \
- $(TOP)/frameworks/av/include
-
-# Set the following flag to enable the decryption passthru flow
-#LOCAL_CFLAGS += -DENABLE_PASSTHRU_DECRYPTION
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
index 084e323..d7f2d28 100644
--- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
+++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
@@ -52,12 +52,12 @@
}
-DrmMetadata* DrmPassthruPlugIn::onGetMetadata(int uniqueId, const String8* path) {
+DrmMetadata* DrmPassthruPlugIn::onGetMetadata(int /*uniqueId*/, const String8* /*path*/) {
return NULL;
}
DrmConstraints* DrmPassthruPlugIn::onGetConstraints(
- int uniqueId, const String8* path, int action) {
+ int uniqueId, const String8* /*path*/, int /*action*/) {
ALOGV("DrmPassthruPlugIn::onGetConstraints From Path: %d", uniqueId);
DrmConstraints* drmConstraints = new DrmConstraints();
@@ -108,7 +108,7 @@
}
status_t DrmPassthruPlugIn::onSetOnInfoListener(
- int uniqueId, const IDrmEngine::OnInfoListener* infoListener) {
+ int uniqueId, const IDrmEngine::OnInfoListener* /*infoListener*/) {
ALOGV("DrmPassthruPlugIn::onSetOnInfoListener : %d", uniqueId);
return DRM_NO_ERROR;
}
@@ -135,8 +135,8 @@
return drmSupportInfo;
}
-status_t DrmPassthruPlugIn::onSaveRights(int uniqueId, const DrmRights& drmRights,
- const String8& rightsPath, const String8& contentPath) {
+status_t DrmPassthruPlugIn::onSaveRights(int uniqueId, const DrmRights& /*drmRights*/,
+ const String8& /*rightsPath*/, const String8& /*contentPath*/) {
ALOGV("DrmPassthruPlugIn::onSaveRights : %d", uniqueId);
return DRM_NO_ERROR;
}
@@ -157,49 +157,50 @@
return drmInfo;
}
-bool DrmPassthruPlugIn::onCanHandle(int uniqueId, const String8& path) {
+bool DrmPassthruPlugIn::onCanHandle(int /*uniqueId*/, const String8& path) {
ALOGV("DrmPassthruPlugIn::canHandle: %s ", path.string());
String8 extension = path.getPathExtension();
extension.toLower();
return (String8(".passthru") == extension);
}
-String8 DrmPassthruPlugIn::onGetOriginalMimeType(int uniqueId, const String8& path, int fd) {
+String8 DrmPassthruPlugIn::onGetOriginalMimeType(int uniqueId,
+ const String8& /*path*/, int /*fd*/) {
ALOGV("DrmPassthruPlugIn::onGetOriginalMimeType() : %d", uniqueId);
return String8("video/passthru");
}
int DrmPassthruPlugIn::onGetDrmObjectType(
- int uniqueId, const String8& path, const String8& mimeType) {
+ int uniqueId, const String8& /*path*/, const String8& /*mimeType*/) {
ALOGV("DrmPassthruPlugIn::onGetDrmObjectType() : %d", uniqueId);
return DrmObjectType::UNKNOWN;
}
-int DrmPassthruPlugIn::onCheckRightsStatus(int uniqueId, const String8& path, int action) {
+int DrmPassthruPlugIn::onCheckRightsStatus(int uniqueId, const String8& /*path*/, int /*action*/) {
ALOGV("DrmPassthruPlugIn::onCheckRightsStatus() : %d", uniqueId);
int rightsStatus = RightsStatus::RIGHTS_VALID;
return rightsStatus;
}
-status_t DrmPassthruPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
- int action, bool reserve) {
+status_t DrmPassthruPlugIn::onConsumeRights(int uniqueId,
+ DecryptHandle* /*decryptHandle*/, int /*action*/, bool /*reserve*/) {
ALOGV("DrmPassthruPlugIn::onConsumeRights() : %d", uniqueId);
return DRM_NO_ERROR;
}
-status_t DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
- int playbackStatus, int64_t position) {
+status_t DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId,
+ DecryptHandle* /*decryptHandle*/, int /*playbackStatus*/, int64_t /*position*/) {
ALOGV("DrmPassthruPlugIn::onSetPlaybackStatus() : %d", uniqueId);
return DRM_NO_ERROR;
}
-bool DrmPassthruPlugIn::onValidateAction(int uniqueId, const String8& path,
- int action, const ActionDescription& description) {
+bool DrmPassthruPlugIn::onValidateAction(int uniqueId,
+ const String8& /*path*/, int /*action*/, const ActionDescription& /*description*/) {
ALOGV("DrmPassthruPlugIn::onValidateAction() : %d", uniqueId);
return true;
}
-status_t DrmPassthruPlugIn::onRemoveRights(int uniqueId, const String8& path) {
+status_t DrmPassthruPlugIn::onRemoveRights(int uniqueId, const String8& /*path*/) {
ALOGV("DrmPassthruPlugIn::onRemoveRights() : %d", uniqueId);
return DRM_NO_ERROR;
}
@@ -209,13 +210,13 @@
return DRM_NO_ERROR;
}
-status_t DrmPassthruPlugIn::onOpenConvertSession(int uniqueId, int convertId) {
+status_t DrmPassthruPlugIn::onOpenConvertSession(int uniqueId, int /*convertId*/) {
ALOGV("DrmPassthruPlugIn::onOpenConvertSession() : %d", uniqueId);
return DRM_NO_ERROR;
}
DrmConvertedStatus* DrmPassthruPlugIn::onConvertData(
- int uniqueId, int convertId, const DrmBuffer* inputData) {
+ int uniqueId, int /*convertId*/, const DrmBuffer* inputData) {
ALOGV("DrmPassthruPlugIn::onConvertData() : %d", uniqueId);
DrmBuffer* convertedData = NULL;
@@ -229,13 +230,13 @@
return new DrmConvertedStatus(DrmConvertedStatus::STATUS_OK, convertedData, 0 /*offset*/);
}
-DrmConvertedStatus* DrmPassthruPlugIn::onCloseConvertSession(int uniqueId, int convertId) {
+DrmConvertedStatus* DrmPassthruPlugIn::onCloseConvertSession(int uniqueId, int /*convertId*/) {
ALOGV("DrmPassthruPlugIn::onCloseConvertSession() : %d", uniqueId);
return new DrmConvertedStatus(DrmConvertedStatus::STATUS_OK, NULL, 0 /*offset*/);
}
status_t DrmPassthruPlugIn::onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
+ int uniqueId, DecryptHandle* decryptHandle, int /*fd*/, off64_t /*offset*/, off64_t /*length*/) {
ALOGV("DrmPassthruPlugIn::onOpenDecryptSession() : %d", uniqueId);
#ifdef ENABLE_PASSTHRU_DECRYPTION
@@ -244,13 +245,15 @@
decryptHandle->status = DRM_NO_ERROR;
decryptHandle->decryptInfo = NULL;
return DRM_NO_ERROR;
+#else
+ (void)(decryptHandle); // unused
#endif
return DRM_ERROR_CANNOT_HANDLE;
}
status_t DrmPassthruPlugIn::onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
+ int /*uniqueId*/, DecryptHandle* /*decryptHandle*/, const char* /*uri*/) {
return DRM_ERROR_CANNOT_HANDLE;
}
@@ -265,14 +268,14 @@
return DRM_NO_ERROR;
}
-status_t DrmPassthruPlugIn::onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* headerInfo) {
+status_t DrmPassthruPlugIn::onInitializeDecryptUnit(int uniqueId, DecryptHandle* /*decryptHandle*/,
+ int /*decryptUnitId*/, const DrmBuffer* /*headerInfo*/) {
ALOGV("DrmPassthruPlugIn::onInitializeDecryptUnit() : %d", uniqueId);
return DRM_NO_ERROR;
}
-status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
+status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* /*decryptHandle*/,
+ int /*decryptUnitId*/, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* /*IV*/) {
ALOGV("DrmPassthruPlugIn::onDecrypt() : %d", uniqueId);
/**
* As a workaround implementation passthru would copy the given
@@ -293,13 +296,13 @@
}
status_t DrmPassthruPlugIn::onFinalizeDecryptUnit(
- int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
+ int uniqueId, DecryptHandle* /*decryptHandle*/, int /*decryptUnitId*/) {
ALOGV("DrmPassthruPlugIn::onFinalizeDecryptUnit() : %d", uniqueId);
return DRM_NO_ERROR;
}
-ssize_t DrmPassthruPlugIn::onPread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off64_t offset) {
+ssize_t DrmPassthruPlugIn::onPread(int uniqueId, DecryptHandle* /*decryptHandle*/,
+ void* /*buffer*/, ssize_t /*numBytes*/, off64_t /*offset*/) {
ALOGV("DrmPassthruPlugIn::onPread() : %d", uniqueId);
return 0;
}
diff --git a/drm/libmediadrm/Android.bp b/drm/libmediadrm/Android.bp
new file mode 100644
index 0000000..32f487e
--- /dev/null
+++ b/drm/libmediadrm/Android.bp
@@ -0,0 +1,33 @@
+//
+// libmediadrm
+//
+
+cc_library_shared {
+ name: "libmediadrm",
+
+ srcs: [
+ "Crypto.cpp",
+ "Drm.cpp",
+ "DrmSessionManager.cpp",
+ "ICrypto.cpp",
+ "IDrm.cpp",
+ "IDrmClient.cpp",
+ "IMediaDrmService.cpp",
+ "SharedLibrary.cpp",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ "libcutils",
+ "libdl",
+ "liblog",
+ "libmediautils",
+ "libstagefright_foundation",
+ "libutils",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
diff --git a/drm/libmediadrm/Android.mk b/drm/libmediadrm/Android.mk
deleted file mode 100644
index 6a2ed31..0000000
--- a/drm/libmediadrm/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#
-# libmediadrm
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- Crypto.cpp \
- Drm.cpp \
- DrmSessionManager.cpp \
- SharedLibrary.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libcrypto \
- libcutils \
- libdl \
- liblog \
- libmedia \
- libstagefright \
- libstagefright_foundation \
- libutils
-
-LOCAL_C_INCLUDES := \
- libcore/include
-
-LOCAL_CFLAGS += -Werror -Wno-error=deprecated-declarations -Wall
-LOCAL_CLANG := true
-
-LOCAL_MODULE:= libmediadrm
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/drm/libmediadrm/Drm.cpp b/drm/libmediadrm/Drm.cpp
index 7c1f5c8..9ab08db 100644
--- a/drm/libmediadrm/Drm.cpp
+++ b/drm/libmediadrm/Drm.cpp
@@ -61,7 +61,7 @@
}
struct DrmSessionClient : public DrmSessionClientInterface {
- DrmSessionClient(Drm* drm) : mDrm(drm) {}
+ explicit DrmSessionClient(Drm* drm) : mDrm(drm) {}
virtual bool reclaimSession(const Vector<uint8_t>& sessionId) {
sp<Drm> drm = mDrm.promote();
diff --git a/drm/libmediadrm/DrmSessionManager.cpp b/drm/libmediadrm/DrmSessionManager.cpp
index a87fb9d..02270d0 100644
--- a/drm/libmediadrm/DrmSessionManager.cpp
+++ b/drm/libmediadrm/DrmSessionManager.cpp
@@ -65,7 +65,7 @@
DrmSessionManager::~DrmSessionManager() {}
void DrmSessionManager::addSession(
- int pid, sp<DrmSessionClientInterface> drm, const Vector<uint8_t> &sessionId) {
+ int pid, const sp<DrmSessionClientInterface>& drm, const Vector<uint8_t> &sessionId) {
ALOGV("addSession(pid %d, drm %p, sessionId %s)", pid, drm.get(),
GetSessionIdString(sessionId).string());
@@ -116,7 +116,7 @@
}
}
-void DrmSessionManager::removeDrm(sp<DrmSessionClientInterface> drm) {
+void DrmSessionManager::removeDrm(const sp<DrmSessionClientInterface>& drm) {
ALOGV("removeDrm(%p)", drm.get());
Mutex::Autolock lock(mLock);
diff --git a/media/libmedia/ICrypto.cpp b/drm/libmediadrm/ICrypto.cpp
similarity index 99%
rename from media/libmedia/ICrypto.cpp
rename to drm/libmediadrm/ICrypto.cpp
index 302e6ee..7b261be 100644
--- a/media/libmedia/ICrypto.cpp
+++ b/drm/libmediadrm/ICrypto.cpp
@@ -39,7 +39,7 @@
};
struct BpCrypto : public BpInterface<ICrypto> {
- BpCrypto(const sp<IBinder> &impl)
+ explicit BpCrypto(const sp<IBinder> &impl)
: BpInterface<ICrypto>(impl) {
}
diff --git a/media/libmedia/IDrm.cpp b/drm/libmediadrm/IDrm.cpp
similarity index 99%
rename from media/libmedia/IDrm.cpp
rename to drm/libmediadrm/IDrm.cpp
index 51a1130..c4558c6 100644
--- a/media/libmedia/IDrm.cpp
+++ b/drm/libmediadrm/IDrm.cpp
@@ -59,7 +59,7 @@
};
struct BpDrm : public BpInterface<IDrm> {
- BpDrm(const sp<IBinder> &impl)
+ explicit BpDrm(const sp<IBinder> &impl)
: BpInterface<IDrm>(impl) {
}
diff --git a/media/libmedia/IDrmClient.cpp b/drm/libmediadrm/IDrmClient.cpp
similarity index 97%
rename from media/libmedia/IDrmClient.cpp
rename to drm/libmediadrm/IDrmClient.cpp
index 490c6ed..444201f 100644
--- a/media/libmedia/IDrmClient.cpp
+++ b/drm/libmediadrm/IDrmClient.cpp
@@ -35,7 +35,7 @@
class BpDrmClient: public BpInterface<IDrmClient>
{
public:
- BpDrmClient(const sp<IBinder>& impl)
+ explicit BpDrmClient(const sp<IBinder>& impl)
: BpInterface<IDrmClient>(impl)
{
}
diff --git a/media/libmedia/IMediaDrmService.cpp b/drm/libmediadrm/IMediaDrmService.cpp
similarity index 100%
rename from media/libmedia/IMediaDrmService.cpp
rename to drm/libmediadrm/IMediaDrmService.cpp
diff --git a/drm/mediadrm/Android.bp b/drm/mediadrm/Android.bp
new file mode 100644
index 0000000..b9f07f1
--- /dev/null
+++ b/drm/mediadrm/Android.bp
@@ -0,0 +1 @@
+subdirs = ["plugins/*"]
diff --git a/drm/mediadrm/plugins/clearkey/Android.bp b/drm/mediadrm/plugins/clearkey/Android.bp
new file mode 100644
index 0000000..6af7cd8
--- /dev/null
+++ b/drm/mediadrm/plugins/clearkey/Android.bp
@@ -0,0 +1,54 @@
+//
+// Copyright (C) 2014 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.
+//
+
+cc_library_shared {
+ name: "libdrmclearkeyplugin",
+
+ srcs: [
+ "AesCtrDecryptor.cpp",
+ "ClearKeyUUID.cpp",
+ "CreatePluginFactories.cpp",
+ "CryptoFactory.cpp",
+ "CryptoPlugin.cpp",
+ "DrmFactory.cpp",
+ "DrmPlugin.cpp",
+ "InitDataParser.cpp",
+ "JsonWebKey.cpp",
+ "Session.cpp",
+ "SessionLibrary.cpp",
+ "Utils.cpp",
+ ],
+
+ vendor: true,
+ relative_install_path: "mediadrm",
+
+ shared_libs: [
+ "libcrypto",
+ "liblog",
+ "libstagefright_foundation",
+ "libutils",
+ ],
+
+ static_libs: ["libjsmn"],
+
+ export_include_dirs: ["."],
+ export_static_lib_headers: ["libjsmn"],
+}
+
+//########################################################################
+// Build unit tests
+
+subdirs = ["tests"]
diff --git a/drm/mediadrm/plugins/clearkey/Android.mk b/drm/mediadrm/plugins/clearkey/Android.mk
deleted file mode 100644
index 2efdcf5..0000000
--- a/drm/mediadrm/plugins/clearkey/Android.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- AesCtrDecryptor.cpp \
- ClearKeyUUID.cpp \
- CreatePluginFactories.cpp \
- CryptoFactory.cpp \
- CryptoPlugin.cpp \
- DrmFactory.cpp \
- DrmPlugin.cpp \
- InitDataParser.cpp \
- JsonWebKey.cpp \
- Session.cpp \
- SessionLibrary.cpp \
- Utils.cpp \
-
-LOCAL_C_INCLUDES := \
- external/jsmn \
- frameworks/av/drm/mediadrm/plugins/clearkey \
- frameworks/av/include \
- frameworks/native/include \
-
-LOCAL_MODULE := libdrmclearkeyplugin
-
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := mediadrm
-
-LOCAL_SHARED_LIBRARIES := \
- libcrypto \
- liblog \
- libstagefright_foundation \
- libutils \
-
-LOCAL_STATIC_LIBRARIES := \
- libjsmn \
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-#########################################################################
-# Build unit tests
-
-include $(LOCAL_PATH)/tests/Android.mk
diff --git a/drm/mediadrm/plugins/clearkey/CryptoPlugin.h b/drm/mediadrm/plugins/clearkey/CryptoPlugin.h
index de84c36..a6d2f7b 100644
--- a/drm/mediadrm/plugins/clearkey/CryptoPlugin.h
+++ b/drm/mediadrm/plugins/clearkey/CryptoPlugin.h
@@ -31,7 +31,7 @@
class CryptoPlugin : public android::CryptoPlugin {
public:
- CryptoPlugin(const android::Vector<uint8_t>& sessionId) {
+ explicit CryptoPlugin(const android::Vector<uint8_t>& sessionId) {
mInitStatus = setMediaDrmSession(sessionId);
}
diff --git a/drm/mediadrm/plugins/clearkey/DrmPlugin.h b/drm/mediadrm/plugins/clearkey/DrmPlugin.h
index efb9f8b..c4d934e 100644
--- a/drm/mediadrm/plugins/clearkey/DrmPlugin.h
+++ b/drm/mediadrm/plugins/clearkey/DrmPlugin.h
@@ -39,7 +39,7 @@
class DrmPlugin : public android::DrmPlugin {
public:
- DrmPlugin(SessionLibrary* sessionLibrary)
+ explicit DrmPlugin(SessionLibrary* sessionLibrary)
: mSessionLibrary(sessionLibrary) {}
virtual ~DrmPlugin() {}
diff --git a/drm/mediadrm/plugins/clearkey/tests/Android.bp b/drm/mediadrm/plugins/clearkey/tests/Android.bp
new file mode 100644
index 0000000..1b208ad
--- /dev/null
+++ b/drm/mediadrm/plugins/clearkey/tests/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2014 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.
+//
+// ----------------------------------------------------------------
+// Builds ClearKey Drm Tests
+//
+
+cc_test {
+ name: "ClearKeyDrmUnitTest",
+
+ srcs: [
+ "AesCtrDecryptorUnittest.cpp",
+ "InitDataParserUnittest.cpp",
+ "JsonWebKeyUnittest.cpp",
+ ],
+
+ shared_libs: [
+ "libcrypto",
+ "libdrmclearkeyplugin",
+ "liblog",
+ "libstagefright_foundation",
+ "libutils",
+ ],
+}
diff --git a/drm/mediadrm/plugins/clearkey/tests/Android.mk b/drm/mediadrm/plugins/clearkey/tests/Android.mk
deleted file mode 100644
index 392f218..0000000
--- a/drm/mediadrm/plugins/clearkey/tests/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-# ----------------------------------------------------------------
-# Builds ClearKey Drm Tests
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := ClearKeyDrmUnitTest
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- AesCtrDecryptorUnittest.cpp \
- InitDataParserUnittest.cpp \
- JsonWebKeyUnittest.cpp \
-
-LOCAL_C_INCLUDES := \
- external/jsmn \
- frameworks/av/drm/mediadrm/plugins/clearkey \
- frameworks/av/include \
- frameworks/native/include \
-
-LOCAL_SHARED_LIBRARIES := \
- libcrypto \
- libdrmclearkeyplugin \
- liblog \
- libstagefright_foundation \
- libutils \
-
-include $(BUILD_NATIVE_TEST)
diff --git a/drm/mediadrm/plugins/clearkey/tests/InitDataParserUnittest.cpp b/drm/mediadrm/plugins/clearkey/tests/InitDataParserUnittest.cpp
index e275108..84ed242 100644
--- a/drm/mediadrm/plugins/clearkey/tests/InitDataParserUnittest.cpp
+++ b/drm/mediadrm/plugins/clearkey/tests/InitDataParserUnittest.cpp
@@ -56,7 +56,7 @@
request.size());
EXPECT_EQ(0, requestString.find(kRequestPrefix));
EXPECT_EQ(requestString.size() - kRequestSuffix.size(),
- requestString.find(kRequestSuffix));
+ (size_t)requestString.find(kRequestSuffix));
for (size_t i = 0; i < expectedKeys.size(); ++i) {
AString encodedIdAString;
android::encodeBase64(expectedKeys[i], kKeyIdSize,
@@ -71,7 +71,7 @@
const String8& mimeType) {
Vector<uint8_t> request;
ASSERT_NE(android::OK, attemptParse(initData, mimeType, &request));
- EXPECT_EQ(0, request.size());
+ EXPECT_EQ(0u, request.size());
}
};
diff --git a/drm/mediadrm/plugins/mock/Android.bp b/drm/mediadrm/plugins/mock/Android.bp
new file mode 100644
index 0000000..7f44819
--- /dev/null
+++ b/drm/mediadrm/plugins/mock/Android.bp
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2013 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.
+//
+
+cc_library_shared {
+ name: "libmockdrmcryptoplugin",
+
+ srcs: ["MockDrmCryptoPlugin.cpp"],
+
+ vendor: true,
+ relative_install_path: "mediadrm",
+
+ shared_libs: [
+ "libutils",
+ "liblog",
+ ],
+
+ cflags: [
+ // Set the following flag to enable the decryption passthru flow
+ //"-DENABLE_PASSTHRU_DECRYPTION",
+ ],
+}
diff --git a/drm/mediadrm/plugins/mock/Android.mk b/drm/mediadrm/plugins/mock/Android.mk
deleted file mode 100644
index 26c245b..0000000
--- a/drm/mediadrm/plugins/mock/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- MockDrmCryptoPlugin.cpp
-
-LOCAL_MODULE := libmockdrmcryptoplugin
-
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := mediadrm
-
-LOCAL_SHARED_LIBRARIES := \
- libutils liblog
-
-LOCAL_C_INCLUDES += \
- $(TOP)/frameworks/av/include \
- $(TOP)/frameworks/native/include/media
-
-# Set the following flag to enable the decryption passthru flow
-#LOCAL_CFLAGS += -DENABLE_PASSTHRU_DECRYPTION
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.cpp b/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.cpp
index 1e80f8e..cb199e5 100644
--- a/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.cpp
+++ b/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.cpp
@@ -19,7 +19,7 @@
#include <utils/Log.h>
-#include "drm/DrmAPI.h"
+#include "media/drm/DrmAPI.h"
#include "MockDrmCryptoPlugin.h"
#include "media/stagefright/MediaErrors.h"
@@ -729,7 +729,7 @@
ssize_t MockDrmPlugin::findSession(Vector<uint8_t> const &sessionId) const
{
- ALOGD("findSession: nsessions=%d, size=%d", mSessions.size(), sessionId.size());
+ ALOGD("findSession: nsessions=%zu, size=%zu", mSessions.size(), sessionId.size());
for (size_t i = 0; i < mSessions.size(); ++i) {
if (memcmp(mSessions[i].array(), sessionId.array(), sessionId.size()) == 0) {
return i;
@@ -740,7 +740,7 @@
ssize_t MockDrmPlugin::findKeySet(Vector<uint8_t> const &keySetId) const
{
- ALOGD("findKeySet: nkeySets=%d, size=%d", mKeySets.size(), keySetId.size());
+ ALOGD("findKeySet: nkeySets=%zu, size=%zu", mKeySets.size(), keySetId.size());
for (size_t i = 0; i < mKeySets.size(); ++i) {
if (memcmp(mKeySets[i].array(), keySetId.array(), keySetId.size()) == 0) {
return i;
@@ -766,7 +766,7 @@
return result;
}
- String8 MockDrmPlugin::stringMapToString(KeyedVector<String8, String8> map) const
+ String8 MockDrmPlugin::stringMapToString(const KeyedVector<String8, String8>& map) const
{
String8 result("{ ");
for (size_t i = 0; i < map.size(); i++) {
@@ -791,8 +791,9 @@
}
ssize_t
- MockCryptoPlugin::decrypt(bool secure, const uint8_t key[16], const uint8_t iv[16],
- Mode mode, const Pattern &pattern, const void *srcPtr,
+ MockCryptoPlugin::decrypt(bool secure, const uint8_t key[DECRYPT_KEY_SIZE],
+ const uint8_t iv[DECRYPT_KEY_SIZE], Mode mode,
+ const Pattern &pattern, const void *srcPtr,
const SubSample *subSamples, size_t numSubSamples,
void *dstPtr, AString * /* errorDetailMsg */)
{
@@ -800,8 +801,8 @@
"pattern:{encryptBlocks=%d, skipBlocks=%d} src=%p, "
"subSamples=%s, dst=%p)",
(int)secure,
- arrayToString(key, sizeof(key)).string(),
- arrayToString(iv, sizeof(iv)).string(),
+ arrayToString(key, DECRYPT_KEY_SIZE).string(),
+ arrayToString(iv, DECRYPT_KEY_SIZE).string(),
(int)mode, pattern.mEncryptBlocks, pattern.mSkipBlocks, srcPtr,
subSamplesToString(subSamples, numSubSamples).string(),
dstPtr);
diff --git a/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.h b/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.h
index 40d4e84..9012d2d 100644
--- a/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.h
+++ b/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.h
@@ -16,8 +16,8 @@
#include <utils/Mutex.h>
-#include "drm/DrmAPI.h"
-#include "hardware/CryptoAPI.h"
+#include "media/drm/DrmAPI.h"
+#include "media/hardware/CryptoAPI.h"
extern "C" {
android::DrmFactory *createDrmFactory();
@@ -138,7 +138,7 @@
private:
String8 vectorToString(Vector<uint8_t> const &vector) const;
String8 arrayToString(uint8_t const *array, size_t len) const;
- String8 stringMapToString(KeyedVector<String8, String8> map) const;
+ String8 stringMapToString(const KeyedVector<String8, String8>& map) const;
SortedVector<Vector<uint8_t> > mSessions;
SortedVector<Vector<uint8_t> > mKeySets;
@@ -157,9 +157,12 @@
bool requiresSecureDecoderComponent(const char *mime) const;
+ static constexpr size_t DECRYPT_KEY_SIZE = 16;
+
ssize_t decrypt(bool secure,
- const uint8_t key[16], const uint8_t iv[16],
- Mode mode, const Pattern &pattern, const void *srcPtr,
+ const uint8_t key[DECRYPT_KEY_SIZE],
+ const uint8_t iv[DECRYPT_KEY_SIZE], Mode mode,
+ const Pattern &pattern, const void *srcPtr,
const SubSample *subSamples, size_t numSubSamples,
void *dstPtr, AString *errorDetailMsg);
private:
diff --git a/include/camera b/include/camera
new file mode 120000
index 0000000..67a148a
--- /dev/null
+++ b/include/camera
@@ -0,0 +1 @@
+../camera/include/camera
\ No newline at end of file
diff --git a/include/drm/DrmConstraints.h b/include/drm/DrmConstraints.h
index a9ec942..b8bb24f 100644
--- a/include/drm/DrmConstraints.h
+++ b/include/drm/DrmConstraints.h
@@ -70,7 +70,7 @@
class KeyIterator {
friend class DrmConstraints;
private:
- KeyIterator(DrmConstraints* drmConstraints)
+ explicit KeyIterator(DrmConstraints* drmConstraints)
: mDrmConstraints(drmConstraints), mIndex(0) {}
public:
@@ -93,7 +93,7 @@
class Iterator {
friend class DrmConstraints;
private:
- Iterator(DrmConstraints* drmConstraints)
+ explicit Iterator(DrmConstraints* drmConstraints)
: mDrmConstraints(drmConstraints), mIndex(0) {}
public:
diff --git a/include/drm/DrmInfo.h b/include/drm/DrmInfo.h
index 7b48541..53dfd61 100644
--- a/include/drm/DrmInfo.h
+++ b/include/drm/DrmInfo.h
@@ -55,7 +55,7 @@
friend class DrmInfo;
private:
- KeyIterator(const DrmInfo* drmInfo)
+ explicit KeyIterator(const DrmInfo* drmInfo)
: mDrmInfo(const_cast <DrmInfo*> (drmInfo)), mIndex(0) {}
public:
@@ -79,7 +79,7 @@
friend class DrmInfo;
private:
- Iterator(const DrmInfo* drmInfo)
+ explicit Iterator(const DrmInfo* drmInfo)
: mDrmInfo(const_cast <DrmInfo*> (drmInfo)), mIndex(0) {}
public:
diff --git a/include/drm/DrmInfoEvent.h b/include/drm/DrmInfoEvent.h
index dfca228..3165f02 100644
--- a/include/drm/DrmInfoEvent.h
+++ b/include/drm/DrmInfoEvent.h
@@ -77,7 +77,7 @@
* @param[in] infoType Type of information
* @param[in] message Message description
*/
- DrmInfoEvent(int uniqueId, int infoType, const String8 message);
+ DrmInfoEvent(int uniqueId, int infoType, const String8& message);
/**
* Destructor for DrmInfoEvent
diff --git a/include/drm/DrmInfoRequest.h b/include/drm/DrmInfoRequest.h
index 3e48ecc..e2da4fe 100644
--- a/include/drm/DrmInfoRequest.h
+++ b/include/drm/DrmInfoRequest.h
@@ -69,7 +69,7 @@
friend class DrmInfoRequest;
private:
- KeyIterator(const DrmInfoRequest* drmInfoRequest)
+ explicit KeyIterator(const DrmInfoRequest* drmInfoRequest)
: mDrmInfoRequest(const_cast <DrmInfoRequest*> (drmInfoRequest)), mIndex(0) {}
public:
@@ -93,7 +93,7 @@
friend class DrmInfoRequest;
private:
- Iterator(const DrmInfoRequest* drmInfoRequest)
+ explicit Iterator(const DrmInfoRequest* drmInfoRequest)
: mDrmInfoRequest(const_cast <DrmInfoRequest*> (drmInfoRequest)), mIndex(0) {}
public:
diff --git a/include/drm/DrmMetadata.h b/include/drm/DrmMetadata.h
index 2c7538a..6624450 100644
--- a/include/drm/DrmMetadata.h
+++ b/include/drm/DrmMetadata.h
@@ -35,7 +35,7 @@
class KeyIterator {
friend class DrmMetadata;
private:
- KeyIterator(DrmMetadata* drmMetadata) : mDrmMetadata(drmMetadata), mIndex(0) {}
+ explicit KeyIterator(DrmMetadata* drmMetadata) : mDrmMetadata(drmMetadata), mIndex(0) {}
public:
KeyIterator(const KeyIterator& keyIterator);
@@ -57,7 +57,7 @@
class Iterator {
friend class DrmMetadata;
private:
- Iterator(DrmMetadata* drmMetadata) : mDrmMetadata(drmMetadata), mIndex(0) {}
+ explicit Iterator(DrmMetadata* drmMetadata) : mDrmMetadata(drmMetadata), mIndex(0) {}
public:
Iterator(const Iterator& iterator);
diff --git a/include/drm/DrmSupportInfo.h b/include/drm/DrmSupportInfo.h
index bf12b0b..bf85dbb 100644
--- a/include/drm/DrmSupportInfo.h
+++ b/include/drm/DrmSupportInfo.h
@@ -37,7 +37,7 @@
class MimeTypeIterator {
friend class DrmSupportInfo;
private:
- MimeTypeIterator(DrmSupportInfo* drmSupportInfo)
+ explicit MimeTypeIterator(DrmSupportInfo* drmSupportInfo)
: mDrmSupportInfo(drmSupportInfo), mIndex(0) {}
public:
MimeTypeIterator(const MimeTypeIterator& iterator);
@@ -60,7 +60,7 @@
friend class DrmSupportInfo;
private:
- FileSuffixIterator(DrmSupportInfo* drmSupportInfo)
+ explicit FileSuffixIterator(DrmSupportInfo* drmSupportInfo)
: mDrmSupportInfo(drmSupportInfo), mIndex(0) {}
public:
FileSuffixIterator(const FileSuffixIterator& iterator);
diff --git a/include/drm/drm_framework_common.h b/include/drm/drm_framework_common.h
index 637409c..0750406 100644
--- a/include/drm/drm_framework_common.h
+++ b/include/drm/drm_framework_common.h
@@ -23,7 +23,7 @@
#include <utils/String8.h>
#include <utils/Errors.h>
-#define INVALID_VALUE -1
+#define INVALID_VALUE (-1)
namespace android {
diff --git a/include/media/AudioEffect.h b/include/media/AudioEffect.h
index 6af1962..7f6ccac 100644
--- a/include/media/AudioEffect.h
+++ b/include/media/AudioEffect.h
@@ -462,7 +462,7 @@
}
// IBinder::DeathRecipient
- virtual void binderDied(const wp<IBinder>& who) {
+ virtual void binderDied(const wp<IBinder>& /*who*/) {
sp<AudioEffect> effect = mEffect.promote();
if (effect != 0) {
effect->binderDied();
diff --git a/include/media/AudioPolicy.h b/include/media/AudioPolicy.h
index 8528c7a..8da0069 100644
--- a/include/media/AudioPolicy.h
+++ b/include/media/AudioPolicy.h
@@ -36,7 +36,7 @@
(RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET)
#define RULE_EXCLUDE_UID (RULE_EXCLUSION_MASK|RULE_MATCH_UID)
-#define MIX_TYPE_INVALID -1
+#define MIX_TYPE_INVALID (-1)
#define MIX_TYPE_PLAYERS 0
#define MIX_TYPE_RECORDERS 1
@@ -45,7 +45,7 @@
// keep in sync with AudioSystem.java
#define DYNAMIC_POLICY_EVENT_MIX_STATE_UPDATE 0
-#define MIX_STATE_DISABLED -1
+#define MIX_STATE_DISABLED (-1)
#define MIX_STATE_IDLE 0
#define MIX_STATE_MIXING 1
diff --git a/include/media/AudioPolicyHelper.h b/include/media/AudioPolicyHelper.h
index 79231be..d39aa20 100644
--- a/include/media/AudioPolicyHelper.h
+++ b/include/media/AudioPolicyHelper.h
@@ -18,7 +18,8 @@
#include <system/audio.h>
-static audio_stream_type_t audio_attributes_to_stream_type(const audio_attributes_t *attr)
+static inline
+audio_stream_type_t audio_attributes_to_stream_type(const audio_attributes_t *attr)
{
// flags to stream type mapping
if ((attr->flags & AUDIO_FLAG_AUDIBILITY_ENFORCED) == AUDIO_FLAG_AUDIBILITY_ENFORCED) {
@@ -61,7 +62,8 @@
}
}
-static void stream_type_to_audio_attributes(audio_stream_type_t streamType,
+static inline
+void stream_type_to_audio_attributes(audio_stream_type_t streamType,
audio_attributes_t *attr) {
memset(attr, 0, sizeof(audio_attributes_t));
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 2e6646a..d67ad44 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -200,6 +200,9 @@
const char *device_address, const char *device_name);
static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
const char *device_address);
+ static status_t handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name);
static status_t setPhoneState(audio_mode_t state);
static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config);
static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage);
@@ -326,7 +329,7 @@
static audio_mode_t getPhoneState();
- static status_t registerPolicyMixes(Vector<AudioMix> mixes, bool registration);
+ static status_t registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration);
static status_t startAudioSource(const struct audio_port_config *source,
const audio_attributes_t *attributes,
diff --git a/include/media/DrmSessionManager.h b/include/media/DrmSessionManager.h
index ba5c268..ba27199 100644
--- a/include/media/DrmSessionManager.h
+++ b/include/media/DrmSessionManager.h
@@ -45,12 +45,12 @@
static sp<DrmSessionManager> Instance();
DrmSessionManager();
- DrmSessionManager(sp<ProcessInfoInterface> processInfo);
+ explicit DrmSessionManager(sp<ProcessInfoInterface> processInfo);
- void addSession(int pid, sp<DrmSessionClientInterface> drm, const Vector<uint8_t>& sessionId);
+ void addSession(int pid, const sp<DrmSessionClientInterface>& drm, const Vector<uint8_t>& sessionId);
void useSession(const Vector<uint8_t>& sessionId);
void removeSession(const Vector<uint8_t>& sessionId);
- void removeDrm(sp<DrmSessionClientInterface> drm);
+ void removeDrm(const sp<DrmSessionClientInterface>& drm);
bool reclaimSession(int callingPid);
protected:
diff --git a/include/media/ExtendedAudioBufferProvider.h b/include/media/ExtendedAudioBufferProvider.h
index 168ceed..51e4713 100644
--- a/include/media/ExtendedAudioBufferProvider.h
+++ b/include/media/ExtendedAudioBufferProvider.h
@@ -31,7 +31,7 @@
// Invoked by buffer consumer when a new timestamp is available.
// Default implementation ignores the timestamp.
- virtual void onTimestamp(const ExtendedTimestamp& timestamp) { }
+ virtual void onTimestamp(const ExtendedTimestamp& /*timestamp*/) { }
};
} // namespace android
diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h
index 0e9e3bc..f9dcbea 100644
--- a/include/media/IAudioPolicyService.h
+++ b/include/media/IAudioPolicyService.h
@@ -48,6 +48,9 @@
const char *device_name) = 0;
virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
const char *device_address) = 0;
+ virtual status_t handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name) = 0;
virtual status_t setPhoneState(audio_mode_t state) = 0;
virtual status_t setForceUse(audio_policy_force_use_t usage,
audio_policy_forced_cfg_t config) = 0;
@@ -160,7 +163,7 @@
virtual audio_mode_t getPhoneState() = 0;
- virtual status_t registerPolicyMixes(Vector<AudioMix> mixes, bool registration) = 0;
+ virtual status_t registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration) = 0;
virtual status_t startAudioSource(const struct audio_port_config *source,
const audio_attributes_t *attributes,
diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h
index 8266b0b..f21bb3a 100644
--- a/include/media/IMediaPlayerService.h
+++ b/include/media/IMediaPlayerService.h
@@ -32,7 +32,7 @@
namespace android {
struct IHDCP;
-struct IMediaCodecList;
+class IMediaCodecList;
struct IMediaHTTPService;
class IMediaRecorder;
class IOMX;
diff --git a/include/media/IMediaSource.h b/include/media/IMediaSource.h
index 2ff42ec..2bde782 100644
--- a/include/media/IMediaSource.h
+++ b/include/media/IMediaSource.h
@@ -98,7 +98,7 @@
SeekMode mSeekMode;
int64_t mLatenessUs;
bool mNonBlocking;
- };
+ } __attribute__((packed)); // sent through Binder
// Returns a new buffer of data. Call blocks until a
// buffer is available, an error is encountered or the end of the stream
diff --git a/include/media/IOMX.h b/include/media/IOMX.h
index 1c39b9c..ffa6d6d 100644
--- a/include/media/IOMX.h
+++ b/include/media/IOMX.h
@@ -261,7 +261,7 @@
protected:
// check if the codec is secure.
- virtual bool isSecure(IOMX::node_id node) {
+ virtual bool isSecure(IOMX::node_id /*node*/) {
return false;
}
};
diff --git a/include/media/MediaCodecInfo.h b/include/media/MediaCodecInfo.h
index 48d0407..6b50f22 100644
--- a/include/media/MediaCodecInfo.h
+++ b/include/media/MediaCodecInfo.h
@@ -74,7 +74,7 @@
DISALLOW_EVIL_CONSTRUCTORS(Capabilities);
- friend class MediaCodecInfo;
+ friend struct MediaCodecInfo;
};
// Use a subclass to allow setting fields on construction without allowing
@@ -136,7 +136,7 @@
DISALLOW_EVIL_CONSTRUCTORS(MediaCodecInfo);
- friend class MediaCodecList;
+ friend struct MediaCodecList;
friend class MediaCodecListOverridesTest;
};
diff --git a/include/media/MediaDefs.h b/include/media/MediaDefs.h
new file mode 100644
index 0000000..5f2a32d
--- /dev/null
+++ b/include/media/MediaDefs.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+#ifndef MEDIA_DEFS_H_
+
+#define MEDIA_DEFS_H_
+
+namespace android {
+
+extern const char *MEDIA_MIMETYPE_IMAGE_JPEG;
+
+extern const char *MEDIA_MIMETYPE_VIDEO_VP8;
+extern const char *MEDIA_MIMETYPE_VIDEO_VP9;
+extern const char *MEDIA_MIMETYPE_VIDEO_AVC;
+extern const char *MEDIA_MIMETYPE_VIDEO_HEVC;
+extern const char *MEDIA_MIMETYPE_VIDEO_MPEG4;
+extern const char *MEDIA_MIMETYPE_VIDEO_H263;
+extern const char *MEDIA_MIMETYPE_VIDEO_MPEG2;
+extern const char *MEDIA_MIMETYPE_VIDEO_RAW;
+extern const char *MEDIA_MIMETYPE_VIDEO_DOLBY_VISION;
+
+extern const char *MEDIA_MIMETYPE_AUDIO_AMR_NB;
+extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB;
+extern const char *MEDIA_MIMETYPE_AUDIO_MPEG; // layer III
+extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I;
+extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II;
+extern const char *MEDIA_MIMETYPE_AUDIO_MIDI;
+extern const char *MEDIA_MIMETYPE_AUDIO_AAC;
+extern const char *MEDIA_MIMETYPE_AUDIO_QCELP;
+extern const char *MEDIA_MIMETYPE_AUDIO_VORBIS;
+extern const char *MEDIA_MIMETYPE_AUDIO_OPUS;
+extern const char *MEDIA_MIMETYPE_AUDIO_G711_ALAW;
+extern const char *MEDIA_MIMETYPE_AUDIO_G711_MLAW;
+extern const char *MEDIA_MIMETYPE_AUDIO_RAW;
+extern const char *MEDIA_MIMETYPE_AUDIO_FLAC;
+extern const char *MEDIA_MIMETYPE_AUDIO_AAC_ADTS;
+extern const char *MEDIA_MIMETYPE_AUDIO_MSGSM;
+extern const char *MEDIA_MIMETYPE_AUDIO_AC3;
+extern const char *MEDIA_MIMETYPE_AUDIO_EAC3;
+
+extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4;
+extern const char *MEDIA_MIMETYPE_CONTAINER_WAV;
+extern const char *MEDIA_MIMETYPE_CONTAINER_OGG;
+extern const char *MEDIA_MIMETYPE_CONTAINER_MATROSKA;
+extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG2TS;
+extern const char *MEDIA_MIMETYPE_CONTAINER_AVI;
+extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG2PS;
+
+extern const char *MEDIA_MIMETYPE_CONTAINER_WVM;
+
+extern const char *MEDIA_MIMETYPE_TEXT_3GPP;
+extern const char *MEDIA_MIMETYPE_TEXT_SUBRIP;
+extern const char *MEDIA_MIMETYPE_TEXT_VTT;
+extern const char *MEDIA_MIMETYPE_TEXT_CEA_608;
+extern const char *MEDIA_MIMETYPE_TEXT_CEA_708;
+extern const char *MEDIA_MIMETYPE_DATA_TIMED_ID3;
+
+// These are values exported to JAVA API that need to be in sync with
+// frameworks/base/media/java/android/media/AudioFormat.java. Unfortunately,
+// they are not defined in frameworks/av, so defining them here.
+enum AudioEncoding {
+ kAudioEncodingPcm16bit = 2,
+ kAudioEncodingPcm8bit = 3,
+ kAudioEncodingPcmFloat = 4,
+};
+
+} // namespace android
+
+#endif // MEDIA_DEFS_H_
diff --git a/include/media/MediaMetadataRetrieverInterface.h b/include/media/MediaMetadataRetrieverInterface.h
index bce6ee3..a5e1350 100644
--- a/include/media/MediaMetadataRetrieverInterface.h
+++ b/include/media/MediaMetadataRetrieverInterface.h
@@ -54,9 +54,9 @@
MediaMetadataRetrieverInterface() {}
virtual ~MediaMetadataRetrieverInterface() {}
- virtual VideoFrame* getFrameAtTime(int64_t timeUs, int option) { return NULL; }
+ virtual VideoFrame* getFrameAtTime(int64_t /*timeUs*/, int /*option*/) { return NULL; }
virtual MediaAlbumArt* extractAlbumArt() { return NULL; }
- virtual const char* extractMetadata(int keyCode) { return NULL; }
+ virtual const char* extractMetadata(int /*keyCode*/) { return NULL; }
};
}; // namespace android
diff --git a/include/media/MediaRecorderBase.h b/include/media/MediaRecorderBase.h
index 5195993..42151ea 100644
--- a/include/media/MediaRecorderBase.h
+++ b/include/media/MediaRecorderBase.h
@@ -46,7 +46,7 @@
const sp<ICameraRecordingProxy>& proxy) = 0;
virtual status_t setPreviewSurface(const sp<IGraphicBufferProducer>& surface) = 0;
virtual status_t setOutputFile(int fd, int64_t offset, int64_t length) = 0;
- virtual status_t setOutputFileAuxiliary(int fd) {return INVALID_OPERATION;}
+ virtual status_t setOutputFileAuxiliary(int /*fd*/) {return INVALID_OPERATION;}
virtual status_t setParameters(const String8& params) = 0;
virtual status_t setListener(const sp<IMediaRecorderClient>& listener) = 0;
virtual status_t setClientName(const String16& clientName) = 0;
diff --git a/include/media/RingBuffer.h b/include/media/RingBuffer.h
index df7c00e..4d92d87 100644
--- a/include/media/RingBuffer.h
+++ b/include/media/RingBuffer.h
@@ -39,7 +39,7 @@
/**
* Construct a RingBuffer that can grow up to the given length.
*/
- RingBuffer(size_t length);
+ explicit RingBuffer(size_t length);
/**
* Forward iterator to this class. Implements an std:forward_iterator.
diff --git a/include/media/SharedLibrary.h b/include/media/SharedLibrary.h
index 88451a0..fd02203 100644
--- a/include/media/SharedLibrary.h
+++ b/include/media/SharedLibrary.h
@@ -24,7 +24,7 @@
namespace android {
class SharedLibrary : public RefBase {
public:
- SharedLibrary(const String8 &path);
+ explicit SharedLibrary(const String8 &path);
~SharedLibrary();
bool operator!() const;
diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h
index cec9d99..389ec01 100644
--- a/include/media/mediaplayer.h
+++ b/include/media/mediaplayer.h
@@ -30,7 +30,7 @@
#include <utils/KeyedVector.h>
#include <utils/String8.h>
-class ANativeWindow;
+struct ANativeWindow;
namespace android {
diff --git a/include/media/nbaio/NBAIO.h b/include/media/nbaio/NBAIO.h
index 120de4f..212f8e8 100644
--- a/include/media/nbaio/NBAIO.h
+++ b/include/media/nbaio/NBAIO.h
@@ -212,7 +212,7 @@
// Returns NO_ERROR if a timestamp is available. The timestamp includes the total number
// of frames presented to an external observer, together with the value of CLOCK_MONOTONIC
// as of this presentation count. The timestamp parameter is undefined if error is returned.
- virtual status_t getTimestamp(ExtendedTimestamp ×tamp) { return INVALID_OPERATION; }
+ virtual status_t getTimestamp(ExtendedTimestamp& /*timestamp*/) { return INVALID_OPERATION; }
protected:
NBAIO_Sink(const NBAIO_Format& format = Format_Invalid) : NBAIO_Port(format), mFramesWritten(0)
@@ -299,7 +299,7 @@
// Invoked asynchronously by corresponding sink when a new timestamp is available.
// Default implementation ignores the timestamp.
- virtual void onTimestamp(const ExtendedTimestamp& timestamp) { }
+ virtual void onTimestamp(const ExtendedTimestamp& /*timestamp*/) { }
protected:
NBAIO_Source(const NBAIO_Format& format = Format_Invalid) : NBAIO_Port(format), mFramesRead(0)
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index 25f7173..3379d1a 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -35,7 +35,7 @@
namespace android {
struct ABuffer;
-struct MemoryDealer;
+class MemoryDealer;
struct DescribeColorFormat2Params;
struct DataConverter;
@@ -94,10 +94,6 @@
DISALLOW_EVIL_CONSTRUCTORS(PortDescription);
};
- static bool isFlexibleColorFormat(
- const sp<IOMX> &omx, IOMX::node_id node,
- uint32_t colorFormat, bool usingNativeBuffers, OMX_U32 *flexibleEquivalent);
-
// Returns 0 if configuration is not supported. NOTE: this is treated by
// some OMX components as auto level, and by others as invalid level.
static int /* OMX_VIDEO_AVCLEVELTYPE */ getAVCLevelFor(
@@ -238,6 +234,7 @@
sp<IdleToLoadedState> mIdleToLoadedState;
sp<FlushingState> mFlushingState;
sp<SkipCutBuffer> mSkipCutBuffer;
+ int32_t mSampleRate;
AString mComponentName;
uint32_t mFlags;
@@ -341,9 +338,6 @@
ssize_t *index = NULL);
status_t setComponentRole(bool isEncoder, const char *mime);
- static const char *getComponentRole(bool isEncoder, const char *mime);
- static status_t setComponentRole(
- const sp<IOMX> &omx, IOMX::node_id node, const char *role);
status_t configureCodec(const char *mime, const sp<AMessage> &msg);
@@ -551,11 +545,6 @@
OMX_ERRORTYPE error = OMX_ErrorUndefined,
status_t internalError = UNKNOWN_ERROR);
- static bool describeDefaultColorFormat(DescribeColorFormat2Params &describeParams);
- static bool describeColorFormat(
- const sp<IOMX> &omx, IOMX::node_id node,
- DescribeColorFormat2Params &describeParams);
-
status_t requestIDRFrame();
status_t setParameters(const sp<AMessage> ¶ms);
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index c2e75a6..c604f2d 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -216,10 +216,10 @@
// Returns true if need to skip the current frame.
// Called from dataCallbackTimestamp.
- virtual bool skipCurrentFrame(int64_t timestampUs) {return false;}
+ virtual bool skipCurrentFrame(int64_t /*timestampUs*/) {return false;}
// Callback called when still camera raw data is available.
- virtual void dataCallback(int32_t msgType, const sp<IMemory> &data) {}
+ virtual void dataCallback(int32_t /*msgType*/, const sp<IMemory>& /*data*/) {}
virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType,
const sp<IMemory> &data);
diff --git a/include/media/stagefright/CodecBase.h b/include/media/stagefright/CodecBase.h
index be2835d..e057075 100644
--- a/include/media/stagefright/CodecBase.h
+++ b/include/media/stagefright/CodecBase.h
@@ -73,10 +73,10 @@
virtual void onMessageReceived(const sp<AMessage> &msg) = 0;
virtual status_t queryCapabilities(
- const AString &name, const AString &mime, bool isEncoder,
- sp<MediaCodecInfo::Capabilities> *caps /* nonnull */) { return INVALID_OPERATION; }
+ const AString& /*name*/, const AString& /*mime*/, bool /*isEncoder*/,
+ sp<MediaCodecInfo::Capabilities>* /*caps*/ /* nonnull */) { return INVALID_OPERATION; }
- virtual status_t setSurface(const sp<Surface> &surface) { return INVALID_OPERATION; }
+ virtual status_t setSurface(const sp<Surface>& /*surface*/) { return INVALID_OPERATION; }
virtual void signalFlush() = 0;
virtual void signalResume() = 0;
@@ -89,8 +89,8 @@
virtual size_t countBuffers() = 0;
virtual IOMX::buffer_id bufferIDAt(size_t index) const = 0;
virtual sp<ABuffer> bufferAt(size_t index) const = 0;
- virtual sp<NativeHandle> handleAt(size_t index) const { return NULL; };
- virtual sp<RefBase> memRefAt(size_t index) const { return NULL; }
+ virtual sp<NativeHandle> handleAt(size_t /*index*/) const { return NULL; };
+ virtual sp<RefBase> memRefAt(size_t /*index*/) const { return NULL; }
protected:
PortDescription();
diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h
index 0254545..ca21719 100644
--- a/include/media/stagefright/DataSource.h
+++ b/include/media/stagefright/DataSource.h
@@ -96,7 +96,7 @@
return String8("<unspecified>");
}
- virtual status_t reconnectAtOffset(off64_t offset) {
+ virtual status_t reconnectAtOffset(off64_t /*offset*/) {
return ERROR_UNSUPPORTED;
}
@@ -114,10 +114,10 @@
static void RegisterDefaultSniffers();
// for DRM
- virtual sp<DecryptHandle> DrmInitialization(const char *mime = NULL) {
+ virtual sp<DecryptHandle> DrmInitialization(const char * /*mime*/ = NULL) {
return NULL;
}
- virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client) {};
+ virtual void getDrmInfo(sp<DecryptHandle> &/*handle*/, DrmManagerClient ** /*client*/) {};
virtual String8 getUri() {
return String8();
@@ -165,7 +165,7 @@
if (numBytesRead == -1) { // If readAt() returns -1, there is an error.
return false;
}
- if (numBytesRead < numBytesPerChunk) {
+ if (static_cast<size_t>(numBytesRead) < numBytesPerChunk) {
// This case is triggered when the stream ends before the whole
// chunk is read.
x->appendArray(tmp, (size_t)numBytesRead / sizeof(T));
diff --git a/include/media/stagefright/FrameRenderTracker.h b/include/media/stagefright/FrameRenderTracker.h
index 9333e8f..327d260 100644
--- a/include/media/stagefright/FrameRenderTracker.h
+++ b/include/media/stagefright/FrameRenderTracker.h
@@ -32,7 +32,7 @@
class Fence;
class GraphicBuffer;
-struct FrameRenderTracker : public RefBase {
+struct FrameRenderTracker {
// Tracks the render information about a frame. Frames go through several states while
// the render information is tracked:
//
@@ -82,7 +82,7 @@
sp<GraphicBuffer> mGraphicBuffer;
sp<Fence> mFence;
- friend class FrameRenderTracker;
+ friend struct FrameRenderTracker;
};
FrameRenderTracker();
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h
index 8f0eaa7..a8ba095 100644
--- a/include/media/stagefright/MPEG4Writer.h
+++ b/include/media/stagefright/MPEG4Writer.h
@@ -27,7 +27,7 @@
namespace android {
-class AMessage;
+struct AMessage;
class MediaBuffer;
class MetaData;
diff --git a/include/media/stagefright/MediaBuffer.h b/include/media/stagefright/MediaBuffer.h
index a61ddaa..e74410d 100644
--- a/include/media/stagefright/MediaBuffer.h
+++ b/include/media/stagefright/MediaBuffer.h
@@ -56,11 +56,11 @@
// The underlying data remains the responsibility of the caller!
MediaBuffer(void *data, size_t size);
- MediaBuffer(size_t size);
+ explicit MediaBuffer(size_t size);
- MediaBuffer(const sp<GraphicBuffer>& graphicBuffer);
+ explicit MediaBuffer(const sp<GraphicBuffer>& graphicBuffer);
- MediaBuffer(const sp<ABuffer> &buffer);
+ explicit MediaBuffer(const sp<ABuffer> &buffer);
MediaBuffer(const sp<IMemory> &mem) :
MediaBuffer((uint8_t *)mem->pointer() + sizeof(SharedControl), mem->size()) {
@@ -223,7 +223,7 @@
// Caution: atomic_int_fast32_t is 64 bits on LP64.
std::atomic_int_least32_t mFlags;
std::atomic_int_least32_t mRemoteRefcount;
- int32_t unused[6]; // additional buffer space
+ int32_t unused[6] __attribute__((__unused__)); // additional buffer space
};
inline SharedControl *getSharedControl() const {
diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h
index fe579b7..d18aad8 100644
--- a/include/media/stagefright/MediaCodec.h
+++ b/include/media/stagefright/MediaCodec.h
@@ -33,15 +33,15 @@
struct AReplyToken;
struct AString;
struct CodecBase;
-struct IBatteryStats;
+class IBatteryStats;
struct ICrypto;
class IMemory;
-struct MemoryDealer;
+class MemoryDealer;
class IResourceManagerClient;
class IResourceManagerService;
struct PersistentSurface;
-struct SoftwareRenderer;
-struct Surface;
+class SoftwareRenderer;
+class Surface;
struct MediaCodec : public AHandler {
enum ConfigureFlags {
@@ -175,7 +175,7 @@
// by adding rendered frame information to a base notification message. Returns the number
// of frames that were rendered.
static size_t CreateFramesRenderedMessage(
- std::list<FrameRenderTracker::Info> done, sp<AMessage> &msg);
+ const std::list<FrameRenderTracker::Info> &done, sp<AMessage> &msg);
protected:
virtual ~MediaCodec();
@@ -274,7 +274,7 @@
void addResource(
int64_t clientId,
- const sp<IResourceManagerClient> client,
+ const sp<IResourceManagerClient> &client,
const Vector<MediaResource> &resources);
void removeResource(int64_t clientId);
diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.h
index 5f2a32d..359fb69 100644
--- a/include/media/stagefright/MediaDefs.h
+++ b/include/media/stagefright/MediaDefs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 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.
@@ -14,69 +14,18 @@
* limitations under the License.
*/
-#ifndef MEDIA_DEFS_H_
-#define MEDIA_DEFS_H_
+#ifndef STAGEFRIGHT_MEDIA_DEFS_H_
+#define STAGEFRIGHT_MEDIA_DEFS_H_
-namespace android {
+/*
+ * Please, DO NOT USE!
+ *
+ * This file is here only for legacy reasons. Instead, include directly
+ * the header below.
+ *
+ */
-extern const char *MEDIA_MIMETYPE_IMAGE_JPEG;
+#include <media/MediaDefs.h>
-extern const char *MEDIA_MIMETYPE_VIDEO_VP8;
-extern const char *MEDIA_MIMETYPE_VIDEO_VP9;
-extern const char *MEDIA_MIMETYPE_VIDEO_AVC;
-extern const char *MEDIA_MIMETYPE_VIDEO_HEVC;
-extern const char *MEDIA_MIMETYPE_VIDEO_MPEG4;
-extern const char *MEDIA_MIMETYPE_VIDEO_H263;
-extern const char *MEDIA_MIMETYPE_VIDEO_MPEG2;
-extern const char *MEDIA_MIMETYPE_VIDEO_RAW;
-extern const char *MEDIA_MIMETYPE_VIDEO_DOLBY_VISION;
-
-extern const char *MEDIA_MIMETYPE_AUDIO_AMR_NB;
-extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB;
-extern const char *MEDIA_MIMETYPE_AUDIO_MPEG; // layer III
-extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I;
-extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II;
-extern const char *MEDIA_MIMETYPE_AUDIO_MIDI;
-extern const char *MEDIA_MIMETYPE_AUDIO_AAC;
-extern const char *MEDIA_MIMETYPE_AUDIO_QCELP;
-extern const char *MEDIA_MIMETYPE_AUDIO_VORBIS;
-extern const char *MEDIA_MIMETYPE_AUDIO_OPUS;
-extern const char *MEDIA_MIMETYPE_AUDIO_G711_ALAW;
-extern const char *MEDIA_MIMETYPE_AUDIO_G711_MLAW;
-extern const char *MEDIA_MIMETYPE_AUDIO_RAW;
-extern const char *MEDIA_MIMETYPE_AUDIO_FLAC;
-extern const char *MEDIA_MIMETYPE_AUDIO_AAC_ADTS;
-extern const char *MEDIA_MIMETYPE_AUDIO_MSGSM;
-extern const char *MEDIA_MIMETYPE_AUDIO_AC3;
-extern const char *MEDIA_MIMETYPE_AUDIO_EAC3;
-
-extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4;
-extern const char *MEDIA_MIMETYPE_CONTAINER_WAV;
-extern const char *MEDIA_MIMETYPE_CONTAINER_OGG;
-extern const char *MEDIA_MIMETYPE_CONTAINER_MATROSKA;
-extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG2TS;
-extern const char *MEDIA_MIMETYPE_CONTAINER_AVI;
-extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG2PS;
-
-extern const char *MEDIA_MIMETYPE_CONTAINER_WVM;
-
-extern const char *MEDIA_MIMETYPE_TEXT_3GPP;
-extern const char *MEDIA_MIMETYPE_TEXT_SUBRIP;
-extern const char *MEDIA_MIMETYPE_TEXT_VTT;
-extern const char *MEDIA_MIMETYPE_TEXT_CEA_608;
-extern const char *MEDIA_MIMETYPE_TEXT_CEA_708;
-extern const char *MEDIA_MIMETYPE_DATA_TIMED_ID3;
-
-// These are values exported to JAVA API that need to be in sync with
-// frameworks/base/media/java/android/media/AudioFormat.java. Unfortunately,
-// they are not defined in frameworks/av, so defining them here.
-enum AudioEncoding {
- kAudioEncodingPcm16bit = 2,
- kAudioEncodingPcm8bit = 3,
- kAudioEncodingPcmFloat = 4,
-};
-
-} // namespace android
-
-#endif // MEDIA_DEFS_H_
+#endif // STAGEFRIGHT_MEDIA_DEFS_H_
diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h
index 6bf8c9e..f383e72 100644
--- a/include/media/stagefright/MediaExtractor.h
+++ b/include/media/stagefright/MediaExtractor.h
@@ -24,7 +24,7 @@
namespace android {
class DataSource;
-class MediaSource;
+struct MediaSource;
class MetaData;
class MediaExtractor : public BnMediaExtractor {
@@ -65,10 +65,10 @@
bool getDrmFlag() {
return mIsDrm;
}
- virtual char* getDrmTrackInfo(size_t trackID, int *len) {
+ virtual char* getDrmTrackInfo(size_t /*trackID*/, int * /*len*/) {
return NULL;
}
- virtual void setUID(uid_t uid) {
+ virtual void setUID(uid_t /*uid*/) {
}
virtual const char * name() { return "<unspecified>"; }
diff --git a/include/media/stagefright/MediaFilter.h b/include/media/stagefright/MediaFilter.h
index d0a572c..5725f88 100644
--- a/include/media/stagefright/MediaFilter.h
+++ b/include/media/stagefright/MediaFilter.h
@@ -23,7 +23,7 @@
struct ABuffer;
struct GraphicBufferListener;
-struct MemoryDealer;
+class MemoryDealer;
struct SimpleFilter;
struct MediaFilter : public CodecBase {
diff --git a/include/media/stagefright/MediaWriter.h b/include/media/stagefright/MediaWriter.h
index b6476c9..2b19523 100644
--- a/include/media/stagefright/MediaWriter.h
+++ b/include/media/stagefright/MediaWriter.h
@@ -44,11 +44,11 @@
mListener = listener;
}
- virtual status_t dump(int fd, const Vector<String16>& args) {
+ virtual status_t dump(int /*fd*/, const Vector<String16>& /*args*/) {
return OK;
}
- virtual void setStartTimeOffsetMs(int ms) {}
+ virtual void setStartTimeOffsetMs(int /*ms*/) {}
virtual int32_t getStartTimeOffsetMs() const { return 0; }
protected:
diff --git a/include/media/stagefright/NuMediaExtractor.h b/include/media/stagefright/NuMediaExtractor.h
index 03e2185..dd31447 100644
--- a/include/media/stagefright/NuMediaExtractor.h
+++ b/include/media/stagefright/NuMediaExtractor.h
@@ -34,7 +34,7 @@
class DataSource;
struct IMediaHTTPService;
class MediaBuffer;
-struct MediaExtractor;
+class MediaExtractor;
struct MediaSource;
class MetaData;
diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h
index ca3a3bf..2c11e84 100644
--- a/include/media/stagefright/SurfaceMediaSource.h
+++ b/include/media/stagefright/SurfaceMediaSource.h
@@ -107,8 +107,8 @@
void setFrameAvailableListener(const sp<FrameAvailableListener>& listener);
// dump our state in a String
- void dump(String8& result) const;
- void dump(String8& result, const char* prefix, char* buffer,
+ void dumpState(String8& result) const;
+ void dumpState(String8& result, const char* prefix, char* buffer,
size_t SIZE) const;
// metaDataStoredInVideoBuffers tells the encoder what kind of metadata
diff --git a/include/media/stagefright/Utils.h b/include/media/stagefright/Utils.h
index 01b3e3f..8eff914 100644
--- a/include/media/stagefright/Utils.h
+++ b/include/media/stagefright/Utils.h
@@ -28,7 +28,7 @@
namespace android {
#define FOURCC(c1, c2, c3, c4) \
- (c1 << 24 | c2 << 16 | c3 << 8 | c4)
+ ((c1) << 24 | (c2) << 16 | (c3) << 8 | (c4))
uint16_t U16_AT(const uint8_t *ptr);
uint32_t U32_AT(const uint8_t *ptr);
@@ -75,7 +75,7 @@
int64_t mTimeUs;
sp<AMessage> mMeta;
- HLSTime(const sp<AMessage> &meta = NULL);
+ explicit HLSTime(const sp<AMessage> &meta = NULL);
int64_t getSegmentTimeUs() const;
};
@@ -83,10 +83,10 @@
// read and write various object to/from AMessage
-void writeToAMessage(sp<AMessage> msg, const AudioPlaybackRate &rate);
+void writeToAMessage(const sp<AMessage> &msg, const AudioPlaybackRate &rate);
void readFromAMessage(const sp<AMessage> &msg, AudioPlaybackRate *rate /* nonnull */);
-void writeToAMessage(sp<AMessage> msg, const AVSyncSettings &sync, float videoFpsHint);
+void writeToAMessage(const sp<AMessage> &msg, const AVSyncSettings &sync, float videoFpsHint);
void readFromAMessage(
const sp<AMessage> &msg, AVSyncSettings *sync /* nonnull */, float *videoFps /* nonnull */);
diff --git a/include/media/stagefright/foundation/ABase.h b/include/media/stagefright/foundation/ABase.h
index ef1e010..76a787e 100644
--- a/include/media/stagefright/foundation/ABase.h
+++ b/include/media/stagefright/foundation/ABase.h
@@ -24,7 +24,7 @@
#define DISALLOW_EVIL_CONSTRUCTORS(name) \
name(const name &); \
- name &operator=(const name &)
+ name &operator=(const name &) /* NOLINT */
/* Returns true if the size parameter is safe for new array allocation (32-bit)
*
diff --git a/include/media/stagefright/foundation/ABuffer.h b/include/media/stagefright/foundation/ABuffer.h
index dc9c778..ef11434 100644
--- a/include/media/stagefright/foundation/ABuffer.h
+++ b/include/media/stagefright/foundation/ABuffer.h
@@ -30,7 +30,7 @@
class MediaBufferBase;
struct ABuffer : public RefBase {
- ABuffer(size_t capacity);
+ explicit ABuffer(size_t capacity);
ABuffer(void *data, size_t capacity);
uint8_t *base() { return (uint8_t *)mData; }
diff --git a/include/media/stagefright/foundation/ADebug.h b/include/media/stagefright/foundation/ADebug.h
index 564b3f7..bc1acdc 100644
--- a/include/media/stagefright/foundation/ADebug.h
+++ b/include/media/stagefright/foundation/ADebug.h
@@ -53,6 +53,9 @@
#define LITERAL_TO_STRING_INTERNAL(x) #x
#define LITERAL_TO_STRING(x) LITERAL_TO_STRING_INTERNAL(x)
+#ifdef CHECK
+#undef CHECK
+#endif
#define CHECK(condition) \
LOG_ALWAYS_FATAL_IF( \
!(condition), \
@@ -92,6 +95,15 @@
} \
} while (false)
+#ifdef CHECK_EQ
+#undef CHECK_EQ
+#undef CHECK_NE
+#undef CHECK_LE
+#undef CHECK_LT
+#undef CHECK_GE
+#undef CHECK_GT
+#endif
+
#define CHECK_EQ(x,y) CHECK_OP(x,y,EQ,==)
#define CHECK_NE(x,y) CHECK_OP(x,y,NE,!=)
#define CHECK_LE(x,y) CHECK_OP(x,y,LE,<=)
diff --git a/include/media/stagefright/foundation/AHandler.h b/include/media/stagefright/foundation/AHandler.h
index fe02a86..53d8a9b 100644
--- a/include/media/stagefright/foundation/AHandler.h
+++ b/include/media/stagefright/foundation/AHandler.h
@@ -60,7 +60,7 @@
ALooper::handler_id mID;
wp<ALooper> mLooper;
- inline void setID(ALooper::handler_id id, wp<ALooper> looper) {
+ inline void setID(ALooper::handler_id id, const wp<ALooper> &looper) {
mID = id;
mLooper = looper;
}
diff --git a/include/media/stagefright/foundation/ALooperRoster.h b/include/media/stagefright/foundation/ALooperRoster.h
index 9912455..5873e68 100644
--- a/include/media/stagefright/foundation/ALooperRoster.h
+++ b/include/media/stagefright/foundation/ALooperRoster.h
@@ -28,7 +28,7 @@
ALooperRoster();
ALooper::handler_id registerHandler(
- const sp<ALooper> looper, const sp<AHandler> &handler);
+ const sp<ALooper> &looper, const sp<AHandler> &handler);
void unregisterHandler(ALooper::handler_id handlerID);
void unregisterStaleHandlers();
diff --git a/include/media/stagefright/foundation/AMessage.h b/include/media/stagefright/foundation/AMessage.h
index 4b2b868..782f8e6 100644
--- a/include/media/stagefright/foundation/AMessage.h
+++ b/include/media/stagefright/foundation/AMessage.h
@@ -31,7 +31,7 @@
class Parcel;
struct AReplyToken : public RefBase {
- AReplyToken(const sp<ALooper> &looper)
+ explicit AReplyToken(const sp<ALooper> &looper)
: mLooper(looper),
mReplied(false) {
}
diff --git a/include/media/stagefright/foundation/AString.h b/include/media/stagefright/foundation/AString.h
index 2f6d532..ff086b3 100644
--- a/include/media/stagefright/foundation/AString.h
+++ b/include/media/stagefright/foundation/AString.h
@@ -28,9 +28,9 @@
struct AString {
AString();
- AString(const char *s);
+ AString(const char *s); // NOLINT, implicit conversion
AString(const char *s, size_t size);
- AString(const String8 &from);
+ AString(const String8 &from); // NOLINT, implicit conversion
AString(const AString &from);
AString(const AString &from, size_t offset, size_t n);
~AString();
diff --git a/include/media/stagefright/foundation/AWakeLock.h b/include/media/stagefright/foundation/AWakeLock.h
index 57716c1..323e7d7 100644
--- a/include/media/stagefright/foundation/AWakeLock.h
+++ b/include/media/stagefright/foundation/AWakeLock.h
@@ -43,7 +43,7 @@
class PMDeathRecipient : public IBinder::DeathRecipient {
public:
- PMDeathRecipient(AWakeLock *wakeLock) : mWakeLock(wakeLock) {}
+ explicit PMDeathRecipient(AWakeLock *wakeLock) : mWakeLock(wakeLock) {}
virtual ~PMDeathRecipient() {}
// IBinder::DeathRecipient
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index 7becf57..9da5ef3 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -172,7 +172,7 @@
// client write-only, server read-only
uint16_t mSendLevel; // Fixed point U4.12 so 0x1000 means 1.0
- uint16_t mPad2; // unused
+ uint16_t mPad2 __attribute__((__unused__)); // unused
// server write-only, client read
ExtendedTimestampQueue::Shared mExtendedTimestampQueue;
diff --git a/include/private/media/VideoFrame.h b/include/private/media/VideoFrame.h
index 5193d00..51050cd 100644
--- a/include/private/media/VideoFrame.h
+++ b/include/private/media/VideoFrame.h
@@ -30,8 +30,8 @@
class VideoFrame
{
public:
- VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0), mData(0),
- mRotationAngle(0) {}
+ VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0),
+ mRotationAngle(0), mData(0) {}
VideoFrame(const VideoFrame& copy) {
mWidth = copy.mWidth;
diff --git a/include/radio/Radio.h b/include/radio/Radio.h
index a4dfdd1..fb4dd2f 100644
--- a/include/radio/Radio.h
+++ b/include/radio/Radio.h
@@ -79,7 +79,6 @@
Mutex mLock;
sp<IRadio> mIRadio;
- const radio_handle_t mHandle;
sp<RadioCallback> mCallback;
};
diff --git a/include/soundtrigger/SoundTrigger.h b/include/soundtrigger/SoundTrigger.h
index 9a05cac..7a29e31 100644
--- a/include/soundtrigger/SoundTrigger.h
+++ b/include/soundtrigger/SoundTrigger.h
@@ -72,7 +72,6 @@
Mutex mLock;
sp<ISoundTrigger> mISoundTrigger;
- const sound_trigger_module_handle_t mModule;
sp<SoundTriggerCallback> mCallback;
};
diff --git a/media/audioserver/Android.mk b/media/audioserver/Android.mk
index 5ce1798..c620e7c 100644
--- a/media/audioserver/Android.mk
+++ b/media/audioserver/Android.mk
@@ -11,9 +11,7 @@
libbinder \
libcutils \
liblog \
- libmedia \
libmedialogservice \
- libnbaio \
libradioservice \
libsoundtriggerservice \
libutils
diff --git a/media/common_time/ICommonClock.cpp b/media/common_time/ICommonClock.cpp
index 19b7d6e..f1f1fca 100644
--- a/media/common_time/ICommonClock.cpp
+++ b/media/common_time/ICommonClock.cpp
@@ -48,7 +48,7 @@
class BpCommonClock : public BpInterface<ICommonClock>
{
public:
- BpCommonClock(const sp<IBinder>& impl)
+ explicit BpCommonClock(const sp<IBinder>& impl)
: BpInterface<ICommonClock>(impl) {}
virtual status_t isCommonTimeValid(bool* valid, uint32_t* timelineID) {
@@ -401,7 +401,7 @@
class BpCommonClockListener : public BpInterface<ICommonClockListener>
{
public:
- BpCommonClockListener(const sp<IBinder>& impl)
+ explicit BpCommonClockListener(const sp<IBinder>& impl)
: BpInterface<ICommonClockListener>(impl) {}
virtual void onTimelineChanged(uint64_t timelineID) {
diff --git a/media/common_time/ICommonTimeConfig.cpp b/media/common_time/ICommonTimeConfig.cpp
index 67167b0..e587b39 100644
--- a/media/common_time/ICommonTimeConfig.cpp
+++ b/media/common_time/ICommonTimeConfig.cpp
@@ -50,7 +50,7 @@
class BpCommonTimeConfig : public BpInterface<ICommonTimeConfig>
{
public:
- BpCommonTimeConfig(const sp<IBinder>& impl)
+ explicit BpCommonTimeConfig(const sp<IBinder>& impl)
: BpInterface<ICommonTimeConfig>(impl) {}
virtual status_t getMasterElectionPriority(uint8_t *priority) {
diff --git a/media/common_time/cc_helper.cpp b/media/common_time/cc_helper.cpp
index 222b7ce..6a7de74 100644
--- a/media/common_time/cc_helper.cpp
+++ b/media/common_time/cc_helper.cpp
@@ -80,7 +80,7 @@
}
}
-void CCHelper::CommonClockListener::onTimelineChanged(uint64_t timelineID __unused) {
+void CCHelper::CommonClockListener::onTimelineChanged(uint64_t /*timelineID*/) {
// do nothing; listener is only really used as a token so the server can
// find out when clients die.
}
diff --git a/media/img_utils/Android.bp b/media/img_utils/Android.bp
new file mode 100644
index 0000000..64530e1
--- /dev/null
+++ b/media/img_utils/Android.bp
@@ -0,0 +1,60 @@
+// Copyright 2014 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.
+
+cc_library_shared {
+ name: "libimg_utils",
+
+ srcs: [
+ "src/EndianUtils.cpp",
+ "src/FileInput.cpp",
+ "src/FileOutput.cpp",
+ "src/SortedEntryVector.cpp",
+ "src/Input.cpp",
+ "src/Output.cpp",
+ "src/Orderable.cpp",
+ "src/TiffIfd.cpp",
+ "src/TiffWritable.cpp",
+ "src/TiffWriter.cpp",
+ "src/TiffEntry.cpp",
+ "src/TiffEntryImpl.cpp",
+ "src/ByteArrayOutput.cpp",
+ "src/DngUtils.cpp",
+ "src/StripSource.cpp",
+ ],
+
+ shared_libs: [
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-fvisibility=hidden",
+ ],
+
+ product_variables: {
+ debuggable: {
+ // Enable assert() in eng builds
+ cflags: [
+ "-UNDEBUG",
+ "-DLOG_NDEBUG=1",
+ ],
+ },
+ },
+
+ export_include_dirs: ["include"],
+}
diff --git a/media/img_utils/Android.mk b/media/img_utils/Android.mk
deleted file mode 100644
index 1cd00bd..0000000
--- a/media/img_utils/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2014 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.
-
-include $(call all-subdir-makefiles)
diff --git a/media/img_utils/include/img_utils/EndianUtils.h b/media/img_utils/include/img_utils/EndianUtils.h
index e99be1a..bfa42e9 100644
--- a/media/img_utils/include/img_utils/EndianUtils.h
+++ b/media/img_utils/include/img_utils/EndianUtils.h
@@ -58,7 +58,7 @@
* Wrap the given Output. Calling write methods will result in
* writes to this output.
*/
- EndianOutput(Output* out, Endianness end=LITTLE);
+ explicit EndianOutput(Output* out, Endianness end=LITTLE);
virtual ~EndianOutput();
diff --git a/media/img_utils/include/img_utils/FileInput.h b/media/img_utils/include/img_utils/FileInput.h
index 4d4f22b..66afaff 100644
--- a/media/img_utils/include/img_utils/FileInput.h
+++ b/media/img_utils/include/img_utils/FileInput.h
@@ -36,7 +36,7 @@
/**
* Create a file input for the given path.
*/
- FileInput(String8 path);
+ explicit FileInput(String8 path);
virtual ~FileInput();
diff --git a/media/img_utils/include/img_utils/FileOutput.h b/media/img_utils/include/img_utils/FileOutput.h
index fd5be27..3d4cf76 100644
--- a/media/img_utils/include/img_utils/FileOutput.h
+++ b/media/img_utils/include/img_utils/FileOutput.h
@@ -29,7 +29,7 @@
class ANDROID_API FileOutput : public Output {
public:
- FileOutput(String8 path);
+ explicit FileOutput(String8 path);
virtual ~FileOutput();
virtual status_t open();
virtual status_t write(const uint8_t* buf, size_t offset, size_t count);
diff --git a/media/img_utils/include/img_utils/TiffHelpers.h b/media/img_utils/include/img_utils/TiffHelpers.h
index 0969e4d..3e5f863 100644
--- a/media/img_utils/include/img_utils/TiffHelpers.h
+++ b/media/img_utils/include/img_utils/TiffHelpers.h
@@ -25,7 +25,7 @@
const uint8_t ZERO_WORD[] = {0, 0, 0, 0};
#define BAIL_ON_FAIL(x, flag) \
- if ((flag = (x)) != OK) return flag;
+ if (((flag) = (x)) != OK) return flag;
#define BYTES_TILL_WORD(index) \
((TIFF_WORD_SIZE - ((index) % TIFF_WORD_SIZE)) % TIFF_WORD_SIZE)
diff --git a/media/img_utils/include/img_utils/TiffIfd.h b/media/img_utils/include/img_utils/TiffIfd.h
index 51b5c9a..2d8e91f 100644
--- a/media/img_utils/include/img_utils/TiffIfd.h
+++ b/media/img_utils/include/img_utils/TiffIfd.h
@@ -42,7 +42,7 @@
*/
class ANDROID_API TiffIfd : public TiffWritable {
public:
- TiffIfd(uint32_t ifdId);
+ explicit TiffIfd(uint32_t ifdId);
virtual ~TiffIfd();
/**
diff --git a/media/img_utils/src/Android.mk b/media/img_utils/src/Android.mk
deleted file mode 100644
index 4074849..0000000
--- a/media/img_utils/src/Android.mk
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2014 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- EndianUtils.cpp \
- FileInput.cpp \
- FileOutput.cpp \
- SortedEntryVector.cpp \
- Input.cpp \
- Output.cpp \
- Orderable.cpp \
- TiffIfd.cpp \
- TiffWritable.cpp \
- TiffWriter.cpp \
- TiffEntry.cpp \
- TiffEntryImpl.cpp \
- ByteArrayOutput.cpp \
- DngUtils.cpp \
- StripSource.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libexpat \
- libutils \
- libcutils \
- libcamera_metadata \
- libcamera_client
-
-LOCAL_C_INCLUDES += \
- $(LOCAL_PATH)/../include \
- system/media/camera/include
-
-LOCAL_CFLAGS += \
- -Wall \
- -Wextra \
- -Werror \
- -fvisibility=hidden
-
-ifneq ($(filter userdebug eng,$(TARGET_BUILD_VARIANT)),)
- # Enable assert() in eng builds
- LOCAL_CFLAGS += -UNDEBUG -DLOG_NDEBUG=1
-endif
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include
-
-LOCAL_MODULE := libimg_utils
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/img_utils/src/TiffWriter.cpp b/media/img_utils/src/TiffWriter.cpp
index a6f9218..564474f 100644
--- a/media/img_utils/src/TiffWriter.cpp
+++ b/media/img_utils/src/TiffWriter.cpp
@@ -40,7 +40,7 @@
}
#define ARRAY_SIZE(array) \
- (sizeof(array) / sizeof(array[0]))
+ (sizeof(array) / sizeof((array)[0]))
KeyedVector<uint16_t, const TagDefinition_t*> TiffWriter::sTagMaps[] = {
buildTagMap(TIFF_EP_TAG_DEFINITIONS, ARRAY_SIZE(TIFF_EP_TAG_DEFINITIONS)),
diff --git a/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
new file mode 100644
index 0000000..d5c9217
--- /dev/null
+++ b/media/libaudioclient/Android.bp
@@ -0,0 +1,44 @@
+cc_library_shared {
+ name: "libaudioclient",
+ srcs: [
+ "AudioEffect.cpp",
+ "AudioPolicy.cpp",
+ "AudioRecord.cpp",
+ "AudioSystem.cpp",
+ "AudioTrack.cpp",
+ "AudioTrackShared.cpp",
+ "IAudioFlinger.cpp",
+ "IAudioFlingerClient.cpp",
+ "IAudioPolicyService.cpp",
+ "IAudioPolicyServiceClient.cpp",
+ "IAudioRecord.cpp",
+ "IAudioTrack.cpp",
+ "IEffect.cpp",
+ "IEffectClient.cpp",
+ "ToneGenerator.cpp",
+ ],
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ "libutils",
+ "libbinder",
+ "libdl",
+ "libaudioutils",
+ ],
+ export_shared_lib_headers: ["libbinder"],
+ // for memory heap analysis
+ static_libs: [
+ "libc_malloc_debug_backtrace",
+ ],
+ cflags: [
+ "-Werror",
+ "-Wno-error=deprecated-declarations",
+ "-Wall",
+ ],
+ sanitize: {
+ misc_undefined : [
+ "unsigned-integer-overflow",
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libmedia/AudioEffect.cpp b/media/libaudioclient/AudioEffect.cpp
similarity index 100%
rename from media/libmedia/AudioEffect.cpp
rename to media/libaudioclient/AudioEffect.cpp
diff --git a/media/libmedia/AudioPolicy.cpp b/media/libaudioclient/AudioPolicy.cpp
similarity index 100%
rename from media/libmedia/AudioPolicy.cpp
rename to media/libaudioclient/AudioPolicy.cpp
diff --git a/media/libmedia/AudioRecord.cpp b/media/libaudioclient/AudioRecord.cpp
similarity index 100%
rename from media/libmedia/AudioRecord.cpp
rename to media/libaudioclient/AudioRecord.cpp
diff --git a/media/libmedia/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
similarity index 98%
rename from media/libmedia/AudioSystem.cpp
rename to media/libaudioclient/AudioSystem.cpp
index 808b3ab..bbe6a8f 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -751,6 +751,25 @@
return aps->getDeviceConnectionState(device, device_address);
}
+status_t AudioSystem::handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name)
+{
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ const char *address = "";
+ const char *name = "";
+
+ if (aps == 0) return PERMISSION_DENIED;
+
+ if (device_address != NULL) {
+ address = device_address;
+ }
+ if (device_name != NULL) {
+ name = device_name;
+ }
+ return aps->handleDeviceConfigChange(device, address, name);
+}
+
status_t AudioSystem::setPhoneState(audio_mode_t state)
{
if (uint32_t(state) >= AUDIO_MODE_CNT) return BAD_VALUE;
@@ -1166,7 +1185,7 @@
return aps->getPhoneState();
}
-status_t AudioSystem::registerPolicyMixes(Vector<AudioMix> mixes, bool registration)
+status_t AudioSystem::registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration)
{
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
diff --git a/media/libmedia/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp
similarity index 99%
rename from media/libmedia/AudioTrack.cpp
rename to media/libaudioclient/AudioTrack.cpp
index 7663fef..c96f16a 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libaudioclient/AudioTrack.cpp
@@ -2498,7 +2498,7 @@
// This is sometimes caused by erratic reports of the available space in the ALSA drivers.
if (status == NO_ERROR) {
if (previousTimestampValid) {
-#define TIME_TO_NANOS(time) ((int64_t)time.tv_sec * 1000000000 + time.tv_nsec)
+#define TIME_TO_NANOS(time) ((int64_t)(time).tv_sec * 1000000000 + (time).tv_nsec)
const int64_t previousTimeNanos = TIME_TO_NANOS(mPreviousTimestamp.mTime);
const int64_t currentTimeNanos = TIME_TO_NANOS(timestamp.mTime);
#undef TIME_TO_NANOS
diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libaudioclient/AudioTrackShared.cpp
similarity index 100%
rename from media/libmedia/AudioTrackShared.cpp
rename to media/libaudioclient/AudioTrackShared.cpp
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
similarity index 99%
rename from media/libmedia/IAudioFlinger.cpp
rename to media/libaudioclient/IAudioFlinger.cpp
index 900d418..65fdedb 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -90,7 +90,7 @@
class BpAudioFlinger : public BpInterface<IAudioFlinger>
{
public:
- BpAudioFlinger(const sp<IBinder>& impl)
+ explicit BpAudioFlinger(const sp<IBinder>& impl)
: BpInterface<IAudioFlinger>(impl)
{
}
diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libaudioclient/IAudioFlingerClient.cpp
similarity index 97%
rename from media/libmedia/IAudioFlingerClient.cpp
rename to media/libaudioclient/IAudioFlingerClient.cpp
index 8dca9e9..b2dbc4c 100644
--- a/media/libmedia/IAudioFlingerClient.cpp
+++ b/media/libaudioclient/IAudioFlingerClient.cpp
@@ -34,7 +34,7 @@
class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>
{
public:
- BpAudioFlingerClient(const sp<IBinder>& impl)
+ explicit BpAudioFlingerClient(const sp<IBinder>& impl)
: BpInterface<IAudioFlingerClient>(impl)
{
}
diff --git a/media/libmedia/IAudioPolicyService.cpp b/media/libaudioclient/IAudioPolicyService.cpp
similarity index 95%
rename from media/libmedia/IAudioPolicyService.cpp
rename to media/libaudioclient/IAudioPolicyService.cpp
index 6405d6d..0ac5726 100644
--- a/media/libmedia/IAudioPolicyService.cpp
+++ b/media/libaudioclient/IAudioPolicyService.cpp
@@ -33,6 +33,7 @@
enum {
SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION,
GET_DEVICE_CONNECTION_STATE,
+ HANDLE_DEVICE_CONFIG_CHANGE,
SET_PHONE_STATE,
SET_RINGER_MODE, // reserved, no longer used
SET_FORCE_USE,
@@ -83,7 +84,7 @@
class BpAudioPolicyService : public BpInterface<IAudioPolicyService>
{
public:
- BpAudioPolicyService(const sp<IBinder>& impl)
+ explicit BpAudioPolicyService(const sp<IBinder>& impl)
: BpInterface<IAudioPolicyService>(impl)
{
}
@@ -116,6 +117,19 @@
return static_cast <audio_policy_dev_state_t>(reply.readInt32());
}
+ virtual status_t handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
+ data.writeInt32(static_cast <uint32_t>(device));
+ data.writeCString(device_address);
+ data.writeCString(device_name);
+ remote()->transact(HANDLE_DEVICE_CONFIG_CHANGE, data, &reply);
+ return static_cast <status_t> (reply.readInt32());
+ }
+
virtual status_t setPhoneState(audio_mode_t state)
{
Parcel data, reply;
@@ -704,7 +718,7 @@
return (audio_mode_t)reply.readInt32();
}
- virtual status_t registerPolicyMixes(Vector<AudioMix> mixes, bool registration)
+ virtual status_t registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
@@ -821,10 +835,15 @@
static_cast <audio_policy_dev_state_t>(data.readInt32());
const char *device_address = data.readCString();
const char *device_name = data.readCString();
- reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device,
- state,
- device_address,
- device_name)));
+ if (device_address == nullptr || device_name == nullptr) {
+ ALOGE("Bad Binder transaction: SET_DEVICE_CONNECTION_STATE for device %u", device);
+ reply->writeInt32(static_cast<int32_t> (BAD_VALUE));
+ } else {
+ reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device,
+ state,
+ device_address,
+ device_name)));
+ }
return NO_ERROR;
} break;
@@ -833,8 +852,30 @@
audio_devices_t device =
static_cast<audio_devices_t> (data.readInt32());
const char *device_address = data.readCString();
- reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device,
- device_address)));
+ if (device_address == nullptr) {
+ ALOGE("Bad Binder transaction: GET_DEVICE_CONNECTION_STATE for device %u", device);
+ reply->writeInt32(static_cast<int32_t> (AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE));
+ } else {
+ reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device,
+ device_address)));
+ }
+ return NO_ERROR;
+ } break;
+
+ case HANDLE_DEVICE_CONFIG_CHANGE: {
+ CHECK_INTERFACE(IAudioPolicyService, data, reply);
+ audio_devices_t device =
+ static_cast <audio_devices_t>(data.readInt32());
+ const char *device_address = data.readCString();
+ const char *device_name = data.readCString();
+ if (device_address == nullptr || device_name == nullptr) {
+ ALOGE("Bad Binder transaction: HANDLE_DEVICE_CONFIG_CHANGE for device %u", device);
+ reply->writeInt32(static_cast<int32_t> (BAD_VALUE));
+ } else {
+ reply->writeInt32(static_cast<uint32_t> (handleDeviceConfigChange(device,
+ device_address,
+ device_name)));
+ }
return NO_ERROR;
} break;
diff --git a/media/libmedia/IAudioPolicyServiceClient.cpp b/media/libaudioclient/IAudioPolicyServiceClient.cpp
similarity index 98%
rename from media/libmedia/IAudioPolicyServiceClient.cpp
rename to media/libaudioclient/IAudioPolicyServiceClient.cpp
index 5f931e5..98a0521 100644
--- a/media/libmedia/IAudioPolicyServiceClient.cpp
+++ b/media/libaudioclient/IAudioPolicyServiceClient.cpp
@@ -52,7 +52,7 @@
class BpAudioPolicyServiceClient : public BpInterface<IAudioPolicyServiceClient>
{
public:
- BpAudioPolicyServiceClient(const sp<IBinder>& impl)
+ explicit BpAudioPolicyServiceClient(const sp<IBinder>& impl)
: BpInterface<IAudioPolicyServiceClient>(impl)
{
}
diff --git a/media/libmedia/IAudioRecord.cpp b/media/libaudioclient/IAudioRecord.cpp
similarity index 97%
rename from media/libmedia/IAudioRecord.cpp
rename to media/libaudioclient/IAudioRecord.cpp
index ae66436..1331c0d 100644
--- a/media/libmedia/IAudioRecord.cpp
+++ b/media/libaudioclient/IAudioRecord.cpp
@@ -37,7 +37,7 @@
class BpAudioRecord : public BpInterface<IAudioRecord>
{
public:
- BpAudioRecord(const sp<IBinder>& impl)
+ explicit BpAudioRecord(const sp<IBinder>& impl)
: BpInterface<IAudioRecord>(impl)
{
}
diff --git a/media/libmedia/IAudioTrack.cpp b/media/libaudioclient/IAudioTrack.cpp
similarity index 98%
rename from media/libmedia/IAudioTrack.cpp
rename to media/libaudioclient/IAudioTrack.cpp
index 636e3bb..89e0fcc 100644
--- a/media/libmedia/IAudioTrack.cpp
+++ b/media/libaudioclient/IAudioTrack.cpp
@@ -44,7 +44,7 @@
class BpAudioTrack : public BpInterface<IAudioTrack>
{
public:
- BpAudioTrack(const sp<IBinder>& impl)
+ explicit BpAudioTrack(const sp<IBinder>& impl)
: BpInterface<IAudioTrack>(impl)
{
}
diff --git a/media/libmedia/IEffect.cpp b/media/libaudioclient/IEffect.cpp
similarity index 98%
rename from media/libmedia/IEffect.cpp
rename to media/libaudioclient/IEffect.cpp
index af6d8de..ce72dae 100644
--- a/media/libmedia/IEffect.cpp
+++ b/media/libaudioclient/IEffect.cpp
@@ -39,7 +39,7 @@
class BpEffect: public BpInterface<IEffect>
{
public:
- BpEffect(const sp<IBinder>& impl)
+ explicit BpEffect(const sp<IBinder>& impl)
: BpInterface<IEffect>(impl)
{
}
diff --git a/media/libmedia/IEffectClient.cpp b/media/libaudioclient/IEffectClient.cpp
similarity index 98%
rename from media/libmedia/IEffectClient.cpp
rename to media/libaudioclient/IEffectClient.cpp
index 1322e72..3f2c67d 100644
--- a/media/libmedia/IEffectClient.cpp
+++ b/media/libaudioclient/IEffectClient.cpp
@@ -33,7 +33,7 @@
class BpEffectClient: public BpInterface<IEffectClient>
{
public:
- BpEffectClient(const sp<IBinder>& impl)
+ explicit BpEffectClient(const sp<IBinder>& impl)
: BpInterface<IEffectClient>(impl)
{
}
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libaudioclient/ToneGenerator.cpp
similarity index 100%
rename from media/libmedia/ToneGenerator.cpp
rename to media/libaudioclient/ToneGenerator.cpp
diff --git a/media/libcpustats/Android.bp b/media/libcpustats/Android.bp
new file mode 100644
index 0000000..3ea96c9
--- /dev/null
+++ b/media/libcpustats/Android.bp
@@ -0,0 +1,13 @@
+cc_library_static {
+ name: "libcpustats",
+
+ srcs: [
+ "CentralTendencyStatistics.cpp",
+ "ThreadCpuUsage.cpp",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
diff --git a/media/libcpustats/Android.mk b/media/libcpustats/Android.mk
deleted file mode 100644
index 57fe527..0000000
--- a/media/libcpustats/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- CentralTendencyStatistics.cpp \
- ThreadCpuUsage.cpp
-
-LOCAL_MODULE := libcpustats
-
-LOCAL_CFLAGS := -std=gnu++11 -Werror -Wall
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libeffects/Android.bp b/media/libeffects/Android.bp
new file mode 100644
index 0000000..ccaa2b4
--- /dev/null
+++ b/media/libeffects/Android.bp
@@ -0,0 +1 @@
+subdirs = ["factory"]
diff --git a/media/libeffects/downmix/Android.mk b/media/libeffects/downmix/Android.mk
index e0ca8af..c5ae5f8 100644
--- a/media/libeffects/downmix/Android.mk
+++ b/media/libeffects/downmix/Android.mk
@@ -3,6 +3,7 @@
# Multichannel downmix effect library
include $(CLEAR_VARS)
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \
EffectDownmix.c
diff --git a/media/libeffects/downmix/EffectDownmix.c b/media/libeffects/downmix/EffectDownmix.c
index 9823c55..5b74845 100644
--- a/media/libeffects/downmix/EffectDownmix.c
+++ b/media/libeffects/downmix/EffectDownmix.c
@@ -16,11 +16,14 @@
#define LOG_TAG "EffectDownmix"
//#define LOG_NDEBUG 0
-#include <log/log.h>
+
#include <inttypes.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
-#include <stdbool.h>
+
+#include <log/log.h>
+
#include "EffectDownmix.h"
// Do not submit with DOWNMIX_TEST_CHANNEL_INDEX defined, strictly for testing
diff --git a/media/libeffects/factory/Android.bp b/media/libeffects/factory/Android.bp
new file mode 100644
index 0000000..0d8b6eb
--- /dev/null
+++ b/media/libeffects/factory/Android.bp
@@ -0,0 +1,13 @@
+// Effect factory library
+cc_library_shared {
+ name: "libeffects",
+ srcs: ["EffectsFactory.c"],
+
+ shared_libs: [
+ "libcutils",
+ "liblog",
+ "libdl",
+ ],
+
+ include_dirs: ["system/media/audio_effects/include"],
+}
diff --git a/media/libeffects/factory/Android.mk b/media/libeffects/factory/Android.mk
deleted file mode 100644
index a932af7..0000000
--- a/media/libeffects/factory/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# Effect factory library
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- EffectsFactory.c
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils liblog
-
-LOCAL_MODULE:= libeffects
-
-LOCAL_SHARED_LIBRARIES += libdl
-
-LOCAL_C_INCLUDES := \
- $(call include-path-for, audio-effects)
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
index db7865a..ba20ac2 100644
--- a/media/libeffects/factory/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -18,13 +18,17 @@
//#define LOG_NDEBUG 0
#include "EffectsFactory.h"
-#include <string.h>
-#include <stdlib.h>
-#include <dlfcn.h>
-#include <cutils/misc.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#include <cutils/config_utils.h>
+#include <cutils/misc.h>
#include <cutils/properties.h>
+#include <log/log.h>
+
#include <audio_effects/audio_effects_conf.h>
static list_elem_t *gEffectList; // list of effect_entry_t: all currently created effects
diff --git a/media/libeffects/factory/EffectsFactory.h b/media/libeffects/factory/EffectsFactory.h
index 518800d..b7936e0 100644
--- a/media/libeffects/factory/EffectsFactory.h
+++ b/media/libeffects/factory/EffectsFactory.h
@@ -17,9 +17,10 @@
#ifndef ANDROID_EFFECTSFACTORY_H_
#define ANDROID_EFFECTSFACTORY_H_
-#include <cutils/log.h>
-#include <pthread.h>
#include <dirent.h>
+#include <pthread.h>
+
+#include <android/log.h>
#include <hardware/audio_effect.h>
#if __cplusplus
diff --git a/media/libeffects/loudness/Android.mk b/media/libeffects/loudness/Android.mk
index 55d0611..a1c4495 100644
--- a/media/libeffects/loudness/Android.mk
+++ b/media/libeffects/loudness/Android.mk
@@ -3,20 +3,21 @@
# LoudnessEnhancer library
include $(CLEAR_VARS)
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \
- EffectLoudnessEnhancer.cpp \
- dsp/core/dynamic_range_compression.cpp
+ EffectLoudnessEnhancer.cpp \
+ dsp/core/dynamic_range_compression.cpp
LOCAL_CFLAGS+= -O2 -fvisibility=hidden
LOCAL_SHARED_LIBRARIES := \
- libcutils \
- liblog \
+ libcutils \
+ liblog \
LOCAL_MODULE_RELATIVE_PATH := soundfx
LOCAL_MODULE:= libldnhncr
-LOCAL_C_INCLUDES := \
- $(call include-path-for, audio-effects) \
+LOCAL_HEADER_LIBRARIES := \
+ libaudioeffects
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/loudness/EffectLoudnessEnhancer.cpp b/media/libeffects/loudness/EffectLoudnessEnhancer.cpp
index a5a1a3f..cf00e60 100644
--- a/media/libeffects/loudness/EffectLoudnessEnhancer.cpp
+++ b/media/libeffects/loudness/EffectLoudnessEnhancer.cpp
@@ -16,13 +16,17 @@
#define LOG_TAG "EffectLE"
//#define LOG_NDEBUG 0
-#include <cutils/log.h>
+
#include <assert.h>
+#include <math.h>
#include <stdlib.h>
#include <string.h>
-#include <new>
#include <time.h>
-#include <math.h>
+
+#include <new>
+
+#include <log/log.h>
+
#include <audio_effects/effect_loudnessenhancer.h>
#include "dsp/core/dynamic_range_compression.h"
diff --git a/media/libeffects/loudness/dsp/core/dynamic_range_compression-inl.h b/media/libeffects/loudness/dsp/core/dynamic_range_compression-inl.h
index da75ceb..7ea0593 100644
--- a/media/libeffects/loudness/dsp/core/dynamic_range_compression-inl.h
+++ b/media/libeffects/loudness/dsp/core/dynamic_range_compression-inl.h
@@ -16,13 +16,15 @@
#ifndef LE_FX_ENGINE_DSP_CORE_DYNAMIC_RANGE_COMPRESSION_INL_H_
#define LE_FX_ENGINE_DSP_CORE_DYNAMIC_RANGE_COMPRESSION_INL_H_
+#ifndef LOG_TAG
+#define LOG_TAG NULL
+#endif
//#define LOG_NDEBUG 0
-#include <cutils/log.h>
+#include <log/log.h>
namespace le_fx {
-
inline void AdaptiveDynamicRangeCompression::set_knee_threshold(float decibel) {
// Converts to 1og-base
knee_threshold_in_decibel_ = decibel;
diff --git a/media/libeffects/loudness/dsp/core/dynamic_range_compression.cpp b/media/libeffects/loudness/dsp/core/dynamic_range_compression.cpp
index 7bd068e..578f58a 100644
--- a/media/libeffects/loudness/dsp/core/dynamic_range_compression.cpp
+++ b/media/libeffects/loudness/dsp/core/dynamic_range_compression.cpp
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
#include <cmath>
@@ -22,9 +23,7 @@
#include "dsp/core/interpolation.h"
#include "dsp/core/dynamic_range_compression.h"
-//#define LOG_NDEBUG 0
-#include <cutils/log.h>
-
+#include <android/log.h>
namespace le_fx {
diff --git a/media/libeffects/loudness/dsp/core/dynamic_range_compression.h b/media/libeffects/loudness/dsp/core/dynamic_range_compression.h
index 2821a78..04455c5 100644
--- a/media/libeffects/loudness/dsp/core/dynamic_range_compression.h
+++ b/media/libeffects/loudness/dsp/core/dynamic_range_compression.h
@@ -16,14 +16,14 @@
#ifndef LE_FX_ENGINE_DSP_CORE_DYNAMIC_RANGE_COMPRESSION_H_
#define LE_FX_ENGINE_DSP_CORE_DYNAMIC_RANGE_COMPRESSION_H_
+//#define LOG_NDEBUG 0
+
#include "common/core/types.h"
#include "common/core/math.h"
#include "dsp/core/basic.h"
#include "dsp/core/interpolation.h"
-//#define LOG_NDEBUG 0
-#include <cutils/log.h>
-
+#include <android/log.h>
namespace le_fx {
diff --git a/media/libeffects/loudness/dsp/core/interpolator_base-inl.h b/media/libeffects/loudness/dsp/core/interpolator_base-inl.h
index bd08b65..fb87c79 100644
--- a/media/libeffects/loudness/dsp/core/interpolator_base-inl.h
+++ b/media/libeffects/loudness/dsp/core/interpolator_base-inl.h
@@ -16,13 +16,15 @@
#ifndef LE_FX_ENGINE_DSP_CORE_INTERPOLATOR_BASE_INL_H_
#define LE_FX_ENGINE_DSP_CORE_INTERPOLATOR_BASE_INL_H_
+#ifndef LOG_TAG
+#define LOG_TAG NULL
+#endif
+//#define LOG_NDEBUG 0
+
+#include <log/log.h>
#include "dsp/core/basic.h"
-//#define LOG_NDEBUG 0
-#include <cutils/log.h>
-
-
namespace le_fx {
namespace sigmod {
@@ -112,7 +114,7 @@
if (x_data_[n + 1] <= x_data_[n]) {
ALOGE("InterpolatorBase::Initialize: xData are not ordered or "
"contain equal values (X[%d] <= X[%d]) (%.5e <= %.5e)",
- n + 1, n, x_data_[n + 1], x_data_[n]);
+ n + 1, n, x_data_[n + 1], x_data_[n]);
status_ = false;
return false;
}
diff --git a/media/libeffects/lvm/lib/Android.mk b/media/libeffects/lvm/lib/Android.mk
index bb56c75..85e01e0 100644
--- a/media/libeffects/lvm/lib/Android.mk
+++ b/media/libeffects/lvm/lib/Android.mk
@@ -6,6 +6,7 @@
LOCAL_ARM_MODE := arm
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \
StereoWidening/src/LVCS_BypassMix.c \
StereoWidening/src/LVCS_Control.c \
@@ -130,6 +131,7 @@
LOCAL_ARM_MODE := arm
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \
Reverb/src/LVREV_ApplyNewSettings.c \
Reverb/src/LVREV_ClearAudioBuffers.c \
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h
index 94a7869..b1ebadf 100644
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Coeffs.h
@@ -36,190 +36,190 @@
/* Coefficients for centre frequency 55Hz */
#define HPF_Fs8000_Fc55_A0 1029556328 /* Floating point value 0.958849 */
-#define HPF_Fs8000_Fc55_A1 -2059112655 /* Floating point value -1.917698 */
+#define HPF_Fs8000_Fc55_A1 (-2059112655) /* Floating point value -1.917698 */
#define HPF_Fs8000_Fc55_A2 1029556328 /* Floating point value 0.958849 */
-#define HPF_Fs8000_Fc55_B1 -2081986375 /* Floating point value -1.939001 */
+#define HPF_Fs8000_Fc55_B1 (-2081986375) /* Floating point value -1.939001 */
#define HPF_Fs8000_Fc55_B2 1010183914 /* Floating point value 0.940807 */
#define HPF_Fs11025_Fc55_A0 1038210831 /* Floating point value 0.966909 */
-#define HPF_Fs11025_Fc55_A1 -2076421662 /* Floating point value -1.933818 */
+#define HPF_Fs11025_Fc55_A1 (-2076421662) /* Floating point value -1.933818 */
#define HPF_Fs11025_Fc55_A2 1038210831 /* Floating point value 0.966909 */
-#define HPF_Fs11025_Fc55_B1 -2099950710 /* Floating point value -1.955732 */
+#define HPF_Fs11025_Fc55_B1 (-2099950710) /* Floating point value -1.955732 */
#define HPF_Fs11025_Fc55_B2 1027238450 /* Floating point value 0.956690 */
#define HPF_Fs12000_Fc55_A0 1040079943 /* Floating point value 0.968650 */
-#define HPF_Fs12000_Fc55_A1 -2080159885 /* Floating point value -1.937300 */
+#define HPF_Fs12000_Fc55_A1 (-2080159885) /* Floating point value -1.937300 */
#define HPF_Fs12000_Fc55_A2 1040079943 /* Floating point value 0.968650 */
-#define HPF_Fs12000_Fc55_B1 -2103811702 /* Floating point value -1.959327 */
+#define HPF_Fs12000_Fc55_B1 (-2103811702) /* Floating point value -1.959327 */
#define HPF_Fs12000_Fc55_B2 1030940477 /* Floating point value 0.960138 */
#define HPF_Fs16000_Fc55_A0 1045381988 /* Floating point value 0.973588 */
-#define HPF_Fs16000_Fc55_A1 -2090763976 /* Floating point value -1.947176 */
+#define HPF_Fs16000_Fc55_A1 (-2090763976) /* Floating point value -1.947176 */
#define HPF_Fs16000_Fc55_A2 1045381988 /* Floating point value 0.973588 */
-#define HPF_Fs16000_Fc55_B1 -2114727793 /* Floating point value -1.969494 */
+#define HPF_Fs16000_Fc55_B1 (-2114727793) /* Floating point value -1.969494 */
#define HPF_Fs16000_Fc55_B2 1041478147 /* Floating point value 0.969952 */
#define HPF_Fs22050_Fc55_A0 1049766523 /* Floating point value 0.977671 */
-#define HPF_Fs22050_Fc55_A1 -2099533046 /* Floating point value -1.955343 */
+#define HPF_Fs22050_Fc55_A1 (-2099533046) /* Floating point value -1.955343 */
#define HPF_Fs22050_Fc55_A2 1049766523 /* Floating point value 0.977671 */
-#define HPF_Fs22050_Fc55_B1 -2123714381 /* Floating point value -1.977863 */
+#define HPF_Fs22050_Fc55_B1 (-2123714381) /* Floating point value -1.977863 */
#define HPF_Fs22050_Fc55_B2 1050232780 /* Floating point value 0.978105 */
#define HPF_Fs24000_Fc55_A0 1050711051 /* Floating point value 0.978551 */
-#define HPF_Fs24000_Fc55_A1 -2101422103 /* Floating point value -1.957102 */
+#define HPF_Fs24000_Fc55_A1 (-2101422103) /* Floating point value -1.957102 */
#define HPF_Fs24000_Fc55_A2 1050711051 /* Floating point value 0.978551 */
-#define HPF_Fs24000_Fc55_B1 -2125645498 /* Floating point value -1.979662 */
+#define HPF_Fs24000_Fc55_B1 (-2125645498) /* Floating point value -1.979662 */
#define HPF_Fs24000_Fc55_B2 1052123526 /* Floating point value 0.979866 */
#define HPF_Fs32000_Fc55_A0 1053385759 /* Floating point value 0.981042 */
-#define HPF_Fs32000_Fc55_A1 -2106771519 /* Floating point value -1.962084 */
+#define HPF_Fs32000_Fc55_A1 (-2106771519) /* Floating point value -1.962084 */
#define HPF_Fs32000_Fc55_A2 1053385759 /* Floating point value 0.981042 */
-#define HPF_Fs32000_Fc55_B1 -2131104794 /* Floating point value -1.984746 */
+#define HPF_Fs32000_Fc55_B1 (-2131104794) /* Floating point value -1.984746 */
#define HPF_Fs32000_Fc55_B2 1057486949 /* Floating point value 0.984861 */
#define HPF_Fs44100_Fc55_A0 1055592498 /* Floating point value 0.983097 */
-#define HPF_Fs44100_Fc55_A1 -2111184995 /* Floating point value -1.966194 */
+#define HPF_Fs44100_Fc55_A1 (-2111184995) /* Floating point value -1.966194 */
#define HPF_Fs44100_Fc55_A2 1055592498 /* Floating point value 0.983097 */
-#define HPF_Fs44100_Fc55_B1 -2135598658 /* Floating point value -1.988931 */
+#define HPF_Fs44100_Fc55_B1 (-2135598658) /* Floating point value -1.988931 */
#define HPF_Fs44100_Fc55_B2 1061922249 /* Floating point value 0.988992 */
#define HPF_Fs48000_Fc55_A0 1056067276 /* Floating point value 0.983539 */
-#define HPF_Fs48000_Fc55_A1 -2112134551 /* Floating point value -1.967079 */
+#define HPF_Fs48000_Fc55_A1 (-2112134551) /* Floating point value -1.967079 */
#define HPF_Fs48000_Fc55_A2 1056067276 /* Floating point value 0.983539 */
-#define HPF_Fs48000_Fc55_B1 -2136564296 /* Floating point value -1.989831 */
+#define HPF_Fs48000_Fc55_B1 (-2136564296) /* Floating point value -1.989831 */
#define HPF_Fs48000_Fc55_B2 1062877714 /* Floating point value 0.989882 */
/* Coefficients for centre frequency 66Hz */
#define HPF_Fs8000_Fc66_A0 1023293271 /* Floating point value 0.953016 */
-#define HPF_Fs8000_Fc66_A1 -2046586542 /* Floating point value -1.906032 */
+#define HPF_Fs8000_Fc66_A1 (-2046586542) /* Floating point value -1.906032 */
#define HPF_Fs8000_Fc66_A2 1023293271 /* Floating point value 0.953016 */
-#define HPF_Fs8000_Fc66_B1 -2068896860 /* Floating point value -1.926810 */
+#define HPF_Fs8000_Fc66_B1 (-2068896860) /* Floating point value -1.926810 */
#define HPF_Fs8000_Fc66_B2 997931110 /* Floating point value 0.929396 */
#define HPF_Fs11025_Fc66_A0 1033624228 /* Floating point value 0.962638 */
-#define HPF_Fs11025_Fc66_A1 -2067248455 /* Floating point value -1.925275 */
+#define HPF_Fs11025_Fc66_A1 (-2067248455) /* Floating point value -1.925275 */
#define HPF_Fs11025_Fc66_A2 1033624228 /* Floating point value 0.962638 */
-#define HPF_Fs11025_Fc66_B1 -2090448000 /* Floating point value -1.946881 */
+#define HPF_Fs11025_Fc66_B1 (-2090448000) /* Floating point value -1.946881 */
#define HPF_Fs11025_Fc66_B2 1018182305 /* Floating point value 0.948256 */
#define HPF_Fs12000_Fc66_A0 1035857662 /* Floating point value 0.964718 */
-#define HPF_Fs12000_Fc66_A1 -2071715325 /* Floating point value -1.929435 */
+#define HPF_Fs12000_Fc66_A1 (-2071715325) /* Floating point value -1.929435 */
#define HPF_Fs12000_Fc66_A2 1035857662 /* Floating point value 0.964718 */
-#define HPF_Fs12000_Fc66_B1 -2095080333 /* Floating point value -1.951196 */
+#define HPF_Fs12000_Fc66_B1 (-2095080333) /* Floating point value -1.951196 */
#define HPF_Fs12000_Fc66_B2 1022587158 /* Floating point value 0.952359 */
#define HPF_Fs16000_Fc66_A0 1042197528 /* Floating point value 0.970622 */
-#define HPF_Fs16000_Fc66_A1 -2084395056 /* Floating point value -1.941244 */
+#define HPF_Fs16000_Fc66_A1 (-2084395056) /* Floating point value -1.941244 */
#define HPF_Fs16000_Fc66_A2 1042197528 /* Floating point value 0.970622 */
-#define HPF_Fs16000_Fc66_B1 -2108177912 /* Floating point value -1.963394 */
+#define HPF_Fs16000_Fc66_B1 (-2108177912) /* Floating point value -1.963394 */
#define HPF_Fs16000_Fc66_B2 1035142690 /* Floating point value 0.964052 */
#define HPF_Fs22050_Fc66_A0 1047445145 /* Floating point value 0.975509 */
-#define HPF_Fs22050_Fc66_A1 -2094890289 /* Floating point value -1.951019 */
+#define HPF_Fs22050_Fc66_A1 (-2094890289) /* Floating point value -1.951019 */
#define HPF_Fs22050_Fc66_A2 1047445145 /* Floating point value 0.975509 */
-#define HPF_Fs22050_Fc66_B1 -2118961025 /* Floating point value -1.973436 */
+#define HPF_Fs22050_Fc66_B1 (-2118961025) /* Floating point value -1.973436 */
#define HPF_Fs22050_Fc66_B2 1045593102 /* Floating point value 0.973784 */
#define HPF_Fs24000_Fc66_A0 1048576175 /* Floating point value 0.976563 */
-#define HPF_Fs24000_Fc66_A1 -2097152349 /* Floating point value -1.953125 */
+#define HPF_Fs24000_Fc66_A1 (-2097152349) /* Floating point value -1.953125 */
#define HPF_Fs24000_Fc66_A2 1048576175 /* Floating point value 0.976563 */
-#define HPF_Fs24000_Fc66_B1 -2121278255 /* Floating point value -1.975594 */
+#define HPF_Fs24000_Fc66_B1 (-2121278255) /* Floating point value -1.975594 */
#define HPF_Fs24000_Fc66_B2 1047852379 /* Floating point value 0.975889 */
#define HPF_Fs32000_Fc66_A0 1051780119 /* Floating point value 0.979547 */
-#define HPF_Fs32000_Fc66_A1 -2103560237 /* Floating point value -1.959093 */
+#define HPF_Fs32000_Fc66_A1 (-2103560237) /* Floating point value -1.959093 */
#define HPF_Fs32000_Fc66_A2 1051780119 /* Floating point value 0.979547 */
-#define HPF_Fs32000_Fc66_B1 -2127829187 /* Floating point value -1.981695 */
+#define HPF_Fs32000_Fc66_B1 (-2127829187) /* Floating point value -1.981695 */
#define HPF_Fs32000_Fc66_B2 1054265623 /* Floating point value 0.981861 */
#define HPF_Fs44100_Fc66_A0 1054424722 /* Floating point value 0.982010 */
-#define HPF_Fs44100_Fc66_A1 -2108849444 /* Floating point value -1.964019 */
+#define HPF_Fs44100_Fc66_A1 (-2108849444) /* Floating point value -1.964019 */
#define HPF_Fs44100_Fc66_A2 1054424722 /* Floating point value 0.982010 */
-#define HPF_Fs44100_Fc66_B1 -2133221723 /* Floating point value -1.986718 */
+#define HPF_Fs44100_Fc66_B1 (-2133221723) /* Floating point value -1.986718 */
#define HPF_Fs44100_Fc66_B2 1059573993 /* Floating point value 0.986805 */
#define HPF_Fs48000_Fc66_A0 1054993851 /* Floating point value 0.982540 */
-#define HPF_Fs48000_Fc66_A1 -2109987702 /* Floating point value -1.965079 */
+#define HPF_Fs48000_Fc66_A1 (-2109987702) /* Floating point value -1.965079 */
#define HPF_Fs48000_Fc66_A2 1054993851 /* Floating point value 0.982540 */
-#define HPF_Fs48000_Fc66_B1 -2134380475 /* Floating point value -1.987797 */
+#define HPF_Fs48000_Fc66_B1 (-2134380475) /* Floating point value -1.987797 */
#define HPF_Fs48000_Fc66_B2 1060718118 /* Floating point value 0.987871 */
/* Coefficients for centre frequency 78Hz */
#define HPF_Fs8000_Fc78_A0 1016504203 /* Floating point value 0.946693 */
-#define HPF_Fs8000_Fc78_A1 -2033008405 /* Floating point value -1.893387 */
+#define HPF_Fs8000_Fc78_A1 (-2033008405) /* Floating point value -1.893387 */
#define HPF_Fs8000_Fc78_A2 1016504203 /* Floating point value 0.946693 */
-#define HPF_Fs8000_Fc78_B1 -2054623390 /* Floating point value -1.913517 */
+#define HPF_Fs8000_Fc78_B1 (-2054623390) /* Floating point value -1.913517 */
#define HPF_Fs8000_Fc78_B2 984733853 /* Floating point value 0.917105 */
#define HPF_Fs11025_Fc78_A0 1028643741 /* Floating point value 0.957999 */
-#define HPF_Fs11025_Fc78_A1 -2057287482 /* Floating point value -1.915998 */
+#define HPF_Fs11025_Fc78_A1 (-2057287482) /* Floating point value -1.915998 */
#define HPF_Fs11025_Fc78_A2 1028643741 /* Floating point value 0.957999 */
-#define HPF_Fs11025_Fc78_B1 -2080083769 /* Floating point value -1.937229 */
+#define HPF_Fs11025_Fc78_B1 (-2080083769) /* Floating point value -1.937229 */
#define HPF_Fs11025_Fc78_B2 1008393904 /* Floating point value 0.939140 */
#define HPF_Fs12000_Fc78_A0 1031271067 /* Floating point value 0.960446 */
-#define HPF_Fs12000_Fc78_A1 -2062542133 /* Floating point value -1.920892 */
+#define HPF_Fs12000_Fc78_A1 (-2062542133) /* Floating point value -1.920892 */
#define HPF_Fs12000_Fc78_A2 1031271067 /* Floating point value 0.960446 */
-#define HPF_Fs12000_Fc78_B1 -2085557048 /* Floating point value -1.942326 */
+#define HPF_Fs12000_Fc78_B1 (-2085557048) /* Floating point value -1.942326 */
#define HPF_Fs12000_Fc78_B2 1013551620 /* Floating point value 0.943944 */
#define HPF_Fs16000_Fc78_A0 1038734628 /* Floating point value 0.967397 */
-#define HPF_Fs16000_Fc78_A1 -2077469256 /* Floating point value -1.934794 */
+#define HPF_Fs16000_Fc78_A1 (-2077469256) /* Floating point value -1.934794 */
#define HPF_Fs16000_Fc78_A2 1038734628 /* Floating point value 0.967397 */
-#define HPF_Fs16000_Fc78_B1 -2101033380 /* Floating point value -1.956740 */
+#define HPF_Fs16000_Fc78_B1 (-2101033380) /* Floating point value -1.956740 */
#define HPF_Fs16000_Fc78_B2 1028275228 /* Floating point value 0.957656 */
#define HPF_Fs22050_Fc78_A0 1044918584 /* Floating point value 0.973156 */
-#define HPF_Fs22050_Fc78_A1 -2089837169 /* Floating point value -1.946313 */
+#define HPF_Fs22050_Fc78_A1 (-2089837169) /* Floating point value -1.946313 */
#define HPF_Fs22050_Fc78_A2 1044918584 /* Floating point value 0.973156 */
-#define HPF_Fs22050_Fc78_B1 -2113775854 /* Floating point value -1.968607 */
+#define HPF_Fs22050_Fc78_B1 (-2113775854) /* Floating point value -1.968607 */
#define HPF_Fs22050_Fc78_B2 1040555007 /* Floating point value 0.969092 */
#define HPF_Fs24000_Fc78_A0 1046252164 /* Floating point value 0.974398 */
-#define HPF_Fs24000_Fc78_A1 -2092504328 /* Floating point value -1.948797 */
+#define HPF_Fs24000_Fc78_A1 (-2092504328) /* Floating point value -1.948797 */
#define HPF_Fs24000_Fc78_A2 1046252164 /* Floating point value 0.974398 */
-#define HPF_Fs24000_Fc78_B1 -2116514229 /* Floating point value -1.971157 */
+#define HPF_Fs24000_Fc78_B1 (-2116514229) /* Floating point value -1.971157 */
#define HPF_Fs24000_Fc78_B2 1043212719 /* Floating point value 0.971568 */
#define HPF_Fs32000_Fc78_A0 1050031301 /* Floating point value 0.977918 */
-#define HPF_Fs32000_Fc78_A1 -2100062603 /* Floating point value -1.955836 */
+#define HPF_Fs32000_Fc78_A1 (-2100062603) /* Floating point value -1.955836 */
#define HPF_Fs32000_Fc78_A2 1050031301 /* Floating point value 0.977918 */
-#define HPF_Fs32000_Fc78_B1 -2124255900 /* Floating point value -1.978367 */
+#define HPF_Fs32000_Fc78_B1 (-2124255900) /* Floating point value -1.978367 */
#define HPF_Fs32000_Fc78_B2 1050762639 /* Floating point value 0.978599 */
#define HPF_Fs44100_Fc78_A0 1053152258 /* Floating point value 0.980824 */
-#define HPF_Fs44100_Fc78_A1 -2106304516 /* Floating point value -1.961649 */
+#define HPF_Fs44100_Fc78_A1 (-2106304516) /* Floating point value -1.961649 */
#define HPF_Fs44100_Fc78_A2 1053152258 /* Floating point value 0.980824 */
-#define HPF_Fs44100_Fc78_B1 -2130628742 /* Floating point value -1.984303 */
+#define HPF_Fs44100_Fc78_B1 (-2130628742) /* Floating point value -1.984303 */
#define HPF_Fs44100_Fc78_B2 1057018180 /* Floating point value 0.984425 */
#define HPF_Fs48000_Fc78_A0 1053824087 /* Floating point value 0.981450 */
-#define HPF_Fs48000_Fc78_A1 -2107648173 /* Floating point value -1.962900 */
+#define HPF_Fs48000_Fc78_A1 (-2107648173) /* Floating point value -1.962900 */
#define HPF_Fs48000_Fc78_A2 1053824087 /* Floating point value 0.981450 */
-#define HPF_Fs48000_Fc78_B1 -2131998154 /* Floating point value -1.985578 */
+#define HPF_Fs48000_Fc78_B1 (-2131998154) /* Floating point value -1.985578 */
#define HPF_Fs48000_Fc78_B2 1058367200 /* Floating point value 0.985681 */
/* Coefficients for centre frequency 90Hz */
#define HPF_Fs8000_Fc90_A0 1009760053 /* Floating point value 0.940412 */
-#define HPF_Fs8000_Fc90_A1 -2019520105 /* Floating point value -1.880825 */
+#define HPF_Fs8000_Fc90_A1 (-2019520105) /* Floating point value -1.880825 */
#define HPF_Fs8000_Fc90_A2 1009760053 /* Floating point value 0.940412 */
-#define HPF_Fs8000_Fc90_B1 -2040357139 /* Floating point value -1.900231 */
+#define HPF_Fs8000_Fc90_B1 (-2040357139) /* Floating point value -1.900231 */
#define HPF_Fs8000_Fc90_B2 971711129 /* Floating point value 0.904977 */
#define HPF_Fs11025_Fc90_A0 1023687217 /* Floating point value 0.953383 */
-#define HPF_Fs11025_Fc90_A1 -2047374434 /* Floating point value -1.906766 */
+#define HPF_Fs11025_Fc90_A1 (-2047374434) /* Floating point value -1.906766 */
#define HPF_Fs11025_Fc90_A2 1023687217 /* Floating point value 0.953383 */
-#define HPF_Fs11025_Fc90_B1 -2069722397 /* Floating point value -1.927579 */
+#define HPF_Fs11025_Fc90_B1 (-2069722397) /* Floating point value -1.927579 */
#define HPF_Fs11025_Fc90_B2 998699604 /* Floating point value 0.930111 */
#define HPF_Fs12000_Fc90_A0 1026704754 /* Floating point value 0.956193 */
-#define HPF_Fs12000_Fc90_A1 -2053409508 /* Floating point value -1.912387 */
+#define HPF_Fs12000_Fc90_A1 (-2053409508) /* Floating point value -1.912387 */
#define HPF_Fs12000_Fc90_A2 1026704754 /* Floating point value 0.956193 */
-#define HPF_Fs12000_Fc90_B1 -2076035996 /* Floating point value -1.933459 */
+#define HPF_Fs12000_Fc90_B1 (-2076035996) /* Floating point value -1.933459 */
#define HPF_Fs12000_Fc90_B2 1004595918 /* Floating point value 0.935603 */
#define HPF_Fs16000_Fc90_A0 1035283225 /* Floating point value 0.964183 */
-#define HPF_Fs16000_Fc90_A1 -2070566451 /* Floating point value -1.928365 */
+#define HPF_Fs16000_Fc90_A1 (-2070566451) /* Floating point value -1.928365 */
#define HPF_Fs16000_Fc90_A2 1035283225 /* Floating point value 0.964183 */
-#define HPF_Fs16000_Fc90_B1 -2093889811 /* Floating point value -1.950087 */
+#define HPF_Fs16000_Fc90_B1 (-2093889811) /* Floating point value -1.950087 */
#define HPF_Fs16000_Fc90_B2 1021453326 /* Floating point value 0.951303 */
#define HPF_Fs22050_Fc90_A0 1042398116 /* Floating point value 0.970809 */
-#define HPF_Fs22050_Fc90_A1 -2084796232 /* Floating point value -1.941618 */
+#define HPF_Fs22050_Fc90_A1 (-2084796232) /* Floating point value -1.941618 */
#define HPF_Fs22050_Fc90_A2 1042398116 /* Floating point value 0.970809 */
-#define HPF_Fs22050_Fc90_B1 -2108591057 /* Floating point value -1.963778 */
+#define HPF_Fs22050_Fc90_B1 (-2108591057) /* Floating point value -1.963778 */
#define HPF_Fs22050_Fc90_B2 1035541188 /* Floating point value 0.964423 */
#define HPF_Fs24000_Fc90_A0 1043933302 /* Floating point value 0.972239 */
-#define HPF_Fs24000_Fc90_A1 -2087866604 /* Floating point value -1.944477 */
+#define HPF_Fs24000_Fc90_A1 (-2087866604) /* Floating point value -1.944477 */
#define HPF_Fs24000_Fc90_A2 1043933302 /* Floating point value 0.972239 */
-#define HPF_Fs24000_Fc90_B1 -2111750495 /* Floating point value -1.966721 */
+#define HPF_Fs24000_Fc90_B1 (-2111750495) /* Floating point value -1.966721 */
#define HPF_Fs24000_Fc90_B2 1038593601 /* Floating point value 0.967266 */
#define HPF_Fs32000_Fc90_A0 1048285391 /* Floating point value 0.976292 */
-#define HPF_Fs32000_Fc90_A1 -2096570783 /* Floating point value -1.952584 */
+#define HPF_Fs32000_Fc90_A1 (-2096570783) /* Floating point value -1.952584 */
#define HPF_Fs32000_Fc90_A2 1048285391 /* Floating point value 0.976292 */
-#define HPF_Fs32000_Fc90_B1 -2120682737 /* Floating point value -1.975040 */
+#define HPF_Fs32000_Fc90_B1 (-2120682737) /* Floating point value -1.975040 */
#define HPF_Fs32000_Fc90_B2 1047271295 /* Floating point value 0.975347 */
#define HPF_Fs44100_Fc90_A0 1051881330 /* Floating point value 0.979641 */
-#define HPF_Fs44100_Fc90_A1 -2103762660 /* Floating point value -1.959282 */
+#define HPF_Fs44100_Fc90_A1 (-2103762660) /* Floating point value -1.959282 */
#define HPF_Fs44100_Fc90_A2 1051881330 /* Floating point value 0.979641 */
-#define HPF_Fs44100_Fc90_B1 -2128035809 /* Floating point value -1.981888 */
+#define HPF_Fs44100_Fc90_B1 (-2128035809) /* Floating point value -1.981888 */
#define HPF_Fs44100_Fc90_B2 1054468533 /* Floating point value 0.982050 */
#define HPF_Fs48000_Fc90_A0 1052655619 /* Floating point value 0.980362 */
-#define HPF_Fs48000_Fc90_A1 -2105311238 /* Floating point value -1.960724 */
+#define HPF_Fs48000_Fc90_A1 (-2105311238) /* Floating point value -1.960724 */
#define HPF_Fs48000_Fc90_A2 1052655619 /* Floating point value 0.980362 */
-#define HPF_Fs48000_Fc90_B1 -2129615871 /* Floating point value -1.983359 */
+#define HPF_Fs48000_Fc90_B1 (-2129615871) /* Floating point value -1.983359 */
#define HPF_Fs48000_Fc90_B2 1056021492 /* Floating point value 0.983497 */
@@ -232,189 +232,189 @@
/* Coefficients for centre frequency 55Hz */
#define BPF_Fs8000_Fc55_A0 9875247 /* Floating point value 0.009197 */
#define BPF_Fs8000_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs8000_Fc55_A2 -9875247 /* Floating point value -0.009197 */
-#define BPF_Fs8000_Fc55_B1 -2125519830 /* Floating point value -1.979545 */
+#define BPF_Fs8000_Fc55_A2 (-9875247) /* Floating point value -0.009197 */
+#define BPF_Fs8000_Fc55_B1 (-2125519830) /* Floating point value -1.979545 */
#define BPF_Fs8000_Fc55_B2 1053762629 /* Floating point value 0.981393 */
#define BPF_Fs11025_Fc55_A0 7183952 /* Floating point value 0.006691 */
#define BPF_Fs11025_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs11025_Fc55_A2 -7183952 /* Floating point value -0.006691 */
-#define BPF_Fs11025_Fc55_B1 -2131901658 /* Floating point value -1.985488 */
+#define BPF_Fs11025_Fc55_A2 (-7183952) /* Floating point value -0.006691 */
+#define BPF_Fs11025_Fc55_B1 (-2131901658) /* Floating point value -1.985488 */
#define BPF_Fs11025_Fc55_B2 1059207548 /* Floating point value 0.986464 */
#define BPF_Fs12000_Fc55_A0 6603871 /* Floating point value 0.006150 */
#define BPF_Fs12000_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs12000_Fc55_A2 -6603871 /* Floating point value -0.006150 */
-#define BPF_Fs12000_Fc55_B1 -2133238092 /* Floating point value -1.986733 */
+#define BPF_Fs12000_Fc55_A2 (-6603871) /* Floating point value -0.006150 */
+#define BPF_Fs12000_Fc55_B1 (-2133238092) /* Floating point value -1.986733 */
#define BPF_Fs12000_Fc55_B2 1060381143 /* Floating point value 0.987557 */
#define BPF_Fs16000_Fc55_A0 4960591 /* Floating point value 0.004620 */
#define BPF_Fs16000_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs16000_Fc55_A2 -4960591 /* Floating point value -0.004620 */
-#define BPF_Fs16000_Fc55_B1 -2136949052 /* Floating point value -1.990189 */
+#define BPF_Fs16000_Fc55_A2 (-4960591) /* Floating point value -0.004620 */
+#define BPF_Fs16000_Fc55_B1 (-2136949052) /* Floating point value -1.990189 */
#define BPF_Fs16000_Fc55_B2 1063705760 /* Floating point value 0.990653 */
#define BPF_Fs22050_Fc55_A0 3604131 /* Floating point value 0.003357 */
#define BPF_Fs22050_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs22050_Fc55_A2 -3604131 /* Floating point value -0.003357 */
-#define BPF_Fs22050_Fc55_B1 -2139929085 /* Floating point value -1.992964 */
+#define BPF_Fs22050_Fc55_A2 (-3604131) /* Floating point value -0.003357 */
+#define BPF_Fs22050_Fc55_B1 (-2139929085) /* Floating point value -1.992964 */
#define BPF_Fs22050_Fc55_B2 1066450095 /* Floating point value 0.993209 */
#define BPF_Fs24000_Fc55_A0 3312207 /* Floating point value 0.003085 */
#define BPF_Fs24000_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs24000_Fc55_A2 -3312207 /* Floating point value -0.003085 */
-#define BPF_Fs24000_Fc55_B1 -2140560606 /* Floating point value -1.993552 */
+#define BPF_Fs24000_Fc55_A2 (-3312207) /* Floating point value -0.003085 */
+#define BPF_Fs24000_Fc55_B1 (-2140560606) /* Floating point value -1.993552 */
#define BPF_Fs24000_Fc55_B2 1067040703 /* Floating point value 0.993759 */
#define BPF_Fs32000_Fc55_A0 2486091 /* Floating point value 0.002315 */
#define BPF_Fs32000_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs32000_Fc55_A2 -2486091 /* Floating point value -0.002315 */
-#define BPF_Fs32000_Fc55_B1 -2142328962 /* Floating point value -1.995199 */
+#define BPF_Fs32000_Fc55_A2 (-2486091) /* Floating point value -0.002315 */
+#define BPF_Fs32000_Fc55_B1 (-2142328962) /* Floating point value -1.995199 */
#define BPF_Fs32000_Fc55_B2 1068712067 /* Floating point value 0.995316 */
#define BPF_Fs44100_Fc55_A0 1805125 /* Floating point value 0.001681 */
#define BPF_Fs44100_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs44100_Fc55_A2 -1805125 /* Floating point value -0.001681 */
-#define BPF_Fs44100_Fc55_B1 -2143765772 /* Floating point value -1.996537 */
+#define BPF_Fs44100_Fc55_A2 (-1805125) /* Floating point value -0.001681 */
+#define BPF_Fs44100_Fc55_B1 (-2143765772) /* Floating point value -1.996537 */
#define BPF_Fs44100_Fc55_B2 1070089770 /* Floating point value 0.996599 */
#define BPF_Fs48000_Fc55_A0 1658687 /* Floating point value 0.001545 */
#define BPF_Fs48000_Fc55_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs48000_Fc55_A2 -1658687 /* Floating point value -0.001545 */
-#define BPF_Fs48000_Fc55_B1 -2144072292 /* Floating point value -1.996823 */
+#define BPF_Fs48000_Fc55_A2 (-1658687) /* Floating point value -0.001545 */
+#define BPF_Fs48000_Fc55_B1 (-2144072292) /* Floating point value -1.996823 */
#define BPF_Fs48000_Fc55_B2 1070386036 /* Floating point value 0.996875 */
/* Coefficients for centre frequency 66Hz */
#define BPF_Fs8000_Fc66_A0 13580189 /* Floating point value 0.012648 */
#define BPF_Fs8000_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs8000_Fc66_A2 -13580189 /* Floating point value -0.012648 */
-#define BPF_Fs8000_Fc66_B1 -2117161175 /* Floating point value -1.971760 */
+#define BPF_Fs8000_Fc66_A2 (-13580189) /* Floating point value -0.012648 */
+#define BPF_Fs8000_Fc66_B1 (-2117161175) /* Floating point value -1.971760 */
#define BPF_Fs8000_Fc66_B2 1046266945 /* Floating point value 0.974412 */
#define BPF_Fs11025_Fc66_A0 9888559 /* Floating point value 0.009209 */
#define BPF_Fs11025_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs11025_Fc66_A2 -9888559 /* Floating point value -0.009209 */
-#define BPF_Fs11025_Fc66_B1 -2125972738 /* Floating point value -1.979966 */
+#define BPF_Fs11025_Fc66_A2 (-9888559) /* Floating point value -0.009209 */
+#define BPF_Fs11025_Fc66_B1 (-2125972738) /* Floating point value -1.979966 */
#define BPF_Fs11025_Fc66_B2 1053735698 /* Floating point value 0.981368 */
#define BPF_Fs12000_Fc66_A0 9091954 /* Floating point value 0.008468 */
#define BPF_Fs12000_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs12000_Fc66_A2 -9091954 /* Floating point value -0.008468 */
-#define BPF_Fs12000_Fc66_B1 -2127818004 /* Floating point value -1.981685 */
+#define BPF_Fs12000_Fc66_A2 (-9091954) /* Floating point value -0.008468 */
+#define BPF_Fs12000_Fc66_B1 (-2127818004) /* Floating point value -1.981685 */
#define BPF_Fs12000_Fc66_B2 1055347356 /* Floating point value 0.982869 */
#define BPF_Fs16000_Fc66_A0 6833525 /* Floating point value 0.006364 */
#define BPF_Fs16000_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs16000_Fc66_A2 -6833525 /* Floating point value -0.006364 */
-#define BPF_Fs16000_Fc66_B1 -2132941739 /* Floating point value -1.986457 */
+#define BPF_Fs16000_Fc66_A2 (-6833525) /* Floating point value -0.006364 */
+#define BPF_Fs16000_Fc66_B1 (-2132941739) /* Floating point value -1.986457 */
#define BPF_Fs16000_Fc66_B2 1059916517 /* Floating point value 0.987124 */
#define BPF_Fs22050_Fc66_A0 4967309 /* Floating point value 0.004626 */
#define BPF_Fs22050_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs22050_Fc66_A2 -4967309 /* Floating point value -0.004626 */
-#define BPF_Fs22050_Fc66_B1 -2137056003 /* Floating point value -1.990288 */
+#define BPF_Fs22050_Fc66_A2 (-4967309) /* Floating point value -0.004626 */
+#define BPF_Fs22050_Fc66_B1 (-2137056003) /* Floating point value -1.990288 */
#define BPF_Fs22050_Fc66_B2 1063692170 /* Floating point value 0.990641 */
#define BPF_Fs24000_Fc66_A0 4565445 /* Floating point value 0.004252 */
#define BPF_Fs24000_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs24000_Fc66_A2 -4565445 /* Floating point value -0.004252 */
-#define BPF_Fs24000_Fc66_B1 -2137927842 /* Floating point value -1.991100 */
+#define BPF_Fs24000_Fc66_A2 (-4565445) /* Floating point value -0.004252 */
+#define BPF_Fs24000_Fc66_B1 (-2137927842) /* Floating point value -1.991100 */
#define BPF_Fs24000_Fc66_B2 1064505202 /* Floating point value 0.991398 */
#define BPF_Fs32000_Fc66_A0 3427761 /* Floating point value 0.003192 */
#define BPF_Fs32000_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs32000_Fc66_A2 -3427761 /* Floating point value -0.003192 */
-#define BPF_Fs32000_Fc66_B1 -2140369007 /* Floating point value -1.993374 */
+#define BPF_Fs32000_Fc66_A2 (-3427761) /* Floating point value -0.003192 */
+#define BPF_Fs32000_Fc66_B1 (-2140369007) /* Floating point value -1.993374 */
#define BPF_Fs32000_Fc66_B2 1066806920 /* Floating point value 0.993541 */
#define BPF_Fs44100_Fc66_A0 2489466 /* Floating point value 0.002318 */
#define BPF_Fs44100_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs44100_Fc66_A2 -2489466 /* Floating point value -0.002318 */
-#define BPF_Fs44100_Fc66_B1 -2142352342 /* Floating point value -1.995221 */
+#define BPF_Fs44100_Fc66_A2 (-2489466) /* Floating point value -0.002318 */
+#define BPF_Fs44100_Fc66_B1 (-2142352342) /* Floating point value -1.995221 */
#define BPF_Fs44100_Fc66_B2 1068705240 /* Floating point value 0.995309 */
#define BPF_Fs48000_Fc66_A0 2287632 /* Floating point value 0.002131 */
#define BPF_Fs48000_Fc66_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs48000_Fc66_A2 -2287632 /* Floating point value -0.002131 */
-#define BPF_Fs48000_Fc66_B1 -2142775436 /* Floating point value -1.995615 */
+#define BPF_Fs48000_Fc66_A2 (-2287632) /* Floating point value -0.002131 */
+#define BPF_Fs48000_Fc66_B1 (-2142775436) /* Floating point value -1.995615 */
#define BPF_Fs48000_Fc66_B2 1069113581 /* Floating point value 0.995690 */
/* Coefficients for centre frequency 78Hz */
#define BPF_Fs8000_Fc78_A0 19941180 /* Floating point value 0.018572 */
#define BPF_Fs8000_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs8000_Fc78_A2 -19941180 /* Floating point value -0.018572 */
-#define BPF_Fs8000_Fc78_B1 -2103186749 /* Floating point value -1.958745 */
+#define BPF_Fs8000_Fc78_A2 (-19941180) /* Floating point value -0.018572 */
+#define BPF_Fs8000_Fc78_B1 (-2103186749) /* Floating point value -1.958745 */
#define BPF_Fs8000_Fc78_B2 1033397648 /* Floating point value 0.962427 */
#define BPF_Fs11025_Fc78_A0 14543934 /* Floating point value 0.013545 */
#define BPF_Fs11025_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs11025_Fc78_A2 -14543934 /* Floating point value -0.013545 */
-#define BPF_Fs11025_Fc78_B1 -2115966638 /* Floating point value -1.970647 */
+#define BPF_Fs11025_Fc78_A2 (-14543934) /* Floating point value -0.013545 */
+#define BPF_Fs11025_Fc78_B1 (-2115966638) /* Floating point value -1.970647 */
#define BPF_Fs11025_Fc78_B2 1044317135 /* Floating point value 0.972596 */
#define BPF_Fs12000_Fc78_A0 13376999 /* Floating point value 0.012458 */
#define BPF_Fs12000_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs12000_Fc78_A2 -13376999 /* Floating point value -0.012458 */
-#define BPF_Fs12000_Fc78_B1 -2118651708 /* Floating point value -1.973148 */
+#define BPF_Fs12000_Fc78_A2 (-13376999) /* Floating point value -0.012458 */
+#define BPF_Fs12000_Fc78_B1 (-2118651708) /* Floating point value -1.973148 */
#define BPF_Fs12000_Fc78_B2 1046678029 /* Floating point value 0.974795 */
#define BPF_Fs16000_Fc78_A0 10064222 /* Floating point value 0.009373 */
#define BPF_Fs16000_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs16000_Fc78_A2 -10064222 /* Floating point value -0.009373 */
-#define BPF_Fs16000_Fc78_B1 -2126124342 /* Floating point value -1.980108 */
+#define BPF_Fs16000_Fc78_A2 (-10064222) /* Floating point value -0.009373 */
+#define BPF_Fs16000_Fc78_B1 (-2126124342) /* Floating point value -1.980108 */
#define BPF_Fs16000_Fc78_B2 1053380304 /* Floating point value 0.981037 */
#define BPF_Fs22050_Fc78_A0 7321780 /* Floating point value 0.006819 */
#define BPF_Fs22050_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs22050_Fc78_A2 -7321780 /* Floating point value -0.006819 */
-#define BPF_Fs22050_Fc78_B1 -2132143771 /* Floating point value -1.985714 */
+#define BPF_Fs22050_Fc78_A2 (-7321780) /* Floating point value -0.006819 */
+#define BPF_Fs22050_Fc78_B1 (-2132143771) /* Floating point value -1.985714 */
#define BPF_Fs22050_Fc78_B2 1058928700 /* Floating point value 0.986204 */
#define BPF_Fs24000_Fc78_A0 6730640 /* Floating point value 0.006268 */
#define BPF_Fs24000_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs24000_Fc78_A2 -6730640 /* Floating point value -0.006268 */
-#define BPF_Fs24000_Fc78_B1 -2133421607 /* Floating point value -1.986904 */
+#define BPF_Fs24000_Fc78_A2 (-6730640) /* Floating point value -0.006268 */
+#define BPF_Fs24000_Fc78_B1 (-2133421607) /* Floating point value -1.986904 */
#define BPF_Fs24000_Fc78_B2 1060124669 /* Floating point value 0.987318 */
#define BPF_Fs32000_Fc78_A0 5055965 /* Floating point value 0.004709 */
#define BPF_Fs32000_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs32000_Fc78_A2 -5055965 /* Floating point value -0.004709 */
-#define BPF_Fs32000_Fc78_B1 -2137003977 /* Floating point value -1.990240 */
+#define BPF_Fs32000_Fc78_A2 (-5055965) /* Floating point value -0.004709 */
+#define BPF_Fs32000_Fc78_B1 (-2137003977) /* Floating point value -1.990240 */
#define BPF_Fs32000_Fc78_B2 1063512802 /* Floating point value 0.990473 */
#define BPF_Fs44100_Fc78_A0 3673516 /* Floating point value 0.003421 */
#define BPF_Fs44100_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs44100_Fc78_A2 -3673516 /* Floating point value -0.003421 */
-#define BPF_Fs44100_Fc78_B1 -2139919394 /* Floating point value -1.992955 */
+#define BPF_Fs44100_Fc78_A2 (-3673516) /* Floating point value -0.003421 */
+#define BPF_Fs44100_Fc78_B1 (-2139919394) /* Floating point value -1.992955 */
#define BPF_Fs44100_Fc78_B2 1066309718 /* Floating point value 0.993078 */
#define BPF_Fs48000_Fc78_A0 3375990 /* Floating point value 0.003144 */
#define BPF_Fs48000_Fc78_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs48000_Fc78_A2 -3375990 /* Floating point value -0.003144 */
-#define BPF_Fs48000_Fc78_B1 -2140541906 /* Floating point value -1.993535 */
+#define BPF_Fs48000_Fc78_A2 (-3375990) /* Floating point value -0.003144 */
+#define BPF_Fs48000_Fc78_B1 (-2140541906) /* Floating point value -1.993535 */
#define BPF_Fs48000_Fc78_B2 1066911660 /* Floating point value 0.993639 */
/* Coefficients for centre frequency 90Hz */
#define BPF_Fs8000_Fc90_A0 24438548 /* Floating point value 0.022760 */
#define BPF_Fs8000_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs8000_Fc90_A2 -24438548 /* Floating point value -0.022760 */
-#define BPF_Fs8000_Fc90_B1 -2092801347 /* Floating point value -1.949073 */
+#define BPF_Fs8000_Fc90_A2 (-24438548) /* Floating point value -0.022760 */
+#define BPF_Fs8000_Fc90_B1 (-2092801347) /* Floating point value -1.949073 */
#define BPF_Fs8000_Fc90_B2 1024298757 /* Floating point value 0.953953 */
#define BPF_Fs11025_Fc90_A0 17844385 /* Floating point value 0.016619 */
#define BPF_Fs11025_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs11025_Fc90_A2 -17844385 /* Floating point value -0.016619 */
-#define BPF_Fs11025_Fc90_B1 -2108604921 /* Floating point value -1.963791 */
+#define BPF_Fs11025_Fc90_A2 (-17844385) /* Floating point value -0.016619 */
+#define BPF_Fs11025_Fc90_B1 (-2108604921) /* Floating point value -1.963791 */
#define BPF_Fs11025_Fc90_B2 1037639797 /* Floating point value 0.966377 */
#define BPF_Fs12000_Fc90_A0 16416707 /* Floating point value 0.015289 */
#define BPF_Fs12000_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs12000_Fc90_A2 -16416707 /* Floating point value -0.015289 */
-#define BPF_Fs12000_Fc90_B1 -2111922936 /* Floating point value -1.966882 */
+#define BPF_Fs12000_Fc90_A2 (-16416707) /* Floating point value -0.015289 */
+#define BPF_Fs12000_Fc90_B1 (-2111922936) /* Floating point value -1.966882 */
#define BPF_Fs12000_Fc90_B2 1040528216 /* Floating point value 0.969067 */
#define BPF_Fs16000_Fc90_A0 12359883 /* Floating point value 0.011511 */
#define BPF_Fs16000_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs16000_Fc90_A2 -12359883 /* Floating point value -0.011511 */
-#define BPF_Fs16000_Fc90_B1 -2121152162 /* Floating point value -1.975477 */
+#define BPF_Fs16000_Fc90_A2 (-12359883) /* Floating point value -0.011511 */
+#define BPF_Fs16000_Fc90_B1 (-2121152162) /* Floating point value -1.975477 */
#define BPF_Fs16000_Fc90_B2 1048735817 /* Floating point value 0.976711 */
#define BPF_Fs22050_Fc90_A0 8997173 /* Floating point value 0.008379 */
#define BPF_Fs22050_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs22050_Fc90_A2 -8997173 /* Floating point value -0.008379 */
-#define BPF_Fs22050_Fc90_B1 -2128580762 /* Floating point value -1.982395 */
+#define BPF_Fs22050_Fc90_A2 (-8997173) /* Floating point value -0.008379 */
+#define BPF_Fs22050_Fc90_B1 (-2128580762) /* Floating point value -1.982395 */
#define BPF_Fs22050_Fc90_B2 1055539113 /* Floating point value 0.983047 */
#define BPF_Fs24000_Fc90_A0 8271818 /* Floating point value 0.007704 */
#define BPF_Fs24000_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs24000_Fc90_A2 -8271818 /* Floating point value -0.007704 */
-#define BPF_Fs24000_Fc90_B1 -2130157013 /* Floating point value -1.983863 */
+#define BPF_Fs24000_Fc90_A2 (-8271818) /* Floating point value -0.007704 */
+#define BPF_Fs24000_Fc90_B1 (-2130157013) /* Floating point value -1.983863 */
#define BPF_Fs24000_Fc90_B2 1057006621 /* Floating point value 0.984414 */
#define BPF_Fs32000_Fc90_A0 6215918 /* Floating point value 0.005789 */
#define BPF_Fs32000_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs32000_Fc90_A2 -6215918 /* Floating point value -0.005789 */
-#define BPF_Fs32000_Fc90_B1 -2134574521 /* Floating point value -1.987977 */
+#define BPF_Fs32000_Fc90_A2 (-6215918) /* Floating point value -0.005789 */
+#define BPF_Fs32000_Fc90_B1 (-2134574521) /* Floating point value -1.987977 */
#define BPF_Fs32000_Fc90_B2 1061166033 /* Floating point value 0.988288 */
#define BPF_Fs44100_Fc90_A0 4517651 /* Floating point value 0.004207 */
#define BPF_Fs44100_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs44100_Fc90_A2 -4517651 /* Floating point value -0.004207 */
-#define BPF_Fs44100_Fc90_B1 -2138167926 /* Floating point value -1.991324 */
+#define BPF_Fs44100_Fc90_A2 (-4517651) /* Floating point value -0.004207 */
+#define BPF_Fs44100_Fc90_B1 (-2138167926) /* Floating point value -1.991324 */
#define BPF_Fs44100_Fc90_B2 1064601898 /* Floating point value 0.991488 */
#define BPF_Fs48000_Fc90_A0 4152024 /* Floating point value 0.003867 */
#define BPF_Fs48000_Fc90_A1 0 /* Floating point value 0.000000 */
-#define BPF_Fs48000_Fc90_A2 -4152024 /* Floating point value -0.003867 */
-#define BPF_Fs48000_Fc90_B1 -2138935002 /* Floating point value -1.992038 */
+#define BPF_Fs48000_Fc90_A2 (-4152024) /* Floating point value -0.003867 */
+#define BPF_Fs48000_Fc90_B1 (-2138935002) /* Floating point value -1.992038 */
#define BPF_Fs48000_Fc90_B2 1065341620 /* Floating point value 0.992177 */
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
index ab2a832..b6632a3 100644
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
@@ -334,10 +334,10 @@
pParams); /* New parameters */
LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[0],
- LVDBE_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ LVDBE_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2);
LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[1],
- LVDBE_BYPASS_MIXER_TC,pParams->SampleRate,2);
+ LVDBE_BYPASS_MIXER_TC,(LVM_Fs_en)pParams->SampleRate,2);
}
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
index 35e5bc8..a3623bc 100644
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
@@ -270,7 +270,7 @@
pBypassMixer_Instance->MixerStream[0].CallbackSet=0;
LVC_Mixer_Init(&pBypassMixer_Instance->MixerStream[0],0,0);
LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[0],
- LVDBE_BYPASS_MIXER_TC,pInstance->Params.SampleRate,2);
+ LVDBE_BYPASS_MIXER_TC,(LVM_Fs_en)pInstance->Params.SampleRate,2);
/*
* Setup the mixer gain for the unprocessed path
*/
@@ -280,8 +280,7 @@
pBypassMixer_Instance->MixerStream[1].CallbackSet=0;
LVC_Mixer_Init(&pBypassMixer_Instance->MixerStream[1],0x00007FFF,0x00007FFF);
LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[1],
- LVDBE_BYPASS_MIXER_TC,pInstance->Params.SampleRate,2);
+ LVDBE_BYPASS_MIXER_TC,(LVM_Fs_en)pInstance->Params.SampleRate,2);
return(LVDBE_SUCCESS);
}
-
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h
index f578db9..2712b2c 100644
--- a/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Coeffs.h
@@ -74,63 +74,63 @@
#define HPF_Fs22050_Gain6_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain6_Shift 1 /* Shift value */
/* Gain = 7.000000 dB */
-#define HPF_Fs22050_Gain7_A0 -164 /* Floating point value -0.005002 */
+#define HPF_Fs22050_Gain7_A0 (-164) /* Floating point value -0.005002 */
#define HPF_Fs22050_Gain7_A1 11311 /* Floating point value 0.345199 */
#define HPF_Fs22050_Gain7_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain7_B1 12125 /* Floating point value 0.370033 */
#define HPF_Fs22050_Gain7_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain7_Shift 2 /* Shift value */
/* Gain = 8.000000 dB */
-#define HPF_Fs22050_Gain8_A0 -864 /* Floating point value -0.026368 */
+#define HPF_Fs22050_Gain8_A0 (-864) /* Floating point value -0.026368 */
#define HPF_Fs22050_Gain8_A1 12012 /* Floating point value 0.366565 */
#define HPF_Fs22050_Gain8_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain8_B1 12125 /* Floating point value 0.370033 */
#define HPF_Fs22050_Gain8_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain8_Shift 2 /* Shift value */
/* Gain = 9.000000 dB */
-#define HPF_Fs22050_Gain9_A0 -1650 /* Floating point value -0.050340 */
+#define HPF_Fs22050_Gain9_A0 (-1650) /* Floating point value -0.050340 */
#define HPF_Fs22050_Gain9_A1 12797 /* Floating point value 0.390537 */
#define HPF_Fs22050_Gain9_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain9_B1 12125 /* Floating point value 0.370033 */
#define HPF_Fs22050_Gain9_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain9_Shift 2 /* Shift value */
/* Gain = 10.000000 dB */
-#define HPF_Fs22050_Gain10_A0 -2531 /* Floating point value -0.077238 */
+#define HPF_Fs22050_Gain10_A0 (-2531) /* Floating point value -0.077238 */
#define HPF_Fs22050_Gain10_A1 13679 /* Floating point value 0.417435 */
#define HPF_Fs22050_Gain10_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain10_B1 12125 /* Floating point value 0.370033 */
#define HPF_Fs22050_Gain10_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain10_Shift 2 /* Shift value */
/* Gain = 11.000000 dB */
-#define HPF_Fs22050_Gain11_A0 -3520 /* Floating point value -0.107417 */
+#define HPF_Fs22050_Gain11_A0 (-3520) /* Floating point value -0.107417 */
#define HPF_Fs22050_Gain11_A1 14667 /* Floating point value 0.447615 */
#define HPF_Fs22050_Gain11_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain11_B1 12125 /* Floating point value 0.370033 */
#define HPF_Fs22050_Gain11_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain11_Shift 2 /* Shift value */
/* Gain = 12.000000 dB */
-#define HPF_Fs22050_Gain12_A0 -4629 /* Floating point value -0.141279 */
+#define HPF_Fs22050_Gain12_A0 (-4629) /* Floating point value -0.141279 */
#define HPF_Fs22050_Gain12_A1 15777 /* Floating point value 0.481477 */
#define HPF_Fs22050_Gain12_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain12_B1 12125 /* Floating point value 0.370033 */
#define HPF_Fs22050_Gain12_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain12_Shift 2 /* Shift value */
/* Gain = 13.000000 dB */
-#define HPF_Fs22050_Gain13_A0 -2944 /* Floating point value -0.089849 */
+#define HPF_Fs22050_Gain13_A0 (-2944) /* Floating point value -0.089849 */
#define HPF_Fs22050_Gain13_A1 8531 /* Floating point value 0.260352 */
#define HPF_Fs22050_Gain13_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain13_B1 12125 /* Floating point value 0.370033 */
#define HPF_Fs22050_Gain13_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain13_Shift 3 /* Shift value */
/* Gain = 14.000000 dB */
-#define HPF_Fs22050_Gain14_A0 -3644 /* Floating point value -0.111215 */
+#define HPF_Fs22050_Gain14_A0 (-3644) /* Floating point value -0.111215 */
#define HPF_Fs22050_Gain14_A1 9231 /* Floating point value 0.281718 */
#define HPF_Fs22050_Gain14_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain14_B1 12125 /* Floating point value 0.370033 */
#define HPF_Fs22050_Gain14_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain14_Shift 3 /* Shift value */
/* Gain = 15.000000 dB */
-#define HPF_Fs22050_Gain15_A0 -4430 /* Floating point value -0.135187 */
+#define HPF_Fs22050_Gain15_A0 (-4430) /* Floating point value -0.135187 */
#define HPF_Fs22050_Gain15_A1 10017 /* Floating point value 0.305690 */
#define HPF_Fs22050_Gain15_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs22050_Gain15_B1 12125 /* Floating point value 0.370033 */
@@ -168,77 +168,77 @@
#define HPF_Fs24000_Gain4_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain4_Shift 1 /* Shift value */
/* Gain = 5.000000 dB */
-#define HPF_Fs24000_Gain5_A0 -275 /* Floating point value -0.008383 */
+#define HPF_Fs24000_Gain5_A0 (-275) /* Floating point value -0.008383 */
#define HPF_Fs24000_Gain5_A1 20860 /* Floating point value 0.636589 */
#define HPF_Fs24000_Gain5_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain5_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain5_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain5_Shift 1 /* Shift value */
/* Gain = 6.000000 dB */
-#define HPF_Fs24000_Gain6_A0 -1564 /* Floating point value -0.047733 */
+#define HPF_Fs24000_Gain6_A0 (-1564) /* Floating point value -0.047733 */
#define HPF_Fs24000_Gain6_A1 22149 /* Floating point value 0.675938 */
#define HPF_Fs24000_Gain6_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain6_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain6_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain6_Shift 1 /* Shift value */
/* Gain = 7.000000 dB */
-#define HPF_Fs24000_Gain7_A0 -1509 /* Floating point value -0.046051 */
+#define HPF_Fs24000_Gain7_A0 (-1509) /* Floating point value -0.046051 */
#define HPF_Fs24000_Gain7_A1 11826 /* Floating point value 0.360899 */
#define HPF_Fs24000_Gain7_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain7_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain7_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain7_Shift 2 /* Shift value */
/* Gain = 8.000000 dB */
-#define HPF_Fs24000_Gain8_A0 -2323 /* Floating point value -0.070878 */
+#define HPF_Fs24000_Gain8_A0 (-2323) /* Floating point value -0.070878 */
#define HPF_Fs24000_Gain8_A1 12640 /* Floating point value 0.385727 */
#define HPF_Fs24000_Gain8_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain8_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain8_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain8_Shift 2 /* Shift value */
/* Gain = 9.000000 dB */
-#define HPF_Fs24000_Gain9_A0 -3235 /* Floating point value -0.098736 */
+#define HPF_Fs24000_Gain9_A0 (-3235) /* Floating point value -0.098736 */
#define HPF_Fs24000_Gain9_A1 13552 /* Floating point value 0.413584 */
#define HPF_Fs24000_Gain9_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain9_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain9_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain9_Shift 2 /* Shift value */
/* Gain = 10.000000 dB */
-#define HPF_Fs24000_Gain10_A0 -4260 /* Floating point value -0.129992 */
+#define HPF_Fs24000_Gain10_A0 (-4260) /* Floating point value -0.129992 */
#define HPF_Fs24000_Gain10_A1 14577 /* Floating point value 0.444841 */
#define HPF_Fs24000_Gain10_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain10_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain10_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain10_Shift 2 /* Shift value */
/* Gain = 11.000000 dB */
-#define HPF_Fs24000_Gain11_A0 -5409 /* Floating point value -0.165062 */
+#define HPF_Fs24000_Gain11_A0 (-5409) /* Floating point value -0.165062 */
#define HPF_Fs24000_Gain11_A1 15726 /* Floating point value 0.479911 */
#define HPF_Fs24000_Gain11_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain11_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain11_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain11_Shift 2 /* Shift value */
/* Gain = 12.000000 dB */
-#define HPF_Fs24000_Gain12_A0 -6698 /* Floating point value -0.204411 */
+#define HPF_Fs24000_Gain12_A0 (-6698) /* Floating point value -0.204411 */
#define HPF_Fs24000_Gain12_A1 17015 /* Floating point value 0.519260 */
#define HPF_Fs24000_Gain12_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain12_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain12_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain12_Shift 2 /* Shift value */
/* Gain = 13.000000 dB */
-#define HPF_Fs24000_Gain13_A0 -4082 /* Floating point value -0.124576 */
+#define HPF_Fs24000_Gain13_A0 (-4082) /* Floating point value -0.124576 */
#define HPF_Fs24000_Gain13_A1 9253 /* Floating point value 0.282374 */
#define HPF_Fs24000_Gain13_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain13_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain13_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain13_Shift 3 /* Shift value */
/* Gain = 14.000000 dB */
-#define HPF_Fs24000_Gain14_A0 -4896 /* Floating point value -0.149404 */
+#define HPF_Fs24000_Gain14_A0 (-4896) /* Floating point value -0.149404 */
#define HPF_Fs24000_Gain14_A1 10066 /* Floating point value 0.307202 */
#define HPF_Fs24000_Gain14_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain14_B1 8780 /* Floating point value 0.267949 */
#define HPF_Fs24000_Gain14_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain14_Shift 3 /* Shift value */
/* Gain = 15.000000 dB */
-#define HPF_Fs24000_Gain15_A0 -5808 /* Floating point value -0.177261 */
+#define HPF_Fs24000_Gain15_A0 (-5808) /* Floating point value -0.177261 */
#define HPF_Fs24000_Gain15_A1 10979 /* Floating point value 0.335059 */
#define HPF_Fs24000_Gain15_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs24000_Gain15_B1 8780 /* Floating point value 0.267949 */
@@ -249,105 +249,105 @@
/* Coefficients for sample rate 32000Hz */
/* Gain = 1.000000 dB */
#define HPF_Fs32000_Gain1_A0 17225 /* Floating point value 0.525677 */
-#define HPF_Fs32000_Gain1_A1 -990 /* Floating point value -0.030227 */
+#define HPF_Fs32000_Gain1_A1 (-990) /* Floating point value -0.030227 */
#define HPF_Fs32000_Gain1_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain1_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain1_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain1_Shift 1 /* Shift value */
/* Gain = 2.000000 dB */
#define HPF_Fs32000_Gain2_A0 18337 /* Floating point value 0.559593 */
-#define HPF_Fs32000_Gain2_A1 -2102 /* Floating point value -0.064142 */
+#define HPF_Fs32000_Gain2_A1 (-2102) /* Floating point value -0.064142 */
#define HPF_Fs32000_Gain2_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain2_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain2_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain2_Shift 1 /* Shift value */
/* Gain = 3.000000 dB */
#define HPF_Fs32000_Gain3_A0 19584 /* Floating point value 0.597646 */
-#define HPF_Fs32000_Gain3_A1 -3349 /* Floating point value -0.102196 */
+#define HPF_Fs32000_Gain3_A1 (-3349) /* Floating point value -0.102196 */
#define HPF_Fs32000_Gain3_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain3_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain3_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain3_Shift 1 /* Shift value */
/* Gain = 4.000000 dB */
#define HPF_Fs32000_Gain4_A0 20983 /* Floating point value 0.640343 */
-#define HPF_Fs32000_Gain4_A1 -4748 /* Floating point value -0.144893 */
+#define HPF_Fs32000_Gain4_A1 (-4748) /* Floating point value -0.144893 */
#define HPF_Fs32000_Gain4_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain4_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain4_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain4_Shift 1 /* Shift value */
/* Gain = 5.000000 dB */
#define HPF_Fs32000_Gain5_A0 22553 /* Floating point value 0.688250 */
-#define HPF_Fs32000_Gain5_A1 -6318 /* Floating point value -0.192799 */
+#define HPF_Fs32000_Gain5_A1 (-6318) /* Floating point value -0.192799 */
#define HPF_Fs32000_Gain5_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain5_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain5_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain5_Shift 1 /* Shift value */
/* Gain = 6.000000 dB */
#define HPF_Fs32000_Gain6_A0 24314 /* Floating point value 0.742002 */
-#define HPF_Fs32000_Gain6_A1 -8079 /* Floating point value -0.246551 */
+#define HPF_Fs32000_Gain6_A1 (-8079) /* Floating point value -0.246551 */
#define HPF_Fs32000_Gain6_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain6_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain6_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain6_Shift 1 /* Shift value */
/* Gain = 7.000000 dB */
#define HPF_Fs32000_Gain7_A0 13176 /* Floating point value 0.402109 */
-#define HPF_Fs32000_Gain7_A1 -5040 /* Floating point value -0.153795 */
+#define HPF_Fs32000_Gain7_A1 (-5040) /* Floating point value -0.153795 */
#define HPF_Fs32000_Gain7_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain7_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain7_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain7_Shift 2 /* Shift value */
/* Gain = 8.000000 dB */
#define HPF_Fs32000_Gain8_A0 14288 /* Floating point value 0.436024 */
-#define HPF_Fs32000_Gain8_A1 -6151 /* Floating point value -0.187711 */
+#define HPF_Fs32000_Gain8_A1 (-6151) /* Floating point value -0.187711 */
#define HPF_Fs32000_Gain8_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain8_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain8_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain8_Shift 2 /* Shift value */
/* Gain = 9.000000 dB */
#define HPF_Fs32000_Gain9_A0 15535 /* Floating point value 0.474078 */
-#define HPF_Fs32000_Gain9_A1 -7398 /* Floating point value -0.225764 */
+#define HPF_Fs32000_Gain9_A1 (-7398) /* Floating point value -0.225764 */
#define HPF_Fs32000_Gain9_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain9_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain9_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain9_Shift 2 /* Shift value */
/* Gain = 10.000000 dB */
#define HPF_Fs32000_Gain10_A0 16934 /* Floating point value 0.516774 */
-#define HPF_Fs32000_Gain10_A1 -8797 /* Floating point value -0.268461 */
+#define HPF_Fs32000_Gain10_A1 (-8797) /* Floating point value -0.268461 */
#define HPF_Fs32000_Gain10_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain10_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain10_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain10_Shift 2 /* Shift value */
/* Gain = 11.000000 dB */
#define HPF_Fs32000_Gain11_A0 18503 /* Floating point value 0.564681 */
-#define HPF_Fs32000_Gain11_A1 -10367 /* Floating point value -0.316368 */
+#define HPF_Fs32000_Gain11_A1 (-10367) /* Floating point value -0.316368 */
#define HPF_Fs32000_Gain11_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain11_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain11_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain11_Shift 2 /* Shift value */
/* Gain = 12.000000 dB */
#define HPF_Fs32000_Gain12_A0 20265 /* Floating point value 0.618433 */
-#define HPF_Fs32000_Gain12_A1 -12128 /* Floating point value -0.370120 */
+#define HPF_Fs32000_Gain12_A1 (-12128) /* Floating point value -0.370120 */
#define HPF_Fs32000_Gain12_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain12_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain12_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain12_Shift 2 /* Shift value */
/* Gain = 13.000000 dB */
#define HPF_Fs32000_Gain13_A0 11147 /* Floating point value 0.340178 */
-#define HPF_Fs32000_Gain13_A1 -7069 /* Floating point value -0.215726 */
+#define HPF_Fs32000_Gain13_A1 (-7069) /* Floating point value -0.215726 */
#define HPF_Fs32000_Gain13_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain13_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain13_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain13_Shift 3 /* Shift value */
/* Gain = 14.000000 dB */
#define HPF_Fs32000_Gain14_A0 12258 /* Floating point value 0.374093 */
-#define HPF_Fs32000_Gain14_A1 -8180 /* Floating point value -0.249642 */
+#define HPF_Fs32000_Gain14_A1 (-8180) /* Floating point value -0.249642 */
#define HPF_Fs32000_Gain14_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain14_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain14_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain14_Shift 3 /* Shift value */
/* Gain = 15.000000 dB */
#define HPF_Fs32000_Gain15_A0 13505 /* Floating point value 0.412147 */
-#define HPF_Fs32000_Gain15_A1 -9427 /* Floating point value -0.287695 */
+#define HPF_Fs32000_Gain15_A1 (-9427) /* Floating point value -0.287695 */
#define HPF_Fs32000_Gain15_A2 0 /* Floating point value 0.000000 */
#define HPF_Fs32000_Gain15_B1 0 /* Floating point value -0.000000 */
#define HPF_Fs32000_Gain15_B2 0 /* Floating point value 0.000000 */
@@ -357,107 +357,107 @@
/* Coefficients for sample rate 44100Hz */
/* Gain = 1.000000 dB */
#define HPF_Fs44100_Gain1_A0 17442 /* Floating point value 0.532294 */
-#define HPF_Fs44100_Gain1_A1 -4761 /* Floating point value -0.145294 */
+#define HPF_Fs44100_Gain1_A1 (-4761) /* Floating point value -0.145294 */
#define HPF_Fs44100_Gain1_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain1_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain1_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain1_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain1_Shift 1 /* Shift value */
/* Gain = 2.000000 dB */
#define HPF_Fs44100_Gain2_A0 18797 /* Floating point value 0.573633 */
-#define HPF_Fs44100_Gain2_A1 -6116 /* Floating point value -0.186634 */
+#define HPF_Fs44100_Gain2_A1 (-6116) /* Floating point value -0.186634 */
#define HPF_Fs44100_Gain2_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain2_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain2_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain2_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain2_Shift 1 /* Shift value */
/* Gain = 3.000000 dB */
#define HPF_Fs44100_Gain3_A0 20317 /* Floating point value 0.620016 */
-#define HPF_Fs44100_Gain3_A1 -7635 /* Floating point value -0.233017 */
+#define HPF_Fs44100_Gain3_A1 (-7635) /* Floating point value -0.233017 */
#define HPF_Fs44100_Gain3_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain3_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain3_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain3_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain3_Shift 1 /* Shift value */
/* Gain = 4.000000 dB */
#define HPF_Fs44100_Gain4_A0 22022 /* Floating point value 0.672059 */
-#define HPF_Fs44100_Gain4_A1 -9341 /* Floating point value -0.285060 */
+#define HPF_Fs44100_Gain4_A1 (-9341) /* Floating point value -0.285060 */
#define HPF_Fs44100_Gain4_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain4_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain4_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain4_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain4_Shift 1 /* Shift value */
/* Gain = 5.000000 dB */
#define HPF_Fs44100_Gain5_A0 23935 /* Floating point value 0.730452 */
-#define HPF_Fs44100_Gain5_A1 -11254 /* Floating point value -0.343453 */
+#define HPF_Fs44100_Gain5_A1 (-11254) /* Floating point value -0.343453 */
#define HPF_Fs44100_Gain5_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain5_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain5_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain5_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain5_Shift 1 /* Shift value */
/* Gain = 6.000000 dB */
#define HPF_Fs44100_Gain6_A0 26082 /* Floating point value 0.795970 */
-#define HPF_Fs44100_Gain6_A1 -13401 /* Floating point value -0.408971 */
+#define HPF_Fs44100_Gain6_A1 (-13401) /* Floating point value -0.408971 */
#define HPF_Fs44100_Gain6_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain6_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain6_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain6_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain6_Shift 1 /* Shift value */
/* Gain = 7.000000 dB */
#define HPF_Fs44100_Gain7_A0 14279 /* Floating point value 0.435774 */
-#define HPF_Fs44100_Gain7_A1 -7924 /* Floating point value -0.241815 */
+#define HPF_Fs44100_Gain7_A1 (-7924) /* Floating point value -0.241815 */
#define HPF_Fs44100_Gain7_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain7_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain7_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain7_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain7_Shift 2 /* Shift value */
/* Gain = 8.000000 dB */
#define HPF_Fs44100_Gain8_A0 15634 /* Floating point value 0.477113 */
-#define HPF_Fs44100_Gain8_A1 -9278 /* Floating point value -0.283154 */
+#define HPF_Fs44100_Gain8_A1 (-9278) /* Floating point value -0.283154 */
#define HPF_Fs44100_Gain8_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain8_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain8_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain8_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain8_Shift 2 /* Shift value */
/* Gain = 9.000000 dB */
#define HPF_Fs44100_Gain9_A0 17154 /* Floating point value 0.523496 */
-#define HPF_Fs44100_Gain9_A1 -10798 /* Floating point value -0.329537 */
+#define HPF_Fs44100_Gain9_A1 (-10798) /* Floating point value -0.329537 */
#define HPF_Fs44100_Gain9_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain9_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain9_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain9_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain9_Shift 2 /* Shift value */
/* Gain = 10.000000 dB */
#define HPF_Fs44100_Gain10_A0 18859 /* Floating point value 0.575539 */
-#define HPF_Fs44100_Gain10_A1 -12504 /* Floating point value -0.381580 */
+#define HPF_Fs44100_Gain10_A1 (-12504) /* Floating point value -0.381580 */
#define HPF_Fs44100_Gain10_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain10_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain10_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain10_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain10_Shift 2 /* Shift value */
/* Gain = 11.000000 dB */
#define HPF_Fs44100_Gain11_A0 20773 /* Floating point value 0.633932 */
-#define HPF_Fs44100_Gain11_A1 -14417 /* Floating point value -0.439973 */
+#define HPF_Fs44100_Gain11_A1 (-14417) /* Floating point value -0.439973 */
#define HPF_Fs44100_Gain11_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain11_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain11_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain11_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain11_Shift 2 /* Shift value */
/* Gain = 12.000000 dB */
#define HPF_Fs44100_Gain12_A0 22920 /* Floating point value 0.699450 */
-#define HPF_Fs44100_Gain12_A1 -16564 /* Floating point value -0.505491 */
+#define HPF_Fs44100_Gain12_A1 (-16564) /* Floating point value -0.505491 */
#define HPF_Fs44100_Gain12_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain12_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain12_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain12_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain12_Shift 2 /* Shift value */
/* Gain = 13.000000 dB */
#define HPF_Fs44100_Gain13_A0 12694 /* Floating point value 0.387399 */
-#define HPF_Fs44100_Gain13_A1 -9509 /* Floating point value -0.290189 */
+#define HPF_Fs44100_Gain13_A1 (-9509) /* Floating point value -0.290189 */
#define HPF_Fs44100_Gain13_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain13_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain13_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain13_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain13_Shift 3 /* Shift value */
/* Gain = 14.000000 dB */
#define HPF_Fs44100_Gain14_A0 14049 /* Floating point value 0.428738 */
-#define HPF_Fs44100_Gain14_A1 -10864 /* Floating point value -0.331528 */
+#define HPF_Fs44100_Gain14_A1 (-10864) /* Floating point value -0.331528 */
#define HPF_Fs44100_Gain14_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain14_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain14_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain14_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain14_Shift 3 /* Shift value */
/* Gain = 15.000000 dB */
#define HPF_Fs44100_Gain15_A0 15569 /* Floating point value 0.475121 */
-#define HPF_Fs44100_Gain15_A1 -12383 /* Floating point value -0.377912 */
+#define HPF_Fs44100_Gain15_A1 (-12383) /* Floating point value -0.377912 */
#define HPF_Fs44100_Gain15_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs44100_Gain15_B1 -7173 /* Floating point value -0.218894 */
+#define HPF_Fs44100_Gain15_B1 (-7173) /* Floating point value -0.218894 */
#define HPF_Fs44100_Gain15_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs44100_Gain15_Shift 3 /* Shift value */
@@ -465,107 +465,107 @@
/* Coefficients for sample rate 48000Hz */
/* Gain = 1.000000 dB */
#define HPF_Fs48000_Gain1_A0 17491 /* Floating point value 0.533777 */
-#define HPF_Fs48000_Gain1_A1 -5606 /* Floating point value -0.171082 */
+#define HPF_Fs48000_Gain1_A1 (-5606) /* Floating point value -0.171082 */
#define HPF_Fs48000_Gain1_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain1_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain1_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain1_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain1_Shift 1 /* Shift value */
/* Gain = 2.000000 dB */
#define HPF_Fs48000_Gain2_A0 18900 /* Floating point value 0.576779 */
-#define HPF_Fs48000_Gain2_A1 -7015 /* Floating point value -0.214085 */
+#define HPF_Fs48000_Gain2_A1 (-7015) /* Floating point value -0.214085 */
#define HPF_Fs48000_Gain2_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain2_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain2_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain2_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain2_Shift 1 /* Shift value */
/* Gain = 3.000000 dB */
#define HPF_Fs48000_Gain3_A0 20481 /* Floating point value 0.625029 */
-#define HPF_Fs48000_Gain3_A1 -8596 /* Floating point value -0.262335 */
+#define HPF_Fs48000_Gain3_A1 (-8596) /* Floating point value -0.262335 */
#define HPF_Fs48000_Gain3_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain3_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain3_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain3_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain3_Shift 1 /* Shift value */
/* Gain = 4.000000 dB */
#define HPF_Fs48000_Gain4_A0 22255 /* Floating point value 0.679167 */
-#define HPF_Fs48000_Gain4_A1 -10370 /* Floating point value -0.316472 */
+#define HPF_Fs48000_Gain4_A1 (-10370) /* Floating point value -0.316472 */
#define HPF_Fs48000_Gain4_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain4_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain4_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain4_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain4_Shift 1 /* Shift value */
/* Gain = 5.000000 dB */
#define HPF_Fs48000_Gain5_A0 24245 /* Floating point value 0.739910 */
-#define HPF_Fs48000_Gain5_A1 -12361 /* Floating point value -0.377215 */
+#define HPF_Fs48000_Gain5_A1 (-12361) /* Floating point value -0.377215 */
#define HPF_Fs48000_Gain5_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain5_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain5_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain5_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain5_Shift 1 /* Shift value */
/* Gain = 6.000000 dB */
#define HPF_Fs48000_Gain6_A0 26479 /* Floating point value 0.808065 */
-#define HPF_Fs48000_Gain6_A1 -14594 /* Floating point value -0.445370 */
+#define HPF_Fs48000_Gain6_A1 (-14594) /* Floating point value -0.445370 */
#define HPF_Fs48000_Gain6_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain6_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain6_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain6_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain6_Shift 1 /* Shift value */
/* Gain = 7.000000 dB */
#define HPF_Fs48000_Gain7_A0 14527 /* Floating point value 0.443318 */
-#define HPF_Fs48000_Gain7_A1 -8570 /* Floating point value -0.261540 */
+#define HPF_Fs48000_Gain7_A1 (-8570) /* Floating point value -0.261540 */
#define HPF_Fs48000_Gain7_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain7_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain7_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain7_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain7_Shift 2 /* Shift value */
/* Gain = 8.000000 dB */
#define HPF_Fs48000_Gain8_A0 15936 /* Floating point value 0.486321 */
-#define HPF_Fs48000_Gain8_A1 -9979 /* Floating point value -0.304543 */
+#define HPF_Fs48000_Gain8_A1 (-9979) /* Floating point value -0.304543 */
#define HPF_Fs48000_Gain8_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain8_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain8_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain8_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain8_Shift 2 /* Shift value */
/* Gain = 9.000000 dB */
#define HPF_Fs48000_Gain9_A0 17517 /* Floating point value 0.534571 */
-#define HPF_Fs48000_Gain9_A1 -11560 /* Floating point value -0.352793 */
+#define HPF_Fs48000_Gain9_A1 (-11560) /* Floating point value -0.352793 */
#define HPF_Fs48000_Gain9_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain9_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain9_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain9_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain9_Shift 2 /* Shift value */
/* Gain = 10.000000 dB */
#define HPF_Fs48000_Gain10_A0 19291 /* Floating point value 0.588708 */
-#define HPF_Fs48000_Gain10_A1 -13334 /* Floating point value -0.406930 */
+#define HPF_Fs48000_Gain10_A1 (-13334) /* Floating point value -0.406930 */
#define HPF_Fs48000_Gain10_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain10_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain10_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain10_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain10_Shift 2 /* Shift value */
/* Gain = 11.000000 dB */
#define HPF_Fs48000_Gain11_A0 21281 /* Floating point value 0.649452 */
-#define HPF_Fs48000_Gain11_A1 -15325 /* Floating point value -0.467674 */
+#define HPF_Fs48000_Gain11_A1 (-15325) /* Floating point value -0.467674 */
#define HPF_Fs48000_Gain11_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain11_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain11_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain11_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain11_Shift 2 /* Shift value */
/* Gain = 12.000000 dB */
#define HPF_Fs48000_Gain12_A0 23515 /* Floating point value 0.717607 */
-#define HPF_Fs48000_Gain12_A1 -17558 /* Floating point value -0.535829 */
+#define HPF_Fs48000_Gain12_A1 (-17558) /* Floating point value -0.535829 */
#define HPF_Fs48000_Gain12_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain12_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain12_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain12_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain12_Shift 2 /* Shift value */
/* Gain = 13.000000 dB */
#define HPF_Fs48000_Gain13_A0 13041 /* Floating point value 0.397982 */
-#define HPF_Fs48000_Gain13_A1 -10056 /* Floating point value -0.306877 */
+#define HPF_Fs48000_Gain13_A1 (-10056) /* Floating point value -0.306877 */
#define HPF_Fs48000_Gain13_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain13_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain13_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain13_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain13_Shift 3 /* Shift value */
/* Gain = 14.000000 dB */
#define HPF_Fs48000_Gain14_A0 14450 /* Floating point value 0.440984 */
-#define HPF_Fs48000_Gain14_A1 -11465 /* Floating point value -0.349880 */
+#define HPF_Fs48000_Gain14_A1 (-11465) /* Floating point value -0.349880 */
#define HPF_Fs48000_Gain14_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain14_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain14_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain14_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain14_Shift 3 /* Shift value */
/* Gain = 15.000000 dB */
#define HPF_Fs48000_Gain15_A0 16031 /* Floating point value 0.489234 */
-#define HPF_Fs48000_Gain15_A1 -13046 /* Floating point value -0.398130 */
+#define HPF_Fs48000_Gain15_A1 (-13046) /* Floating point value -0.398130 */
#define HPF_Fs48000_Gain15_A2 0 /* Floating point value 0.000000 */
-#define HPF_Fs48000_Gain15_B1 -8780 /* Floating point value -0.267949 */
+#define HPF_Fs48000_Gain15_B1 (-8780) /* Floating point value -0.267949 */
#define HPF_Fs48000_Gain15_B2 0 /* Floating point value 0.000000 */
#define HPF_Fs48000_Gain15_Shift 3 /* Shift value */
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h b/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h
index 2d1cf42..2e85f77 100644
--- a/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Private.h
@@ -81,7 +81,7 @@
#define LVM_TE_MIN_EFFECTLEVEL 0 /*TE Minimum EffectLevel*/
#define LVM_TE_MAX_EFFECTLEVEL 15 /*TE Maximum Effect level*/
-#define LVM_VC_MIN_EFFECTLEVEL -96 /*VC Minimum EffectLevel*/
+#define LVM_VC_MIN_EFFECTLEVEL (-96) /*VC Minimum EffectLevel*/
#define LVM_VC_MAX_EFFECTLEVEL 0 /*VC Maximum Effect level*/
#define LVM_BE_MIN_EFFECTLEVEL 0 /*BE Minimum EffectLevel*/
@@ -89,7 +89,7 @@
#define LVM_EQNB_MIN_BAND_FREQ 20 /*EQNB Minimum Band Frequency*/
#define LVM_EQNB_MAX_BAND_FREQ 24000 /*EQNB Maximum Band Frequency*/
-#define LVM_EQNB_MIN_BAND_GAIN -15 /*EQNB Minimum Band Frequency*/
+#define LVM_EQNB_MIN_BAND_GAIN (-15) /*EQNB Minimum Band Frequency*/
#define LVM_EQNB_MAX_BAND_GAIN 15 /*EQNB Maximum Band Frequency*/
#define LVM_EQNB_MIN_QFACTOR 25 /*EQNB Minimum Q Factor*/
#define LVM_EQNB_MAX_QFACTOR 1200 /*EQNB Maximum Q Factor*/
@@ -103,7 +103,7 @@
#define LVM_VC_MIXER_TIME 100 /*VC mixer time*/
#define LVM_VC_BALANCE_MAX 96 /*VC balance max value*/
-#define LVM_VC_BALANCE_MIN -96 /*VC balance min value*/
+#define LVM_VC_BALANCE_MIN (-96) /*VC balance min value*/
/* Algorithm masks */
#define LVM_CS_MASK 1
diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Types.h b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h
index 0c6fb25..68c55f7 100644
--- a/media/libeffects/lvm/lib/Common/lib/LVM_Types.h
+++ b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h
@@ -73,10 +73,10 @@
#define LVM_MEM_EXTERNAL 8 /* External (slow) access memory */
/* Platform specific */
-#define LVM_PERSISTENT LVM_MEM_PARTITION0+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL
-#define LVM_PERSISTENT_DATA LVM_MEM_PARTITION1+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL
-#define LVM_PERSISTENT_COEF LVM_MEM_PARTITION2+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL
-#define LVM_SCRATCH LVM_MEM_PARTITION3+LVM_MEM_SCRATCH+LVM_MEM_INTERNAL
+#define LVM_PERSISTENT (LVM_MEM_PARTITION0+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL)
+#define LVM_PERSISTENT_DATA (LVM_MEM_PARTITION1+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL)
+#define LVM_PERSISTENT_COEF (LVM_MEM_PARTITION2+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL)
+#define LVM_SCRATCH (LVM_MEM_PARTITION3+LVM_MEM_SCRATCH+LVM_MEM_INTERNAL)
/****************************************************************************************/
/* */
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h
index 87d7145..95212f2 100644
--- a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Coeffs.h
@@ -27,21 +27,21 @@
/************************************************************************************/
#define LVEQNB_GAINSHIFT 11 /* As a power of 2 */
-#define LVEQNB_Gain_Neg15_dB -1684 /* Floating point value -0.822172 */
-#define LVEQNB_Gain_Neg14_dB -1639 /* Floating point value -0.800474 */
-#define LVEQNB_Gain_Neg13_dB -1590 /* Floating point value -0.776128 */
-#define LVEQNB_Gain_Neg12_dB -1534 /* Floating point value -0.748811 */
-#define LVEQNB_Gain_Neg11_dB -1471 /* Floating point value -0.718162 */
-#define LVEQNB_Gain_Neg10_dB -1400 /* Floating point value -0.683772 */
-#define LVEQNB_Gain_Neg9_dB -1321 /* Floating point value -0.645187 */
-#define LVEQNB_Gain_Neg8_dB -1233 /* Floating point value -0.601893 */
-#define LVEQNB_Gain_Neg7_dB -1133 /* Floating point value -0.553316 */
-#define LVEQNB_Gain_Neg6_dB -1022 /* Floating point value -0.498813 */
-#define LVEQNB_Gain_Neg5_dB -896 /* Floating point value -0.437659 */
-#define LVEQNB_Gain_Neg4_dB -756 /* Floating point value -0.369043 */
-#define LVEQNB_Gain_Neg3_dB -598 /* Floating point value -0.292054 */
-#define LVEQNB_Gain_Neg2_dB -421 /* Floating point value -0.205672 */
-#define LVEQNB_Gain_Neg1_dB -223 /* Floating point value -0.108749 */
+#define LVEQNB_Gain_Neg15_dB (-1684) /* Floating point value -0.822172 */
+#define LVEQNB_Gain_Neg14_dB (-1639) /* Floating point value -0.800474 */
+#define LVEQNB_Gain_Neg13_dB (-1590) /* Floating point value -0.776128 */
+#define LVEQNB_Gain_Neg12_dB (-1534) /* Floating point value -0.748811 */
+#define LVEQNB_Gain_Neg11_dB (-1471) /* Floating point value -0.718162 */
+#define LVEQNB_Gain_Neg10_dB (-1400) /* Floating point value -0.683772 */
+#define LVEQNB_Gain_Neg9_dB (-1321) /* Floating point value -0.645187 */
+#define LVEQNB_Gain_Neg8_dB (-1233) /* Floating point value -0.601893 */
+#define LVEQNB_Gain_Neg7_dB (-1133) /* Floating point value -0.553316 */
+#define LVEQNB_Gain_Neg6_dB (-1022) /* Floating point value -0.498813 */
+#define LVEQNB_Gain_Neg5_dB (-896) /* Floating point value -0.437659 */
+#define LVEQNB_Gain_Neg4_dB (-756) /* Floating point value -0.369043 */
+#define LVEQNB_Gain_Neg3_dB (-598) /* Floating point value -0.292054 */
+#define LVEQNB_Gain_Neg2_dB (-421) /* Floating point value -0.205672 */
+#define LVEQNB_Gain_Neg1_dB (-223) /* Floating point value -0.108749 */
#define LVEQNB_Gain_0_dB 0 /* Floating point value 0.000000 */
#define LVEQNB_Gain_1_dB 250 /* Floating point value 0.122018 */
#define LVEQNB_Gain_2_dB 530 /* Floating point value 0.258925 */
diff --git a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h
index 1d8bedd..03522fb 100644
--- a/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h
+++ b/media/libeffects/lvm/lib/SpectrumAnalyzer/src/LVPSA_Private.h
@@ -52,7 +52,7 @@
#define LVPSA_NBANDSMIN 1 /* Minimum number of frequency band */
#define LVPSA_NBANDSMAX 30 /* Maximum number of frequency band */
#define LVPSA_MAXCENTERFREQ 20000 /* Maximum possible center frequency */
-#define LVPSA_MINPOSTGAIN -15 /* Minimum possible post gain */
+#define LVPSA_MINPOSTGAIN (-15) /* Minimum possible post gain */
#define LVPSA_MAXPOSTGAIN 15 /* Maximum possible post gain */
#define LVPSA_MINQFACTOR 25 /* Minimum possible Q factor */
#define LVPSA_MAXQFACTOR 1200 /* Maximum possible Q factor */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h
index 1d55281..3e640cb 100644
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Headphone_Coeffs.h
@@ -27,127 +27,127 @@
/* Stereo Enhancer coefficients for 8000 Hz sample rate, scaled with 0.161258 */
#define CS_MIDDLE_8000_A0 7462 /* Floating point value 0.227720 */
-#define CS_MIDDLE_8000_A1 -7049 /* Floating point value -0.215125 */
+#define CS_MIDDLE_8000_A1 (-7049) /* Floating point value -0.215125 */
#define CS_MIDDLE_8000_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_8000_B1 -30209 /* Floating point value -0.921899 */
+#define CS_MIDDLE_8000_B1 (-30209) /* Floating point value -0.921899 */
#define CS_MIDDLE_8000_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_8000_SCALE 15
#define CS_SIDE_8000_A0 20036 /* Floating point value 0.611441 */
-#define CS_SIDE_8000_A1 -12463 /* Floating point value -0.380344 */
-#define CS_SIDE_8000_A2 -7573 /* Floating point value -0.231097 */
-#define CS_SIDE_8000_B1 -20397 /* Floating point value -0.622470 */
-#define CS_SIDE_8000_B2 -4285 /* Floating point value -0.130759 */
+#define CS_SIDE_8000_A1 (-12463) /* Floating point value -0.380344 */
+#define CS_SIDE_8000_A2 (-7573) /* Floating point value -0.231097 */
+#define CS_SIDE_8000_B1 (-20397) /* Floating point value -0.622470 */
+#define CS_SIDE_8000_B2 (-4285) /* Floating point value -0.130759 */
#define CS_SIDE_8000_SCALE 15
/* Stereo Enhancer coefficients for 11025Hz sample rate, scaled with 0.162943 */
#define CS_MIDDLE_11025_A0 7564 /* Floating point value 0.230838 */
-#define CS_MIDDLE_11025_A1 -7260 /* Floating point value -0.221559 */
+#define CS_MIDDLE_11025_A1 (-7260) /* Floating point value -0.221559 */
#define CS_MIDDLE_11025_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_11025_B1 -30902 /* Floating point value -0.943056 */
+#define CS_MIDDLE_11025_B1 (-30902) /* Floating point value -0.943056 */
#define CS_MIDDLE_11025_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_11025_SCALE 15
#define CS_SIDE_11025_A0 18264 /* Floating point value 0.557372 */
-#define CS_SIDE_11025_A1 -12828 /* Floating point value -0.391490 */
-#define CS_SIDE_11025_A2 -5436 /* Floating point value -0.165881 */
-#define CS_SIDE_11025_B1 -28856 /* Floating point value -0.880608 */
+#define CS_SIDE_11025_A1 (-12828) /* Floating point value -0.391490 */
+#define CS_SIDE_11025_A2 (-5436) /* Floating point value -0.165881 */
+#define CS_SIDE_11025_B1 (-28856) /* Floating point value -0.880608 */
#define CS_SIDE_11025_B2 1062 /* Floating point value 0.032397 */
#define CS_SIDE_11025_SCALE 15
/* Stereo Enhancer coefficients for 12000Hz sample rate, scaled with 0.162191 */
#define CS_MIDDLE_12000_A0 7534 /* Floating point value 0.229932 */
-#define CS_MIDDLE_12000_A1 -7256 /* Floating point value -0.221436 */
+#define CS_MIDDLE_12000_A1 (-7256) /* Floating point value -0.221436 */
#define CS_MIDDLE_12000_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_12000_B1 -31051 /* Floating point value -0.947616 */
+#define CS_MIDDLE_12000_B1 (-31051) /* Floating point value -0.947616 */
#define CS_MIDDLE_12000_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_12000_SCALE 15
#define CS_SIDE_12000_A0 18298 /* Floating point value 0.558398 */
-#define CS_SIDE_12000_A1 -12852 /* Floating point value -0.392211 */
-#define CS_SIDE_12000_A2 -5446 /* Floating point value -0.166187 */
-#define CS_SIDE_12000_B1 -29247 /* Floating point value -0.892550 */
+#define CS_SIDE_12000_A1 (-12852) /* Floating point value -0.392211 */
+#define CS_SIDE_12000_A2 (-5446) /* Floating point value -0.166187 */
+#define CS_SIDE_12000_B1 (-29247) /* Floating point value -0.892550 */
#define CS_SIDE_12000_B2 1077 /* Floating point value 0.032856 */
#define CS_SIDE_12000_SCALE 15
/* Stereo Enhancer coefficients for 16000Hz sample rate, scaled with 0.162371 */
#define CS_MIDDLE_16000_A0 7558 /* Floating point value 0.230638 */
-#define CS_MIDDLE_16000_A1 -7348 /* Floating point value -0.224232 */
+#define CS_MIDDLE_16000_A1 (-7348) /* Floating point value -0.224232 */
#define CS_MIDDLE_16000_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_16000_B1 -31475 /* Floating point value -0.960550 */
+#define CS_MIDDLE_16000_B1 (-31475) /* Floating point value -0.960550 */
#define CS_MIDDLE_16000_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_16000_SCALE 15
#define CS_SIDE_16000_A0 8187 /* Floating point value 0.499695 */
-#define CS_SIDE_16000_A1 -5825 /* Floating point value -0.355543 */
-#define CS_SIDE_16000_A2 -2362 /* Floating point value -0.144152 */
-#define CS_SIDE_16000_B1 -17216 /* Floating point value -1.050788 */
+#define CS_SIDE_16000_A1 (-5825) /* Floating point value -0.355543 */
+#define CS_SIDE_16000_A2 (-2362) /* Floating point value -0.144152 */
+#define CS_SIDE_16000_B1 (-17216) /* Floating point value -1.050788 */
#define CS_SIDE_16000_B2 2361 /* Floating point value 0.144104 */
#define CS_SIDE_16000_SCALE 14
/* Stereo Enhancer coefficients for 22050Hz sample rate, scaled with 0.160781 */
#define CS_MIDDLE_22050_A0 7496 /* Floating point value 0.228749 */
-#define CS_MIDDLE_22050_A1 -7344 /* Floating point value -0.224128 */
+#define CS_MIDDLE_22050_A1 (-7344) /* Floating point value -0.224128 */
#define CS_MIDDLE_22050_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_22050_B1 -31826 /* Floating point value -0.971262 */
+#define CS_MIDDLE_22050_B1 (-31826) /* Floating point value -0.971262 */
#define CS_MIDDLE_22050_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_22050_SCALE 15
#define CS_SIDE_22050_A0 7211 /* Floating point value 0.440112 */
-#define CS_SIDE_22050_A1 -4278 /* Floating point value -0.261096 */
-#define CS_SIDE_22050_A2 -2933 /* Floating point value -0.179016 */
-#define CS_SIDE_22050_B1 -18297 /* Floating point value -1.116786 */
+#define CS_SIDE_22050_A1 (-4278) /* Floating point value -0.261096 */
+#define CS_SIDE_22050_A2 (-2933) /* Floating point value -0.179016 */
+#define CS_SIDE_22050_B1 (-18297) /* Floating point value -1.116786 */
#define CS_SIDE_22050_B2 2990 /* Floating point value 0.182507 */
#define CS_SIDE_22050_SCALE 14
/* Stereo Enhancer coefficients for 24000Hz sample rate, scaled with 0.161882 */
#define CS_MIDDLE_24000_A0 7550 /* Floating point value 0.230395 */
-#define CS_MIDDLE_24000_A1 -7409 /* Floating point value -0.226117 */
+#define CS_MIDDLE_24000_A1 (-7409) /* Floating point value -0.226117 */
#define CS_MIDDLE_24000_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_24000_B1 -31902 /* Floating point value -0.973573 */
+#define CS_MIDDLE_24000_B1 (-31902) /* Floating point value -0.973573 */
#define CS_MIDDLE_24000_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_24000_SCALE 15
#define CS_SIDE_24000_A0 6796 /* Floating point value 0.414770 */
-#define CS_SIDE_24000_A1 -4705 /* Floating point value -0.287182 */
-#define CS_SIDE_24000_A2 -2090 /* Floating point value -0.127588 */
-#define CS_SIDE_24000_B1 -20147 /* Floating point value -1.229648 */
+#define CS_SIDE_24000_A1 (-4705) /* Floating point value -0.287182 */
+#define CS_SIDE_24000_A2 (-2090) /* Floating point value -0.127588 */
+#define CS_SIDE_24000_B1 (-20147) /* Floating point value -1.229648 */
#define CS_SIDE_24000_B2 4623 /* Floating point value 0.282177 */
#define CS_SIDE_24000_SCALE 14
/* Stereo Enhancer coefficients for 32000Hz sample rate, scaled with 0.160322 */
#define CS_MIDDLE_32000_A0 7484 /* Floating point value 0.228400 */
-#define CS_MIDDLE_32000_A1 -7380 /* Floating point value -0.225214 */
+#define CS_MIDDLE_32000_A1 (-7380) /* Floating point value -0.225214 */
#define CS_MIDDLE_32000_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_32000_B1 -32117 /* Floating point value -0.980126 */
+#define CS_MIDDLE_32000_B1 (-32117) /* Floating point value -0.980126 */
#define CS_MIDDLE_32000_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_32000_SCALE 15
#define CS_SIDE_32000_A0 5973 /* Floating point value 0.364579 */
-#define CS_SIDE_32000_A1 -3397 /* Floating point value -0.207355 */
-#define CS_SIDE_32000_A2 -2576 /* Floating point value -0.157224 */
-#define CS_SIDE_32000_B1 -20877 /* Floating point value -1.274231 */
+#define CS_SIDE_32000_A1 (-3397) /* Floating point value -0.207355 */
+#define CS_SIDE_32000_A2 (-2576) /* Floating point value -0.157224 */
+#define CS_SIDE_32000_B1 (-20877) /* Floating point value -1.274231 */
#define CS_SIDE_32000_B2 5120 /* Floating point value 0.312495 */
#define CS_SIDE_32000_SCALE 14
/* Stereo Enhancer coefficients for 44100Hz sample rate, scaled with 0.163834 */
#define CS_MIDDLE_44100_A0 7654 /* Floating point value 0.233593 */
-#define CS_MIDDLE_44100_A1 -7577 /* Floating point value -0.231225 */
+#define CS_MIDDLE_44100_A1 (-7577) /* Floating point value -0.231225 */
#define CS_MIDDLE_44100_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_44100_B1 -32294 /* Floating point value -0.985545 */
+#define CS_MIDDLE_44100_B1 (-32294) /* Floating point value -0.985545 */
#define CS_MIDDLE_44100_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_44100_SCALE 15
#define CS_SIDE_44100_A0 4662 /* Floating point value 0.284573 */
-#define CS_SIDE_44100_A1 -4242 /* Floating point value -0.258910 */
-#define CS_SIDE_44100_A2 -420 /* Floating point value -0.025662 */
-#define CS_SIDE_44100_B1 -25760 /* Floating point value -1.572248 */
+#define CS_SIDE_44100_A1 (-4242) /* Floating point value -0.258910 */
+#define CS_SIDE_44100_A2 (-420) /* Floating point value -0.025662 */
+#define CS_SIDE_44100_B1 (-25760) /* Floating point value -1.572248 */
#define CS_SIDE_44100_B2 9640 /* Floating point value 0.588399 */
#define CS_SIDE_44100_SCALE 14
/* Stereo Enhancer coefficients for 48000Hz sample rate, scaled with 0.164402 */
#define CS_MIDDLE_48000_A0 7682 /* Floating point value 0.234445 */
-#define CS_MIDDLE_48000_A1 -7611 /* Floating point value -0.232261 */
+#define CS_MIDDLE_48000_A1 (-7611) /* Floating point value -0.232261 */
#define CS_MIDDLE_48000_A2 0 /* Floating point value 0.000000 */
-#define CS_MIDDLE_48000_B1 -32333 /* Floating point value -0.986713 */
+#define CS_MIDDLE_48000_B1 (-32333) /* Floating point value -0.986713 */
#define CS_MIDDLE_48000_B2 0 /* Floating point value 0.000000 */
#define CS_MIDDLE_48000_SCALE 15
#define CS_SIDE_48000_A0 4466 /* Floating point value 0.272606 */
-#define CS_SIDE_48000_A1 -4374 /* Floating point value -0.266952 */
-#define CS_SIDE_48000_A2 -93 /* Floating point value -0.005654 */
-#define CS_SIDE_48000_B1 -26495 /* Floating point value -1.617141 */
+#define CS_SIDE_48000_A1 (-4374) /* Floating point value -0.266952 */
+#define CS_SIDE_48000_A2 (-93) /* Floating point value -0.005654 */
+#define CS_SIDE_48000_B1 (-26495) /* Floating point value -1.617141 */
#define CS_SIDE_48000_B2 10329 /* Floating point value 0.630405 */
#define CS_SIDE_48000_SCALE 14
@@ -171,73 +171,73 @@
/* Reverb coefficients for 8000 Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_8000_A0 21865 /* Floating point value 0.667271 */
-#define CS_REVERB_8000_A1 -21865 /* Floating point value -0.667271 */
+#define CS_REVERB_8000_A1 (-21865) /* Floating point value -0.667271 */
#define CS_REVERB_8000_A2 0 /* Floating point value 0.000000 */
-#define CS_REVERB_8000_B1 -21895 /* Floating point value -0.668179 */
+#define CS_REVERB_8000_B1 (-21895) /* Floating point value -0.668179 */
#define CS_REVERB_8000_B2 0 /* Floating point value 0.000000 */
#define CS_REVERB_8000_SCALE 15
/* Reverb coefficients for 11025Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_11025_A0 22926 /* Floating point value 0.699638 */
-#define CS_REVERB_11025_A1 -22926 /* Floating point value -0.699638 */
+#define CS_REVERB_11025_A1 (-22926) /* Floating point value -0.699638 */
#define CS_REVERB_11025_A2 0 /* Floating point value 0.000000 */
-#define CS_REVERB_11025_B1 -24546 /* Floating point value -0.749096 */
+#define CS_REVERB_11025_B1 (-24546) /* Floating point value -0.749096 */
#define CS_REVERB_11025_B2 0 /* Floating point value 0.000000 */
#define CS_REVERB_11025_SCALE 15
/* Reverb coefficients for 12000Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_12000_A0 23165 /* Floating point value 0.706931 */
-#define CS_REVERB_12000_A1 -23165 /* Floating point value -0.706931 */
+#define CS_REVERB_12000_A1 (-23165) /* Floating point value -0.706931 */
#define CS_REVERB_12000_A2 0 /* Floating point value 0.000000 */
-#define CS_REVERB_12000_B1 -25144 /* Floating point value -0.767327 */
+#define CS_REVERB_12000_B1 (-25144) /* Floating point value -0.767327 */
#define CS_REVERB_12000_B2 0 /* Floating point value 0.000000 */
#define CS_REVERB_12000_SCALE 15
/* Reverb coefficients for 16000Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_16000_A0 23864 /* Floating point value 0.728272 */
-#define CS_REVERB_16000_A1 -23864 /* Floating point value -0.728272 */
+#define CS_REVERB_16000_A1 (-23864) /* Floating point value -0.728272 */
#define CS_REVERB_16000_A2 0 /* Floating point value 0.000000 */
-#define CS_REVERB_16000_B1 -26892 /* Floating point value -0.820679 */
+#define CS_REVERB_16000_B1 (-26892) /* Floating point value -0.820679 */
#define CS_REVERB_16000_B2 0 /* Floating point value 0.000000 */
#define CS_REVERB_16000_SCALE 15
/* Reverb coefficients for 22050Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_22050_A0 16921 /* Floating point value 0.516396 */
#define CS_REVERB_22050_A1 0 /* Floating point value 0.000000 */
-#define CS_REVERB_22050_A2 -16921 /* Floating point value -0.516396 */
-#define CS_REVERB_22050_B1 -16991 /* Floating point value -0.518512 */
-#define CS_REVERB_22050_B2 -9535 /* Floating point value -0.290990 */
+#define CS_REVERB_22050_A2 (-16921) /* Floating point value -0.516396 */
+#define CS_REVERB_22050_B1 (-16991) /* Floating point value -0.518512 */
+#define CS_REVERB_22050_B2 (-9535) /* Floating point value -0.290990 */
#define CS_REVERB_22050_SCALE 15
/* Reverb coefficients for 24000Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_24000_A0 15714 /* Floating point value 0.479565 */
#define CS_REVERB_24000_A1 0 /* Floating point value 0.000000 */
-#define CS_REVERB_24000_A2 -15714 /* Floating point value -0.479565 */
-#define CS_REVERB_24000_B1 -20898 /* Floating point value -0.637745 */
-#define CS_REVERB_24000_B2 -6518 /* Floating point value -0.198912 */
+#define CS_REVERB_24000_A2 (-15714) /* Floating point value -0.479565 */
+#define CS_REVERB_24000_B1 (-20898) /* Floating point value -0.637745 */
+#define CS_REVERB_24000_B2 (-6518) /* Floating point value -0.198912 */
#define CS_REVERB_24000_SCALE 15
/* Reverb coefficients for 32000Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_32000_A0 12463 /* Floating point value 0.380349 */
#define CS_REVERB_32000_A1 0 /* Floating point value 0.000000 */
-#define CS_REVERB_32000_A2 -12463 /* Floating point value -0.380349 */
-#define CS_REVERB_32000_B1 -31158 /* Floating point value -0.950873 */
+#define CS_REVERB_32000_A2 (-12463) /* Floating point value -0.380349 */
+#define CS_REVERB_32000_B1 (-31158) /* Floating point value -0.950873 */
#define CS_REVERB_32000_B2 1610 /* Floating point value 0.049127 */
#define CS_REVERB_32000_SCALE 15
/* Reverb coefficients for 44100Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_44100_A0 4872 /* Floating point value 0.297389 */
#define CS_REVERB_44100_A1 0 /* Floating point value 0.000000 */
-#define CS_REVERB_44100_A2 -4872 /* Floating point value -0.297389 */
-#define CS_REVERB_44100_B1 -19668 /* Floating point value -1.200423 */
+#define CS_REVERB_44100_A2 (-4872) /* Floating point value -0.297389 */
+#define CS_REVERB_44100_B1 (-19668) /* Floating point value -1.200423 */
#define CS_REVERB_44100_B2 4203 /* Floating point value 0.256529 */
#define CS_REVERB_44100_SCALE 14
/* Reverb coefficients for 48000Hz sample rate, scaled with 1.038030 */
#define CS_REVERB_48000_A0 4566 /* Floating point value 0.278661 */
#define CS_REVERB_48000_A1 0 /* Floating point value 0.000000 */
-#define CS_REVERB_48000_A2 -4566 /* Floating point value -0.278661 */
-#define CS_REVERB_48000_B1 -20562 /* Floating point value -1.254993 */
+#define CS_REVERB_48000_A2 (-4566) /* Floating point value -0.278661 */
+#define CS_REVERB_48000_B1 (-20562) /* Floating point value -1.254993 */
#define CS_REVERB_48000_B2 4970 /* Floating point value 0.303347 */
#define CS_REVERB_48000_SCALE 14
@@ -257,128 +257,128 @@
/* Equaliser coefficients for 8000 Hz sample rate, CS scaled with 1.038497 and CSEX scaled with 0.775480 */
#define CS_EQUALISER_8000_A0 20698 /* Floating point value 1.263312 */
-#define CS_EQUALISER_8000_A1 -9859 /* Floating point value -0.601748 */
-#define CS_EQUALISER_8000_A2 -4599 /* Floating point value -0.280681 */
-#define CS_EQUALISER_8000_B1 -7797 /* Floating point value -0.475865 */
-#define CS_EQUALISER_8000_B2 -6687 /* Floating point value -0.408154 */
+#define CS_EQUALISER_8000_A1 (-9859) /* Floating point value -0.601748 */
+#define CS_EQUALISER_8000_A2 (-4599) /* Floating point value -0.280681 */
+#define CS_EQUALISER_8000_B1 (-7797) /* Floating point value -0.475865 */
+#define CS_EQUALISER_8000_B2 (-6687) /* Floating point value -0.408154 */
#define CS_EQUALISER_8000_SCALE 14
#define CSEX_EQUALISER_8000_A0 30912 /* Floating point value 0.943357 */
-#define CSEX_EQUALISER_8000_A1 -14724 /* Floating point value -0.449345 */
-#define CSEX_EQUALISER_8000_A2 -6868 /* Floating point value -0.209594 */
-#define CSEX_EQUALISER_8000_B1 -15593 /* Floating point value -0.475865 */
-#define CSEX_EQUALISER_8000_B2 -13374 /* Floating point value -0.408154 */
+#define CSEX_EQUALISER_8000_A1 (-14724) /* Floating point value -0.449345 */
+#define CSEX_EQUALISER_8000_A2 (-6868) /* Floating point value -0.209594 */
+#define CSEX_EQUALISER_8000_B1 (-15593) /* Floating point value -0.475865 */
+#define CSEX_EQUALISER_8000_B2 (-13374) /* Floating point value -0.408154 */
#define CSEX_EQUALISER_8000_SCALE 15
/* Equaliser coefficients for 11025Hz sample rate, CS scaled with 1.027761 and CSEX scaled with 0.767463 */
#define CS_EQUALISER_11025_A0 18041 /* Floating point value 1.101145 */
#define CS_EQUALISER_11025_A1 2278 /* Floating point value 0.139020 */
-#define CS_EQUALISER_11025_A2 -14163 /* Floating point value -0.864423 */
+#define CS_EQUALISER_11025_A2 (-14163) /* Floating point value -0.864423 */
#define CS_EQUALISER_11025_B1 402 /* Floating point value 0.024541 */
-#define CS_EQUALISER_11025_B2 -14892 /* Floating point value -0.908930 */
+#define CS_EQUALISER_11025_B2 (-14892) /* Floating point value -0.908930 */
#define CS_EQUALISER_11025_SCALE 14
#define CSEX_EQUALISER_11025_A0 31983 /* Floating point value 0.976058 */
-#define CSEX_EQUALISER_11025_A1 -22784 /* Floating point value -0.695326 */
-#define CSEX_EQUALISER_11025_A2 -2976 /* Floating point value -0.090809 */
-#define CSEX_EQUALISER_11025_B1 -20008 /* Floating point value -0.610594 */
-#define CSEX_EQUALISER_11025_B2 -10196 /* Floating point value -0.311149 */
+#define CSEX_EQUALISER_11025_A1 (-22784) /* Floating point value -0.695326 */
+#define CSEX_EQUALISER_11025_A2 (-2976) /* Floating point value -0.090809 */
+#define CSEX_EQUALISER_11025_B1 (-20008) /* Floating point value -0.610594 */
+#define CSEX_EQUALISER_11025_B2 (-10196) /* Floating point value -0.311149 */
#define CSEX_EQUALISER_11025_SCALE 15
/* Equaliser coefficients for 12000Hz sample rate, CS scaled with 1.032521 and CSEX scaled with 0.771017 */
#define CS_EQUALISER_12000_A0 20917 /* Floating point value 1.276661 */
-#define CS_EQUALISER_12000_A1 -16671 /* Floating point value -1.017519 */
-#define CS_EQUALISER_12000_A2 -723 /* Floating point value -0.044128 */
-#define CS_EQUALISER_12000_B1 -11954 /* Floating point value -0.729616 */
-#define CS_EQUALISER_12000_B2 -3351 /* Floating point value -0.204532 */
+#define CS_EQUALISER_12000_A1 (-16671) /* Floating point value -1.017519 */
+#define CS_EQUALISER_12000_A2 (-723) /* Floating point value -0.044128 */
+#define CS_EQUALISER_12000_B1 (-11954) /* Floating point value -0.729616 */
+#define CS_EQUALISER_12000_B2 (-3351) /* Floating point value -0.204532 */
#define CS_EQUALISER_12000_SCALE 14
#define CSEX_EQUALISER_12000_A0 16500 /* Floating point value 1.007095 */
-#define CSEX_EQUALISER_12000_A1 -14285 /* Floating point value -0.871912 */
+#define CSEX_EQUALISER_12000_A1 (-14285) /* Floating point value -0.871912 */
#define CSEX_EQUALISER_12000_A2 381 /* Floating point value 0.023232 */
-#define CSEX_EQUALISER_12000_B1 -12220 /* Floating point value -0.745857 */
-#define CSEX_EQUALISER_12000_B2 -3099 /* Floating point value -0.189171 */
+#define CSEX_EQUALISER_12000_B1 (-12220) /* Floating point value -0.745857 */
+#define CSEX_EQUALISER_12000_B2 (-3099) /* Floating point value -0.189171 */
#define CSEX_EQUALISER_12000_SCALE 14
/* Equaliser coefficients for 16000Hz sample rate, CS scaled with 1.031378 and CSEX scaled with 0.770164 */
#define CS_EQUALISER_16000_A0 20998 /* Floating point value 1.281629 */
-#define CS_EQUALISER_16000_A1 -17627 /* Floating point value -1.075872 */
-#define CS_EQUALISER_16000_A2 -678 /* Floating point value -0.041365 */
-#define CS_EQUALISER_16000_B1 -11882 /* Floating point value -0.725239 */
-#define CS_EQUALISER_16000_B2 -3676 /* Floating point value -0.224358 */
+#define CS_EQUALISER_16000_A1 (-17627) /* Floating point value -1.075872 */
+#define CS_EQUALISER_16000_A2 (-678) /* Floating point value -0.041365 */
+#define CS_EQUALISER_16000_B1 (-11882) /* Floating point value -0.725239 */
+#define CS_EQUALISER_16000_B2 (-3676) /* Floating point value -0.224358 */
#define CS_EQUALISER_16000_SCALE 14
#define CSEX_EQUALISER_16000_A0 17713 /* Floating point value 1.081091 */
-#define CSEX_EQUALISER_16000_A1 -14208 /* Floating point value -0.867183 */
-#define CSEX_EQUALISER_16000_A2 -1151 /* Floating point value -0.070247 */
-#define CSEX_EQUALISER_16000_B1 -8440 /* Floating point value -0.515121 */
-#define CSEX_EQUALISER_16000_B2 -6978 /* Floating point value -0.425893 */
+#define CSEX_EQUALISER_16000_A1 (-14208) /* Floating point value -0.867183 */
+#define CSEX_EQUALISER_16000_A2 (-1151) /* Floating point value -0.070247 */
+#define CSEX_EQUALISER_16000_B1 (-8440) /* Floating point value -0.515121 */
+#define CSEX_EQUALISER_16000_B2 (-6978) /* Floating point value -0.425893 */
#define CSEX_EQUALISER_16000_SCALE 14
/* Equaliser coefficients for 22050Hz sample rate, CS scaled with 1.041576 and CSEX scaled with 0.777779 */
#define CS_EQUALISER_22050_A0 22751 /* Floating point value 1.388605 */
-#define CS_EQUALISER_22050_A1 -21394 /* Floating point value -1.305799 */
+#define CS_EQUALISER_22050_A1 (-21394) /* Floating point value -1.305799 */
#define CS_EQUALISER_22050_A2 654 /* Floating point value 0.039922 */
-#define CS_EQUALISER_22050_B1 -11788 /* Floating point value -0.719494 */
-#define CS_EQUALISER_22050_B2 -3985 /* Floating point value -0.243245 */
+#define CS_EQUALISER_22050_B1 (-11788) /* Floating point value -0.719494 */
+#define CS_EQUALISER_22050_B2 (-3985) /* Floating point value -0.243245 */
#define CS_EQUALISER_22050_SCALE 14
#define CSEX_EQUALISER_22050_A0 20855 /* Floating point value 1.272910 */
-#define CSEX_EQUALISER_22050_A1 -21971 /* Floating point value -1.341014 */
+#define CSEX_EQUALISER_22050_A1 (-21971) /* Floating point value -1.341014 */
#define CSEX_EQUALISER_22050_A2 2744 /* Floating point value 0.167462 */
-#define CSEX_EQUALISER_22050_B1 -10063 /* Floating point value -0.614219 */
-#define CSEX_EQUALISER_22050_B2 -5659 /* Floating point value -0.345384 */
+#define CSEX_EQUALISER_22050_B1 (-10063) /* Floating point value -0.614219 */
+#define CSEX_EQUALISER_22050_B2 (-5659) /* Floating point value -0.345384 */
#define CSEX_EQUALISER_22050_SCALE 14
/* Equaliser coefficients for 24000Hz sample rate, CS scaled with 1.034495 and CSEX scaled with 0.772491 */
#define CS_EQUALISER_24000_A0 23099 /* Floating point value 1.409832 */
-#define CS_EQUALISER_24000_A1 -23863 /* Floating point value -1.456506 */
+#define CS_EQUALISER_24000_A1 (-23863) /* Floating point value -1.456506 */
#define CS_EQUALISER_24000_A2 2481 /* Floating point value 0.151410 */
-#define CS_EQUALISER_24000_B1 -13176 /* Floating point value -0.804201 */
-#define CS_EQUALISER_24000_B2 -2683 /* Floating point value -0.163783 */
+#define CS_EQUALISER_24000_B1 (-13176) /* Floating point value -0.804201 */
+#define CS_EQUALISER_24000_B2 (-2683) /* Floating point value -0.163783 */
#define CS_EQUALISER_24000_SCALE 14
#define CSEX_EQUALISER_24000_A0 21286 /* Floating point value 1.299198 */
-#define CSEX_EQUALISER_24000_A1 -23797 /* Floating point value -1.452447 */
+#define CSEX_EQUALISER_24000_A1 (-23797) /* Floating point value -1.452447 */
#define CSEX_EQUALISER_24000_A2 3940 /* Floating point value 0.240489 */
-#define CSEX_EQUALISER_24000_B1 -10966 /* Floating point value -0.669303 */
-#define CSEX_EQUALISER_24000_B2 -4833 /* Floating point value -0.294984 */
+#define CSEX_EQUALISER_24000_B1 (-10966) /* Floating point value -0.669303 */
+#define CSEX_EQUALISER_24000_B2 (-4833) /* Floating point value -0.294984 */
#define CSEX_EQUALISER_24000_SCALE 14
/* Equaliser coefficients for 32000Hz sample rate, CS scaled with 1.044559 and CSEX scaled with 0.780006 */
#define CS_EQUALISER_32000_A0 25575 /* Floating point value 1.560988 */
-#define CS_EQUALISER_32000_A1 -30765 /* Floating point value -1.877724 */
+#define CS_EQUALISER_32000_A1 (-30765) /* Floating point value -1.877724 */
#define CS_EQUALISER_32000_A2 6386 /* Floating point value 0.389741 */
-#define CS_EQUALISER_32000_B1 -14867 /* Floating point value -0.907410 */
-#define CS_EQUALISER_32000_B2 -1155 /* Floating point value -0.070489 */
+#define CS_EQUALISER_32000_B1 (-14867) /* Floating point value -0.907410 */
+#define CS_EQUALISER_32000_B2 (-1155) /* Floating point value -0.070489 */
#define CS_EQUALISER_32000_SCALE 14
#define CSEX_EQUALISER_32000_A0 14623 /* Floating point value 1.785049 */
-#define CSEX_EQUALISER_32000_A1 -18297 /* Floating point value -2.233497 */
+#define CSEX_EQUALISER_32000_A1 (-18297) /* Floating point value -2.233497 */
#define CSEX_EQUALISER_32000_A2 4313 /* Floating point value 0.526431 */
-#define CSEX_EQUALISER_32000_B1 -3653 /* Floating point value -0.445939 */
-#define CSEX_EQUALISER_32000_B2 -4280 /* Floating point value -0.522446 */
+#define CSEX_EQUALISER_32000_B1 (-3653) /* Floating point value -0.445939 */
+#define CSEX_EQUALISER_32000_B2 (-4280) /* Floating point value -0.522446 */
#define CSEX_EQUALISER_32000_SCALE 13
/* Equaliser coefficients for 44100Hz sample rate, CS scaled with 1.022170 and CSEX scaled with 0.763288 */
#define CS_EQUALISER_44100_A0 13304 /* Floating point value 1.623993 */
-#define CS_EQUALISER_44100_A1 -18602 /* Floating point value -2.270743 */
+#define CS_EQUALISER_44100_A1 (-18602) /* Floating point value -2.270743 */
#define CS_EQUALISER_44100_A2 5643 /* Floating point value 0.688829 */
-#define CS_EQUALISER_44100_B1 -9152 /* Floating point value -1.117190 */
+#define CS_EQUALISER_44100_B1 (-9152) /* Floating point value -1.117190 */
#define CS_EQUALISER_44100_B2 1067 /* Floating point value 0.130208 */
#define CS_EQUALISER_44100_SCALE 13
#define CSEX_EQUALISER_44100_A0 16616 /* Floating point value 2.028315 */
-#define CSEX_EQUALISER_44100_A1 -23613 /* Floating point value -2.882459 */
+#define CSEX_EQUALISER_44100_A1 (-23613) /* Floating point value -2.882459 */
#define CSEX_EQUALISER_44100_A2 7410 /* Floating point value 0.904535 */
-#define CSEX_EQUALISER_44100_B1 -4860 /* Floating point value -0.593308 */
-#define CSEX_EQUALISER_44100_B2 -3161 /* Floating point value -0.385816 */
+#define CSEX_EQUALISER_44100_B1 (-4860) /* Floating point value -0.593308 */
+#define CSEX_EQUALISER_44100_B2 (-3161) /* Floating point value -0.385816 */
#define CSEX_EQUALISER_44100_SCALE 13
/* Equaliser coefficients for 48000Hz sample rate, CS scaled with 1.018635 and CSEX scaled with 0.760648 */
#define CS_EQUALISER_48000_A0 13445 /* Floating point value 1.641177 */
-#define CS_EQUALISER_48000_A1 -19372 /* Floating point value -2.364687 */
+#define CS_EQUALISER_48000_A1 (-19372) /* Floating point value -2.364687 */
#define CS_EQUALISER_48000_A2 6225 /* Floating point value 0.759910 */
-#define CS_EQUALISER_48000_B1 -9558 /* Floating point value -1.166774 */
+#define CS_EQUALISER_48000_B1 (-9558) /* Floating point value -1.166774 */
#define CS_EQUALISER_48000_B2 1459 /* Floating point value 0.178074 */
#define CS_EQUALISER_48000_SCALE 13
#define CSEX_EQUALISER_48000_A0 17200 /* Floating point value 2.099655 */
-#define CSEX_EQUALISER_48000_A1 -25110 /* Floating point value -3.065220 */
+#define CSEX_EQUALISER_48000_A1 (-25110) /* Floating point value -3.065220 */
#define CSEX_EQUALISER_48000_A2 8277 /* Floating point value 1.010417 */
-#define CSEX_EQUALISER_48000_B1 -5194 /* Floating point value -0.634021 */
-#define CSEX_EQUALISER_48000_B2 -2845 /* Floating point value -0.347332 */
+#define CSEX_EQUALISER_48000_B1 (-5194) /* Floating point value -0.634021 */
+#define CSEX_EQUALISER_48000_B2 (-2845) /* Floating point value -0.347332 */
#define CSEX_EQUALISER_48000_SCALE 13
diff --git a/media/libeffects/lvm/wrapper/Android.mk b/media/libeffects/lvm/wrapper/Android.mk
index 68ba34c..f2c6fd9 100644
--- a/media/libeffects/lvm/wrapper/Android.mk
+++ b/media/libeffects/lvm/wrapper/Android.mk
@@ -6,6 +6,7 @@
LOCAL_ARM_MODE := arm
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \
Bundle/EffectBundle.cpp
@@ -18,6 +19,7 @@
LOCAL_STATIC_LIBRARIES += libmusicbundle
LOCAL_SHARED_LIBRARIES := \
+ liblog \
libcutils \
libdl
@@ -35,6 +37,7 @@
LOCAL_ARM_MODE := arm
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \
Reverb/EffectReverb.cpp
@@ -47,6 +50,7 @@
LOCAL_STATIC_LIBRARIES += libreverb
LOCAL_SHARED_LIBRARIES := \
+ liblog \
libcutils \
libdl
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index a0af3cf..3ab4124 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -16,7 +16,7 @@
*/
#define LOG_TAG "Bundle"
-#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
+#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array)[0])
//#define LOG_NDEBUG 0
#include <assert.h>
@@ -25,28 +25,28 @@
#include <stdlib.h>
#include <string.h>
-#include <cutils/log.h>
+#include <log/log.h>
+
#include "EffectBundle.h"
#include "math.h"
-
// effect_handle_t interface implementation for bass boost
extern "C" const struct effect_interface_s gLvmEffectInterface;
#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
- if (LvmStatus == LVM_NULLADDRESS){\
+ if ((LvmStatus) == LVM_NULLADDRESS){\
ALOGV("\tLVM_ERROR : Parameter error - "\
"null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
}\
- if (LvmStatus == LVM_ALIGNMENTERROR){\
+ if ((LvmStatus) == LVM_ALIGNMENTERROR){\
ALOGV("\tLVM_ERROR : Parameter error - "\
"bad alignment returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
}\
- if (LvmStatus == LVM_INVALIDNUMSAMPLES){\
+ if ((LvmStatus) == LVM_INVALIDNUMSAMPLES){\
ALOGV("\tLVM_ERROR : Parameter error - "\
"bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
}\
- if (LvmStatus == LVM_OUTOFRANGE){\
+ if ((LvmStatus) == LVM_OUTOFRANGE){\
ALOGV("\tLVM_ERROR : Parameter error - "\
"out of range returned by %s in %s\n", callingFunc, calledFunc);\
}\
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
index 4dc8b45..fc82dd1 100644
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -16,7 +16,7 @@
*/
#define LOG_TAG "Reverb"
-#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
+#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array)[0])
//#define LOG_NDEBUG 0
#include <assert.h>
@@ -25,7 +25,8 @@
#include <stdlib.h>
#include <string.h>
-#include <cutils/log.h>
+#include <log/log.h>
+
#include "EffectReverb.h"
// from Reverb/lib
#include "LVREV.h"
@@ -34,15 +35,15 @@
extern "C" const struct effect_interface_s gReverbInterface;
#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
- if (LvmStatus == LVREV_NULLADDRESS){\
+ if ((LvmStatus) == LVREV_NULLADDRESS){\
ALOGV("\tLVREV_ERROR : Parameter error - "\
"null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
}\
- if (LvmStatus == LVREV_INVALIDNUMSAMPLES){\
+ if ((LvmStatus) == LVREV_INVALIDNUMSAMPLES){\
ALOGV("\tLVREV_ERROR : Parameter error - "\
"bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
}\
- if (LvmStatus == LVREV_OUTOFRANGE){\
+ if ((LvmStatus) == LVREV_OUTOFRANGE){\
ALOGV("\tLVREV_ERROR : Parameter error - "\
"out of range returned by %s in %s\n", callingFunc, calledFunc);\
}\
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
index 7c15b18..8165f5a 100644
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
@@ -30,7 +30,7 @@
#define LVREV_MAX_REVERB_LEVEL 2000
#define LVREV_MAX_FRAME_SIZE 2560
#define LVREV_CUP_LOAD_ARM9E 470 // Expressed in 0.1 MIPS
-#define LVREV_MEM_USAGE 71+(LVREV_MAX_FRAME_SIZE>>7) // Expressed in kB
+#define LVREV_MEM_USAGE (71+(LVREV_MAX_FRAME_SIZE>>7)) // Expressed in kB
//#define LVM_PCM
typedef struct _LPFPair_t
diff --git a/media/libeffects/preprocessing/Android.mk b/media/libeffects/preprocessing/Android.mk
index 4e4b094..bc03686 100644
--- a/media/libeffects/preprocessing/Android.mk
+++ b/media/libeffects/preprocessing/Android.mk
@@ -7,6 +7,7 @@
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_RELATIVE_PATH := soundfx
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \
PreProcessing.cpp
@@ -16,8 +17,6 @@
external/webrtc/webrtc/modules/audio_processing/include \
$(call include-path-for, audio-effects)
-LOCAL_C_INCLUDES += $(call include-path-for, speex)
-
LOCAL_SHARED_LIBRARIES := \
libwebrtc_audio_preprocessing \
libspeexresampler \
diff --git a/media/libeffects/proxy/Android.mk b/media/libeffects/proxy/Android.mk
index 2ba452e..eeba73f 100644
--- a/media/libeffects/proxy/Android.mk
+++ b/media/libeffects/proxy/Android.mk
@@ -18,7 +18,7 @@
LOCAL_MODULE_RELATIVE_PATH := soundfx
LOCAL_MODULE_TAGS := optional
-
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES := \
EffectProxy.cpp
diff --git a/media/libeffects/proxy/EffectProxy.cpp b/media/libeffects/proxy/EffectProxy.cpp
index 62d3fd3..0eddc15 100644
--- a/media/libeffects/proxy/EffectProxy.cpp
+++ b/media/libeffects/proxy/EffectProxy.cpp
@@ -17,13 +17,16 @@
#define LOG_TAG "EffectProxy"
//#define LOG_NDEBUG 0
-#include <cutils/log.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <new>
+
#include <EffectProxy.h>
+
+#include <log/log.h>
#include <utils/threads.h>
+
#include <media/EffectsFactoryApi.h>
namespace android {
@@ -91,6 +94,7 @@
delete[] pContext->sube;
delete[] pContext->desc;
delete[] pContext->aeli;
+ delete pContext;
return -EINVAL;
}
// Check which is the HW descriptor and copy the descriptors
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index 3cb13f2..db4d009 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -18,17 +18,20 @@
#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
//
#define LOG_NDEBUG 0
-#include <cutils/log.h>
+
#include <assert.h>
#include <stdlib.h>
#include <string.h>
+
#include <new>
+
+#include <log/log.h>
+
#include "AudioEqualizer.h"
#include "AudioBiquadFilter.h"
#include "AudioFormatAdapter.h"
#include <audio_effects/effect_equalizer.h>
-
// effect_handle_t interface implementation for equalizer effect
extern "C" const struct effect_interface_s gEqualizerInterface;
diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
index f056d19..fce9bed 100644
--- a/media/libeffects/testlibs/EffectReverb.c
+++ b/media/libeffects/testlibs/EffectReverb.c
@@ -16,10 +16,13 @@
#define LOG_TAG "EffectReverb"
//#define LOG_NDEBUG 0
-#include <cutils/log.h>
+
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
-#include <stdbool.h>
+
+#include <log/log.h>
+
#include "EffectReverb.h"
#include "EffectsMath.h"
diff --git a/media/libeffects/testlibs/EffectsMath.c b/media/libeffects/testlibs/EffectsMath.c
index 41ec662..efd9e87 100644
--- a/media/libeffects/testlibs/EffectsMath.c
+++ b/media/libeffects/testlibs/EffectsMath.c
@@ -15,9 +15,11 @@
*/
#define LOG_TAG "EFFECTSMATH"
//#define LOG_NDEBUG 0
-#include <cutils/log.h>
+
#include <assert.h>
+#include <android/log.h>
+
#include "EffectsMath.h"
// gLogTab contains pre-calculated values of log2(1 + ai5*2^-1 + ai4*2^-2 + ai3*2^-3 + ai2*2^-4 + ai1*2^-5 + ai0*2^-6)
diff --git a/media/libeffects/visualizer/Android.mk b/media/libeffects/visualizer/Android.mk
index c92c543..aac90a6 100644
--- a/media/libeffects/visualizer/Android.mk
+++ b/media/libeffects/visualizer/Android.mk
@@ -3,6 +3,7 @@
# Visualizer library
include $(CLEAR_VARS)
+LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \
EffectVisualizer.cpp
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index b7d27d6..6a126ef 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -16,17 +16,19 @@
#define LOG_TAG "EffectVisualizer"
//#define LOG_NDEBUG 0
-#include <log/log.h>
+
#include <assert.h>
#include <inttypes.h>
+#include <math.h>
#include <stdlib.h>
#include <string.h>
-#include <new>
#include <time.h>
-#include <math.h>
-#include <audio_effects/effect_visualizer.h>
-#include <cutils/log.h>
+#include <new>
+
+#include <log/log.h>
+
+#include <audio_effects/effect_visualizer.h>
extern "C" {
diff --git a/media/libmedia/Android.bp b/media/libmedia/Android.bp
new file mode 100644
index 0000000..205b3cd
--- /dev/null
+++ b/media/libmedia/Android.bp
@@ -0,0 +1,108 @@
+cc_library_static {
+ name: "libmedia_helper",
+ srcs: ["AudioParameter.cpp"],
+ cflags: [
+ "-Werror",
+ "-Wno-error=deprecated-declarations",
+ "-Wall",
+ ],
+ clang: true,
+}
+
+cc_library_shared {
+ name: "libmedia",
+
+ srcs: [
+ "IDataSource.cpp",
+ "IHDCP.cpp",
+ "mediaplayer.cpp",
+ "IMediaCodecList.cpp",
+ "IMediaCodecService.cpp",
+ "IMediaHTTPConnection.cpp",
+ "IMediaHTTPService.cpp",
+ "IMediaExtractor.cpp",
+ "IMediaExtractorService.cpp",
+ "IMediaPlayerService.cpp",
+ "IMediaPlayerClient.cpp",
+ "IMediaRecorderClient.cpp",
+ "IMediaPlayer.cpp",
+ "IMediaRecorder.cpp",
+ "IMediaSource.cpp",
+ "IRemoteDisplay.cpp",
+ "IRemoteDisplayClient.cpp",
+ "IResourceManagerClient.cpp",
+ "IResourceManagerService.cpp",
+ "IStreamSource.cpp",
+ "MediaCodecInfo.cpp",
+ "MediaDefs.cpp",
+ "MediaUtils.cpp",
+ "Metadata.cpp",
+ "mediarecorder.cpp",
+ "IMediaMetadataRetriever.cpp",
+ "mediametadataretriever.cpp",
+ "MidiIoWrapper.cpp",
+ "JetPlayer.cpp",
+ "IOMX.cpp",
+ "MediaScanner.cpp",
+ "MediaScannerClient.cpp",
+ "CharacterEncodingDetector.cpp",
+ "IMediaDeathNotifier.cpp",
+ "MediaProfiles.cpp",
+ "MediaResource.cpp",
+ "MediaResourcePolicy.cpp",
+ "Visualizer.cpp",
+ "StringArray.cpp",
+ ],
+
+ shared_libs: [
+ "libui",
+ "liblog",
+ "libcutils",
+ "libutils",
+ "libbinder",
+ "libsonivox",
+ "libicuuc",
+ "libicui18n",
+ "libexpat",
+ "libcamera_client",
+ "libstagefright_foundation",
+ "libgui",
+ "libdl",
+ "libaudioutils",
+ "libaudioclient",
+ ],
+
+ header_libs: ["libaudioeffects"],
+
+ export_shared_lib_headers: [
+ "libbinder",
+ "libicuuc",
+ "libicui18n",
+ ],
+
+ whole_static_libs: ["libmedia_helper"],
+
+ // for memory heap analysis
+ static_libs: [
+ "libc_malloc_debug_backtrace",
+ ],
+
+ include_dirs: [
+ "frameworks/native/include/media/openmax",
+ "frameworks/av/include/media/",
+ "frameworks/av/media/libstagefright",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wno-error=deprecated-declarations",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "unsigned-integer-overflow",
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk
deleted file mode 100644
index 2bdfd43..0000000
--- a/media/libmedia/Android.mk
+++ /dev/null
@@ -1,104 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- AudioParameter.cpp
-LOCAL_MODULE:= libmedia_helper
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Werror -Wno-error=deprecated-declarations -Wall
-LOCAL_CLANG := true
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- AudioTrack.cpp \
- AudioTrackShared.cpp \
- IAudioFlinger.cpp \
- IAudioFlingerClient.cpp \
- IAudioTrack.cpp \
- IAudioRecord.cpp \
- ICrypto.cpp \
- IDataSource.cpp \
- IDrm.cpp \
- IDrmClient.cpp \
- IHDCP.cpp \
- AudioRecord.cpp \
- AudioSystem.cpp \
- mediaplayer.cpp \
- IMediaCodecList.cpp \
- IMediaCodecService.cpp \
- IMediaDrmService.cpp \
- IMediaHTTPConnection.cpp \
- IMediaHTTPService.cpp \
- IMediaLogService.cpp \
- IMediaExtractor.cpp \
- IMediaExtractorService.cpp \
- IMediaPlayerService.cpp \
- IMediaPlayerClient.cpp \
- IMediaRecorderClient.cpp \
- IMediaPlayer.cpp \
- IMediaRecorder.cpp \
- IMediaSource.cpp \
- IRemoteDisplay.cpp \
- IRemoteDisplayClient.cpp \
- IResourceManagerClient.cpp \
- IResourceManagerService.cpp \
- IStreamSource.cpp \
- MediaCodecInfo.cpp \
- MediaUtils.cpp \
- Metadata.cpp \
- mediarecorder.cpp \
- IMediaMetadataRetriever.cpp \
- mediametadataretriever.cpp \
- MidiIoWrapper.cpp \
- ToneGenerator.cpp \
- JetPlayer.cpp \
- IOMX.cpp \
- IAudioPolicyService.cpp \
- IAudioPolicyServiceClient.cpp \
- MediaScanner.cpp \
- MediaScannerClient.cpp \
- CharacterEncodingDetector.cpp \
- IMediaDeathNotifier.cpp \
- MediaProfiles.cpp \
- MediaResource.cpp \
- MediaResourcePolicy.cpp \
- IEffect.cpp \
- IEffectClient.cpp \
- AudioEffect.cpp \
- Visualizer.cpp \
- MemoryLeakTrackUtil.cpp \
- StringArray.cpp \
- AudioPolicy.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libui liblog libcutils libutils libbinder libsonivox libicuuc libicui18n libexpat \
- libcamera_client libstagefright_foundation \
- libgui libdl libaudioutils libnbaio
-
-LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
-
-# for memory heap analysis
-LOCAL_STATIC_LIBRARIES := libc_malloc_debug_backtrace libc_logging
-
-LOCAL_MODULE:= libmedia
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/av/include/media/ \
- $(TOP)/frameworks/av/media/libstagefright \
- $(call include-path-for, audio-effects) \
- $(call include-path-for, audio-utils)
-
-LOCAL_CFLAGS += -Werror -Wno-error=deprecated-declarations -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/media/libmedia/IDataSource.cpp b/media/libmedia/IDataSource.cpp
index 51c9938..7df3b65 100644
--- a/media/libmedia/IDataSource.cpp
+++ b/media/libmedia/IDataSource.cpp
@@ -39,7 +39,8 @@
};
struct BpDataSource : public BpInterface<IDataSource> {
- BpDataSource(const sp<IBinder>& impl) : BpInterface<IDataSource>(impl) {}
+ explicit BpDataSource(const sp<IBinder>& impl)
+ : BpInterface<IDataSource>(impl) {}
virtual sp<IMemory> getIMemory() {
Parcel data, reply;
diff --git a/media/libmedia/IHDCP.cpp b/media/libmedia/IHDCP.cpp
index e8c8a3d..a46017f 100644
--- a/media/libmedia/IHDCP.cpp
+++ b/media/libmedia/IHDCP.cpp
@@ -37,7 +37,7 @@
};
struct BpHDCPObserver : public BpInterface<IHDCPObserver> {
- BpHDCPObserver(const sp<IBinder> &impl)
+ explicit BpHDCPObserver(const sp<IBinder> &impl)
: BpInterface<IHDCPObserver>(impl) {
}
@@ -58,7 +58,7 @@
IMPLEMENT_META_INTERFACE(HDCPObserver, "android.hardware.IHDCPObserver");
struct BpHDCP : public BpInterface<IHDCP> {
- BpHDCP(const sp<IBinder> &impl)
+ explicit BpHDCP(const sp<IBinder> &impl)
: BpInterface<IHDCP>(impl) {
}
@@ -240,6 +240,8 @@
case HDCP_ENCRYPT:
{
+ CHECK_INTERFACE(IHDCP, data, reply);
+
size_t size = data.readInt32();
void *inData = NULL;
// watch out for overflow
@@ -313,6 +315,8 @@
case HDCP_DECRYPT:
{
+ CHECK_INTERFACE(IHDCP, data, reply);
+
size_t size = data.readInt32();
size_t bufSize = 2 * size;
diff --git a/media/libmedia/IMediaCodecList.cpp b/media/libmedia/IMediaCodecList.cpp
index 737f50c..806f46d 100644
--- a/media/libmedia/IMediaCodecList.cpp
+++ b/media/libmedia/IMediaCodecList.cpp
@@ -38,7 +38,7 @@
class BpMediaCodecList: public BpInterface<IMediaCodecList>
{
public:
- BpMediaCodecList(const sp<IBinder>& impl)
+ explicit BpMediaCodecList(const sp<IBinder>& impl)
: BpInterface<IMediaCodecList>(impl)
{
}
diff --git a/media/libmedia/IMediaExtractor.cpp b/media/libmedia/IMediaExtractor.cpp
index 72d1d7c..4be1118 100644
--- a/media/libmedia/IMediaExtractor.cpp
+++ b/media/libmedia/IMediaExtractor.cpp
@@ -209,11 +209,16 @@
for (size_t i = 0; i < tracks.size(); i++) {
const String8 desc = trackDescriptions.itemAt(i);
str.appendFormat(" track {%s} ", desc.string());
- const sp<IMediaSource> source = tracks.itemAt(i).promote();
- if (source == NULL) {
- str.append(": deleted\n");
+ wp<IMediaSource> wSource = tracks.itemAt(i);
+ if (wSource == NULL) {
+ str.append(": null\n");
} else {
- str.appendFormat(": active\n");
+ const sp<IMediaSource> source = wSource.promote();
+ if (source == NULL) {
+ str.append(": deleted\n");
+ } else {
+ str.appendFormat(": active\n");
+ }
}
}
return str;
@@ -232,9 +237,14 @@
if (extractor != NULL && extractor == ex) {
if (instance.tracks.size() > 5) {
instance.tracks.resize(5);
+ instance.trackDescriptions.resize(5);
}
instance.tracks.push_front(source);
- instance.trackDescriptions.add(source->getFormat()->toString());
+ if (source != NULL) {
+ instance.trackDescriptions.push_front(source->getFormat()->toString());
+ } else {
+ instance.trackDescriptions.push_front(String8::empty());
+ }
break;
}
}
diff --git a/media/libmedia/IMediaHTTPConnection.cpp b/media/libmedia/IMediaHTTPConnection.cpp
index 0dda0be9..e4b717b 100644
--- a/media/libmedia/IMediaHTTPConnection.cpp
+++ b/media/libmedia/IMediaHTTPConnection.cpp
@@ -38,7 +38,7 @@
};
struct BpMediaHTTPConnection : public BpInterface<IMediaHTTPConnection> {
- BpMediaHTTPConnection(const sp<IBinder> &impl)
+ explicit BpMediaHTTPConnection(const sp<IBinder> &impl)
: BpInterface<IMediaHTTPConnection>(impl) {
}
diff --git a/media/libmedia/IMediaHTTPService.cpp b/media/libmedia/IMediaHTTPService.cpp
index 0c16a2b..062a07a 100644
--- a/media/libmedia/IMediaHTTPService.cpp
+++ b/media/libmedia/IMediaHTTPService.cpp
@@ -30,7 +30,7 @@
};
struct BpMediaHTTPService : public BpInterface<IMediaHTTPService> {
- BpMediaHTTPService(const sp<IBinder> &impl)
+ explicit BpMediaHTTPService(const sp<IBinder> &impl)
: BpInterface<IMediaHTTPService>(impl) {
}
diff --git a/media/libmedia/IMediaMetadataRetriever.cpp b/media/libmedia/IMediaMetadataRetriever.cpp
index 0bee8d3..7058ee8 100644
--- a/media/libmedia/IMediaMetadataRetriever.cpp
+++ b/media/libmedia/IMediaMetadataRetriever.cpp
@@ -75,7 +75,7 @@
class BpMediaMetadataRetriever: public BpInterface<IMediaMetadataRetriever>
{
public:
- BpMediaMetadataRetriever(const sp<IBinder>& impl)
+ explicit BpMediaMetadataRetriever(const sp<IBinder>& impl)
: BpInterface<IMediaMetadataRetriever>(impl)
{
}
diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp
index 519a1fd..f8345e4 100644
--- a/media/libmedia/IMediaPlayer.cpp
+++ b/media/libmedia/IMediaPlayer.cpp
@@ -72,7 +72,7 @@
class BpMediaPlayer: public BpInterface<IMediaPlayer>
{
public:
- BpMediaPlayer(const sp<IBinder>& impl)
+ explicit BpMediaPlayer(const sp<IBinder>& impl)
: BpInterface<IMediaPlayer>(impl)
{
}
diff --git a/media/libmedia/IMediaPlayerClient.cpp b/media/libmedia/IMediaPlayerClient.cpp
index d608386..bbf8475 100644
--- a/media/libmedia/IMediaPlayerClient.cpp
+++ b/media/libmedia/IMediaPlayerClient.cpp
@@ -30,7 +30,7 @@
class BpMediaPlayerClient: public BpInterface<IMediaPlayerClient>
{
public:
- BpMediaPlayerClient(const sp<IBinder>& impl)
+ explicit BpMediaPlayerClient(const sp<IBinder>& impl)
: BpInterface<IMediaPlayerClient>(impl)
{
}
diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp
index 7590c1b..a01852c 100644
--- a/media/libmedia/IMediaPlayerService.cpp
+++ b/media/libmedia/IMediaPlayerService.cpp
@@ -50,7 +50,7 @@
class BpMediaPlayerService: public BpInterface<IMediaPlayerService>
{
public:
- BpMediaPlayerService(const sp<IBinder>& impl)
+ explicit BpMediaPlayerService(const sp<IBinder>& impl)
: BpInterface<IMediaPlayerService>(impl)
{
}
diff --git a/media/libmedia/IMediaRecorder.cpp b/media/libmedia/IMediaRecorder.cpp
index cded55c..a6860e2 100644
--- a/media/libmedia/IMediaRecorder.cpp
+++ b/media/libmedia/IMediaRecorder.cpp
@@ -63,7 +63,7 @@
class BpMediaRecorder: public BpInterface<IMediaRecorder>
{
public:
- BpMediaRecorder(const sp<IBinder>& impl)
+ explicit BpMediaRecorder(const sp<IBinder>& impl)
: BpInterface<IMediaRecorder>(impl)
{
}
diff --git a/media/libmedia/IMediaRecorderClient.cpp b/media/libmedia/IMediaRecorderClient.cpp
index 6795d23..a76f934 100644
--- a/media/libmedia/IMediaRecorderClient.cpp
+++ b/media/libmedia/IMediaRecorderClient.cpp
@@ -30,7 +30,7 @@
class BpMediaRecorderClient: public BpInterface<IMediaRecorderClient>
{
public:
- BpMediaRecorderClient(const sp<IBinder>& impl)
+ explicit BpMediaRecorderClient(const sp<IBinder>& impl)
: BpInterface<IMediaRecorderClient>(impl)
{
}
diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp
index 1090a83..beca464 100644
--- a/media/libmedia/IOMX.cpp
+++ b/media/libmedia/IOMX.cpp
@@ -66,7 +66,7 @@
class BpOMX : public BpInterface<IOMX> {
public:
- BpOMX(const sp<IBinder> &impl)
+ explicit BpOMX(const sp<IBinder> &impl)
: BpInterface<IOMX>(impl) {
}
@@ -630,7 +630,7 @@
////////////////////////////////////////////////////////////////////////////////
#define CHECK_OMX_INTERFACE(interface, data, reply) \
- do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \
+ do { if (!(data).enforceInterface(interface::getInterfaceDescriptor())) { \
ALOGW("Call incorrectly routed to " #interface); \
return PERMISSION_DENIED; \
} } while (0)
@@ -758,7 +758,7 @@
params = mmap(NULL, allocSize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1 /* fd */, 0 /* offset */);
}
- if (params != MAP_FAILED) {
+ if (params != MAP_FAILED && params != NULL) {
err = data.read(params, size);
if (err != OK) {
android_errorWriteLog(0x534e4554, "26914474");
@@ -1231,7 +1231,7 @@
class BpOMXObserver : public BpInterface<IOMXObserver> {
public:
- BpOMXObserver(const sp<IBinder> &impl)
+ explicit BpOMXObserver(const sp<IBinder> &impl)
: BpInterface<IOMXObserver>(impl) {
}
diff --git a/media/libmedia/IRemoteDisplay.cpp b/media/libmedia/IRemoteDisplay.cpp
index 869d11a..85c7bd6 100644
--- a/media/libmedia/IRemoteDisplay.cpp
+++ b/media/libmedia/IRemoteDisplay.cpp
@@ -30,7 +30,7 @@
class BpRemoteDisplay: public BpInterface<IRemoteDisplay>
{
public:
- BpRemoteDisplay(const sp<IBinder>& impl)
+ explicit BpRemoteDisplay(const sp<IBinder>& impl)
: BpInterface<IRemoteDisplay>(impl)
{
}
diff --git a/media/libmedia/IRemoteDisplayClient.cpp b/media/libmedia/IRemoteDisplayClient.cpp
index bedeb6c..ca67665 100644
--- a/media/libmedia/IRemoteDisplayClient.cpp
+++ b/media/libmedia/IRemoteDisplayClient.cpp
@@ -32,7 +32,7 @@
class BpRemoteDisplayClient: public BpInterface<IRemoteDisplayClient>
{
public:
- BpRemoteDisplayClient(const sp<IBinder>& impl)
+ explicit BpRemoteDisplayClient(const sp<IBinder>& impl)
: BpInterface<IRemoteDisplayClient>(impl)
{
}
diff --git a/media/libmedia/IResourceManagerClient.cpp b/media/libmedia/IResourceManagerClient.cpp
index b3f56e8..1fea479 100644
--- a/media/libmedia/IResourceManagerClient.cpp
+++ b/media/libmedia/IResourceManagerClient.cpp
@@ -31,7 +31,7 @@
class BpResourceManagerClient: public BpInterface<IResourceManagerClient>
{
public:
- BpResourceManagerClient(const sp<IBinder> &impl)
+ explicit BpResourceManagerClient(const sp<IBinder> &impl)
: BpInterface<IResourceManagerClient>(impl)
{
}
diff --git a/media/libmedia/IResourceManagerService.cpp b/media/libmedia/IResourceManagerService.cpp
index 6cb4440..95f7d2e 100644
--- a/media/libmedia/IResourceManagerService.cpp
+++ b/media/libmedia/IResourceManagerService.cpp
@@ -58,7 +58,7 @@
class BpResourceManagerService : public BpInterface<IResourceManagerService>
{
public:
- BpResourceManagerService(const sp<IBinder> &impl)
+ explicit BpResourceManagerService(const sp<IBinder> &impl)
: BpInterface<IResourceManagerService>(impl)
{
}
diff --git a/media/libmedia/IStreamSource.cpp b/media/libmedia/IStreamSource.cpp
index 8c0905c..ba0a272 100644
--- a/media/libmedia/IStreamSource.cpp
+++ b/media/libmedia/IStreamSource.cpp
@@ -51,7 +51,7 @@
};
struct BpStreamSource : public BpInterface<IStreamSource> {
- BpStreamSource(const sp<IBinder> &impl)
+ explicit BpStreamSource(const sp<IBinder> &impl)
: BpInterface<IStreamSource>(impl) {
}
@@ -145,7 +145,7 @@
////////////////////////////////////////////////////////////////////////////////
struct BpStreamListener : public BpInterface<IStreamListener> {
- BpStreamListener(const sp<IBinder> &impl)
+ explicit BpStreamListener(const sp<IBinder> &impl)
: BpInterface<IStreamListener>(impl) {
}
diff --git a/media/libmedia/MediaCodecInfo.cpp b/media/libmedia/MediaCodecInfo.cpp
index 1b3b3eb..2bc5984 100644
--- a/media/libmedia/MediaCodecInfo.cpp
+++ b/media/libmedia/MediaCodecInfo.cpp
@@ -85,13 +85,13 @@
}
status_t MediaCodecInfo::Capabilities::writeToParcel(Parcel *parcel) const {
- CHECK_LE(mProfileLevels.size(), INT32_MAX);
+ CHECK_LE(mProfileLevels.size(), static_cast<size_t>(INT32_MAX));
parcel->writeInt32(mProfileLevels.size());
for (size_t i = 0; i < mProfileLevels.size(); i++) {
parcel->writeInt32(mProfileLevels.itemAt(i).mProfile);
parcel->writeInt32(mProfileLevels.itemAt(i).mLevel);
}
- CHECK_LE(mColorFormats.size(), INT32_MAX);
+ CHECK_LE(mColorFormats.size(), static_cast<size_t>(INT32_MAX));
parcel->writeInt32(mColorFormats.size());
for (size_t i = 0; i < mColorFormats.size(); i++) {
parcel->writeInt32(mColorFormats.itemAt(i));
diff --git a/media/libstagefright/MediaDefs.cpp b/media/libmedia/MediaDefs.cpp
similarity index 98%
rename from media/libstagefright/MediaDefs.cpp
rename to media/libmedia/MediaDefs.cpp
index 845462b..a2110c9 100644
--- a/media/libstagefright/MediaDefs.cpp
+++ b/media/libmedia/MediaDefs.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <media/stagefright/MediaDefs.h>
+#include <media/MediaDefs.h>
namespace android {
diff --git a/media/libmedia/MediaUtils.cpp b/media/libmedia/MediaUtils.cpp
index a02ca65..dc2bc82 100644
--- a/media/libmedia/MediaUtils.cpp
+++ b/media/libmedia/MediaUtils.cpp
@@ -31,6 +31,11 @@
size_t numberOfBytes,
size_t percentageOfTotalMem) {
+ if (running_with_asan()) {
+ ALOGW("Running with ASan, skip enforcing memory limitations.");
+ return;
+ }
+
long pageSize = sysconf(_SC_PAGESIZE);
long numPages = sysconf(_SC_PHYS_PAGES);
size_t maxMem = SIZE_MAX;
diff --git a/media/libmedia/MediaUtils.h b/media/libmedia/MediaUtils.h
index f80dd30..a678bcc 100644
--- a/media/libmedia/MediaUtils.h
+++ b/media/libmedia/MediaUtils.h
@@ -19,6 +19,12 @@
namespace android {
+extern "C" void __asan_init(void) __attribute__((weak));
+
+static inline int running_with_asan() {
+ return &__asan_init != 0;
+}
+
/**
Limit the amount of memory a process can allocate using setrlimit(RLIMIT_AS).
The value to use will be read from the specified system property, or if the
diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp
index 37bf0bd..4984b18 100644
--- a/media/libmedia/Visualizer.cpp
+++ b/media/libmedia/Visualizer.cpp
@@ -24,8 +24,6 @@
#include <sys/types.h>
#include <limits.h>
-#include <cutils/bitops.h>
-
#include <media/Visualizer.h>
#include <audio_utils/fixedfft.h>
#include <utils/Thread.h>
diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk
index 8d86366..2e6d0f1 100644
--- a/media/libmediaplayerservice/Android.mk
+++ b/media/libmediaplayerservice/Android.mk
@@ -19,7 +19,6 @@
LOCAL_SHARED_LIBRARIES := \
libbinder \
- libcamera_client \
libcrypto \
libcutils \
libdrmframework \
@@ -27,36 +26,35 @@
libdl \
libgui \
libmedia \
+ libaudioclient \
libmediautils \
libmemunreachable \
- libsonivox \
libstagefright \
libstagefright_foundation \
libstagefright_httplive \
libstagefright_omx \
libstagefright_wfd \
libutils \
- libvorbisidec \
LOCAL_STATIC_LIBRARIES := \
libstagefright_nuplayer \
libstagefright_rtsp \
libstagefright_timedtext \
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libmedia
+
LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/av/media/libstagefright/rtsp \
- $(TOP)/frameworks/av/media/libstagefright/wifi-display \
- $(TOP)/frameworks/av/media/libstagefright/webm \
- $(TOP)/frameworks/av/include/media \
- $(TOP)/frameworks/av/include/camera \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/native/include/media/hardware \
- $(TOP)/external/tremolo/Tremolo \
- libcore/include \
+ frameworks/av/media/libstagefright/include \
+ frameworks/av/media/libstagefright/rtsp \
+ frameworks/av/media/libstagefright/wifi-display \
+ frameworks/av/media/libstagefright/webm \
+ frameworks/av/include/media \
+ frameworks/av/include/camera \
+ frameworks/native/include/media/openmax \
+ frameworks/native/include/media/hardware \
+ external/tremolo/Tremolo \
LOCAL_CFLAGS += -Werror -Wno-error=deprecated-declarations -Wall
-LOCAL_CLANG := true
LOCAL_MODULE:= libmediaplayerservice
diff --git a/media/libmediaplayerservice/HDCP.h b/media/libmediaplayerservice/HDCP.h
index 26ddc86..83c61b5 100644
--- a/media/libmediaplayerservice/HDCP.h
+++ b/media/libmediaplayerservice/HDCP.h
@@ -24,7 +24,7 @@
namespace android {
struct HDCP : public BnHDCP {
- HDCP(bool createEncryptionModule);
+ explicit HDCP(bool createEncryptionModule);
virtual ~HDCP();
virtual status_t setObserver(const sp<IHDCPObserver> &observer);
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index bd16e91..95c91d1 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -307,7 +307,7 @@
return recorder;
}
-void MediaPlayerService::removeMediaRecorderClient(wp<MediaRecorderClient> client)
+void MediaPlayerService::removeMediaRecorderClient(const wp<MediaRecorderClient>& client)
{
Mutex::Autolock lock(mLock);
mMediaRecorderClients.remove(client);
@@ -552,7 +552,7 @@
return NO_ERROR;
}
-void MediaPlayerService::removeClient(wp<Client> client)
+void MediaPlayerService::removeClient(const wp<Client>& client)
{
Mutex::Autolock lock(mLock);
mClients.remove(client);
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index 7a41d9c..601b046 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -169,7 +169,7 @@
class CallbackData {
friend AudioOutput;
public:
- CallbackData(AudioOutput *cookie) {
+ explicit CallbackData(AudioOutput *cookie) {
mData = cookie;
mSwitching = false;
}
@@ -212,7 +212,7 @@
// IMediaPlayerService interface
virtual sp<IMediaRecorder> createMediaRecorder(const String16 &opPackageName);
- void removeMediaRecorderClient(wp<MediaRecorderClient> client);
+ void removeMediaRecorderClient(const wp<MediaRecorderClient>& client);
virtual sp<IMediaMetadataRetriever> createMetadataRetriever();
virtual sp<IMediaPlayer> create(const sp<IMediaPlayerClient>& client,
@@ -226,7 +226,7 @@
const sp<IRemoteDisplayClient>& client, const String8& iface);
virtual status_t dump(int fd, const Vector<String16>& args);
- void removeClient(wp<Client> client);
+ void removeClient(const wp<Client>& client);
bool hasClient(wp<Client> client);
enum {
diff --git a/media/libmediaplayerservice/MediaRecorderClient.h b/media/libmediaplayerservice/MediaRecorderClient.h
index eceb653..b2d0f0e 100644
--- a/media/libmediaplayerservice/MediaRecorderClient.h
+++ b/media/libmediaplayerservice/MediaRecorderClient.h
@@ -22,7 +22,7 @@
namespace android {
-class MediaRecorderBase;
+struct MediaRecorderBase;
class MediaPlayerService;
class ICameraRecordingProxy;
class IGraphicBufferProducer;
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index bd1fd7c..cdb0a7b 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -1493,7 +1493,7 @@
}
status_t StagefrightRecorder::setupVideoEncoder(
- sp<MediaSource> cameraSource,
+ const sp<MediaSource> &cameraSource,
sp<MediaCodecSource> *source) {
source->clear();
diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h
index d7f43bc..4dbd039 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.h
+++ b/media/libmediaplayerservice/StagefrightRecorder.h
@@ -44,7 +44,7 @@
struct ALooper;
struct StagefrightRecorder : public MediaRecorderBase {
- StagefrightRecorder(const String16 &opPackageName);
+ explicit StagefrightRecorder(const String16 &opPackageName);
virtual ~StagefrightRecorder();
virtual status_t init();
@@ -59,9 +59,9 @@
virtual status_t setPreviewSurface(const sp<IGraphicBufferProducer>& surface);
virtual status_t setInputSurface(const sp<IGraphicBufferConsumer>& surface);
virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
- virtual status_t setParameters(const String8& params);
- virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
- virtual status_t setClientName(const String16& clientName);
+ virtual status_t setParameters(const String8 ¶ms);
+ virtual status_t setListener(const sp<IMediaRecorderClient> &listener);
+ virtual status_t setClientName(const String16 &clientName);
virtual status_t prepare();
virtual status_t start();
virtual status_t pause();
@@ -70,7 +70,7 @@
virtual status_t close();
virtual status_t reset();
virtual status_t getMaxAmplitude(int *max);
- virtual status_t dump(int fd, const Vector<String16>& args) const;
+ virtual status_t dump(int fd, const Vector<String16> &args) const;
// Querying a SurfaceMediaSourcer
virtual sp<IGraphicBufferProducer> querySurfaceMediaSource() const;
@@ -158,7 +158,7 @@
status_t setupMediaSource(sp<MediaSource> *mediaSource);
status_t setupCameraSource(sp<CameraSource> *cameraSource);
status_t setupAudioEncoder(const sp<MediaWriter>& writer);
- status_t setupVideoEncoder(sp<MediaSource> cameraSource, sp<MediaCodecSource> *source);
+ status_t setupVideoEncoder(const sp<MediaSource>& cameraSource, sp<MediaCodecSource> *source);
// Encoding parameter handling utilities
status_t setParameter(const String8 &key, const String8 &value);
diff --git a/media/libmediaplayerservice/nuplayer/Android.mk b/media/libmediaplayerservice/nuplayer/Android.mk
index cd20837..21487ca 100644
--- a/media/libmediaplayerservice/nuplayer/Android.mk
+++ b/media/libmediaplayerservice/nuplayer/Android.mk
@@ -16,14 +16,14 @@
StreamingSource.cpp \
LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/av/media/libstagefright/httplive \
- $(TOP)/frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/av/media/libstagefright/mpeg2ts \
- $(TOP)/frameworks/av/media/libstagefright/rtsp \
- $(TOP)/frameworks/av/media/libstagefright/timedtext \
- $(TOP)/frameworks/av/media/libmediaplayerservice \
- $(TOP)/frameworks/native/include/media/openmax
+ frameworks/av/media/libstagefright \
+ frameworks/av/media/libstagefright/httplive \
+ frameworks/av/media/libstagefright/include \
+ frameworks/av/media/libstagefright/mpeg2ts \
+ frameworks/av/media/libstagefright/rtsp \
+ frameworks/av/media/libstagefright/timedtext \
+ frameworks/av/media/libmediaplayerservice \
+ frameworks/native/include/media/openmax
LOCAL_CFLAGS += -Werror -Wall
@@ -32,7 +32,7 @@
LOCAL_CFLAGS += -DENABLE_STAGEFRIGHT_EXPERIMENTS
endif
-LOCAL_CLANG := true
+LOCAL_SHARED_LIBRARIES := libmedia
LOCAL_MODULE:= libstagefright_nuplayer
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
index af2d0f3..57a7286 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
@@ -691,6 +691,12 @@
break;
}
+ case kWhatGetTrackInfo:
+ {
+ onGetTrackInfo(msg);
+ break;
+ }
+
case kWhatSelectTrack:
{
onSelectTrack(msg);
@@ -741,8 +747,8 @@
uint32_t sendWhat,
media_track_type type,
int32_t curGen,
- sp<AnotherPacketSource> packets,
- sp<AMessage> msg) {
+ const sp<AnotherPacketSource>& packets,
+ const sp<AMessage>& msg) {
int32_t msgGeneration;
CHECK(msg->findInt32("generation", &msgGeneration));
if (msgGeneration != curGen) {
@@ -775,8 +781,8 @@
uint32_t what,
media_track_type type,
int32_t curGen,
- sp<AnotherPacketSource> packets,
- sp<AMessage> msg) {
+ const sp<AnotherPacketSource>& packets,
+ const sp<AMessage>& msg) {
int32_t msgGeneration;
CHECK(msg->findInt32("generation", &msgGeneration));
if (msgGeneration != curGen) {
@@ -851,7 +857,7 @@
}
}
-void NuPlayer::GenericSource::onGetFormatMeta(sp<AMessage> msg) const {
+void NuPlayer::GenericSource::onGetFormatMeta(const sp<AMessage>& msg) const {
int32_t audio;
CHECK(msg->findInt32("audio", &audio));
@@ -960,6 +966,34 @@
}
sp<AMessage> NuPlayer::GenericSource::getTrackInfo(size_t trackIndex) const {
+ sp<AMessage> msg = new AMessage(kWhatGetTrackInfo, this);
+ msg->setSize("trackIndex", trackIndex);
+
+ sp<AMessage> response;
+ sp<RefBase> format;
+ status_t err = msg->postAndAwaitResponse(&response);
+ if (err == OK && response != NULL) {
+ CHECK(response->findObject("format", &format));
+ return static_cast<AMessage*>(format.get());
+ } else {
+ return NULL;
+ }
+}
+
+void NuPlayer::GenericSource::onGetTrackInfo(const sp<AMessage>& msg) const {
+ size_t trackIndex;
+ CHECK(msg->findSize("trackIndex", &trackIndex));
+
+ sp<AMessage> response = new AMessage;
+ sp<AMessage> format = doGetTrackInfo(trackIndex);
+ response->setObject("format", format);
+
+ sp<AReplyToken> replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+ response->postReply(replyID);
+}
+
+sp<AMessage> NuPlayer::GenericSource::doGetTrackInfo(size_t trackIndex) const {
size_t trackCount = mSources.size();
if (trackIndex >= trackCount) {
return NULL;
@@ -1023,7 +1057,7 @@
}
}
-void NuPlayer::GenericSource::onGetSelectedTrack(sp<AMessage> msg) const {
+void NuPlayer::GenericSource::onGetSelectedTrack(const sp<AMessage>& msg) const {
int32_t tmpType;
CHECK(msg->findInt32("type", &tmpType));
media_track_type type = (media_track_type)tmpType;
@@ -1079,7 +1113,7 @@
return err;
}
-void NuPlayer::GenericSource::onSelectTrack(sp<AMessage> msg) {
+void NuPlayer::GenericSource::onSelectTrack(const sp<AMessage>& msg) {
int32_t trackIndex, select;
int64_t timeUs;
CHECK(msg->findInt32("trackIndex", &trackIndex));
@@ -1199,7 +1233,7 @@
return err;
}
-void NuPlayer::GenericSource::onSeek(sp<AMessage> msg) {
+void NuPlayer::GenericSource::onSeek(const sp<AMessage>& msg) {
int64_t seekTimeUs;
CHECK(msg->findInt64("seekTimeUs", &seekTimeUs));
@@ -1358,7 +1392,7 @@
}
}
-void NuPlayer::GenericSource::onReadBuffer(sp<AMessage> msg) {
+void NuPlayer::GenericSource::onReadBuffer(const sp<AMessage>& msg) {
int32_t tmpType;
CHECK(msg->findInt32("trackType", &tmpType));
media_track_type trackType = (media_track_type)tmpType;
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h
index 2fd703e..e92a2ae 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.h
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.h
@@ -117,7 +117,7 @@
// When necessary, it will send out buffering events to the player.
struct BufferingMonitor : public AHandler {
public:
- BufferingMonitor(const sp<AMessage> ¬ify);
+ explicit BufferingMonitor(const sp<AMessage> ¬ify);
// Set up state.
void prepare(const sp<NuCachedSource2> &cachedSource,
@@ -248,23 +248,26 @@
void finishPrepareAsync();
status_t startSources();
- void onGetFormatMeta(sp<AMessage> msg) const;
+ void onGetFormatMeta(const sp<AMessage>& msg) const;
sp<MetaData> doGetFormatMeta(bool audio) const;
- void onGetSelectedTrack(sp<AMessage> msg) const;
+ void onGetTrackInfo(const sp<AMessage>& msg) const;
+ sp<AMessage> doGetTrackInfo(size_t trackIndex) const;
+
+ void onGetSelectedTrack(const sp<AMessage>& msg) const;
ssize_t doGetSelectedTrack(media_track_type type) const;
- void onSelectTrack(sp<AMessage> msg);
+ void onSelectTrack(const sp<AMessage>& msg);
status_t doSelectTrack(size_t trackIndex, bool select, int64_t timeUs);
- void onSeek(sp<AMessage> msg);
+ void onSeek(const sp<AMessage>& msg);
status_t doSeek(int64_t seekTimeUs);
void onPrepareAsync();
void fetchTextData(
uint32_t what, media_track_type type,
- int32_t curGen, sp<AnotherPacketSource> packets, sp<AMessage> msg);
+ int32_t curGen, const sp<AnotherPacketSource>& packets, const sp<AMessage>& msg);
void sendGlobalTextData(
uint32_t what,
@@ -272,7 +275,7 @@
void sendTextData(
uint32_t what, media_track_type type,
- int32_t curGen, sp<AnotherPacketSource> packets, sp<AMessage> msg);
+ int32_t curGen, const sp<AnotherPacketSource>& packets, const sp<AMessage>& msg);
sp<ABuffer> mediaBufferToABuffer(
MediaBuffer *mbuf,
@@ -281,7 +284,7 @@
int64_t *actualTimeUs = NULL);
void postReadBuffer(media_track_type trackType);
- void onReadBuffer(sp<AMessage> msg);
+ void onReadBuffer(const sp<AMessage>& msg);
void readBuffer(
media_track_type trackType,
int64_t seekTimeUs = -1ll, int64_t *actualTimeUs = NULL, bool formatChange = false);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index dc4e5d4..6380ae8 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -69,7 +69,7 @@
};
struct NuPlayer::SeekAction : public Action {
- SeekAction(int64_t seekTimeUs)
+ explicit SeekAction(int64_t seekTimeUs)
: mSeekTimeUs(seekTimeUs) {
}
@@ -84,7 +84,7 @@
};
struct NuPlayer::ResumeDecoderAction : public Action {
- ResumeDecoderAction(bool needNotify)
+ explicit ResumeDecoderAction(bool needNotify)
: mNeedNotify(needNotify) {
}
@@ -99,7 +99,7 @@
};
struct NuPlayer::SetSurfaceAction : public Action {
- SetSurfaceAction(const sp<Surface> &surface)
+ explicit SetSurfaceAction(const sp<Surface> &surface)
: mSurface(surface) {
}
@@ -131,7 +131,7 @@
};
struct NuPlayer::PostMessageAction : public Action {
- PostMessageAction(const sp<AMessage> &msg)
+ explicit PostMessageAction(const sp<AMessage> &msg)
: mMessage(msg) {
}
@@ -150,7 +150,7 @@
struct NuPlayer::SimpleAction : public Action {
typedef void (NuPlayer::*ActionFunc)();
- SimpleAction(ActionFunc func)
+ explicit SimpleAction(ActionFunc func)
: mFunc(func) {
}
@@ -428,7 +428,7 @@
void NuPlayer::writeTrackInfo(
- Parcel* reply, const sp<AMessage> format) const {
+ Parcel* reply, const sp<AMessage>& format) const {
if (format == NULL) {
ALOGE("NULL format");
return;
@@ -666,12 +666,13 @@
}
mDeferredActions.push_back(
- new FlushDecoderAction(FLUSH_CMD_FLUSH /* audio */,
+ new FlushDecoderAction(
+ (obj != NULL ? FLUSH_CMD_FLUSH : FLUSH_CMD_NONE) /* audio */,
FLUSH_CMD_SHUTDOWN /* video */));
mDeferredActions.push_back(new SetSurfaceAction(surface));
- if (obj != NULL || mAudioDecoder != NULL) {
+ if (obj != NULL) {
if (mStarted) {
// Issue a seek to refresh the video screen only if started otherwise
// the extractor may not yet be started and will assert.
@@ -688,13 +689,13 @@
// again if possible.
mDeferredActions.push_back(
new SimpleAction(&NuPlayer::performScanSources));
- }
- // After a flush without shutdown, decoder is paused.
- // Don't resume it until source seek is done, otherwise it could
- // start pulling stale data too soon.
- mDeferredActions.push_back(
- new ResumeDecoderAction(false /* needNotify */));
+ // After a flush without shutdown, decoder is paused.
+ // Don't resume it until source seek is done, otherwise it could
+ // start pulling stale data too soon.
+ mDeferredActions.push_back(
+ new ResumeDecoderAction(false /* needNotify */));
+ }
processDeferredActions();
break;
@@ -1338,26 +1339,26 @@
flags |= Renderer::FLAG_REAL_TIME;
}
- sp<MetaData> audioMeta = mSource->getFormatMeta(true /* audio */);
- sp<MetaData> videoMeta = mSource->getFormatMeta(false /* audio */);
- if (audioMeta == NULL && videoMeta == NULL) {
+ bool hasAudio = (mSource->getFormat(true /* audio */) != NULL);
+ bool hasVideo = (mSource->getFormat(false /* audio */) != NULL);
+ if (!hasAudio && !hasVideo) {
ALOGE("no metadata for either audio or video source");
mSource->stop();
mSourceStarted = false;
notifyListener(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_MALFORMED);
return;
}
- ALOGV_IF(audioMeta == NULL, "no metadata for audio source"); // video only stream
+ ALOGV_IF(!hasAudio, "no metadata for audio source"); // video only stream
+
+ sp<MetaData> audioMeta = mSource->getFormatMeta(true /* audio */);
audio_stream_type_t streamType = AUDIO_STREAM_MUSIC;
if (mAudioSink != NULL) {
streamType = mAudioSink->getAudioStreamType();
}
- sp<AMessage> videoFormat = mSource->getFormat(false /* audio */);
-
mOffloadAudio =
- canOffloadStream(audioMeta, (videoFormat != NULL), mSource->isStreaming(), streamType)
+ canOffloadStream(audioMeta, hasVideo, mSource->isStreaming(), streamType)
&& (mPlaybackSettings.mSpeed == 1.f && mPlaybackSettings.mPitch == 1.f);
if (mOffloadAudio) {
flags |= Renderer::FLAG_OFFLOAD_AUDIO;
@@ -1718,6 +1719,16 @@
notifyListener(MEDIA_SET_VIDEO_SIZE, 0, 0);
return;
}
+ int32_t err = OK;
+ inputFormat->findInt32("err", &err);
+ if (err == -EWOULDBLOCK) {
+ ALOGW("Video meta is not available yet!");
+ return;
+ }
+ if (err != OK) {
+ ALOGW("Something is wrong with video meta!");
+ return;
+ }
int32_t displayWidth, displayHeight;
if (outputFormat != NULL) {
@@ -1802,8 +1813,10 @@
// Make sure we don't continue to scan sources until we finish flushing.
++mScanSourcesGeneration;
if (mScanSourcesPending) {
- mDeferredActions.push_back(
- new SimpleAction(&NuPlayer::performScanSources));
+ if (!needShutdown) {
+ mDeferredActions.push_back(
+ new SimpleAction(&NuPlayer::performScanSources));
+ }
mScanSourcesPending = false;
}
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h
index ae17c76..a002f6f 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h
@@ -33,7 +33,7 @@
struct NuPlayerDriver;
struct NuPlayer : public AHandler {
- NuPlayer(pid_t pid);
+ explicit NuPlayer(pid_t pid);
void setUID(uid_t uid);
@@ -280,7 +280,7 @@
void sendTimedMetaData(const sp<ABuffer> &buffer);
void sendTimedTextData(const sp<ABuffer> &buffer);
- void writeTrackInfo(Parcel* reply, const sp<AMessage> format) const;
+ void writeTrackInfo(Parcel* reply, const sp<AMessage>& format) const;
DISALLOW_EVIL_CONSTRUCTORS(NuPlayer);
};
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerCCDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerCCDecoder.cpp
index 13716cf..978d360 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerCCDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerCCDecoder.cpp
@@ -256,6 +256,12 @@
payload_size += last_byte;
} while (last_byte == 0xFF);
+ if (payload_size > SIZE_MAX / 8
+ || !br.atLeastNumBitsLeft(payload_size * 8)) {
+ ALOGV("Malformed SEI payload");
+ break;
+ }
+
// sei_payload()
if (payload_type == 4) {
bool isCC = false;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerCCDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerCCDecoder.h
index a297334..f310f37 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerCCDecoder.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerCCDecoder.h
@@ -33,7 +33,7 @@
kTrackTypeCEA708,
};
- CCDecoder(const sp<AMessage> ¬ify);
+ explicit CCDecoder(const sp<AMessage> ¬ify);
size_t getTrackCount() const;
sp<AMessage> getTrackInfo(size_t index) const;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h
index a334ec5..9966144 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h
@@ -30,7 +30,7 @@
class Surface;
struct NuPlayer::DecoderBase : public AHandler {
- DecoderBase(const sp<AMessage> ¬ify);
+ explicit DecoderBase(const sp<AMessage> ¬ify);
void configure(const sp<AMessage> &format);
void init();
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h
index 26d3a60..58008f0 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h
@@ -24,7 +24,7 @@
struct NuPlayer;
struct NuPlayerDriver : public MediaPlayerInterface {
- NuPlayerDriver(pid_t pid);
+ explicit NuPlayerDriver(pid_t pid);
virtual status_t initCheck();
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index b742762..f8453eb 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -1028,7 +1028,7 @@
// (Case 1)
// Must be a multiple of the frame size. If it is not a multiple of a frame size, it
// needs to fail, as we should not carry over fractional frames between calls.
- CHECK_EQ(copy % mAudioSink->frameSize(), 0);
+ CHECK_EQ(copy % mAudioSink->frameSize(), 0u);
// (Case 2, 3, 4)
// Return early to the caller.
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
index 0176eafa..438db0c 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
@@ -59,7 +59,7 @@
// The provides message is used to notify the player about various
// events.
- Source(const sp<AMessage> ¬ify)
+ explicit Source(const sp<AMessage> ¬ify)
: mNotify(notify) {
}
@@ -77,7 +77,11 @@
// an error or ERROR_END_OF_STREAM if not.
virtual status_t feedMoreTSData() = 0;
+ // Returns non-NULL format when the specified track exists.
+ // When the format has "err" set to -EWOULDBLOCK, source needs more time to get valid meta data.
+ // Returns NULL if the specified track doesn't exist or is invalid;
virtual sp<AMessage> getFormat(bool audio);
+
virtual sp<MetaData> getFormatMeta(bool /* audio */) { return NULL; }
virtual sp<MetaData> getFileFormatMeta() const { return NULL; }
diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
index c4e5df7..79e157f 100644
--- a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
@@ -477,7 +477,7 @@
return;
}
- CHECK_EQ(msg->what(), (int)kWhatNotify);
+ CHECK_EQ(msg->what(), kWhatNotify);
int32_t what;
CHECK(msg->findInt32("what", &what));
diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
index a7c5cf4..d6b1e8c 100644
--- a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
@@ -228,10 +228,13 @@
}
sp<MetaData> meta = source->getFormat();
+ if (meta == NULL) {
+ format->setInt32("err", -EWOULDBLOCK);
+ return format;
+ }
status_t err = convertMetaDataToMessage(meta, &format);
if (err != OK) { // format may have been cleared on error
- format = new AMessage;
- format->setInt32("err", err);
+ return NULL;
}
return format;
}
diff --git a/media/libmediaplayerservice/tests/Android.mk b/media/libmediaplayerservice/tests/Android.mk
index ea75a97..c0b3265 100644
--- a/media/libmediaplayerservice/tests/Android.mk
+++ b/media/libmediaplayerservice/tests/Android.mk
@@ -20,7 +20,6 @@
frameworks/av/media/libmediaplayerservice \
LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
LOCAL_32_BIT_ONLY := true
diff --git a/media/libnbaio/Android.bp b/media/libnbaio/Android.bp
new file mode 100644
index 0000000..615b541
--- /dev/null
+++ b/media/libnbaio/Android.bp
@@ -0,0 +1,36 @@
+cc_library_shared {
+ name: "libnbaio",
+ srcs: [
+ "AudioBufferProviderSource.cpp",
+ "AudioStreamOutSink.cpp",
+ "AudioStreamInSource.cpp",
+ "NBAIO.cpp",
+ "MonoPipe.cpp",
+ "MonoPipeReader.cpp",
+ "Pipe.cpp",
+ "PipeReader.cpp",
+ "SourceAudioBufferProvider.cpp",
+
+ "NBLog.cpp",
+ ],
+
+ // libsndfile license is incompatible; uncomment to use for local debug only
+ // srcs: [
+ // "LibsndfileSink.cpp",
+ // "LibsndfileSource.cpp",
+ // ],
+ // static_libs: ["libsndfile"],
+
+ shared_libs: [
+ "libaudioutils",
+ "libbinder",
+ "libcutils",
+ "libutils",
+ "liblog",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
diff --git a/media/libnbaio/Android.mk b/media/libnbaio/Android.mk
deleted file mode 100644
index e2f416b..0000000
--- a/media/libnbaio/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- AudioBufferProviderSource.cpp \
- AudioStreamOutSink.cpp \
- AudioStreamInSource.cpp \
- NBAIO.cpp \
- MonoPipe.cpp \
- MonoPipeReader.cpp \
- Pipe.cpp \
- PipeReader.cpp \
- SourceAudioBufferProvider.cpp
-
-LOCAL_SRC_FILES += NBLog.cpp
-
-# libsndfile license is incompatible; uncomment to use for local debug only
-#LOCAL_SRC_FILES += LibsndfileSink.cpp LibsndfileSource.cpp
-#LOCAL_C_INCLUDES += path/to/libsndfile/src
-#LOCAL_STATIC_LIBRARIES += libsndfile
-
-LOCAL_MODULE := libnbaio
-
-LOCAL_SHARED_LIBRARIES := \
- libaudioutils \
- libbinder \
- libcutils \
- libutils \
- liblog
-
-LOCAL_C_INCLUDES := $(call include-path-for, audio-utils)
-
-LOCAL_CFLAGS := -Werror -Wall
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 37fd5a5..b2eec91 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -216,7 +216,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::BaseState : public AState {
- BaseState(ACodec *codec, const sp<AState> &parentState = NULL);
+ explicit BaseState(ACodec *codec, const sp<AState> &parentState = NULL);
protected:
enum PortMode {
@@ -267,7 +267,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::DeathNotifier : public IBinder::DeathRecipient {
- DeathNotifier(const sp<AMessage> ¬ify)
+ explicit DeathNotifier(const sp<AMessage> ¬ify)
: mNotify(notify) {
}
@@ -285,7 +285,7 @@
};
struct ACodec::UninitializedState : public ACodec::BaseState {
- UninitializedState(ACodec *codec);
+ explicit UninitializedState(ACodec *codec);
protected:
virtual bool onMessageReceived(const sp<AMessage> &msg);
@@ -303,7 +303,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::LoadedState : public ACodec::BaseState {
- LoadedState(ACodec *codec);
+ explicit LoadedState(ACodec *codec);
protected:
virtual bool onMessageReceived(const sp<AMessage> &msg);
@@ -326,7 +326,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::LoadedToIdleState : public ACodec::BaseState {
- LoadedToIdleState(ACodec *codec);
+ explicit LoadedToIdleState(ACodec *codec);
protected:
virtual bool onMessageReceived(const sp<AMessage> &msg);
@@ -342,7 +342,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::IdleToExecutingState : public ACodec::BaseState {
- IdleToExecutingState(ACodec *codec);
+ explicit IdleToExecutingState(ACodec *codec);
protected:
virtual bool onMessageReceived(const sp<AMessage> &msg);
@@ -356,7 +356,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::ExecutingState : public ACodec::BaseState {
- ExecutingState(ACodec *codec);
+ explicit ExecutingState(ACodec *codec);
void submitRegularOutputBuffers();
void submitOutputMetaBuffers();
@@ -386,7 +386,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::OutputPortSettingsChangedState : public ACodec::BaseState {
- OutputPortSettingsChangedState(ACodec *codec);
+ explicit OutputPortSettingsChangedState(ACodec *codec);
protected:
virtual PortMode getPortMode(OMX_U32 portIndex);
@@ -403,7 +403,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::ExecutingToIdleState : public ACodec::BaseState {
- ExecutingToIdleState(ACodec *codec);
+ explicit ExecutingToIdleState(ACodec *codec);
protected:
virtual bool onMessageReceived(const sp<AMessage> &msg);
@@ -425,7 +425,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::IdleToLoadedState : public ACodec::BaseState {
- IdleToLoadedState(ACodec *codec);
+ explicit IdleToLoadedState(ACodec *codec);
protected:
virtual bool onMessageReceived(const sp<AMessage> &msg);
@@ -440,7 +440,7 @@
////////////////////////////////////////////////////////////////////////////////
struct ACodec::FlushingState : public ACodec::BaseState {
- FlushingState(ACodec *codec);
+ explicit FlushingState(ACodec *codec);
protected:
virtual bool onMessageReceived(const sp<AMessage> &msg);
@@ -494,7 +494,8 @@
////////////////////////////////////////////////////////////////////////////////
ACodec::ACodec()
- : mQuirks(0),
+ : mSampleRate(0),
+ mQuirks(0),
mNode(0),
mUsingNativeWindow(false),
mNativeWindowUsageBits(0),
@@ -1607,11 +1608,11 @@
status_t ACodec::setComponentRole(
bool isEncoder, const char *mime) {
- const char *role = getComponentRole(isEncoder, mime);
+ const char *role = GetComponentRole(isEncoder, mime);
if (role == NULL) {
return BAD_VALUE;
}
- status_t err = setComponentRole(mOMX, mNode, role);
+ status_t err = SetComponentRole(mOMX, mNode, role);
if (err != OK) {
ALOGW("[%s] Failed to set standard component role '%s'.",
mComponentName.c_str(), role);
@@ -1619,98 +1620,6 @@
return err;
}
-//static
-const char *ACodec::getComponentRole(
- bool isEncoder, const char *mime) {
- struct MimeToRole {
- const char *mime;
- const char *decoderRole;
- const char *encoderRole;
- };
-
- static const MimeToRole kMimeToRole[] = {
- { MEDIA_MIMETYPE_AUDIO_MPEG,
- "audio_decoder.mp3", "audio_encoder.mp3" },
- { MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I,
- "audio_decoder.mp1", "audio_encoder.mp1" },
- { MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II,
- "audio_decoder.mp2", "audio_encoder.mp2" },
- { MEDIA_MIMETYPE_AUDIO_AMR_NB,
- "audio_decoder.amrnb", "audio_encoder.amrnb" },
- { MEDIA_MIMETYPE_AUDIO_AMR_WB,
- "audio_decoder.amrwb", "audio_encoder.amrwb" },
- { MEDIA_MIMETYPE_AUDIO_AAC,
- "audio_decoder.aac", "audio_encoder.aac" },
- { MEDIA_MIMETYPE_AUDIO_VORBIS,
- "audio_decoder.vorbis", "audio_encoder.vorbis" },
- { MEDIA_MIMETYPE_AUDIO_OPUS,
- "audio_decoder.opus", "audio_encoder.opus" },
- { MEDIA_MIMETYPE_AUDIO_G711_MLAW,
- "audio_decoder.g711mlaw", "audio_encoder.g711mlaw" },
- { MEDIA_MIMETYPE_AUDIO_G711_ALAW,
- "audio_decoder.g711alaw", "audio_encoder.g711alaw" },
- { MEDIA_MIMETYPE_VIDEO_AVC,
- "video_decoder.avc", "video_encoder.avc" },
- { MEDIA_MIMETYPE_VIDEO_HEVC,
- "video_decoder.hevc", "video_encoder.hevc" },
- { MEDIA_MIMETYPE_VIDEO_MPEG4,
- "video_decoder.mpeg4", "video_encoder.mpeg4" },
- { MEDIA_MIMETYPE_VIDEO_H263,
- "video_decoder.h263", "video_encoder.h263" },
- { MEDIA_MIMETYPE_VIDEO_VP8,
- "video_decoder.vp8", "video_encoder.vp8" },
- { MEDIA_MIMETYPE_VIDEO_VP9,
- "video_decoder.vp9", "video_encoder.vp9" },
- { MEDIA_MIMETYPE_AUDIO_RAW,
- "audio_decoder.raw", "audio_encoder.raw" },
- { MEDIA_MIMETYPE_VIDEO_DOLBY_VISION,
- "video_decoder.dolby-vision", "video_encoder.dolby-vision" },
- { MEDIA_MIMETYPE_AUDIO_FLAC,
- "audio_decoder.flac", "audio_encoder.flac" },
- { MEDIA_MIMETYPE_AUDIO_MSGSM,
- "audio_decoder.gsm", "audio_encoder.gsm" },
- { MEDIA_MIMETYPE_VIDEO_MPEG2,
- "video_decoder.mpeg2", "video_encoder.mpeg2" },
- { MEDIA_MIMETYPE_AUDIO_AC3,
- "audio_decoder.ac3", "audio_encoder.ac3" },
- { MEDIA_MIMETYPE_AUDIO_EAC3,
- "audio_decoder.eac3", "audio_encoder.eac3" },
- };
-
- static const size_t kNumMimeToRole =
- sizeof(kMimeToRole) / sizeof(kMimeToRole[0]);
-
- size_t i;
- for (i = 0; i < kNumMimeToRole; ++i) {
- if (!strcasecmp(mime, kMimeToRole[i].mime)) {
- break;
- }
- }
-
- if (i == kNumMimeToRole) {
- return NULL;
- }
-
- return isEncoder ? kMimeToRole[i].encoderRole
- : kMimeToRole[i].decoderRole;
-}
-
-//static
-status_t ACodec::setComponentRole(
- const sp<IOMX> &omx, IOMX::node_id node, const char *role) {
- OMX_PARAM_COMPONENTROLETYPE roleParams;
- InitOMXParams(&roleParams);
-
- strncpy((char *)roleParams.cRole,
- role, OMX_MAX_STRINGNAME_SIZE - 1);
-
- roleParams.cRole[OMX_MAX_STRINGNAME_SIZE - 1] = '\0';
-
- return omx->setParameter(
- node, OMX_IndexParamStandardComponentRole,
- &roleParams, sizeof(roleParams));
-}
-
status_t ACodec::configureCodec(
const char *mime, const sp<AMessage> &msg) {
int32_t encoder;
@@ -2067,7 +1976,7 @@
}
ALOGD("[%s] Requested output format %#x and got %#x.",
mComponentName.c_str(), requestedColorFormat, colorFormat);
- if (!isFlexibleColorFormat(
+ if (!IsFlexibleColorFormat(
mOMX, mNode, colorFormat, haveNativeWindow, &flexibleEquivalent)
|| flexibleEquivalent != (OMX_U32)requestedColorFormat) {
// device did not handle flex-YUV request for native window, fall back
@@ -2782,6 +2691,7 @@
} else {
ALOGW("did not set AudioAndroidAacPresentation due to error %d when setting AudioAac", res);
}
+ mSampleRate = sampleRate;
return res;
}
@@ -3087,7 +2997,7 @@
// substitute back flexible color format to codec supported format
OMX_U32 flexibleEquivalent;
if (compressionFormat == OMX_VIDEO_CodingUnused
- && isFlexibleColorFormat(
+ && IsFlexibleColorFormat(
mOMX, mNode, format.eColorFormat, usingNativeBuffers, &flexibleEquivalent)
&& colorFormat == flexibleEquivalent) {
ALOGI("[%s] using color format %#x in place of %#x",
@@ -3191,7 +3101,7 @@
// find best legacy non-standard format
OMX_U32 flexibleEquivalent;
if (legacyFormat.eColorFormat == OMX_COLOR_FormatUnused
- && isFlexibleColorFormat(
+ && IsFlexibleColorFormat(
mOMX, mNode, format.eColorFormat, false /* usingNativeBuffers */,
&flexibleEquivalent)
&& flexibleEquivalent == OMX_COLOR_FormatYUV420Flexible) {
@@ -4745,188 +4655,6 @@
}
}
-// static
-bool ACodec::describeDefaultColorFormat(DescribeColorFormat2Params ¶ms) {
- MediaImage2 &image = params.sMediaImage;
- memset(&image, 0, sizeof(image));
-
- image.mType = MediaImage2::MEDIA_IMAGE_TYPE_UNKNOWN;
- image.mNumPlanes = 0;
-
- const OMX_COLOR_FORMATTYPE fmt = params.eColorFormat;
- image.mWidth = params.nFrameWidth;
- image.mHeight = params.nFrameHeight;
-
- // only supporting YUV420
- if (fmt != OMX_COLOR_FormatYUV420Planar &&
- fmt != OMX_COLOR_FormatYUV420PackedPlanar &&
- fmt != OMX_COLOR_FormatYUV420SemiPlanar &&
- fmt != OMX_COLOR_FormatYUV420PackedSemiPlanar &&
- fmt != (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YV12) {
- ALOGW("do not know color format 0x%x = %d", fmt, fmt);
- return false;
- }
-
- // TEMPORARY FIX for some vendors that advertise sliceHeight as 0
- if (params.nStride != 0 && params.nSliceHeight == 0) {
- ALOGW("using sliceHeight=%u instead of what codec advertised (=0)",
- params.nFrameHeight);
- params.nSliceHeight = params.nFrameHeight;
- }
-
- // we need stride and slice-height to be non-zero and sensible. These values were chosen to
- // prevent integer overflows further down the line, and do not indicate support for
- // 32kx32k video.
- if (params.nStride == 0 || params.nSliceHeight == 0
- || params.nStride > 32768 || params.nSliceHeight > 32768) {
- ALOGW("cannot describe color format 0x%x = %d with stride=%u and sliceHeight=%u",
- fmt, fmt, params.nStride, params.nSliceHeight);
- return false;
- }
-
- // set-up YUV format
- image.mType = MediaImage2::MEDIA_IMAGE_TYPE_YUV;
- image.mNumPlanes = 3;
- image.mBitDepth = 8;
- image.mBitDepthAllocated = 8;
- image.mPlane[image.Y].mOffset = 0;
- image.mPlane[image.Y].mColInc = 1;
- image.mPlane[image.Y].mRowInc = params.nStride;
- image.mPlane[image.Y].mHorizSubsampling = 1;
- image.mPlane[image.Y].mVertSubsampling = 1;
-
- switch ((int)fmt) {
- case HAL_PIXEL_FORMAT_YV12:
- if (params.bUsingNativeBuffers) {
- size_t ystride = align(params.nStride, 16);
- size_t cstride = align(params.nStride / 2, 16);
- image.mPlane[image.Y].mRowInc = ystride;
-
- image.mPlane[image.V].mOffset = ystride * params.nSliceHeight;
- image.mPlane[image.V].mColInc = 1;
- image.mPlane[image.V].mRowInc = cstride;
- image.mPlane[image.V].mHorizSubsampling = 2;
- image.mPlane[image.V].mVertSubsampling = 2;
-
- image.mPlane[image.U].mOffset = image.mPlane[image.V].mOffset
- + (cstride * params.nSliceHeight / 2);
- image.mPlane[image.U].mColInc = 1;
- image.mPlane[image.U].mRowInc = cstride;
- image.mPlane[image.U].mHorizSubsampling = 2;
- image.mPlane[image.U].mVertSubsampling = 2;
- break;
- } else {
- // fall through as YV12 is used for YUV420Planar by some codecs
- }
-
- case OMX_COLOR_FormatYUV420Planar:
- case OMX_COLOR_FormatYUV420PackedPlanar:
- image.mPlane[image.U].mOffset = params.nStride * params.nSliceHeight;
- image.mPlane[image.U].mColInc = 1;
- image.mPlane[image.U].mRowInc = params.nStride / 2;
- image.mPlane[image.U].mHorizSubsampling = 2;
- image.mPlane[image.U].mVertSubsampling = 2;
-
- image.mPlane[image.V].mOffset = image.mPlane[image.U].mOffset
- + (params.nStride * params.nSliceHeight / 4);
- image.mPlane[image.V].mColInc = 1;
- image.mPlane[image.V].mRowInc = params.nStride / 2;
- image.mPlane[image.V].mHorizSubsampling = 2;
- image.mPlane[image.V].mVertSubsampling = 2;
- break;
-
- case OMX_COLOR_FormatYUV420SemiPlanar:
- // FIXME: NV21 for sw-encoder, NV12 for decoder and hw-encoder
- case OMX_COLOR_FormatYUV420PackedSemiPlanar:
- // NV12
- image.mPlane[image.U].mOffset = params.nStride * params.nSliceHeight;
- image.mPlane[image.U].mColInc = 2;
- image.mPlane[image.U].mRowInc = params.nStride;
- image.mPlane[image.U].mHorizSubsampling = 2;
- image.mPlane[image.U].mVertSubsampling = 2;
-
- image.mPlane[image.V].mOffset = image.mPlane[image.U].mOffset + 1;
- image.mPlane[image.V].mColInc = 2;
- image.mPlane[image.V].mRowInc = params.nStride;
- image.mPlane[image.V].mHorizSubsampling = 2;
- image.mPlane[image.V].mVertSubsampling = 2;
- break;
-
- default:
- TRESPASS();
- }
- return true;
-}
-
-// static
-bool ACodec::describeColorFormat(
- const sp<IOMX> &omx, IOMX::node_id node,
- DescribeColorFormat2Params &describeParams)
-{
- OMX_INDEXTYPE describeColorFormatIndex;
- if (omx->getExtensionIndex(
- node, "OMX.google.android.index.describeColorFormat",
- &describeColorFormatIndex) == OK) {
- DescribeColorFormatParams describeParamsV1(describeParams);
- if (omx->getParameter(
- node, describeColorFormatIndex,
- &describeParamsV1, sizeof(describeParamsV1)) == OK) {
- describeParams.initFromV1(describeParamsV1);
- return describeParams.sMediaImage.mType != MediaImage2::MEDIA_IMAGE_TYPE_UNKNOWN;
- }
- } else if (omx->getExtensionIndex(
- node, "OMX.google.android.index.describeColorFormat2", &describeColorFormatIndex) == OK
- && omx->getParameter(
- node, describeColorFormatIndex, &describeParams, sizeof(describeParams)) == OK) {
- return describeParams.sMediaImage.mType != MediaImage2::MEDIA_IMAGE_TYPE_UNKNOWN;
- }
-
- return describeDefaultColorFormat(describeParams);
-}
-
-// static
-bool ACodec::isFlexibleColorFormat(
- const sp<IOMX> &omx, IOMX::node_id node,
- uint32_t colorFormat, bool usingNativeBuffers, OMX_U32 *flexibleEquivalent) {
- DescribeColorFormat2Params describeParams;
- InitOMXParams(&describeParams);
- describeParams.eColorFormat = (OMX_COLOR_FORMATTYPE)colorFormat;
- // reasonable dummy values
- describeParams.nFrameWidth = 128;
- describeParams.nFrameHeight = 128;
- describeParams.nStride = 128;
- describeParams.nSliceHeight = 128;
- describeParams.bUsingNativeBuffers = (OMX_BOOL)usingNativeBuffers;
-
- CHECK(flexibleEquivalent != NULL);
-
- if (!describeColorFormat(omx, node, describeParams)) {
- return false;
- }
-
- const MediaImage2 &img = describeParams.sMediaImage;
- if (img.mType == MediaImage2::MEDIA_IMAGE_TYPE_YUV) {
- if (img.mNumPlanes != 3
- || img.mPlane[img.Y].mHorizSubsampling != 1
- || img.mPlane[img.Y].mVertSubsampling != 1) {
- return false;
- }
-
- // YUV 420
- if (img.mPlane[img.U].mHorizSubsampling == 2
- && img.mPlane[img.U].mVertSubsampling == 2
- && img.mPlane[img.V].mHorizSubsampling == 2
- && img.mPlane[img.V].mVertSubsampling == 2) {
- // possible flexible YUV420 format
- if (img.mBitDepth <= 8) {
- *flexibleEquivalent = OMX_COLOR_FormatYUV420Flexible;
- return true;
- }
- }
- }
- return false;
-}
-
status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> ¬ify) {
const char *niceIndex = portIndex == kPortIndexInput ? "input" : "output";
OMX_PARAM_PORTDEFINITIONTYPE def;
@@ -4967,7 +4695,7 @@
describeParams.nSliceHeight = videoDef->nSliceHeight;
describeParams.bUsingNativeBuffers = OMX_FALSE;
- if (describeColorFormat(mOMX, mNode, describeParams)) {
+ if (DescribeColorFormat(mOMX, mNode, describeParams)) {
notify->setBuffer(
"image-data",
ABuffer::CreateAsCopy(
@@ -5473,8 +5201,14 @@
CHECK(mOutputFormat->findString("mime", &mime));
if (mime == MEDIA_MIMETYPE_AUDIO_RAW && (mEncoderDelay || mEncoderPadding)) {
- int32_t channelCount;
+ int32_t channelCount, sampleRate;
CHECK(mOutputFormat->findInt32("channel-count", &channelCount));
+ CHECK(mOutputFormat->findInt32("sample-rate", &sampleRate));
+ if (mSampleRate != 0 && sampleRate != 0) {
+ mEncoderDelay = mEncoderDelay * sampleRate / mSampleRate;
+ mEncoderPadding = mEncoderPadding * sampleRate / mSampleRate;
+ mSampleRate = sampleRate;
+ }
if (mSkipCutBuffer != NULL) {
size_t prevbufsize = mSkipCutBuffer->size();
if (prevbufsize != 0) {
@@ -8071,7 +7805,7 @@
const AString &name, const AString &mime, bool isEncoder,
sp<MediaCodecInfo::Capabilities> *caps) {
(*caps).clear();
- const char *role = getComponentRole(isEncoder, mime.c_str());
+ const char *role = GetComponentRole(isEncoder, mime.c_str());
if (role == NULL) {
return BAD_VALUE;
}
@@ -8092,7 +7826,7 @@
return err;
}
- err = setComponentRole(omx, node, role);
+ err = SetComponentRole(omx, node, role);
if (err != OK) {
omx->freeNode(node);
client.disconnect();
@@ -8141,7 +7875,7 @@
}
OMX_U32 flexibleEquivalent;
- if (isFlexibleColorFormat(
+ if (IsFlexibleColorFormat(
omx, node, portFormat.eColorFormat, false /* usingNativeWindow */,
&flexibleEquivalent)) {
bool marked = false;
diff --git a/media/libstagefright/Android.bp b/media/libstagefright/Android.bp
new file mode 100644
index 0000000..9dbde82
--- /dev/null
+++ b/media/libstagefright/Android.bp
@@ -0,0 +1,155 @@
+cc_library_shared {
+ name: "libstagefright",
+
+ srcs: [
+ "ACodec.cpp",
+ "AACExtractor.cpp",
+ "AACWriter.cpp",
+ "AMRExtractor.cpp",
+ "AMRWriter.cpp",
+ "AudioPlayer.cpp",
+ "AudioSource.cpp",
+ "CallbackDataSource.cpp",
+ "CameraSource.cpp",
+ "CameraSourceTimeLapse.cpp",
+ "CodecBase.cpp",
+ "DataConverter.cpp",
+ "DataSource.cpp",
+ "DataURISource.cpp",
+ "DRMExtractor.cpp",
+ "ESDS.cpp",
+ "FileSource.cpp",
+ "FLACExtractor.cpp",
+ "FrameRenderTracker.cpp",
+ "HTTPBase.cpp",
+ "HevcUtils.cpp",
+ "JPEGSource.cpp",
+ "MP3Extractor.cpp",
+ "MPEG2TSWriter.cpp",
+ "MPEG4Extractor.cpp",
+ "MPEG4Writer.cpp",
+ "MediaAdapter.cpp",
+ "MediaClock.cpp",
+ "MediaCodec.cpp",
+ "MediaCodecList.cpp",
+ "MediaCodecListOverrides.cpp",
+ "MediaCodecSource.cpp",
+ "MediaExtractor.cpp",
+ "MediaSync.cpp",
+ "MidiExtractor.cpp",
+ "http/MediaHTTP.cpp",
+ "MediaMuxer.cpp",
+ "MediaSource.cpp",
+ "NuCachedSource2.cpp",
+ "NuMediaExtractor.cpp",
+ "OMXClient.cpp",
+ "OggExtractor.cpp",
+ "SampleIterator.cpp",
+ "SampleTable.cpp",
+ "SimpleDecodingSource.cpp",
+ "SkipCutBuffer.cpp",
+ "StagefrightMediaScanner.cpp",
+ "StagefrightMetadataRetriever.cpp",
+ "SurfaceMediaSource.cpp",
+ "SurfaceUtils.cpp",
+ "ThrottledSource.cpp",
+ "Utils.cpp",
+ "VBRISeeker.cpp",
+ "VideoFrameScheduler.cpp",
+ "WAVExtractor.cpp",
+ "WVMExtractor.cpp",
+ "XINGSeeker.cpp",
+ "avc_utils.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/native/include/media/openmax",
+ "frameworks/native/include/media/hardware",
+ ],
+
+ shared_libs: [
+ "libaudioutils",
+ "libbinder",
+ "libcamera_client",
+ "libcutils",
+ "libdl",
+ "libdrmframework",
+ "libexpat",
+ "libgui",
+ "liblog",
+ "libmedia",
+ "libaudioclient",
+ "libmediautils",
+ "libnetd_client",
+ "libsonivox",
+ "libstagefright_omx",
+ "libui",
+ "libutils",
+ "libvorbisidec",
+
+ "libstagefright_foundation",
+ "libdl",
+ "libRScpp",
+ ],
+
+ static_libs: [
+ "libstagefright_color_conversion",
+ "libyuv_static",
+ "libstagefright_aacenc",
+ "libstagefright_matroska",
+ "libstagefright_mediafilter",
+ "libstagefright_webm",
+ "libstagefright_timedtext",
+ "libvpx",
+ "libwebm",
+ "libstagefright_mpeg2ts",
+ "libstagefright_id3",
+ "libFLAC",
+ "libmedia_helper",
+ ],
+
+ export_shared_lib_headers: ["libmedia"],
+ export_include_dirs: [
+ ".",
+ "include",
+ ],
+
+ cflags: [
+ "-Wno-multichar",
+ "-Werror",
+ "-Wno-error=deprecated-declarations",
+ "-Wall",
+ ],
+
+ product_variables: {
+ debuggable: {
+ // enable experiments only in userdebug and eng builds
+ cflags: ["-DENABLE_STAGEFRIGHT_EXPERIMENTS"],
+ },
+ },
+
+ sanitize: {
+ misc_undefined: [
+ "unsigned-integer-overflow",
+ "signed-integer-overflow",
+ ],
+ },
+}
+
+subdirs = [
+ "codecs/*",
+ "colorconversion",
+ "filters",
+ "foundation",
+ "http",
+ "httplive",
+ "id3",
+ "matroska",
+ "mpeg2ts",
+ "omx",
+ "rtsp",
+ "tests",
+ "timedtext",
+ "webm",
+ "wifi-display",
+]
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
deleted file mode 100644
index 3848502..0000000
--- a/media/libstagefright/Android.mk
+++ /dev/null
@@ -1,143 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-
-LOCAL_SRC_FILES:= \
- ACodec.cpp \
- AACExtractor.cpp \
- AACWriter.cpp \
- AMRExtractor.cpp \
- AMRWriter.cpp \
- AudioPlayer.cpp \
- AudioSource.cpp \
- CallbackDataSource.cpp \
- CameraSource.cpp \
- CameraSourceTimeLapse.cpp \
- CodecBase.cpp \
- DataConverter.cpp \
- DataSource.cpp \
- DataURISource.cpp \
- DRMExtractor.cpp \
- ESDS.cpp \
- FileSource.cpp \
- FLACExtractor.cpp \
- FrameRenderTracker.cpp \
- HTTPBase.cpp \
- HevcUtils.cpp \
- JPEGSource.cpp \
- MP3Extractor.cpp \
- MPEG2TSWriter.cpp \
- MPEG4Extractor.cpp \
- MPEG4Writer.cpp \
- MediaAdapter.cpp \
- MediaClock.cpp \
- MediaCodec.cpp \
- MediaCodecList.cpp \
- MediaCodecListOverrides.cpp \
- MediaCodecSource.cpp \
- MediaDefs.cpp \
- MediaExtractor.cpp \
- MediaSync.cpp \
- MidiExtractor.cpp \
- http/MediaHTTP.cpp \
- MediaMuxer.cpp \
- MediaSource.cpp \
- NuCachedSource2.cpp \
- NuMediaExtractor.cpp \
- OMXClient.cpp \
- OggExtractor.cpp \
- ProcessInfo.cpp \
- SampleIterator.cpp \
- SampleTable.cpp \
- SimpleDecodingSource.cpp \
- SkipCutBuffer.cpp \
- StagefrightMediaScanner.cpp \
- StagefrightMetadataRetriever.cpp \
- SurfaceMediaSource.cpp \
- SurfaceUtils.cpp \
- ThrottledSource.cpp \
- Utils.cpp \
- VBRISeeker.cpp \
- VideoFrameScheduler.cpp \
- WAVExtractor.cpp \
- WVMExtractor.cpp \
- XINGSeeker.cpp \
- avc_utils.cpp \
-
-LOCAL_C_INCLUDES:= \
- $(TOP)/frameworks/av/include/media/ \
- $(TOP)/frameworks/av/include/media/stagefright/timedtext \
- $(TOP)/frameworks/native/include/media/hardware \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/external/flac/include \
- $(TOP)/external/tremolo \
- $(TOP)/external/libvpx/libwebm \
- $(TOP)/system/netd/include \
- $(call include-path-for, audio-utils)
-
-LOCAL_SHARED_LIBRARIES := \
- libaudioutils \
- libbinder \
- libcamera_client \
- libcutils \
- libdl \
- libdrmframework \
- libexpat \
- libgui \
- libicui18n \
- libicuuc \
- liblog \
- libmedia \
- libmediautils \
- libnetd_client \
- libopus \
- libsonivox \
- libssl \
- libstagefright_omx \
- libstagefright_yuv \
- libsync \
- libui \
- libutils \
- libvorbisidec \
- libz \
- libpowermanager
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_color_conversion \
- libyuv_static \
- libstagefright_aacenc \
- libstagefright_matroska \
- libstagefright_mediafilter \
- libstagefright_webm \
- libstagefright_timedtext \
- libvpx \
- libwebm \
- libstagefright_mpeg2ts \
- libstagefright_id3 \
- libFLAC \
- libmedia_helper \
-
-LOCAL_SHARED_LIBRARIES += \
- libstagefright_enc_common \
- libstagefright_avc_common \
- libstagefright_foundation \
- libdl \
- libRScpp \
-
-LOCAL_CFLAGS += -Wno-multichar -Werror -Wno-error=deprecated-declarations -Wall
-
-# enable experiments only in userdebug and eng builds
-ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
-LOCAL_CFLAGS += -DENABLE_STAGEFRIGHT_EXPERIMENTS
-endif
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_MODULE:= libstagefright
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/CallbackDataSource.cpp b/media/libstagefright/CallbackDataSource.cpp
index 0df7da4..0434bab 100644
--- a/media/libstagefright/CallbackDataSource.cpp
+++ b/media/libstagefright/CallbackDataSource.cpp
@@ -51,7 +51,7 @@
}
ssize_t CallbackDataSource::readAt(off64_t offset, void* data, size_t size) {
- if (mMemory == NULL) {
+ if (mMemory == NULL || data == NULL) {
return -1;
}
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index 893da89..408ad7a 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -47,7 +47,7 @@
static const int64_t CAMERA_SOURCE_TIMEOUT_NS = 3000000000LL;
struct CameraSourceListener : public CameraListener {
- CameraSourceListener(const sp<CameraSource> &source);
+ explicit CameraSourceListener(const sp<CameraSource> &source);
virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2);
virtual void postData(int32_t msgType, const sp<IMemory> &dataPtr,
diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp
index 163a527..2cfadba 100644
--- a/media/libstagefright/DataSource.cpp
+++ b/media/libstagefright/DataSource.cpp
@@ -231,7 +231,7 @@
}
String8 cacheConfig;
- bool disconnectAtHighwatermark;
+ bool disconnectAtHighwatermark = false;
KeyedVector<String8, String8> nonCacheSpecificHeaders;
if (headers != NULL) {
nonCacheSpecificHeaders = *headers;
diff --git a/media/libstagefright/DataURISource.cpp b/media/libstagefright/DataURISource.cpp
index 2a61c3a..3dc345f 100644
--- a/media/libstagefright/DataURISource.cpp
+++ b/media/libstagefright/DataURISource.cpp
@@ -28,7 +28,7 @@
return NULL;
}
- char *commaPos = strrchr(uri, ',');
+ const char *commaPos = strrchr(uri, ',');
if (commaPos == NULL) {
return NULL;
diff --git a/media/libstagefright/FLACExtractor.cpp b/media/libstagefright/FLACExtractor.cpp
index 543e0af..1b88e5d 100644
--- a/media/libstagefright/FLACExtractor.cpp
+++ b/media/libstagefright/FLACExtractor.cpp
@@ -77,7 +77,7 @@
kMaxChannels = 8,
};
- FLACParser(
+ explicit FLACParser(
const sp<DataSource> &dataSource,
// If metadata pointers aren't provided, we don't fill them
const sp<MetaData> &fileMetadata = 0,
diff --git a/media/libstagefright/MPEG2TSWriter.cpp b/media/libstagefright/MPEG2TSWriter.cpp
index a9e8846..dc4e32c 100644
--- a/media/libstagefright/MPEG2TSWriter.cpp
+++ b/media/libstagefright/MPEG2TSWriter.cpp
@@ -35,7 +35,7 @@
namespace android {
struct MPEG2TSWriter::SourceInfo : public AHandler {
- SourceInfo(const sp<IMediaSource> &source);
+ explicit SourceInfo(const sp<IMediaSource> &source);
void start(const sp<AMessage> ¬ify);
void stop();
@@ -739,7 +739,7 @@
uint32_t crc = htonl(crc32(&buffer->data()[5], 12));
memcpy(&buffer->data()[17], &crc, sizeof(crc));
- CHECK_EQ(internalWrite(buffer->data(), buffer->size()), buffer->size());
+ CHECK_EQ(internalWrite(buffer->data(), buffer->size()), (ssize_t)buffer->size());
}
void MPEG2TSWriter::writeProgramMap() {
@@ -815,7 +815,7 @@
uint32_t crc = htonl(crc32(&buffer->data()[5], 12+mSources.size()*5));
memcpy(&buffer->data()[17+mSources.size()*5], &crc, sizeof(crc));
- CHECK_EQ(internalWrite(buffer->data(), buffer->size()), buffer->size());
+ CHECK_EQ(internalWrite(buffer->data(), buffer->size()), (ssize_t)buffer->size());
}
void MPEG2TSWriter::writeAccessUnit(
@@ -920,7 +920,7 @@
memcpy(ptr, accessUnit->data(), copy);
- CHECK_EQ(internalWrite(buffer->data(), buffer->size()), buffer->size());
+ CHECK_EQ(internalWrite(buffer->data(), buffer->size()), (ssize_t)buffer->size());
size_t offset = copy;
while (offset < accessUnit->size()) {
@@ -966,7 +966,7 @@
memcpy(ptr, accessUnit->data() + offset, copy);
CHECK_EQ(internalWrite(buffer->data(), buffer->size()),
- buffer->size());
+ (ssize_t)buffer->size());
offset += copy;
}
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 5441714..f6c73ca 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -184,7 +184,7 @@
// Each MPEG4DataSource caches the sampletable metadata for a single track.
struct MPEG4DataSource : public DataSource {
- MPEG4DataSource(const sp<DataSource> &source);
+ explicit MPEG4DataSource(const sp<DataSource> &source);
virtual status_t initCheck() const;
virtual ssize_t readAt(off64_t offset, void *data, size_t size);
@@ -602,7 +602,7 @@
// Reads an encoded integer 7 bits at a time until it encounters the high bit clear.
static int32_t readSize(off64_t offset,
- const sp<DataSource> DataSource, uint8_t *numOfBytes) {
+ const sp<DataSource> &DataSource, uint8_t *numOfBytes) {
uint32_t size = 0;
uint8_t data;
bool moreData = true;
@@ -1018,7 +1018,9 @@
while (cur && cur->next != mLastTrack) {
cur = cur->next;
}
- cur->next = NULL;
+ if (cur) {
+ cur->next = NULL;
+ }
delete mLastTrack;
mLastTrack = cur;
}
@@ -3890,7 +3892,12 @@
return OK;
}
if (smplcnt > mCurrentSampleInfoAllocSize) {
- mCurrentSampleInfoSizes = (uint8_t*) realloc(mCurrentSampleInfoSizes, smplcnt);
+ uint8_t * newPtr = (uint8_t*) realloc(mCurrentSampleInfoSizes, smplcnt);
+ if (newPtr == NULL) {
+ ALOGE("failed to realloc %u -> %u", mCurrentSampleInfoAllocSize, smplcnt);
+ return NO_MEMORY;
+ }
+ mCurrentSampleInfoSizes = newPtr;
mCurrentSampleInfoAllocSize = smplcnt;
}
@@ -3929,6 +3936,7 @@
if (entrycount > mCurrentSampleInfoOffsetsAllocSize) {
uint64_t *newPtr = (uint64_t *)realloc(mCurrentSampleInfoOffsets, entrycount * 8);
if (newPtr == NULL) {
+ ALOGE("failed to realloc %u -> %u", mCurrentSampleInfoOffsetsAllocSize, entrycount * 8);
return NO_MEMORY;
}
mCurrentSampleInfoOffsets = newPtr;
@@ -4407,8 +4415,8 @@
// fall through
}
- off64_t offset;
- size_t size;
+ off64_t offset = 0;
+ size_t size = 0;
uint32_t cts, stts;
bool isSyncSample;
bool newBuffer = false;
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
old mode 100644
new mode 100755
index 5e96c2b..5cf5863
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -133,7 +133,7 @@
mTotalNumTableEntries(0),
mNumValuesInCurrEntry(0),
mCurrTableEntriesElement(NULL) {
- CHECK_GT(mElementCapacity, 0);
+ CHECK_GT(mElementCapacity, 0u);
// Ensure no integer overflow on allocation in add().
CHECK_LT(ENTRY_SIZE, UINT32_MAX / mElementCapacity);
}
@@ -161,7 +161,7 @@
--iterations;
}
CHECK(it != mTableEntryList.end());
- CHECK_EQ(iterations, 0);
+ CHECK_EQ(iterations, 0u);
(*it)[(pos % (mElementCapacity * ENTRY_SIZE))] = value;
}
@@ -182,7 +182,7 @@
--iterations;
}
CHECK(it != mTableEntryList.end());
- CHECK_EQ(iterations, 0);
+ CHECK_EQ(iterations, 0u);
value = (*it)[(pos % (mElementCapacity * ENTRY_SIZE))];
return true;
@@ -230,12 +230,12 @@
// 2. followed by the values in the table enties in order
// @arg writer the writer to actual write to the storage
void write(MPEG4Writer *writer) const {
- CHECK_EQ(mNumValuesInCurrEntry % ENTRY_SIZE, 0);
+ CHECK_EQ(mNumValuesInCurrEntry % ENTRY_SIZE, 0u);
uint32_t nEntries = mTotalNumTableEntries;
writer->writeInt32(nEntries);
for (typename List<TYPE *>::iterator it = mTableEntryList.begin();
it != mTableEntryList.end(); ++it) {
- CHECK_GT(nEntries, 0);
+ CHECK_GT(nEntries, 0u);
if (nEntries >= mElementCapacity) {
writer->write(*it, sizeof(TYPE) * ENTRY_SIZE, mElementCapacity);
nEntries -= mElementCapacity;
@@ -643,7 +643,7 @@
if (mMaxFileDurationLimitUs != 0) {
if (bitRate > 0) {
int64_t size2 =
- ((mMaxFileDurationLimitUs * bitRate * 6) / 1000 / 8000000);
+ ((mMaxFileDurationLimitUs / 1000) * bitRate * 6) / 8000000;
if (mMaxFileSizeLimitBytes != 0 && mIsFileSizeLimitExplicitlyRequested) {
// When both file size and duration limits are set,
// we use the smaller limit of the two.
@@ -1237,7 +1237,7 @@
mOffset += length + 4;
} else {
- CHECK_LT(length, 65536);
+ CHECK_LT(length, 65536u);
uint8_t x = length >> 8;
::write(mFd, &x, 1);
@@ -1297,7 +1297,7 @@
}
void MPEG4Writer::beginBox(const char *fourcc) {
- CHECK_EQ(strlen(fourcc), 4);
+ CHECK_EQ(strlen(fourcc), 4u);
mBoxes.push_back(mWriteMoovBoxToMemory?
mMoovBoxBufferOffset: mOffset);
@@ -1348,7 +1348,7 @@
}
void MPEG4Writer::writeFourcc(const char *s) {
- CHECK_EQ(strlen(s), 4);
+ CHECK_EQ(strlen(s), 4u);
write(s, 1, 4);
}
@@ -3085,7 +3085,7 @@
mOwner->writeInt16(primaries);
mOwner->writeInt16(transfer);
mOwner->writeInt16(coeffs);
- mOwner->writeInt8(fullRange ? 128 : 0);
+ mOwner->writeInt8(int8_t(fullRange ? 0x80 : 0x0));
mOwner->endBox(); // colr
}
}
@@ -3129,10 +3129,10 @@
void MPEG4Writer::Track::writeMp4aEsdsBox() {
mOwner->beginBox("esds");
CHECK(mCodecSpecificData);
- CHECK_GT(mCodecSpecificDataSize, 0);
+ CHECK_GT(mCodecSpecificDataSize, 0u);
// Make sure all sizes encode to a single byte.
- CHECK_LT(mCodecSpecificDataSize + 23, 128);
+ CHECK_LT(mCodecSpecificDataSize + 23, 128u);
mOwner->writeInt32(0); // version=0, flags=0
mOwner->writeInt8(0x03); // ES_DescrTag
@@ -3171,10 +3171,10 @@
void MPEG4Writer::Track::writeMp4vEsdsBox() {
CHECK(mCodecSpecificData);
- CHECK_GT(mCodecSpecificDataSize, 0);
+ CHECK_GT(mCodecSpecificDataSize, 0u);
// Make sure all sizes encode to a single byte.
- CHECK_LT(23 + mCodecSpecificDataSize, 128);
+ CHECK_LT(23 + mCodecSpecificDataSize, 128u);
mOwner->beginBox("esds");
@@ -3288,13 +3288,22 @@
void MPEG4Writer::Track::writeMdhdBox(uint32_t now) {
int64_t trakDurationUs = getDurationUs();
+ int64_t mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6;
mOwner->beginBox("mdhd");
- mOwner->writeInt32(0); // version=0, flags=0
- mOwner->writeInt32(now); // creation time
- mOwner->writeInt32(now); // modification time
- mOwner->writeInt32(mTimeScale); // media timescale
- int32_t mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6;
- mOwner->writeInt32(mdhdDuration); // use media timescale
+
+ if (mdhdDuration > UINT32_MAX) {
+ mOwner->writeInt32((1 << 24)); // version=1, flags=0
+ mOwner->writeInt64((int64_t)now); // creation time
+ mOwner->writeInt64((int64_t)now); // modification time
+ mOwner->writeInt32(mTimeScale); // media timescale
+ mOwner->writeInt64(mdhdDuration); // media timescale
+ } else {
+ mOwner->writeInt32(0); // version=0, flags=0
+ mOwner->writeInt32(now); // creation time
+ mOwner->writeInt32(now); // modification time
+ mOwner->writeInt32(mTimeScale); // media timescale
+ mOwner->writeInt32((int32_t)mdhdDuration); // use media timescale
+ }
// Language follows the three letter standard ISO-639-2/T
// 'e', 'n', 'g' for "English", for instance.
// Each character is packed as the difference between its ASCII value and 0x60.
@@ -3340,7 +3349,7 @@
void MPEG4Writer::Track::writeAvccBox() {
CHECK(mCodecSpecificData);
- CHECK_GE(mCodecSpecificDataSize, 5);
+ CHECK_GE(mCodecSpecificDataSize, 5u);
// Patch avcc's lengthSize field to match the number
// of bytes we use to indicate the size of a nal unit.
@@ -3354,7 +3363,7 @@
void MPEG4Writer::Track::writeHvccBox() {
CHECK(mCodecSpecificData);
- CHECK_GE(mCodecSpecificDataSize, 5);
+ CHECK_GE(mCodecSpecificDataSize, 5u);
// Patch avcc's lengthSize field to match the number
// of bytes we use to indicate the size of a nal unit.
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index e476424..b088775 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -53,7 +53,7 @@
namespace android {
-static int64_t getId(sp<IResourceManagerClient> client) {
+static int64_t getId(const sp<IResourceManagerClient> &client) {
return (int64_t) client.get();
}
@@ -65,7 +65,7 @@
static const int kMaxReclaimWaitTimeInUs = 500000; // 0.5s
struct ResourceManagerClient : public BnResourceManagerClient {
- ResourceManagerClient(MediaCodec* codec) : mMediaCodec(codec) {}
+ explicit ResourceManagerClient(MediaCodec* codec) : mMediaCodec(codec) {}
virtual bool reclaimResource() {
sp<MediaCodec> codec = mMediaCodec.promote();
@@ -142,7 +142,7 @@
void MediaCodec::ResourceManagerServiceProxy::addResource(
int64_t clientId,
- const sp<IResourceManagerClient> client,
+ const sp<IResourceManagerClient> &client,
const Vector<MediaResource> &resources) {
Mutex::Autolock _l(mLock);
if (mService == NULL) {
@@ -2569,7 +2569,7 @@
//static
size_t MediaCodec::CreateFramesRenderedMessage(
- std::list<FrameRenderTracker::Info> done, sp<AMessage> &msg) {
+ const std::list<FrameRenderTracker::Info> &done, sp<AMessage> &msg) {
size_t index = 0;
for (std::list<FrameRenderTracker::Info>::const_iterator it = done.cbegin();
diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp
index 0fb5072..23d49f0 100644
--- a/media/libstagefright/MediaCodecList.cpp
+++ b/media/libstagefright/MediaCodecList.cpp
@@ -182,7 +182,7 @@
void MediaCodecList::parseTopLevelXMLFile(const char *codecs_xml, bool ignore_errors) {
// get href_base
- char *href_base_end = strrchr(codecs_xml, '/');
+ const char *href_base_end = strrchr(codecs_xml, '/');
if (href_base_end != NULL) {
mHrefBase = AString(codecs_xml, href_base_end - codecs_xml + 1);
}
@@ -888,18 +888,18 @@
return -ENOENT;
}
-static status_t limitFoundMissingAttr(AString name, const char *attr, bool found = true) {
+static status_t limitFoundMissingAttr(const AString &name, const char *attr, bool found = true) {
ALOGE("limit '%s' with %s'%s' attribute", name.c_str(),
(found ? "" : "no "), attr);
return -EINVAL;
}
-static status_t limitError(AString name, const char *msg) {
+static status_t limitError(const AString &name, const char *msg) {
ALOGE("limit '%s' %s", name.c_str(), msg);
return -EINVAL;
}
-static status_t limitInvalidAttr(AString name, const char *attr, AString value) {
+static status_t limitInvalidAttr(const AString &name, const char *attr, const AString &value) {
ALOGE("limit '%s' with invalid '%s' attribute (%s)", name.c_str(),
attr, value.c_str());
return -EINVAL;
@@ -1165,13 +1165,15 @@
CHECK(info != NULL);
AString componentName = info->getCodecName();
- if (!((flags & kHardwareCodecsOnly) && !isSoftwareCodec(componentName))) {
+ if ((flags & kHardwareCodecsOnly) && isSoftwareCodec(componentName)) {
+ ALOGV("skipping SW codec '%s'", componentName.c_str());
+ } else {
matches->push(componentName);
ALOGV("matching '%s'", componentName.c_str());
}
}
- if (flags & kPreferSoftwareCodecs) {
+ if (flags & kPreferSoftwareCodecs || property_get_bool("debug.stagefright.swcodec", false)) {
matches->sort(compareSoftwareCodecsFirst);
}
}
diff --git a/media/libstagefright/MediaCodecListOverrides.cpp b/media/libstagefright/MediaCodecListOverrides.cpp
index 4ec36b5..33795f3 100644
--- a/media/libstagefright/MediaCodecListOverrides.cpp
+++ b/media/libstagefright/MediaCodecListOverrides.cpp
@@ -49,7 +49,7 @@
static const int kMaxInstances = 32;
// TODO: move MediaCodecInfo to C++. Until then, some temp methods to parse out info.
-static bool getMeasureSize(sp<MediaCodecInfo::Capabilities> caps, int32_t *width, int32_t *height) {
+static bool getMeasureSize(const sp<MediaCodecInfo::Capabilities> &caps, int32_t *width, int32_t *height) {
AString sizeRange;
if (!caps->getDetails()->findString("size-range", &sizeRange)) {
return false;
@@ -72,7 +72,7 @@
return (*width > 0) && (*height > 0);
}
-static void getMeasureBitrate(sp<MediaCodecInfo::Capabilities> caps, int32_t *bitrate) {
+static void getMeasureBitrate(const sp<MediaCodecInfo::Capabilities> &caps, int32_t *bitrate) {
// Until have native MediaCodecInfo, we cannot get bitrates based on profile/levels.
// We use 200000 as default value for our measurement.
*bitrate = 200000;
@@ -90,7 +90,7 @@
}
static sp<AMessage> getMeasureFormat(
- bool isEncoder, AString mime, sp<MediaCodecInfo::Capabilities> caps) {
+ bool isEncoder, const AString &mime, const sp<MediaCodecInfo::Capabilities> &caps) {
sp<AMessage> format = new AMessage();
format->setString("mime", mime);
@@ -128,7 +128,7 @@
}
static size_t doProfileEncoderInputBuffers(
- AString name, AString mime, sp<MediaCodecInfo::Capabilities> caps) {
+ const AString &name, const AString &mime, const sp<MediaCodecInfo::Capabilities> &caps) {
ALOGV("doProfileEncoderInputBuffers: name %s, mime %s", name.c_str(), mime.c_str());
sp<AMessage> format = getMeasureFormat(true /* isEncoder */, mime, caps);
@@ -183,7 +183,7 @@
}
static size_t doProfileCodecs(
- bool isEncoder, AString name, AString mime, sp<MediaCodecInfo::Capabilities> caps) {
+ bool isEncoder, const AString &name, const AString &mime, const sp<MediaCodecInfo::Capabilities> &caps) {
sp<AMessage> format = getMeasureFormat(isEncoder, mime, caps);
if (format == NULL) {
return 0;
@@ -337,7 +337,7 @@
global_results->add(kPolicySupportsMultipleSecureCodecs, supportMultipleSecureCodecs);
}
-static AString globalResultsToXml(const CodecSettings& results) {
+static AString globalResultsToXml(const CodecSettings &results) {
AString ret;
for (size_t i = 0; i < results.size(); ++i) {
AString setting = AStringPrintf(
@@ -349,7 +349,7 @@
return ret;
}
-static AString codecResultsToXml(const KeyedVector<AString, CodecSettings>& results) {
+static AString codecResultsToXml(const KeyedVector<AString, CodecSettings> &results) {
AString ret;
for (size_t i = 0; i < results.size(); ++i) {
AString name;
@@ -362,7 +362,7 @@
name.c_str(),
mime.c_str());
ret.append(codec);
- CodecSettings settings = results.valueAt(i);
+ const CodecSettings &settings = results.valueAt(i);
for (size_t i = 0; i < settings.size(); ++i) {
// WARNING: we assume all the settings are "Limit". Currently we have only one type
// of setting in this case, which is "max-supported-instances".
@@ -379,9 +379,9 @@
void exportResultsToXML(
const char *fileName,
- const CodecSettings& global_results,
- const KeyedVector<AString, CodecSettings>& encoder_results,
- const KeyedVector<AString, CodecSettings>& decoder_results) {
+ const CodecSettings &global_results,
+ const KeyedVector<AString, CodecSettings> &encoder_results,
+ const KeyedVector<AString, CodecSettings> &decoder_results) {
if (global_results.size() == 0 && encoder_results.size() == 0 && decoder_results.size() == 0) {
return;
}
diff --git a/media/libstagefright/MediaCodecSource.cpp b/media/libstagefright/MediaCodecSource.cpp
index ea5ef06..35c07ca 100644
--- a/media/libstagefright/MediaCodecSource.cpp
+++ b/media/libstagefright/MediaCodecSource.cpp
@@ -47,7 +47,7 @@
const int kStopTimeoutUs = 300000; // allow 1 sec for shutting down encoder
struct MediaCodecSource::Puller : public AHandler {
- Puller(const sp<MediaSource> &source);
+ explicit Puller(const sp<MediaSource> &source);
void interruptSource();
status_t start(const sp<MetaData> &meta, const sp<AMessage> ¬ify);
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index 453db03..afd6ffb 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -31,7 +31,7 @@
namespace android {
struct PageCache {
- PageCache(size_t pageSize);
+ explicit PageCache(size_t pageSize);
~PageCache();
struct Page {
diff --git a/media/libstagefright/OggExtractor.cpp b/media/libstagefright/OggExtractor.cpp
index ebbe510..e31c37c 100644
--- a/media/libstagefright/OggExtractor.cpp
+++ b/media/libstagefright/OggExtractor.cpp
@@ -46,7 +46,7 @@
namespace android {
struct OggSource : public MediaSource {
- OggSource(const sp<OggExtractor> &extractor);
+ explicit OggSource(const sp<OggExtractor> &extractor);
virtual sp<MetaData> getFormat();
@@ -164,7 +164,7 @@
};
struct MyVorbisExtractor : public MyOggExtractor {
- MyVorbisExtractor(const sp<DataSource> &source)
+ explicit MyVorbisExtractor(const sp<DataSource> &source)
: MyOggExtractor(source,
MEDIA_MIMETYPE_AUDIO_VORBIS,
/* numHeaders */ 3,
@@ -192,7 +192,7 @@
static const int32_t kOpusSampleRate = 48000;
static const int64_t kOpusSeekPreRollUs = 80000; // 80 ms
- MyOpusExtractor(const sp<DataSource> &source)
+ explicit MyOpusExtractor(const sp<DataSource> &source)
: MyOggExtractor(source, MEDIA_MIMETYPE_AUDIO_OPUS, /*numHeaders*/ 2, kOpusSeekPreRollUs),
mChannelCount(0),
mCodecDelay(0),
diff --git a/media/libstagefright/SampleIterator.cpp b/media/libstagefright/SampleIterator.cpp
index 54c9fa3..4f31c5f 100644
--- a/media/libstagefright/SampleIterator.cpp
+++ b/media/libstagefright/SampleIterator.cpp
@@ -282,7 +282,7 @@
default:
{
- CHECK_EQ(mTable->mSampleSizeFieldSize, 4);
+ CHECK_EQ(mTable->mSampleSizeFieldSize, 4u);
uint8_t x;
if (mTable->mDataSource->readAt(
@@ -305,8 +305,16 @@
return ERROR_OUT_OF_RANGE;
}
- while (sampleIndex >= mTTSSampleIndex + mTTSCount) {
- if (mTimeToSampleIndex == mTable->mTimeToSampleCount) {
+ while (true) {
+ if (mTTSSampleIndex > UINT32_MAX - mTTSCount) {
+ return ERROR_OUT_OF_RANGE;
+ }
+ if(sampleIndex < mTTSSampleIndex + mTTSCount) {
+ break;
+ }
+ if (mTimeToSampleIndex == mTable->mTimeToSampleCount ||
+ (mTTSDuration != 0 && mTTSCount > UINT32_MAX / mTTSDuration) ||
+ mTTSSampleTime > UINT32_MAX - (mTTSCount * mTTSDuration)) {
return ERROR_OUT_OF_RANGE;
}
diff --git a/media/libstagefright/SampleTable.cpp b/media/libstagefright/SampleTable.cpp
index ee5fdf0..93cd275 100644
--- a/media/libstagefright/SampleTable.cpp
+++ b/media/libstagefright/SampleTable.cpp
@@ -215,6 +215,11 @@
status_t SampleTable::setSampleToChunkParams(
off64_t data_offset, size_t data_size) {
if (mSampleToChunkOffset >= 0) {
+ // already set
+ return ERROR_MALFORMED;
+ }
+
+ if (data_offset < 0) {
return ERROR_MALFORMED;
}
@@ -696,7 +701,13 @@
}
++sampleIndex;
- sampleTime += delta;
+ if (sampleTime > UINT32_MAX - delta) {
+ ALOGE("%u + %u would overflow, clamping",
+ sampleTime, delta);
+ sampleTime = UINT32_MAX;
+ } else {
+ sampleTime += delta;
+ }
}
}
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index be5067d..96e506e 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -44,7 +44,7 @@
#include <media/stagefright/MetaData.h>
#include <media/stagefright/Utils.h>
-#include <CharacterEncodingDetector.h>
+#include <media/CharacterEncodingDetector.h>
namespace android {
diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp
index 15ff569..eadab86 100644
--- a/media/libstagefright/SurfaceMediaSource.cpp
+++ b/media/libstagefright/SurfaceMediaSource.cpp
@@ -97,13 +97,13 @@
mFrameAvailableListener = listener;
}
-void SurfaceMediaSource::dump(String8& result) const
+void SurfaceMediaSource::dumpState(String8& result) const
{
char buffer[1024];
- dump(result, "", buffer, 1024);
+ dumpState(result, "", buffer, 1024);
}
-void SurfaceMediaSource::dump(
+void SurfaceMediaSource::dumpState(
String8& result,
const char* /* prefix */,
char* buffer,
@@ -112,7 +112,7 @@
Mutex::Autolock lock(mMutex);
result.append(buffer);
- mConsumer->dump(result, "");
+ mConsumer->dumpState(result, "");
}
status_t SurfaceMediaSource::setFrameRate(int32_t fps)
@@ -167,7 +167,7 @@
mMaxAcquiredBufferCount = bufferCount;
}
- CHECK_GT(mMaxAcquiredBufferCount, 1);
+ CHECK_GT(mMaxAcquiredBufferCount, 1u);
status_t err =
mConsumer->setMaxAcquiredBufferCount(mMaxAcquiredBufferCount);
@@ -186,7 +186,7 @@
ALOGV("setMaxAcquiredBufferCount(%zu)", count);
Mutex::Autolock lock(mMutex);
- CHECK_GT(count, 1);
+ CHECK_GT(count, 1u);
mMaxAcquiredBufferCount = count;
return OK;
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
index 1c76ad7..36be7a0 100644
--- a/media/libstagefright/Utils.cpp
+++ b/media/libstagefright/Utils.cpp
@@ -1070,7 +1070,7 @@
return res != NULL && res < data + length - 4 ? res : &data[length];
}
-static size_t reassembleAVCC(const sp<ABuffer> &csd0, const sp<ABuffer> csd1, char *avcc) {
+static size_t reassembleAVCC(const sp<ABuffer> &csd0, const sp<ABuffer> &csd1, char *avcc) {
avcc[0] = 1; // version
avcc[1] = 0x64; // profile (default to high)
avcc[2] = 0; // constraints (default to none)
@@ -1713,7 +1713,7 @@
|| (t0.mSeq == t1.mSeq && t0.mTimeUs < t1.mTimeUs);
}
-void writeToAMessage(sp<AMessage> msg, const AudioPlaybackRate &rate) {
+void writeToAMessage(const sp<AMessage> &msg, const AudioPlaybackRate &rate) {
msg->setFloat("speed", rate.mSpeed);
msg->setFloat("pitch", rate.mPitch);
msg->setInt32("audio-fallback-mode", rate.mFallbackMode);
@@ -1728,7 +1728,7 @@
CHECK(msg->findInt32("audio-stretch-mode", (int32_t *)&rate->mStretchMode));
}
-void writeToAMessage(sp<AMessage> msg, const AVSyncSettings &sync, float videoFpsHint) {
+void writeToAMessage(const sp<AMessage> &msg, const AVSyncSettings &sync, float videoFpsHint) {
msg->setInt32("sync-source", sync.mSource);
msg->setInt32("audio-adjust-mode", sync.mAudioAdjustMode);
msg->setFloat("tolerance", sync.mTolerance);
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp
index 1f04fa0..780b746 100644
--- a/media/libstagefright/WAVExtractor.cpp
+++ b/media/libstagefright/WAVExtractor.cpp
@@ -45,7 +45,7 @@
};
static const char* WAVEEXT_SUBFORMAT = "\x00\x00\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71";
-
+static const char* AMBISONIC_SUBFORMAT = "\x00\x00\x21\x07\xD3\x11\x86\x44\xC8\xC1\xCA\x00\x00\x00";
static uint32_t U32_LE_AT(const uint8_t *ptr) {
return ptr[3] << 24 | ptr[2] << 16 | ptr[1] << 8 | ptr[0];
@@ -250,7 +250,8 @@
// In a WAVE_EXT header, the first two bytes of the GUID stored at byte 24 contain
// the sample format, using the same definitions as a regular WAV header
mWaveFormat = U16_LE_AT(&formatSpec[24]);
- if (memcmp(&formatSpec[26], WAVEEXT_SUBFORMAT, 14)) {
+ if (memcmp(&formatSpec[26], WAVEEXT_SUBFORMAT, 14) &&
+ memcmp(&formatSpec[26], AMBISONIC_SUBFORMAT, 14)) {
ALOGE("unsupported GUID");
return ERROR_UNSUPPORTED;
}
diff --git a/media/libstagefright/codecs/Android.mk b/media/libstagefright/codecs/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/aacdec/Android.bp b/media/libstagefright/codecs/aacdec/Android.bp
new file mode 100644
index 0000000..9ee9b9d
--- /dev/null
+++ b/media/libstagefright/codecs/aacdec/Android.bp
@@ -0,0 +1,32 @@
+cc_library_shared {
+ name: "libstagefright_soft_aacdec",
+
+ srcs: [
+ "SoftAAC2.cpp",
+ "DrcPresModeWrap.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ static_libs: ["libFraunhoferAAC"],
+
+ shared_libs: [
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "libcutils",
+ "liblog",
+ ],
+}
diff --git a/media/libstagefright/codecs/aacdec/Android.mk b/media/libstagefright/codecs/aacdec/Android.mk
deleted file mode 100644
index 84ea708..0000000
--- a/media/libstagefright/codecs/aacdec/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftAAC2.cpp \
- DrcPresModeWrap.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
- external/aac/libAACdec/include \
- external/aac/libPCMutils/include \
- external/aac/libFDK/include \
- external/aac/libMpegTPDec/include \
- external/aac/libSBRdec/include \
- external/aac/libSYS/include
-
-LOCAL_CFLAGS :=
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-LOCAL_STATIC_LIBRARIES := libFraunhoferAAC
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils libcutils liblog
-
-LOCAL_MODULE := libstagefright_soft_aacdec
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
index ff76bc8..1c5e3c6 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
@@ -36,7 +36,7 @@
#define DRC_DEFAULT_MOBILE_DRC_CUT 127 /* maximum compression of dynamic range for mobile conf */
#define DRC_DEFAULT_MOBILE_DRC_BOOST 127 /* maximum compression of dynamic range for mobile conf */
#define DRC_DEFAULT_MOBILE_DRC_HEAVY 1 /* switch for heavy compression for mobile conf */
-#define DRC_DEFAULT_MOBILE_ENC_LEVEL -1 /* encoder target level; -1 => the value is unknown, otherwise dB step value (e.g. 64 for -16 dB) */
+#define DRC_DEFAULT_MOBILE_ENC_LEVEL (-1) /* encoder target level; -1 => the value is unknown, otherwise dB step value (e.g. 64 for -16 dB) */
#define MAX_CHANNEL_COUNT 8 /* maximum number of audio channels that can be decoded */
// names of properties that can be used to override the default DRC settings
#define PROP_DRC_OVERRIDE_REF_LEVEL "aac_drc_reference_level"
diff --git a/media/libstagefright/codecs/aacenc/AACEncoder.cpp b/media/libstagefright/codecs/aacenc/AACEncoder.cpp
index 9e596ff..5656139 100644
--- a/media/libstagefright/codecs/aacenc/AACEncoder.cpp
+++ b/media/libstagefright/codecs/aacenc/AACEncoder.cpp
@@ -296,7 +296,7 @@
memset(&inputData, 0, sizeof(inputData));
inputData.Buffer = (unsigned char*) mInputFrame;
inputData.Length = nSamples * sizeof(int16_t);
- CHECK(VO_ERR_NONE == mApiHandle->SetInputData(mEncoderHandle,&inputData));
+ CHECK((VO_U32)VO_ERR_NONE == mApiHandle->SetInputData(mEncoderHandle,&inputData));
VO_CODECBUFFER outputData;
memset(&outputData, 0, sizeof(outputData));
diff --git a/media/libstagefright/codecs/aacenc/Android.bp b/media/libstagefright/codecs/aacenc/Android.bp
new file mode 100644
index 0000000..0297630
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/Android.bp
@@ -0,0 +1,172 @@
+cc_library_static {
+ name: "libstagefright_aacenc",
+
+ srcs: [
+ "basic_op/basicop2.c",
+ "basic_op/oper_32b.c",
+
+ "AACEncoder.cpp",
+ "src/aac_rom.c",
+ "src/aacenc.c",
+ "src/aacenc_core.c",
+ "src/adj_thr.c",
+ "src/band_nrg.c",
+ "src/bit_cnt.c",
+ "src/bitbuffer.c",
+ "src/bitenc.c",
+ "src/block_switch.c",
+ "src/channel_map.c",
+ "src/dyn_bits.c",
+ "src/grp_data.c",
+ "src/interface.c",
+ "src/line_pe.c",
+ "src/ms_stereo.c",
+ "src/pre_echo_control.c",
+ "src/psy_configuration.c",
+ "src/psy_main.c",
+ "src/qc_main.c",
+ "src/quantize.c",
+ "src/sf_estim.c",
+ "src/spreading.c",
+ "src/stat_bits.c",
+ "src/tns.c",
+ "src/transform.c",
+ "src/memalign.c",
+ ],
+
+ arch: {
+ arm: {
+ srcs: [
+ "src/asm/ARMV5E/AutoCorrelation_v5.s",
+ "src/asm/ARMV5E/band_nrg_v5.s",
+ "src/asm/ARMV5E/CalcWindowEnergy_v5.s",
+ "src/asm/ARMV5E/PrePostMDCT_v5.s",
+ "src/asm/ARMV5E/R4R8First_v5.s",
+ "src/asm/ARMV5E/Radix4FFT_v5.s",
+ ],
+
+ cflags: [
+ "-DARMV5E",
+ "-DARM_INASM",
+ "-DARMV5_INASM",
+ ],
+
+ local_include_dirs: ["src/asm/ARMV5E"],
+
+ instruction_set: "arm",
+
+ armv7_a_neon: {
+ exclude_srcs: [
+ "src/asm/ARMV5E/PrePostMDCT_v5.s",
+ "src/asm/ARMV5E/R4R8First_v5.s",
+ "src/asm/ARMV5E/Radix4FFT_v5.s",
+ ],
+ srcs: [
+ "src/asm/ARMV7/PrePostMDCT_v7.s",
+ "src/asm/ARMV7/R4R8First_v7.s",
+ "src/asm/ARMV7/Radix4FFT_v7.s",
+ ],
+
+ cflags: [
+ "-DARMV7Neon",
+ "-DARMV6_INASM",
+ ],
+
+ local_include_dirs: ["src/asm/ARMV7"],
+ },
+ },
+ },
+
+ // libstagefright links this static library, so it probably isn't appropriate to
+ // link libstagefright. However, this library includes libstagefright headers,
+ // and needs libbinder to be able to do so correctly.
+ shared_libs: [
+ "libbinder",
+ "libstagefright_enc_common",
+ ],
+
+ include_dirs: [
+ "frameworks/av/include",
+ "frameworks/av/media/libstagefright/include",
+ ],
+
+ local_include_dirs: [
+ "src",
+ "inc",
+ "basic_op",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+}
+
+//###############################################################################
+
+cc_library_shared {
+ name: "libstagefright_soft_aacenc",
+
+ srcs: ["SoftAACEncoder2.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ static_libs: ["libFraunhoferAAC"],
+
+ shared_libs: [
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+}
+
+cc_library_shared {
+ name: "libstagefright_soft_aacenc_visualon",
+
+ srcs: ["SoftAACEncoder.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: [
+ "-DOSCL_IMPORT_REF=",
+ "-Werror",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ static_libs: ["libstagefright_aacenc"],
+
+ shared_libs: [
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ "libstagefright_enc_common",
+ ],
+}
diff --git a/media/libstagefright/codecs/aacenc/Android.mk b/media/libstagefright/codecs/aacenc/Android.mk
deleted file mode 100644
index 266f01b..0000000
--- a/media/libstagefright/codecs/aacenc/Android.mk
+++ /dev/null
@@ -1,147 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-AAC_LIBRARY = fraunhofer
-
-LOCAL_SRC_FILES := basic_op/basicop2.c basic_op/oper_32b.c
-
-LOCAL_SRC_FILES += \
- AACEncoder.cpp \
- src/aac_rom.c \
- src/aacenc.c \
- src/aacenc_core.c \
- src/adj_thr.c \
- src/band_nrg.c \
- src/bit_cnt.c \
- src/bitbuffer.c \
- src/bitenc.c \
- src/block_switch.c \
- src/channel_map.c \
- src/dyn_bits.c \
- src/grp_data.c \
- src/interface.c \
- src/line_pe.c \
- src/ms_stereo.c \
- src/pre_echo_control.c \
- src/psy_configuration.c \
- src/psy_main.c \
- src/qc_main.c \
- src/quantize.c \
- src/sf_estim.c \
- src/spreading.c \
- src/stat_bits.c \
- src/tns.c \
- src/transform.c \
- src/memalign.c
-
-ifneq ($(ARCH_ARM_HAVE_NEON),true)
- LOCAL_SRC_FILES_arm := \
- src/asm/ARMV5E/AutoCorrelation_v5.s \
- src/asm/ARMV5E/band_nrg_v5.s \
- src/asm/ARMV5E/CalcWindowEnergy_v5.s \
- src/asm/ARMV5E/PrePostMDCT_v5.s \
- src/asm/ARMV5E/R4R8First_v5.s \
- src/asm/ARMV5E/Radix4FFT_v5.s
-
- LOCAL_CFLAGS_arm := -DARMV5E -DARM_INASM -DARMV5_INASM
- LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/src/asm/ARMV5E
-else
- LOCAL_SRC_FILES_arm := \
- src/asm/ARMV5E/AutoCorrelation_v5.s \
- src/asm/ARMV5E/band_nrg_v5.s \
- src/asm/ARMV5E/CalcWindowEnergy_v5.s \
- src/asm/ARMV7/PrePostMDCT_v7.s \
- src/asm/ARMV7/R4R8First_v7.s \
- src/asm/ARMV7/Radix4FFT_v7.s
- LOCAL_CFLAGS_arm := -DARMV5E -DARMV7Neon -DARM_INASM -DARMV5_INASM -DARMV6_INASM
- LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/src/asm/ARMV5E
- LOCAL_C_INCLUDES_arm += $(LOCAL_PATH)/src/asm/ARMV7
-endif
-
-LOCAL_MODULE := libstagefright_aacenc
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_STATIC_LIBRARIES :=
-
-LOCAL_SHARED_LIBRARIES :=
-
-LOCAL_C_INCLUDES := \
- frameworks/av/include \
- frameworks/av/media/libstagefright/include \
- frameworks/av/media/libstagefright/codecs/common/include \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/inc \
- $(LOCAL_PATH)/basic_op
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-ifeq ($(AAC_LIBRARY), fraunhofer)
-
- include $(CLEAR_VARS)
-
- LOCAL_SRC_FILES := \
- SoftAACEncoder2.cpp
-
- LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
- external/aac/libAACenc/include \
- external/aac/libFDK/include \
- external/aac/libMpegTPEnc/include \
- external/aac/libSBRenc/include \
- external/aac/libSYS/include
-
- LOCAL_CFLAGS :=
-
- LOCAL_CFLAGS += -Werror
- LOCAL_CLANG := true
- LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
- LOCAL_STATIC_LIBRARIES := libFraunhoferAAC
-
- LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils liblog
-
- LOCAL_MODULE := libstagefright_soft_aacenc
- LOCAL_MODULE_TAGS := optional
-
- include $(BUILD_SHARED_LIBRARY)
-
-else # visualon
-
- LOCAL_SRC_FILES := \
- SoftAACEncoder.cpp
-
- LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/av/media/libstagefright/codecs/common/include \
- frameworks/native/include/media/openmax
-
- LOCAL_CFLAGS := -DOSCL_IMPORT_REF=
-
- LOCAL_CFLAGS += -Werror
- LOCAL_CLANG := true
- LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
- LOCAL_STATIC_LIBRARIES := \
- libstagefright_aacenc
-
- LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils liblog \
- libstagefright_enc_common
-
- LOCAL_MODULE := libstagefright_soft_aacenc
- LOCAL_MODULE_TAGS := optional
-
- include $(BUILD_SHARED_LIBRARY)
-
-endif # $(AAC_LIBRARY)
diff --git a/media/libstagefright/codecs/aacenc/SampleCode/Android.bp b/media/libstagefright/codecs/aacenc/SampleCode/Android.bp
new file mode 100644
index 0000000..c6ba4f3
--- /dev/null
+++ b/media/libstagefright/codecs/aacenc/SampleCode/Android.bp
@@ -0,0 +1,18 @@
+cc_binary {
+ name: "AACEncTest",
+
+ srcs: ["AAC_E_SAMPLES.c"],
+
+ arch: {
+ arm: {
+ instruction_set: "arm",
+ },
+ },
+
+ shared_libs: [
+ "libstagefright",
+ "libdl",
+ ],
+
+ static_libs: ["libstagefright_enc_common"],
+}
diff --git a/media/libstagefright/codecs/aacenc/SampleCode/Android.mk b/media/libstagefright/codecs/aacenc/SampleCode/Android.mk
deleted file mode 100644
index d06dcf6..0000000
--- a/media/libstagefright/codecs/aacenc/SampleCode/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- AAC_E_SAMPLES.c \
- ../../common/cmnMemory.c
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := AACEncTest
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright \
- libdl
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/ \
- $(LOCAL_PATH)/../../common \
- $(LOCAL_PATH)/../../common/include \
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/codecs/aacenc/SoftAACEncoder.cpp b/media/libstagefright/codecs/aacenc/SoftAACEncoder.cpp
index 96bbb85..e16ea33 100644
--- a/media/libstagefright/codecs/aacenc/SoftAACEncoder.cpp
+++ b/media/libstagefright/codecs/aacenc/SoftAACEncoder.cpp
@@ -65,7 +65,7 @@
onReset();
if (mEncoderHandle) {
- CHECK_EQ(VO_ERR_NONE, mApiHandle->Uninit(mEncoderHandle));
+ CHECK_EQ((VO_U32)VO_ERR_NONE, mApiHandle->Uninit(mEncoderHandle));
mEncoderHandle = NULL;
}
@@ -337,7 +337,7 @@
// We call this whenever sample rate, number of channels or bitrate change
// in reponse to setParameter calls.
- ALOGV("setAudioParams: %lu Hz, %lu channels, %lu bps",
+ ALOGV("setAudioParams: %u Hz, %u channels, %u bps",
mSampleRate, mNumChannels, mBitRate);
status_t err = setAudioSpecificConfigData();
@@ -387,12 +387,12 @@
int32_t index;
status_t err = getSampleRateTableIndex(mSampleRate, index);
if (err != OK) {
- ALOGE("Unsupported sample rate (%lu Hz)", mSampleRate);
+ ALOGE("Unsupported sample rate (%u Hz)", mSampleRate);
return err;
}
if (mNumChannels > 2 || mNumChannels <= 0) {
- ALOGE("Unsupported number of channels(%lu)", mNumChannels);
+ ALOGE("Unsupported number of channels(%u)", mNumChannels);
return UNKNOWN_ERROR;
}
@@ -403,7 +403,7 @@
return OK;
}
-void SoftAACEncoder::onQueueFilled(OMX_U32 portIndex) {
+void SoftAACEncoder::onQueueFilled(OMX_U32 /*portIndex*/) {
if (mSignalledError) {
return;
}
@@ -524,7 +524,7 @@
memset(&inputData, 0, sizeof(inputData));
inputData.Buffer = (unsigned char *)mInputFrame;
inputData.Length = numBytesPerInputFrame;
- CHECK(VO_ERR_NONE ==
+ CHECK((VO_U32)VO_ERR_NONE ==
mApiHandle->SetInputData(mEncoderHandle, &inputData));
VO_CODECBUFFER outputData;
diff --git a/media/libstagefright/codecs/aacenc/basic_op/oper_32b.c b/media/libstagefright/codecs/aacenc/basic_op/oper_32b.c
index 4fd16a1..78f032b 100644
--- a/media/libstagefright/codecs/aacenc/basic_op/oper_32b.c
+++ b/media/libstagefright/codecs/aacenc/basic_op/oper_32b.c
@@ -234,10 +234,10 @@
}
#define step(shift) \
- if ((0x40000000l >> shift) + root <= value) \
+ if ((0x40000000l >> (shift)) + root <= value) \
{ \
- value -= (0x40000000l >> shift) + root; \
- root = (root >> 1) | (0x40000000l >> shift); \
+ value -= (0x40000000l >> (shift)) + root; \
+ root = (root >> 1) | (0x40000000l >> (shift)); \
} else { \
root = root >> 1; \
}
diff --git a/media/libstagefright/codecs/aacenc/basic_op/typedefs.h b/media/libstagefright/codecs/aacenc/basic_op/typedefs.h
index 6059237..80d350d 100644
--- a/media/libstagefright/codecs/aacenc/basic_op/typedefs.h
+++ b/media/libstagefright/codecs/aacenc/basic_op/typedefs.h
@@ -89,11 +89,11 @@
#endif
#ifndef min
-#define min(a,b) ( a < b ? a : b)
+#define min(a,b) ( (a) < (b) ? (a) : (b))
#endif
#ifndef max
-#define max(a,b) ( a > b ? a : b)
+#define max(a,b) ( (a) > (b) ? (a) : (b))
#endif
#ifdef ARM_INASM
diff --git a/media/libstagefright/codecs/aacenc/inc/psy_const.h b/media/libstagefright/codecs/aacenc/inc/psy_const.h
index 19fb9b2..0b9f8c3 100644
--- a/media/libstagefright/codecs/aacenc/inc/psy_const.h
+++ b/media/libstagefright/codecs/aacenc/inc/psy_const.h
@@ -73,7 +73,7 @@
#define TRANSFORM_OFFSET_LONG 0
#define TRANSFORM_OFFSET_SHORT 448
-#define LOG_NORM_PCM -15
+#define LOG_NORM_PCM (-15)
#define NUM_SAMPLE_RATES 12
diff --git a/media/libstagefright/codecs/aacenc/src/bit_cnt.c b/media/libstagefright/codecs/aacenc/src/bit_cnt.c
index 9fe511c..65b035e 100644
--- a/media/libstagefright/codecs/aacenc/src/bit_cnt.c
+++ b/media/libstagefright/codecs/aacenc/src/bit_cnt.c
@@ -23,10 +23,10 @@
#include "bit_cnt.h"
#include "aac_rom.h"
-#define HI_LTAB(a) (a>>8)
-#define LO_LTAB(a) (a & 0xff)
+#define HI_LTAB(a) ((a)>>8)
+#define LO_LTAB(a) ((a) & 0xff)
-#define EXPAND(a) ((((Word32)(a&0xff00)) << 8)|(Word32)(a&0xff))
+#define EXPAND(a) ((((Word32)((a)&0xff00)) << 8)|(Word32)((a)&0xff))
/*****************************************************************************
diff --git a/media/libstagefright/codecs/aacenc/src/dyn_bits.c b/media/libstagefright/codecs/aacenc/src/dyn_bits.c
index 4d763d0..e75b48f 100644
--- a/media/libstagefright/codecs/aacenc/src/dyn_bits.c
+++ b/media/libstagefright/codecs/aacenc/src/dyn_bits.c
@@ -20,6 +20,10 @@
*******************************************************************************/
+#define LOG_TAG "NoiselessCoder"
+
+#include "log/log.h"
+
#include "aac_rom.h"
#include "dyn_bits.h"
#include "bit_cnt.h"
@@ -296,6 +300,9 @@
case SHORT_WINDOW:
sideInfoTab = sideInfoTabShort;
break;
+ default:
+ ALOGE("invalid blockType: %d", blockType);
+ return;
}
diff --git a/media/libstagefright/codecs/aacenc/src/grp_data.c b/media/libstagefright/codecs/aacenc/src/grp_data.c
index 7861e1c..edfb95b 100644
--- a/media/libstagefright/codecs/aacenc/src/grp_data.c
+++ b/media/libstagefright/codecs/aacenc/src/grp_data.c
@@ -88,7 +88,6 @@
offset += groupLen[grp] * FRAME_LEN_SHORT;
}
groupedSfbOffset[i] = FRAME_LEN_LONG;
- i += 1;
/* calculate minSnr */
i = 0;
diff --git a/media/libstagefright/codecs/aacenc/src/ms_stereo.c b/media/libstagefright/codecs/aacenc/src/ms_stereo.c
index 1e4b227..ca028dc 100644
--- a/media/libstagefright/codecs/aacenc/src/ms_stereo.c
+++ b/media/libstagefright/codecs/aacenc/src/ms_stereo.c
@@ -94,8 +94,6 @@
pnms = fixmul(nrgL, nrgR);
- temp = (pnlr + 1) / ((pnms >> 8) + 1);
-
temp = pnms - pnlr;
if( temp > 0 ){
diff --git a/media/libstagefright/codecs/aacenc/src/transform.c b/media/libstagefright/codecs/aacenc/src/transform.c
index 0080810..5de2b96 100644
--- a/media/libstagefright/codecs/aacenc/src/transform.c
+++ b/media/libstagefright/codecs/aacenc/src/transform.c
@@ -30,8 +30,8 @@
#define SQRT1_2 0x5a82799a /* sqrt(1/2) in Q31 */
#define swap2(p0,p1) \
t = p0; t1 = *(&(p0)+1); \
- p0 = p1; *(&(p0)+1) = *(&(p1)+1); \
- p1 = t; *(&(p1)+1) = t1
+ (p0) = p1; *(&(p0)+1) = *(&(p1)+1); \
+ (p1) = t; *(&(p1)+1) = t1
/*********************************************************************************
*
diff --git a/media/libstagefright/codecs/amrnb/Android.bp b/media/libstagefright/codecs/amrnb/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/media/libstagefright/codecs/amrnb/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/media/libstagefright/codecs/amrnb/Android.mk b/media/libstagefright/codecs/amrnb/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/amrnb/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/amrnb/common/Android.bp b/media/libstagefright/codecs/amrnb/common/Android.bp
new file mode 100644
index 0000000..c5ac558
--- /dev/null
+++ b/media/libstagefright/codecs/amrnb/common/Android.bp
@@ -0,0 +1,82 @@
+cc_library_shared {
+ name: "libstagefright_amrnb_common",
+
+ srcs: [
+ "src/add.cpp",
+ "src/az_lsp.cpp",
+ "src/bitno_tab.cpp",
+ "src/bitreorder_tab.cpp",
+ "src/bits2prm.cpp",
+ "src/c2_9pf_tab.cpp",
+ "src/copy.cpp",
+ "src/div_32.cpp",
+ "src/div_s.cpp",
+ "src/extract_h.cpp",
+ "src/extract_l.cpp",
+ "src/gains_tbl.cpp",
+ "src/gc_pred.cpp",
+ "src/gmed_n.cpp",
+ "src/grid_tbl.cpp",
+ "src/gray_tbl.cpp",
+ "src/int_lpc.cpp",
+ "src/inv_sqrt.cpp",
+ "src/inv_sqrt_tbl.cpp",
+ "src/l_abs.cpp",
+ "src/l_deposit_h.cpp",
+ "src/l_deposit_l.cpp",
+ "src/l_shr_r.cpp",
+ "src/log2.cpp",
+ "src/log2_norm.cpp",
+ "src/log2_tbl.cpp",
+ "src/lsfwt.cpp",
+ "src/lsp.cpp",
+ "src/lsp_az.cpp",
+ "src/lsp_lsf.cpp",
+ "src/lsp_lsf_tbl.cpp",
+ "src/lsp_tab.cpp",
+ "src/mult_r.cpp",
+ "src/norm_l.cpp",
+ "src/norm_s.cpp",
+ "src/ph_disp_tab.cpp",
+ "src/pow2.cpp",
+ "src/pow2_tbl.cpp",
+ "src/pred_lt.cpp",
+ "src/q_plsf.cpp",
+ "src/q_plsf_3.cpp",
+ "src/q_plsf_3_tbl.cpp",
+ "src/q_plsf_5.cpp",
+ "src/q_plsf_5_tbl.cpp",
+ "src/qua_gain_tbl.cpp",
+ "src/reorder.cpp",
+ "src/residu.cpp",
+ "src/round.cpp",
+ "src/set_zero.cpp",
+ "src/shr.cpp",
+ "src/shr_r.cpp",
+ "src/sqrt_l.cpp",
+ "src/sqrt_l_tbl.cpp",
+ "src/sub.cpp",
+ "src/syn_filt.cpp",
+ "src/vad1.cpp",
+ "src/weight_a.cpp",
+ "src/window_tab.cpp",
+ ],
+
+ export_include_dirs: ["include"],
+
+ cflags: [
+ "-DOSCL_UNUSED_ARG(x)=(void)(x)",
+ "-DOSCL_IMPORT_REF=",
+ "-DOSCL_EXPORT_REF=",
+
+ "-Werror",
+ ],
+
+ //addressing b/25409744
+ //sanitize: {
+ // misc_undefined: [
+ // "signed-integer-overflow",
+ // "unsigned-integer-overflow",
+ // ],
+ //},
+}
diff --git a/media/libstagefright/codecs/amrnb/common/Android.mk b/media/libstagefright/codecs/amrnb/common/Android.mk
deleted file mode 100644
index 15220a4..0000000
--- a/media/libstagefright/codecs/amrnb/common/Android.mk
+++ /dev/null
@@ -1,77 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/add.cpp \
- src/az_lsp.cpp \
- src/bitno_tab.cpp \
- src/bitreorder_tab.cpp \
- src/bits2prm.cpp \
- src/c2_9pf_tab.cpp \
- src/copy.cpp \
- src/div_32.cpp \
- src/div_s.cpp \
- src/extract_h.cpp \
- src/extract_l.cpp \
- src/gains_tbl.cpp \
- src/gc_pred.cpp \
- src/gmed_n.cpp \
- src/grid_tbl.cpp \
- src/gray_tbl.cpp \
- src/int_lpc.cpp \
- src/inv_sqrt.cpp \
- src/inv_sqrt_tbl.cpp \
- src/l_abs.cpp \
- src/l_deposit_h.cpp \
- src/l_deposit_l.cpp \
- src/l_shr_r.cpp \
- src/log2.cpp \
- src/log2_norm.cpp \
- src/log2_tbl.cpp \
- src/lsfwt.cpp \
- src/lsp.cpp \
- src/lsp_az.cpp \
- src/lsp_lsf.cpp \
- src/lsp_lsf_tbl.cpp \
- src/lsp_tab.cpp \
- src/mult_r.cpp \
- src/norm_l.cpp \
- src/norm_s.cpp \
- src/ph_disp_tab.cpp \
- src/pow2.cpp \
- src/pow2_tbl.cpp \
- src/pred_lt.cpp \
- src/q_plsf.cpp \
- src/q_plsf_3.cpp \
- src/q_plsf_3_tbl.cpp \
- src/q_plsf_5.cpp \
- src/q_plsf_5_tbl.cpp \
- src/qua_gain_tbl.cpp \
- src/reorder.cpp \
- src/residu.cpp \
- src/round.cpp \
- src/set_zero.cpp \
- src/shr.cpp \
- src/shr_r.cpp \
- src/sqrt_l.cpp \
- src/sqrt_l_tbl.cpp \
- src/sub.cpp \
- src/syn_filt.cpp \
- src/vad1.cpp \
- src/weight_a.cpp \
- src/window_tab.cpp
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include
-
-LOCAL_CFLAGS := \
- -D"OSCL_UNUSED_ARG(x)=(void)(x)" -DOSCL_IMPORT_REF= -DOSCL_EXPORT_REF=
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-#addressing b/25409744
-#LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-LOCAL_MODULE := libstagefright_amrnb_common
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/amrnb/common/src/az_lsp.cpp b/media/libstagefright/codecs/amrnb/common/src/az_lsp.cpp
index 459c3c3..f3098f5 100644
--- a/media/libstagefright/codecs/amrnb/common/src/az_lsp.cpp
+++ b/media/libstagefright/codecs/amrnb/common/src/az_lsp.cpp
@@ -103,7 +103,7 @@
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
-#define NC M/2 /* M = LPC order, NC = M/2 */
+#define NC (M/2) /* M = LPC order, NC = M/2 */
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/amrnb/common/src/gc_pred.cpp b/media/libstagefright/codecs/amrnb/common/src/gc_pred.cpp
index 1c8a700..731dc52 100644
--- a/media/libstagefright/codecs/amrnb/common/src/gc_pred.cpp
+++ b/media/libstagefright/codecs/amrnb/common/src/gc_pred.cpp
@@ -69,8 +69,8 @@
#define MEAN_ENER_MR122 783741L /* 36/(20*log10(2)) (Q17) */
/* minimum quantized energy: -14 dB */
-#define MIN_ENERGY -14336 /* 14 Q10 */
-#define MIN_ENERGY_MR122 -2381 /* 14 / (20*log10(2)) Q10 */
+#define MIN_ENERGY (-14336) /* 14 Q10 */
+#define MIN_ENERGY_MR122 (-2381) /* 14 / (20*log10(2)) Q10 */
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/amrnb/dec/Android.bp b/media/libstagefright/codecs/amrnb/dec/Android.bp
new file mode 100644
index 0000000..996183b
--- /dev/null
+++ b/media/libstagefright/codecs/amrnb/dec/Android.bp
@@ -0,0 +1,126 @@
+cc_library_static {
+ name: "libstagefright_amrnbdec",
+
+ srcs: [
+ "src/a_refl.cpp",
+ "src/agc.cpp",
+ "src/amrdecode.cpp",
+ "src/b_cn_cod.cpp",
+ "src/bgnscd.cpp",
+ "src/c_g_aver.cpp",
+ "src/d1035pf.cpp",
+ "src/d2_11pf.cpp",
+ "src/d2_9pf.cpp",
+ "src/d3_14pf.cpp",
+ "src/d4_17pf.cpp",
+ "src/d8_31pf.cpp",
+ "src/d_gain_c.cpp",
+ "src/d_gain_p.cpp",
+ "src/d_plsf.cpp",
+ "src/d_plsf_3.cpp",
+ "src/d_plsf_5.cpp",
+ "src/dec_amr.cpp",
+ "src/dec_gain.cpp",
+ "src/dec_input_format_tab.cpp",
+ "src/dec_lag3.cpp",
+ "src/dec_lag6.cpp",
+ "src/dtx_dec.cpp",
+ "src/ec_gains.cpp",
+ "src/ex_ctrl.cpp",
+ "src/if2_to_ets.cpp",
+ "src/int_lsf.cpp",
+ "src/lsp_avg.cpp",
+ "src/ph_disp.cpp",
+ "src/post_pro.cpp",
+ "src/preemph.cpp",
+ "src/pstfilt.cpp",
+ "src/qgain475_tab.cpp",
+ "src/sp_dec.cpp",
+ "src/wmf_to_ets.cpp",
+ ],
+
+ include_dirs: ["frameworks/av/media/libstagefright/include"],
+ local_include_dirs: ["src"],
+
+ cflags: [
+ "-DOSCL_UNUSED_ARG(x)=(void)(x)",
+ "-DOSCL_IMPORT_REF=",
+
+ "-Werror",
+ ],
+
+ //sanitize: {
+ // misc_undefined: [
+ // "signed-integer-overflow",
+ // ],
+ //},
+
+ shared_libs: ["libstagefright_amrnb_common"],
+}
+
+//###############################################################################
+
+cc_library_shared {
+ name: "libstagefright_soft_amrdec",
+
+ srcs: ["SoftAMR.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/av/media/libstagefright/codecs/amrwb/src",
+ "frameworks/native/include/media/openmax",
+ ],
+ local_include_dirs: ["src"],
+
+ cflags: [
+ "-DOSCL_IMPORT_REF=",
+ "-Werror",
+ ],
+
+ //sanitize: {
+ // misc_undefined: [
+ // "signed-integer-overflow",
+ // ],
+ //},
+ //LOCAL_SANITIZE := signed-integer-overflow
+
+ static_libs: [
+ "libstagefright_amrnbdec",
+ "libstagefright_amrwbdec",
+ ],
+
+ shared_libs: [
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ "libstagefright_amrnb_common",
+ ],
+}
+
+//###############################################################################
+cc_test {
+ name: "libstagefright_amrnbdec_test",
+ gtest: false,
+
+ srcs: ["test/amrnbdec_test.cpp"],
+
+ local_include_dirs: ["src"],
+
+ static_libs: [
+ "libstagefright_amrnbdec",
+ "libsndfile",
+ ],
+
+ shared_libs: [
+ "libstagefright_amrnb_common",
+ "libaudioutils",
+ "liblog",
+ ],
+
+ //sanitize: {
+ // misc_undefined: [
+ // "signed-integer-overflow",
+ // ],
+ //},
+}
diff --git a/media/libstagefright/codecs/amrnb/dec/Android.mk b/media/libstagefright/codecs/amrnb/dec/Android.mk
deleted file mode 100644
index 7967ec3..0000000
--- a/media/libstagefright/codecs/amrnb/dec/Android.mk
+++ /dev/null
@@ -1,113 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/a_refl.cpp \
- src/agc.cpp \
- src/amrdecode.cpp \
- src/b_cn_cod.cpp \
- src/bgnscd.cpp \
- src/c_g_aver.cpp \
- src/d1035pf.cpp \
- src/d2_11pf.cpp \
- src/d2_9pf.cpp \
- src/d3_14pf.cpp \
- src/d4_17pf.cpp \
- src/d8_31pf.cpp \
- src/d_gain_c.cpp \
- src/d_gain_p.cpp \
- src/d_plsf.cpp \
- src/d_plsf_3.cpp \
- src/d_plsf_5.cpp \
- src/dec_amr.cpp \
- src/dec_gain.cpp \
- src/dec_input_format_tab.cpp \
- src/dec_lag3.cpp \
- src/dec_lag6.cpp \
- src/dtx_dec.cpp \
- src/ec_gains.cpp \
- src/ex_ctrl.cpp \
- src/if2_to_ets.cpp \
- src/int_lsf.cpp \
- src/lsp_avg.cpp \
- src/ph_disp.cpp \
- src/post_pro.cpp \
- src/preemph.cpp \
- src/pstfilt.cpp \
- src/qgain475_tab.cpp \
- src/sp_dec.cpp \
- src/wmf_to_ets.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../common/include
-
-LOCAL_CFLAGS := \
- -D"OSCL_UNUSED_ARG(x)=(void)(x)" -DOSCL_IMPORT_REF=
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-#LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE := libstagefright_amrnbdec
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftAMR.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/av/media/libstagefright/codecs/amrwb/src \
- frameworks/native/include/media/openmax \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../common/include \
-
-LOCAL_CFLAGS := -DOSCL_IMPORT_REF=
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-#LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_amrnbdec libstagefright_amrwbdec
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils liblog \
- libstagefright_amrnb_common
-
-LOCAL_MODULE := libstagefright_soft_amrdec
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-################################################################################
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
- test/amrnbdec_test.cpp
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/../common/include \
- $(call include-path-for, audio-utils)
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_amrnbdec libsndfile
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_amrnb_common libaudioutils liblog
-
-LOCAL_CLANG := true
-#LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE := libstagefright_amrnbdec_test
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/codecs/amrnb/dec/src/a_refl.cpp b/media/libstagefright/codecs/amrnb/dec/src/a_refl.cpp
index 696d2da..5a47510 100644
--- a/media/libstagefright/codecs/amrnb/dec/src/a_refl.cpp
+++ b/media/libstagefright/codecs/amrnb/dec/src/a_refl.cpp
@@ -59,6 +59,7 @@
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
+#define LOG_TAG "a_refl"
#include <log/log.h>
#include "a_refl.h"
diff --git a/media/libstagefright/codecs/amrnb/enc/Android.bp b/media/libstagefright/codecs/amrnb/enc/Android.bp
new file mode 100644
index 0000000..af0f8c2
--- /dev/null
+++ b/media/libstagefright/codecs/amrnb/enc/Android.bp
@@ -0,0 +1,135 @@
+cc_library_static {
+ name: "libstagefright_amrnbenc",
+
+ srcs: [
+ "src/amrencode.cpp",
+ "src/autocorr.cpp",
+ "src/c1035pf.cpp",
+ "src/c2_11pf.cpp",
+ "src/c2_9pf.cpp",
+ "src/c3_14pf.cpp",
+ "src/c4_17pf.cpp",
+ "src/c8_31pf.cpp",
+ "src/calc_cor.cpp",
+ "src/calc_en.cpp",
+ "src/cbsearch.cpp",
+ "src/cl_ltp.cpp",
+ "src/cod_amr.cpp",
+ "src/convolve.cpp",
+ "src/cor_h.cpp",
+ "src/cor_h_x.cpp",
+ "src/cor_h_x2.cpp",
+ "src/corrwght_tab.cpp",
+ "src/dtx_enc.cpp",
+ "src/enc_lag3.cpp",
+ "src/enc_lag6.cpp",
+ "src/enc_output_format_tab.cpp",
+ "src/ets_to_if2.cpp",
+ "src/ets_to_wmf.cpp",
+ "src/g_adapt.cpp",
+ "src/g_code.cpp",
+ "src/g_pitch.cpp",
+ "src/gain_q.cpp",
+ "src/hp_max.cpp",
+ "src/inter_36.cpp",
+ "src/inter_36_tab.cpp",
+ "src/l_comp.cpp",
+ "src/l_extract.cpp",
+ "src/l_negate.cpp",
+ "src/lag_wind.cpp",
+ "src/lag_wind_tab.cpp",
+ "src/levinson.cpp",
+ "src/lpc.cpp",
+ "src/ol_ltp.cpp",
+ "src/p_ol_wgh.cpp",
+ "src/pitch_fr.cpp",
+ "src/pitch_ol.cpp",
+ "src/pre_big.cpp",
+ "src/pre_proc.cpp",
+ "src/prm2bits.cpp",
+ "src/q_gain_c.cpp",
+ "src/q_gain_p.cpp",
+ "src/qgain475.cpp",
+ "src/qgain795.cpp",
+ "src/qua_gain.cpp",
+ "src/s10_8pf.cpp",
+ "src/set_sign.cpp",
+ "src/sid_sync.cpp",
+ "src/sp_enc.cpp",
+ "src/spreproc.cpp",
+ "src/spstproc.cpp",
+ "src/ton_stab.cpp",
+ ],
+
+ include_dirs: ["frameworks/av/media/libstagefright/include"],
+ local_include_dirs: ["src"],
+
+ cflags: [
+ "-DOSCL_UNUSED_ARG(x)=(void)(x)",
+ "-Werror",
+ ],
+
+ //addressing b/25409744
+ //sanitize: {
+ // misc_undefined: [
+ // "signed-integer-overflow",
+ // ],
+ //},
+
+ shared_libs: ["libstagefright_amrnb_common"],
+}
+
+//###############################################################################
+
+cc_library_shared {
+ name: "libstagefright_soft_amrnbenc",
+
+ srcs: ["SoftAMRNBEncoder.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+ local_include_dirs: ["src"],
+
+ cflags: ["-Werror"],
+
+ //addressing b/25409744
+ //sanitize: {
+ // misc_undefined: [
+ // "signed-integer-overflow",
+ // ],
+ //},
+
+ static_libs: ["libstagefright_amrnbenc"],
+
+ shared_libs: [
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ "libstagefright_amrnb_common",
+ ],
+}
+
+//###############################################################################
+
+cc_test {
+ name: "libstagefright_amrnbenc_test",
+ gtest: false,
+
+ srcs: ["test/amrnb_enc_test.cpp"],
+
+ local_include_dirs: ["src"],
+
+ static_libs: ["libstagefright_amrnbenc"],
+
+ shared_libs: ["libstagefright_amrnb_common"],
+
+ //addressing b/25409744
+ //sanitize: {
+ // misc_undefined: [
+ // "signed-integer-overflow",
+ // ],
+ //},
+}
diff --git a/media/libstagefright/codecs/amrnb/enc/Android.mk b/media/libstagefright/codecs/amrnb/enc/Android.mk
deleted file mode 100644
index f8a41af..0000000
--- a/media/libstagefright/codecs/amrnb/enc/Android.mk
+++ /dev/null
@@ -1,137 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/amrencode.cpp \
- src/autocorr.cpp \
- src/c1035pf.cpp \
- src/c2_11pf.cpp \
- src/c2_9pf.cpp \
- src/c3_14pf.cpp \
- src/c4_17pf.cpp \
- src/c8_31pf.cpp \
- src/calc_cor.cpp \
- src/calc_en.cpp \
- src/cbsearch.cpp \
- src/cl_ltp.cpp \
- src/cod_amr.cpp \
- src/convolve.cpp \
- src/cor_h.cpp \
- src/cor_h_x.cpp \
- src/cor_h_x2.cpp \
- src/corrwght_tab.cpp \
- src/dtx_enc.cpp \
- src/enc_lag3.cpp \
- src/enc_lag6.cpp \
- src/enc_output_format_tab.cpp \
- src/ets_to_if2.cpp \
- src/ets_to_wmf.cpp \
- src/g_adapt.cpp \
- src/g_code.cpp \
- src/g_pitch.cpp \
- src/gain_q.cpp \
- src/hp_max.cpp \
- src/inter_36.cpp \
- src/inter_36_tab.cpp \
- src/l_comp.cpp \
- src/l_extract.cpp \
- src/l_negate.cpp \
- src/lag_wind.cpp \
- src/lag_wind_tab.cpp \
- src/levinson.cpp \
- src/lpc.cpp \
- src/ol_ltp.cpp \
- src/p_ol_wgh.cpp \
- src/pitch_fr.cpp \
- src/pitch_ol.cpp \
- src/pre_big.cpp \
- src/pre_proc.cpp \
- src/prm2bits.cpp \
- src/q_gain_c.cpp \
- src/q_gain_p.cpp \
- src/qgain475.cpp \
- src/qgain795.cpp \
- src/qua_gain.cpp \
- src/s10_8pf.cpp \
- src/set_sign.cpp \
- src/sid_sync.cpp \
- src/sp_enc.cpp \
- src/spreproc.cpp \
- src/spstproc.cpp \
- src/ton_stab.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../common/include
-
-LOCAL_CFLAGS := \
- -D"OSCL_UNUSED_ARG(x)=(void)(x)"
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-#addressing b/25409744
-#LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE := libstagefright_amrnbenc
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftAMRNBEncoder.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../common/include \
- $(LOCAL_PATH)/../common
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-#addressing b/25409744
-#LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_amrnbenc
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils liblog \
- libstagefright_amrnb_common
-
-LOCAL_MODULE := libstagefright_soft_amrnbenc
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
- test/amrnb_enc_test.cpp
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/../common/include
-
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_amrnbenc
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_amrnb_common
-
-LOCAL_CLANG := true
-#addressing b/25409744
-#LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE := libstagefright_amrnbenc_test
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/codecs/amrwb/Android.bp b/media/libstagefright/codecs/amrwb/Android.bp
new file mode 100644
index 0000000..e261c04
--- /dev/null
+++ b/media/libstagefright/codecs/amrwb/Android.bp
@@ -0,0 +1,85 @@
+cc_library_static {
+ name: "libstagefright_amrwbdec",
+
+ srcs: [
+ "src/agc2_amr_wb.cpp",
+ "src/band_pass_6k_7k.cpp",
+ "src/dec_acelp_2p_in_64.cpp",
+ "src/dec_acelp_4p_in_64.cpp",
+ "src/dec_alg_codebook.cpp",
+ "src/dec_gain2_amr_wb.cpp",
+ "src/deemphasis_32.cpp",
+ "src/dtx_decoder_amr_wb.cpp",
+ "src/get_amr_wb_bits.cpp",
+ "src/highpass_400hz_at_12k8.cpp",
+ "src/highpass_50hz_at_12k8.cpp",
+ "src/homing_amr_wb_dec.cpp",
+ "src/interpolate_isp.cpp",
+ "src/isf_extrapolation.cpp",
+ "src/isp_az.cpp",
+ "src/isp_isf.cpp",
+ "src/lagconceal.cpp",
+ "src/low_pass_filt_7k.cpp",
+ "src/median5.cpp",
+ "src/mime_io.cpp",
+ "src/noise_gen_amrwb.cpp",
+ "src/normalize_amr_wb.cpp",
+ "src/oversamp_12k8_to_16k.cpp",
+ "src/phase_dispersion.cpp",
+ "src/pit_shrp.cpp",
+ "src/pred_lt4.cpp",
+ "src/preemph_amrwb_dec.cpp",
+ "src/pvamrwb_math_op.cpp",
+ "src/pvamrwbdecoder.cpp",
+ "src/q_gain2_tab.cpp",
+ "src/qisf_ns.cpp",
+ "src/qisf_ns_tab.cpp",
+ "src/qpisf_2s.cpp",
+ "src/qpisf_2s_tab.cpp",
+ "src/scale_signal.cpp",
+ "src/synthesis_amr_wb.cpp",
+ "src/voice_factor.cpp",
+ "src/wb_syn_filt.cpp",
+ "src/weight_amrwb_lpc.cpp",
+ ],
+
+ include_dirs: ["frameworks/av/media/libstagefright/include"],
+ local_include_dirs: ["src"],
+ export_include_dirs: ["include"],
+
+ cflags: [
+ "-DOSCL_UNUSED_ARG(x)=(void)(x)",
+ "-DOSCL_IMPORT_REF=",
+
+ "-Werror",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
+
+//###############################################################################
+cc_test {
+ name: "libstagefright_amrwbdec_test",
+ gtest: false,
+
+ srcs: ["test/amrwbdec_test.cpp"],
+
+ static_libs: [
+ "libstagefright_amrwbdec",
+ "libsndfile",
+ ],
+
+ local_include_dirs: ["src"],
+
+ shared_libs: ["libaudioutils"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/codecs/amrwb/Android.mk b/media/libstagefright/codecs/amrwb/Android.mk
deleted file mode 100644
index 1649c4a..0000000
--- a/media/libstagefright/codecs/amrwb/Android.mk
+++ /dev/null
@@ -1,83 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/agc2_amr_wb.cpp \
- src/band_pass_6k_7k.cpp \
- src/dec_acelp_2p_in_64.cpp \
- src/dec_acelp_4p_in_64.cpp \
- src/dec_alg_codebook.cpp \
- src/dec_gain2_amr_wb.cpp \
- src/deemphasis_32.cpp \
- src/dtx_decoder_amr_wb.cpp \
- src/get_amr_wb_bits.cpp \
- src/highpass_400hz_at_12k8.cpp \
- src/highpass_50hz_at_12k8.cpp \
- src/homing_amr_wb_dec.cpp \
- src/interpolate_isp.cpp \
- src/isf_extrapolation.cpp \
- src/isp_az.cpp \
- src/isp_isf.cpp \
- src/lagconceal.cpp \
- src/low_pass_filt_7k.cpp \
- src/median5.cpp \
- src/mime_io.cpp \
- src/noise_gen_amrwb.cpp \
- src/normalize_amr_wb.cpp \
- src/oversamp_12k8_to_16k.cpp \
- src/phase_dispersion.cpp \
- src/pit_shrp.cpp \
- src/pred_lt4.cpp \
- src/preemph_amrwb_dec.cpp \
- src/pvamrwb_math_op.cpp \
- src/pvamrwbdecoder.cpp \
- src/q_gain2_tab.cpp \
- src/qisf_ns.cpp \
- src/qisf_ns_tab.cpp \
- src/qpisf_2s.cpp \
- src/qpisf_2s_tab.cpp \
- src/scale_signal.cpp \
- src/synthesis_amr_wb.cpp \
- src/voice_factor.cpp \
- src/wb_syn_filt.cpp \
- src/weight_amrwb_lpc.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include
-
-LOCAL_CFLAGS := \
- -D"OSCL_UNUSED_ARG(x)=(void)(x)" -DOSCL_IMPORT_REF=
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE := libstagefright_amrwbdec
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
- test/amrwbdec_test.cpp
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(call include-path-for, audio-utils)
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_amrwbdec libsndfile
-
-LOCAL_SHARED_LIBRARIES := \
- libaudioutils
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE := libstagefright_amrwbdec_test
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/codecs/amrwb/src/dtx.h b/media/libstagefright/codecs/amrwb/src/dtx.h
index a81f089..cf686a0 100644
--- a/media/libstagefright/codecs/amrwb/src/dtx.h
+++ b/media/libstagefright/codecs/amrwb/src/dtx.h
@@ -77,7 +77,7 @@
#define DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
#define INV_MED_THRESH 14564
#define ISF_GAP 128 /* 50 */
-#define ONE_MINUS_ISF_GAP 16384 - ISF_GAP
+#define ONE_MINUS_ISF_GAP (16384 - ISF_GAP)
#define ISF_GAP 128
#define ISF_DITH_GAP 448
diff --git a/media/libstagefright/codecs/amrwb/src/homing_amr_wb_dec.cpp b/media/libstagefright/codecs/amrwb/src/homing_amr_wb_dec.cpp
index f032a08..dde3e43 100644
--- a/media/libstagefright/codecs/amrwb/src/homing_amr_wb_dec.cpp
+++ b/media/libstagefright/codecs/amrwb/src/homing_amr_wb_dec.cpp
@@ -105,15 +105,15 @@
#define NUM_OF_SPMODES 9
#define PRML 15
-#define PRMN_7k NBBITS_7k/PRML + 1
-#define PRMN_9k NBBITS_9k/PRML + 1
-#define PRMN_12k NBBITS_12k/PRML + 1
-#define PRMN_14k NBBITS_14k/PRML + 1
-#define PRMN_16k NBBITS_16k/PRML + 1
-#define PRMN_18k NBBITS_18k/PRML + 1
-#define PRMN_20k NBBITS_20k/PRML + 1
-#define PRMN_23k NBBITS_23k/PRML + 1
-#define PRMN_24k NBBITS_24k/PRML + 1
+#define PRMN_7k (NBBITS_7k/PRML + 1)
+#define PRMN_9k (NBBITS_9k/PRML + 1)
+#define PRMN_12k (NBBITS_12k/PRML + 1)
+#define PRMN_14k (NBBITS_14k/PRML + 1)
+#define PRMN_16k (NBBITS_16k/PRML + 1)
+#define PRMN_18k (NBBITS_18k/PRML + 1)
+#define PRMN_20k (NBBITS_20k/PRML + 1)
+#define PRMN_23k (NBBITS_23k/PRML + 1)
+#define PRMN_24k (NBBITS_24k/PRML + 1)
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/amrwb/src/pvamrwb_math_op.h b/media/libstagefright/codecs/amrwb/src/pvamrwb_math_op.h
index 8951e5c..2143c9a 100644
--- a/media/libstagefright/codecs/amrwb/src/pvamrwb_math_op.h
+++ b/media/libstagefright/codecs/amrwb/src/pvamrwb_math_op.h
@@ -119,8 +119,8 @@
#define norm_s( x) (normalize_amr_wb( x) - 16)
-#define extract_h( x) (int16)(x>>16)
-#define L_deposit_h( x) (int32)(x<<16)
+#define extract_h( x) (int16)((x)>>16)
+#define L_deposit_h( x) (int32)((x)<<16)
#ifdef __cplusplus
diff --git a/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder_basic_op.h b/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder_basic_op.h
index df239d2..88ff9bc 100644
--- a/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder_basic_op.h
+++ b/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder_basic_op.h
@@ -56,8 +56,8 @@
#define MAX_32 (int32)0x7fffffffL
#define MIN_32 (int32)0x80000000L
-#define MAX_16 (int16)+32767 /* 0x7fff */
-#define MIN_16 (int16)-32768 /* 0x8000 */
+#define MAX_16 ((int16)+32767) /* 0x7fff */
+#define MIN_16 ((int16)-32768) /* 0x8000 */
diff --git a/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder_cnst.h b/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder_cnst.h
index ecf1bf3..3981ce3 100644
--- a/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder_cnst.h
+++ b/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder_cnst.h
@@ -130,7 +130,7 @@
#define EHF_MASK (int16)0x0008 /* homing frame pattern */
-#define BIT_0 (int16)-127
+#define BIT_0 ((int16)-127)
#define BIT_1 (int16)127
#define BIT_0_ITU (int16)0x007F
#define BIT_1_ITU (int16)0x0081
diff --git a/media/libstagefright/codecs/amrwbenc/Android.bp b/media/libstagefright/codecs/amrwbenc/Android.bp
new file mode 100644
index 0000000..a3068b6
--- /dev/null
+++ b/media/libstagefright/codecs/amrwbenc/Android.bp
@@ -0,0 +1,169 @@
+cc_library_static {
+ name: "libstagefright_amrwbenc",
+
+ srcs: [
+ "src/autocorr.c",
+ "src/az_isp.c",
+ "src/bits.c",
+ "src/c2t64fx.c",
+ "src/c4t64fx.c",
+ "src/convolve.c",
+ "src/cor_h_x.c",
+ "src/decim54.c",
+ "src/deemph.c",
+ "src/dtx.c",
+ "src/g_pitch.c",
+ "src/gpclip.c",
+ "src/homing.c",
+ "src/hp400.c",
+ "src/hp50.c",
+ "src/hp6k.c",
+ "src/hp_wsp.c",
+ "src/int_lpc.c",
+ "src/isp_az.c",
+ "src/isp_isf.c",
+ "src/lag_wind.c",
+ "src/levinson.c",
+ "src/log2.c",
+ "src/lp_dec2.c",
+ "src/math_op.c",
+ "src/oper_32b.c",
+ "src/p_med_ol.c",
+ "src/pit_shrp.c",
+ "src/pitch_f4.c",
+ "src/pred_lt4.c",
+ "src/preemph.c",
+ "src/q_gain2.c",
+ "src/q_pulse.c",
+ "src/qisf_ns.c",
+ "src/qpisf_2s.c",
+ "src/random.c",
+ "src/residu.c",
+ "src/scale.c",
+ "src/stream.c",
+ "src/syn_filt.c",
+ "src/updt_tar.c",
+ "src/util.c",
+ "src/voAMRWBEnc.c",
+ "src/voicefac.c",
+ "src/wb_vad.c",
+ "src/weight_a.c",
+ "src/mem_align.c",
+ ],
+
+ arch: {
+ arm: {
+ srcs: [
+ "src/asm/ARMV5E/convolve_opt.s",
+ "src/asm/ARMV5E/cor_h_vec_opt.s",
+ "src/asm/ARMV5E/Deemph_32_opt.s",
+ "src/asm/ARMV5E/Dot_p_opt.s",
+ "src/asm/ARMV5E/Filt_6k_7k_opt.s",
+ "src/asm/ARMV5E/Norm_Corr_opt.s",
+ "src/asm/ARMV5E/pred_lt4_1_opt.s",
+ "src/asm/ARMV5E/residu_asm_opt.s",
+ "src/asm/ARMV5E/scale_sig_opt.s",
+ "src/asm/ARMV5E/Syn_filt_32_opt.s",
+ "src/asm/ARMV5E/syn_filt_opt.s",
+ ],
+
+ cflags: [
+ "-DARM",
+ "-DASM_OPT",
+ ],
+ local_include_dirs: ["src/asm/ARMV5E"],
+
+ instruction_set: "arm",
+
+ armv7_a_neon: {
+ exclude_srcs: [
+ "src/asm/ARMV5E/convolve_opt.s",
+ "src/asm/ARMV5E/cor_h_vec_opt.s",
+ "src/asm/ARMV5E/Deemph_32_opt.s",
+ "src/asm/ARMV5E/Dot_p_opt.s",
+ "src/asm/ARMV5E/Filt_6k_7k_opt.s",
+ "src/asm/ARMV5E/Norm_Corr_opt.s",
+ "src/asm/ARMV5E/pred_lt4_1_opt.s",
+ "src/asm/ARMV5E/residu_asm_opt.s",
+ "src/asm/ARMV5E/scale_sig_opt.s",
+ "src/asm/ARMV5E/Syn_filt_32_opt.s",
+ "src/asm/ARMV5E/syn_filt_opt.s",
+ ],
+
+ srcs: [
+ "src/asm/ARMV7/convolve_neon.s",
+ "src/asm/ARMV7/cor_h_vec_neon.s",
+ "src/asm/ARMV7/Deemph_32_neon.s",
+ "src/asm/ARMV7/Dot_p_neon.s",
+ "src/asm/ARMV7/Filt_6k_7k_neon.s",
+ "src/asm/ARMV7/Norm_Corr_neon.s",
+ "src/asm/ARMV7/pred_lt4_1_neon.s",
+ "src/asm/ARMV7/residu_asm_neon.s",
+ "src/asm/ARMV7/scale_sig_neon.s",
+ "src/asm/ARMV7/Syn_filt_32_neon.s",
+ "src/asm/ARMV7/syn_filt_neon.s",
+ ],
+
+ // don't actually generate neon instructions, see bug 26932980
+ cflags: [
+ "-DARMV7",
+ "-mfpu=vfpv3",
+ ],
+ local_include_dirs: [
+ "src/asm/ARMV5E",
+ "src/asm/ARMV7",
+ ],
+ },
+
+ },
+ },
+
+ include_dirs: [
+ "frameworks/av/include",
+ "frameworks/av/media/libstagefright/include",
+ ],
+
+ local_include_dirs: ["src"],
+ export_include_dirs: ["inc"],
+
+ shared_libs: [
+ "libstagefright_enc_common",
+ ],
+
+ cflags: ["-Werror"],
+}
+
+//###############################################################################
+
+cc_library_shared {
+ name: "libstagefright_soft_amrwbenc",
+
+ srcs: ["SoftAMRWBEncoder.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ static_libs: ["libstagefright_amrwbenc"],
+
+ shared_libs: [
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ "libstagefright_enc_common",
+ ],
+}
+
+//###############################################################################
+
+subdirs = ["SampleCode"]
diff --git a/media/libstagefright/codecs/amrwbenc/Android.mk b/media/libstagefright/codecs/amrwbenc/Android.mk
deleted file mode 100644
index 026006e..0000000
--- a/media/libstagefright/codecs/amrwbenc/Android.mk
+++ /dev/null
@@ -1,139 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/autocorr.c \
- src/az_isp.c \
- src/bits.c \
- src/c2t64fx.c \
- src/c4t64fx.c \
- src/convolve.c \
- src/cor_h_x.c \
- src/decim54.c \
- src/deemph.c \
- src/dtx.c \
- src/g_pitch.c \
- src/gpclip.c \
- src/homing.c \
- src/hp400.c \
- src/hp50.c \
- src/hp6k.c \
- src/hp_wsp.c \
- src/int_lpc.c \
- src/isp_az.c \
- src/isp_isf.c \
- src/lag_wind.c \
- src/levinson.c \
- src/log2.c \
- src/lp_dec2.c \
- src/math_op.c \
- src/oper_32b.c \
- src/p_med_ol.c \
- src/pit_shrp.c \
- src/pitch_f4.c \
- src/pred_lt4.c \
- src/preemph.c \
- src/q_gain2.c \
- src/q_pulse.c \
- src/qisf_ns.c \
- src/qpisf_2s.c \
- src/random.c \
- src/residu.c \
- src/scale.c \
- src/stream.c \
- src/syn_filt.c \
- src/updt_tar.c \
- src/util.c \
- src/voAMRWBEnc.c \
- src/voicefac.c \
- src/wb_vad.c \
- src/weight_a.c \
- src/mem_align.c
-
-ifneq ($(ARCH_ARM_HAVE_NEON),true)
- LOCAL_SRC_FILES_arm := \
- src/asm/ARMV5E/convolve_opt.s \
- src/asm/ARMV5E/cor_h_vec_opt.s \
- src/asm/ARMV5E/Deemph_32_opt.s \
- src/asm/ARMV5E/Dot_p_opt.s \
- src/asm/ARMV5E/Filt_6k_7k_opt.s \
- src/asm/ARMV5E/Norm_Corr_opt.s \
- src/asm/ARMV5E/pred_lt4_1_opt.s \
- src/asm/ARMV5E/residu_asm_opt.s \
- src/asm/ARMV5E/scale_sig_opt.s \
- src/asm/ARMV5E/Syn_filt_32_opt.s \
- src/asm/ARMV5E/syn_filt_opt.s
-
- LOCAL_CFLAGS_arm := -DARM -DASM_OPT
- LOCAL_C_INCLUDES_arm = $(LOCAL_PATH)/src/asm/ARMV5E
-else
- LOCAL_SRC_FILES_arm := \
- src/asm/ARMV7/convolve_neon.s \
- src/asm/ARMV7/cor_h_vec_neon.s \
- src/asm/ARMV7/Deemph_32_neon.s \
- src/asm/ARMV7/Dot_p_neon.s \
- src/asm/ARMV7/Filt_6k_7k_neon.s \
- src/asm/ARMV7/Norm_Corr_neon.s \
- src/asm/ARMV7/pred_lt4_1_neon.s \
- src/asm/ARMV7/residu_asm_neon.s \
- src/asm/ARMV7/scale_sig_neon.s \
- src/asm/ARMV7/Syn_filt_32_neon.s \
- src/asm/ARMV7/syn_filt_neon.s
-
- # don't actually generate neon instructions, see bug 26932980
- LOCAL_CFLAGS_arm := -DARM -DARMV7 -DASM_OPT -mfpu=vfpv3
- LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/src/asm/ARMV5E
- LOCAL_C_INCLUDES_arm += $(LOCAL_PATH)/src/asm/ARMV7
-endif
-
-LOCAL_MODULE := libstagefright_amrwbenc
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_STATIC_LIBRARIES :=
-
-LOCAL_SHARED_LIBRARIES :=
-
-LOCAL_C_INCLUDES := \
- frameworks/av/include \
- frameworks/av/media/libstagefright/include \
- frameworks/av/media/libstagefright/codecs/common/include \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/inc
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-#LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftAMRWBEncoder.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/av/media/libstagefright/codecs/common/include \
- frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_amrwbenc
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils liblog \
- libstagefright_enc_common
-
-LOCAL_MODULE := libstagefright_soft_amrwbenc
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-################################################################################
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/amrwbenc/SampleCode/AMRWB_E_SAMPLE.c b/media/libstagefright/codecs/amrwbenc/SampleCode/AMRWB_E_SAMPLE.c
index 0cb0097..7c094f3 100644
--- a/media/libstagefright/codecs/amrwbenc/SampleCode/AMRWB_E_SAMPLE.c
+++ b/media/libstagefright/codecs/amrwbenc/SampleCode/AMRWB_E_SAMPLE.c
@@ -90,7 +90,7 @@
VO_AUDIO_CODECAPI AudioAPI;
VO_MEM_OPERATOR moper;
VO_CODEC_INIT_USERDATA useData;
- VO_HANDLE hCodec;
+ VO_HANDLE hCodec = NULL;
VO_CODECBUFFER inData;
VO_CODECBUFFER outData;
VO_AUDIO_OUTPUTINFO outFormat;
@@ -211,7 +211,7 @@
if(returnCode == 0)
{
framenum++;
- printf(" Frames processed: %hd\r", framenum);
+ printf(" Frames processed: %d\r", framenum);
if(framenum == 1)
{
fwrite(OutputBuf, 1, outData.Length + size1, fdst);
diff --git a/media/libstagefright/codecs/amrwbenc/SampleCode/Android.bp b/media/libstagefright/codecs/amrwbenc/SampleCode/Android.bp
new file mode 100644
index 0000000..9091296
--- /dev/null
+++ b/media/libstagefright/codecs/amrwbenc/SampleCode/Android.bp
@@ -0,0 +1,21 @@
+cc_test {
+ name: "AMRWBEncTest",
+ gtest: false,
+
+ srcs: ["AMRWB_E_SAMPLE.c"],
+
+ arch: {
+ arm: {
+ instruction_set: "arm",
+ },
+ },
+
+ shared_libs: [
+ "libdl",
+ ],
+
+ static_libs: [
+ "libstagefright_amrwbenc",
+ "libstagefright_enc_common",
+ ],
+}
diff --git a/media/libstagefright/codecs/amrwbenc/SampleCode/Android.mk b/media/libstagefright/codecs/amrwbenc/SampleCode/Android.mk
deleted file mode 100644
index 65d69a2..0000000
--- a/media/libstagefright/codecs/amrwbenc/SampleCode/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- AMRWB_E_SAMPLE.c \
- ../../common/cmnMemory.c
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := AMRWBEncTest
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_CFLAGS :=
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright \
- libdl
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_amrwbenc
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/ \
- $(LOCAL_PATH)/../../common \
- $(LOCAL_PATH)/../../common/include
-
-include $(BUILD_EXECUTABLE)
-
-
-
diff --git a/media/libstagefright/codecs/amrwbenc/SoftAMRWBEncoder.cpp b/media/libstagefright/codecs/amrwbenc/SoftAMRWBEncoder.cpp
index 9d50c4e..c7973d6 100644
--- a/media/libstagefright/codecs/amrwbenc/SoftAMRWBEncoder.cpp
+++ b/media/libstagefright/codecs/amrwbenc/SoftAMRWBEncoder.cpp
@@ -59,7 +59,7 @@
SoftAMRWBEncoder::~SoftAMRWBEncoder() {
if (mEncoderHandle != NULL) {
- CHECK_EQ(VO_ERR_NONE, mApiHandle->Uninit(mEncoderHandle));
+ CHECK_EQ((VO_U32)VO_ERR_NONE, mApiHandle->Uninit(mEncoderHandle));
mEncoderHandle = NULL;
}
@@ -435,7 +435,7 @@
inputData.Buffer = (unsigned char *) mInputFrame;
inputData.Length = mInputSize;
- CHECK_EQ(VO_ERR_NONE,
+ CHECK_EQ((VO_U32)VO_ERR_NONE,
mApiHandle->SetInputData(mEncoderHandle, &inputData));
VO_CODECBUFFER outputData;
diff --git a/media/libstagefright/codecs/amrwbenc/inc/basic_op.h b/media/libstagefright/codecs/amrwbenc/inc/basic_op.h
index 8165f69..80ad7f1 100644
--- a/media/libstagefright/codecs/amrwbenc/inc/basic_op.h
+++ b/media/libstagefright/codecs/amrwbenc/inc/basic_op.h
@@ -25,8 +25,8 @@
#define MAX_32 (Word32)0x7fffffffL
#define MIN_32 (Word32)0x80000000L
-#define MAX_16 (Word16)+32767 /* 0x7fff */
-#define MIN_16 (Word16)-32768 /* 0x8000 */
+#define MAX_16 ((Word16)+32767) /* 0x7fff */
+#define MIN_16 ((Word16)-32768) /* 0x8000 */
#define static_vo static __inline
@@ -41,23 +41,23 @@
#define L_negate(L_var1) (((L_var1) == (MIN_32)) ? (MAX_32) : (-(L_var1))) /* Long negate, 2*/
-#define extract_h(a) ((Word16)(a >> 16))
-#define extract_l(x) (Word16)((x))
-#define add1(a,b) (a + b)
-#define vo_L_msu(a,b,c) ( a - (( b * c ) << 1) )
+#define extract_h(a) ((Word16)((a) >> 16))
+#define extract_l(x) (Word16)((x))
+#define add1(a,b) ((a) + (b))
+#define vo_L_msu(a,b,c) ((a) - (((b) * (c)) << 1))
#define vo_mult32(a, b) ((a) * (b))
-#define vo_mult(a,b) (( a * b ) >> 15 )
-#define vo_L_mult(a,b) (((a) * (b)) << 1)
-#define vo_shr_r(var1, var2) ((var1+((Word16)(1L<<(var2-1))))>>var2)
-#define vo_sub(a,b) (a - b)
+#define vo_mult(a,b) (((a) * (b)) >> 15)
+#define vo_L_mult(a,b) (((a) * (b)) << 1)
+#define vo_shr_r(var1, var2) (((var1)+((Word16)(1L<<((var2)-1))))>>(var2))
+#define vo_sub(a,b) ((a) - (b))
#define vo_L_deposit_h(a) ((Word32)((a) << 16))
-#define vo_round(a) ((((a) >> 15) + 1) >> 1)
+#define vo_round(a) ((((a) >> 15) + 1) >> 1)
#define vo_extract_l(a) ((Word16)(a))
-#define vo_L_add(a,b) (a + b)
-#define vo_L_sub(a,b) (a - b)
-#define vo_mult_r(a,b) (((( a * b ) >> 14) + 1 ) >> 1 )
-#define vo_negate(a) (-a)
-#define vo_L_shr_r(L_var1, var2) ((L_var1+((Word32)(1L<<(var2-1))))>>var2)
+#define vo_L_add(a,b) ((a) + (b))
+#define vo_L_sub(a,b) ((a) - (b))
+#define vo_mult_r(a,b) (((( (a) * (b) ) >> 14) + 1 ) >> 1 )
+#define vo_negate(a) (-(a))
+#define vo_L_shr_r(L_var1, var2) (((L_var1)+((Word32)(1L<<((var2)-1))))>>(var2))
/*___________________________________________________________________________
@@ -765,7 +765,7 @@
break;
}
}
- L_var1 <<=1 ;
+ L_var1 *= 2 ;
L_var_out = L_var1;
}
return (L_var_out);
diff --git a/media/libstagefright/codecs/amrwbenc/inc/bits.h b/media/libstagefright/codecs/amrwbenc/inc/bits.h
index ff9c0c1..57e71f7 100644
--- a/media/libstagefright/codecs/amrwbenc/inc/bits.h
+++ b/media/libstagefright/codecs/amrwbenc/inc/bits.h
@@ -42,7 +42,7 @@
#define NBBITS_SID 35
#define NB_BITS_MAX NBBITS_24k
-#define BIT_0 (Word16)-127
+#define BIT_0 ((Word16)-127)
#define BIT_1 (Word16)127
#define BIT_0_ITU (Word16)0x007F
#define BIT_1_ITU (Word16)0x0081
diff --git a/media/libstagefright/codecs/amrwbenc/inc/dtx.h b/media/libstagefright/codecs/amrwbenc/inc/dtx.h
index 82a9bf4..7d7ebd8 100644
--- a/media/libstagefright/codecs/amrwbenc/inc/dtx.h
+++ b/media/libstagefright/codecs/amrwbenc/inc/dtx.h
@@ -31,7 +31,7 @@
#define DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
#define INV_MED_THRESH 14564
#define ISF_GAP 128 /* 50 */
-#define ONE_MINUS_ISF_GAP 16384 - ISF_GAP
+#define ONE_MINUS_ISF_GAP (16384 - ISF_GAP)
#define ISF_GAP 128
#define ISF_DITH_GAP 448
#define ISF_FACTOR_LOW 256
diff --git a/media/libstagefright/codecs/amrwbenc/inc/homing.tab b/media/libstagefright/codecs/amrwbenc/inc/homing.tab
index e399fb8..6408d3a 100644
--- a/media/libstagefright/codecs/amrwbenc/inc/homing.tab
+++ b/media/libstagefright/codecs/amrwbenc/inc/homing.tab
@@ -21,15 +21,15 @@
#define NUM_OF_SPMODES 9
#define PRML 15
-#define PRMN_7k NBBITS_7k/PRML + 1
-#define PRMN_9k NBBITS_9k/PRML + 1
-#define PRMN_12k NBBITS_12k/PRML + 1
-#define PRMN_14k NBBITS_14k/PRML + 1
-#define PRMN_16k NBBITS_16k/PRML + 1
-#define PRMN_18k NBBITS_18k/PRML + 1
-#define PRMN_20k NBBITS_20k/PRML + 1
-#define PRMN_23k NBBITS_23k/PRML + 1
-#define PRMN_24k NBBITS_24k/PRML + 1
+#define PRMN_7k (NBBITS_7k/PRML + 1)
+#define PRMN_9k (NBBITS_9k/PRML + 1)
+#define PRMN_12k (NBBITS_12k/PRML + 1)
+#define PRMN_14k (NBBITS_14k/PRML + 1)
+#define PRMN_16k (NBBITS_16k/PRML + 1)
+#define PRMN_18k (NBBITS_18k/PRML + 1)
+#define PRMN_20k (NBBITS_20k/PRML + 1)
+#define PRMN_23k (NBBITS_23k/PRML + 1)
+#define PRMN_24k (NBBITS_24k/PRML + 1)
static const Word16 dfh_M7k[PRMN_7k] =
{
diff --git a/media/libstagefright/codecs/amrwbenc/inc/stream.h b/media/libstagefright/codecs/amrwbenc/inc/stream.h
index ec1a700..fbaae9e 100644
--- a/media/libstagefright/codecs/amrwbenc/inc/stream.h
+++ b/media/libstagefright/codecs/amrwbenc/inc/stream.h
@@ -26,7 +26,7 @@
#define __STREAM_H__
#include "voMem.h"
-#define Frame_Maxsize 1024 * 2 //Work Buffer 10K
+#define Frame_Maxsize (1024 * 2) //Work Buffer 10K
#define Frame_MaxByte 640 //AMR_WB Encoder one frame 320 samples = 640 Bytes
#define MIN(a,b) ((a) < (b)? (a) : (b))
diff --git a/media/libstagefright/codecs/avc/Android.mk b/media/libstagefright/codecs/avc/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/avc/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/avc/common/Android.mk b/media/libstagefright/codecs/avc/common/Android.mk
deleted file mode 100644
index ed0f8ca..0000000
--- a/media/libstagefright/codecs/avc/common/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/deblock.cpp \
- src/dpb.cpp \
- src/fmo.cpp \
- src/mb_access.cpp \
- src/reflist.cpp
-
-LOCAL_MODULE := libstagefright_avc_common
-
-LOCAL_CFLAGS := -DOSCL_EXPORT_REF= -DOSCL_IMPORT_REF=
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/avc/common/MODULE_LICENSE_APACHE2 b/media/libstagefright/codecs/avc/common/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/media/libstagefright/codecs/avc/common/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/media/libstagefright/codecs/avc/common/NOTICE b/media/libstagefright/codecs/avc/common/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/media/libstagefright/codecs/avc/common/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, 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.
-
- 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.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/media/libstagefright/codecs/avc/common/include/avc_types.h b/media/libstagefright/codecs/avc/common/include/avc_types.h
deleted file mode 100644
index ec8b6de..0000000
--- a/media/libstagefright/codecs/avc/common/include/avc_types.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-#ifndef AVC_TYPES_H_
-
-#define AVC_TYPES_H_
-
-#include <stdint.h>
-
-typedef uint8_t uint8;
-typedef uint16_t uint16;
-typedef int16_t int16;
-typedef uint32_t uint32;
-typedef int32_t int32;
-typedef unsigned int uint;
-
-#endif // AVC_TYPES_H_
diff --git a/media/libstagefright/codecs/avc/common/include/avcapi_common.h b/media/libstagefright/codecs/avc/common/include/avcapi_common.h
deleted file mode 100644
index abffe6e..0000000
--- a/media/libstagefright/codecs/avc/common/include/avcapi_common.h
+++ /dev/null
@@ -1,274 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-/**
-This file contains common type definitions and enumerations used by AVC encoder
-and decoder libraries which are exposed to the users.
-@publishedAll
-*/
-
-#ifndef AVCAPI_COMMON_H_INCLUDED
-#define AVCAPI_COMMON_H_INCLUDED
-
-#include "avc_types.h"
-
-#define PV_MEMORY_POOL
-/**
-This is common return status.
-@publishedAll
-*/
-typedef enum
-{
- AVC_NO_BUFFER = -2,
- AVC_MEMORY_FAIL = -1,
- AVC_FAIL = 0,
- AVC_SUCCESS = 1,
- AVC_PICTURE_OUTPUT_READY = 2
-} AVCStatus;
-
-/**
-This enumeration is for profiles. The value follows the profile_idc in sequence
-parameter set rbsp. See Annex A.
-@publishedAll
-*/
-typedef enum
-{
- AVC_BASELINE = 66,
- AVC_MAIN = 77,
- AVC_EXTENDED = 88,
- AVC_HIGH = 100,
- AVC_HIGH10 = 110,
- AVC_HIGH422 = 122,
- AVC_HIGH444 = 144
-} AVCProfile;
-
-/**
-This enumeration is for levels. The value follows the level_idc in sequence
-parameter set rbsp. See Annex A.
-@published All
-*/
-typedef enum
-{
- AVC_LEVEL_AUTO = 0,
- AVC_LEVEL1_B = 9,
- AVC_LEVEL1 = 10,
- AVC_LEVEL1_1 = 11,
- AVC_LEVEL1_2 = 12,
- AVC_LEVEL1_3 = 13,
- AVC_LEVEL2 = 20,
- AVC_LEVEL2_1 = 21,
- AVC_LEVEL2_2 = 22,
- AVC_LEVEL3 = 30,
- AVC_LEVEL3_1 = 31,
- AVC_LEVEL3_2 = 32,
- AVC_LEVEL4 = 40,
- AVC_LEVEL4_1 = 41,
- AVC_LEVEL4_2 = 42,
- AVC_LEVEL5 = 50,
- AVC_LEVEL5_1 = 51
-} AVCLevel;
-
-/**
-This enumeration follows Table 7-1 for NAL unit type codes.
-This may go to avccommon_api.h later (external common).
-@publishedAll
-*/
-typedef enum
-{
- AVC_NALTYPE_SLICE = 1, /* non-IDR non-data partition */
- AVC_NALTYPE_DPA = 2, /* data partition A */
- AVC_NALTYPE_DPB = 3, /* data partition B */
- AVC_NALTYPE_DPC = 4, /* data partition C */
- AVC_NALTYPE_IDR = 5, /* IDR NAL */
- AVC_NALTYPE_SEI = 6, /* supplemental enhancement info */
- AVC_NALTYPE_SPS = 7, /* sequence parameter set */
- AVC_NALTYPE_PPS = 8, /* picture parameter set */
- AVC_NALTYPE_AUD = 9, /* access unit delimiter */
- AVC_NALTYPE_EOSEQ = 10, /* end of sequence */
- AVC_NALTYPE_EOSTREAM = 11, /* end of stream */
- AVC_NALTYPE_FILL = 12 /* filler data */
-} AVCNalUnitType;
-
-/**
-This enumeration specifies debug logging type.
-This may go to avccommon_api.h later (external common).
-@publishedAll
-*/
-typedef enum
-{
- AVC_LOGTYPE_ERROR = 0,
- AVC_LOGTYPE_WARNING = 1,
- AVC_LOGTYPE_INFO = 2
-} AVCLogType;
-
-/**
-This enumerate the status of certain flags.
-@publishedAll
-*/
-typedef enum
-{
- AVC_OFF = 0,
- AVC_ON = 1
-} AVCFlag;
-
-/**
-This structure contains input information.
-Note, this structure is identical to AVCDecOutput for now.
-*/
-typedef struct tagAVCFrameIO
-{
- /** A unique identification number for a particular instance of this structure.
- To remain unchanged by the application between the time when it is given to the
- library and the time when the library returns it back. */
- uint32 id;
-
- /** Array of pointers to Y,Cb,Cr content in 4:2:0 format. For AVC decoding,
- this memory is allocated by the AVC decoder library. For AVC encoding, only the
- memory for original unencoded frame is allocated by the application. Internal
- memory is also allocated by the AVC encoder library. */
- uint8 *YCbCr[3];
-
- /** In/Out: Coded width of the luma component, it has to be multiple of 16. */
- int pitch;
-
- /** In/Out: Coded height of the luma component, must be multiple of 16. */
- int height;
-
- /** In/Out: Display width, less than picth */
- int clip_width;
-
- /** In/Out: Display height, less than height */
- int clip_height;
-
- /** Input: Origin of the display area [0]=>row, [1]=>column */
- int clip_origin[2];
-
- /** Output: Frame number in de/encoding order (not necessary)*/
- uint32 coding_order;
-
- /** Output: Frame number in displaying order (this may or may not be associated with the POC at all!!!). */
- uint32 disp_order;
-
- /** In/Out: Flag for use for reference or not. */
- uint is_reference;
-
- /** In/Out: Coding timestamp in msec (not display timestamp) */
- uint32 coding_timestamp;
-
- /* there could be something else here such as format, DON (decoding order number)
- if available thru SEI, etc. */
-} AVCFrameIO;
-
-
-/** CALLBACK FUNCTION TO BE IMPLEMENTED BY APPLICATION */
-/** In AVCDecControls structure, userData is a pointer to an object with the following
- member functions.
-*/
-
-
-/** @brief Decoded picture buffers (DPB) must be allocated or re-allocated before an
- IDR frame is decoded. If PV_MEMORY_POOL is not defined, AVC lib will allocate DPB
- internally which cannot be shared with the application. In that case, this function
- will not be called.
- @param userData The same value of userData in AVCHandle object.
- @param frame_size_in_mbs The size of each frame in number of macroblocks.
- @param num_frames The number of frames in DPB.
- @return 1 for success, 0 for fail (cannot allocate DPB)
-*/
-
-typedef int (*FunctionType_DPBAlloc)(void *userData, uint frame_size_in_mbs, uint num_buffers);
-
-/** @brief AVC library calls this function is reserve a memory of one frame from the DPB.
- Once reserved, this frame shall not be deleted or over-written by the app.
- @param userData The same value of userData in AVCHandle object.
- @param indx Index of a frame in DPB (AVC library keeps track of the index).
- @param yuv The address of the yuv pointer returned to the AVC lib.
- @return 1 for success, 0 for fail (no frames available to bind).
- */
-typedef int (*FunctionType_FrameBind)(void *userData, int indx, uint8 **yuv);
-
-/** @brief AVC library calls this function once a bound frame is not needed for decoding
- operation (falls out of the sliding window, or marked unused for reference).
- @param userData The same value of userData in AVCHandle object.
- @param indx Index of frame to be unbound (AVC library keeps track of the index).
- @return none.
-*/
-typedef void (*FuctionType_FrameUnbind)(void *userData, int);
-
-/** Pointer to malloc function for general memory allocation, so that application can keep track of
- memory usage.
-\param "size" "Size of requested memory in bytes."
-\param "attribute" "Some value specifying types, priority, etc. of the memory."
-\return "The address of the allocated, zero-initialized memory"
-*/
-typedef void* (*FunctionType_Malloc)(void *userData, int32 size, int attribute);
-
-/** Function pointer to free
-\param "mem" "Pointer to the memory to be freed"
-\return "void"
-*/
-typedef void (*FunctionType_Free)(void *userData, void *mem);
-
-/** Debug logging information is returned to the application thru this function.
-\param "type" "Type of logging message, see definition of AVCLogType."
-\param "string1" "Logging message."
-\param "string2" "To be defined."
-*/
-typedef void (*FunctionType_DebugLog)(uint32 *userData, AVCLogType type, char *string1, int val1, int val2);
-
-/**
-This structure has to be allocated and maintained by the user of the library.
-This structure is used as a handle to the library object.
-*/
-typedef struct tagAVCHandle
-{
- /** A pointer to the internal data structure. Users have to make sure that this value
- is NULL at the beginning.
- */
- void *AVCObject;
-
- /** A pointer to user object which has the following member functions used for
- callback purpose. !!! */
- void *userData;
-
- /** Pointers to functions implemented by the users of AVC library */
- FunctionType_DPBAlloc CBAVC_DPBAlloc;
-
- FunctionType_FrameBind CBAVC_FrameBind;
-
- FuctionType_FrameUnbind CBAVC_FrameUnbind;
-
- FunctionType_Malloc CBAVC_Malloc;
-
- FunctionType_Free CBAVC_Free;
-
- FunctionType_DebugLog CBAVC_DebugLog;
-
- /** Flag to enable debugging */
- uint32 debugEnable;
-
-} AVCHandle;
-
-
-
-#ifdef PVDEBUGMSG_LOG
-#define DEBUG_LOG(a,b,c,d,e) CBAVC_DebugLog(a,b,c,d,e)
-#else
-#define DEBUG_LOG(a,b,c,d,e)
-#endif
-
-#endif /* _AVCAPI_COMMON_H_ */
diff --git a/media/libstagefright/codecs/avc/common/include/avcint_common.h b/media/libstagefright/codecs/avc/common/include/avcint_common.h
deleted file mode 100644
index 465e604..0000000
--- a/media/libstagefright/codecs/avc/common/include/avcint_common.h
+++ /dev/null
@@ -1,882 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-/**
-This file contains common code shared between AVC decoder and AVC encoder for
-internal use only.
-@publishedAll
-*/
-
-#ifndef AVCINT_COMMON_H_INCLUDED
-#define AVCINT_COMMON_H_INCLUDED
-
-#ifndef AVCAPI_COMMON_H_INCLUDED
-#include "avcapi_common.h"
-#endif
-
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-
-
-/**
-Mathematic functions defined in subclause 5.7.
-Can be replaced with assembly instructions for speedup.
-@publishedAll
-*/
-#define AVC_ABS(x) (((x)<0)? -(x) : (x))
-#define AVC_SIGN(x) (((x)<0)? -1 : 1)
-#define AVC_SIGN0(x) (((x)<0)? -1 : (((x)>0) ? 1 : 0))
-#define AVC_MAX(x,y) ((x)>(y)? (x):(y))
-#define AVC_MIN(x,y) ((x)<(y)? (x):(y))
-#define AVC_MEDIAN(A,B,C) ((A) > (B) ? ((A) < (C) ? (A) : (B) > (C) ? (B) : (C)): (B) < (C) ? (B) : (C) > (A) ? (C) : (A))
-#define AVC_CLIP3(a,b,x) (AVC_MAX(a,AVC_MIN(x,b))) /* clip x between a and b */
-#define AVC_CLIP(x) AVC_CLIP3(0,255,x)
-#define AVC_FLOOR(x) ((int)(x))
-#define AVC_RASTER_SCAN(x,y,n) ((x)+(y)*(n))
-#define AVC_ROUND(x) (AVC_SIGN(x)*AVC_FLOOR(AVC_ABS(x)+0.5))
-#define AVC_INVERSE_RASTER_SCAN(a,b,c,d,e) (((e)==0)? (((a)%((d)/(b)))*(b)): (((a)/((d)/(b)))*(c)))
-/* a:block address, b:block width, c:block height, d:total_width, e:x or y coordinate */
-
-#define DEFAULT_ATTR 0 /* default memory attribute */
-#define FAST_MEM_ATTR 1 /* fast memory attribute */
-
-
-/* This section is for definition of constants. */
-#define MB_SIZE 16
-#define BLOCK_SIZE 4
-#define EMULATION_PREVENTION_THREE_BYTE 0x3
-#define NUM_PIXELS_IN_MB (24*16)
-#define NUM_BLKS_IN_MB 24
-
-#define AVCNumI4PredMode 9
-#define AVCNumI16PredMode 4
-#define AVCNumIChromaMode 4
-
-/* constants used in the structures below */
-#define MAXIMUMVALUEOFcpb_cnt 32 /* used in HRDParams */
-#define MAX_NUM_REF_FRAMES_IN_PIC_ORDER_CNT_CYCLE 255 /* used in SeqParamSet */
-#define MAX_NUM_SLICE_GROUP 8 /* used in PicParamSet */
-#define MAX_REF_PIC_LIST_REORDERING 32 /* 32 is maximum according to Annex A, SliceHeader */
-#define MAX_DEC_REF_PIC_MARKING 64 /* 64 is the maximum possible given the max num ref pictures to 31. */
-#define MAX_FS (16+1) /* pre-defined size of frame store array */
-#define MAX_LEVEL_IDX 15 /* only 15 levels defined for now */
-#define MAX_REF_PIC_LIST 33 /* max size of the RefPicList0 and RefPicList1 */
-
-
-/**
-Architectural related macros.
-@publishedAll
-*/
-#ifdef USE_PRED_BLOCK
-#define MB_BASED_DEBLOCK
-#endif
-
-/**
-Picture type, PV created.
-@publishedAll
-*/
-typedef enum
-{
- AVC_FRAME = 3
-} AVCPictureType;
-
-/**
-This slice type follows Table 7-3. The bottom 5 items may not needed.
-@publishedAll
-*/
-typedef enum
-{
- AVC_P_SLICE = 0,
- AVC_B_SLICE = 1,
- AVC_I_SLICE = 2,
- AVC_SP_SLICE = 3,
- AVC_SI_SLICE = 4,
- AVC_P_ALL_SLICE = 5,
- AVC_B_ALL_SLICE = 6,
- AVC_I_ALL_SLICE = 7,
- AVC_SP_ALL_SLICE = 8,
- AVC_SI_ALL_SLICE = 9
-} AVCSliceType;
-
-/**
-Types of the macroblock and partition. PV Created.
-@publishedAll
-*/
-typedef enum
-{
- /* intra */
- AVC_I4,
- AVC_I16,
- AVC_I_PCM,
- AVC_SI4,
-
- /* inter for both P and B*/
- AVC_BDirect16,
- AVC_P16,
- AVC_P16x8,
- AVC_P8x16,
- AVC_P8,
- AVC_P8ref0,
- AVC_SKIP
-} AVCMBMode;
-
-/**
-Enumeration for sub-macroblock mode, interpreted from sub_mb_type.
-@publishedAll
-*/
-typedef enum
-{
- /* for sub-partition mode */
- AVC_BDirect8,
- AVC_8x8,
- AVC_8x4,
- AVC_4x8,
- AVC_4x4
-} AVCSubMBMode;
-
-/**
-Mode of prediction of partition or sub-partition. PV Created.
-Do not change the order!!! Used in table look-up mode prediction in
-vlc.c.
-@publishedAll
-*/
-typedef enum
-{
- AVC_Pred_L0 = 0,
- AVC_Pred_L1,
- AVC_BiPred,
- AVC_Direct
-} AVCPredMode;
-
-
-/**
-Mode of intra 4x4 prediction. Table 8-2
-@publishedAll
-*/
-typedef enum
-{
- AVC_I4_Vertical = 0,
- AVC_I4_Horizontal,
- AVC_I4_DC,
- AVC_I4_Diagonal_Down_Left,
- AVC_I4_Diagonal_Down_Right,
- AVC_I4_Vertical_Right,
- AVC_I4_Horizontal_Down,
- AVC_I4_Vertical_Left,
- AVC_I4_Horizontal_Up
-} AVCIntra4x4PredMode;
-
-/**
-Mode of intra 16x16 prediction. Table 8-3
-@publishedAll
-*/
-typedef enum
-{
- AVC_I16_Vertical = 0,
- AVC_I16_Horizontal,
- AVC_I16_DC,
- AVC_I16_Plane
-} AVCIntra16x16PredMode;
-
-
-/**
-Mode of intra chroma prediction. Table 8-4
-@publishedAll
-*/
-typedef enum
-{
- AVC_IC_DC = 0,
- AVC_IC_Horizontal,
- AVC_IC_Vertical,
- AVC_IC_Plane
-} AVCIntraChromaPredMode;
-
-/**
-Type of residual going to residual_block_cavlc function, PV created.
-@publishedAll
-*/
-typedef enum
-{
- AVC_Luma,
- AVC_Intra16DC,
- AVC_Intra16AC,
- AVC_ChromaDC,
- AVC_ChromaAC
-} AVCResidualType;
-
-
-/**
-This structure contains VUI parameters as specified in Annex E.
-Some variables may be removed from the structure if they are found to be useless to store.
-@publishedAll
-*/
-typedef struct tagHRDParams
-{
- uint cpb_cnt_minus1; /* ue(v), range 0..31 */
- uint bit_rate_scale; /* u(4) */
- uint cpb_size_scale; /* u(4) */
- uint32 bit_rate_value_minus1[MAXIMUMVALUEOFcpb_cnt];/* ue(v), range 0..2^32-2 */
- uint32 cpb_size_value_minus1[MAXIMUMVALUEOFcpb_cnt]; /* ue(v), range 0..2^32-2 */
- uint cbr_flag[MAXIMUMVALUEOFcpb_cnt]; /* u(1) */
- uint initial_cpb_removal_delay_length_minus1; /* u(5), default 23 */
- uint cpb_removal_delay_length_minus1; /* u(5), default 23 */
- uint dpb_output_delay_length_minus1; /* u(5), default 23 */
- uint time_offset_length; /* u(5), default 24 */
-} AVCHRDParams;
-
-/**
-This structure contains VUI parameters as specified in Annex E.
-Some variables may be removed from the structure if they are found to be useless to store.
-@publishedAll
-*/
-typedef struct tagVUIParam
-{
- uint aspect_ratio_info_present_flag; /* u(1) */
- uint aspect_ratio_idc; /* u(8), table E-1 */
- uint sar_width; /* u(16) */
- uint sar_height; /* u(16) */
- uint overscan_info_present_flag; /* u(1) */
- uint overscan_appropriate_flag; /* u(1) */
- uint video_signal_type_present_flag; /* u(1) */
- uint video_format; /* u(3), Table E-2, default 5, unspecified */
- uint video_full_range_flag; /* u(1) */
- uint colour_description_present_flag; /* u(1) */
- uint colour_primaries; /* u(8), Table E-3, default 2, unspecified */
- uint transfer_characteristics; /* u(8), Table E-4, default 2, unspecified */
- uint matrix_coefficients; /* u(8), Table E-5, default 2, unspecified */
- uint chroma_location_info_present_flag; /* u(1) */
- uint chroma_sample_loc_type_top_field; /* ue(v), Fig. E-1range 0..5, default 0 */
- uint chroma_sample_loc_type_bottom_field; /* ue(v) */
- uint timing_info_present_flag; /* u(1) */
- uint num_units_in_tick; /* u(32), must be > 0 */
- uint time_scale; /* u(32), must be > 0 */
- uint fixed_frame_rate_flag; /* u(1), Eq. C-13 */
- uint nal_hrd_parameters_present_flag; /* u(1) */
- AVCHRDParams nal_hrd_parameters; /* hrd_paramters */
- uint vcl_hrd_parameters_present_flag; /* u(1) */
- AVCHRDParams vcl_hrd_parameters; /* hrd_paramters */
- /* if ((nal_hrd_parameters_present_flag || (vcl_hrd_parameters_present_flag)) */
- uint low_delay_hrd_flag; /* u(1) */
- uint pic_struct_present_flag;
- uint bitstream_restriction_flag; /* u(1) */
- uint motion_vectors_over_pic_boundaries_flag; /* u(1) */
- uint max_bytes_per_pic_denom; /* ue(v), default 2 */
- uint max_bits_per_mb_denom; /* ue(v), range 0..16, default 1 */
- uint log2_max_mv_length_vertical; /* ue(v), range 0..16, default 16 */
- uint log2_max_mv_length_horizontal; /* ue(v), range 0..16, default 16 */
- uint max_dec_frame_reordering; /* ue(v) */
- uint max_dec_frame_buffering; /* ue(v) */
-} AVCVUIParams;
-
-
-/**
-This structure contains information in a sequence parameter set NAL.
-Some variables may be removed from the structure if they are found to be useless to store.
-@publishedAll
-*/
-typedef struct tagSeqParamSet
-{
- uint Valid; /* indicates the parameter set is valid */
-
- uint profile_idc; /* u(8) */
- uint constrained_set0_flag; /* u(1) */
- uint constrained_set1_flag; /* u(1) */
- uint constrained_set2_flag; /* u(1) */
- uint constrained_set3_flag; /* u(1) */
- uint level_idc; /* u(8) */
- uint seq_parameter_set_id; /* ue(v), range 0..31 */
- uint log2_max_frame_num_minus4; /* ue(v), range 0..12 */
- uint pic_order_cnt_type; /* ue(v), range 0..2 */
- /* if( pic_order_cnt_type == 0 ) */
- uint log2_max_pic_order_cnt_lsb_minus4; /* ue(v), range 0..12 */
- /* else if( pic_order_cnt_type == 1 ) */
- uint delta_pic_order_always_zero_flag; /* u(1) */
- int32 offset_for_non_ref_pic; /* se(v) */
- int32 offset_for_top_to_bottom_field; /* se(v) */
- uint num_ref_frames_in_pic_order_cnt_cycle; /* ue(v) , range 0..255 */
- /* for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ ) */
- int32 offset_for_ref_frame[MAX_NUM_REF_FRAMES_IN_PIC_ORDER_CNT_CYCLE]; /* se(v) */
- uint num_ref_frames; /* ue(v), range 0..16 */
- uint gaps_in_frame_num_value_allowed_flag; /* u(1) */
- uint pic_width_in_mbs_minus1; /* ue(v) */
- uint pic_height_in_map_units_minus1; /* ue(v) */
- uint frame_mbs_only_flag; /* u(1) */
- /* if( !frame_mbs_only_flag ) */
- uint mb_adaptive_frame_field_flag; /* u(1) */
- uint direct_8x8_inference_flag; /* u(1), must be 1 when frame_mbs_only_flag is 0 */
- uint frame_cropping_flag; /* u(1) */
- /* if( frmae_cropping_flag) */
- uint frame_crop_left_offset; /* ue(v) */
- uint frame_crop_right_offset; /* ue(v) */
- uint frame_crop_top_offset; /* ue(v) */
- uint frame_crop_bottom_offset; /* ue(v) */
- uint vui_parameters_present_flag; /* u(1) */
-// uint nal_hrd_parameters_present_flag;
-// uint vcl_hrd_parameters_present_flag;
-// AVCHRDParams *nal_hrd_parameters;
-// AVCHRDParams *vcl_hrd_parameters;
- AVCVUIParams vui_parameters; /* AVCVUIParam */
-} AVCSeqParamSet;
-
-/**
-This structure contains information in a picture parameter set NAL.
-Some variables may be removed from the structure if they are found to be useless to store.
-@publishedAll
-*/
-typedef struct tagPicParamSet
-{
- uint pic_parameter_set_id; /* ue(v), range 0..255 */
- uint seq_parameter_set_id; /* ue(v), range 0..31 */
- uint entropy_coding_mode_flag; /* u(1) */
- uint pic_order_present_flag; /* u(1) */
- uint num_slice_groups_minus1; /* ue(v), range in Annex A */
- /* if( num_slice_groups_minus1 > 0) */
- uint slice_group_map_type; /* ue(v), range 0..6 */
- /* if( slice_group_map_type = = 0 ) */
- /* for(0:1:num_slice_groups_minus1) */
- uint run_length_minus1[MAX_NUM_SLICE_GROUP]; /* ue(v) */
- /* else if( slice_group_map_type = = 2 ) */
- /* for(0:1:num_slice_groups_minus1-1) */
- uint top_left[MAX_NUM_SLICE_GROUP-1]; /* ue(v) */
- uint bottom_right[MAX_NUM_SLICE_GROUP-1]; /* ue(v) */
- /* else if( slice_group_map_type = = 3 || 4 || 5 */
- uint slice_group_change_direction_flag; /* u(1) */
- uint slice_group_change_rate_minus1; /* ue(v) */
- /* else if( slice_group_map_type = = 6 ) */
- uint pic_size_in_map_units_minus1; /* ue(v) */
- /* for(0:1:pic_size_in_map_units_minus1) */
- uint *slice_group_id; /* complete MBAmap u(v) */
- uint num_ref_idx_l0_active_minus1; /* ue(v), range 0..31 */
- uint num_ref_idx_l1_active_minus1; /* ue(v), range 0..31 */
- uint weighted_pred_flag; /* u(1) */
- uint weighted_bipred_idc; /* u(2), range 0..2 */
- int pic_init_qp_minus26; /* se(v), range -26..25 */
- int pic_init_qs_minus26; /* se(v), range -26..25 */
- int chroma_qp_index_offset; /* se(v), range -12..12 */
- uint deblocking_filter_control_present_flag; /* u(1) */
- uint constrained_intra_pred_flag; /* u(1) */
- uint redundant_pic_cnt_present_flag; /* u(1) */
-} AVCPicParamSet;
-
-
-/**
-This structure contains slice header information.
-Some variables may be removed from the structure if they are found to be useless to store.
-@publishedAll
-*/
-typedef struct tagSliceHeader
-{
- uint first_mb_in_slice; /* ue(v) */
- AVCSliceType slice_type; /* ue(v), Table 7-3, range 0..9 */
- uint pic_parameter_set_id; /* ue(v), range 0..255 */
- uint frame_num; /* u(v), see log2max_frame_num_minus4 */
- /* if( !frame_mbs_only_flag) */
- uint field_pic_flag; /* u(1) */
- /* if(field_pic_flag) */
- uint bottom_field_flag; /* u(1) */
- /* if(nal_unit_type == 5) */
- uint idr_pic_id; /* ue(v), range 0..65535 */
- /* if(pic_order_cnt_type==0) */
- uint pic_order_cnt_lsb; /* u(v), range 0..MaxPicOrderCntLsb-1 */
- /* if(pic_order_present_flag && !field_pic_flag) */
- int32 delta_pic_order_cnt_bottom; /* se(v) */
- /* if(pic_order_cnt_type==1 && !delta_pic_order_always_zero_flag) */
- /* if(pic_order_present_flag && !field_pic_flag) */
- int32 delta_pic_order_cnt[2];
- /* if(redundant_pic_cnt_present_flag) */
- uint redundant_pic_cnt; /* ue(v), range 0..127 */
- /* if(slice_type == B) */
- uint direct_spatial_mv_pred_flag; /* u(1) */
- /* if(slice_type == P || slice_type==SP || slice_type==B) */
- uint num_ref_idx_active_override_flag; /* u(1) */
- /* if(num_ref_idx_active_override_flag) */
- uint num_ref_idx_l0_active_minus1; /* ue(v) */
- /* if(slie_type == B) */
- uint num_ref_idx_l1_active_minus1; /* ue(v) */
-
- /* ref_pic_list_reordering() */
- uint ref_pic_list_reordering_flag_l0; /* u(1) */
- uint reordering_of_pic_nums_idc_l0[MAX_REF_PIC_LIST_REORDERING]; /* ue(v), range 0..3 */
- uint abs_diff_pic_num_minus1_l0[MAX_REF_PIC_LIST_REORDERING]; /* ue(v) */
- uint long_term_pic_num_l0[MAX_REF_PIC_LIST_REORDERING]; /* ue(v) */
- uint ref_pic_list_reordering_flag_l1; /* u(1) */
- uint reordering_of_pic_nums_idc_l1[MAX_REF_PIC_LIST_REORDERING]; /* ue(v), range 0..3 */
- uint abs_diff_pic_num_minus1_l1[MAX_REF_PIC_LIST_REORDERING]; /* ue(v) */
- uint long_term_pic_num_l1[MAX_REF_PIC_LIST_REORDERING]; /* ue(v) */
-
- /* end ref_pic_list_reordering() */
- /* if(nal_ref_idc!=0) */
- /* dec_ref_pic_marking() */
- uint no_output_of_prior_pics_flag; /* u(1) */
- uint long_term_reference_flag; /* u(1) */
- uint adaptive_ref_pic_marking_mode_flag; /* u(1) */
- uint memory_management_control_operation[MAX_DEC_REF_PIC_MARKING]; /* ue(v), range 0..6 */
- uint difference_of_pic_nums_minus1[MAX_DEC_REF_PIC_MARKING]; /* ue(v) */
- uint long_term_pic_num[MAX_DEC_REF_PIC_MARKING]; /* ue(v) */
- uint long_term_frame_idx[MAX_DEC_REF_PIC_MARKING]; /* ue(v) */
- uint max_long_term_frame_idx_plus1[MAX_DEC_REF_PIC_MARKING]; /* ue(v) */
- /* end dec_ref_pic_marking() */
- /* if(entropy_coding_mode_flag && slice_type!=I && slice_type!=SI) */
- uint cabac_init_idc; /* ue(v), range 0..2 */
- int slice_qp_delta; /* se(v), range 0..51 */
- /* if(slice_type==SP || slice_type==SI) */
- /* if(slice_type==SP) */
- uint sp_for_switch_flag; /* u(1) */
- int slice_qs_delta; /* se(v) */
-
- /* if(deblocking_filter_control_present_flag)*/
- uint disable_deblocking_filter_idc; /* ue(v), range 0..2 */
- /* if(disable_deblocking_filter_idc!=1) */
- int slice_alpha_c0_offset_div2; /* se(v), range -6..6, default 0 */
- int slice_beta_offset_div_2; /* se(v), range -6..6, default 0 */
- /* if(num_slice_groups_minus1>0 && slice_group_map_type>=3 && slice_group_map_type<=5)*/
- uint slice_group_change_cycle; /* u(v), use ceil(log2(PicSizeInMapUnits/SliceGroupChangeRate + 1)) bits*/
-
-} AVCSliceHeader;
-
-/**
-This struct contains information about the neighboring pixel.
-@publishedAll
-*/
-typedef struct tagPixPos
-{
- int available;
- int mb_addr; /* macroblock address of the current pixel, see below */
- int x; /* x,y positions of current pixel relative to the macroblock mb_addr */
- int y;
- int pos_x; /* x,y positions of current pixel relative to the picture. */
- int pos_y;
-} AVCPixelPos;
-
-typedef struct tagNeighborAvailability
-{
- int left;
- int top; /* macroblock address of the current pixel, see below */
- int top_right; /* x,y positions of current pixel relative to the macroblock mb_addr */
-} AVCNeighborAvailability;
-
-
-/**
-This structure contains picture data and related information necessary to be used as
-reference frame.
-@publishedAll
-*/
-typedef struct tagPictureData
-{
- uint16 RefIdx; /* index used for reference frame */
- uint8 *Sl; /* derived from base_dpb in AVCFrameStore */
- uint8 *Scb; /* for complementary fields, YUV are interlaced */
- uint8 *Scr; /* Sl of top_field and bottom_fields will be one line apart and the
- stride will be 2 times the width. */
- /* For non-complementary field, the above still applies. A special
- output formatting is required. */
-
- /* Then, necessary variables that need to be stored */
- AVCPictureType picType; /* frame, top-field or bot-field */
- /*bool*/
- uint isReference;
- /*bool*/
- uint isLongTerm;
- int PicOrderCnt;
- int PicNum;
- int LongTermPicNum;
-
- int width; /* how many pixel per line */
- int height;/* how many line */
- int pitch; /* how many pixel between the line */
-
- uint padded; /* flag for being padded */
-
-} AVCPictureData;
-
-/**
-This structure contains information for frame storage.
-@publishedAll
-*/
-typedef struct tagFrameStore
-{
- uint8 *base_dpb; /* base pointer for the YCbCr */
-
- int IsReference; /* 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used */
- int IsLongTerm; /* 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used */
- /* if IsLongTerm is true, IsReference can be ignored. */
- /* if IsReference is true, IsLongterm will be checked for short-term or long-term. */
- /* IsUsed must be true to enable the validity of IsReference and IsLongTerm */
-
- int IsOutputted; /* has it been outputted via AVCDecGetOutput API, then don't output it again,
- wait until it is returned. */
- AVCPictureData frame;
-
- int FrameNum;
- int FrameNumWrap;
- int LongTermFrameIdx;
- int PicOrderCnt; /* of the frame, smaller of the 2 fields */
-
-} AVCFrameStore;
-
-/**
-This structure maintains the actual memory for the decoded picture buffer (DPB) which is
-allocated at the beginning according to profile/level.
-Once decoded_picture_buffer is allocated, Sl,Scb,Scr in
-AVCPictureData structure just point to the address in decoded_picture_buffer.
-used_size maintains the used space.
-NOTE:: In order to maintain contiguous memory space, memory equal to a single frame is
-assigned at a time. Two opposite fields reside in the same frame memory.
-
- |-------|---|---|---|xxx|-------|xxx|---|-------| decoded_picture_buffer
- frame top bot top frame bot frame
- 0 1 1 2 3 4 5
-
- bot 2 and top 4 do not exist, the memory is not used.
-
-@publishedAll
-*/
-typedef struct tagDecPicBuffer
-{
- uint8 *decoded_picture_buffer; /* actual memory */
- uint32 dpb_size; /* size of dpb in bytes */
- uint32 used_size; /* used size */
- struct tagFrameStore *fs[MAX_FS]; /* list of frame stored, actual buffer */
- int num_fs; /* size of fs */
-
-} AVCDecPicBuffer;
-
-
-/**
-This structure contains macroblock related variables.
-@publishedAll
-*/
-typedef struct tagMacroblock
-{
- AVCIntraChromaPredMode intra_chroma_pred_mode; /* ue(v) */
-
- int32 mvL0[16]; /* motion vectors, 16 bit packed (x,y) per element */
- int32 mvL1[16];
- int16 ref_idx_L0[4];
- int16 ref_idx_L1[4];
- uint16 RefIdx[4]; /* ref index, has value of AVCPictureData->RefIdx */
- /* stored data */
- /*bool*/
- uint mb_intra; /* intra flag */
- /*bool*/
- uint mb_bottom_field;
-
- AVCMBMode mbMode; /* type of MB prediction */
- AVCSubMBMode subMbMode[4]; /* for each 8x8 partition */
-
- uint CBP; /* CodeBlockPattern */
- AVCIntra16x16PredMode i16Mode; /* Intra16x16PredMode */
- AVCIntra4x4PredMode i4Mode[16]; /* Intra4x4PredMode, in raster scan order */
- int NumMbPart; /* number of partition */
- AVCPredMode MBPartPredMode[4][4]; /* prediction mode [MBPartIndx][subMBPartIndx] */
- int MbPartWidth;
- int MbPartHeight;
- int NumSubMbPart[4]; /* for each 8x8 partition */
- int SubMbPartWidth[4]; /* for each 8x8 partition */
- int SubMbPartHeight[4]; /* for each 8x8 partition */
-
- uint8 nz_coeff[NUM_BLKS_IN_MB]; /* [blk_y][blk_x], Chroma is [4..5][0...3], see predict_nnz() function */
-
- int QPy; /* Luma QP */
- int QPc; /* Chroma QP */
- int QSc; /* Chroma QP S-picture */
-
- int slice_id; // MC slice
-} AVCMacroblock;
-
-
-/**
-This structure contains common internal variables between the encoder and decoder
-such that some functions can be shared among them.
-@publishedAll
-*/
-typedef struct tagCommonObj
-{
- /* put these 2 up here to make sure they are word-aligned */
- int16 block[NUM_PIXELS_IN_MB]; /* for transformed residue coefficient */
- uint8 *pred_block; /* pointer to prediction block, could point to a frame */
-#ifdef USE_PRED_BLOCK
- uint8 pred[688]; /* for prediction */
- /* Luma [0-399], Cb [400-543], Cr[544-687] */
-#endif
- int pred_pitch; /* either equal to 20 or to frame pitch */
-
- /* temporary buffers for intra prediction */
- /* these variables should remain inside fast RAM */
-#ifdef MB_BASED_DEBLOCK
- uint8 *intra_pred_top; /* a row of pixel for intra prediction */
- uint8 intra_pred_left[17]; /* a column of pixel for intra prediction */
- uint8 *intra_pred_top_cb;
- uint8 intra_pred_left_cb[9];
- uint8 *intra_pred_top_cr;
- uint8 intra_pred_left_cr[9];
-#endif
- /* pointer to the prediction area for intra prediction */
- uint8 *pintra_pred_top; /* pointer to the top intra prediction value */
- uint8 *pintra_pred_left; /* pointer to the left intra prediction value */
- uint8 intra_pred_topleft; /* the [-1,-1] neighboring pixel */
- uint8 *pintra_pred_top_cb;
- uint8 *pintra_pred_left_cb;
- uint8 intra_pred_topleft_cb;
- uint8 *pintra_pred_top_cr;
- uint8 *pintra_pred_left_cr;
- uint8 intra_pred_topleft_cr;
-
- int QPy;
- int QPc;
- int QPy_div_6;
- int QPy_mod_6;
- int QPc_div_6;
- int QPc_mod_6;
- /**** nal_unit ******/
- /* previously in AVCNALUnit format */
- uint NumBytesInRBSP;
- int forbidden_bit;
- int nal_ref_idc;
- AVCNalUnitType nal_unit_type;
- AVCNalUnitType prev_nal_unit_type;
- /*bool*/
- uint slice_data_partitioning; /* flag when nal_unit_type is between 2 and 4 */
- /**** ******** ******/
- AVCSliceType slice_type;
- AVCDecPicBuffer *decPicBuf; /* decoded picture buffer */
-
- AVCSeqParamSet *currSeqParams; /* the currently used one */
-
- AVCPicParamSet *currPicParams; /* the currently used one */
- uint seq_parameter_set_id;
- /* slice header */
- AVCSliceHeader *sliceHdr; /* slice header param syntax variables */
-
- AVCPictureData *currPic; /* pointer to current picture */
- AVCFrameStore *currFS; /* pointer to current frame store */
- AVCPictureType currPicType; /* frame, top-field or bot-field */
- /*bool*/
- uint newPic; /* flag for new picture */
- uint newSlice; /* flag for new slice */
- AVCPictureData *prevRefPic; /* pointer to previous picture */
-
- AVCMacroblock *mblock; /* array of macroblocks covering entire picture */
- AVCMacroblock *currMB; /* pointer to current macroblock */
- uint mbNum; /* number of current MB */
- int mb_x; /* x-coordinate of the current mbNum */
- int mb_y; /* y-coordinate of the current mbNum */
-
- /* For internal operation, scratch memory for MV, prediction, transform, etc.*/
- uint32 cbp4x4; /* each bit represent nonzero 4x4 block in reverse raster scan order */
- /* starting from luma, Cb and Cr, lsb toward msb */
- int mvd_l0[4][4][2]; /* [mbPartIdx][subMbPartIdx][compIdx], se(v) */
- int mvd_l1[4][4][2]; /* [mbPartIdx][subMbPartIdx][compIdx], se(v) */
-
- int mbAddrA, mbAddrB, mbAddrC, mbAddrD; /* address of neighboring MBs */
- /*bool*/
- uint mbAvailA, mbAvailB, mbAvailC, mbAvailD; /* availability */
- /*bool*/
- uint intraAvailA, intraAvailB, intraAvailC, intraAvailD; /* for intra mode */
- /***********************************************/
- /* The following variables are defined in the draft. */
- /* They may need to be stored in PictureData structure and used for reference. */
- /* In that case, just move or copy it to AVCDecPictureData structure. */
-
- int padded_size; /* size of extra padding to a frame */
-
- uint MaxFrameNum; /*2^(log2_max_frame_num_minus4+4), range 0.. 2^16-1 */
- uint MaxPicOrderCntLsb; /*2^(log2_max_pic_order_cnt_lsb_minus4+4), 0..2^16-1 */
- uint PicWidthInMbs; /*pic_width_in_mbs_minus1+1 */
- uint PicWidthInSamplesL; /* PicWidthInMbs*16 */
- uint PicWidthInSamplesC; /* PicWIdthInMbs*8 */
- uint PicHeightInMapUnits; /* pic_height_in_map_units_minus1+1 */
- uint PicSizeInMapUnits; /* PicWidthInMbs*PicHeightInMapUnits */
- uint FrameHeightInMbs; /*(2-frame_mbs_only_flag)*PicHeightInMapUnits */
-
- uint SliceGroupChangeRate; /* slice_group_change_rate_minus1 + 1 */
-
- /* access unit */
- uint primary_pic_type; /* u(3), Table 7-2, kinda informative only */
-
- /* slice data partition */
- uint slice_id; /* ue(v) */
-
- uint UnusedShortTermFrameNum;
- uint PrevRefFrameNum;
- uint MbaffFrameFlag; /* (mb_adaptive_frame_field_flag && !field_pic_flag) */
- uint PicHeightInMbs; /* FrameHeightInMbs/(1+field_pic_flag) */
- int PicHeightInSamplesL; /* PicHeightInMbs*16 */
- int PicHeightInSamplesC; /* PicHeightInMbs*8 */
- uint PicSizeInMbs; /* PicWidthInMbs*PicHeightInMbs */
- uint level_idc;
- int numMBs;
- uint MaxPicNum;
- uint CurrPicNum;
- int QSy; /* 26+pic_init_qp_minus26+slice_qs_delta */
- int FilterOffsetA;
- int FilterOffsetB;
- uint MapUnitsInSliceGroup0; /* Min(slie_group_change_cycle*SliceGroupChangeRate,PicSizeInMapUnits) */
- /* dec_ref_pic_marking */
- int MaxLongTermFrameIdx;
- int LongTermFrameIdx;
-
- /* POC related variables */
- /*bool*/
- uint mem_mgr_ctrl_eq_5; /* if memory_management_control_operation equal to 5 flag */
- int PicOrderCnt;
- int BottomFieldOrderCnt, TopFieldOrderCnt;
- /* POC mode 0 */
- int prevPicOrderCntMsb;
- uint prevPicOrderCntLsb;
- int PicOrderCntMsb;
- /* POC mode 1 */
- int prevFrameNumOffset, FrameNumOffset;
- uint prevFrameNum;
- int absFrameNum;
- int picOrderCntCycleCnt, frameNumInPicOrderCntCycle;
- int expectedDeltaPerPicOrderCntCycle;
- int expectedPicOrderCnt;
-
- /* FMO */
- int *MbToSliceGroupMap; /* to be re-calculate at the beginning */
-
- /* ref pic list */
- AVCPictureData *RefPicList0[MAX_REF_PIC_LIST]; /* list 0 */
- AVCPictureData *RefPicList1[MAX_REF_PIC_LIST]; /* list 1 */
- AVCFrameStore *refFrameList0ShortTerm[32];
- AVCFrameStore *refFrameList1ShortTerm[32];
- AVCFrameStore *refFrameListLongTerm[32];
- int refList0Size;
- int refList1Size;
-
- /* slice data semantics*/
- int mb_skip_run; /* ue(v) */
- /*uint mb_skip_flag;*/ /* ae(v) */
- /* uint end_of_slice_flag;*//* ae(v) */
- /***********************************************/
-
- /* function pointers */
- int (*is_short_ref)(AVCPictureData *s);
- int (*is_long_ref)(AVCPictureData *s);
-
-} AVCCommonObj;
-
-/**
-Commonly used constant arrays.
-@publishedAll
-*/
-/**
-Zigzag scan from 1-D to 2-D. */
-const static uint8 ZZ_SCAN[16] = {0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15};
-/* Zigzag scan from 1-D to 2-D output to block[24][16]. */
-const static uint8 ZZ_SCAN_BLOCK[16] = {0, 1, 16, 32, 17, 2, 3, 18, 33, 48, 49, 34, 19, 35, 50, 51};
-
-/**
-From zigzag to raster for luma DC value */
-const static uint8 ZIGZAG2RASTERDC[16] = {0, 4, 64, 128, 68, 8, 12, 72, 132, 192, 196, 136, 76, 140, 200, 204};
-
-
-/**
-Mapping from coding scan block indx to raster scan block index */
-const static int blkIdx2blkX[16] = {0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3};
-const static int blkIdx2blkY[16] = {0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3};
-/** from [blk8indx][blk4indx] to raster scan index */
-const static int blkIdx2blkXY[4][4] = {{0, 1, 4, 5}, {2, 3, 6, 7}, {8, 9, 12, 13}, {10, 11, 14, 15}};
-
-/*
-Availability of the neighboring top-right block relative to the current block. */
-const static int BlkTopRight[16] = {2, 2, 2, 3, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0};
-
-/**
-Table 8-13 Specification of QPc as a function of qPI. */
-const static uint8 mapQPi2QPc[52] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 34, 35, 35, 36, 36,
- 37, 37, 37, 38, 38, 38, 39, 39, 39, 39
- };
-
-/**
-See 8.5.5 equation (8-252 and 8-253) the definition of v matrix. */
-/* in zigzag scan */
-const static int dequant_coefres[6][16] =
-{
- {10, 13, 13, 10, 16, 10, 13, 13, 13, 13, 16, 10, 16, 13, 13, 16},
- {11, 14, 14, 11, 18, 11, 14, 14, 14, 14, 18, 11, 18, 14, 14, 18},
- {13, 16, 16, 13, 20, 13, 16, 16, 16, 16, 20, 13, 20, 16, 16, 20},
- {14, 18, 18, 14, 23, 14, 18, 18, 18, 18, 23, 14, 23, 18, 18, 23},
- {16, 20, 20, 16, 25, 16, 20, 20, 20, 20, 25, 16, 25, 20, 20, 25},
- {18, 23, 23, 18, 29, 18, 23, 23, 23, 23, 29, 18, 29, 23, 23, 29}
-};
-
-/**
-From jm7.6 block.c. (in zigzag scan) */
-const static int quant_coef[6][16] =
-{
- {13107, 8066, 8066, 13107, 5243, 13107, 8066, 8066, 8066, 8066, 5243, 13107, 5243, 8066, 8066, 5243},
- {11916, 7490, 7490, 11916, 4660, 11916, 7490, 7490, 7490, 7490, 4660, 11916, 4660, 7490, 7490, 4660},
- {10082, 6554, 6554, 10082, 4194, 10082, 6554, 6554, 6554, 6554, 4194, 10082, 4194, 6554, 6554, 4194},
- {9362, 5825, 5825, 9362, 3647, 9362, 5825, 5825, 5825, 5825, 3647, 9362, 3647, 5825, 5825, 3647},
- {8192, 5243, 5243, 8192, 3355, 8192, 5243, 5243, 5243, 5243, 3355, 8192, 3355, 5243, 5243, 3355},
- {7282, 4559, 4559, 7282, 2893, 7282, 4559, 4559, 4559, 4559, 2893, 7282, 2893, 4559, 4559, 2893}
-};
-
-/**
-Convert scan from raster scan order to block decoding order and
-from block decoding order to raster scan order. Same table!!!
-*/
-const static uint8 ras2dec[16] = {0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15};
-
-/* mapping from level_idc to index map */
-const static uint8 mapLev2Idx[61] = {255, 255, 255, 255, 255, 255, 255, 255, 255, 1,
- 0, 1, 2, 3, 255, 255, 255, 255, 255, 255,
- 4, 5, 6, 255, 255, 255, 255, 255, 255, 255,
- 7, 8, 9, 255, 255, 255, 255, 255, 255, 255,
- 10, 11, 12, 255, 255, 255, 255, 255, 255, 255,
- 13, 14, 255, 255, 255, 255, 255, 255, 255, 255
- };
-/* map back from index to Level IDC */
-const static uint8 mapIdx2Lev[MAX_LEVEL_IDX] = {10, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51};
-
-/**
-from the index map to the MaxDPB value times 2 */
-const static int32 MaxDPBX2[MAX_LEVEL_IDX] = {297, 675, 1782, 1782, 1782, 3564, 6075, 6075,
- 13500, 15360, 24576, 24576, 24576, 82620, 138240
- };
-
-/* map index to the max frame size */
-const static int MaxFS[MAX_LEVEL_IDX] = {99, 396, 396, 396, 396, 792, 1620, 1620, 3600, 5120,
- 8192, 8192, 8192, 22080, 36864
- };
-
-/* map index to max MB processing rate */
-const static int32 MaxMBPS[MAX_LEVEL_IDX] = {1485, 3000, 6000, 11880, 11880, 19800, 20250, 40500,
- 108000, 216000, 245760, 245760, 491520, 589824, 983040
- };
-
-/* map index to max video bit rate */
-const static uint32 MaxBR[MAX_LEVEL_IDX] = {64, 192, 384, 768, 2000, 4000, 4000, 10000, 14000, 20000,
- 20000, 50000, 50000, 135000, 240000
- };
-
-/* map index to max CPB size */
-const static uint32 MaxCPB[MAX_LEVEL_IDX] = {175, 500, 1000, 2000, 2000, 4000, 4000, 10000, 14000,
- 20000, 25000, 62500, 62500, 135000, 240000
- };
-
-/* map index to max vertical MV range */
-const static int MaxVmvR[MAX_LEVEL_IDX] = {64, 128, 128, 128, 128, 256, 256, 256, 512, 512, 512, 512, 512, 512, 512};
-
-#endif /* _AVCINT_COMMON_H_ */
diff --git a/media/libstagefright/codecs/avc/common/include/avclib_common.h b/media/libstagefright/codecs/avc/common/include/avclib_common.h
deleted file mode 100644
index cbbf0c6..0000000
--- a/media/libstagefright/codecs/avc/common/include/avclib_common.h
+++ /dev/null
@@ -1,557 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-/**
-This file contains declarations of internal functions for common encoder/decoder library.
-@publishedAll
-*/
-#ifndef AVCCOMMON_LIB_H_INCLUDED
-#define AVCCOMMON_LIB_H_INCLUDED
-
-#include <stdlib.h>
-
-#ifndef AVCINT_COMMON_H_INCLUDED
-#include "avcint_common.h"
-#endif
-
-/*----------- deblock.c --------------*/
-/**
-This function performs conditional deblocking on a complete picture.
-\param "video" "Pointer to AVCCommonObj."
-\return "AVC_SUCCESS for success and AVC_FAIL otherwise."
-*/
-OSCL_IMPORT_REF AVCStatus DeblockPicture(AVCCommonObj *video);
-
-/**
-This function performs MB-based deblocking when MB_BASED_DEBLOCK
-is defined at compile time.
-\param "video" "Pointer to AVCCommonObj."
-\return "AVC_SUCCESS for success and AVC_FAIL otherwise."
-*/
-void MBInLoopDeblock(AVCCommonObj *video);
-
-
-/*---------- dpb.c --------------------*/
-/**
-This function is called everytime a new sequence is detected.
-\param "avcHandle" "Pointer to AVCHandle."
-\param "video" "Pointer to AVCCommonObj."
-\param "padding" "Flag specifying whether padding in luma component is needed (used for encoding)."
-\return "AVC_SUCCESS or AVC_FAIL."
-*/
-OSCL_IMPORT_REF AVCStatus AVCConfigureSequence(AVCHandle *avcHandle, AVCCommonObj *video, bool padding);
-
-/**
-This function allocates and initializes the decoded picture buffer structure based on
-the profile and level for the first sequence parameter set. Currently,
-it does not allow changing in profile/level for subsequent SPS.
-\param "avcHandle" "Pointer to AVCHandle."
-\param "video" "Pointer to AVCCommonObj."
-\param "FrameHeightInMbs" "Height of the frame in the unit of MBs."
-\param "PicWidthInMbs" "Width of the picture in the unit of MBs."
-\param "padding" "Flag specifying whether padding in luma component is needed (used for encoding)."
-\return "AVC_SUCCESS or AVC_FAIL."
-*/
-AVCStatus InitDPB(AVCHandle *avcHandle, AVCCommonObj *video, int FrameHeightInMbs, int PicWidthInMbs, bool padding);
-
-/**
-This function frees the DPB memory.
-\param "avcHandle" "Pointer to AVCHandle."
-\param "video" "Pointer to AVCCommonObj."
-\return "AVC_SUCCESS or AVC_FAIL."
-*/
-OSCL_IMPORT_REF AVCStatus CleanUpDPB(AVCHandle *avcHandle, AVCCommonObj *video);
-
-/**
-This function finds empty frame in the decoded picture buffer to be used for the
-current picture, initializes the corresponding picture structure with Sl, Scb, Scr,
-width, height and pitch.
-\param "avcHandle" "Pointer to the main handle object."
-\param "video" "Pointer to AVCCommonObj."
-\return "AVC_SUCCESS or AVC_FAIL."
-*/
-OSCL_IMPORT_REF AVCStatus DPBInitBuffer(AVCHandle *avcHandle, AVCCommonObj *video);
-/**
-This function finds empty frame in the decoded picture buffer to be used for the
-current picture, initializes the corresponding picture structure with Sl, Scb, Scr,
-width, height and pitch.
-\param "video" "Pointer to AVCCommonObj."
-\param "CurrPicNum" "Current picture number (only used in decoder)."
-\return "AVC_SUCCESS or AVC_FAIL."
-*/
-
-OSCL_IMPORT_REF void DPBInitPic(AVCCommonObj *video, int CurrPicNum);
-
-/**
-This function releases the current frame back to the available pool for skipped frame after encoding.
-\param "avcHandle" "Pointer to the main handle object."
-\param "video" "Pointer to the AVCCommonObj."
-\return "void."
-*/
-OSCL_IMPORT_REF void DPBReleaseCurrentFrame(AVCHandle *avcHandle, AVCCommonObj *video);
-
-/**
-This function performs decoded reference picture marking process and store the current picture to the
-corresponding frame storage in the decoded picture buffer.
-\param "avcHandle" "Pointer to the main handle object."
-\param "video" "Pointer to the AVCCommonObj."
-\return "AVC_SUCCESS or AVC_FAIL."
-*/
-OSCL_IMPORT_REF AVCStatus StorePictureInDPB(AVCHandle *avcHandle, AVCCommonObj *video);
-
-/**
-This function perform sliding window operation on the reference picture lists, see subclause 8.2.5.3.
-It removes short-term ref frames with smallest FrameNumWrap from the reference list.
-\param "avcHandle" "Pointer to the main handle object."
-\param "video" "Pointer to the AVCCommonObj."
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\return "AVC_SUCCESS or AVC_FAIL (contradicting values or scenario as in the Note in the draft)."
-*/
-AVCStatus sliding_window_process(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb);
-
-
-/**
-This function perform adaptive memory marking operation on the reference picture lists,
-see subclause 8.2.5.4. It calls other functions for specific operations.
-\param "video" "Pointer to the AVCCommonObj."
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\param "sliceHdr" "Pointer to the AVCSliceHeader."
-\return "AVC_SUCCESS or AVC_FAIL (contradicting values or scenario as in the Note in the draft)."
-*/
-AVCStatus adaptive_memory_marking(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, AVCSliceHeader *sliceHdr);
-
-/**
-This function performs memory management control operation 1, marking a short-term picture
-as unused for reference. See subclause 8.2.5.4.1.
-\param "video" "Pointer to the AVCCommonObj."
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\param "difference_of_pic_nums_minus1" "From the syntax in dec_ref_pic_marking()."
-*/
-void MemMgrCtrlOp1(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, int difference_of_pic_nums_minus1);
-
-/**
-This function performs memory management control operation 2, marking a long-term picture
-as unused for reference. See subclause 8.2.5.4.2.
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\param "field_pic_flag" "Flag whether the current picture is field or not."
-\param "long_term_pic_num" "From the syntax in dec_ref_pic_marking()."
-*/
-void MemMgrCtrlOp2(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, int long_term_pic_num);
-
-/**
-This function performs memory management control operation 3, assigning a LongTermFrameIdx to
-a short-term reference picture. See subclause 8.2.5.4.3.
-\param "video" "Pointer to the AVCCommonObj."
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\param "difference_of_pic_nums_minus1" "From the syntax in dec_ref_pic_marking()."
-\param "long_term_pic_num" "From the syntax in dec_ref_pic_marking()."
-*/
-void MemMgrCtrlOp3(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint difference_of_pic_nums_minus1,
- uint long_term_frame_idx);
-
-/**
-This function performs memory management control operation 4, getting new MaxLongTermFrameIdx.
- See subclause 8.2.5.4.4.
-\param "video" "Pointer to the AVCCommonObj."
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\param "max_long_term_frame_idx_plus1" "From the syntax in dec_ref_pic_marking()."
-*/
-void MemMgrCtrlOp4(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint max_long_term_frame_idx_plus1);
-
-/**
-This function performs memory management control operation 5, marking all reference pictures
-as unused for reference and set MaxLongTermFrameIdx to no long-termframe indices.
- See subclause 8.2.5.4.5.
-\param "video" "Pointer to the AVCCommonObj."
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-*/
-void MemMgrCtrlOp5(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb);
-
-/**
-This function performs memory management control operation 6, assigning a long-term frame index
-to the current picture. See subclause 8.2.5.4.6.
-\param "video" "Pointer to the AVCCommonObj."
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\param "long_term_frame_idx" "From the syntax in dec_ref_pic_marking()."
-*/
-void MemMgrCtrlOp6(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint long_term_frame_idx);
-
-/**
-This function mark a long-term ref frame with a specific frame index as unused for reference.
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\param "long_term_frame_idx" "To look for"
-*/
-void unmark_long_term_frame_for_reference_by_frame_idx(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, uint long_term_frame_idx);
-
-/**
-This function mark a long-term ref field with a specific frame index as unused for reference except
-a frame that contains a picture with picNumX.
-\param "dpb" "Pointer to the AVCDecPicBuffer."
-\param "long_term_frame_idx" "To look for."
-\param "picNumX" "To look for."
-*/
-void unmark_long_term_field_for_reference_by_frame_idx(AVCCommonObj *video, AVCDecPicBuffer *dpb, uint long_term_frame_indx, int picNumX);
-
-/**
-This function mark a frame to unused for reference.
-\param "fs" "Pointer to AVCFrameStore to be unmarked."
-*/
-void unmark_for_reference(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, uint idx);
-
-void update_ref_list(AVCDecPicBuffer *dpb);
-
-
-/*---------- fmo.c --------------*/
-/**
-This function initializes flexible macroblock reordering.
-\param "video" "Pointer to AVCCommonObj."
-\return "AVC_SUCCESS for success and AVC_FAIL otherwise."
-*/
-OSCL_IMPORT_REF AVCStatus FMOInit(AVCCommonObj *video);
-
-/**
-This function fills up an array that maps Map unit to the slice group
-following the interleaved slice group map type.
-\param "mapUnitToSliceGroupMap" "Array of slice group mapping."
-\param "run_length_minus1" "Array of the run-length."
-\param "num_slice_groups_minus_1" "Number of slice group minus 1."
-\param "PicSizeInMapUnit" "Size of the picture in number Map units."
-\return "Void."
-*/
-void FmoGenerateType0MapUnitMap(int *mapUnitToSliceGroupMap, uint *run_length_minus1, uint num_slice_groups_minus1, uint PicSizeInMapUnits);
-
-/**
-This function fills up an array that maps Map unit to the slice group
-following the dispersed slice group map type.
-\param "mapUnitToSliceGroupMap" "Array of slice group mapping."
-\param "PicWidthInMbs" "Width of the luma picture in macroblock unit."
-\param "num_slice_groups_minus_1" "Number of slice group minus 1."
-\param "PicSizeInMapUnit" "Size of the picture in number Map units."
-\return "Void."
-*/
-void FmoGenerateType1MapUnitMap(int *mapUnitToSliceGroupMap, int PicWidthInMbs, uint num_slice_groups_minus1, uint PicSizeInMapUnits);
-
-/**
-This function fills up an array that maps Map unit to the slice group
-following the foreground with left-over slice group map type.
-\param "pps" "Pointer to AVCPicParamSets structure."
-\param "mapUnitToSliceGroupMap" "Array of slice group mapping."
-\param "PicWidthInMbs" "Width of the luma picture in macroblock unit."
-\param "num_slice_groups_minus_1" "Number of slice group minus 1."
-\param "PicSizeInMapUnit" "Size of the picture in number Map units."
-\return "Void."
-*/
-void FmoGenerateType2MapUnitMap(AVCPicParamSet *pps, int *mapUnitToSliceGroupMap, int PicWidthInMbs,
- uint num_slice_groups_minus1, uint PicSizeInMapUnits);
-
-/**
-This function fills up an array that maps Map unit to the slice group
-following the box-out slice group map type.
-\param "pps" "Pointer to AVCPicParamSets structure."
-\param "mapUnitToSliceGroupMap" "Array of slice group mapping."
-\param "PicWidthInMbs" "Width of the luma picture in macroblock unit."
-\return "Void."
-*/
-void FmoGenerateType3MapUnitMap(AVCCommonObj *video, AVCPicParamSet* pps, int *mapUnitToSliceGroupMap,
- int PicWidthInMbs);
-
-/**
-This function fills up an array that maps Map unit to the slice group
-following the raster scan slice group map type.
-\param "mapUnitToSliceGroupMap" "Array of slice group mapping."
-\param "MapUnitsInSliceGroup0" "Derived in subclause 7.4.3."
-\param "slice_group_change_direction_flag" "A value from the slice header."
-\param "PicSizeInMapUnit" "Size of the picture in number Map units."
-\return "void"
-*/
-void FmoGenerateType4MapUnitMap(int *mapUnitToSliceGroupMap, int MapUnitsInSliceGroup0,
- int slice_group_change_direction_flag, uint PicSizeInMapUnits);
-
-/**
-This function fills up an array that maps Map unit to the slice group
-following wipe slice group map type.
-\param "mapUnitToSliceGroupMap" "Array of slice group mapping."
-\param "video" "Pointer to AVCCommonObj structure."
-\param "slice_group_change_direction_flag" "A value from the slice header."
-\param "PicSizeInMapUnit" "Size of the picture in number Map units."
-\return "void"
-*/
-void FmoGenerateType5MapUnitMap(int *mapUnitsToSliceGroupMap, AVCCommonObj *video,
- int slice_group_change_direction_flag, uint PicSizeInMapUnits);
-
-/**
-This function fills up an array that maps Map unit to the slice group
-following wipe slice group map type.
-\param "mapUnitToSliceGroupMap" "Array of slice group mapping."
-\param "slice_group_id" "Array of slice_group_id from AVCPicParamSet structure."
-\param "PicSizeInMapUnit" "Size of the picture in number Map units."
-\return "void"
-*/
-void FmoGenerateType6MapUnitMap(int *mapUnitsToSliceGroupMap, int *slice_group_id, uint PicSizeInMapUnits);
-
-/*------------- itrans.c --------------*/
-/**
-This function performs transformation of the Intra16x16DC value according to
-subclause 8.5.6.
-\param "block" "Pointer to the video->block[0][0][0]."
-\param "QPy" "Quantization parameter."
-\return "void."
-*/
-void Intra16DCTrans(int16 *block, int Qq, int Rq);
-
-/**
-This function performs transformation of a 4x4 block according to
-subclause 8.5.8.
-\param "block" "Pointer to the origin of transform coefficient area."
-\param "pred" "Pointer to the origin of predicted area."
-\param "cur" "Pointer to the origin of the output area."
-\param "width" "Pitch of cur."
-\return "void."
-*/
-void itrans(int16 *block, uint8 *pred, uint8 *cur, int width);
-
-/*
-This function is the same one as itrans except for chroma.
-\param "block" "Pointer to the origin of transform coefficient area."
-\param "pred" "Pointer to the origin of predicted area."
-\param "cur" "Pointer to the origin of the output area."
-\param "width" "Pitch of cur."
-\return "void."
-*/
-void ictrans(int16 *block, uint8 *pred, uint8 *cur, int width);
-
-/**
-This function performs transformation of the DCChroma value according to
-subclause 8.5.7.
-\param "block" "Pointer to the video->block[0][0][0]."
-\param "QPc" "Quantization parameter."
-\return "void."
-*/
-void ChromaDCTrans(int16 *block, int Qq, int Rq);
-
-/**
-This function copies a block from pred to cur.
-\param "pred" "Pointer to prediction block."
-\param "cur" "Pointer to the current YUV block."
-\param "width" "Pitch of cur memory."
-\param "pred_pitch" "Pitch for pred memory.
-\return "void."
-*/
-void copy_block(uint8 *pred, uint8 *cur, int width, int pred_pitch);
-
-/*--------- mb_access.c ----------------*/
-/**
-This function initializes the neighboring information before start macroblock decoding.
-\param "video" "Pointer to AVCCommonObj."
-\param "mbNum" "The current macroblock index."
-\param "currMB" "Pointer to the current AVCMacroblock structure."
-\return "void"
-*/
-OSCL_IMPORT_REF void InitNeighborAvailability(AVCCommonObj *video, int mbNum);
-
-/**
-This function checks whether the requested neighboring macroblock is available.
-\param "MbToSliceGroupMap" "Array containing the slice group ID mapping to MB index."
-\param "PicSizeInMbs" "Size of the picture in number of MBs."
-\param "mbAddr" "Neighboring macroblock index to check."
-\param "currMbAddr" "Current macroblock index."
-\return "TRUE if the neighboring MB is available, FALSE otherwise."
-*/
-bool mb_is_available(AVCMacroblock *mblock, uint PicSizeInMbs, int mbAddr, int currMbAddr);
-
-/**
-This function performs prediction of the nonzero coefficient for a luma block (i,j).
-\param "video" "Pointer to AVCCommonObj."
-\param "i" "Block index, horizontal."
-\param "j" "Block index, vertical."
-\return "Predicted number of nonzero coefficient."
-*/
-OSCL_IMPORT_REF int predict_nnz(AVCCommonObj *video, int i, int j);
-
-/**
-This function performs prediction of the nonzero coefficient for a chroma block (i,j).
-\param "video" "Pointer to AVCCommonObj."
-\param "i" "Block index, horizontal."
-\param "j" "Block index, vertical."
-\return "Predicted number of nonzero coefficient."
-*/
-OSCL_IMPORT_REF int predict_nnz_chroma(AVCCommonObj *video, int i, int j);
-
-/**
-This function calculates the predicted motion vectors for the current macroblock.
-\param "video" "Pointer to AVCCommonObj."
-\param "encFlag" "Boolean whether this function is used by encoder or decoder."
-\return "void."
-*/
-OSCL_IMPORT_REF void GetMotionVectorPredictor(AVCCommonObj *video, int encFlag);
-
-/*---------- reflist.c -----------------*/
-/**
-This function initializes reference picture list used in INTER prediction
-at the beginning of each slice decoding. See subclause 8.2.4.
-\param "video" "Pointer to AVCCommonObj."
-\return "void"
-Output is video->RefPicList0, video->RefPicList1, video->refList0Size and video->refList1Size.
-*/
-OSCL_IMPORT_REF void RefListInit(AVCCommonObj *video);
-
-/**
-This function generates picture list from frame list. Used when current picture is field.
-see subclause 8.2.4.2.5.
-\param "video" "Pointer to AVCCommonObj."
-\param "IsL1" "Is L1 list?"
-\param "long_term" "Is long-term prediction?"
-\return "void"
-*/
-void GenPicListFromFrameList(AVCCommonObj *video, int IsL1, int long_term);
-
-/**
-This function performs reference picture list reordering according to the
-ref_pic_list_reordering() syntax. See subclause 8.2.4.3.
-\param "video" "Pointer to AVCCommonObj."
-\return "AVC_SUCCESS or AVC_FAIL"
-Output is video->RefPicList0, video->RefPicList1, video->refList0Size and video->refList1Size.
-*/
-OSCL_IMPORT_REF AVCStatus ReOrderList(AVCCommonObj *video);
-
-/**
-This function performs reference picture list reordering according to the
-ref_pic_list_reordering() syntax regardless of list 0 or list 1. See subclause 8.2.4.3.
-\param "video" "Pointer to AVCCommonObj."
-\param "isL1" "Is list 1 or not."
-\return "AVC_SUCCESS or AVC_FAIL"
-Output is video->RefPicList0 and video->refList0Size or video->RefPicList1 and video->refList1Size.
-*/
-AVCStatus ReorderRefPicList(AVCCommonObj *video, int isL1);
-
-/**
-This function performs reordering process of reference picture list for short-term pictures.
-See subclause 8.2.4.3.1.
-\param "video" "Pointer to AVCCommonObj."
-\param "picNumLX" "picNumLX of an entry in the reference list."
-\param "refIdxLX" "Pointer to the current entry index in the reference."
-\param "isL1" "Is list 1 or not."
-\return "AVC_SUCCESS or AVC_FAIL"
-*/
-AVCStatus ReorderShortTerm(AVCCommonObj *video, int picNumLX, int *refIdxLX, int isL1);
-
-/**
-This function performs reordering process of reference picture list for long-term pictures.
-See subclause 8.2.4.3.2.
-\param "video" "Pointer to AVCCommonObj."
-\param "LongTermPicNum" "LongTermPicNum of an entry in the reference list."
-\param "refIdxLX" "Pointer to the current entry index in the reference."
-\param "isL1" "Is list 1 or not."
-\return "AVC_SUCCESS or AVC_FAIL"
-*/
-AVCStatus ReorderLongTerm(AVCCommonObj *video, int LongTermPicNum, int *refIdxLX, int isL1);
-
-/**
-This function gets the pictures in DPB according to the PicNum.
-\param "video" "Pointer to AVCCommonObj."
-\param "picNum" "PicNum of the picture we are looking for."
-\return "Pointer to the AVCPictureData or NULL if not found"
-*/
-AVCPictureData* GetShortTermPic(AVCCommonObj *video, int picNum);
-
-/**
-This function gets the pictures in DPB according to the LongtermPicNum.
-\param "video" "Pointer to AVCCommonObj."
-\param "LongtermPicNum" "LongtermPicNum of the picture we are looking for."
-\return "Pointer to the AVCPictureData."
-*/
-AVCPictureData* GetLongTermPic(AVCCommonObj *video, int LongtermPicNum);
-
-/**
-This function indicates whether the picture is used for short-term reference or not.
-\param "s" "Pointer to AVCPictureData."
-\return "1 if it is used for short-term, 0 otherwise."
-*/
-int is_short_ref(AVCPictureData *s);
-
-/**
-This function indicates whether the picture is used for long-term reference or not.
-\param "s" "Pointer to AVCPictureData."
-\return "1 if it is used for long-term, 0 otherwise."
-*/
-int is_long_ref(AVCPictureData *s);
-
-/**
-This function sorts array of pointers to AVCPictureData in descending order of
-the PicNum value.
-\param "data" "Array of pointers to AVCPictureData."
-\param "num" "Size of the array."
-\return "void"
-*/
-void SortPicByPicNum(AVCPictureData *data[], int num);
-
-/**
-This function sorts array of pointers to AVCPictureData in ascending order of
-the PicNum value.
-\param "data" "Array of pointers to AVCPictureData."
-\param "num" "Size of the array."
-\return "void"
-*/
-void SortPicByPicNumLongTerm(AVCPictureData *data[], int num);
-
-/**
-This function sorts array of pointers to AVCFrameStore in descending order of
-the FrameNumWrap value.
-\param "data" "Array of pointers to AVCFrameStore."
-\param "num" "Size of the array."
-\return "void"
-*/
-void SortFrameByFrameNumWrap(AVCFrameStore *data[], int num);
-
-/**
-This function sorts array of pointers to AVCFrameStore in ascending order of
-the LongTermFrameIdx value.
-\param "data" "Array of pointers to AVCFrameStore."
-\param "num" "Size of the array."
-\return "void"
-*/
-void SortFrameByLTFrameIdx(AVCFrameStore *data[], int num);
-
-/**
-This function sorts array of pointers to AVCPictureData in descending order of
-the PicOrderCnt value.
-\param "data" "Array of pointers to AVCPictureData."
-\param "num" "Size of the array."
-\return "void"
-*/
-void SortPicByPOC(AVCPictureData *data[], int num, int descending);
-
-/**
-This function sorts array of pointers to AVCPictureData in ascending order of
-the LongTermPicNum value.
-\param "data" "Array of pointers to AVCPictureData."
-\param "num" "Size of the array."
-\return "void"
-*/
-void SortPicByLTPicNum(AVCPictureData *data[], int num);
-
-/**
-This function sorts array of pointers to AVCFrameStore in descending order of
-the PicOrderCnt value.
-\param "data" "Array of pointers to AVCFrameStore."
-\param "num" "Size of the array."
-\return "void"
-*/
-void SortFrameByPOC(AVCFrameStore *data[], int num, int descending);
-
-
-#endif /* _AVCCOMMON_LIB_H_ */
diff --git a/media/libstagefright/codecs/avc/common/src/deblock.cpp b/media/libstagefright/codecs/avc/common/src/deblock.cpp
deleted file mode 100644
index 5f8b693..0000000
--- a/media/libstagefright/codecs/avc/common/src/deblock.cpp
+++ /dev/null
@@ -1,1667 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-
-#include <string.h>
-
-#include "avclib_common.h"
-
-#define MAX_QP 51
-#define MB_BLOCK_SIZE 16
-
-// NOTE: these 3 tables are for funtion GetStrength() only
-const static int ININT_STRENGTH[4] = {0x04040404, 0x03030303, 0x03030303, 0x03030303};
-
-
-// NOTE: these 3 tables are for funtion EdgeLoop() only
-// NOTE: to change the tables below for instance when the QP doubling is changed from 6 to 8 values
-
-const static int ALPHA_TABLE[52] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 20, 22, 25, 28, 32, 36, 40, 45, 50, 56, 63, 71, 80, 90, 101, 113, 127, 144, 162, 182, 203, 226, 255, 255} ;
-const static int BETA_TABLE[52] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18} ;
-const static int CLIP_TAB[52][5] =
-{
- { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0},
- { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0},
- { 0, 0, 0, 0, 0}, { 0, 0, 0, 1, 1}, { 0, 0, 0, 1, 1}, { 0, 0, 0, 1, 1}, { 0, 0, 0, 1, 1}, { 0, 0, 1, 1, 1}, { 0, 0, 1, 1, 1}, { 0, 1, 1, 1, 1},
- { 0, 1, 1, 1, 1}, { 0, 1, 1, 1, 1}, { 0, 1, 1, 1, 1}, { 0, 1, 1, 2, 2}, { 0, 1, 1, 2, 2}, { 0, 1, 1, 2, 2}, { 0, 1, 1, 2, 2}, { 0, 1, 2, 3, 3},
- { 0, 1, 2, 3, 3}, { 0, 2, 2, 3, 3}, { 0, 2, 2, 4, 4}, { 0, 2, 3, 4, 4}, { 0, 2, 3, 4, 4}, { 0, 3, 3, 5, 5}, { 0, 3, 4, 6, 6}, { 0, 3, 4, 6, 6},
- { 0, 4, 5, 7, 7}, { 0, 4, 5, 8, 8}, { 0, 4, 6, 9, 9}, { 0, 5, 7, 10, 10}, { 0, 6, 8, 11, 11}, { 0, 6, 8, 13, 13}, { 0, 7, 10, 14, 14}, { 0, 8, 11, 16, 16},
- { 0, 9, 12, 18, 18}, { 0, 10, 13, 20, 20}, { 0, 11, 15, 23, 23}, { 0, 13, 17, 25, 25}
-};
-
-// NOTE: this table is only QP clipping, index = QP + video->FilterOffsetA/B, clipped to [0, 51]
-// video->FilterOffsetA/B is in {-12, 12]
-const static int QP_CLIP_TAB[76] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // [-12, 0]
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // [1, 51]
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51 // [52,63]
-};
-
-static void DeblockMb(AVCCommonObj *video, int mb_x, int mb_y, uint8 *SrcY, uint8 *SrcU, uint8 *SrcV);
-//static void GetStrength(AVCCommonObj *video, uint8 *Strength, AVCMacroblock* MbP, AVCMacroblock* MbQ, int dir, int edge);
-static void GetStrength_Edge0(uint8 *Strength, AVCMacroblock* MbP, AVCMacroblock* MbQ, int dir);
-static void GetStrength_VerticalEdges(uint8 *Strength, AVCMacroblock* MbQ);
-static void GetStrength_HorizontalEdges(uint8 Strength[12], AVCMacroblock* MbQ);
-static void EdgeLoop_Luma_vertical(uint8* SrcPtr, uint8 *Strength, int Alpha, int Beta, int *clipTable, int pitch);
-static void EdgeLoop_Luma_horizontal(uint8* SrcPtr, uint8 *Strength, int Alpha, int Beta, int *clipTable, int pitch);
-static void EdgeLoop_Chroma_vertical(uint8* SrcPtr, uint8 *Strength, int Alpha, int Beta, int *clipTable, int pitch);
-static void EdgeLoop_Chroma_horizontal(uint8* SrcPtr, uint8 *Strength, int Alpha, int Beta, int *clipTable, int pitch);
-
-/*
- *****************************************************************************************
- * \brief Filter all macroblocks in order of increasing macroblock address.
- *****************************************************************************************
-*/
-
-OSCL_EXPORT_REF AVCStatus DeblockPicture(AVCCommonObj *video)
-{
- uint i, j;
- int pitch = video->currPic->pitch, pitch_c, width;
- uint8 *SrcY, *SrcU, *SrcV;
-
- SrcY = video->currPic->Sl; // pointers to source
- SrcU = video->currPic->Scb;
- SrcV = video->currPic->Scr;
- pitch_c = pitch >> 1;
- width = video->currPic->width;
-
- for (i = 0; i < video->PicHeightInMbs; i++)
- {
- for (j = 0; j < video->PicWidthInMbs; j++)
- {
- DeblockMb(video, j, i, SrcY, SrcU, SrcV);
- // update SrcY, SrcU, SrcV
- SrcY += MB_BLOCK_SIZE;
- SrcU += (MB_BLOCK_SIZE >> 1);
- SrcV += (MB_BLOCK_SIZE >> 1);
- }
-
- SrcY += ((pitch << 4) - width);
- SrcU += ((pitch_c << 3) - (width >> 1));
- SrcV += ((pitch_c << 3) - (width >> 1));
- }
-
- return AVC_SUCCESS;
-}
-
-#ifdef MB_BASED_DEBLOCK
-/*
- *****************************************************************************************
- * \brief Filter one macroblocks in a fast macroblock memory and copy it to frame
- *****************************************************************************************
-*/
-void MBInLoopDeblock(AVCCommonObj *video)
-{
- AVCPictureData *currPic = video->currPic;
-#ifdef USE_PRED_BLOCK
- uint8 *predCb, *predCr, *pred_block;
- int i, j, dst_width, dst_height, dst_widthc, dst_heightc;
-#endif
- int pitch = currPic->pitch;
- int x_pos = video->mb_x;
- int y_pos = video->mb_y;
- uint8 *curL, *curCb, *curCr;
- int offset;
-
- offset = (y_pos << 4) * pitch;
-
- curL = currPic->Sl + offset + (x_pos << 4);
-
- offset >>= 2;
- offset += (x_pos << 3);
-
- curCb = currPic->Scb + offset;
- curCr = currPic->Scr + offset;
-
-#ifdef USE_PRED_BLOCK
- pred_block = video->pred;
-
- /* 1. copy neighboring pixels from frame to the video->pred_block */
- if (y_pos) /* not the 0th row */
- {
- /* copy to the top 4 lines of the macroblock */
- curL -= (pitch << 2); /* go back 4 lines */
-
- memcpy(pred_block + 4, curL, 16);
- curL += pitch;
- memcpy(pred_block + 24, curL, 16);
- curL += pitch;
- memcpy(pred_block + 44, curL, 16);
- curL += pitch;
- memcpy(pred_block + 64, curL, 16);
- curL += pitch;
-
- curCb -= (pitch << 1); /* go back 4 lines chroma */
- curCr -= (pitch << 1);
-
- pred_block += 400;
-
- memcpy(pred_block + 4, curCb, 8);
- curCb += (pitch >> 1);
- memcpy(pred_block + 16, curCb, 8);
- curCb += (pitch >> 1);
- memcpy(pred_block + 28, curCb, 8);
- curCb += (pitch >> 1);
- memcpy(pred_block + 40, curCb, 8);
- curCb += (pitch >> 1);
-
- pred_block += 144;
- memcpy(pred_block + 4, curCr, 8);
- curCr += (pitch >> 1);
- memcpy(pred_block + 16, curCr, 8);
- curCr += (pitch >> 1);
- memcpy(pred_block + 28, curCr, 8);
- curCr += (pitch >> 1);
- memcpy(pred_block + 40, curCr, 8);
- curCr += (pitch >> 1);
-
- pred_block = video->pred;
- }
-
- /* 2. perform deblocking. */
- DeblockMb(video, x_pos, y_pos, pred_block + 84, pred_block + 452, pred_block + 596);
-
- /* 3. copy it back to the frame and update pred_block */
- predCb = pred_block + 400;
- predCr = predCb + 144;
-
- /* find the range of the block inside pred_block to be copied back */
- if (y_pos) /* the first row */
- {
- curL -= (pitch << 2);
- curCb -= (pitch << 1);
- curCr -= (pitch << 1);
-
- dst_height = 20;
- dst_heightc = 12;
- }
- else
- {
- pred_block += 80;
- predCb += 48;
- predCr += 48;
- dst_height = 16;
- dst_heightc = 8;
- }
-
- if (x_pos) /* find the width */
- {
- curL -= 4;
- curCb -= 4;
- curCr -= 4;
- if (x_pos == (int)(video->PicWidthInMbs - 1))
- {
- dst_width = 20;
- dst_widthc = 12;
- }
- else
- {
- dst_width = 16;
- dst_widthc = 8;
- }
- }
- else
- {
- pred_block += 4;
- predCb += 4;
- predCr += 4;
- dst_width = 12;
- dst_widthc = 4;
- }
-
- /* perform copy */
- for (j = 0; j < dst_height; j++)
- {
- memcpy(curL, pred_block, dst_width);
- curL += pitch;
- pred_block += 20;
- }
- for (j = 0; j < dst_heightc; j++)
- {
- memcpy(curCb, predCb, dst_widthc);
- memcpy(curCr, predCr, dst_widthc);
- curCb += (pitch >> 1);
- curCr += (pitch >> 1);
- predCb += 12;
- predCr += 12;
- }
-
- if (x_pos != (int)(video->PicWidthInMbs - 1)) /* now copy from the right-most 4 columns to the left-most 4 columns */
- {
- pred_block = video->pred;
- for (i = 0; i < 20; i += 4)
- {
- *((uint32*)pred_block) = *((uint32*)(pred_block + 16));
- pred_block += 20;
- *((uint32*)pred_block) = *((uint32*)(pred_block + 16));
- pred_block += 20;
- *((uint32*)pred_block) = *((uint32*)(pred_block + 16));
- pred_block += 20;
- *((uint32*)pred_block) = *((uint32*)(pred_block + 16));
- pred_block += 20;
- }
-
- for (i = 0; i < 24; i += 4)
- {
- *((uint32*)pred_block) = *((uint32*)(pred_block + 8));
- pred_block += 12;
- *((uint32*)pred_block) = *((uint32*)(pred_block + 8));
- pred_block += 12;
- *((uint32*)pred_block) = *((uint32*)(pred_block + 8));
- pred_block += 12;
- *((uint32*)pred_block) = *((uint32*)(pred_block + 8));
- pred_block += 12;
- }
-
- }
-#else
- DeblockMb(video, x_pos, y_pos, curL, curCb, curCr);
-#endif
-
- return ;
-}
-#endif
-
-/*
- *****************************************************************************************
- * \brief Deblocking filter for one macroblock.
- *****************************************************************************************
- */
-
-void DeblockMb(AVCCommonObj *video, int mb_x, int mb_y, uint8 *SrcY, uint8 *SrcU, uint8 *SrcV)
-{
- AVCMacroblock *MbP, *MbQ;
- int edge, QP, QPC;
- int filterLeftMbEdgeFlag = (mb_x != 0);
- int filterTopMbEdgeFlag = (mb_y != 0);
- int pitch = video->currPic->pitch;
- int indexA, indexB;
- int *tmp;
- int Alpha, Beta, Alpha_c, Beta_c;
- int mbNum = mb_y * video->PicWidthInMbs + mb_x;
- int *clipTable, *clipTable_c, *qp_clip_tab;
- uint8 Strength[16];
- void* str;
-
- MbQ = &(video->mblock[mbNum]); // current Mb
-
-
- // If filter is disabled, return
- if (video->sliceHdr->disable_deblocking_filter_idc == 1) return;
-
- if (video->sliceHdr->disable_deblocking_filter_idc == 2)
- {
- // don't filter at slice boundaries
- filterLeftMbEdgeFlag = mb_is_available(video->mblock, video->PicSizeInMbs, mbNum - 1, mbNum);
- filterTopMbEdgeFlag = mb_is_available(video->mblock, video->PicSizeInMbs, mbNum - video->PicWidthInMbs, mbNum);
- }
-
- /* NOTE: edge=0 and edge=1~3 are separate cases because of the difference of MbP, index A and indexB calculation */
- /* for edge = 1~3, MbP, indexA and indexB remain the same, and thus there is no need to re-calculate them for each edge */
-
- qp_clip_tab = (int *)QP_CLIP_TAB + 12;
-
- /* 1.VERTICAL EDGE + MB BOUNDARY (edge = 0) */
- if (filterLeftMbEdgeFlag)
- {
- MbP = MbQ - 1;
- //GetStrength(video, Strength, MbP, MbQ, 0, 0); // Strength for 4 blks in 1 stripe, 0 => vertical edge
- GetStrength_Edge0(Strength, MbP, MbQ, 0);
-
- str = (void*)Strength; //de-ref type-punned pointer fix
- if (*((uint32*)str)) // only if one of the 4 Strength bytes is != 0
- {
- QP = (MbP->QPy + MbQ->QPy + 1) >> 1; // Average QP of the two blocks;
- indexA = QP + video->FilterOffsetA;
- indexB = QP + video->FilterOffsetB;
- indexA = qp_clip_tab[indexA]; // IClip(0, MAX_QP, QP+video->FilterOffsetA)
- indexB = qp_clip_tab[indexB]; // IClip(0, MAX_QP, QP+video->FilterOffsetB)
-
- Alpha = ALPHA_TABLE[indexA];
- Beta = BETA_TABLE[indexB];
- clipTable = (int *) CLIP_TAB[indexA];
-
- if (Alpha > 0 && Beta > 0)
-#ifdef USE_PRED_BLOCK
- EdgeLoop_Luma_vertical(SrcY, Strength, Alpha, Beta, clipTable, 20);
-#else
- EdgeLoop_Luma_vertical(SrcY, Strength, Alpha, Beta, clipTable, pitch);
-#endif
-
- QPC = (MbP->QPc + MbQ->QPc + 1) >> 1;
- indexA = QPC + video->FilterOffsetA;
- indexB = QPC + video->FilterOffsetB;
- indexA = qp_clip_tab[indexA]; // IClip(0, MAX_QP, QP+video->FilterOffsetA)
- indexB = qp_clip_tab[indexB]; // IClip(0, MAX_QP, QP+video->FilterOffsetB)
-
- Alpha = ALPHA_TABLE[indexA];
- Beta = BETA_TABLE[indexB];
- clipTable = (int *) CLIP_TAB[indexA];
- if (Alpha > 0 && Beta > 0)
- {
-#ifdef USE_PRED_BLOCK
- EdgeLoop_Chroma_vertical(SrcU, Strength, Alpha, Beta, clipTable, 12);
- EdgeLoop_Chroma_vertical(SrcV, Strength, Alpha, Beta, clipTable, 12);
-#else
- EdgeLoop_Chroma_vertical(SrcU, Strength, Alpha, Beta, clipTable, pitch >> 1);
- EdgeLoop_Chroma_vertical(SrcV, Strength, Alpha, Beta, clipTable, pitch >> 1);
-#endif
- }
- }
-
- } /* end of: if(filterLeftMbEdgeFlag) */
-
- /* 2.VERTICAL EDGE (no boundary), the edges are all inside a MB */
- /* First calculate the necesary parameters all at once, outside the loop */
- MbP = MbQ;
-
- indexA = MbQ->QPy + video->FilterOffsetA;
- indexB = MbQ->QPy + video->FilterOffsetB;
- // index
- indexA = qp_clip_tab[indexA]; // IClip(0, MAX_QP, QP+video->FilterOffsetA)
- indexB = qp_clip_tab[indexB]; // IClip(0, MAX_QP, QP+video->FilterOffsetB)
-
- Alpha = ALPHA_TABLE[indexA];
- Beta = BETA_TABLE[indexB];
- clipTable = (int *)CLIP_TAB[indexA];
-
- /* Save Alpha, Beta and clipTable for future use, with the obselete variables filterLeftMbEdgeFlag, mbNum amd tmp */
- filterLeftMbEdgeFlag = Alpha;
- mbNum = Beta;
- tmp = clipTable;
-
- indexA = MbQ->QPc + video->FilterOffsetA;
- indexB = MbQ->QPc + video->FilterOffsetB;
- indexA = qp_clip_tab[indexA]; // IClip(0, MAX_QP, QP+video->FilterOffsetA)
- indexB = qp_clip_tab[indexB]; // IClip(0, MAX_QP, QP+video->FilterOffsetB)
-
- Alpha_c = ALPHA_TABLE[indexA];
- Beta_c = BETA_TABLE[indexB];
- clipTable_c = (int *)CLIP_TAB[indexA];
-
- GetStrength_VerticalEdges(Strength + 4, MbQ); // Strength for 4 blks in 1 stripe, 0 => vertical edge
-
- for (edge = 1; edge < 4; edge++) // 4 vertical strips of 16 pel
- {
- //GetStrength_VerticalEdges(video, Strength, MbP, MbQ, 0, edge); // Strength for 4 blks in 1 stripe, 0 => vertical edge
- if (*((int*)(Strength + (edge << 2)))) // only if one of the 4 Strength bytes is != 0
- {
- if (Alpha > 0 && Beta > 0)
-#ifdef USE_PRED_BLOCK
- EdgeLoop_Luma_vertical(SrcY + (edge << 2), Strength + (edge << 2), Alpha, Beta, clipTable, 20);
-#else
- EdgeLoop_Luma_vertical(SrcY + (edge << 2), Strength + (edge << 2), Alpha, Beta, clipTable, pitch);
-#endif
-
- if (!(edge & 1) && Alpha_c > 0 && Beta_c > 0)
- {
-#ifdef USE_PRED_BLOCK
- EdgeLoop_Chroma_vertical(SrcU + (edge << 1), Strength + (edge << 2), Alpha_c, Beta_c, clipTable_c, 12);
- EdgeLoop_Chroma_vertical(SrcV + (edge << 1), Strength + (edge << 2), Alpha_c, Beta_c, clipTable_c, 12);
-#else
- EdgeLoop_Chroma_vertical(SrcU + (edge << 1), Strength + (edge << 2), Alpha_c, Beta_c, clipTable_c, pitch >> 1);
- EdgeLoop_Chroma_vertical(SrcV + (edge << 1), Strength + (edge << 2), Alpha_c, Beta_c, clipTable_c, pitch >> 1);
-#endif
- }
- }
-
- } //end edge
-
-
-
- /* 3.HORIZONTAL EDGE + MB BOUNDARY (edge = 0) */
- if (filterTopMbEdgeFlag)
- {
- MbP = MbQ - video->PicWidthInMbs;
- //GetStrength(video, Strength, MbP, MbQ, 1, 0); // Strength for 4 blks in 1 stripe, 0 => vertical edge
- GetStrength_Edge0(Strength, MbP, MbQ, 1);
- str = (void*)Strength; //de-ref type-punned pointer fix
- if (*((uint32*)str)) // only if one of the 4 Strength bytes is != 0
- {
- QP = (MbP->QPy + MbQ->QPy + 1) >> 1; // Average QP of the two blocks;
- indexA = QP + video->FilterOffsetA;
- indexB = QP + video->FilterOffsetB;
- indexA = qp_clip_tab[indexA]; // IClip(0, MAX_QP, QP+video->FilterOffsetA)
- indexB = qp_clip_tab[indexB]; // IClip(0, MAX_QP, QP+video->FilterOffsetB)
-
- Alpha = ALPHA_TABLE[indexA];
- Beta = BETA_TABLE[indexB];
- clipTable = (int *)CLIP_TAB[indexA];
-
- if (Alpha > 0 && Beta > 0)
- {
-#ifdef USE_PRED_BLOCK
- EdgeLoop_Luma_horizontal(SrcY, Strength, Alpha, Beta, clipTable, 20);
-#else
- EdgeLoop_Luma_horizontal(SrcY, Strength, Alpha, Beta, clipTable, pitch);
-#endif
- }
-
- QPC = (MbP->QPc + MbQ->QPc + 1) >> 1;
- indexA = QPC + video->FilterOffsetA;
- indexB = QPC + video->FilterOffsetB;
- indexA = qp_clip_tab[indexA]; // IClip(0, MAX_QP, QP+video->FilterOffsetA)
- indexB = qp_clip_tab[indexB]; // IClip(0, MAX_QP, QP+video->FilterOffsetB)
-
- Alpha = ALPHA_TABLE[indexA];
- Beta = BETA_TABLE[indexB];
- clipTable = (int *)CLIP_TAB[indexA];
- if (Alpha > 0 && Beta > 0)
- {
-#ifdef USE_PRED_BLOCK
- EdgeLoop_Chroma_horizontal(SrcU, Strength, Alpha, Beta, clipTable, 12);
- EdgeLoop_Chroma_horizontal(SrcV, Strength, Alpha, Beta, clipTable, 12);
-#else
- EdgeLoop_Chroma_horizontal(SrcU, Strength, Alpha, Beta, clipTable, pitch >> 1);
- EdgeLoop_Chroma_horizontal(SrcV, Strength, Alpha, Beta, clipTable, pitch >> 1);
-#endif
- }
- }
-
- } /* end of: if(filterTopMbEdgeFlag) */
-
-
- /* 4.HORIZONTAL EDGE (no boundary), the edges are inside a MB */
- MbP = MbQ;
-
- /* Recover Alpha, Beta and clipTable for edge!=0 with the variables filterLeftMbEdgeFlag, mbNum and tmp */
- /* Note that Alpha_c, Beta_c and clipTable_c for chroma is already calculated */
- Alpha = filterLeftMbEdgeFlag;
- Beta = mbNum;
- clipTable = tmp;
-
- GetStrength_HorizontalEdges(Strength + 4, MbQ); // Strength for 4 blks in 1 stripe, 0 => vertical edge
-
- for (edge = 1; edge < 4; edge++) // 4 horicontal strips of 16 pel
- {
- //GetStrength(video, Strength, MbP, MbQ, 1, edge); // Strength for 4 blks in 1 stripe 1 => horizontal edge
- if (*((int*)(Strength + (edge << 2)))) // only if one of the 4 Strength bytes is != 0
- {
- if (Alpha > 0 && Beta > 0)
- {
-#ifdef USE_PRED_BLOCK
- EdgeLoop_Luma_horizontal(SrcY + (edge << 2)*20, Strength + (edge << 2), Alpha, Beta, clipTable, 20);
-#else
- EdgeLoop_Luma_horizontal(SrcY + (edge << 2)*pitch, Strength + (edge << 2), Alpha, Beta, clipTable, pitch);
-#endif
- }
-
- if (!(edge & 1) && Alpha_c > 0 && Beta_c > 0)
- {
-#ifdef USE_PRED_BLOCK
- EdgeLoop_Chroma_horizontal(SrcU + (edge << 1)*12, Strength + (edge << 2), Alpha_c, Beta_c, clipTable_c, 12);
- EdgeLoop_Chroma_horizontal(SrcV + (edge << 1)*12, Strength + (edge << 2), Alpha_c, Beta_c, clipTable_c, 12);
-#else
- EdgeLoop_Chroma_horizontal(SrcU + (edge << 1)*(pitch >> 1), Strength + (edge << 2), Alpha_c, Beta_c, clipTable_c, pitch >> 1);
- EdgeLoop_Chroma_horizontal(SrcV + (edge << 1)*(pitch >> 1), Strength + (edge << 2), Alpha_c, Beta_c, clipTable_c, pitch >> 1);
-#endif
- }
- }
-
- } //end edge
-
- return;
-}
-
-/*
- *****************************************************************************************************
- * \brief returns a buffer of 4 Strength values for one stripe in a mb (for different Frame types)
- *****************************************************************************************************
-*/
-
-void GetStrength_Edge0(uint8 *Strength, AVCMacroblock* MbP, AVCMacroblock* MbQ, int dir)
-{
- int tmp;
- int16 *ptrQ, *ptrP;
- void* vptr;
- uint8 *pStrength;
- void* refIdx;
-
- if (MbP->mbMode == AVC_I4 || MbP->mbMode == AVC_I16 ||
- MbQ->mbMode == AVC_I4 || MbQ->mbMode == AVC_I16)
- {
-
- *((int*)Strength) = ININT_STRENGTH[0]; // Start with Strength=3. or Strength=4 for Mb-edge
-
- }
- else // if not intra or SP-frame
- {
- *((int*)Strength) = 0;
-
- if (dir == 0) // Vertical Edge 0
- {
-
- //1. Check the ref_frame_id
- refIdx = (void*) MbQ->RefIdx; //de-ref type-punned pointer fix
- ptrQ = (int16*)refIdx;
- refIdx = (void*)MbP->RefIdx; //de-ref type-punned pointer fix
- ptrP = (int16*)refIdx;
- pStrength = Strength;
- if (ptrQ[0] != ptrP[1]) pStrength[0] = 1;
- if (ptrQ[2] != ptrP[3]) pStrength[2] = 1;
- pStrength[1] = pStrength[0];
- pStrength[3] = pStrength[2];
-
- //2. Check the non-zero coeff blocks (4x4)
- if (MbQ->nz_coeff[0] != 0 || MbP->nz_coeff[3] != 0) pStrength[0] = 2;
- if (MbQ->nz_coeff[4] != 0 || MbP->nz_coeff[7] != 0) pStrength[1] = 2;
- if (MbQ->nz_coeff[8] != 0 || MbP->nz_coeff[11] != 0) pStrength[2] = 2;
- if (MbQ->nz_coeff[12] != 0 || MbP->nz_coeff[15] != 0) pStrength[3] = 2;
-
- //3. Only need to check the mv difference
- vptr = (void*)MbQ->mvL0; // for deref type-punned pointer
- ptrQ = (int16*)vptr;
- ptrP = (int16*)(MbP->mvL0 + 3); // points to 4x4 block #3 (the 4th column)
-
- // 1st blk
- if (*pStrength == 0)
- {
- // check |mv difference| >= 4
- tmp = *ptrQ++ - *ptrP++;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *ptrQ-- - *ptrP--;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- pStrength++;
- ptrQ += 8;
- ptrP += 8;
-
- // 2nd blk
- if (*pStrength == 0)
- {
- // check |mv difference| >= 4
- tmp = *ptrQ++ - *ptrP++;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *ptrQ-- - *ptrP--;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- pStrength++;
- ptrQ += 8;
- ptrP += 8;
-
- // 3rd blk
- if (*pStrength == 0)
- {
- // check |mv difference| >= 4
- tmp = *ptrQ++ - *ptrP++;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *ptrQ-- - *ptrP--;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- pStrength++;
- ptrQ += 8;
- ptrP += 8;
-
- // 4th blk
- if (*pStrength == 0)
- {
- // check |mv difference| >= 4
- tmp = *ptrQ++ - *ptrP++;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *ptrQ-- - *ptrP--;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
- }
- else // Horizontal Edge 0
- {
-
- //1. Check the ref_frame_id
- refIdx = (void*)MbQ->RefIdx; //de-ref type-punned pointer
- ptrQ = (int16*)refIdx;
- refIdx = (void*)MbP->RefIdx; //de-ref type-punned pointer
- ptrP = (int16*)refIdx;
- pStrength = Strength;
- if (ptrQ[0] != ptrP[2]) pStrength[0] = 1;
- if (ptrQ[1] != ptrP[3]) pStrength[2] = 1;
- pStrength[1] = pStrength[0];
- pStrength[3] = pStrength[2];
-
- //2. Check the non-zero coeff blocks (4x4)
- if (MbQ->nz_coeff[0] != 0 || MbP->nz_coeff[12] != 0) pStrength[0] = 2;
- if (MbQ->nz_coeff[1] != 0 || MbP->nz_coeff[13] != 0) pStrength[1] = 2;
- if (MbQ->nz_coeff[2] != 0 || MbP->nz_coeff[14] != 0) pStrength[2] = 2;
- if (MbQ->nz_coeff[3] != 0 || MbP->nz_coeff[15] != 0) pStrength[3] = 2;
-
- //3. Only need to check the mv difference
- vptr = (void*)MbQ->mvL0;
- ptrQ = (int16*)vptr;
- ptrP = (int16*)(MbP->mvL0 + 12); // points to 4x4 block #12 (the 4th row)
-
- // 1st blk
- if (*pStrength == 0)
- {
- // check |mv difference| >= 4
- tmp = *ptrQ++ - *ptrP++;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *ptrQ-- - *ptrP--;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- pStrength++;
- ptrQ += 2;
- ptrP += 2;
-
- // 2nd blk
- if (*pStrength == 0)
- {
- // check |mv difference| >= 4
- tmp = *ptrQ++ - *ptrP++;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *ptrQ-- - *ptrP--;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- pStrength++;
- ptrQ += 2;
- ptrP += 2;
-
- // 3rd blk
- if (*pStrength == 0)
- {
- // check |mv difference| >= 4
- tmp = *ptrQ++ - *ptrP++;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *ptrQ-- - *ptrP--;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- pStrength++;
- ptrQ += 2;
- ptrP += 2;
-
- // 4th blk
- if (*pStrength == 0)
- {
- // check |mv difference| >= 4
- tmp = *ptrQ++ - *ptrP++;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *ptrQ-- - *ptrP--;
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- } /* end of: else if(dir == 0) */
-
- } /* end of: if( !(MbP->mbMode == AVC_I4 ...) */
-}
-
-
-void GetStrength_VerticalEdges(uint8 *Strength, AVCMacroblock* MbQ)
-{
- int idx, tmp;
- int16 *ptr, *pmvx, *pmvy;
- uint8 *pnz;
- uint8 *pStrength, *pStr;
- void* refIdx;
-
- if (MbQ->mbMode == AVC_I4 || MbQ->mbMode == AVC_I16)
- {
- *((int*)Strength) = ININT_STRENGTH[1]; // Start with Strength=3. or Strength=4 for Mb-edge
- *((int*)(Strength + 4)) = ININT_STRENGTH[2];
- *((int*)(Strength + 8)) = ININT_STRENGTH[3];
- }
- else // Not intra or SP-frame
- {
-
- *((int*)Strength) = 0; // for non-intra MB, strength = 0, 1 or 2.
- *((int*)(Strength + 4)) = 0;
- *((int*)(Strength + 8)) = 0;
-
- //1. Check the ref_frame_id
- refIdx = (void*)MbQ->RefIdx; //de-ref type-punned pointer fix
- ptr = (int16*)refIdx;
- pStrength = Strength;
- if (ptr[0] != ptr[1]) pStrength[4] = 1;
- if (ptr[2] != ptr[3]) pStrength[6] = 1;
- pStrength[5] = pStrength[4];
- pStrength[7] = pStrength[6];
-
- //2. Check the nz_coeff block and mv difference
- pmvx = (int16*)(MbQ->mvL0 + 1); // points to 4x4 block #1,not #0
- pmvy = pmvx + 1;
- for (idx = 0; idx < 4; idx += 2) // unroll the loop, make 4 iterations to 2
- {
- // first/third row : 1,2,3 or 9,10,12
- // Strength = 2 for a whole row
- pnz = MbQ->nz_coeff + (idx << 2);
- if (*pnz++ != 0) *pStrength = 2;
- if (*pnz++ != 0)
- {
- *pStrength = 2;
- *(pStrength + 4) = 2;
- }
- if (*pnz++ != 0)
- {
- *(pStrength + 4) = 2;
- *(pStrength + 8) = 2;
- }
- if (*pnz != 0) *(pStrength + 8) = 2;
-
- // Then Strength = 1
- if (*pStrength == 0)
- {
- //within the same 8x8 block, no need to check the reference id
- //only need to check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *pmvy - *(pmvy - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- pmvx += 2;
- pmvy += 2;
- pStr = pStrength + 4;
-
- if (*pStr == 0)
- {
- //check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- pmvx += 2;
- pmvy += 2;
- pStr = pStrength + 8;
-
- if (*pStr == 0)
- {
- //within the same 8x8 block, no need to check the reference id
- //only need to check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- // Second/fourth row: 5,6,7 or 14,15,16
- // Strength = 2 for a whole row
- pnz = MbQ->nz_coeff + ((idx + 1) << 2);
- if (*pnz++ != 0) *(pStrength + 1) = 2;
- if (*pnz++ != 0)
- {
- *(pStrength + 1) = 2;
- *(pStrength + 5) = 2;
- }
- if (*pnz++ != 0)
- {
- *(pStrength + 5) = 2;
- *(pStrength + 9) = 2;
- }
- if (*pnz != 0) *(pStrength + 9) = 2;
-
- // Then Strength = 1
- pmvx += 4;
- pmvy += 4;
- pStr = pStrength + 1;
- if (*pStr == 0)
- {
- //within the same 8x8 block, no need to check the reference id
- //only need to check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- pmvx += 2;
- pmvy += 2;
- pStr = pStrength + 5;
-
- if (*pStr == 0)
- {
- //check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- pmvx += 2;
- pmvy += 2;
- pStr = pStrength + 9;
-
- if (*pStr == 0)
- {
- //within the same 8x8 block, no need to check the reference id
- //only need to check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 2);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- // update some variables for the next two rows
- pmvx += 4;
- pmvy += 4;
- pStrength += 2;
-
- } /* end of: for(idx=0; idx<2; idx++) */
-
- } /* end of: else if( MbQ->mbMode == AVC_I4 ...) */
-}
-
-
-void GetStrength_HorizontalEdges(uint8 Strength[12], AVCMacroblock* MbQ)
-{
- int idx, tmp;
- int16 *ptr, *pmvx, *pmvy;
- uint8 *pStrength, *pStr;
- void* refIdx;
-
- if (MbQ->mbMode == AVC_I4 || MbQ->mbMode == AVC_I16)
- {
- *((int*)Strength) = ININT_STRENGTH[1]; // Start with Strength=3. or Strength=4 for Mb-edge
- *((int*)(Strength + 4)) = ININT_STRENGTH[2];
- *((int*)(Strength + 8)) = ININT_STRENGTH[3];
- }
- else // Not intra or SP-frame
- {
-
- *((int*)Strength) = 0; // for non-intra MB, strength = 0, 1 or 2.
- *((int*)(Strength + 4)) = 0; // for non-intra MB, strength = 0, 1 or 2.
- *((int*)(Strength + 8)) = 0; // for non-intra MB, strength = 0, 1 or 2.
-
-
- //1. Check the ref_frame_id
- refIdx = (void*) MbQ->RefIdx; // de-ref type-punned fix
- ptr = (int16*) refIdx;
- pStrength = Strength;
- if (ptr[0] != ptr[2]) pStrength[4] = 1;
- if (ptr[1] != ptr[3]) pStrength[6] = 1;
- pStrength[5] = pStrength[4];
- pStrength[7] = pStrength[6];
-
- //2. Check the nz_coeff block and mv difference
- pmvx = (int16*)(MbQ->mvL0 + 4); // points to 4x4 block #4,not #0
- pmvy = pmvx + 1;
- for (idx = 0; idx < 4; idx += 2) // unroll the loop, make 4 iterations to 2
- {
- // first/third row : 1,2,3 or 9,10,12
- // Strength = 2 for a whole row
- if (MbQ->nz_coeff[idx] != 0) *pStrength = 2;
- if (MbQ->nz_coeff[4+idx] != 0)
- {
- *pStrength = 2;
- *(pStrength + 4) = 2;
- }
- if (MbQ->nz_coeff[8+idx] != 0)
- {
- *(pStrength + 4) = 2;
- *(pStrength + 8) = 2;
- }
- if (MbQ->nz_coeff[12+idx] != 0) *(pStrength + 8) = 2;
-
- // Then Strength = 1
- if (*pStrength == 0)
- {
- //within the same 8x8 block, no need to check the reference id
- //only need to check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
-
- tmp = *pmvy - *(pmvy - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStrength = 1;
- }
-
- pmvx += 8;
- pmvy += 8;
- pStr = pStrength + 4;
-
- if (*pStr == 0)
- {
- //check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- pmvx += 8;
- pmvy += 8;
- pStr = pStrength + 8;
-
- if (*pStr == 0)
- {
- //within the same 8x8 block, no need to check the reference id
- //only need to check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- // Second/fourth row: 5,6,7 or 14,15,16
- // Strength = 2 for a whole row
- if (MbQ->nz_coeff[idx+1] != 0) *(pStrength + 1) = 2;
- if (MbQ->nz_coeff[4+idx+1] != 0)
- {
- *(pStrength + 1) = 2;
- *(pStrength + 5) = 2;
- }
- if (MbQ->nz_coeff[8+idx+1] != 0)
- {
- *(pStrength + 5) = 2;
- *(pStrength + 9) = 2;
- }
- if (MbQ->nz_coeff[12+idx+1] != 0) *(pStrength + 9) = 2;
-
- // Then Strength = 1
- pmvx -= 14;
- pmvy -= 14; // -14 = -16 + 2
- pStr = pStrength + 1;
- if (*pStr == 0)
- {
- //within the same 8x8 block, no need to check the reference id
- //only need to check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- pmvx += 8;
- pmvy += 8;
- pStr = pStrength + 5;
-
- if (*pStr == 0)
- {
- //check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- pmvx += 8;
- pmvy += 8;
- pStr = pStrength + 9;
-
- if (*pStr == 0)
- {
- //within the same 8x8 block, no need to check the reference id
- //only need to check the |mv difference| >= 4
- tmp = *pmvx - *(pmvx - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
-
- tmp = *pmvy - *(pmvy - 8);
- if (tmp < 0) tmp = -tmp;
- if (tmp >= 4) *pStr = 1;
- }
-
- // update some variables for the next two rows
- pmvx -= 14;
- pmvy -= 14; // -14 = -16 + 2
- pStrength += 2;
-
- } /* end of: for(idx=0; idx<2; idx++) */
-
- } /* end of: else if( MbQ->mbMode == AVC_I4 ...) */
-}
-
-/*
- *****************************************************************************************
- * \brief Filters one edge of 16 (luma) or 8 (chroma) pel
- *****************************************************************************************
-*/
-
-void EdgeLoop_Luma_horizontal(uint8* SrcPtr, uint8 *Strength, int Alpha, int Beta, int *clipTable, int pitch)
-{
- int pel, ap = 0, aq = 0, Strng;
- int C0, c0, dif, AbsDelta, tmp, tmp1;
- int L2 = 0, L1, L0, R0, R1, R2 = 0, RL0;
-
-
- if (Strength[0] == 4) /* INTRA strong filtering */
- {
- for (pel = 0; pel < 16; pel++)
- {
- R0 = SrcPtr[0];
- R1 = SrcPtr[pitch];
- L0 = SrcPtr[-pitch];
- L1 = SrcPtr[-(pitch<<1)];
-
- // |R0 - R1| < Beta
- tmp1 = R0 - R1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp = (tmp1 - Beta);
-
- //|L0 - L1| < Beta
- tmp1 = L0 - L1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Beta);
-
- //|R0 - L0| < Alpha
- AbsDelta = R0 - L0;
- if (AbsDelta < 0) AbsDelta = -AbsDelta;
- tmp &= (AbsDelta - Alpha);
-
- if (tmp < 0)
- {
- AbsDelta -= ((Alpha >> 2) + 2);
- R2 = SrcPtr[pitch<<1]; //inc2
- L2 = SrcPtr[-(pitch+(pitch<<1))]; // -inc3
-
- // |R0 - R2| < Beta && |R0 - L0| < (Alpha/4 + 2)
- tmp = R0 - R2;
- if (tmp < 0) tmp = -tmp;
- aq = AbsDelta & (tmp - Beta);
-
- // |L0 - L2| < Beta && |R0 - L0| < (Alpha/4 + 2)
- tmp = L0 - L2;
- if (tmp < 0) tmp = -tmp;
- ap = AbsDelta & (tmp - Beta);
-
- if (aq < 0)
- {
- tmp = R1 + R0 + L0;
- SrcPtr[0] = (L1 + (tmp << 1) + R2 + 4) >> 3;
- tmp += R2;
- SrcPtr[pitch] = (tmp + 2) >> 2;
- SrcPtr[pitch<<1] = (((SrcPtr[(pitch+(pitch<<1))] + R2) << 1) + tmp + 4) >> 3;
- }
- else
- SrcPtr[0] = ((R1 << 1) + R0 + L1 + 2) >> 2;
-
- if (ap < 0)
- {
- tmp = L1 + R0 + L0;
- SrcPtr[-pitch] = (R1 + (tmp << 1) + L2 + 4) >> 3;
- tmp += L2;
- SrcPtr[-(pitch<<1)] = (tmp + 2) >> 2;
- SrcPtr[-(pitch+(pitch<<1))] = (((SrcPtr[-(pitch<<2)] + L2) << 1) + tmp + 4) >> 3;
- }
- else
- SrcPtr[-pitch] = ((L1 << 1) + L0 + R1 + 2) >> 2;
-
- } /* if(tmp < 0) */
-
- SrcPtr ++; // Increment to next set of pixel
-
- } /* end of: for(pel=0; pel<16; pel++) */
-
- } /* if(Strength[0] == 4) */
-
- else /* Normal filtering */
- {
- for (pel = 0; pel < 16; pel++)
- {
- Strng = Strength[pel >> 2];
- if (Strng)
- {
- R0 = SrcPtr[0];
- R1 = SrcPtr[pitch];
- L0 = SrcPtr[-pitch];
- L1 = SrcPtr[-(pitch<<1)]; // inc2
-
- //|R0 - L0| < Alpha
- tmp1 = R0 - L0;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp = (tmp1 - Alpha);
-
- // |R0 - R1| < Beta
- tmp1 = R0 - R1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Beta);
-
- //|L0 - L1| < Beta
- tmp1 = L0 - L1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Beta);
-
- if (tmp < 0)
- {
- R2 = SrcPtr[pitch<<1]; //inc2
- L2 = SrcPtr[-(pitch+(pitch<<1))]; // -inc3
-
- // |R0 - R2| < Beta
- tmp = R0 - R2;
- if (tmp < 0) tmp = -tmp;
- aq = tmp - Beta;
-
- // |L0 - L2| < Beta
- tmp = L0 - L2;
- if (tmp < 0) tmp = -tmp;
- ap = tmp - Beta;
-
-
- c0 = C0 = clipTable[Strng];
- if (ap < 0) c0++;
- if (aq < 0) c0++;
-
- //dif = IClip(-c0, c0, ((Delta << 2) + (L1 - R1) + 4) >> 3);
- dif = (((R0 - L0) << 2) + (L1 - R1) + 4) >> 3;
- tmp = dif + c0;
- if ((uint)tmp > (uint)c0 << 1)
- {
- tmp = ~(tmp >> 31);
- dif = (tmp & (c0 << 1)) - c0;
- }
-
- //SrcPtr[0] = (uint8)IClip(0, 255, R0 - dif);
- //SrcPtr[-inc] = (uint8)IClip(0, 255, L0 + dif);
- RL0 = R0 + L0;
- R0 -= dif;
- L0 += dif;
- if ((uint)R0 > 255)
- {
- tmp = ~(R0 >> 31);
- R0 = tmp & 255;
- }
- if ((uint)L0 > 255)
- {
- tmp = ~(L0 >> 31);
- L0 = tmp & 255;
- }
- SrcPtr[-pitch] = L0;
- SrcPtr[0] = R0;
-
- if (C0 != 0) /* Multiple zeros in the clip tables */
- {
- if (aq < 0) // SrcPtr[inc] += IClip(-C0, C0,(R2 + ((RL0 + 1) >> 1) - (R1<<1)) >> 1);
- {
- R2 = (R2 + ((RL0 + 1) >> 1) - (R1 << 1)) >> 1;
- tmp = R2 + C0;
- if ((uint)tmp > (uint)C0 << 1)
- {
- tmp = ~(tmp >> 31);
- R2 = (tmp & (C0 << 1)) - C0;
- }
- SrcPtr[pitch] += R2;
- }
-
- if (ap < 0) //SrcPtr[-inc2] += IClip(-C0, C0,(L2 + ((RL0 + 1) >> 1) - (L1<<1)) >> 1);
- {
- L2 = (L2 + ((RL0 + 1) >> 1) - (L1 << 1)) >> 1;
- tmp = L2 + C0;
- if ((uint)tmp > (uint)C0 << 1)
- {
- tmp = ~(tmp >> 31);
- L2 = (tmp & (C0 << 1)) - C0;
- }
- SrcPtr[-(pitch<<1)] += L2;
- }
- }
-
- } /* if(tmp < 0) */
-
- } /* end of: if((Strng = Strength[pel >> 2])) */
-
- SrcPtr ++; // Increment to next set of pixel
-
- } /* for(pel=0; pel<16; pel++) */
-
- } /* else if(Strength[0] == 4) */
-}
-
-void EdgeLoop_Luma_vertical(uint8* SrcPtr, uint8 *Strength, int Alpha, int Beta, int *clipTable, int pitch)
-{
- int pel, ap = 1, aq = 1;
- int C0, c0, dif, AbsDelta, Strng, tmp, tmp1;
- int L2 = 0, L1, L0, R0, R1, R2 = 0;
- uint8 *ptr, *ptr1;
- uint R_in, L_in;
- uint R_out, L_out;
-
-
- if (Strength[0] == 4) /* INTRA strong filtering */
- {
-
- for (pel = 0; pel < 16; pel++)
- {
-
- // Read 8 pels
- R_in = *((uint *)SrcPtr); // R_in = {R3, R2, R1, R0}
- L_in = *((uint *)(SrcPtr - 4)); // L_in = {L0, L1, L2, L3}
- R1 = (R_in >> 8) & 0xff;
- R0 = R_in & 0xff;
- L0 = L_in >> 24;
- L1 = (L_in >> 16) & 0xff;
-
- // |R0 - R1| < Beta
- tmp1 = (R_in & 0xff) - R1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp = (tmp1 - Beta);
-
-
- //|L0 - L1| < Beta
- tmp1 = (L_in >> 24) - L1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Beta);
-
- //|R0 - L0| < Alpha
- AbsDelta = (R_in & 0xff) - (L_in >> 24);
- if (AbsDelta < 0) AbsDelta = -AbsDelta;
- tmp &= (AbsDelta - Alpha);
-
- if (tmp < 0)
- {
- AbsDelta -= ((Alpha >> 2) + 2);
- R2 = (R_in >> 16) & 0xff;
- L2 = (L_in >> 8) & 0xff;
-
- // |R0 - R2| < Beta && |R0 - L0| < (Alpha/4 + 2)
- tmp1 = (R_in & 0xff) - R2;
- if (tmp1 < 0) tmp1 = -tmp1;
- aq = AbsDelta & (tmp1 - Beta);
-
- // |L0 - L2| < Beta && |R0 - L0| < (Alpha/4 + 2)
- tmp1 = (L_in >> 24) - L2;
- if (tmp1 < 0) tmp1 = -tmp1;
- ap = AbsDelta & (tmp1 - Beta);
-
-
- ptr = SrcPtr;
- if (aq < 0)
- {
- R_out = (R_in >> 24) << 24; // Keep R3 at the fourth byte
-
- tmp = R0 + L0 + R1;
- R_out |= (((tmp << 1) + L1 + R2 + 4) >> 3);
- tmp += R2;
- R_out |= (((tmp + 2) >> 2) << 8);
- tmp1 = ((R_in >> 24) + R2) << 1;
- R_out |= (((tmp1 + tmp + 4) >> 3) << 16);
-
- *((uint *)SrcPtr) = R_out;
- }
- else
- *ptr = ((R1 << 1) + R0 + L1 + 2) >> 2;
-
-
- if (ap < 0)
- {
- L_out = (L_in << 24) >> 24; // Keep L3 at the first byte
-
- tmp = R0 + L0 + L1;
- L_out |= ((((tmp << 1) + R1 + L2 + 4) >> 3) << 24);
- tmp += L2;
- L_out |= (((tmp + 2) >> 2) << 16);
- tmp1 = ((L_in & 0xff) + L2) << 1;
- L_out |= (((tmp1 + tmp + 4) >> 3) << 8);
-
- *((uint *)(SrcPtr - 4)) = L_out;
- }
- else
- *(--ptr) = ((L1 << 1) + L0 + R1 + 2) >> 2;
-
- } /* if(tmp < 0) */
-
- SrcPtr += pitch; // Increment to next set of pixel
-
- } /* end of: for(pel=0; pel<16; pel++) */
-
- } /* if(Strength[0] == 4) */
-
- else /* Normal filtering */
- {
-
- for (pel = 0; pel < 16; pel++)
- {
- Strng = Strength[pel >> 2];
- if (Strng)
- {
- // Read 8 pels
- R_in = *((uint *)SrcPtr); // R_in = {R3, R2, R1, R0}
- L_in = *((uint *)(SrcPtr - 4)); // L_in = {L0, L1, L2, L3}
- R1 = (R_in >> 8) & 0xff;
- R0 = R_in & 0xff;
- L0 = L_in >> 24;
- L1 = (L_in >> 16) & 0xff;
-
- //|R0 - L0| < Alpha
- tmp = R0 - L0;
- if (tmp < 0) tmp = -tmp;
- tmp -= Alpha;
-
- // |R0 - R1| < Beta
- tmp1 = R0 - R1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Beta);
-
- //|L0 - L1| < Beta
- tmp1 = L0 - L1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Beta);
-
- if (tmp < 0)
- {
- L2 = SrcPtr[-3];
- R2 = SrcPtr[2];
-
- // |R0 - R2| < Beta
- tmp = R0 - R2;
- if (tmp < 0) tmp = -tmp;
- aq = tmp - Beta;
-
- // |L0 - L2| < Beta
- tmp = L0 - L2;
- if (tmp < 0) tmp = -tmp;
- ap = tmp - Beta;
-
-
- c0 = C0 = clipTable[Strng];
- if (ap < 0) c0++;
- if (aq < 0) c0++;
-
- //dif = IClip(-c0, c0, ((Delta << 2) + (L1 - R1) + 4) >> 3);
- dif = (((R0 - L0) << 2) + (L1 - R1) + 4) >> 3;
- tmp = dif + c0;
- if ((uint)tmp > (uint)c0 << 1)
- {
- tmp = ~(tmp >> 31);
- dif = (tmp & (c0 << 1)) - c0;
- }
-
- ptr = SrcPtr;
- ptr1 = SrcPtr - 1;
- //SrcPtr[0] = (uint8)IClip(0, 255, R0 - dif);
- //SrcPtr[-inc] = (uint8)IClip(0, 255, L0 + dif);
- R_in = R0 - dif;
- L_in = L0 + dif; /* cannot re-use R0 and L0 here */
- if ((uint)R_in > 255)
- {
- tmp = ~((int)R_in >> 31);
- R_in = tmp & 255;
- }
- if ((uint)L_in > 255)
- {
- tmp = ~((int)L_in >> 31);
- L_in = tmp & 255;
- }
- *ptr1-- = L_in;
- *ptr++ = R_in;
-
- if (C0 != 0) // Multiple zeros in the clip tables
- {
- if (ap < 0) //SrcPtr[-inc2] += IClip(-C0, C0,(L2 + ((RL0 + 1) >> 1) - (L1<<1)) >> 1);
- {
- L2 = (L2 + ((R0 + L0 + 1) >> 1) - (L1 << 1)) >> 1;
- tmp = L2 + C0;
- if ((uint)tmp > (uint)C0 << 1)
- {
- tmp = ~(tmp >> 31);
- L2 = (tmp & (C0 << 1)) - C0;
- }
- *ptr1 += L2;
- }
-
- if (aq < 0) // SrcPtr[inc] += IClip(-C0, C0,(R2 + ((RL0 + 1) >> 1) - (R1<<1)) >> 1);
- {
- R2 = (R2 + ((R0 + L0 + 1) >> 1) - (R1 << 1)) >> 1;
- tmp = R2 + C0;
- if ((uint)tmp > (uint)C0 << 1)
- {
- tmp = ~(tmp >> 31);
- R2 = (tmp & (C0 << 1)) - C0;
- }
- *ptr += R2;
- }
- }
-
- } /* if(tmp < 0) */
-
- } /* end of: if((Strng = Strength[pel >> 2])) */
-
- SrcPtr += pitch; // Increment to next set of pixel
-
- } /* for(pel=0; pel<16; pel++) */
-
- } /* else if(Strength[0] == 4) */
-
-}
-
-void EdgeLoop_Chroma_vertical(uint8* SrcPtr, uint8 *Strength, int Alpha, int Beta, int *clipTable, int pitch)
-{
- int pel, Strng;
- int c0, dif;
- int L1, L0, R0, R1, tmp, tmp1;
- uint8 *ptr;
- uint R_in, L_in;
-
-
- for (pel = 0; pel < 16; pel++)
- {
- Strng = Strength[pel>>2];
- if (Strng)
- {
- // Read 8 pels
- R_in = *((uint *)SrcPtr); // R_in = {R3, R2, R1, R0}
- L_in = *((uint *)(SrcPtr - 4)); // L_in = {L0, L1, L2, L3}
- R1 = (R_in >> 8) & 0xff;
- R0 = R_in & 0xff;
- L0 = L_in >> 24;
- L1 = (L_in >> 16) & 0xff;
-
- // |R0 - R1| < Beta
- tmp1 = R0 - R1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp = (tmp1 - Beta);
-
- //|L0 - L1| < Beta
- tmp1 = L0 - L1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Beta);
-
- //|R0 - L0| < Alpha
- tmp1 = R0 - L0;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Alpha);
-
- if (tmp < 0)
- {
- ptr = SrcPtr;
- if (Strng == 4) /* INTRA strong filtering */
- {
- *ptr-- = ((R1 << 1) + R0 + L1 + 2) >> 2;
- *ptr = ((L1 << 1) + L0 + R1 + 2) >> 2;
- }
- else /* normal filtering */
- {
- c0 = clipTable[Strng] + 1;
- //dif = IClip(-c0, c0, ((Delta << 2) + (L1 - R1) + 4) >> 3);
- dif = (((R0 - L0) << 2) + (L1 - R1) + 4) >> 3;
- tmp = dif + c0;
- if ((uint)tmp > (uint)c0 << 1)
- {
- tmp = ~(tmp >> 31);
- dif = (tmp & (c0 << 1)) - c0;
- }
-
- //SrcPtr[0] = (uint8)IClip(0, 255, R0 - dif);
- //SrcPtr[-inc] = (uint8)IClip(0, 255, L0 + dif);
- L0 += dif;
- R0 -= dif;
- if ((uint)L0 > 255)
- {
- tmp = ~(L0 >> 31);
- L0 = tmp & 255;
- }
- if ((uint)R0 > 255)
- {
- tmp = ~(R0 >> 31);
- R0 = tmp & 255;
- }
-
- *ptr-- = R0;
- *ptr = L0;
- }
- }
- pel ++;
- SrcPtr += pitch; // Increment to next set of pixel
-
- } /* end of: if((Strng = Strength[pel >> 2])) */
- else
- {
- pel += 3;
- SrcPtr += (pitch << 1); //PtrInc << 1;
- }
-
- } /* end of: for(pel=0; pel<16; pel++) */
-}
-
-
-void EdgeLoop_Chroma_horizontal(uint8* SrcPtr, uint8 *Strength, int Alpha, int Beta, int *clipTable, int pitch)
-{
- int pel, Strng;
- int c0, dif;
- int L1, L0, R0, R1, tmp, tmp1;
-
- for (pel = 0; pel < 16; pel++)
- {
- Strng = Strength[pel>>2];
- if (Strng)
- {
- R0 = SrcPtr[0];
- L0 = SrcPtr[-pitch];
- L1 = SrcPtr[-(pitch<<1)]; //inc2
- R1 = SrcPtr[pitch];
-
- // |R0 - R1| < Beta
- tmp1 = R0 - R1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp = (tmp1 - Beta);
-
- //|L0 - L1| < Beta
- tmp1 = L0 - L1;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Beta);
-
- //|R0 - L0| < Alpha
- tmp1 = R0 - L0;
- if (tmp1 < 0) tmp1 = -tmp1;
- tmp &= (tmp1 - Alpha);
-
- if (tmp < 0)
- {
- if (Strng == 4) /* INTRA strong filtering */
- {
- SrcPtr[0] = ((R1 << 1) + R0 + L1 + 2) >> 2;
- SrcPtr[-pitch] = ((L1 << 1) + L0 + R1 + 2) >> 2;
- }
- else /* normal filtering */
- {
- c0 = clipTable[Strng] + 1;
- //dif = IClip(-c0, c0, ((Delta << 2) + (L1 - R1) + 4) >> 3);
- dif = (((R0 - L0) << 2) + (L1 - R1) + 4) >> 3;
- tmp = dif + c0;
- if ((uint)tmp > (uint)c0 << 1)
- {
- tmp = ~(tmp >> 31);
- dif = (tmp & (c0 << 1)) - c0;
- }
-
- //SrcPtr[-inc] = (uint8)IClip(0, 255, L0 + dif);
- //SrcPtr[0] = (uint8)IClip(0, 255, R0 - dif);
- L0 += dif;
- R0 -= dif;
- if ((uint)L0 > 255)
- {
- tmp = ~(L0 >> 31);
- L0 = tmp & 255;
- }
- if ((uint)R0 > 255)
- {
- tmp = ~(R0 >> 31);
- R0 = tmp & 255;
- }
- SrcPtr[0] = R0;
- SrcPtr[-pitch] = L0;
- }
- }
-
- pel ++;
- SrcPtr ++; // Increment to next set of pixel
-
- } /* end of: if((Strng = Strength[pel >> 2])) */
- else
- {
- pel += 3;
- SrcPtr += 2;
- }
-
- } /* end of: for(pel=0; pel<16; pel++) */
-}
-
-
-
-
diff --git a/media/libstagefright/codecs/avc/common/src/dpb.cpp b/media/libstagefright/codecs/avc/common/src/dpb.cpp
deleted file mode 100644
index b5d0dfe..0000000
--- a/media/libstagefright/codecs/avc/common/src/dpb.cpp
+++ /dev/null
@@ -1,724 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avclib_common.h"
-
-#define DPB_MEM_ATTR 0
-
-AVCStatus InitDPB(AVCHandle *avcHandle, AVCCommonObj *video, int FrameHeightInMbs, int PicWidthInMbs, bool padding)
-{
- AVCDecPicBuffer *dpb = video->decPicBuf;
- int level, framesize, num_fs;
- void *userData = avcHandle->userData;
-#ifndef PV_MEMORY_POOL
- uint32 addr;
-#endif
- uint16 refIdx = 0;
- level = video->currSeqParams->level_idc;
-
- for (num_fs = 0; num_fs < MAX_FS; num_fs++)
- {
- dpb->fs[num_fs] = NULL;
- }
-
- framesize = (int)(((FrameHeightInMbs * PicWidthInMbs) << 7) * 3);
- if (padding)
- {
- video->padded_size = (int)((((FrameHeightInMbs + 2) * (PicWidthInMbs + 2)) << 7) * 3) - framesize;
- }
- else
- {
- video->padded_size = 0;
- }
-
-#ifndef PV_MEMORY_POOL
- if (dpb->decoded_picture_buffer)
- {
- avcHandle->CBAVC_Free(userData, (int)dpb->decoded_picture_buffer);
- dpb->decoded_picture_buffer = NULL;
- }
-#endif
- /* need to allocate one extra frame for current frame, DPB only defines for reference frames */
-
- dpb->num_fs = (uint32)(MaxDPBX2[mapLev2Idx[level]] << 2) / (3 * FrameHeightInMbs * PicWidthInMbs) + 1;
- if (dpb->num_fs > MAX_FS)
- {
- dpb->num_fs = MAX_FS;
- }
-
- if (video->currSeqParams->num_ref_frames + 1 > (uint32)dpb->num_fs)
- {
- dpb->num_fs = video->currSeqParams->num_ref_frames + 1;
- }
-
- dpb->dpb_size = dpb->num_fs * (framesize + video->padded_size);
-// dpb->dpb_size = (uint32)MaxDPBX2[mapLev2Idx[level]]*512 + framesize;
-
-#ifndef PV_MEMORY_POOL
- dpb->decoded_picture_buffer = (uint8*) avcHandle->CBAVC_Malloc(userData, dpb->dpb_size, 100/*DPB_MEM_ATTR*/);
-
- if (dpb->decoded_picture_buffer == NULL || dpb->decoded_picture_buffer&0x3) // not word aligned
- return AVC_MEMORY_FAIL;
-#endif
- dpb->used_size = 0;
- num_fs = 0;
-
- while (num_fs < dpb->num_fs)
- {
- /* fs is an array pointers to AVCDecPicture */
- dpb->fs[num_fs] = (AVCFrameStore*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCFrameStore), 101/*DEFAULT_ATTR*/);
- if (dpb->fs[num_fs] == NULL)
- {
- return AVC_MEMORY_FAIL;
- }
-#ifndef PV_MEMORY_POOL
- /* assign the actual memory for Sl, Scb, Scr */
- dpb->fs[num_fs]->base_dpb = dpb->decoded_picture_buffer + dpb->used_size;
-#endif
- dpb->fs[num_fs]->IsReference = 0;
- dpb->fs[num_fs]->IsLongTerm = 0;
- dpb->fs[num_fs]->IsOutputted = 3;
- dpb->fs[num_fs]->frame.RefIdx = refIdx++; /* this value will remain unchanged through out the encoding session */
- dpb->fs[num_fs]->frame.picType = AVC_FRAME;
- dpb->fs[num_fs]->frame.isLongTerm = 0;
- dpb->fs[num_fs]->frame.isReference = 0;
- video->RefPicList0[num_fs] = &(dpb->fs[num_fs]->frame);
- dpb->fs[num_fs]->frame.padded = 0;
- dpb->used_size += (framesize + video->padded_size);
- num_fs++;
- }
-
- return AVC_SUCCESS;
-}
-
-OSCL_EXPORT_REF AVCStatus AVCConfigureSequence(AVCHandle *avcHandle, AVCCommonObj *video, bool padding)
-{
- void *userData = avcHandle->userData;
- AVCDecPicBuffer *dpb = video->decPicBuf;
- int framesize, ii; /* size of one frame */
- uint PicWidthInMbs, PicHeightInMapUnits, FrameHeightInMbs, PicSizeInMapUnits;
- uint num_fs;
- /* derived variables from SPS */
- PicWidthInMbs = video->currSeqParams->pic_width_in_mbs_minus1 + 1;
- PicHeightInMapUnits = video->currSeqParams->pic_height_in_map_units_minus1 + 1 ;
- FrameHeightInMbs = (2 - video->currSeqParams->frame_mbs_only_flag) * PicHeightInMapUnits ;
- PicSizeInMapUnits = PicWidthInMbs * PicHeightInMapUnits ;
-
- if (video->PicSizeInMapUnits != PicSizeInMapUnits || video->currSeqParams->level_idc != video->level_idc)
- {
- /* make sure you mark all the frames as unused for reference for flushing*/
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- dpb->fs[ii]->IsReference = 0;
- dpb->fs[ii]->IsOutputted |= 0x02;
- }
-
- num_fs = (uint32)(MaxDPBX2[(uint32)mapLev2Idx[video->currSeqParams->level_idc]] << 2) / (3 * PicSizeInMapUnits) + 1;
- if (num_fs >= MAX_FS)
- {
- num_fs = MAX_FS;
- }
-#ifdef PV_MEMORY_POOL
- if (padding)
- {
- avcHandle->CBAVC_DPBAlloc(avcHandle->userData,
- PicSizeInMapUnits + ((PicWidthInMbs + 2) << 1) + (PicHeightInMapUnits << 1), num_fs);
- }
- else
- {
- avcHandle->CBAVC_DPBAlloc(avcHandle->userData, PicSizeInMapUnits, num_fs);
- }
-#endif
- CleanUpDPB(avcHandle, video);
- if (InitDPB(avcHandle, video, FrameHeightInMbs, PicWidthInMbs, padding) != AVC_SUCCESS)
- {
- return AVC_FAIL;
- }
- /* Allocate video->mblock upto PicSizeInMbs and populate the structure such as the neighboring MB pointers. */
- framesize = (FrameHeightInMbs * PicWidthInMbs);
- if (video->mblock)
- {
- avcHandle->CBAVC_Free(userData, video->mblock);
- video->mblock = NULL;
- }
- video->mblock = (AVCMacroblock*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCMacroblock) * framesize, DEFAULT_ATTR);
- if (video->mblock == NULL)
- {
- return AVC_FAIL;
- }
- for (ii = 0; ii < framesize; ii++)
- {
- video->mblock[ii].slice_id = -1;
- }
- /* Allocate memory for intra prediction */
-#ifdef MB_BASED_DEBLOCK
- video->intra_pred_top = (uint8*) avcHandle->CBAVC_Malloc(userData, PicWidthInMbs << 4, FAST_MEM_ATTR);
- if (video->intra_pred_top == NULL)
- {
- return AVC_FAIL;
- }
- video->intra_pred_top_cb = (uint8*) avcHandle->CBAVC_Malloc(userData, PicWidthInMbs << 3, FAST_MEM_ATTR);
- if (video->intra_pred_top_cb == NULL)
- {
- return AVC_FAIL;
- }
- video->intra_pred_top_cr = (uint8*) avcHandle->CBAVC_Malloc(userData, PicWidthInMbs << 3, FAST_MEM_ATTR);
- if (video->intra_pred_top_cr == NULL)
- {
- return AVC_FAIL;
- }
-
-#endif
- /* Allocate slice group MAP map */
-
- if (video->MbToSliceGroupMap)
- {
- avcHandle->CBAVC_Free(userData, video->MbToSliceGroupMap);
- video->MbToSliceGroupMap = NULL;
- }
- video->MbToSliceGroupMap = (int*) avcHandle->CBAVC_Malloc(userData, sizeof(uint) * PicSizeInMapUnits * 2, 7/*DEFAULT_ATTR*/);
- if (video->MbToSliceGroupMap == NULL)
- {
- return AVC_FAIL;
- }
- video->PicSizeInMapUnits = PicSizeInMapUnits;
- video->level_idc = video->currSeqParams->level_idc;
-
- }
- return AVC_SUCCESS;
-}
-
-OSCL_EXPORT_REF AVCStatus CleanUpDPB(AVCHandle *avcHandle, AVCCommonObj *video)
-{
- AVCDecPicBuffer *dpb = video->decPicBuf;
- int ii;
- void *userData = avcHandle->userData;
-
- for (ii = 0; ii < MAX_FS; ii++)
- {
- if (dpb->fs[ii] != NULL)
- {
- avcHandle->CBAVC_Free(userData, dpb->fs[ii]);
- dpb->fs[ii] = NULL;
- }
- }
-#ifndef PV_MEMORY_POOL
- if (dpb->decoded_picture_buffer)
- {
- avcHandle->CBAVC_Free(userData, dpb->decoded_picture_buffer);
- dpb->decoded_picture_buffer = NULL;
- }
-#endif
- dpb->used_size = 0;
- dpb->dpb_size = 0;
-
- return AVC_SUCCESS;
-}
-
-OSCL_EXPORT_REF AVCStatus DPBInitBuffer(AVCHandle *avcHandle, AVCCommonObj *video)
-{
- AVCDecPicBuffer *dpb = video->decPicBuf;
- int ii, status;
-
- /* Before doing any decoding, check if there's a frame memory available */
- /* look for next unused dpb->fs, or complementary field pair */
- /* video->currPic is assigned to this */
-
- /* There's also restriction on the frame_num, see page 59 of JVT-I1010.doc. */
-
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- /* looking for the one not used or not reference and has been outputted */
- if (dpb->fs[ii]->IsReference == 0 && dpb->fs[ii]->IsOutputted == 3)
- {
- video->currFS = dpb->fs[ii];
-#ifdef PV_MEMORY_POOL
- status = avcHandle->CBAVC_FrameBind(avcHandle->userData, ii, &(video->currFS->base_dpb));
- if (status == AVC_FAIL)
- {
- return AVC_NO_BUFFER; /* this should not happen */
- }
-#endif
- break;
- }
- }
- if (ii == dpb->num_fs)
- {
- return AVC_PICTURE_OUTPUT_READY; /* no empty frame available */
- }
- return AVC_SUCCESS;
-}
-
-OSCL_EXPORT_REF void DPBInitPic(AVCCommonObj *video, int CurrPicNum)
-{
- int offset = 0;
- int offsetc = 0;
- int luma_framesize;
- /* this part has to be set here, assuming that slice header and POC have been decoded. */
- /* used in GetOutput API */
- video->currFS->PicOrderCnt = video->PicOrderCnt;
- video->currFS->FrameNum = video->sliceHdr->frame_num;
- video->currFS->FrameNumWrap = CurrPicNum; // MC_FIX
- /* initialize everything to zero */
- video->currFS->IsOutputted = 0;
- video->currFS->IsReference = 0;
- video->currFS->IsLongTerm = 0;
- video->currFS->frame.isReference = FALSE;
- video->currFS->frame.isLongTerm = FALSE;
-
- /* initialize the pixel pointer to NULL */
- video->currFS->frame.Sl = video->currFS->frame.Scb = video->currFS->frame.Scr = NULL;
-
- /* determine video->currPic */
- /* assign dbp->base_dpb to fs[i]->frame.Sl, Scb, Scr .*/
- /* For PicSizeInMbs, see DecodeSliceHeader() */
-
- video->currPic = &(video->currFS->frame);
-
- video->currPic->padded = 0; // reset this flag to not-padded
-
- if (video->padded_size)
- {
- offset = ((video->PicWidthInSamplesL + 32) << 4) + 16; // offset to the origin
- offsetc = (offset >> 2) + 4;
- luma_framesize = (int)((((video->FrameHeightInMbs + 2) * (video->PicWidthInMbs + 2)) << 8));
- }
- else
- luma_framesize = video->PicSizeInMbs << 8;
-
-
- video->currPic->Sl = video->currFS->base_dpb + offset;
- video->currPic->Scb = video->currFS->base_dpb + luma_framesize + offsetc;
- video->currPic->Scr = video->currPic->Scb + (luma_framesize >> 2);
- video->currPic->pitch = video->PicWidthInSamplesL + (video->padded_size == 0 ? 0 : 32);
-
-
- video->currPic->height = video->PicHeightInSamplesL;
- video->currPic->width = video->PicWidthInSamplesL;
- video->currPic->PicNum = CurrPicNum;
-}
-
-/* to release skipped frame after encoding */
-OSCL_EXPORT_REF void DPBReleaseCurrentFrame(AVCHandle *avcHandle, AVCCommonObj *video)
-{
- AVCDecPicBuffer *dpb = video->decPicBuf;
- int ii;
-
- video->currFS->IsOutputted = 3; // return this buffer.
-
-#ifdef PV_MEMORY_POOL /* for non-memory pool, no need to do anything */
-
- /* search for current frame index */
- ii = dpb->num_fs;
- while (ii--)
- {
- if (dpb->fs[ii] == video->currFS)
- {
- avcHandle->CBAVC_FrameUnbind(avcHandle->userData, ii);
- break;
- }
- }
-#endif
-
- return ;
-}
-
-/* see subclause 8.2.5.1 */
-OSCL_EXPORT_REF AVCStatus StorePictureInDPB(AVCHandle *avcHandle, AVCCommonObj *video)
-{
- AVCStatus status;
- AVCDecPicBuffer *dpb = video->decPicBuf;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- int ii, num_ref;
-
- /* number 1 of 8.2.5.1, we handle gaps in frame_num differently without using the memory */
- /* to be done!!!! */
-
- /* number 3 of 8.2.5.1 */
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii] != video->currFS) /* not current frame */
- {
- dpb->fs[ii]->IsReference = 0; /* mark as unused for reference */
- dpb->fs[ii]->IsLongTerm = 0; /* but still used until output */
- dpb->fs[ii]->IsOutputted |= 0x02;
-#ifdef PV_MEMORY_POOL
- if (dpb->fs[ii]->IsOutputted == 3)
- {
- avcHandle->CBAVC_FrameUnbind(avcHandle->userData, ii);
- }
-#endif
- }
- }
-
- video->currPic->isReference = TRUE;
- video->currFS->IsReference = 3;
-
- if (sliceHdr->long_term_reference_flag == 0)
- {
- video->currPic->isLongTerm = FALSE;
- video->currFS->IsLongTerm = 0;
- video->MaxLongTermFrameIdx = -1;
- }
- else
- {
- video->currPic->isLongTerm = TRUE;
- video->currFS->IsLongTerm = 3;
- video->currFS->LongTermFrameIdx = 0;
- video->MaxLongTermFrameIdx = 0;
- }
- if (sliceHdr->no_output_of_prior_pics_flag)
- {
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii] != video->currFS) /* not current frame */
- {
- dpb->fs[ii]->IsOutputted = 3;
-#ifdef PV_MEMORY_POOL
- avcHandle->CBAVC_FrameUnbind(avcHandle->userData, ii);
-#endif
- }
- }
- }
- video->mem_mgr_ctrl_eq_5 = TRUE; /* flush reference frames MC_FIX */
- }
- else
- {
- if (video->currPic->isReference == TRUE)
- {
- if (sliceHdr->adaptive_ref_pic_marking_mode_flag == 0)
- {
- status = sliding_window_process(avcHandle, video, dpb); /* we may have to do this after adaptive_memory_marking */
- }
- else
- {
- status = adaptive_memory_marking(avcHandle, video, dpb, sliceHdr);
- }
- if (status != AVC_SUCCESS)
- {
- return status;
- }
- }
- }
- /* number 4 of 8.2.5.1 */
- /* This basically says every frame must be at least used for short-term ref. */
- /* Need to be revisited!!! */
- /* look at insert_picture_in_dpb() */
-
-
-
- if (video->nal_unit_type != AVC_NALTYPE_IDR && video->currPic->isLongTerm == FALSE)
- {
- if (video->currPic->isReference)
- {
- video->currFS->IsReference = 3;
- }
- else
- {
- video->currFS->IsReference = 0;
- }
- video->currFS->IsLongTerm = 0;
- }
-
- /* check if number of reference frames doesn't exceed num_ref_frames */
- num_ref = 0;
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii]->IsReference)
- {
- num_ref++;
- }
- }
-
- if (num_ref > (int)video->currSeqParams->num_ref_frames)
- {
- return AVC_FAIL; /* out of range */
- }
-
- return AVC_SUCCESS;
-}
-
-
-AVCStatus sliding_window_process(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb)
-{
- int ii, numShortTerm, numLongTerm;
- int32 MinFrameNumWrap;
- int MinIdx;
-
-
- numShortTerm = 0;
- numLongTerm = 0;
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii] != video->currFS) /* do not count the current frame */
- {
- if (dpb->fs[ii]->IsLongTerm)
- {
- numLongTerm++;
- }
- else if (dpb->fs[ii]->IsReference)
- {
- numShortTerm++;
- }
- }
- }
-
- while (numShortTerm + numLongTerm >= (int)video->currSeqParams->num_ref_frames)
- {
- /* get short-term ref frame with smallest PicOrderCnt */
- /* this doesn't work for all I-slice clip since PicOrderCnt will not be initialized */
-
- MinFrameNumWrap = 0x7FFFFFFF;
- MinIdx = -1;
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii]->IsReference && !dpb->fs[ii]->IsLongTerm)
- {
- if (dpb->fs[ii]->FrameNumWrap < MinFrameNumWrap)
- {
- MinFrameNumWrap = dpb->fs[ii]->FrameNumWrap;
- MinIdx = ii;
- }
- }
- }
- if (MinIdx < 0) /* something wrong, impossible */
- {
- return AVC_FAIL;
- }
-
- /* mark the frame with smallest PicOrderCnt to be unused for reference */
- dpb->fs[MinIdx]->IsReference = 0;
- dpb->fs[MinIdx]->IsLongTerm = 0;
- dpb->fs[MinIdx]->frame.isReference = FALSE;
- dpb->fs[MinIdx]->frame.isLongTerm = FALSE;
- dpb->fs[MinIdx]->IsOutputted |= 0x02;
-#ifdef PV_MEMORY_POOL
- if (dpb->fs[MinIdx]->IsOutputted == 3)
- {
- avcHandle->CBAVC_FrameUnbind(avcHandle->userData, MinIdx);
- }
-#endif
- numShortTerm--;
- }
- return AVC_SUCCESS;
-}
-
-/* see subclause 8.2.5.4 */
-AVCStatus adaptive_memory_marking(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, AVCSliceHeader *sliceHdr)
-{
- int ii;
-
- ii = 0;
- while (ii < MAX_DEC_REF_PIC_MARKING && sliceHdr->memory_management_control_operation[ii] != 0)
- {
- switch (sliceHdr->memory_management_control_operation[ii])
- {
- case 1:
- MemMgrCtrlOp1(avcHandle, video, dpb, sliceHdr->difference_of_pic_nums_minus1[ii]);
- // update_ref_list(dpb);
- break;
- case 2:
- MemMgrCtrlOp2(avcHandle, dpb, sliceHdr->long_term_pic_num[ii]);
- break;
- case 3:
- MemMgrCtrlOp3(avcHandle, video, dpb, sliceHdr->difference_of_pic_nums_minus1[ii], sliceHdr->long_term_frame_idx[ii]);
- break;
- case 4:
- MemMgrCtrlOp4(avcHandle, video, dpb, sliceHdr->max_long_term_frame_idx_plus1[ii]);
- break;
- case 5:
- MemMgrCtrlOp5(avcHandle, video, dpb);
- video->currFS->FrameNum = 0; //
- video->currFS->PicOrderCnt = 0;
- break;
- case 6:
- MemMgrCtrlOp6(avcHandle, video, dpb, sliceHdr->long_term_frame_idx[ii]);
- break;
- }
- ii++;
- }
-
- if (ii == MAX_DEC_REF_PIC_MARKING)
- {
- return AVC_FAIL; /* exceed the limit */
- }
-
- return AVC_SUCCESS;
-}
-
-
-/* see subclause 8.2.5.4.1, mark short-term picture as "unused for reference" */
-void MemMgrCtrlOp1(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, int difference_of_pic_nums_minus1)
-{
- int picNumX, ii;
-
- picNumX = video->CurrPicNum - (difference_of_pic_nums_minus1 + 1);
-
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii]->IsReference == 3 && dpb->fs[ii]->IsLongTerm == 0)
- {
- if (dpb->fs[ii]->frame.PicNum == picNumX)
- {
- unmark_for_reference(avcHandle, dpb, ii);
- return ;
- }
- }
- }
-
- return ;
-}
-
-/* see subclause 8.2.5.4.2 mark long-term picture as "unused for reference" */
-void MemMgrCtrlOp2(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, int long_term_pic_num)
-{
- int ii;
-
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii]->IsLongTerm == 3)
- {
- if (dpb->fs[ii]->frame.LongTermPicNum == long_term_pic_num)
- {
- unmark_for_reference(avcHandle, dpb, ii);
- }
- }
- }
-}
-
-/* see subclause 8.2.5.4.3 assign LongTermFrameIdx to a short-term ref picture */
-void MemMgrCtrlOp3(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint difference_of_pic_nums_minus1,
- uint long_term_frame_idx)
-{
- int picNumX, ii;
-
- picNumX = video->CurrPicNum - (difference_of_pic_nums_minus1 + 1);
-
- /* look for fs[i] with long_term_frame_idx */
-
- unmark_long_term_frame_for_reference_by_frame_idx(avcHandle, dpb, long_term_frame_idx);
-
-
- /* now mark the picture with picNumX to long term frame idx */
-
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii]->IsReference == 3)
- {
- if ((dpb->fs[ii]->frame.isLongTerm == FALSE) && (dpb->fs[ii]->frame.PicNum == picNumX))
- {
- dpb->fs[ii]->LongTermFrameIdx = long_term_frame_idx;
- dpb->fs[ii]->frame.LongTermPicNum = long_term_frame_idx;
-
- dpb->fs[ii]->frame.isLongTerm = TRUE;
-
- dpb->fs[ii]->IsLongTerm = 3;
- return;
- }
- }
- }
-
-}
-
-/* see subclause 8.2.5.4.4, MaxLongTermFrameIdx */
-void MemMgrCtrlOp4(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint max_long_term_frame_idx_plus1)
-{
- int ii;
-
- video->MaxLongTermFrameIdx = max_long_term_frame_idx_plus1 - 1;
-
- /* then mark long term frame with exceeding LongTermFrameIdx to unused for reference. */
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
- if (dpb->fs[ii]->IsLongTerm && dpb->fs[ii] != video->currFS)
- {
- if (dpb->fs[ii]->LongTermFrameIdx > video->MaxLongTermFrameIdx)
- {
- unmark_for_reference(avcHandle, dpb, ii);
- }
- }
- }
-}
-
-/* see subclause 8.2.5.4.5 mark all reference picture as "unused for reference" and setting
-MaxLongTermFrameIdx to "no long-term frame indices" */
-void MemMgrCtrlOp5(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb)
-{
- int ii;
-
- video->MaxLongTermFrameIdx = -1;
- for (ii = 0; ii < dpb->num_fs; ii++) /* including the current frame ??????*/
- {
- if (dpb->fs[ii] != video->currFS) // MC_FIX
- {
- unmark_for_reference(avcHandle, dpb, ii);
- }
- }
-
- video->mem_mgr_ctrl_eq_5 = TRUE;
-}
-
-/* see subclause 8.2.5.4.6 assing long-term frame index to the current picture */
-void MemMgrCtrlOp6(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint long_term_frame_idx)
-{
-
- unmark_long_term_frame_for_reference_by_frame_idx(avcHandle, dpb, long_term_frame_idx);
- video->currFS->IsLongTerm = 3;
- video->currFS->IsReference = 3;
-
- video->currPic->isLongTerm = TRUE;
- video->currPic->isReference = TRUE;
- video->currFS->LongTermFrameIdx = long_term_frame_idx;
-}
-
-
-void unmark_for_reference(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, uint idx)
-{
-
- AVCFrameStore *fs = dpb->fs[idx];
- fs->frame.isReference = FALSE;
- fs->frame.isLongTerm = FALSE;
-
- fs->IsLongTerm = 0;
- fs->IsReference = 0;
- fs->IsOutputted |= 0x02;
-#ifdef PV_MEMORY_POOL
- if (fs->IsOutputted == 3)
- {
- avcHandle->CBAVC_FrameUnbind(avcHandle->userData, idx);
- }
-#endif
- return ;
-}
-
-void unmark_long_term_frame_for_reference_by_frame_idx(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, uint long_term_frame_idx)
-{
- int ii;
- for (ii = 0; ii < dpb->num_fs; ii++)
- {
-
- if (dpb->fs[ii]->IsLongTerm && (dpb->fs[ii]->LongTermFrameIdx == (int)long_term_frame_idx))
- {
- unmark_for_reference(avcHandle, dpb, ii);
- }
-
- }
-}
-
-
diff --git a/media/libstagefright/codecs/avc/common/src/fmo.cpp b/media/libstagefright/codecs/avc/common/src/fmo.cpp
deleted file mode 100644
index d66eba3..0000000
--- a/media/libstagefright/codecs/avc/common/src/fmo.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include <string.h>
-
-#include "avclib_common.h"
-
-/* see subclause 8.2.2 Decoding process for macroblock to slice group map */
-OSCL_EXPORT_REF AVCStatus FMOInit(AVCCommonObj *video)
-{
- AVCPicParamSet *currPPS = video->currPicParams;
- int *MbToSliceGroupMap = video->MbToSliceGroupMap;
- int PicSizeInMapUnits = video->PicSizeInMapUnits;
- int PicWidthInMbs = video->PicWidthInMbs;
-
- if (currPPS->num_slice_groups_minus1 == 0)
- {
- memset(video->MbToSliceGroupMap, 0, video->PicSizeInMapUnits*sizeof(uint));
- }
- else
- {
- switch (currPPS->slice_group_map_type)
- {
- case 0:
- FmoGenerateType0MapUnitMap(MbToSliceGroupMap, currPPS->run_length_minus1, currPPS->num_slice_groups_minus1, PicSizeInMapUnits);
- break;
- case 1:
- FmoGenerateType1MapUnitMap(MbToSliceGroupMap, PicWidthInMbs, currPPS->num_slice_groups_minus1, PicSizeInMapUnits);
- break;
- case 2:
- FmoGenerateType2MapUnitMap(currPPS, MbToSliceGroupMap, PicWidthInMbs, currPPS->num_slice_groups_minus1, PicSizeInMapUnits);
- break;
- case 3:
- FmoGenerateType3MapUnitMap(video, currPPS, MbToSliceGroupMap, PicWidthInMbs);
- break;
- case 4:
- FmoGenerateType4MapUnitMap(MbToSliceGroupMap, video->MapUnitsInSliceGroup0, currPPS->slice_group_change_direction_flag, PicSizeInMapUnits);
- break;
- case 5:
- FmoGenerateType5MapUnitMap(MbToSliceGroupMap, video, currPPS->slice_group_change_direction_flag, PicSizeInMapUnits);
- break;
- case 6:
- FmoGenerateType6MapUnitMap(MbToSliceGroupMap, (int*)currPPS->slice_group_id, PicSizeInMapUnits);
- break;
- default:
- return AVC_FAIL; /* out of range, shouldn't come this far */
- }
- }
-
- return AVC_SUCCESS;
-}
-
-/* see subclause 8.2.2.1 interleaved slice group map type*/
-void FmoGenerateType0MapUnitMap(int *mapUnitToSliceGroupMap, uint *run_length_minus1, uint num_slice_groups_minus1, uint PicSizeInMapUnits)
-{
- uint iGroup, j;
- uint i = 0;
- do
- {
- for (iGroup = 0;
- (iGroup <= num_slice_groups_minus1) && (i < PicSizeInMapUnits);
- i += run_length_minus1[iGroup++] + 1)
- {
- for (j = 0; j <= run_length_minus1[ iGroup ] && i + j < PicSizeInMapUnits; j++)
- mapUnitToSliceGroupMap[i+j] = iGroup;
- }
- }
- while (i < PicSizeInMapUnits);
-}
-
-/* see subclause 8.2.2.2 dispersed slice group map type*/
-void FmoGenerateType1MapUnitMap(int *mapUnitToSliceGroupMap, int PicWidthInMbs, uint num_slice_groups_minus1, uint PicSizeInMapUnits)
-{
- uint i;
- for (i = 0; i < PicSizeInMapUnits; i++)
- {
- mapUnitToSliceGroupMap[i] = ((i % PicWidthInMbs) + (((i / PicWidthInMbs) * (num_slice_groups_minus1 + 1)) / 2))
- % (num_slice_groups_minus1 + 1);
- }
-}
-
-/* see subclause 8.2.2.3 foreground with left-over slice group map type */
-void FmoGenerateType2MapUnitMap(AVCPicParamSet *pps, int *mapUnitToSliceGroupMap, int PicWidthInMbs,
- uint num_slice_groups_minus1, uint PicSizeInMapUnits)
-{
- int iGroup;
- uint i, x, y;
- uint yTopLeft, xTopLeft, yBottomRight, xBottomRight;
-
- for (i = 0; i < PicSizeInMapUnits; i++)
- {
- mapUnitToSliceGroupMap[ i ] = num_slice_groups_minus1;
- }
-
- for (iGroup = num_slice_groups_minus1 - 1 ; iGroup >= 0; iGroup--)
- {
- yTopLeft = pps->top_left[ iGroup ] / PicWidthInMbs;
- xTopLeft = pps->top_left[ iGroup ] % PicWidthInMbs;
- yBottomRight = pps->bottom_right[ iGroup ] / PicWidthInMbs;
- xBottomRight = pps->bottom_right[ iGroup ] % PicWidthInMbs;
- for (y = yTopLeft; y <= yBottomRight; y++)
- {
- for (x = xTopLeft; x <= xBottomRight; x++)
- {
- mapUnitToSliceGroupMap[ y * PicWidthInMbs + x ] = iGroup;
- }
- }
- }
-}
-
-
-/* see subclause 8.2.2.4 box-out slice group map type */
-/* follow the text rather than the JM, it's quite different. */
-void FmoGenerateType3MapUnitMap(AVCCommonObj *video, AVCPicParamSet* pps, int *mapUnitToSliceGroupMap,
- int PicWidthInMbs)
-{
- uint i, k;
- int leftBound, topBound, rightBound, bottomBound;
- int x, y, xDir, yDir;
- int mapUnitVacant;
- uint PicSizeInMapUnits = video->PicSizeInMapUnits;
- uint MapUnitsInSliceGroup0 = video->MapUnitsInSliceGroup0;
-
- for (i = 0; i < PicSizeInMapUnits; i++)
- {
- mapUnitToSliceGroupMap[ i ] = 1;
- }
-
- x = (PicWidthInMbs - pps->slice_group_change_direction_flag) / 2;
- y = (video->PicHeightInMapUnits - pps->slice_group_change_direction_flag) / 2;
-
- leftBound = x;
- topBound = y;
- rightBound = x;
- bottomBound = y;
-
- xDir = pps->slice_group_change_direction_flag - 1;
- yDir = pps->slice_group_change_direction_flag;
-
- for (k = 0; k < MapUnitsInSliceGroup0; k += mapUnitVacant)
- {
- mapUnitVacant = (mapUnitToSliceGroupMap[ y * PicWidthInMbs + x ] == 1);
- if (mapUnitVacant)
- {
- mapUnitToSliceGroupMap[ y * PicWidthInMbs + x ] = 0;
- }
-
- if (xDir == -1 && x == leftBound)
- {
- leftBound = AVC_MAX(leftBound - 1, 0);
- x = leftBound;
- xDir = 0;
- yDir = 2 * pps->slice_group_change_direction_flag - 1;
- }
- else if (xDir == 1 && x == rightBound)
- {
- rightBound = AVC_MIN(rightBound + 1, (int)PicWidthInMbs - 1);
- x = rightBound;
- xDir = 0;
- yDir = 1 - 2 * pps->slice_group_change_direction_flag;
- }
- else if (yDir == -1 && y == topBound)
- {
- topBound = AVC_MAX(topBound - 1, 0);
- y = topBound;
- xDir = 1 - 2 * pps->slice_group_change_direction_flag;
- yDir = 0;
- }
- else if (yDir == 1 && y == bottomBound)
- {
- bottomBound = AVC_MIN(bottomBound + 1, (int)video->PicHeightInMapUnits - 1);
- y = bottomBound;
- xDir = 2 * pps->slice_group_change_direction_flag - 1;
- yDir = 0;
- }
- else
- {
- x = x + xDir;
- y = y + yDir;
- }
- }
-}
-
-/* see subclause 8.2.2.5 raster scan slice group map types */
-void FmoGenerateType4MapUnitMap(int *mapUnitToSliceGroupMap, int MapUnitsInSliceGroup0, int slice_group_change_direction_flag, uint PicSizeInMapUnits)
-{
- uint sizeOfUpperLeftGroup = slice_group_change_direction_flag ? (PicSizeInMapUnits - MapUnitsInSliceGroup0) : MapUnitsInSliceGroup0;
-
- uint i;
-
- for (i = 0; i < PicSizeInMapUnits; i++)
- if (i < sizeOfUpperLeftGroup)
- mapUnitToSliceGroupMap[ i ] = 1 - slice_group_change_direction_flag;
- else
- mapUnitToSliceGroupMap[ i ] = slice_group_change_direction_flag;
-
-}
-
-/* see subclause 8.2.2.6, wipe slice group map type. */
-void FmoGenerateType5MapUnitMap(int *mapUnitToSliceGroupMap, AVCCommonObj *video,
- int slice_group_change_direction_flag, uint PicSizeInMapUnits)
-{
- int PicWidthInMbs = video->PicWidthInMbs;
- int PicHeightInMapUnits = video->PicHeightInMapUnits;
- int MapUnitsInSliceGroup0 = video->MapUnitsInSliceGroup0;
- int sizeOfUpperLeftGroup = slice_group_change_direction_flag ? (PicSizeInMapUnits - MapUnitsInSliceGroup0) : MapUnitsInSliceGroup0;
- int i, j, k = 0;
-
- for (j = 0; j < PicWidthInMbs; j++)
- {
- for (i = 0; i < PicHeightInMapUnits; i++)
- {
- if (k++ < sizeOfUpperLeftGroup)
- {
- mapUnitToSliceGroupMap[ i * PicWidthInMbs + j ] = 1 - slice_group_change_direction_flag;
- }
- else
- {
- mapUnitToSliceGroupMap[ i * PicWidthInMbs + j ] = slice_group_change_direction_flag;
- }
- }
- }
-}
-
-/* see subclause 8.2.2.7, explicit slice group map */
-void FmoGenerateType6MapUnitMap(int *mapUnitToSliceGroupMap, int *slice_group_id, uint PicSizeInMapUnits)
-{
- uint i;
- for (i = 0; i < PicSizeInMapUnits; i++)
- {
- mapUnitToSliceGroupMap[i] = slice_group_id[i];
- }
-}
-
-
diff --git a/media/libstagefright/codecs/avc/common/src/mb_access.cpp b/media/libstagefright/codecs/avc/common/src/mb_access.cpp
deleted file mode 100644
index 414b8f7..0000000
--- a/media/libstagefright/codecs/avc/common/src/mb_access.cpp
+++ /dev/null
@@ -1,471 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include <string.h>
-
-#include "avclib_common.h"
-
-OSCL_EXPORT_REF void InitNeighborAvailability(AVCCommonObj *video, int mbNum)
-{
- int PicWidthInMbs = video->PicWidthInMbs;
-
- // do frame-only and postpone intraAvail calculattion
- video->mbAddrA = mbNum - 1;
- video->mbAddrB = mbNum - PicWidthInMbs;
- video->mbAddrC = mbNum - PicWidthInMbs + 1;
- video->mbAddrD = mbNum - PicWidthInMbs - 1;
-
- video->mbAvailA = video->mbAvailB = video->mbAvailC = video->mbAvailD = 0;
- if (video->mb_x)
- {
- video->mbAvailA = (video->mblock[video->mbAddrA].slice_id == video->currMB->slice_id);
- if (video->mb_y)
- {
- video->mbAvailD = (video->mblock[video->mbAddrD].slice_id == video->currMB->slice_id);
- }
- }
-
- if (video->mb_y)
- {
- video->mbAvailB = (video->mblock[video->mbAddrB].slice_id == video->currMB->slice_id);
- if (video->mb_x < (PicWidthInMbs - 1))
- {
- video->mbAvailC = (video->mblock[video->mbAddrC].slice_id == video->currMB->slice_id);
- }
- }
- return ;
-}
-
-bool mb_is_available(AVCMacroblock *mblock, uint PicSizeInMbs, int mbAddr, int currMbAddr)
-{
- if (mbAddr < 0 || mbAddr >= (int)PicSizeInMbs)
- {
- return FALSE;
- }
-
- if (mblock[mbAddr].slice_id != mblock[currMbAddr].slice_id)
- {
- return FALSE;
- }
-
- return TRUE;
-}
-
-OSCL_EXPORT_REF int predict_nnz(AVCCommonObj *video, int i, int j)
-{
- int pred_nnz = 0;
- int cnt = 1;
- AVCMacroblock *tempMB;
-
- /* left block */
- /*getLuma4x4Neighbour(video, mb_nr, i, j, -1, 0, &pix);
- leftMB = video->mblock + pix.mb_addr; */
- /* replace the above with below (won't work for field decoding), 1/19/04 */
-
- if (i)
- {
- pred_nnz = video->currMB->nz_coeff[(j<<2)+i-1];
- }
- else
- {
- if (video->mbAvailA)
- {
- tempMB = video->mblock + video->mbAddrA;
- pred_nnz = tempMB->nz_coeff[(j<<2)+3];
- }
- else
- {
- cnt = 0;
- }
- }
-
-
- /* top block */
- /*getLuma4x4Neighbour(video, mb_nr, i, j, 0, -1, &pix);
- topMB = video->mblock + pix.mb_addr;*/
- /* replace the above with below (won't work for field decoding), 1/19/04 */
-
- if (j)
- {
- pred_nnz += video->currMB->nz_coeff[((j-1)<<2)+i];
- cnt++;
- }
- else
- {
- if (video->mbAvailB)
- {
- tempMB = video->mblock + video->mbAddrB;
- pred_nnz += tempMB->nz_coeff[12+i];
- cnt++;
- }
- }
-
-
- if (cnt == 2)
- {
- pred_nnz = (pred_nnz + 1) >> 1;
- }
-
- return pred_nnz;
-
-}
-
-
-OSCL_EXPORT_REF int predict_nnz_chroma(AVCCommonObj *video, int i, int j)
-{
- int pred_nnz = 0;
- int cnt = 1;
- AVCMacroblock *tempMB;
-
- /* left block */
- /*getChroma4x4Neighbour(video, mb_nr, i%2, j-4, -1, 0, &pix);
- leftMB = video->mblock + pix.mb_addr;*/
- /* replace the above with below (won't work for field decoding), 1/19/04 */
- if (i&1)
- {
- pred_nnz = video->currMB->nz_coeff[(j<<2)+i-1];
-
- }
- else
- {
- if (video->mbAvailA)
- {
- tempMB = video->mblock + video->mbAddrA;
- pred_nnz = tempMB->nz_coeff[(j<<2)+i+1];
- }
- else
- {
- cnt = 0;
- }
- }
-
-
- /* top block */
- /*getChroma4x4Neighbour(video, mb_nr, i%2, j-4, 0, -1, &pix);
- topMB = video->mblock + pix.mb_addr;*/
- /* replace the above with below (won't work for field decoding), 1/19/04 */
-
- if (j&1)
- {
- pred_nnz += video->currMB->nz_coeff[((j-1)<<2)+i];
- cnt++;
- }
- else
- {
- if (video->mbAvailB)
- {
- tempMB = video->mblock + video->mbAddrB;
- pred_nnz += tempMB->nz_coeff[20+i];
- cnt++;
- }
-
- }
-
- if (cnt == 2)
- {
- pred_nnz = (pred_nnz + 1) >> 1;
- }
-
- return pred_nnz;
-}
-
-OSCL_EXPORT_REF void GetMotionVectorPredictor(AVCCommonObj *video, int encFlag)
-{
- AVCMacroblock *currMB = video->currMB;
- AVCMacroblock *MB_A, *MB_B, *MB_C, *MB_D;
- int block_x, block_y, block_x_1, block_y_1, new_block_x;
- int mbPartIdx, subMbPartIdx, offset_indx;
- int16 *mv, pmv_x, pmv_y;
- int nmSubMbHeight, nmSubMbWidth, mbPartIdx_X, mbPartIdx_Y;
- int avail_a, avail_b, avail_c;
- const static uint32 C = 0x5750;
- int i, j, offset_MbPart_indx, refIdxLXA, refIdxLXB, refIdxLXC = 0, curr_ref_idx;
- int pmv_A_x, pmv_B_x, pmv_C_x = 0, pmv_A_y, pmv_B_y, pmv_C_y = 0;
-
- /* we have to take care of Intra/skip blocks somewhere, i.e. set MV to 0 and set ref to -1! */
- /* we have to populate refIdx as well */
-
-
- MB_A = &video->mblock[video->mbAddrA];
- MB_B = &video->mblock[video->mbAddrB];
-
-
- if (currMB->mbMode == AVC_SKIP /* && !encFlag */) /* only for decoder */
- {
- currMB->ref_idx_L0[0] = currMB->ref_idx_L0[1] = currMB->ref_idx_L0[2] = currMB->ref_idx_L0[3] = 0;
- if (video->mbAvailA && video->mbAvailB)
- {
- if ((MB_A->ref_idx_L0[1] == 0 && MB_A->mvL0[3] == 0) ||
- (MB_B->ref_idx_L0[2] == 0 && MB_B->mvL0[12] == 0))
- {
- memset(currMB->mvL0, 0, sizeof(int32)*16);
- return;
- }
- }
- else
- {
- memset(currMB->mvL0, 0, sizeof(int32)*16);
- return;
- }
- video->mvd_l0[0][0][0] = 0;
- video->mvd_l0[0][0][1] = 0;
- }
-
- MB_C = &video->mblock[video->mbAddrC];
- MB_D = &video->mblock[video->mbAddrD];
-
- offset_MbPart_indx = 0;
- for (mbPartIdx = 0; mbPartIdx < currMB->NumMbPart; mbPartIdx++)
- {
- offset_indx = 0;
- nmSubMbHeight = currMB->SubMbPartHeight[mbPartIdx] >> 2;
- nmSubMbWidth = currMB->SubMbPartWidth[mbPartIdx] >> 2;
- mbPartIdx_X = ((mbPartIdx + offset_MbPart_indx) & 1) << 1;
- mbPartIdx_Y = (mbPartIdx + offset_MbPart_indx) & 2;
-
- for (subMbPartIdx = 0; subMbPartIdx < currMB->NumSubMbPart[mbPartIdx]; subMbPartIdx++)
- {
- block_x = mbPartIdx_X + ((subMbPartIdx + offset_indx) & 1);
- block_y = mbPartIdx_Y + (((subMbPartIdx + offset_indx) >> 1) & 1);
-
- block_x_1 = block_x - 1;
- block_y_1 = block_y - 1;
- refIdxLXA = refIdxLXB = refIdxLXC = -1;
- pmv_A_x = pmv_A_y = pmv_B_x = pmv_B_y = pmv_C_x = pmv_C_y = 0;
-
- if (block_x)
- {
- avail_a = 1;
- refIdxLXA = currMB->ref_idx_L0[(block_y & 2) + (block_x_1 >> 1)];
- mv = (int16*)(currMB->mvL0 + (block_y << 2) + block_x_1);
- pmv_A_x = *mv++;
- pmv_A_y = *mv;
- }
- else
- {
- avail_a = video->mbAvailA;
- if (avail_a)
- {
- refIdxLXA = MB_A->ref_idx_L0[(block_y & 2) + 1];
- mv = (int16*)(MB_A->mvL0 + (block_y << 2) + 3);
- pmv_A_x = *mv++;
- pmv_A_y = *mv;
- }
- }
-
- if (block_y)
- {
- avail_b = 1;
- refIdxLXB = currMB->ref_idx_L0[(block_y_1 & 2) + (block_x >> 1)];
- mv = (int16*)(currMB->mvL0 + (block_y_1 << 2) + block_x);
- pmv_B_x = *mv++;
- pmv_B_y = *mv;
- }
-
- else
- {
- avail_b = video->mbAvailB;
- if (avail_b)
- {
- refIdxLXB = MB_B->ref_idx_L0[2 + (block_x >> 1)];
- mv = (int16*)(MB_B->mvL0 + 12 + block_x);
- pmv_B_x = *mv++;
- pmv_B_y = *mv;
- }
- }
-
- new_block_x = block_x + (currMB->SubMbPartWidth[mbPartIdx] >> 2) - 1;
- avail_c = (C >> ((block_y << 2) + new_block_x)) & 0x1;
-
- if (avail_c)
- {
- /* it guaranteed that block_y > 0 && new_block_x<3 ) */
- refIdxLXC = currMB->ref_idx_L0[(block_y_1 & 2) + ((new_block_x+1) >> 1)];
- mv = (int16*)(currMB->mvL0 + (block_y_1 << 2) + (new_block_x + 1));
- pmv_C_x = *mv++;
- pmv_C_y = *mv;
- }
- else
- {
- if (block_y == 0 && new_block_x < 3)
- {
- avail_c = video->mbAvailB;
- if (avail_c)
- {
- refIdxLXC = MB_B->ref_idx_L0[2 + ((new_block_x+1)>>1)];
- mv = (int16*)(MB_B->mvL0 + 12 + (new_block_x + 1));
- pmv_C_x = *mv++;
- pmv_C_y = *mv;
- }
- }
- else if (block_y == 0 && new_block_x == 3)
- {
- avail_c = video->mbAvailC;
- if (avail_c)
- {
- refIdxLXC = MB_C->ref_idx_L0[2];
- mv = (int16*)(MB_C->mvL0 + 12);
- pmv_C_x = *mv++;
- pmv_C_y = *mv;
- }
- }
-
- if (avail_c == 0)
- { /* check D */
- if (block_x && block_y)
- {
- avail_c = 1;
- refIdxLXC = currMB->ref_idx_L0[(block_y_1 & 2) + (block_x_1 >> 1)];
- mv = (int16*)(currMB->mvL0 + (block_y_1 << 2) + block_x_1);
- pmv_C_x = *mv++;
- pmv_C_y = *mv;
- }
- else if (block_y)
- {
- avail_c = video->mbAvailA;
- if (avail_c)
- {
- refIdxLXC = MB_A->ref_idx_L0[(block_y_1 & 2) + 1];
- mv = (int16*)(MB_A->mvL0 + (block_y_1 << 2) + 3);
- pmv_C_x = *mv++;
- pmv_C_y = *mv;
- }
- }
- else if (block_x)
- {
- avail_c = video->mbAvailB;
- if (avail_c)
- {
- refIdxLXC = MB_B->ref_idx_L0[2 + (block_x_1 >> 1)];
- mv = (int16*)(MB_B->mvL0 + 12 + block_x_1);
- pmv_C_x = *mv++;
- pmv_C_y = *mv;
- }
- }
- else
- {
- avail_c = video->mbAvailD;
- if (avail_c)
- {
- refIdxLXC = MB_D->ref_idx_L0[3];
- mv = (int16*)(MB_D->mvL0 + 15);
- pmv_C_x = *mv++;
- pmv_C_y = *mv;
- }
- }
- }
- }
-
- offset_indx = currMB->SubMbPartWidth[mbPartIdx] >> 3;
-
- curr_ref_idx = currMB->ref_idx_L0[(block_y & 2) + (block_x >> 1)];
-
- if (avail_a && !(avail_b || avail_c))
- {
- pmv_x = pmv_A_x;
- pmv_y = pmv_A_y;
- }
- else if (((curr_ref_idx == refIdxLXA) + (curr_ref_idx == refIdxLXB) + (curr_ref_idx == refIdxLXC)) == 1)
- {
- if (curr_ref_idx == refIdxLXA)
- {
- pmv_x = pmv_A_x;
- pmv_y = pmv_A_y;
- }
- else if (curr_ref_idx == refIdxLXB)
- {
- pmv_x = pmv_B_x;
- pmv_y = pmv_B_y;
- }
- else
- {
- pmv_x = pmv_C_x;
- pmv_y = pmv_C_y;
- }
- }
- else
- {
- pmv_x = AVC_MEDIAN(pmv_A_x, pmv_B_x, pmv_C_x);
- pmv_y = AVC_MEDIAN(pmv_A_y, pmv_B_y, pmv_C_y);
- }
-
- /* overwrite if special case */
- if (currMB->NumMbPart == 2)
- {
- if (currMB->MbPartWidth == 16)
- {
- if (mbPartIdx == 0)
- {
- if (refIdxLXB == curr_ref_idx)
- {
- pmv_x = pmv_B_x;
- pmv_y = pmv_B_y;
- }
- }
- else if (refIdxLXA == curr_ref_idx)
- {
- pmv_x = pmv_A_x;
- pmv_y = pmv_A_y;
- }
- }
- else
- {
- if (mbPartIdx == 0)
- {
- if (refIdxLXA == curr_ref_idx)
- {
- pmv_x = pmv_A_x;
- pmv_y = pmv_A_y;
- }
- }
- else if (refIdxLXC == curr_ref_idx)
- {
- pmv_x = pmv_C_x;
- pmv_y = pmv_C_y;
- }
- }
- }
-
- mv = (int16*)(currMB->mvL0 + block_x + (block_y << 2));
-
- if (encFlag) /* calculate residual MV video->mvd_l0 */
- {
- video->mvd_l0[mbPartIdx][subMbPartIdx][0] = *mv++ - pmv_x;
- video->mvd_l0[mbPartIdx][subMbPartIdx][1] = *mv++ - pmv_y;
- }
- else /* calculate original MV currMB->mvL0 */
- {
- pmv_x += video->mvd_l0[mbPartIdx][subMbPartIdx][0];
- pmv_y += video->mvd_l0[mbPartIdx][subMbPartIdx][1];
-
- for (i = 0; i < nmSubMbHeight; i++)
- {
- for (j = 0; j < nmSubMbWidth; j++)
- {
- *mv++ = pmv_x;
- *mv++ = pmv_y;
- }
- mv += (8 - (j << 1));
- }
- }
- }
- offset_MbPart_indx = currMB->MbPartWidth >> 4;
-
- }
-}
-
-
diff --git a/media/libstagefright/codecs/avc/common/src/reflist.cpp b/media/libstagefright/codecs/avc/common/src/reflist.cpp
deleted file mode 100644
index 4ddc7dd..0000000
--- a/media/libstagefright/codecs/avc/common/src/reflist.cpp
+++ /dev/null
@@ -1,596 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avclib_common.h"
-
-/** see subclause 8.2.4 Decoding process for reference picture lists construction. */
-OSCL_EXPORT_REF void RefListInit(AVCCommonObj *video)
-{
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCDecPicBuffer *dpb = video->decPicBuf;
- int slice_type = video->slice_type;
- int i, list0idx;
-
- AVCPictureData *tmp_s;
-
- list0idx = 0;
-
- if (slice_type == AVC_I_SLICE)
- {
- video->refList0Size = 0;
- video->refList1Size = 0;
-
- /* we still have to calculate FrameNumWrap to make sure that all I-slice clip
- can perform sliding_window_operation properly. */
-
- for (i = 0; i < dpb->num_fs; i++)
- {
- if ((dpb->fs[i]->IsReference == 3) && (!dpb->fs[i]->IsLongTerm))
- {
- /* subclause 8.2.4.1 Decoding process for picture numbers. */
- if (dpb->fs[i]->FrameNum > (int)sliceHdr->frame_num)
- {
- dpb->fs[i]->FrameNumWrap = dpb->fs[i]->FrameNum - video->MaxFrameNum;
- }
- else
- {
- dpb->fs[i]->FrameNumWrap = dpb->fs[i]->FrameNum;
- }
- dpb->fs[i]->frame.PicNum = dpb->fs[i]->FrameNumWrap;
- }
- }
-
-
- return ;
- }
- if (slice_type == AVC_P_SLICE)
- {
- /* Calculate FrameNumWrap and PicNum */
-
- for (i = 0; i < dpb->num_fs; i++)
- {
- if ((dpb->fs[i]->IsReference == 3) && (!dpb->fs[i]->IsLongTerm))
- {
- /* subclause 8.2.4.1 Decoding process for picture numbers. */
- if (dpb->fs[i]->FrameNum > (int)sliceHdr->frame_num)
- {
- dpb->fs[i]->FrameNumWrap = dpb->fs[i]->FrameNum - video->MaxFrameNum;
- }
- else
- {
- dpb->fs[i]->FrameNumWrap = dpb->fs[i]->FrameNum;
- }
- dpb->fs[i]->frame.PicNum = dpb->fs[i]->FrameNumWrap;
- video->RefPicList0[list0idx++] = &(dpb->fs[i]->frame);
- }
- }
-
- if (list0idx == 0)
- {
- dpb->fs[0]->IsReference = 3;
- video->RefPicList0[0] = &(dpb->fs[0]->frame);
- list0idx = 1;
- }
- /* order list 0 by PicNum from max to min, see subclause 8.2.4.2.1 */
- SortPicByPicNum(video->RefPicList0, list0idx);
- video->refList0Size = list0idx;
-
- /* long term handling */
- for (i = 0; i < dpb->num_fs; i++)
- {
- if (dpb->fs[i]->IsLongTerm == 3)
- {
- /* subclause 8.2.4.1 Decoding process for picture numbers. */
- dpb->fs[i]->frame.LongTermPicNum = dpb->fs[i]->LongTermFrameIdx;
- video->RefPicList0[list0idx++] = &(dpb->fs[i]->frame);
- }
- }
-
- /* order PicNum from min to max, see subclause 8.2.4.2.1 */
- SortPicByPicNumLongTerm(&(video->RefPicList0[video->refList0Size]), list0idx - video->refList0Size);
- video->refList0Size = list0idx;
-
-
- video->refList1Size = 0;
- }
-
-
- if ((video->refList0Size == video->refList1Size) && (video->refList0Size > 1))
- {
- /* check if lists are identical, if yes swap first two elements of listX[1] */
- /* last paragraph of subclause 8.2.4.2.4 */
-
- for (i = 0; i < video->refList0Size; i++)
- {
- if (video->RefPicList0[i] != video->RefPicList1[i])
- {
- break;
- }
- }
- if (i == video->refList0Size)
- {
- tmp_s = video->RefPicList1[0];
- video->RefPicList1[0] = video->RefPicList1[1];
- video->RefPicList1[1] = tmp_s;
- }
- }
-
- /* set max size */
- video->refList0Size = AVC_MIN(video->refList0Size, (int)video->sliceHdr->num_ref_idx_l0_active_minus1 + 1);
- video->refList1Size = AVC_MIN(video->refList1Size, (int)video->sliceHdr->num_ref_idx_l1_active_minus1 + 1);
-
- return ;
-}
-/* see subclause 8.2.4.3 */
-OSCL_EXPORT_REF AVCStatus ReOrderList(AVCCommonObj *video)
-{
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCStatus status = AVC_SUCCESS;
- int slice_type = video->slice_type;
-
- if (slice_type != AVC_I_SLICE)
- {
- if (sliceHdr->ref_pic_list_reordering_flag_l0)
- {
- status = ReorderRefPicList(video, 0);
- if (status != AVC_SUCCESS)
- return status;
- }
- if (video->refList0Size == 0)
- {
- return AVC_FAIL;
- }
- }
- return status;
-}
-
-AVCStatus ReorderRefPicList(AVCCommonObj *video, int isL1)
-{
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCStatus status;
-
- int *list_size;
- int num_ref_idx_lX_active_minus1;
- uint *remapping_of_pic_nums_idc;
- int *abs_diff_pic_num_minus1;
- int *long_term_pic_idx;
- int i;
- int maxPicNum, currPicNum, picNumLXNoWrap, picNumLXPred, picNumLX;
- int refIdxLX = 0;
- void* tmp;
-
- if (!isL1) /* list 0 */
- {
- list_size = &(video->refList0Size);
- num_ref_idx_lX_active_minus1 = sliceHdr->num_ref_idx_l0_active_minus1;
- remapping_of_pic_nums_idc = sliceHdr->reordering_of_pic_nums_idc_l0;
- tmp = (void*)sliceHdr->abs_diff_pic_num_minus1_l0;
- abs_diff_pic_num_minus1 = (int*) tmp;
- tmp = (void*)sliceHdr->long_term_pic_num_l0;
- long_term_pic_idx = (int*) tmp;
- }
- else
- {
- list_size = &(video->refList1Size);
- num_ref_idx_lX_active_minus1 = sliceHdr->num_ref_idx_l1_active_minus1;
- remapping_of_pic_nums_idc = sliceHdr->reordering_of_pic_nums_idc_l1;
- tmp = (void*) sliceHdr->abs_diff_pic_num_minus1_l1;
- abs_diff_pic_num_minus1 = (int*) tmp;
- tmp = (void*) sliceHdr->long_term_pic_num_l1;
- long_term_pic_idx = (int*)tmp;
- }
-
- maxPicNum = video->MaxPicNum;
- currPicNum = video->CurrPicNum;
-
- picNumLXPred = currPicNum; /* initial value */
-
- for (i = 0; remapping_of_pic_nums_idc[i] != 3; i++)
- {
- if ((remapping_of_pic_nums_idc[i] > 3) || (i >= MAX_REF_PIC_LIST_REORDERING))
- {
- return AVC_FAIL; /* out of range */
- }
- /* see subclause 8.2.4.3.1 */
- if (remapping_of_pic_nums_idc[i] < 2)
- {
- if (remapping_of_pic_nums_idc[i] == 0)
- {
- if (picNumLXPred - (abs_diff_pic_num_minus1[i] + 1) < 0)
- picNumLXNoWrap = picNumLXPred - (abs_diff_pic_num_minus1[i] + 1) + maxPicNum;
- else
- picNumLXNoWrap = picNumLXPred - (abs_diff_pic_num_minus1[i] + 1);
- }
- else /* (remapping_of_pic_nums_idc[i] == 1) */
- {
- if (picNumLXPred + (abs_diff_pic_num_minus1[i] + 1) >= maxPicNum)
- picNumLXNoWrap = picNumLXPred + (abs_diff_pic_num_minus1[i] + 1) - maxPicNum;
- else
- picNumLXNoWrap = picNumLXPred + (abs_diff_pic_num_minus1[i] + 1);
- }
- picNumLXPred = picNumLXNoWrap; /* prediction for the next one */
-
- if (picNumLXNoWrap > currPicNum)
- picNumLX = picNumLXNoWrap - maxPicNum;
- else
- picNumLX = picNumLXNoWrap;
-
- status = ReorderShortTerm(video, picNumLX, &refIdxLX, isL1);
- if (status != AVC_SUCCESS)
- {
- return status;
- }
- }
- else /* (remapping_of_pic_nums_idc[i] == 2), subclause 8.2.4.3.2 */
- {
- status = ReorderLongTerm(video, long_term_pic_idx[i], &refIdxLX, isL1);
- if (status != AVC_SUCCESS)
- {
- return status;
- }
- }
- }
- /* that's a definition */
- *list_size = num_ref_idx_lX_active_minus1 + 1;
-
- return AVC_SUCCESS;
-}
-
-/* see subclause 8.2.4.3.1 */
-AVCStatus ReorderShortTerm(AVCCommonObj *video, int picNumLX, int *refIdxLX, int isL1)
-{
- int cIdx, nIdx;
- int num_ref_idx_lX_active_minus1;
- AVCPictureData *picLX, **RefPicListX;
-
- if (!isL1) /* list 0 */
- {
- RefPicListX = video->RefPicList0;
- num_ref_idx_lX_active_minus1 = video->sliceHdr->num_ref_idx_l0_active_minus1;
- }
- else
- {
- RefPicListX = video->RefPicList1;
- num_ref_idx_lX_active_minus1 = video->sliceHdr->num_ref_idx_l1_active_minus1;
- }
-
- picLX = GetShortTermPic(video, picNumLX);
-
- if (picLX == NULL)
- {
- return AVC_FAIL;
- }
- /* Note RefPicListX has to access element number num_ref_idx_lX_active */
- /* There could be access violation here. */
- if (num_ref_idx_lX_active_minus1 + 1 >= MAX_REF_PIC_LIST)
- {
- return AVC_FAIL;
- }
-
- for (cIdx = num_ref_idx_lX_active_minus1 + 1; cIdx > *refIdxLX; cIdx--)
- {
- RefPicListX[ cIdx ] = RefPicListX[ cIdx - 1];
- }
-
- RefPicListX[(*refIdxLX)++ ] = picLX;
-
- nIdx = *refIdxLX;
-
- for (cIdx = *refIdxLX; cIdx <= num_ref_idx_lX_active_minus1 + 1; cIdx++)
- {
- if (RefPicListX[ cIdx ])
- {
- if ((RefPicListX[ cIdx ]->isLongTerm) || ((int)RefPicListX[ cIdx ]->PicNum != picNumLX))
- {
- RefPicListX[ nIdx++ ] = RefPicListX[ cIdx ];
- }
- }
- }
- return AVC_SUCCESS;
-}
-
-/* see subclause 8.2.4.3.2 */
-AVCStatus ReorderLongTerm(AVCCommonObj *video, int LongTermPicNum, int *refIdxLX, int isL1)
-{
- AVCPictureData **RefPicListX;
- int num_ref_idx_lX_active_minus1;
- int cIdx, nIdx;
- AVCPictureData *picLX;
-
- if (!isL1) /* list 0 */
- {
- RefPicListX = video->RefPicList0;
- num_ref_idx_lX_active_minus1 = video->sliceHdr->num_ref_idx_l0_active_minus1;
- }
- else
- {
- RefPicListX = video->RefPicList1;
- num_ref_idx_lX_active_minus1 = video->sliceHdr->num_ref_idx_l1_active_minus1;
- }
-
- picLX = GetLongTermPic(video, LongTermPicNum);
- if (picLX == NULL)
- {
- return AVC_FAIL;
- }
- /* Note RefPicListX has to access element number num_ref_idx_lX_active */
- /* There could be access violation here. */
- if (num_ref_idx_lX_active_minus1 + 1 >= MAX_REF_PIC_LIST)
- {
- return AVC_FAIL;
- }
- for (cIdx = num_ref_idx_lX_active_minus1 + 1; cIdx > *refIdxLX; cIdx--)
- RefPicListX[ cIdx ] = RefPicListX[ cIdx - 1];
-
- RefPicListX[(*refIdxLX)++ ] = picLX;
-
- nIdx = *refIdxLX;
-
- for (cIdx = *refIdxLX; cIdx <= num_ref_idx_lX_active_minus1 + 1; cIdx++)
- {
- if ((!RefPicListX[ cIdx ]->isLongTerm) || ((int)RefPicListX[ cIdx ]->LongTermPicNum != LongTermPicNum))
- {
- RefPicListX[ nIdx++ ] = RefPicListX[ cIdx ];
- }
- }
- return AVC_SUCCESS;
-}
-
-
-AVCPictureData* GetShortTermPic(AVCCommonObj *video, int picNum)
-{
- int i;
- AVCDecPicBuffer *dpb = video->decPicBuf;
-
- for (i = 0; i < dpb->num_fs; i++)
- {
-
- if (dpb->fs[i]->IsReference == 3)
- {
- if ((dpb->fs[i]->frame.isLongTerm == FALSE) && (dpb->fs[i]->frame.PicNum == picNum))
- {
- return &(dpb->fs[i]->frame);
- }
- }
-
- }
-
- return NULL;
-}
-
-AVCPictureData* GetLongTermPic(AVCCommonObj *video, int LongtermPicNum)
-{
- AVCDecPicBuffer *dpb = video->decPicBuf;
- int i;
-
- for (i = 0; i < dpb->num_fs; i++)
- {
-
- if (dpb->fs[i]->IsReference == 3)
- {
- if ((dpb->fs[i]->frame.isLongTerm == TRUE) && (dpb->fs[i]->frame.LongTermPicNum == LongtermPicNum))
- {
- return &(dpb->fs[i]->frame);
- }
- }
-
- }
- return NULL;
-}
-
-int is_short_ref(AVCPictureData *s)
-{
- return ((s->isReference) && !(s->isLongTerm));
-}
-
-int is_long_ref(AVCPictureData *s)
-{
- return ((s->isReference) && (s->isLongTerm));
-}
-
-
-/* sort by PicNum, descending order */
-void SortPicByPicNum(AVCPictureData *data[], int num)
-{
- int i, j;
- AVCPictureData *temp;
-
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->PicNum > data[i]->PicNum)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
-
- return ;
-}
-
-/* sort by PicNum, ascending order */
-void SortPicByPicNumLongTerm(AVCPictureData *data[], int num)
-{
- int i, j;
- AVCPictureData *temp;
-
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->LongTermPicNum < data[i]->LongTermPicNum)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
-
- return ;
-}
-
-
-/* sort by FrameNumWrap, descending order */
-void SortFrameByFrameNumWrap(AVCFrameStore *data[], int num)
-{
- int i, j;
- AVCFrameStore *temp;
-
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->FrameNumWrap > data[i]->FrameNumWrap)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
-
- return ;
-}
-
-/* sort frames by LongTermFrameIdx, ascending order */
-void SortFrameByLTFrameIdx(AVCFrameStore *data[], int num)
-{
- int i, j;
- AVCFrameStore *temp;
-
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->LongTermFrameIdx < data[i]->LongTermFrameIdx)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
-
- return ;
-}
-
-/* sort PictureData by POC in descending order */
-void SortPicByPOC(AVCPictureData *data[], int num, int descending)
-{
- int i, j;
- AVCPictureData *temp;
-
- if (descending)
- {
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->PicOrderCnt > data[i]->PicOrderCnt)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
- }
- else
- {
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->PicOrderCnt < data[i]->PicOrderCnt)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
- }
- return ;
-}
-
-/* sort PictureData by LongTermPicNum in ascending order */
-void SortPicByLTPicNum(AVCPictureData *data[], int num)
-{
- int i, j;
- AVCPictureData *temp;
-
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->LongTermPicNum < data[i]->LongTermPicNum)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
-
- return ;
-}
-
-/* sort by PicOrderCnt, descending order */
-void SortFrameByPOC(AVCFrameStore *data[], int num, int descending)
-{
- int i, j;
- AVCFrameStore *temp;
-
- if (descending)
- {
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->PicOrderCnt > data[i]->PicOrderCnt)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
- }
- else
- {
- for (i = 0; i < num - 1; i++)
- {
- for (j = i + 1; j < num; j++)
- {
- if (data[j]->PicOrderCnt < data[i]->PicOrderCnt)
- {
- temp = data[j];
- data[j] = data[i];
- data[i] = temp;
- }
- }
- }
- }
-
- return ;
-}
-
-
diff --git a/media/libstagefright/codecs/avc/enc/Android.mk b/media/libstagefright/codecs/avc/enc/Android.mk
deleted file mode 100644
index 8ff2f35..0000000
--- a/media/libstagefright/codecs/avc/enc/Android.mk
+++ /dev/null
@@ -1,110 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/avcenc_api.cpp \
- src/bitstream_io.cpp \
- src/block.cpp \
- src/findhalfpel.cpp \
- src/header.cpp \
- src/init.cpp \
- src/intra_est.cpp \
- src/motion_comp.cpp \
- src/motion_est.cpp \
- src/rate_control.cpp \
- src/residual.cpp \
- src/sad.cpp \
- src/sad_halfpel.cpp \
- src/slice.cpp \
- src/vlc_encode.cpp
-
-
-LOCAL_MODULE := libstagefright_avcenc
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/../common/include \
- $(TOP)/frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS := \
- -DOSCL_IMPORT_REF= -D"OSCL_UNUSED_ARG(x)=(void)(x)" -DOSCL_EXPORT_REF=
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftAVCEncoder.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/hardware \
- frameworks/native/include/media/openmax \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../common/include \
- $(LOCAL_PATH)/../common
-
-LOCAL_CFLAGS := \
- -DOSCL_IMPORT_REF= -D"OSCL_UNUSED_ARG(x)=(void)(x)" -DOSCL_EXPORT_REF=
-
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_avcenc
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright \
- libstagefright_avc_common \
- libstagefright_enc_common \
- libstagefright_foundation \
- libstagefright_omx \
- libutils \
- liblog \
- libui
-
-
-LOCAL_MODULE := libstagefright_soft_h264enc
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- test/h264_enc_test.cpp
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../common/include \
- $(LOCAL_PATH)/../common
-
-LOCAL_CFLAGS := \
- -DOSCL_IMPORT_REF= -DOSCL_UNUSED_ARG= -DOSCL_EXPORT_REF=
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_avcenc
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_avc_common
-
-LOCAL_MODULE := libstagefright_h264enc_test
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/codecs/avc/enc/MODULE_LICENSE_APACHE2 b/media/libstagefright/codecs/avc/enc/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/media/libstagefright/codecs/avc/enc/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/media/libstagefright/codecs/avc/enc/NOTICE b/media/libstagefright/codecs/avc/enc/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/media/libstagefright/codecs/avc/enc/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, 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.
-
- 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.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
deleted file mode 100644
index cce6d15..0000000
--- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
+++ /dev/null
@@ -1,734 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "SoftAVCEncoder"
-#include <utils/Log.h>
-#include <utils/misc.h>
-
-#include "avcenc_api.h"
-#include "avcenc_int.h"
-#include "OMX_Video.h"
-
-#include <HardwareAPI.h>
-#include <MetadataBufferType.h>
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/foundation/AUtils.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/Utils.h>
-#include <ui/Rect.h>
-#include <ui/GraphicBufferMapper.h>
-
-#include "SoftAVCEncoder.h"
-
-#if LOG_NDEBUG
-#define UNUSED_UNLESS_VERBOSE(x) (void)(x)
-#else
-#define UNUSED_UNLESS_VERBOSE(x)
-#endif
-
-namespace android {
-
-template<class T>
-static void InitOMXParams(T *params) {
- params->nSize = sizeof(T);
- params->nVersion.s.nVersionMajor = 1;
- params->nVersion.s.nVersionMinor = 0;
- params->nVersion.s.nRevision = 0;
- params->nVersion.s.nStep = 0;
-}
-
-static const CodecProfileLevel kProfileLevels[] = {
- { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2 },
-};
-
-typedef struct LevelConversion {
- OMX_U32 omxLevel;
- AVCLevel avcLevel;
- uint32_t maxMacroBlocks;
-} LevelConcersion;
-
-static LevelConversion ConversionTable[] = {
- { OMX_VIDEO_AVCLevel1, AVC_LEVEL1_B, 99 },
- { OMX_VIDEO_AVCLevel1b, AVC_LEVEL1, 99 },
- { OMX_VIDEO_AVCLevel11, AVC_LEVEL1_1, 396 },
- { OMX_VIDEO_AVCLevel12, AVC_LEVEL1_2, 396 },
- { OMX_VIDEO_AVCLevel13, AVC_LEVEL1_3, 396 },
- { OMX_VIDEO_AVCLevel2, AVC_LEVEL2, 396 },
-#if 0
- // encoding speed is very poor if video resolution
- // is higher than CIF or if level is higher than 2
- { OMX_VIDEO_AVCLevel21, AVC_LEVEL2_1, 792 },
- { OMX_VIDEO_AVCLevel22, AVC_LEVEL2_2, 1620 },
- { OMX_VIDEO_AVCLevel3, AVC_LEVEL3, 1620 },
- { OMX_VIDEO_AVCLevel31, AVC_LEVEL3_1, 3600 },
- { OMX_VIDEO_AVCLevel32, AVC_LEVEL3_2, 5120 },
- { OMX_VIDEO_AVCLevel4, AVC_LEVEL4, 8192 },
- { OMX_VIDEO_AVCLevel41, AVC_LEVEL4_1, 8192 },
- { OMX_VIDEO_AVCLevel42, AVC_LEVEL4_2, 8704 },
- { OMX_VIDEO_AVCLevel5, AVC_LEVEL5, 22080 },
- { OMX_VIDEO_AVCLevel51, AVC_LEVEL5_1, 36864 },
-#endif
-};
-
-static status_t ConvertOmxAvcLevelToAvcSpecLevel(
- OMX_U32 omxLevel, AVCLevel *avcLevel) {
- for (size_t i = 0, n = sizeof(ConversionTable)/sizeof(ConversionTable[0]);
- i < n; ++i) {
- if (omxLevel == ConversionTable[i].omxLevel) {
- *avcLevel = ConversionTable[i].avcLevel;
- return OK;
- }
- }
-
- ALOGE("ConvertOmxAvcLevelToAvcSpecLevel: %d level not supported",
- (int32_t)omxLevel);
-
- return BAD_VALUE;
-}
-
-static status_t ConvertAvcSpecLevelToOmxAvcLevel(
- AVCLevel avcLevel, OMX_U32 *omxLevel) {
- for (size_t i = 0, n = sizeof(ConversionTable)/sizeof(ConversionTable[0]);
- i < n; ++i) {
- if (avcLevel == ConversionTable[i].avcLevel) {
- *omxLevel = ConversionTable[i].omxLevel;
- return OK;
- }
- }
-
- ALOGE("ConvertAvcSpecLevelToOmxAvcLevel: %d level not supported",
- (int32_t) avcLevel);
-
- return BAD_VALUE;
-}
-
-static void* MallocWrapper(
- void * /* userData */, int32_t size, int32_t /* attrs */) {
- void *ptr = malloc(size);
- if (ptr)
- memset(ptr, 0, size);
- return ptr;
-}
-
-static void FreeWrapper(void * /* userData */, void* ptr) {
- free(ptr);
-}
-
-static int32_t DpbAllocWrapper(void *userData,
- unsigned int sizeInMbs, unsigned int numBuffers) {
- SoftAVCEncoder *encoder = static_cast<SoftAVCEncoder *>(userData);
- CHECK(encoder != NULL);
- return encoder->allocOutputBuffers(sizeInMbs, numBuffers);
-}
-
-static int32_t BindFrameWrapper(
- void *userData, int32_t index, uint8_t **yuv) {
- SoftAVCEncoder *encoder = static_cast<SoftAVCEncoder *>(userData);
- CHECK(encoder != NULL);
- return encoder->bindOutputBuffer(index, yuv);
-}
-
-static void UnbindFrameWrapper(void *userData, int32_t index) {
- SoftAVCEncoder *encoder = static_cast<SoftAVCEncoder *>(userData);
- CHECK(encoder != NULL);
- return encoder->unbindOutputBuffer(index);
-}
-
-SoftAVCEncoder::SoftAVCEncoder(
- const char *name,
- const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData,
- OMX_COMPONENTTYPE **component)
- : SoftVideoEncoderOMXComponent(
- name, "video_encoder.avc", OMX_VIDEO_CodingAVC,
- kProfileLevels, NELEM(kProfileLevels),
- 176 /* width */, 144 /* height */,
- callbacks, appData, component),
- mIDRFrameRefreshIntervalInSec(1),
- mAVCEncProfile(AVC_BASELINE),
- mAVCEncLevel(AVC_LEVEL2),
- mNumInputFrames(-1),
- mPrevTimestampUs(-1),
- mStarted(false),
- mSawInputEOS(false),
- mSignalledError(false),
- mHandle(new tagAVCHandle),
- mEncParams(new tagAVCEncParam),
- mInputFrameData(NULL),
- mSliceGroup(NULL) {
-
- const size_t kOutputBufferSize =
- 320 * ConversionTable[NELEM(ConversionTable) - 1].maxMacroBlocks;
-
- initPorts(
- kNumBuffers, kNumBuffers, kOutputBufferSize,
- MEDIA_MIMETYPE_VIDEO_AVC, 2 /* minCompressionRatio */);
-
- ALOGI("Construct SoftAVCEncoder");
-}
-
-SoftAVCEncoder::~SoftAVCEncoder() {
- ALOGV("Destruct SoftAVCEncoder");
- releaseEncoder();
- List<BufferInfo *> &outQueue = getPortQueue(1);
- List<BufferInfo *> &inQueue = getPortQueue(0);
- CHECK(outQueue.empty());
- CHECK(inQueue.empty());
-}
-
-OMX_ERRORTYPE SoftAVCEncoder::initEncParams() {
- CHECK(mHandle != NULL);
- memset(mHandle, 0, sizeof(tagAVCHandle));
- mHandle->AVCObject = NULL;
- mHandle->userData = this;
- mHandle->CBAVC_DPBAlloc = DpbAllocWrapper;
- mHandle->CBAVC_FrameBind = BindFrameWrapper;
- mHandle->CBAVC_FrameUnbind = UnbindFrameWrapper;
- mHandle->CBAVC_Malloc = MallocWrapper;
- mHandle->CBAVC_Free = FreeWrapper;
-
- CHECK(mEncParams != NULL);
- memset(mEncParams, 0, sizeof(*mEncParams));
- mEncParams->rate_control = AVC_ON;
- mEncParams->initQP = 0;
- mEncParams->init_CBP_removal_delay = 1600;
-
- mEncParams->intramb_refresh = 0;
- mEncParams->auto_scd = AVC_ON;
- mEncParams->out_of_band_param_set = AVC_ON;
- mEncParams->poc_type = 2;
- mEncParams->log2_max_poc_lsb_minus_4 = 12;
- mEncParams->delta_poc_zero_flag = 0;
- mEncParams->offset_poc_non_ref = 0;
- mEncParams->offset_top_bottom = 0;
- mEncParams->num_ref_in_cycle = 0;
- mEncParams->offset_poc_ref = NULL;
-
- mEncParams->num_ref_frame = 1;
- mEncParams->num_slice_group = 1;
- mEncParams->fmo_type = 0;
-
- mEncParams->db_filter = AVC_ON;
- mEncParams->disable_db_idc = 0;
-
- mEncParams->alpha_offset = 0;
- mEncParams->beta_offset = 0;
- mEncParams->constrained_intra_pred = AVC_OFF;
-
- mEncParams->data_par = AVC_OFF;
- mEncParams->fullsearch = AVC_OFF;
- mEncParams->search_range = 16;
- mEncParams->sub_pel = AVC_OFF;
- mEncParams->submb_pred = AVC_OFF;
- mEncParams->rdopt_mode = AVC_OFF;
- mEncParams->bidir_pred = AVC_OFF;
-
- mEncParams->use_overrun_buffer = AVC_OFF;
-
- if (mColorFormat != OMX_COLOR_FormatYUV420Planar || mInputDataIsMeta) {
- // Color conversion is needed.
- free(mInputFrameData);
- if (((uint64_t)mWidth * mHeight) > ((uint64_t)INT32_MAX / 3)) {
- ALOGE("Buffer size is too big.");
- return OMX_ErrorUndefined;
- }
- mInputFrameData =
- (uint8_t *) malloc((mWidth * mHeight * 3 ) >> 1);
- CHECK(mInputFrameData != NULL);
- }
-
- // PV's AVC encoder requires the video dimension of multiple
- if (mWidth % 16 != 0 || mHeight % 16 != 0) {
- ALOGE("Video frame size %dx%d must be a multiple of 16",
- mWidth, mHeight);
- return OMX_ErrorBadParameter;
- }
-
- mEncParams->width = mWidth;
- mEncParams->height = mHeight;
- mEncParams->bitrate = mBitrate;
- mEncParams->frame_rate = (1000 * mFramerate) >> 16; // In frames/ms!, mFramerate is in Q16
- mEncParams->CPB_size = (uint32_t) (mBitrate >> 1);
-
- int32_t nMacroBlocks = divUp(mWidth, 16) * divUp(mHeight, 16);
- CHECK(mSliceGroup == NULL);
- if ((size_t)nMacroBlocks > SIZE_MAX / sizeof(uint32_t)) {
- ALOGE("requested memory size is too big.");
- return OMX_ErrorUndefined;
- }
- mSliceGroup = (uint32_t *) malloc(sizeof(uint32_t) * nMacroBlocks);
- CHECK(mSliceGroup != NULL);
- for (int ii = 0, idx = 0; ii < nMacroBlocks; ++ii) {
- mSliceGroup[ii] = idx++;
- if (idx >= mEncParams->num_slice_group) {
- idx = 0;
- }
- }
- mEncParams->slice_group = mSliceGroup;
-
- // Set IDR frame refresh interval
- if (mIDRFrameRefreshIntervalInSec < 0) {
- mEncParams->idr_period = -1;
- } else if (mIDRFrameRefreshIntervalInSec == 0) {
- mEncParams->idr_period = 1; // All I frames
- } else {
- mEncParams->idr_period =
- (mIDRFrameRefreshIntervalInSec * mFramerate) >> 16; // mFramerate is in Q16
- }
-
- // Set profile and level
- mEncParams->profile = mAVCEncProfile;
- mEncParams->level = mAVCEncLevel;
-
- return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE SoftAVCEncoder::initEncoder() {
- CHECK(!mStarted);
-
- OMX_ERRORTYPE errType = OMX_ErrorNone;
- if (OMX_ErrorNone != (errType = initEncParams())) {
- ALOGE("Failed to initialized encoder params");
- mSignalledError = true;
- notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
- return errType;
- }
-
- AVCEnc_Status err;
- err = PVAVCEncInitialize(mHandle, mEncParams, NULL, NULL);
- if (err != AVCENC_SUCCESS) {
- ALOGE("Failed to initialize the encoder: %d", err);
- mSignalledError = true;
- notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
- return OMX_ErrorUndefined;
- }
-
- mNumInputFrames = -2; // 1st two buffers contain SPS and PPS
- mSpsPpsHeaderReceived = false;
- mReadyForNextFrame = true;
- mIsIDRFrame = false;
- mStarted = true;
-
- return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE SoftAVCEncoder::releaseEncoder() {
- if (!mStarted) {
- return OMX_ErrorNone;
- }
-
- PVAVCCleanUpEncoder(mHandle);
- releaseOutputBuffers();
-
- free(mInputFrameData);
- mInputFrameData = NULL;
-
- free(mSliceGroup);
- mSliceGroup = NULL;
-
- delete mEncParams;
- mEncParams = NULL;
-
- delete mHandle;
- mHandle = NULL;
-
- mStarted = false;
-
- return OMX_ErrorNone;
-}
-
-void SoftAVCEncoder::releaseOutputBuffers() {
- for (size_t i = 0; i < mOutputBuffers.size(); ++i) {
- MediaBuffer *buffer = mOutputBuffers.editItemAt(i);
- buffer->setObserver(NULL);
- buffer->release();
- }
- mOutputBuffers.clear();
-}
-
-OMX_ERRORTYPE SoftAVCEncoder::internalGetParameter(
- OMX_INDEXTYPE index, OMX_PTR params) {
- switch (index) {
- case OMX_IndexParamVideoBitrate:
- {
- OMX_VIDEO_PARAM_BITRATETYPE *bitRate =
- (OMX_VIDEO_PARAM_BITRATETYPE *) params;
-
- if (!isValidOMXParam(bitRate)) {
- return OMX_ErrorBadParameter;
- }
-
- if (bitRate->nPortIndex != 1) {
- return OMX_ErrorUndefined;
- }
-
- bitRate->eControlRate = OMX_Video_ControlRateVariable;
- bitRate->nTargetBitrate = mBitrate;
- return OMX_ErrorNone;
- }
-
- case OMX_IndexParamVideoAvc:
- {
- OMX_VIDEO_PARAM_AVCTYPE *avcParams =
- (OMX_VIDEO_PARAM_AVCTYPE *)params;
-
- if (!isValidOMXParam(avcParams)) {
- return OMX_ErrorBadParameter;
- }
-
- if (avcParams->nPortIndex != 1) {
- return OMX_ErrorUndefined;
- }
-
- avcParams->eProfile = OMX_VIDEO_AVCProfileBaseline;
- OMX_U32 omxLevel = AVC_LEVEL2;
- if (OMX_ErrorNone !=
- ConvertAvcSpecLevelToOmxAvcLevel(mAVCEncLevel, &omxLevel)) {
- return OMX_ErrorUndefined;
- }
-
- avcParams->eLevel = (OMX_VIDEO_AVCLEVELTYPE) omxLevel;
- avcParams->nRefFrames = 1;
- avcParams->nBFrames = 0;
- avcParams->bUseHadamard = OMX_TRUE;
- avcParams->nAllowedPictureTypes =
- (OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP);
- avcParams->nRefIdx10ActiveMinus1 = 0;
- avcParams->nRefIdx11ActiveMinus1 = 0;
- avcParams->bWeightedPPrediction = OMX_FALSE;
- avcParams->bEntropyCodingCABAC = OMX_FALSE;
- avcParams->bconstIpred = OMX_FALSE;
- avcParams->bDirect8x8Inference = OMX_FALSE;
- avcParams->bDirectSpatialTemporal = OMX_FALSE;
- avcParams->nCabacInitIdc = 0;
- return OMX_ErrorNone;
- }
-
- default:
- return SoftVideoEncoderOMXComponent::internalGetParameter(index, params);
- }
-}
-
-OMX_ERRORTYPE SoftAVCEncoder::internalSetParameter(
- OMX_INDEXTYPE index, const OMX_PTR params) {
- int32_t indexFull = index;
-
- switch (indexFull) {
- case OMX_IndexParamVideoBitrate:
- {
- OMX_VIDEO_PARAM_BITRATETYPE *bitRate =
- (OMX_VIDEO_PARAM_BITRATETYPE *) params;
-
- if (!isValidOMXParam(bitRate)) {
- return OMX_ErrorBadParameter;
- }
-
- if (bitRate->nPortIndex != 1 ||
- bitRate->eControlRate != OMX_Video_ControlRateVariable) {
- return OMX_ErrorUndefined;
- }
-
- mBitrate = bitRate->nTargetBitrate;
- return OMX_ErrorNone;
- }
-
- case OMX_IndexParamVideoAvc:
- {
- OMX_VIDEO_PARAM_AVCTYPE *avcType =
- (OMX_VIDEO_PARAM_AVCTYPE *)params;
-
- if (!isValidOMXParam(avcType)) {
- return OMX_ErrorBadParameter;
- }
-
- if (avcType->nPortIndex != 1) {
- return OMX_ErrorUndefined;
- }
-
- // PV's AVC encoder only supports baseline profile
- if (avcType->eProfile != OMX_VIDEO_AVCProfileBaseline ||
- avcType->nRefFrames != 1 ||
- avcType->nBFrames != 0 ||
- avcType->bUseHadamard != OMX_TRUE ||
- (avcType->nAllowedPictureTypes & OMX_VIDEO_PictureTypeB) != 0 ||
- avcType->nRefIdx10ActiveMinus1 != 0 ||
- avcType->nRefIdx11ActiveMinus1 != 0 ||
- avcType->bWeightedPPrediction != OMX_FALSE ||
- avcType->bEntropyCodingCABAC != OMX_FALSE ||
- avcType->bconstIpred != OMX_FALSE ||
- avcType->bDirect8x8Inference != OMX_FALSE ||
- avcType->bDirectSpatialTemporal != OMX_FALSE ||
- avcType->nCabacInitIdc != 0) {
- return OMX_ErrorUndefined;
- }
-
- if (OK != ConvertOmxAvcLevelToAvcSpecLevel(avcType->eLevel, &mAVCEncLevel)) {
- return OMX_ErrorUndefined;
- }
-
- return OMX_ErrorNone;
- }
-
- default:
- return SoftVideoEncoderOMXComponent::internalSetParameter(index, params);
- }
-}
-
-void SoftAVCEncoder::onQueueFilled(OMX_U32 /* portIndex */) {
- if (mSignalledError || mSawInputEOS) {
- return;
- }
-
- if (!mStarted) {
- if (OMX_ErrorNone != initEncoder()) {
- return;
- }
- }
-
- List<BufferInfo *> &inQueue = getPortQueue(0);
- List<BufferInfo *> &outQueue = getPortQueue(1);
-
- while (!mSawInputEOS && !inQueue.empty() && !outQueue.empty()) {
- BufferInfo *inInfo = *inQueue.begin();
- OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
- BufferInfo *outInfo = *outQueue.begin();
- OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
-
- outHeader->nTimeStamp = 0;
- outHeader->nFlags = 0;
- outHeader->nOffset = 0;
- outHeader->nFilledLen = 0;
- outHeader->nOffset = 0;
-
- uint8_t *outPtr = (uint8_t *) outHeader->pBuffer;
- uint32_t dataLength = outHeader->nAllocLen;
-
- if (!mSpsPpsHeaderReceived && mNumInputFrames < 0) {
- // 4 bytes are reserved for holding the start code 0x00000001
- // of the sequence parameter set at the beginning.
- outPtr += 4;
- dataLength -= 4;
- }
-
- int32_t type;
- AVCEnc_Status encoderStatus = AVCENC_SUCCESS;
-
- // Combine SPS and PPS and place them in the very first output buffer
- // SPS and PPS are separated by start code 0x00000001
- // Assume that we have exactly one SPS and exactly one PPS.
- while (!mSpsPpsHeaderReceived && mNumInputFrames <= 0) {
- encoderStatus = PVAVCEncodeNAL(mHandle, outPtr, &dataLength, &type);
- if (encoderStatus == AVCENC_WRONG_STATE) {
- mSpsPpsHeaderReceived = true;
- CHECK_EQ(0, mNumInputFrames); // 1st video frame is 0
- outHeader->nFlags = OMX_BUFFERFLAG_CODECCONFIG;
- outQueue.erase(outQueue.begin());
- outInfo->mOwnedByUs = false;
- notifyFillBufferDone(outHeader);
- return;
- } else {
- switch (type) {
- case AVC_NALTYPE_SPS:
- ++mNumInputFrames;
- memcpy((uint8_t *)outHeader->pBuffer, "\x00\x00\x00\x01", 4);
- outHeader->nFilledLen = 4 + dataLength;
- outPtr += (dataLength + 4); // 4 bytes for next start code
- dataLength = outHeader->nAllocLen - outHeader->nFilledLen;
- break;
- default:
- CHECK_EQ(AVC_NALTYPE_PPS, type);
- ++mNumInputFrames;
- memcpy((uint8_t *) outHeader->pBuffer + outHeader->nFilledLen,
- "\x00\x00\x00\x01", 4);
- outHeader->nFilledLen += (dataLength + 4);
- outPtr += (dataLength + 4);
- break;
- }
- }
- }
-
- // Get next input video frame
- if (mReadyForNextFrame) {
- // Save the input buffer info so that it can be
- // passed to an output buffer
- InputBufferInfo info;
- info.mTimeUs = inHeader->nTimeStamp;
- info.mFlags = inHeader->nFlags;
- mInputBufferInfoVec.push(info);
- mPrevTimestampUs = inHeader->nTimeStamp;
-
- if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
- mSawInputEOS = true;
- }
-
- if (inHeader->nFilledLen > 0) {
- AVCFrameIO videoInput;
- memset(&videoInput, 0, sizeof(videoInput));
- videoInput.height = align(mHeight, 16);
- videoInput.pitch = align(mWidth, 16);
- videoInput.coding_timestamp = (inHeader->nTimeStamp + 500) / 1000; // in ms
- const uint8_t *inputData = NULL;
- if (mInputDataIsMeta) {
- inputData =
- extractGraphicBuffer(
- mInputFrameData, (mWidth * mHeight * 3) >> 1,
- inHeader->pBuffer + inHeader->nOffset, inHeader->nFilledLen,
- mWidth, mHeight);
- if (inputData == NULL) {
- ALOGE("Unable to extract gralloc buffer in metadata mode");
- mSignalledError = true;
- notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
- return;
- }
- // TODO: Verify/convert pixel format enum
- } else {
- inputData = (const uint8_t *)inHeader->pBuffer + inHeader->nOffset;
- if (mColorFormat != OMX_COLOR_FormatYUV420Planar) {
- ConvertYUV420SemiPlanarToYUV420Planar(
- inputData, mInputFrameData, mWidth, mHeight);
- inputData = mInputFrameData;
- }
- }
-
- CHECK(inputData != NULL);
- videoInput.YCbCr[0] = (uint8_t *)inputData;
- videoInput.YCbCr[1] = videoInput.YCbCr[0] + videoInput.height * videoInput.pitch;
- videoInput.YCbCr[2] = videoInput.YCbCr[1] +
- ((videoInput.height * videoInput.pitch) >> 2);
- videoInput.disp_order = mNumInputFrames;
-
- encoderStatus = PVAVCEncSetInput(mHandle, &videoInput);
- if (encoderStatus == AVCENC_SUCCESS || encoderStatus == AVCENC_NEW_IDR) {
- mReadyForNextFrame = false;
- ++mNumInputFrames;
- if (encoderStatus == AVCENC_NEW_IDR) {
- mIsIDRFrame = 1;
- }
- } else {
- if (encoderStatus < AVCENC_SUCCESS) {
- ALOGE("encoderStatus = %d at line %d", encoderStatus, __LINE__);
- mSignalledError = true;
- notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
- return;
- } else {
- ALOGV("encoderStatus = %d at line %d", encoderStatus, __LINE__);
- inQueue.erase(inQueue.begin());
- inInfo->mOwnedByUs = false;
- notifyEmptyBufferDone(inHeader);
- return;
- }
- }
- }
- }
-
- // Encode an input video frame
- CHECK(encoderStatus == AVCENC_SUCCESS || encoderStatus == AVCENC_NEW_IDR);
- dataLength = outHeader->nAllocLen; // Reset the output buffer length
- if (inHeader->nFilledLen > 0) {
- if (outHeader->nAllocLen >= 4) {
- memcpy(outPtr, "\x00\x00\x00\x01", 4);
- outPtr += 4;
- dataLength -= 4;
- }
- encoderStatus = PVAVCEncodeNAL(mHandle, outPtr, &dataLength, &type);
- dataLength = outPtr + dataLength - outHeader->pBuffer;
- if (encoderStatus == AVCENC_SUCCESS) {
- CHECK(NULL == PVAVCEncGetOverrunBuffer(mHandle));
- } else if (encoderStatus == AVCENC_PICTURE_READY) {
- CHECK(NULL == PVAVCEncGetOverrunBuffer(mHandle));
- if (mIsIDRFrame) {
- outHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
- mIsIDRFrame = false;
- }
- mReadyForNextFrame = true;
- AVCFrameIO recon;
- if (PVAVCEncGetRecon(mHandle, &recon) == AVCENC_SUCCESS) {
- PVAVCEncReleaseRecon(mHandle, &recon);
- }
- } else {
- dataLength = 0;
- mReadyForNextFrame = true;
- }
-
- if (encoderStatus < AVCENC_SUCCESS) {
- ALOGE("encoderStatus = %d at line %d", encoderStatus, __LINE__);
- mSignalledError = true;
- notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
- return;
- }
- } else {
- dataLength = 0;
- }
-
- inQueue.erase(inQueue.begin());
- inInfo->mOwnedByUs = false;
- notifyEmptyBufferDone(inHeader);
-
- outQueue.erase(outQueue.begin());
- CHECK(!mInputBufferInfoVec.empty());
- InputBufferInfo *inputBufInfo = mInputBufferInfoVec.begin();
- outHeader->nTimeStamp = inputBufInfo->mTimeUs;
- outHeader->nFlags |= (inputBufInfo->mFlags | OMX_BUFFERFLAG_ENDOFFRAME);
- if (mSawInputEOS) {
- outHeader->nFlags |= OMX_BUFFERFLAG_EOS;
- }
- outHeader->nFilledLen = dataLength;
- outInfo->mOwnedByUs = false;
- notifyFillBufferDone(outHeader);
- mInputBufferInfoVec.erase(mInputBufferInfoVec.begin());
- }
-}
-
-int32_t SoftAVCEncoder::allocOutputBuffers(
- unsigned int sizeInMbs, unsigned int numBuffers) {
- CHECK(mOutputBuffers.isEmpty());
- size_t frameSize = (sizeInMbs << 7) * 3;
- for (unsigned int i = 0; i < numBuffers; ++i) {
- MediaBuffer *buffer = new MediaBuffer(frameSize);
- buffer->setObserver(this);
- mOutputBuffers.push(buffer);
- }
-
- return 1;
-}
-
-void SoftAVCEncoder::unbindOutputBuffer(int32_t index) {
- CHECK(index >= 0);
-}
-
-int32_t SoftAVCEncoder::bindOutputBuffer(int32_t index, uint8_t **yuv) {
- CHECK(index >= 0);
- CHECK(index < (int32_t) mOutputBuffers.size());
- *yuv = (uint8_t *) mOutputBuffers[index]->data();
-
- return 1;
-}
-
-void SoftAVCEncoder::signalBufferReturned(MediaBuffer *buffer) {
- UNUSED_UNLESS_VERBOSE(buffer);
- ALOGV("signalBufferReturned: %p", buffer);
-}
-
-} // namespace android
-
-android::SoftOMXComponent *createSoftOMXComponent(
- const char *name, const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData, OMX_COMPONENTTYPE **component) {
- return new android::SoftAVCEncoder(name, callbacks, appData, component);
-}
diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h
deleted file mode 100644
index 81de109..0000000
--- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#ifndef SOFT_AVC_ENCODER_H_
-#define SOFT_AVC_ENCODER_H_
-
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/foundation/ABase.h>
-#include <utils/Vector.h>
-
-#include "avcenc_api.h"
-#include "SoftVideoEncoderOMXComponent.h"
-
-namespace android {
-
-struct SoftAVCEncoder : public MediaBufferObserver,
- public SoftVideoEncoderOMXComponent {
- SoftAVCEncoder(
- const char *name,
- const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData,
- OMX_COMPONENTTYPE **component);
-
- // Override SimpleSoftOMXComponent methods
- virtual OMX_ERRORTYPE internalGetParameter(
- OMX_INDEXTYPE index, OMX_PTR params);
-
- virtual OMX_ERRORTYPE internalSetParameter(
- OMX_INDEXTYPE index, const OMX_PTR params);
-
- virtual void onQueueFilled(OMX_U32 portIndex);
-
- // Implement MediaBufferObserver
- virtual void signalBufferReturned(MediaBuffer *buffer);
-
-
- // Callbacks required by PV's encoder
- int32_t allocOutputBuffers(unsigned int sizeInMbs, unsigned int numBuffers);
- void unbindOutputBuffer(int32_t index);
- int32_t bindOutputBuffer(int32_t index, uint8_t **yuv);
-
-protected:
- virtual ~SoftAVCEncoder();
-
-private:
- enum {
- kNumBuffers = 2,
- };
-
- // OMX input buffer's timestamp and flags
- typedef struct {
- int64_t mTimeUs;
- int32_t mFlags;
- } InputBufferInfo;
-
- int32_t mIDRFrameRefreshIntervalInSec;
- AVCProfile mAVCEncProfile;
- AVCLevel mAVCEncLevel;
-
- int64_t mNumInputFrames;
- int64_t mPrevTimestampUs;
- bool mStarted;
- bool mSpsPpsHeaderReceived;
- bool mReadyForNextFrame;
- bool mSawInputEOS;
- bool mSignalledError;
- bool mIsIDRFrame;
-
- tagAVCHandle *mHandle;
- tagAVCEncParam *mEncParams;
- uint8_t *mInputFrameData;
- uint32_t *mSliceGroup;
- Vector<MediaBuffer *> mOutputBuffers;
- Vector<InputBufferInfo> mInputBufferInfoVec;
-
- OMX_ERRORTYPE initEncParams();
- OMX_ERRORTYPE initEncoder();
- OMX_ERRORTYPE releaseEncoder();
- void releaseOutputBuffers();
-
- DISALLOW_EVIL_CONSTRUCTORS(SoftAVCEncoder);
-};
-
-} // namespace android
-
-#endif // SOFT_AVC_ENCODER_H_
diff --git a/media/libstagefright/codecs/avc/enc/src/avcenc_api.cpp b/media/libstagefright/codecs/avc/enc/src/avcenc_api.cpp
deleted file mode 100644
index cf14e10..0000000
--- a/media/libstagefright/codecs/avc/enc/src/avcenc_api.cpp
+++ /dev/null
@@ -1,736 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_api.h"
-#include "avcenc_lib.h"
-
-/* ======================================================================== */
-/* Function : PVAVCGetNALType() */
-/* Date : 11/4/2003 */
-/* Purpose : Sniff NAL type from the bitstream */
-/* In/out : */
-/* Return : AVCENC_SUCCESS if succeed, AVCENC_FAIL if fail. */
-/* Modified : */
-/* ======================================================================== */
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncGetNALType(unsigned char *bitstream, int size,
- int *nal_type, int *nal_ref_idc)
-{
- int forbidden_zero_bit;
- if (size > 0)
- {
- forbidden_zero_bit = bitstream[0] >> 7;
- if (forbidden_zero_bit != 0)
- return AVCENC_FAIL;
- *nal_ref_idc = (bitstream[0] & 0x60) >> 5;
- *nal_type = bitstream[0] & 0x1F;
- return AVCENC_SUCCESS;
- }
-
- return AVCENC_FAIL;
-}
-
-
-/* ======================================================================== */
-/* Function : PVAVCEncInitialize() */
-/* Date : 3/18/2004 */
-/* Purpose : Initialize the encoder library, allocate memory and verify */
-/* the profile/level support/settings. */
-/* In/out : Encoding parameters. */
-/* Return : AVCENC_SUCCESS for success. */
-/* Modified : */
-/* ======================================================================== */
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncInitialize(AVCHandle *avcHandle, AVCEncParams *encParam,
- void* extSPS, void* extPPS)
-{
- AVCEnc_Status status;
- AVCEncObject *encvid;
- AVCCommonObj *video;
- uint32 *userData = (uint32*) avcHandle->userData;
- int framesize;
-
- if (avcHandle->AVCObject != NULL)
- {
- return AVCENC_ALREADY_INITIALIZED; /* It's already initialized, need to cleanup first */
- }
-
- /* not initialized */
-
- /* allocate videoObject */
- avcHandle->AVCObject = (void*)avcHandle->CBAVC_Malloc(userData, sizeof(AVCEncObject), DEFAULT_ATTR);
- if (avcHandle->AVCObject == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- encvid = (AVCEncObject*) avcHandle->AVCObject;
-
- encvid->enc_state = AVCEnc_Initializing;
-
- encvid->avcHandle = avcHandle;
-
- encvid->common = (AVCCommonObj*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCCommonObj), DEFAULT_ATTR);
- if (encvid->common == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- video = encvid->common;
-
- /* allocate bitstream structure */
- encvid->bitstream = (AVCEncBitstream*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCEncBitstream), DEFAULT_ATTR);
- if (encvid->bitstream == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
- encvid->bitstream->encvid = encvid; /* to point back for reallocation */
-
- /* allocate sequence parameter set structure */
- video->currSeqParams = (AVCSeqParamSet*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCSeqParamSet), DEFAULT_ATTR);
- if (video->currSeqParams == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- /* allocate picture parameter set structure */
- video->currPicParams = (AVCPicParamSet*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCPicParamSet), DEFAULT_ATTR);
- if (video->currPicParams == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- /* allocate slice header structure */
- video->sliceHdr = (AVCSliceHeader*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCSliceHeader), DEFAULT_ATTR);
- if (video->sliceHdr == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- /* allocate encoded picture buffer structure*/
- video->decPicBuf = (AVCDecPicBuffer*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCDecPicBuffer), DEFAULT_ATTR);
- if (video->decPicBuf == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- /* allocate rate control structure */
- encvid->rateCtrl = (AVCRateControl*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCRateControl), DEFAULT_ATTR);
- if (encvid->rateCtrl == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- /* reset frame list, not really needed */
- video->currPic = NULL;
- video->currFS = NULL;
- encvid->currInput = NULL;
- video->prevRefPic = NULL;
-
- /* now read encParams, and allocate dimension-dependent variables */
- /* such as mblock */
- status = SetEncodeParam(avcHandle, encParam, extSPS, extPPS); /* initialized variables to be used in SPS*/
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- if (encParam->use_overrun_buffer == AVC_ON)
- {
- /* allocate overrun buffer */
- encvid->oBSize = encvid->rateCtrl->cpbSize;
- if (encvid->oBSize > DEFAULT_OVERRUN_BUFFER_SIZE)
- {
- encvid->oBSize = DEFAULT_OVERRUN_BUFFER_SIZE;
- }
- encvid->overrunBuffer = (uint8*) avcHandle->CBAVC_Malloc(userData, encvid->oBSize, DEFAULT_ATTR);
- if (encvid->overrunBuffer == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
- }
- else
- {
- encvid->oBSize = 0;
- encvid->overrunBuffer = NULL;
- }
-
- /* allocate frame size dependent structures */
- framesize = video->FrameHeightInMbs * video->PicWidthInMbs;
-
- video->mblock = (AVCMacroblock*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCMacroblock) * framesize, DEFAULT_ATTR);
- if (video->mblock == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- video->MbToSliceGroupMap = (int*) avcHandle->CBAVC_Malloc(userData, sizeof(uint) * video->PicSizeInMapUnits * 2, DEFAULT_ATTR);
- if (video->MbToSliceGroupMap == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- encvid->mot16x16 = (AVCMV*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCMV) * framesize, DEFAULT_ATTR);
- if (encvid->mot16x16 == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- encvid->intraSearch = (uint8*) avcHandle->CBAVC_Malloc(userData, sizeof(uint8) * framesize, DEFAULT_ATTR);
- if (encvid->intraSearch == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- encvid->min_cost = (int*) avcHandle->CBAVC_Malloc(userData, sizeof(int) * framesize, DEFAULT_ATTR);
- if (encvid->min_cost == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- /* initialize motion search related memory */
- if (AVCENC_SUCCESS != InitMotionSearchModule(avcHandle))
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- if (AVCENC_SUCCESS != InitRateControlModule(avcHandle))
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- /* intialize function pointers */
- encvid->functionPointer = (AVCEncFuncPtr*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCEncFuncPtr), DEFAULT_ATTR);
- if (encvid->functionPointer == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
- encvid->functionPointer->SAD_Macroblock = &AVCSAD_Macroblock_C;
- encvid->functionPointer->SAD_MB_HalfPel[0] = NULL;
- encvid->functionPointer->SAD_MB_HalfPel[1] = &AVCSAD_MB_HalfPel_Cxh;
- encvid->functionPointer->SAD_MB_HalfPel[2] = &AVCSAD_MB_HalfPel_Cyh;
- encvid->functionPointer->SAD_MB_HalfPel[3] = &AVCSAD_MB_HalfPel_Cxhyh;
-
- /* initialize timing control */
- encvid->modTimeRef = 0; /* ALWAYS ASSUME THAT TIMESTAMP START FROM 0 !!!*/
- video->prevFrameNum = 0;
- encvid->prevCodedFrameNum = 0;
- encvid->dispOrdPOCRef = 0;
-
- if (encvid->outOfBandParamSet == TRUE)
- {
- encvid->enc_state = AVCEnc_Encoding_SPS;
- }
- else
- {
- encvid->enc_state = AVCEnc_Analyzing_Frame;
- }
-
- return AVCENC_SUCCESS;
-}
-
-/* ======================================================================== */
-/* Function : PVAVCEncGetMaxOutputSize() */
-/* Date : 11/29/2008 */
-/* Purpose : Return max output buffer size that apps should allocate for */
-/* output buffer. */
-/* In/out : */
-/* Return : AVCENC_SUCCESS for success. */
-/* Modified : size */
-/* ======================================================================== */
-
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncGetMaxOutputBufferSize(AVCHandle *avcHandle, int* size)
-{
- AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
-
- if (encvid == NULL)
- {
- return AVCENC_UNINITIALIZED;
- }
-
- *size = encvid->rateCtrl->cpbSize;
-
- return AVCENC_SUCCESS;
-}
-
-/* ======================================================================== */
-/* Function : PVAVCEncSetInput() */
-/* Date : 4/18/2004 */
-/* Purpose : To feed an unencoded original frame to the encoder library. */
-/* In/out : */
-/* Return : AVCENC_SUCCESS for success. */
-/* Modified : */
-/* ======================================================================== */
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncSetInput(AVCHandle *avcHandle, AVCFrameIO *input)
-{
- AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
- AVCCommonObj *video = encvid->common;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
-
- AVCEnc_Status status;
- uint frameNum;
-
- if (encvid == NULL)
- {
- return AVCENC_UNINITIALIZED;
- }
-
- if (encvid->enc_state == AVCEnc_WaitingForBuffer)
- {
- goto RECALL_INITFRAME;
- }
- else if (encvid->enc_state != AVCEnc_Analyzing_Frame)
- {
- return AVCENC_FAIL;
- }
-
- if (input->pitch > 0xFFFF)
- {
- return AVCENC_NOT_SUPPORTED; // we use 2-bytes for pitch
- }
-
- /***********************************/
-
- /* Let's rate control decide whether to encode this frame or not */
- /* Also set video->nal_unit_type, sliceHdr->slice_type, video->slice_type */
- if (AVCENC_SUCCESS != RCDetermineFrameNum(encvid, rateCtrl, input->coding_timestamp, &frameNum))
- {
- return AVCENC_SKIPPED_PICTURE; /* not time to encode, thus skipping */
- }
-
- /* we may not need this line */
- //nextFrmModTime = (uint32)((((frameNum+1)*1000)/rateCtrl->frame_rate) + modTimeRef); /* rec. time */
- //encvid->nextModTime = nextFrmModTime - (encvid->frameInterval>>1) - 1; /* between current and next frame */
-
- encvid->currInput = input;
- encvid->currInput->coding_order = frameNum;
-
-RECALL_INITFRAME:
- /* initialize and analyze the frame */
- status = InitFrame(encvid);
-
- if (status == AVCENC_SUCCESS)
- {
- encvid->enc_state = AVCEnc_Encoding_Frame;
- }
- else if (status == AVCENC_NEW_IDR)
- {
- if (encvid->outOfBandParamSet == TRUE)
- {
- encvid->enc_state = AVCEnc_Encoding_Frame;
- }
- else // assuming that in-band paramset keeps sending new SPS and PPS.
- {
- encvid->enc_state = AVCEnc_Encoding_SPS;
- //video->currSeqParams->seq_parameter_set_id++;
- //if(video->currSeqParams->seq_parameter_set_id > 31) // range check
- {
- video->currSeqParams->seq_parameter_set_id = 0; // reset
- }
- }
-
- video->sliceHdr->idr_pic_id++;
- if (video->sliceHdr->idr_pic_id > 65535) // range check
- {
- video->sliceHdr->idr_pic_id = 0; // reset
- }
- }
- /* the following logics need to be revisited */
- else if (status == AVCENC_PICTURE_READY) // no buffers returned back to the encoder
- {
- encvid->enc_state = AVCEnc_WaitingForBuffer; // Input accepted but can't continue
- // need to free up some memory before proceeding with Encode
- }
-
- return status; // return status, including the AVCENC_FAIL case and all 3 above.
-}
-
-/* ======================================================================== */
-/* Function : PVAVCEncodeNAL() */
-/* Date : 4/29/2004 */
-/* Purpose : To encode one NAL/slice. */
-/* In/out : */
-/* Return : AVCENC_SUCCESS for success. */
-/* Modified : */
-/* ======================================================================== */
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncodeNAL(AVCHandle *avcHandle, unsigned char *buffer, unsigned int *buf_nal_size, int *nal_type)
-{
- AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
- AVCCommonObj *video = encvid->common;
- AVCEncBitstream *bitstream = encvid->bitstream;
- AVCEnc_Status status;
-
- if (encvid == NULL)
- {
- return AVCENC_UNINITIALIZED;
- }
-
- switch (encvid->enc_state)
- {
- case AVCEnc_Initializing:
- return AVCENC_UNINITIALIZED;
- case AVCEnc_Encoding_SPS:
- /* initialized the structure */
- BitstreamEncInit(bitstream, buffer, *buf_nal_size, NULL, 0);
- BitstreamWriteBits(bitstream, 8, (1 << 5) | AVC_NALTYPE_SPS);
-
- /* encode SPS */
- status = EncodeSPS(encvid, bitstream);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- /* closing the NAL with trailing bits */
- status = BitstreamTrailingBits(bitstream, buf_nal_size);
- if (status == AVCENC_SUCCESS)
- {
- encvid->enc_state = AVCEnc_Encoding_PPS;
- video->currPicParams->seq_parameter_set_id = video->currSeqParams->seq_parameter_set_id;
- video->currPicParams->pic_parameter_set_id++;
- *nal_type = AVC_NALTYPE_SPS;
- *buf_nal_size = bitstream->write_pos;
- }
- break;
- case AVCEnc_Encoding_PPS:
- /* initialized the structure */
- BitstreamEncInit(bitstream, buffer, *buf_nal_size, NULL, 0);
- BitstreamWriteBits(bitstream, 8, (1 << 5) | AVC_NALTYPE_PPS);
-
- /* encode PPS */
- status = EncodePPS(encvid, bitstream);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- /* closing the NAL with trailing bits */
- status = BitstreamTrailingBits(bitstream, buf_nal_size);
- if (status == AVCENC_SUCCESS)
- {
- if (encvid->outOfBandParamSet == TRUE) // already extract PPS, SPS
- {
- encvid->enc_state = AVCEnc_Analyzing_Frame;
- }
- else // SetInput has been called before SPS and PPS.
- {
- encvid->enc_state = AVCEnc_Encoding_Frame;
- }
-
- *nal_type = AVC_NALTYPE_PPS;
- *buf_nal_size = bitstream->write_pos;
- }
- break;
-
- case AVCEnc_Encoding_Frame:
- /* initialized the structure */
- BitstreamEncInit(bitstream, buffer, *buf_nal_size, encvid->overrunBuffer, encvid->oBSize);
- BitstreamWriteBits(bitstream, 8, (video->nal_ref_idc << 5) | (video->nal_unit_type));
-
- /* Re-order the reference list according to the ref_pic_list_reordering() */
- /* We don't have to reorder the list for the encoder here. This can only be done
- after we encode this slice. We can run thru a second-pass to see if new ordering
- would save more bits. Too much delay !! */
- /* status = ReOrderList(video);*/
- status = InitSlice(encvid);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- /* when we have everything, we encode the slice header */
- status = EncodeSliceHeader(encvid, bitstream);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- status = AVCEncodeSlice(encvid);
-
- video->slice_id++;
-
- /* closing the NAL with trailing bits */
- BitstreamTrailingBits(bitstream, buf_nal_size);
-
- *buf_nal_size = bitstream->write_pos;
-
- encvid->rateCtrl->numFrameBits += ((*buf_nal_size) << 3);
-
- *nal_type = video->nal_unit_type;
-
- if (status == AVCENC_PICTURE_READY)
- {
- status = RCUpdateFrame(encvid);
- if (status == AVCENC_SKIPPED_PICTURE) /* skip current frame */
- {
- DPBReleaseCurrentFrame(avcHandle, video);
- encvid->enc_state = AVCEnc_Analyzing_Frame;
-
- return status;
- }
-
- /* perform loop-filtering on the entire frame */
- DeblockPicture(video);
-
- /* update the original frame array */
- encvid->prevCodedFrameNum = encvid->currInput->coding_order;
-
- /* store the encoded picture in the DPB buffer */
- StorePictureInDPB(avcHandle, video);
-
- if (video->currPic->isReference)
- {
- video->PrevRefFrameNum = video->sliceHdr->frame_num;
- }
-
- /* update POC related variables */
- PostPOC(video);
-
- encvid->enc_state = AVCEnc_Analyzing_Frame;
- status = AVCENC_PICTURE_READY;
-
- }
- break;
- default:
- status = AVCENC_WRONG_STATE;
- }
-
- return status;
-}
-
-/* ======================================================================== */
-/* Function : PVAVCEncGetOverrunBuffer() */
-/* Purpose : To retrieve the overrun buffer. Check whether overrun buffer */
-/* is used or not before returning */
-/* In/out : */
-/* Return : Pointer to the internal overrun buffer. */
-/* Modified : */
-/* ======================================================================== */
-OSCL_EXPORT_REF uint8* PVAVCEncGetOverrunBuffer(AVCHandle* avcHandle)
-{
- AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
- AVCEncBitstream *bitstream = encvid->bitstream;
-
- if (bitstream->overrunBuffer == bitstream->bitstreamBuffer) /* OB is used */
- {
- return encvid->overrunBuffer;
- }
- else
- {
- return NULL;
- }
-}
-
-
-/* ======================================================================== */
-/* Function : PVAVCEncGetRecon() */
-/* Date : 4/29/2004 */
-/* Purpose : To retrieve the most recently encoded frame. */
-/* assume that user will make a copy if they want to hold on */
-/* to it. Otherwise, it is not guaranteed to be reserved. */
-/* Most applications prefer to see original frame rather than */
-/* reconstructed frame. So, we are staying aware from complex */
-/* buffering mechanism. If needed, can be added later. */
-/* In/out : */
-/* Return : AVCENC_SUCCESS for success. */
-/* Modified : */
-/* ======================================================================== */
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncGetRecon(AVCHandle *avcHandle, AVCFrameIO *recon)
-{
- AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
- AVCCommonObj *video = encvid->common;
- AVCFrameStore *currFS = video->currFS;
-
- if (encvid == NULL)
- {
- return AVCENC_UNINITIALIZED;
- }
-
- recon->YCbCr[0] = currFS->frame.Sl;
- recon->YCbCr[1] = currFS->frame.Scb;
- recon->YCbCr[2] = currFS->frame.Scr;
- recon->height = currFS->frame.height;
- recon->pitch = currFS->frame.pitch;
- recon->disp_order = currFS->PicOrderCnt;
- recon->coding_order = currFS->FrameNum;
- recon->id = (intptr_t) currFS->base_dpb; /* use the pointer as the id */
-
- currFS->IsOutputted |= 1;
-
- return AVCENC_SUCCESS;
-}
-
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncReleaseRecon(AVCHandle *avcHandle, AVCFrameIO *recon)
-{
- OSCL_UNUSED_ARG(avcHandle);
- OSCL_UNUSED_ARG(recon);
-
- return AVCENC_SUCCESS; //for now
-}
-
-/* ======================================================================== */
-/* Function : PVAVCCleanUpEncoder() */
-/* Date : 4/18/2004 */
-/* Purpose : To clean up memories allocated by PVAVCEncInitialize() */
-/* In/out : */
-/* Return : AVCENC_SUCCESS for success. */
-/* Modified : */
-/* ======================================================================== */
-OSCL_EXPORT_REF void PVAVCCleanUpEncoder(AVCHandle *avcHandle)
-{
- AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
- AVCCommonObj *video;
- uint32 *userData = (uint32*) avcHandle->userData;
-
- if (encvid != NULL)
- {
- CleanMotionSearchModule(avcHandle);
-
- CleanupRateControlModule(avcHandle);
-
- if (encvid->functionPointer != NULL)
- {
- avcHandle->CBAVC_Free(userData, encvid->functionPointer);
- }
-
- if (encvid->min_cost)
- {
- avcHandle->CBAVC_Free(userData, encvid->min_cost);
- }
-
- if (encvid->intraSearch)
- {
- avcHandle->CBAVC_Free(userData, encvid->intraSearch);
- }
-
- if (encvid->mot16x16)
- {
- avcHandle->CBAVC_Free(userData, encvid->mot16x16);
- }
-
- if (encvid->rateCtrl)
- {
- avcHandle->CBAVC_Free(userData, encvid->rateCtrl);
- }
-
- if (encvid->overrunBuffer)
- {
- avcHandle->CBAVC_Free(userData, encvid->overrunBuffer);
- }
-
- video = encvid->common;
- if (video != NULL)
- {
- if (video->MbToSliceGroupMap)
- {
- avcHandle->CBAVC_Free(userData, video->MbToSliceGroupMap);
- }
- if (video->mblock != NULL)
- {
- avcHandle->CBAVC_Free(userData, video->mblock);
- }
- if (video->decPicBuf != NULL)
- {
- CleanUpDPB(avcHandle, video);
- avcHandle->CBAVC_Free(userData, video->decPicBuf);
- }
- if (video->sliceHdr != NULL)
- {
- avcHandle->CBAVC_Free(userData, video->sliceHdr);
- }
- if (video->currPicParams != NULL)
- {
- if (video->currPicParams->slice_group_id)
- {
- avcHandle->CBAVC_Free(userData, video->currPicParams->slice_group_id);
- }
-
- avcHandle->CBAVC_Free(userData, video->currPicParams);
- }
- if (video->currSeqParams != NULL)
- {
- avcHandle->CBAVC_Free(userData, video->currSeqParams);
- }
- if (encvid->bitstream != NULL)
- {
- avcHandle->CBAVC_Free(userData, encvid->bitstream);
- }
- if (video != NULL)
- {
- avcHandle->CBAVC_Free(userData, video);
- }
- }
-
- avcHandle->CBAVC_Free(userData, encvid);
-
- avcHandle->AVCObject = NULL;
- }
-
- return ;
-}
-
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncUpdateBitRate(AVCHandle *avcHandle, uint32 bitrate)
-{
- OSCL_UNUSED_ARG(avcHandle);
- OSCL_UNUSED_ARG(bitrate);
-
- return AVCENC_FAIL;
-}
-
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncUpdateFrameRate(AVCHandle *avcHandle, uint32 num, uint32 denom)
-{
- OSCL_UNUSED_ARG(avcHandle);
- OSCL_UNUSED_ARG(num);
- OSCL_UNUSED_ARG(denom);
-
- return AVCENC_FAIL;
-}
-
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncUpdateIDRInterval(AVCHandle *avcHandle, int IDRInterval)
-{
- OSCL_UNUSED_ARG(avcHandle);
- OSCL_UNUSED_ARG(IDRInterval);
-
- return AVCENC_FAIL;
-}
-
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncIDRRequest(AVCHandle *avcHandle)
-{
- OSCL_UNUSED_ARG(avcHandle);
-
- return AVCENC_FAIL;
-}
-
-OSCL_EXPORT_REF AVCEnc_Status PVAVCEncUpdateIMBRefresh(AVCHandle *avcHandle, int numMB)
-{
- OSCL_UNUSED_ARG(avcHandle);
- OSCL_UNUSED_ARG(numMB);
-
- return AVCENC_FAIL;
-}
-
-void PVAVCEncGetFrameStats(AVCHandle *avcHandle, AVCEncFrameStats *avcStats)
-{
- AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
-
- avcStats->avgFrameQP = GetAvgFrameQP(rateCtrl);
- avcStats->numIntraMBs = encvid->numIntraMB;
-
- return ;
-}
-
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/avcenc_api.h b/media/libstagefright/codecs/avc/enc/src/avcenc_api.h
deleted file mode 100644
index 6841ec3..0000000
--- a/media/libstagefright/codecs/avc/enc/src/avcenc_api.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-/**
-This file contains application function interfaces to the AVC encoder library
-and necessary type defitionitions and enumerations.
-@publishedAll
-*/
-
-#ifndef AVCENC_API_H_INCLUDED
-#define AVCENC_API_H_INCLUDED
-
-#ifndef AVCAPI_COMMON_H_INCLUDED
-#include "avcapi_common.h"
-#endif
-
-// For memset, etc
-#include <string.h>
-
-/**
- This enumeration is used for the status returned from the library interface.
-*/
-typedef enum
-{
- /**
- Fail information, need to add more error code for more specific info
- */
- AVCENC_TRAILINGONES_FAIL = -35,
- AVCENC_SLICE_EMPTY = -34,
- AVCENC_POC_FAIL = -33,
- AVCENC_CONSECUTIVE_NONREF = -32,
- AVCENC_CABAC_FAIL = -31,
- AVCENC_PRED_WEIGHT_TAB_FAIL = -30,
- AVCENC_DEC_REF_PIC_MARK_FAIL = -29,
- AVCENC_SPS_FAIL = -28,
- AVCENC_BITSTREAM_BUFFER_FULL = -27,
- AVCENC_BITSTREAM_INIT_FAIL = -26,
- AVCENC_CHROMA_QP_FAIL = -25,
- AVCENC_INIT_QS_FAIL = -24,
- AVCENC_INIT_QP_FAIL = -23,
- AVCENC_WEIGHTED_BIPRED_FAIL = -22,
- AVCENC_INVALID_INTRA_PERIOD = -21,
- AVCENC_INVALID_CHANGE_RATE = -20,
- AVCENC_INVALID_BETA_OFFSET = -19,
- AVCENC_INVALID_ALPHA_OFFSET = -18,
- AVCENC_INVALID_DEBLOCK_IDC = -17,
- AVCENC_INVALID_REDUNDANT_PIC = -16,
- AVCENC_INVALID_FRAMERATE = -15,
- AVCENC_INVALID_NUM_SLICEGROUP = -14,
- AVCENC_INVALID_POC_LSB = -13,
- AVCENC_INVALID_NUM_REF = -12,
- AVCENC_INVALID_FMO_TYPE = -11,
- AVCENC_ENCPARAM_MEM_FAIL = -10,
- AVCENC_LEVEL_NOT_SUPPORTED = -9,
- AVCENC_LEVEL_FAIL = -8,
- AVCENC_PROFILE_NOT_SUPPORTED = -7,
- AVCENC_TOOLS_NOT_SUPPORTED = -6,
- AVCENC_WRONG_STATE = -5,
- AVCENC_UNINITIALIZED = -4,
- AVCENC_ALREADY_INITIALIZED = -3,
- AVCENC_NOT_SUPPORTED = -2,
- AVCENC_MEMORY_FAIL = AVC_MEMORY_FAIL,
- AVCENC_FAIL = AVC_FAIL,
- /**
- Generic success value
- */
- AVCENC_SUCCESS = AVC_SUCCESS,
- AVCENC_PICTURE_READY = 2,
- AVCENC_NEW_IDR = 3, /* upon getting this, users have to call PVAVCEncodeSPS and PVAVCEncodePPS to get a new SPS and PPS*/
- AVCENC_SKIPPED_PICTURE = 4 /* continuable error message */
-
-} AVCEnc_Status;
-
-#define MAX_NUM_SLICE_GROUP 8 /* maximum for all the profiles */
-
-/**
-This structure contains the encoding parameters.
-*/
-typedef struct tagAVCEncParam
-{
- /* if profile/level is set to zero, encoder will choose the closest one for you */
- AVCProfile profile; /* profile of the bitstream to be compliant with*/
- AVCLevel level; /* level of the bitstream to be compliant with*/
-
- int width; /* width of an input frame in pixel */
- int height; /* height of an input frame in pixel */
-
- int poc_type; /* picture order count mode, 0,1 or 2 */
- /* for poc_type == 0 */
- uint log2_max_poc_lsb_minus_4; /* specify maximum value of POC Lsb, range 0..12*/
- /* for poc_type == 1 */
- uint delta_poc_zero_flag; /* delta POC always zero */
- int offset_poc_non_ref; /* offset for non-reference pic */
- int offset_top_bottom; /* offset between top and bottom field */
- uint num_ref_in_cycle; /* number of reference frame in one cycle */
- int *offset_poc_ref; /* array of offset for ref pic, dimension [num_ref_in_cycle] */
-
- int num_ref_frame; /* number of reference frame used */
- int num_slice_group; /* number of slice group */
- int fmo_type; /* 0: interleave, 1: dispersed, 2: foreground with left-over
- 3: box-out, 4:raster scan, 5:wipe, 6:explicit */
- /* for fmo_type == 0 */
- uint run_length_minus1[MAX_NUM_SLICE_GROUP]; /* array of size num_slice_group, in round robin fasion */
- /* fmo_type == 2*/
- uint top_left[MAX_NUM_SLICE_GROUP-1]; /* array of co-ordinates of each slice_group */
- uint bottom_right[MAX_NUM_SLICE_GROUP-1]; /* except the last one which is the background. */
- /* fmo_type == 3,4,5 */
- AVCFlag change_dir_flag; /* slice group change direction flag */
- uint change_rate_minus1;
- /* fmo_type == 6 */
- uint *slice_group; /* array of size MBWidth*MBHeight */
-
- AVCFlag db_filter; /* enable deblocking loop filter */
- int disable_db_idc; /* 0: filter everywhere, 1: no filter, 2: no filter across slice boundary */
- int alpha_offset; /* alpha offset range -6,...,6 */
- int beta_offset; /* beta offset range -6,...,6 */
-
- AVCFlag constrained_intra_pred; /* constrained intra prediction flag */
-
- AVCFlag auto_scd; /* scene change detection on or off */
- int idr_period; /* idr frame refresh rate in number of target encoded frame (no concept of actual time).*/
- int intramb_refresh; /* minimum number of intra MB per frame */
- AVCFlag data_par; /* enable data partitioning */
-
- AVCFlag fullsearch; /* enable full-pel full-search mode */
- int search_range; /* search range for motion vector in (-search_range,+search_range) pixels */
- AVCFlag sub_pel; /* enable sub pel prediction */
- AVCFlag submb_pred; /* enable sub MB partition mode */
- AVCFlag rdopt_mode; /* RD optimal mode selection */
- AVCFlag bidir_pred; /* enable bi-directional for B-slice, this flag forces the encoder to encode
- any frame with POC less than the previously encoded frame as a B-frame.
- If it's off, then such frames will remain P-frame. */
-
- AVCFlag rate_control; /* rate control enable, on: RC on, off: constant QP */
- int initQP; /* initial QP */
- uint32 bitrate; /* target encoding bit rate in bits/second */
- uint32 CPB_size; /* coded picture buffer in number of bits */
- uint32 init_CBP_removal_delay; /* initial CBP removal delay in msec */
-
- uint32 frame_rate; /* frame rate in the unit of frames per 1000 second */
- /* note, frame rate is only needed by the rate control, AVC is timestamp agnostic. */
-
- AVCFlag out_of_band_param_set; /* flag to set whether param sets are to be retrieved up front or not */
-
- AVCFlag use_overrun_buffer; /* do not throw away the frame if output buffer is not big enough.
- copy excess bits to the overrun buffer */
-} AVCEncParams;
-
-
-/**
-This structure contains current frame encoding statistics for debugging purpose.
-*/
-typedef struct tagAVCEncFrameStats
-{
- int avgFrameQP; /* average frame QP */
- int numIntraMBs; /* number of intra MBs */
- int numFalseAlarm;
- int numMisDetected;
- int numDetected;
-
-} AVCEncFrameStats;
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
- /** THE FOLLOWINGS ARE APIS */
- /**
- This function initializes the encoder library. It verifies the validity of the
- encoding parameters against the specified profile/level and the list of supported
- tools by this library. It allocates necessary memories required to perform encoding.
- For re-encoding application, if users want to setup encoder in a more precise way,
- users can give the external SPS and PPS to the encoder to follow.
- \param "avcHandle" "Handle to the AVC encoder library object."
- \param "encParam" "Pointer to the encoding parameter structure."
- \param "extSPS" "External SPS used for re-encoding purpose. NULL if not present"
- \param "extPPS" "External PPS used for re-encoding purpose. NULL if not present"
- \return "AVCENC_SUCCESS for success,
- AVCENC_NOT_SUPPORTED for the use of unsupported tools,
- AVCENC_MEMORY_FAIL for memory allocation failure,
- AVCENC_FAIL for generic failure."
- */
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncInitialize(AVCHandle *avcHandle, AVCEncParams *encParam, void* extSPS, void* extPPS);
-
-
- /**
- Since the output buffer size is not known prior to encoding a frame, users need to
- allocate big enough buffer otherwise, that frame will be dropped. This function returns
- the size of the output buffer to be allocated by the users that guarantees to hold one frame.
- It follows the CPB spec for a particular level. However, when the users set use_overrun_buffer
- flag, this API is useless as excess output bits are saved in the overrun buffer waiting to be
- copied out in small chunks, i.e. users can allocate any size of output buffer.
- \param "avcHandle" "Handle to the AVC encoder library object."
- \param "size" "Pointer to the size to be modified."
- \return "AVCENC_SUCCESS for success, AVCENC_UNINITIALIZED when level is not known.
- */
-
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncGetMaxOutputBufferSize(AVCHandle *avcHandle, int* size);
-
- /**
- Users call this function to provide an input structure to the encoder library which will keep
- a list of input structures it receives in case the users call this function many time before
- calling PVAVCEncodeSlice. The encoder library will encode them according to the frame_num order.
- Users should not modify the content of a particular frame until this frame is encoded and
- returned thru CBAVCEnc_ReturnInput() callback function.
- \param "avcHandle" "Handle to the AVC encoder library object."
- \param "input" "Pointer to the input structure."
- \return "AVCENC_SUCCESS for success,
- AVCENC_FAIL if the encoder is not in the right state to take a new input frame.
- AVCENC_NEW_IDR for the detection or determination of a new IDR, with this status,
- the returned NAL is an SPS NAL,
- AVCENC_NO_PICTURE if the input frame coding timestamp is too early, users must
- get next frame or adjust the coding timestamp."
- */
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncSetInput(AVCHandle *avcHandle, AVCFrameIO *input);
-
- /**
- This function is called to encode a NAL unit which can be an SPS NAL, a PPS NAL or
- a VCL (video coding layer) NAL which contains one slice of data. It could be a
- fixed number of macroblocks, as specified in the encoder parameters set, or the
- maximum number of macroblocks fitted into the given input argument "buffer". The
- input frame is taken from the oldest unencoded input frame retrieved by users by
- PVAVCEncGetInput API.
- \param "avcHandle" "Handle to the AVC encoder library object."
- \param "buffer" "Pointer to the output AVC bitstream buffer, the format will be EBSP,
- not RBSP."
- \param "buf_nal_size" "As input, the size of the buffer in bytes.
- This is the physical limitation of the buffer. As output, the size of the EBSP."
- \param "nal_type" "Pointer to the NAL type of the returned buffer."
- \return "AVCENC_SUCCESS for success of encoding one slice,
- AVCENC_PICTURE_READY for the completion of a frame encoding,
- AVCENC_FAIL for failure (this should not occur, though)."
- */
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncodeNAL(AVCHandle *avcHandle, uint8 *buffer, uint *buf_nal_size, int *nal_type);
-
- /**
- This function sniffs the nal_unit_type such that users can call corresponding APIs.
- This function is identical to PVAVCDecGetNALType() in the decoder.
- \param "bitstream" "Pointer to the beginning of a NAL unit (start with forbidden_zero_bit, etc.)."
- \param "size" "size of the bitstream (NumBytesInNALunit + 1)."
- \param "nal_unit_type" "Pointer to the return value of nal unit type."
- \return "AVCENC_SUCCESS if success, AVCENC_FAIL otherwise."
- */
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncGetNALType(uint8 *bitstream, int size, int *nal_type, int *nal_ref_idc);
-
- /**
- This function returns the pointer to internal overrun buffer. Users can call this to query
- whether the overrun buffer has been used to encode the current NAL.
- \param "avcHandle" "Pointer to the handle."
- \return "Pointer to overrun buffer if it is used, otherwise, NULL."
- */
- OSCL_IMPORT_REF uint8* PVAVCEncGetOverrunBuffer(AVCHandle* avcHandle);
-
- /**
- This function returns the reconstructed frame of the most recently encoded frame.
- Note that this frame is not returned to the users yet. Users should only read the
- content of this frame.
- \param "avcHandle" "Handle to the AVC encoder library object."
- \param "output" "Pointer to the input structure."
- \return "AVCENC_SUCCESS for success, AVCENC_NO_PICTURE if no picture to be outputted."
- */
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncGetRecon(AVCHandle *avcHandle, AVCFrameIO *recon);
-
- /**
- This function is used to return the recontructed frame back to the AVC encoder library
- in order to be re-used for encoding operation. If users want the content of it to remain
- unchanged for a long time, they should make a copy of it and release the memory back to
- the encoder. The encoder relies on the id element in the AVCFrameIO structure,
- thus users should not change the id value.
- \param "avcHandle" "Handle to the AVC decoder library object."
- \param "output" "Pointer to the AVCFrameIO structure."
- \return "AVCENC_SUCCESS for success, AVCENC_FAIL for fail for id not found."
- */
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncReleaseRecon(AVCHandle *avcHandle, AVCFrameIO *recon);
-
- /**
- This function performs clean up operation including memory deallocation.
- The encoder will also clear the list of input structures it has not released.
- This implies that users must keep track of the number of input structure they have allocated
- and free them accordingly.
- \param "avcHandle" "Handle to the AVC encoder library object."
- */
- OSCL_IMPORT_REF void PVAVCCleanUpEncoder(AVCHandle *avcHandle);
-
- /**
- This function extracts statistics of the current frame. If the encoder has not finished
- with the current frame, the result is not accurate.
- \param "avcHandle" "Handle to the AVC encoder library object."
- \param "avcStats" "Pointer to AVCEncFrameStats structure."
- \return "void."
- */
- void PVAVCEncGetFrameStats(AVCHandle *avcHandle, AVCEncFrameStats *avcStats);
-
- /**
- These functions are used for the modification of encoding parameters.
- To be polished.
- */
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncUpdateBitRate(AVCHandle *avcHandle, uint32 bitrate);
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncUpdateFrameRate(AVCHandle *avcHandle, uint32 num, uint32 denom);
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncUpdateIDRInterval(AVCHandle *avcHandle, int IDRInterval);
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncIDRRequest(AVCHandle *avcHandle);
- OSCL_IMPORT_REF AVCEnc_Status PVAVCEncUpdateIMBRefresh(AVCHandle *avcHandle, int numMB);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _AVCENC_API_H_ */
-
diff --git a/media/libstagefright/codecs/avc/enc/src/avcenc_int.h b/media/libstagefright/codecs/avc/enc/src/avcenc_int.h
deleted file mode 100644
index 3fe08a1..0000000
--- a/media/libstagefright/codecs/avc/enc/src/avcenc_int.h
+++ /dev/null
@@ -1,471 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-/**
-This file contains application function interfaces to the AVC encoder library
-and necessary type defitionitions and enumerations.
-@publishedAll
-*/
-
-#ifndef AVCENC_INT_H_INCLUDED
-#define AVCENC_INT_H_INCLUDED
-
-#ifndef AVCINT_COMMON_H_INCLUDED
-#include "avcint_common.h"
-#endif
-#ifndef AVCENC_API_H_INCLUDED
-#include "avcenc_api.h"
-#endif
-
-typedef float OsclFloat;
-
-/* Definition for the structures below */
-#define DEFAULT_ATTR 0 /* default memory attribute */
-#define MAX_INPUT_FRAME 30 /* some arbitrary number, it can be much higher than this. */
-#define MAX_REF_FRAME 16 /* max size of the RefPicList0 and RefPicList1 */
-#define MAX_REF_PIC_LIST 33
-
-#define MIN_QP 0
-#define MAX_QP 51
-#define SHIFT_QP 12
-#define LAMBDA_ACCURACY_BITS 16
-#define LAMBDA_FACTOR(lambda) ((int)((double)(1<<LAMBDA_ACCURACY_BITS)*lambda+0.5))
-
-
-#define DISABLE_THRESHOLDING 0
-// for better R-D performance
-#define _LUMA_COEFF_COST_ 4 //!< threshold for luma coeffs
-#define _CHROMA_COEFF_COST_ 4 //!< threshold for chroma coeffs, used to be 7
-#define _LUMA_MB_COEFF_COST_ 5 //!< threshold for luma coeffs of inter Macroblocks
-#define _LUMA_8x8_COEFF_COST_ 5 //!< threshold for luma coeffs of 8x8 Inter Partition
-#define MAX_VALUE 999999 //!< used for start value for some variables
-
-#define WEIGHTED_COST(factor,bits) (((factor)*(bits))>>LAMBDA_ACCURACY_BITS)
-#define MV_COST(f,s,cx,cy,px,py) (WEIGHTED_COST(f,mvbits[((cx)<<(s))-px]+mvbits[((cy)<<(s))-py]))
-#define MV_COST_S(f,cx,cy,px,py) (WEIGHTED_COST(f,mvbits[cx-px]+mvbits[cy-py]))
-
-/* for sub-pel search and interpolation */
-#define SUBPEL_PRED_BLK_SIZE 576 // 24x24
-#define REF_CENTER 75
-#define V2Q_H0Q 1
-#define V0Q_H2Q 2
-#define V2Q_H2Q 3
-
-/*
-#define V3Q_H0Q 1
-#define V3Q_H1Q 2
-#define V0Q_H1Q 3
-#define V1Q_H1Q 4
-#define V1Q_H0Q 5
-#define V1Q_H3Q 6
-#define V0Q_H3Q 7
-#define V3Q_H3Q 8
-#define V2Q_H3Q 9
-#define V2Q_H0Q 10
-#define V2Q_H1Q 11
-#define V2Q_H2Q 12
-#define V3Q_H2Q 13
-#define V0Q_H2Q 14
-#define V1Q_H2Q 15
-*/
-
-
-#define DEFAULT_OVERRUN_BUFFER_SIZE 1000
-
-// associated with the above cost model
-const uint8 COEFF_COST[2][16] =
-{
- {3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}
-};
-
-
-
-//! convert from H.263 QP to H.264 quant given by: quant=pow(2,QP/6)
-const int QP2QUANT[40] =
-{
- 1, 1, 1, 1, 2, 2, 2, 2,
- 3, 3, 3, 4, 4, 4, 5, 6,
- 6, 7, 8, 9, 10, 11, 13, 14,
- 16, 18, 20, 23, 25, 29, 32, 36,
- 40, 45, 51, 57, 64, 72, 81, 91
-};
-
-
-/**
-This enumeration keeps track of the internal status of the encoder whether it is doing
-something. The encoding flow follows the order in which these states are.
-@publishedAll
-*/
-typedef enum
-{
- AVCEnc_Initializing = 0,
- AVCEnc_Encoding_SPS,
- AVCEnc_Encoding_PPS,
- AVCEnc_Analyzing_Frame,
- AVCEnc_WaitingForBuffer, // pending state
- AVCEnc_Encoding_Frame,
-} AVCEnc_State ;
-
-/**
-Bitstream structure contains bitstream related parameters such as the pointer
-to the buffer, the current byte position and bit position. The content of the
-bitstreamBuffer will be in EBSP format as the emulation prevention codes are
-automatically inserted as the RBSP is recorded.
-@publishedAll
-*/
-typedef struct tagEncBitstream
-{
- uint8 *bitstreamBuffer; /* pointer to buffer memory */
- int buf_size; /* size of the buffer memory */
- int write_pos; /* next position to write to bitstreamBuffer */
- int count_zeros; /* count number of consecutive zero */
- uint current_word; /* byte-swapped (MSB left) current word to write to buffer */
- int bit_left; /* number of bit left in current_word */
- uint8 *overrunBuffer; /* extra output buffer to prevent current skip due to output buffer overrun*/
- int oBSize; /* size of allocated overrun buffer */
- void *encvid; /* pointer to the main object */
-
-} AVCEncBitstream;
-
-/**
-This structure is used for rate control purpose and other performance related control
-variables such as, RD cost, statistics, motion search stuffs, etc.
-should be in this structure.
-@publishedAll
-*/
-
-
-typedef struct tagRDInfo
-{
- int QP;
- int actual_bits;
- OsclFloat mad;
- OsclFloat R_D;
-} RDInfo;
-
-typedef struct tagMultiPass
-{
- /* multipass rate control data */
- int target_bits; /* target bits for current frame, = rc->T */
- int actual_bits; /* actual bits for current frame obtained after encoding, = rc->Rc*/
- int QP; /* quantization level for current frame, = rc->Qc*/
- int prev_QP; /* quantization level for previous frame */
- int prev_prev_QP; /* quantization level for previous frame before last*/
- OsclFloat mad; /* mad for current frame, = video->avgMAD*/
- int bitrate; /* bitrate for current frame */
- OsclFloat framerate; /* framerate for current frame*/
-
- int nRe_Quantized; /* control variable for multipass encoding, */
- /* 0 : first pass */
- /* 1 : intermediate pass(quantization and VLC loop only) */
- /* 2 : final pass(de-quantization, idct, etc) */
- /* 3 : macroblock level rate control */
-
- int encoded_frames; /* counter for all encoded frames */
- int re_encoded_frames; /* counter for all multipass encoded frames*/
- int re_encoded_times; /* counter for all times of multipass frame encoding */
-
- /* Multiple frame prediction*/
- RDInfo **pRDSamples; /* pRDSamples[30][32], 30->30fps, 32 -> 5 bit quantizer, 32 candidates*/
- int framePos; /* specific position in previous multiple frames*/
- int frameRange; /* number of overall previous multiple frames */
- int samplesPerFrame[30]; /* number of samples per frame, 30->30fps */
-
- /* Bit allocation for scene change frames and high motion frames */
- OsclFloat sum_mad;
- int counter_BTsrc; /* BT = Bit Transfer, bit transfer from low motion frames or less complicatedly compressed frames */
- int counter_BTdst; /* BT = Bit Transfer, bit transfer to scene change frames or high motion frames or more complicatedly compressed frames */
- OsclFloat sum_QP;
- int diff_counter; /* diff_counter = -diff_counter_BTdst, or diff_counter_BTsrc */
-
- /* For target bitrate or framerate update */
- OsclFloat target_bits_per_frame; /* = C = bitrate/framerate */
- OsclFloat target_bits_per_frame_prev; /* previous C */
- OsclFloat aver_mad; /* so-far average mad could replace sum_mad */
- OsclFloat aver_mad_prev; /* previous average mad */
- int overlapped_win_size; /* transition period of time */
- int encoded_frames_prev; /* previous encoded_frames */
-} MultiPass;
-
-
-typedef struct tagdataPointArray
-{
- int Qp;
- int Rp;
- OsclFloat Mp; /* for MB-based RC */
- struct tagdataPointArray *next;
- struct tagdataPointArray *prev;
-} dataPointArray;
-
-typedef struct tagAVCRateControl
-{
-
- /* these parameters are initialized by the users AVCEncParams */
- /* bitrate-robustness tradeoff */
- uint scdEnable; /* enable scene change detection */
- int idrPeriod; /* IDR period in number of frames */
- int intraMBRate; /* intra MB refresh rate per frame */
- uint dpEnable; /* enable data partitioning */
-
- /* quality-complexity tradeoff */
- uint subPelEnable; /* enable quarter pel search */
- int mvRange; /* motion vector search range in +/- pixel */
- uint subMBEnable; /* enable sub MB prediction mode (4x4, 4x8, 8x4) */
- uint rdOptEnable; /* enable RD-opt mode selection */
- uint twoPass; /* flag for 2 pass encoding ( for future )*/
- uint bidirPred; /* bi-directional prediction for B-frame. */
-
- uint rcEnable; /* enable rate control, '1' on, '0' const QP */
- int initQP; /* initial QP */
-
- /* note the following 3 params are for HRD, these triplets can be a series
- of triplets as the generalized HRD allows. SEI message must be generated in this case. */
- /* We no longer have to differentiate between CBR and VBR. The users to the
- AVC encoder lib will do the mapping from CBR/VBR to these parameters. */
- int32 bitRate; /* target bit rate for the overall clip in bits/second*/
- int32 cpbSize; /* coded picture buffer size in bytes */
- int32 initDelayOffset; /* initial CBP removal delay in bits */
-
- OsclFloat frame_rate; /* frame rate */
- int srcInterval; /* source frame rate in msec */
- int basicUnit; /* number of macroblocks per BU */
-
- /* Then internal parameters for the operation */
- uint first_frame; /* a flag for the first frame */
- int lambda_mf; /* for example */
- int totalSAD; /* SAD of current frame */
-
- /*******************************************/
- /* this part comes from MPEG4 rate control */
- int alpha; /* weight for I frame */
- int Rs; /*bit rate for the sequence (or segment) e.g., 24000 bits/sec */
- int Rc; /*bits used for the current frame. It is the bit count obtained after encoding. */
- int Rp; /*bits to be removed from the buffer per picture. */
- /*? is this the average one, or just the bits coded for the previous frame */
- int Rps; /*bit to be removed from buffer per src frame */
- OsclFloat Ts; /*number of seconds for the sequence (or segment). e.g., 10 sec */
- OsclFloat Ep;
- OsclFloat Ec; /*mean absolute difference for the current frame after motion compensation.*/
- /*If the macroblock is intra coded, the original spatial pixel values are summed.*/
- int Qc; /*quantization level used for the current frame. */
- int Nr; /*number of P frames remaining for encoding.*/
- int Rr; /*number of bits remaining for encoding this sequence (or segment).*/
- int Rr_Old;
- int T; /*target bit to be used for the current frame.*/
- int S; /*number of bits used for encoding the previous frame.*/
- int Hc; /*header and motion vector bits used in the current frame. It includes all the information except to the residual information.*/
- int Hp; /*header and motion vector bits used in the previous frame. It includes all the information except to the residual information.*/
- int Ql; /*quantization level used in the previous frame */
- int Bs; /*buffer size e.g., R/2 */
- int B; /*current buffer level e.g., R/4 - start from the middle of the buffer */
- OsclFloat X1;
- OsclFloat X2;
- OsclFloat X11;
- OsclFloat M; /*safe margin for the buffer */
- OsclFloat smTick; /*ratio of src versus enc frame rate */
- double remnant; /*remainder frame of src/enc frame for fine frame skipping */
- int timeIncRes; /* vol->timeIncrementResolution */
-
- dataPointArray *end; /*quantization levels for the past (20) frames */
-
- int frameNumber; /* ranging from 0 to 20 nodes*/
- int w;
- int Nr_Original;
- int Nr_Old, Nr_Old2;
- int skip_next_frame;
- int Qdep; /* smooth Q adjustment */
- int VBR_Enabled;
-
- int totalFrameNumber; /* total coded frames, for debugging!!*/
-
- char oFirstTime;
-
- int numFrameBits; /* keep track of number of bits of the current frame */
- int NumberofHeaderBits;
- int NumberofTextureBits;
- int numMBHeaderBits;
- int numMBTextureBits;
- double *MADofMB;
- int32 bitsPerFrame;
-
- /* BX rate control, something like TMN8 rate control*/
-
- MultiPass *pMP;
-
- int TMN_W;
- int TMN_TH;
- int VBV_fullness;
- int max_BitVariance_num; /* the number of the maximum bit variance within the given buffer with the unit of 10% of bitrate/framerate*/
- int encoded_frames; /* counter for all encoded frames */
- int low_bound; /* bound for underflow detection, usually low_bound=-Bs/2, but could be changed in H.263 mode */
- int VBV_fullness_offset; /* offset of VBV_fullness, usually is zero, but can be changed in H.263 mode*/
- /* End BX */
-
-} AVCRateControl;
-
-
-/**
-This structure is for the motion vector information. */
-typedef struct tagMV
-{
- int x;
- int y;
- uint sad;
-} AVCMV;
-
-/**
-This structure contains function pointers for different platform dependent implementation of
-functions. */
-typedef struct tagAVCEncFuncPtr
-{
-
- int (*SAD_MB_HalfPel[4])(uint8*, uint8*, int, void *);
- int (*SAD_Macroblock)(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
-
-} AVCEncFuncPtr;
-
-/**
-This structure contains information necessary for correct padding.
-*/
-typedef struct tagPadInfo
-{
- int i;
- int width;
- int j;
- int height;
-} AVCPadInfo;
-
-
-#ifdef HTFM
-typedef struct tagHTFM_Stat
-{
- int abs_dif_mad_avg;
- uint countbreak;
- int offsetArray[16];
- int offsetRef[16];
-} HTFM_Stat;
-#endif
-
-
-/**
-This structure is the main object for AVC encoder library providing access to all
-global variables. It is allocated at PVAVCInitEncoder and freed at PVAVCCleanUpEncoder.
-@publishedAll
-*/
-typedef struct tagEncObject
-{
-
- AVCCommonObj *common;
-
- AVCEncBitstream *bitstream; /* for current NAL */
- uint8 *overrunBuffer; /* extra output buffer to prevent current skip due to output buffer overrun*/
- int oBSize; /* size of allocated overrun buffer */
-
- /* rate control */
- AVCRateControl *rateCtrl; /* pointer to the rate control structure */
-
- /* encoding operation */
- AVCEnc_State enc_state; /* encoding state */
-
- AVCFrameIO *currInput; /* pointer to the current input frame */
-
- int currSliceGroup; /* currently encoded slice group id */
-
- int level[24][16], run[24][16]; /* scratch memory */
- int leveldc[16], rundc[16]; /* for DC component */
- int levelcdc[16], runcdc[16]; /* for chroma DC component */
- int numcoefcdc[2]; /* number of coefficient for chroma DC */
- int numcoefdc; /* number of coefficients for DC component */
-
- int qp_const;
- int qp_const_c;
- /********* intra prediction scratch memory **********************/
- uint8 pred_i16[AVCNumI16PredMode][256]; /* save prediction for MB */
- uint8 pred_i4[AVCNumI4PredMode][16]; /* save prediction for blk */
- uint8 pred_ic[AVCNumIChromaMode][128]; /* for 2 chroma */
-
- int mostProbableI4Mode[16]; /* in raster scan order */
- /********* motion compensation related variables ****************/
- AVCMV *mot16x16; /* Saved motion vectors for 16x16 block*/
- AVCMV(*mot16x8)[2]; /* Saved motion vectors for 16x8 block*/
- AVCMV(*mot8x16)[2]; /* Saved motion vectors for 8x16 block*/
- AVCMV(*mot8x8)[4]; /* Saved motion vectors for 8x8 block*/
-
- /********* subpel position **************************************/
- uint32 subpel_pred[SUBPEL_PRED_BLK_SIZE/*<<2*/]; /* all 16 sub-pel positions */
- uint8 *hpel_cand[9]; /* pointer to half-pel position */
- int best_hpel_pos; /* best position */
- uint8 qpel_cand[8][24*16]; /* pointer to quarter-pel position */
- int best_qpel_pos;
- uint8 *bilin_base[9][4]; /* pointer to 4 position at top left of bilinear quarter-pel */
-
- /* need for intra refresh rate */
- uint8 *intraSearch; /* Intra Array for MBs to be intra searched */
- uint firstIntraRefreshMBIndx; /* keep track for intra refresh */
-
- int i4_sad; /* temporary for i4 mode SAD */
- int *min_cost; /* Minimum cost for the all MBs */
- int lambda_mode; /* Lagrange parameter for mode selection */
- int lambda_motion; /* Lagrange parameter for MV selection */
-
- uint8 *mvbits_array; /* Table for bits spent in the cost funciton */
- uint8 *mvbits; /* An offset to the above array. */
-
- /* to speedup the SAD calculation */
- void *sad_extra_info;
- uint8 currYMB[256]; /* interleaved current macroblock in HTFM order */
-
-#ifdef HTFM
- int nrmlz_th[48]; /* Threshold for fast SAD calculation using HTFM */
- HTFM_Stat htfm_stat; /* For statistics collection */
-#endif
-
- /* statistics */
- int numIntraMB; /* keep track of number of intra MB */
-
- /* encoding complexity control */
- uint fullsearch_enable; /* flag to enable full-pel full-search */
-
- /* misc.*/
- bool outOfBandParamSet; /* flag to enable out-of-band param set */
-
- AVCSeqParamSet extSPS; /* for external SPS */
- AVCPicParamSet extPPS; /* for external PPS */
-
- /* time control */
- uint32 prevFrameNum; /* previous frame number starting from modTimeRef */
- uint32 modTimeRef; /* Reference modTime update every I-Vop*/
- uint32 wrapModTime; /* Offset to modTime Ref, rarely used */
-
- uint prevProcFrameNum; /* previously processed frame number, could be skipped */
- uint prevCodedFrameNum; /* previously encoded frame number */
- /* POC related variables */
- uint32 dispOrdPOCRef; /* reference POC is displayer order unit. */
-
- /* Function pointers */
- AVCEncFuncPtr *functionPointer; /* store pointers to platform specific functions */
-
- /* Application control data */
- AVCHandle *avcHandle;
-
-
-} AVCEncObject;
-
-
-#endif /*AVCENC_INT_H_INCLUDED*/
-
diff --git a/media/libstagefright/codecs/avc/enc/src/avcenc_lib.h b/media/libstagefright/codecs/avc/enc/src/avcenc_lib.h
deleted file mode 100644
index 17e28ef..0000000
--- a/media/libstagefright/codecs/avc/enc/src/avcenc_lib.h
+++ /dev/null
@@ -1,1020 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-/**
-This file contains declarations of internal functions for AVC decoder library.
-@publishedAll
-*/
-#ifndef AVCENC_LIB_H_INCLUDED
-#define AVCENC_LIB_H_INCLUDED
-
-#ifndef AVCLIB_COMMON_H_INCLUDED
-#include "avclib_common.h"
-#endif
-#ifndef AVCENC_INT_H_INCLUDED
-#include "avcenc_int.h"
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
- /*------------- block.c -------------------------*/
-
- /**
- This function perform residue calculation, transform, quantize, inverse quantize,
- inverse transform and residue compensation on a 4x4 block.
- \param "encvid" "Pointer to AVCEncObject."
- \param "blkidx" "raster scan block index of the current 4x4 block."
- \param "cur" "Pointer to the reconstructed block."
- \param "org" "Pointer to the original block."
- \param "coef_cost" "Pointer to the coefficient cost to be filled in and returned."
- \return "Number of non-zero coefficients."
- */
- int dct_luma(AVCEncObject *encvid, int blkidx, uint8 *cur, uint8 *org, int *coef_cost);
-
- /**
- This function performs IDCT on an INTER macroblock.
- \param "video" "Pointer to AVCCommonObj."
- \param "curL" "Pointer to the origin of the macroblock on the current frame."
- \param "currMB" "Pointer to the AVCMacroblock structure."
- \param "picPitch" "Pitch of the current frame."
- \return "void".
- */
- void MBInterIdct(AVCCommonObj *video, uint8 *curL, AVCMacroblock *currMB, int picPitch);
-
- /**
- This function perform residue calculation, transform, quantize, inverse quantize,
- inverse transform and residue compensation on a macroblock.
- \param "encvid" "Pointer to AVCEncObject."
- \param "curL" "Pointer to the reconstructed MB."
- \param "orgL" "Pointer to the original MB."
- \return "void"
- */
- void dct_luma_16x16(AVCEncObject *encvid, uint8 *curL, uint8 *orgL);
-
- /**
- This function perform residue calculation, transform, quantize, inverse quantize,
- inverse transform and residue compensation for chroma components of an MB.
- \param "encvid" "Pointer to AVCEncObject."
- \param "curC" "Pointer to the reconstructed MB."
- \param "orgC" "Pointer to the original MB."
- \param "cr" "Flag whether it is Cr or not."
- \return "void"
- */
- void dct_chroma(AVCEncObject *encvid, uint8 *curC, uint8 *orgC, int cr);
-
- /*----------- init.c ------------------*/
- /**
- This function interprets the encoding parameters provided by users in encParam.
- The results are kept in AVCEncObject, AVCSeqParamSet, AVCPicParamSet and AVCSliceHeader.
- \param "encvid" "Pointer to AVCEncObject."
- \param "encParam" "Pointer to AVCEncParam."
- \param "extSPS" "External SPS template to be followed. NULL if not present."
- \param "extPPS" "External PPS template to be followed. NULL if not present."
- \return "see AVCEnc_Status."
- */
- AVCEnc_Status SetEncodeParam(AVCHandle *avcHandle, AVCEncParams *encParam,
- void *extSPS, void *extPPS);
-
- /**
- This function verifies the encoding parameters whether they meet the set of supported
- tool by a specific profile. If the profile is not set, it will just find the closest
- profile instead of verifying it.
- \param "video" "Pointer to AVCEncObject."
- \param "seqParam" "Pointer to AVCSeqParamSet."
- \param "picParam" "Pointer to AVCPicParamSet."
- \return "AVCENC_SUCCESS if success,
- AVCENC_PROFILE_NOT_SUPPORTED if the specified profile
- is not supported by this version of the library,
- AVCENC_TOOLS_NOT_SUPPORTED if any of the specified encoding tools are
- not supported by the user-selected profile."
- */
- AVCEnc_Status VerifyProfile(AVCEncObject *video, AVCSeqParamSet *seqParam, AVCPicParamSet *picParam);
-
- /**
- This function verifies the encoding parameters whether they meet the requirement
- for a specific level. If the level is not set, it will just find the closest
- level instead of verifying it.
- \param "video" "Pointer to AVCEncObject."
- \param "seqParam" "Pointer to AVCSeqParamSet."
- \param "picParam" "Pointer to AVCPicParamSet."
- \return "AVCENC_SUCCESS if success,
- AVCENC_LEVEL_NOT_SUPPORTED if the specified level
- is not supported by this version of the library,
- AVCENC_LEVEL_FAIL if any of the encoding parameters exceed
- the range of the user-selected level."
- */
- AVCEnc_Status VerifyLevel(AVCEncObject *video, AVCSeqParamSet *seqParam, AVCPicParamSet *picParam);
-
- /**
- This funciton initializes the frame encoding by setting poc/frame_num related parameters. it
- also performs motion estimation.
- \param "encvid" "Pointer to the AVCEncObject."
- \return "AVCENC_SUCCESS if success, AVCENC_NO_PICTURE if there is no input picture
- in the queue to encode, AVCENC_POC_FAIL or AVCENC_CONSECUTIVE_NONREF for POC
- related errors, AVCENC_NEW_IDR if new IDR is detected."
- */
- AVCEnc_Status InitFrame(AVCEncObject *encvid);
-
- /**
- This function initializes slice header related variables and other variables necessary
- for decoding one slice.
- \param "encvid" "Pointer to the AVCEncObject."
- \return "AVCENC_SUCCESS if success."
- */
- AVCEnc_Status InitSlice(AVCEncObject *encvid);
-
- /*----------- header.c ----------------*/
- /**
- This function performs bitstream encoding of the sequence parameter set NAL.
- \param "encvid" "Pointer to the AVCEncObject."
- \param "stream" "Pointer to AVCEncBitstream."
- \return "AVCENC_SUCCESS if success or AVCENC_SPS_FAIL or others for unexpected failure which
- should not occur. The SPS parameters should all be verified before this function is called."
- */
- AVCEnc_Status EncodeSPS(AVCEncObject *encvid, AVCEncBitstream *stream);
-
- /**
- This function encodes the VUI parameters into the sequence parameter set bitstream.
- \param "stream" "Pointer to AVCEncBitstream."
- \param "vui" "Pointer to AVCVUIParams."
- \return "nothing."
- */
- void EncodeVUI(AVCEncBitstream* stream, AVCVUIParams* vui);
-
- /**
- This function encodes HRD parameters into the sequence parameter set bitstream
- \param "stream" "Pointer to AVCEncBitstream."
- \param "hrd" "Pointer to AVCHRDParams."
- \return "nothing."
- */
- void EncodeHRD(AVCEncBitstream* stream, AVCHRDParams* hrd);
-
-
- /**
- This function performs bitstream encoding of the picture parameter set NAL.
- \param "encvid" "Pointer to the AVCEncObject."
- \param "stream" "Pointer to AVCEncBitstream."
- \return "AVCENC_SUCCESS if success or AVCENC_PPS_FAIL or others for unexpected failure which
- should not occur. The SPS parameters should all be verified before this function is called."
- */
- AVCEnc_Status EncodePPS(AVCEncObject *encvid, AVCEncBitstream *stream);
-
- /**
- This function encodes slice header information which has been initialized or fabricated
- prior to entering this funciton.
- \param "encvid" "Pointer to the AVCEncObject."
- \param "stream" "Pointer to AVCEncBitstream."
- \return "AVCENC_SUCCESS if success or bitstream fail statuses."
- */
- AVCEnc_Status EncodeSliceHeader(AVCEncObject *encvid, AVCEncBitstream *stream);
-
- /**
- This function encodes reference picture list reordering relted syntax.
- \param "video" "Pointer to AVCCommonObj."
- \param "stream" "Pointer to AVCEncBitstream."
- \param "sliceHdr" "Pointer to AVCSliceHdr."
- \param "slice_type" "Value of slice_type - 5 if greater than 5."
- \return "AVCENC_SUCCESS for success and AVCENC_FAIL otherwise."
- */
- AVCEnc_Status ref_pic_list_reordering(AVCCommonObj *video, AVCEncBitstream *stream, AVCSliceHeader *sliceHdr, int slice_type);
-
- /**
- This function encodes dec_ref_pic_marking related syntax.
- \param "video" "Pointer to AVCCommonObj."
- \param "stream" "Pointer to AVCEncBitstream."
- \param "sliceHdr" "Pointer to AVCSliceHdr."
- \return "AVCENC_SUCCESS for success and AVCENC_FAIL otherwise."
- */
- AVCEnc_Status dec_ref_pic_marking(AVCCommonObj *video, AVCEncBitstream *stream, AVCSliceHeader *sliceHdr);
-
- /**
- This function initializes the POC related variables and the POC syntax to be encoded
- to the slice header derived from the disp_order and is_reference flag of the original
- input frame to be encoded.
- \param "video" "Pointer to the AVCEncObject."
- \return "AVCENC_SUCCESS if success,
- AVCENC_POC_FAIL if the poc type is undefined or
- AVCENC_CONSECUTIVE_NONREF if there are consecutive non-reference frame for POC type 2."
- */
- AVCEnc_Status InitPOC(AVCEncObject *video);
-
- /**
- This function performs POC related operation after a picture is decoded.
- \param "video" "Pointer to AVCCommonObj."
- \return "AVCENC_SUCCESS"
- */
- AVCEnc_Status PostPOC(AVCCommonObj *video);
-
- /*----------- bitstream_io.c ----------------*/
- /**
- This function initializes the bitstream structure with the information given by
- the users.
- \param "bitstream" "Pointer to the AVCEncBitstream structure."
- \param "buffer" "Pointer to the unsigned char buffer for output."
- \param "buf_size" "The size of the buffer in bytes."
- \param "overrunBuffer" "Pointer to extra overrun buffer."
- \param "oBSize" "Size of overrun buffer in bytes."
- \return "AVCENC_SUCCESS if success, AVCENC_BITSTREAM_INIT_FAIL if fail"
- */
- AVCEnc_Status BitstreamEncInit(AVCEncBitstream *bitstream, uint8 *buffer, int buf_size,
- uint8 *overrunBuffer, int oBSize);
-
- /**
- This function writes the data from the cache into the bitstream buffer. It also adds the
- emulation prevention code if necessary.
- \param "stream" "Pointer to the AVCEncBitstream structure."
- \return "AVCENC_SUCCESS if success or AVCENC_BITSTREAM_BUFFER_FULL if fail."
- */
- AVCEnc_Status AVCBitstreamSaveWord(AVCEncBitstream *stream);
-
- /**
- This function writes the codeword into the cache which will eventually be written to
- the bitstream buffer.
- \param "stream" "Pointer to the AVCEncBitstream structure."
- \param "nBits" "Number of bits in the codeword."
- \param "code" "The codeword."
- \return "AVCENC_SUCCESS if success or AVCENC_BITSTREAM_BUFFER_FULL if fail."
- */
- AVCEnc_Status BitstreamWriteBits(AVCEncBitstream *stream, int nBits, uint code);
-
- /**
- This function writes one bit of data into the cache which will eventually be written
- to the bitstream buffer.
- \param "stream" "Pointer to the AVCEncBitstream structure."
- \param "code" "The codeword."
- \return "AVCENC_SUCCESS if success or AVCENC_BITSTREAM_BUFFER_FULL if fail."
- */
- AVCEnc_Status BitstreamWrite1Bit(AVCEncBitstream *stream, uint code);
-
- /**
- This function adds trailing bits to the bitstream and reports back the final EBSP size.
- \param "stream" "Pointer to the AVCEncBitstream structure."
- \param "nal_size" "Output the final NAL size."
- \return "AVCENC_SUCCESS if success or AVCENC_BITSTREAM_BUFFER_FULL if fail."
- */
- AVCEnc_Status BitstreamTrailingBits(AVCEncBitstream *bitstream, uint *nal_size);
-
- /**
- This function checks whether the current bit position is byte-aligned or not.
- \param "stream" "Pointer to the bitstream structure."
- \return "true if byte-aligned, false otherwise."
- */
- bool byte_aligned(AVCEncBitstream *stream);
-
-
- /**
- This function checks the availability of overrun buffer and switches to use it when
- normal bufffer is not big enough.
- \param "stream" "Pointer to the bitstream structure."
- \param "numExtraBytes" "Number of extra byte needed."
- \return "AVCENC_SUCCESS or AVCENC_FAIL."
- */
- AVCEnc_Status AVCBitstreamUseOverrunBuffer(AVCEncBitstream* stream, int numExtraBytes);
-
-
- /*-------------- intra_est.c ---------------*/
-
- /** This function performs intra/inter decision based on ABE.
- \param "encvid" "Pointer to AVCEncObject."
- \param "min_cost" "Best inter cost."
- \param "curL" "Pointer to the current MB origin in reconstructed frame."
- \param "picPitch" "Pitch of the reconstructed frame."
- \return "Boolean for intra mode."
- */
-
-//bool IntraDecisionABE(AVCEncObject *encvid, int min_cost, uint8 *curL, int picPitch);
- bool IntraDecision(int *min_cost, uint8 *cur, int pitch, bool ave);
-
- /**
- This function performs intra prediction mode search.
- \param "encvid" "Pointer to AVCEncObject."
- \param "mbnum" "Current MB number."
- \param "curL" "Pointer to the current MB origin in reconstructed frame."
- \param "picPitch" "Pitch of the reconstructed frame."
- \return "void."
- */
- void MBIntraSearch(AVCEncObject *encvid, int mbnum, uint8 *curL, int picPitch);
-
- /**
- This function generates all the I16 prediction modes for an MB and keep it in
- encvid->pred_i16.
- \param "encvid" "Pointer to AVCEncObject."
- \return "void"
- */
- void intrapred_luma_16x16(AVCEncObject *encvid);
-
- /**
- This function calculate the cost of all I16 modes and compare them to get the minimum.
- \param "encvid" "Pointer to AVCEncObject."
- \param "orgY" "Pointer to the original luma MB."
- \param "min_cost" "Pointer to the minimal cost so-far."
- \return "void"
- */
- void find_cost_16x16(AVCEncObject *encvid, uint8 *orgY, int *min_cost);
-
- /**
- This function calculates the cost of each I16 mode.
- \param "org" "Pointer to the original luma MB."
- \param "org_pitch" "Stride size of the original frame."
- \param "pred" "Pointer to the prediction values."
- \param "min_cost" "Minimal cost so-far."
- \return "Cost"
- */
-
- int cost_i16(uint8 *org, int org_pitch, uint8 *pred, int min_cost);
-
- /**
- This function generates all the I4 prediction modes and select the best one
- for all the blocks inside a macroblock.It also calls dct_luma to generate the reconstructed
- MB, and transform coefficients to be encoded.
- \param "encvid" "Pointer to AVCEncObject."
- \param "min_cost" "Pointer to the minimal cost so-far."
- \return "void"
- */
- void mb_intra4x4_search(AVCEncObject *encvid, int *min_cost);
-
- /**
- This function calculates the most probable I4 mode of a given 4x4 block
- from neighboring informationaccording to AVC/H.264 standard.
- \param "video" "Pointer to AVCCommonObj."
- \param "blkidx" "The current block index."
- \return "Most probable mode."
- */
- int FindMostProbableI4Mode(AVCCommonObj *video, int blkidx);
-
- /**
- This function is where a lot of actions take place in the 4x4 block level inside
- mb_intra4x4_search.
- \param "encvid" "Pointer to AVCEncObject."
- \param "blkidx" "The current 4x4 block index."
- \param "cur" "Pointer to the reconstructed block."
- \param "org" "Pointer to the original block."
- \return "Minimal cost, also set currMB->i4Mode"
- */
- int blk_intra4x4_search(AVCEncObject *encvid, int blkidx, uint8 *cur, uint8 *org);
-
- /**
- This function calculates the cost of a given I4 prediction mode.
- \param "org" "Pointer to the original block."
- \param "org_pitch" "Stride size of the original frame."
- \param "pred" "Pointer to the prediction block. (encvid->pred_i4)"
- \param "cost" "Pointer to the minimal cost (to be updated)."
- \return "void"
- */
- void cost_i4(uint8 *org, int org_pitch, uint8 *pred, uint16 *cost);
-
- /**
- This function performs chroma intra search. Each mode is saved in encvid->pred_ic.
- \param "encvid" "Pointer to AVCEncObject."
- \return "void"
- */
- void chroma_intra_search(AVCEncObject *encvid);
-
- /**
- This function calculates the cost of a chroma prediction mode.
- \param "orgCb" "Pointer to the original Cb block."
- \param "orgCr" "Pointer to the original Cr block."
- \param "org_pitch" "Stride size of the original frame."
- \param "pred" "Pointer to the prediction block (encvid->pred_ic)"
- \param "mincost" "Minimal cost so far."
- \return "Cost."
- */
-
- int SATDChroma(uint8 *orgCb, uint8 *orgCr, int org_pitch, uint8 *pred, int mincost);
-
- /*-------------- motion_comp.c ---------------*/
-
- /**
- This is a main function to peform inter prediction.
- \param "encvid" "Pointer to AVCEncObject."
- \param "video" "Pointer to AVCCommonObj."
- \return "void".
- */
- void AVCMBMotionComp(AVCEncObject *encvid, AVCCommonObj *video);
-
-
- /**
- This function is called for luma motion compensation.
- \param "ref" "Pointer to the origin of a reference luma."
- \param "picwidth" "Width of the picture."
- \param "picheight" "Height of the picture."
- \param "x_pos" "X-coordinate of the predicted block in quarter pel resolution."
- \param "y_pos" "Y-coordinate of the predicted block in quarter pel resolution."
- \param "pred" "Pointer to the output predicted block."
- \param "pred_pitch" "Width of pred."
- \param "blkwidth" "Width of the current partition."
- \param "blkheight" "Height of the current partition."
- \return "void"
- */
- void eLumaMotionComp(uint8 *ref, int picwidth, int picheight,
- int x_pos, int y_pos,
- uint8 *pred, int pred_pitch,
- int blkwidth, int blkheight);
-
- void eFullPelMC(uint8 *in, int inwidth, uint8 *out, int outpitch,
- int blkwidth, int blkheight);
-
- void eHorzInterp1MC(uint8 *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight, int dx);
-
- void eHorzInterp2MC(int *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight, int dx);
-
- void eHorzInterp3MC(uint8 *in, int inpitch, int *out, int outpitch,
- int blkwidth, int blkheight);
-
- void eVertInterp1MC(uint8 *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight, int dy);
-
- void eVertInterp2MC(uint8 *in, int inpitch, int *out, int outpitch,
- int blkwidth, int blkheight);
-
- void eVertInterp3MC(int *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight, int dy);
-
- void eDiagonalInterpMC(uint8 *in1, uint8 *in2, int inpitch,
- uint8 *out, int outpitch,
- int blkwidth, int blkheight);
-
- void eChromaMotionComp(uint8 *ref, int picwidth, int picheight,
- int x_pos, int y_pos, uint8 *pred, int pred_pitch,
- int blkwidth, int blkheight);
-
- void eChromaDiagonalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight);
-
- void eChromaHorizontalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight);
-
- void eChromaVerticalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight);
-
- void eChromaFullMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight);
-
- void eChromaVerticalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight);
-
- void eChromaHorizontalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight);
-
- void eChromaDiagonalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight);
-
-
- /*-------------- motion_est.c ---------------*/
-
- /**
- Allocate and initialize arrays necessary for motion search algorithm.
- \param "envid" "Pointer to AVCEncObject."
- \return "AVC_SUCCESS or AVC_MEMORY_FAIL."
- */
- AVCEnc_Status InitMotionSearchModule(AVCHandle *avcHandle);
-
- /**
- Clean up memory allocated in InitMotionSearchModule.
- \param "envid" "Pointer to AVCEncObject."
- \return "void."
- */
- void CleanMotionSearchModule(AVCHandle *avcHandle);
-
-
- /**
- This function performs motion estimation of all macroblocks in a frame during the InitFrame.
- The goal is to find the best MB partition for inter and find out if intra search is needed for
- any MBs. This intra MB tendency can be used for scene change detection.
- \param "encvid" "Pointer to AVCEncObject."
- \return "void"
- */
- void AVCMotionEstimation(AVCEncObject *encvid);
-
- /**
- This function performs repetitive edge padding to the reference picture by adding 16 pixels
- around the luma and 8 pixels around the chromas.
- \param "refPic" "Pointer to the reference picture."
- \return "void"
- */
- void AVCPaddingEdge(AVCPictureData *refPic);
-
- /**
- This function keeps track of intra refresh macroblock locations.
- \param "encvid" "Pointer to the global array structure AVCEncObject."
- \param "mblock" "Pointer to the array of AVCMacroblock structures."
- \param "totalMB" "Total number of MBs in a frame."
- \param "numRefresh" "Number of MB to be intra refresh in a single frame."
- \return "void"
- */
- void AVCRasterIntraUpdate(AVCEncObject *encvid, AVCMacroblock *mblock, int totalMB, int numRefresh);
-
-#ifdef HTFM
- void InitHTFM(VideoEncData *encvid, HTFM_Stat *htfm_stat, double *newvar, int *collect);
- void UpdateHTFM(AVCEncObject *encvid, double *newvar, double *exp_lamda, HTFM_Stat *htfm_stat);
- void CalcThreshold(double pf, double exp_lamda[], int nrmlz_th[]);
- void HTFMPrepareCurMB_AVC(AVCEncObject *encvid, HTFM_Stat *htfm_stat, uint8 *cur, int pitch);
-#endif
-
- /**
- This function reads the input MB into a smaller faster memory space to minimize the cache miss.
- \param "encvid" "Pointer to the global AVCEncObject."
- \param "cur" "Pointer to the original input macroblock."
- \param "pitch" "Stride size of the input frame (luma)."
- \return "void"
- */
- void AVCPrepareCurMB(AVCEncObject *encvid, uint8 *cur, int pitch);
-
- /**
- Performs motion vector search for a macroblock.
- \param "encvid" "Pointer to AVCEncObject structure."
- \param "cur" "Pointer to the current macroblock in the input frame."
- \param "best_cand" "Array of best candidates (to be filled in and returned)."
- \param "i0" "X-coordinate of the macroblock."
- \param "j0" "Y-coordinate of the macroblock."
- \param "type_pred" "Indicates the type of operations."
- \param "FS_en" "Flag for fullsearch enable."
- \param "hp_guess" "Guess for half-pel search."
- \return "void"
- */
- void AVCMBMotionSearch(AVCEncObject *encvid, uint8 *cur, uint8 *best_cand[],
- int i0, int j0, int type_pred, int FS_en, int *hp_guess);
-
-//AVCEnc_Status AVCMBMotionSearch(AVCEncObject *encvid, AVCMacroblock *currMB, int mbNum,
-// int num_pass);
-
- /**
- Perform full-pel exhaustive search around the predicted MV.
- \param "encvid" "Pointer to AVCEncObject structure."
- \param "prev" "Pointer to the reference frame."
- \param "cur" "Pointer to the input macroblock."
- \param "imin" "Pointer to minimal mv (x)."
- \param "jmin" "Pointer to minimal mv (y)."
- \param "ilow, ihigh, jlow, jhigh" "Lower bound on search range."
- \param "cmvx, cmvy" "Predicted MV value."
-
- \return "The cost function of the best candidate."
- */
- int AVCFullSearch(AVCEncObject *encvid, uint8 *prev, uint8 *cur,
- int *imin, int *jmin, int ilow, int ihigh, int jlow, int jhigh,
- int cmvx, int cmvy);
-
- /**
- Select candidates from neighboring blocks according to the type of the
- prediction selection.
- \param "mvx" "Pointer to the candidate, x-coordinate."
- \param "mvy" "Pointer to the candidate, y-coordinate."
- \param "num_can" "Pointer to the number of candidates returned."
- \param "imb" "The MB index x-coordinate."
- \param "jmb" "The MB index y-coordinate."
- \param "type_pred" "Type of the prediction."
- \param "cmvx, cmvy" "Pointer to predicted MV (modified version)."
- \return "void."
- */
- void AVCCandidateSelection(int *mvx, int *mvy, int *num_can, int imb, int jmb,
- AVCEncObject *encvid, int type_pred, int *cmvx, int *cmvy);
-
- /**
- Utility function to move the values in the array dn according to the new
- location to avoid redundant calculation.
- \param "dn" "Array of integer of size 9."
- \param "new_loc" "New location index."
- \return "void."
- */
- void AVCMoveNeighborSAD(int dn[], int new_loc);
-
- /**
- Find minimum index of dn.
- \param "dn" "Array of integer of size 9."
- \return "The index of dn with the smallest dn[] value."
- */
- int AVCFindMin(int dn[]);
-
-
- /*------------- findhalfpel.c -------------------*/
-
- /**
- Search for the best half-pel resolution MV around the full-pel MV.
- \param "encvid" "Pointer to the global AVCEncObject structure."
- \param "cur" "Pointer to the current macroblock."
- \param "mot" "Pointer to the AVCMV array of the frame."
- \param "ncand" "Pointer to the origin of the fullsearch result."
- \param "xpos" "The current MB position in x."
- \param "ypos" "The current MB position in y."
- \param "hp_guess" "Input to help speedup the search."
- \param "cmvx, cmvy" "Predicted motion vector use for mvcost."
- \return "Minimal cost (SATD) without MV cost. (for rate control purpose)"
- */
- int AVCFindHalfPelMB(AVCEncObject *encvid, uint8 *cur, AVCMV *mot, uint8 *ncand,
- int xpos, int ypos, int hp_guess, int cmvx, int cmvy);
-
- /**
- This function generates sub-pel pixels required to do subpel MV search.
- \param "subpel_pred" "Pointer to 2-D array, each array for each position."
- \param "ncand" "Pointer to the full-pel center position in ref frame."
- \param "lx" "Pitch of the ref frame."
- \return "void"
- */
- void GenerateHalfPelPred(uint8 *subpel_pred, uint8 *ncand, int lx);
-
- /**
- This function calculate vertical interpolation at half-point of size 4x17.
- \param "dst" "Pointer to destination."
- \param "ref" "Pointer to the starting reference pixel."
- \return "void."
- */
- void VertInterpWClip(uint8 *dst, uint8 *ref);
-
- /**
- This function generates quarter-pel pixels around the best half-pel result
- during the sub-pel MV search.
- \param "bilin_base" "Array of pointers to be used as basis for q-pel interp."
- \param "qpel_pred" "Array of pointers pointing to quarter-pel candidates."
- \param "hpel_pos" "Best half-pel position at the center."
- \return "void"
- */
- void GenerateQuartPelPred(uint8 **bilin_base, uint8 *qpel_pred, int hpel_pos);
-
- /**
- This function calculates the SATD of a subpel candidate.
- \param "cand" "Pointer to a candidate."
- \param "cur" "Pointer to the current block."
- \param "dmin" "Min-so-far SATD."
- \return "Sum of Absolute Transformed Difference."
- */
- int SATD_MB(uint8 *cand, uint8 *cur, int dmin);
-
- /*------------- rate_control.c -------------------*/
-
- /** This function is a utility function. It returns average QP of the previously encoded frame.
- \param "rateCtrl" "Pointer to AVCRateControl structure."
- \return "Average QP."
- */
- int GetAvgFrameQP(AVCRateControl *rateCtrl);
-
- /**
- This function takes the timestamp of the input and determine whether it should be encoded
- or skipped.
- \param "encvid" "Pointer to the AVCEncObject structure."
- \param "rateCtrl" "Pointer to the AVCRateControl structure."
- \param "modTime" "The 32 bit timestamp of the input frame."
- \param "frameNum" "Pointer to the frame number if to be encoded."
- \return "AVC_SUCCESS or else."
- */
- AVCEnc_Status RCDetermineFrameNum(AVCEncObject *encvid, AVCRateControl *rateCtrl, uint32 modTime, uint *frameNum);
-
- /**
- This function updates the buffer fullness when frames are dropped either by the
- rate control algorithm or by the users to make sure that target bit rate is still met.
- \param "video" "Pointer to the common object structure."
- \param "rateCtrl" "Pointer to rate control structure."
- \param "frameInc" "Difference of the current frame number and previous frame number."
- \return "void."
- */
- void RCUpdateBuffer(AVCCommonObj *video, AVCRateControl *rateCtrl, int frameInc);
-
- /**
- This function initializes rate control module and allocates necessary bufferes to do the job.
- \param "avcHandle" "Pointer to the encoder handle."
- \return "AVCENC_SUCCESS or AVCENC_MEMORY_FAIL."
- */
- AVCEnc_Status InitRateControlModule(AVCHandle *avcHandle);
-
- /**
- This function frees buffers allocated in InitRateControlModule.
- \param "avcHandle" "Pointer to the encoder handle."
- \return "void."
- */
- void CleanupRateControlModule(AVCHandle *avcHandle);
-
- /**
- This function is called at the beginning of each GOP or the first IDR frame. It calculates
- target bits for a GOP.
- \param "encvid" "Pointer to the encoder object."
- \return "void."
- */
- void RCInitGOP(AVCEncObject *encvid);
-
- /**
- This function calculates target bits for a particular frame.
- \param "video" "Pointer to the AVCEncObject structure."
- \return "void"
- */
- void RCInitFrameQP(AVCEncObject *video);
-
- /**
- This function calculates QP for the upcoming frame or basic unit.
- \param "encvid" "Pointer to the encoder object."
- \param "rateCtrl" "Pointer to the rate control object."
- \return "QP value ranging from 0-51."
- */
- int RCCalculateQP(AVCEncObject *encvid, AVCRateControl *rateCtrl);
-
- /**
- This function translates the luma QP to chroma QP and calculates lambda based on QP.
- \param "video" "Pointer to the AVCEncObject structure."
- \return "void"
- */
- void RCInitChromaQP(AVCEncObject *encvid);
-
- /**
- This function is called before encoding each macroblock.
- \param "encvid" "Pointer to the encoder object."
- \return "void."
- */
- void RCInitMBQP(AVCEncObject *encvid);
-
- /**
- This function updates bits usage stats after encoding an macroblock.
- \param "video" "Pointer to AVCCommonObj."
- \param "rateCtrl" "Pointer to AVCRateControl."
- \param "num_header_bits" "Number of bits used for MB header."
- \param "num_texture_bits" "Number of bits used for MB texture."
- \return "void"
- */
- void RCPostMB(AVCCommonObj *video, AVCRateControl *rateCtrl, int num_header_bits, int num_texture_bits);
-
- /**
- This function calculates the difference between prediction and original MB.
- \param "encvid" "Pointer to the encoder object."
- \param "currMB" "Pointer to the current macroblock structure."
- \param "orgL" "Pointer to the original MB."
- \param "orgPitch" "Pointer to the original picture pitch."
- \return "void."
- */
- void RCCalculateMAD(AVCEncObject *encvid, AVCMacroblock *currMB, uint8 *orgL, int orgPitch);
-
- /**
- Restore QP related parameters of previous MB when current MB is skipped.
- \param "currMB" "Pointer to the current macroblock."
- \param "video" "Pointer to the common video structure."
- \param "encvid" "Pointer to the global encoding structure."
- \return "void"
- */
- void RCRestoreQP(AVCMacroblock *currMB, AVCCommonObj *video, AVCEncObject *encvid);
-
- /**
- This function is called after done with a frame.
- \param "encvid" "Pointer to the encoder object."
- \return "AVCENC_SUCCESS or AVCENC_SKIPPED_PICTURE when bufer overflow (need to discard current frame)."
- */
- AVCEnc_Status RCUpdateFrame(AVCEncObject *encvid);
-
- /*--------- residual.c -------------------*/
-
- /**
- This function encodes the intra pcm data and fill it in the corresponding location
- on the current picture.
- \param "video" "Pointer to AVCEncObject."
- \return "AVCENC_SUCCESS if success, or else for bitstream errors."
- */
- AVCEnc_Status EncodeIntraPCM(AVCEncObject *video);
-
- /**
- This function performs CAVLC syntax encoding on the run and level information of the coefficients.
- The level and run arrays are elements in AVCEncObject structure, populated by TransQuantZZ,
- TransQuantIntraDC and TransQuantChromaDC functions.
- \param "video" "Pointer to AVCEncObject."
- \param "type" "One of AVCResidualType for a particular 4x4 block."
- \param "bindx" "Block index or number of nonzero coefficients for AVC_Intra16DC and AVC_ChromaDC mode."
- \param "currMB" "Pointer to the current macroblock structure."
- \return "AVCENC_SUCCESS for success."
- \Note "This function has 32-bit machine specific instruction!!!!"
- */
- AVCEnc_Status enc_residual_block(AVCEncObject *encvid, AVCResidualType type, int bindx, AVCMacroblock *currMB);
-
-
- /*------------- sad.c ---------------------------*/
-
-
- int AVCSAD_MB_HalfPel_Cxhyh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
- int AVCSAD_MB_HalfPel_Cyh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
- int AVCSAD_MB_HalfPel_Cxh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
- int AVCSAD_Macroblock_C(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
-
-#ifdef HTFM /* 3/2/1, Hypothesis Testing Fast Matching */
- int AVCSAD_MB_HP_HTFM_Collectxhyh(uint8 *ref, uint8 *blk, int dmin_x, void *extra_info);
- int AVCSAD_MB_HP_HTFM_Collectyh(uint8 *ref, uint8 *blk, int dmin_x, void *extra_info);
- int AVCSAD_MB_HP_HTFM_Collectxh(uint8 *ref, uint8 *blk, int dmin_x, void *extra_info);
- int AVCSAD_MB_HP_HTFMxhyh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
- int AVCSAD_MB_HP_HTFMyh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
- int AVCSAD_MB_HP_HTFMxh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
- int AVCSAD_MB_HTFM_Collect(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
- int AVCSAD_MB_HTFM(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
-#endif
-
-
- /*------------- slice.c -------------------------*/
-
- /**
- This function performs the main encoding loop for a slice.
- \param "encvid" "Pointer to AVCEncObject."
- \return "AVCENC_SUCCESS for success, AVCENC_PICTURE_READY for end-of-picture and
- AVCENC_FAIL or AVCENC_SLICE_EMPTY otherwise."
- */
- AVCEnc_Status AVCEncodeSlice(AVCEncObject *encvid);
-
- /**
- This function performs the main encoding operation for one macroblock.
- \param "video" "pointer to AVCEncObject."
- \return "AVCENC_SUCCESS for success, or other bitstream related failure status."
- */
- AVCEnc_Status EncodeMB(AVCEncObject *video);
-
- /**
- This function calls prediction INTRA/INTER functions, transform,
- quantization and zigzag scanning to get the run-level symbols.
- \param "encvid" "pointer to AVCEncObject."
- \param "curL" "pointer to Luma component of the current frame.
- \param "curCb" "pointer to Cb component of the current frame.
- \param "curCr" "pointer to Cr component of the current frame.
- \return "void for now."
- */
- void MBPredTransQuantZZ(AVCEncObject *encvid, uint8 *curL, uint8 *curCb, uint8 *curCr);
-
- /**
- This function copies the content of the prediction MB into the reconstructed YUV
- frame directly.
- \param "curL" "Pointer to the destination Y component."
- \param "curCb" "Pointer to the destination Cb component."
- \param "curCr" "Pointer to the destination Cr component."
- \param "predBlock" "Pointer to the prediction MB."
- \param "picWidth" "The width of the frame."
- \return "None."
- */
- void Copy_MB(uint8 *curL, uint8 *curCb, uint8 *curCr, uint8 *predBlock, int picWidth);
-
- /**
- This function encodes the mb_type, CBP, prediction mode, ref idx and MV.
- \param "currMB" "Pointer to the current macroblock structure."
- \param "video" "Pointer to the AVCEncObject structure."
- \return "AVCENC_SUCCESS for success or else for fail."
- */
- AVCEnc_Status EncodeMBHeader(AVCMacroblock *currMB, AVCEncObject *video);
-
- /**
- This function finds the right mb_type for a macroblock given the mbMode, CBP,
- NumPart, PredPartMode.
- \param "currMB" "Pointer to the current macroblock structure."
- \param "slice_type" "Value of the slice_type."
- \return "mb_type."
- */
- uint InterpretMBType(AVCMacroblock *currMB, int slice_type);
-
- /**
- This function encodes the mb_pred part of the macroblock data.
- \param "video" "Pointer to the AVCCommonObj structure."
- \param "currMB" "Pointer to the current macroblock structure."
- \param "stream" "Pointer to the AVCEncBitstream structure."
- \return "AVCENC_SUCCESS for success or bitstream fail status."
- */
- AVCEnc_Status mb_pred(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream);
-
- /**
- This function encodes the sub_mb_pred part of the macroblock data.
- \param "video" "Pointer to the AVCCommonObj structure."
- \param "currMB" "Pointer to the current macroblock structure."
- \param "stream" "Pointer to the AVCEncBitstream structure."
- \return "AVCENC_SUCCESS for success or bitstream fail status."
- */
- AVCEnc_Status sub_mb_pred(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream);
-
- /**
- This function interprets the sub_mb_type and sets necessary information
- when the slice type is AVC_P_SLICE.
- in the macroblock structure.
- \param "mblock" "Pointer to current AVCMacroblock."
- \param "sub_mb_type" "From the syntax bitstream."
- \return "void"
- */
- void InterpretSubMBTypeP(AVCMacroblock *mblock, uint *sub_mb_type);
-
- /**
- This function interprets the sub_mb_type and sets necessary information
- when the slice type is AVC_B_SLICE.
- in the macroblock structure.
- \param "mblock" "Pointer to current AVCMacroblock."
- \param "sub_mb_type" "From the syntax bitstream."
- \return "void"
- */
- void InterpretSubMBTypeB(AVCMacroblock *mblock, uint *sub_mb_type);
-
- /**
- This function encodes intra 4x4 mode. It calculates the predicted I4x4 mode and the
- remnant to be encoded.
- \param "video" "Pointer to AVCEncObject structure."
- \param "currMB" "Pointer to the AVCMacroblock structure."
- \param "stream" "Pointer to AVCEncBitstream sructure."
- \return "AVCENC_SUCCESS for success."
- */
- AVCEnc_Status EncodeIntra4x4Mode(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream);
-
- /*------------- vlc_encode.c -----------------------*/
- /**
- This function encodes and writes a value into an Exp-Golomb codeword.
- \param "bitstream" "Pointer to AVCEncBitstream."
- \param "codeNum" "Pointer to the value of the codeNum."
- \return "AVCENC_SUCCESS for success or bitstream error messages for fail."
- */
- AVCEnc_Status ue_v(AVCEncBitstream *bitstream, uint codeNum);
-
- /**
- This function maps and encodes signed Exp-Golomb codes.
- \param "bitstream" "Pointer to AVCEncBitstream."
- \param "value" "Pointer to syntax element value."
- \return "AVCENC_SUCCESS or AVCENC_FAIL."
- */
- AVCEnc_Status se_v(AVCEncBitstream *bitstream, int value);
-
- /**
- This function maps and encodes truncated Exp-Golomb codes.
- \param "bitstream" "Pointer to AVCEncBitstream."
- \param "value" "Pointer to syntax element value."
- \param "range" "Range of the value as input to determine the algorithm."
- \return "AVCENC_SUCCESS or AVCENC_FAIL."
- */
- AVCEnc_Status te_v(AVCEncBitstream *bitstream, uint value, uint range);
-
- /**
- This function creates Exp-Golomb codeword from codeNum.
- \param "bitstream" "Pointer to AVCEncBitstream."
- \param "codeNum" "Pointer to the codeNum value."
- \return "AVCENC_SUCCESS for success or bitstream error messages for fail."
- */
- AVCEnc_Status SetEGBitstring(AVCEncBitstream *bitstream, uint codeNum);
-
- /**
- This function performs CAVLC encoding of the CBP (coded block pattern) of a macroblock
- by calling ue_v() and then mapping the CBP to the corresponding VLC codeNum.
- \param "currMB" "Pointer to the current AVCMacroblock structure."
- \param "stream" "Pointer to the AVCEncBitstream."
- \return "void"
- */
- AVCEnc_Status EncodeCBP(AVCMacroblock *currMB, AVCEncBitstream *stream);
-
- /**
- This function encodes trailing ones and total coefficient.
- \param "stream" "Pointer to the AVCEncBitstream."
- \param "TrailingOnes" "The trailing one variable output."
- \param "TotalCoeff" "The total coefficient variable output."
- \param "nC" "Context for number of nonzero coefficient (prediction context)."
- \return "AVCENC_SUCCESS for success or else for bitstream failure."
- */
- AVCEnc_Status ce_TotalCoeffTrailingOnes(AVCEncBitstream *stream, int TrailingOnes, int TotalCoeff, int nC);
-
- /**
- This function encodes trailing ones and total coefficient for chroma DC block.
- \param "stream" "Pointer to the AVCEncBitstream."
- \param "TrailingOnes" "The trailing one variable output."
- \param "TotalCoeff" "The total coefficient variable output."
- \return "AVCENC_SUCCESS for success or else for bitstream failure."
- */
- AVCEnc_Status ce_TotalCoeffTrailingOnesChromaDC(AVCEncBitstream *stream, int TrailingOnes, int TotalCoeff);
-
- /**
- This function encodes total_zeros value as in Table 9-7 and 9-8.
- \param "stream" "Pointer to the AVCEncBitstream."
- \param "TotalZeros" "The total_zeros value."
- \param "TotalCoeff" "The total coefficient variable output."
- \return "AVCENC_SUCCESS for success or else for bitstream failure."
- */
- AVCEnc_Status ce_TotalZeros(AVCEncBitstream *stream, int total_zeros, int TotalCoeff);
-
- /**
- This function encodes total_zeros VLC syntax for chroma DC as in Table 9-9.
- \param "stream" "Pointer to the AVCEncBitstream."
- \param "TotalZeros" "The total_zeros value."
- \param "TotalCoeff" "The total coefficient variable output."
- \return "AVCENC_SUCCESS for success or else for bitstream failure."
- */
- AVCEnc_Status ce_TotalZerosChromaDC(AVCEncBitstream *stream, int total_zeros, int TotalCoeff);
-
- /**
- This function encodes run_before VLC syntax as in Table 9-10.
- \param "stream" "Pointer to the AVCEncBitstream."
- \param "run_before" "The run_before value."
- \param "zerosLeft" "The context for number of zeros left."
- \return "AVCENC_SUCCESS for success or else for bitstream failure."
- */
- AVCEnc_Status ce_RunBefore(AVCEncBitstream *stream, int run_before, int zerosLeft);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _AVCENC_LIB_H_ */
-
diff --git a/media/libstagefright/codecs/avc/enc/src/bitstream_io.cpp b/media/libstagefright/codecs/avc/enc/src/bitstream_io.cpp
deleted file mode 100644
index d71c327..0000000
--- a/media/libstagefright/codecs/avc/enc/src/bitstream_io.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-
-#define WORD_SIZE 32
-
-/* array for trailing bit pattern as function of number of bits */
-/* the first one is unused. */
-const static uint8 trailing_bits[9] = {0, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
-
-/* ======================================================================== */
-/* Function : BitstreamInit() */
-/* Date : 11/4/2003 */
-/* Purpose : Populate bitstream structure with bitstream buffer and size */
-/* it also initializes internal data */
-/* In/out : */
-/* Return : AVCENC_SUCCESS if successed, AVCENC_FAIL if failed. */
-/* Modified : */
-/* ======================================================================== */
-/* |--------|--------|----~~~~~-----|---------|---------|---------|
- ^ ^write_pos ^buf_size
- bitstreamBuffer <--------->
- current_word
-
- |-----xxxxxxxxxxxxx| = current_word 32 or 16 bits
- <---->
- bit_left
- ======================================================================== */
-
-AVCEnc_Status BitstreamEncInit(AVCEncBitstream *stream, uint8 *buffer, int buf_size,
- uint8 *overrunBuffer, int oBSize)
-{
- if (stream == NULL || buffer == NULL || buf_size <= 0)
- {
- return AVCENC_BITSTREAM_INIT_FAIL;
- }
-
- stream->bitstreamBuffer = buffer;
-
- stream->buf_size = buf_size;
-
- stream->write_pos = 0;
-
- stream->count_zeros = 0;
-
- stream->current_word = 0;
-
- stream->bit_left = WORD_SIZE;
-
- stream->overrunBuffer = overrunBuffer;
-
- stream->oBSize = oBSize;
-
- return AVCENC_SUCCESS;
-}
-
-/* ======================================================================== */
-/* Function : AVCBitstreamSaveWord() */
-/* Date : 3/29/2004 */
-/* Purpose : Save the current_word into the buffer, byte-swap, and */
-/* add emulation prevention insertion. */
-/* In/out : */
-/* Return : AVCENC_SUCCESS if successed, AVCENC_WRITE_FAIL if buffer is */
-/* full. */
-/* Modified : */
-/* ======================================================================== */
-AVCEnc_Status AVCBitstreamSaveWord(AVCEncBitstream *stream)
-{
- int num_bits;
- uint8 *write_pnt, byte;
- uint current_word;
-
- /* check number of bytes in current_word, must always be byte-aligned!!!! */
- num_bits = WORD_SIZE - stream->bit_left; /* must be multiple of 8 !!*/
-
- if (stream->buf_size - stream->write_pos <= (num_bits >> 3) + 2) /* 2 more bytes for possible EPBS */
- {
- if (AVCENC_SUCCESS != AVCBitstreamUseOverrunBuffer(stream, (num_bits >> 3) + 2))
- {
- return AVCENC_BITSTREAM_BUFFER_FULL;
- }
- }
-
- /* write word, byte-by-byte */
- write_pnt = stream->bitstreamBuffer + stream->write_pos;
- current_word = stream->current_word;
- while (num_bits) /* no need to check stream->buf_size and stream->write_pos, taken care already */
- {
- num_bits -= 8;
- byte = (current_word >> num_bits) & 0xFF;
- if (stream->count_zeros == 2)
- { /* for num_bits = 32, this can add 2 more bytes extra for EPBS */
- if (byte <= 3)
- {
- *write_pnt++ = 0x3;
- stream->write_pos++;
- stream->count_zeros = 0;
- }
- }
- if (byte != 0)
- {
- *write_pnt++ = byte;
- stream->write_pos++;
- stream->count_zeros = 0;
- }
- else
- {
- stream->count_zeros++;
- *write_pnt++ = byte;
- stream->write_pos++;
- }
- }
-
- /* reset current_word and bit_left */
- stream->current_word = 0;
- stream->bit_left = WORD_SIZE;
-
- return AVCENC_SUCCESS;
-}
-
-/* ======================================================================== */
-/* Function : BitstreamWriteBits() */
-/* Date : 3/29/2004 */
-/* Purpose : Write up to machine word. */
-/* In/out : Unused bits in 'code' must be all zeros. */
-/* Return : AVCENC_SUCCESS if successed, AVCENC_WRITE_FAIL if buffer is */
-/* full. */
-/* Modified : */
-/* ======================================================================== */
-AVCEnc_Status BitstreamWriteBits(AVCEncBitstream *stream, int nBits, uint code)
-{
- AVCEnc_Status status = AVCENC_SUCCESS;
- int bit_left = stream->bit_left;
- uint current_word = stream->current_word;
-
- //DEBUG_LOG(userData,AVC_LOGTYPE_INFO,"BitstreamWriteBits",nBits,-1);
-
- if (nBits > WORD_SIZE) /* has to be taken care of specially */
- {
- return AVCENC_FAIL; /* for now */
- /* otherwise, break it down to 2 write of less than 16 bits at a time. */
- }
-
- if (nBits <= bit_left) /* more bits left in current_word */
- {
- stream->current_word = (current_word << nBits) | code;
- stream->bit_left -= nBits;
- if (stream->bit_left == 0) /* prepare for the next word */
- {
- status = AVCBitstreamSaveWord(stream);
- return status;
- }
- }
- else
- {
- stream->current_word = (current_word << bit_left) | (code >> (nBits - bit_left));
-
- nBits -= bit_left;
-
- stream->bit_left = 0;
-
- status = AVCBitstreamSaveWord(stream); /* save current word */
-
- stream->bit_left = WORD_SIZE - nBits;
-
- stream->current_word = code; /* no extra masking for code, must be handled before saving */
- }
-
- return status;
-}
-
-
-/* ======================================================================== */
-/* Function : BitstreamWrite1Bit() */
-/* Date : 3/30/2004 */
-/* Purpose : Write 1 bit */
-/* In/out : Unused bits in 'code' must be all zeros. */
-/* Return : AVCENC_SUCCESS if successed, AVCENC_WRITE_FAIL if buffer is */
-/* full. */
-/* Modified : */
-/* ======================================================================== */
-AVCEnc_Status BitstreamWrite1Bit(AVCEncBitstream *stream, uint code)
-{
- AVCEnc_Status status;
- uint current_word = stream->current_word;
-
- //DEBUG_LOG(userData,AVC_LOGTYPE_INFO,"BitstreamWrite1Bit",code,-1);
-
- //if(1 <= bit_left) /* more bits left in current_word */
- /* we can assume that there always be positive bit_left in the current word */
- stream->current_word = (current_word << 1) | code;
- stream->bit_left--;
- if (stream->bit_left == 0) /* prepare for the next word */
- {
- status = AVCBitstreamSaveWord(stream);
- return status;
- }
-
- return AVCENC_SUCCESS;
-}
-
-
-/* ======================================================================== */
-/* Function : BitstreamTrailingBits() */
-/* Date : 3/31/2004 */
-/* Purpose : Add trailing bits and report the final EBSP size. */
-/* In/out : */
-/* Return : AVCENC_SUCCESS if successed, AVCENC_WRITE_FAIL if buffer is */
-/* full. */
-/* Modified : */
-/* ======================================================================== */
-AVCEnc_Status BitstreamTrailingBits(AVCEncBitstream *bitstream, uint *nal_size)
-{
- (void)(nal_size);
-
- AVCEnc_Status status;
- int bit_left = bitstream->bit_left;
-
- bit_left &= 0x7; /* modulo by 8 */
- if (bit_left == 0) bit_left = 8;
- /* bitstream->bit_left == 0 cannot happen here since it would have been Saved already */
-
- status = BitstreamWriteBits(bitstream, bit_left, trailing_bits[bit_left]);
-
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- /* if it's not saved, save it. */
- //if(bitstream->bit_left<(WORD_SIZE<<3)) /* in fact, no need to check */
- {
- status = AVCBitstreamSaveWord(bitstream);
- }
-
- return status;
-}
-
-/* check whether it's byte-aligned */
-bool byte_aligned(AVCEncBitstream *stream)
-{
- if (stream->bit_left % 8)
- return false;
- else
- return true;
-}
-
-
-/* determine whether overrun buffer can be used or not */
-AVCEnc_Status AVCBitstreamUseOverrunBuffer(AVCEncBitstream* stream, int numExtraBytes)
-{
- AVCEncObject *encvid = (AVCEncObject*)stream->encvid;
-
- if (stream->overrunBuffer != NULL) // overrunBuffer is set
- {
- if (stream->bitstreamBuffer != stream->overrunBuffer) // not already used
- {
- if (stream->write_pos + numExtraBytes >= stream->oBSize)
- {
- stream->oBSize = stream->write_pos + numExtraBytes + 100;
- stream->oBSize &= (~0x3); // make it multiple of 4
-
- // allocate new overrun Buffer
- if (encvid->overrunBuffer)
- {
- encvid->avcHandle->CBAVC_Free(encvid->avcHandle->userData,
- encvid->overrunBuffer);
- }
-
- encvid->oBSize = stream->oBSize;
- encvid->overrunBuffer = (uint8*) encvid->avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
- stream->oBSize, DEFAULT_ATTR);
-
- stream->overrunBuffer = encvid->overrunBuffer;
- if (stream->overrunBuffer == NULL)
- {
- return AVCENC_FAIL;
- }
- }
-
- // copy everything to overrun buffer and start using it.
- memcpy(stream->overrunBuffer, stream->bitstreamBuffer, stream->write_pos);
- stream->bitstreamBuffer = stream->overrunBuffer;
- stream->buf_size = stream->oBSize;
- }
- else // overrun buffer is already used
- {
- stream->oBSize = stream->write_pos + numExtraBytes + 100;
- stream->oBSize &= (~0x3); // make it multiple of 4
-
- // allocate new overrun buffer
- encvid->oBSize = stream->oBSize;
- encvid->overrunBuffer = (uint8*) encvid->avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
- stream->oBSize, DEFAULT_ATTR);
-
- if (encvid->overrunBuffer == NULL)
- {
- return AVCENC_FAIL;
- }
-
-
- // copy from the old buffer to new buffer
- memcpy(encvid->overrunBuffer, stream->overrunBuffer, stream->write_pos);
- // free old buffer
- encvid->avcHandle->CBAVC_Free(encvid->avcHandle->userData,
- stream->overrunBuffer);
-
- // assign pointer to new buffer
- stream->overrunBuffer = encvid->overrunBuffer;
- stream->bitstreamBuffer = stream->overrunBuffer;
- stream->buf_size = stream->oBSize;
- }
-
- return AVCENC_SUCCESS;
- }
- else // overrunBuffer is not enable.
- {
- return AVCENC_FAIL;
- }
-
-}
-
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/block.cpp b/media/libstagefright/codecs/avc/enc/src/block.cpp
deleted file mode 100644
index 01e26a6..0000000
--- a/media/libstagefright/codecs/avc/enc/src/block.cpp
+++ /dev/null
@@ -1,1283 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-
-/* subtract with the prediction and do transformation */
-void trans(uint8 *cur, int pitch, uint8 *predBlock, int16 *dataBlock)
-{
- int16 *ptr = dataBlock;
- int r0, r1, r2, r3, j;
- int curpitch = (uint)pitch >> 16;
- int predpitch = (pitch & 0xFFFF);
-
- /* horizontal */
- j = 4;
- while (j > 0)
- {
- /* calculate the residue first */
- r0 = cur[0] - predBlock[0];
- r1 = cur[1] - predBlock[1];
- r2 = cur[2] - predBlock[2];
- r3 = cur[3] - predBlock[3];
-
- r0 += r3; //ptr[0] + ptr[3];
- r3 = r0 - (r3 << 1); //ptr[0] - ptr[3];
- r1 += r2; //ptr[1] + ptr[2];
- r2 = r1 - (r2 << 1); //ptr[1] - ptr[2];
-
- ptr[0] = r0 + r1;
- ptr[2] = r0 - r1;
- ptr[1] = (r3 << 1) + r2;
- ptr[3] = r3 - (r2 << 1);
-
- ptr += 16;
- predBlock += predpitch;
- cur += curpitch;
- j--;
- }
- /* vertical */
- ptr = dataBlock;
- j = 4;
- while (j > 0)
- {
- r0 = ptr[0] + ptr[48];
- r3 = ptr[0] - ptr[48];
- r1 = ptr[16] + ptr[32];
- r2 = ptr[16] - ptr[32];
-
- ptr[0] = r0 + r1;
- ptr[32] = r0 - r1;
- ptr[16] = (r3 << 1) + r2;
- ptr[48] = r3 - (r2 << 1);
-
- ptr++;
- j--;
- }
-
- return ;
-}
-
-
-/* do residue transform quant invquant, invtrans and write output out */
-int dct_luma(AVCEncObject *encvid, int blkidx, uint8 *cur, uint8 *org, int *coef_cost)
-{
- AVCCommonObj *video = encvid->common;
- int org_pitch = encvid->currInput->pitch;
- int pitch = video->currPic->pitch;
- int16 *coef = video->block;
- uint8 *pred = video->pred_block; // size 16 for a 4x4 block
- int pred_pitch = video->pred_pitch;
- int r0, r1, r2, r3, j, k, idx;
- int *level, *run;
- int Qq, Rq, q_bits, qp_const, quant;
- int data, lev, zero_run;
- int numcoeff;
-
- coef += ((blkidx & 0x3) << 2) + ((blkidx >> 2) << 6); /* point to the 4x4 block */
-
- /* first take a 4x4 transform */
- /* horizontal */
- j = 4;
- while (j > 0)
- {
- /* calculate the residue first */
- r0 = org[0] - pred[0]; /* OPTIMIZEABLE */
- r1 = org[1] - pred[1];
- r2 = org[2] - pred[2];
- r3 = org[3] - pred[3];
-
- r0 += r3; //ptr[0] + ptr[3];
- r3 = r0 - (r3 << 1); //ptr[0] - ptr[3];
- r1 += r2; //ptr[1] + ptr[2];
- r2 = r1 - (r2 << 1); //ptr[1] - ptr[2];
-
- coef[0] = r0 + r1;
- coef[2] = r0 - r1;
- coef[1] = (r3 << 1) + r2;
- coef[3] = r3 - (r2 << 1);
-
- coef += 16;
- org += org_pitch;
- pred += pred_pitch;
- j--;
- }
- /* vertical */
- coef -= 64;
- pred -= (pred_pitch << 2);
- j = 4;
- while (j > 0) /* OPTIMIZABLE */
- {
- r0 = coef[0] + coef[48];
- r3 = coef[0] - coef[48];
- r1 = coef[16] + coef[32];
- r2 = coef[16] - coef[32];
-
- coef[0] = r0 + r1;
- coef[32] = r0 - r1;
- coef[16] = (r3 << 1) + r2;
- coef[48] = r3 - (r2 << 1);
-
- coef++;
- j--;
- }
-
- coef -= 4;
-
- /* quant */
- level = encvid->level[ras2dec[blkidx]];
- run = encvid->run[ras2dec[blkidx]];
-
- Rq = video->QPy_mod_6;
- Qq = video->QPy_div_6;
- qp_const = encvid->qp_const;
- q_bits = 15 + Qq;
-
- zero_run = 0;
- numcoeff = 0;
- for (k = 0; k < 16; k++)
- {
- idx = ZZ_SCAN_BLOCK[k]; /* map back to raster scan order */
- data = coef[idx];
- quant = quant_coef[Rq][k];
- if (data > 0)
- {
- lev = data * quant + qp_const;
- }
- else
- {
- lev = -data * quant + qp_const;
- }
- lev >>= q_bits;
- if (lev)
- {
- *coef_cost += ((lev > 1) ? MAX_VALUE : COEFF_COST[DISABLE_THRESHOLDING][zero_run]);
-
- /* dequant */
- quant = dequant_coefres[Rq][k];
- if (data > 0)
- {
- level[numcoeff] = lev;
- coef[idx] = (lev * quant) << Qq;
- }
- else
- {
- level[numcoeff] = -lev;
- coef[idx] = (-lev * quant) << Qq;
- }
- run[numcoeff++] = zero_run;
- zero_run = 0;
- }
- else
- {
- zero_run++;
- coef[idx] = 0;
- }
- }
-
- if (video->currMB->mb_intra) // only do inverse transform with intra block
- {
- if (numcoeff) /* then do inverse transform */
- {
- for (j = 4; j > 0; j--) /* horizontal */
- {
- r0 = coef[0] + coef[2];
- r1 = coef[0] - coef[2];
- r2 = (coef[1] >> 1) - coef[3];
- r3 = coef[1] + (coef[3] >> 1);
-
- coef[0] = r0 + r3;
- coef[1] = r1 + r2;
- coef[2] = r1 - r2;
- coef[3] = r0 - r3;
-
- coef += 16;
- }
-
- coef -= 64;
- for (j = 4; j > 0; j--) /* vertical, has to be done after horizontal */
- {
- r0 = coef[0] + coef[32];
- r1 = coef[0] - coef[32];
- r2 = (coef[16] >> 1) - coef[48];
- r3 = coef[16] + (coef[48] >> 1);
- r0 += r3;
- r3 = (r0 - (r3 << 1)); /* r0-r3 */
- r1 += r2;
- r2 = (r1 - (r2 << 1)); /* r1-r2 */
- r0 += 32;
- r1 += 32;
- r2 += 32;
- r3 += 32;
-
- r0 = pred[0] + (r0 >> 6);
- if ((uint)r0 > 0xFF) r0 = 0xFF & (~(r0 >> 31)); /* clip */
- r1 = *(pred += pred_pitch) + (r1 >> 6);
- if ((uint)r1 > 0xFF) r1 = 0xFF & (~(r1 >> 31)); /* clip */
- r2 = *(pred += pred_pitch) + (r2 >> 6);
- if ((uint)r2 > 0xFF) r2 = 0xFF & (~(r2 >> 31)); /* clip */
- r3 = pred[pred_pitch] + (r3 >> 6);
- if ((uint)r3 > 0xFF) r3 = 0xFF & (~(r3 >> 31)); /* clip */
-
- *cur = r0;
- *(cur += pitch) = r1;
- *(cur += pitch) = r2;
- cur[pitch] = r3;
- cur -= (pitch << 1);
- cur++;
- pred -= (pred_pitch << 1);
- pred++;
- coef++;
- }
- }
- else // copy from pred to cur
- {
- *((uint32*)cur) = *((uint32*)pred);
- *((uint32*)(cur += pitch)) = *((uint32*)(pred += pred_pitch));
- *((uint32*)(cur += pitch)) = *((uint32*)(pred += pred_pitch));
- *((uint32*)(cur += pitch)) = *((uint32*)(pred += pred_pitch));
- }
- }
-
- return numcoeff;
-}
-
-
-void MBInterIdct(AVCCommonObj *video, uint8 *curL, AVCMacroblock *currMB, int picPitch)
-{
- int16 *coef, *coef8 = video->block;
- uint8 *cur; // the same as curL
- int b8, b4;
- int r0, r1, r2, r3, j, blkidx;
-
- for (b8 = 0; b8 < 4; b8++)
- {
- cur = curL;
- coef = coef8;
-
- if (currMB->CBP&(1 << b8))
- {
- for (b4 = 0; b4 < 4; b4++)
- {
- blkidx = blkIdx2blkXY[b8][b4];
- /* do IDCT */
- if (currMB->nz_coeff[blkidx])
- {
- for (j = 4; j > 0; j--) /* horizontal */
- {
- r0 = coef[0] + coef[2];
- r1 = coef[0] - coef[2];
- r2 = (coef[1] >> 1) - coef[3];
- r3 = coef[1] + (coef[3] >> 1);
-
- coef[0] = r0 + r3;
- coef[1] = r1 + r2;
- coef[2] = r1 - r2;
- coef[3] = r0 - r3;
-
- coef += 16;
- }
-
- coef -= 64;
- for (j = 4; j > 0; j--) /* vertical, has to be done after horizontal */
- {
- r0 = coef[0] + coef[32];
- r1 = coef[0] - coef[32];
- r2 = (coef[16] >> 1) - coef[48];
- r3 = coef[16] + (coef[48] >> 1);
- r0 += r3;
- r3 = (r0 - (r3 << 1)); /* r0-r3 */
- r1 += r2;
- r2 = (r1 - (r2 << 1)); /* r1-r2 */
- r0 += 32;
- r1 += 32;
- r2 += 32;
- r3 += 32;
-
- r0 = cur[0] + (r0 >> 6);
- if ((uint)r0 > 0xFF) r0 = 0xFF & (~(r0 >> 31)); /* clip */
- *cur = r0;
- r1 = *(cur += picPitch) + (r1 >> 6);
- if ((uint)r1 > 0xFF) r1 = 0xFF & (~(r1 >> 31)); /* clip */
- *cur = r1;
- r2 = *(cur += picPitch) + (r2 >> 6);
- if ((uint)r2 > 0xFF) r2 = 0xFF & (~(r2 >> 31)); /* clip */
- *cur = r2;
- r3 = cur[picPitch] + (r3 >> 6);
- if ((uint)r3 > 0xFF) r3 = 0xFF & (~(r3 >> 31)); /* clip */
- cur[picPitch] = r3;
-
- cur -= (picPitch << 1);
- cur++;
- coef++;
- }
- cur -= 4;
- coef -= 4;
- }
- if (b4&1)
- {
- cur += ((picPitch << 2) - 4);
- coef += 60;
- }
- else
- {
- cur += 4;
- coef += 4;
- }
- }
- }
-
- if (b8&1)
- {
- curL += ((picPitch << 3) - 8);
- coef8 += 120;
- }
- else
- {
- curL += 8;
- coef8 += 8;
- }
- }
-
- return ;
-}
-
-/* performa dct, quant, iquant, idct for the entire MB */
-void dct_luma_16x16(AVCEncObject *encvid, uint8 *curL, uint8 *orgL)
-{
- AVCCommonObj *video = encvid->common;
- int pitch = video->currPic->pitch;
- int org_pitch = encvid->currInput->pitch;
- AVCMacroblock *currMB = video->currMB;
- int16 *coef = video->block;
- uint8 *pred = encvid->pred_i16[currMB->i16Mode];
- int blk_x, blk_y, j, k, idx, b8, b4;
- int r0, r1, r2, r3, m0, m1, m2 , m3;
- int data, lev;
- int *level, *run, zero_run, ncoeff;
- int Rq, Qq, quant, q_bits, qp_const;
- int offset_cur[4], offset_pred[4], offset;
-
- /* horizontal */
- for (j = 16; j > 0; j--)
- {
- for (blk_x = 4; blk_x > 0; blk_x--)
- {
- /* calculate the residue first */
- r0 = *orgL++ - *pred++;
- r1 = *orgL++ - *pred++;
- r2 = *orgL++ - *pred++;
- r3 = *orgL++ - *pred++;
-
- r0 += r3; //ptr[0] + ptr[3];
- r3 = r0 - (r3 << 1); //ptr[0] - ptr[3];
- r1 += r2; //ptr[1] + ptr[2];
- r2 = r1 - (r2 << 1); //ptr[1] - ptr[2];
-
- *coef++ = r0 + r1;
- *coef++ = (r3 << 1) + r2;
- *coef++ = r0 - r1;
- *coef++ = r3 - (r2 << 1);
- }
- orgL += (org_pitch - 16);
- }
- pred -= 256;
- coef -= 256;
- /* vertical */
- for (blk_y = 4; blk_y > 0; blk_y--)
- {
- for (j = 16; j > 0; j--)
- {
- r0 = coef[0] + coef[48];
- r3 = coef[0] - coef[48];
- r1 = coef[16] + coef[32];
- r2 = coef[16] - coef[32];
-
- coef[0] = r0 + r1;
- coef[32] = r0 - r1;
- coef[16] = (r3 << 1) + r2;
- coef[48] = r3 - (r2 << 1);
-
- coef++;
- }
- coef += 48;
- }
-
- /* then perform DC transform */
- coef -= 256;
- for (j = 4; j > 0; j--)
- {
- r0 = coef[0] + coef[12];
- r3 = coef[0] - coef[12];
- r1 = coef[4] + coef[8];
- r2 = coef[4] - coef[8];
-
- coef[0] = r0 + r1;
- coef[8] = r0 - r1;
- coef[4] = r3 + r2;
- coef[12] = r3 - r2;
- coef += 64;
- }
- coef -= 256;
- for (j = 4; j > 0; j--)
- {
- r0 = coef[0] + coef[192];
- r3 = coef[0] - coef[192];
- r1 = coef[64] + coef[128];
- r2 = coef[64] - coef[128];
-
- coef[0] = (r0 + r1) >> 1;
- coef[128] = (r0 - r1) >> 1;
- coef[64] = (r3 + r2) >> 1;
- coef[192] = (r3 - r2) >> 1;
- coef += 4;
- }
-
- coef -= 16;
- // then quantize DC
- level = encvid->leveldc;
- run = encvid->rundc;
-
- Rq = video->QPy_mod_6;
- Qq = video->QPy_div_6;
- quant = quant_coef[Rq][0];
- q_bits = 15 + Qq;
- qp_const = encvid->qp_const;
-
- zero_run = 0;
- ncoeff = 0;
- for (k = 0; k < 16; k++) /* in zigzag scan order */
- {
- idx = ZIGZAG2RASTERDC[k];
- data = coef[idx];
- if (data > 0) // quant
- {
- lev = data * quant + (qp_const << 1);
- }
- else
- {
- lev = -data * quant + (qp_const << 1);
- }
- lev >>= (q_bits + 1);
- if (lev) // dequant
- {
- if (data > 0)
- {
- level[ncoeff] = lev;
- coef[idx] = lev;
- }
- else
- {
- level[ncoeff] = -lev;
- coef[idx] = -lev;
- }
- run[ncoeff++] = zero_run;
- zero_run = 0;
- }
- else
- {
- zero_run++;
- coef[idx] = 0;
- }
- }
-
- /* inverse transform DC */
- encvid->numcoefdc = ncoeff;
- if (ncoeff)
- {
- quant = dequant_coefres[Rq][0];
-
- for (j = 0; j < 4; j++)
- {
- m0 = coef[0] + coef[4];
- m1 = coef[0] - coef[4];
- m2 = coef[8] + coef[12];
- m3 = coef[8] - coef[12];
-
-
- coef[0] = m0 + m2;
- coef[4] = m0 - m2;
- coef[8] = m1 - m3;
- coef[12] = m1 + m3;
- coef += 64;
- }
-
- coef -= 256;
-
- if (Qq >= 2) /* this way should be faster than JM */
- { /* they use (((m4*scale)<<(QPy/6))+2)>>2 for both cases. */
- Qq -= 2;
- for (j = 0; j < 4; j++)
- {
- m0 = coef[0] + coef[64];
- m1 = coef[0] - coef[64];
- m2 = coef[128] + coef[192];
- m3 = coef[128] - coef[192];
-
- coef[0] = ((m0 + m2) * quant) << Qq;
- coef[64] = ((m0 - m2) * quant) << Qq;
- coef[128] = ((m1 - m3) * quant) << Qq;
- coef[192] = ((m1 + m3) * quant) << Qq;
- coef += 4;
- }
- Qq += 2; /* restore the value */
- }
- else
- {
- Qq = 2 - Qq;
- offset = 1 << (Qq - 1);
-
- for (j = 0; j < 4; j++)
- {
- m0 = coef[0] + coef[64];
- m1 = coef[0] - coef[64];
- m2 = coef[128] + coef[192];
- m3 = coef[128] - coef[192];
-
- coef[0] = (((m0 + m2) * quant + offset) >> Qq);
- coef[64] = (((m0 - m2) * quant + offset) >> Qq);
- coef[128] = (((m1 - m3) * quant + offset) >> Qq);
- coef[192] = (((m1 + m3) * quant + offset) >> Qq);
- coef += 4;
- }
- Qq = 2 - Qq; /* restore the value */
- }
- coef -= 16; /* back to the origin */
- }
-
- /* now zigzag scan ac coefs, quant, iquant and itrans */
- run = encvid->run[0];
- level = encvid->level[0];
-
- /* offset btw 4x4 block */
- offset_cur[0] = 0;
- offset_cur[1] = (pitch << 2) - 8;
-
- /* offset btw 8x8 block */
- offset_cur[2] = 8 - (pitch << 3);
- offset_cur[3] = -8;
-
- /* similarly for pred */
- offset_pred[0] = 0;
- offset_pred[1] = 56;
- offset_pred[2] = -120;
- offset_pred[3] = -8;
-
- currMB->CBP = 0;
-
- for (b8 = 0; b8 < 4; b8++)
- {
- for (b4 = 0; b4 < 4; b4++)
- {
-
- zero_run = 0;
- ncoeff = 0;
-
- for (k = 1; k < 16; k++)
- {
- idx = ZZ_SCAN_BLOCK[k]; /* map back to raster scan order */
- data = coef[idx];
- quant = quant_coef[Rq][k];
- if (data > 0)
- {
- lev = data * quant + qp_const;
- }
- else
- {
- lev = -data * quant + qp_const;
- }
- lev >>= q_bits;
- if (lev)
- { /* dequant */
- quant = dequant_coefres[Rq][k];
- if (data > 0)
- {
- level[ncoeff] = lev;
- coef[idx] = (lev * quant) << Qq;
- }
- else
- {
- level[ncoeff] = -lev;
- coef[idx] = (-lev * quant) << Qq;
- }
- run[ncoeff++] = zero_run;
- zero_run = 0;
- }
- else
- {
- zero_run++;
- coef[idx] = 0;
- }
- }
-
- currMB->nz_coeff[blkIdx2blkXY[b8][b4]] = ncoeff; /* in raster scan !!! */
- if (ncoeff)
- {
- currMB->CBP |= (1 << b8);
-
- // do inverse transform here
- for (j = 4; j > 0; j--)
- {
- r0 = coef[0] + coef[2];
- r1 = coef[0] - coef[2];
- r2 = (coef[1] >> 1) - coef[3];
- r3 = coef[1] + (coef[3] >> 1);
-
- coef[0] = r0 + r3;
- coef[1] = r1 + r2;
- coef[2] = r1 - r2;
- coef[3] = r0 - r3;
-
- coef += 16;
- }
- coef -= 64;
- for (j = 4; j > 0; j--)
- {
- r0 = coef[0] + coef[32];
- r1 = coef[0] - coef[32];
- r2 = (coef[16] >> 1) - coef[48];
- r3 = coef[16] + (coef[48] >> 1);
-
- r0 += r3;
- r3 = (r0 - (r3 << 1)); /* r0-r3 */
- r1 += r2;
- r2 = (r1 - (r2 << 1)); /* r1-r2 */
- r0 += 32;
- r1 += 32;
- r2 += 32;
- r3 += 32;
- r0 = pred[0] + (r0 >> 6);
- if ((uint)r0 > 0xFF) r0 = 0xFF & (~(r0 >> 31)); /* clip */
- r1 = pred[16] + (r1 >> 6);
- if ((uint)r1 > 0xFF) r1 = 0xFF & (~(r1 >> 31)); /* clip */
- r2 = pred[32] + (r2 >> 6);
- if ((uint)r2 > 0xFF) r2 = 0xFF & (~(r2 >> 31)); /* clip */
- r3 = pred[48] + (r3 >> 6);
- if ((uint)r3 > 0xFF) r3 = 0xFF & (~(r3 >> 31)); /* clip */
- *curL = r0;
- *(curL += pitch) = r1;
- *(curL += pitch) = r2;
- curL[pitch] = r3;
- curL -= (pitch << 1);
- curL++;
- pred++;
- coef++;
- }
- }
- else // do DC-only inverse
- {
- m0 = coef[0] + 32;
-
- for (j = 4; j > 0; j--)
- {
- r0 = pred[0] + (m0 >> 6);
- if ((uint)r0 > 0xFF) r0 = 0xFF & (~(r0 >> 31)); /* clip */
- r1 = pred[16] + (m0 >> 6);
- if ((uint)r1 > 0xFF) r1 = 0xFF & (~(r1 >> 31)); /* clip */
- r2 = pred[32] + (m0 >> 6);
- if ((uint)r2 > 0xFF) r2 = 0xFF & (~(r2 >> 31)); /* clip */
- r3 = pred[48] + (m0 >> 6);
- if ((uint)r3 > 0xFF) r3 = 0xFF & (~(r3 >> 31)); /* clip */
- *curL = r0;
- *(curL += pitch) = r1;
- *(curL += pitch) = r2;
- curL[pitch] = r3;
- curL -= (pitch << 1);
- curL++;
- pred++;
- }
- coef += 4;
- }
-
- run += 16; // follow coding order
- level += 16;
- curL += offset_cur[b4&1];
- pred += offset_pred[b4&1];
- coef += offset_pred[b4&1];
- }
-
- curL += offset_cur[2 + (b8&1)];
- pred += offset_pred[2 + (b8&1)];
- coef += offset_pred[2 + (b8&1)];
- }
-
- return ;
-}
-
-
-void dct_chroma(AVCEncObject *encvid, uint8 *curC, uint8 *orgC, int cr)
-{
- AVCCommonObj *video = encvid->common;
- AVCMacroblock *currMB = video->currMB;
- int org_pitch = (encvid->currInput->pitch) >> 1;
- int pitch = (video->currPic->pitch) >> 1;
- int pred_pitch = 16;
- int16 *coef = video->block + 256;
- uint8 *pred = video->pred_block;
- int j, blk_x, blk_y, k, idx, b4;
- int r0, r1, r2, r3, m0;
- int Qq, Rq, qp_const, q_bits, quant;
- int *level, *run, zero_run, ncoeff;
- int data, lev;
- int offset_cur[2], offset_pred[2], offset_coef[2];
- uint8 nz_temp[4];
- int coeff_cost;
-
- if (cr)
- {
- coef += 8;
- pred += 8;
- }
-
- if (currMB->mb_intra == 0) // inter mode
- {
- pred = curC;
- pred_pitch = pitch;
- }
-
- /* do 4x4 transform */
- /* horizontal */
- for (j = 8; j > 0; j--)
- {
- for (blk_x = 2; blk_x > 0; blk_x--)
- {
- /* calculate the residue first */
- r0 = *orgC++ - *pred++;
- r1 = *orgC++ - *pred++;
- r2 = *orgC++ - *pred++;
- r3 = *orgC++ - *pred++;
-
- r0 += r3; //ptr[0] + ptr[3];
- r3 = r0 - (r3 << 1); //ptr[0] - ptr[3];
- r1 += r2; //ptr[1] + ptr[2];
- r2 = r1 - (r2 << 1); //ptr[1] - ptr[2];
-
- *coef++ = r0 + r1;
- *coef++ = (r3 << 1) + r2;
- *coef++ = r0 - r1;
- *coef++ = r3 - (r2 << 1);
-
- }
- coef += 8; // coef pitch is 16
- pred += (pred_pitch - 8); // pred_pitch is 16
- orgC += (org_pitch - 8);
- }
- pred -= (pred_pitch << 3);
- coef -= 128;
- /* vertical */
- for (blk_y = 2; blk_y > 0; blk_y--)
- {
- for (j = 8; j > 0; j--)
- {
- r0 = coef[0] + coef[48];
- r3 = coef[0] - coef[48];
- r1 = coef[16] + coef[32];
- r2 = coef[16] - coef[32];
-
- coef[0] = r0 + r1;
- coef[32] = r0 - r1;
- coef[16] = (r3 << 1) + r2;
- coef[48] = r3 - (r2 << 1);
-
- coef++;
- }
- coef += 56;
- }
- /* then perform DC transform */
- coef -= 128;
-
- /* 2x2 transform of DC components*/
- r0 = coef[0];
- r1 = coef[4];
- r2 = coef[64];
- r3 = coef[68];
-
- coef[0] = r0 + r1 + r2 + r3;
- coef[4] = r0 - r1 + r2 - r3;
- coef[64] = r0 + r1 - r2 - r3;
- coef[68] = r0 - r1 - r2 + r3;
-
- Qq = video->QPc_div_6;
- Rq = video->QPc_mod_6;
- quant = quant_coef[Rq][0];
- q_bits = 15 + Qq;
- qp_const = encvid->qp_const_c;
-
- zero_run = 0;
- ncoeff = 0;
- run = encvid->runcdc + (cr << 2);
- level = encvid->levelcdc + (cr << 2);
-
- /* in zigzag scan order */
- for (k = 0; k < 4; k++)
- {
- idx = ((k >> 1) << 6) + ((k & 1) << 2);
- data = coef[idx];
- if (data > 0)
- {
- lev = data * quant + (qp_const << 1);
- }
- else
- {
- lev = -data * quant + (qp_const << 1);
- }
- lev >>= (q_bits + 1);
- if (lev)
- {
- if (data > 0)
- {
- level[ncoeff] = lev;
- coef[idx] = lev;
- }
- else
- {
- level[ncoeff] = -lev;
- coef[idx] = -lev;
- }
- run[ncoeff++] = zero_run;
- zero_run = 0;
- }
- else
- {
- zero_run++;
- coef[idx] = 0;
- }
- }
-
- encvid->numcoefcdc[cr] = ncoeff;
-
- if (ncoeff)
- {
- currMB->CBP |= (1 << 4); // DC present
- // do inverse transform
- quant = dequant_coefres[Rq][0];
-
- r0 = coef[0] + coef[4];
- r1 = coef[0] - coef[4];
- r2 = coef[64] + coef[68];
- r3 = coef[64] - coef[68];
-
- r0 += r2;
- r2 = r0 - (r2 << 1);
- r1 += r3;
- r3 = r1 - (r3 << 1);
-
- if (Qq >= 1)
- {
- Qq -= 1;
- coef[0] = (r0 * quant) << Qq;
- coef[4] = (r1 * quant) << Qq;
- coef[64] = (r2 * quant) << Qq;
- coef[68] = (r3 * quant) << Qq;
- Qq++;
- }
- else
- {
- coef[0] = (r0 * quant) >> 1;
- coef[4] = (r1 * quant) >> 1;
- coef[64] = (r2 * quant) >> 1;
- coef[68] = (r3 * quant) >> 1;
- }
- }
-
- /* now do AC zigzag scan, quant, iquant and itrans */
- if (cr)
- {
- run = encvid->run[20];
- level = encvid->level[20];
- }
- else
- {
- run = encvid->run[16];
- level = encvid->level[16];
- }
-
- /* offset btw 4x4 block */
- offset_cur[0] = 0;
- offset_cur[1] = (pitch << 2) - 8;
- offset_pred[0] = 0;
- offset_pred[1] = (pred_pitch << 2) - 8;
- offset_coef[0] = 0;
- offset_coef[1] = 56;
-
- coeff_cost = 0;
-
- for (b4 = 0; b4 < 4; b4++)
- {
- zero_run = 0;
- ncoeff = 0;
- for (k = 1; k < 16; k++) /* in zigzag scan order */
- {
- idx = ZZ_SCAN_BLOCK[k]; /* map back to raster scan order */
- data = coef[idx];
- quant = quant_coef[Rq][k];
- if (data > 0)
- {
- lev = data * quant + qp_const;
- }
- else
- {
- lev = -data * quant + qp_const;
- }
- lev >>= q_bits;
- if (lev)
- {
- /* for RD performance*/
- if (lev > 1)
- coeff_cost += MAX_VALUE; // set high cost, shall not be discarded
- else
- coeff_cost += COEFF_COST[DISABLE_THRESHOLDING][zero_run];
-
- /* dequant */
- quant = dequant_coefres[Rq][k];
- if (data > 0)
- {
- level[ncoeff] = lev;
- coef[idx] = (lev * quant) << Qq;
- }
- else
- {
- level[ncoeff] = -lev;
- coef[idx] = (-lev * quant) << Qq;
- }
- run[ncoeff++] = zero_run;
- zero_run = 0;
- }
- else
- {
- zero_run++;
- coef[idx] = 0;
- }
- }
-
- nz_temp[b4] = ncoeff; // raster scan
-
- // just advance the pointers for now, do IDCT later
- coef += 4;
- run += 16;
- level += 16;
- coef += offset_coef[b4&1];
- }
-
- /* rewind the pointers */
- coef -= 128;
-
- if (coeff_cost < _CHROMA_COEFF_COST_)
- {
- /* if it's not efficient to encode any blocks.
- Just do DC only */
- /* We can reset level and run also, but setting nz to zero should be enough. */
- currMB->nz_coeff[16+(cr<<1)] = 0;
- currMB->nz_coeff[17+(cr<<1)] = 0;
- currMB->nz_coeff[20+(cr<<1)] = 0;
- currMB->nz_coeff[21+(cr<<1)] = 0;
-
- for (b4 = 0; b4 < 4; b4++)
- {
- // do DC-only inverse
- m0 = coef[0] + 32;
-
- for (j = 4; j > 0; j--)
- {
- r0 = pred[0] + (m0 >> 6);
- if ((uint)r0 > 0xFF) r0 = 0xFF & (~(r0 >> 31)); /* clip */
- r1 = *(pred += pred_pitch) + (m0 >> 6);
- if ((uint)r1 > 0xFF) r1 = 0xFF & (~(r1 >> 31)); /* clip */
- r2 = pred[pred_pitch] + (m0 >> 6);
- if ((uint)r2 > 0xFF) r2 = 0xFF & (~(r2 >> 31)); /* clip */
- r3 = pred[pred_pitch<<1] + (m0 >> 6);
- if ((uint)r3 > 0xFF) r3 = 0xFF & (~(r3 >> 31)); /* clip */
- *curC = r0;
- *(curC += pitch) = r1;
- *(curC += pitch) = r2;
- curC[pitch] = r3;
- curC -= (pitch << 1);
- curC++;
- pred += (1 - pred_pitch);
- }
- coef += 4;
- curC += offset_cur[b4&1];
- pred += offset_pred[b4&1];
- coef += offset_coef[b4&1];
- }
- }
- else // not dropping anything, continue with the IDCT
- {
- for (b4 = 0; b4 < 4; b4++)
- {
- ncoeff = nz_temp[b4] ; // in raster scan
- currMB->nz_coeff[16+(b4&1)+(cr<<1)+((b4>>1)<<2)] = ncoeff; // in raster scan
-
- if (ncoeff) // do a check on the nonzero-coeff
- {
- currMB->CBP |= (2 << 4);
-
- // do inverse transform here
- for (j = 4; j > 0; j--)
- {
- r0 = coef[0] + coef[2];
- r1 = coef[0] - coef[2];
- r2 = (coef[1] >> 1) - coef[3];
- r3 = coef[1] + (coef[3] >> 1);
-
- coef[0] = r0 + r3;
- coef[1] = r1 + r2;
- coef[2] = r1 - r2;
- coef[3] = r0 - r3;
-
- coef += 16;
- }
- coef -= 64;
- for (j = 4; j > 0; j--)
- {
- r0 = coef[0] + coef[32];
- r1 = coef[0] - coef[32];
- r2 = (coef[16] >> 1) - coef[48];
- r3 = coef[16] + (coef[48] >> 1);
-
- r0 += r3;
- r3 = (r0 - (r3 << 1)); /* r0-r3 */
- r1 += r2;
- r2 = (r1 - (r2 << 1)); /* r1-r2 */
- r0 += 32;
- r1 += 32;
- r2 += 32;
- r3 += 32;
- r0 = pred[0] + (r0 >> 6);
- if ((uint)r0 > 0xFF) r0 = 0xFF & (~(r0 >> 31)); /* clip */
- r1 = *(pred += pred_pitch) + (r1 >> 6);
- if ((uint)r1 > 0xFF) r1 = 0xFF & (~(r1 >> 31)); /* clip */
- r2 = pred[pred_pitch] + (r2 >> 6);
- if ((uint)r2 > 0xFF) r2 = 0xFF & (~(r2 >> 31)); /* clip */
- r3 = pred[pred_pitch<<1] + (r3 >> 6);
- if ((uint)r3 > 0xFF) r3 = 0xFF & (~(r3 >> 31)); /* clip */
- *curC = r0;
- *(curC += pitch) = r1;
- *(curC += pitch) = r2;
- curC[pitch] = r3;
- curC -= (pitch << 1);
- curC++;
- pred += (1 - pred_pitch);
- coef++;
- }
- }
- else
- {
- // do DC-only inverse
- m0 = coef[0] + 32;
-
- for (j = 4; j > 0; j--)
- {
- r0 = pred[0] + (m0 >> 6);
- if ((uint)r0 > 0xFF) r0 = 0xFF & (~(r0 >> 31)); /* clip */
- r1 = *(pred += pred_pitch) + (m0 >> 6);
- if ((uint)r1 > 0xFF) r1 = 0xFF & (~(r1 >> 31)); /* clip */
- r2 = pred[pred_pitch] + (m0 >> 6);
- if ((uint)r2 > 0xFF) r2 = 0xFF & (~(r2 >> 31)); /* clip */
- r3 = pred[pred_pitch<<1] + (m0 >> 6);
- if ((uint)r3 > 0xFF) r3 = 0xFF & (~(r3 >> 31)); /* clip */
- *curC = r0;
- *(curC += pitch) = r1;
- *(curC += pitch) = r2;
- curC[pitch] = r3;
- curC -= (pitch << 1);
- curC++;
- pred += (1 - pred_pitch);
- }
- coef += 4;
- }
- curC += offset_cur[b4&1];
- pred += offset_pred[b4&1];
- coef += offset_coef[b4&1];
- }
- }
-
- return ;
-}
-
-
-/* only DC transform */
-int TransQuantIntra16DC(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- int16 *block = video->block;
- int *level = encvid->leveldc;
- int *run = encvid->rundc;
- int16 *ptr = block;
- int r0, r1, r2, r3, j;
- int Qq = video->QPy_div_6;
- int Rq = video->QPy_mod_6;
- int q_bits, qp_const, quant;
- int data, lev, zero_run;
- int k, ncoeff, idx;
-
- /* DC transform */
- /* horizontal */
- j = 4;
- while (j)
- {
- r0 = ptr[0] + ptr[12];
- r3 = ptr[0] - ptr[12];
- r1 = ptr[4] + ptr[8];
- r2 = ptr[4] - ptr[8];
-
- ptr[0] = r0 + r1;
- ptr[8] = r0 - r1;
- ptr[4] = r3 + r2;
- ptr[12] = r3 - r2;
- ptr += 64;
- j--;
- }
- /* vertical */
- ptr = block;
- j = 4;
- while (j)
- {
- r0 = ptr[0] + ptr[192];
- r3 = ptr[0] - ptr[192];
- r1 = ptr[64] + ptr[128];
- r2 = ptr[64] - ptr[128];
-
- ptr[0] = (r0 + r1) >> 1;
- ptr[128] = (r0 - r1) >> 1;
- ptr[64] = (r3 + r2) >> 1;
- ptr[192] = (r3 - r2) >> 1;
- ptr += 4;
- j--;
- }
-
- quant = quant_coef[Rq][0];
- q_bits = 15 + Qq;
- qp_const = (1 << q_bits) / 3; // intra
-
- zero_run = 0;
- ncoeff = 0;
-
- for (k = 0; k < 16; k++) /* in zigzag scan order */
- {
- idx = ZIGZAG2RASTERDC[k];
- data = block[idx];
- if (data > 0)
- {
- lev = data * quant + (qp_const << 1);
- }
- else
- {
- lev = -data * quant + (qp_const << 1);
- }
- lev >>= (q_bits + 1);
- if (lev)
- {
- if (data > 0)
- {
- level[ncoeff] = lev;
- block[idx] = lev;
- }
- else
- {
- level[ncoeff] = -lev;
- block[idx] = -lev;
- }
- run[ncoeff++] = zero_run;
- zero_run = 0;
- }
- else
- {
- zero_run++;
- block[idx] = 0;
- }
- }
- return ncoeff;
-}
-
-int TransQuantChromaDC(AVCEncObject *encvid, int16 *block, int slice_type, int cr)
-{
- AVCCommonObj *video = encvid->common;
- int *level, *run;
- int r0, r1, r2, r3;
- int Qq, Rq, q_bits, qp_const, quant;
- int data, lev, zero_run;
- int k, ncoeff, idx;
-
- level = encvid->levelcdc + (cr << 2); /* cb or cr */
- run = encvid->runcdc + (cr << 2);
-
- /* 2x2 transform of DC components*/
- r0 = block[0];
- r1 = block[4];
- r2 = block[64];
- r3 = block[68];
-
- block[0] = r0 + r1 + r2 + r3;
- block[4] = r0 - r1 + r2 - r3;
- block[64] = r0 + r1 - r2 - r3;
- block[68] = r0 - r1 - r2 + r3;
-
- Qq = video->QPc_div_6;
- Rq = video->QPc_mod_6;
- quant = quant_coef[Rq][0];
- q_bits = 15 + Qq;
- if (slice_type == AVC_I_SLICE)
- {
- qp_const = (1 << q_bits) / 3;
- }
- else
- {
- qp_const = (1 << q_bits) / 6;
- }
-
- zero_run = 0;
- ncoeff = 0;
-
- for (k = 0; k < 4; k++) /* in zigzag scan order */
- {
- idx = ((k >> 1) << 6) + ((k & 1) << 2);
- data = block[idx];
- if (data > 0)
- {
- lev = data * quant + (qp_const << 1);
- }
- else
- {
- lev = -data * quant + (qp_const << 1);
- }
- lev >>= (q_bits + 1);
- if (lev)
- {
- if (data > 0)
- {
- level[ncoeff] = lev;
- block[idx] = lev;
- }
- else
- {
- level[ncoeff] = -lev;
- block[idx] = -lev;
- }
- run[ncoeff++] = zero_run;
- zero_run = 0;
- }
- else
- {
- zero_run++;
- block[idx] = 0;
- }
- }
- return ncoeff;
-}
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/findhalfpel.cpp b/media/libstagefright/codecs/avc/enc/src/findhalfpel.cpp
deleted file mode 100644
index d0bbee2..0000000
--- a/media/libstagefright/codecs/avc/enc/src/findhalfpel.cpp
+++ /dev/null
@@ -1,607 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-/* 3/29/01 fast half-pel search based on neighboring guess */
-/* value ranging from 0 to 4, high complexity (more accurate) to
- low complexity (less accurate) */
-#define HP_DISTANCE_TH 5 // 2 /* half-pel distance threshold */
-
-#define PREF_16_VEC 129 /* 1MV bias versus 4MVs*/
-
-#define CLIP_RESULT(x) if((uint)x > 0xFF){ \
- x = 0xFF & (~(x>>31));}
-
-#define CLIP_UPPER16(x) if((uint)x >= 0x20000000){ \
- x = 0xFF0000 & (~(x>>31));} \
- else { \
- x = (x>>5)&0xFF0000; \
- }
-
-/*=====================================================================
- Function: AVCFindHalfPelMB
- Date: 10/31/2007
- Purpose: Find half pel resolution MV surrounding the full-pel MV
-=====================================================================*/
-
-int AVCFindHalfPelMB(AVCEncObject *encvid, uint8 *cur, AVCMV *mot, uint8 *ncand,
- int xpos, int ypos, int hp_guess, int cmvx, int cmvy)
-{
- AVCPictureData *currPic = encvid->common->currPic;
- int lx = currPic->pitch;
- int d, dmin, satd_min;
- uint8* cand;
- int lambda_motion = encvid->lambda_motion;
- uint8 *mvbits = encvid->mvbits;
- int mvcost;
- /* list of candidate to go through for half-pel search*/
- uint8 *subpel_pred = (uint8*) encvid->subpel_pred; // all 16 sub-pel positions
- uint8 **hpel_cand = (uint8**) encvid->hpel_cand; /* half-pel position */
-
- int xh[9] = {0, 0, 2, 2, 2, 0, -2, -2, -2};
- int yh[9] = {0, -2, -2, 0, 2, 2, 2, 0, -2};
- int xq[8] = {0, 1, 1, 1, 0, -1, -1, -1};
- int yq[8] = { -1, -1, 0, 1, 1, 1, 0, -1};
- int h, hmin, q, qmin;
-
- OSCL_UNUSED_ARG(xpos);
- OSCL_UNUSED_ARG(ypos);
- OSCL_UNUSED_ARG(hp_guess);
-
- GenerateHalfPelPred(subpel_pred, ncand, lx);
-
- cur = encvid->currYMB; // pre-load current original MB
-
- cand = hpel_cand[0];
-
- // find cost for the current full-pel position
- dmin = SATD_MB(cand, cur, 65535); // get Hadamaard transform SAD
- mvcost = MV_COST_S(lambda_motion, mot->x, mot->y, cmvx, cmvy);
- satd_min = dmin;
- dmin += mvcost;
- hmin = 0;
-
- /* find half-pel */
- for (h = 1; h < 9; h++)
- {
- d = SATD_MB(hpel_cand[h], cur, dmin);
- mvcost = MV_COST_S(lambda_motion, mot->x + xh[h], mot->y + yh[h], cmvx, cmvy);
- d += mvcost;
-
- if (d < dmin)
- {
- dmin = d;
- hmin = h;
- satd_min = d - mvcost;
- }
- }
-
- mot->sad = dmin;
- mot->x += xh[hmin];
- mot->y += yh[hmin];
- encvid->best_hpel_pos = hmin;
-
- /*** search for quarter-pel ****/
- GenerateQuartPelPred(encvid->bilin_base[hmin], &(encvid->qpel_cand[0][0]), hmin);
-
- encvid->best_qpel_pos = qmin = -1;
-
- for (q = 0; q < 8; q++)
- {
- d = SATD_MB(encvid->qpel_cand[q], cur, dmin);
- mvcost = MV_COST_S(lambda_motion, mot->x + xq[q], mot->y + yq[q], cmvx, cmvy);
- d += mvcost;
- if (d < dmin)
- {
- dmin = d;
- qmin = q;
- satd_min = d - mvcost;
- }
- }
-
- if (qmin != -1)
- {
- mot->sad = dmin;
- mot->x += xq[qmin];
- mot->y += yq[qmin];
- encvid->best_qpel_pos = qmin;
- }
-
- return satd_min;
-}
-
-
-
-/** This function generates sub-pel prediction around the full-pel candidate.
-Each sub-pel position array is 20 pixel wide (for word-alignment) and 17 pixel tall. */
-/** The sub-pel position is labeled in spiral manner from the center. */
-
-void GenerateHalfPelPred(uint8* subpel_pred, uint8 *ncand, int lx)
-{
- /* let's do straightforward way first */
- uint8 *ref;
- uint8 *dst;
- uint8 tmp8;
- int32 tmp32;
- int16 tmp_horz[18*22], *dst_16, *src_16;
- int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0; // temp
- int i, j;
-
- /* first copy full-pel to the first array */
- /* to be optimized later based on byte-offset load */
- ref = ncand - 3 - lx - (lx << 1); /* move back (-3,-3) */
- dst = subpel_pred;
-
- dst -= 4; /* offset */
- for (j = 0; j < 22; j++) /* 24x22 */
- {
- i = 6;
- while (i > 0)
- {
- tmp32 = *ref++;
- tmp8 = *ref++;
- tmp32 |= (tmp8 << 8);
- tmp8 = *ref++;
- tmp32 |= (tmp8 << 16);
- tmp8 = *ref++;
- tmp32 |= (tmp8 << 24);
- *((uint32*)(dst += 4)) = tmp32;
- i--;
- }
- ref += (lx - 24);
- }
-
- /* from the first array, we do horizontal interp */
- ref = subpel_pred + 2;
- dst_16 = tmp_horz; /* 17 x 22 */
-
- for (j = 4; j > 0; j--)
- {
- for (i = 16; i > 0; i -= 4)
- {
- a = ref[-2];
- b = ref[-1];
- c = ref[0];
- d = ref[1];
- e = ref[2];
- f = ref[3];
- *dst_16++ = a + f - 5 * (b + e) + 20 * (c + d);
- a = ref[4];
- *dst_16++ = b + a - 5 * (c + f) + 20 * (d + e);
- b = ref[5];
- *dst_16++ = c + b - 5 * (d + a) + 20 * (e + f);
- c = ref[6];
- *dst_16++ = d + c - 5 * (e + b) + 20 * (f + a);
-
- ref += 4;
- }
- /* do the 17th column here */
- d = ref[3];
- *dst_16 = e + d - 5 * (f + c) + 20 * (a + b);
- dst_16 += 2; /* stride for tmp_horz is 18 */
- ref += 8; /* stride for ref is 24 */
- if (j == 3) // move 18 lines down
- {
- dst_16 += 324;//18*18;
- ref += 432;//18*24;
- }
- }
-
- ref -= 480;//20*24;
- dst_16 -= 360;//20*18;
- dst = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* go to the 14th array 17x18*/
-
- for (j = 18; j > 0; j--)
- {
- for (i = 16; i > 0; i -= 4)
- {
- a = ref[-2];
- b = ref[-1];
- c = ref[0];
- d = ref[1];
- e = ref[2];
- f = ref[3];
- tmp32 = a + f - 5 * (b + e) + 20 * (c + d);
- *dst_16++ = tmp32;
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *dst++ = tmp32;
-
- a = ref[4];
- tmp32 = b + a - 5 * (c + f) + 20 * (d + e);
- *dst_16++ = tmp32;
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *dst++ = tmp32;
-
- b = ref[5];
- tmp32 = c + b - 5 * (d + a) + 20 * (e + f);
- *dst_16++ = tmp32;
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *dst++ = tmp32;
-
- c = ref[6];
- tmp32 = d + c - 5 * (e + b) + 20 * (f + a);
- *dst_16++ = tmp32;
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *dst++ = tmp32;
-
- ref += 4;
- }
- /* do the 17th column here */
- d = ref[3];
- tmp32 = e + d - 5 * (f + c) + 20 * (a + b);
- *dst_16 = tmp32;
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *dst = tmp32;
-
- dst += 8; /* stride for dst is 24 */
- dst_16 += 2; /* stride for tmp_horz is 18 */
- ref += 8; /* stride for ref is 24 */
- }
-
-
- /* Do middle point filtering*/
- src_16 = tmp_horz; /* 17 x 22 */
- dst = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 12th array 17x17*/
- dst -= 24; // offset
- for (i = 0; i < 17; i++)
- {
- for (j = 16; j > 0; j -= 4)
- {
- a = *src_16;
- b = *(src_16 += 18);
- c = *(src_16 += 18);
- d = *(src_16 += 18);
- e = *(src_16 += 18);
- f = *(src_16 += 18);
-
- tmp32 = a + f - 5 * (b + e) + 20 * (c + d);
- tmp32 = (tmp32 + 512) >> 10;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32;
-
- a = *(src_16 += 18);
- tmp32 = b + a - 5 * (c + f) + 20 * (d + e);
- tmp32 = (tmp32 + 512) >> 10;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32;
-
- b = *(src_16 += 18);
- tmp32 = c + b - 5 * (d + a) + 20 * (e + f);
- tmp32 = (tmp32 + 512) >> 10;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32;
-
- c = *(src_16 += 18);
- tmp32 = d + c - 5 * (e + b) + 20 * (f + a);
- tmp32 = (tmp32 + 512) >> 10;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32;
-
- src_16 -= (18 << 2);
- }
-
- d = src_16[90]; // 18*5
- tmp32 = e + d - 5 * (f + c) + 20 * (a + b);
- tmp32 = (tmp32 + 512) >> 10;
- CLIP_RESULT(tmp32)
- dst[24] = tmp32;
-
- src_16 -= ((18 << 4) - 1);
- dst -= ((24 << 4) - 1);
- }
-
- /* do vertical interpolation */
- ref = subpel_pred + 2;
- dst = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE; /* 10th array 18x17 */
- dst -= 24; // offset
-
- for (i = 2; i > 0; i--)
- {
- for (j = 16; j > 0; j -= 4)
- {
- a = *ref;
- b = *(ref += 24);
- c = *(ref += 24);
- d = *(ref += 24);
- e = *(ref += 24);
- f = *(ref += 24);
-
- tmp32 = a + f - 5 * (b + e) + 20 * (c + d);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32; // 10th
-
- a = *(ref += 24);
- tmp32 = b + a - 5 * (c + f) + 20 * (d + e);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32; // 10th
-
- b = *(ref += 24);
- tmp32 = c + b - 5 * (d + a) + 20 * (e + f);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32; // 10th
-
- c = *(ref += 24);
- tmp32 = d + c - 5 * (e + b) + 20 * (f + a);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32; // 10th
-
- ref -= (24 << 2);
- }
-
- d = ref[120]; // 24*5
- tmp32 = e + d - 5 * (f + c) + 20 * (a + b);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- dst[24] = tmp32; // 10th
-
- dst -= ((24 << 4) - 1);
- ref -= ((24 << 4) - 1);
- }
-
- // note that using SIMD here doesn't help much, the cycle almost stays the same
- // one can just use the above code and change the for(i=2 to for(i=18
- for (i = 16; i > 0; i -= 4)
- {
- for (j = 17; j > 0; j--)
- {
- a = *((uint32*)ref); /* load 4 bytes */
- b = (a >> 8) & 0xFF00FF; /* second and fourth byte */
- a &= 0xFF00FF;
-
- c = *((uint32*)(ref + 120));
- d = (c >> 8) & 0xFF00FF;
- c &= 0xFF00FF;
-
- a += c;
- b += d;
-
- e = *((uint32*)(ref + 72)); /* e, f */
- f = (e >> 8) & 0xFF00FF;
- e &= 0xFF00FF;
-
- c = *((uint32*)(ref + 48)); /* c, d */
- d = (c >> 8) & 0xFF00FF;
- c &= 0xFF00FF;
-
- c += e;
- d += f;
-
- a += 20 * c;
- b += 20 * d;
- a += 0x100010;
- b += 0x100010;
-
- e = *((uint32*)(ref += 24)); /* e, f */
- f = (e >> 8) & 0xFF00FF;
- e &= 0xFF00FF;
-
- c = *((uint32*)(ref + 72)); /* c, d */
- d = (c >> 8) & 0xFF00FF;
- c &= 0xFF00FF;
-
- c += e;
- d += f;
-
- a -= 5 * c;
- b -= 5 * d;
-
- c = a << 16;
- d = b << 16;
- CLIP_UPPER16(a)
- CLIP_UPPER16(c)
- CLIP_UPPER16(b)
- CLIP_UPPER16(d)
-
- a |= (c >> 16);
- b |= (d >> 16);
- // a>>=5;
- // b>>=5;
- /* clip */
- // msk |= b; msk|=a;
- // a &= 0xFF00FF;
- // b &= 0xFF00FF;
- a |= (b << 8); /* pack it back */
-
- *((uint16*)(dst += 24)) = a & 0xFFFF; //dst is not word-aligned.
- *((uint16*)(dst + 2)) = a >> 16;
-
- }
- dst -= 404; // 24*17-4
- ref -= 404;
- /* if(msk & 0xFF00FF00) // need clipping
- {
- VertInterpWClip(dst,ref); // re-do 4 column with clip
- }*/
- }
-
- return ;
-}
-
-void VertInterpWClip(uint8 *dst, uint8 *ref)
-{
- int i, j;
- int a, b, c, d, e, f;
- int32 tmp32;
-
- dst -= 4;
- ref -= 4;
-
- for (i = 4; i > 0; i--)
- {
- for (j = 16; j > 0; j -= 4)
- {
- a = *ref;
- b = *(ref += 24);
- c = *(ref += 24);
- d = *(ref += 24);
- e = *(ref += 24);
- f = *(ref += 24);
-
- tmp32 = a + f - 5 * (b + e) + 20 * (c + d);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32; // 10th
-
- a = *(ref += 24);
- tmp32 = b + a - 5 * (c + f) + 20 * (d + e);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32; // 10th
-
- b = *(ref += 24);
- tmp32 = c + b - 5 * (d + a) + 20 * (e + f);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32; // 10th
-
- c = *(ref += 24);
- tmp32 = d + c - 5 * (e + b) + 20 * (f + a);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- *(dst += 24) = tmp32; // 10th
-
- ref -= (24 << 2);
- }
-
- d = ref[120]; // 24*5
- tmp32 = e + d - 5 * (f + c) + 20 * (a + b);
- tmp32 = (tmp32 + 16) >> 5;
- CLIP_RESULT(tmp32)
- dst[24] = tmp32; // 10th
-
- dst -= ((24 << 4) - 1);
- ref -= ((24 << 4) - 1);
- }
-
- return ;
-}
-
-
-void GenerateQuartPelPred(uint8 **bilin_base, uint8 *qpel_cand, int hpel_pos)
-{
- // for even value of hpel_pos, start with pattern 1, otherwise, start with pattern 2
- int i, j;
-
- uint8 *c1 = qpel_cand;
- uint8 *tl = bilin_base[0];
- uint8 *tr = bilin_base[1];
- uint8 *bl = bilin_base[2];
- uint8 *br = bilin_base[3];
- int a, b, c, d;
- int offset = 1 - (384 * 7);
-
- if (!(hpel_pos&1)) // diamond pattern
- {
- j = 16;
- while (j--)
- {
- i = 16;
- while (i--)
- {
- d = tr[24];
- a = *tr++;
- b = bl[1];
- c = *br++;
-
- *c1 = (c + a + 1) >> 1;
- *(c1 += 384) = (b + a + 1) >> 1; /* c2 */
- *(c1 += 384) = (b + c + 1) >> 1; /* c3 */
- *(c1 += 384) = (b + d + 1) >> 1; /* c4 */
-
- b = *bl++;
-
- *(c1 += 384) = (c + d + 1) >> 1; /* c5 */
- *(c1 += 384) = (b + d + 1) >> 1; /* c6 */
- *(c1 += 384) = (b + c + 1) >> 1; /* c7 */
- *(c1 += 384) = (b + a + 1) >> 1; /* c8 */
-
- c1 += offset;
- }
- // advance to the next line, pitch is 24
- tl += 8;
- tr += 8;
- bl += 8;
- br += 8;
- c1 += 8;
- }
- }
- else // star pattern
- {
- j = 16;
- while (j--)
- {
- i = 16;
- while (i--)
- {
- a = *br++;
- b = *tr++;
- c = tl[1];
- *c1 = (a + b + 1) >> 1;
- b = bl[1];
- *(c1 += 384) = (a + c + 1) >> 1; /* c2 */
- c = tl[25];
- *(c1 += 384) = (a + b + 1) >> 1; /* c3 */
- b = tr[23];
- *(c1 += 384) = (a + c + 1) >> 1; /* c4 */
- c = tl[24];
- *(c1 += 384) = (a + b + 1) >> 1; /* c5 */
- b = *bl++;
- *(c1 += 384) = (a + c + 1) >> 1; /* c6 */
- c = *tl++;
- *(c1 += 384) = (a + b + 1) >> 1; /* c7 */
- *(c1 += 384) = (a + c + 1) >> 1; /* c8 */
-
- c1 += offset;
- }
- // advance to the next line, pitch is 24
- tl += 8;
- tr += 8;
- bl += 8;
- br += 8;
- c1 += 8;
- }
- }
-
- return ;
-}
-
-
-/* assuming cand always has a pitch of 24 */
-int SATD_MB(uint8 *cand, uint8 *cur, int dmin)
-{
- int cost;
-
-
- dmin = (dmin << 16) | 24;
- cost = AVCSAD_Macroblock_C(cand, cur, dmin, NULL);
-
- return cost;
-}
-
-
-
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/header.cpp b/media/libstagefright/codecs/avc/enc/src/header.cpp
deleted file mode 100644
index 9acff9e..0000000
--- a/media/libstagefright/codecs/avc/enc/src/header.cpp
+++ /dev/null
@@ -1,917 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-#include "avcenc_api.h"
-
-/** see subclause 7.4.2.1 */
-/* no need for checking the valid range , already done in SetEncodeParam(),
-if we have to send another SPS, the ranges should be verified first before
-users call PVAVCEncodeSPS() */
-AVCEnc_Status EncodeSPS(AVCEncObject *encvid, AVCEncBitstream *stream)
-{
- AVCCommonObj *video = encvid->common;
- AVCSeqParamSet *seqParam = video->currSeqParams;
- AVCVUIParams *vui = &(seqParam->vui_parameters);
- int i;
- AVCEnc_Status status = AVCENC_SUCCESS;
-
- //DEBUG_LOG(userData,AVC_LOGTYPE_INFO,"EncodeSPS",-1,-1);
-
- status = BitstreamWriteBits(stream, 8, seqParam->profile_idc);
- status = BitstreamWrite1Bit(stream, seqParam->constrained_set0_flag);
- status = BitstreamWrite1Bit(stream, seqParam->constrained_set1_flag);
- status = BitstreamWrite1Bit(stream, seqParam->constrained_set2_flag);
- status = BitstreamWrite1Bit(stream, seqParam->constrained_set3_flag);
- status = BitstreamWriteBits(stream, 4, 0); /* forbidden zero bits */
- if (status != AVCENC_SUCCESS) /* we can check after each write also */
- {
- return status;
- }
-
- status = BitstreamWriteBits(stream, 8, seqParam->level_idc);
- status = ue_v(stream, seqParam->seq_parameter_set_id);
- status = ue_v(stream, seqParam->log2_max_frame_num_minus4);
- status = ue_v(stream, seqParam->pic_order_cnt_type);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- if (seqParam->pic_order_cnt_type == 0)
- {
- status = ue_v(stream, seqParam->log2_max_pic_order_cnt_lsb_minus4);
- }
- else if (seqParam->pic_order_cnt_type == 1)
- {
- status = BitstreamWrite1Bit(stream, seqParam->delta_pic_order_always_zero_flag);
- status = se_v(stream, seqParam->offset_for_non_ref_pic); /* upto 32 bits */
- status = se_v(stream, seqParam->offset_for_top_to_bottom_field); /* upto 32 bits */
- status = ue_v(stream, seqParam->num_ref_frames_in_pic_order_cnt_cycle);
-
- for (i = 0; i < (int)(seqParam->num_ref_frames_in_pic_order_cnt_cycle); i++)
- {
- status = se_v(stream, seqParam->offset_for_ref_frame[i]); /* upto 32 bits */
- }
- }
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- status = ue_v(stream, seqParam->num_ref_frames);
- status = BitstreamWrite1Bit(stream, seqParam->gaps_in_frame_num_value_allowed_flag);
- status = ue_v(stream, seqParam->pic_width_in_mbs_minus1);
- status = ue_v(stream, seqParam->pic_height_in_map_units_minus1);
- status = BitstreamWrite1Bit(stream, seqParam->frame_mbs_only_flag);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- /* if frame_mbs_only_flag is 0, then write, mb_adaptive_frame_field_frame here */
-
- status = BitstreamWrite1Bit(stream, seqParam->direct_8x8_inference_flag);
- status = BitstreamWrite1Bit(stream, seqParam->frame_cropping_flag);
- if (seqParam->frame_cropping_flag)
- {
- status = ue_v(stream, seqParam->frame_crop_left_offset);
- status = ue_v(stream, seqParam->frame_crop_right_offset);
- status = ue_v(stream, seqParam->frame_crop_top_offset);
- status = ue_v(stream, seqParam->frame_crop_bottom_offset);
- }
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- status = BitstreamWrite1Bit(stream, seqParam->vui_parameters_present_flag);
- if (seqParam->vui_parameters_present_flag)
- {
- /* not supported */
- //return AVCENC_SPS_FAIL;
- EncodeVUI(stream, vui);
- }
-
- return status;
-}
-
-
-void EncodeVUI(AVCEncBitstream* stream, AVCVUIParams* vui)
-{
- int temp;
-
- temp = vui->aspect_ratio_info_present_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- BitstreamWriteBits(stream, 8, vui->aspect_ratio_idc);
- if (vui->aspect_ratio_idc == 255)
- {
- BitstreamWriteBits(stream, 16, vui->sar_width);
- BitstreamWriteBits(stream, 16, vui->sar_height);
- }
- }
- temp = vui->overscan_info_present_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- BitstreamWrite1Bit(stream, vui->overscan_appropriate_flag);
- }
- temp = vui->video_signal_type_present_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- BitstreamWriteBits(stream, 3, vui->video_format);
- BitstreamWrite1Bit(stream, vui->video_full_range_flag);
- temp = vui->colour_description_present_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- BitstreamWriteBits(stream, 8, vui->colour_primaries);
- BitstreamWriteBits(stream, 8, vui->transfer_characteristics);
- BitstreamWriteBits(stream, 8, vui->matrix_coefficients);
- }
- }
- temp = vui->chroma_location_info_present_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- ue_v(stream, vui->chroma_sample_loc_type_top_field);
- ue_v(stream, vui->chroma_sample_loc_type_bottom_field);
- }
-
- temp = vui->timing_info_present_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- BitstreamWriteBits(stream, 32, vui->num_units_in_tick);
- BitstreamWriteBits(stream, 32, vui->time_scale);
- BitstreamWrite1Bit(stream, vui->fixed_frame_rate_flag);
- }
-
- temp = vui->nal_hrd_parameters_present_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- EncodeHRD(stream, &(vui->nal_hrd_parameters));
- }
- temp = vui->vcl_hrd_parameters_present_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- EncodeHRD(stream, &(vui->vcl_hrd_parameters));
- }
- if (vui->nal_hrd_parameters_present_flag || vui->vcl_hrd_parameters_present_flag)
- {
- BitstreamWrite1Bit(stream, vui->low_delay_hrd_flag);
- }
- BitstreamWrite1Bit(stream, vui->pic_struct_present_flag);
- temp = vui->bitstream_restriction_flag;
- BitstreamWrite1Bit(stream, temp);
- if (temp)
- {
- BitstreamWrite1Bit(stream, vui->motion_vectors_over_pic_boundaries_flag);
- ue_v(stream, vui->max_bytes_per_pic_denom);
- ue_v(stream, vui->max_bits_per_mb_denom);
- ue_v(stream, vui->log2_max_mv_length_horizontal);
- ue_v(stream, vui->log2_max_mv_length_vertical);
- ue_v(stream, vui->max_dec_frame_reordering);
- ue_v(stream, vui->max_dec_frame_buffering);
- }
-
- return ;
-}
-
-
-void EncodeHRD(AVCEncBitstream* stream, AVCHRDParams* hrd)
-{
- int i;
-
- ue_v(stream, hrd->cpb_cnt_minus1);
- BitstreamWriteBits(stream, 4, hrd->bit_rate_scale);
- BitstreamWriteBits(stream, 4, hrd->cpb_size_scale);
- for (i = 0; i <= (int)hrd->cpb_cnt_minus1; i++)
- {
- ue_v(stream, hrd->bit_rate_value_minus1[i]);
- ue_v(stream, hrd->cpb_size_value_minus1[i]);
- ue_v(stream, hrd->cbr_flag[i]);
- }
- BitstreamWriteBits(stream, 5, hrd->initial_cpb_removal_delay_length_minus1);
- BitstreamWriteBits(stream, 5, hrd->cpb_removal_delay_length_minus1);
- BitstreamWriteBits(stream, 5, hrd->dpb_output_delay_length_minus1);
- BitstreamWriteBits(stream, 5, hrd->time_offset_length);
-
- return ;
-}
-
-
-
-/** see subclause 7.4.2.2 */
-/* no need for checking the valid range , already done in SetEncodeParam().
-If we have to send another SPS, the ranges should be verified first before
-users call PVAVCEncodeSPS()*/
-AVCEnc_Status EncodePPS(AVCEncObject *encvid, AVCEncBitstream *stream)
-{
- AVCCommonObj *video = encvid->common;
- AVCEnc_Status status = AVCENC_SUCCESS;
- AVCPicParamSet *picParam = video->currPicParams;
- int i, iGroup, numBits;
- uint temp;
-
- status = ue_v(stream, picParam->pic_parameter_set_id);
- status = ue_v(stream, picParam->seq_parameter_set_id);
- status = BitstreamWrite1Bit(stream, picParam->entropy_coding_mode_flag);
- status = BitstreamWrite1Bit(stream, picParam->pic_order_present_flag);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- status = ue_v(stream, picParam->num_slice_groups_minus1);
- if (picParam->num_slice_groups_minus1 > 0)
- {
- status = ue_v(stream, picParam->slice_group_map_type);
- if (picParam->slice_group_map_type == 0)
- {
- for (iGroup = 0; iGroup <= (int)picParam->num_slice_groups_minus1; iGroup++)
- {
- status = ue_v(stream, picParam->run_length_minus1[iGroup]);
- }
- }
- else if (picParam->slice_group_map_type == 2)
- {
- for (iGroup = 0; iGroup < (int)picParam->num_slice_groups_minus1; iGroup++)
- {
- status = ue_v(stream, picParam->top_left[iGroup]);
- status = ue_v(stream, picParam->bottom_right[iGroup]);
- }
- }
- else if (picParam->slice_group_map_type == 3 ||
- picParam->slice_group_map_type == 4 ||
- picParam->slice_group_map_type == 5)
- {
- status = BitstreamWrite1Bit(stream, picParam->slice_group_change_direction_flag);
- status = ue_v(stream, picParam->slice_group_change_rate_minus1);
- }
- else /*if(picParam->slice_group_map_type == 6)*/
- {
- status = ue_v(stream, picParam->pic_size_in_map_units_minus1);
-
- numBits = 0;/* ceil(log2(num_slice_groups_minus1+1)) bits */
- i = picParam->num_slice_groups_minus1;
- while (i > 0)
- {
- numBits++;
- i >>= 1;
- }
-
- for (i = 0; i <= (int)picParam->pic_size_in_map_units_minus1; i++)
- {
- status = BitstreamWriteBits(stream, numBits, picParam->slice_group_id[i]);
- }
- }
- }
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- status = ue_v(stream, picParam->num_ref_idx_l0_active_minus1);
- status = ue_v(stream, picParam->num_ref_idx_l1_active_minus1);
- status = BitstreamWrite1Bit(stream, picParam->weighted_pred_flag);
- status = BitstreamWriteBits(stream, 2, picParam->weighted_bipred_idc);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- status = se_v(stream, picParam->pic_init_qp_minus26);
- status = se_v(stream, picParam->pic_init_qs_minus26);
- status = se_v(stream, picParam->chroma_qp_index_offset);
-
- temp = picParam->deblocking_filter_control_present_flag << 2;
- temp |= (picParam->constrained_intra_pred_flag << 1);
- temp |= picParam->redundant_pic_cnt_present_flag;
-
- status = BitstreamWriteBits(stream, 3, temp);
-
- return status;
-}
-
-/** see subclause 7.4.3 */
-AVCEnc_Status EncodeSliceHeader(AVCEncObject *encvid, AVCEncBitstream *stream)
-{
- AVCCommonObj *video = encvid->common;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCPicParamSet *currPPS = video->currPicParams;
- AVCSeqParamSet *currSPS = video->currSeqParams;
- AVCEnc_Status status = AVCENC_SUCCESS;
- int slice_type, temp, i;
- int num_bits;
-
- num_bits = (stream->write_pos << 3) - stream->bit_left;
-
- status = ue_v(stream, sliceHdr->first_mb_in_slice);
-
- slice_type = video->slice_type;
-
- if (video->mbNum == 0) /* first mb in frame */
- {
- status = ue_v(stream, sliceHdr->slice_type);
- }
- else
- {
- status = ue_v(stream, slice_type);
- }
-
- status = ue_v(stream, sliceHdr->pic_parameter_set_id);
-
- status = BitstreamWriteBits(stream, currSPS->log2_max_frame_num_minus4 + 4, sliceHdr->frame_num);
-
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- /* if frame_mbs_only_flag is 0, encode field_pic_flag, bottom_field_flag here */
-
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- status = ue_v(stream, sliceHdr->idr_pic_id);
- }
-
- if (currSPS->pic_order_cnt_type == 0)
- {
- status = BitstreamWriteBits(stream, currSPS->log2_max_pic_order_cnt_lsb_minus4 + 4,
- sliceHdr->pic_order_cnt_lsb);
-
- if (currPPS->pic_order_present_flag && !sliceHdr->field_pic_flag)
- {
- status = se_v(stream, sliceHdr->delta_pic_order_cnt_bottom); /* 32 bits */
- }
- }
- if (currSPS->pic_order_cnt_type == 1 && !currSPS->delta_pic_order_always_zero_flag)
- {
- status = se_v(stream, sliceHdr->delta_pic_order_cnt[0]); /* 32 bits */
- if (currPPS->pic_order_present_flag && !sliceHdr->field_pic_flag)
- {
- status = se_v(stream, sliceHdr->delta_pic_order_cnt[1]); /* 32 bits */
- }
- }
-
- if (currPPS->redundant_pic_cnt_present_flag)
- {
- status = ue_v(stream, sliceHdr->redundant_pic_cnt);
- }
-
- if (slice_type == AVC_B_SLICE)
- {
- status = BitstreamWrite1Bit(stream, sliceHdr->direct_spatial_mv_pred_flag);
- }
-
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- if (slice_type == AVC_P_SLICE || slice_type == AVC_SP_SLICE || slice_type == AVC_B_SLICE)
- {
- status = BitstreamWrite1Bit(stream, sliceHdr->num_ref_idx_active_override_flag);
- if (sliceHdr->num_ref_idx_active_override_flag)
- {
- /* we shouldn't enter this part at all */
- status = ue_v(stream, sliceHdr->num_ref_idx_l0_active_minus1);
- if (slice_type == AVC_B_SLICE)
- {
- status = ue_v(stream, sliceHdr->num_ref_idx_l1_active_minus1);
- }
- }
- }
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- /* ref_pic_list_reordering() */
- status = ref_pic_list_reordering(video, stream, sliceHdr, slice_type);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- if ((currPPS->weighted_pred_flag && (slice_type == AVC_P_SLICE || slice_type == AVC_SP_SLICE)) ||
- (currPPS->weighted_bipred_idc == 1 && slice_type == AVC_B_SLICE))
- {
- // pred_weight_table(); // not supported !!
- return AVCENC_PRED_WEIGHT_TAB_FAIL;
- }
-
- if (video->nal_ref_idc != 0)
- {
- status = dec_ref_pic_marking(video, stream, sliceHdr);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- }
-
- if (currPPS->entropy_coding_mode_flag && slice_type != AVC_I_SLICE && slice_type != AVC_SI_SLICE)
- {
- return AVCENC_CABAC_FAIL;
- /* ue_v(stream,&(sliceHdr->cabac_init_idc));
- if(sliceHdr->cabac_init_idc > 2){
- // not supported !!!!
- }*/
- }
-
- status = se_v(stream, sliceHdr->slice_qp_delta);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- if (slice_type == AVC_SP_SLICE || slice_type == AVC_SI_SLICE)
- {
- if (slice_type == AVC_SP_SLICE)
- {
- status = BitstreamWrite1Bit(stream, sliceHdr->sp_for_switch_flag);
- /* if sp_for_switch_flag is 0, P macroblocks in SP slice is decoded using
- SP decoding process for non-switching pictures in 8.6.1 */
- /* else, P macroblocks in SP slice is decoded using SP and SI decoding
- process for switching picture in 8.6.2 */
- }
- status = se_v(stream, sliceHdr->slice_qs_delta);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- }
-
- if (currPPS->deblocking_filter_control_present_flag)
- {
-
- status = ue_v(stream, sliceHdr->disable_deblocking_filter_idc);
-
- if (sliceHdr->disable_deblocking_filter_idc != 1)
- {
- status = se_v(stream, sliceHdr->slice_alpha_c0_offset_div2);
-
- status = se_v(stream, sliceHdr->slice_beta_offset_div_2);
- }
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- }
-
- if (currPPS->num_slice_groups_minus1 > 0 && currPPS->slice_group_map_type >= 3
- && currPPS->slice_group_map_type <= 5)
- {
- /* Ceil(Log2(PicSizeInMapUnits/(float)SliceGroupChangeRate + 1)) */
- temp = video->PicSizeInMapUnits / video->SliceGroupChangeRate;
- if (video->PicSizeInMapUnits % video->SliceGroupChangeRate)
- {
- temp++;
- }
- i = 0;
- while (temp > 1)
- {
- temp >>= 1;
- i++;
- }
-
- BitstreamWriteBits(stream, i, sliceHdr->slice_group_change_cycle);
- }
-
-
- encvid->rateCtrl->NumberofHeaderBits += (stream->write_pos << 3) - stream->bit_left - num_bits;
-
- return AVCENC_SUCCESS;
-}
-
-/** see subclause 7.4.3.1 */
-AVCEnc_Status ref_pic_list_reordering(AVCCommonObj *video, AVCEncBitstream *stream, AVCSliceHeader *sliceHdr, int slice_type)
-{
- (void)(video);
- int i;
- AVCEnc_Status status = AVCENC_SUCCESS;
-
- if (slice_type != AVC_I_SLICE && slice_type != AVC_SI_SLICE)
- {
- status = BitstreamWrite1Bit(stream, sliceHdr->ref_pic_list_reordering_flag_l0);
- if (sliceHdr->ref_pic_list_reordering_flag_l0)
- {
- i = 0;
- do
- {
- status = ue_v(stream, sliceHdr->reordering_of_pic_nums_idc_l0[i]);
- if (sliceHdr->reordering_of_pic_nums_idc_l0[i] == 0 ||
- sliceHdr->reordering_of_pic_nums_idc_l0[i] == 1)
- {
- status = ue_v(stream, sliceHdr->abs_diff_pic_num_minus1_l0[i]);
- /* this check should be in InitSlice(), if we ever use it */
- /*if(sliceHdr->reordering_of_pic_nums_idc_l0[i] == 0 &&
- sliceHdr->abs_diff_pic_num_minus1_l0[i] > video->MaxPicNum/2 -1)
- {
- return AVCENC_REF_PIC_REORDER_FAIL; // out of range
- }
- if(sliceHdr->reordering_of_pic_nums_idc_l0[i] == 1 &&
- sliceHdr->abs_diff_pic_num_minus1_l0[i] > video->MaxPicNum/2 -2)
- {
- return AVCENC_REF_PIC_REORDER_FAIL; // out of range
- }*/
- }
- else if (sliceHdr->reordering_of_pic_nums_idc_l0[i] == 2)
- {
- status = ue_v(stream, sliceHdr->long_term_pic_num_l0[i]);
- }
- i++;
- }
- while (sliceHdr->reordering_of_pic_nums_idc_l0[i] != 3
- && i <= (int)sliceHdr->num_ref_idx_l0_active_minus1 + 1) ;
- }
- }
- if (slice_type == AVC_B_SLICE)
- {
- status = BitstreamWrite1Bit(stream, sliceHdr->ref_pic_list_reordering_flag_l1);
- if (sliceHdr->ref_pic_list_reordering_flag_l1)
- {
- i = 0;
- do
- {
- status = ue_v(stream, sliceHdr->reordering_of_pic_nums_idc_l1[i]);
- if (sliceHdr->reordering_of_pic_nums_idc_l1[i] == 0 ||
- sliceHdr->reordering_of_pic_nums_idc_l1[i] == 1)
- {
- status = ue_v(stream, sliceHdr->abs_diff_pic_num_minus1_l1[i]);
- /* This check should be in InitSlice() if we ever use it
- if(sliceHdr->reordering_of_pic_nums_idc_l1[i] == 0 &&
- sliceHdr->abs_diff_pic_num_minus1_l1[i] > video->MaxPicNum/2 -1)
- {
- return AVCENC_REF_PIC_REORDER_FAIL; // out of range
- }
- if(sliceHdr->reordering_of_pic_nums_idc_l1[i] == 1 &&
- sliceHdr->abs_diff_pic_num_minus1_l1[i] > video->MaxPicNum/2 -2)
- {
- return AVCENC_REF_PIC_REORDER_FAIL; // out of range
- }*/
- }
- else if (sliceHdr->reordering_of_pic_nums_idc_l1[i] == 2)
- {
- status = ue_v(stream, sliceHdr->long_term_pic_num_l1[i]);
- }
- i++;
- }
- while (sliceHdr->reordering_of_pic_nums_idc_l1[i] != 3
- && i <= (int)sliceHdr->num_ref_idx_l1_active_minus1 + 1) ;
- }
- }
-
- return status;
-}
-
-/** see subclause 7.4.3.3 */
-AVCEnc_Status dec_ref_pic_marking(AVCCommonObj *video, AVCEncBitstream *stream, AVCSliceHeader *sliceHdr)
-{
- int i;
- AVCEnc_Status status = AVCENC_SUCCESS;
-
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- status = BitstreamWrite1Bit(stream, sliceHdr->no_output_of_prior_pics_flag);
- status = BitstreamWrite1Bit(stream, sliceHdr->long_term_reference_flag);
- if (sliceHdr->long_term_reference_flag == 0) /* used for short-term */
- {
- video->MaxLongTermFrameIdx = -1; /* no long-term frame indx */
- }
- else /* used for long-term */
- {
- video->MaxLongTermFrameIdx = 0;
- video->LongTermFrameIdx = 0;
- }
- }
- else
- {
- status = BitstreamWrite1Bit(stream, sliceHdr->adaptive_ref_pic_marking_mode_flag); /* default to zero */
- if (sliceHdr->adaptive_ref_pic_marking_mode_flag)
- {
- i = 0;
- do
- {
- status = ue_v(stream, sliceHdr->memory_management_control_operation[i]);
- if (sliceHdr->memory_management_control_operation[i] == 1 ||
- sliceHdr->memory_management_control_operation[i] == 3)
- {
- status = ue_v(stream, sliceHdr->difference_of_pic_nums_minus1[i]);
- }
- if (sliceHdr->memory_management_control_operation[i] == 2)
- {
- status = ue_v(stream, sliceHdr->long_term_pic_num[i]);
- }
- if (sliceHdr->memory_management_control_operation[i] == 3 ||
- sliceHdr->memory_management_control_operation[i] == 6)
- {
- status = ue_v(stream, sliceHdr->long_term_frame_idx[i]);
- }
- if (sliceHdr->memory_management_control_operation[i] == 4)
- {
- status = ue_v(stream, sliceHdr->max_long_term_frame_idx_plus1[i]);
- }
- i++;
- }
- while (sliceHdr->memory_management_control_operation[i] != 0 && i < MAX_DEC_REF_PIC_MARKING);
- if (i >= MAX_DEC_REF_PIC_MARKING && sliceHdr->memory_management_control_operation[i] != 0)
- {
- return AVCENC_DEC_REF_PIC_MARK_FAIL; /* we're screwed!!, not enough memory */
- }
- }
- }
-
- return status;
-}
-
-/* see subclause 8.2.1 Decoding process for picture order count.
-See also PostPOC() for initialization of some variables. */
-AVCEnc_Status InitPOC(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- AVCSeqParamSet *currSPS = video->currSeqParams;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCFrameIO *currInput = encvid->currInput;
- int i;
-
- switch (currSPS->pic_order_cnt_type)
- {
- case 0: /* POC MODE 0 , subclause 8.2.1.1 */
- /* encoding part */
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- encvid->dispOrdPOCRef = currInput->disp_order;
- }
- while (currInput->disp_order < encvid->dispOrdPOCRef)
- {
- encvid->dispOrdPOCRef -= video->MaxPicOrderCntLsb;
- }
- sliceHdr->pic_order_cnt_lsb = currInput->disp_order - encvid->dispOrdPOCRef;
- while (sliceHdr->pic_order_cnt_lsb >= video->MaxPicOrderCntLsb)
- {
- sliceHdr->pic_order_cnt_lsb -= video->MaxPicOrderCntLsb;
- }
- /* decoding part */
- /* Calculate the MSBs of current picture */
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- video->prevPicOrderCntMsb = 0;
- video->prevPicOrderCntLsb = 0;
- }
- if (sliceHdr->pic_order_cnt_lsb < video->prevPicOrderCntLsb &&
- (video->prevPicOrderCntLsb - sliceHdr->pic_order_cnt_lsb) >= (video->MaxPicOrderCntLsb / 2))
- video->PicOrderCntMsb = video->prevPicOrderCntMsb + video->MaxPicOrderCntLsb;
- else if (sliceHdr->pic_order_cnt_lsb > video->prevPicOrderCntLsb &&
- (sliceHdr->pic_order_cnt_lsb - video->prevPicOrderCntLsb) > (video->MaxPicOrderCntLsb / 2))
- video->PicOrderCntMsb = video->prevPicOrderCntMsb - video->MaxPicOrderCntLsb;
- else
- video->PicOrderCntMsb = video->prevPicOrderCntMsb;
-
- /* JVT-I010 page 81 is different from JM7.3 */
- if (!sliceHdr->field_pic_flag || !sliceHdr->bottom_field_flag)
- {
- video->PicOrderCnt = video->TopFieldOrderCnt = video->PicOrderCntMsb + sliceHdr->pic_order_cnt_lsb;
- }
-
- if (!sliceHdr->field_pic_flag)
- {
- video->BottomFieldOrderCnt = video->TopFieldOrderCnt + sliceHdr->delta_pic_order_cnt_bottom;
- }
- else if (sliceHdr->bottom_field_flag)
- {
- video->PicOrderCnt = video->BottomFieldOrderCnt = video->PicOrderCntMsb + sliceHdr->pic_order_cnt_lsb;
- }
-
- if (!sliceHdr->field_pic_flag)
- {
- video->PicOrderCnt = AVC_MIN(video->TopFieldOrderCnt, video->BottomFieldOrderCnt);
- }
-
- if (video->currPicParams->pic_order_present_flag && !sliceHdr->field_pic_flag)
- {
- sliceHdr->delta_pic_order_cnt_bottom = 0; /* defaulted to zero */
- }
-
- break;
- case 1: /* POC MODE 1, subclause 8.2.1.2 */
- /* calculate FrameNumOffset */
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- encvid->dispOrdPOCRef = currInput->disp_order; /* reset the reference point */
- video->prevFrameNumOffset = 0;
- video->FrameNumOffset = 0;
- }
- else if (video->prevFrameNum > sliceHdr->frame_num)
- {
- video->FrameNumOffset = video->prevFrameNumOffset + video->MaxFrameNum;
- }
- else
- {
- video->FrameNumOffset = video->prevFrameNumOffset;
- }
- /* calculate absFrameNum */
- if (currSPS->num_ref_frames_in_pic_order_cnt_cycle)
- {
- video->absFrameNum = video->FrameNumOffset + sliceHdr->frame_num;
- }
- else
- {
- video->absFrameNum = 0;
- }
-
- if (video->absFrameNum > 0 && video->nal_ref_idc == 0)
- {
- video->absFrameNum--;
- }
-
- /* derive picOrderCntCycleCnt and frameNumInPicOrderCntCycle */
- if (video->absFrameNum > 0)
- {
- video->picOrderCntCycleCnt = (video->absFrameNum - 1) / currSPS->num_ref_frames_in_pic_order_cnt_cycle;
- video->frameNumInPicOrderCntCycle = (video->absFrameNum - 1) % currSPS->num_ref_frames_in_pic_order_cnt_cycle;
- }
- /* derive expectedDeltaPerPicOrderCntCycle, this value can be computed up front. */
- video->expectedDeltaPerPicOrderCntCycle = 0;
- for (i = 0; i < (int)currSPS->num_ref_frames_in_pic_order_cnt_cycle; i++)
- {
- video->expectedDeltaPerPicOrderCntCycle += currSPS->offset_for_ref_frame[i];
- }
- /* derive expectedPicOrderCnt */
- if (video->absFrameNum)
- {
- video->expectedPicOrderCnt = video->picOrderCntCycleCnt * video->expectedDeltaPerPicOrderCntCycle;
- for (i = 0; i <= video->frameNumInPicOrderCntCycle; i++)
- {
- video->expectedPicOrderCnt += currSPS->offset_for_ref_frame[i];
- }
- }
- else
- {
- video->expectedPicOrderCnt = 0;
- }
-
- if (video->nal_ref_idc == 0)
- {
- video->expectedPicOrderCnt += currSPS->offset_for_non_ref_pic;
- }
- /* derive TopFieldOrderCnt and BottomFieldOrderCnt */
- /* encoding part */
- if (!currSPS->delta_pic_order_always_zero_flag)
- {
- sliceHdr->delta_pic_order_cnt[0] = currInput->disp_order - encvid->dispOrdPOCRef - video->expectedPicOrderCnt;
-
- if (video->currPicParams->pic_order_present_flag && !sliceHdr->field_pic_flag)
- {
- sliceHdr->delta_pic_order_cnt[1] = sliceHdr->delta_pic_order_cnt[0]; /* should be calculated from currInput->bottom_field->disp_order */
- }
- else
- {
- sliceHdr->delta_pic_order_cnt[1] = 0;
- }
- }
- else
- {
- sliceHdr->delta_pic_order_cnt[0] = sliceHdr->delta_pic_order_cnt[1] = 0;
- }
-
- if (sliceHdr->field_pic_flag == 0)
- {
- video->TopFieldOrderCnt = video->expectedPicOrderCnt + sliceHdr->delta_pic_order_cnt[0];
- video->BottomFieldOrderCnt = video->TopFieldOrderCnt + currSPS->offset_for_top_to_bottom_field + sliceHdr->delta_pic_order_cnt[1];
-
- video->PicOrderCnt = AVC_MIN(video->TopFieldOrderCnt, video->BottomFieldOrderCnt);
- }
- else if (sliceHdr->bottom_field_flag == 0)
- {
- video->TopFieldOrderCnt = video->expectedPicOrderCnt + sliceHdr->delta_pic_order_cnt[0];
- video->PicOrderCnt = video->TopFieldOrderCnt;
- }
- else
- {
- video->BottomFieldOrderCnt = video->expectedPicOrderCnt + currSPS->offset_for_top_to_bottom_field + sliceHdr->delta_pic_order_cnt[0];
- video->PicOrderCnt = video->BottomFieldOrderCnt;
- }
- break;
-
-
- case 2: /* POC MODE 2, subclause 8.2.1.3 */
- /* decoding order must be the same as display order */
- /* we don't check for that. The decoder will just output in decoding order. */
- /* Check for 2 consecutive non-reference frame */
- if (video->nal_ref_idc == 0)
- {
- if (encvid->dispOrdPOCRef == 1)
- {
- return AVCENC_CONSECUTIVE_NONREF;
- }
- encvid->dispOrdPOCRef = 1; /* act as a flag for non ref */
- }
- else
- {
- encvid->dispOrdPOCRef = 0;
- }
-
-
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- video->FrameNumOffset = 0;
- }
- else if (video->prevFrameNum > sliceHdr->frame_num)
- {
- video->FrameNumOffset = video->prevFrameNumOffset + video->MaxFrameNum;
- }
- else
- {
- video->FrameNumOffset = video->prevFrameNumOffset;
- }
- /* derive tempPicOrderCnt, we just use PicOrderCnt */
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- video->PicOrderCnt = 0;
- }
- else if (video->nal_ref_idc == 0)
- {
- video->PicOrderCnt = 2 * (video->FrameNumOffset + sliceHdr->frame_num) - 1;
- }
- else
- {
- video->PicOrderCnt = 2 * (video->FrameNumOffset + sliceHdr->frame_num);
- }
- /* derive TopFieldOrderCnt and BottomFieldOrderCnt */
- if (sliceHdr->field_pic_flag == 0)
- {
- video->TopFieldOrderCnt = video->BottomFieldOrderCnt = video->PicOrderCnt;
- }
- else if (sliceHdr->bottom_field_flag)
- {
- video->BottomFieldOrderCnt = video->PicOrderCnt;
- }
- else
- {
- video->TopFieldOrderCnt = video->PicOrderCnt;
- }
- break;
- default:
- return AVCENC_POC_FAIL;
- }
-
- return AVCENC_SUCCESS;
-}
-
-/** see subclause 8.2.1 */
-AVCEnc_Status PostPOC(AVCCommonObj *video)
-{
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCSeqParamSet *currSPS = video->currSeqParams;
-
- video->prevFrameNum = sliceHdr->frame_num;
-
- switch (currSPS->pic_order_cnt_type)
- {
- case 0: /* subclause 8.2.1.1 */
- if (video->mem_mgr_ctrl_eq_5)
- {
- video->prevPicOrderCntMsb = 0;
- video->prevPicOrderCntLsb = video->TopFieldOrderCnt;
- }
- else
- {
- video->prevPicOrderCntMsb = video->PicOrderCntMsb;
- video->prevPicOrderCntLsb = sliceHdr->pic_order_cnt_lsb;
- }
- break;
- case 1: /* subclause 8.2.1.2 and 8.2.1.3 */
- case 2:
- if (video->mem_mgr_ctrl_eq_5)
- {
- video->prevFrameNumOffset = 0;
- }
- else
- {
- video->prevFrameNumOffset = video->FrameNumOffset;
- }
- break;
- }
-
- return AVCENC_SUCCESS;
-}
-
diff --git a/media/libstagefright/codecs/avc/enc/src/init.cpp b/media/libstagefright/codecs/avc/enc/src/init.cpp
deleted file mode 100644
index 6e1413a..0000000
--- a/media/libstagefright/codecs/avc/enc/src/init.cpp
+++ /dev/null
@@ -1,895 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-#include "avcenc_api.h"
-
-#define LOG2_MAX_FRAME_NUM_MINUS4 12 /* 12 default */
-#define SLICE_GROUP_CHANGE_CYCLE 1 /* default */
-
-/* initialized variables to be used in SPS*/
-AVCEnc_Status SetEncodeParam(AVCHandle* avcHandle, AVCEncParams* encParam,
- void* extSPS, void* extPPS)
-{
- AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
- AVCCommonObj *video = encvid->common;
- AVCSeqParamSet *seqParam = video->currSeqParams;
- AVCPicParamSet *picParam = video->currPicParams;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- AVCEnc_Status status;
- void *userData = avcHandle->userData;
- int ii, maxFrameNum;
-
- AVCSeqParamSet* extS = NULL;
- AVCPicParamSet* extP = NULL;
-
- if (extSPS) extS = (AVCSeqParamSet*) extSPS;
- if (extPPS) extP = (AVCPicParamSet*) extPPS;
-
- /* This part sets the default values of the encoding options this
- library supports in seqParam, picParam and sliceHdr structures and
- also copy the values from the encParam into the above 3 structures.
-
- Some parameters will be assigned later when we encode SPS or PPS such as
- the seq_parameter_id or pic_parameter_id. Also some of the slice parameters
- have to be re-assigned per slice basis such as frame_num, slice_type,
- first_mb_in_slice, pic_order_cnt_lsb, slice_qp_delta, slice_group_change_cycle */
-
- /* profile_idc, constrained_setx_flag and level_idc is set by VerifyProfile(),
- and VerifyLevel() functions later. */
-
- encvid->fullsearch_enable = encParam->fullsearch;
-
- encvid->outOfBandParamSet = ((encParam->out_of_band_param_set == AVC_ON) ? TRUE : FALSE);
-
- /* parameters derived from the the encParam that are used in SPS */
- if (extS)
- {
- video->MaxPicOrderCntLsb = 1 << (extS->log2_max_pic_order_cnt_lsb_minus4 + 4);
- video->PicWidthInMbs = extS->pic_width_in_mbs_minus1 + 1;
- video->PicHeightInMapUnits = extS->pic_height_in_map_units_minus1 + 1 ;
- video->FrameHeightInMbs = (2 - extS->frame_mbs_only_flag) * video->PicHeightInMapUnits ;
- }
- else
- {
- video->MaxPicOrderCntLsb = 1 << (encParam->log2_max_poc_lsb_minus_4 + 4);
- video->PicWidthInMbs = (encParam->width + 15) >> 4; /* round it to multiple of 16 */
- video->FrameHeightInMbs = (encParam->height + 15) >> 4; /* round it to multiple of 16 */
- video->PicHeightInMapUnits = video->FrameHeightInMbs;
- }
-
- video->PicWidthInSamplesL = video->PicWidthInMbs * 16 ;
- if (video->PicWidthInSamplesL + 32 > 0xFFFF)
- {
- return AVCENC_NOT_SUPPORTED; // we use 2-bytes for pitch
- }
-
- video->PicWidthInSamplesC = video->PicWidthInMbs * 8 ;
- video->PicHeightInMbs = video->FrameHeightInMbs;
- video->PicSizeInMapUnits = video->PicWidthInMbs * video->PicHeightInMapUnits ;
- video->PicHeightInSamplesL = video->PicHeightInMbs * 16;
- video->PicHeightInSamplesC = video->PicHeightInMbs * 8;
- video->PicSizeInMbs = video->PicWidthInMbs * video->PicHeightInMbs;
-
- if (!extS && !extP)
- {
- maxFrameNum = (encParam->idr_period == -1) ? (1 << 16) : encParam->idr_period;
- ii = 0;
- while (maxFrameNum > 0)
- {
- ii++;
- maxFrameNum >>= 1;
- }
- if (ii < 4) ii = 4;
- else if (ii > 16) ii = 16;
-
- seqParam->log2_max_frame_num_minus4 = ii - 4;//LOG2_MAX_FRAME_NUM_MINUS4; /* default */
-
- video->MaxFrameNum = 1 << ii; //(LOG2_MAX_FRAME_NUM_MINUS4 + 4); /* default */
- video->MaxPicNum = video->MaxFrameNum;
-
- /************* set the SPS *******************/
- seqParam->seq_parameter_set_id = 0; /* start with zero */
- /* POC */
- seqParam->pic_order_cnt_type = encParam->poc_type; /* POC type */
- if (encParam->poc_type == 0)
- {
- if (/*encParam->log2_max_poc_lsb_minus_4<0 || (no need, it's unsigned)*/
- encParam->log2_max_poc_lsb_minus_4 > 12)
- {
- return AVCENC_INVALID_POC_LSB;
- }
- seqParam->log2_max_pic_order_cnt_lsb_minus4 = encParam->log2_max_poc_lsb_minus_4;
- }
- else if (encParam->poc_type == 1)
- {
- seqParam->delta_pic_order_always_zero_flag = encParam->delta_poc_zero_flag;
- seqParam->offset_for_non_ref_pic = encParam->offset_poc_non_ref;
- seqParam->offset_for_top_to_bottom_field = encParam->offset_top_bottom;
- seqParam->num_ref_frames_in_pic_order_cnt_cycle = encParam->num_ref_in_cycle;
- if (encParam->offset_poc_ref == NULL)
- {
- return AVCENC_ENCPARAM_MEM_FAIL;
- }
- for (ii = 0; ii < encParam->num_ref_frame; ii++)
- {
- seqParam->offset_for_ref_frame[ii] = encParam->offset_poc_ref[ii];
- }
- }
- /* number of reference frame */
- if (encParam->num_ref_frame > 16 || encParam->num_ref_frame < 0)
- {
- return AVCENC_INVALID_NUM_REF;
- }
- seqParam->num_ref_frames = encParam->num_ref_frame; /* num reference frame range 0...16*/
- seqParam->gaps_in_frame_num_value_allowed_flag = FALSE;
- seqParam->pic_width_in_mbs_minus1 = video->PicWidthInMbs - 1;
- seqParam->pic_height_in_map_units_minus1 = video->PicHeightInMapUnits - 1;
- seqParam->frame_mbs_only_flag = TRUE;
- seqParam->mb_adaptive_frame_field_flag = FALSE;
- seqParam->direct_8x8_inference_flag = FALSE; /* default */
- seqParam->frame_cropping_flag = FALSE;
- seqParam->frame_crop_bottom_offset = 0;
- seqParam->frame_crop_left_offset = 0;
- seqParam->frame_crop_right_offset = 0;
- seqParam->frame_crop_top_offset = 0;
- seqParam->vui_parameters_present_flag = FALSE; /* default */
- }
- else if (extS) // use external SPS and PPS
- {
- seqParam->seq_parameter_set_id = extS->seq_parameter_set_id;
- seqParam->log2_max_frame_num_minus4 = extS->log2_max_frame_num_minus4;
- video->MaxFrameNum = 1 << (extS->log2_max_frame_num_minus4 + 4);
- video->MaxPicNum = video->MaxFrameNum;
- if (encParam->idr_period > (int)(video->MaxFrameNum) || (encParam->idr_period == -1))
- {
- encParam->idr_period = (int)video->MaxFrameNum;
- }
-
- seqParam->pic_order_cnt_type = extS->pic_order_cnt_type;
- if (seqParam->pic_order_cnt_type == 0)
- {
- if (/*extS->log2_max_pic_order_cnt_lsb_minus4<0 || (no need it's unsigned)*/
- extS->log2_max_pic_order_cnt_lsb_minus4 > 12)
- {
- return AVCENC_INVALID_POC_LSB;
- }
- seqParam->log2_max_pic_order_cnt_lsb_minus4 = extS->log2_max_pic_order_cnt_lsb_minus4;
- }
- else if (seqParam->pic_order_cnt_type == 1)
- {
- seqParam->delta_pic_order_always_zero_flag = extS->delta_pic_order_always_zero_flag;
- seqParam->offset_for_non_ref_pic = extS->offset_for_non_ref_pic;
- seqParam->offset_for_top_to_bottom_field = extS->offset_for_top_to_bottom_field;
- seqParam->num_ref_frames_in_pic_order_cnt_cycle = extS->num_ref_frames_in_pic_order_cnt_cycle;
- for (ii = 0; ii < (int) extS->num_ref_frames; ii++)
- {
- seqParam->offset_for_ref_frame[ii] = extS->offset_for_ref_frame[ii];
- }
- }
- /* number of reference frame */
- if (extS->num_ref_frames > 16 /*|| extS->num_ref_frames<0 (no need, it's unsigned)*/)
- {
- return AVCENC_INVALID_NUM_REF;
- }
- seqParam->num_ref_frames = extS->num_ref_frames; /* num reference frame range 0...16*/
- seqParam->gaps_in_frame_num_value_allowed_flag = extS->gaps_in_frame_num_value_allowed_flag;
- seqParam->pic_width_in_mbs_minus1 = extS->pic_width_in_mbs_minus1;
- seqParam->pic_height_in_map_units_minus1 = extS->pic_height_in_map_units_minus1;
- seqParam->frame_mbs_only_flag = extS->frame_mbs_only_flag;
- if (extS->frame_mbs_only_flag != TRUE)
- {
- return AVCENC_NOT_SUPPORTED;
- }
- seqParam->mb_adaptive_frame_field_flag = extS->mb_adaptive_frame_field_flag;
- if (extS->mb_adaptive_frame_field_flag != FALSE)
- {
- return AVCENC_NOT_SUPPORTED;
- }
-
- seqParam->direct_8x8_inference_flag = extS->direct_8x8_inference_flag;
- seqParam->frame_cropping_flag = extS->frame_cropping_flag ;
- if (extS->frame_cropping_flag != FALSE)
- {
- return AVCENC_NOT_SUPPORTED;
- }
-
- seqParam->frame_crop_bottom_offset = 0;
- seqParam->frame_crop_left_offset = 0;
- seqParam->frame_crop_right_offset = 0;
- seqParam->frame_crop_top_offset = 0;
- seqParam->vui_parameters_present_flag = extS->vui_parameters_present_flag;
- if (extS->vui_parameters_present_flag)
- {
- memcpy(&(seqParam->vui_parameters), &(extS->vui_parameters), sizeof(AVCVUIParams));
- }
- }
- else
- {
- return AVCENC_NOT_SUPPORTED;
- }
-
- /***************** now PPS ******************************/
- if (!extP && !extS)
- {
- picParam->pic_parameter_set_id = (uint)(-1); /* start with zero */
- picParam->seq_parameter_set_id = (uint)(-1); /* start with zero */
- picParam->entropy_coding_mode_flag = 0; /* default to CAVLC */
- picParam->pic_order_present_flag = 0; /* default for now, will need it for B-slice */
- /* FMO */
- if (encParam->num_slice_group < 1 || encParam->num_slice_group > MAX_NUM_SLICE_GROUP)
- {
- return AVCENC_INVALID_NUM_SLICEGROUP;
- }
- picParam->num_slice_groups_minus1 = encParam->num_slice_group - 1;
-
- if (picParam->num_slice_groups_minus1 > 0)
- {
- picParam->slice_group_map_type = encParam->fmo_type;
- switch (encParam->fmo_type)
- {
- case 0:
- for (ii = 0; ii <= (int)picParam->num_slice_groups_minus1; ii++)
- {
- picParam->run_length_minus1[ii] = encParam->run_length_minus1[ii];
- }
- break;
- case 2:
- for (ii = 0; ii < (int)picParam->num_slice_groups_minus1; ii++)
- {
- picParam->top_left[ii] = encParam->top_left[ii];
- picParam->bottom_right[ii] = encParam->bottom_right[ii];
- }
- break;
- case 3:
- case 4:
- case 5:
- if (encParam->change_dir_flag == AVC_ON)
- {
- picParam->slice_group_change_direction_flag = TRUE;
- }
- else
- {
- picParam->slice_group_change_direction_flag = FALSE;
- }
- if (/*encParam->change_rate_minus1 < 0 || (no need it's unsigned) */
- encParam->change_rate_minus1 > video->PicSizeInMapUnits - 1)
- {
- return AVCENC_INVALID_CHANGE_RATE;
- }
- picParam->slice_group_change_rate_minus1 = encParam->change_rate_minus1;
- video->SliceGroupChangeRate = picParam->slice_group_change_rate_minus1 + 1;
- break;
- case 6:
- picParam->pic_size_in_map_units_minus1 = video->PicSizeInMapUnits - 1;
-
- /* allocate picParam->slice_group_id */
- picParam->slice_group_id = (uint*)avcHandle->CBAVC_Malloc(userData, sizeof(uint) * video->PicSizeInMapUnits, DEFAULT_ATTR);
- if (picParam->slice_group_id == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- if (encParam->slice_group == NULL)
- {
- return AVCENC_ENCPARAM_MEM_FAIL;
- }
- for (ii = 0; ii < (int)video->PicSizeInMapUnits; ii++)
- {
- picParam->slice_group_id[ii] = encParam->slice_group[ii];
- }
- break;
- default:
- return AVCENC_INVALID_FMO_TYPE;
- }
- }
- picParam->num_ref_idx_l0_active_minus1 = encParam->num_ref_frame - 1; /* assume frame only */
- picParam->num_ref_idx_l1_active_minus1 = 0; /* default value */
- picParam->weighted_pred_flag = 0; /* no weighted prediction supported */
- picParam->weighted_bipred_idc = 0; /* range 0,1,2 */
- if (/*picParam->weighted_bipred_idc < 0 || (no need, it's unsigned) */
- picParam->weighted_bipred_idc > 2)
- {
- return AVCENC_WEIGHTED_BIPRED_FAIL;
- }
- picParam->pic_init_qp_minus26 = 0; /* default, will be changed at slice level anyway */
- if (picParam->pic_init_qp_minus26 < -26 || picParam->pic_init_qp_minus26 > 25)
- {
- return AVCENC_INIT_QP_FAIL; /* out of range */
- }
- picParam->pic_init_qs_minus26 = 0;
- if (picParam->pic_init_qs_minus26 < -26 || picParam->pic_init_qs_minus26 > 25)
- {
- return AVCENC_INIT_QS_FAIL; /* out of range */
- }
-
- picParam->chroma_qp_index_offset = 0; /* default to zero for now */
- if (picParam->chroma_qp_index_offset < -12 || picParam->chroma_qp_index_offset > 12)
- {
- return AVCENC_CHROMA_QP_FAIL; /* out of range */
- }
- /* deblocking */
- picParam->deblocking_filter_control_present_flag = (encParam->db_filter == AVC_ON) ? TRUE : FALSE ;
- /* constrained intra prediction */
- picParam->constrained_intra_pred_flag = (encParam->constrained_intra_pred == AVC_ON) ? TRUE : FALSE;
- picParam->redundant_pic_cnt_present_flag = 0; /* default */
- }
- else if (extP)// external PPS
- {
- picParam->pic_parameter_set_id = extP->pic_parameter_set_id - 1; /* to be increased by one */
- picParam->seq_parameter_set_id = extP->seq_parameter_set_id;
- picParam->entropy_coding_mode_flag = extP->entropy_coding_mode_flag;
- if (extP->entropy_coding_mode_flag != 0) /* default to CAVLC */
- {
- return AVCENC_NOT_SUPPORTED;
- }
- picParam->pic_order_present_flag = extP->pic_order_present_flag; /* default for now, will need it for B-slice */
- if (extP->pic_order_present_flag != 0)
- {
- return AVCENC_NOT_SUPPORTED;
- }
- /* FMO */
- if (/*(extP->num_slice_groups_minus1<0) || (no need it's unsigned) */
- (extP->num_slice_groups_minus1 > MAX_NUM_SLICE_GROUP - 1))
- {
- return AVCENC_INVALID_NUM_SLICEGROUP;
- }
- picParam->num_slice_groups_minus1 = extP->num_slice_groups_minus1;
-
- if (picParam->num_slice_groups_minus1 > 0)
- {
- picParam->slice_group_map_type = extP->slice_group_map_type;
- switch (extP->slice_group_map_type)
- {
- case 0:
- for (ii = 0; ii <= (int)extP->num_slice_groups_minus1; ii++)
- {
- picParam->run_length_minus1[ii] = extP->run_length_minus1[ii];
- }
- break;
- case 2:
- for (ii = 0; ii < (int)picParam->num_slice_groups_minus1; ii++)
- {
- picParam->top_left[ii] = extP->top_left[ii];
- picParam->bottom_right[ii] = extP->bottom_right[ii];
- }
- break;
- case 3:
- case 4:
- case 5:
- picParam->slice_group_change_direction_flag = extP->slice_group_change_direction_flag;
- if (/*extP->slice_group_change_rate_minus1 < 0 || (no need, it's unsigned) */
- extP->slice_group_change_rate_minus1 > video->PicSizeInMapUnits - 1)
- {
- return AVCENC_INVALID_CHANGE_RATE;
- }
- picParam->slice_group_change_rate_minus1 = extP->slice_group_change_rate_minus1;
- video->SliceGroupChangeRate = picParam->slice_group_change_rate_minus1 + 1;
- break;
- case 6:
- if (extP->pic_size_in_map_units_minus1 != video->PicSizeInMapUnits - 1)
- {
- return AVCENC_NOT_SUPPORTED;
- }
-
- picParam->pic_size_in_map_units_minus1 = extP->pic_size_in_map_units_minus1;
-
- /* allocate picParam->slice_group_id */
- picParam->slice_group_id = (uint*)avcHandle->CBAVC_Malloc(userData, sizeof(uint) * video->PicSizeInMapUnits, DEFAULT_ATTR);
- if (picParam->slice_group_id == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- if (extP->slice_group_id == NULL)
- {
- return AVCENC_ENCPARAM_MEM_FAIL;
- }
- for (ii = 0; ii < (int)video->PicSizeInMapUnits; ii++)
- {
- picParam->slice_group_id[ii] = extP->slice_group_id[ii];
- }
- break;
- default:
- return AVCENC_INVALID_FMO_TYPE;
- }
- }
- picParam->num_ref_idx_l0_active_minus1 = extP->num_ref_idx_l0_active_minus1;
- picParam->num_ref_idx_l1_active_minus1 = extP->num_ref_idx_l1_active_minus1; /* default value */
- if (picParam->num_ref_idx_l1_active_minus1 != 0)
- {
- return AVCENC_NOT_SUPPORTED;
- }
-
- if (extP->weighted_pred_flag)
- {
- return AVCENC_NOT_SUPPORTED;
- }
-
- picParam->weighted_pred_flag = 0; /* no weighted prediction supported */
- picParam->weighted_bipred_idc = extP->weighted_bipred_idc; /* range 0,1,2 */
- if (/*picParam->weighted_bipred_idc < 0 || (no need, it's unsigned) */
- picParam->weighted_bipred_idc > 2)
- {
- return AVCENC_WEIGHTED_BIPRED_FAIL;
- }
- picParam->pic_init_qp_minus26 = extP->pic_init_qp_minus26; /* default, will be changed at slice level anyway */
- if (picParam->pic_init_qp_minus26 < -26 || picParam->pic_init_qp_minus26 > 25)
- {
- return AVCENC_INIT_QP_FAIL; /* out of range */
- }
- picParam->pic_init_qs_minus26 = extP->pic_init_qs_minus26;
- if (picParam->pic_init_qs_minus26 < -26 || picParam->pic_init_qs_minus26 > 25)
- {
- return AVCENC_INIT_QS_FAIL; /* out of range */
- }
-
- picParam->chroma_qp_index_offset = extP->chroma_qp_index_offset; /* default to zero for now */
- if (picParam->chroma_qp_index_offset < -12 || picParam->chroma_qp_index_offset > 12)
- {
- return AVCENC_CHROMA_QP_FAIL; /* out of range */
- }
- /* deblocking */
- picParam->deblocking_filter_control_present_flag = extP->deblocking_filter_control_present_flag;
- /* constrained intra prediction */
- picParam->constrained_intra_pred_flag = extP->constrained_intra_pred_flag;
- if (extP->redundant_pic_cnt_present_flag != 0)
- {
- return AVCENC_NOT_SUPPORTED;
- }
- picParam->redundant_pic_cnt_present_flag = extP->redundant_pic_cnt_present_flag; /* default */
- }
- else
- {
- return AVCENC_NOT_SUPPORTED;
- }
-
- /****************** now set up some SliceHeader parameters ***********/
- if (picParam->deblocking_filter_control_present_flag == TRUE)
- {
- /* these values only present when db_filter is ON */
- if (encParam->disable_db_idc > 2)
- {
- return AVCENC_INVALID_DEBLOCK_IDC; /* out of range */
- }
- sliceHdr->disable_deblocking_filter_idc = encParam->disable_db_idc;
-
- if (encParam->alpha_offset < -6 || encParam->alpha_offset > 6)
- {
- return AVCENC_INVALID_ALPHA_OFFSET;
- }
- sliceHdr->slice_alpha_c0_offset_div2 = encParam->alpha_offset;
-
- if (encParam->beta_offset < -6 || encParam->beta_offset > 6)
- {
- return AVCENC_INVALID_BETA_OFFSET;
- }
- sliceHdr->slice_beta_offset_div_2 = encParam->beta_offset;
- }
- if (encvid->outOfBandParamSet == TRUE)
- {
- sliceHdr->idr_pic_id = 0;
- }
- else
- {
- sliceHdr->idr_pic_id = (uint)(-1); /* start with zero */
- }
- sliceHdr->field_pic_flag = FALSE;
- sliceHdr->bottom_field_flag = FALSE; /* won't be used anyway */
- video->MbaffFrameFlag = (seqParam->mb_adaptive_frame_field_flag && !sliceHdr->field_pic_flag);
-
- /* the rest will be set in InitSlice() */
-
- /* now the rate control and performance related parameters */
- rateCtrl->scdEnable = (encParam->auto_scd == AVC_ON) ? TRUE : FALSE;
- rateCtrl->idrPeriod = encParam->idr_period + 1;
- rateCtrl->intraMBRate = encParam->intramb_refresh;
- rateCtrl->dpEnable = (encParam->data_par == AVC_ON) ? TRUE : FALSE;
-
- rateCtrl->subPelEnable = (encParam->sub_pel == AVC_ON) ? TRUE : FALSE;
- rateCtrl->mvRange = encParam->search_range;
-
- rateCtrl->subMBEnable = (encParam->submb_pred == AVC_ON) ? TRUE : FALSE;
- rateCtrl->rdOptEnable = (encParam->rdopt_mode == AVC_ON) ? TRUE : FALSE;
- rateCtrl->bidirPred = (encParam->bidir_pred == AVC_ON) ? TRUE : FALSE;
-
- rateCtrl->rcEnable = (encParam->rate_control == AVC_ON) ? TRUE : FALSE;
- rateCtrl->initQP = encParam->initQP;
- rateCtrl->initQP = AVC_CLIP3(0, 51, rateCtrl->initQP);
-
- rateCtrl->bitRate = encParam->bitrate;
- rateCtrl->cpbSize = encParam->CPB_size;
- rateCtrl->initDelayOffset = (rateCtrl->bitRate * encParam->init_CBP_removal_delay / 1000);
-
- if (encParam->frame_rate == 0)
- {
- return AVCENC_INVALID_FRAMERATE;
- }
-
- rateCtrl->frame_rate = (OsclFloat)(encParam->frame_rate * 1.0 / 1000);
-// rateCtrl->srcInterval = encParam->src_interval;
- rateCtrl->first_frame = 1; /* set this flag for the first time */
-
- /* contrained_setx_flag will be set inside the VerifyProfile called below.*/
- if (!extS && !extP)
- {
- seqParam->profile_idc = encParam->profile;
- seqParam->constrained_set0_flag = FALSE;
- seqParam->constrained_set1_flag = FALSE;
- seqParam->constrained_set2_flag = FALSE;
- seqParam->constrained_set3_flag = FALSE;
- seqParam->level_idc = encParam->level;
- }
- else
- {
- seqParam->profile_idc = extS->profile_idc;
- seqParam->constrained_set0_flag = extS->constrained_set0_flag;
- seqParam->constrained_set1_flag = extS->constrained_set1_flag;
- seqParam->constrained_set2_flag = extS->constrained_set2_flag;
- seqParam->constrained_set3_flag = extS->constrained_set3_flag;
- seqParam->level_idc = extS->level_idc;
- }
-
-
- status = VerifyProfile(encvid, seqParam, picParam);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- status = VerifyLevel(encvid, seqParam, picParam);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
-
- return AVCENC_SUCCESS;
-}
-
-/* verify the profile setting */
-AVCEnc_Status VerifyProfile(AVCEncObject *encvid, AVCSeqParamSet *seqParam, AVCPicParamSet *picParam)
-{
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- AVCEnc_Status status = AVCENC_SUCCESS;
-
- if (seqParam->profile_idc == 0) /* find profile for this setting */
- {
- /* find the right profile for it */
- if (seqParam->direct_8x8_inference_flag == TRUE &&
- picParam->entropy_coding_mode_flag == FALSE &&
- picParam->num_slice_groups_minus1 <= 7 /*&&
- picParam->num_slice_groups_minus1>=0 (no need, it's unsigned) */)
- {
- seqParam->profile_idc = AVC_EXTENDED;
- seqParam->constrained_set2_flag = TRUE;
- }
-
- if (rateCtrl->dpEnable == FALSE &&
- picParam->num_slice_groups_minus1 == 0 &&
- picParam->redundant_pic_cnt_present_flag == FALSE)
- {
- seqParam->profile_idc = AVC_MAIN;
- seqParam->constrained_set1_flag = TRUE;
- }
-
- if (rateCtrl->bidirPred == FALSE &&
- rateCtrl->dpEnable == FALSE &&
- seqParam->frame_mbs_only_flag == TRUE &&
- picParam->weighted_pred_flag == FALSE &&
- picParam->weighted_bipred_idc == 0 &&
- picParam->entropy_coding_mode_flag == FALSE &&
- picParam->num_slice_groups_minus1 <= 7 /*&&
- picParam->num_slice_groups_minus1>=0 (no need, it's unsigned)*/)
- {
- seqParam->profile_idc = AVC_BASELINE;
- seqParam->constrained_set0_flag = TRUE;
- }
-
- if (seqParam->profile_idc == 0) /* still zero */
- {
- return AVCENC_PROFILE_NOT_SUPPORTED;
- }
- }
-
- /* check the list of supported profile by this library */
- switch (seqParam->profile_idc)
- {
- case AVC_BASELINE:
- if (rateCtrl->bidirPred == TRUE ||
- rateCtrl->dpEnable == TRUE ||
- seqParam->frame_mbs_only_flag != TRUE ||
- picParam->weighted_pred_flag == TRUE ||
- picParam->weighted_bipred_idc != 0 ||
- picParam->entropy_coding_mode_flag == TRUE ||
- picParam->num_slice_groups_minus1 > 7 /*||
- picParam->num_slice_groups_minus1<0 (no need, it's unsigned) */)
- {
- status = AVCENC_TOOLS_NOT_SUPPORTED;
- }
- break;
-
- case AVC_MAIN:
- case AVC_EXTENDED:
- status = AVCENC_PROFILE_NOT_SUPPORTED;
- }
-
- return status;
-}
-
-/* verify the level setting */
-AVCEnc_Status VerifyLevel(AVCEncObject *encvid, AVCSeqParamSet *seqParam, AVCPicParamSet *picParam)
-{
- (void)(picParam);
-
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- AVCCommonObj *video = encvid->common;
- int mb_per_sec, ii;
- int lev_idx;
- int dpb_size;
-
- mb_per_sec = (int)(video->PicSizeInMbs * rateCtrl->frame_rate + 0.5);
- dpb_size = (seqParam->num_ref_frames * video->PicSizeInMbs * 3) >> 6;
-
- if (seqParam->level_idc == 0) /* find level for this setting */
- {
- for (ii = 0; ii < MAX_LEVEL_IDX; ii++)
- {
- if (mb_per_sec <= MaxMBPS[ii] &&
- video->PicSizeInMbs <= (uint)MaxFS[ii] &&
- rateCtrl->bitRate <= (int32)MaxBR[ii]*1000 &&
- rateCtrl->cpbSize <= (int32)MaxCPB[ii]*1000 &&
- rateCtrl->mvRange <= MaxVmvR[ii] &&
- dpb_size <= MaxDPBX2[ii]*512)
- {
- seqParam->level_idc = mapIdx2Lev[ii];
- break;
- }
- }
- if (seqParam->level_idc == 0)
- {
- return AVCENC_LEVEL_NOT_SUPPORTED;
- }
- }
-
- /* check if this level is supported by this library */
- lev_idx = mapLev2Idx[seqParam->level_idc];
- if (seqParam->level_idc == AVC_LEVEL1_B)
- {
- seqParam->constrained_set3_flag = 1;
- }
-
-
- if (lev_idx == 255) /* not defined */
- {
- return AVCENC_LEVEL_NOT_SUPPORTED;
- }
-
- /* check if the encoding setting complies with the level */
- if (mb_per_sec > MaxMBPS[lev_idx] ||
- video->PicSizeInMbs > (uint)MaxFS[lev_idx] ||
- rateCtrl->bitRate > (int32)MaxBR[lev_idx]*1000 ||
- rateCtrl->cpbSize > (int32)MaxCPB[lev_idx]*1000 ||
- rateCtrl->mvRange > MaxVmvR[lev_idx])
- {
- return AVCENC_LEVEL_FAIL;
- }
-
- return AVCENC_SUCCESS;
-}
-
-/* initialize variables at the beginning of each frame */
-/* determine the picture type */
-/* encode POC */
-/* maybe we should do more stuff here. MotionEstimation+SCD and generate a new SPS and PPS */
-AVCEnc_Status InitFrame(AVCEncObject *encvid)
-{
- AVCStatus ret;
- AVCEnc_Status status;
- AVCCommonObj *video = encvid->common;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
-
- /* look for the next frame in coding_order and look for available picture
- in the DPB. Note, video->currFS->PicOrderCnt, currFS->FrameNum and currPic->PicNum
- are set to wrong number in this function (right for decoder). */
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- // call init DPB in here.
- ret = AVCConfigureSequence(encvid->avcHandle, video, TRUE);
- if (ret != AVC_SUCCESS)
- {
- return AVCENC_FAIL;
- }
- }
-
- /* flexible macroblock ordering (every frame)*/
- /* populate video->mapUnitToSliceGroupMap and video->MbToSliceGroupMap */
- /* It changes once per each PPS. */
- FMOInit(video);
-
- ret = DPBInitBuffer(encvid->avcHandle, video); // get new buffer
-
- if (ret != AVC_SUCCESS)
- {
- return (AVCEnc_Status)ret; // AVCENC_PICTURE_READY, FAIL
- }
-
- DPBInitPic(video, 0); /* 0 is dummy */
-
- /************* determine picture type IDR or non-IDR ***********/
- video->currPicType = AVC_FRAME;
- video->slice_data_partitioning = FALSE;
- encvid->currInput->is_reference = 1; /* default to all frames */
- video->nal_ref_idc = 1; /* need to set this for InitPOC */
- video->currPic->isReference = TRUE;
-
- /************* set frame_num ********************/
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- video->prevFrameNum = video->MaxFrameNum;
- video->PrevRefFrameNum = 0;
- sliceHdr->frame_num = 0;
- }
- /* otherwise, it's set to previous reference frame access unit's frame_num in decoding order,
- see the end of PVAVCDecodeSlice()*/
- /* There's also restriction on the frame_num, see page 59 of JVT-I1010.doc. */
- /* Basically, frame_num can't be repeated unless it's opposite fields or non reference fields */
- else
- {
- sliceHdr->frame_num = (video->PrevRefFrameNum + 1) % video->MaxFrameNum;
- }
- video->CurrPicNum = sliceHdr->frame_num; /* for field_pic_flag = 0 */
- //video->CurrPicNum = 2*sliceHdr->frame_num + 1; /* for field_pic_flag = 1 */
-
- /* assign pic_order_cnt, video->PicOrderCnt */
- status = InitPOC(encvid);
- if (status != AVCENC_SUCCESS) /* incorrigable fail */
- {
- return status;
- }
-
- /* Initialize refListIdx for this picture */
- RefListInit(video);
-
- /************* motion estimation and scene analysis ************/
- // , to move this to MB-based MV search for comparison
- // use sub-optimal QP for mv search
- AVCMotionEstimation(encvid); /* AVCENC_SUCCESS or AVCENC_NEW_IDR */
-
- /* after this point, the picture type will be fixed to either IDR or non-IDR */
- video->currFS->PicOrderCnt = video->PicOrderCnt;
- video->currFS->FrameNum = video->sliceHdr->frame_num;
- video->currPic->PicNum = video->CurrPicNum;
- video->mbNum = 0; /* start from zero MB */
- encvid->currSliceGroup = 0; /* start from slice group #0 */
- encvid->numIntraMB = 0; /* reset this counter */
-
- if (video->nal_unit_type == AVC_NALTYPE_IDR)
- {
- RCInitGOP(encvid);
-
- /* calculate picture QP */
- RCInitFrameQP(encvid);
-
- return AVCENC_NEW_IDR;
- }
-
- /* calculate picture QP */
- RCInitFrameQP(encvid); /* get QP after MV search */
-
- return AVCENC_SUCCESS;
-}
-
-/* initialize variables for this slice */
-AVCEnc_Status InitSlice(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCPicParamSet *currPPS = video->currPicParams;
- AVCSeqParamSet *currSPS = video->currSeqParams;
- int slice_type = video->slice_type;
-
- sliceHdr->first_mb_in_slice = video->mbNum;
- if (video->mbNum) // not first slice of a frame
- {
- video->sliceHdr->slice_type = (AVCSliceType)slice_type;
- }
-
- /* sliceHdr->slice_type already set in InitFrame */
-
- sliceHdr->pic_parameter_set_id = video->currPicParams->pic_parameter_set_id;
-
- /* sliceHdr->frame_num already set in InitFrame */
-
- if (!currSPS->frame_mbs_only_flag) /* we shouldn't need this check */
- {
- sliceHdr->field_pic_flag = sliceHdr->bottom_field_flag = FALSE;
- return AVCENC_TOOLS_NOT_SUPPORTED;
- }
-
- /* sliceHdr->idr_pic_id already set in PVAVCEncodeNAL
-
- sliceHdr->pic_order_cnt_lsb already set in InitFrame..InitPOC
- sliceHdr->delta_pic_order_cnt_bottom already set in InitPOC
-
- sliceHdr->delta_pic_order_cnt[0] already set in InitPOC
- sliceHdr->delta_pic_order_cnt[1] already set in InitPOC
- */
-
- sliceHdr->redundant_pic_cnt = 0; /* default if(currPPS->redundant_pic_cnt_present_flag), range 0..127 */
- sliceHdr->direct_spatial_mv_pred_flag = 0; // default if(slice_type == AVC_B_SLICE)
-
- sliceHdr->num_ref_idx_active_override_flag = FALSE; /* default, if(slice_type== P,SP or B)*/
- sliceHdr->num_ref_idx_l0_active_minus1 = 0; /* default, if (num_ref_idx_active_override_flag) */
- sliceHdr->num_ref_idx_l1_active_minus1 = 0; /* default, if above and B_slice */
- /* the above 2 values range from 0..15 for frame picture and 0..31 for field picture */
-
- /* ref_pic_list_reordering(), currently we don't do anything */
- sliceHdr->ref_pic_list_reordering_flag_l0 = FALSE; /* default */
- sliceHdr->ref_pic_list_reordering_flag_l1 = FALSE; /* default */
- /* if the above are TRUE, some other params must be set */
-
- if ((currPPS->weighted_pred_flag && (slice_type == AVC_P_SLICE || slice_type == AVC_SP_SLICE)) ||
- (currPPS->weighted_bipred_idc == 1 && slice_type == AVC_B_SLICE))
- {
- // pred_weight_table(); // not supported !!
- return AVCENC_TOOLS_NOT_SUPPORTED;
- }
-
- /* dec_ref_pic_marking(), this will be done later*/
- sliceHdr->no_output_of_prior_pics_flag = FALSE; /* default */
- sliceHdr->long_term_reference_flag = FALSE; /* for IDR frame, do not make it long term */
- sliceHdr->adaptive_ref_pic_marking_mode_flag = FALSE; /* default */
- /* other params are not set here because they are not used */
-
- sliceHdr->cabac_init_idc = 0; /* default, if entropy_coding_mode_flag && slice_type==I or SI, range 0..2 */
- sliceHdr->slice_qp_delta = 0; /* default for now */
- sliceHdr->sp_for_switch_flag = FALSE; /* default, if slice_type == SP */
- sliceHdr->slice_qs_delta = 0; /* default, if slice_type == SP or SI */
-
- /* derived variables from encParam */
- /* deblocking filter */
- video->FilterOffsetA = video->FilterOffsetB = 0;
- if (currPPS->deblocking_filter_control_present_flag == TRUE)
- {
- video->FilterOffsetA = sliceHdr->slice_alpha_c0_offset_div2 << 1;
- video->FilterOffsetB = sliceHdr->slice_beta_offset_div_2 << 1;
- }
-
- /* flexible macroblock ordering */
- /* populate video->mapUnitToSliceGroupMap and video->MbToSliceGroupMap */
- /* We already call it at the end of PVAVCEncInitialize(). It changes once per each PPS. */
- if (video->currPicParams->num_slice_groups_minus1 > 0 && video->currPicParams->slice_group_map_type >= 3
- && video->currPicParams->slice_group_map_type <= 5)
- {
- sliceHdr->slice_group_change_cycle = SLICE_GROUP_CHANGE_CYCLE; /* default, don't understand how to set it!!!*/
-
- video->MapUnitsInSliceGroup0 =
- AVC_MIN(sliceHdr->slice_group_change_cycle * video->SliceGroupChangeRate, video->PicSizeInMapUnits);
-
- FMOInit(video);
- }
-
- /* calculate SliceQPy first */
- /* calculate QSy first */
-
- sliceHdr->slice_qp_delta = video->QPy - 26 - currPPS->pic_init_qp_minus26;
- //sliceHdr->slice_qs_delta = video->QSy - 26 - currPPS->pic_init_qs_minus26;
-
- return AVCENC_SUCCESS;
-}
-
diff --git a/media/libstagefright/codecs/avc/enc/src/intra_est.cpp b/media/libstagefright/codecs/avc/enc/src/intra_est.cpp
deleted file mode 100644
index 17e5985..0000000
--- a/media/libstagefright/codecs/avc/enc/src/intra_est.cpp
+++ /dev/null
@@ -1,2199 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-
-#define TH_I4 0 /* threshold biasing toward I16 mode instead of I4 mode */
-#define TH_Intra 0 /* threshold biasing toward INTER mode instead of intra mode */
-
-#define FIXED_INTRAPRED_MODE AVC_I16
-#define FIXED_I16_MODE AVC_I16_DC
-#define FIXED_I4_MODE AVC_I4_Diagonal_Down_Left
-#define FIXED_INTRA_CHROMA_MODE AVC_IC_DC
-
-#define CLIP_RESULT(x) if((uint)x > 0xFF){ \
- x = 0xFF & (~(x>>31));}
-
-
-bool IntraDecisionABE(AVCEncObject *encvid, int min_cost, uint8 *curL, int picPitch)
-{
- AVCCommonObj *video = encvid->common;
- AVCFrameIO *currInput = encvid->currInput;
- int orgPitch = currInput->pitch;
- int x_pos = (video->mb_x) << 4;
- int y_pos = (video->mb_y) << 4;
- uint8 *orgY = currInput->YCbCr[0] + y_pos * orgPitch + x_pos;
- int j;
- uint8 *topL, *leftL, *orgY_2, *orgY_3;
- int temp, SBE, offset;
- OsclFloat ABE;
- bool intra = true;
-
- if (((x_pos >> 4) != (int)video->PicWidthInMbs - 1) &&
- ((y_pos >> 4) != (int)video->PicHeightInMbs - 1) &&
- video->intraAvailA &&
- video->intraAvailB)
- {
- SBE = 0;
- /* top neighbor */
- topL = curL - picPitch;
- /* left neighbor */
- leftL = curL - 1;
- orgY_2 = orgY - orgPitch;
-
- for (j = 0; j < 16; j++)
- {
- temp = *topL++ - orgY[j];
- SBE += ((temp >= 0) ? temp : -temp);
- temp = *(leftL += picPitch) - *(orgY_2 += orgPitch);
- SBE += ((temp >= 0) ? temp : -temp);
- }
-
- /* calculate chroma */
- offset = (y_pos >> 2) * picPitch + (x_pos >> 1);
- topL = video->currPic->Scb + offset;
- orgY_2 = currInput->YCbCr[1] + offset + (y_pos >> 2) * (orgPitch - picPitch);
-
- leftL = topL - 1;
- topL -= (picPitch >> 1);
- orgY_3 = orgY_2 - (orgPitch >> 1);
- for (j = 0; j < 8; j++)
- {
- temp = *topL++ - orgY_2[j];
- SBE += ((temp >= 0) ? temp : -temp);
- temp = *(leftL += (picPitch >> 1)) - *(orgY_3 += (orgPitch >> 1));
- SBE += ((temp >= 0) ? temp : -temp);
- }
-
- topL = video->currPic->Scr + offset;
- orgY_2 = currInput->YCbCr[2] + offset + (y_pos >> 2) * (orgPitch - picPitch);
-
- leftL = topL - 1;
- topL -= (picPitch >> 1);
- orgY_3 = orgY_2 - (orgPitch >> 1);
- for (j = 0; j < 8; j++)
- {
- temp = *topL++ - orgY_2[j];
- SBE += ((temp >= 0) ? temp : -temp);
- temp = *(leftL += (picPitch >> 1)) - *(orgY_3 += (orgPitch >> 1));
- SBE += ((temp >= 0) ? temp : -temp);
- }
-
- /* compare mincost/384 and SBE/64 */
- ABE = SBE / 64.0;
- if (ABE*0.8 >= min_cost / 384.0)
- {
- intra = false;
- }
- }
-
- return intra;
-}
-
-/* perform searching for MB mode */
-/* assuming that this is done inside the encoding loop,
-no need to call InitNeighborAvailability */
-
-void MBIntraSearch(AVCEncObject *encvid, int mbnum, uint8 *curL, int picPitch)
-{
- AVCCommonObj *video = encvid->common;
- AVCFrameIO *currInput = encvid->currInput;
- AVCMacroblock *currMB = video->currMB;
- int min_cost;
- uint8 *orgY;
- int x_pos = (video->mb_x) << 4;
- int y_pos = (video->mb_y) << 4;
- uint32 *saved_inter;
- int j;
- int orgPitch = currInput->pitch;
- bool intra = true;
-
- currMB->CBP = 0;
-
- /* first do motion vector and variable block size search */
- min_cost = encvid->min_cost[mbnum];
-
- /* now perform intra prediction search */
- /* need to add the check for encvid->intraSearch[video->mbNum] to skip intra
- if it's not worth checking. */
- if (video->slice_type == AVC_P_SLICE)
- {
- /* Decide whether intra search is necessary or not */
- /* This one, we do it in the encoding loop so the neighboring pixel are the
- actual reconstructed pixels. */
- intra = IntraDecisionABE(encvid, min_cost, curL, picPitch);
- }
-
- if (intra == true || video->slice_type == AVC_I_SLICE)
- {
- orgY = currInput->YCbCr[0] + y_pos * orgPitch + x_pos;
-
- /* i16 mode search */
- /* generate all the predictions */
- intrapred_luma_16x16(encvid);
-
- /* evaluate them one by one */
- find_cost_16x16(encvid, orgY, &min_cost);
-
- if (video->slice_type == AVC_P_SLICE)
- {
- /* save current inter prediction */
- saved_inter = encvid->subpel_pred; /* reuse existing buffer */
- j = 16;
- curL -= 4;
- picPitch -= 16;
- while (j--)
- {
- *saved_inter++ = *((uint32*)(curL += 4));
- *saved_inter++ = *((uint32*)(curL += 4));
- *saved_inter++ = *((uint32*)(curL += 4));
- *saved_inter++ = *((uint32*)(curL += 4));
- curL += picPitch;
- }
-
- }
-
- /* i4 mode search */
- mb_intra4x4_search(encvid, &min_cost);
-
- encvid->min_cost[mbnum] = min_cost; /* update min_cost */
- }
-
-
- if (currMB->mb_intra)
- {
- chroma_intra_search(encvid);
-
- /* need to set this in order for the MBInterPrediction to work!! */
- memset(currMB->mvL0, 0, sizeof(int32)*16);
- currMB->ref_idx_L0[0] = currMB->ref_idx_L0[1] =
- currMB->ref_idx_L0[2] = currMB->ref_idx_L0[3] = -1;
- }
- else if (video->slice_type == AVC_P_SLICE && intra == true)
- {
- /* restore current inter prediction */
- saved_inter = encvid->subpel_pred; /* reuse existing buffer */
- j = 16;
- curL -= ((picPitch + 16) << 4);
- while (j--)
- {
- *((uint32*)(curL += 4)) = *saved_inter++;
- *((uint32*)(curL += 4)) = *saved_inter++;
- *((uint32*)(curL += 4)) = *saved_inter++;
- *((uint32*)(curL += 4)) = *saved_inter++;
- curL += picPitch;
- }
- }
-
- return ;
-}
-
-/* generate all the prediction values */
-void intrapred_luma_16x16(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- AVCPictureData *currPic = video->currPic;
-
- int x_pos = (video->mb_x) << 4;
- int y_pos = (video->mb_y) << 4;
- int pitch = currPic->pitch;
-
- int offset = y_pos * pitch + x_pos;
-
- uint8 *pred, *top, *left;
- uint8 *curL = currPic->Sl + offset; /* point to reconstructed frame */
- uint32 word1, word2, word3, word4;
- uint32 sum = 0;
-
- int a_16, b, c, factor_c;
- uint8 *comp_ref_x0, *comp_ref_x1, *comp_ref_y0, *comp_ref_y1;
- int H = 0, V = 0, tmp, value;
- int i;
-
- if (video->intraAvailB)
- {
- //get vertical prediction mode
- top = curL - pitch;
-
- pred = encvid->pred_i16[AVC_I16_Vertical] - 16;
-
- word1 = *((uint32*)(top)); /* read 4 bytes from top */
- word2 = *((uint32*)(top + 4)); /* read 4 bytes from top */
- word3 = *((uint32*)(top + 8)); /* read 4 bytes from top */
- word4 = *((uint32*)(top + 12)); /* read 4 bytes from top */
-
- for (i = 0; i < 16; i++)
- {
- *((uint32*)(pred += 16)) = word1;
- *((uint32*)(pred + 4)) = word2;
- *((uint32*)(pred + 8)) = word3;
- *((uint32*)(pred + 12)) = word4;
-
- }
-
- sum = word1 & 0xFF00FF;
- word1 = (word1 >> 8) & 0xFF00FF;
- sum += word1;
- word1 = (word2 & 0xFF00FF);
- sum += word1;
- word2 = (word2 >> 8) & 0xFF00FF;
- sum += word2;
- word1 = (word3 & 0xFF00FF);
- sum += word1;
- word3 = (word3 >> 8) & 0xFF00FF;
- sum += word3;
- word1 = (word4 & 0xFF00FF);
- sum += word1;
- word4 = (word4 >> 8) & 0xFF00FF;
- sum += word4;
-
- sum += (sum >> 16);
- sum &= 0xFFFF;
-
- if (!video->intraAvailA)
- {
- sum = (sum + 8) >> 4;
- }
- }
-
- if (video->intraAvailA)
- {
- // get horizontal mode
- left = curL - 1 - pitch;
-
- pred = encvid->pred_i16[AVC_I16_Horizontal] - 16;
-
- for (i = 0; i < 16; i++)
- {
- word1 = *(left += pitch);
- sum += word1;
-
- word1 = (word1 << 8) | word1;
- word1 = (word1 << 16) | word1; /* make it 4 */
-
- *(uint32*)(pred += 16) = word1;
- *(uint32*)(pred + 4) = word1;
- *(uint32*)(pred + 8) = word1;
- *(uint32*)(pred + 12) = word1;
- }
-
- if (!video->intraAvailB)
- {
- sum = (sum + 8) >> 4;
- }
- else
- {
- sum = (sum + 16) >> 5;
- }
- }
-
- // get DC mode
- if (!video->intraAvailA && !video->intraAvailB)
- {
- sum = 0x80808080;
- }
- else
- {
- sum = (sum << 8) | sum;
- sum = (sum << 16) | sum;
- }
-
- pred = encvid->pred_i16[AVC_I16_DC] - 16;
- for (i = 0; i < 16; i++)
- {
- *((uint32*)(pred += 16)) = sum;
- *((uint32*)(pred + 4)) = sum;
- *((uint32*)(pred + 8)) = sum;
- *((uint32*)(pred + 12)) = sum;
- }
-
- // get plane mode
- if (video->intraAvailA && video->intraAvailB && video->intraAvailD)
- {
- pred = encvid->pred_i16[AVC_I16_Plane] - 16;
-
- comp_ref_x0 = curL - pitch + 8;
- comp_ref_x1 = curL - pitch + 6;
- comp_ref_y0 = curL - 1 + (pitch << 3);
- comp_ref_y1 = curL - 1 + 6 * pitch;
-
- for (i = 1; i < 8; i++)
- {
- H += i * (*comp_ref_x0++ - *comp_ref_x1--);
- V += i * (*comp_ref_y0 - *comp_ref_y1);
- comp_ref_y0 += pitch;
- comp_ref_y1 -= pitch;
- }
-
- H += i * (*comp_ref_x0++ - curL[-pitch-1]);
- V += i * (*comp_ref_y0 - *comp_ref_y1);
-
-
- a_16 = ((*(curL - pitch + 15) + *(curL - 1 + 15 * pitch)) << 4) + 16;;
- b = (5 * H + 32) >> 6;
- c = (5 * V + 32) >> 6;
-
- tmp = 0;
- for (i = 0; i < 16; i++)
- {
- factor_c = a_16 + c * (tmp++ - 7);
- factor_c -= 7 * b;
-
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = value;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 8);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 16);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 24);
- *((uint32*)(pred += 16)) = word1;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = value;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 8);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 16);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 24);
- *((uint32*)(pred + 4)) = word1;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = value;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 8);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 16);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 24);
- *((uint32*)(pred + 8)) = word1;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = value;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 8);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 16);
- value = factor_c >> 5;
- CLIP_RESULT(value)
- word1 = (word1) | (value << 24);
- *((uint32*)(pred + 12)) = word1;
- }
- }
-
- return ;
-}
-
-
-/* evaluate each prediction mode of I16 */
-void find_cost_16x16(AVCEncObject *encvid, uint8 *orgY, int *min_cost)
-{
- AVCCommonObj *video = encvid->common;
- AVCMacroblock *currMB = video->currMB;
- int cost;
- int org_pitch = encvid->currInput->pitch;
-
- /* evaluate vertical mode */
- if (video->intraAvailB)
- {
- cost = cost_i16(orgY, org_pitch, encvid->pred_i16[AVC_I16_Vertical], *min_cost);
- if (cost < *min_cost)
- {
- *min_cost = cost;
- currMB->mbMode = AVC_I16;
- currMB->mb_intra = 1;
- currMB->i16Mode = AVC_I16_Vertical;
- }
- }
-
-
- /* evaluate horizontal mode */
- if (video->intraAvailA)
- {
- cost = cost_i16(orgY, org_pitch, encvid->pred_i16[AVC_I16_Horizontal], *min_cost);
- if (cost < *min_cost)
- {
- *min_cost = cost;
- currMB->mbMode = AVC_I16;
- currMB->mb_intra = 1;
- currMB->i16Mode = AVC_I16_Horizontal;
- }
- }
-
- /* evaluate DC mode */
- cost = cost_i16(orgY, org_pitch, encvid->pred_i16[AVC_I16_DC], *min_cost);
- if (cost < *min_cost)
- {
- *min_cost = cost;
- currMB->mbMode = AVC_I16;
- currMB->mb_intra = 1;
- currMB->i16Mode = AVC_I16_DC;
- }
-
- /* evaluate plane mode */
- if (video->intraAvailA && video->intraAvailB && video->intraAvailD)
- {
- cost = cost_i16(orgY, org_pitch, encvid->pred_i16[AVC_I16_Plane], *min_cost);
- if (cost < *min_cost)
- {
- *min_cost = cost;
- currMB->mbMode = AVC_I16;
- currMB->mb_intra = 1;
- currMB->i16Mode = AVC_I16_Plane;
- }
- }
-
- return ;
-}
-
-
-int cost_i16(uint8 *org, int org_pitch, uint8 *pred, int min_cost)
-{
-
- int cost;
- int j, k;
- int16 res[256], *pres; // residue
- int m0, m1, m2, m3;
-
- // calculate SATD
- org_pitch -= 16;
- pres = res;
- // horizontal transform
- for (j = 0; j < 16; j++)
- {
- k = 4;
- while (k > 0)
- {
- m0 = org[0] - pred[0];
- m3 = org[3] - pred[3];
- m0 += m3;
- m3 = m0 - (m3 << 1);
- m1 = org[1] - pred[1];
- m2 = org[2] - pred[2];
- m1 += m2;
- m2 = m1 - (m2 << 1);
- pres[0] = m0 + m1;
- pres[2] = m0 - m1;
- pres[1] = m2 + m3;
- pres[3] = m3 - m2;
-
- org += 4;
- pres += 4;
- pred += 4;
- k--;
- }
- org += org_pitch;
- }
- /* vertical transform */
- cost = 0;
- for (j = 0; j < 4; j++)
- {
- pres = res + (j << 6);
- k = 16;
- while (k > 0)
- {
- m0 = pres[0];
- m3 = pres[3<<4];
- m0 += m3;
- m3 = m0 - (m3 << 1);
- m1 = pres[1<<4];
- m2 = pres[2<<4];
- m1 += m2;
- m2 = m1 - (m2 << 1);
- pres[0] = m0 = m0 + m1;
-
- if (k&0x3) // only sum up non DC values.
- {
- cost += ((m0 > 0) ? m0 : -m0);
- }
-
- m1 = m0 - (m1 << 1);
- cost += ((m1 > 0) ? m1 : -m1);
- m3 = m2 + m3;
- cost += ((m3 > 0) ? m3 : -m3);
- m2 = m3 - (m2 << 1);
- cost += ((m2 > 0) ? m2 : -m2);
-
- pres++;
- k--;
- }
- if ((cost >> 1) > min_cost) /* early drop out */
- {
- return (cost >> 1);
- }
- }
-
- /* Hadamard of the DC coefficient */
- pres = res;
- k = 4;
- while (k > 0)
- {
- m0 = pres[0];
- m3 = pres[3<<2];
- m0 >>= 2;
- m0 += (m3 >> 2);
- m3 = m0 - (m3 >> 1);
- m1 = pres[1<<2];
- m2 = pres[2<<2];
- m1 >>= 2;
- m1 += (m2 >> 2);
- m2 = m1 - (m2 >> 1);
- pres[0] = (m0 + m1);
- pres[2<<2] = (m0 - m1);
- pres[1<<2] = (m2 + m3);
- pres[3<<2] = (m3 - m2);
- pres += (4 << 4);
- k--;
- }
-
- pres = res;
- k = 4;
- while (k > 0)
- {
- m0 = pres[0];
- m3 = pres[3<<6];
- m0 += m3;
- m3 = m0 - (m3 << 1);
- m1 = pres[1<<6];
- m2 = pres[2<<6];
- m1 += m2;
- m2 = m1 - (m2 << 1);
- m0 = m0 + m1;
- cost += ((m0 >= 0) ? m0 : -m0);
- m1 = m0 - (m1 << 1);
- cost += ((m1 >= 0) ? m1 : -m1);
- m3 = m2 + m3;
- cost += ((m3 >= 0) ? m3 : -m3);
- m2 = m3 - (m2 << 1);
- cost += ((m2 >= 0) ? m2 : -m2);
- pres += 4;
-
- if ((cost >> 1) > min_cost) /* early drop out */
- {
- return (cost >> 1);
- }
-
- k--;
- }
-
- return (cost >> 1);
-}
-
-
-void mb_intra4x4_search(AVCEncObject *encvid, int *min_cost)
-{
- AVCCommonObj *video = encvid->common;
- AVCMacroblock *currMB = video->currMB;
- AVCPictureData *currPic = video->currPic;
- AVCFrameIO *currInput = encvid->currInput;
- int pitch = currPic->pitch;
- int org_pitch = currInput->pitch;
- int offset;
- uint8 *curL, *comp, *org4, *org8;
- int y = video->mb_y << 4;
- int x = video->mb_x << 4;
-
- int b8, b4, cost4x4, blkidx;
- int cost = 0;
- int numcoef;
- int dummy = 0;
- int mb_intra = currMB->mb_intra; // save the original value
-
- offset = y * pitch + x;
-
- curL = currPic->Sl + offset;
- org8 = currInput->YCbCr[0] + y * org_pitch + x;
- video->pred_pitch = 4;
-
- cost = (int)(6.0 * encvid->lambda_mode + 0.4999);
- cost <<= 2;
-
- currMB->mb_intra = 1; // temporary set this to one to enable the IDCT
- // operation inside dct_luma
-
- for (b8 = 0; b8 < 4; b8++)
- {
- comp = curL;
- org4 = org8;
-
- for (b4 = 0; b4 < 4; b4++)
- {
- blkidx = blkIdx2blkXY[b8][b4];
- cost4x4 = blk_intra4x4_search(encvid, blkidx, comp, org4);
- cost += cost4x4;
- if (cost > *min_cost)
- {
- currMB->mb_intra = mb_intra; // restore the value
- return ;
- }
-
- /* do residue, Xfrm, Q, invQ, invXfrm, recon and save the DCT coefs.*/
- video->pred_block = encvid->pred_i4[currMB->i4Mode[blkidx]];
- numcoef = dct_luma(encvid, blkidx, comp, org4, &dummy);
- currMB->nz_coeff[blkidx] = numcoef;
- if (numcoef)
- {
- video->cbp4x4 |= (1 << blkidx);
- currMB->CBP |= (1 << b8);
- }
-
- if (b4&1)
- {
- comp += ((pitch << 2) - 4);
- org4 += ((org_pitch << 2) - 4);
- }
- else
- {
- comp += 4;
- org4 += 4;
- }
- }
-
- if (b8&1)
- {
- curL += ((pitch << 3) - 8);
- org8 += ((org_pitch << 3) - 8);
- }
- else
- {
- curL += 8;
- org8 += 8;
- }
- }
-
- currMB->mb_intra = mb_intra; // restore the value
-
- if (cost < *min_cost)
- {
- *min_cost = cost;
- currMB->mbMode = AVC_I4;
- currMB->mb_intra = 1;
- }
-
- return ;
-}
-
-
-/* search for i4 mode for a 4x4 block */
-int blk_intra4x4_search(AVCEncObject *encvid, int blkidx, uint8 *cur, uint8 *org)
-{
- AVCCommonObj *video = encvid->common;
- AVCNeighborAvailability availability;
- AVCMacroblock *currMB = video->currMB;
- bool top_left = FALSE;
- int pitch = video->currPic->pitch;
- uint8 mode_avail[AVCNumI4PredMode];
- uint32 temp, DC;
- uint8 *pred;
- int org_pitch = encvid->currInput->pitch;
- uint16 min_cost, cost;
-
- int P_x, Q_x, R_x, P_y, Q_y, R_y, D, D0, D1;
- int P0, Q0, R0, S0, P1, Q1, R1, P2, Q2;
- uint8 P_A, P_B, P_C, P_D, P_E, P_F, P_G, P_H, P_I, P_J, P_K, P_L, P_X;
- int r0, r1, r2, r3, r4, r5, r6, r7;
- int x0, x1, x2, x3, x4, x5;
- uint32 temp1, temp2;
-
- int ipmode, mostProbableMode;
- int fixedcost = 4 * encvid->lambda_mode;
- int min_sad = 0x7FFF;
-
- availability.left = TRUE;
- availability.top = TRUE;
- if (blkidx <= 3) /* top row block (!block_y) */
- { /* check availability up */
- availability.top = video->intraAvailB ;
- }
- if (!(blkidx&0x3)) /* left column block (!block_x)*/
- { /* check availability left */
- availability.left = video->intraAvailA ;
- }
- availability.top_right = BlkTopRight[blkidx];
-
- if (availability.top_right == 2)
- {
- availability.top_right = video->intraAvailB;
- }
- else if (availability.top_right == 3)
- {
- availability.top_right = video->intraAvailC;
- }
-
- if (availability.top == TRUE)
- {
- temp = *(uint32*)(cur - pitch);
- P_A = temp & 0xFF;
- P_B = (temp >> 8) & 0xFF;
- P_C = (temp >> 16) & 0xFF;
- P_D = (temp >> 24) & 0xFF;
- }
- else
- {
- P_A = P_B = P_C = P_D = 128;
- }
-
- if (availability.top_right == TRUE)
- {
- temp = *(uint32*)(cur - pitch + 4);
- P_E = temp & 0xFF;
- P_F = (temp >> 8) & 0xFF;
- P_G = (temp >> 16) & 0xFF;
- P_H = (temp >> 24) & 0xFF;
- }
- else
- {
- P_E = P_F = P_G = P_H = 128;
- }
-
- if (availability.left == TRUE)
- {
- cur--;
- P_I = *cur;
- P_J = *(cur += pitch);
- P_K = *(cur += pitch);
- P_L = *(cur + pitch);
- cur -= (pitch << 1);
- cur++;
- }
- else
- {
- P_I = P_J = P_K = P_L = 128;
- }
-
- /* check if top-left pixel is available */
- if (((blkidx > 3) && (blkidx&0x3)) || ((blkidx > 3) && video->intraAvailA)
- || ((blkidx&0x3) && video->intraAvailB)
- || (video->intraAvailA && video->intraAvailD && video->intraAvailB))
- {
- top_left = TRUE;
- P_X = *(cur - pitch - 1);
- }
- else
- {
- P_X = 128;
- }
-
- //===== INTRA PREDICTION FOR 4x4 BLOCK =====
- /* vertical */
- mode_avail[AVC_I4_Vertical] = 0;
- if (availability.top)
- {
- mode_avail[AVC_I4_Vertical] = 1;
- pred = encvid->pred_i4[AVC_I4_Vertical];
-
- temp = (P_D << 24) | (P_C << 16) | (P_B << 8) | P_A ;
- *((uint32*)pred) = temp; /* write 4 at a time */
- *((uint32*)(pred += 4)) = temp;
- *((uint32*)(pred += 4)) = temp;
- *((uint32*)(pred += 4)) = temp;
- }
- /* horizontal */
- mode_avail[AVC_I4_Horizontal] = 0;
- mode_avail[AVC_I4_Horizontal_Up] = 0;
- if (availability.left)
- {
- mode_avail[AVC_I4_Horizontal] = 1;
- pred = encvid->pred_i4[AVC_I4_Horizontal];
-
- temp = P_I | (P_I << 8);
- temp = temp | (temp << 16);
- *((uint32*)pred) = temp;
- temp = P_J | (P_J << 8);
- temp = temp | (temp << 16);
- *((uint32*)(pred += 4)) = temp;
- temp = P_K | (P_K << 8);
- temp = temp | (temp << 16);
- *((uint32*)(pred += 4)) = temp;
- temp = P_L | (P_L << 8);
- temp = temp | (temp << 16);
- *((uint32*)(pred += 4)) = temp;
-
- mode_avail[AVC_I4_Horizontal_Up] = 1;
- pred = encvid->pred_i4[AVC_I4_Horizontal_Up];
-
- Q0 = (P_J + P_K + 1) >> 1;
- Q1 = (P_J + (P_K << 1) + P_L + 2) >> 2;
- P0 = ((P_I + P_J + 1) >> 1);
- P1 = ((P_I + (P_J << 1) + P_K + 2) >> 2);
-
- temp = P0 | (P1 << 8); // [P0 P1 Q0 Q1]
- temp |= (Q0 << 16); // [Q0 Q1 R0 DO]
- temp |= (Q1 << 24); // [R0 D0 D1 D1]
- *((uint32*)pred) = temp; // [D1 D1 D1 D1]
-
- D0 = (P_K + 3 * P_L + 2) >> 2;
- R0 = (P_K + P_L + 1) >> 1;
-
- temp = Q0 | (Q1 << 8);
- temp |= (R0 << 16);
- temp |= (D0 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- D1 = P_L;
-
- temp = R0 | (D0 << 8);
- temp |= (D1 << 16);
- temp |= (D1 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = D1 | (D1 << 8);
- temp |= (temp << 16);
- *((uint32*)(pred += 4)) = temp;
- }
- /* DC */
- mode_avail[AVC_I4_DC] = 1;
- pred = encvid->pred_i4[AVC_I4_DC];
- if (availability.left)
- {
- DC = P_I + P_J + P_K + P_L;
-
- if (availability.top)
- {
- DC = (P_A + P_B + P_C + P_D + DC + 4) >> 3;
- }
- else
- {
- DC = (DC + 2) >> 2;
-
- }
- }
- else if (availability.top)
- {
- DC = (P_A + P_B + P_C + P_D + 2) >> 2;
-
- }
- else
- {
- DC = 128;
- }
-
- temp = DC | (DC << 8);
- temp = temp | (temp << 16);
- *((uint32*)pred) = temp;
- *((uint32*)(pred += 4)) = temp;
- *((uint32*)(pred += 4)) = temp;
- *((uint32*)(pred += 4)) = temp;
-
- /* Down-left */
- mode_avail[AVC_I4_Diagonal_Down_Left] = 0;
-
- if (availability.top)
- {
- mode_avail[AVC_I4_Diagonal_Down_Left] = 1;
-
- pred = encvid->pred_i4[AVC_I4_Diagonal_Down_Left];
-
- r0 = P_A;
- r1 = P_B;
- r2 = P_C;
- r3 = P_D;
-
- r0 += (r1 << 1);
- r0 += r2;
- r0 += 2;
- r0 >>= 2;
- r1 += (r2 << 1);
- r1 += r3;
- r1 += 2;
- r1 >>= 2;
-
- if (availability.top_right)
- {
- r4 = P_E;
- r5 = P_F;
- r6 = P_G;
- r7 = P_H;
-
- r2 += (r3 << 1);
- r2 += r4;
- r2 += 2;
- r2 >>= 2;
- r3 += (r4 << 1);
- r3 += r5;
- r3 += 2;
- r3 >>= 2;
- r4 += (r5 << 1);
- r4 += r6;
- r4 += 2;
- r4 >>= 2;
- r5 += (r6 << 1);
- r5 += r7;
- r5 += 2;
- r5 >>= 2;
- r6 += (3 * r7);
- r6 += 2;
- r6 >>= 2;
- temp = r0 | (r1 << 8);
- temp |= (r2 << 16);
- temp |= (r3 << 24);
- *((uint32*)pred) = temp;
-
- temp = (temp >> 8) | (r4 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = (temp >> 8) | (r5 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = (temp >> 8) | (r6 << 24);
- *((uint32*)(pred += 4)) = temp;
- }
- else
- {
- r2 += (r3 * 3);
- r2 += 2;
- r2 >>= 2;
- r3 = ((r3 << 2) + 2);
- r3 >>= 2;
-
- temp = r0 | (r1 << 8);
- temp |= (r2 << 16);
- temp |= (r3 << 24);
- *((uint32*)pred) = temp;
-
- temp = (temp >> 8) | (r3 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = (temp >> 8) | (r3 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = (temp >> 8) | (r3 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- }
- }
-
- /* Down Right */
- mode_avail[AVC_I4_Diagonal_Down_Right] = 0;
- /* Diagonal Vertical Right */
- mode_avail[AVC_I4_Vertical_Right] = 0;
- /* Horizontal Down */
- mode_avail[AVC_I4_Horizontal_Down] = 0;
-
- if (top_left == TRUE)
- {
- /* Down Right */
- mode_avail[AVC_I4_Diagonal_Down_Right] = 1;
- pred = encvid->pred_i4[AVC_I4_Diagonal_Down_Right];
-
- Q_x = (P_A + 2 * P_B + P_C + 2) >> 2;
- R_x = (P_B + 2 * P_C + P_D + 2) >> 2;
- P_x = (P_X + 2 * P_A + P_B + 2) >> 2;
- D = (P_A + 2 * P_X + P_I + 2) >> 2;
- P_y = (P_X + 2 * P_I + P_J + 2) >> 2;
- Q_y = (P_I + 2 * P_J + P_K + 2) >> 2;
- R_y = (P_J + 2 * P_K + P_L + 2) >> 2;
-
- /* we can pack these */
- temp = D | (P_x << 8); //[D P_x Q_x R_x]
- //[P_y D P_x Q_x]
- temp |= (Q_x << 16); //[Q_y P_y D P_x]
- temp |= (R_x << 24); //[R_y Q_y P_y D ]
- *((uint32*)pred) = temp;
-
- temp = P_y | (D << 8);
- temp |= (P_x << 16);
- temp |= (Q_x << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = Q_y | (P_y << 8);
- temp |= (D << 16);
- temp |= (P_x << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = R_y | (Q_y << 8);
- temp |= (P_y << 16);
- temp |= (D << 24);
- *((uint32*)(pred += 4)) = temp;
-
-
- /* Diagonal Vertical Right */
- mode_avail[AVC_I4_Vertical_Right] = 1;
- pred = encvid->pred_i4[AVC_I4_Vertical_Right];
-
- Q0 = P_A + P_B + 1;
- R0 = P_B + P_C + 1;
- S0 = P_C + P_D + 1;
- P0 = P_X + P_A + 1;
- D = (P_I + 2 * P_X + P_A + 2) >> 2;
-
- P1 = (P0 + Q0) >> 2;
- Q1 = (Q0 + R0) >> 2;
- R1 = (R0 + S0) >> 2;
-
- P0 >>= 1;
- Q0 >>= 1;
- R0 >>= 1;
- S0 >>= 1;
-
- P2 = (P_X + 2 * P_I + P_J + 2) >> 2;
- Q2 = (P_I + 2 * P_J + P_K + 2) >> 2;
-
- temp = P0 | (Q0 << 8); //[P0 Q0 R0 S0]
- //[D P1 Q1 R1]
- temp |= (R0 << 16); //[P2 P0 Q0 R0]
- temp |= (S0 << 24); //[Q2 D P1 Q1]
- *((uint32*)pred) = temp;
-
- temp = D | (P1 << 8);
- temp |= (Q1 << 16);
- temp |= (R1 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = P2 | (P0 << 8);
- temp |= (Q0 << 16);
- temp |= (R0 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = Q2 | (D << 8);
- temp |= (P1 << 16);
- temp |= (Q1 << 24);
- *((uint32*)(pred += 4)) = temp;
-
-
- /* Horizontal Down */
- mode_avail[AVC_I4_Horizontal_Down] = 1;
- pred = encvid->pred_i4[AVC_I4_Horizontal_Down];
-
-
- Q2 = (P_A + 2 * P_B + P_C + 2) >> 2;
- P2 = (P_X + 2 * P_A + P_B + 2) >> 2;
- D = (P_I + 2 * P_X + P_A + 2) >> 2;
- P0 = P_X + P_I + 1;
- Q0 = P_I + P_J + 1;
- R0 = P_J + P_K + 1;
- S0 = P_K + P_L + 1;
-
- P1 = (P0 + Q0) >> 2;
- Q1 = (Q0 + R0) >> 2;
- R1 = (R0 + S0) >> 2;
-
- P0 >>= 1;
- Q0 >>= 1;
- R0 >>= 1;
- S0 >>= 1;
-
-
- /* we can pack these */
- temp = P0 | (D << 8); //[P0 D P2 Q2]
- //[Q0 P1 P0 D ]
- temp |= (P2 << 16); //[R0 Q1 Q0 P1]
- temp |= (Q2 << 24); //[S0 R1 R0 Q1]
- *((uint32*)pred) = temp;
-
- temp = Q0 | (P1 << 8);
- temp |= (P0 << 16);
- temp |= (D << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = R0 | (Q1 << 8);
- temp |= (Q0 << 16);
- temp |= (P1 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- temp = S0 | (R1 << 8);
- temp |= (R0 << 16);
- temp |= (Q1 << 24);
- *((uint32*)(pred += 4)) = temp;
-
- }
-
- /* vertical left */
- mode_avail[AVC_I4_Vertical_Left] = 0;
- if (availability.top)
- {
- mode_avail[AVC_I4_Vertical_Left] = 1;
- pred = encvid->pred_i4[AVC_I4_Vertical_Left];
-
- x0 = P_A + P_B + 1;
- x1 = P_B + P_C + 1;
- x2 = P_C + P_D + 1;
- if (availability.top_right)
- {
- x3 = P_D + P_E + 1;
- x4 = P_E + P_F + 1;
- x5 = P_F + P_G + 1;
- }
- else
- {
- x3 = x4 = x5 = (P_D << 1) + 1;
- }
-
- temp1 = (x0 >> 1);
- temp1 |= ((x1 >> 1) << 8);
- temp1 |= ((x2 >> 1) << 16);
- temp1 |= ((x3 >> 1) << 24);
-
- *((uint32*)pred) = temp1;
-
- temp2 = ((x0 + x1) >> 2);
- temp2 |= (((x1 + x2) >> 2) << 8);
- temp2 |= (((x2 + x3) >> 2) << 16);
- temp2 |= (((x3 + x4) >> 2) << 24);
-
- *((uint32*)(pred += 4)) = temp2;
-
- temp1 = (temp1 >> 8) | ((x4 >> 1) << 24); /* rotate out old value */
- *((uint32*)(pred += 4)) = temp1;
-
- temp2 = (temp2 >> 8) | (((x4 + x5) >> 2) << 24); /* rotate out old value */
- *((uint32*)(pred += 4)) = temp2;
- }
-
- //===== LOOP OVER ALL 4x4 INTRA PREDICTION MODES =====
- // can re-order the search here instead of going in order
-
- // find most probable mode
- encvid->mostProbableI4Mode[blkidx] = mostProbableMode = FindMostProbableI4Mode(video, blkidx);
-
- min_cost = 0xFFFF;
-
- for (ipmode = 0; ipmode < AVCNumI4PredMode; ipmode++)
- {
- if (mode_avail[ipmode] == TRUE)
- {
- cost = (ipmode == mostProbableMode) ? 0 : fixedcost;
- pred = encvid->pred_i4[ipmode];
-
- cost_i4(org, org_pitch, pred, &cost);
-
- if (cost < min_cost)
- {
- currMB->i4Mode[blkidx] = (AVCIntra4x4PredMode)ipmode;
- min_cost = cost;
- min_sad = cost - ((ipmode == mostProbableMode) ? 0 : fixedcost);
- }
- }
- }
-
- if (blkidx == 0)
- {
- encvid->i4_sad = min_sad;
- }
- else
- {
- encvid->i4_sad += min_sad;
- }
-
- return min_cost;
-}
-
-int FindMostProbableI4Mode(AVCCommonObj *video, int blkidx)
-{
- int dcOnlyPredictionFlag;
- AVCMacroblock *currMB = video->currMB;
- int intra4x4PredModeA, intra4x4PredModeB, predIntra4x4PredMode;
-
-
- dcOnlyPredictionFlag = 0;
- if (blkidx&0x3)
- {
- intra4x4PredModeA = currMB->i4Mode[blkidx-1]; // block to the left
- }
- else /* for blk 0, 4, 8, 12 */
- {
- if (video->intraAvailA)
- {
- if (video->mblock[video->mbAddrA].mbMode == AVC_I4)
- {
- intra4x4PredModeA = video->mblock[video->mbAddrA].i4Mode[blkidx + 3];
- }
- else
- {
- intra4x4PredModeA = AVC_I4_DC;
- }
- }
- else
- {
- dcOnlyPredictionFlag = 1;
- goto PRED_RESULT_READY; // skip below
- }
- }
-
- if (blkidx >> 2)
- {
- intra4x4PredModeB = currMB->i4Mode[blkidx-4]; // block above
- }
- else /* block 0, 1, 2, 3 */
- {
- if (video->intraAvailB)
- {
- if (video->mblock[video->mbAddrB].mbMode == AVC_I4)
- {
- intra4x4PredModeB = video->mblock[video->mbAddrB].i4Mode[blkidx+12];
- }
- else
- {
- intra4x4PredModeB = AVC_I4_DC;
- }
- }
- else
- {
- dcOnlyPredictionFlag = 1;
- }
- }
-
-PRED_RESULT_READY:
- if (dcOnlyPredictionFlag)
- {
- intra4x4PredModeA = intra4x4PredModeB = AVC_I4_DC;
- }
-
- predIntra4x4PredMode = AVC_MIN(intra4x4PredModeA, intra4x4PredModeB);
-
- return predIntra4x4PredMode;
-}
-
-void cost_i4(uint8 *org, int org_pitch, uint8 *pred, uint16 *cost)
-{
- int k;
- int16 res[16], *pres;
- int m0, m1, m2, m3, tmp1;
- int satd = 0;
-
- pres = res;
- // horizontal transform
- k = 4;
- while (k > 0)
- {
- m0 = org[0] - pred[0];
- m3 = org[3] - pred[3];
- m0 += m3;
- m3 = m0 - (m3 << 1);
- m1 = org[1] - pred[1];
- m2 = org[2] - pred[2];
- m1 += m2;
- m2 = m1 - (m2 << 1);
- pres[0] = m0 + m1;
- pres[2] = m0 - m1;
- pres[1] = m2 + m3;
- pres[3] = m3 - m2;
-
- org += org_pitch;
- pres += 4;
- pred += 4;
- k--;
- }
- /* vertical transform */
- pres = res;
- k = 4;
- while (k > 0)
- {
- m0 = pres[0];
- m3 = pres[12];
- m0 += m3;
- m3 = m0 - (m3 << 1);
- m1 = pres[4];
- m2 = pres[8];
- m1 += m2;
- m2 = m1 - (m2 << 1);
- pres[0] = m0 + m1;
- pres[8] = m0 - m1;
- pres[4] = m2 + m3;
- pres[12] = m3 - m2;
-
- pres++;
- k--;
-
- }
-
- pres = res;
- k = 4;
- while (k > 0)
- {
- tmp1 = *pres++;
- satd += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- satd += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- satd += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- satd += ((tmp1 >= 0) ? tmp1 : -tmp1);
- k--;
- }
-
- satd = (satd + 1) >> 1;
- *cost += satd;
-
- return ;
-}
-
-void chroma_intra_search(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- AVCPictureData *currPic = video->currPic;
-
- int x_pos = video->mb_x << 3;
- int y_pos = video->mb_y << 3;
- int pitch = currPic->pitch >> 1;
- int offset = y_pos * pitch + x_pos;
-
- uint8 *comp_ref_x, *comp_ref_y, *pred;
- int sum_x0, sum_x1, sum_y0, sum_y1;
- int pred_0[2], pred_1[2], pred_2[2], pred_3[2];
- uint32 pred_a, pred_b, pred_c, pred_d;
- int i, j, component;
- int a_16, b, c, factor_c, topleft;
- int H, V, value;
- uint8 *comp_ref_x0, *comp_ref_x1, *comp_ref_y0, *comp_ref_y1;
-
- uint8 *curCb = currPic->Scb + offset;
- uint8 *curCr = currPic->Scr + offset;
-
- uint8 *orgCb, *orgCr;
- AVCFrameIO *currInput = encvid->currInput;
- AVCMacroblock *currMB = video->currMB;
- int org_pitch;
- int cost, mincost;
-
- /* evaluate DC mode */
- if (video->intraAvailB & video->intraAvailA)
- {
- comp_ref_x = curCb - pitch;
- comp_ref_y = curCb - 1;
-
- for (i = 0; i < 2; i++)
- {
- pred_a = *((uint32*)comp_ref_x);
- comp_ref_x += 4;
- pred_b = (pred_a >> 8) & 0xFF00FF;
- pred_a &= 0xFF00FF;
- pred_a += pred_b;
- pred_a += (pred_a >> 16);
- sum_x0 = pred_a & 0xFFFF;
-
- pred_a = *((uint32*)comp_ref_x);
- pred_b = (pred_a >> 8) & 0xFF00FF;
- pred_a &= 0xFF00FF;
- pred_a += pred_b;
- pred_a += (pred_a >> 16);
- sum_x1 = pred_a & 0xFFFF;
-
- pred_1[i] = (sum_x1 + 2) >> 2;
-
- sum_y0 = *comp_ref_y;
- sum_y0 += *(comp_ref_y += pitch);
- sum_y0 += *(comp_ref_y += pitch);
- sum_y0 += *(comp_ref_y += pitch);
-
- sum_y1 = *(comp_ref_y += pitch);
- sum_y1 += *(comp_ref_y += pitch);
- sum_y1 += *(comp_ref_y += pitch);
- sum_y1 += *(comp_ref_y += pitch);
-
- pred_2[i] = (sum_y1 + 2) >> 2;
-
- pred_0[i] = (sum_y0 + sum_x0 + 4) >> 3;
- pred_3[i] = (sum_y1 + sum_x1 + 4) >> 3;
-
- comp_ref_x = curCr - pitch;
- comp_ref_y = curCr - 1;
- }
- }
-
- else if (video->intraAvailA)
- {
- comp_ref_y = curCb - 1;
- for (i = 0; i < 2; i++)
- {
- sum_y0 = *comp_ref_y;
- sum_y0 += *(comp_ref_y += pitch);
- sum_y0 += *(comp_ref_y += pitch);
- sum_y0 += *(comp_ref_y += pitch);
-
- sum_y1 = *(comp_ref_y += pitch);
- sum_y1 += *(comp_ref_y += pitch);
- sum_y1 += *(comp_ref_y += pitch);
- sum_y1 += *(comp_ref_y += pitch);
-
- pred_0[i] = pred_1[i] = (sum_y0 + 2) >> 2;
- pred_2[i] = pred_3[i] = (sum_y1 + 2) >> 2;
-
- comp_ref_y = curCr - 1;
- }
- }
- else if (video->intraAvailB)
- {
- comp_ref_x = curCb - pitch;
- for (i = 0; i < 2; i++)
- {
- pred_a = *((uint32*)comp_ref_x);
- comp_ref_x += 4;
- pred_b = (pred_a >> 8) & 0xFF00FF;
- pred_a &= 0xFF00FF;
- pred_a += pred_b;
- pred_a += (pred_a >> 16);
- sum_x0 = pred_a & 0xFFFF;
-
- pred_a = *((uint32*)comp_ref_x);
- pred_b = (pred_a >> 8) & 0xFF00FF;
- pred_a &= 0xFF00FF;
- pred_a += pred_b;
- pred_a += (pred_a >> 16);
- sum_x1 = pred_a & 0xFFFF;
-
- pred_0[i] = pred_2[i] = (sum_x0 + 2) >> 2;
- pred_1[i] = pred_3[i] = (sum_x1 + 2) >> 2;
-
- comp_ref_x = curCr - pitch;
- }
- }
- else
- {
- pred_0[0] = pred_0[1] = pred_1[0] = pred_1[1] =
- pred_2[0] = pred_2[1] = pred_3[0] = pred_3[1] = 128;
- }
-
- pred = encvid->pred_ic[AVC_IC_DC];
-
- pred_a = pred_0[0];
- pred_b = pred_1[0];
- pred_a |= (pred_a << 8);
- pred_a |= (pred_a << 16);
- pred_b |= (pred_b << 8);
- pred_b |= (pred_b << 16);
-
- pred_c = pred_0[1];
- pred_d = pred_1[1];
- pred_c |= (pred_c << 8);
- pred_c |= (pred_c << 16);
- pred_d |= (pred_d << 8);
- pred_d |= (pred_d << 16);
-
-
- for (j = 0; j < 4; j++) /* 4 lines */
- {
- *((uint32*)pred) = pred_a;
- *((uint32*)(pred + 4)) = pred_b;
- *((uint32*)(pred + 8)) = pred_c;
- *((uint32*)(pred + 12)) = pred_d;
- pred += 16; /* move to the next line */
- }
-
- pred_a = pred_2[0];
- pred_b = pred_3[0];
- pred_a |= (pred_a << 8);
- pred_a |= (pred_a << 16);
- pred_b |= (pred_b << 8);
- pred_b |= (pred_b << 16);
-
- pred_c = pred_2[1];
- pred_d = pred_3[1];
- pred_c |= (pred_c << 8);
- pred_c |= (pred_c << 16);
- pred_d |= (pred_d << 8);
- pred_d |= (pred_d << 16);
-
- for (j = 0; j < 4; j++) /* 4 lines */
- {
- *((uint32*)pred) = pred_a;
- *((uint32*)(pred + 4)) = pred_b;
- *((uint32*)(pred + 8)) = pred_c;
- *((uint32*)(pred + 12)) = pred_d;
- pred += 16; /* move to the next line */
- }
-
- /* predict horizontal mode */
- if (video->intraAvailA)
- {
- comp_ref_y = curCb - 1;
- comp_ref_x = curCr - 1;
- pred = encvid->pred_ic[AVC_IC_Horizontal];
-
- for (i = 4; i < 6; i++)
- {
- for (j = 0; j < 4; j++)
- {
- pred_a = *comp_ref_y;
- comp_ref_y += pitch;
- pred_a |= (pred_a << 8);
- pred_a |= (pred_a << 16);
- *((uint32*)pred) = pred_a;
- *((uint32*)(pred + 4)) = pred_a;
-
- pred_a = *comp_ref_x;
- comp_ref_x += pitch;
- pred_a |= (pred_a << 8);
- pred_a |= (pred_a << 16);
- *((uint32*)(pred + 8)) = pred_a;
- *((uint32*)(pred + 12)) = pred_a;
-
- pred += 16;
- }
- }
- }
-
- /* vertical mode */
- if (video->intraAvailB)
- {
- comp_ref_x = curCb - pitch;
- comp_ref_y = curCr - pitch;
- pred = encvid->pred_ic[AVC_IC_Vertical];
-
- pred_a = *((uint32*)comp_ref_x);
- pred_b = *((uint32*)(comp_ref_x + 4));
- pred_c = *((uint32*)comp_ref_y);
- pred_d = *((uint32*)(comp_ref_y + 4));
-
- for (j = 0; j < 8; j++)
- {
- *((uint32*)pred) = pred_a;
- *((uint32*)(pred + 4)) = pred_b;
- *((uint32*)(pred + 8)) = pred_c;
- *((uint32*)(pred + 12)) = pred_d;
- pred += 16;
- }
- }
-
- /* Intra_Chroma_Plane */
- if (video->intraAvailA && video->intraAvailB && video->intraAvailD)
- {
- comp_ref_x = curCb - pitch;
- comp_ref_y = curCb - 1;
- topleft = curCb[-pitch-1];
-
- pred = encvid->pred_ic[AVC_IC_Plane];
- for (component = 0; component < 2; component++)
- {
- H = V = 0;
- comp_ref_x0 = comp_ref_x + 4;
- comp_ref_x1 = comp_ref_x + 2;
- comp_ref_y0 = comp_ref_y + (pitch << 2);
- comp_ref_y1 = comp_ref_y + (pitch << 1);
- for (i = 1; i < 4; i++)
- {
- H += i * (*comp_ref_x0++ - *comp_ref_x1--);
- V += i * (*comp_ref_y0 - *comp_ref_y1);
- comp_ref_y0 += pitch;
- comp_ref_y1 -= pitch;
- }
- H += i * (*comp_ref_x0++ - topleft);
- V += i * (*comp_ref_y0 - *comp_ref_y1);
-
- a_16 = ((*(comp_ref_x + 7) + *(comp_ref_y + 7 * pitch)) << 4) + 16;
- b = (17 * H + 16) >> 5;
- c = (17 * V + 16) >> 5;
-
- pred_a = 0;
- for (i = 4; i < 6; i++)
- {
- for (j = 0; j < 4; j++)
- {
- factor_c = a_16 + c * (pred_a++ - 3);
-
- factor_c -= 3 * b;
-
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- pred_b = value;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- pred_b |= (value << 8);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- pred_b |= (value << 16);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- pred_b |= (value << 24);
- *((uint32*)pred) = pred_b;
-
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- pred_b = value;
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- pred_b |= (value << 8);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- pred_b |= (value << 16);
- value = factor_c >> 5;
- factor_c += b;
- CLIP_RESULT(value)
- pred_b |= (value << 24);
- *((uint32*)(pred + 4)) = pred_b;
- pred += 16;
- }
- }
-
- pred -= 120; /* point to cr */
- comp_ref_x = curCr - pitch;
- comp_ref_y = curCr - 1;
- topleft = curCr[-pitch-1];
- }
- }
-
- /* now evaluate it */
-
- org_pitch = (currInput->pitch) >> 1;
- offset = x_pos + y_pos * org_pitch;
-
- orgCb = currInput->YCbCr[1] + offset;
- orgCr = currInput->YCbCr[2] + offset;
-
- mincost = 0x7fffffff;
- cost = SATDChroma(orgCb, orgCr, org_pitch, encvid->pred_ic[AVC_IC_DC], mincost);
- if (cost < mincost)
- {
- mincost = cost;
- currMB->intra_chroma_pred_mode = AVC_IC_DC;
- }
-
- if (video->intraAvailA)
- {
- cost = SATDChroma(orgCb, orgCr, org_pitch, encvid->pred_ic[AVC_IC_Horizontal], mincost);
- if (cost < mincost)
- {
- mincost = cost;
- currMB->intra_chroma_pred_mode = AVC_IC_Horizontal;
- }
- }
-
- if (video->intraAvailB)
- {
- cost = SATDChroma(orgCb, orgCr, org_pitch, encvid->pred_ic[AVC_IC_Vertical], mincost);
- if (cost < mincost)
- {
- mincost = cost;
- currMB->intra_chroma_pred_mode = AVC_IC_Vertical;
- }
- }
-
- if (video->intraAvailA && video->intraAvailB && video->intraAvailD)
- {
- cost = SATDChroma(orgCb, orgCr, org_pitch, encvid->pred_ic[AVC_IC_Plane], mincost);
- if (cost < mincost)
- {
- mincost = cost;
- currMB->intra_chroma_pred_mode = AVC_IC_Plane;
- }
- }
-
-
- return ;
-}
-
-
-int SATDChroma(uint8 *orgCb, uint8 *orgCr, int org_pitch, uint8 *pred, int min_cost)
-{
- int cost;
- /* first take difference between orgCb, orgCr and pred */
- int16 res[128], *pres; // residue
- int m0, m1, m2, m3, tmp1;
- int j, k;
-
- pres = res;
- org_pitch -= 8;
- // horizontal transform
- for (j = 0; j < 8; j++)
- {
- k = 2;
- while (k > 0)
- {
- m0 = orgCb[0] - pred[0];
- m3 = orgCb[3] - pred[3];
- m0 += m3;
- m3 = m0 - (m3 << 1);
- m1 = orgCb[1] - pred[1];
- m2 = orgCb[2] - pred[2];
- m1 += m2;
- m2 = m1 - (m2 << 1);
- pres[0] = m0 + m1;
- pres[2] = m0 - m1;
- pres[1] = m2 + m3;
- pres[3] = m3 - m2;
-
- orgCb += 4;
- pres += 4;
- pred += 4;
- k--;
- }
- orgCb += org_pitch;
- k = 2;
- while (k > 0)
- {
- m0 = orgCr[0] - pred[0];
- m3 = orgCr[3] - pred[3];
- m0 += m3;
- m3 = m0 - (m3 << 1);
- m1 = orgCr[1] - pred[1];
- m2 = orgCr[2] - pred[2];
- m1 += m2;
- m2 = m1 - (m2 << 1);
- pres[0] = m0 + m1;
- pres[2] = m0 - m1;
- pres[1] = m2 + m3;
- pres[3] = m3 - m2;
-
- orgCr += 4;
- pres += 4;
- pred += 4;
- k--;
- }
- orgCr += org_pitch;
- }
-
- /* vertical transform */
- for (j = 0; j < 2; j++)
- {
- pres = res + (j << 6);
- k = 16;
- while (k > 0)
- {
- m0 = pres[0];
- m3 = pres[3<<4];
- m0 += m3;
- m3 = m0 - (m3 << 1);
- m1 = pres[1<<4];
- m2 = pres[2<<4];
- m1 += m2;
- m2 = m1 - (m2 << 1);
- pres[0] = m0 + m1;
- pres[2<<4] = m0 - m1;
- pres[1<<4] = m2 + m3;
- pres[3<<4] = m3 - m2;
-
- pres++;
- k--;
- }
- }
-
- /* now sum of absolute value */
- pres = res;
- cost = 0;
- k = 128;
- while (k > 0)
- {
- tmp1 = *pres++;
- cost += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- cost += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- cost += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- cost += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- cost += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- cost += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- cost += ((tmp1 >= 0) ? tmp1 : -tmp1);
- tmp1 = *pres++;
- cost += ((tmp1 >= 0) ? tmp1 : -tmp1);
- k -= 8;
- if (cost > min_cost) /* early drop out */
- {
- return cost;
- }
- }
-
- return cost;
-}
-
-
-
-///////////////////////////////// old code, unused
-/* find the best intra mode based on original (unencoded) frame */
-/* output is
- currMB->mb_intra, currMB->mbMode,
- currMB->i16Mode (if currMB->mbMode == AVC_I16)
- currMB->i4Mode[..] (if currMB->mbMode == AVC_I4) */
-
-#ifdef FIXED_INTRAPRED_MODE
-void MBIntraSearch(AVCEncObject *encvid, AVCMacroblock *currMB, int mbNum)
-{
- (void)(mbNum);
-
- AVCCommonObj *video = encvid->common;
- int indx, block_x, block_y;
-
- video->intraAvailA = video->intraAvailB = video->intraAvailC = video->intraAvailD = 0;
-
- if (!video->currPicParams->constrained_intra_pred_flag)
- {
- video->intraAvailA = video->mbAvailA;
- video->intraAvailB = video->mbAvailB;
- video->intraAvailC = video->mbAvailC;
- video->intraAvailD = video->mbAvailD;
- }
- else
- {
- if (video->mbAvailA)
- {
- video->intraAvailA = video->mblock[video->mbAddrA].mb_intra;
- }
- if (video->mbAvailB)
- {
- video->intraAvailB = video->mblock[video->mbAddrB].mb_intra ;
- }
- if (video->mbAvailC)
- {
- video->intraAvailC = video->mblock[video->mbAddrC].mb_intra;
- }
- if (video->mbAvailD)
- {
- video->intraAvailD = video->mblock[video->mbAddrD].mb_intra;
- }
- }
-
- currMB->mb_intra = TRUE;
- currMB->mbMode = FIXED_INTRAPRED_MODE;
-
- if (currMB->mbMode == AVC_I16)
- {
- currMB->i16Mode = FIXED_I16_MODE;
-
- if (FIXED_I16_MODE == AVC_I16_Vertical && !video->intraAvailB)
- {
- currMB->i16Mode = AVC_I16_DC;
- }
-
- if (FIXED_I16_MODE == AVC_I16_Horizontal && !video->intraAvailA)
- {
- currMB->i16Mode = AVC_I16_DC;
- }
-
- if (FIXED_I16_MODE == AVC_I16_Plane && !(video->intraAvailA && video->intraAvailB && video->intraAvailD))
- {
- currMB->i16Mode = AVC_I16_DC;
- }
- }
- else //if(currMB->mbMode == AVC_I4)
- {
- for (indx = 0; indx < 16; indx++)
- {
- block_x = blkIdx2blkX[indx];
- block_y = blkIdx2blkY[indx];
-
- currMB->i4Mode[(block_y<<2)+block_x] = FIXED_I4_MODE;
-
- if (FIXED_I4_MODE == AVC_I4_Vertical && !(block_y > 0 || video->intraAvailB))
- {
- currMB->i4Mode[(block_y<<2)+block_x] = AVC_I4_DC;
- }
-
- if (FIXED_I4_MODE == AVC_I4_Horizontal && !(block_x || video->intraAvailA))
- {
- currMB->i4Mode[(block_y<<2)+block_x] = AVC_I4_DC;
- }
-
- if (FIXED_I4_MODE == AVC_I4_Diagonal_Down_Left &&
- (block_y == 0 && !video->intraAvailB))
- {
- currMB->i4Mode[(block_y<<2)+block_x] = AVC_I4_DC;
- }
-
- if (FIXED_I4_MODE == AVC_I4_Diagonal_Down_Right &&
- !((block_y && block_x)
- || (block_y && video->intraAvailA)
- || (block_x && video->intraAvailB)
- || (video->intraAvailA && video->intraAvailD && video->intraAvailB)))
- {
- currMB->i4Mode[(block_y<<2)+block_x] = AVC_I4_DC;
- }
-
- if (FIXED_I4_MODE == AVC_I4_Vertical_Right &&
- !((block_y && block_x)
- || (block_y && video->intraAvailA)
- || (block_x && video->intraAvailB)
- || (video->intraAvailA && video->intraAvailD && video->intraAvailB)))
- {
- currMB->i4Mode[(block_y<<2)+block_x] = AVC_I4_DC;
- }
-
- if (FIXED_I4_MODE == AVC_I4_Horizontal_Down &&
- !((block_y && block_x)
- || (block_y && video->intraAvailA)
- || (block_x && video->intraAvailB)
- || (video->intraAvailA && video->intraAvailD && video->intraAvailB)))
- {
- currMB->i4Mode[(block_y<<2)+block_x] = AVC_I4_DC;
- }
-
- if (FIXED_I4_MODE == AVC_I4_Vertical_Left &&
- (block_y == 0 && !video->intraAvailB))
- {
- currMB->i4Mode[(block_y<<2)+block_x] = AVC_I4_DC;
- }
-
- if (FIXED_I4_MODE == AVC_I4_Horizontal_Up && !(block_x || video->intraAvailA))
- {
- currMB->i4Mode[(block_y<<2)+block_x] = AVC_I4_DC;
- }
- }
- }
-
- currMB->intra_chroma_pred_mode = FIXED_INTRA_CHROMA_MODE;
-
- if (FIXED_INTRA_CHROMA_MODE == AVC_IC_Horizontal && !(video->intraAvailA))
- {
- currMB->intra_chroma_pred_mode = AVC_IC_DC;
- }
-
- if (FIXED_INTRA_CHROMA_MODE == AVC_IC_Vertical && !(video->intraAvailB))
- {
- currMB->intra_chroma_pred_mode = AVC_IC_DC;
- }
-
- if (FIXED_INTRA_CHROMA_MODE == AVC_IC_Plane && !(video->intraAvailA && video->intraAvailB && video->intraAvailD))
- {
- currMB->intra_chroma_pred_mode = AVC_IC_DC;
- }
-
- /* also reset the motion vectors */
- /* set MV and Ref_Idx codes of Intra blocks in P-slices */
- memset(currMB->mvL0, 0, sizeof(int32)*16);
- currMB->ref_idx_L0[0] = -1;
- currMB->ref_idx_L0[1] = -1;
- currMB->ref_idx_L0[2] = -1;
- currMB->ref_idx_L0[3] = -1;
-
- // output from this function, currMB->mbMode should be set to either
- // AVC_I4, AVC_I16, or else in AVCMBMode enum, mbType, mb_intra, intra_chroma_pred_mode */
- return ;
-}
-#else // faster combined prediction+SAD calculation
-void MBIntraSearch(AVCEncObject *encvid, AVCMacroblock *currMB, int mbNum)
-{
- AVCCommonObj *video = encvid->common;
- AVCFrameIO *currInput = encvid->currInput;
- uint8 *curL, *curCb, *curCr;
- uint8 *comp, *pred_block;
- int block_x, block_y, offset;
- uint sad, sad4, sadI4, sadI16;
- int component, SubBlock_indx, temp;
- int pitch = video->currPic->pitch;
-
- /* calculate the cost of each intra prediction mode and compare to the
- inter mode */
- /* full search for all intra prediction */
- offset = (video->mb_y << 4) * pitch + (video->mb_x << 4);
- curL = currInput->YCbCr[0] + offset;
- pred_block = video->pred_block + 84;
-
- /* Assuming that InitNeighborAvailability has been called prior to this function */
- video->intraAvailA = video->intraAvailB = video->intraAvailC = video->intraAvailD = 0;
-
- if (!video->currPicParams->constrained_intra_pred_flag)
- {
- video->intraAvailA = video->mbAvailA;
- video->intraAvailB = video->mbAvailB;
- video->intraAvailC = video->mbAvailC;
- video->intraAvailD = video->mbAvailD;
- }
- else
- {
- if (video->mbAvailA)
- {
- video->intraAvailA = video->mblock[video->mbAddrA].mb_intra;
- }
- if (video->mbAvailB)
- {
- video->intraAvailB = video->mblock[video->mbAddrB].mb_intra ;
- }
- if (video->mbAvailC)
- {
- video->intraAvailC = video->mblock[video->mbAddrC].mb_intra;
- }
- if (video->mbAvailD)
- {
- video->intraAvailD = video->mblock[video->mbAddrD].mb_intra;
- }
- }
-
- /* currently we're doing exhaustive search. Smart search will be used later */
-
- /* I16 modes */
- curL = currInput->YCbCr[0] + offset;
- video->pintra_pred_top = curL - pitch;
- video->pintra_pred_left = curL - 1;
- if (video->mb_y)
- {
- video->intra_pred_topleft = *(curL - pitch - 1);
- }
-
- /* Intra_16x16_Vertical */
- sadI16 = 65536;
- /* check availability of top */
- if (video->intraAvailB)
- {
- sad = SAD_I16_Vert(video, curL, sadI16);
-
- if (sad < sadI16)
- {
- sadI16 = sad;
- currMB->i16Mode = AVC_I16_Vertical;
- }
- }
- /* Intra_16x16_Horizontal */
- /* check availability of left */
- if (video->intraAvailA)
- {
- sad = SAD_I16_HorzDC(video, curL, AVC_I16_Horizontal, sadI16);
-
- if (sad < sadI16)
- {
- sadI16 = sad;
- currMB->i16Mode = AVC_I16_Horizontal;
- }
- }
-
- /* Intra_16x16_DC, default mode */
- sad = SAD_I16_HorzDC(video, curL, AVC_I16_DC, sadI16);
- if (sad < sadI16)
- {
- sadI16 = sad;
- currMB->i16Mode = AVC_I16_DC;
- }
-
- /* Intra_16x16_Plane */
- if (video->intraAvailA && video->intraAvailB && video->intraAvailD)
- {
- sad = SAD_I16_Plane(video, curL, sadI16);
-
- if (sad < sadI16)
- {
- sadI16 = sad;
- currMB->i16Mode = AVC_I16_Plane;
- }
- }
-
- sadI16 >>= 1; /* before comparison */
-
- /* selection between intra4, intra16 or inter mode */
- if (sadI16 < encvid->min_cost)
- {
- currMB->mb_intra = TRUE;
- currMB->mbMode = AVC_I16;
- encvid->min_cost = sadI16;
- }
-
- if (currMB->mb_intra) /* only do the chrominance search when intra is decided */
- {
- /* Note that we might be able to guess the type of prediction from
- the luma prediction type */
-
- /* now search for the best chroma intra prediction */
- offset = (offset >> 2) + (video->mb_x << 2);
- curCb = currInput->YCbCr[1] + offset;
- curCr = currInput->YCbCr[2] + offset;
-
- pitch >>= 1;
- video->pintra_pred_top_cb = curCb - pitch;
- video->pintra_pred_left_cb = curCb - 1;
- video->pintra_pred_top_cr = curCr - pitch;
- video->pintra_pred_left_cr = curCr - 1;
-
- if (video->mb_y)
- {
- video->intra_pred_topleft_cb = *(curCb - pitch - 1);
- video->intra_pred_topleft_cr = *(curCr - pitch - 1);
- }
-
- /* Intra_Chroma_DC */
- sad4 = SAD_Chroma_DC(video, curCb, curCr, 65536);
- currMB->intra_chroma_pred_mode = AVC_IC_DC;
-
- /* Intra_Chroma_Horizontal */
- if (video->intraAvailA)
- {
- /* check availability of left */
- sad = SAD_Chroma_Horz(video, curCb, curCr, sad4);
- if (sad < sad4)
- {
- sad4 = sad;
- currMB->intra_chroma_pred_mode = AVC_IC_Horizontal;
- }
- }
-
- /* Intra_Chroma_Vertical */
- if (video->intraAvailB)
- {
- /* check availability of top */
- sad = SAD_Chroma_Vert(video, curCb, curCr, sad4);
-
- if (sad < sad4)
- {
- sad4 = sad;
- currMB->intra_chroma_pred_mode = AVC_IC_Vertical;
- }
- }
-
- /* Intra_Chroma_Plane */
- if (video->intraAvailA && video->intraAvailB && video->intraAvailD)
- {
- /* check availability of top and left */
- Intra_Chroma_Plane(video, pitch);
-
- sad = SADChroma(pred_block + 452, curCb, curCr, pitch);
-
- if (sad < sad4)
- {
- sad4 = sad;
- currMB->intra_chroma_pred_mode = AVC_IC_Plane;
- }
- }
-
- /* also reset the motion vectors */
- /* set MV and Ref_Idx codes of Intra blocks in P-slices */
- memset(currMB->mvL0, 0, sizeof(int32)*16);
- memset(currMB->ref_idx_L0, -1, sizeof(int16)*4);
-
- }
-
- // output from this function, currMB->mbMode should be set to either
- // AVC_I4, AVC_I16, or else in AVCMBMode enum, mbType, mb_intra, intra_chroma_pred_mode */
-
- return ;
-}
-#endif
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/motion_comp.cpp b/media/libstagefright/codecs/avc/enc/src/motion_comp.cpp
deleted file mode 100644
index a390f88..0000000
--- a/media/libstagefright/codecs/avc/enc/src/motion_comp.cpp
+++ /dev/null
@@ -1,2152 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-#include "avcenc_int.h"
-
-
-#define CLIP_RESULT(x) if((uint)x > 0xFF){ \
- x = 0xFF & (~(x>>31));}
-
-/* (blkwidth << 2) + (dy << 1) + dx */
-static void (*const eChromaMC_SIMD[8])(uint8 *, int , int , int , uint8 *, int, int , int) =
-{
- &eChromaFullMC_SIMD,
- &eChromaHorizontalMC_SIMD,
- &eChromaVerticalMC_SIMD,
- &eChromaDiagonalMC_SIMD,
- &eChromaFullMC_SIMD,
- &eChromaHorizontalMC2_SIMD,
- &eChromaVerticalMC2_SIMD,
- &eChromaDiagonalMC2_SIMD
-};
-/* Perform motion prediction and compensation with residue if exist. */
-void AVCMBMotionComp(AVCEncObject *encvid, AVCCommonObj *video)
-{
- (void)(encvid);
-
- AVCMacroblock *currMB = video->currMB;
- AVCPictureData *currPic = video->currPic;
- int mbPartIdx, subMbPartIdx;
- int ref_idx;
- int offset_MbPart_indx = 0;
- int16 *mv;
- uint32 x_pos, y_pos;
- uint8 *curL, *curCb, *curCr;
- uint8 *ref_l, *ref_Cb, *ref_Cr;
- uint8 *predBlock, *predCb, *predCr;
- int block_x, block_y, offset_x, offset_y, offsetP, offset;
- int x_position = (video->mb_x << 4);
- int y_position = (video->mb_y << 4);
- int MbHeight, MbWidth, mbPartIdx_X, mbPartIdx_Y, offset_indx;
- int picWidth = currPic->width;
- int picPitch = currPic->pitch;
- int picHeight = currPic->height;
- uint32 tmp_word;
-
- tmp_word = y_position * picPitch;
- curL = currPic->Sl + tmp_word + x_position;
- offset = (tmp_word >> 2) + (x_position >> 1);
- curCb = currPic->Scb + offset;
- curCr = currPic->Scr + offset;
-
- predBlock = curL;
- predCb = curCb;
- predCr = curCr;
-
- GetMotionVectorPredictor(video, 1);
-
- for (mbPartIdx = 0; mbPartIdx < currMB->NumMbPart; mbPartIdx++)
- {
- MbHeight = currMB->SubMbPartHeight[mbPartIdx];
- MbWidth = currMB->SubMbPartWidth[mbPartIdx];
- mbPartIdx_X = ((mbPartIdx + offset_MbPart_indx) & 1);
- mbPartIdx_Y = (mbPartIdx + offset_MbPart_indx) >> 1;
- ref_idx = currMB->ref_idx_L0[(mbPartIdx_Y << 1) + mbPartIdx_X];
- offset_indx = 0;
-
- ref_l = video->RefPicList0[ref_idx]->Sl;
- ref_Cb = video->RefPicList0[ref_idx]->Scb;
- ref_Cr = video->RefPicList0[ref_idx]->Scr;
-
- for (subMbPartIdx = 0; subMbPartIdx < currMB->NumSubMbPart[mbPartIdx]; subMbPartIdx++)
- {
- block_x = (mbPartIdx_X << 1) + ((subMbPartIdx + offset_indx) & 1);
- block_y = (mbPartIdx_Y << 1) + (((subMbPartIdx + offset_indx) >> 1) & 1);
- mv = (int16*)(currMB->mvL0 + block_x + (block_y << 2));
- offset_x = x_position + (block_x << 2);
- offset_y = y_position + (block_y << 2);
- x_pos = (offset_x << 2) + *mv++; /*quarter pel */
- y_pos = (offset_y << 2) + *mv; /*quarter pel */
-
- //offset = offset_y * currPic->width;
- //offsetC = (offset >> 2) + (offset_x >> 1);
- offsetP = (block_y << 2) * picPitch + (block_x << 2);
- eLumaMotionComp(ref_l, picPitch, picHeight, x_pos, y_pos,
- /*comp_Sl + offset + offset_x,*/
- predBlock + offsetP, picPitch, MbWidth, MbHeight);
-
- offsetP = (block_y * picWidth) + (block_x << 1);
- eChromaMotionComp(ref_Cb, picWidth >> 1, picHeight >> 1, x_pos, y_pos,
- /*comp_Scb + offsetC,*/
- predCb + offsetP, picPitch >> 1, MbWidth >> 1, MbHeight >> 1);
- eChromaMotionComp(ref_Cr, picWidth >> 1, picHeight >> 1, x_pos, y_pos,
- /*comp_Scr + offsetC,*/
- predCr + offsetP, picPitch >> 1, MbWidth >> 1, MbHeight >> 1);
-
- offset_indx = currMB->SubMbPartWidth[mbPartIdx] >> 3;
- }
- offset_MbPart_indx = currMB->MbPartWidth >> 4;
- }
-
- return ;
-}
-
-
-/* preform the actual motion comp here */
-void eLumaMotionComp(uint8 *ref, int picpitch, int picheight,
- int x_pos, int y_pos,
- uint8 *pred, int pred_pitch,
- int blkwidth, int blkheight)
-{
- (void)(picheight);
-
- int dx, dy;
- int temp2[21][21]; /* for intermediate results */
- uint8 *ref2;
-
- dx = x_pos & 3;
- dy = y_pos & 3;
- x_pos = x_pos >> 2; /* round it to full-pel resolution */
- y_pos = y_pos >> 2;
-
- /* perform actual motion compensation */
- if (dx == 0 && dy == 0)
- { /* fullpel position *//* G */
-
- ref += y_pos * picpitch + x_pos;
-
- eFullPelMC(ref, picpitch, pred, pred_pitch, blkwidth, blkheight);
-
- } /* other positions */
- else if (dy == 0)
- { /* no vertical interpolation *//* a,b,c*/
-
- ref += y_pos * picpitch + x_pos;
-
- eHorzInterp1MC(ref, picpitch, pred, pred_pitch, blkwidth, blkheight, dx);
- }
- else if (dx == 0)
- { /*no horizontal interpolation *//* d,h,n */
-
- ref += y_pos * picpitch + x_pos;
-
- eVertInterp1MC(ref, picpitch, pred, pred_pitch, blkwidth, blkheight, dy);
- }
- else if (dy == 2)
- { /* horizontal cross *//* i, j, k */
-
- ref += y_pos * picpitch + x_pos - 2; /* move to the left 2 pixels */
-
- eVertInterp2MC(ref, picpitch, &temp2[0][0], 21, blkwidth + 5, blkheight);
-
- eHorzInterp2MC(&temp2[0][2], 21, pred, pred_pitch, blkwidth, blkheight, dx);
- }
- else if (dx == 2)
- { /* vertical cross */ /* f,q */
-
- ref += (y_pos - 2) * picpitch + x_pos; /* move to up 2 lines */
-
- eHorzInterp3MC(ref, picpitch, &temp2[0][0], 21, blkwidth, blkheight + 5);
- eVertInterp3MC(&temp2[2][0], 21, pred, pred_pitch, blkwidth, blkheight, dy);
- }
- else
- { /* diagonal *//* e,g,p,r */
-
- ref2 = ref + (y_pos + (dy / 2)) * picpitch + x_pos;
-
- ref += (y_pos * picpitch) + x_pos + (dx / 2);
-
- eDiagonalInterpMC(ref2, ref, picpitch, pred, pred_pitch, blkwidth, blkheight);
- }
-
- return ;
-}
-
-void eCreateAlign(uint8 *ref, int picpitch, int y_pos,
- uint8 *out, int blkwidth, int blkheight)
-{
- int i, j;
- int offset, out_offset;
- uint32 prev_pix, result, pix1, pix2, pix4;
-
- ref += y_pos * picpitch;// + x_pos;
- out_offset = 24 - blkwidth;
-
- //switch(x_pos&0x3){
- switch (((intptr_t)ref)&0x3)
- {
- case 1:
- offset = picpitch - blkwidth - 3;
- for (j = 0; j < blkheight; j++)
- {
- pix1 = *ref++;
- pix2 = *((uint16*)ref);
- ref += 2;
- result = (pix2 << 8) | pix1;
-
- for (i = 3; i < blkwidth; i += 4)
- {
- pix4 = *((uint32*)ref);
- ref += 4;
- prev_pix = (pix4 << 24) & 0xFF000000; /* mask out byte belong to previous word */
- result |= prev_pix;
- *((uint32*)out) = result; /* write 4 bytes */
- out += 4;
- result = pix4 >> 8; /* for the next loop */
- }
- ref += offset;
- out += out_offset;
- }
- break;
- case 2:
- offset = picpitch - blkwidth - 2;
- for (j = 0; j < blkheight; j++)
- {
- result = *((uint16*)ref);
- ref += 2;
- for (i = 2; i < blkwidth; i += 4)
- {
- pix4 = *((uint32*)ref);
- ref += 4;
- prev_pix = (pix4 << 16) & 0xFFFF0000; /* mask out byte belong to previous word */
- result |= prev_pix;
- *((uint32*)out) = result; /* write 4 bytes */
- out += 4;
- result = pix4 >> 16; /* for the next loop */
- }
- ref += offset;
- out += out_offset;
- }
- break;
- case 3:
- offset = picpitch - blkwidth - 1;
- for (j = 0; j < blkheight; j++)
- {
- result = *ref++;
- for (i = 1; i < blkwidth; i += 4)
- {
- pix4 = *((uint32*)ref);
- ref += 4;
- prev_pix = (pix4 << 8) & 0xFFFFFF00; /* mask out byte belong to previous word */
- result |= prev_pix;
- *((uint32*)out) = result; /* write 4 bytes */
- out += 4;
- result = pix4 >> 24; /* for the next loop */
- }
- ref += offset;
- out += out_offset;
- }
- break;
- }
-}
-
-void eHorzInterp1MC(uint8 *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight, int dx)
-{
- uint8 *p_ref, *tmp;
- uint32 *p_cur;
- uint32 pkres;
- int result, curr_offset, ref_offset;
- int j;
- int32 r0, r1, r2, r3, r4, r5;
- int32 r13, r6;
-
- p_cur = (uint32*)out; /* assume it's word aligned */
- curr_offset = (outpitch - blkwidth) >> 2;
- p_ref = in;
- ref_offset = inpitch - blkwidth;
-
- if (dx&1)
- {
- dx = ((dx >> 1) ? -3 : -4); /* use in 3/4 pel */
- p_ref -= 2;
- r13 = 0;
- for (j = blkheight; j > 0; j--)
- {
- tmp = p_ref + blkwidth;
- r0 = p_ref[0];
- r1 = p_ref[2];
- r0 |= (r1 << 16); /* 0,c,0,a */
- r1 = p_ref[1];
- r2 = p_ref[3];
- r1 |= (r2 << 16); /* 0,d,0,b */
- while (p_ref < tmp)
- {
- r2 = *(p_ref += 4); /* move pointer to e */
- r3 = p_ref[2];
- r2 |= (r3 << 16); /* 0,g,0,e */
- r3 = p_ref[1];
- r4 = p_ref[3];
- r3 |= (r4 << 16); /* 0,h,0,f */
-
- r4 = r0 + r3; /* c+h, a+f */
- r5 = r0 + r1; /* c+d, a+b */
- r6 = r2 + r3; /* g+h, e+f */
- r5 >>= 16;
- r5 |= (r6 << 16); /* e+f, c+d */
- r4 += r5 * 20; /* c+20*e+20*f+h, a+20*c+20*d+f */
- r4 += 0x100010; /* +16, +16 */
- r5 = r1 + r2; /* d+g, b+e */
- r4 -= r5 * 5; /* c-5*d+20*e+20*f-5*g+h, a-5*b+20*c+20*d-5*e+f */
- r4 >>= 5;
- r13 |= r4; /* check clipping */
-
- r5 = p_ref[dx+2];
- r6 = p_ref[dx+4];
- r5 |= (r6 << 16);
- r4 += r5;
- r4 += 0x10001;
- r4 = (r4 >> 1) & 0xFF00FF;
-
- r5 = p_ref[4]; /* i */
- r6 = (r5 << 16);
- r5 = r6 | (r2 >> 16);/* 0,i,0,g */
- r5 += r1; /* d+i, b+g */ /* r5 not free */
- r1 >>= 16;
- r1 |= (r3 << 16); /* 0,f,0,d */ /* r1 has changed */
- r1 += r2; /* f+g, d+e */
- r5 += 20 * r1; /* d+20f+20g+i, b+20d+20e+g */
- r0 >>= 16;
- r0 |= (r2 << 16); /* 0,e,0,c */ /* r0 has changed */
- r0 += r3; /* e+h, c+f */
- r5 += 0x100010; /* 16,16 */
- r5 -= r0 * 5; /* d-5e+20f+20g-5h+i, b-5c+20d+20e-5f+g */
- r5 >>= 5;
- r13 |= r5; /* check clipping */
-
- r0 = p_ref[dx+3];
- r1 = p_ref[dx+5];
- r0 |= (r1 << 16);
- r5 += r0;
- r5 += 0x10001;
- r5 = (r5 >> 1) & 0xFF00FF;
-
- r4 |= (r5 << 8); /* pack them together */
- *p_cur++ = r4;
- r1 = r3;
- r0 = r2;
- }
- p_cur += curr_offset; /* move to the next line */
- p_ref += ref_offset; /* ref_offset = inpitch-blkwidth; */
-
- if (r13&0xFF000700) /* need clipping */
- {
- /* move back to the beginning of the line */
- p_ref -= (ref_offset + blkwidth); /* input */
- p_cur -= (outpitch >> 2);
-
- tmp = p_ref + blkwidth;
- for (; p_ref < tmp;)
- {
-
- r0 = *p_ref++;
- r1 = *p_ref++;
- r2 = *p_ref++;
- r3 = *p_ref++;
- r4 = *p_ref++;
- /* first pixel */
- r5 = *p_ref++;
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- /* 3/4 pel, no need to clip */
- result = (result + p_ref[dx] + 1);
- pkres = (result >> 1) ;
- /* second pixel */
- r0 = *p_ref++;
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- /* 3/4 pel, no need to clip */
- result = (result + p_ref[dx] + 1);
- result = (result >> 1);
- pkres |= (result << 8);
- /* third pixel */
- r1 = *p_ref++;
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- /* 3/4 pel, no need to clip */
- result = (result + p_ref[dx] + 1);
- result = (result >> 1);
- pkres |= (result << 16);
- /* fourth pixel */
- r2 = *p_ref++;
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- /* 3/4 pel, no need to clip */
- result = (result + p_ref[dx] + 1);
- result = (result >> 1);
- pkres |= (result << 24);
- *p_cur++ = pkres; /* write 4 pixels */
- p_ref -= 5; /* offset back to the middle of filter */
- }
- p_cur += curr_offset; /* move to the next line */
- p_ref += ref_offset; /* move to the next line */
- }
- }
- }
- else
- {
- p_ref -= 2;
- r13 = 0;
- for (j = blkheight; j > 0; j--)
- {
- tmp = p_ref + blkwidth;
- r0 = p_ref[0];
- r1 = p_ref[2];
- r0 |= (r1 << 16); /* 0,c,0,a */
- r1 = p_ref[1];
- r2 = p_ref[3];
- r1 |= (r2 << 16); /* 0,d,0,b */
- while (p_ref < tmp)
- {
- r2 = *(p_ref += 4); /* move pointer to e */
- r3 = p_ref[2];
- r2 |= (r3 << 16); /* 0,g,0,e */
- r3 = p_ref[1];
- r4 = p_ref[3];
- r3 |= (r4 << 16); /* 0,h,0,f */
-
- r4 = r0 + r3; /* c+h, a+f */
- r5 = r0 + r1; /* c+d, a+b */
- r6 = r2 + r3; /* g+h, e+f */
- r5 >>= 16;
- r5 |= (r6 << 16); /* e+f, c+d */
- r4 += r5 * 20; /* c+20*e+20*f+h, a+20*c+20*d+f */
- r4 += 0x100010; /* +16, +16 */
- r5 = r1 + r2; /* d+g, b+e */
- r4 -= r5 * 5; /* c-5*d+20*e+20*f-5*g+h, a-5*b+20*c+20*d-5*e+f */
- r4 >>= 5;
- r13 |= r4; /* check clipping */
- r4 &= 0xFF00FF; /* mask */
-
- r5 = p_ref[4]; /* i */
- r6 = (r5 << 16);
- r5 = r6 | (r2 >> 16);/* 0,i,0,g */
- r5 += r1; /* d+i, b+g */ /* r5 not free */
- r1 >>= 16;
- r1 |= (r3 << 16); /* 0,f,0,d */ /* r1 has changed */
- r1 += r2; /* f+g, d+e */
- r5 += 20 * r1; /* d+20f+20g+i, b+20d+20e+g */
- r0 >>= 16;
- r0 |= (r2 << 16); /* 0,e,0,c */ /* r0 has changed */
- r0 += r3; /* e+h, c+f */
- r5 += 0x100010; /* 16,16 */
- r5 -= r0 * 5; /* d-5e+20f+20g-5h+i, b-5c+20d+20e-5f+g */
- r5 >>= 5;
- r13 |= r5; /* check clipping */
- r5 &= 0xFF00FF; /* mask */
-
- r4 |= (r5 << 8); /* pack them together */
- *p_cur++ = r4;
- r1 = r3;
- r0 = r2;
- }
- p_cur += curr_offset; /* move to the next line */
- p_ref += ref_offset; /* ref_offset = inpitch-blkwidth; */
-
- if (r13&0xFF000700) /* need clipping */
- {
- /* move back to the beginning of the line */
- p_ref -= (ref_offset + blkwidth); /* input */
- p_cur -= (outpitch >> 2);
-
- tmp = p_ref + blkwidth;
- for (; p_ref < tmp;)
- {
-
- r0 = *p_ref++;
- r1 = *p_ref++;
- r2 = *p_ref++;
- r3 = *p_ref++;
- r4 = *p_ref++;
- /* first pixel */
- r5 = *p_ref++;
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- pkres = result;
- /* second pixel */
- r0 = *p_ref++;
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- pkres |= (result << 8);
- /* third pixel */
- r1 = *p_ref++;
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- pkres |= (result << 16);
- /* fourth pixel */
- r2 = *p_ref++;
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- pkres |= (result << 24);
- *p_cur++ = pkres; /* write 4 pixels */
- p_ref -= 5;
- }
- p_cur += curr_offset; /* move to the next line */
- p_ref += ref_offset;
- }
- }
- }
-
- return ;
-}
-
-void eHorzInterp2MC(int *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight, int dx)
-{
- int *p_ref, *tmp;
- uint32 *p_cur;
- uint32 pkres;
- int result, result2, curr_offset, ref_offset;
- int j, r0, r1, r2, r3, r4, r5;
-
- p_cur = (uint32*)out; /* assume it's word aligned */
- curr_offset = (outpitch - blkwidth) >> 2;
- p_ref = in;
- ref_offset = inpitch - blkwidth;
-
- if (dx&1)
- {
- dx = ((dx >> 1) ? -3 : -4); /* use in 3/4 pel */
-
- for (j = blkheight; j > 0 ; j--)
- {
- tmp = p_ref + blkwidth;
- for (; p_ref < tmp;)
- {
-
- r0 = p_ref[-2];
- r1 = p_ref[-1];
- r2 = *p_ref++;
- r3 = *p_ref++;
- r4 = *p_ref++;
- /* first pixel */
- r5 = *p_ref++;
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- result2 = ((p_ref[dx] + 16) >> 5);
- CLIP_RESULT(result2)
- /* 3/4 pel, no need to clip */
- result = (result + result2 + 1);
- pkres = (result >> 1);
- /* second pixel */
- r0 = *p_ref++;
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- result2 = ((p_ref[dx] + 16) >> 5);
- CLIP_RESULT(result2)
- /* 3/4 pel, no need to clip */
- result = (result + result2 + 1);
- result = (result >> 1);
- pkres |= (result << 8);
- /* third pixel */
- r1 = *p_ref++;
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- result2 = ((p_ref[dx] + 16) >> 5);
- CLIP_RESULT(result2)
- /* 3/4 pel, no need to clip */
- result = (result + result2 + 1);
- result = (result >> 1);
- pkres |= (result << 16);
- /* fourth pixel */
- r2 = *p_ref++;
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- result2 = ((p_ref[dx] + 16) >> 5);
- CLIP_RESULT(result2)
- /* 3/4 pel, no need to clip */
- result = (result + result2 + 1);
- result = (result >> 1);
- pkres |= (result << 24);
- *p_cur++ = pkres; /* write 4 pixels */
- p_ref -= 3; /* offset back to the middle of filter */
- }
- p_cur += curr_offset; /* move to the next line */
- p_ref += ref_offset; /* move to the next line */
- }
- }
- else
- {
- for (j = blkheight; j > 0 ; j--)
- {
- tmp = p_ref + blkwidth;
- for (; p_ref < tmp;)
- {
-
- r0 = p_ref[-2];
- r1 = p_ref[-1];
- r2 = *p_ref++;
- r3 = *p_ref++;
- r4 = *p_ref++;
- /* first pixel */
- r5 = *p_ref++;
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- pkres = result;
- /* second pixel */
- r0 = *p_ref++;
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- pkres |= (result << 8);
- /* third pixel */
- r1 = *p_ref++;
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- pkres |= (result << 16);
- /* fourth pixel */
- r2 = *p_ref++;
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- pkres |= (result << 24);
- *p_cur++ = pkres; /* write 4 pixels */
- p_ref -= 3; /* offset back to the middle of filter */
- }
- p_cur += curr_offset; /* move to the next line */
- p_ref += ref_offset; /* move to the next line */
- }
- }
-
- return ;
-}
-
-void eHorzInterp3MC(uint8 *in, int inpitch, int *out, int outpitch,
- int blkwidth, int blkheight)
-{
- uint8 *p_ref, *tmp;
- int *p_cur;
- int result, curr_offset, ref_offset;
- int j, r0, r1, r2, r3, r4, r5;
-
- p_cur = out;
- curr_offset = (outpitch - blkwidth);
- p_ref = in;
- ref_offset = inpitch - blkwidth;
-
- for (j = blkheight; j > 0 ; j--)
- {
- tmp = p_ref + blkwidth;
- for (; p_ref < tmp;)
- {
-
- r0 = p_ref[-2];
- r1 = p_ref[-1];
- r2 = *p_ref++;
- r3 = *p_ref++;
- r4 = *p_ref++;
- /* first pixel */
- r5 = *p_ref++;
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- *p_cur++ = result;
- /* second pixel */
- r0 = *p_ref++;
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- *p_cur++ = result;
- /* third pixel */
- r1 = *p_ref++;
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- *p_cur++ = result;
- /* fourth pixel */
- r2 = *p_ref++;
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- *p_cur++ = result;
- p_ref -= 3; /* move back to the middle of the filter */
- }
- p_cur += curr_offset; /* move to the next line */
- p_ref += ref_offset;
- }
-
- return ;
-}
-void eVertInterp1MC(uint8 *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight, int dy)
-{
- uint8 *p_cur, *p_ref, *tmp;
- int result, curr_offset, ref_offset;
- int j, i;
- int32 r0, r1, r2, r3, r4, r5, r6, r7, r8, r13;
- uint8 tmp_in[24][24];
-
- /* not word-aligned */
- if (((intptr_t)in)&0x3)
- {
- eCreateAlign(in, inpitch, -2, &tmp_in[0][0], blkwidth, blkheight + 5);
- in = &tmp_in[2][0];
- inpitch = 24;
- }
- p_cur = out;
- curr_offset = 1 - outpitch * (blkheight - 1); /* offset vertically back up and one pixel to right */
- ref_offset = blkheight * inpitch; /* for limit */
-
- curr_offset += 3;
-
- if (dy&1)
- {
- dy = (dy >> 1) ? 0 : -inpitch;
-
- for (j = 0; j < blkwidth; j += 4, in += 4)
- {
- r13 = 0;
- p_ref = in;
- p_cur -= outpitch; /* compensate for the first offset */
- tmp = p_ref + ref_offset; /* limit */
- while (p_ref < tmp) /* the loop un-rolled */
- {
- r0 = *((uint32*)(p_ref - (inpitch << 1))); /* load 4 bytes */
- p_ref += inpitch;
- r6 = (r0 >> 8) & 0xFF00FF; /* second and fourth byte */
- r0 &= 0xFF00FF;
-
- r1 = *((uint32*)(p_ref + (inpitch << 1))); /* r1, r7, ref[3] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
-
- r0 += r1;
- r6 += r7;
-
- r2 = *((uint32*)p_ref); /* r2, r8, ref[1] */
- r8 = (r2 >> 8) & 0xFF00FF;
- r2 &= 0xFF00FF;
-
- r1 = *((uint32*)(p_ref - inpitch)); /* r1, r7, ref[0] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
- r1 += r2;
-
- r7 += r8;
-
- r0 += 20 * r1;
- r6 += 20 * r7;
- r0 += 0x100010;
- r6 += 0x100010;
-
- r2 = *((uint32*)(p_ref - (inpitch << 1))); /* r2, r8, ref[-1] */
- r8 = (r2 >> 8) & 0xFF00FF;
- r2 &= 0xFF00FF;
-
- r1 = *((uint32*)(p_ref + inpitch)); /* r1, r7, ref[2] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
- r1 += r2;
-
- r7 += r8;
-
- r0 -= 5 * r1;
- r6 -= 5 * r7;
-
- r0 >>= 5;
- r6 >>= 5;
- /* clip */
- r13 |= r6;
- r13 |= r0;
- //CLIPPACK(r6,result)
-
- r1 = *((uint32*)(p_ref + dy));
- r2 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
- r0 += r1;
- r6 += r2;
- r0 += 0x10001;
- r6 += 0x10001;
- r0 = (r0 >> 1) & 0xFF00FF;
- r6 = (r6 >> 1) & 0xFF00FF;
-
- r0 |= (r6 << 8); /* pack it back */
- *((uint32*)(p_cur += outpitch)) = r0;
- }
- p_cur += curr_offset; /* offset to the next pixel */
- if (r13 & 0xFF000700) /* this column need clipping */
- {
- p_cur -= 4;
- for (i = 0; i < 4; i++)
- {
- p_ref = in + i;
- p_cur -= outpitch; /* compensate for the first offset */
-
- tmp = p_ref + ref_offset; /* limit */
- while (p_ref < tmp)
- { /* loop un-rolled */
- r0 = *(p_ref - (inpitch << 1));
- r1 = *(p_ref - inpitch);
- r2 = *p_ref;
- r3 = *(p_ref += inpitch); /* modify pointer before loading */
- r4 = *(p_ref += inpitch);
- /* first pixel */
- r5 = *(p_ref += inpitch);
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- /* 3/4 pel, no need to clip */
- result = (result + p_ref[dy-(inpitch<<1)] + 1);
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* second pixel */
- r0 = *(p_ref += inpitch);
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- /* 3/4 pel, no need to clip */
- result = (result + p_ref[dy-(inpitch<<1)] + 1);
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* third pixel */
- r1 = *(p_ref += inpitch);
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- /* 3/4 pel, no need to clip */
- result = (result + p_ref[dy-(inpitch<<1)] + 1);
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* fourth pixel */
- r2 = *(p_ref += inpitch);
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- /* 3/4 pel, no need to clip */
- result = (result + p_ref[dy-(inpitch<<1)] + 1);
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- p_ref -= (inpitch << 1); /* move back to center of the filter of the next one */
- }
- p_cur += (curr_offset - 3);
- }
- }
- }
- }
- else
- {
- for (j = 0; j < blkwidth; j += 4, in += 4)
- {
- r13 = 0;
- p_ref = in;
- p_cur -= outpitch; /* compensate for the first offset */
- tmp = p_ref + ref_offset; /* limit */
- while (p_ref < tmp) /* the loop un-rolled */
- {
- r0 = *((uint32*)(p_ref - (inpitch << 1))); /* load 4 bytes */
- p_ref += inpitch;
- r6 = (r0 >> 8) & 0xFF00FF; /* second and fourth byte */
- r0 &= 0xFF00FF;
-
- r1 = *((uint32*)(p_ref + (inpitch << 1))); /* r1, r7, ref[3] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
-
- r0 += r1;
- r6 += r7;
-
- r2 = *((uint32*)p_ref); /* r2, r8, ref[1] */
- r8 = (r2 >> 8) & 0xFF00FF;
- r2 &= 0xFF00FF;
-
- r1 = *((uint32*)(p_ref - inpitch)); /* r1, r7, ref[0] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
- r1 += r2;
-
- r7 += r8;
-
- r0 += 20 * r1;
- r6 += 20 * r7;
- r0 += 0x100010;
- r6 += 0x100010;
-
- r2 = *((uint32*)(p_ref - (inpitch << 1))); /* r2, r8, ref[-1] */
- r8 = (r2 >> 8) & 0xFF00FF;
- r2 &= 0xFF00FF;
-
- r1 = *((uint32*)(p_ref + inpitch)); /* r1, r7, ref[2] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
- r1 += r2;
-
- r7 += r8;
-
- r0 -= 5 * r1;
- r6 -= 5 * r7;
-
- r0 >>= 5;
- r6 >>= 5;
- /* clip */
- r13 |= r6;
- r13 |= r0;
- //CLIPPACK(r6,result)
- r0 &= 0xFF00FF;
- r6 &= 0xFF00FF;
- r0 |= (r6 << 8); /* pack it back */
- *((uint32*)(p_cur += outpitch)) = r0;
- }
- p_cur += curr_offset; /* offset to the next pixel */
- if (r13 & 0xFF000700) /* this column need clipping */
- {
- p_cur -= 4;
- for (i = 0; i < 4; i++)
- {
- p_ref = in + i;
- p_cur -= outpitch; /* compensate for the first offset */
- tmp = p_ref + ref_offset; /* limit */
- while (p_ref < tmp)
- { /* loop un-rolled */
- r0 = *(p_ref - (inpitch << 1));
- r1 = *(p_ref - inpitch);
- r2 = *p_ref;
- r3 = *(p_ref += inpitch); /* modify pointer before loading */
- r4 = *(p_ref += inpitch);
- /* first pixel */
- r5 = *(p_ref += inpitch);
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- *(p_cur += outpitch) = result;
- /* second pixel */
- r0 = *(p_ref += inpitch);
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- *(p_cur += outpitch) = result;
- /* third pixel */
- r1 = *(p_ref += inpitch);
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- *(p_cur += outpitch) = result;
- /* fourth pixel */
- r2 = *(p_ref += inpitch);
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- *(p_cur += outpitch) = result;
- p_ref -= (inpitch << 1); /* move back to center of the filter of the next one */
- }
- p_cur += (curr_offset - 3);
- }
- }
- }
- }
-
- return ;
-}
-
-void eVertInterp2MC(uint8 *in, int inpitch, int *out, int outpitch,
- int blkwidth, int blkheight)
-{
- int *p_cur;
- uint8 *p_ref, *tmp;
- int result, curr_offset, ref_offset;
- int j, r0, r1, r2, r3, r4, r5;
-
- p_cur = out;
- curr_offset = 1 - outpitch * (blkheight - 1); /* offset vertically back up and one pixel to right */
- ref_offset = blkheight * inpitch; /* for limit */
-
- for (j = 0; j < blkwidth; j++)
- {
- p_cur -= outpitch; /* compensate for the first offset */
- p_ref = in++;
-
- tmp = p_ref + ref_offset; /* limit */
- while (p_ref < tmp)
- { /* loop un-rolled */
- r0 = *(p_ref - (inpitch << 1));
- r1 = *(p_ref - inpitch);
- r2 = *p_ref;
- r3 = *(p_ref += inpitch); /* modify pointer before loading */
- r4 = *(p_ref += inpitch);
- /* first pixel */
- r5 = *(p_ref += inpitch);
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- *(p_cur += outpitch) = result;
- /* second pixel */
- r0 = *(p_ref += inpitch);
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- *(p_cur += outpitch) = result;
- /* third pixel */
- r1 = *(p_ref += inpitch);
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- *(p_cur += outpitch) = result;
- /* fourth pixel */
- r2 = *(p_ref += inpitch);
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- *(p_cur += outpitch) = result;
- p_ref -= (inpitch << 1); /* move back to center of the filter of the next one */
- }
- p_cur += curr_offset;
- }
-
- return ;
-}
-
-void eVertInterp3MC(int *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight, int dy)
-{
- uint8 *p_cur;
- int *p_ref, *tmp;
- int result, result2, curr_offset, ref_offset;
- int j, r0, r1, r2, r3, r4, r5;
-
- p_cur = out;
- curr_offset = 1 - outpitch * (blkheight - 1); /* offset vertically back up and one pixel to right */
- ref_offset = blkheight * inpitch; /* for limit */
-
- if (dy&1)
- {
- dy = (dy >> 1) ? -(inpitch << 1) : -(inpitch << 1) - inpitch;
-
- for (j = 0; j < blkwidth; j++)
- {
- p_cur -= outpitch; /* compensate for the first offset */
- p_ref = in++;
-
- tmp = p_ref + ref_offset; /* limit */
- while (p_ref < tmp)
- { /* loop un-rolled */
- r0 = *(p_ref - (inpitch << 1));
- r1 = *(p_ref - inpitch);
- r2 = *p_ref;
- r3 = *(p_ref += inpitch); /* modify pointer before loading */
- r4 = *(p_ref += inpitch);
- /* first pixel */
- r5 = *(p_ref += inpitch);
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- result2 = ((p_ref[dy] + 16) >> 5);
- CLIP_RESULT(result2)
- /* 3/4 pel, no need to clip */
- result = (result + result2 + 1);
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* second pixel */
- r0 = *(p_ref += inpitch);
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- result2 = ((p_ref[dy] + 16) >> 5);
- CLIP_RESULT(result2)
- /* 3/4 pel, no need to clip */
- result = (result + result2 + 1);
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* third pixel */
- r1 = *(p_ref += inpitch);
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- result2 = ((p_ref[dy] + 16) >> 5);
- CLIP_RESULT(result2)
- /* 3/4 pel, no need to clip */
- result = (result + result2 + 1);
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* fourth pixel */
- r2 = *(p_ref += inpitch);
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- result2 = ((p_ref[dy] + 16) >> 5);
- CLIP_RESULT(result2)
- /* 3/4 pel, no need to clip */
- result = (result + result2 + 1);
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- p_ref -= (inpitch << 1); /* move back to center of the filter of the next one */
- }
- p_cur += curr_offset;
- }
- }
- else
- {
- for (j = 0; j < blkwidth; j++)
- {
- p_cur -= outpitch; /* compensate for the first offset */
- p_ref = in++;
-
- tmp = p_ref + ref_offset; /* limit */
- while (p_ref < tmp)
- { /* loop un-rolled */
- r0 = *(p_ref - (inpitch << 1));
- r1 = *(p_ref - inpitch);
- r2 = *p_ref;
- r3 = *(p_ref += inpitch); /* modify pointer before loading */
- r4 = *(p_ref += inpitch);
- /* first pixel */
- r5 = *(p_ref += inpitch);
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- *(p_cur += outpitch) = result;
- /* second pixel */
- r0 = *(p_ref += inpitch);
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- *(p_cur += outpitch) = result;
- /* third pixel */
- r1 = *(p_ref += inpitch);
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- *(p_cur += outpitch) = result;
- /* fourth pixel */
- r2 = *(p_ref += inpitch);
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 512) >> 10;
- CLIP_RESULT(result)
- *(p_cur += outpitch) = result;
- p_ref -= (inpitch << 1); /* move back to center of the filter of the next one */
- }
- p_cur += curr_offset;
- }
- }
-
- return ;
-}
-
-void eDiagonalInterpMC(uint8 *in1, uint8 *in2, int inpitch,
- uint8 *out, int outpitch,
- int blkwidth, int blkheight)
-{
- int j, i;
- int result;
- uint8 *p_cur, *p_ref, *p_tmp8, *tmp;
- int curr_offset, ref_offset;
- uint8 tmp_res[24][24], tmp_in[24][24];
- uint32 *p_tmp;
- uint32 pkres, tmp_result;
- int32 r0, r1, r2, r3, r4, r5;
- int32 r6, r7, r8, r9, r10, r13;
-
- ref_offset = inpitch - blkwidth;
- p_ref = in1 - 2;
- /* perform horizontal interpolation */
- /* not word-aligned */
- /* It is faster to read 1 byte at time to avoid calling CreateAlign */
- /* if(((uint32)p_ref)&0x3)
- {
- CreateAlign(p_ref,inpitch,0,&tmp_in[0][0],blkwidth+8,blkheight);
- p_ref = &tmp_in[0][0];
- ref_offset = 24-blkwidth;
- }*/
-
- p_tmp = (uint32*) & (tmp_res[0][0]);
- for (j = blkheight; j > 0; j--)
- {
- r13 = 0;
- tmp = p_ref + blkwidth;
-
- //r0 = *((uint32*)p_ref); /* d,c,b,a */
- //r1 = (r0>>8)&0xFF00FF; /* 0,d,0,b */
- //r0 &= 0xFF00FF; /* 0,c,0,a */
- /* It is faster to read 1 byte at a time */
- r0 = p_ref[0];
- r1 = p_ref[2];
- r0 |= (r1 << 16); /* 0,c,0,a */
- r1 = p_ref[1];
- r2 = p_ref[3];
- r1 |= (r2 << 16); /* 0,d,0,b */
-
- while (p_ref < tmp)
- {
- //r2 = *((uint32*)(p_ref+=4));/* h,g,f,e */
- //r3 = (r2>>8)&0xFF00FF; /* 0,h,0,f */
- //r2 &= 0xFF00FF; /* 0,g,0,e */
- /* It is faster to read 1 byte at a time */
- r2 = *(p_ref += 4);
- r3 = p_ref[2];
- r2 |= (r3 << 16); /* 0,g,0,e */
- r3 = p_ref[1];
- r4 = p_ref[3];
- r3 |= (r4 << 16); /* 0,h,0,f */
-
- r4 = r0 + r3; /* c+h, a+f */
- r5 = r0 + r1; /* c+d, a+b */
- r6 = r2 + r3; /* g+h, e+f */
- r5 >>= 16;
- r5 |= (r6 << 16); /* e+f, c+d */
- r4 += r5 * 20; /* c+20*e+20*f+h, a+20*c+20*d+f */
- r4 += 0x100010; /* +16, +16 */
- r5 = r1 + r2; /* d+g, b+e */
- r4 -= r5 * 5; /* c-5*d+20*e+20*f-5*g+h, a-5*b+20*c+20*d-5*e+f */
- r4 >>= 5;
- r13 |= r4; /* check clipping */
- r4 &= 0xFF00FF; /* mask */
-
- r5 = p_ref[4]; /* i */
- r6 = (r5 << 16);
- r5 = r6 | (r2 >> 16);/* 0,i,0,g */
- r5 += r1; /* d+i, b+g */ /* r5 not free */
- r1 >>= 16;
- r1 |= (r3 << 16); /* 0,f,0,d */ /* r1 has changed */
- r1 += r2; /* f+g, d+e */
- r5 += 20 * r1; /* d+20f+20g+i, b+20d+20e+g */
- r0 >>= 16;
- r0 |= (r2 << 16); /* 0,e,0,c */ /* r0 has changed */
- r0 += r3; /* e+h, c+f */
- r5 += 0x100010; /* 16,16 */
- r5 -= r0 * 5; /* d-5e+20f+20g-5h+i, b-5c+20d+20e-5f+g */
- r5 >>= 5;
- r13 |= r5; /* check clipping */
- r5 &= 0xFF00FF; /* mask */
-
- r4 |= (r5 << 8); /* pack them together */
- *p_tmp++ = r4;
- r1 = r3;
- r0 = r2;
- }
- p_tmp += ((24 - blkwidth) >> 2); /* move to the next line */
- p_ref += ref_offset; /* ref_offset = inpitch-blkwidth; */
-
- if (r13&0xFF000700) /* need clipping */
- {
- /* move back to the beginning of the line */
- p_ref -= (ref_offset + blkwidth); /* input */
- p_tmp -= 6; /* intermediate output */
- tmp = p_ref + blkwidth;
- while (p_ref < tmp)
- {
- r0 = *p_ref++;
- r1 = *p_ref++;
- r2 = *p_ref++;
- r3 = *p_ref++;
- r4 = *p_ref++;
- /* first pixel */
- r5 = *p_ref++;
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- pkres = result;
- /* second pixel */
- r0 = *p_ref++;
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- pkres |= (result << 8);
- /* third pixel */
- r1 = *p_ref++;
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- pkres |= (result << 16);
- /* fourth pixel */
- r2 = *p_ref++;
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- pkres |= (result << 24);
-
- *p_tmp++ = pkres; /* write 4 pixel */
- p_ref -= 5;
- }
- p_tmp += ((24 - blkwidth) >> 2); /* move to the next line */
- p_ref += ref_offset; /* ref_offset = inpitch-blkwidth; */
- }
- }
-
- /* perform vertical interpolation */
- /* not word-aligned */
- if (((intptr_t)in2)&0x3)
- {
- eCreateAlign(in2, inpitch, -2, &tmp_in[0][0], blkwidth, blkheight + 5);
- in2 = &tmp_in[2][0];
- inpitch = 24;
- }
-
- p_cur = out;
- curr_offset = 1 - outpitch * (blkheight - 1); /* offset vertically up and one pixel right */
- pkres = blkheight * inpitch; /* reuse it for limit */
-
- curr_offset += 3;
-
- for (j = 0; j < blkwidth; j += 4, in2 += 4)
- {
- r13 = 0;
- p_ref = in2;
- p_tmp8 = &(tmp_res[0][j]); /* intermediate result */
- p_tmp8 -= 24; /* compensate for the first offset */
- p_cur -= outpitch; /* compensate for the first offset */
- tmp = p_ref + pkres; /* limit */
- while (p_ref < tmp) /* the loop un-rolled */
- {
- /* Read 1 byte at a time is too slow, too many read and pack ops, need to call CreateAlign */
- /*p_ref8 = p_ref-(inpitch<<1); r0 = p_ref8[0]; r1 = p_ref8[2];
- r0 |= (r1<<16); r6 = p_ref8[1]; r1 = p_ref8[3];
- r6 |= (r1<<16); p_ref+=inpitch; */
- r0 = *((uint32*)(p_ref - (inpitch << 1))); /* load 4 bytes */
- p_ref += inpitch;
- r6 = (r0 >> 8) & 0xFF00FF; /* second and fourth byte */
- r0 &= 0xFF00FF;
-
- /*p_ref8 = p_ref+(inpitch<<1);
- r1 = p_ref8[0]; r7 = p_ref8[2]; r1 |= (r7<<16);
- r7 = p_ref8[1]; r2 = p_ref8[3]; r7 |= (r2<<16);*/
- r1 = *((uint32*)(p_ref + (inpitch << 1))); /* r1, r7, ref[3] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
-
- r0 += r1;
- r6 += r7;
-
- /*r2 = p_ref[0]; r8 = p_ref[2]; r2 |= (r8<<16);
- r8 = p_ref[1]; r1 = p_ref[3]; r8 |= (r1<<16);*/
- r2 = *((uint32*)p_ref); /* r2, r8, ref[1] */
- r8 = (r2 >> 8) & 0xFF00FF;
- r2 &= 0xFF00FF;
-
- /*p_ref8 = p_ref-inpitch; r1 = p_ref8[0]; r7 = p_ref8[2];
- r1 |= (r7<<16); r1 += r2; r7 = p_ref8[1];
- r2 = p_ref8[3]; r7 |= (r2<<16);*/
- r1 = *((uint32*)(p_ref - inpitch)); /* r1, r7, ref[0] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
- r1 += r2;
-
- r7 += r8;
-
- r0 += 20 * r1;
- r6 += 20 * r7;
- r0 += 0x100010;
- r6 += 0x100010;
-
- /*p_ref8 = p_ref-(inpitch<<1); r2 = p_ref8[0]; r8 = p_ref8[2];
- r2 |= (r8<<16); r8 = p_ref8[1]; r1 = p_ref8[3]; r8 |= (r1<<16);*/
- r2 = *((uint32*)(p_ref - (inpitch << 1))); /* r2, r8, ref[-1] */
- r8 = (r2 >> 8) & 0xFF00FF;
- r2 &= 0xFF00FF;
-
- /*p_ref8 = p_ref+inpitch; r1 = p_ref8[0]; r7 = p_ref8[2];
- r1 |= (r7<<16); r1 += r2; r7 = p_ref8[1];
- r2 = p_ref8[3]; r7 |= (r2<<16);*/
- r1 = *((uint32*)(p_ref + inpitch)); /* r1, r7, ref[2] */
- r7 = (r1 >> 8) & 0xFF00FF;
- r1 &= 0xFF00FF;
- r1 += r2;
-
- r7 += r8;
-
- r0 -= 5 * r1;
- r6 -= 5 * r7;
-
- r0 >>= 5;
- r6 >>= 5;
- /* clip */
- r13 |= r6;
- r13 |= r0;
- //CLIPPACK(r6,result)
- /* add with horizontal results */
- r10 = *((uint32*)(p_tmp8 += 24));
- r9 = (r10 >> 8) & 0xFF00FF;
- r10 &= 0xFF00FF;
-
- r0 += r10;
- r0 += 0x10001;
- r0 = (r0 >> 1) & 0xFF00FF; /* mask to 8 bytes */
-
- r6 += r9;
- r6 += 0x10001;
- r6 = (r6 >> 1) & 0xFF00FF; /* mask to 8 bytes */
-
- r0 |= (r6 << 8); /* pack it back */
- *((uint32*)(p_cur += outpitch)) = r0;
- }
- p_cur += curr_offset; /* offset to the next pixel */
- if (r13 & 0xFF000700) /* this column need clipping */
- {
- p_cur -= 4;
- for (i = 0; i < 4; i++)
- {
- p_ref = in2 + i;
- p_tmp8 = &(tmp_res[0][j+i]); /* intermediate result */
- p_tmp8 -= 24; /* compensate for the first offset */
- p_cur -= outpitch; /* compensate for the first offset */
- tmp = p_ref + pkres; /* limit */
- while (p_ref < tmp) /* the loop un-rolled */
- {
- r0 = *(p_ref - (inpitch << 1));
- r1 = *(p_ref - inpitch);
- r2 = *p_ref;
- r3 = *(p_ref += inpitch); /* modify pointer before loading */
- r4 = *(p_ref += inpitch);
- /* first pixel */
- r5 = *(p_ref += inpitch);
- result = (r0 + r5);
- r0 = (r1 + r4);
- result -= (r0 * 5);//result -= r0; result -= (r0<<2);
- r0 = (r2 + r3);
- result += (r0 * 20);//result += (r0<<4); result += (r0<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- tmp_result = *(p_tmp8 += 24); /* modify pointer before loading */
- result = (result + tmp_result + 1); /* no clip */
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* second pixel */
- r0 = *(p_ref += inpitch);
- result = (r1 + r0);
- r1 = (r2 + r5);
- result -= (r1 * 5);//result -= r1; result -= (r1<<2);
- r1 = (r3 + r4);
- result += (r1 * 20);//result += (r1<<4); result += (r1<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- tmp_result = *(p_tmp8 += 24); /* intermediate result */
- result = (result + tmp_result + 1); /* no clip */
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* third pixel */
- r1 = *(p_ref += inpitch);
- result = (r2 + r1);
- r2 = (r3 + r0);
- result -= (r2 * 5);//result -= r2; result -= (r2<<2);
- r2 = (r4 + r5);
- result += (r2 * 20);//result += (r2<<4); result += (r2<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- tmp_result = *(p_tmp8 += 24); /* intermediate result */
- result = (result + tmp_result + 1); /* no clip */
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- /* fourth pixel */
- r2 = *(p_ref += inpitch);
- result = (r3 + r2);
- r3 = (r4 + r1);
- result -= (r3 * 5);//result -= r3; result -= (r3<<2);
- r3 = (r5 + r0);
- result += (r3 * 20);//result += (r3<<4); result += (r3<<2);
- result = (result + 16) >> 5;
- CLIP_RESULT(result)
- tmp_result = *(p_tmp8 += 24); /* intermediate result */
- result = (result + tmp_result + 1); /* no clip */
- result = (result >> 1);
- *(p_cur += outpitch) = result;
- p_ref -= (inpitch << 1); /* move back to center of the filter of the next one */
- }
- p_cur += (curr_offset - 3);
- }
- }
- }
-
- return ;
-}
-
-/* position G */
-void eFullPelMC(uint8 *in, int inpitch, uint8 *out, int outpitch,
- int blkwidth, int blkheight)
-{
- int i, j;
- int offset_in = inpitch - blkwidth;
- int offset_out = outpitch - blkwidth;
- uint32 temp;
- uint8 byte;
-
- if (((intptr_t)in)&3)
- {
- for (j = blkheight; j > 0; j--)
- {
- for (i = blkwidth; i > 0; i -= 4)
- {
- temp = *in++;
- byte = *in++;
- temp |= (byte << 8);
- byte = *in++;
- temp |= (byte << 16);
- byte = *in++;
- temp |= (byte << 24);
-
- *((uint32*)out) = temp; /* write 4 bytes */
- out += 4;
- }
- out += offset_out;
- in += offset_in;
- }
- }
- else
- {
- for (j = blkheight; j > 0; j--)
- {
- for (i = blkwidth; i > 0; i -= 4)
- {
- temp = *((uint32*)in);
- *((uint32*)out) = temp;
- in += 4;
- out += 4;
- }
- out += offset_out;
- in += offset_in;
- }
- }
- return ;
-}
-
-void ePadChroma(uint8 *ref, int picwidth, int picheight, int picpitch, int x_pos, int y_pos)
-{
- int pad_height;
- int pad_width;
- uint8 *start;
- uint32 word1, word2, word3;
- int offset, j;
-
-
- pad_height = 8 + ((y_pos & 7) ? 1 : 0);
- pad_width = 8 + ((x_pos & 7) ? 1 : 0);
-
- y_pos >>= 3;
- x_pos >>= 3;
- // pad vertical first
- if (y_pos < 0) // need to pad up
- {
- if (x_pos < -8) start = ref - 8;
- else if (x_pos + pad_width > picwidth + 7) start = ref + picwidth + 7 - pad_width;
- else start = ref + x_pos;
-
- /* word-align start */
- offset = (intptr_t)start & 0x3;
- if (offset) start -= offset;
-
- word1 = *((uint32*)start);
- word2 = *((uint32*)(start + 4));
- word3 = *((uint32*)(start + 8));
-
- /* pad up N rows */
- j = -y_pos;
- if (j > 8) j = 8;
- while (j--)
- {
- *((uint32*)(start -= picpitch)) = word1;
- *((uint32*)(start + 4)) = word2;
- *((uint32*)(start + 8)) = word3;
- }
-
- }
- else if (y_pos + pad_height >= picheight) /* pad down */
- {
- if (x_pos < -8) start = ref + picpitch * (picheight - 1) - 8;
- else if (x_pos + pad_width > picwidth + 7) start = ref + picpitch * (picheight - 1) +
- picwidth + 7 - pad_width;
- else start = ref + picpitch * (picheight - 1) + x_pos;
-
- /* word-align start */
- offset = (intptr_t)start & 0x3;
- if (offset) start -= offset;
-
- word1 = *((uint32*)start);
- word2 = *((uint32*)(start + 4));
- word3 = *((uint32*)(start + 8));
-
- /* pad down N rows */
- j = y_pos + pad_height - picheight;
- if (j > 8) j = 8;
- while (j--)
- {
- *((uint32*)(start += picpitch)) = word1;
- *((uint32*)(start + 4)) = word2;
- *((uint32*)(start + 8)) = word3;
- }
- }
-
- /* now pad horizontal */
- if (x_pos < 0) // pad left
- {
- if (y_pos < -8) start = ref - (picpitch << 3);
- else if (y_pos + pad_height > picheight + 7) start = ref + (picheight + 7 - pad_height) * picpitch;
- else start = ref + y_pos * picpitch;
-
- // now pad left 8 pixels for pad_height rows */
- j = pad_height;
- start -= picpitch;
- while (j--)
- {
- word1 = *(start += picpitch);
- word1 |= (word1 << 8);
- word1 |= (word1 << 16);
- *((uint32*)(start - 8)) = word1;
- *((uint32*)(start - 4)) = word1;
- }
- }
- else if (x_pos + pad_width >= picwidth) /* pad right */
- {
- if (y_pos < -8) start = ref - (picpitch << 3) + picwidth - 1;
- else if (y_pos + pad_height > picheight + 7) start = ref + (picheight + 7 - pad_height) * picpitch + picwidth - 1;
- else start = ref + y_pos * picpitch + picwidth - 1;
-
- // now pad right 8 pixels for pad_height rows */
- j = pad_height;
- start -= picpitch;
- while (j--)
- {
- word1 = *(start += picpitch);
- word1 |= (word1 << 8);
- word1 |= (word1 << 16);
- *((uint32*)(start + 1)) = word1;
- *((uint32*)(start + 5)) = word1;
- }
- }
-
- return ;
-}
-
-
-void eChromaMotionComp(uint8 *ref, int picwidth, int picheight,
- int x_pos, int y_pos,
- uint8 *pred, int picpitch,
- int blkwidth, int blkheight)
-{
- int dx, dy;
- int offset_dx, offset_dy;
- int index;
-
- ePadChroma(ref, picwidth, picheight, picpitch, x_pos, y_pos);
-
- dx = x_pos & 7;
- dy = y_pos & 7;
- offset_dx = (dx + 7) >> 3;
- offset_dy = (dy + 7) >> 3;
- x_pos = x_pos >> 3; /* round it to full-pel resolution */
- y_pos = y_pos >> 3;
-
- ref += y_pos * picpitch + x_pos;
-
- index = offset_dx + (offset_dy << 1) + ((blkwidth << 1) & 0x7);
-
- (*(eChromaMC_SIMD[index]))(ref, picpitch , dx, dy, pred, picpitch, blkwidth, blkheight);
- return ;
-}
-
-
-/* SIMD routines, unroll the loops in vertical direction, decreasing loops (things to be done) */
-void eChromaDiagonalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight)
-{
- int32 r0, r1, r2, r3, result0, result1;
- uint8 temp[288];
- uint8 *ref, *out;
- int i, j;
- int dx_8 = 8 - dx;
- int dy_8 = 8 - dy;
-
- /* horizontal first */
- out = temp;
- for (i = 0; i < blkheight + 1; i++)
- {
- ref = pRef;
- r0 = ref[0];
- for (j = 0; j < blkwidth; j += 4)
- {
- r0 |= (ref[2] << 16);
- result0 = dx_8 * r0;
-
- r1 = ref[1] | (ref[3] << 16);
- result0 += dx * r1;
- *(int32 *)out = result0;
-
- result0 = dx_8 * r1;
-
- r2 = ref[4];
- r0 = r0 >> 16;
- r1 = r0 | (r2 << 16);
- result0 += dx * r1;
- *(int32 *)(out + 16) = result0;
-
- ref += 4;
- out += 4;
- r0 = r2;
- }
- pRef += srcPitch;
- out += (32 - blkwidth);
- }
-
-// pRef -= srcPitch*(blkheight+1);
- ref = temp;
-
- for (j = 0; j < blkwidth; j += 4)
- {
- r0 = *(int32 *)ref;
- r1 = *(int32 *)(ref + 16);
- ref += 32;
- out = pOut;
- for (i = 0; i < (blkheight >> 1); i++)
- {
- result0 = dy_8 * r0 + 0x00200020;
- r2 = *(int32 *)ref;
- result0 += dy * r2;
- result0 >>= 6;
- result0 &= 0x00FF00FF;
- r0 = r2;
-
- result1 = dy_8 * r1 + 0x00200020;
- r3 = *(int32 *)(ref + 16);
- result1 += dy * r3;
- result1 >>= 6;
- result1 &= 0x00FF00FF;
- r1 = r3;
- *(int32 *)out = result0 | (result1 << 8);
- out += predPitch;
- ref += 32;
-
- result0 = dy_8 * r0 + 0x00200020;
- r2 = *(int32 *)ref;
- result0 += dy * r2;
- result0 >>= 6;
- result0 &= 0x00FF00FF;
- r0 = r2;
-
- result1 = dy_8 * r1 + 0x00200020;
- r3 = *(int32 *)(ref + 16);
- result1 += dy * r3;
- result1 >>= 6;
- result1 &= 0x00FF00FF;
- r1 = r3;
- *(int32 *)out = result0 | (result1 << 8);
- out += predPitch;
- ref += 32;
- }
- pOut += 4;
- ref = temp + 4; /* since it can only iterate twice max */
- }
- return;
-}
-
-void eChromaHorizontalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight)
-{
- (void)(dy);
-
- int32 r0, r1, r2, result0, result1;
- uint8 *ref, *out;
- int i, j;
- int dx_8 = 8 - dx;
-
- /* horizontal first */
- for (i = 0; i < blkheight; i++)
- {
- ref = pRef;
- out = pOut;
-
- r0 = ref[0];
- for (j = 0; j < blkwidth; j += 4)
- {
- r0 |= (ref[2] << 16);
- result0 = dx_8 * r0 + 0x00040004;
-
- r1 = ref[1] | (ref[3] << 16);
- result0 += dx * r1;
- result0 >>= 3;
- result0 &= 0x00FF00FF;
-
- result1 = dx_8 * r1 + 0x00040004;
-
- r2 = ref[4];
- r0 = r0 >> 16;
- r1 = r0 | (r2 << 16);
- result1 += dx * r1;
- result1 >>= 3;
- result1 &= 0x00FF00FF;
-
- *(int32 *)out = result0 | (result1 << 8);
-
- ref += 4;
- out += 4;
- r0 = r2;
- }
-
- pRef += srcPitch;
- pOut += predPitch;
- }
- return;
-}
-
-void eChromaVerticalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight)
-{
- (void)(dx);
-
- int32 r0, r1, r2, r3, result0, result1;
- int i, j;
- uint8 *ref, *out;
- int dy_8 = 8 - dy;
- /* vertical first */
- for (i = 0; i < blkwidth; i += 4)
- {
- ref = pRef;
- out = pOut;
-
- r0 = ref[0] | (ref[2] << 16);
- r1 = ref[1] | (ref[3] << 16);
- ref += srcPitch;
- for (j = 0; j < blkheight; j++)
- {
- result0 = dy_8 * r0 + 0x00040004;
- r2 = ref[0] | (ref[2] << 16);
- result0 += dy * r2;
- result0 >>= 3;
- result0 &= 0x00FF00FF;
- r0 = r2;
-
- result1 = dy_8 * r1 + 0x00040004;
- r3 = ref[1] | (ref[3] << 16);
- result1 += dy * r3;
- result1 >>= 3;
- result1 &= 0x00FF00FF;
- r1 = r3;
- *(int32 *)out = result0 | (result1 << 8);
- ref += srcPitch;
- out += predPitch;
- }
- pOut += 4;
- pRef += 4;
- }
- return;
-}
-
-void eChromaDiagonalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight)
-{
- (void)(blkwidth);
-
- int32 r0, r1, temp0, temp1, result;
- int32 temp[9];
- int32 *out;
- int i, r_temp;
- int dy_8 = 8 - dy;
-
- /* horizontal first */
- out = temp;
- for (i = 0; i < blkheight + 1; i++)
- {
- r_temp = pRef[1];
- temp0 = (pRef[0] << 3) + dx * (r_temp - pRef[0]);
- temp1 = (r_temp << 3) + dx * (pRef[2] - r_temp);
- r0 = temp0 | (temp1 << 16);
- *out++ = r0;
- pRef += srcPitch;
- }
-
- pRef -= srcPitch * (blkheight + 1);
-
- out = temp;
-
- r0 = *out++;
-
- for (i = 0; i < blkheight; i++)
- {
- result = dy_8 * r0 + 0x00200020;
- r1 = *out++;
- result += dy * r1;
- result >>= 6;
- result &= 0x00FF00FF;
- *(int16 *)pOut = (result >> 8) | (result & 0xFF);
- r0 = r1;
- pOut += predPitch;
- }
- return;
-}
-
-void eChromaHorizontalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight)
-{
- (void)(dy);
- (void)(blkwidth);
-
- int i, temp, temp0, temp1;
-
- /* horizontal first */
- for (i = 0; i < blkheight; i++)
- {
- temp = pRef[1];
- temp0 = ((pRef[0] << 3) + dx * (temp - pRef[0]) + 4) >> 3;
- temp1 = ((temp << 3) + dx * (pRef[2] - temp) + 4) >> 3;
-
- *(int16 *)pOut = temp0 | (temp1 << 8);
- pRef += srcPitch;
- pOut += predPitch;
-
- }
- return;
-}
-void eChromaVerticalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight)
-{
- (void)(dx);
- (void)(blkwidth);
-
- int32 r0, r1, result;
- int i;
- int dy_8 = 8 - dy;
- r0 = pRef[0] | (pRef[1] << 16);
- pRef += srcPitch;
- for (i = 0; i < blkheight; i++)
- {
- result = dy_8 * r0 + 0x00040004;
- r1 = pRef[0] | (pRef[1] << 16);
- result += dy * r1;
- result >>= 3;
- result &= 0x00FF00FF;
- *(int16 *)pOut = (result >> 8) | (result & 0xFF);
- r0 = r1;
- pRef += srcPitch;
- pOut += predPitch;
- }
- return;
-}
-
-void eChromaFullMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
- uint8 *pOut, int predPitch, int blkwidth, int blkheight)
-{
- (void)(dx);
- (void)(dy);
-
- int i, j;
- int offset_in = srcPitch - blkwidth;
- int offset_out = predPitch - blkwidth;
- uint16 temp;
- uint8 byte;
-
- if (((intptr_t)pRef)&1)
- {
- for (j = blkheight; j > 0; j--)
- {
- for (i = blkwidth; i > 0; i -= 2)
- {
- temp = *pRef++;
- byte = *pRef++;
- temp |= (byte << 8);
- *((uint16*)pOut) = temp; /* write 2 bytes */
- pOut += 2;
- }
- pOut += offset_out;
- pRef += offset_in;
- }
- }
- else
- {
- for (j = blkheight; j > 0; j--)
- {
- for (i = blkwidth; i > 0; i -= 2)
- {
- temp = *((uint16*)pRef);
- *((uint16*)pOut) = temp;
- pRef += 2;
- pOut += 2;
- }
- pOut += offset_out;
- pRef += offset_in;
- }
- }
- return ;
-}
diff --git a/media/libstagefright/codecs/avc/enc/src/motion_est.cpp b/media/libstagefright/codecs/avc/enc/src/motion_est.cpp
deleted file mode 100644
index 00c56c8..0000000
--- a/media/libstagefright/codecs/avc/enc/src/motion_est.cpp
+++ /dev/null
@@ -1,1774 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-
-#define MIN_GOP 1 /* minimum size of GOP, 1/23/01, need to be tested */
-
-#define DEFAULT_REF_IDX 0 /* always from the first frame in the reflist */
-
-#define ALL_CAND_EQUAL 10 /* any number greater than 5 will work */
-
-
-/* from TMN 3.2 */
-#define PREF_NULL_VEC 129 /* zero vector bias */
-#define PREF_16_VEC 129 /* 1MV bias versus 4MVs*/
-#define PREF_INTRA 3024//512 /* bias for INTRA coding */
-
-const static int tab_exclude[9][9] = // [last_loc][curr_loc]
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 1, 1, 1, 0, 0},
- {0, 0, 0, 0, 1, 1, 1, 1, 1},
- {0, 0, 0, 0, 0, 0, 1, 1, 1},
- {0, 1, 1, 0, 0, 0, 1, 1, 1},
- {0, 1, 1, 0, 0, 0, 0, 0, 1},
- {0, 1, 1, 1, 1, 0, 0, 0, 1},
- {0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 1, 1, 1, 1, 1, 0, 0}
-}; //to decide whether to continue or compute
-
-const static int refine_next[8][2] = /* [curr_k][increment] */
-{
- {0, 0}, {2, 0}, {1, 1}, {0, 2}, { -1, 1}, { -2, 0}, { -1, -1}, {0, -2}
-};
-
-#ifdef _SAD_STAT
-uint32 num_MB = 0;
-uint32 num_cand = 0;
-#endif
-
-/************************************************************************/
-#define TH_INTER_2 100 /* temporary for now */
-
-//#define FIXED_INTERPRED_MODE AVC_P16
-#define FIXED_REF_IDX 0
-#define FIXED_MVX 0
-#define FIXED_MVY 0
-
-// only use when AVC_P8 or AVC_P8ref0
-#define FIXED_SUBMB_MODE AVC_4x4
-/*************************************************************************/
-
-/* Initialize arrays necessary for motion search */
-AVCEnc_Status InitMotionSearchModule(AVCHandle *avcHandle)
-{
- AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- int search_range = rateCtrl->mvRange;
- int number_of_subpel_positions = 4 * (2 * search_range + 3);
- int max_mv_bits, max_mvd;
- int temp_bits = 0;
- uint8 *mvbits;
- int bits, imax, imin, i;
- uint8* subpel_pred = (uint8*) encvid->subpel_pred; // all 16 sub-pel positions
-
-
- while (number_of_subpel_positions > 0)
- {
- temp_bits++;
- number_of_subpel_positions >>= 1;
- }
-
- max_mv_bits = 3 + 2 * temp_bits;
- max_mvd = (1 << (max_mv_bits >> 1)) - 1;
-
- encvid->mvbits_array = (uint8*) avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
- sizeof(uint8) * (2 * max_mvd + 1), DEFAULT_ATTR);
-
- if (encvid->mvbits_array == NULL)
- {
- return AVCENC_MEMORY_FAIL;
- }
-
- mvbits = encvid->mvbits = encvid->mvbits_array + max_mvd;
-
- mvbits[0] = 1;
- for (bits = 3; bits <= max_mv_bits; bits += 2)
- {
- imax = 1 << (bits >> 1);
- imin = imax >> 1;
-
- for (i = imin; i < imax; i++) mvbits[-i] = mvbits[i] = bits;
- }
-
- /* initialize half-pel search */
- encvid->hpel_cand[0] = subpel_pred + REF_CENTER;
- encvid->hpel_cand[1] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1 ;
- encvid->hpel_cand[2] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1;
- encvid->hpel_cand[3] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
- encvid->hpel_cand[4] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
- encvid->hpel_cand[5] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 25;
- encvid->hpel_cand[6] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
- encvid->hpel_cand[7] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
- encvid->hpel_cand[8] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
-
- /* For quarter-pel interpolation around best half-pel result */
-
- encvid->bilin_base[0][0] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
- encvid->bilin_base[0][1] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1;
- encvid->bilin_base[0][2] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
- encvid->bilin_base[0][3] = subpel_pred + REF_CENTER;
-
-
- encvid->bilin_base[1][0] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE;
- encvid->bilin_base[1][1] = subpel_pred + REF_CENTER - 24;
- encvid->bilin_base[1][2] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
- encvid->bilin_base[1][3] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1;
-
- encvid->bilin_base[2][0] = subpel_pred + REF_CENTER - 24;
- encvid->bilin_base[2][1] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1;
- encvid->bilin_base[2][2] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1;
- encvid->bilin_base[2][3] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1;
-
- encvid->bilin_base[3][0] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1;
- encvid->bilin_base[3][1] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1;
- encvid->bilin_base[3][2] = subpel_pred + REF_CENTER;
- encvid->bilin_base[3][3] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
-
- encvid->bilin_base[4][0] = subpel_pred + REF_CENTER;
- encvid->bilin_base[4][1] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
- encvid->bilin_base[4][2] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 25;
- encvid->bilin_base[4][3] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
-
- encvid->bilin_base[5][0] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
- encvid->bilin_base[5][1] = subpel_pred + REF_CENTER;
- encvid->bilin_base[5][2] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
- encvid->bilin_base[5][3] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 25;
-
- encvid->bilin_base[6][0] = subpel_pred + REF_CENTER - 1;
- encvid->bilin_base[6][1] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
- encvid->bilin_base[6][2] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 24;
- encvid->bilin_base[6][3] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
-
- encvid->bilin_base[7][0] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE;
- encvid->bilin_base[7][1] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
- encvid->bilin_base[7][2] = subpel_pred + REF_CENTER - 1;
- encvid->bilin_base[7][3] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
-
- encvid->bilin_base[8][0] = subpel_pred + REF_CENTER - 25;
- encvid->bilin_base[8][1] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE;
- encvid->bilin_base[8][2] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE;
- encvid->bilin_base[8][3] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
-
-
- return AVCENC_SUCCESS;
-}
-
-/* Clean-up memory */
-void CleanMotionSearchModule(AVCHandle *avcHandle)
-{
- AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
-
- if (encvid->mvbits_array)
- {
- avcHandle->CBAVC_Free(avcHandle->userData, encvid->mvbits_array);
- encvid->mvbits = NULL;
- }
-
- return ;
-}
-
-
-bool IntraDecisionABE(int *min_cost, uint8 *cur, int pitch, bool ave)
-{
- int j;
- uint8 *out;
- int temp, SBE;
- OsclFloat ABE;
- bool intra = true;
-
- SBE = 0;
- /* top neighbor */
- out = cur - pitch;
- for (j = 0; j < 16; j++)
- {
- temp = out[j] - cur[j];
- SBE += ((temp >= 0) ? temp : -temp);
- }
-
- /* left neighbor */
- out = cur - 1;
- out -= pitch;
- cur -= pitch;
- for (j = 0; j < 16; j++)
- {
- temp = *(out += pitch) - *(cur += pitch);
- SBE += ((temp >= 0) ? temp : -temp);
- }
-
- /* compare mincost/384 and SBE/64 */
- ABE = SBE / 32.0; //ABE = SBE/64.0; //
- if (ABE >= *min_cost / 256.0) //if( ABE*0.8 >= min_cost/384.0) //
- {
- intra = false; // no possibility of intra, just use inter
- }
- else
- {
- if (ave == true)
- {
- *min_cost = (*min_cost + (int)(SBE * 8)) >> 1; // possibility of intra, averaging the cost
- }
- else
- {
- *min_cost = (int)(SBE * 8);
- }
- }
-
- return intra;
-}
-
-/******* main function for macroblock prediction for the entire frame ***/
-/* if turns out to be IDR frame, set video->nal_unit_type to AVC_NALTYPE_IDR */
-void AVCMotionEstimation(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- int slice_type = video->slice_type;
- AVCFrameIO *currInput = encvid->currInput;
- AVCPictureData *refPic = video->RefPicList0[0];
- int i, j, k;
- int mbwidth = video->PicWidthInMbs;
- int mbheight = video->PicHeightInMbs;
- int totalMB = video->PicSizeInMbs;
- int pitch = currInput->pitch;
- AVCMacroblock *currMB, *mblock = video->mblock;
- AVCMV *mot_mb_16x16, *mot16x16 = encvid->mot16x16;
- // AVCMV *mot_mb_16x8, *mot_mb_8x16, *mot_mb_8x8, etc;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- uint8 *intraSearch = encvid->intraSearch;
- uint FS_en = encvid->fullsearch_enable;
-
- int NumIntraSearch, start_i, numLoop, incr_i;
- int mbnum, offset;
- uint8 *cur, *best_cand[5];
- int totalSAD = 0; /* average SAD for rate control */
- int type_pred;
- int abe_cost;
-
-#ifdef HTFM
- /***** HYPOTHESIS TESTING ********/ /* 2/28/01 */
- int collect = 0;
- HTFM_Stat htfm_stat;
- double newvar[16];
- double exp_lamda[15];
- /*********************************/
-#endif
- int hp_guess = 0;
- uint32 mv_uint32;
-
- offset = 0;
-
- if (slice_type == AVC_I_SLICE)
- {
- /* cannot do I16 prediction here because it needs full decoding. */
- for (i = 0; i < totalMB; i++)
- {
- encvid->min_cost[i] = 0x7FFFFFFF; /* max value for int */
- }
-
- memset(intraSearch, 1, sizeof(uint8)*totalMB);
-
- encvid->firstIntraRefreshMBIndx = 0; /* reset this */
-
- return ;
- }
- else // P_SLICE
- {
- for (i = 0; i < totalMB; i++)
- {
- mblock[i].mb_intra = 0;
- }
- memset(intraSearch, 1, sizeof(uint8)*totalMB);
- }
-
- if (refPic->padded == 0)
- {
- AVCPaddingEdge(refPic);
- refPic->padded = 1;
- }
- /* Random INTRA update */
- if (rateCtrl->intraMBRate)
- {
- AVCRasterIntraUpdate(encvid, mblock, totalMB, rateCtrl->intraMBRate);
- }
-
- encvid->sad_extra_info = NULL;
-#ifdef HTFM
- /***** HYPOTHESIS TESTING ********/
- InitHTFM(video, &htfm_stat, newvar, &collect);
- /*********************************/
-#endif
-
- if ((rateCtrl->scdEnable == 1)
- && ((rateCtrl->frame_rate < 5.0) || (video->sliceHdr->frame_num > MIN_GOP)))
- /* do not try to detect a new scene if low frame rate and too close to previous I-frame */
- {
- incr_i = 2;
- numLoop = 2;
- start_i = 1;
- type_pred = 0; /* for initial candidate selection */
- }
- else
- {
- incr_i = 1;
- numLoop = 1;
- start_i = 0;
- type_pred = 2;
- }
-
- /* First pass, loop thru half the macroblock */
- /* determine scene change */
- /* Second pass, for the rest of macroblocks */
- NumIntraSearch = 0; // to be intra searched in the encoding loop.
- while (numLoop--)
- {
- for (j = 0; j < mbheight; j++)
- {
- if (incr_i > 1)
- start_i = (start_i == 0 ? 1 : 0) ; /* toggle 0 and 1 */
-
- offset = pitch * (j << 4) + (start_i << 4);
-
- mbnum = j * mbwidth + start_i;
-
- for (i = start_i; i < mbwidth; i += incr_i)
- {
- video->mbNum = mbnum;
- video->currMB = currMB = mblock + mbnum;
- mot_mb_16x16 = mot16x16 + mbnum;
-
- cur = currInput->YCbCr[0] + offset;
-
- if (currMB->mb_intra == 0) /* for INTER mode */
- {
-#if defined(HTFM)
- HTFMPrepareCurMB_AVC(encvid, &htfm_stat, cur, pitch);
-#else
- AVCPrepareCurMB(encvid, cur, pitch);
-#endif
- /************************************************************/
- /******** full-pel 1MV search **********************/
-
- AVCMBMotionSearch(encvid, cur, best_cand, i << 4, j << 4, type_pred,
- FS_en, &hp_guess);
-
- abe_cost = encvid->min_cost[mbnum] = mot_mb_16x16->sad;
-
- /* set mbMode and MVs */
- currMB->mbMode = AVC_P16;
- currMB->MBPartPredMode[0][0] = AVC_Pred_L0;
- mv_uint32 = ((mot_mb_16x16->y) << 16) | ((mot_mb_16x16->x) & 0xffff);
- for (k = 0; k < 32; k += 2)
- {
- currMB->mvL0[k>>1] = mv_uint32;
- }
-
- /* make a decision whether it should be tested for intra or not */
- if (i != mbwidth - 1 && j != mbheight - 1 && i != 0 && j != 0)
- {
- if (false == IntraDecisionABE(&abe_cost, cur, pitch, true))
- {
- intraSearch[mbnum] = 0;
- }
- else
- {
- NumIntraSearch++;
- rateCtrl->MADofMB[mbnum] = abe_cost;
- }
- }
- else // boundary MBs, always do intra search
- {
- NumIntraSearch++;
- }
-
- totalSAD += (int) rateCtrl->MADofMB[mbnum];//mot_mb_16x16->sad;
- }
- else /* INTRA update, use for prediction */
- {
- mot_mb_16x16[0].x = mot_mb_16x16[0].y = 0;
-
- /* reset all other MVs to zero */
- /* mot_mb_16x8, mot_mb_8x16, mot_mb_8x8, etc. */
- abe_cost = encvid->min_cost[mbnum] = 0x7FFFFFFF; /* max value for int */
-
- if (i != mbwidth - 1 && j != mbheight - 1 && i != 0 && j != 0)
- {
- IntraDecisionABE(&abe_cost, cur, pitch, false);
-
- rateCtrl->MADofMB[mbnum] = abe_cost;
- totalSAD += abe_cost;
- }
-
- NumIntraSearch++ ;
- /* cannot do I16 prediction here because it needs full decoding. */
- // intraSearch[mbnum] = 1;
-
- }
-
- mbnum += incr_i;
- offset += (incr_i << 4);
-
- } /* for i */
- } /* for j */
-
- /* since we cannot do intra/inter decision here, the SCD has to be
- based on other criteria such as motion vectors coherency or the SAD */
- if (incr_i > 1 && numLoop) /* scene change on and first loop */
- {
- //if(NumIntraSearch > ((totalMB>>3)<<1) + (totalMB>>3)) /* 75% of 50%MBs */
- if (NumIntraSearch*99 > (48*totalMB)) /* 20% of 50%MBs */
- /* need to do more investigation about this threshold since the NumIntraSearch
- only show potential intra MBs, not the actual one */
- {
- /* we can choose to just encode I_SLICE without IDR */
- //video->nal_unit_type = AVC_NALTYPE_IDR;
- video->nal_unit_type = AVC_NALTYPE_SLICE;
- video->sliceHdr->slice_type = AVC_I_ALL_SLICE;
- video->slice_type = AVC_I_SLICE;
- memset(intraSearch, 1, sizeof(uint8)*totalMB);
- i = totalMB;
- while (i--)
- {
- mblock[i].mb_intra = 1;
- encvid->min_cost[i] = 0x7FFFFFFF; /* max value for int */
- }
-
- rateCtrl->totalSAD = totalSAD * 2; /* SAD */
-
- return ;
- }
- }
- /******** no scene change, continue motion search **********************/
- start_i = 0;
- type_pred++; /* second pass */
- }
-
- rateCtrl->totalSAD = totalSAD; /* SAD */
-
-#ifdef HTFM
- /***** HYPOTHESIS TESTING ********/
- if (collect)
- {
- collect = 0;
- UpdateHTFM(encvid, newvar, exp_lamda, &htfm_stat);
- }
- /*********************************/
-#endif
-
- return ;
-}
-
-/*=====================================================================
- Function: PaddingEdge
- Date: 09/16/2000
- Purpose: Pad edge of a Vop
-=====================================================================*/
-
-void AVCPaddingEdge(AVCPictureData *refPic)
-{
- uint8 *src, *dst;
- int i;
- int pitch, width, height;
- uint32 temp1, temp2;
-
- width = refPic->width;
- height = refPic->height;
- pitch = refPic->pitch;
-
- /* pad top */
- src = refPic->Sl;
-
- temp1 = *src; /* top-left corner */
- temp2 = src[width-1]; /* top-right corner */
- temp1 |= (temp1 << 8);
- temp1 |= (temp1 << 16);
- temp2 |= (temp2 << 8);
- temp2 |= (temp2 << 16);
-
- dst = src - (pitch << 4);
-
- *((uint32*)(dst - 16)) = temp1;
- *((uint32*)(dst - 12)) = temp1;
- *((uint32*)(dst - 8)) = temp1;
- *((uint32*)(dst - 4)) = temp1;
-
- memcpy(dst, src, width);
-
- *((uint32*)(dst += width)) = temp2;
- *((uint32*)(dst + 4)) = temp2;
- *((uint32*)(dst + 8)) = temp2;
- *((uint32*)(dst + 12)) = temp2;
-
- dst = dst - width - 16;
-
- i = 15;
- while (i--)
- {
- memcpy(dst + pitch, dst, pitch);
- dst += pitch;
- }
-
- /* pad sides */
- dst += (pitch + 16);
- src = dst;
- i = height;
- while (i--)
- {
- temp1 = *src;
- temp2 = src[width-1];
- temp1 |= (temp1 << 8);
- temp1 |= (temp1 << 16);
- temp2 |= (temp2 << 8);
- temp2 |= (temp2 << 16);
-
- *((uint32*)(dst - 16)) = temp1;
- *((uint32*)(dst - 12)) = temp1;
- *((uint32*)(dst - 8)) = temp1;
- *((uint32*)(dst - 4)) = temp1;
-
- *((uint32*)(dst += width)) = temp2;
- *((uint32*)(dst + 4)) = temp2;
- *((uint32*)(dst + 8)) = temp2;
- *((uint32*)(dst + 12)) = temp2;
-
- src += pitch;
- dst = src;
- }
-
- /* pad bottom */
- dst -= 16;
- i = 16;
- while (i--)
- {
- memcpy(dst, dst - pitch, pitch);
- dst += pitch;
- }
-
-
- return ;
-}
-
-/*===========================================================================
- Function: AVCRasterIntraUpdate
- Date: 2/26/01
- Purpose: To raster-scan assign INTRA-update .
- N macroblocks are updated (also was programmable).
-===========================================================================*/
-void AVCRasterIntraUpdate(AVCEncObject *encvid, AVCMacroblock *mblock, int totalMB, int numRefresh)
-{
- int indx, i;
-
- indx = encvid->firstIntraRefreshMBIndx;
- for (i = 0; i < numRefresh && indx < totalMB; i++)
- {
- (mblock + indx)->mb_intra = 1;
- encvid->intraSearch[indx++] = 1;
- }
-
- /* if read the end of frame, reset and loop around */
- if (indx >= totalMB - 1)
- {
- indx = 0;
- while (i < numRefresh && indx < totalMB)
- {
- (mblock + indx)->mb_intra = 1;
- encvid->intraSearch[indx++] = 1;
- i++;
- }
- }
-
- encvid->firstIntraRefreshMBIndx = indx; /* update with a new value */
-
- return ;
-}
-
-
-#ifdef HTFM
-void InitHTFM(VideoEncData *encvid, HTFM_Stat *htfm_stat, double *newvar, int *collect)
-{
- AVCCommonObj *video = encvid->common;
- int i;
- int lx = video->currPic->width; // padding
- int lx2 = lx << 1;
- int lx3 = lx2 + lx;
- int rx = video->currPic->pitch;
- int rx2 = rx << 1;
- int rx3 = rx2 + rx;
-
- int *offset, *offset2;
-
- /* 4/11/01, collect data every 30 frames, doesn't have to be base layer */
- if (((int)video->sliceHdr->frame_num) % 30 == 1)
- {
-
- *collect = 1;
-
- htfm_stat->countbreak = 0;
- htfm_stat->abs_dif_mad_avg = 0;
-
- for (i = 0; i < 16; i++)
- {
- newvar[i] = 0.0;
- }
-// encvid->functionPointer->SAD_MB_PADDING = &SAD_MB_PADDING_HTFM_Collect;
- encvid->functionPointer->SAD_Macroblock = &SAD_MB_HTFM_Collect;
- encvid->functionPointer->SAD_MB_HalfPel[0] = NULL;
- encvid->functionPointer->SAD_MB_HalfPel[1] = &SAD_MB_HP_HTFM_Collectxh;
- encvid->functionPointer->SAD_MB_HalfPel[2] = &SAD_MB_HP_HTFM_Collectyh;
- encvid->functionPointer->SAD_MB_HalfPel[3] = &SAD_MB_HP_HTFM_Collectxhyh;
- encvid->sad_extra_info = (void*)(htfm_stat);
- offset = htfm_stat->offsetArray;
- offset2 = htfm_stat->offsetRef;
- }
- else
- {
-// encvid->functionPointer->SAD_MB_PADDING = &SAD_MB_PADDING_HTFM;
- encvid->functionPointer->SAD_Macroblock = &SAD_MB_HTFM;
- encvid->functionPointer->SAD_MB_HalfPel[0] = NULL;
- encvid->functionPointer->SAD_MB_HalfPel[1] = &SAD_MB_HP_HTFMxh;
- encvid->functionPointer->SAD_MB_HalfPel[2] = &SAD_MB_HP_HTFMyh;
- encvid->functionPointer->SAD_MB_HalfPel[3] = &SAD_MB_HP_HTFMxhyh;
- encvid->sad_extra_info = (void*)(encvid->nrmlz_th);
- offset = encvid->nrmlz_th + 16;
- offset2 = encvid->nrmlz_th + 32;
- }
-
- offset[0] = 0;
- offset[1] = lx2 + 2;
- offset[2] = 2;
- offset[3] = lx2;
- offset[4] = lx + 1;
- offset[5] = lx3 + 3;
- offset[6] = lx + 3;
- offset[7] = lx3 + 1;
- offset[8] = lx;
- offset[9] = lx3 + 2;
- offset[10] = lx3 ;
- offset[11] = lx + 2 ;
- offset[12] = 1;
- offset[13] = lx2 + 3;
- offset[14] = lx2 + 1;
- offset[15] = 3;
-
- offset2[0] = 0;
- offset2[1] = rx2 + 2;
- offset2[2] = 2;
- offset2[3] = rx2;
- offset2[4] = rx + 1;
- offset2[5] = rx3 + 3;
- offset2[6] = rx + 3;
- offset2[7] = rx3 + 1;
- offset2[8] = rx;
- offset2[9] = rx3 + 2;
- offset2[10] = rx3 ;
- offset2[11] = rx + 2 ;
- offset2[12] = 1;
- offset2[13] = rx2 + 3;
- offset2[14] = rx2 + 1;
- offset2[15] = 3;
-
- return ;
-}
-
-void UpdateHTFM(AVCEncObject *encvid, double *newvar, double *exp_lamda, HTFM_Stat *htfm_stat)
-{
- if (htfm_stat->countbreak == 0)
- htfm_stat->countbreak = 1;
-
- newvar[0] = (double)(htfm_stat->abs_dif_mad_avg) / (htfm_stat->countbreak * 16.);
-
- if (newvar[0] < 0.001)
- {
- newvar[0] = 0.001; /* to prevent floating overflow */
- }
- exp_lamda[0] = 1 / (newvar[0] * 1.4142136);
- exp_lamda[1] = exp_lamda[0] * 1.5825;
- exp_lamda[2] = exp_lamda[0] * 2.1750;
- exp_lamda[3] = exp_lamda[0] * 3.5065;
- exp_lamda[4] = exp_lamda[0] * 3.1436;
- exp_lamda[5] = exp_lamda[0] * 3.5315;
- exp_lamda[6] = exp_lamda[0] * 3.7449;
- exp_lamda[7] = exp_lamda[0] * 4.5854;
- exp_lamda[8] = exp_lamda[0] * 4.6191;
- exp_lamda[9] = exp_lamda[0] * 5.4041;
- exp_lamda[10] = exp_lamda[0] * 6.5974;
- exp_lamda[11] = exp_lamda[0] * 10.5341;
- exp_lamda[12] = exp_lamda[0] * 10.0719;
- exp_lamda[13] = exp_lamda[0] * 12.0516;
- exp_lamda[14] = exp_lamda[0] * 15.4552;
-
- CalcThreshold(HTFM_Pf, exp_lamda, encvid->nrmlz_th);
- return ;
-}
-
-
-void CalcThreshold(double pf, double exp_lamda[], int nrmlz_th[])
-{
- int i;
- double temp[15];
- // printf("\nLamda: ");
-
- /* parametric PREMODELling */
- for (i = 0; i < 15; i++)
- {
- // printf("%g ",exp_lamda[i]);
- if (pf < 0.5)
- temp[i] = 1 / exp_lamda[i] * M4VENC_LOG(2 * pf);
- else
- temp[i] = -1 / exp_lamda[i] * M4VENC_LOG(2 * (1 - pf));
- }
-
- nrmlz_th[15] = 0;
- for (i = 0; i < 15; i++) /* scale upto no.pixels */
- nrmlz_th[i] = (int)(temp[i] * ((i + 1) << 4) + 0.5);
-
- return ;
-}
-
-void HTFMPrepareCurMB_AVC(AVCEncObject *encvid, HTFM_Stat *htfm_stat, uint8 *cur, int pitch)
-{
- AVCCommonObj *video = encvid->common;
- uint32 *htfmMB = (uint32*)(encvid->currYMB);
- uint8 *ptr, byte;
- int *offset;
- int i;
- uint32 word;
-
- if (((int)video->sliceHdr->frame_num) % 30 == 1)
- {
- offset = htfm_stat->offsetArray;
- }
- else
- {
- offset = encvid->nrmlz_th + 16;
- }
-
- for (i = 0; i < 16; i++)
- {
- ptr = cur + offset[i];
- word = ptr[0];
- byte = ptr[4];
- word |= (byte << 8);
- byte = ptr[8];
- word |= (byte << 16);
- byte = ptr[12];
- word |= (byte << 24);
- *htfmMB++ = word;
-
- word = *(ptr += (pitch << 2));
- byte = ptr[4];
- word |= (byte << 8);
- byte = ptr[8];
- word |= (byte << 16);
- byte = ptr[12];
- word |= (byte << 24);
- *htfmMB++ = word;
-
- word = *(ptr += (pitch << 2));
- byte = ptr[4];
- word |= (byte << 8);
- byte = ptr[8];
- word |= (byte << 16);
- byte = ptr[12];
- word |= (byte << 24);
- *htfmMB++ = word;
-
- word = *(ptr += (pitch << 2));
- byte = ptr[4];
- word |= (byte << 8);
- byte = ptr[8];
- word |= (byte << 16);
- byte = ptr[12];
- word |= (byte << 24);
- *htfmMB++ = word;
- }
-
- return ;
-}
-
-
-#endif // HTFM
-
-void AVCPrepareCurMB(AVCEncObject *encvid, uint8 *cur, int pitch)
-{
- void* tmp = (void*)(encvid->currYMB);
- uint32 *currYMB = (uint32*) tmp;
- int i;
-
- cur -= pitch;
-
- for (i = 0; i < 16; i++)
- {
- *currYMB++ = *((uint32*)(cur += pitch));
- *currYMB++ = *((uint32*)(cur + 4));
- *currYMB++ = *((uint32*)(cur + 8));
- *currYMB++ = *((uint32*)(cur + 12));
- }
-
- return ;
-}
-
-#ifdef FIXED_INTERPRED_MODE
-
-/* due to the complexity of the predicted motion vector, we may not decide to skip
-a macroblock here just yet. */
-/* We will find the best motion vector and the best intra prediction mode for each block. */
-/* output are
- currMB->NumMbPart, currMB->MbPartWidth, currMB->MbPartHeight,
- currMB->NumSubMbPart[], currMB->SubMbPartWidth[], currMB->SubMbPartHeight,
- currMB->MBPartPredMode[][] (L0 or L1 or BiPred)
- currMB->RefIdx[], currMB->ref_idx_L0[],
- currMB->mvL0[], currMB->mvL1[]
- */
-
-AVCEnc_Status AVCMBMotionSearch(AVCEncObject *encvid, AVCMacroblock *currMB, int mbNum,
- int num_pass)
-{
- AVCCommonObj *video = encvid->common;
- int mbPartIdx, subMbPartIdx;
- int16 *mv;
- int i;
- int SubMbPartHeight, SubMbPartWidth, NumSubMbPart;
-
- /* assign value to currMB->MBPartPredMode[][x],subMbMode[],NumSubMbPart[],SubMbPartWidth[],SubMbPartHeight[] */
-
- currMB->mbMode = FIXED_INTERPRED_MODE;
- currMB->mb_intra = 0;
-
- if (currMB->mbMode == AVC_P16)
- {
- currMB->NumMbPart = 1;
- currMB->MbPartWidth = 16;
- currMB->MbPartHeight = 16;
- currMB->SubMbPartHeight[0] = 16;
- currMB->SubMbPartWidth[0] = 16;
- currMB->NumSubMbPart[0] = 1;
- }
- else if (currMB->mbMode == AVC_P16x8)
- {
- currMB->NumMbPart = 2;
- currMB->MbPartWidth = 16;
- currMB->MbPartHeight = 8;
- for (i = 0; i < 2; i++)
- {
- currMB->SubMbPartWidth[i] = 16;
- currMB->SubMbPartHeight[i] = 8;
- currMB->NumSubMbPart[i] = 1;
- }
- }
- else if (currMB->mbMode == AVC_P8x16)
- {
- currMB->NumMbPart = 2;
- currMB->MbPartWidth = 8;
- currMB->MbPartHeight = 16;
- for (i = 0; i < 2; i++)
- {
- currMB->SubMbPartWidth[i] = 8;
- currMB->SubMbPartHeight[i] = 16;
- currMB->NumSubMbPart[i] = 1;
- }
- }
- else if (currMB->mbMode == AVC_P8 || currMB->mbMode == AVC_P8ref0)
- {
- currMB->NumMbPart = 4;
- currMB->MbPartWidth = 8;
- currMB->MbPartHeight = 8;
- if (FIXED_SUBMB_MODE == AVC_8x8)
- {
- SubMbPartHeight = 8;
- SubMbPartWidth = 8;
- NumSubMbPart = 1;
- }
- else if (FIXED_SUBMB_MODE == AVC_8x4)
- {
- SubMbPartHeight = 4;
- SubMbPartWidth = 8;
- NumSubMbPart = 2;
- }
- else if (FIXED_SUBMB_MODE == AVC_4x8)
- {
- SubMbPartHeight = 8;
- SubMbPartWidth = 4;
- NumSubMbPart = 2;
- }
- else if (FIXED_SUBMB_MODE == AVC_4x4)
- {
- SubMbPartHeight = 4;
- SubMbPartWidth = 4;
- NumSubMbPart = 4;
- }
-
- for (i = 0; i < 4; i++)
- {
- currMB->subMbMode[i] = FIXED_SUBMB_MODE;
- currMB->SubMbPartHeight[i] = SubMbPartHeight;
- currMB->SubMbPartWidth[i] = SubMbPartWidth;
- currMB->NumSubMbPart[i] = NumSubMbPart;
- }
- }
- else /* it's probably intra mode */
- {
- return AVCENC_SUCCESS;
- }
-
- for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++)
- {
- currMB->MBPartPredMode[mbPartIdx][0] = AVC_Pred_L0;
- currMB->ref_idx_L0[mbPartIdx] = FIXED_REF_IDX;
- currMB->RefIdx[mbPartIdx] = video->RefPicList0[FIXED_REF_IDX]->RefIdx;
-
- for (subMbPartIdx = 0; subMbPartIdx < 4; subMbPartIdx++)
- {
- mv = (int16*)(currMB->mvL0 + (mbPartIdx << 2) + subMbPartIdx);
-
- *mv++ = FIXED_MVX;
- *mv = FIXED_MVY;
- }
- }
-
- encvid->min_cost = 0;
-
- return AVCENC_SUCCESS;
-}
-
-#else /* perform the search */
-
-/* This option #1 search is very similar to PV's MPEG4 motion search algorithm.
- The search is done in hierarchical manner from 16x16 MB down to smaller and smaller
- partition. At each level, a decision can be made to stop the search if the expected
- prediction gain is not worth the computation. The decision can also be made at the finest
- level for more fullsearch-like behavior with the price of heavier computation. */
-void AVCMBMotionSearch(AVCEncObject *encvid, uint8 *cur, uint8 *best_cand[],
- int i0, int j0, int type_pred, int FS_en, int *hp_guess)
-{
- AVCCommonObj *video = encvid->common;
- AVCPictureData *currPic = video->currPic;
- AVCSeqParamSet *currSPS = video->currSeqParams;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- AVCMacroblock *currMB = video->currMB;
- uint8 *ref, *cand, *ncand;
- void *extra_info = encvid->sad_extra_info;
- int mbnum = video->mbNum;
- int width = currPic->width; /* 6/12/01, must be multiple of 16 */
- int height = currPic->height;
- AVCMV *mot16x16 = encvid->mot16x16;
- int (*SAD_Macroblock)(uint8*, uint8*, int, void*) = encvid->functionPointer->SAD_Macroblock;
-
- int range = rateCtrl->mvRange;
-
- int lx = currPic->pitch; /* padding */
- int i, j, imin, jmin, ilow, ihigh, jlow, jhigh;
- int d, dmin, dn[9];
- int k;
- int mvx[5], mvy[5];
- int num_can, center_again;
- int last_loc, new_loc = 0;
- int step, max_step = range >> 1;
- int next;
-
- int cmvx, cmvy; /* estimated predicted MV */
- int lev_idx;
- int lambda_motion = encvid->lambda_motion;
- uint8 *mvbits = encvid->mvbits;
- int mvshift = 2;
- int mvcost;
-
- int min_sad = 65535;
-
- ref = video->RefPicList0[DEFAULT_REF_IDX]->Sl; /* origin of actual frame */
-
- /* have to initialize these params, necessary for interprediction part */
- currMB->NumMbPart = 1;
- currMB->SubMbPartHeight[0] = 16;
- currMB->SubMbPartWidth[0] = 16;
- currMB->NumSubMbPart[0] = 1;
- currMB->ref_idx_L0[0] = currMB->ref_idx_L0[1] =
- currMB->ref_idx_L0[2] = currMB->ref_idx_L0[3] = DEFAULT_REF_IDX;
- currMB->ref_idx_L1[0] = currMB->ref_idx_L1[1] =
- currMB->ref_idx_L1[2] = currMB->ref_idx_L1[3] = DEFAULT_REF_IDX;
- currMB->RefIdx[0] = currMB->RefIdx[1] =
- currMB->RefIdx[2] = currMB->RefIdx[3] = video->RefPicList0[DEFAULT_REF_IDX]->RefIdx;
-
- cur = encvid->currYMB; /* use smaller memory space for current MB */
-
- /* find limit of the search (adjusting search range)*/
- lev_idx = mapLev2Idx[currSPS->level_idc];
-
- /* we can make this part dynamic based on previous statistics */
- ilow = i0 - range;
- if (i0 - ilow > 2047) /* clip to conform with the standard */
- {
- ilow = i0 - 2047;
- }
- if (ilow < -13) // change it from -15 to -13 because of 6-tap filter needs extra 2 lines.
- {
- ilow = -13;
- }
-
- ihigh = i0 + range - 1;
- if (ihigh - i0 > 2047) /* clip to conform with the standard */
- {
- ihigh = i0 + 2047;
- }
- if (ihigh > width - 3)
- {
- ihigh = width - 3; // change from width-1 to width-3 for the same reason as above
- }
-
- jlow = j0 - range;
- if (j0 - jlow > MaxVmvR[lev_idx] - 1) /* clip to conform with the standard */
- {
- jlow = j0 - MaxVmvR[lev_idx] + 1;
- }
- if (jlow < -13) // same reason as above
- {
- jlow = -13;
- }
-
- jhigh = j0 + range - 1;
- if (jhigh - j0 > MaxVmvR[lev_idx] - 1) /* clip to conform with the standard */
- {
- jhigh = j0 + MaxVmvR[lev_idx] - 1;
- }
- if (jhigh > height - 3) // same reason as above
- {
- jhigh = height - 3;
- }
-
- /* find initial motion vector & predicted MV*/
- AVCCandidateSelection(mvx, mvy, &num_can, i0 >> 4, j0 >> 4, encvid, type_pred, &cmvx, &cmvy);
-
- imin = i0;
- jmin = j0; /* needed for fullsearch */
- ncand = ref + i0 + j0 * lx;
-
- /* for first row of MB, fullsearch can be used */
- if (FS_en)
- {
- *hp_guess = 0; /* no guess for fast half-pel */
-
- dmin = AVCFullSearch(encvid, ref, cur, &imin, &jmin, ilow, ihigh, jlow, jhigh, cmvx, cmvy);
-
- ncand = ref + imin + jmin * lx;
- }
- else
- { /* fullsearch the top row to only upto (0,3) MB */
- /* upto 30% complexity saving with the same complexity */
- if (video->PrevRefFrameNum == 0 && j0 == 0 && i0 <= 64 && type_pred != 1)
- {
- *hp_guess = 0; /* no guess for fast half-pel */
- dmin = AVCFullSearch(encvid, ref, cur, &imin, &jmin, ilow, ihigh, jlow, jhigh, cmvx, cmvy);
- ncand = ref + imin + jmin * lx;
- }
- else
- {
- /************** initialize candidate **************************/
-
- dmin = 65535;
-
- /* check if all are equal */
- if (num_can == ALL_CAND_EQUAL)
- {
- i = i0 + mvx[0];
- j = j0 + mvy[0];
-
- if (i >= ilow && i <= ihigh && j >= jlow && j <= jhigh)
- {
- cand = ref + i + j * lx;
-
- d = (*SAD_Macroblock)(cand, cur, (dmin << 16) | lx, extra_info);
- mvcost = MV_COST(lambda_motion, mvshift, i - i0, j - j0, cmvx, cmvy);
- d += mvcost;
-
- if (d < dmin)
- {
- dmin = d;
- imin = i;
- jmin = j;
- ncand = cand;
- min_sad = d - mvcost; // for rate control
- }
- }
- }
- else
- {
- /************** evaluate unique candidates **********************/
- for (k = 0; k < num_can; k++)
- {
- i = i0 + mvx[k];
- j = j0 + mvy[k];
-
- if (i >= ilow && i <= ihigh && j >= jlow && j <= jhigh)
- {
- cand = ref + i + j * lx;
- d = (*SAD_Macroblock)(cand, cur, (dmin << 16) | lx, extra_info);
- mvcost = MV_COST(lambda_motion, mvshift, i - i0, j - j0, cmvx, cmvy);
- d += mvcost;
-
- if (d < dmin)
- {
- dmin = d;
- imin = i;
- jmin = j;
- ncand = cand;
- min_sad = d - mvcost; // for rate control
- }
- }
- }
- }
-
- /******************* local refinement ***************************/
- center_again = 0;
- last_loc = new_loc = 0;
- // ncand = ref + jmin*lx + imin; /* center of the search */
- step = 0;
- dn[0] = dmin;
- while (!center_again && step <= max_step)
- {
-
- AVCMoveNeighborSAD(dn, last_loc);
-
- center_again = 1;
- i = imin;
- j = jmin - 1;
- cand = ref + i + j * lx;
-
- /* starting from [0,-1] */
- /* spiral check one step at a time*/
- for (k = 2; k <= 8; k += 2)
- {
- if (!tab_exclude[last_loc][k]) /* exclude last step computation */
- { /* not already computed */
- if (i >= ilow && i <= ihigh && j >= jlow && j <= jhigh)
- {
- d = (*SAD_Macroblock)(cand, cur, (dmin << 16) | lx, extra_info);
- mvcost = MV_COST(lambda_motion, mvshift, i - i0, j - j0, cmvx, cmvy);
- d += mvcost;
-
- dn[k] = d; /* keep it for half pel use */
-
- if (d < dmin)
- {
- ncand = cand;
- dmin = d;
- imin = i;
- jmin = j;
- center_again = 0;
- new_loc = k;
- min_sad = d - mvcost; // for rate control
- }
- }
- }
- if (k == 8) /* end side search*/
- {
- if (!center_again)
- {
- k = -1; /* start diagonal search */
- cand -= lx;
- j--;
- }
- }
- else
- {
- next = refine_next[k][0];
- i += next;
- cand += next;
- next = refine_next[k][1];
- j += next;
- cand += lx * next;
- }
- }
- last_loc = new_loc;
- step ++;
- }
- if (!center_again)
- AVCMoveNeighborSAD(dn, last_loc);
-
- *hp_guess = AVCFindMin(dn);
-
- encvid->rateCtrl->MADofMB[mbnum] = min_sad / 256.0;
- }
- }
-
- mot16x16[mbnum].sad = dmin;
- mot16x16[mbnum].x = (imin - i0) << 2;
- mot16x16[mbnum].y = (jmin - j0) << 2;
- best_cand[0] = ncand;
-
- if (rateCtrl->subPelEnable) // always enable half-pel search
- {
- /* find half-pel resolution motion vector */
- min_sad = AVCFindHalfPelMB(encvid, cur, mot16x16 + mbnum, best_cand[0], i0, j0, *hp_guess, cmvx, cmvy);
-
- encvid->rateCtrl->MADofMB[mbnum] = min_sad / 256.0;
-
-
- if (encvid->best_qpel_pos == -1)
- {
- ncand = encvid->hpel_cand[encvid->best_hpel_pos];
- }
- else
- {
- ncand = encvid->qpel_cand[encvid->best_qpel_pos];
- }
- }
- else
- {
- encvid->rateCtrl->MADofMB[mbnum] = min_sad / 256.0;
- }
-
- /** do motion comp here for now */
- ref = currPic->Sl + i0 + j0 * lx;
- /* copy from the best result to current Picture */
- for (j = 0; j < 16; j++)
- {
- for (i = 0; i < 16; i++)
- {
- *ref++ = *ncand++;
- }
- ref += (lx - 16);
- ncand += 8;
- }
-
- return ;
-}
-
-#endif
-
-/*===============================================================================
- Function: AVCFullSearch
- Date: 09/16/2000
- Purpose: Perform full-search motion estimation over the range of search
- region in a spiral-outward manner.
- Input/Output: VideoEncData, current Vol, previou Vop, pointer to the left corner of
- current VOP, current coord (also output), boundaries.
-===============================================================================*/
-int AVCFullSearch(AVCEncObject *encvid, uint8 *prev, uint8 *cur,
- int *imin, int *jmin, int ilow, int ihigh, int jlow, int jhigh,
- int cmvx, int cmvy)
-{
- int range = encvid->rateCtrl->mvRange;
- AVCPictureData *currPic = encvid->common->currPic;
- uint8 *cand;
- int i, j, k, l;
- int d, dmin;
- int i0 = *imin; /* current position */
- int j0 = *jmin;
- int (*SAD_Macroblock)(uint8*, uint8*, int, void*) = encvid->functionPointer->SAD_Macroblock;
- void *extra_info = encvid->sad_extra_info;
- int lx = currPic->pitch; /* with padding */
-
- int offset = i0 + j0 * lx;
-
- int lambda_motion = encvid->lambda_motion;
- uint8 *mvbits = encvid->mvbits;
- int mvshift = 2;
- int mvcost;
- int min_sad;
-
- cand = prev + offset;
-
- dmin = (*SAD_Macroblock)(cand, cur, (65535 << 16) | lx, (void*)extra_info);
- mvcost = MV_COST(lambda_motion, mvshift, 0, 0, cmvx, cmvy);
- min_sad = dmin;
- dmin += mvcost;
-
- /* perform spiral search */
- for (k = 1; k <= range; k++)
- {
-
- i = i0 - k;
- j = j0 - k;
-
- cand = prev + i + j * lx;
-
- for (l = 0; l < 8*k; l++)
- {
- /* no need for boundary checking again */
- if (i >= ilow && i <= ihigh && j >= jlow && j <= jhigh)
- {
- d = (*SAD_Macroblock)(cand, cur, (dmin << 16) | lx, (void*)extra_info);
- mvcost = MV_COST(lambda_motion, mvshift, i - i0, j - j0, cmvx, cmvy);
- d += mvcost;
-
- if (d < dmin)
- {
- dmin = d;
- *imin = i;
- *jmin = j;
- min_sad = d - mvcost;
- }
- }
-
- if (l < (k << 1))
- {
- i++;
- cand++;
- }
- else if (l < (k << 2))
- {
- j++;
- cand += lx;
- }
- else if (l < ((k << 2) + (k << 1)))
- {
- i--;
- cand--;
- }
- else
- {
- j--;
- cand -= lx;
- }
- }
- }
-
- encvid->rateCtrl->MADofMB[encvid->common->mbNum] = (min_sad / 256.0); // for rate control
-
- return dmin;
-}
-
-/*===============================================================================
- Function: AVCCandidateSelection
- Date: 09/16/2000
- Purpose: Fill up the list of candidate using spatio-temporal correlation
- among neighboring blocks.
- Input/Output: type_pred = 0: first pass, 1: second pass, or no SCD
- Modified: , 09/23/01, get rid of redundant candidates before passing back.
- , 09/11/07, added return for modified predicted MV, this will be
- needed for both fast search and fullsearch.
-===============================================================================*/
-
-void AVCCandidateSelection(int *mvx, int *mvy, int *num_can, int imb, int jmb,
- AVCEncObject *encvid, int type_pred, int *cmvx, int *cmvy)
-{
- AVCCommonObj *video = encvid->common;
- AVCMV *mot16x16 = encvid->mot16x16;
- AVCMV *pmot;
- int mbnum = video->mbNum;
- int mbwidth = video->PicWidthInMbs;
- int mbheight = video->PicHeightInMbs;
- int i, j, same, num1;
-
- /* this part is for predicted MV */
- int pmvA_x = 0, pmvA_y = 0, pmvB_x = 0, pmvB_y = 0, pmvC_x = 0, pmvC_y = 0;
- int availA = 0, availB = 0, availC = 0;
-
- *num_can = 0;
-
- if (video->PrevRefFrameNum != 0) // previous frame is an IDR frame
- {
- /* Spatio-Temporal Candidate (five candidates) */
- if (type_pred == 0) /* first pass */
- {
- pmot = &mot16x16[mbnum]; /* same coordinate previous frame */
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- if (imb >= (mbwidth >> 1) && imb > 0) /*left neighbor previous frame */
- {
- pmot = &mot16x16[mbnum-1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- else if (imb + 1 < mbwidth) /*right neighbor previous frame */
- {
- pmot = &mot16x16[mbnum+1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
-
- if (jmb < mbheight - 1) /*bottom neighbor previous frame */
- {
- pmot = &mot16x16[mbnum+mbwidth];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- else if (jmb > 0) /*upper neighbor previous frame */
- {
- pmot = &mot16x16[mbnum-mbwidth];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
-
- if (imb > 0 && jmb > 0) /* upper-left neighbor current frame*/
- {
- pmot = &mot16x16[mbnum-mbwidth-1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (jmb > 0 && imb < mbheight - 1) /* upper right neighbor current frame*/
- {
- pmot = &mot16x16[mbnum-mbwidth+1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- }
- else /* second pass */
- /* original ST1 algorithm */
- {
- pmot = &mot16x16[mbnum]; /* same coordinate previous frame */
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
-
- if (imb > 0) /*left neighbor current frame */
- {
- pmot = &mot16x16[mbnum-1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (jmb > 0) /*upper neighbor current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (imb < mbwidth - 1) /*right neighbor previous frame */
- {
- pmot = &mot16x16[mbnum+1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (jmb < mbheight - 1) /*bottom neighbor previous frame */
- {
- pmot = &mot16x16[mbnum+mbwidth];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- }
-
- /* get predicted MV */
- if (imb > 0) /* get MV from left (A) neighbor either on current or previous frame */
- {
- availA = 1;
- pmot = &mot16x16[mbnum-1];
- pmvA_x = pmot->x;
- pmvA_y = pmot->y;
- }
-
- if (jmb > 0) /* get MV from top (B) neighbor either on current or previous frame */
- {
- availB = 1;
- pmot = &mot16x16[mbnum-mbwidth];
- pmvB_x = pmot->x;
- pmvB_y = pmot->y;
-
- availC = 1;
-
- if (imb < mbwidth - 1) /* get MV from top-right (C) neighbor of current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth+1];
- }
- else /* get MV from top-left (D) neighbor of current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth-1];
- }
- pmvC_x = pmot->x;
- pmvC_y = pmot->y;
- }
-
- }
- else /* only Spatial Candidate (four candidates)*/
- {
- if (type_pred == 0) /*first pass*/
- {
- if (imb > 1) /* neighbor two blocks away to the left */
- {
- pmot = &mot16x16[mbnum-2];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (imb > 0 && jmb > 0) /* upper-left neighbor */
- {
- pmot = &mot16x16[mbnum-mbwidth-1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (jmb > 0 && imb < mbheight - 1) /* upper right neighbor */
- {
- pmot = &mot16x16[mbnum-mbwidth+1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
-
- /* get predicted MV */
- if (imb > 1) /* get MV from 2nd left (A) neighbor either of current frame */
- {
- availA = 1;
- pmot = &mot16x16[mbnum-2];
- pmvA_x = pmot->x;
- pmvA_y = pmot->y;
- }
-
- if (jmb > 0 && imb > 0) /* get MV from top-left (B) neighbor of current frame */
- {
- availB = 1;
- pmot = &mot16x16[mbnum-mbwidth-1];
- pmvB_x = pmot->x;
- pmvB_y = pmot->y;
- }
-
- if (jmb > 0 && imb < mbwidth - 1)
- {
- availC = 1;
- pmot = &mot16x16[mbnum-mbwidth+1];
- pmvC_x = pmot->x;
- pmvC_y = pmot->y;
- }
- }
-//#ifdef SCENE_CHANGE_DETECTION
- /* second pass (ST2 algorithm)*/
- else
- {
- if (type_pred == 1) /* 4/7/01 */
- {
- if (imb > 0) /*left neighbor current frame */
- {
- pmot = &mot16x16[mbnum-1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (jmb > 0) /*upper neighbor current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (imb < mbwidth - 1) /*right neighbor current frame */
- {
- pmot = &mot16x16[mbnum+1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- if (jmb < mbheight - 1) /*bottom neighbor current frame */
- {
- pmot = &mot16x16[mbnum+mbwidth];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- }
- //#else
- else /* original ST1 algorithm */
- {
- if (imb > 0) /*left neighbor current frame */
- {
- pmot = &mot16x16[mbnum-1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
-
- if (jmb > 0) /*upper-left neighbor current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth-1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
-
- }
- if (jmb > 0) /*upper neighbor current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
-
- if (imb < mbheight - 1) /*upper-right neighbor current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth+1];
- mvx[(*num_can)] = (pmot->x) >> 2;
- mvy[(*num_can)++] = (pmot->y) >> 2;
- }
- }
- }
-
- /* get predicted MV */
- if (imb > 0) /* get MV from left (A) neighbor either on current or previous frame */
- {
- availA = 1;
- pmot = &mot16x16[mbnum-1];
- pmvA_x = pmot->x;
- pmvA_y = pmot->y;
- }
-
- if (jmb > 0) /* get MV from top (B) neighbor either on current or previous frame */
- {
- availB = 1;
- pmot = &mot16x16[mbnum-mbwidth];
- pmvB_x = pmot->x;
- pmvB_y = pmot->y;
-
- availC = 1;
-
- if (imb < mbwidth - 1) /* get MV from top-right (C) neighbor of current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth+1];
- }
- else /* get MV from top-left (D) neighbor of current frame */
- {
- pmot = &mot16x16[mbnum-mbwidth-1];
- }
- pmvC_x = pmot->x;
- pmvC_y = pmot->y;
- }
- }
-//#endif
- }
-
- /* 3/23/01, remove redundant candidate (possible k-mean) */
- num1 = *num_can;
- *num_can = 1;
- for (i = 1; i < num1; i++)
- {
- same = 0;
- j = 0;
- while (!same && j < *num_can)
- {
-#if (CANDIDATE_DISTANCE==0)
- if (mvx[i] == mvx[j] && mvy[i] == mvy[j])
-#else
- // modified k-mean, 3/24/01, shouldn't be greater than 3
- if (AVC_ABS(mvx[i] - mvx[j]) + AVC_ABS(mvy[i] - mvy[j]) < CANDIDATE_DISTANCE)
-#endif
- same = 1;
- j++;
- }
- if (!same)
- {
- mvx[*num_can] = mvx[i];
- mvy[*num_can] = mvy[i];
- (*num_can)++;
- }
- }
-
- if (num1 == 5 && *num_can == 1)
- *num_can = ALL_CAND_EQUAL; /* all are equal */
-
- /* calculate predicted MV */
-
- if (availA && !(availB || availC))
- {
- *cmvx = pmvA_x;
- *cmvy = pmvA_y;
- }
- else
- {
- *cmvx = AVC_MEDIAN(pmvA_x, pmvB_x, pmvC_x);
- *cmvy = AVC_MEDIAN(pmvA_y, pmvB_y, pmvC_y);
- }
-
- return ;
-}
-
-
-/*************************************************************
- Function: AVCMoveNeighborSAD
- Date: 3/27/01
- Purpose: Move neighboring SAD around when center has shifted
-*************************************************************/
-
-void AVCMoveNeighborSAD(int dn[], int new_loc)
-{
- int tmp[9];
- tmp[0] = dn[0];
- tmp[1] = dn[1];
- tmp[2] = dn[2];
- tmp[3] = dn[3];
- tmp[4] = dn[4];
- tmp[5] = dn[5];
- tmp[6] = dn[6];
- tmp[7] = dn[7];
- tmp[8] = dn[8];
- dn[0] = dn[1] = dn[2] = dn[3] = dn[4] = dn[5] = dn[6] = dn[7] = dn[8] = 65536;
-
- switch (new_loc)
- {
- case 0:
- break;
- case 1:
- dn[4] = tmp[2];
- dn[5] = tmp[0];
- dn[6] = tmp[8];
- break;
- case 2:
- dn[4] = tmp[3];
- dn[5] = tmp[4];
- dn[6] = tmp[0];
- dn[7] = tmp[8];
- dn[8] = tmp[1];
- break;
- case 3:
- dn[6] = tmp[4];
- dn[7] = tmp[0];
- dn[8] = tmp[2];
- break;
- case 4:
- dn[1] = tmp[2];
- dn[2] = tmp[3];
- dn[6] = tmp[5];
- dn[7] = tmp[6];
- dn[8] = tmp[0];
- break;
- case 5:
- dn[1] = tmp[0];
- dn[2] = tmp[4];
- dn[8] = tmp[6];
- break;
- case 6:
- dn[1] = tmp[8];
- dn[2] = tmp[0];
- dn[3] = tmp[4];
- dn[4] = tmp[5];
- dn[8] = tmp[7];
- break;
- case 7:
- dn[2] = tmp[8];
- dn[3] = tmp[0];
- dn[4] = tmp[6];
- break;
- case 8:
- dn[2] = tmp[1];
- dn[3] = tmp[2];
- dn[4] = tmp[0];
- dn[5] = tmp[6];
- dn[6] = tmp[7];
- break;
- }
- dn[0] = tmp[new_loc];
-
- return ;
-}
-
-/* 3/28/01, find minimal of dn[9] */
-
-int AVCFindMin(int dn[])
-{
- int min, i;
- int dmin;
-
- dmin = dn[1];
- min = 1;
- for (i = 2; i < 9; i++)
- {
- if (dn[i] < dmin)
- {
- dmin = dn[i];
- min = i;
- }
- }
-
- return min;
-}
-
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/rate_control.cpp b/media/libstagefright/codecs/avc/enc/src/rate_control.cpp
deleted file mode 100644
index 09dcc28..0000000
--- a/media/libstagefright/codecs/avc/enc/src/rate_control.cpp
+++ /dev/null
@@ -1,979 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-#include <math.h>
-
-/* rate control variables */
-#define RC_MAX_QUANT 51
-#define RC_MIN_QUANT 0 //cap to 10 to prevent rate fluctuation
-
-#define MAD_MIN 1 /* handle the case of devision by zero in RC */
-
-
-/* local functions */
-double QP2Qstep(int QP);
-int Qstep2QP(double Qstep);
-
-double ComputeFrameMAD(AVCCommonObj *video, AVCRateControl *rateCtrl);
-
-void targetBitCalculation(AVCEncObject *encvid, AVCCommonObj *video, AVCRateControl *rateCtrl, MultiPass *pMP);
-
-void calculateQuantizer_Multipass(AVCEncObject *encvid, AVCCommonObj *video,
- AVCRateControl *rateCtrl, MultiPass *pMP);
-
-void updateRC_PostProc(AVCRateControl *rateCtrl, MultiPass *pMP);
-
-void AVCSaveRDSamples(MultiPass *pMP, int counter_samples);
-
-void updateRateControl(AVCRateControl *rateControl, int nal_type);
-
-int GetAvgFrameQP(AVCRateControl *rateCtrl)
-{
- return rateCtrl->Qc;
-}
-
-AVCEnc_Status RCDetermineFrameNum(AVCEncObject *encvid, AVCRateControl *rateCtrl, uint32 modTime, uint *frameNum)
-{
- AVCCommonObj *video = encvid->common;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- uint32 modTimeRef = encvid->modTimeRef;
- int32 currFrameNum ;
- int frameInc;
-
-
- /* check with the buffer fullness to make sure that we have enough bits to encode this frame */
- /* we can use a threshold to guarantee minimum picture quality */
- /**********************************/
-
- /* for now, the default is to encode every frame, To Be Changed */
- if (rateCtrl->first_frame)
- {
- encvid->modTimeRef = modTime;
- encvid->wrapModTime = 0;
- encvid->prevFrameNum = 0;
- encvid->prevProcFrameNum = 0;
-
- *frameNum = 0;
-
- /* set frame type to IDR-frame */
- video->nal_unit_type = AVC_NALTYPE_IDR;
- sliceHdr->slice_type = AVC_I_ALL_SLICE;
- video->slice_type = AVC_I_SLICE;
-
- return AVCENC_SUCCESS;
- }
- else
- {
- if (modTime < modTimeRef) /* modTime wrapped around */
- {
- encvid->wrapModTime += ((uint32)0xFFFFFFFF - modTimeRef) + 1;
- encvid->modTimeRef = modTimeRef = 0;
- }
- modTime += encvid->wrapModTime; /* wrapModTime is non zero after wrap-around */
-
- currFrameNum = (int32)(((modTime - modTimeRef) * rateCtrl->frame_rate + 200) / 1000); /* add small roundings */
-
- if (currFrameNum <= (int32)encvid->prevProcFrameNum)
- {
- return AVCENC_FAIL; /* this is a late frame do not encode it */
- }
-
- frameInc = currFrameNum - encvid->prevProcFrameNum;
-
- if (frameInc < rateCtrl->skip_next_frame + 1)
- {
- return AVCENC_FAIL; /* frame skip required to maintain the target bit rate. */
- }
-
- RCUpdateBuffer(video, rateCtrl, frameInc - rateCtrl->skip_next_frame); /* in case more frames dropped */
-
- *frameNum = currFrameNum;
-
- /* This part would be similar to DetermineVopType of m4venc */
- if ((*frameNum >= (uint)rateCtrl->idrPeriod && rateCtrl->idrPeriod > 0) || (*frameNum > video->MaxFrameNum)) /* first frame or IDR*/
- {
- /* set frame type to IDR-frame */
- if (rateCtrl->idrPeriod)
- {
- encvid->modTimeRef += (uint32)(rateCtrl->idrPeriod * 1000 / rateCtrl->frame_rate);
- *frameNum -= rateCtrl->idrPeriod;
- }
- else
- {
- encvid->modTimeRef += (uint32)(video->MaxFrameNum * 1000 / rateCtrl->frame_rate);
- *frameNum -= video->MaxFrameNum;
- }
-
- video->nal_unit_type = AVC_NALTYPE_IDR;
- sliceHdr->slice_type = AVC_I_ALL_SLICE;
- video->slice_type = AVC_I_SLICE;
- encvid->prevProcFrameNum = *frameNum;
- }
- else
- {
- video->nal_unit_type = AVC_NALTYPE_SLICE;
- sliceHdr->slice_type = AVC_P_ALL_SLICE;
- video->slice_type = AVC_P_SLICE;
- encvid->prevProcFrameNum = currFrameNum;
- }
-
- }
-
- return AVCENC_SUCCESS;
-}
-
-void RCUpdateBuffer(AVCCommonObj *video, AVCRateControl *rateCtrl, int frameInc)
-{
- int tmp;
- MultiPass *pMP = rateCtrl->pMP;
-
- OSCL_UNUSED_ARG(video);
-
- if (rateCtrl->rcEnable == TRUE)
- {
- if (frameInc > 1)
- {
- tmp = rateCtrl->bitsPerFrame * (frameInc - 1);
- rateCtrl->VBV_fullness -= tmp;
- pMP->counter_BTsrc += 10 * (frameInc - 1);
-
- /* Check buffer underflow */
- if (rateCtrl->VBV_fullness < rateCtrl->low_bound)
- {
- rateCtrl->VBV_fullness = rateCtrl->low_bound; // -rateCtrl->Bs/2;
- rateCtrl->TMN_W = rateCtrl->VBV_fullness - rateCtrl->low_bound;
- pMP->counter_BTsrc = pMP->counter_BTdst + (int)((OsclFloat)(rateCtrl->Bs / 2 - rateCtrl->low_bound) / 2.0 / (pMP->target_bits_per_frame / 10));
- }
- }
- }
-}
-
-
-AVCEnc_Status InitRateControlModule(AVCHandle *avcHandle)
-{
- AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
- AVCCommonObj *video = encvid->common;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- double L1, L2, L3, bpp;
- int qp;
- int i;
-
- rateCtrl->basicUnit = video->PicSizeInMbs;
-
- rateCtrl->MADofMB = (double*) avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
- video->PicSizeInMbs * sizeof(double), DEFAULT_ATTR);
-
- if (!rateCtrl->MADofMB)
- {
- goto CLEANUP_RC;
- }
-
- if (rateCtrl->rcEnable == TRUE)
- {
- rateCtrl->pMP = (MultiPass*) avcHandle->CBAVC_Malloc(encvid->avcHandle->userData, sizeof(MultiPass), DEFAULT_ATTR);
- if (!rateCtrl->pMP)
- {
- goto CLEANUP_RC;
- }
- rateCtrl->pMP->encoded_frames = -1; /* forget about the very first I frame */
-
- /* RDInfo **pRDSamples */
- rateCtrl->pMP->pRDSamples = (RDInfo **)avcHandle->CBAVC_Malloc(encvid->avcHandle->userData, (30 * sizeof(RDInfo *)), DEFAULT_ATTR);
- if (!rateCtrl->pMP->pRDSamples)
- {
- goto CLEANUP_RC;
- }
-
- for (i = 0; i < 30; i++)
- {
- rateCtrl->pMP->pRDSamples[i] = (RDInfo *)avcHandle->CBAVC_Malloc(encvid->avcHandle->userData, (32 * sizeof(RDInfo)), DEFAULT_ATTR);
- if (!rateCtrl->pMP->pRDSamples[i])
- {
- goto CLEANUP_RC;
- }
- }
- rateCtrl->pMP->frameRange = (int)(rateCtrl->frame_rate * 1.0); /* 1.0s time frame*/
- rateCtrl->pMP->frameRange = AVC_MAX(rateCtrl->pMP->frameRange, 5);
- rateCtrl->pMP->frameRange = AVC_MIN(rateCtrl->pMP->frameRange, 30);
-
- rateCtrl->pMP->framePos = -1;
-
-
- rateCtrl->bitsPerFrame = (int32)(rateCtrl->bitRate / rateCtrl->frame_rate);
-
- /* BX rate control */
- rateCtrl->skip_next_frame = 0; /* must be initialized */
-
- rateCtrl->Bs = rateCtrl->cpbSize;
- rateCtrl->TMN_W = 0;
- rateCtrl->VBV_fullness = (int)(rateCtrl->Bs * 0.5); /* rateCtrl->Bs */
- rateCtrl->encoded_frames = 0;
-
- rateCtrl->TMN_TH = rateCtrl->bitsPerFrame;
-
- rateCtrl->max_BitVariance_num = (int)((OsclFloat)(rateCtrl->Bs - rateCtrl->VBV_fullness) / (rateCtrl->bitsPerFrame / 10.0)) - 5;
- if (rateCtrl->max_BitVariance_num < 0) rateCtrl->max_BitVariance_num += 5;
-
- // Set the initial buffer fullness
- /* According to the spec, the initial buffer fullness needs to be set to 1/3 */
- rateCtrl->VBV_fullness = (int)(rateCtrl->Bs / 3.0 - rateCtrl->Bs / 2.0); /* the buffer range is [-Bs/2, Bs/2] */
- rateCtrl->pMP->counter_BTsrc = (int)((rateCtrl->Bs / 2.0 - rateCtrl->Bs / 3.0) / (rateCtrl->bitsPerFrame / 10.0));
- rateCtrl->TMN_W = (int)(rateCtrl->VBV_fullness + rateCtrl->pMP->counter_BTsrc * (rateCtrl->bitsPerFrame / 10.0));
-
- rateCtrl->low_bound = -rateCtrl->Bs / 2;
- rateCtrl->VBV_fullness_offset = 0;
-
- /* Setting the bitrate and framerate */
- rateCtrl->pMP->bitrate = rateCtrl->bitRate;
- rateCtrl->pMP->framerate = rateCtrl->frame_rate;
- rateCtrl->pMP->target_bits_per_frame = rateCtrl->pMP->bitrate / rateCtrl->pMP->framerate;
-
- /*compute the initial QP*/
- bpp = 1.0 * rateCtrl->bitRate / (rateCtrl->frame_rate * (video->PicSizeInMbs << 8));
- if (video->PicWidthInSamplesL == 176)
- {
- L1 = 0.1;
- L2 = 0.3;
- L3 = 0.6;
- }
- else if (video->PicWidthInSamplesL == 352)
- {
- L1 = 0.2;
- L2 = 0.6;
- L3 = 1.2;
- }
- else
- {
- L1 = 0.6;
- L2 = 1.4;
- L3 = 2.4;
- }
-
- if (rateCtrl->initQP == 0)
- {
- if (bpp <= L1)
- qp = 35;
- else if (bpp <= L2)
- qp = 25;
- else if (bpp <= L3)
- qp = 20;
- else
- qp = 15;
- rateCtrl->initQP = qp;
- }
-
- rateCtrl->Qc = rateCtrl->initQP;
- }
-
- return AVCENC_SUCCESS;
-
-CLEANUP_RC:
-
- CleanupRateControlModule(avcHandle);
- return AVCENC_MEMORY_FAIL;
-
-}
-
-
-void CleanupRateControlModule(AVCHandle *avcHandle)
-{
- AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- int i;
-
- if (rateCtrl->MADofMB)
- {
- avcHandle->CBAVC_Free(avcHandle->userData, rateCtrl->MADofMB);
- }
-
- if (rateCtrl->pMP)
- {
- if (rateCtrl->pMP->pRDSamples)
- {
- for (i = 0; i < 30; i++)
- {
- if (rateCtrl->pMP->pRDSamples[i])
- {
- avcHandle->CBAVC_Free(avcHandle->userData, rateCtrl->pMP->pRDSamples[i]);
- }
- }
- avcHandle->CBAVC_Free(avcHandle->userData, rateCtrl->pMP->pRDSamples);
- }
- avcHandle->CBAVC_Free(avcHandle->userData, rateCtrl->pMP);
- }
-
- return ;
-}
-
-void RCInitGOP(AVCEncObject *encvid)
-{
- /* in BX RC, there's no GOP-level RC */
-
- OSCL_UNUSED_ARG(encvid);
-
- return ;
-}
-
-
-void RCInitFrameQP(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- AVCPicParamSet *picParam = video->currPicParams;
- MultiPass *pMP = rateCtrl->pMP;
-
- if (rateCtrl->rcEnable == TRUE)
- {
- /* frame layer rate control */
- if (rateCtrl->encoded_frames == 0)
- {
- video->QPy = rateCtrl->Qc = rateCtrl->initQP;
- }
- else
- {
- calculateQuantizer_Multipass(encvid, video, rateCtrl, pMP);
- video->QPy = rateCtrl->Qc;
- }
-
- rateCtrl->NumberofHeaderBits = 0;
- rateCtrl->NumberofTextureBits = 0;
- rateCtrl->numFrameBits = 0; // reset
-
- /* update pMP->framePos */
- if (++pMP->framePos == pMP->frameRange) pMP->framePos = 0;
-
- if (rateCtrl->T == 0)
- {
- pMP->counter_BTdst = (int)(rateCtrl->frame_rate * 7.5 + 0.5); /* 0.75s time frame */
- pMP->counter_BTdst = AVC_MIN(pMP->counter_BTdst, (int)(rateCtrl->max_BitVariance_num / 2 * 0.40)); /* 0.75s time frame may go beyond VBV buffer if we set the buffer size smaller than 0.75s */
- pMP->counter_BTdst = AVC_MAX(pMP->counter_BTdst, (int)((rateCtrl->Bs / 2 - rateCtrl->VBV_fullness) * 0.30 / (rateCtrl->TMN_TH / 10.0) + 0.5)); /* At least 30% of VBV buffer size/2 */
- pMP->counter_BTdst = AVC_MIN(pMP->counter_BTdst, 20); /* Limit the target to be smaller than 3C */
-
- pMP->target_bits = rateCtrl->T = rateCtrl->TMN_TH = (int)(rateCtrl->TMN_TH * (1.0 + pMP->counter_BTdst * 0.1));
- pMP->diff_counter = pMP->counter_BTdst;
- }
-
- /* collect the necessary data: target bits, actual bits, mad and QP */
- pMP->target_bits = rateCtrl->T;
- pMP->QP = video->QPy;
-
- pMP->mad = (OsclFloat)rateCtrl->totalSAD / video->PicSizeInMbs; //ComputeFrameMAD(video, rateCtrl);
- if (pMP->mad < MAD_MIN) pMP->mad = MAD_MIN; /* MAD_MIN is defined as 1 in mp4def.h */
-
- pMP->bitrate = rateCtrl->bitRate; /* calculated in RCVopQPSetting */
- pMP->framerate = rateCtrl->frame_rate;
-
- /* first pass encoding */
- pMP->nRe_Quantized = 0;
-
- } // rcEnable
- else
- {
- video->QPy = rateCtrl->initQP;
- }
-
-// printf(" %d ",video->QPy);
-
- if (video->CurrPicNum == 0 && encvid->outOfBandParamSet == FALSE)
- {
- picParam->pic_init_qs_minus26 = 0;
- picParam->pic_init_qp_minus26 = video->QPy - 26;
- }
-
- // need this for motion estimation
- encvid->lambda_mode = QP2QUANT[AVC_MAX(0, video->QPy-SHIFT_QP)];
- encvid->lambda_motion = LAMBDA_FACTOR(encvid->lambda_mode);
- return ;
-}
-
-/* Mad based variable bit allocation + QP calculation with a new quadratic method */
-void calculateQuantizer_Multipass(AVCEncObject *encvid, AVCCommonObj *video,
- AVCRateControl *rateCtrl, MultiPass *pMP)
-{
- int prev_actual_bits = 0, curr_target, /*pos=0,*/i, j;
- OsclFloat Qstep, prev_QP = 0.625;
-
- OsclFloat curr_mad, prev_mad, curr_RD, prev_RD, average_mad, aver_QP;
-
- /* Mad based variable bit allocation */
- targetBitCalculation(encvid, video, rateCtrl, pMP);
-
- if (rateCtrl->T <= 0 || rateCtrl->totalSAD == 0)
- {
- if (rateCtrl->T < 0) rateCtrl->Qc = RC_MAX_QUANT;
- return;
- }
-
- /* ---------------------------------------------------------------------------------------------------*/
- /* current frame QP estimation */
- curr_target = rateCtrl->T;
- curr_mad = (OsclFloat)rateCtrl->totalSAD / video->PicSizeInMbs;
- if (curr_mad < MAD_MIN) curr_mad = MAD_MIN; /* MAD_MIN is defined as 1 in mp4def.h */
- curr_RD = (OsclFloat)curr_target / curr_mad;
-
- if (rateCtrl->skip_next_frame == -1) // previous was skipped
- {
- i = pMP->framePos;
- prev_mad = pMP->pRDSamples[i][0].mad;
- prev_QP = pMP->pRDSamples[i][0].QP;
- prev_actual_bits = pMP->pRDSamples[i][0].actual_bits;
- }
- else
- {
- /* Another version of search the optimal point */
- prev_mad = 0.0;
- i = 0;
- while (i < pMP->frameRange && prev_mad < 0.001) /* find first one with nonzero prev_mad */
- {
- prev_mad = pMP->pRDSamples[i][0].mad;
- i++;
- }
-
- if (i < pMP->frameRange)
- {
- prev_actual_bits = pMP->pRDSamples[i-1][0].actual_bits;
-
- for (j = 0; i < pMP->frameRange; i++)
- {
- if (pMP->pRDSamples[i][0].mad != 0 &&
- AVC_ABS(prev_mad - curr_mad) > AVC_ABS(pMP->pRDSamples[i][0].mad - curr_mad))
- {
- prev_mad = pMP->pRDSamples[i][0].mad;
- prev_actual_bits = pMP->pRDSamples[i][0].actual_bits;
- j = i;
- }
- }
- prev_QP = QP2Qstep(pMP->pRDSamples[j][0].QP);
-
- for (i = 1; i < pMP->samplesPerFrame[j]; i++)
- {
- if (AVC_ABS(prev_actual_bits - curr_target) > AVC_ABS(pMP->pRDSamples[j][i].actual_bits - curr_target))
- {
- prev_actual_bits = pMP->pRDSamples[j][i].actual_bits;
- prev_QP = QP2Qstep(pMP->pRDSamples[j][i].QP);
- }
- }
- }
- }
-
- // quadratic approximation
- if (prev_mad > 0.001) // only when prev_mad is greater than 0, otherwise keep using the same QP
- {
- prev_RD = (OsclFloat)prev_actual_bits / prev_mad;
- //rateCtrl->Qc = (Int)(prev_QP * sqrt(prev_actual_bits/curr_target) + 0.4);
- if (prev_QP == 0.625) // added this to allow getting out of QP = 0 easily
- {
- Qstep = (int)(prev_RD / curr_RD + 0.5);
- }
- else
- {
- // rateCtrl->Qc =(Int)(prev_QP * M4VENC_SQRT(prev_RD/curr_RD) + 0.9);
-
- if (prev_RD / curr_RD > 0.5 && prev_RD / curr_RD < 2.0)
- Qstep = (int)(prev_QP * (sqrt(prev_RD / curr_RD) + prev_RD / curr_RD) / 2.0 + 0.9); /* Quadratic and linear approximation */
- else
- Qstep = (int)(prev_QP * (sqrt(prev_RD / curr_RD) + pow(prev_RD / curr_RD, 1.0 / 3.0)) / 2.0 + 0.9);
- }
- // lower bound on Qc should be a function of curr_mad
- // When mad is already low, lower bound on Qc doesn't have to be small.
- // Note, this doesn't work well for low complexity clip encoded at high bit rate
- // it doesn't hit the target bit rate due to this QP lower bound.
- /// if((curr_mad < 8) && (rateCtrl->Qc < 12)) rateCtrl->Qc = 12;
- // else if((curr_mad < 128) && (rateCtrl->Qc < 3)) rateCtrl->Qc = 3;
-
- rateCtrl->Qc = Qstep2QP(Qstep);
-
- if (rateCtrl->Qc < RC_MIN_QUANT) rateCtrl->Qc = RC_MIN_QUANT;
- if (rateCtrl->Qc > RC_MAX_QUANT) rateCtrl->Qc = RC_MAX_QUANT;
- }
-
- /* active bit resource protection */
- aver_QP = (pMP->encoded_frames == 0 ? 0 : pMP->sum_QP / (OsclFloat)pMP->encoded_frames);
- average_mad = (pMP->encoded_frames == 0 ? 0 : pMP->sum_mad / (OsclFloat)pMP->encoded_frames); /* this function is called from the scond encoded frame*/
- if (pMP->diff_counter == 0 &&
- ((OsclFloat)rateCtrl->Qc <= aver_QP*1.1 || curr_mad <= average_mad*1.1) &&
- pMP->counter_BTsrc <= (pMP->counter_BTdst + (int)(pMP->framerate*1.0 + 0.5)))
- {
- rateCtrl->TMN_TH -= (int)(pMP->target_bits_per_frame / 10.0);
- rateCtrl->T = rateCtrl->TMN_TH - rateCtrl->TMN_W;
- pMP->counter_BTsrc++;
- pMP->diff_counter--;
- }
-
-}
-
-void targetBitCalculation(AVCEncObject *encvid, AVCCommonObj *video, AVCRateControl *rateCtrl, MultiPass *pMP)
-{
- OSCL_UNUSED_ARG(encvid);
- OsclFloat curr_mad;//, average_mad;
- int diff_counter_BTsrc, diff_counter_BTdst, prev_counter_diff, curr_counter_diff, bound;
- /* BT = Bit Transfer, for pMP->counter_BTsrc, pMP->counter_BTdst */
-
- /* some stuff about frame dropping remained here to be done because pMP cannot be inserted into updateRateControl()*/
- updateRC_PostProc(rateCtrl, pMP);
-
- /* update pMP->counter_BTsrc and pMP->counter_BTdst to avoid interger overflow */
- if (pMP->counter_BTsrc > 1000 && pMP->counter_BTdst > 1000)
- {
- pMP->counter_BTsrc -= 1000;
- pMP->counter_BTdst -= 1000;
- }
-
- /* ---------------------------------------------------------------------------------------------------*/
- /* target calculation */
- curr_mad = (OsclFloat)rateCtrl->totalSAD / video->PicSizeInMbs;
- if (curr_mad < MAD_MIN) curr_mad = MAD_MIN; /* MAD_MIN is defined as 1 in mp4def.h */
- diff_counter_BTsrc = diff_counter_BTdst = 0;
- pMP->diff_counter = 0;
-
-
- /*1.calculate average mad */
- pMP->sum_mad += curr_mad;
- //average_mad = (pMP->encoded_frames < 1 ? curr_mad : pMP->sum_mad/(OsclFloat)(pMP->encoded_frames+1)); /* this function is called from the scond encoded frame*/
- //pMP->aver_mad = average_mad;
- if (pMP->encoded_frames >= 0) /* pMP->encoded_frames is set to -1 initially, so forget about the very first I frame */
- pMP->aver_mad = (pMP->aver_mad * pMP->encoded_frames + curr_mad) / (pMP->encoded_frames + 1);
-
- if (pMP->overlapped_win_size > 0 && pMP->encoded_frames_prev >= 0)
- pMP->aver_mad_prev = (pMP->aver_mad_prev * pMP->encoded_frames_prev + curr_mad) / (pMP->encoded_frames_prev + 1);
-
- /*2.average_mad, mad ==> diff_counter_BTsrc, diff_counter_BTdst */
- if (pMP->overlapped_win_size == 0)
- {
- /* original verison */
- if (curr_mad > pMP->aver_mad*1.1)
- {
- if (curr_mad / (pMP->aver_mad + 0.0001) > 2)
- diff_counter_BTdst = (int)(sqrt(curr_mad / (pMP->aver_mad + 0.0001)) * 10 + 0.4) - 10;
- //diff_counter_BTdst = (int)((sqrt(curr_mad/pMP->aver_mad)*2+curr_mad/pMP->aver_mad)/(3*0.1) + 0.4) - 10;
- else
- diff_counter_BTdst = (int)(curr_mad / (pMP->aver_mad + 0.0001) * 10 + 0.4) - 10;
- }
- else /* curr_mad <= average_mad*1.1 */
- //diff_counter_BTsrc = 10 - (int)((sqrt(curr_mad/pMP->aver_mad) + pow(curr_mad/pMP->aver_mad, 1.0/3.0))/(2.0*0.1) + 0.4);
- diff_counter_BTsrc = 10 - (int)(sqrt(curr_mad / (pMP->aver_mad + 0.0001)) * 10 + 0.5);
-
- /* actively fill in the possible gap */
- if (diff_counter_BTsrc == 0 && diff_counter_BTdst == 0 &&
- curr_mad <= pMP->aver_mad*1.1 && pMP->counter_BTsrc < pMP->counter_BTdst)
- diff_counter_BTsrc = 1;
-
- }
- else if (pMP->overlapped_win_size > 0)
- {
- /* transition time: use previous average mad "pMP->aver_mad_prev" instead of the current average mad "pMP->aver_mad" */
- if (curr_mad > pMP->aver_mad_prev*1.1)
- {
- if (curr_mad / pMP->aver_mad_prev > 2)
- diff_counter_BTdst = (int)(sqrt(curr_mad / (pMP->aver_mad_prev + 0.0001)) * 10 + 0.4) - 10;
- //diff_counter_BTdst = (int)((M4VENC_SQRT(curr_mad/pMP->aver_mad_prev)*2+curr_mad/pMP->aver_mad_prev)/(3*0.1) + 0.4) - 10;
- else
- diff_counter_BTdst = (int)(curr_mad / (pMP->aver_mad_prev + 0.0001) * 10 + 0.4) - 10;
- }
- else /* curr_mad <= average_mad*1.1 */
- //diff_counter_BTsrc = 10 - (Int)((sqrt(curr_mad/pMP->aver_mad_prev) + pow(curr_mad/pMP->aver_mad_prev, 1.0/3.0))/(2.0*0.1) + 0.4);
- diff_counter_BTsrc = 10 - (int)(sqrt(curr_mad / (pMP->aver_mad_prev + 0.0001)) * 10 + 0.5);
-
- /* actively fill in the possible gap */
- if (diff_counter_BTsrc == 0 && diff_counter_BTdst == 0 &&
- curr_mad <= pMP->aver_mad_prev*1.1 && pMP->counter_BTsrc < pMP->counter_BTdst)
- diff_counter_BTsrc = 1;
-
- if (--pMP->overlapped_win_size <= 0) pMP->overlapped_win_size = 0;
- }
-
-
- /* if difference is too much, do clipping */
- /* First, set the upper bound for current bit allocation variance: 80% of available buffer */
- bound = (int)((rateCtrl->Bs / 2 - rateCtrl->VBV_fullness) * 0.6 / (pMP->target_bits_per_frame / 10)); /* rateCtrl->Bs */
- diff_counter_BTsrc = AVC_MIN(diff_counter_BTsrc, bound);
- diff_counter_BTdst = AVC_MIN(diff_counter_BTdst, bound);
-
- /* Second, set another upper bound for current bit allocation: 4-5*bitrate/framerate */
- bound = 50;
-// if(video->encParams->RC_Type == CBR_LOWDELAY)
-// not necessary bound = 10; -- For Low delay */
-
- diff_counter_BTsrc = AVC_MIN(diff_counter_BTsrc, bound);
- diff_counter_BTdst = AVC_MIN(diff_counter_BTdst, bound);
-
-
- /* Third, check the buffer */
- prev_counter_diff = pMP->counter_BTdst - pMP->counter_BTsrc;
- curr_counter_diff = prev_counter_diff + (diff_counter_BTdst - diff_counter_BTsrc);
-
- if (AVC_ABS(prev_counter_diff) >= rateCtrl->max_BitVariance_num || AVC_ABS(curr_counter_diff) >= rateCtrl->max_BitVariance_num)
- { //diff_counter_BTsrc = diff_counter_BTdst = 0;
-
- if (curr_counter_diff > rateCtrl->max_BitVariance_num && diff_counter_BTdst)
- {
- diff_counter_BTdst = (rateCtrl->max_BitVariance_num - prev_counter_diff) + diff_counter_BTsrc;
- if (diff_counter_BTdst < 0) diff_counter_BTdst = 0;
- }
-
- else if (curr_counter_diff < -rateCtrl->max_BitVariance_num && diff_counter_BTsrc)
- {
- diff_counter_BTsrc = diff_counter_BTdst - (-rateCtrl->max_BitVariance_num - prev_counter_diff);
- if (diff_counter_BTsrc < 0) diff_counter_BTsrc = 0;
- }
- }
-
-
- /*3.diff_counter_BTsrc, diff_counter_BTdst ==> TMN_TH */
- rateCtrl->TMN_TH = (int)(pMP->target_bits_per_frame);
- pMP->diff_counter = 0;
-
- if (diff_counter_BTsrc)
- {
- rateCtrl->TMN_TH -= (int)(pMP->target_bits_per_frame * diff_counter_BTsrc * 0.1);
- pMP->diff_counter = -diff_counter_BTsrc;
- }
- else if (diff_counter_BTdst)
- {
- rateCtrl->TMN_TH += (int)(pMP->target_bits_per_frame * diff_counter_BTdst * 0.1);
- pMP->diff_counter = diff_counter_BTdst;
- }
-
-
- /*4.update pMP->counter_BTsrc, pMP->counter_BTdst */
- pMP->counter_BTsrc += diff_counter_BTsrc;
- pMP->counter_BTdst += diff_counter_BTdst;
-
-
- /*5.target bit calculation */
- rateCtrl->T = rateCtrl->TMN_TH - rateCtrl->TMN_W;
-
- return ;
-}
-
-void updateRC_PostProc(AVCRateControl *rateCtrl, MultiPass *pMP)
-{
- if (rateCtrl->skip_next_frame > 0) /* skip next frame */
- {
- pMP->counter_BTsrc += 10 * rateCtrl->skip_next_frame;
-
- }
- else if (rateCtrl->skip_next_frame == -1) /* skip current frame */
- {
- pMP->counter_BTdst -= pMP->diff_counter;
- pMP->counter_BTsrc += 10;
-
- pMP->sum_mad -= pMP->mad;
- pMP->aver_mad = (pMP->aver_mad * pMP->encoded_frames - pMP->mad) / (pMP->encoded_frames - 1 + 0.0001);
- pMP->sum_QP -= pMP->QP;
- pMP->encoded_frames --;
- }
- /* some stuff in update VBV_fullness remains here */
- //if(rateCtrl->VBV_fullness < -rateCtrl->Bs/2) /* rateCtrl->Bs */
- if (rateCtrl->VBV_fullness < rateCtrl->low_bound)
- {
- rateCtrl->VBV_fullness = rateCtrl->low_bound; // -rateCtrl->Bs/2;
- rateCtrl->TMN_W = rateCtrl->VBV_fullness - rateCtrl->low_bound;
- pMP->counter_BTsrc = pMP->counter_BTdst + (int)((OsclFloat)(rateCtrl->Bs / 2 - rateCtrl->low_bound) / 2.0 / (pMP->target_bits_per_frame / 10));
- }
-}
-
-
-void RCInitChromaQP(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- AVCMacroblock *currMB = video->currMB;
- int q_bits;
-
- /* we have to do the same thing for AVC_CLIP3(0,51,video->QSy) */
-
- video->QPy_div_6 = (currMB->QPy * 43) >> 8;
- video->QPy_mod_6 = currMB->QPy - 6 * video->QPy_div_6;
- currMB->QPc = video->QPc = mapQPi2QPc[AVC_CLIP3(0, 51, currMB->QPy + video->currPicParams->chroma_qp_index_offset)];
- video->QPc_div_6 = (video->QPc * 43) >> 8;
- video->QPc_mod_6 = video->QPc - 6 * video->QPc_div_6;
-
- /* pre-calculate this to save computation */
- q_bits = 4 + video->QPy_div_6;
- if (video->slice_type == AVC_I_SLICE)
- {
- encvid->qp_const = 682 << q_bits; // intra
- }
- else
- {
- encvid->qp_const = 342 << q_bits; // inter
- }
-
- q_bits = 4 + video->QPc_div_6;
- if (video->slice_type == AVC_I_SLICE)
- {
- encvid->qp_const_c = 682 << q_bits; // intra
- }
- else
- {
- encvid->qp_const_c = 342 << q_bits; // inter
- }
-
- encvid->lambda_mode = QP2QUANT[AVC_MAX(0, currMB->QPy-SHIFT_QP)];
- encvid->lambda_motion = LAMBDA_FACTOR(encvid->lambda_mode);
-
- return ;
-}
-
-
-void RCInitMBQP(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- AVCMacroblock *currMB = video->currMB;
-
- currMB->QPy = video->QPy; /* set to previous value or picture level */
-
- RCInitChromaQP(encvid);
-
-}
-
-void RCPostMB(AVCCommonObj *video, AVCRateControl *rateCtrl, int num_header_bits, int num_texture_bits)
-{
- OSCL_UNUSED_ARG(video);
- rateCtrl->numMBHeaderBits = num_header_bits;
- rateCtrl->numMBTextureBits = num_texture_bits;
- rateCtrl->NumberofHeaderBits += rateCtrl->numMBHeaderBits;
- rateCtrl->NumberofTextureBits += rateCtrl->numMBTextureBits;
-}
-
-void RCRestoreQP(AVCMacroblock *currMB, AVCCommonObj *video, AVCEncObject *encvid)
-{
- currMB->QPy = video->QPy; /* use previous QP */
- RCInitChromaQP(encvid);
-
- return ;
-}
-
-
-void RCCalculateMAD(AVCEncObject *encvid, AVCMacroblock *currMB, uint8 *orgL, int orgPitch)
-{
- AVCCommonObj *video = encvid->common;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- uint32 dmin_lx;
-
- if (rateCtrl->rcEnable == TRUE)
- {
- if (currMB->mb_intra)
- {
- if (currMB->mbMode == AVC_I16)
- {
- dmin_lx = (0xFFFF << 16) | orgPitch;
- rateCtrl->MADofMB[video->mbNum] = AVCSAD_Macroblock_C(orgL,
- encvid->pred_i16[currMB->i16Mode], dmin_lx, NULL);
- }
- else /* i4 */
- {
- rateCtrl->MADofMB[video->mbNum] = encvid->i4_sad / 256.;
- }
- }
- /* for INTER, we have already saved it with the MV search */
- }
-
- return ;
-}
-
-
-
-AVCEnc_Status RCUpdateFrame(AVCEncObject *encvid)
-{
- AVCCommonObj *video = encvid->common;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- AVCEnc_Status status = AVCENC_SUCCESS;
- MultiPass *pMP = rateCtrl->pMP;
- int diff_BTCounter;
- int nal_type = video->nal_unit_type;
-
- /* update the complexity weight of I, P, B frame */
-
- if (rateCtrl->rcEnable == TRUE)
- {
- pMP->actual_bits = rateCtrl->numFrameBits;
- pMP->mad = (OsclFloat)rateCtrl->totalSAD / video->PicSizeInMbs; //ComputeFrameMAD(video, rateCtrl);
-
- AVCSaveRDSamples(pMP, 0);
-
- pMP->encoded_frames++;
-
- /* for pMP->samplesPerFrame */
- pMP->samplesPerFrame[pMP->framePos] = 0;
-
- pMP->sum_QP += pMP->QP;
-
- /* update pMP->counter_BTsrc, pMP->counter_BTdst */
- /* re-allocate the target bit again and then stop encoding */
- diff_BTCounter = (int)((OsclFloat)(rateCtrl->TMN_TH - rateCtrl->TMN_W - pMP->actual_bits) /
- (pMP->bitrate / (pMP->framerate + 0.0001) + 0.0001) / 0.1);
- if (diff_BTCounter >= 0)
- pMP->counter_BTsrc += diff_BTCounter; /* pMP->actual_bits is smaller */
- else
- pMP->counter_BTdst -= diff_BTCounter; /* pMP->actual_bits is bigger */
-
- rateCtrl->TMN_TH -= (int)((OsclFloat)pMP->bitrate / (pMP->framerate + 0.0001) * (diff_BTCounter * 0.1));
- rateCtrl->T = pMP->target_bits = rateCtrl->TMN_TH - rateCtrl->TMN_W;
- pMP->diff_counter -= diff_BTCounter;
-
- rateCtrl->Rc = rateCtrl->numFrameBits; /* Total Bits for current frame */
- rateCtrl->Hc = rateCtrl->NumberofHeaderBits; /* Total Bits in Header and Motion Vector */
-
- /* BX_RC */
- updateRateControl(rateCtrl, nal_type);
- if (rateCtrl->skip_next_frame == -1) // skip current frame
- {
- status = AVCENC_SKIPPED_PICTURE;
- }
- }
-
- rateCtrl->first_frame = 0; // reset here after we encode the first frame.
-
- return status;
-}
-
-void AVCSaveRDSamples(MultiPass *pMP, int counter_samples)
-{
- /* for pMP->pRDSamples */
- pMP->pRDSamples[pMP->framePos][counter_samples].QP = pMP->QP;
- pMP->pRDSamples[pMP->framePos][counter_samples].actual_bits = pMP->actual_bits;
- pMP->pRDSamples[pMP->framePos][counter_samples].mad = pMP->mad;
- pMP->pRDSamples[pMP->framePos][counter_samples].R_D = (OsclFloat)pMP->actual_bits / (pMP->mad + 0.0001);
-
- return ;
-}
-
-void updateRateControl(AVCRateControl *rateCtrl, int nal_type)
-{
- int frame_bits;
- MultiPass *pMP = rateCtrl->pMP;
-
- /* BX rate contro\l */
- frame_bits = (int)(rateCtrl->bitRate / rateCtrl->frame_rate);
- rateCtrl->TMN_W += (rateCtrl->Rc - rateCtrl->TMN_TH);
- rateCtrl->VBV_fullness += (rateCtrl->Rc - frame_bits); //rateCtrl->Rp);
- //if(rateCtrl->VBV_fullness < 0) rateCtrl->VBV_fullness = -1;
-
- rateCtrl->encoded_frames++;
-
- /* frame dropping */
- rateCtrl->skip_next_frame = 0;
-
- if ((rateCtrl->VBV_fullness > rateCtrl->Bs / 2) && nal_type != AVC_NALTYPE_IDR) /* skip the current frame */ /* rateCtrl->Bs */
- {
- rateCtrl->TMN_W -= (rateCtrl->Rc - rateCtrl->TMN_TH);
- rateCtrl->VBV_fullness -= rateCtrl->Rc;
- rateCtrl->skip_next_frame = -1;
- }
- else if ((OsclFloat)(rateCtrl->VBV_fullness - rateCtrl->VBV_fullness_offset) > (rateCtrl->Bs / 2 - rateCtrl->VBV_fullness_offset)*0.95) /* skip next frame */
- {
- rateCtrl->VBV_fullness -= frame_bits; //rateCtrl->Rp;
- rateCtrl->skip_next_frame = 1;
- pMP->counter_BTsrc -= (int)((OsclFloat)(rateCtrl->Bs / 2 - rateCtrl->low_bound) / 2.0 / (pMP->target_bits_per_frame / 10));
- /* BX_1, skip more than 1 frames */
- //while(rateCtrl->VBV_fullness > rateCtrl->Bs*0.475)
- while ((rateCtrl->VBV_fullness - rateCtrl->VBV_fullness_offset) > (rateCtrl->Bs / 2 - rateCtrl->VBV_fullness_offset)*0.95)
- {
- rateCtrl->VBV_fullness -= frame_bits; //rateCtrl->Rp;
- rateCtrl->skip_next_frame++;
- pMP->counter_BTsrc -= (int)((OsclFloat)(rateCtrl->Bs / 2 - rateCtrl->low_bound) / 2.0 / (pMP->target_bits_per_frame / 10));
- }
-
- /* END BX_1 */
- }
-}
-
-
-double ComputeFrameMAD(AVCCommonObj *video, AVCRateControl *rateCtrl)
-{
- double TotalMAD;
- int i;
- TotalMAD = 0.0;
- for (i = 0; i < (int)video->PicSizeInMbs; i++)
- TotalMAD += rateCtrl->MADofMB[i];
- TotalMAD /= video->PicSizeInMbs;
- return TotalMAD;
-}
-
-
-
-
-
-/* convert from QP to Qstep */
-double QP2Qstep(int QP)
-{
- int i;
- double Qstep;
- static const double QP2QSTEP[6] = { 0.625, 0.6875, 0.8125, 0.875, 1.0, 1.125 };
-
- Qstep = QP2QSTEP[QP % 6];
- for (i = 0; i < (QP / 6); i++)
- Qstep *= 2;
-
- return Qstep;
-}
-
-/* convert from step size to QP */
-int Qstep2QP(double Qstep)
-{
- int q_per = 0, q_rem = 0;
-
- // assert( Qstep >= QP2Qstep(0) && Qstep <= QP2Qstep(51) );
- if (Qstep < QP2Qstep(0))
- return 0;
- else if (Qstep > QP2Qstep(51))
- return 51;
-
- while (Qstep > QP2Qstep(5))
- {
- Qstep /= 2;
- q_per += 1;
- }
-
- if (Qstep <= (0.625 + 0.6875) / 2)
- {
- Qstep = 0.625;
- q_rem = 0;
- }
- else if (Qstep <= (0.6875 + 0.8125) / 2)
- {
- Qstep = 0.6875;
- q_rem = 1;
- }
- else if (Qstep <= (0.8125 + 0.875) / 2)
- {
- Qstep = 0.8125;
- q_rem = 2;
- }
- else if (Qstep <= (0.875 + 1.0) / 2)
- {
- Qstep = 0.875;
- q_rem = 3;
- }
- else if (Qstep <= (1.0 + 1.125) / 2)
- {
- Qstep = 1.0;
- q_rem = 4;
- }
- else
- {
- Qstep = 1.125;
- q_rem = 5;
- }
-
- return (q_per * 6 + q_rem);
-}
-
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/residual.cpp b/media/libstagefright/codecs/avc/enc/src/residual.cpp
deleted file mode 100644
index 42eb910..0000000
--- a/media/libstagefright/codecs/avc/enc/src/residual.cpp
+++ /dev/null
@@ -1,389 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-
-AVCEnc_Status EncodeIntraPCM(AVCEncObject *encvid)
-{
- AVCEnc_Status status = AVCENC_SUCCESS;
- AVCCommonObj *video = encvid->common;
- AVCFrameIO *currInput = encvid->currInput;
- AVCEncBitstream *stream = encvid->bitstream;
- int x_position = (video->mb_x << 4);
- int y_position = (video->mb_y << 4);
- int orgPitch = currInput->pitch;
- int offset1 = y_position * orgPitch + x_position;
- int i, j;
- int offset;
- uint8 *pDst, *pSrc;
- uint code;
-
- ue_v(stream, 25);
-
- i = stream->bit_left & 0x7;
- if (i) /* not byte-aligned */
- {
- BitstreamWriteBits(stream, 0, i);
- }
-
- pSrc = currInput->YCbCr[0] + offset1;
- pDst = video->currPic->Sl + offset1;
- offset = video->PicWidthInSamplesL - 16;
-
- /* at this point bitstream is byte-aligned */
- j = 16;
- while (j > 0)
- {
-#if (WORD_SIZE==32)
- for (i = 0; i < 4; i++)
- {
- code = *((uint*)pSrc);
- pSrc += 4;
- *((uint*)pDst) = code;
- pDst += 4;
- status = BitstreamWriteBits(stream, 32, code);
- }
-#else
- for (i = 0; i < 8; i++)
- {
- code = *((uint*)pSrc);
- pSrc += 2;
- *((uint*)pDst) = code;
- pDst += 2;
- status = BitstreamWriteBits(stream, 16, code);
- }
-#endif
- pDst += offset;
- pSrc += offset;
- j--;
- }
- if (status != AVCENC_SUCCESS) /* check only once per line */
- return status;
-
- pDst = video->currPic->Scb + ((offset1 + x_position) >> 2);
- pSrc = currInput->YCbCr[1] + ((offset1 + x_position) >> 2);
- offset >>= 1;
-
- j = 8;
- while (j > 0)
- {
-#if (WORD_SIZE==32)
- for (i = 0; i < 2; i++)
- {
- code = *((uint*)pSrc);
- pSrc += 4;
- *((uint*)pDst) = code;
- pDst += 4;
- status = BitstreamWriteBits(stream, 32, code);
- }
-#else
- for (i = 0; i < 4; i++)
- {
- code = *((uint*)pSrc);
- pSrc += 2;
- *((uint*)pDst) = code;
- pDst += 2;
- status = BitstreamWriteBits(stream, 16, code);
- }
-#endif
- pDst += offset;
- pSrc += offset;
- j--;
- }
-
- if (status != AVCENC_SUCCESS) /* check only once per line */
- return status;
-
- pDst = video->currPic->Scr + ((offset1 + x_position) >> 2);
- pSrc = currInput->YCbCr[2] + ((offset1 + x_position) >> 2);
-
- j = 8;
- while (j > 0)
- {
-#if (WORD_SIZE==32)
- for (i = 0; i < 2; i++)
- {
- code = *((uint*)pSrc);
- pSrc += 4;
- *((uint*)pDst) = code;
- pDst += 4;
- status = BitstreamWriteBits(stream, 32, code);
- }
-#else
- for (i = 0; i < 4; i++)
- {
- code = *((uint*)pSrc);
- pSrc += 2;
- *((uint*)pDst) = code;
- pDst += 2;
- status = BitstreamWriteBits(stream, 16, code);
- }
-#endif
- pDst += offset;
- pSrc += offset;
- j--;
- }
-
- return status;
-}
-
-
-AVCEnc_Status enc_residual_block(AVCEncObject *encvid, AVCResidualType type, int cindx, AVCMacroblock *currMB)
-{
- AVCEnc_Status status = AVCENC_SUCCESS;
- AVCCommonObj *video = encvid->common;
- int i, maxNumCoeff, nC;
- int cdc = 0, cac = 0;
- int TrailingOnes;
- AVCEncBitstream *stream = encvid->bitstream;
- uint trailing_ones_sign_flag;
- int zerosLeft;
- int *level, *run;
- int TotalCoeff;
- const static int incVlc[] = {0, 3, 6, 12, 24, 48, 32768}; // maximum vlc = 6
- int escape, numPrefix, sufmask, suffix, shift, sign, value, absvalue, vlcnum, level_two_or_higher;
- int bindx = blkIdx2blkXY[cindx>>2][cindx&3] ; // raster scan index
-
- switch (type)
- {
- case AVC_Luma:
- maxNumCoeff = 16;
- level = encvid->level[cindx];
- run = encvid->run[cindx];
- TotalCoeff = currMB->nz_coeff[bindx];
- break;
- case AVC_Intra16DC:
- maxNumCoeff = 16;
- level = encvid->leveldc;
- run = encvid->rundc;
- TotalCoeff = cindx; /* special case */
- bindx = 0;
- cindx = 0;
- break;
- case AVC_Intra16AC:
- maxNumCoeff = 15;
- level = encvid->level[cindx];
- run = encvid->run[cindx];
- TotalCoeff = currMB->nz_coeff[bindx];
- break;
- case AVC_ChromaDC: /* how to differentiate Cb from Cr */
- maxNumCoeff = 4;
- cdc = 1;
- if (cindx >= 8)
- {
- level = encvid->levelcdc + 4;
- run = encvid->runcdc + 4;
- TotalCoeff = cindx - 8; /* special case */
- }
- else
- {
- level = encvid->levelcdc;
- run = encvid->runcdc;
- TotalCoeff = cindx; /* special case */
- }
- break;
- case AVC_ChromaAC:
- maxNumCoeff = 15;
- cac = 1;
- level = encvid->level[cindx];
- run = encvid->run[cindx];
- cindx -= 16;
- bindx = 16 + blkIdx2blkXY[cindx>>2][cindx&3];
- cindx += 16;
- TotalCoeff = currMB->nz_coeff[bindx];
- break;
- default:
- return AVCENC_FAIL;
- }
-
-
- /* find TrailingOnes */
- TrailingOnes = 0;
- zerosLeft = 0;
- i = TotalCoeff - 1;
- nC = 1;
- while (i >= 0)
- {
- zerosLeft += run[i];
- if (nC && (level[i] == 1 || level[i] == -1))
- {
- TrailingOnes++;
- }
- else
- {
- nC = 0;
- }
- i--;
- }
- if (TrailingOnes > 3)
- {
- TrailingOnes = 3; /* clip it */
- }
-
- if (!cdc)
- {
- if (!cac) /* not chroma */
- {
- nC = predict_nnz(video, bindx & 3, bindx >> 2);
- }
- else /* chroma ac but not chroma dc */
- {
- nC = predict_nnz_chroma(video, bindx & 3, bindx >> 2);
- }
-
- status = ce_TotalCoeffTrailingOnes(stream, TrailingOnes, TotalCoeff, nC);
- }
- else
- {
- nC = -1; /* Chroma DC level */
- status = ce_TotalCoeffTrailingOnesChromaDC(stream, TrailingOnes, TotalCoeff);
- }
-
- /* This part is done quite differently in ReadCoef4x4_CAVLC() */
- if (TotalCoeff > 0)
- {
-
- i = TotalCoeff - 1;
-
- if (TrailingOnes) /* keep reading the sign of those trailing ones */
- {
- nC = TrailingOnes;
- trailing_ones_sign_flag = 0;
- while (nC)
- {
- trailing_ones_sign_flag <<= 1;
- trailing_ones_sign_flag |= ((uint32)level[i--] >> 31); /* 0 or positive, 1 for negative */
- nC--;
- }
-
- /* instead of writing one bit at a time, read the whole thing at once */
- status = BitstreamWriteBits(stream, TrailingOnes, trailing_ones_sign_flag);
- }
-
- level_two_or_higher = 1;
- if (TotalCoeff > 3 && TrailingOnes == 3)
- {
- level_two_or_higher = 0;
- }
-
- if (TotalCoeff > 10 && TrailingOnes < 3)
- {
- vlcnum = 1;
- }
- else
- {
- vlcnum = 0;
- }
-
- /* then do this TotalCoeff-TrailingOnes times */
- for (i = TotalCoeff - TrailingOnes - 1; i >= 0; i--)
- {
- value = level[i];
- absvalue = (value >= 0) ? value : -value;
-
- if (level_two_or_higher)
- {
- if (value > 0) value--;
- else value++;
- level_two_or_higher = 0;
- }
-
- if (value >= 0)
- {
- sign = 0;
- }
- else
- {
- sign = 1;
- value = -value;
- }
-
- if (vlcnum == 0) // VLC1
- {
- if (value < 8)
- {
- status = BitstreamWriteBits(stream, value * 2 + sign - 1, 1);
- }
- else if (value < 8 + 8)
- {
- status = BitstreamWriteBits(stream, 14 + 1 + 4, (1 << 4) | ((value - 8) << 1) | sign);
- }
- else
- {
- status = BitstreamWriteBits(stream, 14 + 2 + 12, (1 << 12) | ((value - 16) << 1) | sign) ;
- }
- }
- else // VLCN
- {
- shift = vlcnum - 1;
- escape = (15 << shift) + 1;
- numPrefix = (value - 1) >> shift;
- sufmask = ~((0xffffffff) << shift);
- suffix = (value - 1) & sufmask;
- if (value < escape)
- {
- status = BitstreamWriteBits(stream, numPrefix + vlcnum + 1, (1 << (shift + 1)) | (suffix << 1) | sign);
- }
- else
- {
- status = BitstreamWriteBits(stream, 28, (1 << 12) | ((value - escape) << 1) | sign);
- }
-
- }
-
- if (absvalue > incVlc[vlcnum])
- vlcnum++;
-
- if (i == TotalCoeff - TrailingOnes - 1 && absvalue > 3)
- vlcnum = 2;
- }
-
- if (status != AVCENC_SUCCESS) /* occasionally check the bitstream */
- {
- return status;
- }
- if (TotalCoeff < maxNumCoeff)
- {
- if (!cdc)
- {
- ce_TotalZeros(stream, zerosLeft, TotalCoeff);
- }
- else
- {
- ce_TotalZerosChromaDC(stream, zerosLeft, TotalCoeff);
- }
- }
- else
- {
- zerosLeft = 0;
- }
-
- i = TotalCoeff - 1;
- while (i > 0) /* don't do the last one */
- {
- if (zerosLeft > 0)
- {
- ce_RunBefore(stream, run[i], zerosLeft);
- }
-
- zerosLeft = zerosLeft - run[i];
- i--;
- }
- }
-
- return status;
-}
diff --git a/media/libstagefright/codecs/avc/enc/src/sad.cpp b/media/libstagefright/codecs/avc/enc/src/sad.cpp
deleted file mode 100644
index ae7acd2..0000000
--- a/media/libstagefright/codecs/avc/enc/src/sad.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-#include "sad_inline.h"
-
-#define Cached_lx 176
-
-#ifdef _SAD_STAT
-uint32 num_sad_MB = 0;
-uint32 num_sad_Blk = 0;
-uint32 num_sad_MB_call = 0;
-uint32 num_sad_Blk_call = 0;
-
-#define NUM_SAD_MB_CALL() num_sad_MB_call++
-#define NUM_SAD_MB() num_sad_MB++
-#define NUM_SAD_BLK_CALL() num_sad_Blk_call++
-#define NUM_SAD_BLK() num_sad_Blk++
-
-#else
-
-#define NUM_SAD_MB_CALL()
-#define NUM_SAD_MB()
-#define NUM_SAD_BLK_CALL()
-#define NUM_SAD_BLK()
-
-#endif
-
-
-/* consist of
-int AVCSAD_Macroblock_C(uint8 *ref,uint8 *blk,int dmin,int lx,void *extra_info)
-int AVCSAD_MB_HTFM_Collect(uint8 *ref,uint8 *blk,int dmin,int lx,void *extra_info)
-int AVCSAD_MB_HTFM(uint8 *ref,uint8 *blk,int dmin,int lx,void *extra_info)
-*/
-
-
-/*==================================================================
- Function: SAD_Macroblock
- Date: 09/07/2000
- Purpose: Compute SAD 16x16 between blk and ref.
- To do: Uniform subsampling will be inserted later!
- Hypothesis Testing Fast Matching to be used later!
- Changes:
- 11/7/00: implemented MMX
- 1/24/01: implemented SSE
-==================================================================*/
-/********** C ************/
-int AVCSAD_Macroblock_C(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info)
-{
- (void)(extra_info);
-
- int32 x10;
- int dmin = (uint32)dmin_lx >> 16;
- int lx = dmin_lx & 0xFFFF;
-
- NUM_SAD_MB_CALL();
-
- x10 = simd_sad_mb(ref, blk, dmin, lx);
-
- return x10;
-}
-
-#ifdef HTFM /* HTFM with uniform subsampling implementation 2/28/01 */
-/*===============================================================
- Function: AVCAVCSAD_MB_HTFM_Collect and AVCSAD_MB_HTFM
- Date: 3/2/1
- Purpose: Compute the SAD on a 16x16 block using
- uniform subsampling and hypothesis testing fast matching
- for early dropout. SAD_MB_HP_HTFM_Collect is to collect
- the statistics to compute the thresholds to be used in
- SAD_MB_HP_HTFM.
- Input/Output:
- Changes:
- ===============================================================*/
-
-int AVCAVCSAD_MB_HTFM_Collect(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info)
-{
- int i;
- int sad = 0;
- uint8 *p1;
- int lx4 = (dmin_lx << 2) & 0x3FFFC;
- uint32 cur_word;
- int saddata[16], tmp, tmp2; /* used when collecting flag (global) is on */
- int difmad;
- int madstar;
- HTFM_Stat *htfm_stat = (HTFM_Stat*) extra_info;
- int *abs_dif_mad_avg = &(htfm_stat->abs_dif_mad_avg);
- uint *countbreak = &(htfm_stat->countbreak);
- int *offsetRef = htfm_stat->offsetRef;
-
- madstar = (uint32)dmin_lx >> 20;
-
- NUM_SAD_MB_CALL();
-
- blk -= 4;
- for (i = 0; i < 16; i++)
- {
- p1 = ref + offsetRef[i];
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = (cur_word >> 24) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[8];
- tmp2 = (cur_word >> 16) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[4];
- tmp2 = (cur_word >> 8) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[0];
- p1 += lx4;
- tmp2 = (cur_word & 0xFF);
- sad = SUB_SAD(sad, tmp, tmp2);
-
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = (cur_word >> 24) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[8];
- tmp2 = (cur_word >> 16) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[4];
- tmp2 = (cur_word >> 8) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[0];
- p1 += lx4;
- tmp2 = (cur_word & 0xFF);
- sad = SUB_SAD(sad, tmp, tmp2);
-
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = (cur_word >> 24) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[8];
- tmp2 = (cur_word >> 16) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[4];
- tmp2 = (cur_word >> 8) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[0];
- p1 += lx4;
- tmp2 = (cur_word & 0xFF);
- sad = SUB_SAD(sad, tmp, tmp2);
-
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = (cur_word >> 24) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[8];
- tmp2 = (cur_word >> 16) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[4];
- tmp2 = (cur_word >> 8) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[0];
- p1 += lx4;
- tmp2 = (cur_word & 0xFF);
- sad = SUB_SAD(sad, tmp, tmp2);
-
- NUM_SAD_MB();
-
- saddata[i] = sad;
-
- if (i > 0)
- {
- if ((uint32)sad > ((uint32)dmin_lx >> 16))
- {
- difmad = saddata[0] - ((saddata[1] + 1) >> 1);
- (*abs_dif_mad_avg) += ((difmad > 0) ? difmad : -difmad);
- (*countbreak)++;
- return sad;
- }
- }
- }
-
- difmad = saddata[0] - ((saddata[1] + 1) >> 1);
- (*abs_dif_mad_avg) += ((difmad > 0) ? difmad : -difmad);
- (*countbreak)++;
- return sad;
-}
-
-int AVCSAD_MB_HTFM(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info)
-{
- int sad = 0;
- uint8 *p1;
-
- int i;
- int tmp, tmp2;
- int lx4 = (dmin_lx << 2) & 0x3FFFC;
- int sadstar = 0, madstar;
- int *nrmlz_th = (int*) extra_info;
- int *offsetRef = (int*) extra_info + 32;
- uint32 cur_word;
-
- madstar = (uint32)dmin_lx >> 20;
-
- NUM_SAD_MB_CALL();
-
- blk -= 4;
- for (i = 0; i < 16; i++)
- {
- p1 = ref + offsetRef[i];
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = (cur_word >> 24) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[8];
- tmp2 = (cur_word >> 16) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[4];
- tmp2 = (cur_word >> 8) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[0];
- p1 += lx4;
- tmp2 = (cur_word & 0xFF);
- sad = SUB_SAD(sad, tmp, tmp2);
-
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = (cur_word >> 24) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[8];
- tmp2 = (cur_word >> 16) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[4];
- tmp2 = (cur_word >> 8) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[0];
- p1 += lx4;
- tmp2 = (cur_word & 0xFF);
- sad = SUB_SAD(sad, tmp, tmp2);
-
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = (cur_word >> 24) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[8];
- tmp2 = (cur_word >> 16) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[4];
- tmp2 = (cur_word >> 8) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[0];
- p1 += lx4;
- tmp2 = (cur_word & 0xFF);
- sad = SUB_SAD(sad, tmp, tmp2);
-
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = (cur_word >> 24) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[8];
- tmp2 = (cur_word >> 16) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[4];
- tmp2 = (cur_word >> 8) & 0xFF;
- sad = SUB_SAD(sad, tmp, tmp2);
- tmp = p1[0];
- p1 += lx4;
- tmp2 = (cur_word & 0xFF);
- sad = SUB_SAD(sad, tmp, tmp2);
-
- NUM_SAD_MB();
-
- sadstar += madstar;
- if (((uint32)sad <= ((uint32)dmin_lx >> 16)) && (sad <= (sadstar - *nrmlz_th++)))
- ;
- else
- return 65536;
- }
-
- return sad;
-}
-#endif /* HTFM */
-
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/sad_halfpel.cpp b/media/libstagefright/codecs/avc/enc/src/sad_halfpel.cpp
deleted file mode 100644
index faf2198..0000000
--- a/media/libstagefright/codecs/avc/enc/src/sad_halfpel.cpp
+++ /dev/null
@@ -1,629 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-/* contains
-int AVCHalfPel1_SAD_MB(uint8 *ref,uint8 *blk,int dmin,int width,int ih,int jh)
-int AVCHalfPel2_SAD_MB(uint8 *ref,uint8 *blk,int dmin,int width)
-int AVCHalfPel1_SAD_Blk(uint8 *ref,uint8 *blk,int dmin,int width,int ih,int jh)
-int AVCHalfPel2_SAD_Blk(uint8 *ref,uint8 *blk,int dmin,int width)
-
-int AVCSAD_MB_HalfPel_C(uint8 *ref,uint8 *blk,int dmin,int width,int rx,int xh,int yh,void *extra_info)
-int AVCSAD_MB_HP_HTFM_Collect(uint8 *ref,uint8 *blk,int dmin,int width,int rx,int xh,int yh,void *extra_info)
-int AVCSAD_MB_HP_HTFM(uint8 *ref,uint8 *blk,int dmin,int width,int rx,int xh,int yh,void *extra_info)
-int AVCSAD_Blk_HalfPel_C(uint8 *ref,uint8 *blk,int dmin,int width,int rx,int xh,int yh,void *extra_info)
-*/
-
-#include "avcenc_lib.h"
-#include "sad_halfpel_inline.h"
-
-#ifdef _SAD_STAT
-uint32 num_sad_HP_MB = 0;
-uint32 num_sad_HP_Blk = 0;
-uint32 num_sad_HP_MB_call = 0;
-uint32 num_sad_HP_Blk_call = 0;
-#define NUM_SAD_HP_MB_CALL() num_sad_HP_MB_call++
-#define NUM_SAD_HP_MB() num_sad_HP_MB++
-#define NUM_SAD_HP_BLK_CALL() num_sad_HP_Blk_call++
-#define NUM_SAD_HP_BLK() num_sad_HP_Blk++
-#else
-#define NUM_SAD_HP_MB_CALL()
-#define NUM_SAD_HP_MB()
-#define NUM_SAD_HP_BLK_CALL()
-#define NUM_SAD_HP_BLK()
-#endif
-
-
-
-/*===============================================================
- Function: SAD_MB_HalfPel
- Date: 09/17/2000
- Purpose: Compute the SAD on the half-pel resolution
- Input/Output: hmem is assumed to be a pointer to the starting
- point of the search in the 33x33 matrix search region
- Changes:
- 11/7/00: implemented MMX
- ===============================================================*/
-/*==================================================================
- Function: AVCSAD_MB_HalfPel_C
- Date: 04/30/2001
- Purpose: Compute SAD 16x16 between blk and ref in halfpel
- resolution,
- Changes:
- ==================================================================*/
-/* One component is half-pel */
-int AVCSAD_MB_HalfPel_Cxhyh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- (void)(extra_info);
-
- int i, j;
- int sad = 0;
- uint8 *kk, *p1, *p2, *p3, *p4;
-// int sumref=0;
- int temp;
- int rx = dmin_rx & 0xFFFF;
-
- NUM_SAD_HP_MB_CALL();
-
- p1 = ref;
- p2 = ref + 1;
- p3 = ref + rx;
- p4 = ref + rx + 1;
- kk = blk;
-
- for (i = 0; i < 16; i++)
- {
- for (j = 0; j < 16; j++)
- {
-
- temp = ((p1[j] + p2[j] + p3[j] + p4[j] + 2) >> 2) - *kk++;
- sad += AVC_ABS(temp);
- }
-
- NUM_SAD_HP_MB();
-
- if (sad > (int)((uint32)dmin_rx >> 16))
- return sad;
-
- p1 += rx;
- p3 += rx;
- p2 += rx;
- p4 += rx;
- }
- return sad;
-}
-
-int AVCSAD_MB_HalfPel_Cyh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- (void)(extra_info);
-
- int i, j;
- int sad = 0;
- uint8 *kk, *p1, *p2;
-// int sumref=0;
- int temp;
- int rx = dmin_rx & 0xFFFF;
-
- NUM_SAD_HP_MB_CALL();
-
- p1 = ref;
- p2 = ref + rx; /* either left/right or top/bottom pixel */
- kk = blk;
-
- for (i = 0; i < 16; i++)
- {
- for (j = 0; j < 16; j++)
- {
-
- temp = ((p1[j] + p2[j] + 1) >> 1) - *kk++;
- sad += AVC_ABS(temp);
- }
-
- NUM_SAD_HP_MB();
-
- if (sad > (int)((uint32)dmin_rx >> 16))
- return sad;
- p1 += rx;
- p2 += rx;
- }
- return sad;
-}
-
-int AVCSAD_MB_HalfPel_Cxh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- (void)(extra_info);
-
- int i, j;
- int sad = 0;
- uint8 *kk, *p1;
- int temp;
- int rx = dmin_rx & 0xFFFF;
-
- NUM_SAD_HP_MB_CALL();
-
- p1 = ref;
- kk = blk;
-
- for (i = 0; i < 16; i++)
- {
- for (j = 0; j < 16; j++)
- {
-
- temp = ((p1[j] + p1[j+1] + 1) >> 1) - *kk++;
- sad += AVC_ABS(temp);
- }
-
- NUM_SAD_HP_MB();
-
- if (sad > (int)((uint32)dmin_rx >> 16))
- return sad;
- p1 += rx;
- }
- return sad;
-}
-
-#ifdef HTFM /* HTFM with uniform subsampling implementation, 2/28/01 */
-
-//Checheck here
-int AVCAVCSAD_MB_HP_HTFM_Collectxhyh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- int i, j;
- int sad = 0;
- uint8 *p1, *p2;
- int rx = dmin_rx & 0xFFFF;
- int refwx4 = rx << 2;
- int saddata[16]; /* used when collecting flag (global) is on */
- int difmad, tmp, tmp2;
- int madstar;
- HTFM_Stat *htfm_stat = (HTFM_Stat*) extra_info;
- int *abs_dif_mad_avg = &(htfm_stat->abs_dif_mad_avg);
- UInt *countbreak = &(htfm_stat->countbreak);
- int *offsetRef = htfm_stat->offsetRef;
- uint32 cur_word;
-
- madstar = (uint32)dmin_rx >> 20;
-
- NUM_SAD_HP_MB_CALL();
-
- blk -= 4;
-
- for (i = 0; i < 16; i++) /* 16 stages */
- {
- p1 = ref + offsetRef[i];
- p2 = p1 + rx;
-
- j = 4;/* 4 lines */
- do
- {
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12] + p2[12];
- tmp2 = p1[13] + p2[13];
- tmp += tmp2;
- tmp2 = (cur_word >> 24) & 0xFF;
- tmp += 2;
- sad = INTERP2_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[8] + p2[8];
- tmp2 = p1[9] + p2[9];
- tmp += tmp2;
- tmp2 = (cur_word >> 16) & 0xFF;
- tmp += 2;
- sad = INTERP2_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[4] + p2[4];
- tmp2 = p1[5] + p2[5];
- tmp += tmp2;
- tmp2 = (cur_word >> 8) & 0xFF;
- tmp += 2;
- sad = INTERP2_SUB_SAD(sad, tmp, tmp2);;
- tmp2 = p1[1] + p2[1];
- tmp = p1[0] + p2[0];
- p1 += refwx4;
- p2 += refwx4;
- tmp += tmp2;
- tmp2 = (cur_word & 0xFF);
- tmp += 2;
- sad = INTERP2_SUB_SAD(sad, tmp, tmp2);;
- }
- while (--j);
-
- NUM_SAD_HP_MB();
-
- saddata[i] = sad;
-
- if (i > 0)
- {
- if (sad > ((uint32)dmin_rx >> 16))
- {
- difmad = saddata[0] - ((saddata[1] + 1) >> 1);
- (*abs_dif_mad_avg) += ((difmad > 0) ? difmad : -difmad);
- (*countbreak)++;
- return sad;
- }
- }
- }
- difmad = saddata[0] - ((saddata[1] + 1) >> 1);
- (*abs_dif_mad_avg) += ((difmad > 0) ? difmad : -difmad);
- (*countbreak)++;
-
- return sad;
-}
-
-int AVCAVCSAD_MB_HP_HTFM_Collectyh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- int i, j;
- int sad = 0;
- uint8 *p1, *p2;
- int rx = dmin_rx & 0xFFFF;
- int refwx4 = rx << 2;
- int saddata[16]; /* used when collecting flag (global) is on */
- int difmad, tmp, tmp2;
- int madstar;
- HTFM_Stat *htfm_stat = (HTFM_Stat*) extra_info;
- int *abs_dif_mad_avg = &(htfm_stat->abs_dif_mad_avg);
- UInt *countbreak = &(htfm_stat->countbreak);
- int *offsetRef = htfm_stat->offsetRef;
- uint32 cur_word;
-
- madstar = (uint32)dmin_rx >> 20;
-
- NUM_SAD_HP_MB_CALL();
-
- blk -= 4;
-
- for (i = 0; i < 16; i++) /* 16 stages */
- {
- p1 = ref + offsetRef[i];
- p2 = p1 + rx;
- j = 4;
- do
- {
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = p2[12];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 24) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[8];
- tmp2 = p2[8];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 16) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[4];
- tmp2 = p2[4];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 8) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[0];
- p1 += refwx4;
- tmp2 = p2[0];
- p2 += refwx4;
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word & 0xFF);
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- }
- while (--j);
-
- NUM_SAD_HP_MB();
-
- saddata[i] = sad;
-
- if (i > 0)
- {
- if (sad > ((uint32)dmin_rx >> 16))
- {
- difmad = saddata[0] - ((saddata[1] + 1) >> 1);
- (*abs_dif_mad_avg) += ((difmad > 0) ? difmad : -difmad);
- (*countbreak)++;
- return sad;
- }
- }
- }
- difmad = saddata[0] - ((saddata[1] + 1) >> 1);
- (*abs_dif_mad_avg) += ((difmad > 0) ? difmad : -difmad);
- (*countbreak)++;
-
- return sad;
-}
-
-int AVCAVCSAD_MB_HP_HTFM_Collectxh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- int i, j;
- int sad = 0;
- uint8 *p1;
- int rx = dmin_rx & 0xFFFF;
- int refwx4 = rx << 2;
- int saddata[16]; /* used when collecting flag (global) is on */
- int difmad, tmp, tmp2;
- int madstar;
- HTFM_Stat *htfm_stat = (HTFM_Stat*) extra_info;
- int *abs_dif_mad_avg = &(htfm_stat->abs_dif_mad_avg);
- UInt *countbreak = &(htfm_stat->countbreak);
- int *offsetRef = htfm_stat->offsetRef;
- uint32 cur_word;
-
- madstar = (uint32)dmin_rx >> 20;
-
- NUM_SAD_HP_MB_CALL();
-
- blk -= 4;
-
- for (i = 0; i < 16; i++) /* 16 stages */
- {
- p1 = ref + offsetRef[i];
-
- j = 4; /* 4 lines */
- do
- {
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = p1[13];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 24) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[8];
- tmp2 = p1[9];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 16) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[4];
- tmp2 = p1[5];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 8) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[0];
- tmp2 = p1[1];
- p1 += refwx4;
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word & 0xFF);
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- }
- while (--j);
-
- NUM_SAD_HP_MB();
-
- saddata[i] = sad;
-
- if (i > 0)
- {
- if (sad > ((uint32)dmin_rx >> 16))
- {
- difmad = saddata[0] - ((saddata[1] + 1) >> 1);
- (*abs_dif_mad_avg) += ((difmad > 0) ? difmad : -difmad);
- (*countbreak)++;
- return sad;
- }
- }
- }
- difmad = saddata[0] - ((saddata[1] + 1) >> 1);
- (*abs_dif_mad_avg) += ((difmad > 0) ? difmad : -difmad);
- (*countbreak)++;
-
- return sad;
-}
-
-int AVCSAD_MB_HP_HTFMxhyh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- int i, j;
- int sad = 0, tmp, tmp2;
- uint8 *p1, *p2;
- int rx = dmin_rx & 0xFFFF;
- int refwx4 = rx << 2;
- int sadstar = 0, madstar;
- int *nrmlz_th = (int*) extra_info;
- int *offsetRef = nrmlz_th + 32;
- uint32 cur_word;
-
- madstar = (uint32)dmin_rx >> 20;
-
- NUM_SAD_HP_MB_CALL();
-
- blk -= 4;
-
- for (i = 0; i < 16; i++) /* 16 stages */
- {
- p1 = ref + offsetRef[i];
- p2 = p1 + rx;
-
- j = 4; /* 4 lines */
- do
- {
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12] + p2[12];
- tmp2 = p1[13] + p2[13];
- tmp += tmp2;
- tmp2 = (cur_word >> 24) & 0xFF;
- tmp += 2;
- sad = INTERP2_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[8] + p2[8];
- tmp2 = p1[9] + p2[9];
- tmp += tmp2;
- tmp2 = (cur_word >> 16) & 0xFF;
- tmp += 2;
- sad = INTERP2_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[4] + p2[4];
- tmp2 = p1[5] + p2[5];
- tmp += tmp2;
- tmp2 = (cur_word >> 8) & 0xFF;
- tmp += 2;
- sad = INTERP2_SUB_SAD(sad, tmp, tmp2);;
- tmp2 = p1[1] + p2[1];
- tmp = p1[0] + p2[0];
- p1 += refwx4;
- p2 += refwx4;
- tmp += tmp2;
- tmp2 = (cur_word & 0xFF);
- tmp += 2;
- sad = INTERP2_SUB_SAD(sad, tmp, tmp2);;
- }
- while (--j);
-
- NUM_SAD_HP_MB();
-
- sadstar += madstar;
- if (sad > sadstar - nrmlz_th[i] || sad > ((uint32)dmin_rx >> 16))
- {
- return 65536;
- }
- }
-
- return sad;
-}
-
-int AVCSAD_MB_HP_HTFMyh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- int i, j;
- int sad = 0, tmp, tmp2;
- uint8 *p1, *p2;
- int rx = dmin_rx & 0xFFFF;
- int refwx4 = rx << 2;
- int sadstar = 0, madstar;
- int *nrmlz_th = (int*) extra_info;
- int *offsetRef = nrmlz_th + 32;
- uint32 cur_word;
-
- madstar = (uint32)dmin_rx >> 20;
-
- NUM_SAD_HP_MB_CALL();
-
- blk -= 4;
-
- for (i = 0; i < 16; i++) /* 16 stages */
- {
- p1 = ref + offsetRef[i];
- p2 = p1 + rx;
- j = 4;
- do
- {
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = p2[12];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 24) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[8];
- tmp2 = p2[8];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 16) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[4];
- tmp2 = p2[4];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 8) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[0];
- p1 += refwx4;
- tmp2 = p2[0];
- p2 += refwx4;
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word & 0xFF);
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- }
- while (--j);
-
- NUM_SAD_HP_MB();
- sadstar += madstar;
- if (sad > sadstar - nrmlz_th[i] || sad > ((uint32)dmin_rx >> 16))
- {
- return 65536;
- }
- }
-
- return sad;
-}
-
-int AVCSAD_MB_HP_HTFMxh(uint8 *ref, uint8 *blk, int dmin_rx, void *extra_info)
-{
- int i, j;
- int sad = 0, tmp, tmp2;
- uint8 *p1;
- int rx = dmin_rx & 0xFFFF;
- int refwx4 = rx << 2;
- int sadstar = 0, madstar;
- int *nrmlz_th = (int*) extra_info;
- int *offsetRef = nrmlz_th + 32;
- uint32 cur_word;
-
- madstar = (uint32)dmin_rx >> 20;
-
- NUM_SAD_HP_MB_CALL();
-
- blk -= 4;
-
- for (i = 0; i < 16; i++) /* 16 stages */
- {
- p1 = ref + offsetRef[i];
-
- j = 4;/* 4 lines */
- do
- {
- cur_word = *((uint32*)(blk += 4));
- tmp = p1[12];
- tmp2 = p1[13];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 24) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[8];
- tmp2 = p1[9];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 16) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[4];
- tmp2 = p1[5];
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word >> 8) & 0xFF;
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- tmp = p1[0];
- tmp2 = p1[1];
- p1 += refwx4;
- tmp++;
- tmp2 += tmp;
- tmp = (cur_word & 0xFF);
- sad = INTERP1_SUB_SAD(sad, tmp, tmp2);;
- }
- while (--j);
-
- NUM_SAD_HP_MB();
-
- sadstar += madstar;
- if (sad > sadstar - nrmlz_th[i] || sad > ((uint32)dmin_rx >> 16))
- {
- return 65536;
- }
- }
-
- return sad;
-}
-
-#endif /* HTFM */
-
-
-
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/sad_halfpel_inline.h b/media/libstagefright/codecs/avc/enc/src/sad_halfpel_inline.h
deleted file mode 100644
index 22f545a..0000000
--- a/media/libstagefright/codecs/avc/enc/src/sad_halfpel_inline.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-
-#ifndef _SAD_HALFPEL_INLINE_H_
-#define _SAD_HALFPEL_INLINE_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Intentionally not using the gcc asm version, since it is
- * slightly slower than the plain C version on modern GCC versions. */
-#if !defined(__CC_ARM) /* Generic C version */
-
- __inline int32 INTERP1_SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- tmp = (tmp2 >> 1) - tmp;
- if (tmp > 0) sad += tmp;
- else sad -= tmp;
-
- return sad;
- }
-
- __inline int32 INTERP2_SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- tmp = (tmp >> 2) - tmp2;
- if (tmp > 0) sad += tmp;
- else sad -= tmp;
-
- return sad;
- }
-
-#elif defined(__CC_ARM) /* only work with arm v5 */
-
- __inline int32 INTERP1_SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- __asm
- {
- rsbs tmp, tmp, tmp2, asr #1 ;
- rsbmi tmp, tmp, #0 ;
- add sad, sad, tmp ;
- }
-
- return sad;
- }
-
- __inline int32 INTERP2_SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- __asm
- {
- rsbs tmp, tmp2, tmp, asr #2 ;
- rsbmi tmp, tmp, #0 ;
- add sad, sad, tmp ;
- }
-
- return sad;
- }
-
-#elif defined(__GNUC__) && defined(__arm__) /* ARM GNU COMPILER */
-
- __inline int32 INTERP1_SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- __asm__ volatile(
- "rsbs %1, %1, %2, asr #1\n\t"
- "rsbmi %1, %1, #0\n\t"
- "add %0, %0, %1"
- : "+r"(sad), "+r"(tmp)
- : "r"(tmp2)
- );
-
- return sad;
- }
-
- __inline int32 INTERP2_SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- __asm__ volatile(
- "rsbs %1, %2, %1, asr #2\n\t"
- "rsbmi %1, %1, #0\n\t"
- "add %0, %0, %1"
- : "+r"(sad), "+r"(tmp)
- : "r"(tmp2)
- );
-
- return sad;
- }
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //_SAD_HALFPEL_INLINE_H_
-
diff --git a/media/libstagefright/codecs/avc/enc/src/sad_inline.h b/media/libstagefright/codecs/avc/enc/src/sad_inline.h
deleted file mode 100644
index 47abc65..0000000
--- a/media/libstagefright/codecs/avc/enc/src/sad_inline.h
+++ /dev/null
@@ -1,526 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#ifndef _SAD_INLINE_H_
-#define _SAD_INLINE_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Intentionally not using the gcc asm version, since it is
- * slightly slower than the plain C version on modern GCC versions. */
-#if !defined(__CC_ARM) /* Generic C version */
-
- __inline int32 SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- tmp = tmp - tmp2;
- if (tmp > 0) sad += tmp;
- else sad -= tmp;
-
- return sad;
- }
-
- __inline int32 sad_4pixel(int32 src1, int32 src2, int32 mask)
- {
- int32 x7;
-
- x7 = src2 ^ src1; /* check odd/even combination */
- if ((uint32)src2 >= (uint32)src1)
- {
- src1 = src2 - src1; /* subs */
- }
- else
- {
- src1 = src1 - src2;
- }
- x7 = x7 ^ src1; /* only odd bytes need to add carry */
- x7 = mask & ((uint32)x7 >> 1);
- x7 = (x7 << 8) - x7;
- src1 = src1 + (x7 >> 7); /* add 0xFF to the negative byte, add back carry */
- src1 = src1 ^(x7 >> 7); /* take absolute value of negative byte */
-
- return src1;
- }
-
-#define NUMBER 3
-#define SHIFT 24
-
-#include "sad_mb_offset.h"
-
-#undef NUMBER
-#define NUMBER 2
-#undef SHIFT
-#define SHIFT 16
-#include "sad_mb_offset.h"
-
-#undef NUMBER
-#define NUMBER 1
-#undef SHIFT
-#define SHIFT 8
-#include "sad_mb_offset.h"
-
-
- __inline int32 simd_sad_mb(uint8 *ref, uint8 *blk, int dmin, int lx)
- {
- int32 x4, x5, x6, x8, x9, x10, x11, x12, x14;
-
- x9 = 0x80808080; /* const. */
-
- x8 = (intptr_t)ref & 0x3;
- if (x8 == 3)
- goto SadMBOffset3;
- if (x8 == 2)
- goto SadMBOffset2;
- if (x8 == 1)
- goto SadMBOffset1;
-
-// x5 = (x4<<8)-x4; /* x5 = x4*255; */
- x4 = x5 = 0;
-
- x6 = 0xFFFF00FF;
-
- ref -= lx;
- blk -= 16;
-
- x8 = 16;
-
-LOOP_SAD0:
- /****** process 8 pixels ******/
- x10 = *((uint32*)(ref += lx));
- x11 = *((uint32*)(ref + 4));
- x12 = *((uint32*)(blk += 16));
- x14 = *((uint32*)(blk + 4));
-
- /* process x11 & x14 */
- x11 = sad_4pixel(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixel(x10, x12, x9);
-
- x5 = x5 + x10; /* accumulate low bytes */
- x10 = x10 & (x6 << 8); /* x10 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x10 >> 8); /* accumulate high bytes */
- x5 = x5 + x11; /* accumulate low bytes */
- x11 = x11 & (x6 << 8); /* x11 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x11 >> 8); /* accumulate high bytes */
-
- /****** process 8 pixels ******/
- x10 = *((uint32*)(ref + 8));
- x11 = *((uint32*)(ref + 12));
- x12 = *((uint32*)(blk + 8));
- x14 = *((uint32*)(blk + 12));
-
- /* process x11 & x14 */
- x11 = sad_4pixel(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixel(x10, x12, x9);
-
- x5 = x5 + x10; /* accumulate low bytes */
- x10 = x10 & (x6 << 8); /* x10 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x10 >> 8); /* accumulate high bytes */
- x5 = x5 + x11; /* accumulate low bytes */
- x11 = x11 & (x6 << 8); /* x11 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x11 >> 8); /* accumulate high bytes */
-
- /****************/
- x10 = x5 - (x4 << 8); /* extract low bytes */
- x10 = x10 + x4; /* add with high bytes */
- x10 = x10 + (x10 << 16); /* add with lower half word */
-
- if ((int)((uint32)x10 >> 16) <= dmin) /* compare with dmin */
- {
- if (--x8)
- {
- goto LOOP_SAD0;
- }
-
- }
-
- return ((uint32)x10 >> 16);
-
-SadMBOffset3:
-
- return sad_mb_offset3(ref, blk, lx, dmin);
-
-SadMBOffset2:
-
- return sad_mb_offset2(ref, blk, lx, dmin);
-
-SadMBOffset1:
-
- return sad_mb_offset1(ref, blk, lx, dmin);
-
- }
-
-#elif defined(__CC_ARM) /* only work with arm v5 */
-
- __inline int32 SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- __asm
- {
- rsbs tmp, tmp, tmp2 ;
- rsbmi tmp, tmp, #0 ;
- add sad, sad, tmp ;
- }
-
- return sad;
- }
-
- __inline int32 sad_4pixel(int32 src1, int32 src2, int32 mask)
- {
- int32 x7;
-
- __asm
- {
- EOR x7, src2, src1; /* check odd/even combination */
- SUBS src1, src2, src1;
- EOR x7, x7, src1;
- AND x7, mask, x7, lsr #1;
- ORRCC x7, x7, #0x80000000;
- RSB x7, x7, x7, lsl #8;
- ADD src1, src1, x7, asr #7; /* add 0xFF to the negative byte, add back carry */
- EOR src1, src1, x7, asr #7; /* take absolute value of negative byte */
- }
-
- return src1;
- }
-
- __inline int32 sad_4pixelN(int32 src1, int32 src2, int32 mask)
- {
- int32 x7;
-
- __asm
- {
- EOR x7, src2, src1; /* check odd/even combination */
- ADDS src1, src2, src1;
- EOR x7, x7, src1; /* only odd bytes need to add carry */
- ANDS x7, mask, x7, rrx;
- RSB x7, x7, x7, lsl #8;
- SUB src1, src1, x7, asr #7; /* add 0xFF to the negative byte, add back carry */
- EOR src1, src1, x7, asr #7; /* take absolute value of negative byte */
- }
-
- return src1;
- }
-
-#define sum_accumulate __asm{ SBC x5, x5, x10; /* accumulate low bytes */ \
- BIC x10, x6, x10; /* x10 & 0xFF00FF00 */ \
- ADD x4, x4, x10,lsr #8; /* accumulate high bytes */ \
- SBC x5, x5, x11; /* accumulate low bytes */ \
- BIC x11, x6, x11; /* x11 & 0xFF00FF00 */ \
- ADD x4, x4, x11,lsr #8; } /* accumulate high bytes */
-
-
-#define NUMBER 3
-#define SHIFT 24
-#define INC_X8 0x08000001
-
-#include "sad_mb_offset.h"
-
-#undef NUMBER
-#define NUMBER 2
-#undef SHIFT
-#define SHIFT 16
-#undef INC_X8
-#define INC_X8 0x10000001
-#include "sad_mb_offset.h"
-
-#undef NUMBER
-#define NUMBER 1
-#undef SHIFT
-#define SHIFT 8
-#undef INC_X8
-#define INC_X8 0x08000001
-#include "sad_mb_offset.h"
-
-
- __inline int32 simd_sad_mb(uint8 *ref, uint8 *blk, int dmin, int lx)
- {
- int32 x4, x5, x6, x8, x9, x10, x11, x12, x14;
-
- x9 = 0x80808080; /* const. */
- x4 = x5 = 0;
-
- __asm
- {
- MOVS x8, ref, lsl #31 ;
- BHI SadMBOffset3;
- BCS SadMBOffset2;
- BMI SadMBOffset1;
-
- MVN x6, #0xFF00;
- }
-LOOP_SAD0:
- /****** process 8 pixels ******/
- x11 = *((int32*)(ref + 12));
- x10 = *((int32*)(ref + 8));
- x14 = *((int32*)(blk + 12));
- x12 = *((int32*)(blk + 8));
-
- /* process x11 & x14 */
- x11 = sad_4pixel(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixel(x10, x12, x9);
-
- x5 = x5 + x10; /* accumulate low bytes */
- x10 = x10 & (x6 << 8); /* x10 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x10 >> 8); /* accumulate high bytes */
- x5 = x5 + x11; /* accumulate low bytes */
- x11 = x11 & (x6 << 8); /* x11 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x11 >> 8); /* accumulate high bytes */
-
- __asm
- {
- /****** process 8 pixels ******/
- LDR x11, [ref, #4];
- LDR x10, [ref], lx ;
- LDR x14, [blk, #4];
- LDR x12, [blk], #16 ;
- }
-
- /* process x11 & x14 */
- x11 = sad_4pixel(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixel(x10, x12, x9);
-
- x5 = x5 + x10; /* accumulate low bytes */
- x10 = x10 & (x6 << 8); /* x10 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x10 >> 8); /* accumulate high bytes */
- x5 = x5 + x11; /* accumulate low bytes */
- x11 = x11 & (x6 << 8); /* x11 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x11 >> 8); /* accumulate high bytes */
-
- /****************/
- x10 = x5 - (x4 << 8); /* extract low bytes */
- x10 = x10 + x4; /* add with high bytes */
- x10 = x10 + (x10 << 16); /* add with lower half word */
-
- __asm
- {
- /****************/
- RSBS x11, dmin, x10, lsr #16;
- ADDLSS x8, x8, #0x10000001;
- BLS LOOP_SAD0;
- }
-
- return ((uint32)x10 >> 16);
-
-SadMBOffset3:
-
- return sad_mb_offset3(ref, blk, lx, dmin, x8);
-
-SadMBOffset2:
-
- return sad_mb_offset2(ref, blk, lx, dmin, x8);
-
-SadMBOffset1:
-
- return sad_mb_offset1(ref, blk, lx, dmin, x8);
- }
-
-
-#elif defined(__GNUC__) && defined(__arm__) /* ARM GNU COMPILER */
-
- __inline int32 SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
- {
- __asm__ volatile(
- "rsbs %1, %1, %2\n\t"
- "rsbmi %1, %1, #0\n\t"
- "add %0, %0, %1"
- : "+r"(sad), "+r"(tmp)
- : "r"(tmp2)
- );
- return sad;
- }
-
- __inline int32 sad_4pixel(int32 src1, int32 src2, int32 mask)
- {
- int32 x7;
-
- __asm__ volatile(
- "EOR %1, %2, %0\n\t"
- "SUBS %0, %2, %0\n\t"
- "EOR %1, %1, %0\n\t"
- "AND %1, %3, %1, lsr #1\n\t"
- "ORRCC %1, %1, #0x80000000\n\t"
- "RSB %1, %1, %1, lsl #8\n\t"
- "ADD %0, %0, %1, asr #7\n\t"
- "EOR %0, %0, %1, asr #7"
- : "+r"(src1), "=&r"(x7)
- : "r"(src2), "r"(mask)
- );
-
- return src1;
- }
-
- __inline int32 sad_4pixelN(int32 src1, int32 src2, int32 mask)
- {
- int32 x7;
-
- __asm__ volatile(
- "EOR %1, %2, %0\n\t"
- "ADDS %0, %2, %0\n\t"
- "EOR %1, %1, %0\n\t"
- "ANDS %1, %3, %1, rrx\n\t"
- "RSB %1, %1, %1, lsl #8\n\t"
- "SUB %0, %0, %1, asr #7\n\t"
- "EOR %0, %0, %1, asr #7"
- : "+r"(src1), "=&r"(x7)
- : "r"(src2), "r"(mask)
- );
-
- return src1;
- }
-
-#define sum_accumulate __asm__ volatile( \
- "SBC %0, %0, %1\n\t" \
- "BIC %1, %4, %1\n\t" \
- "ADD %2, %2, %1, lsr #8\n\t" \
- "SBC %0, %0, %3\n\t" \
- "BIC %3, %4, %3\n\t" \
- "ADD %2, %2, %3, lsr #8" \
- : "+r" (x5), "+r" (x10), "+r" (x4), "+r" (x11) \
- : "r" (x6) \
- );
-
-#define NUMBER 3
-#define SHIFT 24
-#define INC_X8 0x08000001
-
-#include "sad_mb_offset.h"
-
-#undef NUMBER
-#define NUMBER 2
-#undef SHIFT
-#define SHIFT 16
-#undef INC_X8
-#define INC_X8 0x10000001
-#include "sad_mb_offset.h"
-
-#undef NUMBER
-#define NUMBER 1
-#undef SHIFT
-#define SHIFT 8
-#undef INC_X8
-#define INC_X8 0x08000001
-#include "sad_mb_offset.h"
-
-
- __inline int32 simd_sad_mb(uint8 *ref, uint8 *blk, int dmin, int lx)
- {
- int32 x4, x5, x6, x8, x9, x10, x11, x12, x14;
-
- x9 = 0x80808080; /* const. */
- x4 = x5 = 0;
-
- x8 = (uint32)ref & 0x3;
- if (x8 == 3)
- goto SadMBOffset3;
- if (x8 == 2)
- goto SadMBOffset2;
- if (x8 == 1)
- goto SadMBOffset1;
-
- x8 = 16;
-///
- __asm__ volatile("MVN %0, #0xFF00": "=r"(x6));
-
-LOOP_SAD0:
- /****** process 8 pixels ******/
- x11 = *((int32*)(ref + 12));
- x10 = *((int32*)(ref + 8));
- x14 = *((int32*)(blk + 12));
- x12 = *((int32*)(blk + 8));
-
- /* process x11 & x14 */
- x11 = sad_4pixel(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixel(x10, x12, x9);
-
- x5 = x5 + x10; /* accumulate low bytes */
- x10 = x10 & (x6 << 8); /* x10 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x10 >> 8); /* accumulate high bytes */
- x5 = x5 + x11; /* accumulate low bytes */
- x11 = x11 & (x6 << 8); /* x11 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x11 >> 8); /* accumulate high bytes */
-
- /****** process 8 pixels ******/
- x11 = *((int32*)(ref + 4));
- __asm__ volatile("LDR %0, [%1], %2": "=&r"(x10), "+r"(ref): "r"(lx));
- //x10 = *((int32*)ref); ref+=lx;
- x14 = *((int32*)(blk + 4));
- __asm__ volatile("LDR %0, [%1], #16": "=&r"(x12), "+r"(blk));
-
- /* process x11 & x14 */
- x11 = sad_4pixel(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixel(x10, x12, x9);
-
- x5 = x5 + x10; /* accumulate low bytes */
- x10 = x10 & (x6 << 8); /* x10 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x10 >> 8); /* accumulate high bytes */
- x5 = x5 + x11; /* accumulate low bytes */
- x11 = x11 & (x6 << 8); /* x11 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x11 >> 8); /* accumulate high bytes */
-
- /****************/
- x10 = x5 - (x4 << 8); /* extract low bytes */
- x10 = x10 + x4; /* add with high bytes */
- x10 = x10 + (x10 << 16); /* add with lower half word */
-
- /****************/
-
- if (((uint32)x10 >> 16) <= dmin) /* compare with dmin */
- {
- if (--x8)
- {
- goto LOOP_SAD0;
- }
-
- }
-
- return ((uint32)x10 >> 16);
-
-SadMBOffset3:
-
- return sad_mb_offset3(ref, blk, lx, dmin);
-
-SadMBOffset2:
-
- return sad_mb_offset2(ref, blk, lx, dmin);
-
-SadMBOffset1:
-
- return sad_mb_offset1(ref, blk, lx, dmin);
- }
-
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _SAD_INLINE_H_
-
diff --git a/media/libstagefright/codecs/avc/enc/src/sad_mb_offset.h b/media/libstagefright/codecs/avc/enc/src/sad_mb_offset.h
deleted file mode 100644
index 20ca7eb..0000000
--- a/media/libstagefright/codecs/avc/enc/src/sad_mb_offset.h
+++ /dev/null
@@ -1,355 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-
-/* Intentionally not using the gcc asm version, since it is
- * slightly slower than the plain C version on modern GCC versions. */
-#if !defined(__CC_ARM) /* Generic C version */
-
-#if (NUMBER==3)
-__inline int32 sad_mb_offset3(uint8 *ref, uint8 *blk, int lx, int dmin)
-#elif (NUMBER==2)
-__inline int32 sad_mb_offset2(uint8 *ref, uint8 *blk, int lx, int dmin)
-#elif (NUMBER==1)
-__inline int32 sad_mb_offset1(uint8 *ref, uint8 *blk, int lx, int dmin)
-#endif
-{
- int32 x4, x5, x6, x8, x9, x10, x11, x12, x14;
-
- // x5 = (x4<<8) - x4;
- x4 = x5 = 0;
- x6 = 0xFFFF00FF;
- x9 = 0x80808080; /* const. */
- ref -= NUMBER; /* bic ref, ref, #3 */
- ref -= lx;
- blk -= 16;
- x8 = 16;
-
-#if (NUMBER==3)
-LOOP_SAD3:
-#elif (NUMBER==2)
-LOOP_SAD2:
-#elif (NUMBER==1)
-LOOP_SAD1:
-#endif
- /****** process 8 pixels ******/
- x10 = *((uint32*)(ref += lx)); /* D C B A */
- x11 = *((uint32*)(ref + 4)); /* H G F E */
- x12 = *((uint32*)(ref + 8)); /* L K J I */
-
- x10 = ((uint32)x10 >> SHIFT); /* 0 0 0 D */
- x10 = x10 | (x11 << (32 - SHIFT)); /* G F E D */
- x11 = ((uint32)x11 >> SHIFT); /* 0 0 0 H */
- x11 = x11 | (x12 << (32 - SHIFT)); /* K J I H */
-
- x12 = *((uint32*)(blk += 16));
- x14 = *((uint32*)(blk + 4));
-
- /* process x11 & x14 */
- x11 = sad_4pixel(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixel(x10, x12, x9);
-
- x5 = x5 + x10; /* accumulate low bytes */
- x10 = x10 & (x6 << 8); /* x10 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x10 >> 8); /* accumulate high bytes */
- x5 = x5 + x11; /* accumulate low bytes */
- x11 = x11 & (x6 << 8); /* x11 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x11 >> 8); /* accumulate high bytes */
-
- /****** process 8 pixels ******/
- x10 = *((uint32*)(ref + 8)); /* D C B A */
- x11 = *((uint32*)(ref + 12)); /* H G F E */
- x12 = *((uint32*)(ref + 16)); /* L K J I */
-
- x10 = ((uint32)x10 >> SHIFT); /* mvn x10, x10, lsr #24 = 0xFF 0xFF 0xFF ~D */
- x10 = x10 | (x11 << (32 - SHIFT)); /* bic x10, x10, x11, lsl #8 = ~G ~F ~E ~D */
- x11 = ((uint32)x11 >> SHIFT); /* 0xFF 0xFF 0xFF ~H */
- x11 = x11 | (x12 << (32 - SHIFT)); /* ~K ~J ~I ~H */
-
- x12 = *((uint32*)(blk + 8));
- x14 = *((uint32*)(blk + 12));
-
- /* process x11 & x14 */
- x11 = sad_4pixel(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixel(x10, x12, x9);
-
- x5 = x5 + x10; /* accumulate low bytes */
- x10 = x10 & (x6 << 8); /* x10 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x10 >> 8); /* accumulate high bytes */
- x5 = x5 + x11; /* accumulate low bytes */
- x11 = x11 & (x6 << 8); /* x11 & 0xFF00FF00 */
- x4 = x4 + ((uint32)x11 >> 8); /* accumulate high bytes */
-
- /****************/
- x10 = x5 - (x4 << 8); /* extract low bytes */
- x10 = x10 + x4; /* add with high bytes */
- x10 = x10 + (x10 << 16); /* add with lower half word */
-
- if ((int)((uint32)x10 >> 16) <= dmin) /* compare with dmin */
- {
- if (--x8)
- {
-#if (NUMBER==3)
- goto LOOP_SAD3;
-#elif (NUMBER==2)
- goto LOOP_SAD2;
-#elif (NUMBER==1)
- goto LOOP_SAD1;
-#endif
- }
-
- }
-
- return ((uint32)x10 >> 16);
-}
-
-#elif defined(__CC_ARM) /* only work with arm v5 */
-
-#if (NUMBER==3)
-__inline int32 sad_mb_offset3(uint8 *ref, uint8 *blk, int lx, int dmin, int32 x8)
-#elif (NUMBER==2)
-__inline int32 sad_mb_offset2(uint8 *ref, uint8 *blk, int lx, int dmin, int32 x8)
-#elif (NUMBER==1)
-__inline int32 sad_mb_offset1(uint8 *ref, uint8 *blk, int lx, int dmin, int32 x8)
-#endif
-{
- int32 x4, x5, x6, x9, x10, x11, x12, x14;
-
- x9 = 0x80808080; /* const. */
- x4 = x5 = 0;
-
- __asm{
- MVN x6, #0xff0000;
-#if (NUMBER==3)
-LOOP_SAD3:
-#elif (NUMBER==2)
-LOOP_SAD2:
-#elif (NUMBER==1)
-LOOP_SAD1:
-#endif
- BIC ref, ref, #3;
- }
- /****** process 8 pixels ******/
- x11 = *((int32*)(ref + 12));
- x12 = *((int32*)(ref + 16));
- x10 = *((int32*)(ref + 8));
- x14 = *((int32*)(blk + 12));
-
- __asm{
- MVN x10, x10, lsr #SHIFT;
- BIC x10, x10, x11, lsl #(32-SHIFT);
- MVN x11, x11, lsr #SHIFT;
- BIC x11, x11, x12, lsl #(32-SHIFT);
-
- LDR x12, [blk, #8];
- }
-
- /* process x11 & x14 */
- x11 = sad_4pixelN(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixelN(x10, x12, x9);
-
- sum_accumulate;
-
- __asm{
- /****** process 8 pixels ******/
- LDR x11, [ref, #4];
- LDR x12, [ref, #8];
- LDR x10, [ref], lx ;
- LDR x14, [blk, #4];
-
- MVN x10, x10, lsr #SHIFT;
- BIC x10, x10, x11, lsl #(32-SHIFT);
- MVN x11, x11, lsr #SHIFT;
- BIC x11, x11, x12, lsl #(32-SHIFT);
-
- LDR x12, [blk], #16;
- }
-
- /* process x11 & x14 */
- x11 = sad_4pixelN(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixelN(x10, x12, x9);
-
- sum_accumulate;
-
- /****************/
- x10 = x5 - (x4 << 8); /* extract low bytes */
- x10 = x10 + x4; /* add with high bytes */
- x10 = x10 + (x10 << 16); /* add with lower half word */
-
- __asm{
- RSBS x11, dmin, x10, lsr #16
- ADDLSS x8, x8, #INC_X8
-#if (NUMBER==3)
- BLS LOOP_SAD3;
-#elif (NUMBER==2)
-BLS LOOP_SAD2;
-#elif (NUMBER==1)
-BLS LOOP_SAD1;
-#endif
- }
-
- return ((uint32)x10 >> 16);
-}
-
-#elif defined(__GNUC__) && defined(__arm__) /* ARM GNU COMPILER */
-
-#if (NUMBER==3)
-__inline int32 sad_mb_offset3(uint8 *ref, uint8 *blk, int lx, int dmin)
-#elif (NUMBER==2)
-__inline int32 sad_mb_offset2(uint8 *ref, uint8 *blk, int lx, int dmin)
-#elif (NUMBER==1)
-__inline int32 sad_mb_offset1(uint8 *ref, uint8 *blk, int lx, int dmin)
-#endif
-{
- int32 x4, x5, x6, x8, x9, x10, x11, x12, x14;
-
- x9 = 0x80808080; /* const. */
- x4 = x5 = 0;
- x8 = 16; //<<===========*******
-
- __asm__ volatile("MVN %0, #0xFF0000": "=r"(x6));
-
-#if (NUMBER==3)
-LOOP_SAD3:
-#elif (NUMBER==2)
-LOOP_SAD2:
-#elif (NUMBER==1)
-LOOP_SAD1:
-#endif
- __asm__ volatile("BIC %0, %0, #3": "+r"(ref));
- /****** process 8 pixels ******/
- x11 = *((int32*)(ref + 12));
- x12 = *((int32*)(ref + 16));
- x10 = *((int32*)(ref + 8));
- x14 = *((int32*)(blk + 12));
-
-#if (SHIFT==8)
- __asm__ volatile(
- "MVN %0, %0, lsr #8\n\t"
- "BIC %0, %0, %1, lsl #24\n\t"
- "MVN %1, %1, lsr #8\n\t"
- "BIC %1, %1, %2, lsl #24"
- : "+r"(x10), "+r"(x11)
- : "r"(x12)
- );
-#elif (SHIFT==16)
- __asm__ volatile(
- "MVN %0, %0, lsr #16\n\t"
- "BIC %0, %0, %1, lsl #16\n\t"
- "MVN %1, %1, lsr #16\n\t"
- "BIC %1, %1, %2, lsl #16"
- : "+r"(x10), "+r"(x11)
- : "r"(x12)
- );
-#elif (SHIFT==24)
- __asm__ volatile(
- "MVN %0, %0, lsr #24\n\t"
- "BIC %0, %0, %1, lsl #8\n\t"
- "MVN %1, %1, lsr #24\n\t"
- "BIC %1, %1, %2, lsl #8"
- : "+r"(x10), "+r"(x11)
- : "r"(x12)
- );
-#endif
-
- x12 = *((int32*)(blk + 8));
-
- /* process x11 & x14 */
- x11 = sad_4pixelN(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixelN(x10, x12, x9);
-
- sum_accumulate;
-
- /****** process 8 pixels ******/
- x11 = *((int32*)(ref + 4));
- x12 = *((int32*)(ref + 8));
- x10 = *((int32*)ref); ref += lx;
- x14 = *((int32*)(blk + 4));
-
-#if (SHIFT==8)
- __asm__ volatile(
- "MVN %0, %0, lsr #8\n\t"
- "BIC %0, %0, %1, lsl #24\n\t"
- "MVN %1, %1, lsr #8\n\t"
- "BIC %1, %1, %2, lsl #24"
- : "+r"(x10), "+r"(x11)
- : "r"(x12)
- );
-#elif (SHIFT==16)
- __asm__ volatile(
- "MVN %0, %0, lsr #16\n\t"
- "BIC %0, %0, %1, lsl #16\n\t"
- "MVN %1, %1, lsr #16\n\t"
- "BIC %1, %1, %2, lsl #16"
- : "+r"(x10), "+r"(x11)
- : "r"(x12)
- );
-#elif (SHIFT==24)
- __asm__ volatile(
- "MVN %0, %0, lsr #24\n\t"
- "BIC %0, %0, %1, lsl #8\n\t"
- "MVN %1, %1, lsr #24\n\t"
- "BIC %1, %1, %2, lsl #8"
- : "+r"(x10), "+r"(x11)
- : "r"(x12)
- );
-#endif
- __asm__ volatile("LDR %0, [%1], #16": "=&r"(x12), "+r"(blk));
-
- /* process x11 & x14 */
- x11 = sad_4pixelN(x11, x14, x9);
-
- /* process x12 & x10 */
- x10 = sad_4pixelN(x10, x12, x9);
-
- sum_accumulate;
-
- /****************/
- x10 = x5 - (x4 << 8); /* extract low bytes */
- x10 = x10 + x4; /* add with high bytes */
- x10 = x10 + (x10 << 16); /* add with lower half word */
-
- if (((uint32)x10 >> 16) <= (uint32)dmin) /* compare with dmin */
- {
- if (--x8)
- {
-#if (NUMBER==3)
- goto LOOP_SAD3;
-#elif (NUMBER==2)
- goto LOOP_SAD2;
-#elif (NUMBER==1)
- goto LOOP_SAD1;
-#endif
- }
-
- }
-
- return ((uint32)x10 >> 16);
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/avc/enc/src/slice.cpp b/media/libstagefright/codecs/avc/enc/src/slice.cpp
deleted file mode 100644
index f6d066e..0000000
--- a/media/libstagefright/codecs/avc/enc/src/slice.cpp
+++ /dev/null
@@ -1,1025 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-
-
-AVCEnc_Status AVCEncodeSlice(AVCEncObject *encvid)
-{
- AVCEnc_Status status = AVCENC_SUCCESS;
- AVCCommonObj *video = encvid->common;
- AVCPicParamSet *pps = video->currPicParams;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- AVCMacroblock *currMB ;
- AVCEncBitstream *stream = encvid->bitstream;
- uint slice_group_id;
- int CurrMbAddr, slice_type;
-
- slice_type = video->slice_type;
-
- /* set the first mb in slice */
- video->mbNum = CurrMbAddr = sliceHdr->first_mb_in_slice;// * (1+video->MbaffFrameFlag);
- slice_group_id = video->MbToSliceGroupMap[CurrMbAddr];
-
- video->mb_skip_run = 0;
-
- /* while loop , see subclause 7.3.4 */
- while (1)
- {
- video->mbNum = CurrMbAddr;
- currMB = video->currMB = &(video->mblock[CurrMbAddr]);
- currMB->slice_id = video->slice_id; // for deblocking
-
- video->mb_x = CurrMbAddr % video->PicWidthInMbs;
- video->mb_y = CurrMbAddr / video->PicWidthInMbs;
-
- /* initialize QP for this MB here*/
- /* calculate currMB->QPy */
- RCInitMBQP(encvid);
-
- /* check the availability of neighboring macroblocks */
- InitNeighborAvailability(video, CurrMbAddr);
-
- /* Assuming that InitNeighborAvailability has been called prior to this function */
- video->intraAvailA = video->intraAvailB = video->intraAvailC = video->intraAvailD = 0;
- /* this is necessary for all subsequent intra search */
-
- if (!video->currPicParams->constrained_intra_pred_flag)
- {
- video->intraAvailA = video->mbAvailA;
- video->intraAvailB = video->mbAvailB;
- video->intraAvailC = video->mbAvailC;
- video->intraAvailD = video->mbAvailD;
- }
- else
- {
- if (video->mbAvailA)
- {
- video->intraAvailA = video->mblock[video->mbAddrA].mb_intra;
- }
- if (video->mbAvailB)
- {
- video->intraAvailB = video->mblock[video->mbAddrB].mb_intra ;
- }
- if (video->mbAvailC)
- {
- video->intraAvailC = video->mblock[video->mbAddrC].mb_intra;
- }
- if (video->mbAvailD)
- {
- video->intraAvailD = video->mblock[video->mbAddrD].mb_intra;
- }
- }
-
- /* encode_one_macroblock() */
- status = EncodeMB(encvid);
- if (status != AVCENC_SUCCESS)
- {
- break;
- }
-
- /* go to next MB */
- CurrMbAddr++;
-
- while ((uint)video->MbToSliceGroupMap[CurrMbAddr] != slice_group_id &&
- (uint)CurrMbAddr < video->PicSizeInMbs)
- {
- CurrMbAddr++;
- }
-
- if ((uint)CurrMbAddr >= video->PicSizeInMbs)
- {
- /* end of slice, return, but before that check to see if there are other slices
- to be encoded. */
- encvid->currSliceGroup++;
- if (encvid->currSliceGroup > (int)pps->num_slice_groups_minus1) /* no more slice group */
- {
- status = AVCENC_PICTURE_READY;
- break;
- }
- else
- {
- /* find first_mb_num for the next slice */
- CurrMbAddr = 0;
- while (video->MbToSliceGroupMap[CurrMbAddr] != encvid->currSliceGroup &&
- (uint)CurrMbAddr < video->PicSizeInMbs)
- {
- CurrMbAddr++;
- }
- if ((uint)CurrMbAddr >= video->PicSizeInMbs)
- {
- status = AVCENC_SLICE_EMPTY; /* error, one slice group has no MBs in it */
- }
-
- video->mbNum = CurrMbAddr;
- status = AVCENC_SUCCESS;
- break;
- }
- }
- }
-
- if (video->mb_skip_run > 0)
- {
- /* write skip_run */
- if (slice_type != AVC_I_SLICE && slice_type != AVC_SI_SLICE)
- {
- ue_v(stream, video->mb_skip_run);
- video->mb_skip_run = 0;
- }
- else /* shouldn't happen */
- {
- status = AVCENC_FAIL;
- }
- }
-
- return status;
-}
-
-
-AVCEnc_Status EncodeMB(AVCEncObject *encvid)
-{
- AVCEnc_Status status = AVCENC_SUCCESS;
- AVCCommonObj *video = encvid->common;
- AVCPictureData *currPic = video->currPic;
- AVCFrameIO *currInput = encvid->currInput;
- AVCMacroblock *currMB = video->currMB;
- AVCMacroblock *MB_A, *MB_B;
- AVCEncBitstream *stream = encvid->bitstream;
- AVCRateControl *rateCtrl = encvid->rateCtrl;
- uint8 *cur, *curL, *curCb, *curCr;
- uint8 *orgL, *orgCb, *orgCr, *org4;
- int CurrMbAddr = video->mbNum;
- int picPitch = currPic->pitch;
- int orgPitch = currInput->pitch;
- int x_position = (video->mb_x << 4);
- int y_position = (video->mb_y << 4);
- int offset;
- int b8, b4, blkidx;
- AVCResidualType resType;
- int slice_type;
- int numcoeff; /* output from residual_block_cavlc */
- int cost16, cost8;
-
- int num_bits, start_mb_bits, start_text_bits;
-
- slice_type = video->slice_type;
-
- /* now, point to the reconstructed frame */
- offset = y_position * picPitch + x_position;
- curL = currPic->Sl + offset;
- orgL = currInput->YCbCr[0] + offset;
- offset = (offset + x_position) >> 2;
- curCb = currPic->Scb + offset;
- curCr = currPic->Scr + offset;
- orgCb = currInput->YCbCr[1] + offset;
- orgCr = currInput->YCbCr[2] + offset;
-
- if (orgPitch != picPitch)
- {
- offset = y_position * (orgPitch - picPitch);
- orgL += offset;
- offset >>= 2;
- orgCb += offset;
- orgCr += offset;
- }
-
- /******* determine MB prediction mode *******/
- if (encvid->intraSearch[CurrMbAddr])
- {
- MBIntraSearch(encvid, CurrMbAddr, curL, picPitch);
- }
- /******* This part should be determined somehow ***************/
- if (currMB->mbMode == AVC_I_PCM)
- {
- /* write down mb_type and PCM data */
- /* and copy from currInput to currPic */
- status = EncodeIntraPCM(encvid);
-
-
- return status;
- }
-
- /****** for intra prediction, pred is already done *******/
- /****** for I4, the recon is ready and Xfrm coefs are ready to be encoded *****/
-
- //RCCalculateMAD(encvid,currMB,orgL,orgPitch); // no need to re-calculate MAD for Intra
- // not used since totalSAD is used instead
-
- /* compute the prediction */
- /* output is video->pred_block */
- if (!currMB->mb_intra)
- {
- AVCMBMotionComp(encvid, video); /* perform prediction and residue calculation */
- /* we can do the loop here and call dct_luma */
- video->pred_pitch = picPitch;
- currMB->CBP = 0;
- cost16 = 0;
- cur = curL;
- org4 = orgL;
-
- for (b8 = 0; b8 < 4; b8++)
- {
- cost8 = 0;
-
- for (b4 = 0; b4 < 4; b4++)
- {
- blkidx = blkIdx2blkXY[b8][b4];
- video->pred_block = cur;
- numcoeff = dct_luma(encvid, blkidx, cur, org4, &cost8);
- currMB->nz_coeff[blkidx] = numcoeff;
- if (numcoeff)
- {
- video->cbp4x4 |= (1 << blkidx);
- currMB->CBP |= (1 << b8);
- }
-
- if (b4&1)
- {
- cur += ((picPitch << 2) - 4);
- org4 += ((orgPitch << 2) - 4);
- }
- else
- {
- cur += 4;
- org4 += 4;
- }
- }
-
- /* move the IDCT part out of dct_luma to accommodate the check
- for coeff_cost. */
-
- if ((currMB->CBP&(1 << b8)) && (cost8 <= _LUMA_COEFF_COST_))
- {
- cost8 = 0; // reset it
-
- currMB->CBP ^= (1 << b8);
- blkidx = blkIdx2blkXY[b8][0];
-
- currMB->nz_coeff[blkidx] = 0;
- currMB->nz_coeff[blkidx+1] = 0;
- currMB->nz_coeff[blkidx+4] = 0;
- currMB->nz_coeff[blkidx+5] = 0;
- }
-
- cost16 += cost8;
-
- if (b8&1)
- {
- cur -= 8;
- org4 -= 8;
- }
- else
- {
- cur += (8 - (picPitch << 3));
- org4 += (8 - (orgPitch << 3));
- }
- }
-
- /* after the whole MB, we do another check for coeff_cost */
- if ((currMB->CBP&0xF) && (cost16 <= _LUMA_MB_COEFF_COST_))
- {
- currMB->CBP = 0; // reset it to zero
- memset(currMB->nz_coeff, 0, sizeof(uint8)*16);
- }
-
- // now we do IDCT
- MBInterIdct(video, curL, currMB, picPitch);
-
-// video->pred_block = video->pred + 256;
- }
- else /* Intra prediction */
- {
- encvid->numIntraMB++;
-
- if (currMB->mbMode == AVC_I16) /* do prediction for the whole macroblock */
- {
- currMB->CBP = 0;
- /* get the prediction from encvid->pred_i16 */
- dct_luma_16x16(encvid, curL, orgL);
- }
- video->pred_block = encvid->pred_ic[currMB->intra_chroma_pred_mode];
- }
-
- /* chrominance */
- /* not need to do anything, the result is in encvid->pred_ic
- chroma dct must be aware that prediction block can come from either intra or inter. */
-
- dct_chroma(encvid, curCb, orgCb, 0);
-
- dct_chroma(encvid, curCr, orgCr, 1);
-
-
- /* 4.1 if there's nothing in there, video->mb_skip_run++ */
- /* 4.2 if coded, check if there is a run of skipped MB, encodes it,
- set video->QPyprev = currMB->QPy; */
-
- /* 5. vlc encode */
-
- /* check for skipped macroblock, INTER only */
- if (!currMB->mb_intra)
- {
- /* decide whether this MB (for inter MB) should be skipped if there's nothing left. */
- if (!currMB->CBP && currMB->NumMbPart == 1 && currMB->QPy == video->QPy)
- {
- if (currMB->MBPartPredMode[0][0] == AVC_Pred_L0 && currMB->ref_idx_L0[0] == 0)
- {
- MB_A = &video->mblock[video->mbAddrA];
- MB_B = &video->mblock[video->mbAddrB];
-
- if (!video->mbAvailA || !video->mbAvailB)
- {
- if (currMB->mvL0[0] == 0) /* both mv components are zeros.*/
- {
- currMB->mbMode = AVC_SKIP;
- video->mvd_l0[0][0][0] = 0;
- video->mvd_l0[0][0][1] = 0;
- }
- }
- else
- {
- if ((MB_A->ref_idx_L0[1] == 0 && MB_A->mvL0[3] == 0) ||
- (MB_B->ref_idx_L0[2] == 0 && MB_B->mvL0[12] == 0))
- {
- if (currMB->mvL0[0] == 0) /* both mv components are zeros.*/
- {
- currMB->mbMode = AVC_SKIP;
- video->mvd_l0[0][0][0] = 0;
- video->mvd_l0[0][0][1] = 0;
- }
- }
- else if (video->mvd_l0[0][0][0] == 0 && video->mvd_l0[0][0][1] == 0)
- {
- currMB->mbMode = AVC_SKIP;
- }
- }
- }
-
- if (currMB->mbMode == AVC_SKIP)
- {
- video->mb_skip_run++;
-
- /* set parameters */
- /* not sure whether we need the followings */
- if (slice_type == AVC_P_SLICE)
- {
- currMB->mbMode = AVC_SKIP;
- currMB->MbPartWidth = currMB->MbPartHeight = 16;
- currMB->MBPartPredMode[0][0] = AVC_Pred_L0;
- currMB->NumMbPart = 1;
- currMB->NumSubMbPart[0] = currMB->NumSubMbPart[1] =
- currMB->NumSubMbPart[2] = currMB->NumSubMbPart[3] = 1;
- currMB->SubMbPartWidth[0] = currMB->SubMbPartWidth[1] =
- currMB->SubMbPartWidth[2] = currMB->SubMbPartWidth[3] = currMB->MbPartWidth;
- currMB->SubMbPartHeight[0] = currMB->SubMbPartHeight[1] =
- currMB->SubMbPartHeight[2] = currMB->SubMbPartHeight[3] = currMB->MbPartHeight;
-
- }
- else if (slice_type == AVC_B_SLICE)
- {
- currMB->mbMode = AVC_SKIP;
- currMB->MbPartWidth = currMB->MbPartHeight = 8;
- currMB->MBPartPredMode[0][0] = AVC_Direct;
- currMB->NumMbPart = -1;
- }
-
- /* for skipped MB, always look at the first entry in RefPicList */
- currMB->RefIdx[0] = currMB->RefIdx[1] =
- currMB->RefIdx[2] = currMB->RefIdx[3] = video->RefPicList0[0]->RefIdx;
-
- /* do not return yet, need to do some copies */
- }
- }
- }
- /* non-skipped MB */
-
-
- /************* START ENTROPY CODING *************************/
-
- start_mb_bits = 32 + (encvid->bitstream->write_pos << 3) - encvid->bitstream->bit_left;
-
- /* encode mb_type, mb_pred, sub_mb_pred, CBP */
- if (slice_type != AVC_I_SLICE && slice_type != AVC_SI_SLICE && currMB->mbMode != AVC_SKIP)
- {
- //if(!pps->entropy_coding_mode_flag) ALWAYS true
- {
- ue_v(stream, video->mb_skip_run);
- video->mb_skip_run = 0;
- }
- }
-
- if (currMB->mbMode != AVC_SKIP)
- {
- status = EncodeMBHeader(currMB, encvid);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- }
-
- start_text_bits = 32 + (encvid->bitstream->write_pos << 3) - encvid->bitstream->bit_left;
-
- /**** now decoding part *******/
- resType = AVC_Luma;
-
- /* DC transform for luma I16 mode */
- if (currMB->mbMode == AVC_I16)
- {
- /* vlc encode level/run */
- status = enc_residual_block(encvid, AVC_Intra16DC, encvid->numcoefdc, currMB);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- resType = AVC_Intra16AC;
- }
-
- /* VLC encoding for luma */
- for (b8 = 0; b8 < 4; b8++)
- {
- if (currMB->CBP&(1 << b8))
- {
- for (b4 = 0; b4 < 4; b4++)
- {
- /* vlc encode level/run */
- status = enc_residual_block(encvid, resType, (b8 << 2) + b4, currMB);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- }
- }
- }
-
- /* chroma */
- if (currMB->CBP & (3 << 4)) /* chroma DC residual present */
- {
- for (b8 = 0; b8 < 2; b8++) /* for iCbCr */
- {
- /* vlc encode level/run */
- status = enc_residual_block(encvid, AVC_ChromaDC, encvid->numcoefcdc[b8] + (b8 << 3), currMB);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- }
- }
-
- if (currMB->CBP & (2 << 4))
- {
- /* AC part */
- for (b8 = 0; b8 < 2; b8++) /* for iCbCr */
- {
- for (b4 = 0; b4 < 4; b4++) /* for each block inside Cb or Cr */
- {
- /* vlc encode level/run */
- status = enc_residual_block(encvid, AVC_ChromaAC, 16 + (b8 << 2) + b4, currMB);
- if (status != AVCENC_SUCCESS)
- {
- return status;
- }
- }
- }
- }
-
-
- num_bits = 32 + (encvid->bitstream->write_pos << 3) - encvid->bitstream->bit_left;
-
- RCPostMB(video, rateCtrl, start_text_bits - start_mb_bits,
- num_bits - start_text_bits);
-
-// num_bits -= start_mb_bits;
-// fprintf(fdebug,"MB #%d: %d bits\n",CurrMbAddr,num_bits);
-// fclose(fdebug);
- return status;
-}
-
-/* copy the content from predBlock back to the reconstructed YUV frame */
-void Copy_MB(uint8 *curL, uint8 *curCb, uint8 *curCr, uint8 *predBlock, int picPitch)
-{
- int j, offset;
- uint32 *dst, *dst2, *src;
-
- dst = (uint32*)curL;
- src = (uint32*)predBlock;
-
- offset = (picPitch - 16) >> 2;
-
- for (j = 0; j < 16; j++)
- {
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
-
- dst += offset;
- }
-
- dst = (uint32*)curCb;
- dst2 = (uint32*)curCr;
- offset >>= 1;
-
- for (j = 0; j < 8; j++)
- {
- *dst++ = *src++;
- *dst++ = *src++;
- *dst2++ = *src++;
- *dst2++ = *src++;
-
- dst += offset;
- dst2 += offset;
- }
- return ;
-}
-
-/* encode mb_type, mb_pred, sub_mb_pred, CBP */
-/* decide whether this MB (for inter MB) should be skipped */
-AVCEnc_Status EncodeMBHeader(AVCMacroblock *currMB, AVCEncObject *encvid)
-{
- AVCEnc_Status status = AVCENC_SUCCESS;
- uint mb_type;
- AVCCommonObj *video = encvid->common;
- AVCEncBitstream *stream = encvid->bitstream;
-
- if (currMB->CBP > 47) /* chroma CBP is 11 */
- {
- currMB->CBP -= 16; /* remove the 5th bit from the right */
- }
-
- mb_type = InterpretMBType(currMB, video->slice_type);
-
- status = ue_v(stream, mb_type);
-
- if (currMB->mbMode == AVC_P8 || currMB->mbMode == AVC_P8ref0)
- {
- status = sub_mb_pred(video, currMB, stream);
- }
- else
- {
- status = mb_pred(video, currMB, stream) ;
- }
-
- if (currMB->mbMode != AVC_I16)
- {
- /* decode coded_block_pattern */
- status = EncodeCBP(currMB, stream);
- }
-
- /* calculate currMB->mb_qp_delta = currMB->QPy - video->QPyprev */
- if (currMB->CBP > 0 || currMB->mbMode == AVC_I16)
- {
- status = se_v(stream, currMB->QPy - video->QPy);
- video->QPy = currMB->QPy; /* = (video->QPyprev + currMB->mb_qp_delta + 52)%52; */
- // no need video->QPc = currMB->QPc;
- }
- else
- {
- if (currMB->QPy != video->QPy) // current QP is not the same as previous QP
- {
- /* restore these values */
- RCRestoreQP(currMB, video, encvid);
- }
- }
-
- return status;
-}
-
-
-/* inputs are mbMode, mb_intra, i16Mode, CBP, NumMbPart, MbPartWidth, MbPartHeight */
-uint InterpretMBType(AVCMacroblock *currMB, int slice_type)
-{
- int CBP_chrom;
- int mb_type;// part1, part2, part3;
-// const static int MapParts2Type[2][3][3]={{{4,8,12},{10,6,14},{16,18,20}},
-// {{5,9,13},{11,7,15},{17,19,21}}};
-
- if (currMB->mb_intra)
- {
- if (currMB->mbMode == AVC_I4)
- {
- mb_type = 0;
- }
- else if (currMB->mbMode == AVC_I16)
- {
- CBP_chrom = (currMB->CBP & 0x30);
- if (currMB->CBP&0xF)
- {
- currMB->CBP |= 0xF; /* either 0x0 or 0xF */
- mb_type = 13;
- }
- else
- {
- mb_type = 1;
- }
- mb_type += (CBP_chrom >> 2) + currMB->i16Mode;
- }
- else /* if(currMB->mbMode == AVC_I_PCM) */
- {
- mb_type = 25;
- }
- }
- else
- { /* P-MB *//* note that the order of the enum AVCMBMode cannot be changed
- since we use it here. */
- mb_type = currMB->mbMode - AVC_P16;
- }
-
- if (slice_type == AVC_P_SLICE)
- {
- if (currMB->mb_intra)
- {
- mb_type += 5;
- }
- }
- // following codes have not been tested yet, not needed.
- /* else if(slice_type == AVC_B_SLICE)
- {
- if(currMB->mbMode == AVC_BDirect16)
- {
- mb_type = 0;
- }
- else if(currMB->mbMode == AVC_P16)
- {
- mb_type = currMB->MBPartPredMode[0][0] + 1; // 1 or 2
- }
- else if(currMB->mbMode == AVC_P8)
- {
- mb_type = 26;
- }
- else if(currMB->mbMode == AVC_P8ref0)
- {
- mb_type = 27;
- }
- else
- {
- part1 = currMB->mbMode - AVC_P16x8;
- part2 = currMB->MBPartPredMode[0][0];
- part3 = currMB->MBPartPredMode[1][0];
- mb_type = MapParts2Type[part1][part2][part3];
- }
- }
-
- if(slice_type == AVC_SI_SLICE)
- {
- mb_type++;
- }
- */
- return (uint)mb_type;
-}
-
-//const static int mbPart2raster[3][4] = {{0,0,0,0},{1,1,0,0},{1,0,1,0}};
-
-/* see subclause 7.3.5.1 */
-AVCEnc_Status mb_pred(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream)
-{
- AVCEnc_Status status = AVCENC_SUCCESS;
- int mbPartIdx;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- int max_ref_idx;
- uint code;
-
- if (currMB->mbMode == AVC_I4 || currMB->mbMode == AVC_I16)
- {
- if (currMB->mbMode == AVC_I4)
- {
- /* perform prediction to get the actual intra 4x4 pred mode */
- EncodeIntra4x4Mode(video, currMB, stream);
- /* output will be in currMB->i4Mode[4][4] */
- }
-
- /* assume already set from MBPrediction() */
- status = ue_v(stream, currMB->intra_chroma_pred_mode);
- }
- else if (currMB->MBPartPredMode[0][0] != AVC_Direct)
- {
-
- memset(currMB->ref_idx_L0, 0, sizeof(int16)*4);
-
- /* see subclause 7.4.5.1 for the range of ref_idx_lX */
- max_ref_idx = sliceHdr->num_ref_idx_l0_active_minus1;
- /* if(video->MbaffFrameFlag && currMB->mb_field_decoding_flag)
- max_ref_idx = 2*sliceHdr->num_ref_idx_l0_active_minus1 + 1;
- */
- /* decode ref index for L0 */
- if (sliceHdr->num_ref_idx_l0_active_minus1 > 0)
- {
- for (mbPartIdx = 0; mbPartIdx < currMB->NumMbPart; mbPartIdx++)
- {
- if (/*(sliceHdr->num_ref_idx_l0_active_minus1>0 || currMB->mb_field_decoding_flag) &&*/
- currMB->MBPartPredMode[mbPartIdx][0] != AVC_Pred_L1)
- {
- code = currMB->ref_idx_L0[mbPartIdx];
- status = te_v(stream, code, max_ref_idx);
- }
- }
- }
-
- /* see subclause 7.4.5.1 for the range of ref_idx_lX */
- max_ref_idx = sliceHdr->num_ref_idx_l1_active_minus1;
- /* if(video->MbaffFrameFlag && currMB->mb_field_decoding_flag)
- max_ref_idx = 2*sliceHdr->num_ref_idx_l1_active_minus1 + 1;
- */
- /* decode ref index for L1 */
- if (sliceHdr->num_ref_idx_l1_active_minus1 > 0)
- {
- for (mbPartIdx = 0; mbPartIdx < currMB->NumMbPart; mbPartIdx++)
- {
- if (/*(sliceHdr->num_ref_idx_l1_active_minus1>0 || currMB->mb_field_decoding_flag) &&*/
- currMB->MBPartPredMode[mbPartIdx][0] != AVC_Pred_L0)
- {
- status = te_v(stream, currMB->ref_idx_L1[mbPartIdx], max_ref_idx);
- }
- }
- }
-
- /* encode mvd_l0 */
- for (mbPartIdx = 0; mbPartIdx < currMB->NumMbPart; mbPartIdx++)
- {
- if (currMB->MBPartPredMode[mbPartIdx][0] != AVC_Pred_L1)
- {
- status = se_v(stream, video->mvd_l0[mbPartIdx][0][0]);
- status = se_v(stream, video->mvd_l0[mbPartIdx][0][1]);
- }
- }
- /* encode mvd_l1 */
- for (mbPartIdx = 0; mbPartIdx < currMB->NumMbPart; mbPartIdx++)
- {
- if (currMB->MBPartPredMode[mbPartIdx][0] != AVC_Pred_L0)
- {
- status = se_v(stream, video->mvd_l1[mbPartIdx][0][0]);
- status = se_v(stream, video->mvd_l1[mbPartIdx][0][1]);
- }
- }
- }
-
- return status;
-}
-
-/* see subclause 7.3.5.2 */
-AVCEnc_Status sub_mb_pred(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream)
-{
- AVCEnc_Status status = AVCENC_SUCCESS;
- int mbPartIdx, subMbPartIdx;
- AVCSliceHeader *sliceHdr = video->sliceHdr;
- uint max_ref_idx;
- uint slice_type = video->slice_type;
- uint sub_mb_type[4];
-
- /* this should move somewhere else where we don't have to make this check */
- if (currMB->mbMode == AVC_P8ref0)
- {
- memset(currMB->ref_idx_L0, 0, sizeof(int16)*4);
- }
-
- /* we have to check the values to make sure they are valid */
- /* assign values to currMB->sub_mb_type[] */
- if (slice_type == AVC_P_SLICE)
- {
- InterpretSubMBTypeP(currMB, sub_mb_type);
- }
- /* no need to check for B-slice
- else if(slice_type == AVC_B_SLICE)
- {
- InterpretSubMBTypeB(currMB,sub_mb_type);
- }*/
-
- for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++)
- {
- status = ue_v(stream, sub_mb_type[mbPartIdx]);
- }
-
- /* see subclause 7.4.5.1 for the range of ref_idx_lX */
- max_ref_idx = sliceHdr->num_ref_idx_l0_active_minus1;
- /* if(video->MbaffFrameFlag && currMB->mb_field_decoding_flag)
- max_ref_idx = 2*sliceHdr->num_ref_idx_l0_active_minus1 + 1; */
-
- for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++)
- {
- if ((sliceHdr->num_ref_idx_l0_active_minus1 > 0 /*|| currMB->mb_field_decoding_flag*/) &&
- currMB->mbMode != AVC_P8ref0 && /*currMB->subMbMode[mbPartIdx]!=AVC_BDirect8 &&*/
- currMB->MBPartPredMode[mbPartIdx][0] != AVC_Pred_L1)
- {
- status = te_v(stream, currMB->ref_idx_L0[mbPartIdx], max_ref_idx);
- }
- /* used in deblocking */
- currMB->RefIdx[mbPartIdx] = video->RefPicList0[currMB->ref_idx_L0[mbPartIdx]]->RefIdx;
- }
- /* see subclause 7.4.5.1 for the range of ref_idx_lX */
- max_ref_idx = sliceHdr->num_ref_idx_l1_active_minus1;
- /* if(video->MbaffFrameFlag && currMB->mb_field_decoding_flag)
- max_ref_idx = 2*sliceHdr->num_ref_idx_l1_active_minus1 + 1;*/
-
- if (sliceHdr->num_ref_idx_l1_active_minus1 > 0)
- {
- for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++)
- {
- if (/*(sliceHdr->num_ref_idx_l1_active_minus1>0 || currMB->mb_field_decoding_flag) &&*/
- /*currMB->subMbMode[mbPartIdx]!=AVC_BDirect8 &&*/
- currMB->MBPartPredMode[mbPartIdx][0] != AVC_Pred_L0)
- {
- status = te_v(stream, currMB->ref_idx_L1[mbPartIdx], max_ref_idx);
- }
- }
- }
-
- for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++)
- {
- if (/*currMB->subMbMode[mbPartIdx]!=AVC_BDirect8 &&*/
- currMB->MBPartPredMode[mbPartIdx][0] != AVC_Pred_L1)
- {
- for (subMbPartIdx = 0; subMbPartIdx < currMB->NumSubMbPart[mbPartIdx]; subMbPartIdx++)
- {
- status = se_v(stream, video->mvd_l0[mbPartIdx][subMbPartIdx][0]);
- status = se_v(stream, video->mvd_l0[mbPartIdx][subMbPartIdx][1]);
- }
- }
- }
-
- for (mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++)
- {
- if (/*currMB->subMbMode[mbPartIdx]!=AVC_BDirect8 &&*/
- currMB->MBPartPredMode[mbPartIdx][0] != AVC_Pred_L0)
- {
- for (subMbPartIdx = 0; subMbPartIdx < currMB->NumSubMbPart[mbPartIdx]; subMbPartIdx++)
- {
- status = se_v(stream, video->mvd_l1[mbPartIdx][subMbPartIdx][0]);
- status = se_v(stream, video->mvd_l1[mbPartIdx][subMbPartIdx][1]);
- }
- }
- }
-
- return status;
-}
-
-/* input is mblock->sub_mb_type[] */
-void InterpretSubMBTypeP(AVCMacroblock *mblock, uint *sub_mb_type)
-{
- int i;
- /* see enum AVCMBType declaration */
- /*const static AVCSubMBMode map2subMbMode[4] = {AVC_8x8,AVC_8x4,AVC_4x8,AVC_4x4};
- const static int map2subPartWidth[4] = {8,8,4,4};
- const static int map2subPartHeight[4] = {8,4,8,4};
- const static int map2numSubPart[4] = {1,2,2,4};*/
-
- for (i = 0; i < 4 ; i++)
- {
- sub_mb_type[i] = mblock->subMbMode[i] - AVC_8x8;
- }
-
- return ;
-}
-
-void InterpretSubMBTypeB(AVCMacroblock *mblock, uint *sub_mb_type)
-{
- int i;
- /* see enum AVCMBType declaration */
- /* const static AVCSubMBMode map2subMbMode[13] = {AVC_BDirect8,AVC_8x8,AVC_8x8,
- AVC_8x8,AVC_8x4,AVC_4x8,AVC_8x4,AVC_4x8,AVC_8x4,AVC_4x8,AVC_4x4,AVC_4x4,AVC_4x4};
- const static int map2subPartWidth[13] = {4,8,8,8,8,4,8,4,8,4,4,4,4};
- const static int map2subPartHeight[13] = {4,8,8,8,4,8,4,8,4,8,4,4,4};
- const static int map2numSubPart[13] = {4,1,1,1,2,2,2,2,2,2,4,4,4};
- const static int map2predMode[13] = {3,0,1,2,0,0,1,1,2,2,0,1,2};*/
-
- for (i = 0; i < 4 ; i++)
- {
- if (mblock->subMbMode[i] == AVC_BDirect8)
- {
- sub_mb_type[i] = 0;
- }
- else if (mblock->subMbMode[i] == AVC_8x8)
- {
- sub_mb_type[i] = 1 + mblock->MBPartPredMode[i][0];
- }
- else if (mblock->subMbMode[i] == AVC_4x4)
- {
- sub_mb_type[i] = 10 + mblock->MBPartPredMode[i][0];
- }
- else
- {
- sub_mb_type[i] = 4 + (mblock->MBPartPredMode[i][0] << 1) + (mblock->subMbMode[i] - AVC_8x4);
- }
- }
-
- return ;
-}
-
-/* see subclause 8.3.1 */
-AVCEnc_Status EncodeIntra4x4Mode(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream)
-{
- int intra4x4PredModeA = 0;
- int intra4x4PredModeB, predIntra4x4PredMode;
- int component, SubBlock_indx, block_x, block_y;
- int dcOnlyPredictionFlag;
- uint flag;
- int rem = 0;
- int mode;
- int bindx = 0;
-
- for (component = 0; component < 4; component++) /* partition index */
- {
- block_x = ((component & 1) << 1);
- block_y = ((component >> 1) << 1);
-
- for (SubBlock_indx = 0; SubBlock_indx < 4; SubBlock_indx++) /* sub-partition index */
- {
- dcOnlyPredictionFlag = 0;
- if (block_x > 0)
- {
- intra4x4PredModeA = currMB->i4Mode[(block_y << 2) + block_x - 1 ];
- }
- else
- {
- if (video->intraAvailA)
- {
- if (video->mblock[video->mbAddrA].mbMode == AVC_I4)
- {
- intra4x4PredModeA = video->mblock[video->mbAddrA].i4Mode[(block_y << 2) + 3];
- }
- else
- {
- intra4x4PredModeA = AVC_I4_DC;
- }
- }
- else
- {
- dcOnlyPredictionFlag = 1;
- }
- }
-
- if (block_y > 0)
- {
- intra4x4PredModeB = currMB->i4Mode[((block_y-1) << 2) + block_x];
- }
- else
- {
- if (video->intraAvailB)
- {
- if (video->mblock[video->mbAddrB].mbMode == AVC_I4)
- {
- intra4x4PredModeB = video->mblock[video->mbAddrB].i4Mode[(3 << 2) + block_x];
- }
- else
- {
- intra4x4PredModeB = AVC_I4_DC;
- }
- }
- else
- {
- dcOnlyPredictionFlag = 1;
- }
- }
-
- if (dcOnlyPredictionFlag)
- {
- intra4x4PredModeA = intra4x4PredModeB = AVC_I4_DC;
- }
-
- predIntra4x4PredMode = AVC_MIN(intra4x4PredModeA, intra4x4PredModeB);
-
- flag = 0;
- mode = currMB->i4Mode[(block_y<<2)+block_x];
-
- if (mode == (AVCIntra4x4PredMode)predIntra4x4PredMode)
- {
- flag = 1;
- }
- else if (mode < predIntra4x4PredMode)
- {
- rem = mode;
- }
- else
- {
- rem = mode - 1;
- }
-
- BitstreamWrite1Bit(stream, flag);
-
- if (!flag)
- {
- BitstreamWriteBits(stream, 3, rem);
- }
-
- bindx++;
- block_y += (SubBlock_indx & 1) ;
- block_x += (1 - 2 * (SubBlock_indx & 1)) ;
- }
- }
-
- return AVCENC_SUCCESS;
-}
-
-
-
diff --git a/media/libstagefright/codecs/avc/enc/src/vlc_encode.cpp b/media/libstagefright/codecs/avc/enc/src/vlc_encode.cpp
deleted file mode 100644
index 222e709..0000000
--- a/media/libstagefright/codecs/avc/enc/src/vlc_encode.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * 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.
- * -------------------------------------------------------------------
- */
-#include "avcenc_lib.h"
-
-/**
-See algorithm in subclause 9.1, Table 9-1, Table 9-2. */
-AVCEnc_Status ue_v(AVCEncBitstream *bitstream, uint codeNum)
-{
- if (AVCENC_SUCCESS != SetEGBitstring(bitstream, codeNum))
- return AVCENC_FAIL;
-
- return AVCENC_SUCCESS;
-}
-
-/**
-See subclause 9.1.1, Table 9-3 */
-AVCEnc_Status se_v(AVCEncBitstream *bitstream, int value)
-{
- uint codeNum;
- AVCEnc_Status status;
-
- if (value <= 0)
- {
- codeNum = -value * 2;
- }
- else
- {
- codeNum = value * 2 - 1;
- }
-
- status = ue_v(bitstream, codeNum);
-
- return status;
-}
-
-AVCEnc_Status te_v(AVCEncBitstream *bitstream, uint value, uint range)
-{
- AVCEnc_Status status;
-
- if (range > 1)
- {
- return ue_v(bitstream, value);
- }
- else
- {
- status = BitstreamWrite1Bit(bitstream, 1 - value);
- return status;
- }
-}
-
-/**
-See subclause 9.1, Table 9-1, 9-2. */
-// compute leadingZeros and inforbits
-//codeNum = (1<<leadingZeros)-1+infobits;
-AVCEnc_Status SetEGBitstring(AVCEncBitstream *bitstream, uint codeNum)
-{
- AVCEnc_Status status;
- int leadingZeros;
- int infobits;
-
- if (!codeNum)
- {
- status = BitstreamWrite1Bit(bitstream, 1);
- return status;
- }
-
- /* calculate leadingZeros and infobits */
- leadingZeros = 1;
- while ((uint)(1 << leadingZeros) < codeNum + 2)
- {
- leadingZeros++;
- }
- leadingZeros--;
- infobits = codeNum - (1 << leadingZeros) + 1;
-
- status = BitstreamWriteBits(bitstream, leadingZeros, 0);
- infobits |= (1 << leadingZeros);
- status = BitstreamWriteBits(bitstream, leadingZeros + 1, infobits);
- return status;
-}
-
-/* see Table 9-4 assignment of codeNum to values of coded_block_pattern. */
-const static uint8 MapCBP2code[48][2] =
-{
- {3, 0}, {29, 2}, {30, 3}, {17, 7}, {31, 4}, {18, 8}, {37, 17}, {8, 13}, {32, 5}, {38, 18}, {19, 9}, {9, 14},
- {20, 10}, {10, 15}, {11, 16}, {2, 11}, {16, 1}, {33, 32}, {34, 33}, {21, 36}, {35, 34}, {22, 37}, {39, 44}, {4, 40},
- {36, 35}, {40, 45}, {23, 38}, {5, 41}, {24, 39}, {6, 42}, {7, 43}, {1, 19}, {41, 6}, {42, 24}, {43, 25}, {25, 20},
- {44, 26}, {26, 21}, {46, 46}, {12, 28}, {45, 27}, {47, 47}, {27, 22}, {13, 29}, {28, 23}, {14, 30}, {15, 31}, {0, 12}
-};
-
-AVCEnc_Status EncodeCBP(AVCMacroblock *currMB, AVCEncBitstream *stream)
-{
- AVCEnc_Status status;
- uint codeNum;
-
- if (currMB->mbMode == AVC_I4)
- {
- codeNum = MapCBP2code[currMB->CBP][0];
- }
- else
- {
- codeNum = MapCBP2code[currMB->CBP][1];
- }
-
- status = ue_v(stream, codeNum);
-
- return status;
-}
-
-AVCEnc_Status ce_TotalCoeffTrailingOnes(AVCEncBitstream *stream, int TrailingOnes, int TotalCoeff, int nC)
-{
- const static uint8 totCoeffTrailOne[3][4][17][2] =
- {
- { // 0702
- {{1, 1}, {6, 5}, {8, 7}, {9, 7}, {10, 7}, {11, 7}, {13, 15}, {13, 11}, {13, 8}, {14, 15}, {14, 11}, {15, 15}, {15, 11}, {16, 15}, {16, 11}, {16, 7}, {16, 4}},
- {{0, 0}, {2, 1}, {6, 4}, {8, 6}, {9, 6}, {10, 6}, {11, 6}, {13, 14}, {13, 10}, {14, 14}, {14, 10}, {15, 14}, {15, 10}, {15, 1}, {16, 14}, {16, 10}, {16, 6}},
- {{0, 0}, {0, 0}, {3, 1}, {7, 5}, {8, 5}, {9, 5}, {10, 5}, {11, 5}, {13, 13}, {13, 9}, {14, 13}, {14, 9}, {15, 13}, {15, 9}, {16, 13}, {16, 9}, {16, 5}},
- {{0, 0}, {0, 0}, {0, 0}, {5, 3}, {6, 3}, {7, 4}, {8, 4}, {9, 4}, {10, 4}, {11, 4}, {13, 12}, {14, 12}, {14, 8}, {15, 12}, {15, 8}, {16, 12}, {16, 8}},
- },
- {
- {{2, 3}, {6, 11}, {6, 7}, {7, 7}, {8, 7}, {8, 4}, {9, 7}, {11, 15}, {11, 11}, {12, 15}, {12, 11}, {12, 8}, {13, 15}, {13, 11}, {13, 7}, {14, 9}, {14, 7}},
- {{0, 0}, {2, 2}, {5, 7}, {6, 10}, {6, 6}, {7, 6}, {8, 6}, {9, 6}, {11, 14}, {11, 10}, {12, 14}, {12, 10}, {13, 14}, {13, 10}, {14, 11}, {14, 8}, {14, 6}},
- {{0, 0}, {0, 0}, {3, 3}, {6, 9}, {6, 5}, {7, 5}, {8, 5}, {9, 5}, {11, 13}, {11, 9}, {12, 13}, {12, 9}, {13, 13}, {13, 9}, {13, 6}, {14, 10}, {14, 5}},
- {{0, 0}, {0, 0}, {0, 0}, {4, 5}, {4, 4}, {5, 6}, {6, 8}, {6, 4}, {7, 4}, {9, 4}, {11, 12}, {11, 8}, {12, 12}, {13, 12}, {13, 8}, {13, 1}, {14, 4}},
- },
- {
- {{4, 15}, {6, 15}, {6, 11}, {6, 8}, {7, 15}, {7, 11}, {7, 9}, {7, 8}, {8, 15}, {8, 11}, {9, 15}, {9, 11}, {9, 8}, {10, 13}, {10, 9}, {10, 5}, {10, 1}},
- {{0, 0}, {4, 14}, {5, 15}, {5, 12}, {5, 10}, {5, 8}, {6, 14}, {6, 10}, {7, 14}, {8, 14}, {8, 10}, {9, 14}, {9, 10}, {9, 7}, {10, 12}, {10, 8}, {10, 4}},
- {{0, 0}, {0, 0}, {4, 13}, {5, 14}, {5, 11}, {5, 9}, {6, 13}, {6, 9}, {7, 13}, {7, 10}, {8, 13}, {8, 9}, {9, 13}, {9, 9}, {10, 11}, {10, 7}, {10, 3}},
- {{0, 0}, {0, 0}, {0, 0}, {4, 12}, {4, 11}, {4, 10}, {4, 9}, {4, 8}, {5, 13}, {6, 12}, {7, 12}, {8, 12}, {8, 8}, {9, 12}, {10, 10}, {10, 6}, {10, 2}}
- }
- };
-
-
- AVCEnc_Status status = AVCENC_SUCCESS;
- uint code, len;
- int vlcnum;
-
- if (TrailingOnes > 3)
- {
- return AVCENC_TRAILINGONES_FAIL;
- }
-
- if (nC >= 8)
- {
- if (TotalCoeff)
- {
- code = ((TotalCoeff - 1) << 2) | (TrailingOnes);
- }
- else
- {
- code = 3;
- }
- status = BitstreamWriteBits(stream, 6, code);
- }
- else
- {
- if (nC < 2)
- {
- vlcnum = 0;
- }
- else if (nC < 4)
- {
- vlcnum = 1;
- }
- else
- {
- vlcnum = 2;
- }
-
- len = totCoeffTrailOne[vlcnum][TrailingOnes][TotalCoeff][0];
- code = totCoeffTrailOne[vlcnum][TrailingOnes][TotalCoeff][1];
- status = BitstreamWriteBits(stream, len, code);
- }
-
- return status;
-}
-
-AVCEnc_Status ce_TotalCoeffTrailingOnesChromaDC(AVCEncBitstream *stream, int TrailingOnes, int TotalCoeff)
-{
- const static uint8 totCoeffTrailOneChrom[4][5][2] =
- {
- { {2, 1}, {6, 7}, {6, 4}, {6, 3}, {6, 2}},
- { {0, 0}, {1, 1}, {6, 6}, {7, 3}, {8, 3}},
- { {0, 0}, {0, 0}, {3, 1}, {7, 2}, {8, 2}},
- { {0, 0}, {0, 0}, {0, 0}, {6, 5}, {7, 0}},
- };
-
- AVCEnc_Status status = AVCENC_SUCCESS;
- uint code, len;
-
- len = totCoeffTrailOneChrom[TrailingOnes][TotalCoeff][0];
- code = totCoeffTrailOneChrom[TrailingOnes][TotalCoeff][1];
- status = BitstreamWriteBits(stream, len, code);
-
- return status;
-}
-
-/* see Table 9-7 and 9-8 */
-AVCEnc_Status ce_TotalZeros(AVCEncBitstream *stream, int total_zeros, int TotalCoeff)
-{
- const static uint8 lenTotalZeros[15][16] =
- {
- { 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9},
- { 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6},
- { 4, 3, 3, 3, 4, 4, 3, 3, 4, 5, 5, 6, 5, 6},
- { 5, 3, 4, 4, 3, 3, 3, 4, 3, 4, 5, 5, 5},
- { 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 4, 5},
- { 6, 5, 3, 3, 3, 3, 3, 3, 4, 3, 6},
- { 6, 5, 3, 3, 3, 2, 3, 4, 3, 6},
- { 6, 4, 5, 3, 2, 2, 3, 3, 6},
- { 6, 6, 4, 2, 2, 3, 2, 5},
- { 5, 5, 3, 2, 2, 2, 4},
- { 4, 4, 3, 3, 1, 3},
- { 4, 4, 2, 1, 3},
- { 3, 3, 1, 2},
- { 2, 2, 1},
- { 1, 1},
- };
-
- const static uint8 codTotalZeros[15][16] =
- {
- {1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 1},
- {7, 6, 5, 4, 3, 5, 4, 3, 2, 3, 2, 3, 2, 1, 0},
- {5, 7, 6, 5, 4, 3, 4, 3, 2, 3, 2, 1, 1, 0},
- {3, 7, 5, 4, 6, 5, 4, 3, 3, 2, 2, 1, 0},
- {5, 4, 3, 7, 6, 5, 4, 3, 2, 1, 1, 0},
- {1, 1, 7, 6, 5, 4, 3, 2, 1, 1, 0},
- {1, 1, 5, 4, 3, 3, 2, 1, 1, 0},
- {1, 1, 1, 3, 3, 2, 2, 1, 0},
- {1, 0, 1, 3, 2, 1, 1, 1, },
- {1, 0, 1, 3, 2, 1, 1, },
- {0, 1, 1, 2, 1, 3},
- {0, 1, 1, 1, 1},
- {0, 1, 1, 1},
- {0, 1, 1},
- {0, 1},
- };
- int len, code;
- AVCEnc_Status status;
-
- len = lenTotalZeros[TotalCoeff-1][total_zeros];
- code = codTotalZeros[TotalCoeff-1][total_zeros];
-
- status = BitstreamWriteBits(stream, len, code);
-
- return status;
-}
-
-/* see Table 9-9 */
-AVCEnc_Status ce_TotalZerosChromaDC(AVCEncBitstream *stream, int total_zeros, int TotalCoeff)
-{
- const static uint8 lenTotalZerosChromaDC[3][4] =
- {
- { 1, 2, 3, 3, },
- { 1, 2, 2, 0, },
- { 1, 1, 0, 0, },
- };
-
- const static uint8 codTotalZerosChromaDC[3][4] =
- {
- { 1, 1, 1, 0, },
- { 1, 1, 0, 0, },
- { 1, 0, 0, 0, },
- };
-
- int len, code;
- AVCEnc_Status status;
-
- len = lenTotalZerosChromaDC[TotalCoeff-1][total_zeros];
- code = codTotalZerosChromaDC[TotalCoeff-1][total_zeros];
-
- status = BitstreamWriteBits(stream, len, code);
-
- return status;
-}
-
-/* see Table 9-10 */
-AVCEnc_Status ce_RunBefore(AVCEncBitstream *stream, int run_before, int zerosLeft)
-{
- const static uint8 lenRunBefore[7][16] =
- {
- {1, 1},
- {1, 2, 2},
- {2, 2, 2, 2},
- {2, 2, 2, 3, 3},
- {2, 2, 3, 3, 3, 3},
- {2, 3, 3, 3, 3, 3, 3},
- {3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11},
- };
-
- const static uint8 codRunBefore[7][16] =
- {
- {1, 0},
- {1, 1, 0},
- {3, 2, 1, 0},
- {3, 2, 1, 1, 0},
- {3, 2, 3, 2, 1, 0},
- {3, 0, 1, 3, 2, 5, 4},
- {7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1},
- };
-
- int len, code;
- AVCEnc_Status status;
-
- if (zerosLeft <= 6)
- {
- len = lenRunBefore[zerosLeft-1][run_before];
- code = codRunBefore[zerosLeft-1][run_before];
- }
- else
- {
- len = lenRunBefore[6][run_before];
- code = codRunBefore[6][run_before];
- }
-
- status = BitstreamWriteBits(stream, len, code);
-
-
- return status;
-}
diff --git a/media/libstagefright/codecs/avc/enc/test/h264_enc_test.cpp b/media/libstagefright/codecs/avc/enc/test/h264_enc_test.cpp
deleted file mode 100644
index 7a782a8..0000000
--- a/media/libstagefright/codecs/avc/enc/test/h264_enc_test.cpp
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#include "avcenc_api.h"
-#include "avcenc_int.h"
-
-// Constants.
-enum {
- kMaxWidth = 720,
- kMaxHeight = 480,
- kMaxFrameRate = 30,
- kMaxBitrate = 2048, // in kbps.
- kInputBufferSize = (kMaxWidth * kMaxHeight * 3) / 2, // For YUV 420 format.
- kOutputBufferSize = kInputBufferSize,
- kMaxDpbBuffers = 17,
- kIDRFrameRefreshIntervalInSec = 1,
-};
-
-
-static void *MallocCb(void * /*userData*/, int32_t size, int32_t /*attrs*/) {
- void *ptr = calloc(size, 1);
- return ptr;
-}
-
-static void FreeCb(void * /*userData*/, void *ptr) {
- free(ptr);
-}
-
-static int32_t DpbAllocCb(void * /*userData*/,
- unsigned int sizeInMbs, unsigned int numBuffers) {
-
- size_t frameSize = (sizeInMbs << 7) * 3;
- if(numBuffers < kMaxDpbBuffers && frameSize <= kInputBufferSize) {
- return 1;
- } else {
- return 0;
- }
-}
-
-static int32_t BindFrameCb(void *userData, int32_t index, uint8_t **yuv) {
- assert(index < kMaxDpbBuffers);
- uint8_t** dpbBuffer = static_cast<uint8_t**>(userData);
- *yuv = dpbBuffer[index];
- return 1;
-}
-
-static void UnbindFrameCb(void * /*userData*/, int32_t /*index*/) {
-}
-
-int main(int argc, char *argv[]) {
-
- if (argc < 7) {
- fprintf(stderr, "Usage %s <input yuv> <output file> <width> <height>"
- " <frame rate> <bitrate in kbps>\n", argv[0]);
- fprintf(stderr, "Max width %d\n", kMaxWidth);
- fprintf(stderr, "Max height %d\n", kMaxHeight);
- fprintf(stderr, "Max framerate %d\n", kMaxFrameRate);
- fprintf(stderr, "Max bitrate %d kbps\n", kMaxBitrate);
- return EXIT_FAILURE;
- }
-
- // Read height and width.
- int32_t width;
- int32_t height;
- width = atoi(argv[3]);
- height = atoi(argv[4]);
- if (width > kMaxWidth || height > kMaxHeight || width <= 0 || height <= 0) {
- fprintf(stderr, "Unsupported dimensions %dx%d\n", width, height);
- return EXIT_FAILURE;
- }
-
- if (width % 16 != 0 || height % 16 != 0) {
- fprintf(stderr, "Video frame size %dx%d must be a multiple of 16\n",
- width, height);
- return EXIT_FAILURE;
- }
-
- // Read frame rate.
- int32_t frameRate;
- frameRate = atoi(argv[5]);
- if (frameRate > kMaxFrameRate || frameRate <= 0) {
- fprintf(stderr, "Unsupported frame rate %d\n", frameRate);
- return EXIT_FAILURE;
- }
-
- // Read bit rate.
- int32_t bitrate;
- bitrate = atoi(argv[6]);
- if (bitrate > kMaxBitrate || bitrate <= 0) {
- fprintf(stderr, "Unsupported bitrate %d\n", bitrate);
- return EXIT_FAILURE;
- }
- bitrate *= 1024; // kbps to bps.
-
- // Open the input file.
- FILE *fpInput = fopen(argv[1], "rb");
- if (!fpInput) {
- fprintf(stderr, "Could not open %s\n", argv[1]);
- return EXIT_FAILURE;
- }
-
- // Open the output file.
- FILE *fpOutput = fopen(argv[2], "wb");
- if (!fpOutput) {
- fprintf(stderr, "Could not open %s\n", argv[2]);
- fclose(fpInput);
- return EXIT_FAILURE;
- }
-
- // Allocate input buffer.
- uint8_t *inputBuf = (uint8_t *)malloc(kInputBufferSize);
- assert(inputBuf != NULL);
-
- // Allocate output buffer.
- uint8_t *outputBuf = (uint8_t *)malloc(kOutputBufferSize);
- assert(outputBuf != NULL);
-
- // Allocate dpb buffers.
- uint8_t * dpbBuffers[kMaxDpbBuffers];
- for (int i = 0; i < kMaxDpbBuffers; ++i) {
- dpbBuffers[i] = (uint8_t *)malloc(kInputBufferSize);
- assert(dpbBuffers[i] != NULL);
- }
-
- // Initialize the encoder parameters.
- tagAVCEncParam encParams;
- memset(&encParams, 0, sizeof(tagAVCEncParam));
- encParams.rate_control = AVC_ON;
- encParams.initQP = 0;
- encParams.init_CBP_removal_delay = 1600;
-
- encParams.intramb_refresh = 0;
- encParams.auto_scd = AVC_ON;
- encParams.out_of_band_param_set = AVC_ON;
- encParams.poc_type = 2;
- encParams.log2_max_poc_lsb_minus_4 = 12;
- encParams.delta_poc_zero_flag = 0;
- encParams.offset_poc_non_ref = 0;
- encParams.offset_top_bottom = 0;
- encParams.num_ref_in_cycle = 0;
- encParams.offset_poc_ref = NULL;
-
- encParams.num_ref_frame = 1;
- encParams.num_slice_group = 1;
- encParams.fmo_type = 0;
-
- encParams.db_filter = AVC_ON;
- encParams.disable_db_idc = 0;
-
- encParams.alpha_offset = 0;
- encParams.beta_offset = 0;
- encParams.constrained_intra_pred = AVC_OFF;
-
- encParams.data_par = AVC_OFF;
- encParams.fullsearch = AVC_OFF;
- encParams.search_range = 16;
- encParams.sub_pel = AVC_OFF;
- encParams.submb_pred = AVC_OFF;
- encParams.rdopt_mode = AVC_OFF;
- encParams.bidir_pred = AVC_OFF;
-
- encParams.use_overrun_buffer = AVC_OFF;
-
- encParams.width = width;
- encParams.height = height;
- encParams.bitrate = bitrate;
- encParams.frame_rate = 1000 * frameRate; // In frames/ms.
- encParams.CPB_size = (uint32_t) (bitrate >> 1);
-
- int32_t IDRFrameRefreshIntervalInSec = kIDRFrameRefreshIntervalInSec;
- if (IDRFrameRefreshIntervalInSec == 0) {
- encParams.idr_period = 1; // All I frames.
- } else {
- encParams.idr_period = (IDRFrameRefreshIntervalInSec * frameRate);
- }
-
- int32_t nMacroBlocks = ((((width + 15) >> 4) << 4) *
- (((height + 15) >> 4) << 4)) >> 8;
- uint32_t *sliceGroup = (uint32_t *) malloc(sizeof(uint32_t) * nMacroBlocks);
- assert(sliceGroup != NULL);
- for (int i = 0, idx = 0; i < nMacroBlocks; ++i) {
- sliceGroup[i] = idx++;
- if (idx >= encParams.num_slice_group) {
- idx = 0;
- }
- }
- encParams.slice_group = sliceGroup;
- encParams.profile = AVC_BASELINE;
- encParams.level = AVC_LEVEL2;
-
- // Initialize the handle.
- tagAVCHandle handle;
- memset(&handle, 0, sizeof(tagAVCHandle));
- handle.AVCObject = NULL;
- handle.userData = dpbBuffers;
- handle.CBAVC_DPBAlloc = DpbAllocCb;
- handle.CBAVC_FrameBind = BindFrameCb;
- handle.CBAVC_FrameUnbind = UnbindFrameCb;
- handle.CBAVC_Malloc = MallocCb;
- handle.CBAVC_Free = FreeCb;
-
- // Initialize the encoder.
- AVCEnc_Status status;
- status = PVAVCEncInitialize(&handle, &encParams, NULL, NULL);
- if (status != AVCENC_SUCCESS) {
- fprintf(stderr, "Failed to initialize the encoder\n");
-
- // Release resources.
- fclose(fpInput);
- fclose(fpOutput);
- free(sliceGroup);
- free(inputBuf);
- free(outputBuf);
- for (int i = 0; i < kMaxDpbBuffers; ++i) {
- free(dpbBuffers[i]);
- }
- return EXIT_FAILURE;
- }
-
- // Encode Sequence Parameter Set.
- uint32_t dataLength = kOutputBufferSize;
- int32_t type;
- status = PVAVCEncodeNAL(&handle, outputBuf, &dataLength, &type);
- assert(type == AVC_NALTYPE_SPS);
- fwrite("\x00\x00\x00\x01", 1, 4, fpOutput); // Start Code.
- fwrite(outputBuf, 1, dataLength, fpOutput); // SPS.
-
- // Encode Picture Paramater Set.
- dataLength = kOutputBufferSize;
- status = PVAVCEncodeNAL(&handle, outputBuf, &dataLength, &type);
- assert(type == AVC_NALTYPE_PPS);
- fwrite("\x00\x00\x00\x01", 1, 4, fpOutput); // Start Code.
- fwrite(outputBuf, 1, dataLength, fpOutput); // PPS.
-
- // Core loop.
- int32_t retVal = EXIT_SUCCESS;
- int32_t frameSize = (width * height * 3) / 2;
- int32_t numInputFrames = 0;
- int32_t numNalEncoded = 0;
- bool readyForNextFrame = true;
-
- while (1) {
- if (readyForNextFrame == true) {
- // Read the input frame.
- int32_t bytesRead;
- bytesRead = fread(inputBuf, 1, frameSize, fpInput);
- if (bytesRead != frameSize) {
- break; // End of file.
- }
-
- // Set the input frame.
- AVCFrameIO vin;
- memset(&vin, 0, sizeof(vin));
- vin.height = ((height + 15) >> 4) << 4;
- vin.pitch = ((width + 15) >> 4) << 4;
- vin.coding_timestamp = (numInputFrames * 1000) / frameRate; // in ms
- vin.YCbCr[0] = inputBuf;
- vin.YCbCr[1] = vin.YCbCr[0] + vin.height * vin.pitch;
- vin.YCbCr[2] = vin.YCbCr[1] + ((vin.height * vin.pitch) >> 2);
- vin.disp_order = numInputFrames;
-
- status = PVAVCEncSetInput(&handle, &vin);
- if (status == AVCENC_SUCCESS || status == AVCENC_NEW_IDR) {
- readyForNextFrame = false;
- ++numInputFrames;
- } else if (status < AVCENC_SUCCESS) {
- fprintf(stderr, "Error %d while setting input frame\n", status);
- retVal = EXIT_FAILURE;
- break;
- } else {
- fprintf(stderr, "Frame drop\n");
- readyForNextFrame = true;
- ++numInputFrames;
- continue;
- }
- }
-
- // Encode the input frame.
- dataLength = kOutputBufferSize;
- status = PVAVCEncodeNAL(&handle, outputBuf, &dataLength, &type);
- if (status == AVCENC_SUCCESS) {
- PVAVCEncGetOverrunBuffer(&handle);
- } else if (status == AVCENC_PICTURE_READY) {
- PVAVCEncGetOverrunBuffer(&handle);
- readyForNextFrame = true;
- AVCFrameIO recon;
- if (PVAVCEncGetRecon(&handle, &recon) == AVCENC_SUCCESS) {
- PVAVCEncReleaseRecon(&handle, &recon);
- }
- } else {
- dataLength = 0;
- readyForNextFrame = true;
- }
-
- if (status < AVCENC_SUCCESS) {
- fprintf(stderr, "Error %d while encoding frame\n", status);
- retVal = EXIT_FAILURE;
- break;
- }
-
- numNalEncoded++;
-
- // Write the output.
- if (dataLength > 0) {
- fwrite("\x00\x00\x00\x01", 1, 4, fpOutput); // Start Code.
- fwrite(outputBuf, 1, dataLength, fpOutput); // NAL.
- printf("NAL %d of size %d written\n", numNalEncoded, dataLength + 4);
- }
- }
-
- // Close input and output file.
- fclose(fpInput);
- fclose(fpOutput);
-
- // Free allocated memory.
- free(sliceGroup);
- free(inputBuf);
- free(outputBuf);
- for (int i = 0; i < kMaxDpbBuffers; ++i) {
- free(dpbBuffers[i]);
- }
-
- // Close encoder instance.
- PVAVCCleanUpEncoder(&handle);
-
- return retVal;
-}
diff --git a/media/libstagefright/codecs/avc/patent_disclaimer.txt b/media/libstagefright/codecs/avc/patent_disclaimer.txt
deleted file mode 100644
index b4bf11d..0000000
--- a/media/libstagefright/codecs/avc/patent_disclaimer.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-
-THIS IS NOT A GRANT OF PATENT RIGHTS.
-
-Google makes no representation or warranty that the codecs for which
-source code is made available hereunder are unencumbered by
-third-party patents. Those intending to use this source code in
-hardware or software products are advised that implementations of
-these codecs, including in open source software or shareware, may
-require patent licenses from the relevant patent holders.
diff --git a/media/libstagefright/codecs/avcdec/Android.bp b/media/libstagefright/codecs/avcdec/Android.bp
new file mode 100644
index 0000000..d5c2469
--- /dev/null
+++ b/media/libstagefright/codecs/avcdec/Android.bp
@@ -0,0 +1,29 @@
+cc_library_shared {
+ name: "libstagefright_soft_avcdec",
+
+ static_libs: ["libavcdec"],
+ srcs: ["SoftAVCDec.cpp"],
+
+ include_dirs: [
+ "external/libavc/decoder",
+ "external/libavc/common",
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ ldflags: ["-Wl,-Bsymbolic"],
+}
diff --git a/media/libstagefright/codecs/avcdec/Android.mk b/media/libstagefright/codecs/avcdec/Android.mk
deleted file mode 100644
index ef0dbfd..0000000
--- a/media/libstagefright/codecs/avcdec/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifeq ($(if $(wildcard external/libh264),1,0),1)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libstagefright_soft_avcdec
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_LIBRARIES := libavcdec
-LOCAL_SRC_FILES := SoftAVCDec.cpp
-
-LOCAL_C_INCLUDES := $(TOP)/external/libavc/decoder
-LOCAL_C_INCLUDES += $(TOP)/external/libavc/common
-LOCAL_C_INCLUDES += $(TOP)/frameworks/av/media/libstagefright/include
-LOCAL_C_INCLUDES += $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_SHARED_LIBRARIES := libstagefright
-LOCAL_SHARED_LIBRARIES += libstagefright_omx
-LOCAL_SHARED_LIBRARIES += libstagefright_foundation
-LOCAL_SHARED_LIBRARIES += libutils
-LOCAL_SHARED_LIBRARIES += liblog
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_LDFLAGS := -Wl,-Bsymbolic
-
-include $(BUILD_SHARED_LIBRARY)
-
-#endif
diff --git a/media/libstagefright/codecs/avcdec/SoftAVCDec.cpp b/media/libstagefright/codecs/avcdec/SoftAVCDec.cpp
index cecc52b..8694c73 100644
--- a/media/libstagefright/codecs/avcdec/SoftAVCDec.cpp
+++ b/media/libstagefright/codecs/avcdec/SoftAVCDec.cpp
@@ -120,7 +120,8 @@
mIvColorFormat(IV_YUV_420P),
mChangingResolution(false),
mSignalledError(false),
- mStride(mWidth){
+ mStride(mWidth),
+ mInputOffset(0){
initPorts(
1 /* numMinInputBuffers */, kNumBuffers, INPUT_BUF_SIZE,
1 /* numMinOutputBuffers */, kNumBuffers, CODEC_MIME_TYPE);
@@ -215,6 +216,7 @@
status_t SoftAVC::resetPlugin() {
mIsInFlush = false;
mReceivedEOS = false;
+ mInputOffset = 0;
memset(mTimeStamps, 0, sizeof(mTimeStamps));
memset(mTimeStampsValid, 0, sizeof(mTimeStampsValid));
@@ -443,8 +445,8 @@
if (inHeader) {
ps_dec_ip->u4_ts = timeStampIx;
ps_dec_ip->pv_stream_buffer =
- inHeader->pBuffer + inHeader->nOffset;
- ps_dec_ip->u4_num_Bytes = inHeader->nFilledLen;
+ inHeader->pBuffer + inHeader->nOffset + mInputOffset;
+ ps_dec_ip->u4_num_Bytes = inHeader->nFilledLen - mInputOffset;
} else {
ps_dec_ip->u4_ts = 0;
ps_dec_ip->pv_stream_buffer = NULL;
@@ -515,6 +517,8 @@
void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
UNUSED(portIndex);
+ OMX_BUFFERHEADERTYPE *inHeader = NULL;
+ BufferInfo *inInfo = NULL;
if (mSignalledError) {
return;
@@ -541,17 +545,11 @@
List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
while (!outQueue.empty()) {
- BufferInfo *inInfo;
- OMX_BUFFERHEADERTYPE *inHeader;
-
BufferInfo *outInfo;
OMX_BUFFERHEADERTYPE *outHeader;
- size_t timeStampIx;
+ size_t timeStampIx = 0;
- inInfo = NULL;
- inHeader = NULL;
-
- if (!mIsInFlush) {
+ if (!mIsInFlush && (NULL == inHeader)) {
if (!inQueue.empty()) {
inInfo = *inQueue.begin();
inHeader = inInfo->mHeader;
@@ -618,7 +616,7 @@
return;
}
// If input dump is enabled, then write to file
- DUMP_TO_FILE(mInFile, s_dec_ip.pv_stream_buffer, s_dec_ip.u4_num_Bytes);
+ DUMP_TO_FILE(mInFile, s_dec_ip.pv_stream_buffer, s_dec_ip.u4_num_Bytes, mInputOffset);
GETTIME(&mTimeStart, NULL);
/* Compute time elapsed between end of previous decode()
@@ -734,24 +732,26 @@
resetPlugin();
}
}
+ mInputOffset += s_dec_op.u4_num_bytes_consumed;
}
-
- /* If input EOS is seen and decoder is not in flush mode,
- * set the decoder in flush mode.
- * There can be a case where EOS is sent along with last picture data
- * In that case, only after decoding that input data, decoder has to be
- * put in flush. This case is handled here */
-
- if (mReceivedEOS && !mIsInFlush) {
- setFlushMode();
- }
-
- if (inHeader != NULL) {
+ // If more than 4 bytes are remaining in input, then do not release it
+ if (inHeader != NULL && ((inHeader->nFilledLen - mInputOffset) <= 4)) {
inInfo->mOwnedByUs = false;
inQueue.erase(inQueue.begin());
inInfo = NULL;
notifyEmptyBufferDone(inHeader);
inHeader = NULL;
+ mInputOffset = 0;
+
+ /* If input EOS is seen and decoder is not in flush mode,
+ * set the decoder in flush mode.
+ * There can be a case where EOS is sent along with last picture data
+ * In that case, only after decoding that input data, decoder has to be
+ * put in flush. This case is handled here */
+
+ if (mReceivedEOS && !mIsInFlush) {
+ setFlushMode();
+ }
}
}
}
diff --git a/media/libstagefright/codecs/avcdec/SoftAVCDec.h b/media/libstagefright/codecs/avcdec/SoftAVCDec.h
index 154ca38..2a71188 100644
--- a/media/libstagefright/codecs/avcdec/SoftAVCDec.h
+++ b/media/libstagefright/codecs/avcdec/SoftAVCDec.h
@@ -46,8 +46,8 @@
/** Compute difference between start and end */
#define TIME_DIFF(start, end, diff) \
- diff = ((end.tv_sec - start.tv_sec) * 1000000) + \
- (end.tv_usec - start.tv_usec);
+ diff = (((end).tv_sec - (start).tv_sec) * 1000000) + \
+ ((end).tv_usec - (start).tv_usec);
struct SoftAVC : public SoftVideoDecoderOMXComponent {
SoftAVC(const char *name, const OMX_CALLBACKTYPE *callbacks,
@@ -99,6 +99,7 @@
bool mFlushNeeded;
bool mSignalledError;
size_t mStride;
+ size_t mInputOffset;
status_t initDecoder();
status_t deInitDecoder();
@@ -143,10 +144,10 @@
ALOGD("Could not open file %s", m_filename); \
} \
}
-#define DUMP_TO_FILE(m_filename, m_buf, m_size) \
+#define DUMP_TO_FILE(m_filename, m_buf, m_size, m_offset)\
{ \
FILE *fp = fopen(m_filename, "ab"); \
- if (fp != NULL && m_buf != NULL) { \
+ if (fp != NULL && m_buf != NULL && m_offset == 0) { \
int i; \
i = fwrite(m_buf, 1, m_size, fp); \
ALOGD("fwrite ret %d to write %d", i, m_size); \
@@ -154,10 +155,12 @@
ALOGD("Error in fwrite, returned %d", i); \
perror("Error in write to file"); \
} \
- fclose(fp); \
- } else { \
+ } else if (fp == NULL) { \
ALOGD("Could not write to file %s", m_filename);\
} \
+ if (fp) { \
+ fclose(fp); \
+ } \
}
#else /* FILE_DUMP_ENABLE */
#define INPUT_DUMP_PATH
@@ -166,7 +169,7 @@
#define OUTPUT_DUMP_EXT
#define GENERATE_FILE_NAMES()
#define CREATE_DUMP_FILE(m_filename)
-#define DUMP_TO_FILE(m_filename, m_buf, m_size)
+#define DUMP_TO_FILE(m_filename, m_buf, m_size, m_offset)
#endif /* FILE_DUMP_ENABLE */
} // namespace android
diff --git a/media/libstagefright/codecs/avcenc/Android.bp b/media/libstagefright/codecs/avcenc/Android.bp
new file mode 100644
index 0000000..c766a34
--- /dev/null
+++ b/media/libstagefright/codecs/avcenc/Android.bp
@@ -0,0 +1,29 @@
+cc_library_shared {
+ name: "libstagefright_soft_avcenc",
+
+ static_libs: ["libavcenc"],
+ srcs: ["SoftAVCEnc.cpp"],
+
+ include_dirs: [
+ "external/libavc/encoder",
+ "external/libavc/common",
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/hardware",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libutils",
+ "liblog",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ ldflags: ["-Wl,-Bsymbolic"],
+}
diff --git a/media/libstagefright/codecs/avcenc/Android.mk b/media/libstagefright/codecs/avcenc/Android.mk
deleted file mode 100644
index 70e531b..0000000
--- a/media/libstagefright/codecs/avcenc/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifeq ($(if $(wildcard external/libh264),1,0),1)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libstagefright_soft_avcenc
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_LIBRARIES := libavcenc
-LOCAL_SRC_FILES := SoftAVCEnc.cpp
-
-LOCAL_C_INCLUDES := $(TOP)/external/libavc/encoder
-LOCAL_C_INCLUDES += $(TOP)/external/libavc/common
-LOCAL_C_INCLUDES += $(TOP)/frameworks/av/media/libstagefright/include
-LOCAL_C_INCLUDES += $(TOP)/frameworks/native/include/media/openmax
-LOCAL_C_INCLUDES += $(TOP)/frameworks/av/media/libstagefright/include
-LOCAL_C_INCLUDES += $(TOP)/frameworks/native/include/media/hardware
-LOCAL_C_INCLUDES += $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_SHARED_LIBRARIES := libstagefright
-LOCAL_SHARED_LIBRARIES += libstagefright_omx
-LOCAL_SHARED_LIBRARIES += libstagefright_foundation
-LOCAL_SHARED_LIBRARIES += libutils
-LOCAL_SHARED_LIBRARIES += liblog
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_LDFLAGS := -Wl,-Bsymbolic
-
-include $(BUILD_SHARED_LIBRARY)
-
-#endif
diff --git a/media/libstagefright/codecs/avcenc/SoftAVCEnc.h b/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
index 8b24b62..818e4a1 100644
--- a/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
+++ b/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
@@ -111,8 +111,8 @@
/** Compute difference between start and end */
#define TIME_DIFF(start, end, diff) \
- diff = ((end.tv_sec - start.tv_sec) * 1000000) + \
- (end.tv_usec - start.tv_usec);
+ diff = (((end).tv_sec - (start).tv_sec) * 1000000) + \
+ ((end).tv_usec - (start).tv_usec);
#define ive_aligned_malloc(alignment, size) memalign(alignment, size)
#define ive_aligned_free(buf) free(buf)
diff --git a/media/libstagefright/codecs/common/Android.bp b/media/libstagefright/codecs/common/Android.bp
new file mode 100644
index 0000000..021e6af
--- /dev/null
+++ b/media/libstagefright/codecs/common/Android.bp
@@ -0,0 +1,15 @@
+cc_library {
+ name: "libstagefright_enc_common",
+
+ srcs: ["cmnMemory.c"],
+
+ arch: {
+ arm: {
+ instruction_set: "arm",
+ },
+ },
+
+ export_include_dirs: ["include"],
+
+ cflags: ["-Werror"],
+}
diff --git a/media/libstagefright/codecs/common/Android.mk b/media/libstagefright/codecs/common/Android.mk
deleted file mode 100644
index b0010ff..0000000
--- a/media/libstagefright/codecs/common/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-
-
-LOCAL_SRC_FILES := cmnMemory.c
-
-LOCAL_MODULE := libstagefright_enc_common
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_STATIC_LIBRARIES :=
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include
-
-LOCAL_CFLAGS += -Werror
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-
diff --git a/media/libstagefright/codecs/common/include/voAAC.h b/media/libstagefright/codecs/common/include/voAAC.h
index 9ecb142..0a02feb 100644
--- a/media/libstagefright/codecs/common/include/voAAC.h
+++ b/media/libstagefright/codecs/common/include/voAAC.h
@@ -50,7 +50,7 @@
/* AAC Param ID */
#define VO_PID_AAC_Mdoule 0x42211000
-#define VO_PID_AAC_ENCPARAM VO_PID_AAC_Mdoule | 0x0040 /*!< get/set AAC encoder parameter, the parameter is a pointer to AACENC_PARAM */
+#define VO_PID_AAC_ENCPARAM (VO_PID_AAC_Mdoule | 0x0040) /*!< get/set AAC encoder parameter, the parameter is a pointer to AACENC_PARAM */
/* AAC decoder error ID */
#define VO_ERR_AAC_Mdoule 0x82210000
diff --git a/media/libstagefright/codecs/common/include/voAudio.h b/media/libstagefright/codecs/common/include/voAudio.h
index d8628ee..98d3f44 100644
--- a/media/libstagefright/codecs/common/include/voAudio.h
+++ b/media/libstagefright/codecs/common/include/voAudio.h
@@ -38,9 +38,9 @@
#define VO_PID_AUDIO_CHANNELMODE (VO_PID_AUDIO_BASE | 0X0005) /*!< The channel mode of audio */
#define VO_ERR_AUDIO_BASE 0x82000000
-#define VO_ERR_AUDIO_UNSCHANNEL VO_ERR_AUDIO_BASE | 0x0001
-#define VO_ERR_AUDIO_UNSSAMPLERATE VO_ERR_AUDIO_BASE | 0x0002
-#define VO_ERR_AUDIO_UNSFEATURE VO_ERR_AUDIO_BASE | 0x0003
+#define VO_ERR_AUDIO_UNSCHANNEL (VO_ERR_AUDIO_BASE | 0x0001)
+#define VO_ERR_AUDIO_UNSSAMPLERATE (VO_ERR_AUDIO_BASE | 0x0002)
+#define VO_ERR_AUDIO_UNSFEATURE (VO_ERR_AUDIO_BASE | 0x0003)
/**
diff --git a/media/libstagefright/codecs/common/include/voIndex.h b/media/libstagefright/codecs/common/include/voIndex.h
index 320a2f8..97b21f3 100644
--- a/media/libstagefright/codecs/common/include/voIndex.h
+++ b/media/libstagefright/codecs/common/include/voIndex.h
@@ -31,26 +31,26 @@
/* Define the module ID */
#define _MAKE_SOURCE_ID(id, name) \
-VO_INDEX_SRC_##name = _VO_INDEX_SOURCE | id,
+VO_INDEX_SRC_##name = _VO_INDEX_SOURCE | (id),
#define _MAKE_CODEC_ID(id, name) \
-VO_INDEX_DEC_##name = _VO_INDEX_DEC | id, \
-VO_INDEX_ENC_##name = _VO_INDEX_ENC | id,
+VO_INDEX_DEC_##name = _VO_INDEX_DEC | (id), \
+VO_INDEX_ENC_##name = _VO_INDEX_ENC | (id),
#define _MAKE_EFFECT_ID(id, name) \
-VO_INDEX_EFT_##name = _VO_INDEX_EFFECT | id,
+VO_INDEX_EFT_##name = _VO_INDEX_EFFECT | (id),
#define _MAKE_SINK_ID(id, name) \
-VO_INDEX_SNK_##name = _VO_INDEX_SINK | id,
+VO_INDEX_SNK_##name = _VO_INDEX_SINK | (id),
#define _MAKE_FILTER_ID(id, name) \
-VO_INDEX_FLT_##name = _VO_INDEX_FILTER | id,
+VO_INDEX_FLT_##name = _VO_INDEX_FILTER | (id),
#define _MAKE_OMX_ID(id, name) \
-VO_INDEX_OMX_##name = _VO_INDEX_OMX | id,
+VO_INDEX_OMX_##name = _VO_INDEX_OMX | (id),
#define _MAKE_MFW_ID(id, name) \
-VO_INDEX_MFW_##name = _VO_INDEX_MFW | id,
+VO_INDEX_MFW_##name = _VO_INDEX_MFW | (id),
enum
{
diff --git a/media/libstagefright/codecs/common/include/voMem.h b/media/libstagefright/codecs/common/include/voMem.h
index 8dfb634..2b5aef1 100644
--- a/media/libstagefright/codecs/common/include/voMem.h
+++ b/media/libstagefright/codecs/common/include/voMem.h
@@ -53,8 +53,8 @@
{ \
VO_MEM_INFO voMemInfo; \
voMemInfo.Size=nSize; \
- pMemOP->Alloc(ID, &voMemInfo); \
- pBuff=(VO_PBYTE)voMemInfo.VBuffer; \
+ (pMemOP)->Alloc(ID, &voMemInfo); \
+ (pBuff)=(VO_PBYTE)voMemInfo.VBuffer; \
}
diff --git a/media/libstagefright/codecs/flac/Android.bp b/media/libstagefright/codecs/flac/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/media/libstagefright/codecs/flac/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/media/libstagefright/codecs/flac/Android.mk b/media/libstagefright/codecs/flac/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/flac/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/flac/enc/Android.bp b/media/libstagefright/codecs/flac/enc/Android.bp
new file mode 100644
index 0000000..5416949
--- /dev/null
+++ b/media/libstagefright/codecs/flac/enc/Android.bp
@@ -0,0 +1,32 @@
+cc_library_shared {
+
+ srcs: ["SoftFlacEncoder.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ "external/flac/include",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ static_libs: ["libFLAC"],
+
+ name: "libstagefright_soft_flacenc",
+
+}
diff --git a/media/libstagefright/codecs/flac/enc/Android.mk b/media/libstagefright/codecs/flac/enc/Android.mk
deleted file mode 100644
index 7e6e015..0000000
--- a/media/libstagefright/codecs/flac/enc/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftFlacEncoder.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
- external/flac/include
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libstagefright_omx libstagefright_foundation libutils liblog
-
-LOCAL_STATIC_LIBRARIES := \
- libFLAC \
-
-LOCAL_MODULE := libstagefright_soft_flacenc
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/flac/enc/SoftFlacEncoder.h b/media/libstagefright/codecs/flac/enc/SoftFlacEncoder.h
index 97361fa..6027f76 100644
--- a/media/libstagefright/codecs/flac/enc/SoftFlacEncoder.h
+++ b/media/libstagefright/codecs/flac/enc/SoftFlacEncoder.h
@@ -48,13 +48,10 @@
virtual void onQueueFilled(OMX_U32 portIndex);
private:
-
- enum {
- kNumBuffers = 2,
- kMaxNumSamplesPerFrame = 1152,
- kMaxInputBufferSize = kMaxNumSamplesPerFrame * sizeof(int16_t) * 2,
- kMaxOutputBufferSize = 65536, //TODO check if this can be reduced
- };
+ const unsigned int kNumBuffers = 2;
+ const unsigned int kMaxNumSamplesPerFrame = 1152;
+ const unsigned int kMaxInputBufferSize = kMaxNumSamplesPerFrame * sizeof(int16_t) * 2;
+ const unsigned int kMaxOutputBufferSize = 65536; //TODO check if this can be reduced
bool mSignalledError;
diff --git a/media/libstagefright/codecs/g711/Android.bp b/media/libstagefright/codecs/g711/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/media/libstagefright/codecs/g711/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/media/libstagefright/codecs/g711/Android.mk b/media/libstagefright/codecs/g711/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/g711/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/g711/dec/Android.bp b/media/libstagefright/codecs/g711/dec/Android.bp
new file mode 100644
index 0000000..581ed4f
--- /dev/null
+++ b/media/libstagefright/codecs/g711/dec/Android.bp
@@ -0,0 +1,26 @@
+cc_library_shared {
+ name: "libstagefright_soft_g711dec",
+
+ srcs: ["SoftG711.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libutils",
+ "liblog",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/codecs/g711/dec/Android.mk b/media/libstagefright/codecs/g711/dec/Android.mk
deleted file mode 100644
index b36c99d..0000000
--- a/media/libstagefright/codecs/g711/dec/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftG711.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libstagefright_omx libstagefright_foundation libutils liblog
-
-LOCAL_MODULE := libstagefright_soft_g711dec
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/gsm/Android.bp b/media/libstagefright/codecs/gsm/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/media/libstagefright/codecs/gsm/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/media/libstagefright/codecs/gsm/Android.mk b/media/libstagefright/codecs/gsm/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/gsm/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/gsm/dec/Android.bp b/media/libstagefright/codecs/gsm/dec/Android.bp
new file mode 100644
index 0000000..03b4f88
--- /dev/null
+++ b/media/libstagefright/codecs/gsm/dec/Android.bp
@@ -0,0 +1,29 @@
+cc_library_shared {
+ name: "libstagefright_soft_gsmdec",
+
+ srcs: ["SoftGSM.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ "external/libgsm/inc",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libutils",
+ "liblog",
+ ],
+
+ static_libs: ["libgsm"],
+}
diff --git a/media/libstagefright/codecs/gsm/dec/Android.mk b/media/libstagefright/codecs/gsm/dec/Android.mk
deleted file mode 100644
index fe8c830..0000000
--- a/media/libstagefright/codecs/gsm/dec/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftGSM.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
- external/libgsm/inc
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libstagefright_omx libstagefright_foundation libutils liblog
-
-LOCAL_STATIC_LIBRARIES := \
- libgsm
-
-LOCAL_MODULE := libstagefright_soft_gsmdec
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/hevcdec/Android.bp b/media/libstagefright/codecs/hevcdec/Android.bp
new file mode 100644
index 0000000..6e4df50
--- /dev/null
+++ b/media/libstagefright/codecs/hevcdec/Android.bp
@@ -0,0 +1,32 @@
+cc_library_shared {
+ name: "libstagefright_soft_hevcdec",
+
+ static_libs: ["libhevcdec"],
+ srcs: ["SoftHEVC.cpp"],
+
+ include_dirs: [
+ "external/libhevc/decoder",
+ "external/libhevc/common",
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ // We need this because the current asm generates the following link error:
+ // requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
+ // Bug: 16853291
+ ldflags: ["-Wl,-Bsymbolic"],
+}
diff --git a/media/libstagefright/codecs/hevcdec/Android.mk b/media/libstagefright/codecs/hevcdec/Android.mk
deleted file mode 100644
index 78c4637..0000000
--- a/media/libstagefright/codecs/hevcdec/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-ifeq ($(if $(wildcard external/libhevc),1,0),1)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libstagefright_soft_hevcdec
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_LIBRARIES := libhevcdec
-LOCAL_SRC_FILES := SoftHEVC.cpp
-
-LOCAL_C_INCLUDES := $(TOP)/external/libhevc/decoder
-LOCAL_C_INCLUDES += $(TOP)/external/libhevc/common
-LOCAL_C_INCLUDES += $(TOP)/frameworks/av/media/libstagefright/include
-LOCAL_C_INCLUDES += $(TOP)/frameworks/native/include/media/openmax
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_SHARED_LIBRARIES := libstagefright
-LOCAL_SHARED_LIBRARIES += libstagefright_omx
-LOCAL_SHARED_LIBRARIES += libstagefright_foundation
-LOCAL_SHARED_LIBRARIES += libutils
-LOCAL_SHARED_LIBRARIES += liblog
-
-# We need this because the current asm generates the following link error:
-# requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
-# Bug: 16853291
-LOCAL_LDFLAGS := -Wl,-Bsymbolic
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif
diff --git a/media/libstagefright/codecs/hevcdec/SoftHEVC.h b/media/libstagefright/codecs/hevcdec/SoftHEVC.h
index 20a836b..e7c2127 100644
--- a/media/libstagefright/codecs/hevcdec/SoftHEVC.h
+++ b/media/libstagefright/codecs/hevcdec/SoftHEVC.h
@@ -46,8 +46,8 @@
/** Compute difference between start and end */
#define TIME_DIFF(start, end, diff) \
- diff = ((end.tv_sec - start.tv_sec) * 1000000) + \
- (end.tv_usec - start.tv_usec);
+ diff = (((end).tv_sec - (start).tv_sec) * 1000000) + \
+ ((end).tv_usec - (start).tv_usec);
struct SoftHEVC: public SoftVideoDecoderOMXComponent {
SoftHEVC(const char *name, const OMX_CALLBACKTYPE *callbacks,
diff --git a/media/libstagefright/codecs/m4v_h263/Android.bp b/media/libstagefright/codecs/m4v_h263/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/media/libstagefright/codecs/m4v_h263/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/media/libstagefright/codecs/m4v_h263/Android.mk b/media/libstagefright/codecs/m4v_h263/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/m4v_h263/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/m4v_h263/dec/Android.bp b/media/libstagefright/codecs/m4v_h263/dec/Android.bp
new file mode 100644
index 0000000..af75420
--- /dev/null
+++ b/media/libstagefright/codecs/m4v_h263/dec/Android.bp
@@ -0,0 +1,98 @@
+cc_library_static {
+ name: "libstagefright_m4vh263dec",
+
+ srcs: [
+ "src/adaptive_smooth_no_mmx.cpp",
+ "src/bitstream.cpp",
+ "src/block_idct.cpp",
+ "src/cal_dc_scaler.cpp",
+ "src/chvr_filter.cpp",
+ "src/chv_filter.cpp",
+ "src/combined_decode.cpp",
+ "src/conceal.cpp",
+ "src/datapart_decode.cpp",
+ "src/dcac_prediction.cpp",
+ "src/dec_pred_intra_dc.cpp",
+ "src/deringing_chroma.cpp",
+ "src/deringing_luma.cpp",
+ "src/find_min_max.cpp",
+ "src/get_pred_adv_b_add.cpp",
+ "src/get_pred_outside.cpp",
+ "src/idct.cpp",
+ "src/idct_vca.cpp",
+ "src/mb_motion_comp.cpp",
+ "src/mb_utils.cpp",
+ "src/packet_util.cpp",
+ "src/post_filter.cpp",
+ "src/post_proc_semaphore.cpp",
+ "src/pp_semaphore_chroma_inter.cpp",
+ "src/pp_semaphore_luma.cpp",
+ "src/pvdec_api.cpp",
+ "src/scaling_tab.cpp",
+ "src/vlc_decode.cpp",
+ "src/vlc_dequant.cpp",
+ "src/vlc_tab.cpp",
+ "src/vop.cpp",
+ "src/zigzag_tab.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ local_include_dirs: ["src"],
+ export_include_dirs: ["include"],
+
+ cflags: [
+ "-DOSCL_EXPORT_REF=",
+ "-DOSCL_IMPORT_REF=",
+
+ "-Werror",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
+
+//###############################################################################
+
+cc_library_shared {
+ name: "libstagefright_soft_mpeg4dec",
+
+ srcs: ["SoftMPEG4.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ local_include_dirs: ["src"],
+ export_include_dirs: ["include"],
+
+ cflags: [
+ "-DOSCL_EXPORT_REF=",
+ "-DOSCL_IMPORT_REF=",
+
+ "-Werror",
+ ],
+
+ static_libs: ["libstagefright_m4vh263dec"],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/codecs/m4v_h263/dec/Android.mk b/media/libstagefright/codecs/m4v_h263/dec/Android.mk
deleted file mode 100644
index eb39b44..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/Android.mk
+++ /dev/null
@@ -1,83 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/adaptive_smooth_no_mmx.cpp \
- src/bitstream.cpp \
- src/block_idct.cpp \
- src/cal_dc_scaler.cpp \
- src/chvr_filter.cpp \
- src/chv_filter.cpp \
- src/combined_decode.cpp \
- src/conceal.cpp \
- src/datapart_decode.cpp \
- src/dcac_prediction.cpp \
- src/dec_pred_intra_dc.cpp \
- src/deringing_chroma.cpp \
- src/deringing_luma.cpp \
- src/find_min_max.cpp \
- src/get_pred_adv_b_add.cpp \
- src/get_pred_outside.cpp \
- src/idct.cpp \
- src/idct_vca.cpp \
- src/mb_motion_comp.cpp \
- src/mb_utils.cpp \
- src/packet_util.cpp \
- src/post_filter.cpp \
- src/post_proc_semaphore.cpp \
- src/pp_semaphore_chroma_inter.cpp \
- src/pp_semaphore_luma.cpp \
- src/pvdec_api.cpp \
- src/scaling_tab.cpp \
- src/vlc_decode.cpp \
- src/vlc_dequant.cpp \
- src/vlc_tab.cpp \
- src/vop.cpp \
- src/zigzag_tab.cpp
-
-
-LOCAL_MODULE := libstagefright_m4vh263dec
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(TOP)/frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS := -DOSCL_EXPORT_REF= -DOSCL_IMPORT_REF=
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftMPEG4.cpp
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS := -DOSCL_EXPORT_REF= -DOSCL_IMPORT_REF=
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_m4vh263dec
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libstagefright_omx libstagefright_foundation libutils liblog
-
-LOCAL_MODULE := libstagefright_soft_mpeg4dec
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/m4v_h263/dec/include/m4vh263_decoder_pv_types.h b/media/libstagefright/codecs/m4v_h263/dec/include/m4vh263_decoder_pv_types.h
index ec6871f..711ec58 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/include/m4vh263_decoder_pv_types.h
+++ b/media/libstagefright/codecs/m4v_h263/dec/include/m4vh263_decoder_pv_types.h
@@ -51,7 +51,7 @@
{
public:
OsclAOStatus();
- OsclAOStatus(int32 aStatus);
+ explicit OsclAOStatus(int32 aStatus);
int32 operator=(int32 aStatus);
int32 operator==(int32 aStatus) const;
int32 operator!=(int32 aStatus) const;
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/conceal.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/conceal.cpp
index 03e4119..8393d79 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/conceal.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/conceal.cpp
@@ -15,11 +15,15 @@
* and limitations under the License.
* -------------------------------------------------------------------
*/
+
+#define LOG_TAG "conceal"
+
+#include "log/log.h"
+
#include "mp4dec_lib.h" /* video decoder function prototypes */
#include "vlc_decode.h"
#include "bitstream.h"
#include "scaling.h"
-#include "log/log.h"
/* ====================================================================== /
Function : ConcealTexture_I()
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/idct.h b/media/libstagefright/codecs/m4v_h263/dec/src/idct.h
index 8edb654..484631b 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/idct.h
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/idct.h
@@ -80,9 +80,9 @@
#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */
#define W1mW7 2276
#define W1pW7 3406
-#define W5mW3 -799
-#define mW3mW5 -4017
-#define mW2mW6 -3784
+#define W5mW3 (-799)
+#define mW3mW5 (-4017)
+#define mW2mW6 (-3784)
#define W2mW6 1568
/* left shift by 11 is to maintain the accuracy of the decimal point */
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/motion_comp.h b/media/libstagefright/codecs/m4v_h263/dec/src/motion_comp.h
index 0c12f20..68281ba 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/motion_comp.h
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/motion_comp.h
@@ -54,20 +54,20 @@
{
#endif
-#define CLIP_RESULT(x) if(x & -256){x = 0xFF & (~(x>>31));}
+#define CLIP_RESULT(x) if((x) & -256){(x) = 0xFF & (~((x)>>31));}
#define ADD_AND_CLIP1(x) x += (pred_word&0xFF); CLIP_RESULT(x);
#define ADD_AND_CLIP2(x) x += ((pred_word>>8)&0xFF); CLIP_RESULT(x);
#define ADD_AND_CLIP3(x) x += ((pred_word>>16)&0xFF); CLIP_RESULT(x);
#define ADD_AND_CLIP4(x) x += ((pred_word>>24)&0xFF); CLIP_RESULT(x);
-#define ADD_AND_CLIP(x,y) { x9 = ~(x>>8); \
+#define ADD_AND_CLIP(x,y) { x9 = ~((x)>>8); \
if(x9!=-1){ \
x9 = ((uint32)x9)>>24; \
- y = x9|(y<<8); \
+ (y) = x9|((y)<<8); \
} \
else \
{ \
- y = x|(y<<8); \
+ (y) = (x)|((y)<<8); \
} \
}
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/mp4def.h b/media/libstagefright/codecs/m4v_h263/dec/src/mp4def.h
index 3388d89..20f458d 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/mp4def.h
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/mp4def.h
@@ -47,7 +47,7 @@
/* You don't want to use ((x>UB)?UB:(x<LB)?LB:x) for the clipping */
/* because it will use one extra comparison if the compiler is */
/* not well-optimized. 04/19/2000. */
-#define CLIP_THE_RANGE(x,LB,UB) if (x<LB) x = LB; else if (x>UB) x = UB
+#define CLIP_THE_RANGE(x,LB,UB) if ((x)<(LB)) (x) = (LB); else if ((x)>(UB)) (x) = (UB)
#define MODE_INTRA 0x08 //01000
#define MODE_INTRA_Q 0x09 //01001
@@ -72,7 +72,7 @@
#define START_CODE_LENGTH 32
/* 11/30/98 */
-#define NoMarkerFound -1
+#define NoMarkerFound (-1)
#define FoundRM 1 /* Resync Marker */
#define FoundVSC 2 /* VOP_START_CODE. */
#define FoundGSC 3 /* GROUP_START_CODE */
@@ -153,7 +153,7 @@
/* macro utility */
-#define ZERO_OUT_64BYTES(x) { *((uint32*)x) = *(((uint32*)(x))+1) = \
+#define ZERO_OUT_64BYTES(x) { *((uint32*)(x)) = *(((uint32*)(x))+1) = \
*(((uint32*)(x))+2) = *(((uint32*)(x))+3) = \
*(((uint32*)(x))+4) = *(((uint32*)(x))+5) = \
*(((uint32*)(x))+6) = *(((uint32*)(x))+7) = \
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/post_proc.h b/media/libstagefright/codecs/m4v_h263/dec/src/post_proc.h
index 091fdaf..a8ab37f 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/post_proc.h
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/post_proc.h
@@ -32,9 +32,9 @@
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
-#define UPDATE_PV_MAXPV_MIN(p,max,min) if ((p) > max) max=(p); else if ((p) < min) min = (p);
+#define UPDATE_PV_MAXPV_MIN(p,max,min) if ((p) > (max)) (max)=(p); else if ((p) < (min)) (min) = (p);
-#define INDEX(x,thr) (((x)>=thr)?1:0)
+#define INDEX(x,thr) (((x)>=(thr))?1:0)
#define BLKSIZE 8
#define MBSIZE 16
#define DERING_THR 16
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/vlc_decode.h b/media/libstagefright/codecs/m4v_h263/dec/src/vlc_decode.h
index a804606..e242820 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/vlc_decode.h
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/vlc_decode.h
@@ -79,10 +79,10 @@
#include "mp4lib_int.h"
#define VLC_ERROR_DETECTED(x) ((x) < 0)
-#define VLC_IO_ERROR -1
-#define VLC_CODE_ERROR -2
-#define VLC_MB_STUFFING -4
-#define VLC_NO_LAST_BIT -5
+#define VLC_IO_ERROR (-1)
+#define VLC_CODE_ERROR (-2)
+#define VLC_MB_STUFFING (-4)
+#define VLC_NO_LAST_BIT (-5)
#define VLC_ESCAPE_CODE 7167
diff --git a/media/libstagefright/codecs/m4v_h263/enc/Android.bp b/media/libstagefright/codecs/m4v_h263/enc/Android.bp
new file mode 100644
index 0000000..4a127f3
--- /dev/null
+++ b/media/libstagefright/codecs/m4v_h263/enc/Android.bp
@@ -0,0 +1,110 @@
+cc_library_static {
+ name: "libstagefright_m4vh263enc",
+
+ srcs: [
+ "src/bitstream_io.cpp",
+ "src/combined_encode.cpp",
+ "src/datapart_encode.cpp",
+ "src/dct.cpp",
+ "src/findhalfpel.cpp",
+ "src/fastcodemb.cpp",
+ "src/fastidct.cpp",
+ "src/fastquant.cpp",
+ "src/me_utils.cpp",
+ "src/mp4enc_api.cpp",
+ "src/rate_control.cpp",
+ "src/motion_est.cpp",
+ "src/motion_comp.cpp",
+ "src/sad.cpp",
+ "src/sad_halfpel.cpp",
+ "src/vlc_encode.cpp",
+ "src/vop.cpp",
+ ],
+
+ cflags: [
+ "-DBX_RC",
+ "-DOSCL_IMPORT_REF=",
+ "-DOSCL_UNUSED_ARG(x)=(void)(x)",
+ "-DOSCL_EXPORT_REF=",
+
+ "-Werror",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+ local_include_dirs: ["src"],
+ export_include_dirs: ["include"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
+
+//###############################################################################
+
+cc_library_shared {
+ name: "libstagefright_soft_mpeg4enc",
+
+ srcs: ["SoftMPEG4Encoder.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ "frameworks/native/include/media/hardware",
+ ],
+ local_include_dirs: ["src"],
+ export_include_dirs: ["include"],
+
+ cflags: [
+ "-DBX_RC",
+ "-DOSCL_IMPORT_REF=",
+ "-DOSCL_UNUSED_ARG(x)=(void)(x)",
+ "-DOSCL_EXPORT_REF=",
+
+ "-Werror",
+ ],
+
+ static_libs: ["libstagefright_m4vh263enc"],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libutils",
+ "liblog",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
+
+//###############################################################################
+
+cc_test {
+ name: "libstagefright_m4vh263enc_test",
+ gtest: false,
+
+ srcs: ["test/m4v_h263_enc_test.cpp"],
+
+ local_include_dirs: ["src"],
+
+ cflags: [
+ "-DOSCL_EXPORT_REF=",
+ "-DOSCL_IMPORT_REF=",
+ "-DBX_RC",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ static_libs: ["libstagefright_m4vh263enc"],
+}
diff --git a/media/libstagefright/codecs/m4v_h263/enc/Android.mk b/media/libstagefright/codecs/m4v_h263/enc/Android.mk
deleted file mode 100644
index ab079e8..0000000
--- a/media/libstagefright/codecs/m4v_h263/enc/Android.mk
+++ /dev/null
@@ -1,105 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/bitstream_io.cpp \
- src/combined_encode.cpp \
- src/datapart_encode.cpp \
- src/dct.cpp \
- src/findhalfpel.cpp \
- src/fastcodemb.cpp \
- src/fastidct.cpp \
- src/fastquant.cpp \
- src/me_utils.cpp \
- src/mp4enc_api.cpp \
- src/rate_control.cpp \
- src/motion_est.cpp \
- src/motion_comp.cpp \
- src/sad.cpp \
- src/sad_halfpel.cpp \
- src/vlc_encode.cpp \
- src/vop.cpp
-
-
-LOCAL_MODULE := libstagefright_m4vh263enc
-
-LOCAL_CFLAGS := \
- -DBX_RC \
- -DOSCL_IMPORT_REF= -D"OSCL_UNUSED_ARG(x)=(void)(x)" -DOSCL_EXPORT_REF=
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(TOP)/frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftMPEG4Encoder.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
- frameworks/native/include/media/hardware \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../common/include \
- $(LOCAL_PATH)/../common
-
-LOCAL_CFLAGS := \
- -DBX_RC \
- -DOSCL_IMPORT_REF= -D"OSCL_UNUSED_ARG(x)=(void)(x)" -DOSCL_EXPORT_REF=
-
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_m4vh263enc
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright \
- libstagefright_enc_common \
- libstagefright_foundation \
- libstagefright_omx \
- libutils \
- liblog \
- libui
-
-
-LOCAL_MODULE := libstagefright_soft_mpeg4enc
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
- test/m4v_h263_enc_test.cpp
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include
-
-LOCAL_CFLAGS := -DOSCL_EXPORT_REF= -DOSCL_IMPORT_REF= -DBX_RC
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_m4vh263enc
-
-LOCAL_MODULE := libstagefright_m4vh263enc_test
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/fastidct.cpp b/media/libstagefright/codecs/m4v_h263/enc/src/fastidct.cpp
index 21d7427..688effc 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/src/fastidct.cpp
+++ b/media/libstagefright/codecs/m4v_h263/enc/src/fastidct.cpp
@@ -55,7 +55,7 @@
}
-#define CLIP_RESULT(x) if((UInt)x > 0xFF){x = 0xFF & (~(x>>31));}
+#define CLIP_RESULT(x) if((UInt)(x) > 0xFF){(x) = 0xFF & (~((x)>>31));}
#define ADD_AND_CLIP1(x) x += (pred_word&0xFF); CLIP_RESULT(x);
#define ADD_AND_CLIP2(x) x += ((pred_word>>8)&0xFF); CLIP_RESULT(x);
#define ADD_AND_CLIP3(x) x += ((pred_word>>16)&0xFF); CLIP_RESULT(x);
diff --git a/media/libstagefright/codecs/mp3dec/Android.bp b/media/libstagefright/codecs/mp3dec/Android.bp
new file mode 100644
index 0000000..8b2a761
--- /dev/null
+++ b/media/libstagefright/codecs/mp3dec/Android.bp
@@ -0,0 +1,134 @@
+cc_library_static {
+ name: "libstagefright_mp3dec",
+
+ srcs: [
+ "src/pvmp3_normalize.cpp",
+ "src/pvmp3_alias_reduction.cpp",
+ "src/pvmp3_crc.cpp",
+ "src/pvmp3_decode_header.cpp",
+ "src/pvmp3_decode_huff_cw.cpp",
+ "src/pvmp3_getbits.cpp",
+ "src/pvmp3_dequantize_sample.cpp",
+ "src/pvmp3_framedecoder.cpp",
+ "src/pvmp3_get_main_data_size.cpp",
+ "src/pvmp3_get_side_info.cpp",
+ "src/pvmp3_get_scale_factors.cpp",
+ "src/pvmp3_mpeg2_get_scale_data.cpp",
+ "src/pvmp3_mpeg2_get_scale_factors.cpp",
+ "src/pvmp3_mpeg2_stereo_proc.cpp",
+ "src/pvmp3_huffman_decoding.cpp",
+ "src/pvmp3_huffman_parsing.cpp",
+ "src/pvmp3_tables.cpp",
+ "src/pvmp3_imdct_synth.cpp",
+ "src/pvmp3_mdct_6.cpp",
+ "src/pvmp3_dct_6.cpp",
+ "src/pvmp3_poly_phase_synthesis.cpp",
+ "src/pvmp3_equalizer.cpp",
+ "src/pvmp3_seek_synch.cpp",
+ "src/pvmp3_stereo_proc.cpp",
+ "src/pvmp3_reorder.cpp",
+
+ "src/pvmp3_polyphase_filter_window.cpp",
+ "src/pvmp3_mdct_18.cpp",
+ "src/pvmp3_dct_9.cpp",
+ "src/pvmp3_dct_16.cpp",
+ ],
+
+ arch: {
+ arm: {
+ exclude_srcs: [
+ "src/pvmp3_polyphase_filter_window.cpp",
+ "src/pvmp3_mdct_18.cpp",
+ "src/pvmp3_dct_9.cpp",
+ "src/pvmp3_dct_16.cpp",
+ ],
+ srcs: [
+ "src/asm/pvmp3_polyphase_filter_window_gcc.s",
+ "src/asm/pvmp3_mdct_18_gcc.s",
+ "src/asm/pvmp3_dct_9_gcc.s",
+ "src/asm/pvmp3_dct_16_gcc.s",
+ ],
+
+ instruction_set: "arm",
+ },
+ },
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ include_dirs: ["frameworks/av/media/libstagefright/include"],
+ local_include_dirs: ["src"],
+ export_include_dirs: ["include"],
+
+ cflags: [
+ "-DOSCL_UNUSED_ARG(x)=(void)(x)",
+ "-Werror",
+ ],
+}
+
+//###############################################################################
+
+cc_library_shared {
+ name: "libstagefright_soft_mp3dec",
+
+ srcs: ["SoftMP3.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+ local_include_dirs: [
+ "src",
+ "include",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ static_libs: ["libstagefright_mp3dec"],
+}
+
+//###############################################################################
+cc_test {
+ name: "libstagefright_mp3dec_test",
+ gtest: false,
+
+ srcs: [
+ "test/mp3dec_test.cpp",
+ "test/mp3reader.cpp",
+ ],
+
+ local_include_dirs: [
+ "src",
+ "include",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ static_libs: [
+ "libstagefright_mp3dec",
+ "libsndfile",
+ ],
+
+ shared_libs: ["libaudioutils"],
+}
diff --git a/media/libstagefright/codecs/mp3dec/Android.mk b/media/libstagefright/codecs/mp3dec/Android.mk
deleted file mode 100644
index 11581c1..0000000
--- a/media/libstagefright/codecs/mp3dec/Android.mk
+++ /dev/null
@@ -1,116 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/pvmp3_normalize.cpp \
- src/pvmp3_alias_reduction.cpp \
- src/pvmp3_crc.cpp \
- src/pvmp3_decode_header.cpp \
- src/pvmp3_decode_huff_cw.cpp \
- src/pvmp3_getbits.cpp \
- src/pvmp3_dequantize_sample.cpp \
- src/pvmp3_framedecoder.cpp \
- src/pvmp3_get_main_data_size.cpp \
- src/pvmp3_get_side_info.cpp \
- src/pvmp3_get_scale_factors.cpp \
- src/pvmp3_mpeg2_get_scale_data.cpp \
- src/pvmp3_mpeg2_get_scale_factors.cpp \
- src/pvmp3_mpeg2_stereo_proc.cpp \
- src/pvmp3_huffman_decoding.cpp \
- src/pvmp3_huffman_parsing.cpp \
- src/pvmp3_tables.cpp \
- src/pvmp3_imdct_synth.cpp \
- src/pvmp3_mdct_6.cpp \
- src/pvmp3_dct_6.cpp \
- src/pvmp3_poly_phase_synthesis.cpp \
- src/pvmp3_equalizer.cpp \
- src/pvmp3_seek_synch.cpp \
- src/pvmp3_stereo_proc.cpp \
- src/pvmp3_reorder.cpp \
-
-LOCAL_SRC_FILES_arm += \
- src/asm/pvmp3_polyphase_filter_window_gcc.s \
- src/asm/pvmp3_mdct_18_gcc.s \
- src/asm/pvmp3_dct_9_gcc.s \
- src/asm/pvmp3_dct_16_gcc.s
-LOCAL_SRC_FILES_other_archs := \
- src/pvmp3_polyphase_filter_window.cpp \
- src/pvmp3_mdct_18.cpp \
- src/pvmp3_dct_9.cpp \
- src/pvmp3_dct_16.cpp
-
-LOCAL_SRC_FILES_arm64 := $(LOCAL_SRC_FILES_other_archs)
-LOCAL_SRC_FILES_mips := $(LOCAL_SRC_FILES_other_archs)
-LOCAL_SRC_FILES_mips64 := $(LOCAL_SRC_FILES_other_archs)
-LOCAL_SRC_FILES_x86 := $(LOCAL_SRC_FILES_other_archs)
-LOCAL_SRC_FILES_x86_64 := $(LOCAL_SRC_FILES_other_archs)
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include
-
-LOCAL_CFLAGS := \
- -D"OSCL_UNUSED_ARG(x)=(void)(x)"
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE := libstagefright_mp3dec
-
-LOCAL_ARM_MODE := arm
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftMP3.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libstagefright_omx libstagefright_foundation libutils liblog
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_mp3dec
-
-LOCAL_MODULE := libstagefright_soft_mp3dec
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-################################################################################
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
- test/mp3dec_test.cpp \
- test/mp3reader.cpp
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/src \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/test/include \
- $(call include-path-for, audio-utils)
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_mp3dec libsndfile
-
-LOCAL_SHARED_LIBRARIES := libaudioutils
-
-LOCAL_MODULE := libstagefright_mp3dec_test
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
index 0822c34..3def1f0 100644
--- a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
+++ b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
@@ -274,7 +274,7 @@
mConfig->inputBufferUsedLength = 0;
mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t);
- if ((int32)outHeader->nAllocLen < mConfig->outputFrameSize) {
+ if ((int32_t)outHeader->nAllocLen < mConfig->outputFrameSize) {
ALOGE("input buffer too small: got %u, expected %u",
outHeader->nAllocLen, mConfig->outputFrameSize);
android_errorWriteLog(0x534e4554, "27793371");
@@ -363,7 +363,7 @@
mAnchorTimeUs + (mNumFramesOutput * 1000000ll) / mSamplingRate;
if (inHeader) {
- CHECK_GE(inHeader->nFilledLen, mConfig->inputBufferUsedLength);
+ CHECK_GE((int32_t)inHeader->nFilledLen, mConfig->inputBufferUsedLength);
inHeader->nOffset += mConfig->inputBufferUsedLength;
inHeader->nFilledLen -= mConfig->inputBufferUsedLength;
diff --git a/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h
index 7f480a6..adb0dd4 100644
--- a/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h
+++ b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h
@@ -44,9 +44,9 @@
#endif
#include "pvmp3_audio_type_defs.h"
-#define Qfmt_31(a) (Int32)((float)a*0x7FFFFFFF)
+#define Qfmt_31(a) (Int32)((float)(a)*0x7FFFFFFF)
-#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
+#define Qfmt15(x) (Int16)((x)*((Int32)1<<15) + ((x)>=0?0.5F:-0.5F))
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.cpp
index 32c76c6..af738ba 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.cpp
@@ -109,7 +109,7 @@
----------------------------------------------------------------------------*/
#define NUM_BUTTERFLIES 8
-#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a))
+#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*(a)))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.cpp
index 949e7be..cc99d5c 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.cpp
@@ -109,7 +109,7 @@
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
-#define Qfmt(a) (int32)(a*((int32)1<<27))
+#define Qfmt(a) (int32)((a)*((int32)1<<27))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_6.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_6.cpp
index 4c5fb03..1f8018a 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_6.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_6.cpp
@@ -79,7 +79,7 @@
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
-#define Qfmt30(a) (Int32)(a*((Int32)1<<30) + (a>=0?0.5F:-0.5F))
+#define Qfmt30(a) (Int32)((a)*((Int32)1<<30) + ((a)>=0?0.5F:-0.5F))
#define cos_pi_6 Qfmt30( 0.86602540378444f)
#define cos_2_pi_6 Qfmt30( 0.5f)
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_9.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_9.cpp
index fa581b3..bbb247d 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_9.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_9.cpp
@@ -77,7 +77,7 @@
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
-#define Qfmt31(a) (int32)(a*(0x7FFFFFFF))
+#define Qfmt31(a) (int32)((a)*(0x7FFFFFFF))
#define cos_pi_9 Qfmt31( 0.93969262078591f)
#define cos_2pi_9 Qfmt31( 0.76604444311898f)
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dec_defs.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_dec_defs.h
index 6cf8e3e..2be9ab9 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_dec_defs.h
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dec_defs.h
@@ -53,7 +53,7 @@
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
-#define module(x, POW2) ((x)&(POW2-1))
+#define module(x, POW2) ((x)&((POW2)-1))
/*----------------------------------------------------------------------------
; DEFINES
@@ -75,7 +75,7 @@
#define MPEG_1 0
#define MPEG_2 1
#define MPEG_2_5 2
-#define INVALID_VERSION -1
+#define INVALID_VERSION (-1)
/* MPEG Header Definitions - Mode Values */
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp
index 69e1987..639df81 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp
@@ -108,8 +108,8 @@
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
-#define Q30_fmt(a)(int32(double(0x40000000)*a))
-#define Q29_fmt(a)(int32(double(0x20000000)*a))
+#define Q30_fmt(a)(int32(double(0x40000000)*(a)))
+#define Q29_fmt(a)(int32(double(0x20000000)*(a)))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.cpp
index f4a4efb..61aef30 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.cpp
@@ -98,7 +98,7 @@
#define LEVEL_45__dB 0.005524271f
#define LEVEL_60__dB 0.000976562f
-#define Qmf31( x) (int32)(x*(float)0x7FFFFFFF)
+#define Qmf31( x) (int32)((x)*(float)0x7FFFFFFF)
/*----------------------------------------------------------------------------
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp
index f1a3ff8..d4a2060 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp
@@ -86,7 +86,7 @@
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
-#define Qfmt_28(a)(int32(double(0x10000000)*a))
+#define Qfmt_28(a)(int32(double(0x10000000)*(a)))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.h
index e497aee..2f2f65c 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.h
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.h
@@ -59,9 +59,9 @@
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
-#define Qfmt(a) (Int32)(a*((Int32)1<<28) )
-#define Qfmt1(a) (Int32)(a*((Int32)0x7FFFFFFF))
-#define Qfmt2(a) (Int32)(a*((Int32)1<<27))
+#define Qfmt(a) (Int32)((a)*((Int32)1<<28) )
+#define Qfmt1(a) (Int32)((a)*((Int32)0x7FFFFFFF))
+#define Qfmt2(a) (Int32)((a)*((Int32)1<<27))
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.cpp
index 6a72aad..8d80e8f 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.cpp
@@ -81,7 +81,7 @@
; compile variables also.
----------------------------------------------------------------------------*/
#define QFORMAT 29
-#define Qfmt29(a) (int32)(a*((int32)1<<QFORMAT) + (a>=0?0.5F:-0.5F))
+#define Qfmt29(a) (int32)((a)*((int32)1<<QFORMAT) + ((a)>=0?0.5F:-0.5F))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.h
index 6ba53d7..af4f286 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.h
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.h
@@ -59,9 +59,9 @@
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
-#define Qfmt(a) (Int32)(a*((Int32)1<<28) )
-#define Qfmt1(a) (Int32)(a*((Int32)0x7FFFFFFF))
-#define Qfmt2(a) (Int32)(a*((Int32)1<<27))
+#define Qfmt(a) (Int32)((a)*((Int32)1<<28) )
+#define Qfmt1(a) (Int32)((a)*((Int32)0x7FFFFFFF))
+#define Qfmt2(a) (Int32)((a)*((Int32)1<<27))
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp
index c79062c..a70e716 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp
@@ -123,7 +123,7 @@
; compile variables also.
----------------------------------------------------------------------------*/
-#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a))
+#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*(a)))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.cpp
index d69a46d..10edfc3 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.cpp
@@ -140,7 +140,7 @@
----------------------------------------------------------------------------*/
#define N31 31
-#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a))
+#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*(a)))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.cpp
index 90e524a..91113e3 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.cpp
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.cpp
@@ -136,7 +136,7 @@
};
-#define INV_Q31( x) (int32)(0x7FFFFFFF/(float)x - 1.0f)
+#define INV_Q31( x) (int32)(0x7FFFFFFF/(float)(x) - 1.0f)
const int32 mp3_shortwindBandWidths[9][13] =
{
@@ -161,7 +161,7 @@
};
-#define Q30_fmt(a) (int32((0x40000000)*a))
+#define Q30_fmt(a) (int32((0x40000000)*(a)))
const int32 pqmfSynthWin[(HAN_SIZE/2) + 8] =
{
diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.h
index b54c5bf..8f8509c 100644
--- a/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.h
+++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.h
@@ -52,7 +52,7 @@
/*----------------------------------------------------------------------------
; DEFINES AND SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
-#define Qfmt_28(a) (int32(double(0x10000000)*a))
+#define Qfmt_28(a) (int32(double(0x10000000)*(a)))
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
diff --git a/media/libstagefright/codecs/mpeg2dec/Android.bp b/media/libstagefright/codecs/mpeg2dec/Android.bp
new file mode 100644
index 0000000..666e08f
--- /dev/null
+++ b/media/libstagefright/codecs/mpeg2dec/Android.bp
@@ -0,0 +1,29 @@
+cc_library_shared {
+ name: "libstagefright_soft_mpeg2dec",
+
+ static_libs: ["libmpeg2dec"],
+ srcs: ["SoftMPEG2.cpp"],
+
+ include_dirs: [
+ "external/libmpeg2/decoder",
+ "external/libmpeg2/common",
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ ldflags: ["-Wl,-Bsymbolic"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/codecs/mpeg2dec/Android.mk b/media/libstagefright/codecs/mpeg2dec/Android.mk
deleted file mode 100644
index f1c1719..0000000
--- a/media/libstagefright/codecs/mpeg2dec/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-ifeq ($(if $(wildcard external/libmpeg2),1,0),1)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libstagefright_soft_mpeg2dec
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_LIBRARIES := libmpeg2dec
-LOCAL_SRC_FILES := SoftMPEG2.cpp
-
-LOCAL_C_INCLUDES := $(TOP)/external/libmpeg2/decoder
-LOCAL_C_INCLUDES += $(TOP)/external/libmpeg2/common
-LOCAL_C_INCLUDES += $(TOP)/frameworks/av/media/libstagefright/include
-LOCAL_C_INCLUDES += $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_SHARED_LIBRARIES := libstagefright
-LOCAL_SHARED_LIBRARIES += libstagefright_omx
-LOCAL_SHARED_LIBRARIES += libstagefright_foundation
-LOCAL_SHARED_LIBRARIES += libutils
-LOCAL_SHARED_LIBRARIES += liblog
-
-LOCAL_LDFLAGS := -Wl,-Bsymbolic
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif
diff --git a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.h b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.h
index 700ef5f..1921a23 100644
--- a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.h
+++ b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.h
@@ -49,8 +49,8 @@
/** Compute difference between start and end */
#define TIME_DIFF(start, end, diff) \
- diff = ((end.tv_sec - start.tv_sec) * 1000000) + \
- (end.tv_usec - start.tv_usec);
+ diff = (((end).tv_sec - (start).tv_sec) * 1000000) + \
+ ((end).tv_usec - (start).tv_usec);
struct SoftMPEG2 : public SoftVideoDecoderOMXComponent {
SoftMPEG2(
diff --git a/media/libstagefright/codecs/on2/Android.bp b/media/libstagefright/codecs/on2/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/media/libstagefright/codecs/on2/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/media/libstagefright/codecs/on2/Android.mk b/media/libstagefright/codecs/on2/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/on2/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/on2/dec/Android.bp b/media/libstagefright/codecs/on2/dec/Android.bp
new file mode 100644
index 0000000..24539c0
--- /dev/null
+++ b/media/libstagefright/codecs/on2/dec/Android.bp
@@ -0,0 +1,29 @@
+cc_library_shared {
+ name: "libstagefright_soft_vpxdec",
+
+ srcs: ["SoftVPX.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ static_libs: ["libvpx"],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/codecs/on2/dec/Android.mk b/media/libstagefright/codecs/on2/dec/Android.mk
deleted file mode 100644
index 76f7600..0000000
--- a/media/libstagefright/codecs/on2/dec/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftVPX.cpp
-
-LOCAL_C_INCLUDES := \
- $(TOP)/external/libvpx/libvpx \
- $(TOP)/external/libvpx/libvpx/vpx_codec \
- $(TOP)/external/libvpx/libvpx/vpx_ports \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
-
-LOCAL_STATIC_LIBRARIES := \
- libvpx
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libstagefright_omx libstagefright_foundation libutils liblog
-
-LOCAL_MODULE := libstagefright_soft_vpxdec
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/on2/enc/Android.bp b/media/libstagefright/codecs/on2/enc/Android.bp
new file mode 100644
index 0000000..6c63fc9
--- /dev/null
+++ b/media/libstagefright/codecs/on2/enc/Android.bp
@@ -0,0 +1,27 @@
+cc_library_shared {
+ name: "libstagefright_soft_vpxenc",
+
+ srcs: ["SoftVPXEncoder.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ static_libs: ["libvpx"],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+}
diff --git a/media/libstagefright/codecs/on2/enc/Android.mk b/media/libstagefright/codecs/on2/enc/Android.mk
deleted file mode 100644
index 1de318a..0000000
--- a/media/libstagefright/codecs/on2/enc/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftVPXEncoder.cpp
-
-LOCAL_C_INCLUDES := \
- $(TOP)/external/libvpx/libvpx \
- $(TOP)/external/libvpx/libvpx/vpx_codec \
- $(TOP)/external/libvpx/libvpx/vpx_ports \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-LOCAL_STATIC_LIBRARIES := \
- libvpx
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libstagefright_omx libstagefright_foundation libutils liblog \
- libhardware \
-
-LOCAL_MODULE := libstagefright_soft_vpxenc
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/on2/h264dec/Android.bp b/media/libstagefright/codecs/on2/h264dec/Android.bp
new file mode 100644
index 0000000..ca9c1d4
--- /dev/null
+++ b/media/libstagefright/codecs/on2/h264dec/Android.bp
@@ -0,0 +1,133 @@
+cc_library_shared {
+ name: "libstagefright_soft_h264dec",
+
+ srcs: [
+ "source/h264bsd_transform.c",
+ "source/h264bsd_util.c",
+ "source/h264bsd_byte_stream.c",
+ "source/h264bsd_seq_param_set.c",
+ "source/h264bsd_pic_param_set.c",
+ "source/h264bsd_slice_header.c",
+ "source/h264bsd_slice_data.c",
+ "source/h264bsd_macroblock_layer.c",
+ "source/h264bsd_stream.c",
+ "source/h264bsd_vlc.c",
+ "source/h264bsd_cavlc.c",
+ "source/h264bsd_nal_unit.c",
+ "source/h264bsd_neighbour.c",
+ "source/h264bsd_storage.c",
+ "source/h264bsd_slice_group_map.c",
+ "source/h264bsd_intra_prediction.c",
+ "source/h264bsd_inter_prediction.c",
+ "source/h264bsd_reconstruct.c",
+ "source/h264bsd_dpb.c",
+ "source/h264bsd_image.c",
+ "source/h264bsd_deblocking.c",
+ "source/h264bsd_conceal.c",
+ "source/h264bsd_vui.c",
+ "source/h264bsd_pic_order_cnt.c",
+ "source/h264bsd_decoder.c",
+ "source/H264SwDecApi.c",
+ "SoftAVC.cpp",
+ ],
+
+ arch: {
+ arm: {
+ instruction_set: "arm",
+
+ armv7_a_neon: {
+ cflags: [
+ "-DH264DEC_NEON",
+ "-DH264DEC_OMXDL",
+ ],
+ srcs: [
+ "source/arm_neon_asm_gcc/h264bsdWriteMacroblock.S",
+ "source/arm_neon_asm_gcc/h264bsdClearMbLayer.S",
+ "source/arm_neon_asm_gcc/h264bsdFillRow7.S",
+ "source/arm_neon_asm_gcc/h264bsdCountLeadingZeros.S",
+ "source/arm_neon_asm_gcc/h264bsdFlushBits.S",
+
+ "omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_DeblockChroma_I.c",
+ "omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_DeblockLuma_I.c",
+ "omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_InterpolateChroma.c",
+ "omxdl/arm_neon/vc/m4p10/src/armVCM4P10_CAVLCTables.c",
+ "omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_DecodeChromaDcCoeffsToPairCAVLC.c",
+ "omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_DecodeCoeffsToPairCAVLC.c",
+ "omxdl/arm_neon/src/armCOMM_Bitstream.c",
+ "omxdl/arm_neon/src/armCOMM.c",
+
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_DeblockingChroma_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_DeblockingLuma_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_Interpolate_Chroma_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_Align_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_Copy_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_DiagCopy_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_HalfDiagHorVer4x4_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_HalfDiagVerHor4x4_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_HalfHor4x4_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_HalfVer4x4_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_FilterDeblockingChroma_HorEdge_I_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_FilterDeblockingChroma_VerEdge_I_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_FilterDeblockingLuma_HorEdge_I_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_FilterDeblockingLuma_VerEdge_I_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_InterpolateLuma_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_Average_4x_Align_unsafe_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_DecodeCoeffsToPair_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_DequantTables_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_QuantTables_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_TransformResidual4x4_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_UnpackBlock4x4_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_TransformDequantLumaDCFromPair_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_PredictIntra_16x16_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_PredictIntra_4x4_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_PredictIntraChroma_8x8_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_DequantTransformResidualFromPairAndAdd_s.S",
+ "omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_TransformDequantChromaDCFromPair_s.S",
+ ],
+
+ local_include_dirs: [
+ "source/arm_neon_asm_gcc",
+
+ "omxdl/arm_neon/api",
+ "omxdl/arm_neon/vc/api",
+ "omxdl/arm_neon/vc/m4p10/api",
+ ],
+ },
+ },
+ },
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ export_include_dirs: ["inc"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+}
+
+//####################################################################
+// test utility: decoder
+//####################################################################
+//#
+//# Test application
+//#
+cc_binary {
+ name: "decoder",
+
+ srcs: ["source/DecTestBench.c"],
+
+ shared_libs: ["libstagefright_soft_h264dec"],
+}
diff --git a/media/libstagefright/codecs/on2/h264dec/Android.mk b/media/libstagefright/codecs/on2/h264dec/Android.mk
deleted file mode 100644
index 7159674..0000000
--- a/media/libstagefright/codecs/on2/h264dec/Android.mk
+++ /dev/null
@@ -1,128 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_SRC_FILES := \
- ./source/h264bsd_transform.c \
- ./source/h264bsd_util.c \
- ./source/h264bsd_byte_stream.c \
- ./source/h264bsd_seq_param_set.c \
- ./source/h264bsd_pic_param_set.c \
- ./source/h264bsd_slice_header.c \
- ./source/h264bsd_slice_data.c \
- ./source/h264bsd_macroblock_layer.c \
- ./source/h264bsd_stream.c \
- ./source/h264bsd_vlc.c \
- ./source/h264bsd_cavlc.c \
- ./source/h264bsd_nal_unit.c \
- ./source/h264bsd_neighbour.c \
- ./source/h264bsd_storage.c \
- ./source/h264bsd_slice_group_map.c \
- ./source/h264bsd_intra_prediction.c \
- ./source/h264bsd_inter_prediction.c \
- ./source/h264bsd_reconstruct.c \
- ./source/h264bsd_dpb.c \
- ./source/h264bsd_image.c \
- ./source/h264bsd_deblocking.c \
- ./source/h264bsd_conceal.c \
- ./source/h264bsd_vui.c \
- ./source/h264bsd_pic_order_cnt.c \
- ./source/h264bsd_decoder.c \
- ./source/H264SwDecApi.c \
- SoftAVC.cpp \
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/./inc \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
-
-MY_ASM := \
- ./source/arm_neon_asm_gcc/h264bsdWriteMacroblock.S \
- ./source/arm_neon_asm_gcc/h264bsdClearMbLayer.S \
- ./source/arm_neon_asm_gcc/h264bsdFillRow7.S \
- ./source/arm_neon_asm_gcc/h264bsdCountLeadingZeros.S \
- ./source/arm_neon_asm_gcc/h264bsdFlushBits.S
-
-
-MY_OMXDL_C_SRC := \
- ./omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_DeblockChroma_I.c \
- ./omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_DeblockLuma_I.c \
- ./omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_InterpolateChroma.c \
- ./omxdl/arm_neon/vc/m4p10/src/armVCM4P10_CAVLCTables.c \
- ./omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_DecodeChromaDcCoeffsToPairCAVLC.c \
- ./omxdl/arm_neon/vc/m4p10/src/omxVCM4P10_DecodeCoeffsToPairCAVLC.c \
- ./omxdl/arm_neon/src/armCOMM_Bitstream.c \
- ./omxdl/arm_neon/src/armCOMM.c
-
-MY_OMXDL_ASM_SRC := \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_DeblockingChroma_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_DeblockingLuma_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_Interpolate_Chroma_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_Align_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_Copy_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_DiagCopy_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_HalfDiagHorVer4x4_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_HalfDiagVerHor4x4_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_HalfHor4x4_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_InterpolateLuma_HalfVer4x4_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_FilterDeblockingChroma_HorEdge_I_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_FilterDeblockingChroma_VerEdge_I_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_FilterDeblockingLuma_HorEdge_I_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_FilterDeblockingLuma_VerEdge_I_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_InterpolateLuma_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_Average_4x_Align_unsafe_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_DecodeCoeffsToPair_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_DequantTables_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_QuantTables_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_TransformResidual4x4_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/armVCM4P10_UnpackBlock4x4_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_TransformDequantLumaDCFromPair_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_PredictIntra_16x16_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_PredictIntra_4x4_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_PredictIntraChroma_8x8_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_DequantTransformResidualFromPairAndAdd_s.S \
- ./omxdl/arm_neon/vc/m4p10/src_gcc/omxVCM4P10_TransformDequantChromaDCFromPair_s.S \
-
-
-ifeq ($(ARCH_ARM_HAVE_NEON),true)
- LOCAL_ARM_NEON := true
- LOCAL_CFLAGS_arm := -DH264DEC_NEON -DH264DEC_OMXDL
- LOCAL_SRC_FILES_arm := $(MY_ASM) $(MY_OMXDL_C_SRC) $(MY_OMXDL_ASM_SRC)
- LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/./source/arm_neon_asm_gcc
- LOCAL_C_INCLUDES_arm += $(LOCAL_PATH)/./omxdl/arm_neon/api \
- $(LOCAL_PATH)/./omxdl/arm_neon/vc/api \
- $(LOCAL_PATH)/./omxdl/arm_neon/vc/m4p10/api
-endif
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libstagefright_omx libstagefright_foundation libutils liblog \
-
-LOCAL_MODULE := libstagefright_soft_h264dec
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-#####################################################################
-# test utility: decoder
-#####################################################################
-##
-## Test application
-##
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := ./source/DecTestBench.c
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/inc
-
-LOCAL_SHARED_LIBRARIES := libstagefright_soft_h264dec
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := decoder
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/codecs/on2/h264dec/source/H264SwDecApi.c b/media/libstagefright/codecs/on2/h264dec/source/H264SwDecApi.c
index f820dfd..a9b38e5 100644
--- a/media/libstagefright/codecs/on2/h264dec/source/H264SwDecApi.c
+++ b/media/libstagefright/codecs/on2/h264dec/source/H264SwDecApi.c
@@ -35,10 +35,12 @@
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
-#include <log/log.h>
#include <stdlib.h>
#include <string.h>
+
+#include <log/log.h>
+
#include "basetype.h"
#include "h264bsd_container.h"
#include "H264SwDecApi.h"
diff --git a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_cavlc.c b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_cavlc.c
index 91d78bd..422d7ba 100644
--- a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_cavlc.c
+++ b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_cavlc.c
@@ -60,7 +60,7 @@
#define INFO(vlc) (((vlc) >> 4) & 0xF) /* 4 MSB bits contain information */
/* macro to obtain trailing ones from the coeff token information word,
* bits [5,10] */
-#define TRAILING_ONES(coeffToken) ((coeffToken>>5) & 0x3F)
+#define TRAILING_ONES(coeffToken) (((coeffToken)>>5) & 0x3F)
/* macro to obtain total coeff from the coeff token information word,
* bits [11,15] */
#define TOTAL_COEFF(coeffToken) (((coeffToken) >> 11) & 0x1F)
@@ -323,45 +323,45 @@
/* macro to initialize stream buffer cache, fills the buffer (32 bits) */
#define BUFFER_INIT(value, bits) \
{ \
- bits = 32; \
- value = h264bsdShowBits32(pStrmData); \
+ (bits) = 32; \
+ (value) = h264bsdShowBits32(pStrmData); \
}
/* macro to read numBits bits from the buffer, bits will be written to
* outVal. Refills the buffer if not enough bits left */
#define BUFFER_SHOW(value, bits, outVal, numBits) \
{ \
- if (bits < (numBits)) \
+ if ((bits) < (numBits)) \
{ \
- if(h264bsdFlushBits(pStrmData,32-bits) == END_OF_STREAM) \
+ if(h264bsdFlushBits(pStrmData,32-(bits)) == END_OF_STREAM) \
return(HANTRO_NOK); \
- value = h264bsdShowBits32(pStrmData); \
- bits = 32; \
+ (value) = h264bsdShowBits32(pStrmData); \
+ (bits) = 32; \
} \
- (outVal) = value >> (32 - (numBits)); \
+ (outVal) = (value) >> (32 - (numBits)); \
}
/* macro to flush numBits bits from the buffer */
#define BUFFER_FLUSH(value, bits, numBits) \
{ \
- value <<= (numBits); \
- bits -= (numBits); \
+ (value) <<= (numBits); \
+ (bits) -= (numBits); \
}
/* macro to read and flush numBits bits from the buffer, bits will be written
* to outVal. Refills the buffer if not enough bits left */
#define BUFFER_GET(value, bits, outVal, numBits) \
{ \
- if (bits < (numBits)) \
+ if ((bits) < (numBits)) \
{ \
- if(h264bsdFlushBits(pStrmData,32-bits) == END_OF_STREAM) \
+ if(h264bsdFlushBits(pStrmData,32-(bits)) == END_OF_STREAM) \
return(HANTRO_NOK); \
- value = h264bsdShowBits32(pStrmData); \
- bits = 32; \
+ (value) = h264bsdShowBits32(pStrmData); \
+ (bits) = 32; \
} \
- (outVal) = value >> (32 - (numBits)); \
- value <<= (numBits); \
- bits -= (numBits); \
+ (outVal) = (value) >> (32 - (numBits)); \
+ (value) <<= (numBits); \
+ (bits) -= (numBits); \
}
/*------------------------------------------------------------------------------
diff --git a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_dpb.c b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_dpb.c
index 799bd16..bd9eee9 100644
--- a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_dpb.c
+++ b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_dpb.c
@@ -61,6 +61,7 @@
#include "basetype.h"
#include <log/log.h>
+
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
diff --git a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_util.h b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_util.h
index 9f0eb7d..f43cf82 100644
--- a/media/libstagefright/codecs/on2/h264dec/source/h264bsd_util.h
+++ b/media/libstagefright/codecs/on2/h264dec/source/h264bsd_util.h
@@ -151,7 +151,7 @@
}
#define ALIGN(ptr, bytePos) \
- (ptr + ( ((bytePos - (uintptr_t)ptr) & (bytePos - 1)) / sizeof(*ptr) ))
+ ((ptr) + ( (((bytePos) - (uintptr_t)(ptr)) & ((bytePos) - 1)) / sizeof(*(ptr)) ))
extern const u32 h264bsdQpC[52];
diff --git a/media/libstagefright/codecs/opus/Android.bp b/media/libstagefright/codecs/opus/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/media/libstagefright/codecs/opus/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/media/libstagefright/codecs/opus/Android.mk b/media/libstagefright/codecs/opus/Android.mk
deleted file mode 100644
index 365b179..0000000
--- a/media/libstagefright/codecs/opus/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/media/libstagefright/codecs/opus/dec/Android.bp b/media/libstagefright/codecs/opus/dec/Android.bp
new file mode 100644
index 0000000..56a9eb5
--- /dev/null
+++ b/media/libstagefright/codecs/opus/dec/Android.bp
@@ -0,0 +1,26 @@
+cc_library_shared {
+ name: "libstagefright_soft_opusdec",
+
+ srcs: ["SoftOpus.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ shared_libs: [
+ "libopus",
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/codecs/opus/dec/Android.mk b/media/libstagefright/codecs/opus/dec/Android.mk
deleted file mode 100644
index f272763..0000000
--- a/media/libstagefright/codecs/opus/dec/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftOpus.cpp
-
-LOCAL_C_INCLUDES := \
- external/libopus/include \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
-
-LOCAL_SHARED_LIBRARIES := \
- libopus libstagefright libstagefright_omx \
- libstagefright_foundation libutils liblog
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-LOCAL_MODULE := libstagefright_soft_opusdec
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/raw/Android.bp b/media/libstagefright/codecs/raw/Android.bp
new file mode 100644
index 0000000..628c61e
--- /dev/null
+++ b/media/libstagefright/codecs/raw/Android.bp
@@ -0,0 +1,26 @@
+cc_library_shared {
+ name: "libstagefright_soft_rawdec",
+
+ srcs: ["SoftRaw.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ shared_libs: [
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+}
diff --git a/media/libstagefright/codecs/raw/Android.mk b/media/libstagefright/codecs/raw/Android.mk
deleted file mode 100644
index e454c84..0000000
--- a/media/libstagefright/codecs/raw/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftRaw.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils liblog
-
-LOCAL_MODULE := libstagefright_soft_rawdec
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/vorbis/Android.bp b/media/libstagefright/codecs/vorbis/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/media/libstagefright/codecs/vorbis/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/media/libstagefright/codecs/vorbis/Android.mk b/media/libstagefright/codecs/vorbis/Android.mk
deleted file mode 100644
index 2e43120..0000000
--- a/media/libstagefright/codecs/vorbis/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/codecs/vorbis/dec/Android.bp b/media/libstagefright/codecs/vorbis/dec/Android.bp
new file mode 100644
index 0000000..1a4de60
--- /dev/null
+++ b/media/libstagefright/codecs/vorbis/dec/Android.bp
@@ -0,0 +1,28 @@
+cc_library_shared {
+ name: "libstagefright_soft_vorbisdec",
+
+ srcs: ["SoftVorbis.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ shared_libs: [
+ "libvorbisidec",
+ "libmedia",
+ "libstagefright_omx",
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/codecs/vorbis/dec/Android.mk b/media/libstagefright/codecs/vorbis/dec/Android.mk
deleted file mode 100644
index 039be6f..0000000
--- a/media/libstagefright/codecs/vorbis/dec/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- SoftVorbis.cpp
-
-LOCAL_C_INCLUDES := \
- external/tremolo \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
-
-LOCAL_SHARED_LIBRARIES := \
- libvorbisidec libstagefright libstagefright_omx \
- libstagefright_foundation libutils liblog
-
-LOCAL_MODULE := libstagefright_soft_vorbisdec
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/colorconversion/Android.bp b/media/libstagefright/colorconversion/Android.bp
new file mode 100644
index 0000000..3a5ce9c
--- /dev/null
+++ b/media/libstagefright/colorconversion/Android.bp
@@ -0,0 +1,22 @@
+cc_library_static {
+ name: "libstagefright_color_conversion",
+
+ srcs: [
+ "ColorConverter.cpp",
+ "SoftwareRenderer.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/native/include/media/openmax",
+ ],
+
+ static_libs: ["libyuv_static"],
+
+ cflags: ["-Werror"],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/colorconversion/Android.mk b/media/libstagefright/colorconversion/Android.mk
deleted file mode 100644
index 0bf9701..0000000
--- a/media/libstagefright/colorconversion/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- ColorConverter.cpp \
- SoftwareRenderer.cpp
-
-LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/hardware/msm7k \
- $(TOP)/external/libyuv/files/include
-
-LOCAL_STATIC_LIBRARIES := \
- libyuv_static \
-
-LOCAL_CFLAGS += -Werror
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE:= libstagefright_color_conversion
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libstagefright/filters/Android.bp b/media/libstagefright/filters/Android.bp
new file mode 100644
index 0000000..dce8644
--- /dev/null
+++ b/media/libstagefright/filters/Android.bp
@@ -0,0 +1,29 @@
+cc_library_static {
+ name: "libstagefright_mediafilter",
+
+ srcs: [
+ "ColorConvert.cpp",
+ "GraphicBufferListener.cpp",
+ "IntrinsicBlurFilter.cpp",
+ "MediaFilter.cpp",
+ "RSFilter.cpp",
+ "SaturationFilter.cpp",
+ "saturationARGB.rs",
+ "SimpleFilter.cpp",
+ "ZeroFilter.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: [
+ "-Wno-multichar",
+ "-Werror",
+ "-Wall",
+ ],
+
+ shared_libs: [
+ "libmedia",
+ ],
+}
diff --git a/media/libstagefright/filters/Android.mk b/media/libstagefright/filters/Android.mk
deleted file mode 100644
index 179f054..0000000
--- a/media/libstagefright/filters/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- ColorConvert.cpp \
- GraphicBufferListener.cpp \
- IntrinsicBlurFilter.cpp \
- MediaFilter.cpp \
- RSFilter.cpp \
- SaturationFilter.cpp \
- saturationARGB.rs \
- SimpleFilter.cpp \
- ZeroFilter.cpp
-
-LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/rs/cpp \
- $(TOP)/frameworks/rs \
-
-intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
-LOCAL_C_INCLUDES += $(intermediates)
-
-LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
-
-LOCAL_MODULE:= libstagefright_mediafilter
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libstagefright/foundation/ADebug.cpp b/media/libstagefright/foundation/ADebug.cpp
index 2c5f544..1a5b2a3 100644
--- a/media/libstagefright/foundation/ADebug.cpp
+++ b/media/libstagefright/foundation/ADebug.cpp
@@ -49,7 +49,7 @@
++current;
}
// check for :
- char *colon = strchr(current, ':');
+ const char *colon = strchr(current, ':');
// get level
char *end;
diff --git a/media/libstagefright/foundation/ALooperRoster.cpp b/media/libstagefright/foundation/ALooperRoster.cpp
index 9ed53e7..5f11fb6 100644
--- a/media/libstagefright/foundation/ALooperRoster.cpp
+++ b/media/libstagefright/foundation/ALooperRoster.cpp
@@ -34,7 +34,7 @@
}
ALooper::handler_id ALooperRoster::registerHandler(
- const sp<ALooper> looper, const sp<AHandler> &handler) {
+ const sp<ALooper> &looper, const sp<AHandler> &handler) {
Mutex::Autolock autoLock(mLock);
if (handler->id() != 0) {
diff --git a/media/libstagefright/foundation/AMessage.cpp b/media/libstagefright/foundation/AMessage.cpp
index a4583d6..1b0db33 100644
--- a/media/libstagefright/foundation/AMessage.cpp
+++ b/media/libstagefright/foundation/AMessage.cpp
@@ -17,11 +17,13 @@
#define LOG_TAG "AMessage"
//#define LOG_NDEBUG 0
//#define DUMP_STATS
-#include <cutils/log.h>
+
+#include <ctype.h>
#include "AMessage.h"
-#include <ctype.h>
+#include <binder/Parcel.h>
+#include <log/log.h>
#include "AAtomizer.h"
#include "ABuffer.h"
@@ -30,7 +32,6 @@
#include "AHandler.h"
#include "AString.h"
-#include <binder/Parcel.h>
#include <media/stagefright/foundation/hexdump.h>
namespace android {
@@ -252,7 +253,8 @@
item->u.FIELDNAME = value; \
} \
\
-bool AMessage::find##NAME(const char *name, TYPENAME *value) const { \
+/* NOLINT added to avoid incorrect warning/fix from clang.tidy */ \
+bool AMessage::find##NAME(const char *name, TYPENAME *value) const { /* NOLINT */ \
const Item *item = findItem(name, kType##NAME); \
if (item) { \
*value = item->u.FIELDNAME; \
diff --git a/media/libstagefright/foundation/ANetworkSession.cpp b/media/libstagefright/foundation/ANetworkSession.cpp
index 46314eb..f8b7b41 100644
--- a/media/libstagefright/foundation/ANetworkSession.cpp
+++ b/media/libstagefright/foundation/ANetworkSession.cpp
@@ -53,7 +53,7 @@
static const int32_t kMaxUDPRetries = 200;
struct ANetworkSession::NetworkThread : public Thread {
- NetworkThread(ANetworkSession *session);
+ explicit NetworkThread(ANetworkSession *session);
protected:
virtual ~NetworkThread();
diff --git a/media/libstagefright/foundation/Android.bp b/media/libstagefright/foundation/Android.bp
new file mode 100644
index 0000000..f7bd3f2
--- /dev/null
+++ b/media/libstagefright/foundation/Android.bp
@@ -0,0 +1,51 @@
+cc_library_shared {
+ name: "libstagefright_foundation",
+
+ srcs: [
+ "AAtomizer.cpp",
+ "ABitReader.cpp",
+ "ABuffer.cpp",
+ "ADebug.cpp",
+ "AHandler.cpp",
+ "AHierarchicalStateMachine.cpp",
+ "ALooper.cpp",
+ "ALooperRoster.cpp",
+ "AMessage.cpp",
+ "ANetworkSession.cpp",
+ "AString.cpp",
+ "AStringUtils.cpp",
+ "AWakeLock.cpp",
+ "ColorUtils.cpp",
+ "MediaBuffer.cpp",
+ "MediaBufferGroup.cpp",
+ "MetaData.cpp",
+ "ParsedMessage.cpp",
+ "base64.cpp",
+ "hexdump.cpp",
+ ],
+
+ include_dirs: ["frameworks/av/include/media/stagefright/foundation"],
+
+ shared_libs: [
+ "libbinder",
+ "libutils",
+ "libcutils",
+ "liblog",
+ "libpowermanager",
+ ],
+
+ export_shared_lib_headers: ["libbinder"],
+
+ cflags: [
+ "-Wno-multichar",
+ "-Werror",
+ "-Wall",
+ ],
+ clang: true,
+ sanitize: {
+ misc_undefined: [
+ "unsigned-integer-overflow",
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/foundation/Android.mk b/media/libstagefright/foundation/Android.mk
deleted file mode 100644
index 3c3ed59..0000000
--- a/media/libstagefright/foundation/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- AAtomizer.cpp \
- ABitReader.cpp \
- ABuffer.cpp \
- ADebug.cpp \
- AHandler.cpp \
- AHierarchicalStateMachine.cpp \
- ALooper.cpp \
- ALooperRoster.cpp \
- AMessage.cpp \
- ANetworkSession.cpp \
- AString.cpp \
- AStringUtils.cpp \
- AWakeLock.cpp \
- ColorUtils.cpp \
- MediaBuffer.cpp \
- MediaBufferGroup.cpp \
- MetaData.cpp \
- ParsedMessage.cpp \
- base64.cpp \
- hexdump.cpp
-
-LOCAL_C_INCLUDES:= \
- frameworks/av/include/media/stagefright/foundation
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libutils \
- libcutils \
- liblog \
- libpowermanager
-
-LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_MODULE:= libstagefright_foundation
-
-
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/http/Android.bp b/media/libstagefright/http/Android.bp
new file mode 100644
index 0000000..71a8750
--- /dev/null
+++ b/media/libstagefright/http/Android.bp
@@ -0,0 +1,39 @@
+cc_library_shared {
+ name: "libstagefright_http_support",
+
+ srcs: ["HTTPHelper.cpp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/native/include/media/openmax",
+ "frameworks/base/core/jni",
+ ],
+
+ shared_libs: [
+ "liblog",
+ "libutils",
+ "libbinder",
+ "libandroid_runtime",
+ "libmedia",
+ ],
+
+ export_include_dirs: ["."],
+
+ cflags: [
+ "-Wno-multichar",
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ product_variables: {
+ pdk: {
+ enabled: false,
+ },
+ },
+}
diff --git a/media/libstagefright/http/Android.mk b/media/libstagefright/http/Android.mk
deleted file mode 100644
index bc71134..0000000
--- a/media/libstagefright/http/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-ifneq ($(TARGET_BUILD_PDK), true)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- HTTPHelper.cpp \
-
-LOCAL_C_INCLUDES:= \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/base/core/jni \
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright liblog libutils libbinder libstagefright_foundation \
- libandroid_runtime \
- libmedia
-
-LOCAL_MODULE:= libstagefright_http_support
-
-LOCAL_CFLAGS += -Wno-multichar
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif
diff --git a/media/libstagefright/httplive/Android.bp b/media/libstagefright/httplive/Android.bp
new file mode 100644
index 0000000..9cab226
--- /dev/null
+++ b/media/libstagefright/httplive/Android.bp
@@ -0,0 +1,39 @@
+cc_library_shared {
+ name: "libstagefright_httplive",
+
+ srcs: [
+ "HTTPDownloader.cpp",
+ "LiveDataSource.cpp",
+ "LiveSession.cpp",
+ "M3UParser.cpp",
+ "PlaylistFetcher.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ shared_libs: [
+ "liblog",
+ "libbinder",
+ "libcrypto",
+ "libcutils",
+ "libmedia",
+ "libstagefright",
+ "libstagefright_foundation",
+ "libutils",
+ ],
+}
diff --git a/media/libstagefright/httplive/Android.mk b/media/libstagefright/httplive/Android.mk
deleted file mode 100644
index f904212..0000000
--- a/media/libstagefright/httplive/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- HTTPDownloader.cpp \
- LiveDataSource.cpp \
- LiveSession.cpp \
- M3UParser.cpp \
- PlaylistFetcher.cpp \
-
-LOCAL_C_INCLUDES:= \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libcrypto \
- libcutils \
- libmedia \
- libstagefright \
- libstagefright_foundation \
- libutils \
-
-LOCAL_MODULE:= libstagefright_httplive
-
-ifeq ($(TARGET_ARCH),arm)
- LOCAL_CFLAGS += -Wno-psabi
-endif
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/httplive/HTTPDownloader.cpp b/media/libstagefright/httplive/HTTPDownloader.cpp
index 861b85a..793695a 100644
--- a/media/libstagefright/httplive/HTTPDownloader.cpp
+++ b/media/libstagefright/httplive/HTTPDownloader.cpp
@@ -256,10 +256,6 @@
return NULL;
}
-
- if (curPlaylistHash != NULL) {
- memcpy(curPlaylistHash, hash, sizeof(hash));
- }
#endif
sp<M3UParser> playlist =
@@ -271,6 +267,13 @@
return NULL;
}
+#if defined(__ANDROID__)
+ if (curPlaylistHash != NULL) {
+
+ memcpy(curPlaylistHash, hash, sizeof(hash));
+ }
+#endif
+
return playlist;
}
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 7abc019..8c88fe9 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -178,7 +178,7 @@
*shortTermBps = mShortTermEstimate;
}
- int32_t minEstimate = -1, maxEstimate = -1;
+ int64_t minEstimate = -1, maxEstimate = -1;
List<int32_t>::iterator it;
for (it = mPrevEstimates.begin(); it != mPrevEstimates.end(); it++) {
int32_t estimate = *it;
@@ -690,7 +690,7 @@
}
if (mContinuation != NULL) {
- CHECK_GT(mContinuationCounter, 0);
+ CHECK_GT(mContinuationCounter, 0u);
if (--mContinuationCounter == 0) {
mContinuation->post();
}
@@ -1175,7 +1175,7 @@
#endif
bool LiveSession::UriIsSameAsIndex(const AString &uri, int32_t i, bool newUri) {
- ALOGI("[timed_id3] i %d UriIsSameAsIndex newUri %s, %s", i,
+ ALOGV("[timed_id3] i %d UriIsSameAsIndex newUri %s, %s", i,
newUri ? "true" : "false",
newUri ? mStreams[i].mNewUri.c_str() : mStreams[i].mUri.c_str());
return i >= 0
@@ -1535,7 +1535,7 @@
mOrigBandwidthIndex, mCurBandwidthIndex);
}
}
- CHECK_LT(mCurBandwidthIndex, mBandwidthItems.size());
+ CHECK_LT((size_t)mCurBandwidthIndex, mBandwidthItems.size());
const BandwidthItem &item = mBandwidthItems.itemAt(mCurBandwidthIndex);
uint32_t streamMask = 0; // streams that should be fetched by the new fetcher
diff --git a/media/libstagefright/httplive/LiveSession.h b/media/libstagefright/httplive/LiveSession.h
index b600eba..65a824e 100644
--- a/media/libstagefright/httplive/LiveSession.h
+++ b/media/libstagefright/httplive/LiveSession.h
@@ -165,7 +165,7 @@
int64_t mLastSampleDurationUs;
StreamItem()
: StreamItem("") {}
- StreamItem(const char *type)
+ explicit StreamItem(const char *type)
: mType(type),
mSeekMode(kSeekModeExactPosition) {
reset();
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp
index c04549a..71feb9a 100644
--- a/media/libstagefright/httplive/M3UParser.cpp
+++ b/media/libstagefright/httplive/M3UParser.cpp
@@ -46,7 +46,7 @@
FLAG_HAS_URI = 16,
};
- MediaGroup(Type type);
+ explicit MediaGroup(Type type);
Type type() const;
@@ -498,8 +498,8 @@
if (url[0] == '/') {
// URL is an absolute path.
- char *protocolEnd = strstr(baseURL, "//") + 2;
- char *pathStart = strchr(protocolEnd, '/');
+ const char *protocolEnd = strstr(baseURL, "//") + 2;
+ const char *pathStart = strchr(protocolEnd, '/');
if (pathStart != NULL) {
out->setTo(baseURL, pathStart - baseURL);
diff --git a/media/libstagefright/id3/Android.bp b/media/libstagefright/id3/Android.bp
new file mode 100644
index 0000000..b2aedec
--- /dev/null
+++ b/media/libstagefright/id3/Android.bp
@@ -0,0 +1,41 @@
+cc_library_static {
+ name: "libstagefright_id3",
+
+ srcs: ["ID3.cpp"],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ shared_libs: ["libmedia"],
+}
+
+//###############################################################################
+
+cc_test {
+ name: "testid3",
+ gtest: false,
+
+ srcs: ["testid3.cpp"],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ shared_libs: [
+ "libstagefright",
+ "libutils",
+ "liblog",
+ "libbinder",
+ "libstagefright_foundation",
+ ],
+
+ static_libs: ["libstagefright_id3"],
+}
diff --git a/media/libstagefright/id3/Android.mk b/media/libstagefright/id3/Android.mk
deleted file mode 100644
index 2cfba44..0000000
--- a/media/libstagefright/id3/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- ID3.cpp
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_MODULE := libstagefright_id3
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- testid3.cpp
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libutils liblog libbinder libstagefright_foundation
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_id3
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := testid3
-
-include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp
index 8b80ae9..40d2e2b 100644
--- a/media/libstagefright/id3/ID3.cpp
+++ b/media/libstagefright/id3/ID3.cpp
@@ -538,6 +538,9 @@
}
size_t n = mFrameSize - getHeaderLength() - 1;
if (otherdata) {
+ if (n < 5) {
+ return;
+ }
// skip past the encoding, language, and the 0 separator
frameData += 4;
int32_t i = n - 4;
diff --git a/media/libstagefright/include/AMRExtractor.h b/media/libstagefright/include/AMRExtractor.h
index ba2b674..8abcb12 100644
--- a/media/libstagefright/include/AMRExtractor.h
+++ b/media/libstagefright/include/AMRExtractor.h
@@ -29,7 +29,7 @@
class AMRExtractor : public MediaExtractor {
public:
- AMRExtractor(const sp<DataSource> &source);
+ explicit AMRExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/CallbackDataSource.h b/media/libstagefright/include/CallbackDataSource.h
index d2187d5..80cd1f7 100644
--- a/media/libstagefright/include/CallbackDataSource.h
+++ b/media/libstagefright/include/CallbackDataSource.h
@@ -29,7 +29,7 @@
// DataSource because it calls back to the IDataSource for data.
class CallbackDataSource : public DataSource {
public:
- CallbackDataSource(const sp<IDataSource>& iDataSource);
+ explicit CallbackDataSource(const sp<IDataSource>& iDataSource);
virtual ~CallbackDataSource();
// DataSource implementation.
@@ -59,7 +59,7 @@
// impact on time taken for filetype sniffing and metadata extraction.
class TinyCacheSource : public DataSource {
public:
- TinyCacheSource(const sp<DataSource>& source);
+ explicit TinyCacheSource(const sp<DataSource>& source);
virtual status_t initCheck() const;
virtual ssize_t readAt(off64_t offset, void* data, size_t size);
diff --git a/media/libstagefright/include/FLACExtractor.h b/media/libstagefright/include/FLACExtractor.h
index 5d030b1..51bc139 100644
--- a/media/libstagefright/include/FLACExtractor.h
+++ b/media/libstagefright/include/FLACExtractor.h
@@ -29,7 +29,7 @@
public:
// Extractor assumes ownership of source
- FLACExtractor(const sp<DataSource> &source);
+ explicit FLACExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/ID3.h b/media/libstagefright/include/ID3.h
index c2c4a6d..11682f8 100644
--- a/media/libstagefright/include/ID3.h
+++ b/media/libstagefright/include/ID3.h
@@ -35,7 +35,7 @@
ID3_V2_4,
};
- ID3(const sp<DataSource> &source, bool ignoreV1 = false, off64_t offset = 0);
+ explicit ID3(const sp<DataSource> &source, bool ignoreV1 = false, off64_t offset = 0);
ID3(const uint8_t *data, size_t size, bool ignoreV1 = false);
~ID3();
diff --git a/media/libstagefright/include/MPEG2PSExtractor.h b/media/libstagefright/include/MPEG2PSExtractor.h
index c8abfb6..f5471b3 100644
--- a/media/libstagefright/include/MPEG2PSExtractor.h
+++ b/media/libstagefright/include/MPEG2PSExtractor.h
@@ -31,7 +31,7 @@
class String8;
struct MPEG2PSExtractor : public MediaExtractor {
- MPEG2PSExtractor(const sp<DataSource> &source);
+ explicit MPEG2PSExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/MPEG2TSExtractor.h b/media/libstagefright/include/MPEG2TSExtractor.h
index 34b9606..93e9a4b 100644
--- a/media/libstagefright/include/MPEG2TSExtractor.h
+++ b/media/libstagefright/include/MPEG2TSExtractor.h
@@ -37,7 +37,7 @@
class String8;
struct MPEG2TSExtractor : public MediaExtractor {
- MPEG2TSExtractor(const sp<DataSource> &source);
+ explicit MPEG2TSExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/MPEG4Extractor.h b/media/libstagefright/include/MPEG4Extractor.h
index 836cb08..89ad137 100644
--- a/media/libstagefright/include/MPEG4Extractor.h
+++ b/media/libstagefright/include/MPEG4Extractor.h
@@ -50,7 +50,7 @@
class MPEG4Extractor : public MediaExtractor {
public:
// Extractor assumes ownership of "source".
- MPEG4Extractor(const sp<DataSource> &source);
+ explicit MPEG4Extractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/MidiExtractor.h b/media/libstagefright/include/MidiExtractor.h
index 5a7d90e..94d2d08 100644
--- a/media/libstagefright/include/MidiExtractor.h
+++ b/media/libstagefright/include/MidiExtractor.h
@@ -53,7 +53,7 @@
public:
// Extractor assumes ownership of source
- MidiExtractor(const sp<DataSource> &source);
+ explicit MidiExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/OMXNodeInstance.h b/media/libstagefright/include/OMXNodeInstance.h
index 94cf15a..6411267 100644
--- a/media/libstagefright/include/OMXNodeInstance.h
+++ b/media/libstagefright/include/OMXNodeInstance.h
@@ -257,10 +257,10 @@
OMX::buffer_id buffer, OMX_BUFFERHEADERTYPE *header, bool updateCodecBuffer);
status_t createGraphicBufferSource(
- OMX_U32 portIndex, sp<IGraphicBufferConsumer> consumer /* nullable */,
+ OMX_U32 portIndex, const sp<IGraphicBufferConsumer> &consumer /* nullable */,
MetadataBufferType *type);
sp<GraphicBufferSource> getGraphicBufferSource();
- void setGraphicBufferSource(const sp<GraphicBufferSource>& bufferSource);
+ void setGraphicBufferSource(const sp<GraphicBufferSource> &bufferSource);
// Handles |msg|, and may modify it. Returns true iff completely handled it and
// |msg| does not need to be sent to the event listener.
diff --git a/media/libstagefright/include/OggExtractor.h b/media/libstagefright/include/OggExtractor.h
index 592c264..55aafed 100644
--- a/media/libstagefright/include/OggExtractor.h
+++ b/media/libstagefright/include/OggExtractor.h
@@ -31,7 +31,7 @@
struct OggSource;
struct OggExtractor : public MediaExtractor {
- OggExtractor(const sp<DataSource> &source);
+ explicit OggExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/SampleIterator.h b/media/libstagefright/include/SampleIterator.h
index 2ef41ae..6a3fd3b 100644
--- a/media/libstagefright/include/SampleIterator.h
+++ b/media/libstagefright/include/SampleIterator.h
@@ -25,7 +25,7 @@
class SampleTable;
struct SampleIterator {
- SampleIterator(SampleTable *table);
+ explicit SampleIterator(SampleTable *table);
status_t seekTo(uint32_t sampleIndex);
diff --git a/media/libstagefright/include/SampleTable.h b/media/libstagefright/include/SampleTable.h
index 2100ca6..eb1a674 100644
--- a/media/libstagefright/include/SampleTable.h
+++ b/media/libstagefright/include/SampleTable.h
@@ -32,7 +32,7 @@
class SampleTable : public RefBase {
public:
- SampleTable(const sp<DataSource> &source);
+ explicit SampleTable(const sp<DataSource> &source);
bool isValid() const;
diff --git a/media/libstagefright/include/WAVExtractor.h b/media/libstagefright/include/WAVExtractor.h
index 91ee870..12ad441 100644
--- a/media/libstagefright/include/WAVExtractor.h
+++ b/media/libstagefright/include/WAVExtractor.h
@@ -30,7 +30,7 @@
class WAVExtractor : public MediaExtractor {
public:
// Extractor assumes ownership of "source".
- WAVExtractor(const sp<DataSource> &source);
+ explicit WAVExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/WVMExtractor.h b/media/libstagefright/include/WVMExtractor.h
index 5b91072..65cb99a 100644
--- a/media/libstagefright/include/WVMExtractor.h
+++ b/media/libstagefright/include/WVMExtractor.h
@@ -43,7 +43,7 @@
class WVMExtractor : public MediaExtractor {
public:
- WVMExtractor(const sp<DataSource> &source);
+ explicit WVMExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
virtual sp<IMediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/avc_utils.h b/media/libstagefright/include/avc_utils.h
index 235ee63..b2ef360 100644
--- a/media/libstagefright/include/avc_utils.h
+++ b/media/libstagefright/include/avc_utils.h
@@ -37,8 +37,8 @@
};
struct NALPosition {
- size_t nalOffset;
- size_t nalSize;
+ uint32_t nalOffset;
+ uint32_t nalSize;
};
// Optionally returns sample aspect ratio as well.
diff --git a/media/libstagefright/matroska/Android.bp b/media/libstagefright/matroska/Android.bp
new file mode 100644
index 0000000..bbfd06c
--- /dev/null
+++ b/media/libstagefright/matroska/Android.bp
@@ -0,0 +1,26 @@
+cc_library_static {
+ name: "libstagefright_matroska",
+
+ srcs: ["MatroskaExtractor.cpp"],
+
+ include_dirs: [
+ "external/libvpx/libwebm",
+ "frameworks/native/include/media/openmax",
+ "frameworks/av/media/libstagefright/include",
+ ],
+
+ cflags: [
+ "-Wno-multichar",
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ shared_libs: ["libmedia"],
+}
diff --git a/media/libstagefright/matroska/Android.mk b/media/libstagefright/matroska/Android.mk
deleted file mode 100644
index b0cbf08..0000000
--- a/media/libstagefright/matroska/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- MatroskaExtractor.cpp
-
-LOCAL_C_INCLUDES:= \
- $(TOP)/external/libvpx/libwebm \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/av/media/libstagefright/include \
-
-LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_MODULE:= libstagefright_matroska
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp
index 0f9430e..8e82486 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.cpp
+++ b/media/libstagefright/matroska/MatroskaExtractor.cpp
@@ -40,7 +40,7 @@
namespace android {
struct DataSourceReader : public mkvparser::IMkvReader {
- DataSourceReader(const sp<DataSource> &source)
+ explicit DataSourceReader(const sp<DataSource> &source)
: mSource(source) {
}
diff --git a/media/libstagefright/matroska/MatroskaExtractor.h b/media/libstagefright/matroska/MatroskaExtractor.h
index 665e68e..588bd39 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.h
+++ b/media/libstagefright/matroska/MatroskaExtractor.h
@@ -34,7 +34,7 @@
struct MatroskaSource;
struct MatroskaExtractor : public MediaExtractor {
- MatroskaExtractor(const sp<DataSource> &source);
+ explicit MatroskaExtractor(const sp<DataSource> &source);
virtual size_t countTracks();
diff --git a/media/libstagefright/mpeg2ts/ATSParser.h b/media/libstagefright/mpeg2ts/ATSParser.h
index 9d9102d..2b166f0 100644
--- a/media/libstagefright/mpeg2ts/ATSParser.h
+++ b/media/libstagefright/mpeg2ts/ATSParser.h
@@ -64,7 +64,7 @@
// Event is used to signal sync point event at feedTSPacket().
struct SyncEvent {
- SyncEvent(off64_t offset);
+ explicit SyncEvent(off64_t offset);
void init(off64_t offset, const sp<MediaSource> &source,
int64_t timeUs);
@@ -89,7 +89,7 @@
int64_t mTimeUs;
};
- ATSParser(uint32_t flags = 0);
+ explicit ATSParser(uint32_t flags = 0);
// Feed a TS packet into the parser. uninitialized event with the start
// offset of this TS packet goes in, and if the parser detects PES with
diff --git a/media/libstagefright/mpeg2ts/Android.bp b/media/libstagefright/mpeg2ts/Android.bp
new file mode 100644
index 0000000..ea3b1a6
--- /dev/null
+++ b/media/libstagefright/mpeg2ts/Android.bp
@@ -0,0 +1,30 @@
+cc_library_static {
+ name: "libstagefright_mpeg2ts",
+
+ srcs: [
+ "AnotherPacketSource.cpp",
+ "ATSParser.cpp",
+ "ESQueue.cpp",
+ "MPEG2PSExtractor.cpp",
+ "MPEG2TSExtractor.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "unsigned-integer-overflow",
+ "signed-integer-overflow",
+ ],
+ },
+
+ shared_libs: ["libmedia"],
+}
diff --git a/media/libstagefright/mpeg2ts/Android.mk b/media/libstagefright/mpeg2ts/Android.mk
deleted file mode 100644
index 70afde9..0000000
--- a/media/libstagefright/mpeg2ts/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- AnotherPacketSource.cpp \
- ATSParser.cpp \
- ESQueue.cpp \
- MPEG2PSExtractor.cpp \
- MPEG2TSExtractor.cpp \
-
-LOCAL_C_INCLUDES:= \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_MODULE:= libstagefright_mpeg2ts
-
-ifeq ($(TARGET_ARCH),arm)
- LOCAL_CFLAGS += -Wno-psabi
-endif
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.h b/media/libstagefright/mpeg2ts/AnotherPacketSource.h
index 28a0e89..dd6849e 100644
--- a/media/libstagefright/mpeg2ts/AnotherPacketSource.h
+++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.h
@@ -30,7 +30,7 @@
struct ABuffer;
struct AnotherPacketSource : public MediaSource {
- AnotherPacketSource(const sp<MetaData> &meta);
+ explicit AnotherPacketSource(const sp<MetaData> &meta);
void setFormat(const sp<MetaData> &meta);
diff --git a/media/libstagefright/mpeg2ts/ESQueue.h b/media/libstagefright/mpeg2ts/ESQueue.h
index e9f96b7..56f0706 100644
--- a/media/libstagefright/mpeg2ts/ESQueue.h
+++ b/media/libstagefright/mpeg2ts/ESQueue.h
@@ -44,7 +44,7 @@
// Data appended to the queue is always at access unit boundaries.
kFlag_AlignedData = 1,
};
- ElementaryStreamQueue(Mode mode, uint32_t flags = 0);
+ explicit ElementaryStreamQueue(Mode mode, uint32_t flags = 0);
status_t appendData(const void *data, size_t size, int64_t timeUs);
void signalEOS();
diff --git a/media/libstagefright/omx/Android.bp b/media/libstagefright/omx/Android.bp
new file mode 100644
index 0000000..a76b99e
--- /dev/null
+++ b/media/libstagefright/omx/Android.bp
@@ -0,0 +1,52 @@
+cc_library_shared {
+ name: "libstagefright_omx",
+
+ srcs: [
+ "FrameDropper.cpp",
+ "GraphicBufferSource.cpp",
+ "OMX.cpp",
+ "OMXMaster.cpp",
+ "OMXNodeInstance.cpp",
+ "OMXUtils.cpp",
+ "SimpleSoftOMXComponent.cpp",
+ "SoftOMXComponent.cpp",
+ "SoftOMXPlugin.cpp",
+ "SoftVideoDecoderOMXComponent.cpp",
+ "SoftVideoEncoderOMXComponent.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/native/include/media/hardware",
+ // TODO: export this?
+ "frameworks/native/include/media/openmax",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ "libmedia",
+ "libutils",
+ "liblog",
+ "libui",
+ "libgui",
+ "libcutils",
+ "libstagefright_foundation",
+ "libdl",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+}
+
+//###############################################################################
+
+subdirs = ["tests"]
diff --git a/media/libstagefright/omx/Android.mk b/media/libstagefright/omx/Android.mk
deleted file mode 100644
index e4fbd81..0000000
--- a/media/libstagefright/omx/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- FrameDropper.cpp \
- GraphicBufferSource.cpp \
- OMX.cpp \
- OMXMaster.cpp \
- OMXNodeInstance.cpp \
- OMXUtils.cpp \
- SimpleSoftOMXComponent.cpp \
- SoftOMXComponent.cpp \
- SoftOMXPlugin.cpp \
- SoftVideoDecoderOMXComponent.cpp \
- SoftVideoEncoderOMXComponent.cpp \
-
-LOCAL_C_INCLUDES += \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/hardware \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libhardware \
- libmedia \
- libutils \
- liblog \
- libui \
- libgui \
- libcutils \
- libstagefright_foundation \
- libdl
-
-LOCAL_MODULE:= libstagefright_omx
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
-
-################################################################################
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/omx/GraphicBufferSource.cpp b/media/libstagefright/omx/GraphicBufferSource.cpp
index e1bcd28..82a6f6f 100644
--- a/media/libstagefright/omx/GraphicBufferSource.cpp
+++ b/media/libstagefright/omx/GraphicBufferSource.cpp
@@ -951,11 +951,12 @@
* frameNum: frame number of the frame being released
* buffer: GraphicBuffer pointer to release (note this must not be & as we
* will clear the original mBufferSlot in persistent case)
+ * Use NOLINT to supress warning on the copy of 'buffer'.
* fence: fence of the frame being released
*/
void GraphicBufferSource::releaseBuffer(
int &id, uint64_t frameNum,
- const sp<GraphicBuffer> buffer, const sp<Fence> &fence) {
+ const sp<GraphicBuffer> buffer, const sp<Fence> &fence) { // NOLINT
ALOGV("releaseBuffer: slot=%d", id);
if (mIsPersistent) {
mConsumer->detachBuffer(id);
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index 2e989b5..f7058d7 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -48,7 +48,7 @@
// Note that deriving CallbackDispatcher from Thread does not work.
struct OMX::CallbackDispatcherThread : public Thread {
- CallbackDispatcherThread(CallbackDispatcher *dispatcher)
+ explicit CallbackDispatcherThread(CallbackDispatcher *dispatcher)
: mDispatcher(dispatcher) {
}
@@ -64,7 +64,7 @@
////////////////////////////////////////////////////////////////////////////////
struct OMX::CallbackDispatcher : public RefBase {
- CallbackDispatcher(OMXNodeInstance *owner);
+ explicit CallbackDispatcher(OMXNodeInstance *owner);
// Posts |msg| to the listener's queue. If |realTime| is true, the listener thread is notified
// that a new message is available on the queue. Otherwise, the message stays on the queue, but
diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp
index e7aaead..aa7ae7c 100644
--- a/media/libstagefright/omx/OMXNodeInstance.cpp
+++ b/media/libstagefright/omx/OMXNodeInstance.cpp
@@ -93,7 +93,7 @@
namespace android {
struct BufferMeta {
- BufferMeta(
+ explicit BufferMeta(
const sp<IMemory> &mem, OMX_U32 portIndex, bool copyToOmx,
bool copyFromOmx, OMX_U8 *backup)
: mMem(mem),
@@ -103,7 +103,7 @@
mBackup(backup) {
}
- BufferMeta(size_t size, OMX_U32 portIndex)
+ explicit BufferMeta(size_t size, OMX_U32 portIndex)
: mSize(size),
mCopyFromOmx(false),
mCopyToOmx(false),
@@ -111,7 +111,7 @@
mBackup(NULL) {
}
- BufferMeta(const sp<GraphicBuffer> &graphicBuffer, OMX_U32 portIndex)
+ explicit BufferMeta(const sp<GraphicBuffer> &graphicBuffer, OMX_U32 portIndex)
: mGraphicBuffer(graphicBuffer),
mCopyFromOmx(false),
mCopyToOmx(false),
@@ -1066,7 +1066,7 @@
}
status_t OMXNodeInstance::createGraphicBufferSource(
- OMX_U32 portIndex, sp<IGraphicBufferConsumer> bufferConsumer, MetadataBufferType *type) {
+ OMX_U32 portIndex, const sp<IGraphicBufferConsumer> &bufferConsumer, MetadataBufferType *type) {
status_t err;
// only allow graphic source on input port, when there are no allocated buffers yet
diff --git a/media/libstagefright/omx/OMXUtils.cpp b/media/libstagefright/omx/OMXUtils.cpp
index 799696c..c5879b8 100644
--- a/media/libstagefright/omx/OMXUtils.cpp
+++ b/media/libstagefright/omx/OMXUtils.cpp
@@ -20,7 +20,10 @@
#include <string.h>
#include <media/hardware/HardwareAPI.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/MediaErrors.h>
+#include <media/MediaDefs.h>
#include "OMXUtils.h"
namespace android {
@@ -101,5 +104,273 @@
/**************************************************************************************************/
+const char *GetComponentRole(bool isEncoder, const char *mime) {
+ struct MimeToRole {
+ const char *mime;
+ const char *decoderRole;
+ const char *encoderRole;
+ };
+
+ static const MimeToRole kMimeToRole[] = {
+ { MEDIA_MIMETYPE_AUDIO_MPEG,
+ "audio_decoder.mp3", "audio_encoder.mp3" },
+ { MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I,
+ "audio_decoder.mp1", "audio_encoder.mp1" },
+ { MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II,
+ "audio_decoder.mp2", "audio_encoder.mp2" },
+ { MEDIA_MIMETYPE_AUDIO_AMR_NB,
+ "audio_decoder.amrnb", "audio_encoder.amrnb" },
+ { MEDIA_MIMETYPE_AUDIO_AMR_WB,
+ "audio_decoder.amrwb", "audio_encoder.amrwb" },
+ { MEDIA_MIMETYPE_AUDIO_AAC,
+ "audio_decoder.aac", "audio_encoder.aac" },
+ { MEDIA_MIMETYPE_AUDIO_VORBIS,
+ "audio_decoder.vorbis", "audio_encoder.vorbis" },
+ { MEDIA_MIMETYPE_AUDIO_OPUS,
+ "audio_decoder.opus", "audio_encoder.opus" },
+ { MEDIA_MIMETYPE_AUDIO_G711_MLAW,
+ "audio_decoder.g711mlaw", "audio_encoder.g711mlaw" },
+ { MEDIA_MIMETYPE_AUDIO_G711_ALAW,
+ "audio_decoder.g711alaw", "audio_encoder.g711alaw" },
+ { MEDIA_MIMETYPE_VIDEO_AVC,
+ "video_decoder.avc", "video_encoder.avc" },
+ { MEDIA_MIMETYPE_VIDEO_HEVC,
+ "video_decoder.hevc", "video_encoder.hevc" },
+ { MEDIA_MIMETYPE_VIDEO_MPEG4,
+ "video_decoder.mpeg4", "video_encoder.mpeg4" },
+ { MEDIA_MIMETYPE_VIDEO_H263,
+ "video_decoder.h263", "video_encoder.h263" },
+ { MEDIA_MIMETYPE_VIDEO_VP8,
+ "video_decoder.vp8", "video_encoder.vp8" },
+ { MEDIA_MIMETYPE_VIDEO_VP9,
+ "video_decoder.vp9", "video_encoder.vp9" },
+ { MEDIA_MIMETYPE_AUDIO_RAW,
+ "audio_decoder.raw", "audio_encoder.raw" },
+ { MEDIA_MIMETYPE_VIDEO_DOLBY_VISION,
+ "video_decoder.dolby-vision", "video_encoder.dolby-vision" },
+ { MEDIA_MIMETYPE_AUDIO_FLAC,
+ "audio_decoder.flac", "audio_encoder.flac" },
+ { MEDIA_MIMETYPE_AUDIO_MSGSM,
+ "audio_decoder.gsm", "audio_encoder.gsm" },
+ { MEDIA_MIMETYPE_VIDEO_MPEG2,
+ "video_decoder.mpeg2", "video_encoder.mpeg2" },
+ { MEDIA_MIMETYPE_AUDIO_AC3,
+ "audio_decoder.ac3", "audio_encoder.ac3" },
+ { MEDIA_MIMETYPE_AUDIO_EAC3,
+ "audio_decoder.eac3", "audio_encoder.eac3" },
+ };
+
+ static const size_t kNumMimeToRole =
+ sizeof(kMimeToRole) / sizeof(kMimeToRole[0]);
+
+ size_t i;
+ for (i = 0; i < kNumMimeToRole; ++i) {
+ if (!strcasecmp(mime, kMimeToRole[i].mime)) {
+ break;
+ }
+ }
+
+ if (i == kNumMimeToRole) {
+ return NULL;
+ }
+
+ return isEncoder ? kMimeToRole[i].encoderRole
+ : kMimeToRole[i].decoderRole;
+}
+
+status_t SetComponentRole(const sp<IOMX> &omx, IOMX::node_id node, const char *role) {
+ OMX_PARAM_COMPONENTROLETYPE roleParams;
+ InitOMXParams(&roleParams);
+
+ strncpy((char *)roleParams.cRole,
+ role, OMX_MAX_STRINGNAME_SIZE - 1);
+
+ roleParams.cRole[OMX_MAX_STRINGNAME_SIZE - 1] = '\0';
+
+ return omx->setParameter(
+ node, OMX_IndexParamStandardComponentRole,
+ &roleParams, sizeof(roleParams));
+}
+
+bool DescribeDefaultColorFormat(DescribeColorFormat2Params ¶ms) {
+ MediaImage2 &image = params.sMediaImage;
+ memset(&image, 0, sizeof(image));
+
+ image.mType = MediaImage2::MEDIA_IMAGE_TYPE_UNKNOWN;
+ image.mNumPlanes = 0;
+
+ const OMX_COLOR_FORMATTYPE fmt = params.eColorFormat;
+ image.mWidth = params.nFrameWidth;
+ image.mHeight = params.nFrameHeight;
+
+ // only supporting YUV420
+ if (fmt != OMX_COLOR_FormatYUV420Planar &&
+ fmt != OMX_COLOR_FormatYUV420PackedPlanar &&
+ fmt != OMX_COLOR_FormatYUV420SemiPlanar &&
+ fmt != OMX_COLOR_FormatYUV420PackedSemiPlanar &&
+ fmt != (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YV12) {
+ ALOGW("do not know color format 0x%x = %d", fmt, fmt);
+ return false;
+ }
+
+ // TEMPORARY FIX for some vendors that advertise sliceHeight as 0
+ if (params.nStride != 0 && params.nSliceHeight == 0) {
+ ALOGW("using sliceHeight=%u instead of what codec advertised (=0)",
+ params.nFrameHeight);
+ params.nSliceHeight = params.nFrameHeight;
+ }
+
+ // we need stride and slice-height to be non-zero and sensible. These values were chosen to
+ // prevent integer overflows further down the line, and do not indicate support for
+ // 32kx32k video.
+ if (params.nStride == 0 || params.nSliceHeight == 0
+ || params.nStride > 32768 || params.nSliceHeight > 32768) {
+ ALOGW("cannot describe color format 0x%x = %d with stride=%u and sliceHeight=%u",
+ fmt, fmt, params.nStride, params.nSliceHeight);
+ return false;
+ }
+
+ // set-up YUV format
+ image.mType = MediaImage2::MEDIA_IMAGE_TYPE_YUV;
+ image.mNumPlanes = 3;
+ image.mBitDepth = 8;
+ image.mBitDepthAllocated = 8;
+ image.mPlane[image.Y].mOffset = 0;
+ image.mPlane[image.Y].mColInc = 1;
+ image.mPlane[image.Y].mRowInc = params.nStride;
+ image.mPlane[image.Y].mHorizSubsampling = 1;
+ image.mPlane[image.Y].mVertSubsampling = 1;
+
+ switch ((int)fmt) {
+ case HAL_PIXEL_FORMAT_YV12:
+ if (params.bUsingNativeBuffers) {
+ size_t ystride = align(params.nStride, 16);
+ size_t cstride = align(params.nStride / 2, 16);
+ image.mPlane[image.Y].mRowInc = ystride;
+
+ image.mPlane[image.V].mOffset = ystride * params.nSliceHeight;
+ image.mPlane[image.V].mColInc = 1;
+ image.mPlane[image.V].mRowInc = cstride;
+ image.mPlane[image.V].mHorizSubsampling = 2;
+ image.mPlane[image.V].mVertSubsampling = 2;
+
+ image.mPlane[image.U].mOffset = image.mPlane[image.V].mOffset
+ + (cstride * params.nSliceHeight / 2);
+ image.mPlane[image.U].mColInc = 1;
+ image.mPlane[image.U].mRowInc = cstride;
+ image.mPlane[image.U].mHorizSubsampling = 2;
+ image.mPlane[image.U].mVertSubsampling = 2;
+ break;
+ } else {
+ // fall through as YV12 is used for YUV420Planar by some codecs
+ }
+
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420PackedPlanar:
+ image.mPlane[image.U].mOffset = params.nStride * params.nSliceHeight;
+ image.mPlane[image.U].mColInc = 1;
+ image.mPlane[image.U].mRowInc = params.nStride / 2;
+ image.mPlane[image.U].mHorizSubsampling = 2;
+ image.mPlane[image.U].mVertSubsampling = 2;
+
+ image.mPlane[image.V].mOffset = image.mPlane[image.U].mOffset
+ + (params.nStride * params.nSliceHeight / 4);
+ image.mPlane[image.V].mColInc = 1;
+ image.mPlane[image.V].mRowInc = params.nStride / 2;
+ image.mPlane[image.V].mHorizSubsampling = 2;
+ image.mPlane[image.V].mVertSubsampling = 2;
+ break;
+
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ // FIXME: NV21 for sw-encoder, NV12 for decoder and hw-encoder
+ case OMX_COLOR_FormatYUV420PackedSemiPlanar:
+ // NV12
+ image.mPlane[image.U].mOffset = params.nStride * params.nSliceHeight;
+ image.mPlane[image.U].mColInc = 2;
+ image.mPlane[image.U].mRowInc = params.nStride;
+ image.mPlane[image.U].mHorizSubsampling = 2;
+ image.mPlane[image.U].mVertSubsampling = 2;
+
+ image.mPlane[image.V].mOffset = image.mPlane[image.U].mOffset + 1;
+ image.mPlane[image.V].mColInc = 2;
+ image.mPlane[image.V].mRowInc = params.nStride;
+ image.mPlane[image.V].mHorizSubsampling = 2;
+ image.mPlane[image.V].mVertSubsampling = 2;
+ break;
+
+ default:
+ TRESPASS();
+ }
+ return true;
+}
+
+bool DescribeColorFormat(
+ const sp<IOMX> &omx, IOMX::node_id node,
+ DescribeColorFormat2Params &describeParams)
+{
+ OMX_INDEXTYPE describeColorFormatIndex;
+ if (omx->getExtensionIndex(
+ node, "OMX.google.android.index.describeColorFormat",
+ &describeColorFormatIndex) == OK) {
+ DescribeColorFormatParams describeParamsV1(describeParams);
+ if (omx->getParameter(
+ node, describeColorFormatIndex,
+ &describeParamsV1, sizeof(describeParamsV1)) == OK) {
+ describeParams.initFromV1(describeParamsV1);
+ return describeParams.sMediaImage.mType != MediaImage2::MEDIA_IMAGE_TYPE_UNKNOWN;
+ }
+ } else if (omx->getExtensionIndex(
+ node, "OMX.google.android.index.describeColorFormat2", &describeColorFormatIndex) == OK
+ && omx->getParameter(
+ node, describeColorFormatIndex, &describeParams, sizeof(describeParams)) == OK) {
+ return describeParams.sMediaImage.mType != MediaImage2::MEDIA_IMAGE_TYPE_UNKNOWN;
+ }
+
+ return DescribeDefaultColorFormat(describeParams);
+}
+
+// static
+bool IsFlexibleColorFormat(
+ const sp<IOMX> &omx, IOMX::node_id node,
+ uint32_t colorFormat, bool usingNativeBuffers, OMX_U32 *flexibleEquivalent) {
+ DescribeColorFormat2Params describeParams;
+ InitOMXParams(&describeParams);
+ describeParams.eColorFormat = (OMX_COLOR_FORMATTYPE)colorFormat;
+ // reasonable dummy values
+ describeParams.nFrameWidth = 128;
+ describeParams.nFrameHeight = 128;
+ describeParams.nStride = 128;
+ describeParams.nSliceHeight = 128;
+ describeParams.bUsingNativeBuffers = (OMX_BOOL)usingNativeBuffers;
+
+ CHECK(flexibleEquivalent != NULL);
+
+ if (!DescribeColorFormat(omx, node, describeParams)) {
+ return false;
+ }
+
+ const MediaImage2 &img = describeParams.sMediaImage;
+ if (img.mType == MediaImage2::MEDIA_IMAGE_TYPE_YUV) {
+ if (img.mNumPlanes != 3
+ || img.mPlane[img.Y].mHorizSubsampling != 1
+ || img.mPlane[img.Y].mVertSubsampling != 1) {
+ return false;
+ }
+
+ // YUV 420
+ if (img.mPlane[img.U].mHorizSubsampling == 2
+ && img.mPlane[img.U].mVertSubsampling == 2
+ && img.mPlane[img.V].mHorizSubsampling == 2
+ && img.mPlane[img.V].mVertSubsampling == 2) {
+ // possible flexible YUV420 format
+ if (img.mBitDepth <= 8) {
+ *flexibleEquivalent = OMX_COLOR_FormatYUV420Flexible;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
} // namespace android
diff --git a/media/libstagefright/omx/OMXUtils.h b/media/libstagefright/omx/OMXUtils.h
index 0c5e537..315f118 100644
--- a/media/libstagefright/omx/OMXUtils.h
+++ b/media/libstagefright/omx/OMXUtils.h
@@ -17,6 +17,8 @@
#ifndef OMX_UTILS_H_
#define OMX_UTILS_H_
+#include <media/IOMX.h>
+
/***** DO NOT USE THIS INCLUDE!!! INTERAL ONLY!!! UNLESS YOU RESIDE IN media/libstagefright *****/
// OMXUtils contains omx-specific utility functions for stagefright/omx library
@@ -36,6 +38,19 @@
status_t StatusFromOMXError(OMX_ERRORTYPE err);
+const char *GetComponentRole(bool isEncoder, const char *mime);
+status_t SetComponentRole(const sp<IOMX> &omx, IOMX::node_id node, const char *role);
+
+struct DescribeColorFormat2Params;
+
+bool IsFlexibleColorFormat(
+ const sp<IOMX> &omx, IOMX::node_id node,
+ uint32_t colorFormat, bool usingNativeBuffers, OMX_U32 *flexibleEquivalent);
+bool DescribeDefaultColorFormat(DescribeColorFormat2Params &describeParams);
+bool DescribeColorFormat(
+ const sp<IOMX> &omx, IOMX::node_id node,
+ DescribeColorFormat2Params &describeParams);
+
} // namespace android
#endif
diff --git a/media/libstagefright/omx/tests/Android.bp b/media/libstagefright/omx/tests/Android.bp
new file mode 100644
index 0000000..e480737
--- /dev/null
+++ b/media/libstagefright/omx/tests/Android.bp
@@ -0,0 +1,45 @@
+cc_test {
+ name: "omx_tests",
+ gtest: false,
+
+ srcs: ["OMXHarness.cpp"],
+
+ shared_libs: [
+ "libstagefright",
+ "libbinder",
+ "libmedia",
+ "libutils",
+ "liblog",
+ "libstagefright_foundation",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ compile_multilib: "32",
+}
+
+cc_test {
+ name: "FrameDropper_test",
+
+ srcs: ["FrameDropper_test.cpp"],
+
+ shared_libs: [
+ "libstagefright_omx",
+ "libutils",
+ ],
+
+ include_dirs: ["frameworks/av/media/libstagefright/omx"],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
diff --git a/media/libstagefright/omx/tests/Android.mk b/media/libstagefright/omx/tests/Android.mk
deleted file mode 100644
index 02e97f1..0000000
--- a/media/libstagefright/omx/tests/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES = \
- OMXHarness.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright libbinder libmedia libutils liblog libstagefright_foundation
-
-LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-
-LOCAL_MODULE := omx_tests
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_32_BIT_ONLY := true
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := FrameDropper_test
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- FrameDropper_test.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx \
- libutils \
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/omx \
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-
-include $(BUILD_NATIVE_TEST)
diff --git a/media/libstagefright/rtsp/AAVCAssembler.h b/media/libstagefright/rtsp/AAVCAssembler.h
index bf389ec..e19480c 100644
--- a/media/libstagefright/rtsp/AAVCAssembler.h
+++ b/media/libstagefright/rtsp/AAVCAssembler.h
@@ -29,7 +29,7 @@
struct AMessage;
struct AAVCAssembler : public ARTPAssembler {
- AAVCAssembler(const sp<AMessage> ¬ify);
+ explicit AAVCAssembler(const sp<AMessage> ¬ify);
protected:
virtual ~AAVCAssembler();
diff --git a/media/libstagefright/rtsp/AH263Assembler.h b/media/libstagefright/rtsp/AH263Assembler.h
index 2b6c625..1448661 100644
--- a/media/libstagefright/rtsp/AH263Assembler.h
+++ b/media/libstagefright/rtsp/AH263Assembler.h
@@ -29,7 +29,7 @@
struct AMessage;
struct AH263Assembler : public ARTPAssembler {
- AH263Assembler(const sp<AMessage> ¬ify);
+ explicit AH263Assembler(const sp<AMessage> ¬ify);
protected:
virtual ~AH263Assembler();
diff --git a/media/libstagefright/rtsp/ARTPConnection.h b/media/libstagefright/rtsp/ARTPConnection.h
index edbcc35..d5f7c2e 100644
--- a/media/libstagefright/rtsp/ARTPConnection.h
+++ b/media/libstagefright/rtsp/ARTPConnection.h
@@ -32,7 +32,7 @@
kRegularlyRequestFIR = 2,
};
- ARTPConnection(uint32_t flags = 0);
+ explicit ARTPConnection(uint32_t flags = 0);
void addStream(
int rtpSocket, int rtcpSocket,
diff --git a/media/libstagefright/rtsp/ARTPWriter.h b/media/libstagefright/rtsp/ARTPWriter.h
index 62abd0a..3c7042e 100644
--- a/media/libstagefright/rtsp/ARTPWriter.h
+++ b/media/libstagefright/rtsp/ARTPWriter.h
@@ -35,7 +35,7 @@
class MediaBuffer;
struct ARTPWriter : public MediaWriter {
- ARTPWriter(int fd);
+ explicit ARTPWriter(int fd);
virtual status_t addSource(const sp<IMediaSource> &source);
virtual bool reachedEOS();
diff --git a/media/libstagefright/rtsp/ARTSPConnection.h b/media/libstagefright/rtsp/ARTSPConnection.h
index 1fe9c99..8df2676 100644
--- a/media/libstagefright/rtsp/ARTSPConnection.h
+++ b/media/libstagefright/rtsp/ARTSPConnection.h
@@ -33,7 +33,7 @@
};
struct ARTSPConnection : public AHandler {
- ARTSPConnection(bool uidValid = false, uid_t uid = 0);
+ explicit ARTSPConnection(bool uidValid = false, uid_t uid = 0);
void connect(const char *url, const sp<AMessage> &reply);
void disconnect(const sp<AMessage> &reply);
diff --git a/media/libstagefright/rtsp/Android.bp b/media/libstagefright/rtsp/Android.bp
new file mode 100644
index 0000000..b3b8334
--- /dev/null
+++ b/media/libstagefright/rtsp/Android.bp
@@ -0,0 +1,88 @@
+cc_library_static {
+ name: "libstagefright_rtsp",
+
+ srcs: [
+ "AAMRAssembler.cpp",
+ "AAVCAssembler.cpp",
+ "AH263Assembler.cpp",
+ "AMPEG2TSAssembler.cpp",
+ "AMPEG4AudioAssembler.cpp",
+ "AMPEG4ElementaryAssembler.cpp",
+ "APacketSource.cpp",
+ "ARawAudioAssembler.cpp",
+ "ARTPAssembler.cpp",
+ "ARTPConnection.cpp",
+ "ARTPSource.cpp",
+ "ARTPWriter.cpp",
+ "ARTSPConnection.cpp",
+ "ASessionDescription.cpp",
+ "SDPLoader.cpp",
+ ],
+
+ shared_libs: [
+ "libcrypto",
+ "libmedia",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ arch: {
+ arm: {
+ cflags: ["-Wno-psabi"],
+ },
+ },
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+}
+
+//###############################################################################
+
+cc_test {
+ name: "rtp_test",
+ gtest: false,
+ enabled: false,
+
+ srcs: ["rtp_test.cpp"],
+
+ shared_libs: [
+ "libstagefright",
+ "liblog",
+ "libutils",
+ "libbinder",
+ "libstagefright_foundation",
+ "libmedia",
+ ],
+
+ static_libs: ["libstagefright_rtsp"],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/av/cmds/stagefright",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: [
+ "-Wno-multichar",
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/rtsp/Android.mk b/media/libstagefright/rtsp/Android.mk
deleted file mode 100644
index bdda19c..0000000
--- a/media/libstagefright/rtsp/Android.mk
+++ /dev/null
@@ -1,70 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- AAMRAssembler.cpp \
- AAVCAssembler.cpp \
- AH263Assembler.cpp \
- AMPEG2TSAssembler.cpp \
- AMPEG4AudioAssembler.cpp \
- AMPEG4ElementaryAssembler.cpp \
- APacketSource.cpp \
- ARawAudioAssembler.cpp \
- ARTPAssembler.cpp \
- ARTPConnection.cpp \
- ARTPSource.cpp \
- ARTPWriter.cpp \
- ARTSPConnection.cpp \
- ASessionDescription.cpp \
- SDPLoader.cpp \
-
-LOCAL_SHARED_LIBRARIES += libcrypto
-
-LOCAL_C_INCLUDES:= \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_MODULE:= libstagefright_rtsp
-
-ifeq ($(TARGET_ARCH),arm)
- LOCAL_CFLAGS += -Wno-psabi
-endif
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- rtp_test.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libstagefright liblog libutils libbinder libstagefright_foundation libmedia
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_rtsp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright \
- frameworks/av/cmds/stagefright \
- $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE:= rtp_test
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-# include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/tests/Android.bp b/media/libstagefright/tests/Android.bp
new file mode 100644
index 0000000..f3362bb
--- /dev/null
+++ b/media/libstagefright/tests/Android.bp
@@ -0,0 +1,95 @@
+// Build the unit tests.
+
+cc_test {
+ name: "SurfaceMediaSource_test",
+
+ srcs: [
+ "SurfaceMediaSource_test.cpp",
+ "DummyRecorder.cpp",
+ ],
+
+ shared_libs: [
+ "libEGL",
+ "libGLESv2",
+ "libbinder",
+ "libcutils",
+ "libgui",
+ "libmedia",
+ "libstagefright",
+ "libstagefright_foundation",
+ "libstagefright_omx",
+ "libsync",
+ "libui",
+ "libutils",
+ "liblog",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ "frameworks/native/include/media/hardware",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ compile_multilib: "32",
+}
+
+cc_test {
+ name: "Utils_test",
+
+ srcs: ["Utils_test.cpp"],
+
+ shared_libs: [
+ "libcutils",
+ "liblog",
+ "libmedia",
+ "libstagefright",
+ "libstagefright_foundation",
+ "libstagefright_omx",
+ ],
+
+ include_dirs: [
+ "frameworks/av/include",
+ "frameworks/av/media/libstagefright",
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
+
+cc_test {
+ name: "MediaCodecListOverrides_test",
+
+ srcs: ["MediaCodecListOverrides_test.cpp"],
+
+ shared_libs: [
+ "libmedia",
+ "libstagefright",
+ "libstagefright_foundation",
+ "libstagefright_omx",
+ "libutils",
+ "liblog",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/av/media/libstagefright/include",
+ "frameworks/native/include/media/openmax",
+ ],
+
+ compile_multilib: "32",
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
diff --git a/media/libstagefright/tests/Android.mk b/media/libstagefright/tests/Android.mk
deleted file mode 100644
index d1c9d36..0000000
--- a/media/libstagefright/tests/Android.mk
+++ /dev/null
@@ -1,109 +0,0 @@
-# Build the unit tests.
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := SurfaceMediaSource_test
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- SurfaceMediaSource_test.cpp \
- DummyRecorder.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libEGL \
- libGLESv2 \
- libbinder \
- libcutils \
- libgui \
- libmedia \
- libstagefright \
- libstagefright_foundation \
- libstagefright_omx \
- libsync \
- libui \
- libutils \
- liblog
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright \
- frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/native/include/media/hardware \
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-
-LOCAL_32_BIT_ONLY := true
-
-include $(BUILD_NATIVE_TEST)
-
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := Utils_test
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- Utils_test.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- liblog \
- libmedia \
- libstagefright \
- libstagefright_foundation \
- libstagefright_omx \
-
-LOCAL_C_INCLUDES := \
- frameworks/av/include \
- frameworks/av/media/libstagefright \
- frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/native/include/media/openmax \
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := MediaCodecListOverrides_test
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- MediaCodecListOverrides_test.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libmedia \
- libstagefright \
- libstagefright_foundation \
- libstagefright_omx \
- libutils \
- liblog
-
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
-
-LOCAL_32_BIT_ONLY := true
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-
-include $(BUILD_NATIVE_TEST)
-
-# Include subdirectory makefiles
-# ============================================================
-
-# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
-# team really wants is to build the stuff defined by this makefile.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/media/libstagefright/tests/DummyRecorder.h b/media/libstagefright/tests/DummyRecorder.h
index cd4d0ee..0759777 100644
--- a/media/libstagefright/tests/DummyRecorder.h
+++ b/media/libstagefright/tests/DummyRecorder.h
@@ -43,7 +43,7 @@
// static function to wrap the actual thread entry point
static void *threadWrapper(void *pthis);
- DummyRecorder(const sp<MediaSource> &source) : mSource(source)
+ explicit DummyRecorder(const sp<MediaSource> &source) : mSource(source)
, mStarted(false) {}
~DummyRecorder( ) {}
diff --git a/media/libstagefright/tests/MediaCodecListOverrides_test.cpp b/media/libstagefright/tests/MediaCodecListOverrides_test.cpp
index ab547be..2599608 100644
--- a/media/libstagefright/tests/MediaCodecListOverrides_test.cpp
+++ b/media/libstagefright/tests/MediaCodecListOverrides_test.cpp
@@ -74,11 +74,11 @@
void verifyProfileResults(const KeyedVector<AString, CodecSettings> &results) {
EXPECT_LT(0u, results.size());
for (size_t i = 0; i < results.size(); ++i) {
- AString key = results.keyAt(i);
- CodecSettings settings = results.valueAt(i);
+ const AString &key = results.keyAt(i);
+ const CodecSettings &settings = results.valueAt(i);
EXPECT_EQ(1u, settings.size());
EXPECT_TRUE(settings.keyAt(0) == "max-supported-instances");
- AString valueS = settings.valueAt(0);
+ const AString &valueS = settings.valueAt(0);
int32_t value = strtol(valueS.c_str(), NULL, 10);
EXPECT_LT(0, value);
ALOGV("profileCodecs results %s %s", key.c_str(), valueS.c_str());
diff --git a/media/libstagefright/tests/SurfaceMediaSource_test.cpp b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
index ad1e684..d419133 100644
--- a/media/libstagefright/tests/SurfaceMediaSource_test.cpp
+++ b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
@@ -593,7 +593,7 @@
struct SimpleDummyRecorder {
sp<MediaSource> mSource;
- SimpleDummyRecorder
+ explicit SimpleDummyRecorder
(const sp<MediaSource> &source): mSource(source) {}
status_t start() { return mSource->start();}
diff --git a/media/libstagefright/timedtext/Android.bp b/media/libstagefright/timedtext/Android.bp
new file mode 100644
index 0000000..e19ca96
--- /dev/null
+++ b/media/libstagefright/timedtext/Android.bp
@@ -0,0 +1,23 @@
+cc_library_static {
+ name: "libstagefright_timedtext",
+
+ srcs: ["TextDescriptions.cpp"],
+
+ cflags: [
+ "-Wno-multichar",
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ ],
+
+ shared_libs: ["libmedia"],
+}
diff --git a/media/libstagefright/timedtext/Android.mk b/media/libstagefright/timedtext/Android.mk
deleted file mode 100644
index f2c6365..0000000
--- a/media/libstagefright/timedtext/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- TextDescriptions.cpp \
-
-LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_C_INCLUDES:= \
- $(TOP)/frameworks/av/include/media/stagefright/timedtext \
- $(TOP)/frameworks/av/media/libstagefright
-
-LOCAL_MODULE:= libstagefright_timedtext
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libstagefright/webm/Android.bp b/media/libstagefright/webm/Android.bp
new file mode 100644
index 0000000..3972878
--- /dev/null
+++ b/media/libstagefright/webm/Android.bp
@@ -0,0 +1,33 @@
+cc_library_static {
+ name: "libstagefright_webm",
+
+ cppflags: ["-D__STDINT_LIMITS"],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ "unsigned-integer-overflow",
+ ],
+ },
+
+ srcs: [
+ "EbmlUtil.cpp",
+ "WebmElement.cpp",
+ "WebmFrame.cpp",
+ "WebmFrameThread.cpp",
+ "WebmWriter.cpp",
+ ],
+
+ include_dirs: ["frameworks/av/include"],
+
+ shared_libs: [
+ "libstagefright_foundation",
+ "libutils",
+ "liblog",
+ ],
+}
diff --git a/media/libstagefright/webm/Android.mk b/media/libstagefright/webm/Android.mk
deleted file mode 100644
index ce580ae..0000000
--- a/media/libstagefright/webm/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CPPFLAGS += -D__STDINT_LIMITS
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_SRC_FILES:= EbmlUtil.cpp \
- WebmElement.cpp \
- WebmFrame.cpp \
- WebmFrameThread.cpp \
- WebmWriter.cpp
-
-
-LOCAL_C_INCLUDES += $(TOP)/frameworks/av/include
-
-LOCAL_SHARED_LIBRARIES += libstagefright_foundation \
- libstagefright \
- libutils \
- liblog
-
-LOCAL_MODULE:= libstagefright_webm
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libstagefright/webm/WebmElement.h b/media/libstagefright/webm/WebmElement.h
index 4e90793..ffbba1b 100644
--- a/media/libstagefright/webm/WebmElement.h
+++ b/media/libstagefright/webm/WebmElement.h
@@ -114,14 +114,14 @@
struct EbmlVoid : public WebmElement {
const uint64_t mSizeWidth;
- EbmlVoid(uint64_t totalSize);
+ explicit EbmlVoid(uint64_t totalSize);
int serializePayloadSize(uint8_t *buf);
void serializePayload(uint8_t *buf);
};
struct WebmMaster : public WebmElement {
const List<sp<WebmElement> > mChildren;
- WebmMaster(uint64_t id);
+ explicit WebmMaster(uint64_t id);
WebmMaster(uint64_t id, const List<sp<WebmElement> > &children);
int serializePayloadSize(uint8_t *buf);
void serializePayload(uint8_t *buf);
diff --git a/media/libstagefright/webm/WebmFrameThread.cpp b/media/libstagefright/webm/WebmFrameThread.cpp
index 7eb4745..c33e0c7 100644
--- a/media/libstagefright/webm/WebmFrameThread.cpp
+++ b/media/libstagefright/webm/WebmFrameThread.cpp
@@ -118,7 +118,7 @@
void WebmFrameSinkThread::writeCluster(List<sp<WebmElement> >& children) {
// children must contain at least one simpleblock and its timecode
- CHECK_GE(children.size(), 2);
+ CHECK_GE(children.size(), 2u);
uint64_t size;
sp<WebmElement> cluster = new WebmMaster(kMkvCluster, children);
@@ -149,7 +149,7 @@
// flushing the second to last frame before we check its type. A audio frame
// should precede the aforementioned video key frame in the next sequence, a video
// frame should be the last frame in the current (to-be-flushed) sequence.
- CHECK_GE(n, 2);
+ CHECK_GE(n, 2u);
n -= 2;
}
diff --git a/media/libstagefright/webm/WebmWriter.cpp b/media/libstagefright/webm/WebmWriter.cpp
index e58964d..d6c6930 100644
--- a/media/libstagefright/webm/WebmWriter.cpp
+++ b/media/libstagefright/webm/WebmWriter.cpp
@@ -488,12 +488,12 @@
params->findInt32(kKeyBitRate, &bitRate);
}
mEstimatedCuesSize = estimateCuesSize(bitRate);
- CHECK_GE(mEstimatedCuesSize, 8);
+ CHECK_GE(mEstimatedCuesSize, 8u);
cues = new EbmlVoid(mEstimatedCuesSize);
}
sp<WebmElement> elems[] = { ebml, segment, seekHead, info, tracks, cues };
- size_t nElems = sizeof(elems) / sizeof(elems[0]);
+ static const size_t nElems = sizeof(elems) / sizeof(elems[0]);
uint64_t offsets[nElems];
uint64_t sizes[nElems];
for (uint32_t i = 0; i < nElems; i++) {
diff --git a/media/libstagefright/webm/WebmWriter.h b/media/libstagefright/webm/WebmWriter.h
index dd1fba3..9f3b19f 100644
--- a/media/libstagefright/webm/WebmWriter.h
+++ b/media/libstagefright/webm/WebmWriter.h
@@ -36,7 +36,7 @@
class WebmWriter : public MediaWriter {
public:
- WebmWriter(int fd);
+ explicit WebmWriter(int fd);
~WebmWriter() { reset(); }
diff --git a/media/libstagefright/wifi-display/Android.bp b/media/libstagefright/wifi-display/Android.bp
new file mode 100644
index 0000000..402c6c1
--- /dev/null
+++ b/media/libstagefright/wifi-display/Android.bp
@@ -0,0 +1,46 @@
+cc_library_shared {
+ name: "libstagefright_wfd",
+
+ srcs: [
+ "MediaSender.cpp",
+ "Parameters.cpp",
+ "rtp/RTPSender.cpp",
+ "source/Converter.cpp",
+ "source/MediaPuller.cpp",
+ "source/PlaybackSession.cpp",
+ "source/RepeaterSource.cpp",
+ "source/TSPacketizer.cpp",
+ "source/WifiDisplaySource.cpp",
+ "VideoFormats.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/libstagefright",
+ "frameworks/native/include/media/openmax",
+ "frameworks/native/include/media/hardware",
+ "frameworks/av/media/libstagefright/mpeg2ts",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ "libcutils",
+ "liblog",
+ "libmedia",
+ "libstagefright",
+ "libstagefright_foundation",
+ "libui",
+ "libutils",
+ ],
+
+ cflags: [
+ "-Wno-multichar",
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/libstagefright/wifi-display/Android.mk b/media/libstagefright/wifi-display/Android.mk
deleted file mode 100644
index ae4ac90..0000000
--- a/media/libstagefright/wifi-display/Android.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- MediaSender.cpp \
- Parameters.cpp \
- rtp/RTPSender.cpp \
- source/Converter.cpp \
- source/MediaPuller.cpp \
- source/PlaybackSession.cpp \
- source/RepeaterSource.cpp \
- source/TSPacketizer.cpp \
- source/WifiDisplaySource.cpp \
- VideoFormats.cpp \
-
-LOCAL_C_INCLUDES:= \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/frameworks/native/include/media/hardware \
- $(TOP)/frameworks/av/media/libstagefright/mpeg2ts \
-
-LOCAL_SHARED_LIBRARIES:= \
- libbinder \
- libcutils \
- liblog \
- libgui \
- libmedia \
- libstagefright \
- libstagefright_foundation \
- libui \
- libutils \
-
-LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-LOCAL_MODULE:= libstagefright_wfd
-
-LOCAL_MODULE_TAGS:= optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/wifi-display/MediaSender.cpp b/media/libstagefright/wifi-display/MediaSender.cpp
index 6f0087f..9b0af33 100644
--- a/media/libstagefright/wifi-display/MediaSender.cpp
+++ b/media/libstagefright/wifi-display/MediaSender.cpp
@@ -420,7 +420,7 @@
CHECK(accessUnit->meta()->findInt32("rangeLength", &rangeLength));
CHECK(accessUnit->meta()->findMessage("notify", ¬ify)
&& notify != NULL);
- CHECK_GE(accessUnit->size(), rangeLength);
+ CHECK_GE((int32_t)accessUnit->size(), rangeLength);
sp<GraphicBuffer> grbuf(new GraphicBuffer(
rangeOffset + rangeLength, 1, HAL_PIXEL_FORMAT_Y8,
diff --git a/media/libstagefright/wifi-display/rtp/RTPBase.h b/media/libstagefright/wifi-display/rtp/RTPBase.h
index 6178f00..194f1ee 100644
--- a/media/libstagefright/wifi-display/rtp/RTPBase.h
+++ b/media/libstagefright/wifi-display/rtp/RTPBase.h
@@ -36,10 +36,8 @@
TRANSPORT_TCP_INTERLEAVED,
};
- enum {
- // Really UDP _payload_ size
- kMaxUDPPacketSize = 1472, // 1472 good, 1473 bad on Android@Home
- };
+ // Really UDP _payload_ size
+ const unsigned int kMaxUDPPacketSize = 1472; // 1472 good, 1473 bad on Android@Home
static int32_t PickRandomRTPPort();
};
diff --git a/media/libstagefright/wifi-display/rtp/RTPSender.cpp b/media/libstagefright/wifi-display/rtp/RTPSender.cpp
index 83af393..ca9fdd2 100644
--- a/media/libstagefright/wifi-display/rtp/RTPSender.cpp
+++ b/media/libstagefright/wifi-display/rtp/RTPSender.cpp
@@ -247,7 +247,7 @@
status_t RTPSender::queueTSPackets(
const sp<ABuffer> &tsPackets, uint8_t packetType) {
- CHECK_EQ(0, tsPackets->size() % 188);
+ CHECK_EQ(0u, tsPackets->size() % 188);
int64_t timeUs;
CHECK(tsPackets->meta()->findInt64("timeUs", &timeUs));
diff --git a/media/libstagefright/wifi-display/rtp/RTPSender.h b/media/libstagefright/wifi-display/rtp/RTPSender.h
index fefcab7..bedfd01 100644
--- a/media/libstagefright/wifi-display/rtp/RTPSender.h
+++ b/media/libstagefright/wifi-display/rtp/RTPSender.h
@@ -66,11 +66,9 @@
kWhatRTCPNotify,
};
- enum {
- kMaxNumTSPacketsPerRTPPacket = (kMaxUDPPacketSize - 12) / 188,
- kMaxHistorySize = 1024,
- kSourceID = 0xdeadbeef,
- };
+ const unsigned int kMaxNumTSPacketsPerRTPPacket = (kMaxUDPPacketSize - 12) / 188;
+ const unsigned int kMaxHistorySize = 1024;
+ const unsigned int kSourceID = 0xdeadbeef;
sp<ANetworkSession> mNetSession;
sp<AMessage> mNotify;
diff --git a/media/libstagefright/wifi-display/source/TSPacketizer.cpp b/media/libstagefright/wifi-display/source/TSPacketizer.cpp
index 4c5ad17..865ba94 100644
--- a/media/libstagefright/wifi-display/source/TSPacketizer.cpp
+++ b/media/libstagefright/wifi-display/source/TSPacketizer.cpp
@@ -273,8 +273,8 @@
CHECK(mFormat->findInt32("profile-idc", &profileIdc));
CHECK(mFormat->findInt32("level-idc", &levelIdc));
CHECK(mFormat->findInt32("constraint-set", &constraintSet));
- CHECK_GE(profileIdc, 0u);
- CHECK_GE(levelIdc, 0u);
+ CHECK_GE(profileIdc, 0);
+ CHECK_GE(levelIdc, 0);
data[2] = profileIdc; // profile_idc
data[3] = constraintSet; // constraint_set*
data[4] = levelIdc; // level_idc
@@ -771,7 +771,7 @@
program_info_length += mProgramInfoDescriptors.itemAt(i)->size();
}
- CHECK_LT(program_info_length, 0x400);
+ CHECK_LT(program_info_length, 0x400u);
*ptr++ = 0xf0 | (program_info_length >> 8);
*ptr++ = (program_info_length & 0xff);
@@ -795,7 +795,7 @@
for (size_t i = 0; i < track->countDescriptors(); ++i) {
ES_info_length += track->descriptorAt(i)->size();
}
- CHECK_LE(ES_info_length, 0xfff);
+ CHECK_LE(ES_info_length, 0xfffu);
*ptr++ = 0xf0 | (ES_info_length >> 8);
*ptr++ = (ES_info_length & 0xff);
diff --git a/media/libstagefright/wifi-display/source/TSPacketizer.h b/media/libstagefright/wifi-display/source/TSPacketizer.h
index 4a664ee..0dcb179 100644
--- a/media/libstagefright/wifi-display/source/TSPacketizer.h
+++ b/media/libstagefright/wifi-display/source/TSPacketizer.h
@@ -36,7 +36,7 @@
EMIT_HDCP20_DESCRIPTOR = 1,
EMIT_HDCP21_DESCRIPTOR = 2,
};
- TSPacketizer(uint32_t flags);
+ explicit TSPacketizer(uint32_t flags);
// Returns trackIndex or error.
ssize_t addTrack(const sp<AMessage> &format);
diff --git a/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
index e26165e..191db93 100644
--- a/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
+++ b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
@@ -454,7 +454,7 @@
sp<ABuffer> data;
CHECK(msg->findBuffer("data", &data));
- CHECK_LE(channel, 0xffu);
+ CHECK_LE(channel, 0xff);
CHECK_LE(data->size(), 0xffffu);
int32_t sessionID;
@@ -782,7 +782,7 @@
return;
}
- char *commaPos = strchr(s, ',');
+ const char *commaPos = strchr(s, ',');
if (commaPos != NULL) {
s = commaPos + 1;
@@ -1669,7 +1669,7 @@
}
struct WifiDisplaySource::HDCPObserver : public BnHDCPObserver {
- HDCPObserver(const sp<AMessage> ¬ify);
+ explicit HDCPObserver(const sp<AMessage> ¬ify);
virtual void notify(
int msg, int ext1, int ext2, const Parcel *obj);
diff --git a/media/libstagefright/yuv/Android.mk b/media/libstagefright/yuv/Android.mk
deleted file mode 100644
index f2fd3be..0000000
--- a/media/libstagefright/yuv/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- YUVImage.cpp \
- YUVCanvas.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- liblog
-
-LOCAL_MODULE:= libstagefright_yuv
-
-
-LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
-LOCAL_SANITIZE := signed-integer-overflow
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/yuv/MODULE_LICENSE_APACHE2 b/media/libstagefright/yuv/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/media/libstagefright/yuv/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/media/libstagefright/yuv/NOTICE b/media/libstagefright/yuv/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/media/libstagefright/yuv/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, 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.
-
- 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.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/media/libstagefright/yuv/YUVCanvas.cpp b/media/libstagefright/yuv/YUVCanvas.cpp
deleted file mode 100644
index 4c9fee8..0000000
--- a/media/libstagefright/yuv/YUVCanvas.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "YUVCanvas"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/YUVCanvas.h>
-#include <media/stagefright/YUVImage.h>
-#include <ui/Rect.h>
-
-namespace android {
-
-YUVCanvas::YUVCanvas(YUVImage &yuvImage)
- : mYUVImage(yuvImage) {
-}
-
-YUVCanvas::~YUVCanvas() {
-}
-
-void YUVCanvas::FillYUV(uint8_t yValue, uint8_t uValue, uint8_t vValue) {
- for (int32_t y = 0; y < mYUVImage.height(); ++y) {
- for (int32_t x = 0; x < mYUVImage.width(); ++x) {
- mYUVImage.setPixelValue(x, y, yValue, uValue, vValue);
- }
- }
-}
-
-void YUVCanvas::FillYUVRectangle(const Rect& rect,
- uint8_t yValue, uint8_t uValue, uint8_t vValue) {
- for (int32_t y = rect.top; y < rect.bottom; ++y) {
- for (int32_t x = rect.left; x < rect.right; ++x) {
- mYUVImage.setPixelValue(x, y, yValue, uValue, vValue);
- }
- }
-}
-
-void YUVCanvas::CopyImageRect(
- const Rect& srcRect,
- int32_t destStartX, int32_t destStartY,
- const YUVImage &srcImage) {
-
- // Try fast copy first
- if (YUVImage::fastCopyRectangle(
- srcRect,
- destStartX, destStartY,
- srcImage, mYUVImage)) {
- return;
- }
-
- int32_t srcStartX = srcRect.left;
- int32_t srcStartY = srcRect.top;
- for (int32_t offsetY = 0; offsetY < srcRect.height(); ++offsetY) {
- for (int32_t offsetX = 0; offsetX < srcRect.width(); ++offsetX) {
- int32_t srcX = srcStartX + offsetX;
- int32_t srcY = srcStartY + offsetY;
-
- int32_t destX = destStartX + offsetX;
- int32_t destY = destStartY + offsetY;
-
- uint8_t yValue;
- uint8_t uValue;
- uint8_t vValue;
-
- srcImage.getPixelValue(srcX, srcY, &yValue, &uValue, &vValue);
- mYUVImage.setPixelValue(destX, destY, yValue, uValue, vValue);
- }
- }
-}
-
-void YUVCanvas::downsample(
- int32_t srcOffsetX, int32_t srcOffsetY,
- int32_t skipX, int32_t skipY,
- const YUVImage &srcImage) {
- // TODO: Add a low pass filter for downsampling.
-
- // Check that srcImage is big enough to fill mYUVImage.
- CHECK((srcOffsetX + (mYUVImage.width() - 1) * skipX) < srcImage.width());
- CHECK((srcOffsetY + (mYUVImage.height() - 1) * skipY) < srcImage.height());
-
- uint8_t yValue;
- uint8_t uValue;
- uint8_t vValue;
-
- int32_t srcY = srcOffsetY;
- for (int32_t y = 0; y < mYUVImage.height(); ++y) {
- int32_t srcX = srcOffsetX;
- for (int32_t x = 0; x < mYUVImage.width(); ++x) {
- srcImage.getPixelValue(srcX, srcY, &yValue, &uValue, &vValue);
- mYUVImage.setPixelValue(x, y, yValue, uValue, vValue);
-
- srcX += skipX;
- }
- srcY += skipY;
- }
-}
-
-} // namespace android
diff --git a/media/libstagefright/yuv/YUVImage.cpp b/media/libstagefright/yuv/YUVImage.cpp
deleted file mode 100644
index c098135..0000000
--- a/media/libstagefright/yuv/YUVImage.cpp
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "YUVImage"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/YUVImage.h>
-#include <ui/Rect.h>
-
-namespace android {
-
-YUVImage::YUVImage(YUVFormat yuvFormat, int32_t width, int32_t height) {
- mYUVFormat = yuvFormat;
- mWidth = width;
- mHeight = height;
-
- size_t numberOfBytes = bufferSize(yuvFormat, width, height);
- uint8_t *buffer = new uint8_t[numberOfBytes];
- mBuffer = buffer;
- mOwnBuffer = true;
-
- initializeYUVPointers();
-}
-
-YUVImage::YUVImage(YUVFormat yuvFormat, int32_t width, int32_t height, uint8_t *buffer) {
- mYUVFormat = yuvFormat;
- mWidth = width;
- mHeight = height;
- mBuffer = buffer;
- mOwnBuffer = false;
-
- initializeYUVPointers();
-}
-
-//static
-size_t YUVImage::bufferSize(YUVFormat yuvFormat, int32_t width, int32_t height) {
- int32_t numberOfPixels = width*height;
- size_t numberOfBytes = 0;
- if (yuvFormat == YUV420Planar || yuvFormat == YUV420SemiPlanar) {
- // Y takes numberOfPixels bytes and U/V take numberOfPixels/4 bytes each.
- numberOfBytes = (size_t)(numberOfPixels + (numberOfPixels >> 1));
- } else {
- ALOGE("Format not supported");
- }
- return numberOfBytes;
-}
-
-bool YUVImage::initializeYUVPointers() {
- int32_t numberOfPixels = mWidth * mHeight;
-
- if (mYUVFormat == YUV420Planar) {
- mYdata = (uint8_t *)mBuffer;
- mUdata = mYdata + numberOfPixels;
- mVdata = mUdata + (numberOfPixels >> 2);
- } else if (mYUVFormat == YUV420SemiPlanar) {
- // U and V channels are interleaved as VUVUVU.
- // So V data starts at the end of Y channel and
- // U data starts right after V's start.
- mYdata = (uint8_t *)mBuffer;
- mVdata = mYdata + numberOfPixels;
- mUdata = mVdata + 1;
- } else {
- ALOGE("Format not supported");
- return false;
- }
- return true;
-}
-
-YUVImage::~YUVImage() {
- if (mOwnBuffer) delete[] mBuffer;
-}
-
-bool YUVImage::getOffsets(int32_t x, int32_t y,
- int32_t *yOffset, int32_t *uOffset, int32_t *vOffset) const {
- *yOffset = y*mWidth + x;
-
- int32_t uvOffset = (y >> 1) * (mWidth >> 1) + (x >> 1);
- if (mYUVFormat == YUV420Planar) {
- *uOffset = uvOffset;
- *vOffset = uvOffset;
- } else if (mYUVFormat == YUV420SemiPlanar) {
- // Since U and V channels are interleaved, offsets need
- // to be doubled.
- *uOffset = 2*uvOffset;
- *vOffset = 2*uvOffset;
- } else {
- ALOGE("Format not supported");
- return false;
- }
-
- return true;
-}
-
-bool YUVImage::getOffsetIncrementsPerDataRow(
- int32_t *yDataOffsetIncrement,
- int32_t *uDataOffsetIncrement,
- int32_t *vDataOffsetIncrement) const {
- *yDataOffsetIncrement = mWidth;
-
- int32_t uvDataOffsetIncrement = mWidth >> 1;
-
- if (mYUVFormat == YUV420Planar) {
- *uDataOffsetIncrement = uvDataOffsetIncrement;
- *vDataOffsetIncrement = uvDataOffsetIncrement;
- } else if (mYUVFormat == YUV420SemiPlanar) {
- // Since U and V channels are interleaved, offsets need
- // to be doubled.
- *uDataOffsetIncrement = 2*uvDataOffsetIncrement;
- *vDataOffsetIncrement = 2*uvDataOffsetIncrement;
- } else {
- ALOGE("Format not supported");
- return false;
- }
-
- return true;
-}
-
-uint8_t* YUVImage::getYAddress(int32_t offset) const {
- return mYdata + offset;
-}
-
-uint8_t* YUVImage::getUAddress(int32_t offset) const {
- return mUdata + offset;
-}
-
-uint8_t* YUVImage::getVAddress(int32_t offset) const {
- return mVdata + offset;
-}
-
-bool YUVImage::getYUVAddresses(int32_t x, int32_t y,
- uint8_t **yAddr, uint8_t **uAddr, uint8_t **vAddr) const {
- int32_t yOffset;
- int32_t uOffset;
- int32_t vOffset;
- if (!getOffsets(x, y, &yOffset, &uOffset, &vOffset)) return false;
-
- *yAddr = getYAddress(yOffset);
- *uAddr = getUAddress(uOffset);
- *vAddr = getVAddress(vOffset);
-
- return true;
-}
-
-bool YUVImage::validPixel(int32_t x, int32_t y) const {
- return (x >= 0 && x < mWidth &&
- y >= 0 && y < mHeight);
-}
-
-bool YUVImage::getPixelValue(int32_t x, int32_t y,
- uint8_t *yPtr, uint8_t *uPtr, uint8_t *vPtr) const {
- CHECK(validPixel(x, y));
-
- uint8_t *yAddr;
- uint8_t *uAddr;
- uint8_t *vAddr;
- if (!getYUVAddresses(x, y, &yAddr, &uAddr, &vAddr)) return false;
-
- *yPtr = *yAddr;
- *uPtr = *uAddr;
- *vPtr = *vAddr;
-
- return true;
-}
-
-bool YUVImage::setPixelValue(int32_t x, int32_t y,
- uint8_t yValue, uint8_t uValue, uint8_t vValue) {
- CHECK(validPixel(x, y));
-
- uint8_t *yAddr;
- uint8_t *uAddr;
- uint8_t *vAddr;
- if (!getYUVAddresses(x, y, &yAddr, &uAddr, &vAddr)) return false;
-
- *yAddr = yValue;
- *uAddr = uValue;
- *vAddr = vValue;
-
- return true;
-}
-
-void YUVImage::fastCopyRectangle420Planar(
- const Rect& srcRect,
- int32_t destStartX, int32_t destStartY,
- const YUVImage &srcImage, YUVImage &destImage) {
- CHECK(srcImage.mYUVFormat == YUV420Planar);
- CHECK(destImage.mYUVFormat == YUV420Planar);
-
- int32_t srcStartX = srcRect.left;
- int32_t srcStartY = srcRect.top;
- int32_t width = srcRect.width();
- int32_t height = srcRect.height();
-
- // Get source and destination start addresses
- uint8_t *ySrcAddrBase;
- uint8_t *uSrcAddrBase;
- uint8_t *vSrcAddrBase;
- srcImage.getYUVAddresses(srcStartX, srcStartY,
- &ySrcAddrBase, &uSrcAddrBase, &vSrcAddrBase);
-
- uint8_t *yDestAddrBase;
- uint8_t *uDestAddrBase;
- uint8_t *vDestAddrBase;
- destImage.getYUVAddresses(destStartX, destStartY,
- &yDestAddrBase, &uDestAddrBase, &vDestAddrBase);
-
- // Get source and destination offset increments incurred in going
- // from one data row to next.
- int32_t ySrcOffsetIncrement;
- int32_t uSrcOffsetIncrement;
- int32_t vSrcOffsetIncrement;
- srcImage.getOffsetIncrementsPerDataRow(
- &ySrcOffsetIncrement, &uSrcOffsetIncrement, &vSrcOffsetIncrement);
-
- int32_t yDestOffsetIncrement;
- int32_t uDestOffsetIncrement = 0;
- int32_t vDestOffsetIncrement = 0;
- destImage.getOffsetIncrementsPerDataRow(
- &yDestOffsetIncrement, &uDestOffsetIncrement, &vDestOffsetIncrement);
-
- // Copy Y
- {
- size_t numberOfYBytesPerRow = (size_t) width;
- uint8_t *ySrcAddr = ySrcAddrBase;
- uint8_t *yDestAddr = yDestAddrBase;
- for (int32_t offsetY = 0; offsetY < height; ++offsetY) {
- memcpy(yDestAddr, ySrcAddr, numberOfYBytesPerRow);
-
- ySrcAddr += ySrcOffsetIncrement;
- yDestAddr += yDestOffsetIncrement;
- }
- }
-
- // Copy U
- {
- size_t numberOfUBytesPerRow = (size_t) (width >> 1);
- uint8_t *uSrcAddr = uSrcAddrBase;
- uint8_t *uDestAddr = uDestAddrBase;
- // Every other row has an entry for U/V channel values. Hence only
- // go half the height.
- for (int32_t offsetY = 0; offsetY < (height >> 1); ++offsetY) {
- memcpy(uDestAddr, uSrcAddr, numberOfUBytesPerRow);
-
- uSrcAddr += uSrcOffsetIncrement;
- uDestAddr += uDestOffsetIncrement;
- }
- }
-
- // Copy V
- {
- size_t numberOfVBytesPerRow = (size_t) (width >> 1);
- uint8_t *vSrcAddr = vSrcAddrBase;
- uint8_t *vDestAddr = vDestAddrBase;
- // Every other pixel row has a U/V data row. Hence only go half the height.
- for (int32_t offsetY = 0; offsetY < (height >> 1); ++offsetY) {
- memcpy(vDestAddr, vSrcAddr, numberOfVBytesPerRow);
-
- vSrcAddr += vSrcOffsetIncrement;
- vDestAddr += vDestOffsetIncrement;
- }
- }
-}
-
-void YUVImage::fastCopyRectangle420SemiPlanar(
- const Rect& srcRect,
- int32_t destStartX, int32_t destStartY,
- const YUVImage &srcImage, YUVImage &destImage) {
- CHECK(srcImage.mYUVFormat == YUV420SemiPlanar);
- CHECK(destImage.mYUVFormat == YUV420SemiPlanar);
-
- int32_t srcStartX = srcRect.left;
- int32_t srcStartY = srcRect.top;
- int32_t width = srcRect.width();
- int32_t height = srcRect.height();
-
- // Get source and destination start addresses
- uint8_t *ySrcAddrBase;
- uint8_t *uSrcAddrBase;
- uint8_t *vSrcAddrBase;
- srcImage.getYUVAddresses(srcStartX, srcStartY,
- &ySrcAddrBase, &uSrcAddrBase, &vSrcAddrBase);
-
- uint8_t *yDestAddrBase;
- uint8_t *uDestAddrBase;
- uint8_t *vDestAddrBase;
- destImage.getYUVAddresses(destStartX, destStartY,
- &yDestAddrBase, &uDestAddrBase, &vDestAddrBase);
-
- // Get source and destination offset increments incurred in going
- // from one data row to next.
- int32_t ySrcOffsetIncrement;
- int32_t uSrcOffsetIncrement;
- int32_t vSrcOffsetIncrement;
- srcImage.getOffsetIncrementsPerDataRow(
- &ySrcOffsetIncrement, &uSrcOffsetIncrement, &vSrcOffsetIncrement);
-
- int32_t yDestOffsetIncrement;
- int32_t uDestOffsetIncrement;
- int32_t vDestOffsetIncrement = 0;
- destImage.getOffsetIncrementsPerDataRow(
- &yDestOffsetIncrement, &uDestOffsetIncrement, &vDestOffsetIncrement);
-
- // Copy Y
- {
- size_t numberOfYBytesPerRow = (size_t) width;
- uint8_t *ySrcAddr = ySrcAddrBase;
- uint8_t *yDestAddr = yDestAddrBase;
- for (int32_t offsetY = 0; offsetY < height; ++offsetY) {
- memcpy(yDestAddr, ySrcAddr, numberOfYBytesPerRow);
-
- ySrcAddr = ySrcAddr + ySrcOffsetIncrement;
- yDestAddr = yDestAddr + yDestOffsetIncrement;
- }
- }
-
- // Copy UV
- {
- // UV are interleaved. So number of UV bytes per row is 2*(width/2).
- size_t numberOfUVBytesPerRow = (size_t) width;
- uint8_t *vSrcAddr = vSrcAddrBase;
- uint8_t *vDestAddr = vDestAddrBase;
- // Every other pixel row has a U/V data row. Hence only go half the height.
- for (int32_t offsetY = 0; offsetY < (height >> 1); ++offsetY) {
- memcpy(vDestAddr, vSrcAddr, numberOfUVBytesPerRow);
-
- vSrcAddr += vSrcOffsetIncrement;
- vDestAddr += vDestOffsetIncrement;
- }
- }
-}
-
-// static
-bool YUVImage::fastCopyRectangle(
- const Rect& srcRect,
- int32_t destStartX, int32_t destStartY,
- const YUVImage &srcImage, YUVImage &destImage) {
- if (srcImage.mYUVFormat == destImage.mYUVFormat) {
- if (srcImage.mYUVFormat == YUV420Planar) {
- fastCopyRectangle420Planar(
- srcRect,
- destStartX, destStartY,
- srcImage, destImage);
- } else if (srcImage.mYUVFormat == YUV420SemiPlanar) {
- fastCopyRectangle420SemiPlanar(
- srcRect,
- destStartX, destStartY,
- srcImage, destImage);
- }
- return true;
- }
- return false;
-}
-
-uint8_t clamp(uint8_t v, uint8_t minValue, uint8_t maxValue) {
- CHECK(maxValue >= minValue);
-
- if (v < minValue) return minValue;
- else if (v > maxValue) return maxValue;
- else return v;
-}
-
-void YUVImage::yuv2rgb(uint8_t yValue, uint8_t uValue, uint8_t vValue,
- uint8_t *r, uint8_t *g, uint8_t *b) const {
- int rTmp = yValue + (1.370705 * (vValue-128));
- int gTmp = yValue - (0.698001 * (vValue-128)) - (0.337633 * (uValue-128));
- int bTmp = yValue + (1.732446 * (uValue-128));
-
- *r = clamp(rTmp, 0, 255);
- *g = clamp(gTmp, 0, 255);
- *b = clamp(bTmp, 0, 255);
-}
-
-bool YUVImage::writeToPPM(const char *filename) const {
- FILE *fp = fopen(filename, "w");
- if (fp == NULL) {
- return false;
- }
- fprintf(fp, "P3\n");
- fprintf(fp, "%d %d\n", mWidth, mHeight);
- fprintf(fp, "255\n");
- for (int32_t y = 0; y < mHeight; ++y) {
- for (int32_t x = 0; x < mWidth; ++x) {
- uint8_t yValue = 0u;
- uint8_t uValue = 0u;
- uint8_t vValue = 0u;
- getPixelValue(x, y, &yValue, &uValue, & vValue);
-
- uint8_t rValue;
- uint8_t gValue;
- uint8_t bValue;
- yuv2rgb(yValue, uValue, vValue, &rValue, &gValue, &bValue);
-
- fprintf(fp, "%d %d %d\n", (int32_t)rValue, (int32_t)gValue, (int32_t)bValue);
- }
- }
- fclose(fp);
- return true;
-}
-
-} // namespace android
diff --git a/media/mediaserver/Android.mk b/media/mediaserver/Android.mk
index 1738df8..ffbfcbb 100644
--- a/media/mediaserver/Android.mk
+++ b/media/mediaserver/Android.mk
@@ -15,12 +15,9 @@
main_mediaserver.cpp
LOCAL_SHARED_LIBRARIES := \
- libcamera_metadata \
- libcamera_client \
- libcameraservice \
libresourcemanagerservice \
+ liblog \
libcutils \
- libmedia \
libmediaplayerservice \
libutils \
libbinder \
@@ -32,7 +29,6 @@
LOCAL_C_INCLUDES := \
frameworks/av/media/libmediaplayerservice \
- frameworks/av/services/camera/libcameraservice \
frameworks/av/services/mediaresourcemanager \
LOCAL_MODULE:= mediaserver
diff --git a/media/mtp/Android.bp b/media/mtp/Android.bp
new file mode 100644
index 0000000..5d5ae49
--- /dev/null
+++ b/media/mtp/Android.bp
@@ -0,0 +1,57 @@
+//
+// 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.
+//
+
+cc_library_shared {
+ name: "libmtp",
+ srcs: [
+ "AsyncIO.cpp",
+ "MtpDataPacket.cpp",
+ "MtpDebug.cpp",
+ "MtpDevHandle.cpp",
+ "MtpDevice.cpp",
+ "MtpDeviceInfo.cpp",
+ "MtpEventPacket.cpp",
+ "MtpFfsHandle.cpp",
+ "MtpObjectInfo.cpp",
+ "MtpPacket.cpp",
+ "MtpProperty.cpp",
+ "MtpRequestPacket.cpp",
+ "MtpResponsePacket.cpp",
+ "MtpServer.cpp",
+ "MtpStorage.cpp",
+ "MtpStorageInfo.cpp",
+ "MtpStringBuffer.cpp",
+ "MtpUtils.cpp",
+ ],
+ export_include_dirs: ["."],
+ cflags: [
+ "-DMTP_DEVICE",
+ "-DMTP_HOST",
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ shared_libs: [
+ "libbase",
+ "libutils",
+ "liblog",
+ "libusbhost",
+ ],
+}
+
+subdirs = [
+ "tests",
+]
diff --git a/media/mtp/Android.mk b/media/mtp/Android.mk
deleted file mode 100644
index cb7e4aa..0000000
--- a/media/mtp/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- MtpDataPacket.cpp \
- MtpDebug.cpp \
- MtpDevice.cpp \
- MtpEventPacket.cpp \
- MtpDeviceInfo.cpp \
- MtpObjectInfo.cpp \
- MtpPacket.cpp \
- MtpProperty.cpp \
- MtpRequestPacket.cpp \
- MtpResponsePacket.cpp \
- MtpServer.cpp \
- MtpStorageInfo.cpp \
- MtpStringBuffer.cpp \
- MtpStorage.cpp \
- MtpUtils.cpp \
-
-LOCAL_MODULE:= libmtp
-
-LOCAL_CFLAGS := -DMTP_DEVICE -DMTP_HOST -Wall -Wextra -Werror
-
-LOCAL_SHARED_LIBRARIES := libutils libcutils liblog libusbhost libbinder
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/mtp/AsyncIO.cpp b/media/mtp/AsyncIO.cpp
new file mode 100644
index 0000000..e77ad38
--- /dev/null
+++ b/media/mtp/AsyncIO.cpp
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <android-base/logging.h>
+#include <condition_variable>
+#include <memory>
+#include <mutex>
+#include <queue>
+
+#include "AsyncIO.h"
+
+namespace {
+
+void read_func(struct aiocb *aiocbp) {
+ aiocbp->ret = TEMP_FAILURE_RETRY(pread(aiocbp->aio_fildes,
+ aiocbp->aio_buf, aiocbp->aio_nbytes, aiocbp->aio_offset));
+ if (aiocbp->ret == -1) aiocbp->error = errno;
+}
+
+void write_func(struct aiocb *aiocbp) {
+ aiocbp->ret = TEMP_FAILURE_RETRY(pwrite(aiocbp->aio_fildes,
+ aiocbp->aio_buf, aiocbp->aio_nbytes, aiocbp->aio_offset));
+ if (aiocbp->ret == -1) aiocbp->error = errno;
+}
+
+void splice_read_func(struct aiocb *aiocbp) {
+ loff_t long_offset = aiocbp->aio_offset;
+ aiocbp->ret = TEMP_FAILURE_RETRY(splice(aiocbp->aio_fildes,
+ &long_offset, aiocbp->aio_sink,
+ NULL, aiocbp->aio_nbytes, 0));
+ if (aiocbp->ret == -1) aiocbp->error = errno;
+}
+
+void splice_write_func(struct aiocb *aiocbp) {
+ loff_t long_offset = aiocbp->aio_offset;
+ aiocbp->ret = TEMP_FAILURE_RETRY(splice(aiocbp->aio_fildes, NULL,
+ aiocbp->aio_sink, &long_offset,
+ aiocbp->aio_nbytes, 0));
+ if (aiocbp->ret == -1) aiocbp->error = errno;
+}
+
+std::queue<std::unique_ptr<struct aiocb>> queue;
+std::mutex queue_lock;
+std::condition_variable queue_cond;
+std::condition_variable write_cond;
+int done = 1;
+void splice_write_pool_func(int) {
+ while(1) {
+ std::unique_lock<std::mutex> lk(queue_lock);
+ queue_cond.wait(lk, []{return !queue.empty() || done;});
+ if (queue.empty() && done) {
+ return;
+ }
+ std::unique_ptr<struct aiocb> aiocbp = std::move(queue.front());
+ queue.pop();
+ lk.unlock();
+ write_cond.notify_one();
+ splice_write_func(aiocbp.get());
+ close(aiocbp->aio_fildes);
+ }
+}
+
+void write_pool_func(int) {
+ while(1) {
+ std::unique_lock<std::mutex> lk(queue_lock);
+ queue_cond.wait(lk, []{return !queue.empty() || done;});
+ if (queue.empty() && done) {
+ return;
+ }
+ std::unique_ptr<struct aiocb> aiocbp = std::move(queue.front());
+ queue.pop();
+ lk.unlock();
+ write_cond.notify_one();
+ aiocbp->ret = TEMP_FAILURE_RETRY(pwrite(aiocbp->aio_fildes,
+ aiocbp->aio_pool_buf.get(), aiocbp->aio_nbytes, aiocbp->aio_offset));
+ if (aiocbp->ret == -1) aiocbp->error = errno;
+ }
+}
+
+constexpr int NUM_THREADS = 1;
+constexpr int MAX_QUEUE_SIZE = 10;
+std::thread pool[NUM_THREADS];
+
+} // end anonymous namespace
+
+void aio_pool_init(void(f)(int)) {
+ CHECK(done == 1);
+ done = 0;
+ for (int i = 0; i < NUM_THREADS; i++) {
+ pool[i] = std::thread(f, i);
+ }
+}
+
+void aio_pool_splice_init() {
+ aio_pool_init(splice_write_pool_func);
+}
+
+void aio_pool_write_init() {
+ aio_pool_init(write_pool_func);
+}
+
+void aio_pool_end() {
+ done = 1;
+ for (int i = 0; i < NUM_THREADS; i++) {
+ std::unique_lock<std::mutex> lk(queue_lock);
+ lk.unlock();
+ queue_cond.notify_one();
+ }
+
+ for (int i = 0; i < NUM_THREADS; i++) {
+ pool[i].join();
+ }
+}
+
+// used for both writes and splices depending on which init was used before.
+int aio_pool_write(struct aiocb *aiocbp) {
+ std::unique_lock<std::mutex> lk(queue_lock);
+ write_cond.wait(lk, []{return queue.size() < MAX_QUEUE_SIZE;});
+ queue.push(std::unique_ptr<struct aiocb>(aiocbp));
+ lk.unlock();
+ queue_cond.notify_one();
+ return 0;
+}
+
+int aio_read(struct aiocb *aiocbp) {
+ aiocbp->thread = std::thread(read_func, aiocbp);
+ return 0;
+}
+
+int aio_write(struct aiocb *aiocbp) {
+ aiocbp->thread = std::thread(write_func, aiocbp);
+ return 0;
+}
+
+int aio_splice_read(struct aiocb *aiocbp) {
+ aiocbp->thread = std::thread(splice_read_func, aiocbp);
+ return 0;
+}
+
+int aio_splice_write(struct aiocb *aiocbp) {
+ aiocbp->thread = std::thread(splice_write_func, aiocbp);
+ return 0;
+}
+
+int aio_error(const struct aiocb *aiocbp) {
+ return aiocbp->error;
+}
+
+ssize_t aio_return(struct aiocb *aiocbp) {
+ return aiocbp->ret;
+}
+
+int aio_suspend(struct aiocb *aiocbp[], int n,
+ const struct timespec *) {
+ for (int i = 0; i < n; i++) {
+ aiocbp[i]->thread.join();
+ }
+ return 0;
+}
+
+int aio_cancel(int, struct aiocb *) {
+ // Not implemented
+ return -1;
+}
+
diff --git a/media/mtp/AsyncIO.h b/media/mtp/AsyncIO.h
new file mode 100644
index 0000000..f7515a2
--- /dev/null
+++ b/media/mtp/AsyncIO.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef _ASYNCIO_H
+#define _ASYNCIO_H
+
+#include <fcntl.h>
+#include <linux/aio_abi.h>
+#include <memory>
+#include <signal.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <time.h>
+#include <thread>
+#include <unistd.h>
+
+/**
+ * Provides a subset of POSIX aio operations, as well
+ * as similar operations with splice and threadpools.
+ */
+
+struct aiocb {
+ int aio_fildes; // Assumed to be the source for splices
+ void *aio_buf; // Unused for splices
+
+ // Used for threadpool operations only, freed automatically
+ std::unique_ptr<char[]> aio_pool_buf;
+
+ off_t aio_offset;
+ size_t aio_nbytes;
+
+ int aio_sink; // Unused for non splice r/w
+
+ // Used internally
+ std::thread thread;
+ ssize_t ret;
+ int error;
+};
+
+// Submit a request for IO to be completed
+int aio_read(struct aiocb *);
+int aio_write(struct aiocb *);
+int aio_splice_read(struct aiocb *);
+int aio_splice_write(struct aiocb *);
+
+// Suspend current thread until given IO is complete, at which point
+// its return value and any errors can be accessed
+int aio_suspend(struct aiocb *[], int, const struct timespec *);
+int aio_error(const struct aiocb *);
+ssize_t aio_return(struct aiocb *);
+int aio_cancel(int, struct aiocb *);
+
+// Initialize a threadpool to perform IO. Only one pool can be
+// running at a time.
+void aio_pool_write_init();
+void aio_pool_splice_init();
+// Suspend current thread until all queued work is complete, then ends the threadpool
+void aio_pool_end();
+// Submit IO work for the threadpool to complete. Memory associated with the work is
+// freed automatically when the work is complete.
+int aio_pool_write(struct aiocb *);
+
+#endif // ASYNCIO_H
+
diff --git a/media/mtp/IMtpHandle.h b/media/mtp/IMtpHandle.h
new file mode 100644
index 0000000..9185255
--- /dev/null
+++ b/media/mtp/IMtpHandle.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+#ifndef _IMTP_HANDLE_H
+#define _IMTP_HANDLE_H
+
+#include <linux/usb/f_mtp.h>
+
+constexpr char FFS_MTP_EP0[] = "/dev/usb-ffs/mtp/ep0";
+
+class IMtpHandle {
+public:
+ // Return number of bytes read/written, or -1 and errno is set
+ virtual int read(void *data, int len) = 0;
+ virtual int write(const void *data, int len) = 0;
+
+ // Return 0 if send/receive is successful, or -1 and errno is set
+ virtual int receiveFile(mtp_file_range mfr) = 0;
+ virtual int sendFile(mtp_file_range mfr) = 0;
+ virtual int sendEvent(mtp_event me) = 0;
+
+ // Return 0 if operation is successful, or -1 else
+ virtual int start() = 0;
+ virtual int configure(bool ptp) = 0;
+
+ virtual void close() = 0;
+
+ virtual ~IMtpHandle() {}
+};
+
+IMtpHandle *get_ffs_handle();
+IMtpHandle *get_mtp_handle();
+
+#endif // _IMTP_HANDLE_H
+
diff --git a/media/mtp/MtpDataPacket.cpp b/media/mtp/MtpDataPacket.cpp
index 0e9bc34..40f4cea 100644
--- a/media/mtp/MtpDataPacket.cpp
+++ b/media/mtp/MtpDataPacket.cpp
@@ -24,6 +24,7 @@
#include <sys/types.h>
#include <usbhost/usbhost.h>
#include "MtpStringBuffer.h"
+#include "IMtpHandle.h"
namespace android {
@@ -438,9 +439,9 @@
putUInt16(0);
}
-#ifdef MTP_DEVICE
-int MtpDataPacket::read(int fd) {
- int ret = ::read(fd, mBuffer, MTP_BUFFER_SIZE);
+#ifdef MTP_DEVICE
+int MtpDataPacket::read(IMtpHandle *h) {
+ int ret = h->read(mBuffer, MTP_BUFFER_SIZE);
if (ret < MTP_CONTAINER_HEADER_SIZE)
return -1;
mPacketSize = ret;
@@ -448,20 +449,20 @@
return ret;
}
-int MtpDataPacket::write(int fd) {
+int MtpDataPacket::write(IMtpHandle *h) {
MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA);
- int ret = ::write(fd, mBuffer, mPacketSize);
+ int ret = h->write(mBuffer, mPacketSize);
return (ret < 0 ? ret : 0);
}
-int MtpDataPacket::writeData(int fd, void* data, uint32_t length) {
+int MtpDataPacket::writeData(IMtpHandle *h, void* data, uint32_t length) {
allocate(length + MTP_CONTAINER_HEADER_SIZE);
memcpy(mBuffer + MTP_CONTAINER_HEADER_SIZE, data, length);
length += MTP_CONTAINER_HEADER_SIZE;
MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, length);
MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA);
- int ret = ::write(fd, mBuffer, length);
+ int ret = h->write(mBuffer, length);
return (ret < 0 ? ret : 0);
}
diff --git a/media/mtp/MtpDataPacket.h b/media/mtp/MtpDataPacket.h
index 82e0ee4..a449d6f 100644
--- a/media/mtp/MtpDataPacket.h
+++ b/media/mtp/MtpDataPacket.h
@@ -20,6 +20,7 @@
#include "MtpPacket.h"
#include "mtp.h"
+class IMtpHandle;
struct usb_device;
struct usb_request;
@@ -94,12 +95,12 @@
inline void putEmptyArray() { putUInt32(0); }
#ifdef MTP_DEVICE
- // fill our buffer with data from the given file descriptor
- int read(int fd);
+ // fill our buffer with data from the given usb handle
+ int read(IMtpHandle *h);
- // write our data to the given file descriptor
- int write(int fd);
- int writeData(int fd, void* data, uint32_t length);
+ // write our data to the given usb handle
+ int write(IMtpHandle *h);
+ int writeData(IMtpHandle *h, void* data, uint32_t length);
#endif
#ifdef MTP_HOST
diff --git a/media/mtp/MtpDevHandle.cpp b/media/mtp/MtpDevHandle.cpp
new file mode 100644
index 0000000..afc0525
--- /dev/null
+++ b/media/mtp/MtpDevHandle.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <utils/Log.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <cutils/properties.h>
+#include <dirent.h>
+#include <errno.h>
+#include <linux/usb/ch9.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/endian.h>
+#include <unistd.h>
+
+#include <android-base/logging.h>
+#include <android-base/unique_fd.h>
+#include "IMtpHandle.h"
+
+constexpr char mtp_dev_path[] = "/dev/mtp_usb";
+
+class MtpDevHandle : public IMtpHandle {
+private:
+ android::base::unique_fd mFd;
+
+public:
+ MtpDevHandle();
+ ~MtpDevHandle();
+ int read(void *data, int len);
+ int write(const void *data, int len);
+
+ int receiveFile(mtp_file_range mfr);
+ int sendFile(mtp_file_range mfr);
+ int sendEvent(mtp_event me);
+
+ int start();
+ void close();
+
+ int configure(bool ptp);
+};
+
+MtpDevHandle::MtpDevHandle()
+ : mFd(-1) {};
+
+MtpDevHandle::~MtpDevHandle() {}
+
+int MtpDevHandle::read(void *data, int len) {
+ return ::read(mFd, data, len);
+}
+
+int MtpDevHandle::write(const void *data, int len) {
+ return ::write(mFd, data, len);
+}
+
+int MtpDevHandle::receiveFile(mtp_file_range mfr) {
+ return ioctl(mFd, MTP_RECEIVE_FILE, reinterpret_cast<unsigned long>(&mfr));
+}
+
+int MtpDevHandle::sendFile(mtp_file_range mfr) {
+ return ioctl(mFd, MTP_SEND_FILE_WITH_HEADER, reinterpret_cast<unsigned long>(&mfr));
+}
+
+int MtpDevHandle::sendEvent(mtp_event me) {
+ return ioctl(mFd, MTP_SEND_EVENT, reinterpret_cast<unsigned long>(&me));
+}
+
+int MtpDevHandle::start() {
+ mFd = android::base::unique_fd(TEMP_FAILURE_RETRY(open(mtp_dev_path, O_RDWR)));
+ if (mFd == -1) return -1;
+ return 0;
+}
+
+void MtpDevHandle::close() {
+ mFd.reset();
+}
+
+int MtpDevHandle::configure(bool) {
+ // Nothing to do, driver can configure itself
+ return 0;
+}
+
+IMtpHandle *get_mtp_handle() {
+ return new MtpDevHandle();
+}
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index e3d2ec6..52ea363 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -266,19 +266,20 @@
}
void MtpDevice::print() {
- if (mDeviceInfo) {
- mDeviceInfo->print();
+ if (!mDeviceInfo)
+ return;
- if (mDeviceInfo->mDeviceProperties) {
- ALOGI("***** DEVICE PROPERTIES *****\n");
- int count = mDeviceInfo->mDeviceProperties->size();
- for (int i = 0; i < count; i++) {
- MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i];
- MtpProperty* property = getDevicePropDesc(propCode);
- if (property) {
- property->print();
- delete property;
- }
+ mDeviceInfo->print();
+
+ if (mDeviceInfo->mDeviceProperties) {
+ ALOGI("***** DEVICE PROPERTIES *****\n");
+ int count = mDeviceInfo->mDeviceProperties->size();
+ for (int i = 0; i < count; i++) {
+ MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i];
+ MtpProperty* property = getDevicePropDesc(propCode);
+ if (property) {
+ property->print();
+ delete property;
}
}
}
diff --git a/media/mtp/MtpEventPacket.cpp b/media/mtp/MtpEventPacket.cpp
index 8e13ea9..fbee72f 100644
--- a/media/mtp/MtpEventPacket.cpp
+++ b/media/mtp/MtpEventPacket.cpp
@@ -19,12 +19,8 @@
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <sys/ioctl.h>
-#ifdef MTP_DEVICE
-#include <linux/usb/f_mtp.h>
-#endif
-
+#include "IMtpHandle.h"
#include "MtpEventPacket.h"
#include <usbhost/usbhost.h>
@@ -40,7 +36,7 @@
}
#ifdef MTP_DEVICE
-int MtpEventPacket::write(int fd) {
+int MtpEventPacket::write(IMtpHandle *h) {
struct mtp_event event;
putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
@@ -48,7 +44,7 @@
event.data = mBuffer;
event.length = mPacketSize;
- int ret = ::ioctl(fd, MTP_SEND_EVENT, (unsigned long)&event);
+ int ret = h->sendEvent(event);
return (ret < 0 ? ret : 0);
}
#endif
diff --git a/media/mtp/MtpEventPacket.h b/media/mtp/MtpEventPacket.h
index a8779fd..3f3b6a3 100644
--- a/media/mtp/MtpEventPacket.h
+++ b/media/mtp/MtpEventPacket.h
@@ -20,6 +20,8 @@
#include "MtpPacket.h"
#include "mtp.h"
+class IMtpHandle;
+
namespace android {
class MtpEventPacket : public MtpPacket {
@@ -29,8 +31,8 @@
virtual ~MtpEventPacket();
#ifdef MTP_DEVICE
- // write our data to the given file descriptor
- int write(int fd);
+ // write our data to the given usb handle
+ int write(IMtpHandle *h);
#endif
#ifdef MTP_HOST
diff --git a/media/mtp/MtpFfsHandle.cpp b/media/mtp/MtpFfsHandle.cpp
new file mode 100644
index 0000000..35dd10f
--- /dev/null
+++ b/media/mtp/MtpFfsHandle.cpp
@@ -0,0 +1,704 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/functionfs.h>
+#include <mutex>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/endian.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <vector>
+
+#include "AsyncIO.h"
+#include "MtpFfsHandle.h"
+#include "mtp.h"
+
+#define cpu_to_le16(x) htole16(x)
+#define cpu_to_le32(x) htole32(x)
+
+#define FUNCTIONFS_ENDPOINT_ALLOC _IOR('g', 231, __u32)
+
+namespace {
+
+constexpr char FFS_MTP_EP_IN[] = "/dev/usb-ffs/mtp/ep1";
+constexpr char FFS_MTP_EP_OUT[] = "/dev/usb-ffs/mtp/ep2";
+constexpr char FFS_MTP_EP_INTR[] = "/dev/usb-ffs/mtp/ep3";
+
+constexpr int MAX_PACKET_SIZE_FS = 64;
+constexpr int MAX_PACKET_SIZE_HS = 512;
+constexpr int MAX_PACKET_SIZE_SS = 1024;
+
+// Must be divisible by all max packet size values
+constexpr int MAX_FILE_CHUNK_SIZE = 3145728;
+
+// Safe values since some devices cannot handle large DMAs
+// To get good performance, override these with
+// higher values per device using the properties
+// sys.usb.ffs.max_read and sys.usb.ffs.max_write
+constexpr int USB_FFS_MAX_WRITE = MTP_BUFFER_SIZE;
+constexpr int USB_FFS_MAX_READ = MTP_BUFFER_SIZE;
+
+static_assert(USB_FFS_MAX_WRITE > 0, "Max r/w values must be > 0!");
+static_assert(USB_FFS_MAX_READ > 0, "Max r/w values must be > 0!");
+
+constexpr unsigned int MAX_MTP_FILE_SIZE = 0xFFFFFFFF;
+
+constexpr size_t ENDPOINT_ALLOC_RETRIES = 10;
+
+struct func_desc {
+ struct usb_interface_descriptor intf;
+ struct usb_endpoint_descriptor_no_audio sink;
+ struct usb_endpoint_descriptor_no_audio source;
+ struct usb_endpoint_descriptor_no_audio intr;
+} __attribute__((packed));
+
+struct ss_func_desc {
+ struct usb_interface_descriptor intf;
+ struct usb_endpoint_descriptor_no_audio sink;
+ struct usb_ss_ep_comp_descriptor sink_comp;
+ struct usb_endpoint_descriptor_no_audio source;
+ struct usb_ss_ep_comp_descriptor source_comp;
+ struct usb_endpoint_descriptor_no_audio intr;
+ struct usb_ss_ep_comp_descriptor intr_comp;
+} __attribute__((packed));
+
+struct desc_v1 {
+ struct usb_functionfs_descs_head_v1 {
+ __le32 magic;
+ __le32 length;
+ __le32 fs_count;
+ __le32 hs_count;
+ } __attribute__((packed)) header;
+ struct func_desc fs_descs, hs_descs;
+} __attribute__((packed));
+
+struct desc_v2 {
+ struct usb_functionfs_descs_head_v2 header;
+ // The rest of the structure depends on the flags in the header.
+ __le32 fs_count;
+ __le32 hs_count;
+ __le32 ss_count;
+ struct func_desc fs_descs, hs_descs;
+ struct ss_func_desc ss_descs;
+} __attribute__((packed));
+
+const struct usb_interface_descriptor mtp_interface_desc = {
+ .bLength = USB_DT_INTERFACE_SIZE,
+ .bDescriptorType = USB_DT_INTERFACE,
+ .bInterfaceNumber = 0,
+ .bNumEndpoints = 3,
+ .bInterfaceClass = USB_CLASS_STILL_IMAGE,
+ .bInterfaceSubClass = 1,
+ .bInterfaceProtocol = 1,
+ .iInterface = 1,
+};
+
+const struct usb_interface_descriptor ptp_interface_desc = {
+ .bLength = USB_DT_INTERFACE_SIZE,
+ .bDescriptorType = USB_DT_INTERFACE,
+ .bInterfaceNumber = 0,
+ .bNumEndpoints = 3,
+ .bInterfaceClass = USB_CLASS_STILL_IMAGE,
+ .bInterfaceSubClass = 1,
+ .bInterfaceProtocol = 1,
+};
+
+const struct usb_endpoint_descriptor_no_audio fs_sink = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 1 | USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = MAX_PACKET_SIZE_FS,
+};
+
+const struct usb_endpoint_descriptor_no_audio fs_source = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 2 | USB_DIR_OUT,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = MAX_PACKET_SIZE_FS,
+};
+
+const struct usb_endpoint_descriptor_no_audio fs_intr = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 3 | USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_INT,
+ .wMaxPacketSize = MAX_PACKET_SIZE_FS,
+ .bInterval = 6,
+};
+
+const struct usb_endpoint_descriptor_no_audio hs_sink = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 1 | USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = MAX_PACKET_SIZE_HS,
+};
+
+const struct usb_endpoint_descriptor_no_audio hs_source = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 2 | USB_DIR_OUT,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = MAX_PACKET_SIZE_HS,
+};
+
+const struct usb_endpoint_descriptor_no_audio hs_intr = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 3 | USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_INT,
+ .wMaxPacketSize = MAX_PACKET_SIZE_HS,
+ .bInterval = 6,
+};
+
+const struct usb_endpoint_descriptor_no_audio ss_sink = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 1 | USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = MAX_PACKET_SIZE_SS,
+};
+
+const struct usb_endpoint_descriptor_no_audio ss_source = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 2 | USB_DIR_OUT,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = MAX_PACKET_SIZE_SS,
+};
+
+const struct usb_endpoint_descriptor_no_audio ss_intr = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 3 | USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_INT,
+ .wMaxPacketSize = MAX_PACKET_SIZE_SS,
+ .bInterval = 6,
+};
+
+const struct usb_ss_ep_comp_descriptor ss_sink_comp = {
+ .bLength = sizeof(ss_sink_comp),
+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+ .bMaxBurst = 6,
+};
+
+const struct usb_ss_ep_comp_descriptor ss_source_comp = {
+ .bLength = sizeof(ss_source_comp),
+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+ .bMaxBurst = 6,
+};
+
+const struct usb_ss_ep_comp_descriptor ss_intr_comp = {
+ .bLength = sizeof(ss_intr_comp),
+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+};
+
+const struct func_desc mtp_fs_descriptors = {
+ .intf = mtp_interface_desc,
+ .sink = fs_sink,
+ .source = fs_source,
+ .intr = fs_intr,
+};
+
+const struct func_desc mtp_hs_descriptors = {
+ .intf = mtp_interface_desc,
+ .sink = hs_sink,
+ .source = hs_source,
+ .intr = hs_intr,
+};
+
+const struct ss_func_desc mtp_ss_descriptors = {
+ .intf = mtp_interface_desc,
+ .sink = ss_sink,
+ .sink_comp = ss_sink_comp,
+ .source = ss_source,
+ .source_comp = ss_source_comp,
+ .intr = ss_intr,
+ .intr_comp = ss_intr_comp,
+};
+
+const struct func_desc ptp_fs_descriptors = {
+ .intf = ptp_interface_desc,
+ .sink = fs_sink,
+ .source = fs_source,
+ .intr = fs_intr,
+};
+
+const struct func_desc ptp_hs_descriptors = {
+ .intf = ptp_interface_desc,
+ .sink = hs_sink,
+ .source = hs_source,
+ .intr = hs_intr,
+};
+
+const struct ss_func_desc ptp_ss_descriptors = {
+ .intf = ptp_interface_desc,
+ .sink = ss_sink,
+ .sink_comp = ss_sink_comp,
+ .source = ss_source,
+ .source_comp = ss_source_comp,
+ .intr = ss_intr,
+ .intr_comp = ss_intr_comp,
+};
+
+#define STR_INTERFACE "MTP"
+const struct {
+ struct usb_functionfs_strings_head header;
+ struct {
+ __le16 code;
+ const char str1[sizeof(STR_INTERFACE)];
+ } __attribute__((packed)) lang0;
+} __attribute__((packed)) strings = {
+ .header = {
+ .magic = cpu_to_le32(FUNCTIONFS_STRINGS_MAGIC),
+ .length = cpu_to_le32(sizeof(strings)),
+ .str_count = cpu_to_le32(1),
+ .lang_count = cpu_to_le32(1),
+ },
+ .lang0 = {
+ .code = cpu_to_le16(0x0409),
+ .str1 = STR_INTERFACE,
+ },
+};
+
+} // anonymous namespace
+
+namespace android {
+
+MtpFfsHandle::MtpFfsHandle() :
+ mMaxWrite(USB_FFS_MAX_WRITE),
+ mMaxRead(USB_FFS_MAX_READ) {}
+
+MtpFfsHandle::~MtpFfsHandle() {}
+
+void MtpFfsHandle::closeEndpoints() {
+ mIntr.reset();
+ mBulkIn.reset();
+ mBulkOut.reset();
+}
+
+bool MtpFfsHandle::initFunctionfs() {
+ ssize_t ret;
+ struct desc_v1 v1_descriptor;
+ struct desc_v2 v2_descriptor;
+
+ v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2);
+ v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor));
+ v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC |
+ FUNCTIONFS_HAS_SS_DESC;
+ v2_descriptor.fs_count = 4;
+ v2_descriptor.hs_count = 4;
+ v2_descriptor.ss_count = 7;
+ v2_descriptor.fs_descs = mPtp ? ptp_fs_descriptors : mtp_fs_descriptors;
+ v2_descriptor.hs_descs = mPtp ? ptp_hs_descriptors : mtp_hs_descriptors;
+ v2_descriptor.ss_descs = mPtp ? ptp_ss_descriptors : mtp_ss_descriptors;
+
+ if (mControl < 0) { // might have already done this before
+ mControl.reset(TEMP_FAILURE_RETRY(open(FFS_MTP_EP0, O_RDWR)));
+ if (mControl < 0) {
+ PLOG(ERROR) << FFS_MTP_EP0 << ": cannot open control endpoint";
+ goto err;
+ }
+
+ ret = TEMP_FAILURE_RETRY(::write(mControl, &v2_descriptor, sizeof(v2_descriptor)));
+ if (ret < 0) {
+ v1_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC);
+ v1_descriptor.header.length = cpu_to_le32(sizeof(v1_descriptor));
+ v1_descriptor.header.fs_count = 4;
+ v1_descriptor.header.hs_count = 4;
+ v1_descriptor.fs_descs = mPtp ? ptp_fs_descriptors : mtp_fs_descriptors;
+ v1_descriptor.hs_descs = mPtp ? ptp_hs_descriptors : mtp_hs_descriptors;
+ PLOG(ERROR) << FFS_MTP_EP0 << "Switching to V1 descriptor format";
+ ret = TEMP_FAILURE_RETRY(::write(mControl, &v1_descriptor, sizeof(v1_descriptor)));
+ if (ret < 0) {
+ PLOG(ERROR) << FFS_MTP_EP0 << "Writing descriptors failed";
+ goto err;
+ }
+ }
+ ret = TEMP_FAILURE_RETRY(::write(mControl, &strings, sizeof(strings)));
+ if (ret < 0) {
+ PLOG(ERROR) << FFS_MTP_EP0 << "Writing strings failed";
+ goto err;
+ }
+ }
+ if (mBulkIn > -1 || mBulkOut > -1 || mIntr > -1)
+ LOG(WARNING) << "Endpoints were not closed before configure!";
+
+ return true;
+
+err:
+ closeConfig();
+ return false;
+}
+
+void MtpFfsHandle::closeConfig() {
+ mControl.reset();
+}
+
+int MtpFfsHandle::writeHandle(int fd, const void* data, int len) {
+ LOG(VERBOSE) << "MTP about to write fd = " << fd << ", len=" << len;
+ int ret = 0;
+ const char* buf = static_cast<const char*>(data);
+ while (len > 0) {
+ int write_len = std::min(mMaxWrite, len);
+ int n = TEMP_FAILURE_RETRY(::write(fd, buf, write_len));
+
+ if (n < 0) {
+ PLOG(ERROR) << "write ERROR: fd = " << fd << ", n = " << n;
+ return -1;
+ } else if (n < write_len) {
+ errno = EIO;
+ PLOG(ERROR) << "less written than expected";
+ return -1;
+ }
+ buf += n;
+ len -= n;
+ ret += n;
+ }
+ return ret;
+}
+
+int MtpFfsHandle::readHandle(int fd, void* data, int len) {
+ LOG(VERBOSE) << "MTP about to read fd = " << fd << ", len=" << len;
+ int ret = 0;
+ char* buf = static_cast<char*>(data);
+ while (len > 0) {
+ int read_len = std::min(mMaxRead, len);
+ int n = TEMP_FAILURE_RETRY(::read(fd, buf, read_len));
+ if (n < 0) {
+ PLOG(ERROR) << "read ERROR: fd = " << fd << ", n = " << n;
+ return -1;
+ }
+ ret += n;
+ if (n < read_len) // done reading early
+ break;
+ buf += n;
+ len -= n;
+ }
+ return ret;
+}
+
+int MtpFfsHandle::spliceReadHandle(int fd, int pipe_out, int len) {
+ LOG(VERBOSE) << "MTP about to splice read fd = " << fd << ", len=" << len;
+ int ret = 0;
+ loff_t dummyoff;
+ while (len > 0) {
+ int read_len = std::min(mMaxRead, len);
+ dummyoff = 0;
+ int n = TEMP_FAILURE_RETRY(splice(fd, &dummyoff, pipe_out, nullptr, read_len, 0));
+ if (n < 0) {
+ PLOG(ERROR) << "splice read ERROR: fd = " << fd << ", n = " << n;
+ return -1;
+ }
+ ret += n;
+ if (n < read_len) // done reading early
+ break;
+ len -= n;
+ }
+ return ret;
+}
+
+int MtpFfsHandle::read(void* data, int len) {
+ return readHandle(mBulkOut, data, len);
+}
+
+int MtpFfsHandle::write(const void* data, int len) {
+ return writeHandle(mBulkIn, data, len);
+}
+
+int MtpFfsHandle::start() {
+ mLock.lock();
+
+ mBulkIn.reset(TEMP_FAILURE_RETRY(open(FFS_MTP_EP_IN, O_RDWR)));
+ if (mBulkIn < 0) {
+ PLOG(ERROR) << FFS_MTP_EP_IN << ": cannot open bulk in ep";
+ return -1;
+ }
+
+ mBulkOut.reset(TEMP_FAILURE_RETRY(open(FFS_MTP_EP_OUT, O_RDWR)));
+ if (mBulkOut < 0) {
+ PLOG(ERROR) << FFS_MTP_EP_OUT << ": cannot open bulk out ep";
+ return -1;
+ }
+
+ mIntr.reset(TEMP_FAILURE_RETRY(open(FFS_MTP_EP_INTR, O_RDWR)));
+ if (mIntr < 0) {
+ PLOG(ERROR) << FFS_MTP_EP0 << ": cannot open intr ep";
+ return -1;
+ }
+
+ mBuffer1.resize(MAX_FILE_CHUNK_SIZE);
+ mBuffer2.resize(MAX_FILE_CHUNK_SIZE);
+ posix_madvise(mBuffer1.data(), MAX_FILE_CHUNK_SIZE,
+ POSIX_MADV_SEQUENTIAL | POSIX_MADV_WILLNEED);
+ posix_madvise(mBuffer2.data(), MAX_FILE_CHUNK_SIZE,
+ POSIX_MADV_SEQUENTIAL | POSIX_MADV_WILLNEED);
+
+ // Get device specific r/w size
+ mMaxWrite = android::base::GetIntProperty("sys.usb.ffs.max_write", USB_FFS_MAX_WRITE);
+ mMaxRead = android::base::GetIntProperty("sys.usb.ffs.max_read", USB_FFS_MAX_READ);
+
+ size_t attempts = 0;
+ while (mMaxWrite >= USB_FFS_MAX_WRITE && mMaxRead >= USB_FFS_MAX_READ &&
+ attempts < ENDPOINT_ALLOC_RETRIES) {
+ // If larger contiguous chunks of memory aren't available, attempt to try
+ // smaller allocations.
+ if (ioctl(mBulkIn, FUNCTIONFS_ENDPOINT_ALLOC, static_cast<__u32>(mMaxWrite)) ||
+ ioctl(mBulkOut, FUNCTIONFS_ENDPOINT_ALLOC, static_cast<__u32>(mMaxRead))) {
+ if (errno == ENODEV) {
+ // Driver hasn't enabled endpoints yet.
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ attempts += 1;
+ continue;
+ }
+ mMaxWrite /= 2;
+ mMaxRead /=2;
+ } else {
+ return 0;
+ }
+ }
+ // Try to start MtpServer anyway, with the smallest max r/w values
+ PLOG(ERROR) << "Functionfs could not allocate any memory!";
+ return 0;
+}
+
+int MtpFfsHandle::configure(bool usePtp) {
+ // Wait till previous server invocation has closed
+ std::lock_guard<std::mutex> lk(mLock);
+
+ // If ptp is changed, the configuration must be rewritten
+ if (mPtp != usePtp) {
+ closeEndpoints();
+ closeConfig();
+ }
+ mPtp = usePtp;
+
+ if (!initFunctionfs()) {
+ return -1;
+ }
+
+ return 0;
+}
+
+void MtpFfsHandle::close() {
+ closeEndpoints();
+ mLock.unlock();
+}
+
+/* Read from USB and write to a local file. */
+int MtpFfsHandle::receiveFile(mtp_file_range mfr) {
+ // When receiving files, the incoming length is given in 32 bits.
+ // A >4G file is given as 0xFFFFFFFF
+ uint32_t file_length = mfr.length;
+ uint64_t offset = lseek(mfr.fd, 0, SEEK_CUR);
+
+ char *data = mBuffer1.data();
+ char *data2 = mBuffer2.data();
+
+ struct aiocb aio;
+ aio.aio_fildes = mfr.fd;
+ aio.aio_buf = nullptr;
+ struct aiocb *aiol[] = {&aio};
+ int ret;
+ size_t length;
+ bool read = false;
+ bool write = false;
+
+ posix_fadvise(mfr.fd, 0, 0, POSIX_FADV_SEQUENTIAL | POSIX_FADV_NOREUSE);
+
+ // Break down the file into pieces that fit in buffers
+ while (file_length > 0 || write) {
+ if (file_length > 0) {
+ length = std::min(static_cast<uint32_t>(MAX_FILE_CHUNK_SIZE), file_length);
+
+ // Read data from USB
+ if ((ret = readHandle(mBulkOut, data, length)) == -1) {
+ return -1;
+ }
+
+ if (file_length != MAX_MTP_FILE_SIZE && ret < static_cast<int>(length)) {
+ errno = EIO;
+ return -1;
+ }
+ read = true;
+ }
+
+ if (write) {
+ // get the return status of the last write request
+ aio_suspend(aiol, 1, nullptr);
+
+ int written = aio_return(&aio);
+ if (written == -1) {
+ errno = aio_error(&aio);
+ return -1;
+ }
+ if (static_cast<size_t>(written) < aio.aio_nbytes) {
+ errno = EIO;
+ return -1;
+ }
+ write = false;
+ }
+
+ if (read) {
+ // Enqueue a new write request
+ aio.aio_buf = data;
+ aio.aio_sink = mfr.fd;
+ aio.aio_offset = offset;
+ aio.aio_nbytes = ret;
+ aio_write(&aio);
+
+ if (file_length == MAX_MTP_FILE_SIZE) {
+ // For larger files, receive until a short packet is received.
+ if (static_cast<size_t>(ret) < length) {
+ file_length = 0;
+ }
+ } else {
+ file_length -= ret;
+ }
+
+ offset += ret;
+ std::swap(data, data2);
+
+ write = true;
+ read = false;
+ }
+ }
+ return 0;
+}
+
+/* Read from a local file and send over USB. */
+int MtpFfsHandle::sendFile(mtp_file_range mfr) {
+ uint64_t file_length = mfr.length;
+ uint32_t given_length = std::min(static_cast<uint64_t>(MAX_MTP_FILE_SIZE),
+ file_length + sizeof(mtp_data_header));
+ uint64_t offset = mfr.offset;
+ struct usb_endpoint_descriptor mBulkIn_desc;
+ int packet_size;
+
+ if (ioctl(mBulkIn, FUNCTIONFS_ENDPOINT_DESC, reinterpret_cast<unsigned long>(&mBulkIn_desc))) {
+ PLOG(ERROR) << "Could not get FFS bulk-in descriptor";
+ packet_size = MAX_PACKET_SIZE_HS;
+ } else {
+ packet_size = mBulkIn_desc.wMaxPacketSize;
+ }
+
+ // If file_length is larger than a size_t, truncating would produce the wrong comparison.
+ // Instead, promote the left side to 64 bits, then truncate the small result.
+ int init_read_len = std::min(
+ static_cast<uint64_t>(packet_size - sizeof(mtp_data_header)), file_length);
+
+ char *data = mBuffer1.data();
+ char *data2 = mBuffer2.data();
+
+ posix_fadvise(mfr.fd, 0, 0, POSIX_FADV_SEQUENTIAL | POSIX_FADV_NOREUSE);
+
+ struct aiocb aio;
+ aio.aio_fildes = mfr.fd;
+ struct aiocb *aiol[] = {&aio};
+ int ret, length;
+ bool read = false;
+ bool write = false;
+
+ // Send the header data
+ mtp_data_header *header = reinterpret_cast<mtp_data_header*>(data);
+ header->length = __cpu_to_le32(given_length);
+ header->type = __cpu_to_le16(2); /* data packet */
+ header->command = __cpu_to_le16(mfr.command);
+ header->transaction_id = __cpu_to_le32(mfr.transaction_id);
+
+ // Some hosts don't support header/data separation even though MTP allows it
+ // Handle by filling first packet with initial file data
+ if (TEMP_FAILURE_RETRY(pread(mfr.fd, reinterpret_cast<char*>(data) +
+ sizeof(mtp_data_header), init_read_len, offset))
+ != init_read_len) return -1;
+ if (writeHandle(mBulkIn, data, sizeof(mtp_data_header) + init_read_len) == -1) return -1;
+ if (file_length == static_cast<unsigned>(init_read_len)) return 0;
+ file_length -= init_read_len;
+ offset += init_read_len;
+ ret = 0;
+
+ // Break down the file into pieces that fit in buffers
+ while(file_length > 0) {
+ if (read) {
+ // Wait for the previous read to finish
+ aio_suspend(aiol, 1, nullptr);
+ ret = aio_return(&aio);
+ if (ret == -1) {
+ errno = aio_error(&aio);
+ return -1;
+ }
+ if (static_cast<size_t>(ret) < aio.aio_nbytes) {
+ errno = EIO;
+ return -1;
+ }
+
+ file_length -= ret;
+ offset += ret;
+ std::swap(data, data2);
+ read = false;
+ write = true;
+ }
+
+ if (file_length > 0) {
+ length = std::min(static_cast<uint64_t>(MAX_FILE_CHUNK_SIZE), file_length);
+ // Queue up another read
+ aio.aio_buf = data;
+ aio.aio_offset = offset;
+ aio.aio_nbytes = length;
+ aio_read(&aio);
+ read = true;
+ }
+
+ if (write) {
+ if (writeHandle(mBulkIn, data2, ret) == -1)
+ return -1;
+ write = false;
+ }
+ }
+
+ if (given_length == MAX_MTP_FILE_SIZE && ret % packet_size == 0) {
+ // If the last packet wasn't short, send a final empty packet
+ if (writeHandle(mBulkIn, data, 0) == -1) return -1;
+ }
+
+ return 0;
+}
+
+int MtpFfsHandle::sendEvent(mtp_event me) {
+ unsigned length = me.length;
+ int ret = writeHandle(mIntr, me.data, length);
+ return static_cast<unsigned>(ret) == length ? 0 : -1;
+}
+
+} // namespace android
+
+IMtpHandle *get_ffs_handle() {
+ return new android::MtpFfsHandle();
+}
+
diff --git a/media/mtp/MtpFfsHandle.h b/media/mtp/MtpFfsHandle.h
new file mode 100644
index 0000000..b4d5a97
--- /dev/null
+++ b/media/mtp/MtpFfsHandle.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef _MTP_FFS_HANDLE_H
+#define _MTP_FFS_HANDLE_H
+
+#include <android-base/unique_fd.h>
+#include <IMtpHandle.h>
+
+namespace android {
+
+class MtpFfsHandleTest;
+
+class MtpFfsHandle : public IMtpHandle {
+ friend class android::MtpFfsHandleTest;
+private:
+ int writeHandle(int fd, const void *data, int len);
+ int readHandle(int fd, void *data, int len);
+ int spliceReadHandle(int fd, int fd_out, int len);
+ bool initFunctionfs();
+ void closeConfig();
+ void closeEndpoints();
+
+ bool mPtp;
+
+ std::mutex mLock;
+
+ android::base::unique_fd mControl;
+ // "in" from the host's perspective => sink for mtp server
+ android::base::unique_fd mBulkIn;
+ // "out" from the host's perspective => source for mtp server
+ android::base::unique_fd mBulkOut;
+ android::base::unique_fd mIntr;
+
+ int mMaxWrite;
+ int mMaxRead;
+
+ std::vector<char> mBuffer1;
+ std::vector<char> mBuffer2;
+
+public:
+ int read(void *data, int len);
+ int write(const void *data, int len);
+
+ int receiveFile(mtp_file_range mfr);
+ int sendFile(mtp_file_range mfr);
+ int sendEvent(mtp_event me);
+
+ /**
+ * Open ffs endpoints and allocate necessary kernel and user memory.
+ * Will sleep until endpoints are enabled, for up to 1 second.
+ */
+ int start();
+ void close();
+
+ int configure(bool ptp);
+
+ MtpFfsHandle();
+ ~MtpFfsHandle();
+};
+
+struct mtp_data_header {
+ /* length of packet, including this header */
+ __le32 length;
+ /* container type (2 for data packet) */
+ __le16 type;
+ /* MTP command code */
+ __le16 command;
+ /* MTP transaction ID */
+ __le32 transaction_id;
+};
+
+} // namespace android
+
+#endif // _MTP_FF_HANDLE_H
+
diff --git a/media/mtp/MtpObjectInfo.h b/media/mtp/MtpObjectInfo.h
index 86780f1..188f21c 100644
--- a/media/mtp/MtpObjectInfo.h
+++ b/media/mtp/MtpObjectInfo.h
@@ -47,7 +47,7 @@
char* mKeywords;
public:
- MtpObjectInfo(MtpObjectHandle handle);
+ explicit MtpObjectInfo(MtpObjectHandle handle);
virtual ~MtpObjectInfo();
bool read(MtpDataPacket& packet);
diff --git a/media/mtp/MtpPacket.h b/media/mtp/MtpPacket.h
index 0e96309..d47c91d 100644
--- a/media/mtp/MtpPacket.h
+++ b/media/mtp/MtpPacket.h
@@ -17,6 +17,8 @@
#ifndef _MTP_PACKET_H
#define _MTP_PACKET_H
+#include <android-base/macros.h>
+
#include "MtpTypes.h"
struct usb_device;
@@ -36,7 +38,7 @@
size_t mPacketSize;
public:
- MtpPacket(int bufferSize);
+ explicit MtpPacket(int bufferSize);
virtual ~MtpPacket();
// sets packet size to the default container size and sets buffer to zero
@@ -66,6 +68,8 @@
uint32_t getUInt32(int offset) const;
void putUInt16(int offset, uint16_t value);
void putUInt32(int offset, uint32_t value);
+
+ DISALLOW_COPY_AND_ASSIGN(MtpPacket);
};
}; // namespace android
diff --git a/media/mtp/MtpRequestPacket.cpp b/media/mtp/MtpRequestPacket.cpp
index 471967f..e0e86a9 100644
--- a/media/mtp/MtpRequestPacket.cpp
+++ b/media/mtp/MtpRequestPacket.cpp
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include <fcntl.h>
+#include "IMtpHandle.h"
#include "MtpRequestPacket.h"
#include <usbhost/usbhost.h>
@@ -36,8 +37,8 @@
}
#ifdef MTP_DEVICE
-int MtpRequestPacket::read(int fd) {
- int ret = ::read(fd, mBuffer, mBufferSize);
+int MtpRequestPacket::read(IMtpHandle *h) {
+ int ret = h->read(mBuffer, mBufferSize);
if (ret < 0) {
// file read error
return ret;
diff --git a/media/mtp/MtpRequestPacket.h b/media/mtp/MtpRequestPacket.h
index 79b798d..d1dc0ff 100644
--- a/media/mtp/MtpRequestPacket.h
+++ b/media/mtp/MtpRequestPacket.h
@@ -20,6 +20,7 @@
#include "MtpPacket.h"
#include "mtp.h"
+class IMtpHandle;
struct usb_request;
namespace android {
@@ -31,8 +32,8 @@
virtual ~MtpRequestPacket();
#ifdef MTP_DEVICE
- // fill our buffer with data from the given file descriptor
- int read(int fd);
+ // fill our buffer with data from the given usb handle
+ int read(IMtpHandle *h);
#endif
#ifdef MTP_HOST
diff --git a/media/mtp/MtpResponsePacket.cpp b/media/mtp/MtpResponsePacket.cpp
index c2b41e4..f186b37 100644
--- a/media/mtp/MtpResponsePacket.cpp
+++ b/media/mtp/MtpResponsePacket.cpp
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include <fcntl.h>
+#include "IMtpHandle.h"
#include "MtpResponsePacket.h"
#include <usbhost/usbhost.h>
@@ -35,10 +36,10 @@
}
#ifdef MTP_DEVICE
-int MtpResponsePacket::write(int fd) {
+int MtpResponsePacket::write(IMtpHandle *h) {
putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_RESPONSE);
- int ret = ::write(fd, mBuffer, mPacketSize);
+ int ret = h->write(mBuffer, mPacketSize);
return (ret < 0 ? ret : 0);
}
#endif
diff --git a/media/mtp/MtpResponsePacket.h b/media/mtp/MtpResponsePacket.h
index 592ad4a..29a72ba 100644
--- a/media/mtp/MtpResponsePacket.h
+++ b/media/mtp/MtpResponsePacket.h
@@ -20,6 +20,8 @@
#include "MtpPacket.h"
#include "mtp.h"
+class IMtpHandle;
+
namespace android {
class MtpResponsePacket : public MtpPacket {
@@ -29,8 +31,8 @@
virtual ~MtpResponsePacket();
#ifdef MTP_DEVICE
- // write our data to the given file descriptor
- int write(int fd);
+ // write our data to the given usb handle
+ int write(IMtpHandle *h);
#endif
#ifdef MTP_HOST
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index e39dcdd..b773e8a 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -14,18 +14,18 @@
* limitations under the License.
*/
+#include <android-base/properties.h>
+#include <chrono>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
-#include <sys/ioctl.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <errno.h>
#include <sys/stat.h>
-#include <dirent.h>
-
-#include <cutils/properties.h>
+#include <sys/time.h>
#define LOG_TAG "MtpServer"
@@ -37,8 +37,6 @@
#include "MtpStorage.h"
#include "MtpStringBuffer.h"
-#include <linux/usb/f_mtp.h>
-
namespace android {
static const MtpOperationCode kSupportedOperationCodes[] = {
@@ -57,7 +55,7 @@
MTP_OPERATION_SEND_OBJECT,
// MTP_OPERATION_INITIATE_CAPTURE,
// MTP_OPERATION_FORMAT_STORE,
-// MTP_OPERATION_RESET_DEVICE,
+ MTP_OPERATION_RESET_DEVICE,
// MTP_OPERATION_SELF_TEST,
// MTP_OPERATION_SET_OBJECT_PROTECTION,
// MTP_OPERATION_POWER_DOWN,
@@ -97,25 +95,48 @@
MTP_EVENT_DEVICE_PROP_CHANGED,
};
-MtpServer::MtpServer(int fd, MtpDatabase* database, bool ptp,
- int fileGroup, int filePerm, int directoryPerm)
- : mFD(fd),
- mDatabase(database),
+MtpServer::MtpServer(MtpDatabase* database, bool ptp,
+ int fileGroup, int filePerm, int directoryPerm,
+ const MtpString& deviceInfoManufacturer,
+ const MtpString& deviceInfoModel,
+ const MtpString& deviceInfoDeviceVersion,
+ const MtpString& deviceInfoSerialNumber)
+ : mDatabase(database),
mPtp(ptp),
mFileGroup(fileGroup),
mFilePermission(filePerm),
mDirectoryPermission(directoryPerm),
+ mDeviceInfoManufacturer(deviceInfoManufacturer),
+ mDeviceInfoModel(deviceInfoModel),
+ mDeviceInfoDeviceVersion(deviceInfoDeviceVersion),
+ mDeviceInfoSerialNumber(deviceInfoSerialNumber),
mSessionID(0),
mSessionOpen(false),
mSendObjectHandle(kInvalidObjectHandle),
mSendObjectFormat(0),
- mSendObjectFileSize(0)
+ mSendObjectFileSize(0),
+ mSendObjectModifiedTime(0)
{
}
MtpServer::~MtpServer() {
}
+IMtpHandle* MtpServer::sHandle = nullptr;
+
+int MtpServer::configure(bool usePtp) {
+ if (sHandle == nullptr) {
+ bool ffs_ok = access(FFS_MTP_EP0, W_OK) == 0;
+ sHandle = ffs_ok ? get_ffs_handle() : get_mtp_handle();
+ }
+
+ int ret = sHandle->configure(usePtp);
+ if (ret) ALOGE("Failed to configure MTP driver!");
+ else android::base::SetProperty("sys.usb.ffs.mtp.ready", "1");
+
+ return ret;
+}
+
void MtpServer::addStorage(MtpStorage* storage) {
Mutex::Autolock autoLock(mMutex);
@@ -143,24 +164,31 @@
if (storage->getStorageID() == id)
return storage;
}
- return NULL;
+ return nullptr;
}
bool MtpServer::hasStorage(MtpStorageID id) {
if (id == 0 || id == 0xFFFFFFFF)
return mStorages.size() > 0;
- return (getStorage(id) != NULL);
+ return (getStorage(id) != nullptr);
}
void MtpServer::run() {
- int fd = mFD;
+ if (!sHandle) {
+ ALOGE("MtpServer was never configured!");
+ return;
+ }
- ALOGV("MtpServer::run fd: %d\n", fd);
+ if (sHandle->start()) {
+ ALOGE("Failed to start usb driver!");
+ sHandle->close();
+ return;
+ }
while (1) {
- int ret = mRequest.read(fd);
+ int ret = mRequest.read(sHandle);
if (ret < 0) {
- ALOGV("request read returned %d, errno: %d", ret, errno);
+ ALOGE("request read returned %d, errno: %d", ret, errno);
if (errno == ECANCELED) {
// return to top of loop and wait for next command
continue;
@@ -171,15 +199,13 @@
MtpTransactionID transaction = mRequest.getTransactionID();
ALOGV("operation: %s", MtpDebug::getOperationCodeName(operation));
- mRequest.dump();
-
// FIXME need to generalize this
bool dataIn = (operation == MTP_OPERATION_SEND_OBJECT_INFO
|| operation == MTP_OPERATION_SET_OBJECT_REFERENCES
|| operation == MTP_OPERATION_SET_OBJECT_PROP_VALUE
|| operation == MTP_OPERATION_SET_DEVICE_PROP_VALUE);
if (dataIn) {
- int ret = mData.read(fd);
+ int ret = mData.read(sHandle);
if (ret < 0) {
ALOGE("data read returned %d, errno: %d", ret, errno);
if (errno == ECANCELED) {
@@ -189,7 +215,6 @@
break;
}
ALOGV("received data:");
- mData.dump();
} else {
mData.reset();
}
@@ -199,8 +224,7 @@
mData.setOperationCode(operation);
mData.setTransactionID(transaction);
ALOGV("sending data:");
- mData.dump();
- ret = mData.write(fd);
+ ret = mData.write(sHandle);
if (ret < 0) {
ALOGE("request write returned %d, errno: %d", ret, errno);
if (errno == ECANCELED) {
@@ -213,9 +237,8 @@
mResponse.setTransactionID(transaction);
ALOGV("sending response %04X", mResponse.getResponseCode());
- ret = mResponse.write(fd);
+ ret = mResponse.write(sHandle);
const int savedErrno = errno;
- mResponse.dump();
if (ret < 0) {
ALOGE("request write returned %d, errno: %d", ret, errno);
if (savedErrno == ECANCELED) {
@@ -240,8 +263,8 @@
if (mSessionOpen)
mDatabase->sessionEnded();
- close(fd);
- mFD = -1;
+
+ sHandle->close();
}
void MtpServer::sendObjectAdded(MtpObjectHandle handle) {
@@ -274,8 +297,8 @@
mEvent.setEventCode(code);
mEvent.setTransactionID(mRequest.getTransactionID());
mEvent.setParameter(1, param1);
- int ret = mEvent.write(mFD);
- ALOGV("mEvent.write returned %d\n", ret);
+ if (mEvent.write(sHandle))
+ ALOGE("Mtp send event failed: %s", strerror(errno));
}
}
@@ -291,7 +314,7 @@
ObjectEdit* edit = mObjectEditList[i];
if (edit->mHandle == handle) return edit;
}
- return NULL;
+ return nullptr;
}
void MtpServer::removeEditObject(MtpObjectHandle handle) {
@@ -341,6 +364,7 @@
case MTP_OPERATION_OPEN_SESSION:
response = doOpenSession();
break;
+ case MTP_OPERATION_RESET_DEVICE:
case MTP_OPERATION_CLOSE_SESSION:
response = doCloseSession();
break;
@@ -438,7 +462,6 @@
MtpResponseCode MtpServer::doGetDeviceInfo() {
MtpStringBuffer string;
- char prop_value[PROPERTY_VALUE_MAX];
MtpObjectFormatList* playbackFormats = mDatabase->getSupportedPlaybackFormats();
MtpObjectFormatList* captureFormats = mDatabase->getSupportedCaptureFormats();
@@ -470,19 +493,10 @@
mData.putAUInt16(captureFormats); // Capture Formats
mData.putAUInt16(playbackFormats); // Playback Formats
- property_get("ro.product.manufacturer", prop_value, "unknown manufacturer");
- string.set(prop_value);
- mData.putString(string); // Manufacturer
-
- property_get("ro.product.model", prop_value, "MTP Device");
- string.set(prop_value);
- mData.putString(string); // Model
- string.set("1.0");
- mData.putString(string); // Device Version
-
- property_get("ro.serialno", prop_value, "????????");
- string.set(prop_value);
- mData.putString(string); // Serial Number
+ mData.putString(mDeviceInfoManufacturer); // Manufacturer
+ mData.putString(mDeviceInfoModel); // Model
+ mData.putString(mDeviceInfoDeviceVersion); // Device Version
+ mData.putString(mDeviceInfoSerialNumber); // Serial Number
delete playbackFormats;
delete captureFormats;
@@ -775,6 +789,8 @@
if (result != MTP_RESPONSE_OK)
return result;
+ auto start = std::chrono::steady_clock::now();
+
const char* filePath = (const char *)pathBuf;
mtp_file_range mfr;
mfr.fd = open(filePath, O_RDONLY);
@@ -787,8 +803,9 @@
mfr.transaction_id = mRequest.getTransactionID();
// then transfer the file
- int ret = ioctl(mFD, MTP_SEND_FILE_WITH_HEADER, (unsigned long)&mfr);
+ int ret = sHandle->sendFile(mfr);
if (ret < 0) {
+ ALOGE("Mtp send file got error %s", strerror(errno));
if (errno == ECANCELED) {
result = MTP_RESPONSE_TRANSACTION_CANCELLED;
} else {
@@ -798,7 +815,13 @@
result = MTP_RESPONSE_OK;
}
- ALOGV("MTP_SEND_FILE_WITH_HEADER returned %d\n", ret);
+ auto end = std::chrono::steady_clock::now();
+ std::chrono::duration<double> diff = end - start;
+ struct stat sstat;
+ fstat(mfr.fd, &sstat);
+ uint64_t finalsize = sstat.st_size;
+ ALOGV("Sent a file over MTP. Time: %f s, Size: %" PRIu64 ", Rate: %f bytes/s",
+ diff.count(), finalsize, ((double) finalsize) / diff.count());
close(mfr.fd);
return result;
}
@@ -813,7 +836,7 @@
// send data
mData.setOperationCode(mRequest.getOperationCode());
mData.setTransactionID(mRequest.getTransactionID());
- mData.writeData(mFD, thumb, thumbSize);
+ mData.writeData(sHandle, thumb, thumbSize);
free(thumb);
return MTP_RESPONSE_OK;
} else {
@@ -867,7 +890,7 @@
mResponse.setParameter(1, length);
// transfer the file
- int ret = ioctl(mFD, MTP_SEND_FILE_WITH_HEADER, (unsigned long)&mfr);
+ int ret = sHandle->sendFile(mfr);
ALOGV("MTP_SEND_FILE_WITH_HEADER returned %d\n", ret);
result = MTP_RESPONSE_OK;
if (ret < 0) {
@@ -978,6 +1001,7 @@
// save the handle for the SendObject call, which should follow
mSendObjectHandle = handle;
mSendObjectFormat = format;
+ mSendObjectModifiedTime = modifiedTime;
}
mResponse.setParameter(1, storageID);
@@ -994,6 +1018,9 @@
mode_t mask;
int ret, initialData;
bool isCanceled = false;
+ struct stat sstat = {};
+
+ auto start = std::chrono::steady_clock::now();
if (mSendObjectHandle == kInvalidObjectHandle) {
ALOGE("Expected SendObjectInfo before SendObject");
@@ -1002,7 +1029,7 @@
}
// read the header, and possibly some data
- ret = mData.read(mFD);
+ ret = mData.read(sHandle);
if (ret < MTP_CONTAINER_HEADER_SIZE) {
result = MTP_RESPONSE_GENERAL_ERROR;
goto done;
@@ -1038,19 +1065,32 @@
mfr.length = mSendObjectFileSize - initialData;
}
- ALOGV("receiving %s\n", (const char *)mSendObjectFilePath);
+ mfr.command = 0;
+ mfr.transaction_id = 0;
+
// transfer the file
- ret = ioctl(mFD, MTP_RECEIVE_FILE, (unsigned long)&mfr);
+ ret = sHandle->receiveFile(mfr);
if ((ret < 0) && (errno == ECANCELED)) {
isCanceled = true;
}
-
- ALOGV("MTP_RECEIVE_FILE returned %d\n", ret);
}
}
+
+ if (mSendObjectModifiedTime) {
+ struct timespec newTime[2];
+ newTime[0].tv_nsec = UTIME_NOW;
+ newTime[1].tv_sec = mSendObjectModifiedTime;
+ newTime[1].tv_nsec = 0;
+ if (futimens(mfr.fd, newTime) < 0) {
+ ALOGW("changing modified time failed, %s", strerror(errno));
+ }
+ }
+
+ fstat(mfr.fd, &sstat);
close(mfr.fd);
if (ret < 0) {
+ ALOGE("Mtp receive file got error %s", strerror(errno));
unlink(mSendObjectFilePath);
if (isCanceled)
result = MTP_RESPONSE_TRANSACTION_CANCELLED;
@@ -1066,6 +1106,13 @@
result == MTP_RESPONSE_OK);
mSendObjectHandle = kInvalidObjectHandle;
mSendObjectFormat = 0;
+ mSendObjectModifiedTime = 0;
+
+ auto end = std::chrono::steady_clock::now();
+ std::chrono::duration<double> diff = end - start;
+ uint64_t finalsize = sstat.st_size;
+ ALOGV("Got a file over MTP. Time: %fs, Size: %" PRIu64 ", Rate: %f bytes/s",
+ diff.count(), finalsize, ((double) finalsize) / diff.count());
return result;
}
@@ -1209,7 +1256,7 @@
ALOGV("receiving partial %s %" PRIu64 " %" PRIu32, filePath, offset, length);
// read the header, and possibly some data
- int ret = mData.read(mFD);
+ int ret = mData.read(sHandle);
if (ret < MTP_CONTAINER_HEADER_SIZE)
return MTP_RESPONSE_GENERAL_ERROR;
int initialData = ret - MTP_CONTAINER_HEADER_SIZE;
@@ -1229,13 +1276,14 @@
mfr.fd = edit->mFD;
mfr.offset = offset;
mfr.length = length;
+ mfr.command = 0;
+ mfr.transaction_id = 0;
// transfer the file
- ret = ioctl(mFD, MTP_RECEIVE_FILE, (unsigned long)&mfr);
+ ret = sHandle->receiveFile(mfr);
if ((ret < 0) && (errno == ECANCELED)) {
isCanceled = true;
}
- ALOGV("MTP_RECEIVE_FILE returned %d", ret);
}
}
if (ret < 0) {
diff --git a/media/mtp/MtpServer.h b/media/mtp/MtpServer.h
index b3a11e0..08a9e4a 100644
--- a/media/mtp/MtpServer.h
+++ b/media/mtp/MtpServer.h
@@ -23,8 +23,12 @@
#include "MtpEventPacket.h"
#include "mtp.h"
#include "MtpUtils.h"
+#include "IMtpHandle.h"
#include <utils/threads.h>
+#include <queue>
+#include <memory>
+#include <mutex>
namespace android {
@@ -34,9 +38,6 @@
class MtpServer {
private:
- // file descriptor for MTP kernel driver
- int mFD;
-
MtpDatabase* mDatabase;
// appear as a PTP device
@@ -48,6 +49,15 @@
int mFilePermission;
int mDirectoryPermission;
+ // Manufacturer to report in DeviceInfo
+ MtpString mDeviceInfoManufacturer;
+ // Model to report in DeviceInfo
+ MtpString mDeviceInfoModel;
+ // Device version to report in DeviceInfo
+ MtpString mDeviceInfoDeviceVersion;
+ // Serial number to report in DeviceInfo
+ MtpString mDeviceInfoSerialNumber;
+
// current session ID
MtpSessionID mSessionID;
// true if we have an open session and mSessionID is valid
@@ -56,15 +66,19 @@
MtpRequestPacket mRequest;
MtpDataPacket mData;
MtpResponsePacket mResponse;
+
MtpEventPacket mEvent;
MtpStorageList mStorages;
+ static IMtpHandle* sHandle;
+
// handle for new object, set by SendObjectInfo and used by SendObject
MtpObjectHandle mSendObjectHandle;
MtpObjectFormat mSendObjectFormat;
MtpString mSendObjectFilePath;
size_t mSendObjectFileSize;
+ time_t mSendObjectModifiedTime;
Mutex mMutex;
@@ -90,8 +104,12 @@
Vector<ObjectEdit*> mObjectEditList;
public:
- MtpServer(int fd, MtpDatabase* database, bool ptp,
- int fileGroup, int filePerm, int directoryPerm);
+ MtpServer(MtpDatabase* database, bool ptp,
+ int fileGroup, int filePerm, int directoryPerm,
+ const MtpString& deviceInfoManufacturer,
+ const MtpString& deviceInfoModel,
+ const MtpString& deviceInfoDeviceVersion,
+ const MtpString& deviceInfoSerialNumber);
virtual ~MtpServer();
MtpStorage* getStorage(MtpStorageID id);
@@ -100,6 +118,7 @@
void addStorage(MtpStorage* storage);
void removeStorage(MtpStorage* storage);
+ static int configure(bool usePtp);
void run();
void sendObjectAdded(MtpObjectHandle handle);
diff --git a/media/mtp/MtpStorageInfo.h b/media/mtp/MtpStorageInfo.h
index 35a8189..3b70675 100644
--- a/media/mtp/MtpStorageInfo.h
+++ b/media/mtp/MtpStorageInfo.h
@@ -36,7 +36,7 @@
char* mVolumeIdentifier;
public:
- MtpStorageInfo(MtpStorageID id);
+ explicit MtpStorageInfo(MtpStorageID id);
virtual ~MtpStorageInfo();
bool read(MtpDataPacket& packet);
diff --git a/media/mtp/MtpStringBuffer.h b/media/mtp/MtpStringBuffer.h
index 85d91e8..bcf2a48 100644
--- a/media/mtp/MtpStringBuffer.h
+++ b/media/mtp/MtpStringBuffer.h
@@ -38,8 +38,8 @@
public:
MtpStringBuffer();
- MtpStringBuffer(const char* src);
- MtpStringBuffer(const uint16_t* src);
+ explicit MtpStringBuffer(const char* src);
+ explicit MtpStringBuffer(const uint16_t* src);
MtpStringBuffer(const MtpStringBuffer& src);
virtual ~MtpStringBuffer();
diff --git a/media/mtp/tests/Android.bp b/media/mtp/tests/Android.bp
new file mode 100644
index 0000000..356406d
--- /dev/null
+++ b/media/mtp/tests/Android.bp
@@ -0,0 +1,45 @@
+//
+// 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.
+//
+
+cc_test {
+ name: "mtp_ffs_handle_test",
+ srcs: ["MtpFfsHandle_test.cpp"],
+ shared_libs: [
+ "libbase",
+ "libmtp",
+ "liblog",
+ ],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+}
+
+cc_test {
+ name: "async_io_test",
+ srcs: ["AsyncIO_test.cpp"],
+ shared_libs: [
+ "libbase",
+ "libmtp",
+ "liblog",
+ ],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+}
diff --git a/media/mtp/tests/AsyncIO_test.cpp b/media/mtp/tests/AsyncIO_test.cpp
new file mode 100644
index 0000000..b5f4538
--- /dev/null
+++ b/media/mtp/tests/AsyncIO_test.cpp
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2016 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.
+ */
+#define LOG_TAG "AsyncIO_test.cpp"
+
+#include <android-base/test_utils.h>
+#include <fcntl.h>
+#include <gtest/gtest.h>
+#include <string>
+#include <unistd.h>
+#include <utils/Log.h>
+
+#include "AsyncIO.h"
+
+namespace android {
+
+constexpr int TEST_PACKET_SIZE = 512;
+constexpr int POOL_COUNT = 10;
+
+static const std::string dummyDataStr =
+ "/*\n * Copyright 2015 The Android Open Source Project\n *\n * Licensed un"
+ "der the Apache License, Version 2.0 (the \"License\");\n * you may not us"
+ "e this file except in compliance with the License.\n * You may obtain a c"
+ "opy of the License at\n *\n * http://www.apache.org/licenses/LICENSE"
+ "-2.0\n *\n * Unless required by applicable law or agreed to in writing, s"
+ "oftware\n * distributed under the License is distributed on an \"AS IS\" "
+ "BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express o"
+ "r implied.\n * Se";
+
+
+class AsyncIOTest : public ::testing::Test {
+protected:
+ TemporaryFile dummy_file;
+
+ AsyncIOTest() {}
+ ~AsyncIOTest() {}
+};
+
+TEST_F(AsyncIOTest, testRead) {
+ char buf[TEST_PACKET_SIZE + 1];
+ buf[TEST_PACKET_SIZE] = '\0';
+ EXPECT_EQ(write(dummy_file.fd, dummyDataStr.c_str(), TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ struct aiocb aio;
+ struct aiocb *aiol[] = {&aio};
+ aio.aio_fildes = dummy_file.fd;
+ aio.aio_buf = buf;
+ aio.aio_offset = 0;
+ aio.aio_nbytes = TEST_PACKET_SIZE;
+
+ EXPECT_EQ(aio_read(&aio), 0);
+ EXPECT_EQ(aio_suspend(aiol, 1, nullptr), 0);
+ EXPECT_EQ(aio_return(&aio), TEST_PACKET_SIZE);
+ EXPECT_STREQ(buf, dummyDataStr.c_str());
+}
+
+TEST_F(AsyncIOTest, testWrite) {
+ char buf[TEST_PACKET_SIZE + 1];
+ buf[TEST_PACKET_SIZE] = '\0';
+ struct aiocb aio;
+ struct aiocb *aiol[] = {&aio};
+ aio.aio_fildes = dummy_file.fd;
+ aio.aio_buf = const_cast<char*>(dummyDataStr.c_str());
+ aio.aio_offset = 0;
+ aio.aio_nbytes = TEST_PACKET_SIZE;
+
+ EXPECT_EQ(aio_write(&aio), 0);
+ EXPECT_EQ(aio_suspend(aiol, 1, nullptr), 0);
+ EXPECT_EQ(aio_return(&aio), TEST_PACKET_SIZE);
+ EXPECT_EQ(read(dummy_file.fd, buf, TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ EXPECT_STREQ(buf, dummyDataStr.c_str());
+}
+
+TEST_F(AsyncIOTest, testError) {
+ char buf[TEST_PACKET_SIZE + 1];
+ buf[TEST_PACKET_SIZE] = '\0';
+ struct aiocb aio;
+ struct aiocb *aiol[] = {&aio};
+ aio.aio_fildes = -1;
+ aio.aio_buf = const_cast<char*>(dummyDataStr.c_str());
+ aio.aio_offset = 0;
+ aio.aio_nbytes = TEST_PACKET_SIZE;
+
+ EXPECT_EQ(aio_write(&aio), 0);
+ EXPECT_EQ(aio_suspend(aiol, 1, nullptr), 0);
+ EXPECT_EQ(aio_return(&aio), -1);
+ EXPECT_EQ(aio_error(&aio), EBADF);
+}
+
+TEST_F(AsyncIOTest, testSpliceRead) {
+ char buf[TEST_PACKET_SIZE + 1];
+ buf[TEST_PACKET_SIZE] = '\0';
+ int pipeFd[2];
+ EXPECT_EQ(pipe(pipeFd), 0);
+ EXPECT_EQ(write(dummy_file.fd, dummyDataStr.c_str(), TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ struct aiocb aio;
+ struct aiocb *aiol[] = {&aio};
+ aio.aio_fildes = dummy_file.fd;
+ aio.aio_sink = pipeFd[1];
+ aio.aio_offset = 0;
+ aio.aio_nbytes = TEST_PACKET_SIZE;
+
+ EXPECT_EQ(aio_splice_read(&aio), 0);
+ EXPECT_EQ(aio_suspend(aiol, 1, nullptr), 0);
+ EXPECT_EQ(aio_return(&aio), TEST_PACKET_SIZE);
+
+ EXPECT_EQ(read(pipeFd[0], buf, TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ EXPECT_STREQ(buf, dummyDataStr.c_str());
+}
+
+TEST_F(AsyncIOTest, testSpliceWrite) {
+ char buf[TEST_PACKET_SIZE + 1];
+ buf[TEST_PACKET_SIZE] = '\0';
+ int pipeFd[2];
+ EXPECT_EQ(pipe(pipeFd), 0);
+ EXPECT_EQ(write(pipeFd[1], dummyDataStr.c_str(), TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ struct aiocb aio;
+ struct aiocb *aiol[] = {&aio};
+ aio.aio_fildes = pipeFd[0];
+ aio.aio_sink = dummy_file.fd;
+ aio.aio_offset = 0;
+ aio.aio_nbytes = TEST_PACKET_SIZE;
+
+ EXPECT_EQ(aio_splice_write(&aio), 0);
+ EXPECT_EQ(aio_suspend(aiol, 1, nullptr), 0);
+ EXPECT_EQ(aio_return(&aio), TEST_PACKET_SIZE);
+ EXPECT_EQ(read(dummy_file.fd, buf, TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ EXPECT_STREQ(buf, dummyDataStr.c_str());
+}
+
+TEST_F(AsyncIOTest, testPoolWrite) {
+ aio_pool_write_init();
+ char buf[TEST_PACKET_SIZE * POOL_COUNT + 1];
+ buf[TEST_PACKET_SIZE * POOL_COUNT] = '\0';
+
+ for (int i = 0; i < POOL_COUNT; i++) {
+ struct aiocb *aiop = new struct aiocb;
+ aiop->aio_fildes = dummy_file.fd;
+ aiop->aio_pool_buf = std::unique_ptr<char[]>(new char[TEST_PACKET_SIZE]);
+ memcpy(aiop->aio_pool_buf.get(), dummyDataStr.c_str(), TEST_PACKET_SIZE);
+ aiop->aio_offset = i * TEST_PACKET_SIZE;
+ aiop->aio_nbytes = TEST_PACKET_SIZE;
+ EXPECT_EQ(aio_pool_write(aiop), 0);
+ }
+ aio_pool_end();
+ EXPECT_EQ(read(dummy_file.fd, buf, TEST_PACKET_SIZE * POOL_COUNT), TEST_PACKET_SIZE * POOL_COUNT);
+
+ std::stringstream ss;
+ for (int i = 0; i < POOL_COUNT; i++)
+ ss << dummyDataStr;
+
+ EXPECT_STREQ(buf, ss.str().c_str());
+}
+
+TEST_F(AsyncIOTest, testSplicePoolWrite) {
+ aio_pool_splice_init();
+ char buf[TEST_PACKET_SIZE * POOL_COUNT + 1];
+ buf[TEST_PACKET_SIZE * POOL_COUNT] = '\0';
+
+ for (int i = 0; i < POOL_COUNT; i++) {
+ int pipeFd[2];
+ EXPECT_EQ(pipe(pipeFd), 0);
+ EXPECT_EQ(write(pipeFd[1], dummyDataStr.c_str(), TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ struct aiocb *aiop = new struct aiocb;
+ aiop->aio_fildes = pipeFd[0];
+ aiop->aio_sink = dummy_file.fd;
+ aiop->aio_offset = i * TEST_PACKET_SIZE;
+ aiop->aio_nbytes = TEST_PACKET_SIZE;
+ EXPECT_EQ(aio_pool_write(aiop), 0);
+ }
+ aio_pool_end();
+ EXPECT_EQ(read(dummy_file.fd, buf, TEST_PACKET_SIZE * POOL_COUNT), TEST_PACKET_SIZE * POOL_COUNT);
+
+ std::stringstream ss;
+ for (int i = 0; i < POOL_COUNT; i++)
+ ss << dummyDataStr;
+
+ EXPECT_STREQ(buf, ss.str().c_str());
+}
+
+} // namespace android
diff --git a/media/mtp/tests/MtpFfsHandle_test.cpp b/media/mtp/tests/MtpFfsHandle_test.cpp
new file mode 100644
index 0000000..e575148
--- /dev/null
+++ b/media/mtp/tests/MtpFfsHandle_test.cpp
@@ -0,0 +1,280 @@
+/*
+ * Copyright 2016 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.
+ */
+#define LOG_TAG "MtpFfsHandle_test.cpp"
+
+#include <android-base/unique_fd.h>
+#include <android-base/test_utils.h>
+#include <fcntl.h>
+#include <gtest/gtest.h>
+#include <memory>
+#include <random>
+#include <string>
+#include <unistd.h>
+#include <utils/Log.h>
+
+#include "MtpFfsHandle.h"
+
+namespace android {
+
+constexpr int MAX_FILE_CHUNK_SIZE = 3 * 1024 * 1024;
+
+constexpr int TEST_PACKET_SIZE = 512;
+constexpr int SMALL_MULT = 30;
+constexpr int MED_MULT = 510;
+
+static const std::string dummyDataStr =
+ "/*\n * Copyright 2015 The Android Open Source Project\n *\n * Licensed un"
+ "der the Apache License, Version 2.0 (the \"License\");\n * you may not us"
+ "e this file except in compliance with the License.\n * You may obtain a c"
+ "opy of the License at\n *\n * http://www.apache.org/licenses/LICENSE"
+ "-2.0\n *\n * Unless required by applicable law or agreed to in writing, s"
+ "oftware\n * distributed under the License is distributed on an \"AS IS\" "
+ "BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express o"
+ "r implied.\n * Se";
+
+/**
+ * Functional tests for the MtpFfsHandle class. Ensures header and data integrity
+ * by mocking ffs endpoints as pipes to capture input / output.
+ */
+class MtpFfsHandleTest : public ::testing::Test {
+protected:
+ std::unique_ptr<IMtpHandle> handle;
+
+ // Pipes for reading endpoint data
+ android::base::unique_fd bulk_in;
+ android::base::unique_fd bulk_out;
+ android::base::unique_fd intr;
+
+ TemporaryFile dummy_file;
+
+ MtpFfsHandleTest() {
+ int fd[2];
+ handle = std::unique_ptr<IMtpHandle>(get_ffs_handle());
+ MtpFfsHandle *ffs_handle = static_cast<MtpFfsHandle*>(handle.get());
+ EXPECT_TRUE(ffs_handle != NULL);
+
+ EXPECT_EQ(pipe(fd), 0);
+ EXPECT_EQ(fcntl(fd[0], F_SETPIPE_SZ, 1048576), 1048576);
+ bulk_in.reset(fd[0]);
+ ffs_handle->mBulkIn.reset(fd[1]);
+
+ EXPECT_EQ(pipe(fd), 0);
+ EXPECT_EQ(fcntl(fd[0], F_SETPIPE_SZ, 1048576), 1048576);
+ bulk_out.reset(fd[1]);
+ ffs_handle->mBulkOut.reset(fd[0]);
+
+ EXPECT_EQ(pipe(fd), 0);
+ intr.reset(fd[0]);
+ ffs_handle->mIntr.reset(fd[1]);
+
+ ffs_handle->mBuffer1.resize(MAX_FILE_CHUNK_SIZE);
+ ffs_handle->mBuffer2.resize(MAX_FILE_CHUNK_SIZE);
+ }
+
+ ~MtpFfsHandleTest() {}
+};
+
+TEST_F(MtpFfsHandleTest, testRead) {
+ EXPECT_EQ(write(bulk_out, dummyDataStr.c_str(), TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ char buf[TEST_PACKET_SIZE + 1];
+ buf[TEST_PACKET_SIZE] = '\0';
+ EXPECT_EQ(handle->read(buf, TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ EXPECT_STREQ(buf, dummyDataStr.c_str());
+}
+
+TEST_F(MtpFfsHandleTest, testWrite) {
+ char buf[TEST_PACKET_SIZE + 1];
+ buf[TEST_PACKET_SIZE] = '\0';
+ EXPECT_EQ(handle->write(dummyDataStr.c_str(), TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ EXPECT_EQ(read(bulk_in, buf, TEST_PACKET_SIZE), TEST_PACKET_SIZE);
+ EXPECT_STREQ(buf, dummyDataStr.c_str());
+}
+
+TEST_F(MtpFfsHandleTest, testReceiveFileSmall) {
+ std::stringstream ss;
+ mtp_file_range mfr;
+ int size = TEST_PACKET_SIZE * SMALL_MULT;
+ char buf[size + 1];
+ buf[size] = '\0';
+
+ mfr.length = size;
+ mfr.fd = dummy_file.fd;
+ for (int i = 0; i < SMALL_MULT; i++)
+ ss << dummyDataStr;
+
+ EXPECT_EQ(write(bulk_out, ss.str().c_str(), size), size);
+ EXPECT_EQ(handle->receiveFile(mfr), 0);
+
+ EXPECT_EQ(read(dummy_file.fd, buf, size), size);
+
+ EXPECT_STREQ(buf, ss.str().c_str());
+}
+
+TEST_F(MtpFfsHandleTest, testReceiveFileMed) {
+ std::stringstream ss;
+ mtp_file_range mfr;
+ int size = TEST_PACKET_SIZE * MED_MULT;
+ char buf[size + 1];
+ buf[size] = '\0';
+
+ mfr.length = size;
+ mfr.fd = dummy_file.fd;
+ for (int i = 0; i < MED_MULT; i++)
+ ss << dummyDataStr;
+
+ EXPECT_EQ(write(bulk_out, ss.str().c_str(), size), size);
+ EXPECT_EQ(handle->receiveFile(mfr), 0);
+
+ EXPECT_EQ(read(dummy_file.fd, buf, size), size);
+
+ EXPECT_STREQ(buf, ss.str().c_str());
+}
+
+TEST_F(MtpFfsHandleTest, testSendFileSmall) {
+ std::stringstream ss;
+ mtp_file_range mfr;
+ mfr.command = 42;
+ mfr.transaction_id = 1337;
+ mfr.offset = 0;
+ int size = TEST_PACKET_SIZE * SMALL_MULT;
+ char buf[size + sizeof(mtp_data_header) + 1];
+ buf[size + sizeof(mtp_data_header)] = '\0';
+
+ mfr.length = size;
+ mfr.fd = dummy_file.fd;
+ for (int i = 0; i < SMALL_MULT; i++)
+ ss << dummyDataStr;
+
+ EXPECT_EQ(write(dummy_file.fd, ss.str().c_str(), size), size);
+ EXPECT_EQ(handle->sendFile(mfr), 0);
+
+ EXPECT_EQ(read(bulk_in, buf, size + sizeof(mtp_data_header)),
+ static_cast<long>(size + sizeof(mtp_data_header)));
+
+ struct mtp_data_header *header = reinterpret_cast<struct mtp_data_header*>(buf);
+ EXPECT_STREQ(buf + sizeof(mtp_data_header), ss.str().c_str());
+ EXPECT_EQ(header->length, static_cast<unsigned int>(size + sizeof(mtp_data_header)));
+ EXPECT_EQ(header->type, static_cast<unsigned int>(2));
+ EXPECT_EQ(header->command, static_cast<unsigned int>(42));
+ EXPECT_EQ(header->transaction_id, static_cast<unsigned int>(1337));
+}
+
+TEST_F(MtpFfsHandleTest, testSendFileMed) {
+ std::stringstream ss;
+ mtp_file_range mfr;
+ mfr.command = 42;
+ mfr.transaction_id = 1337;
+ mfr.offset = 0;
+ int size = TEST_PACKET_SIZE * MED_MULT;
+ char buf[size + sizeof(mtp_data_header) + 1];
+ buf[size + sizeof(mtp_data_header)] = '\0';
+
+ mfr.length = size;
+ mfr.fd = dummy_file.fd;
+ for (int i = 0; i < MED_MULT; i++)
+ ss << dummyDataStr;
+
+ EXPECT_EQ(write(dummy_file.fd, ss.str().c_str(), size), size);
+ EXPECT_EQ(handle->sendFile(mfr), 0);
+
+ EXPECT_EQ(read(bulk_in, buf, size + sizeof(mtp_data_header)),
+ static_cast<long>(size + sizeof(mtp_data_header)));
+
+ struct mtp_data_header *header = reinterpret_cast<struct mtp_data_header*>(buf);
+ EXPECT_STREQ(buf + sizeof(mtp_data_header), ss.str().c_str());
+ EXPECT_EQ(header->length, static_cast<unsigned int>(size + sizeof(mtp_data_header)));
+ EXPECT_EQ(header->type, static_cast<unsigned int>(2));
+ EXPECT_EQ(header->command, static_cast<unsigned int>(42));
+ EXPECT_EQ(header->transaction_id, static_cast<unsigned int>(1337));
+}
+
+TEST_F(MtpFfsHandleTest, testSendFileMedPartial) {
+ std::stringstream ss;
+ mtp_file_range mfr;
+ mfr.fd = dummy_file.fd;
+ mfr.command = 42;
+ mfr.transaction_id = 1337;
+ int size = TEST_PACKET_SIZE * MED_MULT;
+ char buf[size + 1];
+ buf[size] = '\0';
+
+ for (int i = 0; i < MED_MULT; i++)
+ ss << dummyDataStr;
+
+ EXPECT_EQ(write(dummy_file.fd, ss.str().c_str(), size), size);
+
+ std::random_device rd;
+ std::mt19937 gen(rd());
+ std::uniform_int_distribution<> dis(1, TEST_PACKET_SIZE);
+ int offset = 0;
+ while (offset != size) {
+ mfr.offset = offset;
+ int length = std::min(size - offset, dis(gen));
+ mfr.length = length;
+ char temp_buf[length + sizeof(mtp_data_header)];
+ EXPECT_EQ(handle->sendFile(mfr), 0);
+
+ EXPECT_EQ(read(bulk_in, temp_buf, length + sizeof(mtp_data_header)),
+ static_cast<long>(length + sizeof(mtp_data_header)));
+
+ struct mtp_data_header *header = reinterpret_cast<struct mtp_data_header*>(temp_buf);
+ EXPECT_EQ(header->length, static_cast<unsigned int>(length + sizeof(mtp_data_header)));
+ EXPECT_EQ(header->type, static_cast<unsigned int>(2));
+ EXPECT_EQ(header->command, static_cast<unsigned int>(42));
+ EXPECT_EQ(header->transaction_id, static_cast<unsigned int>(1337));
+ memcpy(buf + offset, temp_buf + sizeof(mtp_data_header), length);
+ offset += length;
+ }
+ EXPECT_STREQ(buf, ss.str().c_str());
+}
+
+TEST_F(MtpFfsHandleTest, testSendFileEmpty) {
+ mtp_file_range mfr;
+ mfr.command = 42;
+ mfr.transaction_id = 1337;
+ mfr.offset = 0;
+ int size = 0;
+ char buf[size + sizeof(mtp_data_header) + 1];
+ buf[size + sizeof(mtp_data_header)] = '\0';
+
+ mfr.length = size;
+ mfr.fd = dummy_file.fd;
+
+ EXPECT_EQ(handle->sendFile(mfr), 0);
+
+ EXPECT_EQ(read(bulk_in, buf, size + sizeof(mtp_data_header)),
+ static_cast<long>(size + sizeof(mtp_data_header)));
+
+ struct mtp_data_header *header = reinterpret_cast<struct mtp_data_header*>(buf);
+ EXPECT_EQ(header->length, static_cast<unsigned int>(size + sizeof(mtp_data_header)));
+ EXPECT_EQ(header->type, static_cast<unsigned int>(2));
+ EXPECT_EQ(header->command, static_cast<unsigned int>(42));
+ EXPECT_EQ(header->transaction_id, static_cast<unsigned int>(1337));
+}
+
+TEST_F(MtpFfsHandleTest, testSendEvent) {
+ struct mtp_event event;
+ event.length = TEST_PACKET_SIZE;
+ event.data = const_cast<char*>(dummyDataStr.c_str());
+ char buf[TEST_PACKET_SIZE + 1];
+ buf[TEST_PACKET_SIZE] = '\0';
+
+ handle->sendEvent(event);
+ read(intr, buf, TEST_PACKET_SIZE);
+ EXPECT_STREQ(buf, dummyDataStr.c_str());
+}
+
+} // namespace android
diff --git a/media/ndk/Android.bp b/media/ndk/Android.bp
new file mode 100644
index 0000000..1aeb38f
--- /dev/null
+++ b/media/ndk/Android.bp
@@ -0,0 +1,84 @@
+// Copyright (C) 2016 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.
+
+// Headers module is in frameworks/av/Android.bp because modules are not allowed
+// to refer to headers in parent directories and the headers live in
+// frameworks/av/include.
+
+ndk_library {
+ name: "libmediandk",
+ symbol_file: "libmediandk.map.txt",
+ first_version: "21",
+ unversioned_until: "current",
+}
+
+ndk_headers {
+ name: "libmediandk_headers",
+ from: "include/media",
+ to: "media",
+ srcs: ["include/media/**/*.h"],
+ license: "NOTICE",
+}
+
+cc_library_shared {
+ name: "libmediandk",
+
+ srcs: [
+ "NdkMediaCodec.cpp",
+ "NdkMediaCrypto.cpp",
+ "NdkMediaExtractor.cpp",
+ "NdkMediaFormat.cpp",
+ "NdkMediaMuxer.cpp",
+ "NdkMediaDrm.cpp",
+ "NdkImage.cpp",
+ "NdkImageReader.cpp",
+ ],
+
+ include_dirs: [
+ "bionic/libc/private",
+ "frameworks/base/core/jni",
+ "system/media/camera/include",
+ ],
+
+ cflags: [
+ "-fvisibility=hidden",
+ "-DEXPORT=__attribute__((visibility(\"default\")))",
+
+ "-Werror",
+ "-Wall",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ "libmedia",
+ "libmediadrm",
+ "libstagefright",
+ "libstagefright_foundation",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "libandroid_runtime",
+ "libbinder",
+ "libgui",
+ "libui",
+ ],
+
+ export_include_dirs: ["include"],
+
+ product_variables: {
+ pdk: {
+ enabled: false,
+ },
+ },
+}
diff --git a/media/ndk/Android.mk b/media/ndk/Android.mk
deleted file mode 100644
index 74729e4..0000000
--- a/media/ndk/Android.mk
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifneq ($(TARGET_BUILD_PDK), true)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- NdkMediaCodec.cpp \
- NdkMediaCrypto.cpp \
- NdkMediaExtractor.cpp \
- NdkMediaFormat.cpp \
- NdkMediaMuxer.cpp \
- NdkMediaDrm.cpp \
- NdkImage.cpp \
- NdkImageReader.cpp \
-
-LOCAL_MODULE:= libmediandk
-
-LOCAL_C_INCLUDES := \
- bionic/libc/private \
- frameworks/base/core/jni \
- frameworks/av/include/ndk \
- system/media/camera/include
-
-LOCAL_CFLAGS += -fvisibility=hidden -D EXPORT='__attribute__ ((visibility ("default")))'
-
-LOCAL_CFLAGS += -Werror -Wall
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libmedia \
- libmediadrm \
- libstagefright \
- libstagefright_foundation \
- liblog \
- libutils \
- libcutils \
- libandroid_runtime \
- libbinder \
- libgui \
- libui \
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif
diff --git a/media/ndk/NOTICE b/media/ndk/NOTICE
new file mode 100644
index 0000000..152be20
--- /dev/null
+++ b/media/ndk/NOTICE
@@ -0,0 +1,324 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Android-specific code. ==
+ =========================================================================
+
+Android Code
+Copyright 2005-2008 The Android Open Source Project
+
+This product includes software developed as part of
+The Android Open Source Project (http://source.android.com).
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for Apache Commons code. ==
+ =========================================================================
+
+Apache Commons
+Copyright 1999-2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for Jakarta Commons Logging. ==
+ =========================================================================
+
+Jakarta Commons Logging (JCL)
+Copyright 2005,2006 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Nuance code. ==
+ =========================================================================
+
+These files are Copyright 2007 Nuance Communications, but released under
+the Apache2 License.
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Media Codecs code. ==
+ =========================================================================
+
+Media Codecs
+These files are Copyright 1998 - 2009 PacketVideo, but released under
+the Apache2 License.
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the TagSoup code. ==
+ =========================================================================
+
+This file is part of TagSoup and is Copyright 2002-2008 by John Cowan.
+
+TagSoup is licensed under the Apache License,
+Version 2.0. You may obtain a copy of this license at
+http://www.apache.org/licenses/LICENSE-2.0 . You may also have
+additional legal rights not granted by this license.
+
+TagSoup is distributed in the hope that it will be useful, but
+unless required by applicable law or agreed to in writing, TagSoup
+is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, either express or implied; not even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for Additional Codecs code. ==
+ =========================================================================
+
+Additional Codecs
+These files are Copyright 2003-2010 VisualOn, but released under
+the Apache2 License.
+
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Audio Effects code. ==
+ =========================================================================
+
+Audio Effects
+These files are Copyright (C) 2004-2010 NXP Software and
+Copyright (C) 2010 The Android Open Source Project, but released under
+the Apache2 License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+
+
+UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
+
+Unicode Data Files include all data files under the directories
+http://www.unicode.org/Public/, http://www.unicode.org/reports/,
+and http://www.unicode.org/cldr/data/ . Unicode Software includes any
+source code published in the Unicode Standard or under the directories
+http://www.unicode.org/Public/, http://www.unicode.org/reports/, and
+http://www.unicode.org/cldr/data/.
+
+NOTICE TO USER: Carefully read the following legal agreement. BY
+DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA
+FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY
+ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF
+THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY,
+DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
+
+COPYRIGHT AND PERMISSION NOTICE
+
+Copyright © 1991-2008 Unicode, Inc. All rights reserved. Distributed
+under the Terms of Use in http://www.unicode.org/copyright.html.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Unicode data files and any associated documentation (the
+"Data Files") or Unicode software and any associated documentation (the
+"Software") to deal in the Data Files or Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, and/or sell copies of the Data Files or Software,
+and to permit persons to whom the Data Files or Software are furnished to
+do so, provided that (a) the above copyright notice(s) and this permission
+notice appear with all copies of the Data Files or Software, (b) both the
+above copyright notice(s) and this permission notice appear in associated
+documentation, and (c) there is clear notice in each modified Data File
+or in the Software as well as in the documentation associated with the
+Data File(s) or Software that the data or software has been modified.
+
+THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in these Data Files or Software without prior written
+authorization of the copyright holder.
diff --git a/media/ndk/NdkImagePriv.h b/media/ndk/NdkImagePriv.h
index 89d2b7c..197cacd 100644
--- a/media/ndk/NdkImagePriv.h
+++ b/media/ndk/NdkImagePriv.h
@@ -24,7 +24,7 @@
#include <gui/CpuConsumer.h>
#include "NdkImageReaderPriv.h"
-#include "NdkImage.h"
+#include <media/NdkImage.h>
using namespace android;
diff --git a/media/ndk/NdkImageReader.cpp b/media/ndk/NdkImageReader.cpp
index 30aa7fb..d470cb0 100644
--- a/media/ndk/NdkImageReader.cpp
+++ b/media/ndk/NdkImageReader.cpp
@@ -41,6 +41,11 @@
bool
AImageReader::isSupportedFormat(int32_t format) {
switch (format) {
+ case AIMAGE_FORMAT_RGBA_8888:
+ case AIMAGE_FORMAT_RGBX_8888:
+ case AIMAGE_FORMAT_RGB_888:
+ case AIMAGE_FORMAT_RGB_565:
+ case AIMAGE_FORMAT_RGBA_FP16:
case AIMAGE_FORMAT_YUV_420_888:
case AIMAGE_FORMAT_JPEG:
case AIMAGE_FORMAT_RAW16:
@@ -60,6 +65,11 @@
switch (format) {
case AIMAGE_FORMAT_YUV_420_888:
return 3;
+ case AIMAGE_FORMAT_RGBA_8888:
+ case AIMAGE_FORMAT_RGBX_8888:
+ case AIMAGE_FORMAT_RGB_888:
+ case AIMAGE_FORMAT_RGB_565:
+ case AIMAGE_FORMAT_RGBA_FP16:
case AIMAGE_FORMAT_JPEG:
case AIMAGE_FORMAT_RAW16:
case AIMAGE_FORMAT_RAW_PRIVATE:
diff --git a/media/ndk/NdkImageReaderPriv.h b/media/ndk/NdkImageReaderPriv.h
index 48f0953..f4c1187 100644
--- a/media/ndk/NdkImageReaderPriv.h
+++ b/media/ndk/NdkImageReaderPriv.h
@@ -19,7 +19,7 @@
#include <inttypes.h>
-#include "NdkImageReader.h"
+#include <media/NdkImageReader.h>
#include <utils/List.h>
#include <utils/Mutex.h>
@@ -112,7 +112,7 @@
struct FrameListener : public ConsumerBase::FrameAvailableListener {
public:
- FrameListener(AImageReader* parent) : mReader(parent) {}
+ explicit FrameListener(AImageReader* parent) : mReader(parent) {}
void onFrameAvailable(const BufferItem& item) override;
diff --git a/media/ndk/NdkMediaCodec.cpp b/media/ndk/NdkMediaCodec.cpp
index 50b490d..6229982 100644
--- a/media/ndk/NdkMediaCodec.cpp
+++ b/media/ndk/NdkMediaCodec.cpp
@@ -19,8 +19,8 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "NdkMediaCodec"
-#include "NdkMediaCodec.h"
-#include "NdkMediaError.h"
+#include <media/NdkMediaCodec.h>
+#include <media/NdkMediaError.h>
#include "NdkMediaCryptoPriv.h"
#include "NdkMediaFormatPriv.h"
@@ -59,7 +59,7 @@
private:
AMediaCodec* mCodec;
public:
- CodecHandler(AMediaCodec *codec);
+ explicit CodecHandler(AMediaCodec *codec);
virtual void onMessageReceived(const sp<AMessage> &msg);
};
diff --git a/media/ndk/NdkMediaCrypto.cpp b/media/ndk/NdkMediaCrypto.cpp
index 32aabdd..d7193ca 100644
--- a/media/ndk/NdkMediaCrypto.cpp
+++ b/media/ndk/NdkMediaCrypto.cpp
@@ -18,8 +18,8 @@
#define LOG_TAG "NdkMediaCrypto"
-#include "NdkMediaCrypto.h"
-#include "NdkMediaCodec.h"
+#include <media/NdkMediaCrypto.h>
+#include <media/NdkMediaCodec.h>
#include "NdkMediaFormatPriv.h"
diff --git a/media/ndk/NdkMediaDrm.cpp b/media/ndk/NdkMediaDrm.cpp
index 166e6f1..2c20e51 100644
--- a/media/ndk/NdkMediaDrm.cpp
+++ b/media/ndk/NdkMediaDrm.cpp
@@ -17,7 +17,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "NdkMediaDrm"
-#include "NdkMediaDrm.h"
+#include <media/NdkMediaDrm.h>
#include <cutils/properties.h>
#include <utils/Log.h>
@@ -29,7 +29,7 @@
#include <media/stagefright/MediaErrors.h>
#include <binder/IServiceManager.h>
#include <media/IMediaDrmService.h>
-#include <ndk/NdkMediaCrypto.h>
+#include <media/NdkMediaCrypto.h>
using namespace android;
diff --git a/media/ndk/NdkMediaExtractor.cpp b/media/ndk/NdkMediaExtractor.cpp
index 89f2d9c..e677d00 100644
--- a/media/ndk/NdkMediaExtractor.cpp
+++ b/media/ndk/NdkMediaExtractor.cpp
@@ -18,8 +18,8 @@
#define LOG_TAG "NdkMediaExtractor"
-#include "NdkMediaError.h"
-#include "NdkMediaExtractor.h"
+#include <media/NdkMediaError.h>
+#include <media/NdkMediaExtractor.h>
#include "NdkMediaFormatPriv.h"
@@ -86,7 +86,6 @@
jobject service = NULL;
if (env == NULL) {
ALOGE("setDataSource(path) must be called from Java thread");
- env->ExceptionClear();
return AMEDIA_ERROR_UNSUPPORTED;
}
diff --git a/media/ndk/NdkMediaFormat.cpp b/media/ndk/NdkMediaFormat.cpp
index 5598d5d..ee27520 100644
--- a/media/ndk/NdkMediaFormat.cpp
+++ b/media/ndk/NdkMediaFormat.cpp
@@ -19,7 +19,7 @@
#include <inttypes.h>
-#include "NdkMediaFormat.h"
+#include <media/NdkMediaFormat.h>
#include <utils/Log.h>
#include <utils/StrongPointer.h>
diff --git a/media/ndk/NdkMediaFormatPriv.h b/media/ndk/NdkMediaFormatPriv.h
index 02342d9..c6a6563 100644
--- a/media/ndk/NdkMediaFormatPriv.h
+++ b/media/ndk/NdkMediaFormatPriv.h
@@ -27,7 +27,7 @@
#ifndef _NDK_MEDIA_FORMAT_PRIV_H
#define _NDK_MEDIA_FORMAT_PRIV_H
-#include <NdkMediaFormat.h>
+#include <media/NdkMediaFormat.h>
#ifdef __cplusplus
extern "C" {
diff --git a/media/ndk/NdkMediaMuxer.cpp b/media/ndk/NdkMediaMuxer.cpp
index b1b0362..9bdda75 100644
--- a/media/ndk/NdkMediaMuxer.cpp
+++ b/media/ndk/NdkMediaMuxer.cpp
@@ -18,8 +18,8 @@
#define LOG_TAG "NdkMediaMuxer"
-#include "NdkMediaMuxer.h"
-#include "NdkMediaCodec.h"
+#include <media/NdkMediaMuxer.h>
+#include <media/NdkMediaCodec.h>
#include "NdkMediaFormatPriv.h"
diff --git a/include/ndk/NdkImage.h b/media/ndk/include/media/NdkImage.h
similarity index 90%
rename from include/ndk/NdkImage.h
rename to media/ndk/include/media/NdkImage.h
index cd0b11e..15eae40 100644
--- a/include/ndk/NdkImage.h
+++ b/media/ndk/include/media/NdkImage.h
@@ -36,12 +36,16 @@
#ifndef _NDK_IMAGE_H
#define _NDK_IMAGE_H
+#include <sys/cdefs.h>
+
#include "NdkMediaError.h"
#ifdef __cplusplus
extern "C" {
#endif
+#if __ANDROID_API__ >= 24
+
/**
* AImage is an opaque type that provides access to image generated by {@link AImageReader}.
*/
@@ -50,6 +54,97 @@
// Formats not listed here will not be supported by AImageReader
enum AIMAGE_FORMATS {
/**
+ * 32 bits RGBA format, 8 bits for each of the four channels.
+ *
+ * <p>
+ * Corresponding formats:
+ * <ul>
+ * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM</li>
+ * <li>Vulkan: VK_FORMAT_R8G8B8A8_UNORM</li>
+ * <li>OpenGL ES: GL_RGBA8</li>
+ * </ul>
+ * </p>
+ *
+ * @see AImage
+ * @see AImageReader
+ * @see AHardwareBuffer
+ */
+ AIMAGE_FORMAT_RGBA_8888 = 0x1,
+
+ /**
+ * 32 bits RGBX format, 8 bits for each of the four channels.
+ *
+ * <p>
+ * Corresponding formats:
+ * <ul>
+ * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM</li>
+ * <li>Vulkan: VK_FORMAT_R8G8B8A8_UNORM</li>
+ * <li>OpenGL ES: GL_RGBA8</li>
+ * </ul>
+ * </p>
+ *
+ * @see AImage
+ * @see AImageReader
+ * @see AHardwareBuffer
+ */
+ AIMAGE_FORMAT_RGBX_8888 = 0x2,
+
+ /**
+ * 24 bits RGB format, 8 bits for each of the three channels.
+ *
+ * <p>
+ * Corresponding formats:
+ * <ul>
+ * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM</li>
+ * <li>Vulkan: VK_FORMAT_R8G8B8_UNORM</li>
+ * <li>OpenGL ES: GL_RGB8</li>
+ * </ul>
+ * </p>
+ *
+ * @see AImage
+ * @see AImageReader
+ * @see AHardwareBuffer
+ */
+ AIMAGE_FORMAT_RGB_888 = 0x3,
+
+ /**
+ * 16 bits RGB format, 5 bits for Red channel, 6 bits for Green channel,
+ * and 5 bits for Blue channel.
+ *
+ * <p>
+ * Corresponding formats:
+ * <ul>
+ * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM</li>
+ * <li>Vulkan: VK_FORMAT_R5G6B5_UNORM_PACK16</li>
+ * <li>OpenGL ES: GL_RGB565</li>
+ * </ul>
+ * </p>
+ *
+ * @see AImage
+ * @see AImageReader
+ * @see AHardwareBuffer
+ */
+ AIMAGE_FORMAT_RGB_565 = 0x4,
+
+ /**
+ * 64 bits RGBA format, 16 bits for each of the four channels.
+ *
+ * <p>
+ * Corresponding formats:
+ * <ul>
+ * <li>AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R16G16B16A16_SFLOAT</li>
+ * <li>Vulkan: VK_FORMAT_R16G16B16A16_SFLOAT</li>
+ * <li>OpenGL ES: GL_RGBA16F</li>
+ * </ul>
+ * </p>
+ *
+ * @see AImage
+ * @see AImageReader
+ * @see AHardwareBuffer
+ */
+ AIMAGE_FORMAT_RGBA_FP16 = 0x16,
+
+ /**
* Multi-plane Android YUV 420 format.
*
* <p>This format is a generic YCbCr format, capable of describing any 4:2:0
@@ -604,6 +699,8 @@
const AImage* image, int planeIdx,
/*out*/uint8_t** data, /*out*/int* dataLength);
+#endif /* __ANDROID_API__ >= 24 */
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/include/ndk/NdkImageReader.h b/media/ndk/include/media/NdkImageReader.h
similarity index 98%
rename from include/ndk/NdkImageReader.h
rename to media/ndk/include/media/NdkImageReader.h
index 7c7ec6a..8d72c28 100644
--- a/include/ndk/NdkImageReader.h
+++ b/media/ndk/include/media/NdkImageReader.h
@@ -36,6 +36,8 @@
#ifndef _NDK_IMAGE_READER_H
#define _NDK_IMAGE_READER_H
+#include <sys/cdefs.h>
+
#include <android/native_window.h>
#include "NdkMediaError.h"
#include "NdkImage.h"
@@ -44,6 +46,8 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 24
+
/**
* AImage is an opaque type that allows direct application access to image data rendered into a
* {@link ANativeWindow}.
@@ -294,6 +298,8 @@
media_status_t AImageReader_setImageListener(
AImageReader* reader, AImageReader_ImageListener* listener);
+#endif /* __ANDROID_API__ >= 24 */
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/include/ndk/NdkMediaCodec.h b/media/ndk/include/media/NdkMediaCodec.h
similarity index 98%
rename from include/ndk/NdkMediaCodec.h
rename to media/ndk/include/media/NdkMediaCodec.h
index fcb3a99..ad17321 100644
--- a/include/ndk/NdkMediaCodec.h
+++ b/media/ndk/include/media/NdkMediaCodec.h
@@ -27,6 +27,8 @@
#ifndef _NDK_MEDIA_CODEC_H
#define _NDK_MEDIA_CODEC_H
+#include <sys/cdefs.h>
+
#include <android/native_window.h>
#include "NdkMediaCrypto.h"
@@ -37,6 +39,7 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 21
struct AMediaCodec;
typedef struct AMediaCodec AMediaCodec;
@@ -254,6 +257,8 @@
*/
media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(AMediaCodecCryptoInfo*, size_t *dst);
+#endif /* __ANDROID_API__ >= 21 */
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/include/ndk/NdkMediaCrypto.h b/media/ndk/include/media/NdkMediaCrypto.h
similarity index 94%
rename from include/ndk/NdkMediaCrypto.h
rename to media/ndk/include/media/NdkMediaCrypto.h
index 90374c5..9236765 100644
--- a/include/ndk/NdkMediaCrypto.h
+++ b/media/ndk/include/media/NdkMediaCrypto.h
@@ -28,6 +28,7 @@
#ifndef _NDK_MEDIA_CRYPTO_H
#define _NDK_MEDIA_CRYPTO_H
+#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdbool.h>
@@ -35,6 +36,8 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 21
+
struct AMediaCrypto;
typedef struct AMediaCrypto AMediaCrypto;
@@ -48,6 +51,7 @@
void AMediaCrypto_delete(AMediaCrypto* crypto);
+#endif /* __ANDROID_API__ >= 21 */
#ifdef __cplusplus
} // extern "C"
diff --git a/include/ndk/NdkMediaDrm.h b/media/ndk/include/media/NdkMediaDrm.h
similarity index 99%
rename from include/ndk/NdkMediaDrm.h
rename to media/ndk/include/media/NdkMediaDrm.h
index 3c312a9..9dd6283 100644
--- a/include/ndk/NdkMediaDrm.h
+++ b/media/ndk/include/media/NdkMediaDrm.h
@@ -27,14 +27,17 @@
#ifndef _NDK_MEDIA_DRM_H
#define _NDK_MEDIA_DRM_H
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/cdefs.h>
+
#include "NdkMediaError.h"
#ifdef __cplusplus
extern "C" {
#endif
-#include <stdint.h>
-#include <stdbool.h>
+#if __ANDROID_API__ >= 21
struct AMediaDrm;
typedef struct AMediaDrm AMediaDrm;
@@ -448,6 +451,8 @@
const char *macAlgorithm, uint8_t *keyId, const uint8_t *message, size_t messageSize,
const uint8_t *signature, size_t signatureSize);
+#endif /* __ANDROID_API__ >= 21 */
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/include/ndk/NdkMediaError.h b/media/ndk/include/media/NdkMediaError.h
similarity index 96%
rename from include/ndk/NdkMediaError.h
rename to media/ndk/include/media/NdkMediaError.h
index 60d401b..fb00b1d 100644
--- a/include/ndk/NdkMediaError.h
+++ b/media/ndk/include/media/NdkMediaError.h
@@ -28,10 +28,14 @@
#ifndef _NDK_MEDIA_ERROR_H
#define _NDK_MEDIA_ERROR_H
+#include <sys/cdefs.h>
+
#ifdef __cplusplus
extern "C" {
#endif
+#if __ANDROID_API__ >= 21
+
typedef enum {
AMEDIA_OK = 0,
@@ -59,6 +63,7 @@
} media_status_t;
+#endif /* __ANDROID_API__ >= 21 */
#ifdef __cplusplus
} // extern "C"
diff --git a/include/ndk/NdkMediaExtractor.h b/media/ndk/include/media/NdkMediaExtractor.h
similarity index 97%
rename from include/ndk/NdkMediaExtractor.h
rename to media/ndk/include/media/NdkMediaExtractor.h
index 7324d31..c3180dc 100644
--- a/include/ndk/NdkMediaExtractor.h
+++ b/media/ndk/include/media/NdkMediaExtractor.h
@@ -28,6 +28,7 @@
#ifndef _NDK_MEDIA_EXTRACTOR_H
#define _NDK_MEDIA_EXTRACTOR_H
+#include <sys/cdefs.h>
#include <sys/types.h>
#include "NdkMediaCodec.h"
@@ -38,6 +39,8 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 21
+
struct AMediaExtractor;
typedef struct AMediaExtractor AMediaExtractor;
@@ -158,6 +161,8 @@
AMEDIAEXTRACTOR_SAMPLE_FLAG_ENCRYPTED = 2,
};
+#endif /* __ANDROID_API__ >= 21 */
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/include/ndk/NdkMediaFormat.h b/media/ndk/include/media/NdkMediaFormat.h
similarity index 97%
rename from include/ndk/NdkMediaFormat.h
rename to media/ndk/include/media/NdkMediaFormat.h
index ab29791..a2a21d2 100644
--- a/include/ndk/NdkMediaFormat.h
+++ b/media/ndk/include/media/NdkMediaFormat.h
@@ -27,6 +27,7 @@
#ifndef _NDK_MEDIA_FORMAT_H
#define _NDK_MEDIA_FORMAT_H
+#include <sys/cdefs.h>
#include <sys/types.h>
#include "NdkMediaError.h"
@@ -35,6 +36,8 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 21
+
struct AMediaFormat;
typedef struct AMediaFormat AMediaFormat;
@@ -104,6 +107,8 @@
extern const char* AMEDIAFORMAT_KEY_WIDTH;
extern const char* AMEDIAFORMAT_KEY_STRIDE;
+#endif /* __ANDROID_API__ >= 21 */
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/include/ndk/NdkMediaMuxer.h b/media/ndk/include/media/NdkMediaMuxer.h
similarity index 97%
rename from include/ndk/NdkMediaMuxer.h
rename to media/ndk/include/media/NdkMediaMuxer.h
index 90d946c..25987a2 100644
--- a/include/ndk/NdkMediaMuxer.h
+++ b/media/ndk/include/media/NdkMediaMuxer.h
@@ -28,6 +28,7 @@
#ifndef _NDK_MEDIA_MUXER_H
#define _NDK_MEDIA_MUXER_H
+#include <sys/cdefs.h>
#include <sys/types.h>
#include "NdkMediaCodec.h"
@@ -38,6 +39,8 @@
extern "C" {
#endif
+#if __ANDROID_API__ >= 21
+
struct AMediaMuxer;
typedef struct AMediaMuxer AMediaMuxer;
@@ -112,6 +115,8 @@
media_status_t AMediaMuxer_writeSampleData(AMediaMuxer *muxer,
size_t trackIdx, const uint8_t *data, const AMediaCodecBufferInfo *info);
+#endif /* __ANDROID_API__ >= 21 */
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/media/ndk/libmediandk.map.txt b/media/ndk/libmediandk.map.txt
new file mode 100644
index 0000000..7db4d06
--- /dev/null
+++ b/media/ndk/libmediandk.map.txt
@@ -0,0 +1,141 @@
+LIBMEDIANDK {
+ global:
+ AImageReader_acquireLatestImage; # introduced=24
+ AImageReader_acquireNextImage; # introduced=24
+ AImageReader_delete; # introduced=24
+ AImageReader_getFormat; # introduced=24
+ AImageReader_getHeight; # introduced=24
+ AImageReader_getMaxImages; # introduced=24
+ AImageReader_getWidth; # introduced=24
+ AImageReader_getWindow; # introduced=24
+ AImageReader_new; # introduced=24
+ AImageReader_setImageListener; # introduced=24
+ AImage_delete; # introduced=24
+ AImage_getCropRect; # introduced=24
+ AImage_getFormat; # introduced=24
+ AImage_getHeight; # introduced=24
+ AImage_getNumberOfPlanes; # introduced=24
+ AImage_getPlaneData; # introduced=24
+ AImage_getPlanePixelStride; # introduced=24
+ AImage_getPlaneRowStride; # introduced=24
+ AImage_getTimestamp; # introduced=24
+ AImage_getWidth; # introduced=24
+ AMEDIAFORMAT_KEY_AAC_PROFILE; # var
+ AMEDIAFORMAT_KEY_BIT_RATE; # var
+ AMEDIAFORMAT_KEY_CHANNEL_COUNT; # var
+ AMEDIAFORMAT_KEY_CHANNEL_MASK; # var
+ AMEDIAFORMAT_KEY_COLOR_FORMAT; # var
+ AMEDIAFORMAT_KEY_DURATION; # var
+ AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL; # var
+ AMEDIAFORMAT_KEY_FRAME_RATE; # var
+ AMEDIAFORMAT_KEY_HEIGHT; # var
+ AMEDIAFORMAT_KEY_IS_ADTS; # var
+ AMEDIAFORMAT_KEY_IS_AUTOSELECT; # var
+ AMEDIAFORMAT_KEY_IS_DEFAULT; # var
+ AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE; # var
+ AMEDIAFORMAT_KEY_I_FRAME_INTERVAL; # var
+ AMEDIAFORMAT_KEY_LANGUAGE; # var
+ AMEDIAFORMAT_KEY_MAX_HEIGHT; # var
+ AMEDIAFORMAT_KEY_MAX_INPUT_SIZE; # var
+ AMEDIAFORMAT_KEY_MAX_WIDTH; # var
+ AMEDIAFORMAT_KEY_MIME; # var
+ AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP; # var
+ AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER; # var
+ AMEDIAFORMAT_KEY_SAMPLE_RATE; # var
+ AMEDIAFORMAT_KEY_STRIDE; # var
+ AMEDIAFORMAT_KEY_WIDTH; # var
+ AMediaCodecCryptoInfo_delete;
+ AMediaCodecCryptoInfo_getClearBytes;
+ AMediaCodecCryptoInfo_getEncryptedBytes;
+ AMediaCodecCryptoInfo_getIV;
+ AMediaCodecCryptoInfo_getKey;
+ AMediaCodecCryptoInfo_getMode;
+ AMediaCodecCryptoInfo_getNumSubSamples;
+ AMediaCodecCryptoInfo_new;
+ AMediaCodecCryptoInfo_setPattern; # introduced=24
+ AMediaCodec_configure;
+ AMediaCodec_createCodecByName;
+ AMediaCodec_createDecoderByType;
+ AMediaCodec_createEncoderByType;
+ AMediaCodec_delete;
+ AMediaCodec_dequeueInputBuffer;
+ AMediaCodec_dequeueOutputBuffer;
+ AMediaCodec_flush;
+ AMediaCodec_getInputBuffer;
+ AMediaCodec_getOutputBuffer;
+ AMediaCodec_getOutputFormat;
+ AMediaCodec_queueInputBuffer;
+ AMediaCodec_queueSecureInputBuffer;
+ AMediaCodec_releaseOutputBuffer;
+ AMediaCodec_releaseOutputBufferAtTime;
+ AMediaCodec_setOutputSurface; # introduced=24
+ AMediaCodec_start;
+ AMediaCodec_stop;
+ AMediaCrypto_delete;
+ AMediaCrypto_isCryptoSchemeSupported;
+ AMediaCrypto_new;
+ AMediaCrypto_requiresSecureDecoderComponent;
+ AMediaDrm_closeSession;
+ AMediaDrm_createByUUID;
+ AMediaDrm_decrypt;
+ AMediaDrm_encrypt;
+ AMediaDrm_getKeyRequest;
+ AMediaDrm_getPropertyByteArray;
+ AMediaDrm_getPropertyString;
+ AMediaDrm_getProvisionRequest;
+ AMediaDrm_getSecureStops;
+ AMediaDrm_isCryptoSchemeSupported;
+ AMediaDrm_openSession;
+ AMediaDrm_provideKeyResponse;
+ AMediaDrm_provideProvisionResponse;
+ AMediaDrm_queryKeyStatus;
+ AMediaDrm_release;
+ AMediaDrm_releaseSecureStops;
+ AMediaDrm_removeKeys;
+ AMediaDrm_restoreKeys;
+ AMediaDrm_setOnEventListener;
+ AMediaDrm_setPropertyByteArray;
+ AMediaDrm_setPropertyString;
+ AMediaDrm_sign;
+ AMediaDrm_verify;
+ AMediaExtractor_advance;
+ AMediaExtractor_delete;
+ AMediaExtractor_getPsshInfo;
+ AMediaExtractor_getSampleCryptoInfo;
+ AMediaExtractor_getSampleFlags;
+ AMediaExtractor_getSampleTime;
+ AMediaExtractor_getSampleTrackIndex;
+ AMediaExtractor_getTrackCount;
+ AMediaExtractor_getTrackFormat;
+ AMediaExtractor_new;
+ AMediaExtractor_readSampleData;
+ AMediaExtractor_seekTo;
+ AMediaExtractor_selectTrack;
+ AMediaExtractor_setDataSource;
+ AMediaExtractor_setDataSourceFd;
+ AMediaExtractor_unselectTrack;
+ AMediaFormat_delete;
+ AMediaFormat_getBuffer;
+ AMediaFormat_getFloat;
+ AMediaFormat_getInt32;
+ AMediaFormat_getInt64;
+ AMediaFormat_getSize;
+ AMediaFormat_getString;
+ AMediaFormat_new;
+ AMediaFormat_setBuffer;
+ AMediaFormat_setFloat;
+ AMediaFormat_setInt32;
+ AMediaFormat_setInt64;
+ AMediaFormat_setString;
+ AMediaFormat_toString;
+ AMediaMuxer_addTrack;
+ AMediaMuxer_delete;
+ AMediaMuxer_new;
+ AMediaMuxer_setLocation;
+ AMediaMuxer_setOrientationHint;
+ AMediaMuxer_start;
+ AMediaMuxer_stop;
+ AMediaMuxer_writeSampleData;
+ local:
+ *;
+};
diff --git a/media/utils/Android.bp b/media/utils/Android.bp
new file mode 100644
index 0000000..72917dd
--- /dev/null
+++ b/media/utils/Android.bp
@@ -0,0 +1,41 @@
+// 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.
+
+cc_library_shared {
+ name: "libmediautils",
+
+ srcs: [
+ "BatteryNotifier.cpp",
+ "ISchedulingPolicyService.cpp",
+ "MemoryLeakTrackUtil.cpp",
+ "ProcessInfo.cpp",
+ "SchedulingPolicyService.cpp",
+ ],
+ shared_libs: [
+ "libbinder",
+ "libcutils",
+ "liblog",
+ "libutils",
+ "libmemunreachable",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+
+ local_include_dirs: ["include"],
+ export_include_dirs: ["include"],
+}
diff --git a/media/utils/Android.mk b/media/utils/Android.mk
deleted file mode 100644
index 54d22b1..0000000
--- a/media/utils/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2015 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- BatteryNotifier.cpp \
- ISchedulingPolicyService.cpp \
- SchedulingPolicyService.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libcutils \
- liblog \
- libutils \
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-
-LOCAL_CFLAGS += \
- -Wall \
- -Wextra \
- -Werror \
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-
-LOCAL_MODULE := libmediautils
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/utils/ISchedulingPolicyService.cpp b/media/utils/ISchedulingPolicyService.cpp
index f55bc02..f5bfe20 100644
--- a/media/utils/ISchedulingPolicyService.cpp
+++ b/media/utils/ISchedulingPolicyService.cpp
@@ -32,7 +32,7 @@
class BpSchedulingPolicyService : public BpInterface<ISchedulingPolicyService>
{
public:
- BpSchedulingPolicyService(const sp<IBinder>& impl)
+ explicit BpSchedulingPolicyService(const sp<IBinder>& impl)
: BpInterface<ISchedulingPolicyService>(impl)
{
}
diff --git a/media/libmedia/MemoryLeakTrackUtil.cpp b/media/utils/MemoryLeakTrackUtil.cpp
similarity index 100%
rename from media/libmedia/MemoryLeakTrackUtil.cpp
rename to media/utils/MemoryLeakTrackUtil.cpp
diff --git a/media/libstagefright/ProcessInfo.cpp b/media/utils/ProcessInfo.cpp
similarity index 100%
rename from media/libstagefright/ProcessInfo.cpp
rename to media/utils/ProcessInfo.cpp
diff --git a/radio/Android.bp b/radio/Android.bp
new file mode 100644
index 0000000..8e614f2
--- /dev/null
+++ b/radio/Android.bp
@@ -0,0 +1,37 @@
+// Copyright 2014 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.
+
+cc_library_shared {
+ name: "libradio",
+
+ srcs: [
+ "Radio.cpp",
+ "IRadio.cpp",
+ "IRadioClient.cpp",
+ "IRadioService.cpp",
+ ],
+
+ shared_libs: [
+ "libcutils",
+ "libutils",
+ "liblog",
+ "libbinder",
+ "libradio_metadata",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
diff --git a/radio/Android.mk b/radio/Android.mk
deleted file mode 100644
index 0377328..0000000
--- a/radio/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2014 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- Radio.cpp \
- IRadio.cpp \
- IRadioClient.cpp \
- IRadioService.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- liblog \
- libbinder \
- libhardware \
- libradio_metadata
-
-#LOCAL_C_INCLUDES += \
- system/media/camera/include \
- system/media/private/camera/include
-
-LOCAL_MODULE:= libradio
-
-LOCAL_CFLAGS := -Werror -Wall
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/radio/IRadio.cpp b/radio/IRadio.cpp
index 242df77..e6dbdc3 100644
--- a/radio/IRadio.cpp
+++ b/radio/IRadio.cpp
@@ -16,6 +16,7 @@
*/
#define LOG_TAG "IRadio"
+//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include <utils/Errors.h>
#include <binder/IMemory.h>
@@ -23,7 +24,7 @@
#include <radio/IRadioService.h>
#include <radio/IRadioClient.h>
#include <system/radio.h>
-#include <system/radio_metadata.h>
+#include <system/RadioMetadataWrapper.h>
namespace android {
@@ -44,7 +45,7 @@
class BpRadio: public BpInterface<IRadio>
{
public:
- BpRadio(const sp<IBinder>& impl)
+ explicit BpRadio(const sp<IBinder>& impl)
: BpInterface<IRadio>(impl)
{
}
@@ -303,12 +304,9 @@
case GET_PROGRAM_INFORMATION: {
CHECK_INTERFACE(IRadio, data, reply);
struct radio_program_info info;
+ RadioMetadataWrapper metadataWrapper(&info.metadata);
- status_t status = radio_metadata_allocate(&info.metadata, 0, 0);
- if (status != NO_ERROR) {
- return status;
- }
- status = getProgramInformation(&info);
+ status_t status = getProgramInformation(&info);
reply->writeInt32(status);
if (status == NO_ERROR) {
reply->write(&info, sizeof(struct radio_program_info));
@@ -321,7 +319,6 @@
reply->writeInt32(0);
}
}
- radio_metadata_deallocate(info.metadata);
return NO_ERROR;
}
case HAS_CONTROL: {
diff --git a/radio/IRadioClient.cpp b/radio/IRadioClient.cpp
index 033ca49..ca21949 100644
--- a/radio/IRadioClient.cpp
+++ b/radio/IRadioClient.cpp
@@ -33,7 +33,7 @@
{
public:
- BpRadioClient(const sp<IBinder>& impl)
+ explicit BpRadioClient(const sp<IBinder>& impl)
: BpInterface<IRadioClient>(impl)
{
}
diff --git a/radio/IRadioService.cpp b/radio/IRadioService.cpp
index 81acf9e..be7d21e 100644
--- a/radio/IRadioService.cpp
+++ b/radio/IRadioService.cpp
@@ -45,7 +45,7 @@
class BpRadioService: public BpInterface<IRadioService>
{
public:
- BpRadioService(const sp<IBinder>& impl)
+ explicit BpRadioService(const sp<IBinder>& impl)
: BpInterface<IRadioService>(impl)
{
}
@@ -88,7 +88,9 @@
data.writeInt32(handle);
data.writeStrongBinder(IInterface::asBinder(client));
ALOGV("attach() config %p withAudio %d region %d type %d",
- config == NULL ? 0 : config, withAudio, config->region, config->band.type);
+ config == NULL ? 0 : config, withAudio,
+ config == NULL ? 0 : config->region,
+ config == NULL ? 0 : config->band.type);
if (config == NULL) {
data.writeInt32(0);
} else {
diff --git a/radio/Radio.cpp b/radio/Radio.cpp
index 3c04fb0..57c7e89 100644
--- a/radio/Radio.cpp
+++ b/radio/Radio.cpp
@@ -117,8 +117,8 @@
// Radio
-Radio::Radio(radio_handle_t handle, const sp<RadioCallback>& callback)
- : mHandle(handle), mCallback(callback)
+Radio::Radio(radio_handle_t /*handle*/, const sp<RadioCallback>& callback)
+ : mCallback(callback)
{
}
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index 8b831f0..42b139a 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -34,9 +34,9 @@
StateQueue.cpp
LOCAL_C_INCLUDES := \
- $(TOPDIR)frameworks/av/services/audiopolicy \
- $(TOPDIR)external/sonic \
- libcore/include \
+ frameworks/av/services/audiopolicy \
+ frameworks/av/services/medialog \
+ external/sonic \
$(call include-path-for, audio-effects) \
$(call include-path-for, audio-utils)
@@ -48,7 +48,8 @@
libutils \
liblog \
libbinder \
- libmedia \
+ libaudioclient \
+ libmedialogservice \
libmediautils \
libnbaio \
libhardware \
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index fec3a57..fcb6992 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -36,7 +36,6 @@
#include <utils/threads.h>
#include <utils/Atomic.h>
-#include <cutils/bitops.h>
#include <cutils/properties.h>
#include <system/audio.h>
@@ -1423,11 +1422,15 @@
mAudioFlinger(audioFlinger),
mPid(pid)
{
- size_t heapSize = kClientSharedHeapSizeBytes;
- // Increase heap size on non low ram devices to limit risk of reconnection failure for
- // invalidated tracks
- if (!audioFlinger->isLowRamDevice()) {
- heapSize *= kClientSharedHeapSizeMultiplier;
+ size_t heapSize = property_get_int32("ro.af.client_heap_size_kbyte", 0);
+ heapSize *= 1024;
+ if (!heapSize) {
+ heapSize = kClientSharedHeapSizeBytes;
+ // Increase heap size on non low ram devices to limit risk of reconnection failure for
+ // invalidated tracks
+ if (!audioFlinger->isLowRamDevice()) {
+ heapSize *= kClientSharedHeapSizeMultiplier;
+ }
}
mMemoryDealer = new MemoryDealer(heapSize, "AudioFlinger::Client");
}
@@ -1913,7 +1916,7 @@
config->channel_mask,
flags);
- if (*devices == AUDIO_DEVICE_NONE) {
+ if (devices == NULL || *devices == AUDIO_DEVICE_NONE) {
return BAD_VALUE;
}
@@ -2024,7 +2027,7 @@
return NO_ERROR;
}
-void AudioFlinger::closeOutputFinish(sp<PlaybackThread> thread)
+void AudioFlinger::closeOutputFinish(const sp<PlaybackThread>& thread)
{
AudioStreamOut *out = thread->clearOutput();
ALOG_ASSERT(out != NULL, "out shouldn't be NULL");
@@ -2033,7 +2036,7 @@
delete out;
}
-void AudioFlinger::closeOutputInternal_l(sp<PlaybackThread> thread)
+void AudioFlinger::closeOutputInternal_l(const sp<PlaybackThread>& thread)
{
mPlaybackThreads.removeItem(thread->mId);
thread->exit();
@@ -2294,7 +2297,7 @@
return NO_ERROR;
}
-void AudioFlinger::closeInputFinish(sp<RecordThread> thread)
+void AudioFlinger::closeInputFinish(const sp<RecordThread>& thread)
{
thread->exit();
AudioStreamIn *in = thread->clearInput();
@@ -2304,7 +2307,7 @@
delete in;
}
-void AudioFlinger::closeInputInternal_l(sp<RecordThread> thread)
+void AudioFlinger::closeInputInternal_l(const sp<RecordThread>& thread)
{
mRecordThreads.removeItem(thread->mId);
closeInputFinish(thread);
@@ -2572,7 +2575,7 @@
audio_session_t triggerSession,
audio_session_t listenerSession,
sync_event_callback_t callBack,
- wp<RefBase> cookie)
+ const wp<RefBase>& cookie)
{
Mutex::Autolock _l(mLock);
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 40c8a72..8f5a7cd 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -318,7 +318,7 @@
audio_session_t triggerSession,
audio_session_t listenerSession,
sync_event_callback_t callBack,
- wp<RefBase> cookie);
+ const wp<RefBase>& cookie);
private:
@@ -485,7 +485,7 @@
// server side of the client's IAudioTrack
class TrackHandle : public android::BnAudioTrack {
public:
- TrackHandle(const sp<PlaybackThread::Track>& track);
+ explicit TrackHandle(const sp<PlaybackThread::Track>& track);
virtual ~TrackHandle();
virtual sp<IMemory> getCblk() const;
virtual status_t start();
@@ -507,7 +507,7 @@
// server side of the client's IAudioRecord
class RecordHandle : public android::BnAudioRecord {
public:
- RecordHandle(const sp<RecordThread::RecordTrack>& recordTrack);
+ explicit RecordHandle(const sp<RecordThread::RecordTrack>& recordTrack);
virtual ~RecordHandle();
virtual status_t start(int /*AudioSystem::sync_event_t*/ event,
audio_session_t triggerSession);
@@ -540,8 +540,8 @@
const String8& address,
audio_output_flags_t flags);
- void closeOutputFinish(sp<PlaybackThread> thread);
- void closeInputFinish(sp<RecordThread> thread);
+ void closeOutputFinish(const sp<PlaybackThread>& thread);
+ void closeInputFinish(const sp<RecordThread>& thread);
// no range check, AudioFlinger::mLock held
bool streamMute_l(audio_stream_type_t stream) const
@@ -713,9 +713,9 @@
// for use from destructor
status_t closeOutput_nonvirtual(audio_io_handle_t output);
- void closeOutputInternal_l(sp<PlaybackThread> thread);
+ void closeOutputInternal_l(const sp<PlaybackThread>& thread);
status_t closeInput_nonvirtual(audio_io_handle_t input);
- void closeInputInternal_l(sp<RecordThread> thread);
+ void closeInputInternal_l(const sp<RecordThread>& thread);
void setAudioHwSyncForSession_l(PlaybackThread *thread, audio_session_t sessionId);
status_t checkStreamType(audio_stream_type_t stream) const;
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index 0be7199..41065ae 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -28,7 +28,6 @@
#include <utils/Errors.h>
#include <utils/Log.h>
-#include <cutils/bitops.h>
#include <cutils/compiler.h>
#include <utils/Debug.h>
@@ -1611,8 +1610,13 @@
// in == NULL can happen if the track was flushed just after having
// been enabled for mixing.
if (in == NULL || (((uintptr_t)in) & 3)) {
- memset(out, 0, numFrames
- * t.mMixerChannelCount * audio_bytes_per_sample(t.mMixerFormat));
+ if ( AUDIO_FORMAT_PCM_FLOAT == t.mMixerFormat ) {
+ memset((char*)fout, 0, numFrames
+ * t.mMixerChannelCount * audio_bytes_per_sample(t.mMixerFormat));
+ } else {
+ memset((char*)out, 0, numFrames
+ * t.mMixerChannelCount * audio_bytes_per_sample(t.mMixerFormat));
+ }
ALOGE_IF((((uintptr_t)in) & 3),
"process__OneTrack16BitsStereoNoResampling: misaligned buffer"
" %p track %d, channels %d, needs %08x, volume %08x vfl %f vfr %f",
@@ -1679,8 +1683,8 @@
// Needs to derive a compile time constant (constexpr). Could be targeted to go
// to a MONOVOL mixtype based on MAX_NUM_VOLUMES, but that's an unnecessary complication.
-#define MIXTYPE_MONOVOL(mixtype) (mixtype == MIXTYPE_MULTI ? MIXTYPE_MULTI_MONOVOL : \
- mixtype == MIXTYPE_MULTI_SAVEONLY ? MIXTYPE_MULTI_SAVEONLY_MONOVOL : mixtype)
+#define MIXTYPE_MONOVOL(mixtype) ((mixtype) == MIXTYPE_MULTI ? MIXTYPE_MULTI_MONOVOL : \
+ (mixtype) == MIXTYPE_MULTI_SAVEONLY ? MIXTYPE_MULTI_SAVEONLY_MONOVOL : (mixtype))
/* MIXTYPE (see AudioMixerOps.h MIXTYPE_* enumeration)
* TO: int32_t (Q4.27) or float
diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp
index 4f8b413..8b7259d 100644
--- a/services/audioflinger/AudioResampler.cpp
+++ b/services/audioflinger/AudioResampler.cpp
@@ -17,11 +17,14 @@
#define LOG_TAG "AudioResampler"
//#define LOG_NDEBUG 0
+#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
-#include <cutils/log.h>
+
#include <cutils/properties.h>
+#include <log/log.h>
+
#include <audio_utils/primitives.h>
#include "AudioResampler.h"
#include "AudioResamplerSinc.h"
diff --git a/services/audioflinger/AudioResamplerCubic.cpp b/services/audioflinger/AudioResamplerCubic.cpp
index 9c3c7cb..9fb6699 100644
--- a/services/audioflinger/AudioResamplerCubic.cpp
+++ b/services/audioflinger/AudioResamplerCubic.cpp
@@ -19,7 +19,8 @@
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
-#include <cutils/log.h>
+
+#include <log/log.h>
#include "AudioResampler.h"
#include "AudioResamplerCubic.h"
diff --git a/services/audioflinger/AudioResamplerCubic.h b/services/audioflinger/AudioResamplerCubic.h
index 4b45b0b..f218fd9 100644
--- a/services/audioflinger/AudioResamplerCubic.h
+++ b/services/audioflinger/AudioResamplerCubic.h
@@ -19,7 +19,7 @@
#include <stdint.h>
#include <sys/types.h>
-#include <cutils/log.h>
+#include <android/log.h>
#include "AudioResampler.h"
diff --git a/services/audioflinger/AudioResamplerDyn.cpp b/services/audioflinger/AudioResamplerDyn.cpp
index e615700..213cd1a 100644
--- a/services/audioflinger/AudioResamplerDyn.cpp
+++ b/services/audioflinger/AudioResamplerDyn.cpp
@@ -29,9 +29,10 @@
#include <utils/Log.h>
#include <audio_utils/primitives.h>
-#include "AudioResamplerFirOps.h" // USE_NEON and USE_INLINE_ASSEMBLY defined here
+#include "AudioResamplerFirOps.h" // USE_NEON, USE_SSE and USE_INLINE_ASSEMBLY defined here
#include "AudioResamplerFirProcess.h"
#include "AudioResamplerFirProcessNeon.h"
+#include "AudioResamplerFirProcessSSE.h"
#include "AudioResamplerFirGen.h" // requires math.h
#include "AudioResamplerDyn.h"
@@ -520,7 +521,7 @@
// inFrameCount, outputIndex, outFrameCount, phaseFraction, phaseWrapLimit);
// check inputIndex overflow
- ALOG_ASSERT(inputIndex <= mBuffer.frameCount, "inputIndex%d > frameCount%d",
+ ALOG_ASSERT(inputIndex <= mBuffer.frameCount, "inputIndex%zu > frameCount%zu",
inputIndex, mBuffer.frameCount);
// Buffer is empty, fetch a new one if necessary (inFrameCount > 0).
// We may not fetch a new buffer if the existing data is sufficient.
@@ -591,7 +592,7 @@
// We arrive here when we're finished or when the input buffer runs out.
// Regardless we need to release the input buffer if we've acquired it.
if (inputIndex > 0) { // we've acquired a buffer (alternatively could check frameCount)
- ALOG_ASSERT(inputIndex == frameCount, "inputIndex(%d) != frameCount(%d)",
+ ALOG_ASSERT(inputIndex == frameCount, "inputIndex(%zu) != frameCount(%zu)",
inputIndex, frameCount); // must have been fully read.
inputIndex = 0;
provider->releaseBuffer(&mBuffer);
@@ -603,7 +604,7 @@
// inputIndex must be zero in all three cases:
// (1) the buffer never was been acquired; (2) the buffer was
// released at "done:"; or (3) getNextBuffer() failed.
- ALOG_ASSERT(inputIndex == 0, "Releasing: inputindex:%d frameCount:%d phaseFraction:%u",
+ ALOG_ASSERT(inputIndex == 0, "Releasing: inputindex:%zu frameCount:%zu phaseFraction:%u",
inputIndex, mBuffer.frameCount, phaseFraction);
ALOG_ASSERT(mBuffer.frameCount == 0); // there must be no frames in the buffer
mInBuffer.setImpulse(impulse);
diff --git a/services/audioflinger/AudioResamplerDyn.h b/services/audioflinger/AudioResamplerDyn.h
index 3b1c381..f8b8fa1 100644
--- a/services/audioflinger/AudioResamplerDyn.h
+++ b/services/audioflinger/AudioResamplerDyn.h
@@ -19,7 +19,7 @@
#include <stdint.h>
#include <sys/types.h>
-#include <cutils/log.h>
+#include <android/log.h>
#include "AudioResampler.h"
diff --git a/services/audioflinger/AudioResamplerFirOps.h b/services/audioflinger/AudioResamplerFirOps.h
index 2a26496..776903c 100644
--- a/services/audioflinger/AudioResamplerFirOps.h
+++ b/services/audioflinger/AudioResamplerFirOps.h
@@ -36,6 +36,13 @@
#include <arm_neon.h>
#endif
+#if defined(__SSSE3__) // Should be supported in x86 ABI for both 32 & 64-bit.
+#define USE_SSE (true)
+#include <tmmintrin.h>
+#else
+#define USE_SSE (false)
+#endif
+
template<typename T, typename U>
struct is_same
{
diff --git a/services/audioflinger/AudioResamplerFirProcessSSE.h b/services/audioflinger/AudioResamplerFirProcessSSE.h
new file mode 100644
index 0000000..63ed052
--- /dev/null
+++ b/services/audioflinger/AudioResamplerFirProcessSSE.h
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef ANDROID_AUDIO_RESAMPLER_FIR_PROCESS_SSE_H
+#define ANDROID_AUDIO_RESAMPLER_FIR_PROCESS_SSE_H
+
+namespace android {
+
+// depends on AudioResamplerFirOps.h, AudioResamplerFirProcess.h
+
+#if USE_SSE
+
+#define TO_STRING2(x) #x
+#define TO_STRING(x) TO_STRING2(x)
+// uncomment to print GCC version, may be relevant for intrinsic optimizations
+/* #pragma message ("GCC version: " TO_STRING(__GNUC__) \
+ "." TO_STRING(__GNUC_MINOR__) \
+ "." TO_STRING(__GNUC_PATCHLEVEL__)) */
+
+//
+// SSEx specializations are enabled for Process() and ProcessL() in AudioResamplerFirProcess.h
+//
+
+template <int CHANNELS, int STRIDE, bool FIXED>
+static inline void ProcessSSEIntrinsic(float* out,
+ int count,
+ const float* coefsP,
+ const float* coefsN,
+ const float* sP,
+ const float* sN,
+ const float* volumeLR,
+ float lerpP,
+ const float* coefsP1,
+ const float* coefsN1)
+{
+ ALOG_ASSERT(count > 0 && (count & 7) == 0); // multiple of 8
+ COMPILE_TIME_ASSERT_FUNCTION_SCOPE(CHANNELS == 1 || CHANNELS == 2);
+
+ sP -= CHANNELS*(4-1); // adjust sP for a loop iteration of four
+
+ __m128 interp;
+ if (!FIXED) {
+ interp = _mm_set1_ps(lerpP);
+ }
+
+ __m128 accL, accR;
+ accL = _mm_setzero_ps();
+ if (CHANNELS == 2) {
+ accR = _mm_setzero_ps();
+ }
+
+ do {
+ __m128 posCoef = _mm_load_ps(coefsP);
+ __m128 negCoef = _mm_load_ps(coefsN);
+ coefsP += 4;
+ coefsN += 4;
+
+ if (!FIXED) { // interpolate
+ __m128 posCoef1 = _mm_load_ps(coefsP1);
+ __m128 negCoef1 = _mm_load_ps(coefsN1);
+ coefsP1 += 4;
+ coefsN1 += 4;
+
+ // Calculate the final coefficient for interpolation
+ // posCoef = interp * (posCoef1 - posCoef) + posCoef
+ // negCoef = interp * (negCoef - negCoef1) + negCoef1
+ posCoef1 = _mm_sub_ps(posCoef1, posCoef);
+ negCoef = _mm_sub_ps(negCoef, negCoef1);
+
+ posCoef1 = _mm_mul_ps(posCoef1, interp);
+ negCoef = _mm_mul_ps(negCoef, interp);
+
+ posCoef = _mm_add_ps(posCoef1, posCoef);
+ negCoef = _mm_add_ps(negCoef, negCoef1);
+ }
+ switch (CHANNELS) {
+ case 1: {
+ __m128 posSamp = _mm_loadu_ps(sP);
+ __m128 negSamp = _mm_loadu_ps(sN);
+ sP -= 4;
+ sN += 4;
+
+ posSamp = _mm_shuffle_ps(posSamp, posSamp, 0x1B);
+ posSamp = _mm_mul_ps(posSamp, posCoef);
+ negSamp = _mm_mul_ps(negSamp, negCoef);
+
+ accL = _mm_add_ps(accL, posSamp);
+ accL = _mm_add_ps(accL, negSamp);
+ } break;
+ case 2: {
+ __m128 posSamp0 = _mm_loadu_ps(sP);
+ __m128 posSamp1 = _mm_loadu_ps(sP+4);
+ __m128 negSamp0 = _mm_loadu_ps(sN);
+ __m128 negSamp1 = _mm_loadu_ps(sN+4);
+ sP -= 8;
+ sN += 8;
+
+ // deinterleave everything and reverse the positives
+ __m128 posSampL = _mm_shuffle_ps(posSamp1, posSamp0, 0x22);
+ __m128 posSampR = _mm_shuffle_ps(posSamp1, posSamp0, 0x77);
+ __m128 negSampL = _mm_shuffle_ps(negSamp0, negSamp1, 0x88);
+ __m128 negSampR = _mm_shuffle_ps(negSamp0, negSamp1, 0xDD);
+
+ posSampL = _mm_mul_ps(posSampL, posCoef);
+ posSampR = _mm_mul_ps(posSampR, posCoef);
+ negSampL = _mm_mul_ps(negSampL, negCoef);
+ negSampR = _mm_mul_ps(negSampR, negCoef);
+
+ accL = _mm_add_ps(accL, posSampL);
+ accR = _mm_add_ps(accR, posSampR);
+ accL = _mm_add_ps(accL, negSampL);
+ accR = _mm_add_ps(accR, negSampR);
+ } break;
+ }
+ } while (count -= 4);
+
+ // multiply by volume and save
+ __m128 vLR = _mm_setzero_ps();
+ __m128 outSamp;
+ vLR = _mm_loadl_pi(vLR, reinterpret_cast<const __m64*>(volumeLR));
+ outSamp = _mm_loadl_pi(vLR, reinterpret_cast<__m64*>(out));
+
+ // combine and funnel down accumulator
+ __m128 outAccum = _mm_setzero_ps();
+ if (CHANNELS == 1) {
+ // duplicate accL to both L and R
+ outAccum = _mm_add_ps(accL, _mm_movehl_ps(accL, accL));
+ outAccum = _mm_add_ps(outAccum, _mm_shuffle_ps(outAccum, outAccum, 0x11));
+ } else if (CHANNELS == 2) {
+ // accR contains R, fold in
+ outAccum = _mm_hadd_ps(accL, accR);
+ outAccum = _mm_hadd_ps(outAccum, outAccum);
+ }
+
+ outAccum = _mm_mul_ps(outAccum, vLR);
+ outSamp = _mm_add_ps(outSamp, outAccum);
+ _mm_storel_pi(reinterpret_cast<__m64*>(out), outSamp);
+}
+
+template<>
+inline void ProcessL<1, 16>(float* const out,
+ int count,
+ const float* coefsP,
+ const float* coefsN,
+ const float* sP,
+ const float* sN,
+ const float* const volumeLR)
+{
+ ProcessSSEIntrinsic<1, 16, true>(out, count, coefsP, coefsN, sP, sN, volumeLR,
+ 0 /*lerpP*/, NULL /*coefsP1*/, NULL /*coefsN1*/);
+}
+
+template<>
+inline void ProcessL<2, 16>(float* const out,
+ int count,
+ const float* coefsP,
+ const float* coefsN,
+ const float* sP,
+ const float* sN,
+ const float* const volumeLR)
+{
+ ProcessSSEIntrinsic<2, 16, true>(out, count, coefsP, coefsN, sP, sN, volumeLR,
+ 0 /*lerpP*/, NULL /*coefsP1*/, NULL /*coefsN1*/);
+}
+
+template<>
+inline void Process<1, 16>(float* const out,
+ int count,
+ const float* coefsP,
+ const float* coefsN,
+ const float* coefsP1,
+ const float* coefsN1,
+ const float* sP,
+ const float* sN,
+ float lerpP,
+ const float* const volumeLR)
+{
+ ProcessSSEIntrinsic<1, 16, false>(out, count, coefsP, coefsN, sP, sN, volumeLR,
+ lerpP, coefsP1, coefsN1);
+}
+
+template<>
+inline void Process<2, 16>(float* const out,
+ int count,
+ const float* coefsP,
+ const float* coefsN,
+ const float* coefsP1,
+ const float* coefsN1,
+ const float* sP,
+ const float* sN,
+ float lerpP,
+ const float* const volumeLR)
+{
+ ProcessSSEIntrinsic<2, 16, false>(out, count, coefsP, coefsN, sP, sN, volumeLR,
+ lerpP, coefsP1, coefsN1);
+}
+
+#endif //USE_SSE
+
+} // namespace android
+
+#endif /*ANDROID_AUDIO_RESAMPLER_FIR_PROCESS_SSE_H*/
diff --git a/services/audioflinger/AudioResamplerSinc.h b/services/audioflinger/AudioResamplerSinc.h
index 0fbeac8..df8b45a 100644
--- a/services/audioflinger/AudioResamplerSinc.h
+++ b/services/audioflinger/AudioResamplerSinc.h
@@ -19,7 +19,7 @@
#include <stdint.h>
#include <sys/types.h>
-#include <cutils/log.h>
+#include <android/log.h>
#include "AudioResampler.h"
diff --git a/services/audioflinger/AudioWatchdog.h b/services/audioflinger/AudioWatchdog.h
index 4657530..7b69fc6 100644
--- a/services/audioflinger/AudioWatchdog.h
+++ b/services/audioflinger/AudioWatchdog.h
@@ -41,7 +41,7 @@
class AudioWatchdog : public Thread {
public:
- AudioWatchdog(unsigned periodMs = 50) : Thread(false /*canCallJava*/), mPaused(false),
+ explicit AudioWatchdog(unsigned periodMs = 50) : Thread(false /*canCallJava*/), mPaused(false),
mPeriodNs(periodMs * 1000000), mMaxCycleNs(mPeriodNs * 2),
// mOldTs
// mLogTs initialized below
diff --git a/services/audioflinger/AutoPark.h b/services/audioflinger/AutoPark.h
index e539e47..9ac7b65 100644
--- a/services/audioflinger/AutoPark.h
+++ b/services/audioflinger/AutoPark.h
@@ -21,7 +21,7 @@
public:
// Park the specific FastThread, which can be nullptr, in hot idle if not currently idling
- AutoPark(const sp<T>& fastThread) : mFastThread(fastThread)
+ explicit AutoPark(const sp<T>& fastThread) : mFastThread(fastThread)
{
mPreviousCommand = FastThreadState::HOT_IDLE;
if (fastThread != nullptr) {
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index f908d6d..09e7fd8 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -361,6 +361,8 @@
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO;
+ mConfig.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ ALOGV("Overriding auxiliary effect input as MONO and output as STEREO");
} else {
mConfig.inputCfg.channels = channelMask;
// TODO: Update this logic when multichannel effects are implemented.
@@ -1555,7 +1557,7 @@
}
// Must be called with EffectChain::mLock locked
-void AudioFlinger::EffectChain::clearInputBuffer_l(sp<ThreadBase> thread)
+void AudioFlinger::EffectChain::clearInputBuffer_l(const sp<ThreadBase>& thread)
{
// TODO: This will change in the future, depending on multichannel
// and sample format changes for effects.
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index 864d508..8fe0b96 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -385,7 +385,7 @@
// types or implementations from the suspend/restore mechanism.
bool isEffectEligibleForSuspend(const effect_descriptor_t& desc);
- void clearInputBuffer_l(sp<ThreadBase> thread);
+ void clearInputBuffer_l(const sp<ThreadBase>& thread);
void setThread(const sp<ThreadBase>& thread);
diff --git a/services/audioflinger/LinearMap.h b/services/audioflinger/LinearMap.h
index fca14dd..2220a0c 100644
--- a/services/audioflinger/LinearMap.h
+++ b/services/audioflinger/LinearMap.h
@@ -134,7 +134,7 @@
FIND_METHOD_START_VALUE, // No samples in history, using start value
};
- LinearMap(size_t size)
+ explicit LinearMap(size_t size)
: mSize(size),
mPos(0), // a circular buffer, so could start anywhere. the first sample is at 1.
mSamples(0),
diff --git a/services/audioflinger/PatchPanel.h b/services/audioflinger/PatchPanel.h
index 16ec278..d37c0d3 100644
--- a/services/audioflinger/PatchPanel.h
+++ b/services/audioflinger/PatchPanel.h
@@ -24,7 +24,7 @@
class Patch;
- PatchPanel(const sp<AudioFlinger>& audioFlinger);
+ explicit PatchPanel(const sp<AudioFlinger>& audioFlinger);
virtual ~PatchPanel();
/* List connected audio ports and their attributes */
@@ -54,7 +54,7 @@
class Patch {
public:
- Patch(const struct audio_patch *patch) :
+ explicit Patch(const struct audio_patch *patch) :
mAudioPatch(*patch), mHandle(AUDIO_PATCH_HANDLE_NONE),
mHalHandle(AUDIO_PATCH_HANDLE_NONE), mRecordPatchHandle(AUDIO_PATCH_HANDLE_NONE),
mPlaybackPatchHandle(AUDIO_PATCH_HANDLE_NONE) {}
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 7423ea9..2a29b1b 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -97,7 +97,7 @@
}
#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif
namespace android {
@@ -1153,7 +1153,7 @@
mSuspendedSessions.valueAt(index);
for (size_t i = 0; i < sessionEffects.size(); i++) {
- sp<SuspendedSessionDesc> desc = sessionEffects.valueAt(i);
+ const sp<SuspendedSessionDesc>& desc = sessionEffects.valueAt(i);
for (int j = 0; j < desc->mRefCount; j++) {
if (sessionEffects.keyAt(i) == EffectChain::kKeyForSuspendAll) {
chain->setEffectSuspendedAll_l(true);
@@ -2955,14 +2955,14 @@
}
status_t AudioFlinger::PlaybackThread::attachAuxEffect(
- const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
+ const sp<AudioFlinger::PlaybackThread::Track>& track, int EffectId)
{
Mutex::Autolock _l(mLock);
return attachAuxEffect_l(track, EffectId);
}
status_t AudioFlinger::PlaybackThread::attachAuxEffect_l(
- const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
+ const sp<AudioFlinger::PlaybackThread::Track>& track, int EffectId)
{
status_t status = NO_ERROR;
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index ebeabb5..b3b4cf2 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -97,7 +97,7 @@
sp<ConfigEventData> mData; // event specific parameter data
protected:
- ConfigEvent(int type, bool requiresSystemReady = false) :
+ explicit ConfigEvent(int type, bool requiresSystemReady = false) :
mType(type), mStatus(NO_ERROR), mWaitStatus(false),
mRequiresSystemReady(requiresSystemReady), mData(NULL) {}
};
@@ -149,7 +149,7 @@
class SetParameterConfigEventData : public ConfigEventData {
public:
- SetParameterConfigEventData(String8 keyValuePairs) :
+ explicit SetParameterConfigEventData(String8 keyValuePairs) :
mKeyValuePairs(keyValuePairs) {}
virtual void dump(char *buffer, size_t size) {
@@ -161,7 +161,7 @@
class SetParameterConfigEvent : public ConfigEvent {
public:
- SetParameterConfigEvent(String8 keyValuePairs) :
+ explicit SetParameterConfigEvent(String8 keyValuePairs) :
ConfigEvent(CFG_EVENT_SET_PARAMETER) {
mData = new SetParameterConfigEventData(keyValuePairs);
mWaitStatus = true;
@@ -196,7 +196,7 @@
class ReleaseAudioPatchConfigEventData : public ConfigEventData {
public:
- ReleaseAudioPatchConfigEventData(const audio_patch_handle_t handle) :
+ explicit ReleaseAudioPatchConfigEventData(const audio_patch_handle_t handle) :
mHandle(handle) {}
virtual void dump(char *buffer, size_t size) {
@@ -208,7 +208,7 @@
class ReleaseAudioPatchConfigEvent : public ConfigEvent {
public:
- ReleaseAudioPatchConfigEvent(const audio_patch_handle_t handle) :
+ explicit ReleaseAudioPatchConfigEvent(const audio_patch_handle_t handle) :
ConfigEvent(CFG_EVENT_RELEASE_AUDIO_PATCH) {
mData = new ReleaseAudioPatchConfigEventData(handle);
mWaitStatus = true;
@@ -218,7 +218,7 @@
class PMDeathRecipient : public IBinder::DeathRecipient {
public:
- PMDeathRecipient(const wp<ThreadBase>& thread) : mThread(thread) {}
+ explicit PMDeathRecipient(const wp<ThreadBase>& thread) : mThread(thread) {}
virtual ~PMDeathRecipient() {}
// IBinder::DeathRecipient
@@ -621,9 +621,9 @@
return reinterpret_cast<int16_t *>(mSinkBuffer); };
virtual void detachAuxEffect_l(int effectId);
- status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track,
+ status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track>& track,
int EffectId);
- status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track> track,
+ status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track>& track,
int EffectId);
virtual status_t addEffectChain_l(const sp<EffectChain>& chain);
@@ -1043,7 +1043,7 @@
class AsyncCallbackThread : public Thread {
public:
- AsyncCallbackThread(const wp<PlaybackThread>& playbackThread);
+ explicit AsyncCallbackThread(const wp<PlaybackThread>& playbackThread);
virtual ~AsyncCallbackThread();
@@ -1128,7 +1128,7 @@
class ResamplerBufferProvider : public AudioBufferProvider
{
public:
- ResamplerBufferProvider(RecordTrack* recordTrack) :
+ explicit ResamplerBufferProvider(RecordTrack* recordTrack) :
mRecordTrack(recordTrack),
mRsmpInUnrel(0), mRsmpInFront(0) { }
virtual ~ResamplerBufferProvider() { }
diff --git a/services/audioflinger/tests/resampler_tests.cpp b/services/audioflinger/tests/resampler_tests.cpp
index 9e375db..b0d384d 100644
--- a/services/audioflinger/tests/resampler_tests.cpp
+++ b/services/audioflinger/tests/resampler_tests.cpp
@@ -17,22 +17,25 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "audioflinger_resampler_tests"
-#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <fcntl.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
-#include <errno.h>
#include <time.h>
-#include <math.h>
-#include <vector>
-#include <utility>
+#include <unistd.h>
+
#include <iostream>
-#include <cutils/log.h>
+#include <utility>
+#include <vector>
+
#include <gtest/gtest.h>
+#include <log/log.h>
#include <media/AudioBufferProvider.h>
+
#include "AudioResampler.h"
#include "test_utils.h"
diff --git a/services/audioflinger/tests/test_utils.h b/services/audioflinger/tests/test_utils.h
index 283c768..b61a929 100644
--- a/services/audioflinger/tests/test_utils.h
+++ b/services/audioflinger/tests/test_utils.h
@@ -17,6 +17,12 @@
#ifndef ANDROID_AUDIO_TEST_UTILS_H
#define ANDROID_AUDIO_TEST_UTILS_H
+#ifndef LOG_TAG
+#define LOG_TAG "test_utils"
+#endif
+
+#include <log/log.h>
+
#include <audio_utils/sndfile.h>
#ifndef ARRAY_SIZE
diff --git a/services/audiopolicy/Android.mk b/services/audiopolicy/Android.mk
index c8e5148..9f6b300 100644
--- a/services/audiopolicy/Android.mk
+++ b/services/audiopolicy/Android.mk
@@ -19,20 +19,19 @@
endif
LOCAL_C_INCLUDES := \
- $(TOPDIR)frameworks/av/services/audioflinger \
+ frameworks/av/services/audioflinger \
$(call include-path-for, audio-effects) \
$(call include-path-for, audio-utils) \
- $(TOPDIR)frameworks/av/services/audiopolicy/common/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface \
- $(TOPDIR)frameworks/av/services/audiopolicy/utilities
+ frameworks/av/services/audiopolicy/common/include \
+ frameworks/av/services/audiopolicy/engine/interface \
+ frameworks/av/services/audiopolicy/utilities
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
liblog \
libbinder \
- libmedia \
- libhardware \
+ libaudioclient \
libhardware_legacy \
libserviceutility
@@ -76,7 +75,7 @@
parameter-framework.policy \
audio_policy_criteria.conf \
-LOCAL_C_INCLUDES += $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/include
+LOCAL_C_INCLUDES += frameworks/av/services/audiopolicy/engineconfigurable/include
LOCAL_SHARED_LIBRARIES += libaudiopolicyengineconfigurable
@@ -87,9 +86,9 @@
endif # ifeq ($(USE_CONFIGURABLE_AUDIO_POLICY), 1)
LOCAL_C_INCLUDES += \
- $(TOPDIR)frameworks/av/services/audiopolicy/common/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface \
- $(TOPDIR)frameworks/av/services/audiopolicy/utilities
+ frameworks/av/services/audiopolicy/common/include \
+ frameworks/av/services/audiopolicy/engine/interface \
+ frameworks/av/services/audiopolicy/utilities
LOCAL_STATIC_LIBRARIES := \
libmedia_helper \
@@ -125,8 +124,8 @@
libaudiopolicycomponents
LOCAL_C_INCLUDES += \
- $(TOPDIR)frameworks/av/services/audiopolicy/common/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface
+ frameworks/av/services/audiopolicy/common/include \
+ frameworks/av/services/audiopolicy/engine/interface
LOCAL_CFLAGS := -Wall -Werror
diff --git a/services/audiopolicy/AudioPolicyInterface.h b/services/audiopolicy/AudioPolicyInterface.h
index a215b95..d1b86da 100644
--- a/services/audiopolicy/AudioPolicyInterface.h
+++ b/services/audiopolicy/AudioPolicyInterface.h
@@ -81,6 +81,10 @@
// retrieve a device connection status
virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
const char *device_address) = 0;
+ // indicate a change in device configuration
+ virtual status_t handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name) = 0;
// indicate a change in phone state. Valid phones states are defined by audio_mode_t
virtual void setPhoneState(audio_mode_t state) = 0;
// force using a specific device category for the specified usage
@@ -220,7 +224,7 @@
virtual status_t releaseSoundTriggerSession(audio_session_t session) = 0;
- virtual status_t registerPolicyMixes(Vector<AudioMix> mixes) = 0;
+ virtual status_t registerPolicyMixes(const Vector<AudioMix>& mixes) = 0;
virtual status_t unregisterPolicyMixes(Vector<AudioMix> mixes) = 0;
virtual status_t startAudioSource(const struct audio_port_config *source,
diff --git a/services/audiopolicy/common/managerdefinitions/Android.mk b/services/audiopolicy/common/managerdefinitions/Android.mk
index d7da0ad..96591df 100644
--- a/services/audiopolicy/common/managerdefinitions/Android.mk
+++ b/services/audiopolicy/common/managerdefinitions/Android.mk
@@ -25,14 +25,17 @@
LOCAL_SHARED_LIBRARIES := \
libcutils \
+ libmedia \
libutils \
liblog \
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libmedia
+
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/common/include \
- $(TOPDIR)frameworks/av/services/audiopolicy \
- $(TOPDIR)frameworks/av/services/audiopolicy/utilities \
+ frameworks/av/services/audiopolicy/common/include \
+ frameworks/av/services/audiopolicy \
+ frameworks/av/services/audiopolicy/utilities \
ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)
@@ -43,8 +46,8 @@
LOCAL_SHARED_LIBRARIES += libicuuc
LOCAL_C_INCLUDES += \
- $(TOPDIR)external/libxml2/include \
- $(TOPDIR)external/icu/icu4c/source/common
+ external/libxml2/include \
+ external/icu/icu4c/source/common
else
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
index f2b39f2..e689320 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
@@ -34,7 +34,7 @@
class AudioInputDescriptor: public AudioPortConfig, public AudioSessionInfoProvider
{
public:
- AudioInputDescriptor(const sp<IOProfile>& profile);
+ explicit AudioInputDescriptor(const sp<IOProfile>& profile);
void setIoHandle(audio_io_handle_t ioHandle);
audio_port_handle_t getId() const;
audio_module_handle_t getModuleHandle() const;
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
index dd3f8ae..35bb021 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
@@ -45,7 +45,7 @@
audio_port_handle_t getId() const;
virtual audio_devices_t device() const;
- virtual bool sharesHwModuleWith(const sp<AudioOutputDescriptor> outputDesc);
+ virtual bool sharesHwModuleWith(const sp<AudioOutputDescriptor>& outputDesc);
virtual audio_devices_t supportedDevices();
virtual bool isDuplicated() const { return false; }
virtual uint32_t latency() { return 0; }
@@ -102,7 +102,7 @@
void setIoHandle(audio_io_handle_t ioHandle);
virtual audio_devices_t device() const;
- virtual bool sharesHwModuleWith(const sp<AudioOutputDescriptor> outputDesc);
+ virtual bool sharesHwModuleWith(const sp<AudioOutputDescriptor>& outputDesc);
virtual audio_devices_t supportedDevices();
virtual uint32_t latency();
virtual bool isDuplicated() const { return (mOutput1 != NULL && mOutput2 != NULL); }
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioPolicyMix.h b/services/audiopolicy/common/managerdefinitions/include/AudioPolicyMix.h
index 8f5ebef..c9652de 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioPolicyMix.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioPolicyMix.h
@@ -52,11 +52,11 @@
class AudioPolicyMixCollection : public DefaultKeyedVector<String8, sp<AudioPolicyMix> >
{
public:
- status_t getAudioPolicyMix(String8 address, sp<AudioPolicyMix> &policyMix) const;
+ status_t getAudioPolicyMix(const String8& address, sp<AudioPolicyMix> &policyMix) const;
- status_t registerMix(String8 address, AudioMix mix, sp<SwAudioOutputDescriptor> desc);
+ status_t registerMix(const String8& address, AudioMix mix, sp<SwAudioOutputDescriptor> desc);
- status_t unregisterMix(String8 address);
+ status_t unregisterMix(const String8& address);
void closeOutput(sp<SwAudioOutputDescriptor> &desc);
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioPort.h b/services/audiopolicy/common/managerdefinitions/include/AudioPort.h
index 211ec98..d00d49f 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioPort.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioPort.h
@@ -71,7 +71,7 @@
virtual void toAudioPort(struct audio_port *port) const;
- virtual void importAudioPort(const sp<AudioPort> port);
+ virtual void importAudioPort(const sp<AudioPort>& port);
void addAudioProfile(const sp<AudioProfile> &profile) { mProfiles.add(profile); }
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioRoute.h b/services/audiopolicy/common/managerdefinitions/include/AudioRoute.h
index 67e197f..df54f48 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioRoute.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioRoute.h
@@ -36,7 +36,7 @@
class AudioRoute : public virtual RefBase
{
public:
- AudioRoute(audio_route_type_t type) : mType(type) {}
+ explicit AudioRoute(audio_route_type_t type) : mType(type) {}
void setSources(const AudioPortVector &sources) { mSources = sources; }
const AudioPortVector &getSources() const { return mSources; }
diff --git a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
index ed2450c..9a52d22 100644
--- a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
@@ -30,7 +30,7 @@
{
public:
// Note that empty name refers by convention to a generic device.
- DeviceDescriptor(audio_devices_t type, const String8 &tagName = String8(""));
+ explicit DeviceDescriptor(audio_devices_t type, const String8 &tagName = String8(""));
virtual ~DeviceDescriptor() {}
@@ -48,7 +48,7 @@
// AudioPort
virtual void attach(const sp<HwModule>& module);
virtual void toAudioPort(struct audio_port *port) const;
- virtual void importAudioPort(const sp<AudioPort> port);
+ virtual void importAudioPort(const sp<AudioPort>& port);
audio_port_handle_t getId() const;
status_t dump(int fd, int spaces, int index, bool verbose = true) const;
@@ -76,11 +76,11 @@
audio_devices_t types() const { return mDeviceTypes; }
- sp<DeviceDescriptor> getDevice(audio_devices_t type, String8 address) const;
+ sp<DeviceDescriptor> getDevice(audio_devices_t type, const String8& address) const;
DeviceVector getDevicesFromType(audio_devices_t types) const;
sp<DeviceDescriptor> getDeviceFromId(audio_port_handle_t id) const;
sp<DeviceDescriptor> getDeviceFromTagName(const String8 &tagName) const;
- DeviceVector getDevicesFromTypeAddr(audio_devices_t type, String8 address) const;
+ DeviceVector getDevicesFromTypeAddr(audio_devices_t type, const String8& address) const;
audio_devices_t getDevicesFromHwModule(audio_module_handle_t moduleHandle) const;
diff --git a/services/audiopolicy/common/managerdefinitions/include/HwModule.h b/services/audiopolicy/common/managerdefinitions/include/HwModule.h
index dd2993d..3a31672 100644
--- a/services/audiopolicy/common/managerdefinitions/include/HwModule.h
+++ b/services/audiopolicy/common/managerdefinitions/include/HwModule.h
@@ -40,7 +40,7 @@
class HwModule : public RefBase
{
public:
- HwModule(const char *name, uint32_t halVersion = AUDIO_DEVICE_API_VERSION_MIN);
+ explicit HwModule(const char *name, uint32_t halVersion = AUDIO_DEVICE_API_VERSION_MIN);
~HwModule();
const char *getName() const { return mName.string(); }
@@ -66,12 +66,12 @@
status_t addInputProfile(const sp<IOProfile> &profile);
status_t addProfile(const sp<IOProfile> &profile);
- status_t addOutputProfile(String8 name, const audio_config_t *config,
- audio_devices_t device, String8 address);
- status_t removeOutputProfile(String8 name);
- status_t addInputProfile(String8 name, const audio_config_t *config,
- audio_devices_t device, String8 address);
- status_t removeInputProfile(String8 name);
+ status_t addOutputProfile(const String8& name, const audio_config_t *config,
+ audio_devices_t device, const String8& address);
+ status_t removeOutputProfile(const String8& name);
+ status_t addInputProfile(const String8& name, const audio_config_t *config,
+ audio_devices_t device, const String8& address);
+ status_t removeInputProfile(const String8& name);
audio_module_handle_t getHandle() const { return mHandle; }
diff --git a/services/audiopolicy/common/managerdefinitions/include/IOProfile.h b/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
index dd20e93..ec04ef7 100644
--- a/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
+++ b/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
@@ -44,7 +44,7 @@
// For input, flags is interpreted as audio_input_flags_t.
// TODO: merge audio_output_flags_t and audio_input_flags_t.
bool isCompatibleProfile(audio_devices_t device,
- String8 address,
+ const String8& address,
uint32_t samplingRate,
uint32_t *updatedSamplingRate,
audio_format_t format,
@@ -110,13 +110,13 @@
class InputProfile : public IOProfile
{
public:
- InputProfile(const String8 &name) : IOProfile(name, AUDIO_PORT_ROLE_SINK) {}
+ explicit InputProfile(const String8 &name) : IOProfile(name, AUDIO_PORT_ROLE_SINK) {}
};
class OutputProfile : public IOProfile
{
public:
- OutputProfile(const String8 &name) : IOProfile(name, AUDIO_PORT_ROLE_SOURCE) {}
+ explicit OutputProfile(const String8 &name) : IOProfile(name, AUDIO_PORT_ROLE_SOURCE) {}
};
}; // namespace android
diff --git a/services/audiopolicy/common/managerdefinitions/include/SessionRoute.h b/services/audiopolicy/common/managerdefinitions/include/SessionRoute.h
index b4feaf0..75bfd9d 100644
--- a/services/audiopolicy/common/managerdefinitions/include/SessionRoute.h
+++ b/services/audiopolicy/common/managerdefinitions/include/SessionRoute.h
@@ -86,7 +86,7 @@
MAPTYPE_OUTPUT = 1
} session_route_map_type_t;
- SessionRouteMap(session_route_map_type_t mapType) :
+ explicit SessionRouteMap(session_route_map_type_t mapType) :
mMapType(mapType)
{}
@@ -106,7 +106,7 @@
void addRoute(audio_session_t session,
audio_stream_type_t streamType,
audio_source_t source,
- sp<DeviceDescriptor> deviceDescriptor,
+ const sp<DeviceDescriptor>& deviceDescriptor,
uid_t uid);
private:
diff --git a/services/audiopolicy/common/managerdefinitions/include/TypeConverter.h b/services/audiopolicy/common/managerdefinitions/include/TypeConverter.h
index 1612714..579eb31 100644
--- a/services/audiopolicy/common/managerdefinitions/include/TypeConverter.h
+++ b/services/audiopolicy/common/managerdefinitions/include/TypeConverter.h
@@ -131,6 +131,17 @@
typedef TypeConverter<StreamTraits> StreamTypeConverter;
typedef TypeConverter<DeviceCategoryTraits> DeviceCategoryConverter;
+template<> const DeviceConverter::Table DeviceConverter::mTable[];
+template<> const OutputFlagConverter::Table OutputFlagConverter::mTable[];
+template<> const InputFlagConverter::Table InputFlagConverter::mTable[];
+template<> const FormatConverter::Table FormatConverter::mTable[];
+template<> const OutputChannelConverter::Table OutputChannelConverter::mTable[];
+template<> const InputChannelConverter::Table InputChannelConverter::mTable[];
+template<> const ChannelIndexConverter::Table ChannelIndexConverter::mTable[];
+template<> const GainModeConverter::Table GainModeConverter::mTable[];
+template<> const DeviceCategoryConverter::Table DeviceCategoryConverter::mTable[];
+template<> const StreamTypeConverter::Table StreamTypeConverter::mTable[];
+
inline
static SampleRateTraits::Collection samplingRatesFromString(const std::string &samplingRates,
const char *del = "|")
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
index 79bbc54..1dbc3d0 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
@@ -75,7 +75,7 @@
}
bool AudioOutputDescriptor::sharesHwModuleWith(
- const sp<AudioOutputDescriptor> outputDesc)
+ const sp<AudioOutputDescriptor>& outputDesc)
{
if (outputDesc->isDuplicated()) {
return sharesHwModuleWith(outputDesc->subOutput1()) ||
@@ -264,7 +264,7 @@
}
bool SwAudioOutputDescriptor::sharesHwModuleWith(
- const sp<AudioOutputDescriptor> outputDesc)
+ const sp<AudioOutputDescriptor>& outputDesc)
{
if (isDuplicated()) {
return mOutput1->sharesHwModuleWith(outputDesc) || mOutput2->sharesHwModuleWith(outputDesc);
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp
index f382dec..6059009 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp
@@ -20,7 +20,8 @@
#include "AudioPatch.h"
#include "AudioGain.h"
#include "TypeConverter.h"
-#include <cutils/log.h>
+
+#include <log/log.h>
#include <utils/String8.h>
namespace android {
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
index 7ee98b6..02833a9 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
@@ -51,7 +51,7 @@
return &mMix;
}
-status_t AudioPolicyMixCollection::registerMix(String8 address, AudioMix mix,
+status_t AudioPolicyMixCollection::registerMix(const String8& address, AudioMix mix,
sp<SwAudioOutputDescriptor> desc)
{
ssize_t index = indexOfKey(address);
@@ -70,7 +70,7 @@
return NO_ERROR;
}
-status_t AudioPolicyMixCollection::unregisterMix(String8 address)
+status_t AudioPolicyMixCollection::unregisterMix(const String8& address)
{
ssize_t index = indexOfKey(address);
if (index < 0) {
@@ -82,7 +82,7 @@
return NO_ERROR;
}
-status_t AudioPolicyMixCollection::getAudioPolicyMix(String8 address,
+status_t AudioPolicyMixCollection::getAudioPolicyMix(const String8& address,
sp<AudioPolicyMix> &policyMix) const
{
ssize_t index = indexOfKey(address);
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp
index 17ed537..31bf95c 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp
@@ -127,7 +127,7 @@
port->num_gains = i;
}
-void AudioPort::importAudioPort(const sp<AudioPort> port)
+void AudioPort::importAudioPort(const sp<AudioPort>& port)
{
size_t indexToImport;
for (indexToImport = 0; indexToImport < port->mProfiles.size(); indexToImport++) {
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioSession.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioSession.cpp
index da983c5..a246c3d 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioSession.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioSession.cpp
@@ -21,7 +21,8 @@
#include "AudioSession.h"
#include "AudioGain.h"
#include "TypeConverter.h"
-#include <cutils/log.h>
+
+#include <log/log.h>
#include <utils/String8.h>
namespace android {
diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
index 50453ad..ba2b9e3 100644
--- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
@@ -128,7 +128,7 @@
return devices;
}
-sp<DeviceDescriptor> DeviceVector::getDevice(audio_devices_t type, String8 address) const
+sp<DeviceDescriptor> DeviceVector::getDevice(audio_devices_t type, const String8& address) const
{
sp<DeviceDescriptor> device;
for (size_t i = 0; i < size(); i++) {
@@ -177,7 +177,7 @@
}
DeviceVector DeviceVector::getDevicesFromTypeAddr(
- audio_devices_t type, String8 address) const
+ audio_devices_t type, const String8& address) const
{
DeviceVector devices;
for (size_t i = 0; i < size(); i++) {
@@ -263,7 +263,7 @@
strncpy(port->ext.device.address, mAddress.string(), AUDIO_DEVICE_MAX_ADDRESS_LEN);
}
-void DeviceDescriptor::importAudioPort(const sp<AudioPort> port) {
+void DeviceDescriptor::importAudioPort(const sp<AudioPort>& port) {
AudioPort::importAudioPort(port);
port->pickAudioProfile(mSamplingRate, mChannelMask, mFormat);
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
index a85c07f..7a942cd 100644
--- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
@@ -42,8 +42,8 @@
}
}
-status_t HwModule::addOutputProfile(String8 name, const audio_config_t *config,
- audio_devices_t device, String8 address)
+status_t HwModule::addOutputProfile(const String8 &name, const audio_config_t *config,
+ audio_devices_t device, const String8 &address)
{
sp<IOProfile> profile = new OutputProfile(name);
@@ -93,7 +93,7 @@
}
}
-status_t HwModule::removeOutputProfile(String8 name)
+status_t HwModule::removeOutputProfile(const String8& name)
{
for (size_t i = 0; i < mOutputProfiles.size(); i++) {
if (mOutputProfiles[i]->getName() == name) {
@@ -105,8 +105,8 @@
return NO_ERROR;
}
-status_t HwModule::addInputProfile(String8 name, const audio_config_t *config,
- audio_devices_t device, String8 address)
+status_t HwModule::addInputProfile(const String8& name, const audio_config_t *config,
+ audio_devices_t device, const String8& address)
{
sp<IOProfile> profile = new InputProfile(name);
profile->addAudioProfile(new AudioProfile(config->format, config->channel_mask,
@@ -122,7 +122,7 @@
return addInputProfile(profile);
}
-status_t HwModule::removeInputProfile(String8 name)
+status_t HwModule::removeInputProfile(const String8& name)
{
for (size_t i = 0; i < mInputProfiles.size(); i++) {
if (mInputProfiles[i]->getName() == name) {
diff --git a/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp b/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
index abf2dd4..57f2534 100644
--- a/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
@@ -28,7 +28,7 @@
// Sampling rate, format and channel mask must be specified in order to
// get a valid a match
bool IOProfile::isCompatibleProfile(audio_devices_t device,
- String8 address,
+ const String8& address,
uint32_t samplingRate,
uint32_t *updatedSamplingRate,
audio_format_t format,
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 3e5bb7d..2ecd6b1 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -383,6 +383,7 @@
sp<AudioPort> source = ctx->findPortByTagName(String8(devTag));
if (source == NULL) {
ALOGE("%s: no source found with name=%s", __FUNCTION__, devTag);
+ free(sourcesLiteral);
return BAD_VALUE;
}
sources.add(source);
diff --git a/services/audiopolicy/common/managerdefinitions/src/SessionRoute.cpp b/services/audiopolicy/common/managerdefinitions/src/SessionRoute.cpp
index 7ecfa44..689f4e6 100644
--- a/services/audiopolicy/common/managerdefinitions/src/SessionRoute.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/SessionRoute.cpp
@@ -90,7 +90,7 @@
void SessionRouteMap::addRoute(audio_session_t session,
audio_stream_type_t streamType,
audio_source_t source,
- sp<DeviceDescriptor> descriptor,
+ const sp<DeviceDescriptor>& descriptor,
uid_t uid)
{
if (mMapType == MAPTYPE_INPUT && streamType != SessionRoute::STREAM_TYPE_NA) {
diff --git a/services/audiopolicy/config/a2dp_audio_policy_configuration.xml b/services/audiopolicy/config/a2dp_audio_policy_configuration.xml
index ced7463..7bcab5c 100644
--- a/services/audiopolicy/config/a2dp_audio_policy_configuration.xml
+++ b/services/audiopolicy/config/a2dp_audio_policy_configuration.xml
@@ -2,11 +2,7 @@
<!-- A2dp Audio HAL Audio Policy Configuration file -->
<module name="a2dp" halVersion="2.0">
<mixPorts>
- <mixPort name="a2dp output" role="source">
- <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
- samplingRates="44100"
- channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
- </mixPort>
+ <mixPort name="a2dp output" role="source"/>
<mixPort name="a2dp input" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000"
diff --git a/services/audiopolicy/engineconfigurable/Android.mk b/services/audiopolicy/engineconfigurable/Android.mk
index 6dba75b..1924d1d 100755
--- a/services/audiopolicy/engineconfigurable/Android.mk
+++ b/services/audiopolicy/engineconfigurable/Android.mk
@@ -16,9 +16,9 @@
src/InputSource.cpp \
audio_policy_engine_includes_common := \
- $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/interface \
- $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface
+ frameworks/av/services/audiopolicy/engineconfigurable/include \
+ frameworks/av/services/audiopolicy/engineconfigurable/interface \
+ frameworks/av/services/audiopolicy/engine/interface
LOCAL_CFLAGS += \
-Wall \
@@ -33,7 +33,7 @@
$(TARGET_OUT_HEADERS)/hw \
$(call include-path-for, frameworks-av) \
$(call include-path-for, audio-utils) \
- $(TOPDIR)frameworks/av/services/audiopolicy/common/include
+ frameworks/av/services/audiopolicy/common/include
LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
@@ -46,6 +46,7 @@
libxml2
LOCAL_SHARED_LIBRARIES := \
+ liblog \
libcutils \
libutils \
libaudioutils \
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.mk b/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.mk
index 0e44f2c..3559cf1 100755
--- a/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.mk
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.mk
@@ -21,9 +21,9 @@
-fvisibility=hidden
LOCAL_C_INCLUDES := \
- $(TOPDIR)frameworks/av/services/audiopolicy/common/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/interface \
+ frameworks/av/services/audiopolicy/common/include \
+ frameworks/av/services/audiopolicy/engineconfigurable/include \
+ frameworks/av/services/audiopolicy/engineconfigurable/interface \
LOCAL_SHARED_LIBRARIES := \
libaudiopolicyengineconfigurable \
diff --git a/services/audiopolicy/engineconfigurable/wrapper/Android.mk b/services/audiopolicy/engineconfigurable/wrapper/Android.mk
index f4283a8..9788e0e 100644
--- a/services/audiopolicy/engineconfigurable/wrapper/Android.mk
+++ b/services/audiopolicy/engineconfigurable/wrapper/Android.mk
@@ -8,16 +8,18 @@
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
- $(TARGET_OUT_HEADERS)/parameter \
- $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/interface \
- $(TOPDIR)frameworks/av/services/audiopolicy/utilities/convert \
+ frameworks/av/services/audiopolicy/engineconfigurable/include \
+ frameworks/av/services/audiopolicy/engineconfigurable/interface \
+ frameworks/av/services/audiopolicy/utilities/convert \
LOCAL_SRC_FILES:= ParameterManagerWrapper.cpp
LOCAL_STATIC_LIBRARIES := \
libmedia_helper \
+LOCAL_SHARED_LIBRARIES := \
+ libparameter \
+
LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
LOCAL_MODULE:= libaudiopolicypfwwrapper
diff --git a/services/audiopolicy/engineconfigurable/wrapper/ParameterManagerWrapper.cpp b/services/audiopolicy/engineconfigurable/wrapper/ParameterManagerWrapper.cpp
index 6872e52..fe15d86 100755
--- a/services/audiopolicy/engineconfigurable/wrapper/ParameterManagerWrapper.cpp
+++ b/services/audiopolicy/engineconfigurable/wrapper/ParameterManagerWrapper.cpp
@@ -48,7 +48,7 @@
virtual void info(const string &log)
{
- ALOGD("policy-parameter-manager: %s", log.c_str());
+ ALOGV("policy-parameter-manager: %s", log.c_str());
}
virtual void warning(const string &log)
{
diff --git a/services/audiopolicy/enginedefault/Android.mk b/services/audiopolicy/enginedefault/Android.mk
index 85d1822..6a5655d 100755
--- a/services/audiopolicy/enginedefault/Android.mk
+++ b/services/audiopolicy/enginedefault/Android.mk
@@ -11,7 +11,7 @@
audio_policy_engine_includes_common := \
$(LOCAL_PATH)/include \
- $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface
+ frameworks/av/services/audiopolicy/engine/interface
LOCAL_CFLAGS += \
-Wall \
@@ -27,7 +27,7 @@
$(call include-path-for, frameworks-av) \
$(call include-path-for, audio-utils) \
$(call include-path-for, bionic) \
- $(TOPDIR)frameworks/av/services/audiopolicy/common/include
+ frameworks/av/services/audiopolicy/common/include
LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
@@ -40,8 +40,8 @@
libxml2
LOCAL_SHARED_LIBRARIES += \
+ liblog \
libcutils \
libutils \
- libaudioutils \
include $(BUILD_SHARED_LIBRARY)
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index d31429c..44683df 100755
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -418,6 +418,25 @@
(mForceUse[AUDIO_POLICY_FORCE_FOR_SYSTEM] == AUDIO_POLICY_FORCE_SYSTEM_ENFORCED)) {
device = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
}
+
+ // if SCO headset is connected and we are told to use it, play ringtone over
+ // speaker and BT SCO
+ if (((availableOutputDevicesType & AUDIO_DEVICE_OUT_ALL_SCO) != 0) &&
+ (mForceUse[AUDIO_POLICY_FORCE_FOR_COMMUNICATION] == AUDIO_POLICY_FORCE_BT_SCO)) {
+ uint32_t device2 = AUDIO_DEVICE_NONE;
+ device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
+ if (device2 == AUDIO_DEVICE_NONE) {
+ device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
+ }
+ if (device2 == AUDIO_DEVICE_NONE) {
+ device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO;
+ }
+
+ if (device2 != AUDIO_DEVICE_NONE) {
+ device |= device2;
+ break;
+ }
+ }
// The second device used for sonification is the same as the device used by media strategy
// FALL THROUGH
diff --git a/services/audiopolicy/enginedefault/src/Engine.h b/services/audiopolicy/enginedefault/src/Engine.h
index 606ad28..57538c4 100755
--- a/services/audiopolicy/enginedefault/src/Engine.h
+++ b/services/audiopolicy/enginedefault/src/Engine.h
@@ -43,7 +43,7 @@
class ManagerInterfaceImpl : public AudioPolicyManagerInterface
{
public:
- ManagerInterfaceImpl(Engine *policyEngine)
+ explicit ManagerInterfaceImpl(Engine *policyEngine)
: mPolicyEngine(policyEngine) {}
virtual void setObserver(AudioPolicyManagerObserver *observer)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index d265f11..8cb5e0f 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -64,6 +64,17 @@
return setDeviceConnectionStateInt(device, state, device_address, device_name);
}
+void AudioPolicyManager::broadcastDeviceConnectionState(audio_devices_t device,
+ audio_policy_dev_state_t state,
+ const String8 &device_address)
+{
+ AudioParameter param(device_address);
+ const String8 key(state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE ?
+ AUDIO_PARAMETER_DEVICE_CONNECT : AUDIO_PARAMETER_DEVICE_DISCONNECT);
+ param.addInt(key, device);
+ mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
+}
+
status_t AudioPolicyManager::setDeviceConnectionStateInt(audio_devices_t device,
audio_policy_dev_state_t state,
const char *device_address,
@@ -112,8 +123,15 @@
return NO_MEMORY;
}
+ // Before checking outputs, broadcast connect event to allow HAL to retrieve dynamic
+ // parameters on newly connected devices (instead of opening the outputs...)
+ broadcastDeviceConnectionState(device, state, devDesc->mAddress);
+
if (checkOutputsForDevice(devDesc, state, outputs, devDesc->mAddress) != NO_ERROR) {
mAvailableOutputDevices.remove(devDesc);
+
+ broadcastDeviceConnectionState(device, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
+ devDesc->mAddress);
return INVALID_OPERATION;
}
// Propagate device availability to Engine
@@ -125,11 +143,6 @@
ALOGV("setDeviceConnectionState() checkOutputsForDevice() returned %zu outputs",
outputs.size());
- // Send connect to HALs
- AudioParameter param = AudioParameter(devDesc->mAddress);
- param.addInt(String8(AUDIO_PARAMETER_DEVICE_CONNECT), device);
- mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
-
} break;
// handle output device disconnection
case AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE: {
@@ -141,9 +154,7 @@
ALOGV("setDeviceConnectionState() disconnecting output device %x", device);
// Send Disconnect to HALs
- AudioParameter param = AudioParameter(devDesc->mAddress);
- param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device);
- mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
+ broadcastDeviceConnectionState(device, state, devDesc->mAddress);
// remove device from available output devices
mAvailableOutputDevices.remove(devDesc);
@@ -226,7 +237,14 @@
device);
return INVALID_OPERATION;
}
+
+ // Before checking intputs, broadcast connect event to allow HAL to retrieve dynamic
+ // parameters on newly connected devices (instead of opening the inputs...)
+ broadcastDeviceConnectionState(device, state, devDesc->mAddress);
+
if (checkInputsForDevice(devDesc, state, inputs, devDesc->mAddress) != NO_ERROR) {
+ broadcastDeviceConnectionState(device, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
+ devDesc->mAddress);
return INVALID_OPERATION;
}
@@ -237,11 +255,6 @@
return NO_MEMORY;
}
- // Set connect to HALs
- AudioParameter param = AudioParameter(devDesc->mAddress);
- param.addInt(String8(AUDIO_PARAMETER_DEVICE_CONNECT), device);
- mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
-
// Propagate device availability to Engine
mEngine->setDeviceConnectionState(devDesc, state);
} break;
@@ -256,9 +269,7 @@
ALOGV("setDeviceConnectionState() disconnecting input device %x", device);
// Set Disconnect to HALs
- AudioParameter param = AudioParameter(devDesc->mAddress);
- param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device);
- mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
+ broadcastDeviceConnectionState(device, state, devDesc->mAddress);
checkInputsForDevice(devDesc, state, inputs, devDesc->mAddress);
mAvailableInputDevices.remove(devDesc);
@@ -322,6 +333,50 @@
AUDIO_POLICY_DEVICE_STATE_AVAILABLE : AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
}
+status_t AudioPolicyManager::handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name)
+{
+ status_t status;
+
+ ALOGV("handleDeviceConfigChange(() device: 0x%X, address %s name %s",
+ device, device_address, device_name);
+
+ // connect/disconnect only 1 device at a time
+ if (!audio_is_output_device(device) && !audio_is_input_device(device)) return BAD_VALUE;
+
+ // Check if the device is currently connected
+ sp<DeviceDescriptor> devDesc =
+ mHwModules.getDeviceDescriptor(device, device_address, device_name);
+ ssize_t index = mAvailableOutputDevices.indexOf(devDesc);
+ if (index < 0) {
+ // Nothing to do: device is not connected
+ return NO_ERROR;
+ }
+
+ // Toggle the device state: UNAVAILABLE -> AVAILABLE
+ // This will force reading again the device configuration
+ status = setDeviceConnectionState(device,
+ AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
+ device_address, device_name);
+ if (status != NO_ERROR) {
+ ALOGW("handleDeviceConfigChange() error disabling connection state: %d",
+ status);
+ return status;
+ }
+
+ status = setDeviceConnectionState(device,
+ AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
+ device_address, device_name);
+ if (status != NO_ERROR) {
+ ALOGW("handleDeviceConfigChange() error enabling connection state: %d",
+ status);
+ return status;
+ }
+
+ return NO_ERROR;
+}
+
uint32_t AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, uint32_t delayMs)
{
bool createTxPatch = false;
@@ -1148,7 +1203,7 @@
return status;
}
-status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc,
+status_t AudioPolicyManager::startSource(const sp<AudioOutputDescriptor>& outputDesc,
audio_stream_type_t stream,
audio_devices_t device,
const char *address,
@@ -1286,7 +1341,7 @@
return stopSource(outputDesc, stream, forceDeviceUpdate);
}
-status_t AudioPolicyManager::stopSource(sp<AudioOutputDescriptor> outputDesc,
+status_t AudioPolicyManager::stopSource(const sp<AudioOutputDescriptor>& outputDesc,
audio_stream_type_t stream,
bool forceDeviceUpdate)
{
@@ -2094,7 +2149,7 @@
// - 2 if none found, look for a mix matching the attributes usage
// - 3 if none found, default to device and output selection by policy rules.
-status_t AudioPolicyManager::registerPolicyMixes(Vector<AudioMix> mixes)
+status_t AudioPolicyManager::registerPolicyMixes(const Vector<AudioMix>& mixes)
{
ALOGV("registerPolicyMixes() %zu mix(es)", mixes.size());
status_t res = NO_ERROR;
@@ -3633,7 +3688,7 @@
// ---
-void AudioPolicyManager::addOutput(audio_io_handle_t output, sp<SwAudioOutputDescriptor> outputDesc)
+void AudioPolicyManager::addOutput(audio_io_handle_t output, const sp<SwAudioOutputDescriptor>& outputDesc)
{
outputDesc->setIoHandle(output);
mOutputs.add(output, outputDesc);
@@ -3646,16 +3701,16 @@
mOutputs.removeItem(output);
}
-void AudioPolicyManager::addInput(audio_io_handle_t input, sp<AudioInputDescriptor> inputDesc)
+void AudioPolicyManager::addInput(audio_io_handle_t input, const sp<AudioInputDescriptor>& inputDesc)
{
inputDesc->setIoHandle(input);
mInputs.add(input, inputDesc);
nextAudioPortGeneration();
}
-void AudioPolicyManager::findIoHandlesByAddress(sp<SwAudioOutputDescriptor> desc /*in*/,
+void AudioPolicyManager::findIoHandlesByAddress(const sp<SwAudioOutputDescriptor>& desc /*in*/,
const audio_devices_t device /*in*/,
- const String8 address /*in*/,
+ const String8& address /*in*/,
SortedVector<audio_io_handle_t>& outputs /*out*/) {
sp<DeviceDescriptor> devDesc =
desc->mProfile->getSupportedDeviceByAddress(device, address);
@@ -3666,10 +3721,10 @@
}
}
-status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor> devDesc,
+status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor>& devDesc,
audio_policy_dev_state_t state,
SortedVector<audio_io_handle_t>& outputs,
- const String8 address)
+ const String8& address)
{
audio_devices_t device = devDesc->type();
sp<SwAudioOutputDescriptor> desc;
@@ -3912,10 +3967,10 @@
return NO_ERROR;
}
-status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor> devDesc,
+status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor>& devDesc,
audio_policy_dev_state_t state,
SortedVector<audio_io_handle_t>& inputs,
- const String8 address)
+ const String8& address)
{
audio_devices_t device = devDesc->type();
sp<AudioInputDescriptor> desc;
@@ -4156,13 +4211,13 @@
SortedVector<audio_io_handle_t> AudioPolicyManager::getOutputsForDevice(
audio_devices_t device,
- SwAudioOutputCollection openOutputs)
+ const SwAudioOutputCollection& openOutputs)
{
SortedVector<audio_io_handle_t> outputs;
ALOGVV("getOutputsForDevice() device %04x", device);
for (size_t i = 0; i < openOutputs.size(); i++) {
- ALOGVV("output %d isDuplicated=%d device=%04x",
+ ALOGVV("output %zu isDuplicated=%d device=%04x",
i, openOutputs.valueAt(i)->isDuplicated(),
openOutputs.valueAt(i)->supportedDevices());
if ((device & openOutputs.valueAt(i)->supportedDevices()) == device) {
@@ -4567,7 +4622,7 @@
mPreviousOutputs = mOutputs;
}
-uint32_t AudioPolicyManager::checkDeviceMuteStrategies(sp<AudioOutputDescriptor> outputDesc,
+uint32_t AudioPolicyManager::checkDeviceMuteStrategies(const sp<AudioOutputDescriptor>& outputDesc,
audio_devices_t prevDevice,
uint32_t delayMs)
{
@@ -4603,7 +4658,7 @@
== AUDIO_DEVICE_NONE) {
continue;
}
- ALOGVV("checkDeviceMuteStrategies() %s strategy %d (curDevice %04x)",
+ ALOGVV("checkDeviceMuteStrategies() %s strategy %zu (curDevice %04x)",
mute ? "muting" : "unmuting", i, curDevice);
setStrategyMute((routing_strategy)i, mute, desc, mute ? 0 : delayMs);
if (isStrategyActive(desc, (routing_strategy)i)) {
@@ -4889,7 +4944,7 @@
}
sp<IOProfile> AudioPolicyManager::getInputProfile(audio_devices_t device,
- String8 address,
+ const String8& address,
uint32_t& samplingRate,
audio_format_t& format,
audio_channel_mask_t& channelMask,
@@ -5275,7 +5330,7 @@
return true;
}
-bool AudioPolicyManager::isStrategyActive(const sp<AudioOutputDescriptor> outputDesc,
+bool AudioPolicyManager::isStrategyActive(const sp<AudioOutputDescriptor>& outputDesc,
routing_strategy strategy, uint32_t inPastMs,
nsecs_t sysTime) const
{
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 71bcd5f..3cfe508 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -83,7 +83,7 @@
{
public:
- AudioPolicyManager(AudioPolicyClientInterface *clientInterface);
+ explicit AudioPolicyManager(AudioPolicyClientInterface *clientInterface);
virtual ~AudioPolicyManager();
// AudioPolicyInterface
@@ -93,6 +93,9 @@
const char *device_name);
virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
const char *device_address);
+ virtual status_t handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name);
virtual void setPhoneState(audio_mode_t state);
virtual void setForceUse(audio_policy_force_use_t usage,
audio_policy_forced_cfg_t config);
@@ -222,7 +225,7 @@
return mSoundTriggerSessions.releaseSession(session);
}
- virtual status_t registerPolicyMixes(Vector<AudioMix> mixes);
+ virtual status_t registerPolicyMixes(const Vector<AudioMix>& mixes);
virtual status_t unregisterPolicyMixes(Vector<AudioMix> mixes);
virtual status_t startAudioSource(const struct audio_port_config *source,
@@ -273,9 +276,9 @@
return mDefaultOutputDevice;
}
protected:
- void addOutput(audio_io_handle_t output, sp<SwAudioOutputDescriptor> outputDesc);
+ void addOutput(audio_io_handle_t output, const sp<SwAudioOutputDescriptor>& outputDesc);
void removeOutput(audio_io_handle_t output);
- void addInput(audio_io_handle_t input, sp<AudioInputDescriptor> inputDesc);
+ void addInput(audio_io_handle_t input, const sp<AudioInputDescriptor>& inputDesc);
// return appropriate device for streams handled by the specified strategy according to current
// phone state, connected devices...
@@ -291,7 +294,7 @@
virtual audio_devices_t getDeviceForStrategy(routing_strategy strategy,
bool fromCache);
- bool isStrategyActive(const sp<AudioOutputDescriptor> outputDesc, routing_strategy strategy,
+ bool isStrategyActive(const sp<AudioOutputDescriptor>& outputDesc, routing_strategy strategy,
uint32_t inPastMs = 0, nsecs_t sysTime = 0) const;
// change the route of the specified output. Returns the number of ms we have slept to
@@ -362,15 +365,15 @@
// when a device is disconnected, checks if an output is not used any more and
// returns its handle if any.
// transfers the audio tracks and effects from one output thread to another accordingly.
- status_t checkOutputsForDevice(const sp<DeviceDescriptor> devDesc,
+ status_t checkOutputsForDevice(const sp<DeviceDescriptor>& devDesc,
audio_policy_dev_state_t state,
SortedVector<audio_io_handle_t>& outputs,
- const String8 address);
+ const String8& address);
- status_t checkInputsForDevice(const sp<DeviceDescriptor> devDesc,
+ status_t checkInputsForDevice(const sp<DeviceDescriptor>& devDesc,
audio_policy_dev_state_t state,
SortedVector<audio_io_handle_t>& inputs,
- const String8 address);
+ const String8& address);
// close an output and its companion duplicating output.
void closeOutput(audio_io_handle_t output);
@@ -423,7 +426,7 @@
#endif //AUDIO_POLICY_TEST
SortedVector<audio_io_handle_t> getOutputsForDevice(audio_devices_t device,
- SwAudioOutputCollection openOutputs);
+ const SwAudioOutputCollection& openOutputs);
bool vectorsEqual(SortedVector<audio_io_handle_t>& outputs1,
SortedVector<audio_io_handle_t>& outputs2);
@@ -431,7 +434,7 @@
// if muting, wait for the audio in pcm buffer to be drained before proceeding
// if unmuting, unmute only after the specified delay
// Returns the number of ms waited
- virtual uint32_t checkDeviceMuteStrategies(sp<AudioOutputDescriptor> outputDesc,
+ virtual uint32_t checkDeviceMuteStrategies(const sp<AudioOutputDescriptor>& outputDesc,
audio_devices_t prevDevice,
uint32_t delayMs);
@@ -440,7 +443,7 @@
audio_format_t format);
// samplingRate, format, channelMask are in/out and so may be modified
sp<IOProfile> getInputProfile(audio_devices_t device,
- String8 address,
+ const String8& address,
uint32_t& samplingRate,
audio_format_t& format,
audio_channel_mask_t& channelMask,
@@ -481,12 +484,12 @@
// if argument "device" is different from AUDIO_DEVICE_NONE, startSource() will force
// the re-evaluation of the output device.
- status_t startSource(sp<AudioOutputDescriptor> outputDesc,
+ status_t startSource(const sp<AudioOutputDescriptor>& outputDesc,
audio_stream_type_t stream,
audio_devices_t device,
const char *address,
uint32_t *delayMs);
- status_t stopSource(sp<AudioOutputDescriptor> outputDesc,
+ status_t stopSource(const sp<AudioOutputDescriptor>& outputDesc,
audio_stream_type_t stream,
bool forceDeviceUpdate);
@@ -594,6 +597,15 @@
void updateAudioProfiles(audio_devices_t device, audio_io_handle_t ioHandle,
AudioProfileVector &profiles);
+ // Notify the policy client of any change of device state with AUDIO_IO_HANDLE_NONE,
+ // so that the client interprets it as global to audio hardware interfaces.
+ // It can give a chance to HAL implementer to retrieve dynamic capabilities associated
+ // to this device for example.
+ // TODO avoid opening stream to retrieve capabilities of a profile.
+ void broadcastDeviceConnectionState(audio_devices_t device,
+ audio_policy_dev_state_t state,
+ const String8 &device_address);
+
// updates device caching and output for streams that can influence the
// routing of notifications
void handleNotificationRoutingForStream(audio_stream_type_t stream);
@@ -602,9 +614,9 @@
// in mProfile->mSupportedDevices) matches the device whose address is to be matched.
// see deviceDistinguishesOnAddress(audio_devices_t) for whether the device type is one
// where addresses are used to distinguish between one connected device and another.
- void findIoHandlesByAddress(sp<SwAudioOutputDescriptor> desc /*in*/,
+ void findIoHandlesByAddress(const sp<SwAudioOutputDescriptor>& desc /*in*/,
const audio_devices_t device /*in*/,
- const String8 address /*in*/,
+ const String8& address /*in*/,
SortedVector<audio_io_handle_t>& outputs /*out*/);
uint32_t curAudioPortGeneration() const { return mAudioPortGeneration; }
// internal method to return the output handle for the given device and format
diff --git a/services/audiopolicy/service/AudioPolicyClientImplLegacy.cpp b/services/audiopolicy/service/AudioPolicyClientImplLegacy.cpp
index 151d066..dabffe6 100644
--- a/services/audiopolicy/service/AudioPolicyClientImplLegacy.cpp
+++ b/services/audiopolicy/service/AudioPolicyClientImplLegacy.cpp
@@ -56,7 +56,7 @@
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
- return 0;
+ return AUDIO_MODULE_HANDLE_NONE;
}
return af->loadHwModule(name);
diff --git a/services/audiopolicy/service/AudioPolicyEffects.h b/services/audiopolicy/service/AudioPolicyEffects.h
index ee9bd50..afdaf98 100644
--- a/services/audiopolicy/service/AudioPolicyEffects.h
+++ b/services/audiopolicy/service/AudioPolicyEffects.h
@@ -135,7 +135,7 @@
// class to store voctor of AudioEffects
class EffectVector {
public:
- EffectVector(audio_session_t session) : mSessionId(session), mRefCount(0) {}
+ explicit EffectVector(audio_session_t session) : mSessionId(session), mRefCount(0) {}
/*virtual*/ ~EffectVector() {}
// Enable or disable all effects in effect vector
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index a75e3dd..0387ee6 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -37,9 +37,6 @@
if (!settingsAllowed()) {
return PERMISSION_DENIED;
}
- if (!audio_is_output_device(device) && !audio_is_input_device(device)) {
- return BAD_VALUE;
- }
if (state != AUDIO_POLICY_DEVICE_STATE_AVAILABLE &&
state != AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE) {
return BAD_VALUE;
@@ -62,6 +59,23 @@
device_address);
}
+status_t AudioPolicyService::handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name)
+{
+ if (mAudioPolicyManager == NULL) {
+ return NO_INIT;
+ }
+ if (!settingsAllowed()) {
+ return PERMISSION_DENIED;
+ }
+
+ ALOGV("handleDeviceConfigChange()");
+ Mutex::Autolock _l(mLock);
+ return mAudioPolicyManager->handleDeviceConfigChange(device, device_address,
+ device_name);
+}
+
status_t AudioPolicyService::setPhoneState(audio_mode_t state)
{
if (mAudioPolicyManager == NULL) {
@@ -681,7 +695,7 @@
return mAudioPolicyManager->releaseSoundTriggerSession(session);
}
-status_t AudioPolicyService::registerPolicyMixes(Vector<AudioMix> mixes, bool registration)
+status_t AudioPolicyService::registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration)
{
Mutex::Autolock _l(mLock);
if(!modifyAudioRoutingAllowed()) {
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImplLegacy.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImplLegacy.cpp
index 7c9315d..946c380 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImplLegacy.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImplLegacy.cpp
@@ -602,7 +602,7 @@
return INVALID_OPERATION;
}
-status_t AudioPolicyService::registerPolicyMixes(Vector<AudioMix> mixes __unused,
+status_t AudioPolicyService::registerPolicyMixes(const Vector<AudioMix>& mixes __unused,
bool registration __unused)
{
return INVALID_OPERATION;
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index d24e9a0..52ed73e 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -221,14 +221,14 @@
}
}
-void AudioPolicyService::onDynamicPolicyMixStateUpdate(String8 regId, int32_t state)
+void AudioPolicyService::onDynamicPolicyMixStateUpdate(const String8& regId, int32_t state)
{
ALOGV("AudioPolicyService::onDynamicPolicyMixStateUpdate(%s, %d)",
regId.string(), state);
mOutputCommandThread->dynamicPolicyMixStateUpdateCommand(regId, state);
}
-void AudioPolicyService::doOnDynamicPolicyMixStateUpdate(String8 regId, int32_t state)
+void AudioPolicyService::doOnDynamicPolicyMixStateUpdate(const String8& regId, int32_t state)
{
Mutex::Autolock _l(mNotificationClientsLock);
for (size_t i = 0; i < mNotificationClients.size(); i++) {
@@ -310,7 +310,7 @@
}
void AudioPolicyService::NotificationClient::onDynamicPolicyMixStateUpdate(
- String8 regId, int32_t state)
+ const String8& regId, int32_t state)
{
if (mAudioPolicyServiceClient != 0) {
mAudioPolicyServiceClient->onDynamicPolicyMixStateUpdate(regId, state);
@@ -857,7 +857,7 @@
}
void AudioPolicyService::AudioCommandThread::dynamicPolicyMixStateUpdateCommand(
- String8 regId, int32_t state)
+ const String8& regId, int32_t state)
{
sp<AudioCommand> command = new AudioCommand();
command->mCommand = DYN_POLICY_MIX_STATE_UPDATE;
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 0b2cb35..8c9b23c 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -66,6 +66,9 @@
virtual audio_policy_dev_state_t getDeviceConnectionState(
audio_devices_t device,
const char *device_address);
+ virtual status_t handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name);
virtual status_t setPhoneState(audio_mode_t state);
virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config);
virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage);
@@ -196,7 +199,7 @@
virtual audio_mode_t getPhoneState();
- virtual status_t registerPolicyMixes(Vector<AudioMix> mixes, bool registration);
+ virtual status_t registerPolicyMixes(const Vector<AudioMix>& mixes, bool registration);
virtual status_t startAudioSource(const struct audio_port_config *source,
const audio_attributes_t *attributes,
@@ -227,8 +230,8 @@
void onAudioPatchListUpdate();
void doOnAudioPatchListUpdate();
- void onDynamicPolicyMixStateUpdate(String8 regId, int32_t state);
- void doOnDynamicPolicyMixStateUpdate(String8 regId, int32_t state);
+ void onDynamicPolicyMixStateUpdate(const String8& regId, int32_t state);
+ void doOnDynamicPolicyMixStateUpdate(const String8& regId, int32_t state);
void onRecordingConfigurationUpdate(int event, audio_session_t session,
audio_source_t source, const audio_config_base_t *clientConfig,
const audio_config_base_t *deviceConfig, audio_patch_handle_t patchHandle);
@@ -305,7 +308,7 @@
void updateAudioPatchListCommand();
status_t setAudioPortConfigCommand(const struct audio_port_config *config,
int delayMs);
- void dynamicPolicyMixStateUpdateCommand(String8 regId, int32_t state);
+ void dynamicPolicyMixStateUpdateCommand(const String8& regId, int32_t state);
void recordingConfigurationUpdateCommand(
int event, audio_session_t session,
audio_source_t source,
@@ -424,7 +427,7 @@
class AudioPolicyClient : public AudioPolicyClientInterface
{
public:
- AudioPolicyClient(AudioPolicyService *service) : mAudioPolicyService(service) {}
+ explicit AudioPolicyClient(AudioPolicyService *service) : mAudioPolicyService(service) {}
virtual ~AudioPolicyClient() {}
//
@@ -539,7 +542,7 @@
void onAudioPortListUpdate();
void onAudioPatchListUpdate();
- void onDynamicPolicyMixStateUpdate(String8 regId, int32_t state);
+ void onDynamicPolicyMixStateUpdate(const String8& regId, int32_t state);
void onRecordingConfigurationUpdate(
int event, audio_session_t session,
audio_source_t source,
diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk
index 8d7f71c..d8d3ff1 100644
--- a/services/camera/libcameraservice/Android.mk
+++ b/services/camera/libcameraservice/Android.mk
@@ -65,11 +65,12 @@
libcamera_client \
libgui \
libhardware \
- libsync \
libcamera_metadata \
libjpeg \
libmemunreachable
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libbinder libcamera_client
+
LOCAL_C_INCLUDES += \
system/media/private/camera/include \
frameworks/native/include/media/openmax \
@@ -80,6 +81,9 @@
LOCAL_CFLAGS += -Wall -Wextra -Werror
+# Workaround for invalid unused-lambda-capture warning http://b/38349491
+LOCAL_CLANG_CFLAGS += -Wno-error=unused-lambda-capture
+
LOCAL_MODULE:= libcameraservice
include $(BUILD_SHARED_LIBRARY)
diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp
index ad08a68..6314ba5 100644
--- a/services/camera/libcameraservice/CameraFlashlight.cpp
+++ b/services/camera/libcameraservice/CameraFlashlight.cpp
@@ -812,7 +812,7 @@
}
status_t CameraHardwareInterfaceFlashControl::initializePreviewWindow(
- sp<CameraHardwareInterface> device, int32_t width, int32_t height) {
+ const sp<CameraHardwareInterface>& device, int32_t width, int32_t height) {
status_t res;
BufferQueue::createBufferQueue(&mProducer, &mConsumer);
diff --git a/services/camera/libcameraservice/CameraFlashlight.h b/services/camera/libcameraservice/CameraFlashlight.h
index 5cde372..59fc87d 100644
--- a/services/camera/libcameraservice/CameraFlashlight.h
+++ b/services/camera/libcameraservice/CameraFlashlight.h
@@ -193,7 +193,7 @@
status_t disconnectCameraDevice();
// initialize the preview window
- status_t initializePreviewWindow(sp<CameraHardwareInterface> device,
+ status_t initializePreviewWindow(const sp<CameraHardwareInterface>& device,
int32_t width, int32_t height);
// start preview and enable torch
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 6124fed..85faac6 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -31,6 +31,7 @@
#include <android/hardware/ICamera.h>
#include <android/hardware/ICameraClient.h>
+#include <android-base/macros.h>
#include <binder/AppOpsManager.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
@@ -103,7 +104,7 @@
sp<CameraService> cs = const_cast<CameraService*>(
static_cast<const CameraService*>(callbacks));
- cs->onDeviceStatusChanged(static_cast<camera_device_status_t>(camera_id),
+ cs->onDeviceStatusChanged(camera_id,
static_cast<camera_device_status_t>(new_status));
}
@@ -272,12 +273,14 @@
}
sp<ICameraServiceProxy> CameraService::getCameraServiceProxy() {
+ sp<ICameraServiceProxy> proxyBinder = nullptr;
+#ifndef __BRILLO__
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder = sm->getService(String16("media.camera.proxy"));
- if (binder == nullptr) {
- return nullptr;
+ if (binder != nullptr) {
+ proxyBinder = interface_cast<ICameraServiceProxy>(binder);
}
- sp<ICameraServiceProxy> proxyBinder = interface_cast<ICameraServiceProxy>(binder);
+#endif
return proxyBinder;
}
@@ -296,7 +299,7 @@
gCameraService = nullptr;
}
-void CameraService::onDeviceStatusChanged(camera_device_status_t cameraId,
+void CameraService::onDeviceStatusChanged(int cameraId,
camera_device_status_t newStatus) {
ALOGI("%s: Status changed for cameraId=%d, newStatus=%d", __FUNCTION__,
cameraId, newStatus);
@@ -924,6 +927,53 @@
const String8& clientName8, /*inout*/int& clientUid, /*inout*/int& clientPid,
/*out*/int& originalClientPid) const {
+#ifdef __BRILLO__
+ UNUSED(clientName8);
+ UNUSED(clientUid);
+ UNUSED(clientPid);
+ UNUSED(originalClientPid);
+#else
+ Status allowed = validateClientPermissionsLocked(cameraId, clientName8, clientUid, clientPid,
+ originalClientPid);
+ if (!allowed.isOk()) {
+ return allowed;
+ }
+#endif // __BRILLO__
+
+ int callingPid = getCallingPid();
+
+ if (!mModule) {
+ ALOGE("CameraService::connect X (PID %d) rejected (camera HAL module not loaded)",
+ callingPid);
+ return STATUS_ERROR_FMT(ERROR_DISCONNECTED,
+ "No camera HAL module available to open camera device \"%s\"", cameraId.string());
+ }
+
+ if (getCameraState(cameraId) == nullptr) {
+ ALOGE("CameraService::connect X (PID %d) rejected (invalid camera ID %s)", callingPid,
+ cameraId.string());
+ return STATUS_ERROR_FMT(ERROR_DISCONNECTED,
+ "No camera device with ID \"%s\" available", cameraId.string());
+ }
+
+ status_t err = checkIfDeviceIsUsable(cameraId);
+ if (err != NO_ERROR) {
+ switch(err) {
+ case -ENODEV:
+ case -EBUSY:
+ return STATUS_ERROR_FMT(ERROR_DISCONNECTED,
+ "No camera device with ID \"%s\" currently available", cameraId.string());
+ default:
+ return STATUS_ERROR_FMT(ERROR_INVALID_OPERATION,
+ "Unknown error connecting to ID \"%s\"", cameraId.string());
+ }
+ }
+ return Status::ok();
+}
+
+Status CameraService::validateClientPermissionsLocked(const String8& cameraId,
+ const String8& clientName8, int& clientUid, int& clientPid,
+ /*out*/int& originalClientPid) const {
int callingPid = getCallingPid();
int callingUid = getCallingUid();
@@ -967,20 +1017,6 @@
originalClientPid = clientPid;
clientPid = callingPid;
- if (!mModule) {
- ALOGE("CameraService::connect X (PID %d) rejected (camera HAL module not loaded)",
- callingPid);
- return STATUS_ERROR_FMT(ERROR_DISCONNECTED,
- "No camera HAL module available to open camera device \"%s\"", cameraId.string());
- }
-
- if (getCameraState(cameraId) == nullptr) {
- ALOGE("CameraService::connect X (PID %d) rejected (invalid camera ID %s)", callingPid,
- cameraId.string());
- return STATUS_ERROR_FMT(ERROR_DISCONNECTED,
- "No camera device with ID \"%s\" available", cameraId.string());
- }
-
userid_t clientUserId = multiuser_get_user_id(clientUid);
// Only allow clients who are being used by the current foreground device user, unless calling
@@ -994,18 +1030,6 @@
clientUserId, cameraId.string());
}
- status_t err = checkIfDeviceIsUsable(cameraId);
- if (err != NO_ERROR) {
- switch(err) {
- case -ENODEV:
- case -EBUSY:
- return STATUS_ERROR_FMT(ERROR_DISCONNECTED,
- "No camera device with ID \"%s\" currently available", cameraId.string());
- default:
- return STATUS_ERROR_FMT(ERROR_INVALID_OPERATION,
- "Unknown error connecting to ID \"%s\"", cameraId.string());
- }
- }
return Status::ok();
}
@@ -2348,7 +2372,7 @@
void CameraService::ClientEventListener::onClientAdded(
const resource_policy::ClientDescriptor<String8,
sp<CameraService::BasicClient>>& descriptor) {
- auto basicClient = descriptor.getValue();
+ const auto& basicClient = descriptor.getValue();
if (basicClient.get() != nullptr) {
BatteryNotifier& notifier(BatteryNotifier::getInstance());
notifier.noteStartCamera(descriptor.getKey(),
@@ -2359,7 +2383,7 @@
void CameraService::ClientEventListener::onClientRemoved(
const resource_policy::ClientDescriptor<String8,
sp<CameraService::BasicClient>>& descriptor) {
- auto basicClient = descriptor.getValue();
+ const auto& basicClient = descriptor.getValue();
if (basicClient.get() != nullptr) {
BatteryNotifier& notifier(BatteryNotifier::getInstance());
notifier.noteStopCamera(descriptor.getKey(),
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 11b1351..b35f35c 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -95,7 +95,7 @@
/////////////////////////////////////////////////////////////////////
// HAL Callbacks
- virtual void onDeviceStatusChanged(camera_device_status_t cameraId,
+ virtual void onDeviceStatusChanged(int cameraId,
camera_device_status_t newStatus);
virtual void onTorchStatusChanged(const String8& cameraId,
int32_t newStatus);
@@ -265,7 +265,7 @@
class OpsCallback : public BnAppOpsCallback {
public:
- OpsCallback(wp<BasicClient> client);
+ explicit OpsCallback(wp<BasicClient> client);
virtual void opChanged(int32_t op, const String16& packageName);
private:
@@ -495,7 +495,9 @@
// mediaserver to connect to camera (using MediaRecorder to connect to camera). In that case,
// clientPid is the PID of mediaserver and originalClientPid is the PID of the application.
binder::Status validateConnectLocked(const String8& cameraId, const String8& clientName8,
- /*inout*/int& clientUid, /*inout*/int& clientPid, /*out*/int& originalClientPid) const;
+ /*inout*/int& clientUid, /*inout*/int& clientPid, /*out*/int& originalClientPid) const;
+ binder::Status validateClientPermissionsLocked(const String8& cameraId, const String8& clientName8,
+ /*inout*/int& clientUid, /*inout*/int& clientPid, /*out*/int& originalClientPid) const;
// Handle active client evictions, and update service state.
// Only call with with mServiceLock held.
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index 005dd69..bcd62d6 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -526,7 +526,7 @@
}
status_t Camera2Client::setPreviewWindowL(const sp<IBinder>& binder,
- sp<Surface> window) {
+ const sp<Surface>& window) {
ATRACE_CALL();
status_t res;
@@ -1903,12 +1903,12 @@
}
status_t Camera2Client::registerFrameListener(int32_t minId, int32_t maxId,
- wp<camera2::FrameProcessor::FilteredListener> listener, bool sendPartials) {
+ const wp<camera2::FrameProcessor::FilteredListener>& listener, bool sendPartials) {
return mFrameProcessor->registerListener(minId, maxId, listener, sendPartials);
}
status_t Camera2Client::removeFrameListener(int32_t minId, int32_t maxId,
- wp<camera2::FrameProcessor::FilteredListener> listener) {
+ const wp<camera2::FrameProcessor::FilteredListener>& listener) {
return mFrameProcessor->removeListener(minId, maxId, listener);
}
diff --git a/services/camera/libcameraservice/api1/Camera2Client.h b/services/camera/libcameraservice/api1/Camera2Client.h
index 3cb9e4f..e2129f5 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.h
+++ b/services/camera/libcameraservice/api1/Camera2Client.h
@@ -126,10 +126,10 @@
int getZslStreamId() const;
status_t registerFrameListener(int32_t minId, int32_t maxId,
- wp<camera2::FrameProcessor::FilteredListener> listener,
+ const wp<camera2::FrameProcessor::FilteredListener>& listener,
bool sendPartials = true);
status_t removeFrameListener(int32_t minId, int32_t maxId,
- wp<camera2::FrameProcessor::FilteredListener> listener);
+ const wp<camera2::FrameProcessor::FilteredListener>& listener);
status_t stopStream();
@@ -160,7 +160,7 @@
typedef camera2::Parameters Parameters;
status_t setPreviewWindowL(const sp<IBinder>& binder,
- sp<Surface> window);
+ const sp<Surface>& window);
status_t startPreviewL(Parameters ¶ms, bool restart);
void stopPreviewL();
status_t startRecordingL(Parameters ¶ms, bool restart);
diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
index b4b269a..3f4017f 100644
--- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
@@ -55,7 +55,7 @@
}
status_t CallbackProcessor::setCallbackWindow(
- sp<Surface> callbackWindow) {
+ const sp<Surface>& callbackWindow) {
ATRACE_CALL();
status_t res;
diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.h b/services/camera/libcameraservice/api1/client2/CallbackProcessor.h
index a22442f..5231688 100644
--- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.h
@@ -41,13 +41,13 @@
class CallbackProcessor:
public Thread, public CpuConsumer::FrameAvailableListener {
public:
- CallbackProcessor(sp<Camera2Client> client);
+ explicit CallbackProcessor(sp<Camera2Client> client);
~CallbackProcessor();
void onFrameAvailable(const BufferItem& item);
// Set to NULL to disable the direct-to-app callback window
- status_t setCallbackWindow(sp<Surface> callbackWindow);
+ status_t setCallbackWindow(const sp<Surface>& callbackWindow);
status_t updateStream(const Parameters ¶ms);
status_t deleteStream();
int getStreamId() const;
diff --git a/services/camera/libcameraservice/api1/client2/Camera2Heap.h b/services/camera/libcameraservice/api1/client2/Camera2Heap.h
index 9c72d76..fe3afcb 100644
--- a/services/camera/libcameraservice/api1/client2/Camera2Heap.h
+++ b/services/camera/libcameraservice/api1/client2/Camera2Heap.h
@@ -26,7 +26,7 @@
// Utility class for managing a set of IMemory blocks
class Camera2Heap : public RefBase {
public:
- Camera2Heap(size_t buf_size, uint_t num_buffers = 1,
+ explicit Camera2Heap(size_t buf_size, uint_t num_buffers = 1,
const char *name = NULL) :
mBufSize(buf_size),
mNumBufs(num_buffers) {
diff --git a/services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp b/services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp
index 05adb29..b65f1c7 100644
--- a/services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp
+++ b/services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp
@@ -59,7 +59,7 @@
ALOGV("%s: Exit", __FUNCTION__);
}
-void CaptureSequencer::setZslProcessor(wp<ZslProcessor> processor) {
+void CaptureSequencer::setZslProcessor(const wp<ZslProcessor>& processor) {
Mutex::Autolock l(mInputMutex);
mZslProcessor = processor;
}
@@ -132,7 +132,7 @@
}
void CaptureSequencer::onCaptureAvailable(nsecs_t timestamp,
- sp<MemoryBase> captureBuffer, bool captureError) {
+ const sp<MemoryBase>& captureBuffer, bool captureError) {
ATRACE_CALL();
ALOGV("%s", __FUNCTION__);
Mutex::Autolock l(mInputMutex);
@@ -709,7 +709,7 @@
}
/*static*/ void CaptureSequencer::shutterNotifyLocked(const Parameters ¶ms,
- sp<Camera2Client> client, int msgType) {
+ const sp<Camera2Client>& client, int msgType) {
ATRACE_CALL();
if (params.state == Parameters::STILL_CAPTURE
diff --git a/services/camera/libcameraservice/api1/client2/CaptureSequencer.h b/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
index a7c61d2..f2e3750 100644
--- a/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
+++ b/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
@@ -44,11 +44,11 @@
virtual public Thread,
virtual public FrameProcessor::FilteredListener {
public:
- CaptureSequencer(wp<Camera2Client> client);
+ explicit CaptureSequencer(wp<Camera2Client> client);
~CaptureSequencer();
// Get reference to the ZslProcessor, which holds the ZSL buffers and frames
- void setZslProcessor(wp<ZslProcessor> processor);
+ void setZslProcessor(const wp<ZslProcessor>& processor);
// Begin still image capture
status_t startCapture(int msgType);
@@ -69,7 +69,7 @@
virtual void onResultAvailable(const CaptureResult &result);
// Notifications from the JPEG processor
- void onCaptureAvailable(nsecs_t timestamp, sp<MemoryBase> captureBuffer, bool captureError);
+ void onCaptureAvailable(nsecs_t timestamp, const sp<MemoryBase>& captureBuffer, bool captureError);
void dump(int fd, const Vector<String16>& args);
@@ -172,7 +172,7 @@
// Emit Shutter/Raw callback to java, and maybe play a shutter sound
static void shutterNotifyLocked(const Parameters ¶ms,
- sp<Camera2Client> client, int msgType);
+ const sp<Camera2Client>& client, int msgType);
};
}; // namespace camera2
diff --git a/services/camera/libcameraservice/api1/client2/FrameProcessor.cpp b/services/camera/libcameraservice/api1/client2/FrameProcessor.cpp
index 4d12015..394eb4c 100644
--- a/services/camera/libcameraservice/api1/client2/FrameProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/FrameProcessor.cpp
@@ -389,7 +389,7 @@
}
-void FrameProcessor::callbackFaceDetection(sp<Camera2Client> client,
+void FrameProcessor::callbackFaceDetection(const sp<Camera2Client>& client,
const camera_frame_metadata &metadata) {
camera_frame_metadata *metadata_ptr =
diff --git a/services/camera/libcameraservice/api1/client2/FrameProcessor.h b/services/camera/libcameraservice/api1/client2/FrameProcessor.h
index a5b81a7..62a4e91 100644
--- a/services/camera/libcameraservice/api1/client2/FrameProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/FrameProcessor.h
@@ -107,7 +107,7 @@
int32_t mLast3AFrameNumber;
// Emit FaceDetection event to java if faces changed
- void callbackFaceDetection(sp<Camera2Client> client,
+ void callbackFaceDetection(const sp<Camera2Client>& client,
const camera_frame_metadata &metadata);
};
diff --git a/services/camera/libcameraservice/api1/client2/JpegCompressor.cpp b/services/camera/libcameraservice/api1/client2/JpegCompressor.cpp
index 9ecab71..01951a0 100644
--- a/services/camera/libcameraservice/api1/client2/JpegCompressor.cpp
+++ b/services/camera/libcameraservice/api1/client2/JpegCompressor.cpp
@@ -36,7 +36,7 @@
Mutex::Autolock lock(mMutex);
}
-status_t JpegCompressor::start(Vector<CpuConsumer::LockedBuffer*> buffers,
+status_t JpegCompressor::start(const Vector<CpuConsumer::LockedBuffer*>& buffers,
nsecs_t captureTime) {
ALOGV("%s", __FUNCTION__);
Mutex::Autolock busyLock(mBusyMutex);
diff --git a/services/camera/libcameraservice/api1/client2/JpegCompressor.h b/services/camera/libcameraservice/api1/client2/JpegCompressor.h
index df5da54..589a2fd 100644
--- a/services/camera/libcameraservice/api1/client2/JpegCompressor.h
+++ b/services/camera/libcameraservice/api1/client2/JpegCompressor.h
@@ -48,7 +48,7 @@
// Start compressing COMPRESSED format buffers; JpegCompressor takes
// ownership of the Buffers vector.
- status_t start(Vector<CpuConsumer::LockedBuffer*> buffers,
+ status_t start(const Vector<CpuConsumer::LockedBuffer*>& buffers,
nsecs_t captureTime);
status_t cancel();
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.h b/services/camera/libcameraservice/api1/client2/Parameters.h
index 687ac3e..c8ecbba 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.h
+++ b/services/camera/libcameraservice/api1/client2/Parameters.h
@@ -426,7 +426,7 @@
template<typename S, typename P>
class BaseLock {
public:
- BaseLock(S &p):
+ explicit BaseLock(S &p):
mParameters(p.mParameters),
mSharedParameters(p) {
mSharedParameters.mLock.lock();
diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
index de42fb2..bf92a2b 100644
--- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
@@ -58,7 +58,7 @@
deleteRecordingStream();
}
-status_t StreamingProcessor::setPreviewWindow(sp<Surface> window) {
+status_t StreamingProcessor::setPreviewWindow(const sp<Surface>& window) {
ATRACE_CALL();
status_t res;
@@ -72,7 +72,7 @@
return OK;
}
-status_t StreamingProcessor::setRecordingWindow(sp<Surface> window) {
+status_t StreamingProcessor::setRecordingWindow(const sp<Surface>& window) {
ATRACE_CALL();
status_t res;
diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
index 57e6389..22231d5 100644
--- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
@@ -39,11 +39,11 @@
*/
class StreamingProcessor : public virtual VirtualLightRefBase {
public:
- StreamingProcessor(sp<Camera2Client> client);
+ explicit StreamingProcessor(sp<Camera2Client> client);
~StreamingProcessor();
- status_t setPreviewWindow(sp<Surface> window);
- status_t setRecordingWindow(sp<Surface> window);
+ status_t setPreviewWindow(const sp<Surface>& window);
+ status_t setRecordingWindow(const sp<Surface>& window);
bool haveValidPreviewWindow() const;
bool haveValidRecordingWindow() const;
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index a7fe5e7..b4f8e21 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -530,7 +530,8 @@
}
// Round dimensions to the nearest dimensions available for this format
- if (flexibleConsumer && !CameraDeviceClient::roundBufferDimensionNearest(width, height,
+ if (flexibleConsumer && isPublicFormat(format) &&
+ !CameraDeviceClient::roundBufferDimensionNearest(width, height,
format, dataSpace, mDevice->info(), /*out*/&width, /*out*/&height)) {
String8 msg = String8::format("Camera %d: No supported stream configurations with "
"format %#x defined, failed to create output stream", mCameraId, format);
@@ -714,6 +715,37 @@
return res;
}
+bool CameraDeviceClient::isPublicFormat(int32_t format)
+{
+ switch(format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_RGB_888:
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_Y8:
+ case HAL_PIXEL_FORMAT_Y16:
+ case HAL_PIXEL_FORMAT_RAW16:
+ case HAL_PIXEL_FORMAT_RAW10:
+ case HAL_PIXEL_FORMAT_RAW12:
+ case HAL_PIXEL_FORMAT_RAW_OPAQUE:
+ case HAL_PIXEL_FORMAT_BLOB:
+ case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
+ case HAL_PIXEL_FORMAT_YCbCr_420_888:
+ case HAL_PIXEL_FORMAT_YCbCr_422_888:
+ case HAL_PIXEL_FORMAT_YCbCr_444_888:
+ case HAL_PIXEL_FORMAT_FLEX_RGB_888:
+ case HAL_PIXEL_FORMAT_FLEX_RGBA_8888:
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool CameraDeviceClient::roundBufferDimensionNearest(int32_t width, int32_t height,
int32_t format, android_dataspace dataSpace, const CameraMetadata& info,
/*out*/int32_t* outWidth, /*out*/int32_t* outHeight) {
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.h b/services/camera/libcameraservice/api2/CameraDeviceClient.h
index dde23fb9..de283ea 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.h
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.h
@@ -208,6 +208,9 @@
android_dataspace dataSpace, const CameraMetadata& info,
/*out*/int32_t* outWidth, /*out*/int32_t* outHeight);
+ //check if format is not custom format
+ static bool isPublicFormat(int32_t format);
+
// IGraphicsBufferProducer binder -> Stream ID for output streams
KeyedVector<sp<IBinder>, int> mStreamMap;
diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.h b/services/camera/libcameraservice/common/Camera2ClientBase.h
index 4f60034..dbbf638 100644
--- a/services/camera/libcameraservice/common/Camera2ClientBase.h
+++ b/services/camera/libcameraservice/common/Camera2ClientBase.h
@@ -93,13 +93,13 @@
public:
class Lock {
public:
- Lock(SharedCameraCallbacks &client);
+ explicit Lock(SharedCameraCallbacks &client);
~Lock();
sp<TCamCallbacks> &mRemoteCallback;
private:
SharedCameraCallbacks &mSharedClient;
};
- SharedCameraCallbacks(const sp<TCamCallbacks>& client);
+ explicit SharedCameraCallbacks(const sp<TCamCallbacks>& client);
SharedCameraCallbacks& operator=(const sp<TCamCallbacks>& client);
void clear();
private:
diff --git a/services/camera/libcameraservice/common/CameraModule.h b/services/camera/libcameraservice/common/CameraModule.h
index 1a1c274..d131a26 100644
--- a/services/camera/libcameraservice/common/CameraModule.h
+++ b/services/camera/libcameraservice/common/CameraModule.h
@@ -32,7 +32,7 @@
*/
class CameraModule {
public:
- CameraModule(camera_module_t *module);
+ explicit CameraModule(camera_module_t *module);
virtual ~CameraModule();
// Must be called after construction
diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.cpp b/services/camera/libcameraservice/common/FrameProcessorBase.cpp
index 29eb78f..2ef3057 100644
--- a/services/camera/libcameraservice/common/FrameProcessorBase.cpp
+++ b/services/camera/libcameraservice/common/FrameProcessorBase.cpp
@@ -47,7 +47,7 @@
}
status_t FrameProcessorBase::registerListener(int32_t minId,
- int32_t maxId, wp<FilteredListener> listener, bool sendPartials) {
+ int32_t maxId, const wp<FilteredListener>& listener, bool sendPartials) {
Mutex::Autolock l(mInputMutex);
List<RangeListener>::iterator item = mRangeListeners.begin();
while (item != mRangeListeners.end()) {
@@ -70,7 +70,7 @@
status_t FrameProcessorBase::removeListener(int32_t minId,
int32_t maxId,
- wp<FilteredListener> listener) {
+ const wp<FilteredListener>& listener) {
Mutex::Autolock l(mInputMutex);
List<RangeListener>::iterator item = mRangeListeners.begin();
while (item != mRangeListeners.end()) {
diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.h b/services/camera/libcameraservice/common/FrameProcessorBase.h
index a618d84..00763a4 100644
--- a/services/camera/libcameraservice/common/FrameProcessorBase.h
+++ b/services/camera/libcameraservice/common/FrameProcessorBase.h
@@ -36,7 +36,7 @@
*/
class FrameProcessorBase: public Thread {
public:
- FrameProcessorBase(wp<CameraDeviceBase> device);
+ explicit FrameProcessorBase(wp<CameraDeviceBase> device);
virtual ~FrameProcessorBase();
struct FilteredListener: virtual public RefBase {
@@ -48,10 +48,10 @@
// the same range of IDs has no effect.
// sendPartials controls whether partial results will be sent.
status_t registerListener(int32_t minId, int32_t maxId,
- wp<FilteredListener> listener,
+ const wp<FilteredListener>& listener,
bool sendPartials = true);
status_t removeListener(int32_t minId, int32_t maxId,
- wp<FilteredListener> listener);
+ const wp<FilteredListener>& listener);
void dump(int fd, const Vector<String16>& args);
protected:
diff --git a/services/camera/libcameraservice/device1/CameraHardwareInterface.h b/services/camera/libcameraservice/device1/CameraHardwareInterface.h
index bce0762..952bae1 100644
--- a/services/camera/libcameraservice/device1/CameraHardwareInterface.h
+++ b/services/camera/libcameraservice/device1/CameraHardwareInterface.h
@@ -73,7 +73,7 @@
class CameraHardwareInterface : public virtual RefBase {
public:
- CameraHardwareInterface(const char *name):
+ explicit CameraHardwareInterface(const char *name):
mDevice(nullptr),
mName(name),
mPreviewScalingMode(NOT_SET),
@@ -543,9 +543,9 @@
commonInitialization();
}
- CameraHeapMemory(size_t buf_size, uint_t num_buffers = 1) :
- mBufSize(buf_size),
- mNumBufs(num_buffers)
+ explicit CameraHeapMemory(size_t buf_size, uint_t num_buffers = 1) :
+ mBufSize(buf_size),
+ mNumBufs(num_buffers)
{
mHeap = new MemoryHeapBase(buf_size * num_buffers);
commonInitialization();
@@ -606,9 +606,9 @@
reinterpret_cast<CameraHardwareInterface *>(user);
return __this->mPreviewWindow.get();
}
-#define anw(n) __to_anw(((struct camera_preview_window *)n)->user)
+#define anw(n) __to_anw(((struct camera_preview_window *)(n))->user)
#define hwi(n) reinterpret_cast<CameraHardwareInterface *>(\
- ((struct camera_preview_window *)n)->user)
+ ((struct camera_preview_window *)(n))->user)
static int __dequeue_buffer(struct preview_stream_ops* w,
buffer_handle_t** buffer, int *stride)
diff --git a/services/camera/libcameraservice/device3/Camera3BufferManager.h b/services/camera/libcameraservice/device3/Camera3BufferManager.h
index ab6541e..b5b86a3 100644
--- a/services/camera/libcameraservice/device3/Camera3BufferManager.h
+++ b/services/camera/libcameraservice/device3/Camera3BufferManager.h
@@ -44,7 +44,7 @@
*/
class Camera3BufferManager: public virtual RefBase {
public:
- Camera3BufferManager(const sp<IGraphicBufferAlloc>& allocator = NULL);
+ explicit Camera3BufferManager(const sp<IGraphicBufferAlloc>& allocator = NULL);
virtual ~Camera3BufferManager();
@@ -195,7 +195,7 @@
struct GraphicBufferEntry {
sp<GraphicBuffer> graphicBuffer;
int fenceFd;
- GraphicBufferEntry(const sp<GraphicBuffer>& gb = 0, int fd = -1) :
+ explicit GraphicBufferEntry(const sp<GraphicBuffer>& gb = 0, int fd = -1) :
graphicBuffer(gb),
fenceFd(fd) {}
};
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index eece01b..495de44 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -2894,7 +2894,7 @@
return OK;
}
-bool Camera3Device::RequestThread::isRepeatingRequestLocked(const sp<CaptureRequest> requestIn) {
+bool Camera3Device::RequestThread::isRepeatingRequestLocked(const sp<CaptureRequest>& requestIn) {
if (mRepeatingRequests.empty()) {
return false;
}
@@ -2958,6 +2958,8 @@
}
}
mRequestQueue.clear();
+
+ Mutex::Autolock al(mTriggerMutex);
mTriggerMap.clear();
if (lastFrameNumber != NULL) {
*lastFrameNumber = mRepeatingLastFrameNumber;
@@ -3015,7 +3017,7 @@
* AE_PRECAPTURE_TRIGGER_CANCEL to AE_PRECAPTURE_TRIGGER_IDLE but doesn't add AE_LOCK_ON to the
* request.
*/
-void Camera3Device::RequestThread::handleAePrecaptureCancelRequest(sp<CaptureRequest> request) {
+void Camera3Device::RequestThread::handleAePrecaptureCancelRequest(const sp<CaptureRequest>& request) {
request->mAeTriggerCancelOverride.applyAeLock = false;
request->mAeTriggerCancelOverride.applyAePrecaptureTrigger = false;
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index f422813..87c43f3 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -65,7 +65,7 @@
private camera3_callback_ops {
public:
- Camera3Device(int id);
+ explicit Camera3Device(int id);
virtual ~Camera3Device();
@@ -220,7 +220,7 @@
struct Size {
uint32_t width;
uint32_t height;
- Size(uint32_t w = 0, uint32_t h = 0) : width(w), height(h){}
+ explicit Size(uint32_t w = 0, uint32_t h = 0) : width(w), height(h){}
};
// Map from format to size.
Vector<Size> mSupportedOpaqueInputSizes;
@@ -589,10 +589,10 @@
void setErrorState(const char *fmt, ...);
// If the input request is in mRepeatingRequests. Must be called with mRequestLock hold
- bool isRepeatingRequestLocked(const sp<CaptureRequest>);
+ bool isRepeatingRequestLocked(const sp<CaptureRequest>&);
// Handle AE precapture trigger cancel for devices <= CAMERA_DEVICE_API_VERSION_3_2.
- void handleAePrecaptureCancelRequest(sp<CaptureRequest> request);
+ void handleAePrecaptureCancelRequest(const sp<CaptureRequest>& request);
// Clear repeating requests. Must be called with mRequestLock held.
status_t clearRepeatingRequestsLocked(/*out*/ int64_t *lastFrameNumber = NULL);
diff --git a/services/camera/libcameraservice/device3/Camera3DummyStream.h b/services/camera/libcameraservice/device3/Camera3DummyStream.h
index 639619e..18e8a23 100644
--- a/services/camera/libcameraservice/device3/Camera3DummyStream.h
+++ b/services/camera/libcameraservice/device3/Camera3DummyStream.h
@@ -42,7 +42,7 @@
* Set up a dummy stream; doesn't actually connect to anything, and uses
* a default dummy format and size.
*/
- Camera3DummyStream(int id);
+ explicit Camera3DummyStream(int id);
virtual ~Camera3DummyStream();
diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.h b/services/camera/libcameraservice/device3/Camera3OutputStream.h
index d450a69..12d497e 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputStream.h
+++ b/services/camera/libcameraservice/device3/Camera3OutputStream.h
@@ -46,7 +46,7 @@
uint32_t combinedUsage;
size_t totalBufferCount;
bool isConfigured;
- StreamInfo(int id = CAMERA3_STREAM_ID_INVALID,
+ explicit StreamInfo(int id = CAMERA3_STREAM_ID_INVALID,
int setId = CAMERA3_STREAM_SET_ID_INVALID,
uint32_t w = 0,
uint32_t h = 0,
diff --git a/services/camera/libcameraservice/device3/Camera3ZslStream.cpp b/services/camera/libcameraservice/device3/Camera3ZslStream.cpp
index 7414c4c..ea138b7 100644
--- a/services/camera/libcameraservice/device3/Camera3ZslStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3ZslStream.cpp
@@ -40,7 +40,7 @@
SELECT_NEITHER = 0,
};
- TimestampFinder(nsecs_t timestamp) : mTimestamp(timestamp) {}
+ explicit TimestampFinder(nsecs_t timestamp) : mTimestamp(timestamp) {}
~TimestampFinder() {}
template <typename T>
diff --git a/services/camera/libcameraservice/device3/StatusTracker.h b/services/camera/libcameraservice/device3/StatusTracker.h
index 49cecb3..3a1d85c 100644
--- a/services/camera/libcameraservice/device3/StatusTracker.h
+++ b/services/camera/libcameraservice/device3/StatusTracker.h
@@ -45,7 +45,7 @@
*/
class StatusTracker: public Thread {
public:
- StatusTracker(wp<Camera3Device> parent);
+ explicit StatusTracker(wp<Camera3Device> parent);
~StatusTracker();
// An always-invalid component ID
diff --git a/services/camera/libcameraservice/utils/AutoConditionLock.h b/services/camera/libcameraservice/utils/AutoConditionLock.h
index b7f167b..cdbb01b 100644
--- a/services/camera/libcameraservice/utils/AutoConditionLock.h
+++ b/services/camera/libcameraservice/utils/AutoConditionLock.h
@@ -37,7 +37,7 @@
/**
* Construct the ConditionManger with the given Mutex.
*/
- WaitableMutexWrapper(Mutex* mutex);
+ explicit WaitableMutexWrapper(Mutex* mutex);
virtual ~WaitableMutexWrapper();
private:
@@ -88,7 +88,7 @@
static std::unique_ptr<AutoConditionLock> waitAndAcquire(
const std::shared_ptr<WaitableMutexWrapper>& manager);
private:
- AutoConditionLock(const std::shared_ptr<WaitableMutexWrapper>& manager);
+ explicit AutoConditionLock(const std::shared_ptr<WaitableMutexWrapper>& manager);
std::shared_ptr<WaitableMutexWrapper> mManager;
Mutex::Autolock mAutoLock;
diff --git a/services/camera/libcameraservice/utils/ClientManager.h b/services/camera/libcameraservice/utils/ClientManager.h
index 7ae58d5..830c50b 100644
--- a/services/camera/libcameraservice/utils/ClientManager.h
+++ b/services/camera/libcameraservice/utils/ClientManager.h
@@ -216,7 +216,7 @@
static constexpr int32_t DEFAULT_MAX_COST = 100;
ClientManager();
- ClientManager(int32_t totalCost);
+ explicit ClientManager(int32_t totalCost);
/**
* Add a given ClientDescriptor to the managed list. ClientDescriptors for clients that
diff --git a/services/mediacodec/Android.mk b/services/mediacodec/Android.mk
index a5f0751..de0bdfd 100644
--- a/services/mediacodec/Android.mk
+++ b/services/mediacodec/Android.mk
@@ -5,8 +5,8 @@
LOCAL_SRC_FILES := MediaCodecService.cpp
LOCAL_SHARED_LIBRARIES := libmedia libbinder libutils liblog libstagefright_omx
LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
+ frameworks/av/media/libstagefright \
+ frameworks/native/include/media/openmax
LOCAL_MODULE:= libmediacodecservice
LOCAL_32_BIT_ONLY := true
include $(BUILD_SHARED_LIBRARY)
@@ -19,8 +19,8 @@
LOCAL_SHARED_LIBRARIES := libmedia libmediacodecservice libbinder libutils \
liblog libminijail
LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/av/media/libstagefright \
- $(TOP)/frameworks/native/include/media/openmax
+ frameworks/av/media/libstagefright \
+ frameworks/native/include/media/openmax
LOCAL_MODULE:= mediacodec
LOCAL_32_BIT_ONLY := true
LOCAL_INIT_RC := mediacodec.rc
diff --git a/services/mediacodec/minijail/Android.mk b/services/mediacodec/minijail/Android.mk
index d2becb4..de05bc3 100644
--- a/services/mediacodec/minijail/Android.mk
+++ b/services/mediacodec/minijail/Android.mk
@@ -15,9 +15,8 @@
endif
# allow device specific additions to the syscall whitelist
-ifneq (,$(wildcard $(BOARD_SECCOMP_POLICY)/mediacodec-seccomp.policy))
- LOCAL_SRC_FILES += $(BOARD_SECCOMP_POLICY)/mediacodec-seccomp.policy
-endif
+LOCAL_SRC_FILES += $(wildcard $(foreach dir, $(BOARD_SECCOMP_POLICY), \
+ $(dir)/mediacodec-seccomp.policy))
include $(BUILD_SYSTEM)/base_rules.mk
diff --git a/services/mediacodec/minijail/minijail.cpp b/services/mediacodec/minijail/minijail.cpp
index 72bb1af..463f161 100644
--- a/services/mediacodec/minijail/minijail.cpp
+++ b/services/mediacodec/minijail/minijail.cpp
@@ -15,7 +15,12 @@
** limitations under the License.
*/
-#include <cutils/log.h>
+#define LOG_TAG "minijail"
+
+#include <unistd.h>
+
+#include <log/log.h>
+
#include <libminijail.h>
#include "minijail.h"
diff --git a/services/mediacodec/minijail/seccomp_policy/mediacodec-seccomp-arm.policy b/services/mediacodec/minijail/seccomp_policy/mediacodec-seccomp-arm.policy
index 0afaa15..1a0e76d 100644
--- a/services/mediacodec/minijail/seccomp_policy/mediacodec-seccomp-arm.policy
+++ b/services/mediacodec/minijail/seccomp_policy/mediacodec-seccomp-arm.policy
@@ -21,6 +21,7 @@
setpriority: 1
getuid32: 1
fstat64: 1
+fstatfs64: 1
pread64: 1
faccessat: 1
readlinkat: 1
diff --git a/services/mediadrm/Android.mk b/services/mediadrm/Android.mk
index 8baaf13..38aa472 100644
--- a/services/mediadrm/Android.mk
+++ b/services/mediadrm/Android.mk
@@ -25,16 +25,9 @@
libbinder \
libcutils \
liblog \
- libmedia \
libmediadrm \
- libmediaplayerservice \
- libstagefright \
- libui \
libutils \
-LOCAL_C_INCLUDES := \
- frameworks/av/media/libmediaplayerservice \
-
LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_MODULE:= mediadrmserver
diff --git a/services/mediadrm/tests/Android.mk b/services/mediadrm/tests/Android.mk
index 8cbf782..e2f7399 100644
--- a/services/mediadrm/tests/Android.mk
+++ b/services/mediadrm/tests/Android.mk
@@ -19,7 +19,6 @@
frameworks/av/media/libmediaplayerservice \
LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
LOCAL_32_BIT_ONLY := true
diff --git a/services/mediaextractor/minijail/Android.mk b/services/mediaextractor/minijail/Android.mk
index 79c5505..0cf8eff 100644
--- a/services/mediaextractor/minijail/Android.mk
+++ b/services/mediaextractor/minijail/Android.mk
@@ -15,9 +15,8 @@
endif
# allow device specific additions to the syscall whitelist
-ifneq (,$(wildcard $(BOARD_SECCOMP_POLICY)/mediaextractor-seccomp.policy))
- LOCAL_SRC_FILES += $(BOARD_SECCOMP_POLICY)/mediaextractor-seccomp.policy
-endif
+LOCAL_SRC_FILES += $(wildcard $(foreach dir, $(BOARD_SECCOMP_POLICY), \
+ $(dir)/mediaextractor-seccomp.policy))
include $(BUILD_SYSTEM)/base_rules.mk
diff --git a/services/mediaextractor/minijail/minijail.cpp b/services/mediaextractor/minijail/minijail.cpp
index 421a1e0..c44d00d 100644
--- a/services/mediaextractor/minijail/minijail.cpp
+++ b/services/mediaextractor/minijail/minijail.cpp
@@ -15,7 +15,12 @@
** limitations under the License.
*/
-#include <cutils/log.h>
+#define LOG_TAG "minijail"
+
+#include <unistd.h>
+
+#include <log/log.h>
+
#include <libminijail.h>
#include "minijail.h"
diff --git a/services/mediaextractor/minijail/seccomp_policy/mediaextractor-seccomp-arm.policy b/services/mediaextractor/minijail/seccomp_policy/mediaextractor-seccomp-arm.policy
index 165694c..cb2ac1a 100644
--- a/services/mediaextractor/minijail/seccomp_policy/mediaextractor-seccomp-arm.policy
+++ b/services/mediaextractor/minijail/seccomp_policy/mediaextractor-seccomp-arm.policy
@@ -20,6 +20,7 @@
lseek: 1
writev: 1
fstatat64: 1
+fstatfs64: 1
fstat64: 1
restart_syscall: 1
exit: 1
diff --git a/services/mediaextractor/minijail/seccomp_policy/mediaextractor-seccomp-x86.policy b/services/mediaextractor/minijail/seccomp_policy/mediaextractor-seccomp-x86.policy
index 67976ff..25d9786 100644
--- a/services/mediaextractor/minijail/seccomp_policy/mediaextractor-seccomp-x86.policy
+++ b/services/mediaextractor/minijail/seccomp_policy/mediaextractor-seccomp-x86.policy
@@ -22,6 +22,7 @@
setpriority: 1
sigaltstack: 1
fstatat64: 1
+fstatfs64: 1
fstat64: 1
restart_syscall: 1
exit: 1
diff --git a/services/medialog/Android.mk b/services/medialog/Android.mk
index 88f98cf..a1da63d 100644
--- a/services/medialog/Android.mk
+++ b/services/medialog/Android.mk
@@ -2,9 +2,9 @@
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := MediaLogService.cpp
+LOCAL_SRC_FILES := MediaLogService.cpp IMediaLogService.cpp
-LOCAL_SHARED_LIBRARIES := libmedia libbinder libutils liblog libnbaio
+LOCAL_SHARED_LIBRARIES := libbinder libutils liblog libnbaio
LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
diff --git a/media/libmedia/IMediaLogService.cpp b/services/medialog/IMediaLogService.cpp
similarity index 97%
rename from media/libmedia/IMediaLogService.cpp
rename to services/medialog/IMediaLogService.cpp
index 1536337..bc445ff 100644
--- a/media/libmedia/IMediaLogService.cpp
+++ b/services/medialog/IMediaLogService.cpp
@@ -34,7 +34,7 @@
class BpMediaLogService : public BpInterface<IMediaLogService>
{
public:
- BpMediaLogService(const sp<IBinder>& impl)
+ explicit BpMediaLogService(const sp<IBinder>& impl)
: BpInterface<IMediaLogService>(impl)
{
}
diff --git a/services/mediaresourcemanager/Android.mk b/services/mediaresourcemanager/Android.mk
index b72230f..5823036 100644
--- a/services/mediaresourcemanager/Android.mk
+++ b/services/mediaresourcemanager/Android.mk
@@ -4,17 +4,16 @@
LOCAL_SRC_FILES := ResourceManagerService.cpp ServiceLog.cpp
-LOCAL_SHARED_LIBRARIES := libmedia libstagefright libbinder libutils liblog
+LOCAL_SHARED_LIBRARIES := libmedia libmediautils libbinder libutils liblog
LOCAL_MODULE:= libresourcemanagerservice
LOCAL_32_BIT_ONLY := true
LOCAL_C_INCLUDES += \
- $(TOPDIR)frameworks/av/include
+ frameworks/av/include
LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
include $(BUILD_SHARED_LIBRARY)
diff --git a/services/mediaresourcemanager/ResourceManagerService.cpp b/services/mediaresourcemanager/ResourceManagerService.cpp
index 3ed0189..7346f51 100644
--- a/services/mediaresourcemanager/ResourceManagerService.cpp
+++ b/services/mediaresourcemanager/ResourceManagerService.cpp
@@ -43,7 +43,7 @@
return itemsStr;
}
-static bool hasResourceType(MediaResource::Type type, Vector<MediaResource> resources) {
+static bool hasResourceType(MediaResource::Type type, const Vector<MediaResource>& resources) {
for (size_t i = 0; i < resources.size(); ++i) {
if (resources[i].mType == type) {
return true;
@@ -52,7 +52,7 @@
return false;
}
-static bool hasResourceType(MediaResource::Type type, ResourceInfos infos) {
+static bool hasResourceType(MediaResource::Type type, const ResourceInfos& infos) {
for (size_t i = 0; i < infos.size(); ++i) {
if (hasResourceType(type, infos[i].resources)) {
return true;
@@ -76,7 +76,7 @@
static ResourceInfo& getResourceInfoForEdit(
int64_t clientId,
- const sp<IResourceManagerClient> client,
+ const sp<IResourceManagerClient>& client,
ResourceInfos& infos) {
for (size_t i = 0; i < infos.size(); ++i) {
if (infos[i].clientId == clientId) {
diff --git a/services/mediaresourcemanager/ResourceManagerService.h b/services/mediaresourcemanager/ResourceManagerService.h
index 8f6fe9a..2a4a6b2 100644
--- a/services/mediaresourcemanager/ResourceManagerService.h
+++ b/services/mediaresourcemanager/ResourceManagerService.h
@@ -52,7 +52,7 @@
virtual status_t dump(int fd, const Vector<String16>& args);
ResourceManagerService();
- ResourceManagerService(sp<ProcessInfoInterface> processInfo);
+ explicit ResourceManagerService(sp<ProcessInfoInterface> processInfo);
// IResourceManagerService interface
virtual void config(const Vector<MediaResourcePolicy> &policies);
diff --git a/services/mediaresourcemanager/ServiceLog.h b/services/mediaresourcemanager/ServiceLog.h
index a6f16eb..380e86a 100644
--- a/services/mediaresourcemanager/ServiceLog.h
+++ b/services/mediaresourcemanager/ServiceLog.h
@@ -30,7 +30,7 @@
class ServiceLog : public RefBase {
public:
ServiceLog();
- ServiceLog(size_t maxNum);
+ explicit ServiceLog(size_t maxNum);
void add(const String8 &log);
String8 toString(const char *linePrefix = NULL) const;
diff --git a/services/mediaresourcemanager/test/Android.mk b/services/mediaresourcemanager/test/Android.mk
index 3b4ef0d..6abcf92 100644
--- a/services/mediaresourcemanager/test/Android.mk
+++ b/services/mediaresourcemanager/test/Android.mk
@@ -21,7 +21,6 @@
frameworks/av/services/mediaresourcemanager \
LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
LOCAL_32_BIT_ONLY := true
@@ -47,7 +46,6 @@
frameworks/av/services/mediaresourcemanager \
LOCAL_CFLAGS += -Werror -Wall
-LOCAL_CLANG := true
LOCAL_32_BIT_ONLY := true
diff --git a/services/mediaresourcemanager/test/ResourceManagerService_test.cpp b/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
index 62b7711..ed0b0ef 100644
--- a/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
+++ b/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
@@ -29,7 +29,7 @@
namespace android {
-static int64_t getId(sp<IResourceManagerClient> client) {
+static int64_t getId(const sp<IResourceManagerClient>& client) {
return (int64_t) client.get();
}
diff --git a/services/radio/Android.mk b/services/radio/Android.mk
index f5d74d3..fc8f00c 100644
--- a/services/radio/Android.mk
+++ b/services/radio/Android.mk
@@ -21,12 +21,11 @@
RadioService.cpp
LOCAL_SHARED_LIBRARIES:= \
- libui \
liblog \
libutils \
libbinder \
libcutils \
- libmedia \
+ libaudioclient \
libhardware \
libradio \
libradio_metadata
diff --git a/services/radio/RadioService.cpp b/services/radio/RadioService.cpp
index 5a3f750..3448678 100644
--- a/services/radio/RadioService.cpp
+++ b/services/radio/RadioService.cpp
@@ -84,10 +84,11 @@
radio_properties_t properties;
properties.handle =
(radio_handle_t)android_atomic_inc(&mNextUniqueId);
-
- ALOGI("loaded default module %s, handle %d", properties.product, properties.handle);
-
convertProperties(&properties, &halProperties);
+
+ ALOGI("loaded default module %s, ver %s, handle %d", properties.product,
+ properties.version, properties.handle);
+
sp<Module> module = new Module(dev, properties);
mModules.add(properties.handle, module);
}
diff --git a/services/radio/RadioService.h b/services/radio/RadioService.h
index 49feda6..ac3481e 100644
--- a/services/radio/RadioService.h
+++ b/services/radio/RadioService.h
@@ -103,7 +103,7 @@
class CallbackThread : public Thread {
public:
- CallbackThread(const wp<ModuleClient>& moduleClient);
+ explicit CallbackThread(const wp<ModuleClient>& moduleClient);
virtual ~CallbackThread();
diff --git a/services/soundtrigger/Android.mk b/services/soundtrigger/Android.mk
index c55ac7f..8408c66 100644
--- a/services/soundtrigger/Android.mk
+++ b/services/soundtrigger/Android.mk
@@ -25,18 +25,17 @@
SoundTriggerHwService.cpp
LOCAL_SHARED_LIBRARIES:= \
- libui \
liblog \
libutils \
libbinder \
libcutils \
libhardware \
libsoundtrigger \
- libmedia \
+ libaudioclient \
libserviceutility
LOCAL_C_INCLUDES += \
- $(TOPDIR)frameworks/av/services/audioflinger
+ frameworks/av/services/audioflinger
LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
diff --git a/services/soundtrigger/SoundTriggerHwService.cpp b/services/soundtrigger/SoundTriggerHwService.cpp
index eebc487..6a52b9c 100644
--- a/services/soundtrigger/SoundTriggerHwService.cpp
+++ b/services/soundtrigger/SoundTriggerHwService.cpp
@@ -164,7 +164,7 @@
}
-void SoundTriggerHwService::detachModule(sp<Module> module)
+void SoundTriggerHwService::detachModule(const sp<Module>& module)
{
ALOGV("detachModule");
AutoMutex lock(mServiceLock);
diff --git a/services/soundtrigger/SoundTriggerHwService.h b/services/soundtrigger/SoundTriggerHwService.h
index 2619a5f..13a577a 100644
--- a/services/soundtrigger/SoundTriggerHwService.h
+++ b/services/soundtrigger/SoundTriggerHwService.h
@@ -125,7 +125,7 @@
sound_trigger_hw_device *hwDevice() const { return mHwDevice; }
struct sound_trigger_module_descriptor descriptor() { return mDescriptor; }
- void setClient(sp<ISoundTriggerClient> client) { mClient = client; }
+ void setClient(const sp<ISoundTriggerClient>& client) { mClient = client; }
void clearClient() { mClient.clear(); }
sp<ISoundTriggerClient> client() const { return mClient; }
wp<SoundTriggerHwService> service() const { return mService; }
@@ -156,7 +156,7 @@
class CallbackThread : public Thread {
public:
- CallbackThread(const wp<SoundTriggerHwService>& service);
+ explicit CallbackThread(const wp<SoundTriggerHwService>& service);
virtual ~CallbackThread();
@@ -176,7 +176,7 @@
Vector< sp<CallbackEvent> > mEventQueue;
};
- void detachModule(sp<Module> module);
+ void detachModule(const sp<Module>& module);
static void recognitionCallback(struct sound_trigger_recognition_event *event, void *cookie);
sp<IMemory> prepareRecognitionEvent_l(struct sound_trigger_recognition_event *event);
diff --git a/soundtrigger/Android.bp b/soundtrigger/Android.bp
new file mode 100644
index 0000000..6178153
--- /dev/null
+++ b/soundtrigger/Android.bp
@@ -0,0 +1,36 @@
+// Copyright 2014 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.
+
+cc_library_shared {
+ name: "libsoundtrigger",
+
+ srcs: [
+ "SoundTrigger.cpp",
+ "ISoundTrigger.cpp",
+ "ISoundTriggerClient.cpp",
+ "ISoundTriggerHwService.cpp",
+ ],
+
+ shared_libs: [
+ "libcutils",
+ "libutils",
+ "liblog",
+ "libbinder",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
diff --git a/soundtrigger/Android.mk b/soundtrigger/Android.mk
deleted file mode 100644
index c794cc1..0000000
--- a/soundtrigger/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2014 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- SoundTrigger.cpp \
- ISoundTrigger.cpp \
- ISoundTriggerClient.cpp \
- ISoundTriggerHwService.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- liblog \
- libbinder \
- libhardware
-
-#LOCAL_C_INCLUDES += \
- system/media/camera/include \
- system/media/private/camera/include
-
-LOCAL_MODULE:= libsoundtrigger
-
-LOCAL_CFLAGS := -Werror -Wall
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/soundtrigger/ISoundTrigger.cpp b/soundtrigger/ISoundTrigger.cpp
index 4df2068..25332a4 100644
--- a/soundtrigger/ISoundTrigger.cpp
+++ b/soundtrigger/ISoundTrigger.cpp
@@ -37,7 +37,7 @@
class BpSoundTrigger: public BpInterface<ISoundTrigger>
{
public:
- BpSoundTrigger(const sp<IBinder>& impl)
+ explicit BpSoundTrigger(const sp<IBinder>& impl)
: BpInterface<ISoundTrigger>(impl)
{
}
diff --git a/soundtrigger/ISoundTriggerClient.cpp b/soundtrigger/ISoundTriggerClient.cpp
index e0d3add..1385631 100644
--- a/soundtrigger/ISoundTriggerClient.cpp
+++ b/soundtrigger/ISoundTriggerClient.cpp
@@ -35,7 +35,7 @@
{
public:
- BpSoundTriggerClient(const sp<IBinder>& impl)
+ explicit BpSoundTriggerClient(const sp<IBinder>& impl)
: BpInterface<ISoundTriggerClient>(impl)
{
}
diff --git a/soundtrigger/ISoundTriggerHwService.cpp b/soundtrigger/ISoundTriggerHwService.cpp
index e37bae3..d44f5cb 100644
--- a/soundtrigger/ISoundTriggerHwService.cpp
+++ b/soundtrigger/ISoundTriggerHwService.cpp
@@ -45,7 +45,7 @@
class BpSoundTriggerHwService: public BpInterface<ISoundTriggerHwService>
{
public:
- BpSoundTriggerHwService(const sp<IBinder>& impl)
+ explicit BpSoundTriggerHwService(const sp<IBinder>& impl)
: BpInterface<ISoundTriggerHwService>(impl)
{
}
diff --git a/soundtrigger/SoundTrigger.cpp b/soundtrigger/SoundTrigger.cpp
index e959b83..289b7b1 100644
--- a/soundtrigger/SoundTrigger.cpp
+++ b/soundtrigger/SoundTrigger.cpp
@@ -124,9 +124,9 @@
}
// SoundTrigger
-SoundTrigger::SoundTrigger(sound_trigger_module_handle_t module,
+SoundTrigger::SoundTrigger(sound_trigger_module_handle_t /*module*/,
const sp<SoundTriggerCallback>& callback)
- : mModule(module), mCallback(callback)
+ : mCallback(callback)
{
}