mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
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.
This commit is contained in:
parent
70bfd34b41
commit
b756b13ee2
1 changed files with 34 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue