45 for(i=0; i<buf_size; i++){
47 #if HAVE_FAST_UNALIGNED
52 while(i<buf_size && !((~*(
const uint64_t*)(buf+i) & (*(
const uint64_t*)(buf+i) - 0x0101010101010101ULL)) & 0x8080808080808080ULL))
55 while(i<buf_size && !((~*(
const uint32_t*)(buf+i) & (*(
const uint32_t*)(buf+i) - 0x01010101U)) & 0x80808080U))
59 for(; i<buf_size; i++){
66 if(buf[i]==1) state^= 5;
67 else if(buf[i]) state = 7;
71 if(v==6 || v==7 || v==8 || v==9){
76 }
else if(v==1 || v==2 || v==5){
109 const uint8_t *buf,
int buf_size)
112 const uint8_t *buf_end = buf + buf_size;
114 unsigned int slice_type;
132 int src_length, dst_length, consumed;
137 src_length = buf_end - buf;
138 switch (state & 0x1f) {
147 if (ptr==
NULL || dst_length < 0)
242 const uint8_t **poutbuf,
int *poutbuf_size,
243 const uint8_t *buf,
int buf_size)
298 *poutbuf_size = buf_size;
303 const uint8_t *buf,
int buf_size)
309 for(i=0; i<=buf_size; i++){
310 if((state&0xFFFFFF1F) == 0x107)
314 if((state&0xFFFFFF00) == 0x100 && (state&0xFFFFFF1F) != 0x107 && (state&0xFFFFFF1F) != 0x108 && (state&0xFFFFFF1F) != 0x109){
316 while(i>4 && buf[i-5]==0) i--;
321 state= (state<<8) | buf[i];
348 .parser_close =
close,
int ff_h264_decode_seq_parameter_set(H264Context *h)
Decode SPS.
5: top field, bottom field, top field repeated, in that order
int sei_cpb_removal_delay
cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
3: top field, bottom field, in that order
const uint8_t * ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length)
Decode a network abstraction layer unit.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int ff_h264_get_profile(SPS *sps)
Compute profile from profile_idc and constraint_set?_flags.
struct H264Context H264Context
H264Context.
int dts_ref_dts_delta
Offset of the current timestamp against last timestamp sync point in units of AVCodecContext.time_base.
4: bottom field, top field, in that order
static const uint8_t golomb_to_pict_type[5]
static int init(AVCodecParserContext *s)
int got_first
this flag is != 0 if we've parsed a frame
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static int get_ue_golomb(GetBitContext *gb)
read unsigned exp golomb code.
ParseContext parse_context
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
void av_log(void *avcl, int level, const char *fmt,...)
static char * split(char *message, char delim)
static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Parse NAL units of found picture and decode some basic information.
PPS * pps_buffers[MAX_PPS_COUNT]
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
Decode PPS.
AVCodecParser ff_h264_parser
#define PARSER_FLAG_COMPLETE_FRAMES
SPS * sps_buffers[MAX_SPS_COUNT]
struct H264Context * thread_context[MAX_THREADS]
int pts_dts_delta
Presentation delay of current frame in units of AVCodecContext.time_base.
const uint8_t * avpriv_mpv_find_start_code(const uint8_t *restrict p, const uint8_t *end, uint32_t *restrict state)
H264 / AVC / MPEG4 part10 codec data table
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
int ff_h264_decode_sei(H264Context *h)
Decode SEI.
main external API structure.
static void close(AVCodecParserContext *s)
uint32_t state
contains the last few bytes in MSB order
static unsigned int get_bits1(GetBitContext *s)
SEI_PicStructType sei_pic_struct
pic_struct in picture timing SEI message
static int h264_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
6: bottom field, top field, bottom field repeated, in that order
int sei_buffering_period_present
Buffering period SEI flag.
int pic_struct_present_flag
av_cold void ff_h264_free_context(H264Context *h)
Free any data that may have been allocated in the H264 context like SPS, PPS etc. ...
int log2_max_frame_num
log2_max_frame_num_minus4 + 4
int ff_h264_decode_extradata(H264Context *h)
int repeat_pict
This field is used for proper frame duration computation in lavf.
static int h264_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
int sei_recovery_frame_cnt
recovery_frame_cnt from SEI message
int dts_sync_point
Synchronization point for start of timestamp generation.
static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size)
int sei_dpb_output_delay
dpb_output_delay in picture timing SEI message, see H.264 C.2.2