1 /*
2 * MPEG-1/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
23 #include "config_components.h"
24
32
34 {
36
38 CUVIDPICPARAMS *pp = &
ctx->pic_params;
39 CUVIDMPEG2PICPARAMS *ppc = &pp->CodecSpecific.mpeg2;
42 AVFrame *cur_frame =
s->cur_pic.ptr->f;
43
45
49
52
53 *pp = (CUVIDPICPARAMS) {
54 .PicWidthInMbs = (cur_frame->
width + 15) / 16,
55 .FrameHeightInMbs = (cur_frame->
height + 15) / 16,
56 .CurrPicIdx = cf->
idx,
57
58 .field_pic_flag =
s->picture_structure !=
PICT_FRAME,
60 .second_field =
s->picture_structure !=
PICT_FRAME && !
s->first_field,
61
65
66 .CodecSpecific.mpeg2 = {
69
70 .picture_coding_type =
s->pict_type,
71 .full_pel_forward_vector =
s->full_pel[0],
72 .full_pel_backward_vector =
s->full_pel[1],
73 .f_code = { {
s->mpeg_f_code[0][0],
74 s->mpeg_f_code[0][1] },
75 {
s->mpeg_f_code[1][0],
76 s->mpeg_f_code[1][1] } },
77 .intra_dc_precision =
s->intra_dc_precision,
78 .frame_pred_frame_dct =
s->frame_pred_frame_dct,
79 .concealment_motion_vectors =
s->concealment_motion_vectors,
80 .q_scale_type =
s->q_scale_type,
81 .intra_vlc_format =
s->intra_vlc_format,
82 .alternate_scan =
s->alternate_scan,
83 .top_field_first =
s->top_field_first,
84 }
85 };
86
87 for (
i = 0;
i < 64; ++
i) {
88 int n =
s->idsp.idct_permutation[
i];
89 ppc->QuantMatrixIntra[
i] =
s->intra_matrix[n];
90 ppc->QuantMatrixInter[
i] =
s->inter_matrix[n];
91 }
92
93 return 0;
94 }
95
98 {
99 // Each frame can at most have one P and one B reference
101 }
102
103 #if CONFIG_MPEG2_NVDEC_HWACCEL
105 .
p.
name =
"mpeg2_nvdec",
116 };
117 #endif
118
119 #if CONFIG_MPEG1_NVDEC_HWACCEL
121 .
p.
name =
"mpeg1_nvdec",
132 };
133 #endif