videoaggregator: Copy over more fields from the relevant video-info

gst_video_info_set_format() will reset the complete video-info, but
we want to keep values like the PAR, colorimetry and chroma site.
Otherwise we risk setting different values on the srcpad caps than
what is actually inside the buffers.
This commit is contained in:
Sebastian Dröge 2014-11-27 20:34:25 +01:00
parent 4233ba4ca4
commit fdc87a52f2

View file

@ -165,11 +165,23 @@ gst_video_aggregator_pad_set_info (GstVideoAggregatorPad * pad,
GST_VIDEO_INFO_FORMAT (current_info) GST_VIDEO_INFO_FORMAT (current_info)
|| g_strcmp0 (colorimetry, best_colorimetry) || g_strcmp0 (colorimetry, best_colorimetry)
|| g_strcmp0 (chroma, best_chroma)) { || g_strcmp0 (chroma, best_chroma)) {
GstVideoInfo tmp_info = *current_info; GstVideoInfo tmp_info;
tmp_info.finfo = wanted_info->finfo; /* Initialize with the wanted video format and our original width and
* height as we don't want to rescale. Then copy over the wanted
* colorimetry, and chroma-site and our current pixel-aspect-ratio
* and other relevant fields.
*/
gst_video_info_set_format (&tmp_info, GST_VIDEO_INFO_FORMAT (wanted_info),
current_info->width, current_info->height);
tmp_info.chroma_site = wanted_info->chroma_site; tmp_info.chroma_site = wanted_info->chroma_site;
tmp_info.colorimetry = wanted_info->colorimetry; tmp_info.colorimetry = wanted_info->colorimetry;
tmp_info.par_n = current_info->par_n;
tmp_info.par_d = current_info->par_d;
tmp_info.fps_n = current_info->fps_n;
tmp_info.fps_d = current_info->fps_d;
tmp_info.flags = current_info->flags;
tmp_info.interlace_mode = current_info->interlace_mode;
GST_DEBUG_OBJECT (pad, "This pad will be converted from %d to %d", GST_DEBUG_OBJECT (pad, "This pad will be converted from %d to %d",
GST_VIDEO_INFO_FORMAT (current_info), GST_VIDEO_INFO_FORMAT (current_info),
@ -656,13 +668,21 @@ gst_videoaggregator_update_src_caps (GstVideoAggregator * vagg)
vagg->priv->nframes = 0; vagg->priv->nframes = 0;
} }
} }
gst_video_info_init (&info);
/* Initialize the video info with our target format and
* the best width and height and framerate. Then copy over
* all other fields as we negotiated them before
*/
gst_video_info_set_format (&info, GST_VIDEO_INFO_FORMAT (&vagg->info), gst_video_info_set_format (&info, GST_VIDEO_INFO_FORMAT (&vagg->info),
best_width, best_height); best_width, best_height);
info.fps_n = best_fps_n; info.fps_n = best_fps_n;
info.fps_d = best_fps_d; info.fps_d = best_fps_d;
info.par_n = GST_VIDEO_INFO_PAR_N (&vagg->info); info.chroma_site = vagg->info.chroma_site;
info.par_d = GST_VIDEO_INFO_PAR_D (&vagg->info); info.par_n = vagg->info.par_n;
info.par_d = vagg->info.par_d;
info.colorimetry = vagg->info.colorimetry;
info.flags = vagg->info.flags;
info.interlace_mode = vagg->info.interlace_mode;
info_caps = gst_video_info_to_caps (&info); info_caps = gst_video_info_to_caps (&info);