mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 803394 - Use Android ColorConverter class for video color conversion on Gingerbread r=doublec
--HG-- extra : rebase_source : c5253447416dd786c347c4e853a20ea011499c18
This commit is contained in:
parent
5546139850
commit
48c6073ab3
@ -145,6 +145,7 @@ class OmxDecoder {
|
||||
void ToVideoFrame_YVU420SemiPlanar(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame);
|
||||
void ToVideoFrame_YUV420PackedSemiPlanar(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame);
|
||||
void ToVideoFrame_YVU420PackedSemiPlanar32m4ka(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame);
|
||||
bool ToVideoFrame_RGB565(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback);
|
||||
bool ToVideoFrame_ColorConverter(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback);
|
||||
bool ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback);
|
||||
bool ToAudioFrame(AudioFrame *aFrame, int64_t aTimeUs, void *aData, size_t aDataOffset, size_t aSize,
|
||||
@ -217,9 +218,11 @@ OmxDecoder::~OmxDecoder()
|
||||
mAudioSource->stop();
|
||||
}
|
||||
|
||||
#ifndef MOZ_ANDROID_HC
|
||||
if (mColorConverter) {
|
||||
delete mColorConverter;
|
||||
}
|
||||
#endif
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
mClient.disconnect();
|
||||
#endif
|
||||
@ -304,10 +307,12 @@ static sp<MediaSource> CreateVideoSource(PluginHost* aPluginHost,
|
||||
|
||||
// Use software decoder for color formats we don't know how to convert.
|
||||
default:
|
||||
#ifndef MOZ_ANDROID_HC
|
||||
if (ColorConverter((OMX_COLOR_FORMATTYPE)videoColorFormat,
|
||||
OMX_COLOR_Format16bitRGB565).isValid()) {
|
||||
return videoSource;
|
||||
}
|
||||
#endif
|
||||
// We need to implement a ToVideoFrame_*() color conversion
|
||||
// function for this video color format.
|
||||
LOG("Unknown video color format: %#x", videoColorFormat);
|
||||
@ -669,7 +674,26 @@ void OmxDecoder::ToVideoFrame_YVU420PackedSemiPlanar32m4ka(VideoFrame *aFrame, i
|
||||
uv, mVideoStride, mVideoWidth/2, mVideoHeight/2, 0, 1);
|
||||
}
|
||||
|
||||
bool OmxDecoder::ToVideoFrame_RGB565(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback) {
|
||||
void *buffer = (*aBufferCallback)(mVideoWidth, mVideoHeight, MPAPI::RGB565);
|
||||
|
||||
if (!buffer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aFrame->mTimeUs = aTimeUs;
|
||||
|
||||
memcpy(buffer, aData, mVideoWidth * mVideoHeight * 2);
|
||||
|
||||
aFrame->mSize = mVideoWidth * mVideoHeight * 2;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OmxDecoder::ToVideoFrame_ColorConverter(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback) {
|
||||
#ifdef MOZ_ANDROID_HC
|
||||
return false;
|
||||
#else
|
||||
if (!mColorConverter) {
|
||||
mColorConverter = new ColorConverter((OMX_COLOR_FORMATTYPE)mVideoColorFormat,
|
||||
OMX_COLOR_Format16bitRGB565);
|
||||
@ -687,14 +711,23 @@ bool OmxDecoder::ToVideoFrame_ColorConverter(VideoFrame *aFrame, int64_t aTimeUs
|
||||
return false;
|
||||
}
|
||||
|
||||
aFrame->mSize = mVideoWidth * mVideoHeight * 2;
|
||||
|
||||
#ifdef MOZ_ANDROID_GB
|
||||
mColorConverter->convert(mVideoWidth, mVideoHeight,
|
||||
aData, 0 /* srcSkip */,
|
||||
buffer, mVideoWidth * 2);
|
||||
#else
|
||||
mColorConverter->convert(aData, mVideoStride, mVideoSliceHeight,
|
||||
mVideoCropLeft, mVideoCropTop,
|
||||
mVideoCropLeft + mVideoWidth - 1,
|
||||
mVideoCropTop + mVideoHeight - 1,
|
||||
buffer, mVideoWidth, mVideoHeight,
|
||||
0, 0, mVideoWidth - 1, mVideoHeight - 1);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback) {
|
||||
@ -717,6 +750,9 @@ bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData,
|
||||
case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar: // e.g. Galaxy Nexus
|
||||
ToVideoFrame_YUV420PackedSemiPlanar(aFrame, aTimeUs, aData, aSize, aKeyFrame);
|
||||
break;
|
||||
case OMX_COLOR_Format16bitRGB565:
|
||||
return ToVideoFrame_RGB565(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback);
|
||||
break;
|
||||
default:
|
||||
if (!ToVideoFrame_ColorConverter(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback)) {
|
||||
LOG("Unknown video color format: %#x", mVideoColorFormat);
|
||||
@ -752,6 +788,8 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aSeekTimeUs,
|
||||
err = mVideoSource->read(&mVideoBuffer);
|
||||
}
|
||||
|
||||
aFrame->mSize = 0;
|
||||
|
||||
if (err == OK && mVideoBuffer->range_length() > 0) {
|
||||
int64_t timeUs;
|
||||
int32_t keyFrame;
|
||||
|
@ -54,6 +54,8 @@ EXTRA_DSO_LDOPTS += \
|
||||
-lutils \
|
||||
-L$(DEPTH)/media/omx-plugin/lib/gb/libstagefright \
|
||||
-lstagefright \
|
||||
-L$(DEPTH)/media/omx-plugin/lib/gb/libstagefright_color_conversion \
|
||||
-lstagefright_color_conversion \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += \
|
||||
|
@ -54,6 +54,8 @@ EXTRA_DSO_LDOPTS += \
|
||||
-lutils \
|
||||
-L$(DEPTH)/media/omx-plugin/lib/gb235/libstagefright \
|
||||
-lstagefright \
|
||||
-L$(DEPTH)/media/omx-plugin/lib/gb/libstagefright_color_conversion \
|
||||
-lstagefright_color_conversion \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += \
|
||||
|
72
media/omx-plugin/include/gb/stagefright/ColorConverter.h
Normal file
72
media/omx-plugin/include/gb/stagefright/ColorConverter.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 COLOR_CONVERTER_H_
|
||||
|
||||
#define COLOR_CONVERTER_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <OMX_Video.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
struct ColorConverter {
|
||||
ColorConverter(OMX_COLOR_FORMATTYPE from, OMX_COLOR_FORMATTYPE to);
|
||||
~ColorConverter();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
void convert(
|
||||
size_t width, size_t height,
|
||||
const void *srcBits, size_t srcSkip,
|
||||
void *dstBits, size_t dstSkip);
|
||||
|
||||
private:
|
||||
OMX_COLOR_FORMATTYPE mSrcFormat, mDstFormat;
|
||||
uint8_t *mClip;
|
||||
|
||||
uint8_t *initClip();
|
||||
|
||||
void convertCbYCrY(
|
||||
size_t width, size_t height,
|
||||
const void *srcBits, size_t srcSkip,
|
||||
void *dstBits, size_t dstSkip);
|
||||
|
||||
void convertYUV420Planar(
|
||||
size_t width, size_t height,
|
||||
const void *srcBits, size_t srcSkip,
|
||||
void *dstBits, size_t dstSkip);
|
||||
|
||||
void convertQCOMYUV420SemiPlanar(
|
||||
size_t width, size_t height,
|
||||
const void *srcBits, size_t srcSkip,
|
||||
void *dstBits, size_t dstSkip);
|
||||
|
||||
void convertYUV420SemiPlanar(
|
||||
size_t width, size_t height,
|
||||
const void *srcBits, size_t srcSkip,
|
||||
void *dstBits, size_t dstSkip);
|
||||
|
||||
ColorConverter(const ColorConverter &);
|
||||
ColorConverter &operator=(const ColorConverter &);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // COLOR_CONVERTER_H_
|
@ -28,6 +28,7 @@ cp $1/system/core/include/cutils/logd.h ./cutils/logd.h
|
||||
cp $1/frameworks/base/include/binder/IBinder.h ./binder/IBinder.h
|
||||
cp $1/frameworks/base/include/binder/Binder.h ./binder/Binder.h
|
||||
cp $1/frameworks/base/include/binder/IInterface.h ./binder/IInterface.h
|
||||
cp $1/frameworks/base/include/media/stagefright/ColorConverter.h ./stagefright/ColorConverter.h
|
||||
cp $1/frameworks/base/include/media/stagefright/MediaExtractor.h ./stagefright/MediaExtractor.h
|
||||
cp $1/frameworks/base/include/media/stagefright/OMXCodec.h ./stagefright/OMXCodec.h
|
||||
cp $1/frameworks/base/include/media/stagefright/OMXClient.h ./stagefright/OMXClient.h
|
||||
|
@ -0,0 +1,57 @@
|
||||
# Copyright 2012 Mozilla Foundation and Mozilla contributors
|
||||
#
|
||||
# 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.
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = libstagefright_color_conversion
|
||||
MODULE_NAME = libstagefright_color_conversion
|
||||
LIBRARY_NAME = stagefright_color_conversion
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
# Don't use STL wrappers; this isn't Gecko code
|
||||
STL_FLAGS =
|
||||
|
||||
# must link statically with the CRT; this isn't Gecko code
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
# Need to custom install OMX media plugin
|
||||
NO_DIST_INSTALL = 1
|
||||
NO_INSTALL = 1
|
||||
|
||||
ifneq ($(MOZ_WIDGET_TOOLKIT),gonk)
|
||||
CPPSRCS = \
|
||||
libstagefright_color_conversion.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifdef GNU_CXX
|
||||
# Turn off C++ 11 features due to conflicts with Android OS headers and char16_t definition
|
||||
CXXFLAGS += -std=gnu++98
|
||||
endif
|
||||
|
||||
INCLUDES += \
|
||||
-I$(topsrcdir)/media/omx-plugin/include/gb \
|
||||
-I$(topsrcdir)/media/omx-plugin/include/gb/media/stagefright/openmax \
|
||||
$(NULL)
|
||||
|
||||
# EXTRA_DSO_LDOPTS += \
|
||||
# -L$(DEPTH)/media/omx-plugin/lib/gb/libutils \
|
||||
# -lutils \
|
||||
# $(NULL)
|
@ -0,0 +1,27 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/Types.h"
|
||||
#include "stagefright/ColorConverter.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
MOZ_EXPORT ColorConverter::ColorConverter(OMX_COLOR_FORMATTYPE srcFormat,
|
||||
OMX_COLOR_FORMATTYPE dstFormat)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool ColorConverter::isValid() const { return false; }
|
||||
|
||||
MOZ_EXPORT void ColorConverter::convert(unsigned int, unsigned int,
|
||||
const void*, unsigned int,
|
||||
void*, unsigned int)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT ColorConverter::~ColorConverter() { }
|
||||
|
||||
} // namespace android
|
Loading…
x
Reference in New Issue
Block a user