summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>2016-03-02 17:51:01 +0200
committerSreerenj Balachandran <sreerenj.balachandran@intel.com>2016-03-02 17:51:01 +0200
commit660aa070efab85d17d5d76706a0a2db0de81cc64 (patch)
tree6fbe1beeccb125502af176390fd1beacba66d456
parent1900f0b7279c9e2e35750c28e19dfa1426b760b6 (diff)
vaapidecode: Derive and save the decoded surface format
After the decoding of first frame, try to extract the exact decoded surface format using vaDeriveImage and keep this as the format in decoded_info.
-rw-r--r--gst/vaapi/gstvaapidecode.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c
index f4d03b0f..4f25ea3c 100644
--- a/gst/vaapi/gstvaapidecode.c
+++ b/gst/vaapi/gstvaapidecode.c
@@ -307,11 +307,9 @@ static gboolean
is_surface_resolution_changed (GstVaapiDecode * decode,
GstVaapiSurface * surface)
{
- GstVideoDecoder *const vdec = GST_VIDEO_DECODER (decode);
GstVideoInfo *vinfo = &decode->decoded_info;
- GstVideoFormat format = GST_VIDEO_FORMAT_ENCODED;
+ GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
guint surface_width, surface_height;
- GstVideoCodecState *state;
g_return_val_if_fail (surface != NULL, FALSE);
@@ -321,12 +319,13 @@ is_surface_resolution_changed (GstVaapiDecode * decode,
&& GST_VIDEO_INFO_HEIGHT (vinfo) == surface_height)
return FALSE;
- state = gst_video_decoder_get_output_state (vdec);
- if (state) {
- /* Fixme: Get exact surface format usings gst_vaapi_surface_get_format () */
- format = GST_VIDEO_INFO_FORMAT (&state->info);
- gst_video_codec_state_unref (state);
- }
+ /* doing gst_vaapi_surface_get_format() only if necessary since it execute
+ * vaDeriveImage in the backgrorund . This will usually get executed only once */
+ format =
+ (GST_VIDEO_INFO_FORMAT (vinfo) ==
+ GST_VIDEO_FORMAT_UNKNOWN) ? gst_vaapi_surface_get_format (surface) :
+ GST_VIDEO_INFO_FORMAT (vinfo);
+
gst_video_info_set_format (vinfo, format, surface_width, surface_height);
return TRUE;
@@ -338,9 +337,9 @@ is_display_resolution_changed (GstVaapiDecode * decode,
const GstVaapiRectangle * crop_rect)
{
GstVideoDecoder *const vdec = GST_VIDEO_DECODER (decode);
- GstVideoFormat format = GST_VIDEO_FORMAT_ENCODED;
GstVideoCodecState *state;
GstVideoInfo *vinfo;
+ GstVideoFormat format = GST_VIDEO_INFO_FORMAT (&decoded->decoded_info);
guint display_width = GST_VIDEO_INFO_WIDTH (&decode->decoded_info);
guint display_height = GST_VIDEO_INFO_HEIGHT (&decode->decoded_info);