35 const uint8_t *sps_pps, uint32_t sps_pps_size,
38 uint32_t
offset = *poutbuf_size;
39 uint8_t nal_header_size = offset ? 3 : 4;
42 *poutbuf_size += sps_pps_size + in_size + nal_header_size;
48 memcpy(*poutbuf + offset, sps_pps, sps_pps_size);
49 memcpy(*poutbuf + sps_pps_size + nal_header_size + offset, in, in_size);
51 AV_WB32(*poutbuf + sps_pps_size, 1);
53 (*poutbuf + offset + sps_pps_size)[0] =
54 (*poutbuf + offset + sps_pps_size)[1] = 0;
55 (*poutbuf + offset + sps_pps_size)[2] = 1;
64 uint64_t total_size = 0;
66 sps_seen = 0, pps_seen = 0;
68 static const uint8_t nalu_header[4] = { 0, 0, 0, 1 };
69 int length_size = (*extradata++ & 0x3) + 1;
72 unit_nb = *extradata++ & 0x1f;
83 total_size += unit_size + 4;
84 if (total_size > INT_MAX - padding) {
86 "Too big extradata size, corrupted stream or invalid MP4/AVCC bitstream\n");
92 "corrupted stream or invalid MP4/AVCC bitstream\n");
102 memcpy(out + total_size - unit_size - 4, nalu_header, 4);
103 memcpy(out + total_size - unit_size, extradata + 2, unit_size);
104 extradata += 2 + unit_size;
106 if (!unit_nb && !sps_done++) {
107 unit_nb = *extradata++;
118 "Warning: SPS NALU missing or invalid. "
119 "The resulting stream may not play.\n");
123 "Warning: PPS NALU missing or invalid. "
124 "The resulting stream may not play.\n");
135 uint8_t **poutbuf,
int *poutbuf_size,
143 uint32_t cumul_size = 0;
144 const uint8_t *buf_end = buf + buf_size;
150 *poutbuf_size = buf_size;
172 nal_size = (nal_size << 8) | buf[i];
175 unit_type = *buf & 0x1f;
177 if (buf + nal_size > buf_end || nal_size < 0)
189 NULL, 0, buf, nal_size)) < 0)
197 }
while (cumul_size < buf_size);
208 .
name =
"h264_mp4toannexb",