-#if OPENJPEG_MAJOR_VERSION == 1
- ctx->dec_params.cp_limit_decoding = NO_LIMITATION;
- ctx->dec_params.cp_reduce = avctx->lowres;
- // Tie decoder with decoding parameters.
- opj_setup_decoder(dec, &ctx->dec_params);
- stream = opj_cio_open((opj_common_ptr) dec, buf, buf_size);
- if (!stream) {
- av_log(avctx, AV_LOG_ERROR,
- "Codestream could not be opened for reading.\n");
- ret = AVERROR_EXTERNAL;
- goto done;
- }
- opj_image_destroy(image);
- // Decode the codestream
- image = opj_decode_with_info(dec, stream, NULL);
- ret = !image;
-#else // OPENJPEG_MAJOR_VERSION == 2