[Libva] Multiple vaapi context

Varun Dua varundua007 at gmail.com
Fri Jan 28 04:59:45 PST 2011


Hi

On Mon, Jan 24, 2011 at 3:00 PM, Gwenole Beauchesne <
gbeauchesne at splitted-desktop.com> wrote:

> Hi,
>
>
> On Wed, 19 Jan 2011, Varun Dua wrote:
>
>  I am using FFMpeg and libva for getting hardware acceleration for my h.264
>> videos. With one H.264 stream everything is fine, but with two parallel
>> H.264
>> stream videos I am having a problem. I am creating two FFMpeg contexts
>> (AVCodecContext, AVFormatContext etc) and two vaapi context but I am having
>> problem with that. The errors that come are:
>>
>> VdpOutputSurfaceCreate(): status 25: A catch-all error, used when no other
>> error code applies.
>>
>> vdpau_video: VdpPresentationQueueBlockUntilSurfaceIdle(): status 3: An
>> invalid handle value was provided.
>>
>
> Please provide a self-contained testcase. It's hard to tell otherwise since
> the NVIDIA driver would return this kind of error when none other fits.
>
>
>  Also is there any way before we can know whether these error will come or
>> not, actual decoding the frame (i.e. before calling avcodec_decode_video2 or
>> calling vaPutSurface)
>>
>
> VdpPresentationQueueBlockUntilSurfaceIdle() is used for vaPutSurface()
> implementation. If you use 0.7.x series, could you please also check whether
> prefixing your application with VDPAU_VIDEO_PUTSURFACE_FAST=0 makes a
> difference or not?
>
> Thanks,
> Gwenole.
>

Hi

No it doesn't make any difference. I am having another problem now, I am
getting this error

vdpau_video: VdpDecoderCreate(): status 23: The system does not have enough
resources to complete the requested operation at this time.
[h264 @ 0x852fb10]hardware accelerator failed to decode picture

and since I use vaPutsurface after that, my application crashes. Is there
any way I can know that this error has occured in my application. I am
creating 21 VASurfaces but that doesn't make a difference, reducing the
number also creates that problem. But when I reboot and run the application
again, there are no issues, but after runnning the application again 5 6
times the error again pops up.

Here is my code:

typedef struct _VAAPI_Context {
    Display                    *xdisplay;               /* X11 Display*/
    VAStatus                    vastatus;               /* to check the
status of different libva functions */
    struct vaapi_context       *ffmpeg_va;              /* Vaapi Structure
as required by FFMPEG */
    VASurfaceID                *va_surface_ids;    /* Surfaces are the
render targets for vaapi*/
    int                         va_num_surfaces;   /* number of surfaces
required. Mplayer uses 21 so we are using that only*/
    int                         current_surface;        /* the current
surface holding the decoded data - needed for direct rendering onto a
XWindow or a Drawable
                                                             * context */
    int                         majorversion;           /* major version of
the library. Not used as of now. */
    int                         minorversion;           /* major version of
the library. Not used as of now. */
    Drawable*                   drbl;                   /* The drawable
context required for direct rendering. Can be an XWindow */
    VAProfile                  profile;           /* The H264 profile
supported by the implementation */
} _VAAPI_Context, FAR* P_VAAPI_Context;

typedef struct _FFMpegDecodeContext {
AVFormatContext *pFormatCtx ;
 AVCodecContext   *pCodecCtx ;
 AVCodec         *pCodec;
 AVFrame         *pFrame;
AVFrame         *pFrameRGB;
 uint8_t         *pOUTBufferCTX;
BYTE ActualMagicBytes[6];
 struct SwsContext *img_convert_ctx;
int             iVideoStreamCTX;
 BOOL HWAlloted;
int xLeft;
 int yTop;
BOOL    bDecodingStarted;
} FFMpegDecodeContext, *PFFMpegDecodeContext;

void Decode (pDecodeContext) {
...
...
...
    int len = avcodec_decode_video(pDecodeContext->pCodecCtx,
pDecodeContext->pFrame, &iFrameFinished, AVPacket.data, AVPacket.size);
    if(iFrameFinished)
{
 //Convert the image from its native format to RGB
if(FALSE == pDecodeContext->HWAlloted) {

sws_scale(pDecodeContext->img_convert,&pDecodeContext->pFrame->data[0],&pDecodeContext->pFrame->linesize[0],0,pDecodeContext->pCodecCtx->height,&pDecodeContext->pFrameRGB->data[0],&pDecodeContext->pFrameRGB->linesize[0]);
 }
else {
g_pVaAPI->vastatus = vaPutSurface(g_pVaAPI->ffmpeg_va->display,
g_pVaAPI->va_surface_ids[g_pVaAPI->current_surface],
*(g_pVaAPI->drbl),0,0,pDecodeContext->pCodecCtx->width,pDecodeContext->pCodecCtx->height,pDecodeContext->xLeft,pDecodeContext->yTop,pDecodeContext->pCodecCtx->width,pDecodeContext->pCodecCtx->height,NULL,0,0);
 if(g_pVaAPI->vastatus != VA_STATUS_SUCCESS) {
TRACE((TC_LIB, TT_API1, "Rendering failed:
%s",vaErrorStr(g_pVaAPI->vastatus)));
 return GRAPH_ERR_INTERNAL_ERROR;
}
}
 }
...
...
...
}


Regards
Varun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libva/attachments/20110128/e16658d9/attachment.htm>


More information about the Libva mailing list