diff libmpcodecs/vd_ffmpeg.c @ 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 d334e70dc707
children 8c3f3493301e
line wrap: on
line diff
--- 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;