summaryrefslogtreecommitdiff
path: root/subprojects/gst-plugins-base/ext/theora/gsttheoradec.c
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2021-06-22 12:28:03 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2023-05-12 14:37:06 +0200
commitb660f258a6ba0a6f6d2b78904bb994779f403b78 (patch)
treea9a7f8ea18bf7162357276f9e5a52ed4eb7f4ce3 /subprojects/gst-plugins-base/ext/theora/gsttheoradec.c
parent802b3b98985c93d63f71c5ec027fc0a84bceb6ee (diff)
downloadgstreamer-b660f258a6ba0a6f6d2b78904bb994779f403b78.tar.gz
theoradec: make sure the selected pool accepts the new config
If gst_buffer_pool_set_config() fails then the pool will use its old config. This may include different width or height when pic_width/pic_height != frame_width/frame_height. As a result, the assertions in theora_handle_image() will fail. So check the result of gst_buffer_pool_set_config() and only use the pool if it succeeds. Otherwise let the parrent decide_allocation() create a new pool. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4600>
Diffstat (limited to 'subprojects/gst-plugins-base/ext/theora/gsttheoradec.c')
-rw-r--r--subprojects/gst-plugins-base/ext/theora/gsttheoradec.c79
1 files changed, 46 insertions, 33 deletions
diff --git a/subprojects/gst-plugins-base/ext/theora/gsttheoradec.c b/subprojects/gst-plugins-base/ext/theora/gsttheoradec.c
index 827a7c85a5..351e6f92da 100644
--- a/subprojects/gst-plugins-base/ext/theora/gsttheoradec.c
+++ b/subprojects/gst-plugins-base/ext/theora/gsttheoradec.c
@@ -926,46 +926,59 @@ theora_dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
guint size, min, max;
GstStructure *config;
- if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (decoder,
- query))
- return FALSE;
-
- gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
+ if ((dec->info.pic_width != dec->info.frame_width ||
+ dec->info.pic_height != dec->info.frame_height) &&
+ (gst_query_get_n_allocation_pools (query) > 0)) {
+ gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
+
+ if (pool) {
+ dec->can_crop = FALSE;
+ config = gst_buffer_pool_get_config (pool);
+ if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
+ gst_buffer_pool_config_add_option (config,
+ GST_BUFFER_POOL_OPTION_VIDEO_META);
+ dec->can_crop =
+ gst_query_find_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE,
+ NULL);
+ }
+
+ if (dec->can_crop) {
+ GstVideoInfo *info = &dec->uncropped_info;
+ GstCaps *caps;
+
+ GST_LOG_OBJECT (decoder,
+ "Using GstVideoCropMeta, uncropped wxh = %dx%d", info->width,
+ info->height);
+
+ gst_video_info_set_format (info, info->finfo->format,
+ dec->info.frame_width, dec->info.frame_height);
- dec->can_crop = FALSE;
- config = gst_buffer_pool_get_config (pool);
- if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
- gst_buffer_pool_config_add_option (config,
- GST_BUFFER_POOL_OPTION_VIDEO_META);
- dec->can_crop =
- gst_query_find_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE,
- NULL);
- }
+ /* Calculate uncropped size */
+ size = MAX (size, info->size);
+ caps = gst_video_info_to_caps (info);
+ gst_buffer_pool_config_set_params (config, caps, size, min, max);
+ gst_caps_unref (caps);
+ }
- if (dec->can_crop) {
- GstVideoInfo *info = &dec->uncropped_info;
- GstCaps *caps;
+ if (gst_buffer_pool_set_config (pool, config)) {
+ gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
+ } else {
+ GstVideoInfo *info = &dec->uncropped_info;
- GST_LOG_OBJECT (decoder, "Using GstVideoCropMeta, uncropped wxh = %dx%d",
- info->width, info->height);
+ GST_DEBUG_OBJECT (dec, "ignoring unusable pool");
- gst_video_info_set_format (info, info->finfo->format, dec->info.frame_width,
- dec->info.frame_height);
+ gst_query_remove_nth_allocation_pool (query, 0);
+ gst_video_info_set_format (info, info->finfo->format,
+ dec->info.pic_width, dec->info.pic_height);
+ dec->can_crop = FALSE;
+ }
- /* Calculate uncropped size */
- size = MAX (size, info->size);
- caps = gst_video_info_to_caps (info);
- gst_buffer_pool_config_set_params (config, caps, size, min, max);
- gst_caps_unref (caps);
+ gst_object_unref (pool);
+ }
}
- gst_buffer_pool_set_config (pool, config);
-
- gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
-
- gst_object_unref (pool);
-
- return TRUE;
+ return GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (decoder,
+ query);
}
static void