Browse Source

TT#14008 move avpkt alloc to encoder_new

If encoder_config errors out for some reason, avpkt may end up
uninitialised. Make sure there is an avpkt when flushing/closing the
encoder. Also make the encoder input more resilient against
half-initialised encoders for the same reason.

closes #1312

Change-Id: I44ebcf6e35f1c383aa5c8202b5d9bbf968b0d5f1
(cherry picked from commit 6e160da497)
mr9.5.2
Richard Fuchs 4 years ago
parent
commit
bc9bd26ead
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      lib/codeclib.c

+ 3
- 2
lib/codeclib.c View File

@ -1231,6 +1231,7 @@ encoder_t *encoder_new(void) {
encoder_t *ret = g_slice_alloc0(sizeof(*ret));
format_init(&ret->requested_format);
format_init(&ret->actual_format);
ret->avpkt = av_packet_alloc();
return ret;
}
@ -1312,8 +1313,6 @@ int encoder_config_fmtp(encoder_t *enc, const codec_def_t *def, int bitrate, int
if (err)
goto err;
enc->avpkt = av_packet_alloc();
// output frame and fifo
enc->frame = av_frame_alloc();
@ -1455,6 +1454,8 @@ int encoder_input_data(encoder_t *enc, AVFrame *frame,
enc->avpkt->size = 0;
while (1) {
if (!enc->def || !enc->def->codec_type)
break;
if (!enc->def->codec_type->encoder_input)
break;


Loading…
Cancel
Save