Commit b756b13e authored by U. Artie Eoff's avatar U. Artie Eoff Committed by Víctor Manuel Jáquez Leal

msdkmjpegdec: support 422 output

MSDK supports JPEG YUY2 (422 chroma) output color
format. The color format of input bitstream is
described by JPEGChromaFormat and JPEGColorFormat
fields in the mfxInfoMFX structure which is filled
in by the MFXVideoDECODE_DecodeHeader function.

To obtain lossless decoded output from 422 encoded
JPEGs, we must set the output color format in the
FourCC and ChromaFormat fields in the mfxFrameInfo
structure to the appropriate values at post_configure
so that they are propagated through to the srcpad
caps accordingly.
parent 70bfd34b
Pipeline #45654 passed with stages
in 34 minutes and 44 seconds
......@@ -37,6 +37,7 @@
#include <mfxjpeg.h>
#include "gstmsdkmjpegdec.h"
#include "gstmsdkvideomemory.h"
#include <gst/pbutils/pbutils.h>
......@@ -50,6 +51,18 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
"width = (int) [ 1, MAX ], height = (int) [ 1, MAX ], parsed = true ")
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw, "
"format = (string) { NV12, YUY2 }, "
"framerate = (fraction) [0, MAX], "
"width = (int) [ 1, MAX ], height = (int) [ 1, MAX ],"
"interlace-mode = (string) progressive;"
GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_DMABUF,
"{ NV12, YUY2 }") ";")
);
#define gst_msdkmjpegdec_parent_class parent_class
G_DEFINE_TYPE (GstMsdkMJPEGDec, gst_msdkmjpegdec, GST_TYPE_MSDKDEC);
......@@ -65,6 +78,24 @@ gst_msdkmjpegdec_configure (GstMsdkDec * decoder)
the InterleaveDec to MFX_SCANTYPE_NONINTERLEAVED, msdk seems to be taking care
of Interleaved samples, so let's hardcode it for now */
decoder->param.mfx.InterleavedDec = MFX_SCANTYPE_NONINTERLEAVED;
return TRUE;
}
static gboolean
gst_msdkmjpegdec_post_configure (GstMsdkDec * decoder)
{
/* Set the output color format based on the input color format */
switch (decoder->param.mfx.JPEGChromaFormat) {
case MFX_CHROMAFORMAT_YUV422:
decoder->param.mfx.FrameInfo.FourCC = MFX_FOURCC_YUY2;
decoder->param.mfx.FrameInfo.ChromaFormat =
decoder->param.mfx.JPEGChromaFormat;
break;
default:
break;
}
return TRUE;
}
......@@ -78,6 +109,8 @@ gst_msdkmjpegdec_class_init (GstMsdkMJPEGDecClass * klass)
decoder_class = GST_MSDKDEC_CLASS (klass);
decoder_class->configure = GST_DEBUG_FUNCPTR (gst_msdkmjpegdec_configure);
decoder_class->post_configure =
GST_DEBUG_FUNCPTR (gst_msdkmjpegdec_post_configure);
gst_element_class_set_static_metadata (element_class,
"Intel MSDK MJPEG decoder",
......@@ -86,6 +119,7 @@ gst_msdkmjpegdec_class_init (GstMsdkMJPEGDecClass * klass)
"Scott D Phillips <scott.d.phillips@intel.com>");
gst_element_class_add_static_pad_template (element_class, &sink_factory);
gst_element_class_add_static_pad_template (element_class, &src_factory);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment