diff options
author | Patrik Ryd <patrik.ryd@linaro.org> | 2011-11-17 15:58:10 +0100 |
---|---|---|
committer | Patrik Ryd <patrik.ryd@linaro.org> | 2011-11-17 15:58:10 +0100 |
commit | 9c6f5436d855a6b41fa821584d7b0f9d47990ffd (patch) | |
tree | 637e2aac7ed34a63bacd63f62fd8e457c1cf580f | |
parent | 4f5c807d1ba5ca0444b0ec3d967bb560b4cda8f3 (diff) | |
parent | a0e3095b0bb69029f7bc6743ac20953a817852aa (diff) | |
download | base-linaro_android_2.3.7.tar.gz |
Merge branch 'linaro_android_2.3.5' into linaro_android_2.3.7linaro_android_2.3.7
11 files changed, 239 insertions, 11 deletions
diff --git a/core/java/android/webkit/GeolocationService.java b/core/java/android/webkit/GeolocationService.java index 24306f407b90..8378a8b24873 100755 --- a/core/java/android/webkit/GeolocationService.java +++ b/core/java/android/webkit/GeolocationService.java @@ -165,6 +165,12 @@ final class GeolocationService implements LocationListener { } catch(SecurityException e) { Log.e(TAG, "Caught security exception registering for location updates from system. " + "This should only happen in DumpRenderTree."); + } catch(IllegalArgumentException e) { + Log.e(TAG, "Caught IllegalArugument Exception: Either provider or listener is null"); + e.printStackTrace(); + } catch (RuntimeException e) { + Log.e(TAG, "Caught RuntimeException"); + e.printStackTrace(); } } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java index 46135ff19015..87cd8f1ac669 100755 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java @@ -21,6 +21,7 @@ import com.android.mediaframeworktest.functional.MediaAudioTrackTest; import com.android.mediaframeworktest.functional.MediaMetadataTest; import com.android.mediaframeworktest.functional.MediaMimeTest; import com.android.mediaframeworktest.functional.MediaPlayerApiTest; +import com.android.mediaframeworktest.functional.MediaSamplesTest; import com.android.mediaframeworktest.functional.MediaRecorderTest; import com.android.mediaframeworktest.functional.SimTonesTest; import com.android.mediaframeworktest.functional.MediaPlayerInvokeTest; @@ -33,11 +34,13 @@ import com.android.mediaframeworktest.functional.MediaPresetReverbTest; import com.android.mediaframeworktest.functional.MediaVirtualizerTest; import com.android.mediaframeworktest.functional.MediaVisualizerTest; import junit.framework.TestSuite; +import java.io.File; +import java.util.Arrays; +import android.os.Bundle; import android.test.InstrumentationTestRunner; import android.test.InstrumentationTestSuite; - /** * Instrumentation Test Runner for all MediaPlayer tests. * @@ -49,10 +52,24 @@ import android.test.InstrumentationTestSuite; public class MediaFrameworkTestRunner extends InstrumentationTestRunner { + public static String mTargetDir = "/sdcard/"; + + @Override + public void onCreate (Bundle arguments){ + String targetDir = (String)arguments.get("targetDir"); + if(targetDir != null){ + mTargetDir = targetDir; + } + super.onCreate(arguments); + } @Override public TestSuite getAllTests() { TestSuite suite = new InstrumentationTestSuite(this); + if((mTargetDir != null) && (mTargetDir != "")){ + addMMTestCase(suite, MediaFrameworkTestRunner.mTargetDir); + } + /* suite.addTestSuite(MediaPlayerApiTest.class); suite.addTestSuite(SimTonesTest.class); suite.addTestSuite(MediaMetadataTest.class); @@ -69,9 +86,40 @@ public class MediaFrameworkTestRunner extends InstrumentationTestRunner { suite.addTestSuite(MediaPresetReverbTest.class); suite.addTestSuite(MediaVirtualizerTest.class); suite.addTestSuite(MediaVisualizerTest.class); - return suite; + */ return suite; } + public void addMMTestCase(TestSuite suite, String testFilesDir){ + File dir = new File(testFilesDir); + String[] children; + if (dir.isFile()){ + children = new String[]{testFilesDir}; + }else{ + children = dir.list(); + } + if (children == null) { + return; + } else { + Arrays.sort(children); + int length = children.length; + for (int i = 0; i < length; i++) { + String filename = children[i]; + final File subFile = new File(dir + "/" + filename); + if (subFile.isDirectory()){ + addMMTestCase(suite, subFile.getPath()); + }else{ + MediaSamplesTest tempTestCase= new MediaSamplesTest(){ + protected void runTest() throws Exception { + testSubPlay(subFile.getPath()); + } + }; + tempTestCase.setName(filename); + suite.addTest(tempTestCase); + } + } + return; + } + } @Override public ClassLoader getLoader() { return MediaFrameworkTestRunner.class.getClassLoader(); diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java index 2eea206bacd4..b663ceabe8f7 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java @@ -740,12 +740,23 @@ public class CodecTest { static MediaPlayer.OnCompletionListener mCompletionListener = new MediaPlayer.OnCompletionListener() { public void onCompletion(MediaPlayer mp) { synchronized (onCompletion) { - Log.v(TAG, "notify the completion callback"); + Log.v(TAG, "notify the completion callback from OnCompletion"); onCompletion.notify(); onCompleteSuccess = true; } } }; + static MediaPlayer.OnErrorListener mErrorListener = new MediaPlayer.OnErrorListener() { + public boolean onError(MediaPlayer mp, int what, int extra) { + synchronized (onCompletion) { + Log.v(TAG, "notify the completion callback from OnError what=" + what + ", extra=" + extra); + onCompletion.notify(); + onCompleteSuccess = false; + } + //avoid to execute the complete again + return true; + } + }; // For each media file, forward twice and backward once, then play to the end public static boolean playMediaSamples(String filePath) throws Exception { @@ -765,6 +776,7 @@ public class CodecTest { } try { mMediaPlayer.setOnCompletionListener(mCompletionListener); + mMediaPlayer.setOnErrorListener(mErrorListener); Log.v(TAG, "playMediaSamples: sample file name " + filePath); mMediaPlayer.setDataSource(filePath); mMediaPlayer.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder()); diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaSamplesTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaSamplesTest.java new file mode 100644 index 000000000000..6f7a5c319873 --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaSamplesTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mediaframeworktest.functional; + +import com.android.mediaframeworktest.MediaFrameworkTest; +import com.android.mediaframeworktest.MediaNames; +import com.android.mediaframeworktest.MediaProfileReader; + +import android.content.Context; +import android.test.ActivityInstrumentationTestCase; +import android.util.Log; +import android.test.suitebuilder.annotation.LargeTest; +import android.test.suitebuilder.annotation.MediumTest; +import android.test.suitebuilder.annotation.Suppress; + +import java.io.File; +import junit.framework.*; + +/** + * Junit / Instrumentation test case for the media player api + */ +public class MediaSamplesTest extends ActivityInstrumentationTestCase<MediaFrameworkTest> { + private String TAG = "MediaSamplesTest"; + + public MediaSamplesTest() { + super("com.android.mediaframeworktest", MediaFrameworkTest.class); + } + + protected void setUp() throws Exception { + super.setUp(); + } + + @LargeTest + public void testSubPlay(String path) throws Exception{ + boolean onCompleteSuccess = false; + Log.v(TAG, + "testSubPlay: file to be played: " + + path); + onCompleteSuccess = CodecTest.playMediaSamples(path); + assertTrue("testSubPlay:" + path, onCompleteSuccess); + } +} diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk index 87975af9eabf..6a445f6dd2fb 100644 --- a/services/camera/libcameraservice/Android.mk +++ b/services/camera/libcameraservice/Android.mk @@ -40,7 +40,9 @@ endif # USE_CAMERA_STUB include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - CameraService.cpp + CameraService.cpp \ + convert.S \ + rgbconvert.c LOCAL_SHARED_LIBRARIES:= \ libui \ diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 1f032927cf3c..398422dec096 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -37,6 +37,12 @@ #include "CameraService.h" +extern "C" +{ + void convertYUYVtoYUV420SP(unsigned char *buf, unsigned char *out, int width, int height); + void convertYUYVtoRGB565(unsigned char *buf, unsigned char *rgb, int width, int height); +} + namespace android { // ---------------------------------------------------------------------------- @@ -526,12 +532,13 @@ status_t CameraService::Client::registerPreviewBuffers() { CameraParameters params(mHardware->getParameters()); params.getPreviewSize(&w, &h); + mPreviewHeap = new MemoryHeapBase( w * h * 2); // FIXME: don't use a hardcoded format here. ISurface::BufferHeap buffers(w, h, w, h, HAL_PIXEL_FORMAT_RGB_565, mOrientation, 0, - mHardware->getPreviewHeap()); + mPreviewHeap); status_t result = mSurface->registerBuffers(buffers); if (result != NO_ERROR) { @@ -719,6 +726,8 @@ void CameraService::Client::stopPreview() { } mPreviewBuffer.clear(); + mPreviewHeap.clear(); + mHeap.clear(); } // stop recording mode @@ -1047,10 +1056,16 @@ void CameraService::Client::handleShutter(image_rect_type *size) { void CameraService::Client::handlePreviewData(const sp<IMemory>& mem) { ssize_t offset; size_t size; + int w, h; + + CameraParameters params(mHardware->getParameters()); + params.getPreviewSize(&w, &h); + sp<IMemoryHeap> heap = mem->getMemory(&offset, &size); if (!mUseOverlay) { if (mSurface != 0) { + convertYUYVtoRGB565((unsigned char*)heap->base(),(unsigned char*)mPreviewHeap->base(),w,h); mSurface->postBuffer(offset); } } @@ -1083,8 +1098,10 @@ void CameraService::Client::handlePreviewData(const sp<IMemory>& mem) { if (c != 0) { // Is the received frame copied out or not? if (flags & FRAME_CALLBACK_FLAG_COPY_OUT_MASK) { - LOG2("frame is copied"); - copyFrameAndPostCopiedFrame(c, heap, offset, size); + if(mHeap==NULL) + mHeap = new MemoryHeapBase(size*3/4); + convertYUYVtoYUV420SP((unsigned char*)heap->base(),(unsigned char*)mHeap->base(),w,h); + copyFrameAndPostCopiedFrame(c, mHeap, offset, size); } else { LOG2("frame is forwarded"); mLock.unlock(); diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index f09773d11a6c..9da526be3cc6 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -179,6 +179,8 @@ private: // If the user want us to return a copy of the preview frame (instead // of the original one), we allocate mPreviewBuffer and reuse it if possible. sp<MemoryHeapBase> mPreviewBuffer; + sp<MemoryHeapBase> mPreviewHeap; + sp<MemoryHeapBase> mHeap; // We need to avoid the deadlock when the incoming command thread and // the CameraHardwareInterface callback thread both want to grab mLock. diff --git a/services/camera/libcameraservice/convert.S b/services/camera/libcameraservice/convert.S new file mode 100644 index 000000000000..f9ae191f18be --- /dev/null +++ b/services/camera/libcameraservice/convert.S @@ -0,0 +1,35 @@ + .arch armv7-a + .fpu neon + .text + + .globl convertYUYVtoYUV420SP + .type convertYUYVtoYUV420SP, STT_FUNC + .func convertYUYVtoYUV420SP +convertYUYVtoYUV420SP: + push {r4-r5,lr} + mul r12, r2, r3 + add r4, r0, r2, lsl #1 @ in_1 + add r5, r1, r2 @ out_1 + add lr, r1, r12 @ out_uv +1: + mov r12, r2 +2: + vld1.8 {q0}, [r0]! + vld1.8 {q1}, [r4]! + vuzp.8 d0, d1 + vuzp.8 d2, d3 + vhadd.u8 d1, d1, d3 + vrev16.8 d1, d1 + vst1.8 {d0}, [r1]! + vst1.8 {d2}, [r5]! + vst1.8 {d1}, [lr]! + subs r12, r12, #8 + bgt 2b + add r0, r0, r2, lsl #1 + add r4, r4, r2, lsl #1 + add r1, r1, r2 + add r5, r5, r2 + subs r3, r3, #2 + bgt 1b + pop {r4-r5,pc} +.endfunc diff --git a/services/camera/libcameraservice/rgbconvert.c b/services/camera/libcameraservice/rgbconvert.c new file mode 100644 index 000000000000..d1e832bc110b --- /dev/null +++ b/services/camera/libcameraservice/rgbconvert.c @@ -0,0 +1,50 @@ +static void yuv_to_rgb16(unsigned char y, unsigned char u, unsigned char v, unsigned char *rgb) +{ + int r,g,b; + int z; + int rgb16; + + z = 0; + + r = 1.164 * (y - 16) + 1.596 * (v - 128); + g = 1.164 * (y - 16) - 0.813 * (v - 128) - 0.391 * (u -128); + b = 1.164 * (y - 16) + 2.018 * (u - 128); + + if (r > 255) r = 255; + if (g > 255) g = 255; + if (b > 255) b = 255; + + if (r < 0) r = 0; + if (g < 0) g = 0; + if (b < 0) b = 0; + + rgb16 = (int)(((r >> 3)<<11) | ((g >> 2) << 5)| ((b >> 3) << 0)); + + *rgb = (unsigned char)(rgb16 & 0xFF); + rgb++; + *rgb = (unsigned char)((rgb16 & 0xFF00) >> 8); + +} + + +void convertYUYVtoRGB565(unsigned char *buf, unsigned char *rgb, int width, int height) +{ + int x,y,z=0; + int blocks; + + blocks = (width * height) * 2; + + for (y = 0; y < blocks; y+=4) { + unsigned char Y1, Y2, U, V; + + Y1 = buf[y + 0]; + U = buf[y + 1]; + Y2 = buf[y + 2]; + V = buf[y + 3]; + + yuv_to_rgb16(Y1, U, V, &rgb[y]); + yuv_to_rgb16(Y2, U, V, &rgb[y + 2]); + } + +} + diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp index 3c471ca76107..2dee608e07e1 100644 --- a/tools/aapt/Images.cpp +++ b/tools/aapt/Images.cpp @@ -18,7 +18,8 @@ static void png_write_aapt_file(png_structp png_ptr, png_bytep data, png_size_t length) { - status_t err = ((AaptFile*)png_ptr->io_ptr)->writeData(data, length); + AaptFile* io_ptr = (AaptFile*)png_get_io_ptr(png_ptr); + status_t err = io_ptr->writeData(data, length); if (err != NO_ERROR) { png_error(png_ptr, "Write Error"); } @@ -83,7 +84,7 @@ static void read_png(const char* imageName, png_set_palette_to_rgb(read_ptr); if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_gray_1_2_4_to_8(read_ptr); + png_set_expand_gray_1_2_4_to_8(read_ptr); if (png_get_valid(read_ptr, read_info, PNG_INFO_tRNS)) { //printf("Has PNG_INFO_tRNS!\n"); @@ -937,7 +938,6 @@ static void write_png(const char* imageName, png_bytepp rows; if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - png_set_filler(write_ptr, 0, PNG_FILLER_AFTER); rows = imageInfo.rows; } else { rows = outRows; diff --git a/tools/aapt/ZipFile.h b/tools/aapt/ZipFile.h index dbbd072d1692..78775502884b 100644 --- a/tools/aapt/ZipFile.h +++ b/tools/aapt/ZipFile.h @@ -57,7 +57,7 @@ public: /* * Open a new or existing archive. */ - typedef enum { + enum { kOpenReadOnly = 0x01, kOpenReadWrite = 0x02, kOpenCreate = 0x04, // create if it doesn't exist |