mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
Fix crash when immediately closing encoder
When closing the encoder, the pictures stored in the input frame buffer are freed by repeatedly calling kvz_encoder_feed_frame. If the encoder was closed immediately after opening it, kvz_encoder_feed_frame would be called with an unprepared encoder state. This would trigger an assert. Fixed by changing kvz_encoder_feed_frame so that it does not require the encoder state to be prepared.
This commit is contained in:
parent
b74e0458fd
commit
f54a25f112
|
@ -58,8 +58,6 @@ kvz_picture* kvz_encoder_feed_frame(input_frame_buffer_t *buf,
|
|||
|
||||
const int gop_buf_size = 3 * cfg->gop_len;
|
||||
|
||||
assert(state->frame->num >= 0);
|
||||
|
||||
if (cfg->gop_len == 0 || cfg->gop_lowdelay) {
|
||||
// No reordering of output pictures necessary.
|
||||
|
||||
|
@ -69,12 +67,10 @@ kvz_picture* kvz_encoder_feed_frame(input_frame_buffer_t *buf,
|
|||
state->frame->gop_offset = 0;
|
||||
if (cfg->gop_len > 0) {
|
||||
// Using a low delay GOP structure.
|
||||
state->frame->gop_offset = (state->frame->num - 1) % cfg->gop_len;
|
||||
if (state->frame->gop_offset < 0) {
|
||||
// Set gop_offset of IDR as the highest quality picture.
|
||||
state->frame->gop_offset += cfg->gop_len;
|
||||
}
|
||||
state->frame->gop_offset = (buf->num_out + cfg->gop_len - 1) % cfg->gop_len;
|
||||
}
|
||||
buf->num_in++;
|
||||
buf->num_out++;
|
||||
return kvz_image_copy_ref(img_in);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue