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
23
25 HEVCSEI *
sei,
int is_nalff,
int nal_length_size,
26 int err_recognition, int apply_defdispwin, void *logctx)
27 {
31
35 goto done;
36 }
37
38 for (
i = 0;
i <
pkt.nb_nals;
i++) {
41 continue;
42
43 /* ignore everything except parameter sets and VCL NALUs */
48 goto done;
49 break;
53 goto done;
54 break;
58 goto done;
59 break;
64 goto done;
65 break;
66 default:
68 break;
69 }
70 }
71
72 done:
76
77 return 0;
78 }
79
81 HEVCSEI *
sei,
int *is_nalff,
int *nal_length_size,
82 int err_recognition, int apply_defdispwin, void *logctx)
83 {
86
88
89 /* data[0] == 1 is configurationVersion from 14496-15.
90 * data[0] == 0 is for backward compatibility predates the standard.
91 *
92 * Minimum number of bytes of hvcC with 0 numOfArrays is 23.
93 */
95 /* It seems the extradata is encoded as hvcC format. */
96 int i, j, num_arrays, nal_len_size;
97
98 *is_nalff = 1;
99
101 nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1;
102 num_arrays = bytestream2_get_byte(&gb);
103
104 /* nal units in the hvcC always have length coded with 2 bytes,
105 * so put a fake nal_length_size = 2 while parsing them */
106 *nal_length_size = 2;
107
108 /* Decode nal units from hvcC. */
109 for (
i = 0;
i < num_arrays;
i++) {
110 int type = bytestream2_get_byte(&gb) & 0x3f;
111 int cnt = bytestream2_get_be16(&gb);
112
113 for (j = 0; j < cnt; j++) {
114 // +2 for the nal size field
115 int nalsize = bytestream2_peek_be16(&gb) + 2;
118 "Invalid NAL unit size in extradata.\n");
120 }
121
123 *nal_length_size, err_recognition, apply_defdispwin,
124 logctx);
127 "Decoding nal unit %d %d from hvcC failed\n",
130 }
132 }
133 }
134
135 /* Now store right nal length size, that will be used to parse
136 * all other nals */
137 *nal_length_size = nal_len_size;
138 } else {
139 *is_nalff = 0;
141 err_recognition, apply_defdispwin, logctx);
144 }
145
147 }