Exemplo n.º 1
0
static int ffmpeg_get_va_buffer2(struct AVCodecContext *ctx, AVFrame *frame, int flags)
{
    Q_UNUSED(flags);
    for (unsigned i = 0; i < AV_NUM_DATA_POINTERS; i++) {
        frame->data[i] = NULL;
        frame->linesize[i] = 0;
        frame->buf[i] = NULL;
    }
    //frame->reordered_opaque = ctx->reordered_opaque; //?? xbmc
    VideoDecoderFFmpegHWPrivate *va = (VideoDecoderFFmpegHWPrivate*)ctx->opaque;
    /* hwaccel_context is not present in old ffmpeg version */
    // not coded_width. assume coded_width is 6 aligned of width. ??
    if (!va->setup(ctx)) {
        qWarning("va Setup failed");
        return -1;
    }
    if (!va->getBuffer(&frame->opaque, &frame->data[0])) {
        qWarning("va->getBuffer failed");
        return -1;
    }
    ffmpeg_va_ref_t *ref = new ffmpeg_va_ref_t;
    ref->va = va;
    ref->opaque = frame->opaque;
    /* data[0] must be non-NULL for libavcodec internal checks. data[3] actually contains the format-specific surface handle. */
    frame->data[3] = frame->data[0];
    frame->buf[0] = av_buffer_create(frame->data[0], 0, ffmpeg_release_va_buffer2, ref, 0);
    if (Q_UNLIKELY(!frame->buf[0])) {
        ffmpeg_release_va_buffer2(ref, frame->data[0]);
        return -1;
    }
    Q_ASSERT(frame->data[0] != NULL); // FIXME: VDA may crash in debug mode
    return 0;
}
Exemplo n.º 2
0
static int ffmpeg_get_va_buffer(struct AVCodecContext *c, AVFrame *ff)//vlc_va_t *external, AVFrame *ff)
{
    VideoDecoderFFmpegHWPrivate *va = (VideoDecoderFFmpegHWPrivate*)c->opaque;
    //ff->reordered_opaque = c->reordered_opaque; //TODO: dxva?
    ff->opaque = 0;
#if !AV_MODULE_CHECK(LIBAVCODEC, 54, 34, 0, 79, 101)
    ff->pkt_pts = c->pkt ? c->pkt->pts : AV_NOPTS_VALUE;
#endif
#if LIBAVCODEC_VERSION_MAJOR < 54
    ff->age = 256*256*256*64;
#endif
    /* hwaccel_context is not present in old ffmpeg version */
    // not coded_width. assume coded_width is 6 aligned of width. ??
    if (!va->setup(c)) {
        qWarning("va Setup failed");
        return -1;
    }
    if (!va->getBuffer(&ff->opaque, &ff->data[0]))
        return -1;

    //ffmpeg_va_GetFrameBuf
    ff->data[3] = ff->data[0];
    ff->type = FF_BUFFER_TYPE_USER;
    return 0;
}
Exemplo n.º 3
0
static int ffmpeg_get_va_buffer2(struct AVCodecContext *ctx, AVFrame *frame, int flags)
{
    Q_UNUSED(flags);
    for (unsigned i = 0; i < AV_NUM_DATA_POINTERS; i++) {
        frame->data[i] = NULL;
        frame->linesize[i] = 0;
        frame->buf[i] = NULL;
    }
    //frame->reordered_opaque = ctx->reordered_opaque; //?? xbmc
    // va must be available here
    VideoDecoderFFmpegHWPrivate *va = (VideoDecoderFFmpegHWPrivate*)ctx->opaque;
    if (!va->getBuffer(&frame->opaque, &frame->data[0])) {
        qWarning("va->getBuffer failed");
        return -1;
    }
    ffmpeg_va_ref_t *ref = new ffmpeg_va_ref_t;
    ref->va = va;
    ref->opaque = frame->opaque;
    /* data[0] must be non-NULL for libavcodec internal checks. data[3] actually contains the format-specific surface handle. */
    frame->data[3] = frame->data[0];
    frame->buf[0] = av_buffer_create(frame->data[0], 0, ffmpeg_release_va_buffer2, ref, 0);
    if (Q_UNLIKELY(!frame->buf[0])) {
        ffmpeg_release_va_buffer2(ref, frame->data[0]);
        return -1;
    }
    Q_ASSERT(frame->data[0] != NULL);
    return 0;
}