FFmpeg: libavcodec/nvdec_vc1.c Source File
Go to the documentation of this file. 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 "config_components.h"
24
32
36 {
39
41 CUVIDPICPARAMS *pp = &
ctx->pic_params;
44 AVFrame *cur_frame =
s->cur_pic.ptr->f;
45
47
51
54
55 *pp = (CUVIDPICPARAMS) {
56 .PicWidthInMbs = (cur_frame->
width + 15) / 16,
57 .FrameHeightInMbs = (cur_frame->
height + 15) / 16,
58 .CurrPicIdx = cf->
idx,
62
67
68 .CodecSpecific.vc1 = {
71 .FrameWidth = cur_frame->
width,
72 .FrameHeight = cur_frame->
height,
73
78 .progressive_fcm = v->
fcm == 0,
79
91
107 }
108 };
109
110 return 0;
111 }
112
115 {
118 uint32_t marker;
119 int marker_size;
121
122 if (
ctx->bitstream_len)
126 else
128
129 /* Only insert the marker if not already present in the bitstream */
130 marker_size = (
size >=
sizeof(marker) &&
AV_RB32(
buffer) != marker) ?
sizeof(marker) : 0;
131
133 ctx->bitstream_len +
size + marker_size);
136 ctx->bitstream =
ctx->bitstream_internal =
tmp;
137
139 (
ctx->nb_slices + 1) *
sizeof(*
ctx->slice_offsets));
143
144 if (marker_size)
145 AV_WB32(
ctx->bitstream_internal +
ctx->bitstream_len, marker);
146
147 memcpy(
ctx->bitstream_internal +
ctx->bitstream_len + marker_size,
buffer,
size);
148 ctx->slice_offsets[
ctx->nb_slices] =
ctx->bitstream_len;
149 ctx->bitstream_len +=
size + marker_size;
151
152 return 0;
153 }
154
157 {
158 // Each frame can at most have one P and one B reference
160 }
161
163 .
p.
name =
"vc1_nvdec",
174 };
175
176 #if CONFIG_WMV3_NVDEC_HWACCEL
178 .
p.
name =
"wmv3_nvdec",
189 };
190 #endif
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int overlap
overlapped transforms in use
int interlace
Progressive/interlaced (RPTFTM syntax element)
const struct FFHWAccel ff_wmv3_nvdec_hwaccel
int ff_nvdec_get_ref_idx(AVFrame *frame)
AVHWAccel p
The public AVHWAccel.
This struct stores per-frame lavc-internal data and is attached to it via private_ref.
This structure describes decoded (raw) audio or video data.
static int nvdec_vc1_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
int fastuvmc
Rounding of qpel vector to hpel ? (not in Simple)
@ ILACE_FIELD
in the bitstream is reported as 11b
int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame)
int multires
frame-level RESPIC syntax element present
int dquant
How qscale varies with MBs, 2 bits (not in Simple)
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
int postprocflag
Per-frame processing suggestion flag present.
int rangered
RANGEREDFRM (range reduction) syntax element present at frame level.
int ff_nvdec_simple_end_frame(AVCodecContext *avctx)
int field_mode
1 for interlaced field pictures
int panscanflag
NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} present.
int ff_nvdec_decode_init(AVCodecContext *avctx)
struct AVCodecInternal * internal
Private context used for internal data.
@ AV_PICTURE_TYPE_I
Intra.
int resync_marker
could this stream contain resync markers
int refdist_flag
REFDIST syntax element present in II, IP, PI or PP field picture headers.
void * hwaccel_priv_data
hwaccel-specific private data
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
int tfcntrflag
TFCNTR present.
int ff_nvdec_decode_uninit(AVCodecContext *avctx)
int cur_field_type
0: top, 1: bottom
const char * name
Name of the hardware accelerated codec.
void * private_ref
RefStruct reference for internal use by a single libav* library.
int max_b_frames
max number of B-frames
int extended_mv
Ext MV in P/B (not in Simple)
const FFHWAccel ff_vc1_nvdec_hwaccel
main external API structure.
int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
static int nvdec_vc1_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, const uint8_t *buffer, uint32_t size)
int ff_nvdec_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx, int dpb_size, int supports_444)
int profile
Sequence header data for all Profiles TODO: choose between ints, uint8_ts and monobit flags.
int vstransform
variable-size [48]x[48] transform type + info
enum FrameCodingMode fcm
Frame decoding info for Advanced profile.
@ AV_PICTURE_TYPE_P
Predicted.
int psf
Progressive Segmented Frame.
A reference to a data buffer.
int broadcast
TFF/RFF present.
@ AV_PICTURE_TYPE_BI
BI type.
int finterpflag
INTERPFRM present.
void * hwaccel_priv
Per-frame private data for hwaccels.
int quantizer_mode
2 bits, quantizer mode used for sequence, see QUANT_*
int extended_dmv
Additional extended dmv range at P/B-frame-level.
static int nvdec_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Generated on Wed Nov 19 2025 19:22:21 for FFmpeg by
doxygen
1.8.17