diff mbox series

[FFmpeg-devel] lavc/jpeg2000dec: Allow forcing a compatible pix_fmt

Message ID CAB0OVGou=0NLx1e7d7ot0+QrJzvSZyFO0HJABqU+MZ4P=CZMsw@mail.gmail.com
State Accepted
Headers show
Series [FFmpeg-devel] lavc/jpeg2000dec: Allow forcing a compatible pix_fmt | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Carl Eugen Hoyos April 13, 2020, 2:40 p.m. UTC
Hi!

Attached patch makes the behaviour of the jpeg2000 decoder more
similar to the libopenjpeg decoder and allows a work-around for ticket
#5919.

Please comment, Carl Eugen
diff mbox series

Patch

From ca98ca99d267c0c6009ed4e4981f05ed8712adf8 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Mon, 13 Apr 2020 16:25:02 +0200
Subject: [PATCH] lavc/jpeg2000dec: Allow to force a compatible pix_fmt.

This copies the behaviour of the libopenjpeg decoder.
Fixes ticket #5919.
---
 libavcodec/jpeg2000dec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 7196cba6b4..440b856a3a 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -402,6 +402,10 @@  static int get_siz(Jpeg2000DecoderContext *s)
             break;
         }
     }
+    if (   s->avctx->pix_fmt != AV_PIX_FMT_NONE
+        && !pix_fmt_match(s->avctx->pix_fmt, ncomponents, s->precision, log2_chroma_wh, s->pal8))
+            s->avctx->pix_fmt = AV_PIX_FMT_NONE;
+    if (s->avctx->pix_fmt == AV_PIX_FMT_NONE)
     for (i = 0; i < possible_fmts_nb; ++i) {
         if (pix_fmt_match(possible_fmts[i], ncomponents, s->precision, log2_chroma_wh, s->pal8)) {
             s->avctx->pix_fmt = possible_fmts[i];
-- 
2.24.1