h264_parser: fully parse first_mb_in_slice to more reliably detect AU boundaries.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
23040e2e3d
commit
4ffed61b49
@ -591,6 +591,10 @@ typedef struct H264Context{
|
|||||||
int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
|
int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
|
||||||
|
|
||||||
int sync; ///< did we had a keyframe or recovery point
|
int sync; ///< did we had a keyframe or recovery point
|
||||||
|
|
||||||
|
uint8_t parse_history[4];
|
||||||
|
int parse_history_count;
|
||||||
|
int parse_last_mb;
|
||||||
}H264Context;
|
}H264Context;
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,17 +93,28 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si
|
|||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
}else if(v==1 || v==2 || v==5){
|
}else if(v==1 || v==2 || v==5){
|
||||||
if(pc->frame_start_found){
|
state+=8;
|
||||||
state+=8;
|
continue;
|
||||||
continue;
|
|
||||||
}else
|
|
||||||
pc->frame_start_found = 1;
|
|
||||||
}
|
}
|
||||||
state= 7;
|
state= 7;
|
||||||
}else{
|
}else{
|
||||||
if(buf[i] & 0x80)
|
h->parse_history[h->parse_history_count++]= buf[i];
|
||||||
goto found;
|
if(h->parse_history_count>3){
|
||||||
state= 7;
|
unsigned int mb, last_mb= h->parse_last_mb;
|
||||||
|
GetBitContext gb;
|
||||||
|
|
||||||
|
init_get_bits(&gb, h->parse_history, 8*h->parse_history_count);
|
||||||
|
h->parse_history_count=0;
|
||||||
|
mb= get_ue_golomb_long(&gb);
|
||||||
|
last_mb= h->parse_last_mb;
|
||||||
|
h->parse_last_mb= mb;
|
||||||
|
if(pc->frame_start_found){
|
||||||
|
if(mb <= last_mb)
|
||||||
|
goto found;
|
||||||
|
}else
|
||||||
|
pc->frame_start_found = 1;
|
||||||
|
state= 7;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pc->state= state;
|
pc->state= state;
|
||||||
@ -116,7 +127,7 @@ found:
|
|||||||
pc->frame_start_found= 0;
|
pc->frame_start_found= 0;
|
||||||
if(h->is_avc)
|
if(h->is_avc)
|
||||||
return next_avc;
|
return next_avc;
|
||||||
return i-(state&5);
|
return i-(state&5) - 3*(state>7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user