FFmpeg
Loading...
Searching...
No Matches
nvdec.h
Go to the documentation of this file.
1/*
2 * HW decode acceleration through NVDEC
3 *
4 * Copyright (c) 2016 Anton Khirnov
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#ifndef AVCODEC_NVDEC_H
24#define AVCODEC_NVDEC_H
25
27
28#include <stdint.h>
29
30#include "libavutil/buffer.h"
31#include "libavutil/frame.h"
32
33#include "avcodec.h"
34
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))
38#else
39/* version macros were added in SDK 8.1 ffnvcodec */
40# define NVDECAPI_CHECK_VERSION(major, minor) \
41 ((major) < 8 || ((major) == 8 && (minor) <= 0))
42#endif
43
44// SDK 13.0 compile time feature checks
45#if NVDECAPI_CHECK_VERSION(13, 0)
46#define NVDEC_HAVE_422_SUPPORT
47#endif
48
49// SDK 13.1 compile time feature checks
50#if NVDECAPI_CHECK_VERSION(13, 1)
51#define NVDEC_HAVE_OPAQUE_OUTPUT_SUPPORT
52#endif
53
54typedef struct NVDECFrame {
55 unsigned int idx;
56 unsigned int ref_idx;
57 unsigned int *idx_ref; ///< RefStruct reference
58 unsigned int *ref_idx_ref; ///< RefStruct reference
59 struct NVDECDecoder *decoder; ///< RefStruct reference
61
62typedef struct NVDECContext {
63 CUVIDPICPARAMS pic_params;
64
66
67 struct NVDECDecoder *decoder; ///< RefStruct reference
68
69 const uint8_t *bitstream;
71 unsigned int bitstream_allocated;
73
74 unsigned *slice_offsets;
77
80
84int ff_nvdec_start_frame_sep_ref(AVCodecContext *avctx, AVFrame *frame, int has_sep_ref);
87int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
88 uint32_t size);
90 AVBufferRef *hw_frames_ctx,
91 enum AVPixelFormat hw_format,
92 int dpb_size,
93 int supports_444);
95
96#ifdef NVDEC_HAVE_OPAQUE_OUTPUT_SUPPORT
97void ff_nvdec_fill_cuarray_desc(CUDA_ARRAY3D_DESCRIPTOR *desc,
98 AVCodecContext *avctx,
99 cudaVideoSurfaceFormat output_format);
100#endif
101
102#endif /* AVCODEC_NVDEC_H */
Libavcodec external API header.
refcounted data buffer API
static AVFrame * frame
static char * output_format
Definition ffprobe.c:145
reference-counted frame API
const char * desc
Definition libsvtav1.c:83
int ff_nvdec_start_frame_sep_ref(AVCodecContext *avctx, AVFrame *frame, int has_sep_ref)
Definition nvdec.c:984
int ff_nvdec_simple_end_frame(AVCodecContext *avctx)
Definition nvdec.c:1051
int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition nvdec.c:1061
int ff_nvdec_decode_init(AVCodecContext *avctx)
Definition nvdec.c:404
int ff_nvdec_get_ref_idx(AVFrame *frame)
Definition nvdec.c:1180
int ff_nvdec_end_frame(AVCodecContext *avctx)
Definition nvdec.c:1014
int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame)
Definition nvdec.c:946
int ff_nvdec_decode_uninit(AVCodecContext *avctx)
Definition nvdec.c:297
int ff_nvdec_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx, enum AVPixelFormat hw_format, int dpb_size, int supports_444)
Definition nvdec.c:1083
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
A reference to a data buffer.
Definition buffer.h:82
main external API structure.
Definition avcodec.h:443
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
Definition refstruct.c:183
unsigned int slice_offsets_allocated
Definition nvdec.h:76
unsigned * slice_offsets
Definition nvdec.h:74
int bitstream_len
Definition nvdec.h:70
unsigned int bitstream_allocated
Definition nvdec.h:71
struct NVDECDecoder * decoder
RefStruct reference.
Definition nvdec.h:67
int nb_slices
Definition nvdec.h:75
uint8_t * bitstream_internal
Definition nvdec.h:72
CUVIDPICPARAMS pic_params
Definition nvdec.h:63
int supports_444
Definition nvdec.h:78
const uint8_t * bitstream
Definition nvdec.h:69
struct AVRefStructPool * decoder_pool
Definition nvdec.h:65
struct NVDECDecoder * decoder
RefStruct reference.
Definition nvdec.h:59
unsigned int ref_idx
Definition nvdec.h:56
unsigned int idx
Definition nvdec.h:55
unsigned int * ref_idx_ref
RefStruct reference.
Definition nvdec.h:58
unsigned int * idx_ref
RefStruct reference.
Definition nvdec.h:57
int dpb_size
static char buffer[20]
Definition seek.c:32
int size