diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 76447e5206..0b111b5b99 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -1000,32 +1000,32 @@ static int send_next_delayed_frame(H264Context *h, AVFrame *dst_frame, h->first_field = 0; while (h->delayed_pic[0]) { - out = h->delayed_pic[0]; - out_idx = 0; - for (i = 1; - h->delayed_pic[i] && - !(h->delayed_pic[i]->f->flags & AV_FRAME_FLAG_KEY) && - !h->delayed_pic[i]->mmco_reset; - i++) - if (h->delayed_pic[i]->poc < out->poc) { - out = h->delayed_pic[i]; - out_idx = i; + out = h->delayed_pic[0]; + out_idx = 0; + for (i = 1; + h->delayed_pic[i] && + !(h->delayed_pic[i]->f->flags & AV_FRAME_FLAG_KEY) && + !h->delayed_pic[i]->mmco_reset; + i++) + if (h->delayed_pic[i]->poc < out->poc) { + out = h->delayed_pic[i]; + out_idx = i; + } + + for (i = out_idx; h->delayed_pic[i]; i++) + h->delayed_pic[i] = h->delayed_pic[i + 1]; + + if (out) { + h->frame_recovered |= out->recovered; + out->recovered |= h->frame_recovered & FRAME_RECOVERED_SEI; + + out->reference &= ~DELAYED_PIC_REF; + ret = finalize_frame(h, dst_frame, out, got_frame); + if (ret < 0) + return ret; + if (*got_frame) + break; } - - for (i = out_idx; h->delayed_pic[i]; i++) - h->delayed_pic[i] = h->delayed_pic[i + 1]; - - if (out) { - h->frame_recovered |= out->recovered; - out->recovered |= h->frame_recovered & FRAME_RECOVERED_SEI; - - out->reference &= ~DELAYED_PIC_REF; - ret = finalize_frame(h, dst_frame, out, got_frame); - if (ret < 0) - return ret; - if (*got_frame) - break; - } } return buf_index;