34 unsigned int startcode = 0xFF;
36 for (; *pos < buf_size;) {
37 startcode = ((startcode << 8) | buf[*pos]) & 0xFFFFFFFF;
39 if ((startcode & 0xFFFFFF00) != 0x100)
50 int *pos_p,
int *nb_vop,
int *pos_vop2) {
51 unsigned int startcode;
54 for (pos = 0; pos < buf_size;) {
59 for (i = 0; i < 255 && pos + i + 1 < buf_size; i++) {
60 if (buf[pos + i] ==
'p' && buf[pos + i + 1] ==
'\0') {
67 if (*nb_vop == 2 && pos_vop2) {
79 memcpy(dst, src, size);
88 uint8_t **poutbuf,
int *poutbuf_size,
93 int pos_p = -1, nb_vop = 0, pos_vop2 = -1,
ret = 0;
97 "The mpeg4_unpack_bframes bitstream filter is only useful for mpeg4.\n");
104 if (pos_p_ext >= 0) {
106 "Updating DivX userdata (remove trailing 'p') in extradata.\n");
112 scan_buffer(buf, buf_size, &pos_p, &nb_vop, &pos_vop2);
118 "Missing one N-VOP packet, discarding one B-frame.\n");
133 "Found %d VOP headers in one packet, only unpacking one.\n", nb_vop);
158 }
else if (nb_vop >= 2) {
161 *poutbuf_size = pos_vop2;
162 }
else if (pos_p >= 0) {
164 *poutbuf_size = buf_size;
171 (*poutbuf)[pos_p] =
'\0';
177 *poutbuf_size = buf_size;
190 .
name =
"mpeg4_unpack_bframes",
#define AV_LOG_WARNING
Something somehow does not look correct.
#define USER_DATA_STARTCODE
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int mpeg4_unpack_bframes_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf
Libavcodec external API header.
static void mpeg4_unpack_bframes_close(AVBitStreamFilterContext *bsfc)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static unsigned int find_startcode(const uint8_t *buf, int buf_size, int *pos)
static uint8_t * create_new_buffer(const uint8_t *src, int size)
main external API structure.
static void scan_buffer(const uint8_t *buf, int buf_size, int *pos_p, int *nb_vop, int *pos_vop2)
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)