diff options
author | Andreas Huber <andih@google.com> | 2010-11-22 13:06:35 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-11-22 14:05:21 -0800 |
commit | f5ab57c2d5e02af7483c94eddb177e4f5c9e9892 (patch) | |
tree | 0290c4064caaca875bfbca4cd3a8857a789d942c /media/libstagefright/colorconversion/SoftwareRenderer.cpp | |
parent | d8f4d4a919fb4fa6bbd405d03dc91f079c3c2e37 (diff) | |
download | frameworks_av-f5ab57c2d5e02af7483c94eddb177e4f5c9e9892.zip frameworks_av-f5ab57c2d5e02af7483c94eddb177e4f5c9e9892.tar.gz frameworks_av-f5ab57c2d5e02af7483c94eddb177e4f5c9e9892.tar.bz2 |
Squashed commit of the following:
commit 0870f7bdd10a7cd36087d723d1957d8e1b967ca7
Author: Andreas Huber <andih@google.com>
Date: Mon Nov 22 12:57:04 2010 -0800
set_surface_crop doesn't seem to work right yet, stop using it in the SoftwareRenderer.
Change-Id: If0a24f78b7810a6cecaa82eb4f23d0f90c22cc42
commit 4767b52bee3a54ae117a8708d6832276a44e6a6a
Author: Andreas Huber <andih@google.com>
Date: Mon Nov 22 11:14:57 2010 -0800
info->mMediaBuffer may still be NULL at this point...
Change-Id: I25a71569015b1bb87f1ea7efff7588958774426f
commit 0cef79874e1f1ddb10b7402177a87d3cffc7de92
Author: Andreas Huber <andih@google.com>
Date: Mon Nov 22 10:55:12 2010 -0800
QCOM's YVU420 color format conversion has now been tested.
Change-Id: I7fef4b642a928af15d42f006f7cdc107d5ff1d67
commit 84fe05a6c969ede0ce8a85a530e110afca07c7a7
Author: Andreas Huber <andih@google.com>
Date: Mon Nov 22 09:59:50 2010 -0800
Removed remaining traces of suspend/resume. Proper reporting of video dimensions based on cropping rectangle.
Change-Id: Ib238b80cbc1f19e7d312f2422eb5e9ab6b06b1bc
commit 50970cdc837c5c498bcf0cb61b436196ca9e2ef7
Author: Andreas Huber <andih@google.com>
Date: Fri Nov 19 16:11:06 2010 -0800
Revamped Software Renderer respects the crop rectangle.
Removed obsolete ADRENO support code.
Change-Id: I984cbc8a99c4d97e09e7d1b1292099c88b9ae535
commit 8abbc6a5608bff650f968540f24a2eab75f254ed
Author: Andreas Huber <andih@google.com>
Date: Fri Nov 19 16:10:41 2010 -0800
The metadata retriever now respects the crop rectangle while capturing a video frame.
Change-Id: Id3377176060086d16717f62c77ce26fabe899050
commit 2d42e4466609d304e88bd2cdd6eb7b297340cc21
Author: Andreas Huber <andih@google.com>
Date: Fri Nov 19 16:09:50 2010 -0800
Changed ColorConverter APIs to be more general.
Clients can now refer to crop rectangles in both source and destination.
Change-Id: Ief151d736818396d0389ec04e7df5650e3ad7c04
commit 273184303d54a54febd3e9c3dd4df30507ea78b5
Author: Andreas Huber <andih@google.com>
Date: Fri Nov 19 15:04:06 2010 -0800
The stagefright commandline tool now writes the extracted video frame to /sdcard/out.jpg
Change-Id: Ieb2ab3fda7a7cd9294beccb8db0eed75096eeef4
commit 2d43390328cadf4ba94c1c3c02e4fb30baa29690
Author: Andreas Huber <andih@google.com>
Date: Fri Nov 19 14:36:55 2010 -0800
The AVC software decoder now properly advertises the cropping rectangle.
Change-Id: Idb7a8a7e2fde5740f0fc34b7e8c92eca2577104b
commit 9a7ed23c2fac8ce19dce7a34a603acee945a89f6
Author: Andreas Huber <andih@google.com>
Date: Fri Nov 19 13:40:39 2010 -0800
OMXCodec now signals a format change if the cropping rectangle changes.
...and puts the cropping info into its output format.
Change-Id: I3ffbd8e877ba286fe06a82c536ef20d92548d2e2
commit efe0323947029df1c502599ccc288c8d676dfd31
Author: Andreas Huber <andih@google.com>
Date: Fri Nov 19 11:29:39 2010 -0800
Stagefright's MetaData object now supports rectangle items.
Change-Id: I5667bb5ee6622c76104b99fb57f60abb802a8504
Change-Id: I27cb78f2c5e0353f95fdfc5cb53991949ed75b70
Diffstat (limited to 'media/libstagefright/colorconversion/SoftwareRenderer.cpp')
-rw-r--r-- | media/libstagefright/colorconversion/SoftwareRenderer.cpp | 147 |
1 files changed, 39 insertions, 108 deletions
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp index acbea05..70408d7 100644 --- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp +++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp @@ -21,55 +21,41 @@ #include <binder/MemoryHeapBase.h> #include <binder/MemoryHeapPmem.h> -#include <media/stagefright/MediaDebug.h> +#include <media/stagefright/foundation/ADebug.h> +#include <media/stagefright/MetaData.h> #include <surfaceflinger/Surface.h> #include <ui/android_native_buffer.h> #include <ui/GraphicBufferMapper.h> -// XXX: Temporary hack to allow referencing the _ADRENO pixel format here. -#include <libgralloc-qsd8k/gralloc_priv.h> - namespace android { SoftwareRenderer::SoftwareRenderer( - OMX_COLOR_FORMATTYPE colorFormat, - const sp<Surface> &surface, - size_t displayWidth, size_t displayHeight, - size_t decodedWidth, size_t decodedHeight, - int32_t rotationDegrees) - : mColorFormat(colorFormat), - mConverter(NULL), + const sp<Surface> &surface, const sp<MetaData> &meta) + : mConverter(NULL), mYUVMode(None), - mSurface(surface), - mDisplayWidth(displayWidth), - mDisplayHeight(displayHeight), - mDecodedWidth(decodedWidth), - mDecodedHeight(decodedHeight) { - LOGI("input format = %d", mColorFormat); - LOGI("display = %d x %d, decoded = %d x %d", - mDisplayWidth, mDisplayHeight, mDecodedWidth, mDecodedHeight); - - mDecodedWidth = mDisplayWidth; - mDecodedHeight = mDisplayHeight; + mSurface(surface) { + int32_t tmp; + CHECK(meta->findInt32(kKeyColorFormat, &tmp)); + mColorFormat = (OMX_COLOR_FORMATTYPE)tmp; + + CHECK(meta->findInt32(kKeyWidth, &mWidth)); + CHECK(meta->findInt32(kKeyHeight, &mHeight)); + + if (!meta->findRect( + kKeyCropRect, + &mCropLeft, &mCropTop, &mCropRight, &mCropBottom)) { + mCropLeft = mCropTop = 0; + mCropRight = mWidth - 1; + mCropBottom = mHeight - 1; + } + + int32_t rotationDegrees; + if (!meta->findInt32(kKeyRotation, &rotationDegrees)) { + rotationDegrees = 0; + } int halFormat; switch (mColorFormat) { -#if HAS_YCBCR420_SP_ADRENO - case OMX_COLOR_FormatYUV420Planar: - { - halFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO; - mYUVMode = YUV420ToYUV420sp; - break; - } - - case 0x7fa30c00: - { - halFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO; - mYUVMode = YUV420spToYUV420sp; - break; - } -#endif - default: halFormat = HAL_PIXEL_FORMAT_RGB_565; @@ -80,8 +66,8 @@ SoftwareRenderer::SoftwareRenderer( } CHECK(mSurface.get() != NULL); - CHECK(mDecodedWidth > 0); - CHECK(mDecodedHeight > 0); + CHECK(mWidth > 0); + CHECK(mHeight > 0); CHECK(mConverter == NULL || mConverter->isValid()); CHECK_EQ(0, @@ -94,7 +80,9 @@ SoftwareRenderer::SoftwareRenderer( // Width must be multiple of 32??? CHECK_EQ(0, native_window_set_buffers_geometry( - mSurface.get(), mDecodedWidth, mDecodedHeight, + mSurface.get(), + mCropRight - mCropLeft + 1, + mCropBottom - mCropTop + 1, halFormat)); uint32_t transform; @@ -117,10 +105,6 @@ SoftwareRenderer::~SoftwareRenderer() { mConverter = NULL; } -static inline size_t ALIGN(size_t x, size_t alignment) { - return (x + alignment - 1) & ~(alignment - 1); -} - void SoftwareRenderer::render( const void *data, size_t size, void *platformPrivate) { android_native_buffer_t *buf; @@ -134,7 +118,7 @@ void SoftwareRenderer::render( GraphicBufferMapper &mapper = GraphicBufferMapper::get(); - Rect bounds(mDecodedWidth, mDecodedHeight); + Rect bounds(mWidth, mHeight); void *dst; CHECK_EQ(0, mapper.lock( @@ -142,69 +126,16 @@ void SoftwareRenderer::render( if (mConverter) { mConverter->convert( - mDecodedWidth, mDecodedHeight, - data, 0, dst, buf->stride * 2); - } else if (mYUVMode == YUV420spToYUV420sp) { - // Input and output are both YUV420sp, but the alignment requirements - // are different. - size_t srcYStride = mDecodedWidth; - const uint8_t *srcY = (const uint8_t *)data; - uint8_t *dstY = (uint8_t *)dst; - for (size_t i = 0; i < mDecodedHeight; ++i) { - memcpy(dstY, srcY, mDecodedWidth); - srcY += srcYStride; - dstY += buf->stride; - } - - size_t srcUVStride = (mDecodedWidth + 1) & ~1; - size_t dstUVStride = ALIGN(mDecodedWidth / 2, 32) * 2; - - const uint8_t *srcUV = (const uint8_t *)data - + mDecodedHeight * mDecodedWidth; - - size_t dstUVOffset = ALIGN(ALIGN(mDecodedHeight, 32) * buf->stride, 4096); - uint8_t *dstUV = (uint8_t *)dst + dstUVOffset; - - for (size_t i = 0; i < (mDecodedHeight + 1) / 2; ++i) { - memcpy(dstUV, srcUV, (mDecodedWidth + 1) & ~1); - srcUV += srcUVStride; - dstUV += dstUVStride; - } - } else if (mYUVMode == YUV420ToYUV420sp) { - // Input is YUV420 planar, output is YUV420sp, adhere to proper - // alignment requirements. - size_t srcYStride = mDecodedWidth; - const uint8_t *srcY = (const uint8_t *)data; - uint8_t *dstY = (uint8_t *)dst; - for (size_t i = 0; i < mDecodedHeight; ++i) { - memcpy(dstY, srcY, mDecodedWidth); - srcY += srcYStride; - dstY += buf->stride; - } - - size_t srcUVStride = (mDecodedWidth + 1) / 2; - size_t dstUVStride = ALIGN(mDecodedWidth / 2, 32) * 2; - - const uint8_t *srcU = (const uint8_t *)data - + mDecodedHeight * mDecodedWidth; - - const uint8_t *srcV = - srcU + ((mDecodedWidth + 1) / 2) * ((mDecodedHeight + 1) / 2); - - size_t dstUVOffset = ALIGN(ALIGN(mDecodedHeight, 32) * buf->stride, 4096); - uint8_t *dstUV = (uint8_t *)dst + dstUVOffset; - - for (size_t i = 0; i < (mDecodedHeight + 1) / 2; ++i) { - for (size_t j = 0; j < (mDecodedWidth + 1) / 2; ++j) { - dstUV[2 * j + 1] = srcU[j]; - dstUV[2 * j] = srcV[j]; - } - srcU += srcUVStride; - srcV += srcUVStride; - dstUV += dstUVStride; - } + data, + mWidth, mHeight, + mCropLeft, mCropTop, mCropRight, mCropBottom, + dst, + buf->stride, buf->height, + 0, 0, + mCropRight - mCropLeft, + mCropBottom - mCropTop); } else { - memcpy(dst, data, size); + TRESPASS(); } CHECK_EQ(0, mapper.unlock(buf->handle)); |