vdpau: Add VC-1 decoding via hwaccel infrastructure
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 12 Jan 2013 15:53:47 +0000 (17:53 +0200)
committerDiego Biurrun <diego@biurrun.de>
Sun, 13 Jan 2013 13:54:18 +0000 (14:54 +0100)
Signed-off-by: Diego Biurrun <diego@biurrun.de>
configure
libavcodec/Makefile
libavcodec/allcodecs.c
libavcodec/vdpau_vc1.c [new file with mode: 0644]
libavcodec/version.h

index c62ea2d803b96f957bcec355e63a98c1bc429777..a2bf6e186af2fd2c4c16c9db79fb498383241b4a 100755 (executable)
--- a/configure
+++ b/configure
@@ -1623,9 +1623,11 @@ vc1_dxva2_hwaccel_deps="dxva2api_h"
 vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
 vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
 vc1_vdpau_decoder_select="vdpau vc1_decoder"
+vc1_vdpau_hwaccel_select="vdpau vc1_decoder"
 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
 wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
+wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 
 # parsers
 h264_parser_select="error_resilience golomb h264dsp h264pred mpegvideo"
index 3f5b938cfc546946b7fc6187046db36459482207..1001c2d4079d2c301c1fde77788fb553ec8f74a6 100644 (file)
@@ -383,6 +383,7 @@ OBJS-$(CONFIG_VC1_DECODER)             += vc1dec.o vc1.o vc1data.o vc1dsp.o \
                                           intrax8.o intrax8dsp.o
 OBJS-$(CONFIG_VC1_DXVA2_HWACCEL)       += dxva2_vc1.o
 OBJS-$(CONFIG_VC1_VAAPI_HWACCEL)       += vaapi_vc1.o
+OBJS-$(CONFIG_VC1_VDPAU_HWACCEL)       += vdpau_vc1.o
 OBJS-$(CONFIG_VCR1_DECODER)            += vcr1.o
 OBJS-$(CONFIG_VCR1_ENCODER)            += vcr1.o
 OBJS-$(CONFIG_VMDAUDIO_DECODER)        += vmdav.o
index ac8119a3d5586a1f95cd1fd6761e0b1999f34d57..4622a03491b95f3b73783d621ced3d6db51a8095 100644 (file)
@@ -87,8 +87,10 @@ void avcodec_register_all(void)
     REGISTER_HWACCEL(MPEG4_VDPAU,       mpeg4_vdpau);
     REGISTER_HWACCEL(VC1_DXVA2,         vc1_dxva2);
     REGISTER_HWACCEL(VC1_VAAPI,         vc1_vaapi);
+    REGISTER_HWACCEL(VC1_VDPAU,         vc1_vdpau);
     REGISTER_HWACCEL(WMV3_DXVA2,        wmv3_dxva2);
     REGISTER_HWACCEL(WMV3_VAAPI,        wmv3_vaapi);
+    REGISTER_HWACCEL(WMV3_VDPAU,        wmv3_vdpau);
 
     /* video codecs */
     REGISTER_ENCODER(A64MULTI,          a64multi);
diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
new file mode 100644 (file)
index 0000000..638c07a
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * VC-1 decode acceleration through VDPAU
+ *
+ * Copyright (c) 2008 NVIDIA
+ * Copyright (c) 2013 Rémi Denis-Courmont
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <vdpau/vdpau.h>
+
+#include "avcodec.h"
+#include "vc1.h"
+#include "vdpau.h"
+#include "vdpau_internal.h"
+
+static int vdpau_vc1_start_frame(AVCodecContext *avctx,
+                                 const uint8_t *buffer, uint32_t size)
+{
+    VC1Context * const v  = avctx->priv_data;
+    AVVDPAUContext *hwctx = avctx->hwaccel_context;
+    MpegEncContext * const s = &v->s;
+    VdpPictureInfoVC1 *info = &hwctx->info.vc1;
+    VdpVideoSurface ref;
+
+    /*  fill LvPictureInfoVC1 struct */
+    info->forward_reference  = VDP_INVALID_HANDLE;
+    info->backward_reference = VDP_INVALID_HANDLE;
+
+    switch (s->pict_type) {
+    case AV_PICTURE_TYPE_B:
+        ref = ff_vdpau_get_surface_id(&s->next_picture);
+        assert(ref != VDP_INVALID_HANDLE);
+        info->backward_reference = ref;
+        /* fall-through */
+    case AV_PICTURE_TYPE_P:
+        ref = ff_vdpau_get_surface_id(&s->last_picture);
+        assert(ref != VDP_INVALID_HANDLE);
+        info->forward_reference  = ref;
+    }
+
+    info->slice_count       = 0;
+    if (v->bi_type)
+        info->picture_type  = 4;
+    else
+        info->picture_type  = s->pict_type - 1 + s->pict_type / 3;
+
+    info->frame_coding_mode = v->fcm;
+    info->postprocflag      = v->postprocflag;
+    info->pulldown          = v->broadcast;
+    info->interlace         = v->interlace;
+    info->tfcntrflag        = v->tfcntrflag;
+    info->finterpflag       = v->finterpflag;
+    info->psf               = v->psf;
+    info->dquant            = v->dquant;
+    info->panscan_flag      = v->panscanflag;
+    info->refdist_flag      = v->refdist_flag;
+    info->quantizer         = v->quantizer_mode;
+    info->extended_mv       = v->extended_mv;
+    info->extended_dmv      = v->extended_dmv;
+    info->overlap           = v->overlap;
+    info->vstransform       = v->vstransform;
+    info->loopfilter        = v->s.loop_filter;
+    info->fastuvmc          = v->fastuvmc;
+    info->range_mapy_flag   = v->range_mapy_flag;
+    info->range_mapy        = v->range_mapy;
+    info->range_mapuv_flag  = v->range_mapuv_flag;
+    info->range_mapuv       = v->range_mapuv;
+    /* Specific to simple/main profile only */
+    info->multires          = v->multires;
+    info->syncmarker        = v->s.resync_marker;
+    info->rangered          = v->rangered | (v->rangeredfrm << 1);
+    info->maxbframes        = v->s.max_b_frames;
+    info->deblockEnable     = v->postprocflag & 1;
+    info->pquant            = v->pq;
+
+    return ff_vdpau_common_start_frame(avctx, buffer, size);
+}
+
+static int vdpau_vc1_decode_slice(AVCodecContext *avctx,
+                                  const uint8_t *buffer, uint32_t size)
+{
+    AVVDPAUContext *hwctx = avctx->hwaccel_context;
+    int val;
+
+    val = ff_vdpau_add_buffer(avctx, buffer, size);
+    if (val < 0)
+        return val;
+
+    hwctx->info.vc1.slice_count++;
+    return 0;
+}
+
+#if CONFIG_WMV3_VDPAU_HWACCEL
+AVHWAccel ff_wmv3_vdpau_hwaccel = {
+    .name           = "wm3_vdpau",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_WMV3,
+    .pix_fmt        = AV_PIX_FMT_VDPAU,
+    .start_frame    = vdpau_vc1_start_frame,
+    .end_frame      = ff_vdpau_common_end_frame,
+    .decode_slice   = vdpau_vc1_decode_slice,
+};
+#endif
+
+AVHWAccel ff_vc1_vdpau_hwaccel = {
+    .name           = "vc1_vdpau",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_VC1,
+    .pix_fmt        = AV_PIX_FMT_VDPAU,
+    .start_frame    = vdpau_vc1_start_frame,
+    .end_frame      = ff_vdpau_common_end_frame,
+    .decode_slice   = vdpau_vc1_decode_slice,
+};
index 54e6179e7f3b025a8b2c564d3860481f9334e266..c497edb075be57a768f3284bd38cdaea31a64c7a 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 #define LIBAVCODEC_VERSION_MAJOR 54
-#define LIBAVCODEC_VERSION_MINOR 39
+#define LIBAVCODEC_VERSION_MINOR 40
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \