]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/nvdec_vc1.c
Merge commit '8c893aa3cd5f2d73896c72af330dcbfe299fbc5a'
[ffmpeg] / libavcodec / nvdec_vc1.c
index cf75ba5aca4f6468a5682516763057bf2abd3cfd..7257692d66a35d67b2568d5c180b0d1e239a792d 100644 (file)
 #include "decode.h"
 #include "vc1.h"
 
-static unsigned char get_ref_idx(AVFrame *frame)
-{
-    FrameDecodeData *fdd;
-    NVDECFrame *cf;
-
-    if (!frame || !frame->private_ref)
-        return 255;
-
-    fdd = (FrameDecodeData*)frame->private_ref->data;
-    cf  = (NVDECFrame*)fdd->hwaccel_priv;
-
-    return cf->idx;
-}
-
 static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 {
     VC1Context *v = avctx->priv_data;
@@ -73,8 +59,8 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u
                              s->pict_type == AV_PICTURE_TYPE_P,
 
         .CodecSpecific.vc1 = {
-            .ForwardRefIdx     = get_ref_idx(s->last_picture.f),
-            .BackwardRefIdx    = get_ref_idx(s->next_picture.f),
+            .ForwardRefIdx     = ff_nvdec_get_ref_idx(s->last_picture.f),
+            .BackwardRefIdx    = ff_nvdec_get_ref_idx(s->next_picture.f),
             .FrameWidth        = cur_frame->width,
             .FrameHeight       = cur_frame->height,
 
@@ -117,35 +103,6 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u
     return 0;
 }
 
-static int nvdec_vc1_end_frame(AVCodecContext *avctx)
-{
-    NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
-    int ret = ff_nvdec_end_frame(avctx);
-    ctx->bitstream = NULL;
-    return ret;
-}
-
-static int nvdec_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
-{
-    NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
-    void *tmp;
-
-    tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated,
-                          (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets));
-    if (!tmp)
-        return AVERROR(ENOMEM);
-    ctx->slice_offsets = tmp;
-
-    if (!ctx->bitstream)
-        ctx->bitstream = (uint8_t*)buffer;
-
-    ctx->slice_offsets[ctx->nb_slices] = buffer - ctx->bitstream;
-    ctx->bitstream_len += size;
-    ctx->nb_slices++;
-
-    return 0;
-}
-
 static int nvdec_vc1_frame_params(AVCodecContext *avctx,
                                   AVBufferRef *hw_frames_ctx)
 {
@@ -153,14 +110,14 @@ static int nvdec_vc1_frame_params(AVCodecContext *avctx,
     return ff_nvdec_frame_params(avctx, hw_frames_ctx, 2);
 }
 
-AVHWAccel ff_vc1_nvdec_hwaccel = {
+const AVHWAccel ff_vc1_nvdec_hwaccel = {
     .name                 = "vc1_nvdec",
     .type                 = AVMEDIA_TYPE_VIDEO,
     .id                   = AV_CODEC_ID_VC1,
     .pix_fmt              = AV_PIX_FMT_CUDA,
     .start_frame          = nvdec_vc1_start_frame,
-    .end_frame            = nvdec_vc1_end_frame,
-    .decode_slice         = nvdec_vc1_decode_slice,
+    .end_frame            = ff_nvdec_simple_end_frame,
+    .decode_slice         = ff_nvdec_simple_decode_slice,
     .frame_params         = nvdec_vc1_frame_params,
     .init                 = ff_nvdec_decode_init,
     .uninit               = ff_nvdec_decode_uninit,
@@ -168,14 +125,14 @@ AVHWAccel ff_vc1_nvdec_hwaccel = {
 };
 
 #if CONFIG_WMV3_NVDEC_HWACCEL
-AVHWAccel ff_wmv3_nvdec_hwaccel = {
+const AVHWAccel ff_wmv3_nvdec_hwaccel = {
     .name                 = "wmv3_nvdec",
     .type                 = AVMEDIA_TYPE_VIDEO,
     .id                   = AV_CODEC_ID_WMV3,
     .pix_fmt              = AV_PIX_FMT_CUDA,
     .start_frame          = nvdec_vc1_start_frame,
-    .end_frame            = nvdec_vc1_end_frame,
-    .decode_slice         = nvdec_vc1_decode_slice,
+    .end_frame            = ff_nvdec_simple_end_frame,
+    .decode_slice         = ff_nvdec_simple_decode_slice,
     .frame_params         = nvdec_vc1_frame_params,
     .init                 = ff_nvdec_decode_init,
     .uninit               = ff_nvdec_decode_uninit,