34 int *pos_p,
int *nb_vop,
int *pos_vop2) {
36 const uint8_t *end = buf + buf_size, *
pos = buf;
44 for (
int i = 0;
i < 255 &&
pos +
i + 1 < end;
i++) {
45 if (
pos[
i] ==
'p' &&
pos[
i + 1] ==
'\0') {
46 *pos_p =
pos +
i - buf;
52 if (*nb_vop == 2 && pos_vop2) {
53 *pos_vop2 =
pos - buf - 4;
62 int pos_p = -1, nb_vop = 0, pos_vop2 = -1, ret = 0;
74 "Missing one N-VOP packet, discarding one B-frame.\n");
79 if (!
s->b_frame_ref) {
83 s->b_frame_ref->data =
pkt->
data + pos_vop2;
84 s->b_frame_ref->size =
pkt->
size - pos_vop2;
89 "Found %d VOP headers in one packet, only unpacking one.\n", nb_vop);
92 if (nb_vop == 1 &&
s->b_frame_ref) {
105 s->b_frame_ref =
tmp;
112 }
else if (nb_vop >= 2) {
115 }
else if (pos_p >= 0) {
135 if (
ctx->par_in->extradata) {
138 if (pos_p_ext >= 0) {
140 "Updating DivX userdata (remove trailing 'p') in extradata.\n");
141 ctx->par_out->extradata[pos_p_ext] =
'\0';
159 .
name =
"mpeg4_unpack_bframes",
static void flush(AVCodecContext *avctx)
static av_cold int init(AVCodecContext *avctx)
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
AVCodecID
Identify the syntax and semantics of the bitstream.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_packet_make_writable(AVPacket *pkt)
Create a writable reference for the data described by a given packet, avoiding data copy if possible.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
common internal API header
static enum AVCodecID codec_ids[]
static int mpeg4_unpack_bframes_init(AVBSFContext *ctx)
static void scan_buffer(const uint8_t *buf, int buf_size, int *pos_p, int *nb_vop, int *pos_vop2)
static int mpeg4_unpack_bframes_filter(AVBSFContext *ctx, AVPacket *pkt)
static void mpeg4_unpack_bframes_close_flush(AVBSFContext *bsfc)
const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf
#define USER_DATA_STARTCODE
The bitstream filter state.
void * priv_data
Opaque filter-specific private data.
A reference to a data buffer.
void * priv_data
Format private data.
This structure stores compressed data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVBufferRef * b_frame_ref