LCOV - code coverage report
Current view: top level - libavcodec - nvdec_vp8.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 30 0.0 %
Date: 2017-12-18 06:23:41 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             :  * VP8 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 "internal.h"
      27             : #include "vp8.h"
      28             : 
      29           0 : static unsigned char safe_get_ref_idx(VP8Frame *frame)
      30             : {
      31           0 :     return frame ? ff_nvdec_get_ref_idx(frame->tf.f) : 255;
      32             : }
      33             : 
      34           0 : static int nvdec_vp8_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
      35             : {
      36           0 :     VP8Context *h = avctx->priv_data;
      37             : 
      38           0 :     NVDECContext      *ctx = avctx->internal->hwaccel_priv_data;
      39           0 :     CUVIDPICPARAMS     *pp = &ctx->pic_params;
      40             :     FrameDecodeData *fdd;
      41             :     NVDECFrame *cf;
      42           0 :     AVFrame *cur_frame = h->framep[VP56_FRAME_CURRENT]->tf.f;
      43             : 
      44             :     int ret;
      45             : 
      46           0 :     ret = ff_nvdec_start_frame(avctx, cur_frame);
      47           0 :     if (ret < 0)
      48           0 :         return ret;
      49             : 
      50           0 :     fdd = (FrameDecodeData*)cur_frame->private_ref->data;
      51           0 :     cf  = (NVDECFrame*)fdd->hwaccel_priv;
      52             : 
      53           0 :     *pp = (CUVIDPICPARAMS) {
      54           0 :         .PicWidthInMbs     = (cur_frame->width  + 15) / 16,
      55           0 :         .FrameHeightInMbs  = (cur_frame->height + 15) / 16,
      56           0 :         .CurrPicIdx        = cf->idx,
      57             : 
      58             :         .CodecSpecific.vp8 = {
      59           0 :             .width                       = cur_frame->width,
      60           0 :             .height                      = cur_frame->height,
      61             : 
      62           0 :             .first_partition_size        = h->header_partition_size,
      63             : 
      64           0 :             .LastRefIdx                  = safe_get_ref_idx(h->framep[VP56_FRAME_PREVIOUS]),
      65           0 :             .GoldenRefIdx                = safe_get_ref_idx(h->framep[VP56_FRAME_GOLDEN]),
      66           0 :             .AltRefIdx                   = safe_get_ref_idx(h->framep[VP56_FRAME_GOLDEN2]),
      67             :             /*
      68             :              * Explicit braces for anonymous inners and unnamed fields
      69             :              * to work around limitations in ancient versions of gcc.
      70             :              */
      71             :             { // union
      72             :                 { // struct
      73           0 :                     !h->keyframe,             // frame_type
      74           0 :                     h->profile,               // version
      75           0 :                     !h->invisible,            // show_frame
      76           0 :                     h->segmentation.enabled ? // update_mb_segmentation_data
      77           0 :                         h->segmentation.update_feature_data : 0,
      78             :                 }
      79             :             }
      80             :         }
      81             :     };
      82             : 
      83           0 :     return 0;
      84             : }
      85             : 
      86           0 : static int nvdec_vp8_frame_params(AVCodecContext *avctx,
      87             :                                   AVBufferRef *hw_frames_ctx)
      88             : {
      89             :     // VP8 uses a fixed size pool of 3 possible reference frames
      90           0 :     return ff_nvdec_frame_params(avctx, hw_frames_ctx, 3);
      91             : }
      92             : 
      93             : AVHWAccel ff_vp8_nvdec_hwaccel = {
      94             :     .name                 = "vp8_nvdec",
      95             :     .type                 = AVMEDIA_TYPE_VIDEO,
      96             :     .id                   = AV_CODEC_ID_VP8,
      97             :     .pix_fmt              = AV_PIX_FMT_CUDA,
      98             :     .start_frame          = nvdec_vp8_start_frame,
      99             :     .end_frame            = ff_nvdec_simple_end_frame,
     100             :     .decode_slice         = ff_nvdec_simple_decode_slice,
     101             :     .frame_params         = nvdec_vp8_frame_params,
     102             :     .init                 = ff_nvdec_decode_init,
     103             :     .uninit               = ff_nvdec_decode_uninit,
     104             :     .priv_data_size       = sizeof(NVDECContext),
     105             : };

Generated by: LCOV version 1.13