avcodec/libxvid: remove now redundant init cleanup code

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/135/head
Michael Niedermayer 10 years ago
parent 437bdf482e
commit c949a4500e
  1. 37
      libavcodec/libxvid.c

@ -481,8 +481,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
} else { } else {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Too small height for threads > 1."); "Too small height for threads > 1.");
ret = AVERROR(EINVAL); return AVERROR(EINVAL);
goto fail;
} }
} }
#endif #endif
@ -503,8 +502,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
if (!x->twopassbuffer || !x->old_twopassbuffer) { if (!x->twopassbuffer || !x->old_twopassbuffer) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Xvid: Cannot allocate 2-pass log buffers\n"); "Xvid: Cannot allocate 2-pass log buffers\n");
ret = AVERROR(ENOMEM); return AVERROR(ENOMEM);
goto fail;
} }
x->twopassbuffer[0] = x->twopassbuffer[0] =
x->old_twopassbuffer[0] = 0; x->old_twopassbuffer[0] = 0;
@ -519,16 +517,14 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
fd = av_tempfile("xvidff.", &x->twopassfile, 0, avctx); fd = av_tempfile("xvidff.", &x->twopassfile, 0, avctx);
if (fd < 0) { if (fd < 0) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n"); av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n");
ret = fd; return fd;
goto fail;
} }
x->twopassfd = fd; x->twopassfd = fd;
if (!avctx->stats_in) { if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Xvid: No 2-pass information loaded for second pass\n"); "Xvid: No 2-pass information loaded for second pass\n");
ret = AVERROR(EINVAL); return AVERROR(EINVAL);
goto fail;
} }
ret = write(fd, avctx->stats_in, strlen(avctx->stats_in)); ret = write(fd, avctx->stats_in, strlen(avctx->stats_in));
@ -539,7 +535,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
ret = AVERROR(EIO); ret = AVERROR(EIO);
} }
if (ret < 0) if (ret < 0)
goto fail; return ret;
rc2pass2.filename = x->twopassfile; rc2pass2.filename = x->twopassfile;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2; plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2;
@ -627,19 +623,15 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
if (avctx->intra_matrix) { if (avctx->intra_matrix) {
intra = avctx->intra_matrix; intra = avctx->intra_matrix;
x->intra_matrix = av_malloc(sizeof(unsigned char) * 64); x->intra_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!x->intra_matrix) { if (!x->intra_matrix)
ret = AVERROR(ENOMEM); return AVERROR(ENOMEM);
goto fail;
}
} else } else
intra = NULL; intra = NULL;
if (avctx->inter_matrix) { if (avctx->inter_matrix) {
inter = avctx->inter_matrix; inter = avctx->inter_matrix;
x->inter_matrix = av_malloc(sizeof(unsigned char) * 64); x->inter_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!x->inter_matrix) { if (!x->inter_matrix)
ret = AVERROR(ENOMEM); return AVERROR(ENOMEM);
goto fail;
}
} else } else
inter = NULL; inter = NULL;
@ -684,20 +676,15 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
if (xerr) { if (xerr) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n"); av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
goto fail; return AVERROR_EXTERNAL;
} }
x->encoder_handle = xvid_enc_create.handle; x->encoder_handle = xvid_enc_create.handle;
avctx->coded_frame = av_frame_alloc(); avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame) { if (!avctx->coded_frame)
ret = AVERROR(ENOMEM); return AVERROR(ENOMEM);
goto fail;
}
return 0; return 0;
fail:
xvid_encode_close(avctx);
return ret;
} }
static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,

Loading…
Cancel
Save