32 const uint8_t *sps_pps, uint32_t sps_pps_size,
33 const uint8_t *in, uint32_t in_size) {
34 uint32_t offset = *poutbuf_size;
35 uint8_t nal_header_size = offset ? 3 : 4;
38 *poutbuf_size += sps_pps_size+in_size+nal_header_size;
44 memcpy(*poutbuf+offset, sps_pps, sps_pps_size);
45 memcpy(*poutbuf+sps_pps_size+nal_header_size+offset, in, in_size);
47 AV_WB32(*poutbuf+sps_pps_size, 1);
49 (*poutbuf+offset+sps_pps_size)[0] = (*poutbuf+offset+sps_pps_size)[1] = 0;
50 (*poutbuf+offset+sps_pps_size)[2] = 1;
58 uint8_t **poutbuf,
int *poutbuf_size,
59 const uint8_t *buf,
int buf_size,
64 uint32_t cumul_size = 0;
65 const uint8_t *buf_end = buf + buf_size;
69 *poutbuf = (uint8_t*) buf;
70 *poutbuf_size = buf_size;
77 uint64_t total_size = 0;
78 uint8_t *out =
NULL, unit_nb, sps_done = 0, sps_seen = 0, pps_seen = 0;
79 const uint8_t *extradata = avctx->
extradata+4;
80 static const uint8_t nalu_header[4] = {0, 0, 0, 1};
88 unit_nb = *extradata++ & 0x1f;
90 unit_nb = *extradata++;
102 unit_size =
AV_RB16(extradata);
103 total_size += unit_size+4;
115 memcpy(out+total_size-unit_size-4, nalu_header, 4);
116 memcpy(out+total_size-unit_size, extradata+2, unit_size);
117 extradata += 2+unit_size;
119 if (!unit_nb && !sps_done++) {
120 unit_nb = *extradata++;
130 av_log(avctx,
AV_LOG_WARNING,
"Warning: SPS NALU missing or invalid. The resulting stream may not play.\n");
132 av_log(avctx,
AV_LOG_WARNING,
"Warning: PPS NALU missing or invalid. The resulting stream may not play.\n");
155 unit_type = *buf & 0x1f;
157 if (buf + nal_size > buf_end || nal_size < 0)
178 }
while (cumul_size < buf_size);