Commit fda4918c authored by Haihao Xiang's avatar Haihao Xiang Committed by Víctor Manuel Jáquez Leal
Browse files

msdk: don't use hard-coded video format

Some codecs may support varied formats, e.g. HEVC may support NV12
and P010_10LE etc
parent 27ab7fb4
...@@ -476,6 +476,7 @@ gst_msdkdec_set_src_caps (GstMsdkDec * thiz, gboolean need_allocation) ...@@ -476,6 +476,7 @@ gst_msdkdec_set_src_caps (GstMsdkDec * thiz, gboolean need_allocation)
GstVideoInfo *vinfo; GstVideoInfo *vinfo;
GstVideoAlignment align; GstVideoAlignment align;
GstCaps *allocation_caps = NULL; GstCaps *allocation_caps = NULL;
GstVideoFormat format;
guint width, height; guint width, height;
const gchar *format_str; const gchar *format_str;
...@@ -487,9 +488,19 @@ gst_msdkdec_set_src_caps (GstMsdkDec * thiz, gboolean need_allocation) ...@@ -487,9 +488,19 @@ gst_msdkdec_set_src_caps (GstMsdkDec * thiz, gboolean need_allocation)
height = height =
thiz->param.mfx.FrameInfo.CropH ? thiz->param.mfx. thiz->param.mfx.FrameInfo.CropH ? thiz->param.mfx.
FrameInfo.CropH : GST_VIDEO_INFO_HEIGHT (&thiz->input_state->info); FrameInfo.CropH : GST_VIDEO_INFO_HEIGHT (&thiz->input_state->info);
format =
gst_msdk_get_video_format_from_mfx_fourcc (thiz->param.mfx.
FrameInfo.FourCC);
if (format == GST_VIDEO_FORMAT_UNKNOWN) {
GST_WARNING_OBJECT (thiz, "Failed to find a valid video format\n");
return FALSE;
}
output_state = output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (thiz), gst_video_decoder_set_output_state (GST_VIDEO_DECODER (thiz),
GST_VIDEO_FORMAT_NV12, width, height, thiz->input_state); format, width, height, thiz->input_state);
if (!output_state) if (!output_state)
return FALSE; return FALSE;
......
...@@ -312,3 +312,16 @@ gst_msdk_get_surface_from_buffer (GstBuffer * buf) ...@@ -312,3 +312,16 @@ gst_msdk_get_surface_from_buffer (GstBuffer * buf)
return NULL; return NULL;
} }
GstVideoFormat
gst_msdk_get_video_format_from_mfx_fourcc (mfxU32 fourcc)
{
const struct map *m = gst_msdk_video_format_to_mfx_map;
for (; m->mfx_fourcc != 0; m++) {
if (m->mfx_fourcc == fourcc)
return m->format;
}
return GST_VIDEO_FORMAT_UNKNOWN;
}
...@@ -75,6 +75,9 @@ gst_msdk_is_msdk_buffer (GstBuffer * buf); ...@@ -75,6 +75,9 @@ gst_msdk_is_msdk_buffer (GstBuffer * buf);
mfxFrameSurface1 * mfxFrameSurface1 *
gst_msdk_get_surface_from_buffer (GstBuffer * buf); gst_msdk_get_surface_from_buffer (GstBuffer * buf);
GstVideoFormat
gst_msdk_get_video_format_from_mfx_fourcc (mfxU32 fourcc);
G_END_DECLS G_END_DECLS
#endif /* __MSDK_H__ */ #endif /* __MSDK_H__ */
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