当前位置: 代码迷 >> 多媒体/流媒体开发 >> android2.3 使用libstagefrighthw.so显示yuv数据有关问题
  详细解决方案

android2.3 使用libstagefrighthw.so显示yuv数据有关问题

热度:4878   发布时间:2013-02-26 00:00:00.0
android2.3 使用libstagefrighthw.so显示yuv数据问题
使用使用libstagefrighthw.so显示yuv数据问题,能成功创建VideoRenderer *mTarget对象,
但是在mTarget->render(yuv, frame_len, NULL);//图像为720p的,程序直接挂在render函数中的
LOGE("Doing a memcpy. Report this issue.");
memcpy(mOverlayAddresses[mIndex]->pointer(), data, size);

此memcpy代码中。
mOverlayAddresses[mIndex]->pointer() 内存大小是足够大
log:
02-03 13:48:20.617: ERROR/TIOverlay(13439): Buffer/0/addr=40316000/len=4423680 
02-03 13:48:20.617: ERROR/TIOverlay(13439): Buffer/1/addr=4074e000/len=4423680 
02-03 13:48:20.617: ERROR/TIOverlay(13439): Buffer/2/addr=40b86000/len=4423680 
02-03 13:48:20.617: ERROR/TIOverlay(13439): Buffer/3/addr=40fbe000/len=4423680 
02-03 13:48:20.617: ERROR/TIOverlay(13439): Buffer/4/addr=413f6000/len=4423680 
02-03 13:48:20.617: ERROR/TIOverlay(13439): Buffer/5/addr=4182e000/len=4423680 
02-03 13:48:20.617: ERROR/TIOverlay(13439): Buffer/6/addr=41c66000/len=4423680 
02-03 13:48:20.617: ERROR/TIOverlay(13439): Buffer/7/addr=4209e000/len=4423680 
02-03 13:48:20.625: ERROR/TIOverlay(13439): Buffer/8/addr=424d6000/len=4423680 
02-03 13:48:20.625: ERROR/TIOverlay(13439): Buffer/9/addr=4290e000/len=4423680 

把frame_len设置成1280(720p的,如果是640*480则改为640,相应的上面其他参数也更改),可以出现闪烁的图像。程序不会挂。
请问是否是有些什么设置没有设置?
请求给为给点意见和建议,或者一起讨论下!


设备为:lg p920 android2.3 omap4430 .
程序代码如下:
C/C++ code
char *componentName = NULL;     OMX_COLOR_FORMATTYPE colorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar;    size_t displayWidth = 320;    size_t displayHeight = 240;    size_t decodedWidth = 1280;    size_t decodedHeight = 720;    int32_t rotationDegrees = 0;    int numofBuffers = 1;        sp<ProcessState> proc(ProcessState::self());    ProcessState::self()->startThreadPool();    // create a client to surfaceflinger    sp<SurfaceComposerClient> client = new SurfaceComposerClient();    if (client == 0)    {        printf("sp<SurfaceComposerClient> client error,exit!\n");        return 0;    }    client->setOrientation(0, ISurfaceComposer::eOrientationDefault, 0);    printf("new SurfaceComposerClient end!\n");    sp<SurfaceControl> control = client->createSurface(getpid(), 0,WIDTH_SUR, HEIGHT_SUR,        HAL_PIXEL_FORMAT_YCbCr_420_SP , ISurfaceComposer::ePushBuffers);    if(control == 0)    {        printf("client->createSurface error!\n");        return 0;    }    client->openTransaction();    control->setLayer(100000);      control->setPosition(10, 10);      control->setSize(640, 480);     client->closeTransaction();        // create pushbuffer surface    const sp<Surface> surface = control->getSurface();    if(surface == NULL)    {        printf("control->getSurface error!\n");    }    // get to the isurface    sp<ISurface> isurface = Test::getISurface(surface);        void *mLibHandle = dlopen("libstagefrighthw.so", RTLD_NOW);         if (mLibHandle)     {        printf("\ndlopen success!\n");        typedef VideoRenderer *(*CreateRendererWithRotationFunc)(            const sp<ISurface> &surface,            const char *componentName,            OMX_COLOR_FORMATTYPE colorFormat,            size_t displayWidth, size_t displayHeight,            size_t decodedWidth, size_t decodedHeight,            int32_t rotationDegrees, int is3D, int numofBuffers);        typedef VideoRenderer *(*CreateRendererFunc)(            const sp<ISurface> &surface,            const char *componentName,            OMX_COLOR_FORMATTYPE colorFormat,            size_t displayWidth, size_t displayHeight,            size_t decodedWidth, size_t decodedHeight, int is3D, int numofBuffers);        CreateRendererWithRotationFunc funcWithRotation =            (CreateRendererWithRotationFunc)dlsym(                mLibHandle,                "_Z26createRendererWithRotationRKN7android2spINS_8"                "ISurfaceEEEPKc20OMX_COLOR_FORMATTYPEjjjjiii");        /*CreateRendererWithRotationFunc funcWithRotation =            (CreateRendererWithRotationFunc)dlsym(                mLibHandle,                "_Z14createRendererRKN7android2spINS_8"                "ISurfaceEEEPKc20OMX_COLOR_FORMATTYPEjjjji");*/        if (funcWithRotation)         {            printf("funcWithRotation!\n");            mTarget = (*funcWithRotation)(isurface, componentName, colorFormat,displayWidth,\                displayHeight,decodedWidth, decodedHeight, rotationDegrees, 0, 6);//);//            if(mTarget)            {                printf("mTarget success!\n");            }            else            {                printf(" mTarget is NULL, exit!\n");                //dlclose(mLibHandle);                //return 0;            }        }        else        {            printf("not support funcWithRotation!\n");            if (rotationDegrees != 0)             {                LOGW("renderer does not support rotation.");            }            CreateRendererFunc func = (CreateRendererFunc)dlsym(                            mLibHandle,                            "_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20"                            "OMX_COLOR_FORMATTYPEjjjjii");            //colorFormat            if (func) {                mTarget = (*func)(isurface, componentName, OMX_COLOR_FormatUnused/*colorFormat*/,                            displayWidth, displayHeight,                            decodedWidth, decodedHeight, 0, 6);//90, numofBuffers););//                if(mTarget)                {                    printf("else mTarget success!\n");                }                else                {                    printf("else mTarget is NULL!\n");                    dlclose(mLibHandle);                    mLibHandle = NULL;                    return 0;                }            }        }    }    else    {        printf("dlopen error,exit!\n");        return -1;    }        int i=0;    int frame_len= 1280*720*3/2;    char *yuv = (char *)malloc(1024<<10);    for (i = 0; i < PLAY_FRAME_NUM; i++)    {        FILE *f2642 = fopen(MFILE_DATA2_YUV_VGA, "rb");        if (f2642 == NULL)        {            printf("open 264 file failed!");            return 0;        }                        int read = fread(yuv, 1, frame_len, f2642);        printf("read 264: %d", read);        mTarget->render(yuv, frame_len, NULL);    }    delete yuv;}