compRatio |= c1.dx << 9 | c1.dy << 6;
compRatio |= c2.dx << 3 | c2.dy;
+ if (image->numcomps == 4) {
+ if (c0.prec == 8) {
+ if (compRatio == 0112222 &&
+ image->comps[3].dx == 1 && image->comps[3].dy == 1) {
+ return PIX_FMT_YUVA420P;
+ } else {
+ return PIX_FMT_RGBA;
+ }
+ } else {
+ return PIX_FMT_RGBA64;
+ }
+ }
+
switch (compRatio) {
case 0111111: goto libopenjpeg_yuv444_rgb;
case 0111212: return PIX_FMT_YUV440P;
return PIX_FMT_RGB24;
}
-static int is_yuva420(opj_image_t *image)
-{
- return image->numcomps == 4 &&
- image->comps[0].dx == 1 && image->comps[0].dy == 1 &&
- image->comps[1].dx == 2 && image->comps[1].dy == 2 &&
- image->comps[2].dx == 2 && image->comps[2].dy == 2 &&
- image->comps[3].dx == 1 && image->comps[3].dy == 1;
-}
-
static inline int libopenjpeg_ispacked(enum PixelFormat pix_fmt) {
int i, component_plane;
component_plane = av_pix_fmt_descriptors[pix_fmt].comp[0].plane;
avcodec_set_dimensions(avctx, width, height);
switch (image->numcomps) {
- case 1: avctx->pix_fmt = PIX_FMT_GRAY8;
+ case 1: avctx->pix_fmt = (image->comps[0].bpp == 8) ? PIX_FMT_GRAY8 : PIX_FMT_GRAY16;
break;
- case 3: avctx->pix_fmt = check_image_attributes(avctx, image);
+ case 2: avctx->pix_fmt = PIX_FMT_GRAY8A;
break;
- case 4: avctx->pix_fmt = is_yuva420(image) ? PIX_FMT_YUVA420P : PIX_FMT_RGBA;
+ case 3:
+ case 4: avctx->pix_fmt = check_image_attributes(avctx, image);
break;
default: av_log(avctx, AV_LOG_ERROR, "%d components unsupported.\n", image->numcomps);
goto done;
}
break;
case 2:
- libopenjpeg_copyto16(picture, image);
+ if (ispacked) {
+ libopenjpeg_copy_to_packed8(picture, image);
+ } else {
+ libopenjpeg_copyto16(picture, image);
+ }
break;
case 3:
case 4:
}
break;
case 6:
+ case 8:
if (ispacked) {
libopenjpeg_copy_to_packed16(picture, image);
}
.decode = libopenjpeg_decode_frame,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
.max_lowres = 5,
- .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 decoder"),
+ .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"),
.init_thread_copy = ONLY_IF_THREADS_ENABLED(libopenjpeg_decode_init_thread_copy)
};