Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean First <jeanfirst@gmail.com>2015-01-23 23:58:41 +0300
committerMichael Niedermayer <michaelni@gmx.at>2015-01-24 02:40:08 +0300
commit1f13348f7d1049fe9be2897d8cd88024db233bda (patch)
tree8041b105671af728fdf1d8d84f9d2c0fdf60c06b /libavcodec/libopenjpegenc.c
parent76241c911510ae3eaccf92a21e95b82579dc1ec5 (diff)
lavc/libopenjpegenc: move opj_setup_encoder to libopenjpeg_encode_frame
if the openjpeg parameter tcp_rates is not 0 ( using the ffmpeg compression_level option ) every 2nd image per thread is badly encoded. By moving the opj_setup_encoder function from libopenjpeg_encode_init to libopenjpeg_encode_frame this can be prevented. This fixes ticket #3754. Signed-off-by: Jean First <jeanfirst@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libopenjpegenc.c')
-rw-r--r--libavcodec/libopenjpegenc.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 66633f4ad2..4039663120 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -233,14 +233,6 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
err = AVERROR(EINVAL);
goto fail;
}
- opj_setup_encoder(ctx->compress, &ctx->enc_params, ctx->image);
-
- ctx->stream = opj_cio_open((opj_common_ptr) ctx->compress, NULL, 0);
- if (!ctx->stream) {
- av_log(avctx, AV_LOG_ERROR, "Error creating the cio stream\n");
- err = AVERROR(ENOMEM);
- goto fail;
- }
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame) {
@@ -257,8 +249,6 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
return 0;
fail:
- opj_cio_close(ctx->stream);
- ctx->stream = NULL;
opj_destroy_compress(ctx->compress);
ctx->compress = NULL;
opj_image_destroy(ctx->image);
@@ -569,7 +559,14 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return -1;
}
- cio_seek(stream, 0);
+ opj_setup_encoder(compress, &ctx->enc_params, image);
+
+ stream = opj_cio_open((opj_common_ptr) compress, NULL, 0);
+ if (!stream) {
+ av_log(avctx, AV_LOG_ERROR, "Error creating the cio stream\n");
+ return AVERROR(ENOMEM);
+ }
+
if (!opj_encode(compress, stream, image, NULL)) {
av_log(avctx, AV_LOG_ERROR, "Error during the opj encode\n");
return -1;