1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <inttypes.h>
20
22
25 #include "cbs.h"
31
32 #define NEW_GLOBAL_PIC_INIT_QP 26
33
37
38
41 {
43 int err;
44
45 // The changes we are about to perform affect the parsing process,
46 // so we must make sure that the PPS is writable, otherwise the
47 // parsing of future slices will be incorrect and even raise errors.
48 err = ff_cbs_make_unit_writable(
ctx->common.input, unit);
49 if (err < 0)
50 return err;
52
53 // Overwrite pic_init_qp with the global value.
55
56 // Some PPSs have this set, so it must be set in all of them.
57 // (Slices which do not use such a PPS on input will still have
58 // *_weight_l*flag as zero and therefore write equivalently.)
59 pps->weighted_pred_flag = 1;
60
61 return 0;
62 }
63
66 {
69
70 // We modified the PPS's qp value, now offset this by applying
71 // the negative offset to the slices.
74
75 return 0;
76 }
77
81 {
84
87
90 if (err < 0)
91 return err;
92 }
97 }
98 }
99
100 return 0;
101 }
102
105 .fragment_name = "access unit",
106 .unit_name = "NAL unit",
108 };
109
111 {
113 }
114
117 };
118
120 .
p.
name =
"h264_redundant_pps",
126 };