diff mbox series

[FFmpeg-devel,1/2] libavcodec/jpeg2000dec: Enhance pix fmt selection

Message ID 20200704190309.29214-1-gautamramk@gmail.com
State Accepted
Commit 69522e04001f9dad710a420a6d46aa138659244e
Headers show
Series [FFmpeg-devel,1/2] libavcodec/jpeg2000dec: Enhance pix fmt selection
Related show

Checks

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

Commit Message

Gautam Ramakrishnan July 4, 2020, 7:03 p.m. UTC
From: Gautam Ramakrishnan <gautamramk@gmail.com>

This patch assigns default pix format values when
a match does not take place.
---
 libavcodec/jpeg2000dec.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Michael Niedermayer July 5, 2020, 10:40 p.m. UTC | #1
On Sun, Jul 05, 2020 at 12:33:08AM +0530, gautamramk@gmail.com wrote:
> From: Gautam Ramakrishnan <gautamramk@gmail.com>
> 
> This patch assigns default pix format values when
> a match does not take place.
> ---
>  libavcodec/jpeg2000dec.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 3f4a9ef96c..f62553c874 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -436,6 +436,18 @@  static int get_siz(Jpeg2000DecoderContext *s)
                 s->cdef[3] = 3;
                 i = 0;
             }
+        } else if (ncomponents == 3 && s->precision == 8 &&
+                   s->cdx[0] == s->cdx[1] && s->cdx[0] == s->cdx[2] &&
+                   s->cdy[0] == s->cdy[1] && s->cdy[0] == s->cdy[2]) {
+            s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
+            i = 0;
+        } else if (ncomponents == 2 && s->precision == 8 &&
+                   s->cdx[0] == s->cdx[1] && s->cdy[0] == s->cdy[1]) {
+            s->avctx->pix_fmt = AV_PIX_FMT_YA8;
+            i = 0;
+        } else if (ncomponents == 1 && s->precision == 8) {
+            s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+            i = 0;
         }
     }