mpeg2dec: graceful degradation for badly parsed input
authorMark Nauwelaerts <mnauw@users.sourceforge.net>
Mon, 11 Nov 2013 12:15:54 +0000 (13:15 +0100)
committerMark Nauwelaerts <mnauw@users.sourceforge.net>
Mon, 11 Nov 2013 12:25:22 +0000 (13:25 +0100)
ext/mpeg2dec/gstmpeg2dec.c

index 03c8b4e..811e052 100644 (file)
@@ -406,6 +406,13 @@ gst_mpeg2dec_alloc_sized_buf (GstMpeg2dec * mpeg2dec, guint size,
   state = gst_video_decoder_get_output_state (GST_VIDEO_DECODER (mpeg2dec));
 
   if (!mpeg2dec->need_cropping || mpeg2dec->has_cropping) {
+    /* need parsed input, but that might be slightly bogus,
+     * so avoid giving up altogether and mark it as error */
+    if (frame->output_buffer) {
+      gst_buffer_replace (&frame->output_buffer, NULL);
+      GST_VIDEO_DECODER_ERROR (mpeg2dec, 1, STREAM, DECODE,
+          ("decoding error"), ("Input not correctly parsed"), ret);
+    }
     ret =
         gst_video_decoder_allocate_output_frame (GST_VIDEO_DECODER (mpeg2dec),
         frame);