2013-01-12 18:53:47 +03:00
|
|
|
/*
|
|
|
|
* 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"
|
2016-11-24 16:14:22 +02:00
|
|
|
#include "hwaccel.h"
|
2013-01-12 18:53:47 +03:00
|
|
|
#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;
|
|
|
|
MpegEncContext * const s = &v->s;
|
2013-07-25 22:30:20 +03:00
|
|
|
Picture *pic = s->current_picture_ptr;
|
|
|
|
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
|
|
|
|
VdpPictureInfoVC1 *info = &pic_ctx->info.vc1;
|
2013-01-12 18:53:47 +03:00
|
|
|
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:
|
2014-03-31 20:46:29 +03:00
|
|
|
ref = ff_vdpau_get_surface_id(s->next_picture.f);
|
2013-01-12 18:53:47 +03:00
|
|
|
assert(ref != VDP_INVALID_HANDLE);
|
|
|
|
info->backward_reference = ref;
|
|
|
|
/* fall-through */
|
|
|
|
case AV_PICTURE_TYPE_P:
|
2014-03-31 20:46:29 +03:00
|
|
|
ref = ff_vdpau_get_surface_id(s->last_picture.f);
|
2013-01-12 18:53:47 +03:00
|
|
|
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;
|
|
|
|
|
2013-07-24 19:50:42 +03:00
|
|
|
info->frame_coding_mode = v->fcm ? (v->fcm + 1) : 0;
|
2013-01-12 18:53:47 +03:00
|
|
|
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;
|
2013-11-26 14:18:44 +03:00
|
|
|
info->syncmarker = v->resync_marker;
|
2013-01-12 18:53:47 +03:00
|
|
|
info->rangered = v->rangered | (v->rangeredfrm << 1);
|
|
|
|
info->maxbframes = v->s.max_b_frames;
|
|
|
|
info->deblockEnable = v->postprocflag & 1;
|
|
|
|
info->pquant = v->pq;
|
|
|
|
|
2014-03-20 10:53:16 +03:00
|
|
|
return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
|
2013-01-12 18:53:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vdpau_vc1_decode_slice(AVCodecContext *avctx,
|
|
|
|
const uint8_t *buffer, uint32_t size)
|
|
|
|
{
|
2013-07-25 22:30:20 +03:00
|
|
|
VC1Context * const v = avctx->priv_data;
|
|
|
|
MpegEncContext * const s = &v->s;
|
|
|
|
Picture *pic = s->current_picture_ptr;
|
|
|
|
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
|
2013-01-12 18:53:47 +03:00
|
|
|
int val;
|
|
|
|
|
2014-03-20 10:53:16 +03:00
|
|
|
val = ff_vdpau_add_buffer(pic_ctx, buffer, size);
|
2013-01-12 18:53:47 +03:00
|
|
|
if (val < 0)
|
|
|
|
return val;
|
|
|
|
|
2013-07-25 22:30:20 +03:00
|
|
|
pic_ctx->info.vc1.slice_count++;
|
2013-01-12 18:53:47 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-04 16:55:05 +03:00
|
|
|
static int vdpau_vc1_init(AVCodecContext *avctx)
|
|
|
|
{
|
|
|
|
VdpDecoderProfile profile;
|
|
|
|
|
|
|
|
switch (avctx->profile) {
|
|
|
|
case FF_PROFILE_VC1_SIMPLE:
|
|
|
|
profile = VDP_DECODER_PROFILE_VC1_SIMPLE;
|
|
|
|
break;
|
|
|
|
case FF_PROFILE_VC1_MAIN:
|
|
|
|
profile = VDP_DECODER_PROFILE_VC1_MAIN;
|
|
|
|
break;
|
|
|
|
case FF_PROFILE_VC1_ADVANCED:
|
|
|
|
profile = VDP_DECODER_PROFILE_VC1_ADVANCED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return AVERROR(ENOTSUP);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ff_vdpau_common_init(avctx, profile, avctx->level);
|
|
|
|
}
|
|
|
|
|
2013-01-12 18:53:47 +03:00
|
|
|
#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,
|
2013-02-03 13:10:05 +03:00
|
|
|
.end_frame = ff_vdpau_mpeg_end_frame,
|
2013-01-12 18:53:47 +03:00
|
|
|
.decode_slice = vdpau_vc1_decode_slice,
|
2014-03-06 20:19:52 +03:00
|
|
|
.frame_priv_data_size = sizeof(struct vdpau_picture_context),
|
2014-10-04 16:55:05 +03:00
|
|
|
.init = vdpau_vc1_init,
|
|
|
|
.uninit = ff_vdpau_common_uninit,
|
2017-10-19 16:38:20 +02:00
|
|
|
.frame_params = ff_vdpau_common_frame_params,
|
2014-10-04 16:55:05 +03:00
|
|
|
.priv_data_size = sizeof(VDPAUContext),
|
2016-11-24 16:14:22 +02:00
|
|
|
.caps_internal = HWACCEL_CAP_ASYNC_SAFE,
|
2013-01-12 18:53:47 +03:00
|
|
|
};
|
|
|
|
#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,
|
2013-02-03 13:10:05 +03:00
|
|
|
.end_frame = ff_vdpau_mpeg_end_frame,
|
2013-01-12 18:53:47 +03:00
|
|
|
.decode_slice = vdpau_vc1_decode_slice,
|
2014-03-06 20:19:52 +03:00
|
|
|
.frame_priv_data_size = sizeof(struct vdpau_picture_context),
|
2014-10-04 16:55:05 +03:00
|
|
|
.init = vdpau_vc1_init,
|
|
|
|
.uninit = ff_vdpau_common_uninit,
|
2017-10-19 16:38:20 +02:00
|
|
|
.frame_params = ff_vdpau_common_frame_params,
|
2014-10-04 16:55:05 +03:00
|
|
|
.priv_data_size = sizeof(VDPAUContext),
|
2016-11-24 16:14:22 +02:00
|
|
|
.caps_internal = HWACCEL_CAP_ASYNC_SAFE,
|
2013-01-12 18:53:47 +03:00
|
|
|
};
|