From: <ms...@fr...> - 2005-11-23 00:26:56
|
CVS Root: /cvs/gstreamer Module: gst-plugins-ugly Changes by: msmith Date: Tue Nov 22 2005 16:26:54 PST Log message: * gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event), (gst_rmdemux_src_event), (gst_rmdemux_validate_offset), (find_seek_offset_bytes), (find_seek_offset_time), (gst_rmdemux_perform_seek), (gst_rmdemux_src_query), (gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible), (gst_rmdemux_chain), (gst_rmdemux_send_event), (gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_packet): Fractional framerates. Modified files: . : ChangeLog gst/realmedia : rmdemux.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-ugly/ChangeLog.diff?r1=1.1894&r2=1.1895 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-ugly/gst/realmedia/rmdemux.c.diff?r1=1.54&r2=1.55 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-ugly/ChangeLog,v retrieving revision 1.1894 retrieving revision 1.1895 diff -u -d -r1.1894 -r1.1895 --- ChangeLog 23 Nov 2005 00:12:24 -0000 1.1894 +++ ChangeLog 23 Nov 2005 00:26:42 -0000 1.1895 @@ -1,3 +1,15 @@ +2005-11-23 Michael Smith <ms...@fl...> + + * gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event), + (gst_rmdemux_src_event), (gst_rmdemux_validate_offset), + (find_seek_offset_bytes), (find_seek_offset_time), + (gst_rmdemux_perform_seek), (gst_rmdemux_src_query), + (gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible), + (gst_rmdemux_chain), (gst_rmdemux_send_event), + (gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr), + (gst_rmdemux_parse_packet): + Fractional framerates. 2005-11-23 Jan Schmidt <th...@ma...> * ext/mpeg2dec/gstmpeg2dec.c: (src_templ), Index: rmdemux.c RCS file: /cvs/gstreamer/gst-plugins-ugly/gst/realmedia/rmdemux.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- rmdemux.c 22 Nov 2005 11:55:32 -0000 1.54 +++ rmdemux.c 23 Nov 2005 00:26:42 -0000 1.55 @@ -52,7 +52,8 @@ int sample_index; GstRMDemuxIndex *index; int index_length; - double frame_rate; + gint framerate_numerator; + gint framerate_denominator; guint32 seek_offset; guint16 width; @@ -432,6 +433,9 @@ int i, n; gboolean ret = FALSE; + if (target < 0) + return FALSE; for (n = 0; n < rmdemux->n_streams; n++) { GstRMDemuxStream *stream; @@ -547,8 +551,8 @@ /* For each stream, find the first index offset equal to or before our seek * target. Of these, find the smallest offset. That's where we seek to. * - * Then we pull 4 bytes from that offset, validate that we've seeked to a - * DATA chunk (with the DATA fourcc). + * Then we pull 4 bytes from that offset, and validate that we've seeked to a + * what looks like a plausible packet. * If that fails, restart, with the seek target set to one less than the * offset we just tried. If we run out of places to try, treat that as a fatal * error. @@ -627,11 +631,14 @@ case GST_QUERY_POSITION: GST_DEBUG_OBJECT (rmdemux, "src_query position"); gst_query_set_position (query, GST_FORMAT_TIME, -1); //rmdemux->cur_timestamp, + GST_DEBUG_OBJECT (rmdemux, "Position query: no idea from demuxer!"); break; case GST_QUERY_DURATION: GST_DEBUG_OBJECT (rmdemux, "src_query duration"); gst_query_set_duration (query, GST_FORMAT_TIME, //rmdemux->cur_timestamp, rmdemux->duration); + GST_DEBUG_OBJECT (rmdemux, "Duration query: set to %lld in demuxer", + rmdemux->duration); default: res = FALSE; @@ -1233,7 +1240,8 @@ gst_caps_set_simple (stream->caps, "width", G_TYPE_INT, stream->width, "height", G_TYPE_INT, stream->height, - "framerate", G_TYPE_DOUBLE, stream->frame_rate, NULL); + "framerate", GST_TYPE_FRACTION, stream->framerate_numerator, + stream->framerate_denominator, NULL); } rmdemux->n_video_streams++; @@ -1530,14 +1538,27 @@ stream->format = RMDEMUX_GUINT32_GET (data + offset + 30); stream->extra_data_size = length - (offset + 34); stream->extra_data = (guint8 *) data + offset + 34; - stream->frame_rate = (double) RMDEMUX_GUINT16_GET (data + offset + 22) + - ((double) RMDEMUX_GUINT16_GET (data + offset + 24) / 65536.0); + /* Natural way to represent framerates here requires unsigned 32 bit + * numerator, which we don't have. For the nasty case, approximate... + */ + { + guint32 numerator = RMDEMUX_GUINT16_GET (data + offset + 22) * 65536 + + RMDEMUX_GUINT16_GET (data + offset + 24); + if (numerator > G_MAXINT) { + stream->framerate_numerator = (gint) (numerator >> 1); + stream->framerate_denominator = 32768; + } else { + stream->framerate_numerator = (gint) numerator; + stream->framerate_denominator = 65536; + } + } GST_DEBUG_OBJECT (rmdemux, "Video stream with fourcc=%" GST_FOURCC_FORMAT - " width=%d height=%d rate=%d frame_rate=%f subformat=%x format=%x extra_data_size=%d", + " width=%d height=%d rate=%d framerate=%d/%d subformat=%x format=%x extra_data_size=%d", GST_FOURCC_ARGS (stream->fourcc), stream->width, stream->height, - stream->rate, stream->frame_rate, stream->subformat, stream->format, + stream->rate, stream->framerate_numerator, + stream->framerate_denominator, stream->subformat, stream->format, stream->extra_data_size); case GST_RMDEMUX_STREAM_AUDIO:{ @@ -1697,11 +1718,11 @@ rmdemux->cur_timestamp = RMDEMUX_GUINT32_GET (data + 2) * GST_MSECOND; GST_DEBUG_OBJECT (rmdemux, - "Parsing a packet for stream=%d, timestamp=" GST_TIME_FORMAT + "Parsing a packet for stream=%d, timestamp=%" GST_TIME_FORMAT ", version=%d", id, GST_TIME_ARGS (rmdemux->cur_timestamp), version); - // TODO: This is skipping over either 2 or 3 bytes (version dependent) - // without even reading it. What are these for? + // TODO: We read 6 bytes previously; this is skipping over either 2 or 3 + // bytes (version dependent) // without even reading it. What are these for? if (version == 0) { data += 8; packet_size = length - 8; |