From: Aurélien Zanelli Date: Thu, 7 Jan 2016 13:18:08 +0000 (+0100) Subject: videoparse: cache video info in instance X-Git-Tag: 1.19.3~507^2~7179 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf25e09b1aabbd7b4b594e718e1cb0a1ecbd1862;p=platform%2Fupstream%2Fgstreamer.git videoparse: cache video info in instance To avoid initializing and filling video info each time we need it. https://bugzilla.gnome.org/show_bug.cgi?id=760270 --- diff --git a/gst/rawparse/gstvideoparse.c b/gst/rawparse/gstvideoparse.c index b8bc7d1..80274de 100644 --- a/gst/rawparse/gstvideoparse.c +++ b/gst/rawparse/gstvideoparse.c @@ -40,7 +40,7 @@ static GstCaps *gst_video_parse_get_caps (GstRawParse * rp); static void gst_video_parse_set_buffer_flags (GstRawParse * rp, GstBuffer * buffer); -static void gst_video_parse_update_frame_size (GstVideoParse * vp); +static void gst_video_parse_update_info (GstVideoParse * vp); GST_DEBUG_CATEGORY_STATIC (gst_video_parse_debug); #define GST_CAT_DEFAULT gst_video_parse_debug @@ -126,8 +126,8 @@ gst_video_parse_init (GstVideoParse * vp) vp->par_n = 1; vp->par_d = 1; - gst_video_parse_update_frame_size (vp); gst_raw_parse_set_fps (GST_RAW_PARSE (vp), 25, 1); + gst_video_parse_update_info (vp); } static void @@ -168,7 +168,7 @@ gst_video_parse_set_property (GObject * object, guint prop_id, break; } - gst_video_parse_update_frame_size (vp); + gst_video_parse_update_info (vp); } static void @@ -209,16 +209,27 @@ gst_video_parse_get_property (GObject * object, guint prop_id, GValue * value, } } -void -gst_video_parse_update_frame_size (GstVideoParse * vp) +static void +gst_video_parse_update_info (GstVideoParse * vp) { + GstVideoInfo *info = &vp->info; + gint fps_n, fps_d; gint framesize; - GstVideoInfo info; - gst_video_info_init (&info); - gst_video_info_set_format (&info, vp->format, vp->width, vp->height); - framesize = GST_VIDEO_INFO_SIZE (&info); + gst_raw_parse_get_fps (GST_RAW_PARSE (vp), &fps_n, &fps_d); + + gst_video_info_init (info); + gst_video_info_set_format (info, vp->format, vp->width, vp->height); + info->fps_n = fps_n; + info->fps_d = fps_d; + info->par_n = vp->par_n; + info->par_d = vp->par_d; + info->interlace_mode = vp->interlaced ? + GST_VIDEO_INTERLACE_MODE_INTERLEAVED : + GST_VIDEO_INTERLACE_MODE_PROGRESSIVE; + /* update base class framesize */ + framesize = GST_VIDEO_INFO_SIZE (info); gst_raw_parse_set_framesize (GST_RAW_PARSE (vp), framesize); } @@ -226,25 +237,8 @@ static GstCaps * gst_video_parse_get_caps (GstRawParse * rp) { GstVideoParse *vp = GST_VIDEO_PARSE (rp); - GstVideoInfo info; - GstCaps *caps; - gint fps_n, fps_d; - - gst_raw_parse_get_fps (rp, &fps_n, &fps_d); - - gst_video_info_init (&info); - gst_video_info_set_format (&info, vp->format, vp->width, vp->height); - info.fps_n = fps_n; - info.fps_d = fps_d; - info.par_n = vp->par_n; - info.par_d = vp->par_d; - info.interlace_mode = vp->interlaced ? - GST_VIDEO_INTERLACE_MODE_INTERLEAVED : - GST_VIDEO_INTERLACE_MODE_PROGRESSIVE; - - caps = gst_video_info_to_caps (&info); - return caps; + return gst_video_info_to_caps (&vp->info); } static void diff --git a/gst/rawparse/gstvideoparse.h b/gst/rawparse/gstvideoparse.h index b4173df..1cc40cb 100644 --- a/gst/rawparse/gstvideoparse.h +++ b/gst/rawparse/gstvideoparse.h @@ -48,6 +48,8 @@ struct _GstVideoParse { GstRawParse parent; + GstVideoInfo info; + /* properties */ GstVideoFormat format; gint width;