Merge remote-tracking branch 'origin/master' into 0.11
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 26 Nov 2011 15:37:25 +0000 (15:37 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 26 Nov 2011 15:37:25 +0000 (15:37 +0000)
Conflicts:
ext/opus/gstopusdec.c
ext/opus/gstopusparse.c
gst-libs/gst/video/gstbasevideodecoder.c
gst-libs/gst/video/gstbasevideodecoder.h

1  2 
ext/opus/gstopusdec.c
ext/opus/gstopusenc.c
ext/opus/gstopusheader.c
ext/opus/gstopusparse.c
ext/vp8/gstvp8dec.c
gst-libs/gst/video/gstbasevideodecoder.c
gst-libs/gst/video/gstbasevideodecoder.h
tests/check/Makefile.am

@@@ -216,10 -222,8 +216,11 @@@ gst_opus_dec_parse_header (GstOpusDec 
    const GstAudioChannelPosition *pos = NULL;
  
    g_return_val_if_fail (gst_opus_header_is_id_header (buf), GST_FLOW_ERROR);
-   g_return_val_if_fail (dec->n_channels != data[9], GST_FLOW_ERROR);
 +
 +  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
 +
+   g_return_val_if_fail (dec->n_channels == 0
+       || dec->n_channels == data[9], GST_FLOW_ERROR);
  
    dec->n_channels = data[9];
    dec->pre_skip = GST_READ_UINT16_LE (data + 10);
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1349,33 -1368,14 +1352,15 @@@ gst_base_video_decoder_new_frame (GstBa
    return frame;
  }
  
- /**
-  * gst_base_video_decoder_finish_frame:
-  * @base_video_decoder: a #GstBaseVideoDecoder
-  * @frame: a decoded #GstVideoFrameState
-  *
-  * @frame should have a valid decoded data buffer, whose metadata fields
-  * are then appropriately set according to frame data and pushed downstream.
-  * If no output data is provided, @frame is considered skipped.
-  * In any case, the frame is considered finished and released.
-  *
-  * Returns: a #GstFlowReturn resulting from sending data downstream
-  */
- GstFlowReturn
- gst_base_video_decoder_finish_frame (GstBaseVideoDecoder * base_video_decoder,
-     GstVideoFrameState * frame)
+ static void
+ gst_base_video_decoder_prepare_finish_frame (GstBaseVideoDecoder *
 -    base_video_decoder, GstVideoFrame * frame)
++    base_video_decoder, GstVideoFrameState * frame)
  {
-   GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
-   GstBuffer *src_buffer;
-   GstFlowReturn ret = GST_FLOW_OK;
    GList *l, *events = NULL;
  
-   GST_LOG_OBJECT (base_video_decoder, "finish frame");
-   GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
  #ifndef GST_DISABLE_GST_DEBUG
 -  GST_LOG_OBJECT (base_video_decoder, "n %d in %d out %d",
 +  GST_LOG_OBJECT (base_video_decoder,
 +      "n %d in %" G_GSIZE_FORMAT " out %" G_GSIZE_FORMAT,
        g_list_length (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames),
        gst_adapter_available (base_video_decoder->input_adapter),
        gst_adapter_available (base_video_decoder->output_adapter));
      }
    }
    base_video_decoder->last_timestamp = frame->presentation_timestamp;
 -    GstVideoFrame * frame)
+ }
+ static void
+ gst_base_video_decoder_do_finish_frame (GstBaseVideoDecoder * dec,
++    GstVideoFrameState * frame)
+ {
+   GST_BASE_VIDEO_CODEC (dec)->frames =
+       g_list_remove (GST_BASE_VIDEO_CODEC (dec)->frames, frame);
+   if (frame->src_buffer)
+     gst_buffer_unref (frame->src_buffer);
  
-   /* no buffer data means this frame is skipped/dropped */
+   gst_base_video_codec_free_frame (frame);
+ }
+ /**
+  * gst_base_video_decoder_drop_frame:
+  * @dec: a #GstBaseVideoDecoder
+  * @frame: the #GstVideoFrame to drop
+  *
+  * Similar to gst_base_video_decoder_finish_frame(), but drops @frame in any
+  * case and posts a QoS message with the frame's details on the bus.
+  * In any case, the frame is considered finished and released.
+  *
+  * Returns: a #GstFlowReturn, usually GST_FLOW_OK.
+  *
+  * Since: 0.10.23
+  */
+ GstFlowReturn
+ gst_base_video_decoder_drop_frame (GstBaseVideoDecoder * dec,
 -    GstVideoFrame * frame)
