mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-03 14:32:16 +02:00
h264: Complexify frame num gap shortening code
By observation it did not seem to handle prev_frame_num > frame_num. This does not affect any files I have. (cherry picked from commit 43c0092a80f8212cbb783260bafa157f7b85126e)
This commit is contained in:
parent
53781bf13e
commit
33eac92a3c
@ -2133,9 +2133,20 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
|||||||
h->mb_field_decoding_flag= s->picture_structure != PICT_FRAME;
|
h->mb_field_decoding_flag= s->picture_structure != PICT_FRAME;
|
||||||
|
|
||||||
if(h0->current_slice == 0){
|
if(h0->current_slice == 0){
|
||||||
if(h->frame_num != h->prev_frame_num &&
|
// Shorten frame num gaps so we don't have to allocate reference frames just to throw them away
|
||||||
(h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num) < (h->frame_num - h->sps.ref_frame_count))
|
if(h->frame_num != h->prev_frame_num) {
|
||||||
h->prev_frame_num = h->frame_num - h->sps.ref_frame_count - 1;
|
int unwrap_prev_frame_num = h->prev_frame_num, max_frame_num = 1<<h->sps.log2_max_frame_num;
|
||||||
|
|
||||||
|
if (unwrap_prev_frame_num > h->frame_num) unwrap_prev_frame_num -= max_frame_num;
|
||||||
|
|
||||||
|
if ((h->frame_num - unwrap_prev_frame_num) > h->sps.ref_frame_count) {
|
||||||
|
unwrap_prev_frame_num = (h->frame_num - h->sps.ref_frame_count) - 1;
|
||||||
|
if (unwrap_prev_frame_num < 0)
|
||||||
|
unwrap_prev_frame_num += max_frame_num;
|
||||||
|
|
||||||
|
h->prev_frame_num = unwrap_prev_frame_num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while(h->frame_num != h->prev_frame_num &&
|
while(h->frame_num != h->prev_frame_num &&
|
||||||
h->frame_num != (h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num)){
|
h->frame_num != (h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num)){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user