首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > 多媒体 >

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

2012-03-21 
android2.3使用libstagefrighthw.so显示yuv数据问题使用使用libstagefrighthw.so显示yuv数据问题,能成功创

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;} 



[解决办法]
您好,可以交流一下吗?我现在也在做YUV显示的问题,我qq:25127546,可以加我qq,讨论一下这个问题。
[解决办法]
楼主
componentName不用赋值吗?
如果需要赋值应该是什么呢?

还有我直接用这个代码在平板上funcWithRotation和func都获取不到
在HTC上则是创建surface就失败了

后来我从java层传递了一个surface过来,之后再用你的方法,mTarget又总是为空,费解阿,我怀疑componentName需要赋值,但是不知道是什么

不知道楼主可有解决办法,
还有直接使用overlay,你成功过吗?我试过网上看到的很多方法都不行,最好的也就是获得了overlay但是dequeuebuffer的时候又出错了,后来发现overlay的状态值虽然是对的,但是宽度为0,高度为负值,真扯淡。。。

主要想直接使用硬件显示yuv数据,毫无头绪

楼主有高招分享一下阿
[解决办法]
楼主有没有遇到这个问题:
03-01 16:18:42.560: D/OverlayLIB(10390): In OVLib: startDatachannel: fbnum = 0 size = 38016 mOvDataid 5
03-01 16:18:42.560: I/OverlayLIB(10390): mFD=-1
03-01 16:18:42.560: E/OverlayLIB(10390): Cant open framebuffer 
在打开framebuffer的时候出错?
[解决办法]
应该是分配BUffer有问题或者数据COPY有问题了呵呵

热点排行