summaryrefslogtreecommitdiff
path: root/libavcodec/libopenjpegdec.c
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-05-30 19:40:22 +0200
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-06-02 22:43:58 +0200
commit12a83bc0aa4bf680805757fd5e025adf3b16c526 (patch)
tree0b74d0e57b8a3608d8dbc18311b2604e4d064466 /libavcodec/libopenjpegdec.c
parentcb658d17b623718451cb7d7bbe9079bafe88557f (diff)
libopenjpegdec: register logging callback functions
Reviewed-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Diffstat (limited to 'libavcodec/libopenjpegdec.c')
-rw-r--r--libavcodec/libopenjpegdec.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index ab681f1246..8fe7a506a0 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