2 * HW decode acceleration through NVDEC
4 * Copyright (c) 2016 Anton Khirnov
6 * This file is part of FFmpeg.
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.
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.
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
23 #ifndef AVCODEC_NVDEC_H
24 #define AVCODEC_NVDEC_H
26 #include "compat/cuda/dynlink_loader.h"
30 #include "libavutil/buffer.h"
31 #include "libavutil/frame.h"
35 #if defined(NVDECAPI_MAJOR_VERSION) && defined(NVDECAPI_MINOR_VERSION)
36 # define NVDECAPI_CHECK_VERSION(major, minor) \
37 ((major) < NVDECAPI_MAJOR_VERSION || ((major) == NVDECAPI_MAJOR_VERSION && (minor) <= NVDECAPI_MINOR_VERSION))
39 /* version macros were added in SDK 8.1 ffnvcodec */
40 # define NVDECAPI_CHECK_VERSION(major, minor) \
41 ((major) < 8 || ((major) == 8 && (minor) <= 0))
44 typedef struct NVDECFrame {
48 AVBufferRef *ref_idx_ref;
49 AVBufferRef *decoder_ref;
52 typedef struct NVDECContext {
53 CUVIDPICPARAMS pic_params;
55 AVBufferPool *decoder_pool;
57 AVBufferRef *decoder_ref;
61 unsigned int bitstream_allocated;
62 uint8_t *bitstream_internal;
64 unsigned *slice_offsets;
66 unsigned int slice_offsets_allocated;
71 int ff_nvdec_decode_init(AVCodecContext *avctx);
72 int ff_nvdec_decode_uninit(AVCodecContext *avctx);
73 int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame);
74 int ff_nvdec_start_frame_sep_ref(AVCodecContext *avctx, AVFrame *frame, int has_sep_ref);
75 int ff_nvdec_end_frame(AVCodecContext *avctx);
76 int ff_nvdec_simple_end_frame(AVCodecContext *avctx);
77 int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
79 int ff_nvdec_frame_params(AVCodecContext *avctx,
80 AVBufferRef *hw_frames_ctx,
83 int ff_nvdec_get_ref_idx(AVFrame *frame);
85 #endif /* AVCODEC_NVDEC_H */