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 ||
85 extradata + 2 + unit_size > avctx->
extradata +
96 memcpy(out + total_size - unit_size - 4, nalu_header, 4);
97 memcpy(out + total_size - unit_size, extradata + 2, unit_size);
98 extradata += 2 + unit_size;
100 if (!unit_nb && !sps_done++) {
101 unit_nb = *extradata++;
112 "Warning: SPS NALU missing or invalid. "
113 "The resulting stream may not play.\n");
117 "Warning: PPS NALU missing or invalid. "
118 "The resulting stream may not play.\n");
129 uint8_t **poutbuf,
int *poutbuf_size,
137 uint32_t cumul_size = 0;
138 const uint8_t *buf_end = buf + buf_size;
144 *poutbuf_size = buf_size;
166 nal_size = (nal_size << 8) | buf[i];
169 unit_type = *buf & 0x1f;
171 if (buf + nal_size > buf_end || nal_size < 0)
183 NULL, 0, buf, nal_size)) < 0)
191 }
while (cumul_size < buf_size);