35 const uint8_t *sps_pps, uint32_t sps_pps_size,
36 const uint8_t *in, uint32_t in_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,
67 uint32_t cumul_size = 0;
68 const uint8_t *buf_end = buf + buf_size;
73 *poutbuf_size = buf_size;
80 uint64_t total_size = 0;
81 uint8_t *out =
NULL, unit_nb, sps_done = 0, sps_seen = 0, pps_seen = 0;
83 static const uint8_t nalu_header[4] = {0, 0, 0, 1};
91 unit_nb = *extradata++ & 0x1f;
93 unit_nb = *extradata++;
105 unit_size =
AV_RB16(extradata);
106 total_size += unit_size+4;
118 memcpy(out+total_size-unit_size-4, nalu_header, 4);
119 memcpy(out+total_size-unit_size, extradata+2, unit_size);
120 extradata += 2+unit_size;
122 if (!unit_nb && !sps_done++) {
123 unit_nb = *extradata++;
133 av_log(avctx,
AV_LOG_WARNING,
"Warning: SPS NALU missing or invalid. The resulting stream may not play.\n");
135 av_log(avctx,
AV_LOG_WARNING,
"Warning: PPS NALU missing or invalid. The resulting stream may not play.\n");
158 unit_type = *buf & 0x1f;
160 if (buf + nal_size > buf_end || nal_size < 0)
181 }
while (cumul_size < buf_size);
struct H264BSFContext H264BSFContext
memory handling functions
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
void av_log(void *avcl, int level, const char *fmt,...)
main external API structure.
#define FF_INPUT_BUFFER_PADDING_SIZE
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static int alloc_and_copy(uint8_t **poutbuf, int *poutbuf_size, const uint8_t *sps_pps, uint32_t sps_pps_size, const uint8_t *in, uint32_t in_size)
AVBitStreamFilter ff_h264_mp4toannexb_bsf