#define OPJ_STATIC
#include <openjpeg.h>
+#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixfmt.h"
-#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "thread.h"
avcodec_set_dimensions(avctx, width, height);
- if (avctx->pix_fmt != PIX_FMT_NONE) {
- if (!libopenjpeg_matches_pix_fmt(image, avctx->pix_fmt)) {
+ if (avctx->pix_fmt != PIX_FMT_NONE)
+ if (!libopenjpeg_matches_pix_fmt(image, avctx->pix_fmt))
avctx->pix_fmt = PIX_FMT_NONE;
- }
- }
- if (avctx->pix_fmt == PIX_FMT_NONE) {
+ if (avctx->pix_fmt == PIX_FMT_NONE)
avctx->pix_fmt = libopenjpeg_guess_pix_fmt(image);
- }
if (avctx->pix_fmt == PIX_FMT_NONE) {
av_log(avctx, AV_LOG_ERROR, "Unable to determine pixel format\n");
}
opj_image_destroy(image);
- // Decode the codestream.
+ // Decode the codestream
image = opj_decode_with_info(dec, stream, NULL);
opj_cio_close(stream);
+
if (!image) {
av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
goto done;
AVCodec ff_libopenjpeg_decoder = {
.name = "libopenjpeg",
.type = AVMEDIA_TYPE_VIDEO,
- .id = CODEC_ID_JPEG2000,
+ .id = AV_CODEC_ID_JPEG2000,
.priv_data_size = sizeof(LibOpenJPEGContext),
.init = libopenjpeg_decode_init,
.close = libopenjpeg_decode_close,
.decode = libopenjpeg_decode_frame,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
- .max_lowres = 5,
+ .max_lowres = 31,
.long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"),
.priv_class = &class,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(libopenjpeg_decode_init_thread_copy),