mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-18 03:19:31 +02:00
6f7d3bde11
Instead replace VP56mv by new and identical structures VP8mv and VP9mv. Also replace VP56Frame by VP8FrameType in vp8.h and use that in VP8 code. Also remove VP56_FRAME_GOLDEN2, as this has only been used by VP8, and use VP8_FRAME_ALTREF as replacement for its usage in VP8 as this is more in line with VP8 verbiage. This allows to remove all inclusions of vp56.h from everything that is not VP5/6. This also removes implicit inclusions of hpeldsp.h, h264chroma.h, vp3dsp.h and vp56dsp.h from all VP8/9 files. (This also fixes a build issue: If one compiles with -O0 and disables everything except the VP8-VAAPI encoder, the file containing ff_vpx_norm_shift is not compiled, yet this is used implicitly by vp56_rac_gets_nn() which is defined in vp56.h; it is unused by the VP8-VAAPI encoder and declared as av_unused, yet with -O0 unused noninline functions are not optimized away, leading to linking failures. With this patch, said function is not included in vaapi_encode_vp8.c any more.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
106 lines
3.7 KiB
C
106 lines
3.7 KiB
C
/*
|
|
* VP8 HW decode acceleration through NVDEC
|
|
*
|
|
* Copyright (c) 2017 Philip Langdale
|
|
*
|
|
* This file is part of FFmpeg.
|
|
*
|
|
* FFmpeg 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.
|
|
*
|
|
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "avcodec.h"
|
|
#include "nvdec.h"
|
|
#include "decode.h"
|
|
#include "internal.h"
|
|
#include "vp8.h"
|
|
|
|
static unsigned char safe_get_ref_idx(VP8Frame *frame)
|
|
{
|
|
return frame ? ff_nvdec_get_ref_idx(frame->tf.f) : 255;
|
|
}
|
|
|
|
static int nvdec_vp8_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
|
|
{
|
|
VP8Context *h = avctx->priv_data;
|
|
|
|
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
|
|
CUVIDPICPARAMS *pp = &ctx->pic_params;
|
|
FrameDecodeData *fdd;
|
|
NVDECFrame *cf;
|
|
AVFrame *cur_frame = h->framep[VP8_FRAME_CURRENT]->tf.f;
|
|
|
|
int ret;
|
|
|
|
ret = ff_nvdec_start_frame(avctx, cur_frame);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
fdd = (FrameDecodeData*)cur_frame->private_ref->data;
|
|
cf = (NVDECFrame*)fdd->hwaccel_priv;
|
|
|
|
*pp = (CUVIDPICPARAMS) {
|
|
.PicWidthInMbs = (cur_frame->width + 15) / 16,
|
|
.FrameHeightInMbs = (cur_frame->height + 15) / 16,
|
|
.CurrPicIdx = cf->idx,
|
|
|
|
.CodecSpecific.vp8 = {
|
|
.width = cur_frame->width,
|
|
.height = cur_frame->height,
|
|
|
|
.first_partition_size = h->header_partition_size,
|
|
|
|
.LastRefIdx = safe_get_ref_idx(h->framep[VP8_FRAME_PREVIOUS]),
|
|
.GoldenRefIdx = safe_get_ref_idx(h->framep[VP8_FRAME_GOLDEN]),
|
|
.AltRefIdx = safe_get_ref_idx(h->framep[VP8_FRAME_ALTREF]),
|
|
/*
|
|
* Explicit braces for anonymous inners and unnamed fields
|
|
* to work around limitations in ancient versions of gcc.
|
|
*/
|
|
{ // union
|
|
{ // struct
|
|
!h->keyframe, // frame_type
|
|
h->profile, // version
|
|
!h->invisible, // show_frame
|
|
h->segmentation.enabled ? // update_mb_segmentation_data
|
|
h->segmentation.update_feature_data : 0,
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int nvdec_vp8_frame_params(AVCodecContext *avctx,
|
|
AVBufferRef *hw_frames_ctx)
|
|
{
|
|
// VP8 uses a fixed size pool of 3 possible reference frames
|
|
return ff_nvdec_frame_params(avctx, hw_frames_ctx, 3, 0);
|
|
}
|
|
|
|
AVHWAccel ff_vp8_nvdec_hwaccel = {
|
|
.name = "vp8_nvdec",
|
|
.type = AVMEDIA_TYPE_VIDEO,
|
|
.id = AV_CODEC_ID_VP8,
|
|
.pix_fmt = AV_PIX_FMT_CUDA,
|
|
.start_frame = nvdec_vp8_start_frame,
|
|
.end_frame = ff_nvdec_simple_end_frame,
|
|
.decode_slice = ff_nvdec_simple_decode_slice,
|
|
.frame_params = nvdec_vp8_frame_params,
|
|
.init = ff_nvdec_decode_init,
|
|
.uninit = ff_nvdec_decode_uninit,
|
|
.priv_data_size = sizeof(NVDECContext),
|
|
};
|