Merge branch 'master' into 0.11
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 10 Jan 2012 14:50:37 +0000 (15:50 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 10 Jan 2012 14:50:37 +0000 (15:50 +0100)
Conflicts:
gst/mpegtsdemux/tsdemux.c
gst/videoparsers/gsth264parse.c
tests/check/elements/camerabin2.c

1  2 
ext/opus/gstopusenc.c
ext/vp8/gstvp8dec.c
gst-libs/gst/video/gstbasevideocodec.h
gst-libs/gst/video/gstbasevideodecoder.c
gst/coloreffects/gstcoloreffects.c
gst/interlace/gstinterlace.c
gst/mpegtsdemux/tsdemux.c
gst/videoparsers/gsth264parse.c
gst/videoparsers/gstmpegvideoparse.c
tests/check/elements/camerabin2.c
tests/examples/camerabin2/gst-camera2.c

Simple merge
Simple merge
@@@ -86,6 -86,7 +86,8 @@@ gst_color_effects_preset_get_type (void
      {GST_COLOR_EFFECTS_PRESET_XRAY, "Invert and slightly shade to blue",
          "xray"},
      {GST_COLOR_EFFECTS_PRESET_XPRO, "Cross processing toning", "xpro"},
 -    {GST_COLOR_EFFECTS_PRESET_YELLOWBLUE, "Yellow foreground Blue background color filter", "yellowblue"},
++    {GST_COLOR_EFFECTS_PRESET_YELLOWBLUE,
++        "Yellow foreground Blue background color filter", "yellowblue"},
      {0, NULL, NULL},
    };
  
@@@ -253,6 -254,38 +255,38 @@@ static const guint8 xpro_table[768] 
      "\376\365\377\377\365\377\377\366\377\377\366\377\377\366\377\377\367\377"
      "\377\367\377\377\367\377\377\370";
  
 -  "\0\0\377\1\1\376\2\2\375\3\3\374\4\4\373\5\5\372\6\6\371\7\7\370\10\10\367"
 -  "\11\11\367\12\12\365\13\13\364\14\14\363\15\14\362\16\16\361\17\17\360\20"
 -  "\20\357\20\21\356\22\22\355\23\23\354\24\24\354\24\25\352\26\26\351\27\27"
 -  "\350\27\30\347\31\31\346\32\32\345\33\32\344\34\34\343\34\34\342\36\36\341"
 -  "\37\36\340\40\40\337!!\336!!\335##\334$#\334%%\332&%\331'&\330((\327()\326"
 -  "*)\325++\324,,\323--\322..\321//\320/0\31711\31722\31522\31444\31445\313"
 -  "55\31276\31188\30799\3069:\305;;\305<<\304==\302>>\301>>\300@@\300@A\276"
 -  "AB\275BC\274CD\273DE\272EE\272FF\270HH\270HI\266IJ\265KK\264KL\263MM\262"
 -  "NN\262NN\261OO\257QP\256RQ\256RR\254TT\253UU\253VU\251VW\250XX\247XY\246"
 -  "YZ\245[[\245[[\243]]\243^^\242^_\240_`\237`a\236aa\235bb\235dc\233de\233"
 -  "ff\232gf\231hg\230hi\227ji\226kj\225lk\223lm\223nm\222nn\221op\217qq\216"
 -  "rr\215ss\214st\213uu\213uu\211wv\210ww\207xx\207yz\205z{\205{{\204||\203"
 -  "}}\202\177~\201\177\200\177\200\201\177\202\202~\203\202|\204\203|\204\204"
 -  "{\205\206z\207\206x\207\207w\211\210w\211\211v\212\212u\213\214s\214\214"
 -  "r\215\215r\216\217q\217\217p\221\220o\221\222n\223\222l\224\223k\224\224"
 -  "k\225\225j\226\226i\227\227h\230\231f\231\231f\233\232e\233\233c\234\234"
 -  "c\235\235b\236\236a\237\237`\241\240_\242\241^\242\242]\243\244\\\244\244"
 -  "[\245\245Y\246\246Y\250\247X\250\250W\251\251V\252\252T\253\253T\254\255"
 -  "S\256\255R\257\256Q\257\260P\260\261O\261\261N\262\262M\263\263L\264\265"
 -  "K\265\265J\266\266I\267\270H\270\270G\271\271F\272\272E\273\273C\274\274"
 -  "B\275\275B\276\276A\277\277@\300\300?\301\301>\302\302=\303\303<\304\304"
 -  ";\305\305:\306\3069\307\3078\310\3107\311\3116\312\3125\313\3134\314\314"
 -  "3\315\3152\316\3161\317\3170\320\320/\321\321.\322\322-\323\323,\323\324"
 -  "+\325\325*\326\326)\327\327(\330\330'\331\331&\332\331%\333\332$\334\334"
 -  "#\334\335\"\336\336!\337\337\40\340\340\37\341\341\36\342\342\35\343\343"
 -  "\34\344\344\33\345\345\32\345\346\31\347\347\30\350\350\27\351\351\26\352"
 -  "\352\25\353\353\24\354\354\23\354\355\22\356\356\21\357\357\20\360\360\17"
 -  "\361\361\16\362\362\15\363\362\14\364\364\13\365\365\12\365\366\11\367\367"
 -  "\11\370\370\7\371\371\6\372\371\5\373\373\4\374\374\4\375\375\3\375\376\1";
+ /*Used for a video magnifer emulator in gnome-video-effects*/
+ static const guint8 yellowblue_table[768] =
++    "\0\0\377\1\1\376\2\2\375\3\3\374\4\4\373\5\5\372\6\6\371\7\7\370\10\10\367"
++    "\11\11\367\12\12\365\13\13\364\14\14\363\15\14\362\16\16\361\17\17\360\20"
++    "\20\357\20\21\356\22\22\355\23\23\354\24\24\354\24\25\352\26\26\351\27\27"
++    "\350\27\30\347\31\31\346\32\32\345\33\32\344\34\34\343\34\34\342\36\36\341"
++    "\37\36\340\40\40\337!!\336!!\335##\334$#\334%%\332&%\331'&\330((\327()\326"
++    "*)\325++\324,,\323--\322..\321//\320/0\31711\31722\31522\31444\31445\313"
++    "55\31276\31188\30799\3069:\305;;\305<<\304==\302>>\301>>\300@@\300@A\276"
++    "AB\275BC\274CD\273DE\272EE\272FF\270HH\270HI\266IJ\265KK\264KL\263MM\262"
++    "NN\262NN\261OO\257QP\256RQ\256RR\254TT\253UU\253VU\251VW\250XX\247XY\246"
++    "YZ\245[[\245[[\243]]\243^^\242^_\240_`\237`a\236aa\235bb\235dc\233de\233"
++    "ff\232gf\231hg\230hi\227ji\226kj\225lk\223lm\223nm\222nn\221op\217qq\216"
++    "rr\215ss\214st\213uu\213uu\211wv\210ww\207xx\207yz\205z{\205{{\204||\203"
++    "}}\202\177~\201\177\200\177\200\201\177\202\202~\203\202|\204\203|\204\204"
++    "{\205\206z\207\206x\207\207w\211\210w\211\211v\212\212u\213\214s\214\214"
++    "r\215\215r\216\217q\217\217p\221\220o\221\222n\223\222l\224\223k\224\224"
++    "k\225\225j\226\226i\227\227h\230\231f\231\231f\233\232e\233\233c\234\234"
++    "c\235\235b\236\236a\237\237`\241\240_\242\241^\242\242]\243\244\\\244\244"
++    "[\245\245Y\246\246Y\250\247X\250\250W\251\251V\252\252T\253\253T\254\255"
++    "S\256\255R\257\256Q\257\260P\260\261O\261\261N\262\262M\263\263L\264\265"
++    "K\265\265J\266\266I\267\270H\270\270G\271\271F\272\272E\273\273C\274\274"
++    "B\275\275B\276\276A\277\277@\300\300?\301\301>\302\302=\303\303<\304\304"
++    ";\305\305:\306\3069\307\3078\310\3107\311\3116\312\3125\313\3134\314\314"
++    "3\315\3152\316\3161\317\3170\320\320/\321\321.\322\322-\323\323,\323\324"
++    "+\325\325*\326\326)\327\327(\330\330'\331\331&\332\331%\333\332$\334\334"
++    "#\334\335\"\336\336!\337\337\40\340\340\37\341\341\36\342\342\35\343\343"
++    "\34\344\344\33\345\345\32\345\346\31\347\347\30\350\350\27\351\351\26\352"
++    "\352\25\353\353\24\354\354\23\354\355\22\356\356\21\357\357\20\360\360\17"
++    "\361\361\16\362\362\15\363\362\14\364\364\13\365\365\12\365\366\11\367\367"
++    "\11\370\370\7\371\371\6\372\371\5\373\373\4\374\374\4\375\375\3\375\376\1";
  static const int cog_ycbcr_to_rgb_matrix_8bit_sdtv[] = {
    298, 0, 409, -57068,
    298, -100, -208, 34707,
@@@ -543,6 -576,10 +577,10 @@@ gst_color_effects_set_property (GObjec
            filter->table = xpro_table;
            filter->map_luma = FALSE;
            break;
 -      case GST_COLOR_EFFECTS_PRESET_YELLOWBLUE:
 -        filter->table = yellowblue_table;
 -        filter->map_luma = FALSE;
 -        break;
++        case GST_COLOR_EFFECTS_PRESET_YELLOWBLUE:
++          filter->table = yellowblue_table;
++          filter->map_luma = FALSE;
++          break;
          default:
            g_assert_not_reached ();
  
Simple merge
@@@ -112,10 -115,19 +115,17 @@@ struct _TSDemuxStrea
    guint8 nbpending;
  
    /* Current data to be pushed out */
 -  GstBufferList *current;
 -  GstBufferListIterator *currentit;
    GList *currentlist;
  
-   /* Current PTS for this stream */
+   /* Current PTS/DTS for this stream */
    GstClockTime pts;
+   GstClockTime dts;
+   /* Raw value of current PTS/DTS */
+   guint64 raw_pts;
+   guint64 raw_dts;
+   /* Number of rollover seen for PTS/DTS (default:0) */
+   guint nb_pts_rollover;
+   guint nb_dts_rollover;
  };
  
  #define VIDEO_CAPS \
@@@ -1950,15 -2000,13 +2013,14 @@@ gst_ts_demux_parse_pes_header (GstTSDem
    GstFlowReturn res = GST_FLOW_OK;
    gint offset = 0;
    guint8 *data;
 -  guint32 length;
 +  gsize length;
    guint64 bufferoffset;
-   GstClockTime time;
    PESParsingResult parseres;
 +  GstClockTime origts;
  
 -  data = GST_BUFFER_DATA (stream->pendingbuffers[0]);
 -  length = GST_BUFFER_SIZE (stream->pendingbuffers[0]);
 -  bufferoffset = GST_BUFFER_OFFSET (stream->pendingbuffers[0]);
 +  data = gst_buffer_map (buf, &length, 0, GST_MAP_READ);
 +  bufferoffset = GST_BUFFER_OFFSET (buf);
 +  origts = GST_BUFFER_TIMESTAMP (buf);
  
    GST_MEMDUMP ("Header buffer", data, MIN (length, 32));
  
      time = calc_gsttime_from_pts (&demux->index_pcr, pts);
  #endif
  
-     stream->pts = time = MPEGTIME_TO_GSTTIME (header.PTS);
 -    GST_DEBUG_OBJECT (base, "stream PTS %" GST_TIME_FORMAT,
 -        GST_TIME_ARGS (stream->pts));
 +    GST_DEBUG_OBJECT (base,
 +        "stream PTS %" GST_TIME_FORMAT " DTS %" GST_TIME_FORMAT,
 +        GST_TIME_ARGS (stream->pts),
 +        GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (header.DTS)));
 +
 +    /* FIXME : This will only work if the PES header is contained
 +     * at the beginning of an incoming GstBuffer */
 +    /* FIXME : Handle wrap-around ? */
 +    if (base->upstream_live && GST_CLOCK_TIME_IS_VALID (origts)
 +        && !GST_CLOCK_TIME_IS_VALID (demux->pts_delta)) {
 +      if (GST_CLOCK_TIME_IS_VALID (MPEGTIME_TO_GSTTIME (header.DTS)))
 +        demux->pts_delta = MPEGTIME_TO_GSTTIME (header.DTS) - origts;
 +      else
 +        demux->pts_delta = stream->pts - origts;
 +      GST_DEBUG_OBJECT (base, "buffer timestamp %" GST_TIME_FORMAT,
 +          GST_TIME_ARGS (origts));
 +      GST_DEBUG_OBJECT (base, "delta %" GST_TIME_FORMAT,
 +          GST_TIME_ARGS (demux->pts_delta));
 +    }
  
      /* safe default if insufficient upstream info */
      if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (base->in_gap) &&
      if (!GST_CLOCK_TIME_IS_VALID (base->in_gap))
        base->in_gap = 0;
  
 -    GST_BUFFER_TIMESTAMP (stream->pendingbuffers[0]) =
 -        stream->pts + base->in_gap;
 +    if (base->upstream_live) {
 +      if (GST_CLOCK_TIME_IS_VALID (demux->pts_delta))
 +        GST_BUFFER_TIMESTAMP (buf) = stream->pts - demux->pts_delta;
 +      else
 +        GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
 +    } else
-       GST_BUFFER_TIMESTAMP (buf) = time + base->in_gap;
++      GST_BUFFER_TIMESTAMP (buf) = stream->pts + base->in_gap;
 +    GST_DEBUG ("buf %" GST_TIME_FORMAT,
 +        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
    }
  
 +  if (header.DTS != -1)
 +    gst_ts_demux_record_dts (demux, stream, header.DTS, bufferoffset);
 +
 +  gst_buffer_unmap (buf, data, length);
 +
    /* Remove PES headers */
    GST_DEBUG ("Moving data forward  by %d bytes", header.header_size);
 -  GST_BUFFER_DATA (stream->pendingbuffers[0]) += header.header_size;
 -  GST_BUFFER_SIZE (stream->pendingbuffers[0]) -= header.header_size;
 +  gst_buffer_resize (buf, header.header_size, length - header.header_size);
  
    /* FIXME : responsible for switching to PENDING_PACKET_BUFFER and
     * creating the bufferlist */
@@@ -2185,12 -2210,12 +2250,14 @@@ calculate_and_push_newsegment (GstTSDem
      GST_DEBUG ("stream pts: %" GST_TIME_FORMAT " first pts: %" GST_TIME_FORMAT,
          GST_TIME_ARGS (stream->pts), GST_TIME_ARGS (firstpts));
  
-     start = base->segment.start;
-     stop = base->segment.stop;
-     if (!base->upstream_live) {
-       /* Shift the start depending on our position in the stream */
-       start += firstpts + base->in_gap - base->first_buf_ts;
+     if (base->segment.format == GST_FORMAT_TIME) {
+       start = base->segment.start;
+       stop = base->segment.stop;
++      if (!base->upstream_live) {
++        /* Shift the start depending on our position in the stream */
++        start += firstpts + base->in_gap - base->first_buf_ts;
++      }
      }
 -    /* Shift the start depending on our position in the stream */
 -    start += firstpts + base->in_gap - base->first_buf_ts;
      position = start;
    } else {
      /* pull mode */
@@@ -614,19 -628,14 +628,19 @@@ gst_h264_parse_check_valid_frame (GstBa
    GstH264Parse *h264parse = GST_H264_PARSE (parse);
    GstBuffer *buffer = frame->buffer;
    guint8 *data;
 -  guint size, current_off = 0;
 +  gsize size;
 +  guint current_off = 0;
    gboolean drain;
    GstH264NalParser *nalparser = h264parse->nalparser;
-   GstH264NalUnit nalu = h264parse->nalu;
+   GstH264NalUnit nalu;
  
 +  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 +
    /* expect at least 3 bytes startcode == sc, and 2 bytes NALU payload */
 -  if (G_UNLIKELY (GST_BUFFER_SIZE (buffer) < 5))
 +  if (G_UNLIKELY (size < 5)) {
 +    gst_buffer_unmap (buffer, data, size);
      return FALSE;
 +  }
  
    /* need to configure aggregation */
    if (G_UNLIKELY (h264parse->format == GST_H264_PARSE_FORMAT_NONE))
      GST_LOG_OBJECT (h264parse, "resuming frame parsing");
    }
  
 -  data = GST_BUFFER_DATA (buffer);
 -  size = GST_BUFFER_SIZE (buffer);
 -
    drain = FALSE;
+   nalu = h264parse->nalu;
    current_off = h264parse->current_off;
  
    GST_DEBUG_OBJECT (h264parse, "last parse position %u", current_off);
@@@ -1471,11 -1473,15 +1491,14 @@@ gst_h264_parse_pre_push_frame (GstBaseP
                h264parse->last_report = new_ts;
              }
            }
 -          gst_byte_writer_put_data (&bw,
 -              GST_BUFFER_DATA (buffer) + h264parse->idr_pos,
 -              GST_BUFFER_SIZE (buffer) - h264parse->idr_pos);
 +          gst_byte_writer_put_buffer (&bw, buffer, h264parse->idr_pos, -1);
            /* collect result and push */
            new_buf = gst_byte_writer_reset_and_get_buffer (&bw);
 -          gst_buffer_copy_metadata (new_buf, buffer, GST_BUFFER_COPY_ALL);
 +          gst_buffer_copy_into (new_buf, buffer, GST_BUFFER_COPY_METADATA, 0,
 +              -1);
+           /* should already be keyframe/IDR, but it may not have been,
+            * so mark it as such to avoid being discarded by picky decoder */
+           GST_BUFFER_FLAG_UNSET (new_buf, GST_BUFFER_FLAG_DELTA_UNIT);
            gst_buffer_replace (&frame->buffer, new_buf);
            gst_buffer_unref (new_buf);
          }
@@@ -1732,6 -1735,24 +1767,22 @@@ gst_h264_parse_event (GstBaseParse * pa
        gst_event_replace (&h264parse->force_key_unit_event, event);
        break;
      }
 -    case GST_EVENT_NEWSEGMENT:
+     case GST_EVENT_FLUSH_STOP:
+       h264parse->dts = GST_CLOCK_TIME_NONE;
+       h264parse->ts_trn_nb = GST_CLOCK_TIME_NONE;
+       break;
 -      gdouble rate, applied_rate;
 -      GstFormat format;
 -      gint64 start;
++    case GST_EVENT_SEGMENT:
+     {
 -      gst_event_parse_new_segment_full (event, NULL, &rate, &applied_rate,
 -          &format, &start, NULL, NULL);
++      const GstSegment *segment;
 -      if (format == GST_FORMAT_TIME &&
 -          (start != 0 || rate != 1.0 || applied_rate != 1.0))
++      gst_event_parse_segment (event, &segment);
+       /* don't try to mess with more subtle cases (e.g. seek) */
++      if (segment->format == GST_FORMAT_TIME &&
++          (segment->start != 0 || segment->rate != 1.0
++              || segment->applied_rate != 1.0))
+         h264parse->do_ts = FALSE;
+       break;
+     }
      default:
        break;
    }
Simple merge
@@@ -585,8 -571,18 +587,18 @@@ check_file_validity (const gchar * file
    return TRUE;
  }
  
 -static gboolean
 -filter_buffer_count (GstPad * pad, GstMiniObject * obj, gpointer data)
+ static void
+ remove_file (const gchar * fn_template, guint num)
+ {
+   const gchar *fn;
+   fn = make_const_file_name (fn_template, num);
+   GST_INFO ("removing %s", fn);
+   g_unlink (fn);
+ }
 +static GstPadProbeReturn
 +filter_buffer_count (GstPad * pad, GstPadProbeInfo * info, gpointer data)
  {
    gint *counter = data;