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
30
32 {
35
37 CUVIDPICPARAMS *pp = &
ctx->pic_params;
38 CUVIDMPEG4PICPARAMS *ppc = &pp->CodecSpecific.mpeg4;
41 AVFrame *cur_frame =
s->cur_pic.ptr->f;
42
44
48
51
52 *pp = (CUVIDPICPARAMS) {
53 .PicWidthInMbs = (cur_frame->
width + 15) / 16,
54 .FrameHeightInMbs = (cur_frame->
height + 15) / 16,
55 .CurrPicIdx = cf->
idx,
56
61
62 .CodecSpecific.mpeg4 = {
65
66 .video_object_layer_width =
s->width,
67 .video_object_layer_height =
s->height,
69 .top_field_first =
s->top_field_first,
71 .quant_type =
s->mpeg_quant,
72 .quarter_sample =
s->quarter_sample,
74 .divx_flags =
s->divx_packed ? 5 : 0,
75
77 .vop_coded = 1,
78 .vop_rounding_type =
s->no_rounding,
79 .alternate_vertical_scan_flag =
s->alternate_scan,
80 .interlaced = !
s->progressive_sequence,
81 .vop_fcode_forward =
s->f_code,
82 .vop_fcode_backward =
s->b_code,
83 .trd = {
s->pp_time,
s->pp_field_time >> 1 },
84 .trb = {
s->pb_time,
s->pb_field_time >> 1 },
85
88 }
89 };
90
91 for (
i = 0;
i < 64; ++
i) {
92 int n =
s->idsp.idct_permutation[
i];
93 ppc->QuantMatrixIntra[
i] =
s->intra_matrix[n];
94 ppc->QuantMatrixInter[
i] =
s->inter_matrix[n];
95 }
96
97 // We need to pass the full frame buffer and not just the slice
99 }
100
102 {
103 return 0;
104 }
105
108 {
109 // Each frame can at most have one P and one B reference
111 }
112
114 .
p.
name =
"mpeg4_nvdec",
125 };