|
发表于 2018-10-18 16:02:14
只看该作者
19#
附件需要在android目录下编译,生成的so可以在ndk使用,支持yuyv/nv12/rgba3种格式
external/skia也需要略作修改
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 43c3c8c..eb504bb 100755
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -351,6 +351,7 @@ public:
virtual size_t getLength() const SK_OVERRIDE;
virtual const void* getMemoryBase() SK_OVERRIDE;
+ virtual bool markSupport() SK_OVERRIDE;
private:
SkData* fData;
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index ceb30d5..2972343 100755
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -314,6 +314,7 @@ static SkData* newFromParams(const void* src, size_t size, bool copyData) {
}
}
+
SkMemoryStream::SkMemoryStream() {
fData = SkData::NewEmpty();
fOffset = 0;
@@ -343,6 +344,12 @@ SkMemoryStream::~SkMemoryStream() {
fData->unref();
}
+bool SkMemoryStream::markSupport(){
+ //for show whether support reset() or mark() in java, add by WH
+ return true;
+}
+
+
void SkMemoryStream::setMemoryOwned(const void* src, size_t size) {
fData->unref();
fData = SkData::NewFromMalloc(src, size);
diff --git a/src/images/SkHwJpegUtility.cpp b/src/images/SkHwJpegUtility.cpp
index 9c7b434..5e9c5ae 100755
--- a/src/images/SkHwJpegUtility.cpp
+++ b/src/images/SkHwJpegUtility.cpp
@@ -13,13 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+//#define DEBUG_HW_JPEG
#include "SkHwJpegUtility.h"
#include "SkCanvas.h"
#ifdef DEBUG_HW_JPEG
#include "utils/Log.h"
#undef LOG_TAG
#define LOG_TAG "SkHwJpegUtility"
-#define WHLOG LOGE
+#define WHLOG ALOGD
+#define WHREDLOG ALOGE
#endif
/////////////////////////////////////////////////////////////////////
@@ -514,6 +517,7 @@ SkJpegVPUMemStream::SkJpegVPUMemStream(SkStream * stream, size_t *len){
hw_jpeg_VPUMallocLinear(&vpuMem, mallocSize);
if(vpuMem.vir_addr != NULL)
{
+ WHLOG("SkJpegVPUMemStream virtual addr: %p ", vpuMem.vir_addr);
stream->rewind();
bool readApp1 = false, readApp0 = false, readSof = false, error = false;
unsigned short twoBytes = 0;
@@ -524,7 +528,7 @@ SkJpegVPUMemStream::SkJpegVPUMemStream(SkStream * stream, size_t *len){
break;
}
size_t readBytes = stream->read(&twoBytes,2);//FIX ME if big edian
- WHLOG("meet mark : 0x%x, readBytes: %d", twoBytes, readBytes);
+ WHLOG("meet mark : 0x%x, readBytes: %d, bytesInStream:%d", twoBytes, readBytes, bytesInStream);
error = (readBytes<=0);
if(error){
break;
@@ -533,6 +537,10 @@ SkJpegVPUMemStream::SkJpegVPUMemStream(SkStream * stream, size_t *len){
memcpy(mem, &twoBytes, sizeof(unsigned short));
mem += readBytes;
switch(twoBytes){
+ case 0xDAFF:
+ readApp1 = true;
+ readApp0 = true;
+ break;
case 0xD9FF://EOI
readApp1 = true;
readApp0 = true;
@@ -546,6 +554,8 @@ SkJpegVPUMemStream::SkJpegVPUMemStream(SkStream * stream, size_t *len){
case 0xC2FF://SOF2
if(twoBytes == 0xC0FF || twoBytes == 0xC2FF){
readSof = true;
+ //fix error
+ //readApp0 = true;
} else if(twoBytes == 0xE0FF){
readApp0 = true;
}else if(twoBytes == 0xE1FF){
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index 003a77e..a8513c1 100755
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -30,7 +30,9 @@ extern "C" {
#include "jerror.h"
}
-//#define HW_JPEG_DEBUG
+//extern "C" void *memcpy_kernel(void *dest, const void *src, size_t n);
+
+#define HW_JPEG_DEBUG
#ifdef HW_JPEG_DEBUG
#define HW_DEBUG SkDebugf
#else
@@ -596,6 +598,7 @@ do{
if (SkImageDecoder::kDecodeBounds_Mode != mode) {
//use hardvpu mem sometimes when it is not decodeBounds_Mode
bool markSupport = stream->markSupport();
+ //markSupport = true;
WHLOG("markSupport: %d", markSupport);
if(markSupport){//only markSupport and not justcalwh
#ifdef WH_DEBUG_JPEG
@@ -613,6 +616,7 @@ do{
goto __SOFT_DEC;
}
}
+
HwJpegInputInfo hwInfo;
HwJpegOutputInfo outInfo;
hwInfo.justcaloutwh = SkImageDecoder::kDecodeBounds_Mode != mode? 0:1;
@@ -650,6 +654,8 @@ do{
if(reuseBitmap > 0 && colorType != bm->colorType()){
HW_DEBUG("bitmap is not null, but its config is not according with require.");
}
+
+ HW_DEBUG("bitmap width:%d, height:%d, rowptr:%p", bm->width(), bm->height(), rowptr);
if(hw_jpeg_decode(&hwInfo,&outInfo, &reuseBitmap, bm->width(), bm->height()) >= 0){
if(reuseBitmap < 0){
HW_DEBUG("REUSE BITMAP FAILED.");
@@ -680,9 +686,10 @@ do{
JSAMPLE * rowptr = (JSAMPLE*)bm->getPixels();
char *srcAddr = outInfo.outAddr;
HW_DEBUG("bpr: %d, rowptr: %x, srcAddr: %x, reuseBitmap: %d\n",bpr, rowptr, srcAddr, reuseBitmap);
- WHLOG("bpr: %d, rowptr: %x, srcAddr: %x",bpr, rowptr, srcAddr);
+ HW_DEBUG("bpr: %d, rowptr: %x, srcAddr: %x, ppscale width:%d\n",bpr, rowptr, srcAddr);
while(height < outInfo.outHeight){
memcpy(rowptr, srcAddr, bpr);
+ //memcpy_kernel(rowptr, srcAddr, bpr);
rowptr += bpr;
srcAddr += outInfo.ppscalew * pixelBytes;
height++;
|
|