++    GstVideoFrameState * frame)
+ {
+   GstClockTime stream_time, jitter, earliest_time, qostime, timestamp;
+   GstSegment *segment;
+   GstMessage *qos_msg;
+   gdouble proportion;
+   GST_LOG_OBJECT (dec, "drop frame");
+   GST_BASE_VIDEO_CODEC_STREAM_LOCK (dec);
+   gst_base_video_decoder_prepare_finish_frame (dec, frame);
+   GST_DEBUG_OBJECT (dec, "dropping frame %" GST_TIME_FORMAT,
+       GST_TIME_ARGS (frame->presentation_timestamp));
+   dec->dropped++;
+   /* post QoS message */
+   timestamp = frame->presentation_timestamp;
+   proportion = GST_BASE_VIDEO_CODEC (dec)->proportion;
+   segment = &GST_BASE_VIDEO_CODEC (dec)->segment;
+   stream_time =
+       gst_segment_to_stream_time (segment, GST_FORMAT_TIME, timestamp);
+   qostime = gst_segment_to_running_time (segment, GST_FORMAT_TIME, timestamp);
+   earliest_time = GST_BASE_VIDEO_CODEC (dec)->earliest_time;
+   jitter = GST_CLOCK_DIFF (qostime, earliest_time);
+   qos_msg = gst_message_new_qos (GST_OBJECT_CAST (dec), FALSE,
+       qostime, stream_time, timestamp, GST_CLOCK_TIME_NONE);
+   gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
+   gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
+       dec->processed, dec->dropped);
+   gst_element_post_message (GST_ELEMENT_CAST (dec), qos_msg);
+   /* now free the frame */
+   gst_base_video_decoder_do_finish_frame (dec, frame);
+   GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (dec);
+   return GST_FLOW_OK;
+ }
+ /**
+  * gst_base_video_decoder_finish_frame:
+  * @base_video_decoder: a #GstBaseVideoDecoder
 - * @frame: a decoded #GstVideoFrame
++ * @frame: a decoded #GstVideoFrameState
+  *
+  * @frame should have a valid decoded data buffer, whose metadata fields
+  * are then appropriately set according to frame data and pushed downstream.
+  * If no output data is provided, @frame is considered skipped.
+  * In any case, the frame is considered finished and released.
+  *
+  * Returns: a #GstFlowReturn resulting from sending data downstream
+  */
+ GstFlowReturn
+ gst_base_video_decoder_finish_frame (GstBaseVideoDecoder * base_video_decoder,
 -    GstVideoFrame * frame)
++    GstVideoFrameState * frame)
+ {
+   GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
+   GstBuffer *src_buffer;
+   GstFlowReturn ret = GST_FLOW_OK;
+   GST_LOG_OBJECT (base_video_decoder, "finish frame");
+   GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+   gst_base_video_decoder_prepare_finish_frame (base_video_decoder, frame);
+   base_video_decoder->processed++;
+   /* no buffer data means this frame is skipped */
    if (!frame->src_buffer) {
      GST_DEBUG_OBJECT (base_video_decoder, "skipping frame %" GST_TIME_FORMAT,
          GST_TIME_ARGS (frame->presentation_timestamp));
@@@ -182,12 -182,10 +182,16 @@@ struct _GstBaseVideoDecode
    int               reorder_depth;
    int               distance_from_sync;
  
 +  /* Raw video bufferpool */
 +  GstBufferPool *pool;
 +  /* Indicates whether downstream can handle
 +   * GST_META_API_VIDEO_CROP */
 +  gboolean use_cropping;
 +
+   /* qos messages: frames dropped/processed */
+   guint             dropped;
+   guint             processed;
    /* FIXME before moving to base */
    void             *padding[GST_PADDING_LARGE];
  };
@@@ -270,10 -268,11 +274,12 @@@ GstFlowReturn    gst_base_video_decoder
  GstVideoState   *gst_base_video_decoder_get_state (GstBaseVideoDecoder *base_video_decoder);
  GstClockTimeDiff gst_base_video_decoder_get_max_decode_time (
                                      GstBaseVideoDecoder *base_video_decoder,
 -                                    GstVideoFrame *frame);
 +                                    GstVideoFrameState *frame);
  GstFlowReturn    gst_base_video_decoder_finish_frame (GstBaseVideoDecoder *base_video_decoder,
 -                                    GstVideoFrame *frame);
 +                                    GstVideoFrameState *frame);
+ GstFlowReturn    gst_base_video_decoder_drop_frame (GstBaseVideoDecoder *dec,
 -                                    GstVideoFrame *frame);
++                                    GstVideoFrameState *frame);
 +
  GType            gst_base_video_decoder_get_type (void);
  
  G_END_DECLS
Simple merge