LCOV - code coverage report
Current view: top level - libavcodec - nvdec_vc1.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 60 0.0 %
Date: 2017-12-13 10:57:33 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*
       2             :  * VC1 HW decode acceleration through NVDEC
       3             :  *
       4             :  * Copyright (c) 2017 Philip Langdale
       5             :  *
       6             :  * This file is part of FFmpeg.
       7             :  *
       8             :  * FFmpeg is free software; you can redistribute it and/or
       9             :  * modify it under the terms of the GNU Lesser General Public
      10             :  * License as published by the Free Software Foundation; either
      11             :  * version 2.1 of the License, or (at your option) any later version.
      12             :  *
      13             :  * FFmpeg is distributed in the hope that it will be useful,
      14             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16             :  * Lesser General Public License for more details.
      17             :  *
      18             :  * You should have received a copy of the GNU Lesser General Public
      19             :  * License along with FFmpeg; if not, write to the Free Software
      20             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      21             :  */
      22             : 
      23             : #include "avcodec.h"
      24             : #include "nvdec.h"
      25             : #include "decode.h"
      26             : #include "vc1.h"
      27             : 
      28           0 : static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
      29             : {
      30           0 :     VC1Context *v = avctx->priv_data;
      31           0 :     MpegEncContext *s = &v->s;
      32             : 
      33           0 :     NVDECContext      *ctx = avctx->internal->hwaccel_priv_data;
      34           0 :     CUVIDPICPARAMS     *pp = &ctx->pic_params;
      35             :     FrameDecodeData *fdd;
      36             :     NVDECFrame *cf;
      37           0 :     AVFrame *cur_frame = s->current_picture.f;
      38             : 
      39             :     int ret;
      40             : 
      41           0 :     ret = ff_nvdec_start_frame(avctx, cur_frame);
      42           0 :     if (ret < 0)
      43           0 :         return ret;
      44             : 
      45           0 :     fdd = (FrameDecodeData*)cur_frame->private_ref->data;
      46           0 :     cf  = (NVDECFrame*)fdd->hwaccel_priv;
      47             : 
      48           0 :     *pp = (CUVIDPICPARAMS) {
      49           0 :         .PicWidthInMbs     = (cur_frame->width  + 15) / 16,
      50           0 :         .FrameHeightInMbs  = (cur_frame->height + 15) / 16,
      51           0 :         .CurrPicIdx        = cf->idx,
      52           0 :         .field_pic_flag    = v->field_mode,
      53           0 :         .bottom_field_flag = v->cur_field_type,
      54           0 :         .second_field      = v->second_field,
      55             : 
      56           0 :         .intra_pic_flag    = s->pict_type == AV_PICTURE_TYPE_I ||
      57           0 :                              s->pict_type == AV_PICTURE_TYPE_BI,
      58           0 :         .ref_pic_flag      = s->pict_type == AV_PICTURE_TYPE_I ||
      59           0 :                              s->pict_type == AV_PICTURE_TYPE_P,
      60             : 
      61             :         .CodecSpecific.vc1 = {
      62           0 :             .ForwardRefIdx     = ff_nvdec_get_ref_idx(s->last_picture.f),
      63           0 :             .BackwardRefIdx    = ff_nvdec_get_ref_idx(s->next_picture.f),
      64           0 :             .FrameWidth        = cur_frame->width,
      65           0 :             .FrameHeight       = cur_frame->height,
      66             : 
      67           0 :             .intra_pic_flag    = s->pict_type == AV_PICTURE_TYPE_I ||
      68           0 :                                  s->pict_type == AV_PICTURE_TYPE_BI,
      69           0 :             .ref_pic_flag      = s->pict_type == AV_PICTURE_TYPE_I ||
      70           0 :                                  s->pict_type == AV_PICTURE_TYPE_P,
      71           0 :             .progressive_fcm   = v->fcm == 0,
      72             : 
      73           0 :             .profile           = v->profile,
      74           0 :             .postprocflag      = v->postprocflag,
      75           0 :             .pulldown          = v->broadcast,
      76           0 :             .interlace         = v->interlace,
      77           0 :             .tfcntrflag        = v->tfcntrflag,
      78           0 :             .finterpflag       = v->finterpflag,
      79           0 :             .psf               = v->psf,
      80           0 :             .multires          = v->multires,
      81           0 :             .syncmarker        = v->resync_marker,
      82           0 :             .rangered          = v->rangered,
      83           0 :             .maxbframes        = s->max_b_frames,
      84             : 
      85           0 :             .panscan_flag      = v->panscanflag,
      86           0 :             .refdist_flag      = v->refdist_flag,
      87           0 :             .extended_mv       = v->extended_mv,
      88           0 :             .dquant            = v->dquant,
      89           0 :             .vstransform       = v->vstransform,
      90           0 :             .loopfilter        = v->s.loop_filter,
      91           0 :             .fastuvmc          = v->fastuvmc,
      92           0 :             .overlap           = v->overlap,
      93           0 :             .quantizer         = v->quantizer_mode,
      94           0 :             .extended_dmv      = v->extended_dmv,
      95           0 :             .range_mapy_flag   = v->range_mapy_flag,
      96           0 :             .range_mapy        = v->range_mapy,
      97           0 :             .range_mapuv_flag  = v->range_mapuv_flag,
      98           0 :             .range_mapuv       = v->range_mapuv,
      99           0 :             .rangeredfrm       = v->rangeredfrm,
     100             :         }
     101             :     };
     102             : 
     103           0 :     return 0;
     104             : }
     105             : 
     106           0 : static int nvdec_vc1_frame_params(AVCodecContext *avctx,
     107             :                                   AVBufferRef *hw_frames_ctx)
     108             : {
     109             :     // Each frame can at most have one P and one B reference
     110           0 :     return ff_nvdec_frame_params(avctx, hw_frames_ctx, 2);
     111             : }
     112             : 
     113             : const AVHWAccel ff_vc1_nvdec_hwaccel = {
     114             :     .name                 = "vc1_nvdec",
     115             :     .type                 = AVMEDIA_TYPE_VIDEO,
     116             :     .id                   = AV_CODEC_ID_VC1,
     117             :     .pix_fmt              = AV_PIX_FMT_CUDA,
     118             :     .start_frame          = nvdec_vc1_start_frame,
     119             :     .end_frame            = ff_nvdec_simple_end_frame,
     120             :     .decode_slice         = ff_nvdec_simple_decode_slice,
     121             :     .frame_params         = nvdec_vc1_frame_params,
     122             :     .init                 = ff_nvdec_decode_init,
     123             :     .uninit               = ff_nvdec_decode_uninit,
     124             :     .priv_data_size       = sizeof(NVDECContext),
     125             : };
     126             : 
     127             : #if CONFIG_WMV3_NVDEC_HWACCEL
     128             : const AVHWAccel ff_wmv3_nvdec_hwaccel = {
     129             :     .name                 = "wmv3_nvdec",
     130             :     .type                 = AVMEDIA_TYPE_VIDEO,
     131             :     .id                   = AV_CODEC_ID_WMV3,
     132             :     .pix_fmt              = AV_PIX_FMT_CUDA,
     133             :     .start_frame          = nvdec_vc1_start_frame,
     134             :     .end_frame            = ff_nvdec_simple_end_frame,
     135             :     .decode_slice         = ff_nvdec_simple_decode_slice,
     136             :     .frame_params         = nvdec_vc1_frame_params,
     137             :     .init                 = ff_nvdec_decode_init,
     138             :     .uninit               = ff_nvdec_decode_uninit,
     139             :     .priv_data_size       = sizeof(NVDECContext),
     140             : };
     141             : #endif

Generated by: LCOV version 1.13