35 const uint8_t *sps_pps, uint32_t sps_pps_size,
37 uint32_t
offset = *poutbuf_size;
38 uint8_t nal_header_size = offset ? 3 : 4;
41 *poutbuf_size += sps_pps_size+in_size+nal_header_size;
47 memcpy(*poutbuf+offset, sps_pps, sps_pps_size);
48 memcpy(*poutbuf+sps_pps_size+nal_header_size+offset, in, in_size);
50 AV_WB32(*poutbuf+sps_pps_size, 1);
52 (*poutbuf+offset+sps_pps_size)[0] = (*poutbuf+offset+sps_pps_size)[1] = 0;
53 (*poutbuf+offset+sps_pps_size)[2] = 1;
61 uint8_t **poutbuf,
int *poutbuf_size,
62 const uint8_t *buf,
int buf_size,
68 uint32_t cumul_size = 0;
69 const uint8_t *buf_end = buf + buf_size;
75 *poutbuf_size = buf_size;
82 uint64_t total_size = 0;
83 uint8_t *
out =
NULL, unit_nb, sps_done = 0, sps_seen = 0, pps_seen = 0;
85 static const uint8_t nalu_header[4] = {0, 0, 0, 1};
91 unit_nb = *extradata++ & 0x1f;
101 unit_size =
AV_RB16(extradata);
102 total_size += unit_size+4;
114 memcpy(out+total_size-unit_size-4, nalu_header, 4);
115 memcpy(out+total_size-unit_size, extradata+2, unit_size);
116 extradata += 2+unit_size;
118 if (!unit_nb && !sps_done++) {
119 unit_nb = *extradata++;
129 av_log(avctx,
AV_LOG_WARNING,
"Warning: SPS NALU missing or invalid. The resulting stream may not play.\n");
131 av_log(avctx,
AV_LOG_WARNING,
"Warning: PPS NALU missing or invalid. The resulting stream may not play.\n");
148 nal_size = (nal_size << 8) | buf[i];
151 unit_type = *buf & 0x1f;
153 if (buf + nal_size > buf_end || nal_size < 0)
174 }
while (cumul_size < buf_size);