1 /*
2 * MPEG-4 Part 2 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
27
29 {
32
35 CUVIDMPEG4PICPARAMS *ppc = &pp->CodecSpecific.mpeg4;
39
40 int ret, i;
41
43 if (ret < 0)
44 return ret;
45
48
49 *pp = (CUVIDPICPARAMS) {
50 .PicWidthInMbs = (cur_frame->
width + 15) / 16,
51 .FrameHeightInMbs = (cur_frame->
height + 15) / 16,
52 .CurrPicIdx = cf->
idx,
53
58
59 .CodecSpecific.mpeg4 = {
62
63 .video_object_layer_width = s->
width,
64 .video_object_layer_height = s->
height,
72
74 .vop_coded = 1,
78 .vop_fcode_forward = s->
f_code,
79 .vop_fcode_backward = s->
b_code,
82
85 }
86 };
87
88 for (i = 0; i < 64; ++i) {
91 }
92
93 // We need to pass the full frame buffer and not just the slice
95 }
96
98 {
99 return 0;
100 }
101
104 {
105 // Each frame can at most have one P and one B reference
107 }
108
110 .
name =
"mpeg4_nvdec",
121 };
const struct AVCodec * codec
This structure describes decoded (raw) audio or video data.
int resync_marker
could this stream contain resync markers
int ff_nvdec_simple_end_frame(AVCodecContext *avctx)
static int nvdec_mpeg4_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
CUVIDPICPARAMS pic_params
AVBufferRef * private_ref
AVBufferRef for internal use by a single libav* library.
int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
int no_rounding
apply no rounding to motion compensation (MPEG-4, msmpeg4, ...) for B-frames rounding mode is always ...
Picture current_picture
copy of the current picture structure.
uint16_t pp_time
time distance between the last 2 p,s,i frames
static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame)
int quarter_sample
1->qpel, 0->half pel ME/MC
const AVHWAccel ff_mpeg4_nvdec_hwaccel
int ff_nvdec_decode_init(AVCodecContext *avctx)
int ff_nvdec_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx, int dpb_size)
const char * name
Name of the hardware accelerated codec.
static int nvdec_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
HW acceleration through CUDA.
uint16_t inter_matrix[64]
Libavcodec external API header.
main external API structure.
int ff_nvdec_decode_uninit(AVCodecContext *avctx)
uint8_t * data
The data buffer.
int height
picture size. must be a multiple of 16
int f_code
forward MV resolution
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
uint16_t pb_field_time
like above, just for interlaced
A reference to a data buffer.
This struct stores per-frame lavc-internal data and is attached to it via private_ref.
int ff_nvdec_get_ref_idx(AVFrame *frame)
void * hwaccel_priv_data
hwaccel-specific private data
Picture last_picture
copy of the previous picture structure.
struct AVCodecInternal * internal
Private context used for internal data.
Picture next_picture
copy of the next picture structure.
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
int time_increment_bits
number of bits to represent the fractional part of time
void * hwaccel_priv
Per-frame private data for hwaccels.
int b_code
backward MV resolution for B-frames (MPEG-4)
uint16_t pb_time
time distance between the last b and p,s,i frame