theoradec: Fix decoding in the presence of GstVideoCropMeta
authorJan Schmidt <jan@centricular.com>
Sat, 31 Jan 2015 16:39:07 +0000 (03:39 +1100)
committerJan Schmidt <jan@centricular.com>
Thu, 12 Mar 2015 11:38:37 +0000 (22:38 +1100)
Store the video info of the internal frame decode width/height
separate to the exposed (cropped) frame info, so that it can be
used for mapping the downstream allocated video frame buffer correctly
when using GstVideoCropMeta.

Fixes playback of files with sizes that aren't a multiple of 16-pixels
width or height.

https://bugzilla.gnome.org/show_bug.cgi?id=741030

ext/theora/gsttheoradec.c
ext/theora/gsttheoradec.h

index d2f14b0..5adb057 100644 (file)
@@ -507,6 +507,8 @@ theora_handle_type_packet (GstTheoraDec * dec)
       break;
   }
 
+  dec->uncropped_info = state->info;
+
   gst_video_decoder_negotiate (GST_VIDEO_DECODER (dec));
 
   dec->have_header = TRUE;
@@ -694,7 +696,7 @@ theora_handle_image (GstTheoraDec * dec, th_ycbcr_buffer buf,
   GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, dec,
       "doing unavoidable video frame copy");
 
-  if (G_UNLIKELY (!gst_video_frame_map (&vframe, &dec->output_state->info,
+  if (G_UNLIKELY (!gst_video_frame_map (&vframe, &dec->uncropped_info,
               frame->output_buffer, GST_MAP_WRITE)))
     goto invalid_frame;
 
@@ -912,14 +914,18 @@ theora_dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
   }
 
   if (dec->can_crop) {
-    GstVideoInfo info = state->info;
+    GstVideoInfo *info = &dec->uncropped_info;
     GstCaps *caps;
 
-    /* Calculate uncropped size */
-    gst_video_info_set_format (&info, info.finfo->format, dec->info.frame_width,
+    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);
-    size = MAX (size, info.size);
-    caps = gst_video_info_to_caps (&info);
+
+    /* 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);
   }
index 1ca5583..2445ad3 100644 (file)
@@ -77,6 +77,7 @@ struct _GstTheoraDec
   gint telemetry_bits;
 
   gboolean can_crop;
+  GstVideoInfo uncropped_info;
 };
 
 struct _GstTheoraDecClass