On 31.05.2015 11:11, Luca Barbato wrote: > On 30/05/15 20:00, Andreas Cadhalpun wrote: >> + memset(&ctx->event_mgr, 0, sizeof(opj_event_mgr_t)); > > usually the size is sizeof(*actualpoint)
Yes that's better, patch updated. I just copied this from libopenjpegenc.c, so it should be fixed there too. Additional patch for that attached. >> + ctx->event_mgr.info_handler = info_callback; >> + ctx->event_mgr.error_handler = error_callback; >> + ctx->event_mgr.warning_handler = warning_callback; >> + opj_set_event_mgr((opj_common_ptr) dec, &ctx->event_mgr, avctx); > > The rest seems fine, not sure info_callback should be DEBUG or VERBOSE, > I'll go with your pick if nobody has other opinions. I just picked what was used by the encoder. Best regards, Andreas
>From 79490bdcae3ac44c0383136064f3e267d98c5ec9 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> Date: Sat, 30 May 2015 19:40:22 +0200 Subject: [PATCH 1/2] libopenjpegdec: register logging callback functions Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> --- libavcodec/libopenjpegdec.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c index ab681f1..8fe7a50 100644 --- a/libavcodec/libopenjpegdec.c +++ b/libavcodec/libopenjpegdec.c @@ -83,9 +83,25 @@ static const enum AVPixelFormat libopenjpeg_all_pix_fmts[] = { typedef struct LibOpenJPEGContext { AVClass *class; opj_dparameters_t dec_params; + opj_event_mgr_t event_mgr; int lowqual; } LibOpenJPEGContext; +static void error_callback(const char *msg, void *data) +{ + av_log(data, AV_LOG_ERROR, "%s", msg); +} + +static void warning_callback(const char *msg, void *data) +{ + av_log(data, AV_LOG_WARNING, "%s", msg); +} + +static void info_callback(const char *msg, void *data) +{ + av_log(data, AV_LOG_DEBUG, "%s", msg); +} + static inline int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum AVPixelFormat pix_fmt) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); @@ -286,7 +302,11 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "Error initializing decoder.\n"); return AVERROR_UNKNOWN; } - opj_set_event_mgr((opj_common_ptr) dec, NULL, NULL); + memset(&ctx->event_mgr, 0, sizeof(ctx->event_mgr)); + ctx->event_mgr.info_handler = info_callback; + ctx->event_mgr.error_handler = error_callback; + ctx->event_mgr.warning_handler = warning_callback; + opj_set_event_mgr((opj_common_ptr) dec, &ctx->event_mgr, avctx); ctx->dec_params.cp_limit_decoding = LIMIT_TO_MAIN_HEADER; ctx->dec_params.cp_layer = ctx->lowqual; // Tie decoder with decoding parameters -- 2.1.4
>From 822f2eb3e4c47eed74f4ede5fa52a1112d5cb506 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> Date: Mon, 1 Jun 2015 00:16:29 +0200 Subject: [PATCH 2/2] libopenjpegenc: use variable instead of type for sizeof Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> --- libavcodec/libopenjpegenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 95b0987..9758f31 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -571,7 +571,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return AVERROR(ENOMEM); } - memset(&ctx->event_mgr, 0, sizeof(opj_event_mgr_t)); + memset(&ctx->event_mgr, 0, sizeof(ctx->event_mgr)); ctx->event_mgr.info_handler = info_callback; ctx->event_mgr.error_handler = error_callback; ctx->event_mgr.warning_handler = warning_callback; -- 2.1.4
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel