changeset 36349:20b8efbdfba4

Restore support for old-style VDPAU. It doesn't work exactly the same way, so testing that I did not introduce regressions is highly welcome. To test, change in etc/codecs.conf e.g. dll h264 back to dll h264_vdpau.
author reimar
date Sun, 15 Sep 2013 11:29:03 +0000
parents c4ed4b2d107e
children 44ab9f9a4f42
files fmt-conversion.c libmpcodecs/vd_ffmpeg.c
diffstat 2 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/fmt-conversion.c	Sat Sep 14 10:57:24 2013 +0000
+++ b/fmt-conversion.c	Sun Sep 15 11:29:03 2013 +0000
@@ -137,6 +137,12 @@
 
     { IMGFMT_XVMC_MOCO_MPEG2, AV_PIX_FMT_XVMC_MPEG2_MC },
     { IMGFMT_XVMC_IDCT_MPEG2, AV_PIX_FMT_XVMC_MPEG2_IDCT },
+    { IMGFMT_VDPAU_MPEG1,     AV_PIX_FMT_VDPAU_MPEG1 },
+    { IMGFMT_VDPAU_MPEG2,     AV_PIX_FMT_VDPAU_MPEG2 },
+    { IMGFMT_VDPAU_H264,      AV_PIX_FMT_VDPAU_H264 },
+    { IMGFMT_VDPAU_WMV3,      AV_PIX_FMT_VDPAU_WMV3 },
+    { IMGFMT_VDPAU_VC1,       AV_PIX_FMT_VDPAU_VC1 },
+    { IMGFMT_VDPAU_MPEG4,     AV_PIX_FMT_VDPAU_MPEG4 },
     { 0,                      AV_PIX_FMT_NONE }
 };
 
--- a/libmpcodecs/vd_ffmpeg.c	Sat Sep 14 10:57:24 2013 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Sun Sep 15 11:29:03 2013 +0000
@@ -88,6 +88,7 @@
     int b_count;
     AVRational last_sample_aspect_ratio;
     int palette_sent;
+    int use_hwaccel;
 } vd_ffmpeg_ctx;
 
 #include "m_option.h"
@@ -282,20 +283,21 @@
 static void set_format_params(struct AVCodecContext *avctx,
                               enum AVPixelFormat fmt)
 {
+    sh_video_t *sh     = avctx->opaque;
+    vd_ffmpeg_ctx *ctx = sh->context;
     int imgfmt;
     if (fmt == PIX_FMT_NONE)
         return;
+    ctx->use_hwaccel = fmt == AV_PIX_FMT_VDPAU;
     imgfmt = pixfmt2imgfmt2(fmt, avctx->codec_id);
     if (IMGFMT_IS_HWACCEL(imgfmt)) {
-        sh_video_t *sh     = avctx->opaque;
-        vd_ffmpeg_ctx *ctx = sh->context;
         ctx->do_dr1    = 1;
         ctx->nonref_dr = 0;
         avctx->get_buffer      = get_buffer;
         avctx->release_buffer  = release_buffer;
         avctx->reget_buffer    = get_buffer;
         mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedMPEG2);
-        if (IMGFMT_IS_VDPAU(imgfmt)) {
+        if (ctx->use_hwaccel) {
             avctx->draw_horiz_band = NULL;
             avctx->slice_flags = 0;
             ctx->do_slices = 0;
@@ -526,16 +528,22 @@
                         int y, int type, int height){
     mp_image_t *mpi = src->opaque;
     sh_video_t *sh = s->opaque;
+    vd_ffmpeg_ctx *ctx = sh->context;
     uint8_t *source[MP_MAX_PLANES]= {src->data[0] + offset[0], src->data[1] + offset[1], src->data[2] + offset[2]};
     int strides[MP_MAX_PLANES] = {src->linesize[0], src->linesize[1], src->linesize[2]};
     if (!src->data[0]) {
         mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "BUG in FFmpeg, draw_slice called with NULL pointer!\n");
         return;
     }
-    if (mpi && IMGFMT_IS_VDPAU(mpi->imgfmt)) {
+    if (mpi && ctx->use_hwaccel) {
         mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "BUG in FFmpeg, draw_slice called for VDPAU!\n");
         return;
     }
+    if (IMGFMT_IS_VDPAU(mpi->imgfmt)) {
+        struct vdpau_render_state *render = mpi->priv;
+        vdpau_render_wrapper(s, src, &render->info, render->bitstream_buffers_used, render->bitstream_buffers);
+        return;
+    }
     if (height < 0)
     {
         int i;
@@ -704,7 +712,7 @@
         avctx->draw_horiz_band= draw_slice;
     }
 #if CONFIG_VDPAU
-    if (IMGFMT_IS_VDPAU(mpi->imgfmt)) {
+    if (ctx->use_hwaccel) {
         struct vdpau_render_state *render = mpi->priv;
         AVVDPAUContext *vdpc;
         avctx->draw_horiz_band= NULL;