~ubuntu-branches/ubuntu/dapper/gst-plugins-ugly0.10/dapper

« back to all changes in this revision

Viewing changes to debian/patches/01_mad-bytes-duration-query-fix.patch

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-05-14 17:57:16 UTC
  • Revision ID: james.westby@ubuntu.com-20060514175716-dx7c37tml27hy62f
Tags: 0.10.3-0ubuntu3
* debian/patches/01_mad-bytes-duration-query-fix.patch:
  + Fix BYTES and DEFAULT duration queries in mad
* debian/patches/02_mad-id3tag-fix-writing.patch:
  + Fix writing of ID3 tags with the mad element
* debian/patches/03_mpeg2dec-crop-correctly.patch:
  + When cropping mpeg2 videos make it correctly so downstream can work with
    it and doesn't fail because of weird sizes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
===================================================================
 
2
RCS file: /srv/anoncvs.freedesktop.org/cvs/gstreamer/gst-plugins-ugly/ext/mad/gstmad.c,v
 
3
rcsdiff: /srv/anoncvs.freedesktop.org/cvs/gstreamer/gst-plugins-ugly/ext/mad/gstmad.c,v: warning: Unknown phrases like `commitid ...;' are present.
 
4
retrieving revision 1.155
 
5
retrieving revision 1.157
 
6
diff -u -r1.155 -r1.157
 
7
--- gst-plugins-ugly/ext/mad/gstmad.c   2006/04/09 18:09:39     1.155
 
8
+++ gst-plugins-ugly/ext/mad/gstmad.c   2006/04/21 20:37:43     1.157
 
9
@@ -437,6 +437,11 @@
 
10
   gboolean res = TRUE;
 
11
   GstMad *mad;
 
12
 
 
13
+  if (src_format == *dest_format) {
 
14
+    *dest_value = src_value;
 
15
+    return TRUE;
 
16
+  }
 
17
+
 
18
   mad = GST_MAD (GST_PAD_PARENT (pad));
 
19
 
 
20
   if (mad->vbr_average == 0)
 
21
@@ -480,6 +485,11 @@
 
22
   gint bytes_per_sample;
 
23
   GstMad *mad;
 
24
 
 
25
+  if (src_format == *dest_format) {
 
26
+    *dest_value = src_value;
 
27
+    return TRUE;
 
28
+  }
 
29
+
 
30
   mad = GST_MAD (GST_PAD_PARENT (pad));
 
31
 
 
32
   bytes_per_sample = MAD_NCHANNELS (&mad->frame.header) * 4;
 
33
@@ -498,7 +508,8 @@
 
34
 
 
35
           if (byterate == 0)
 
36
             return FALSE;
 
37
-          *dest_value = src_value * GST_SECOND / byterate;
 
38
+          *dest_value =
 
39
+              gst_util_uint64_scale_int (src_value, GST_SECOND, byterate);
 
40
           break;
 
41
         }
 
42
         default:
 
43
@@ -513,7 +524,8 @@
 
44
         case GST_FORMAT_TIME:
 
45
           if (mad->frame.header.samplerate == 0)
 
46
             return FALSE;
 
47
-          *dest_value = src_value * GST_SECOND / mad->frame.header.samplerate;
 
48
+          *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND,
 
49
+              mad->frame.header.samplerate);
 
50
           break;
 
51
         default:
 
52
           res = FALSE;
 
53
@@ -525,8 +537,8 @@
 
54
           scale = bytes_per_sample;
 
55
           /* fallthrough */
 
56
         case GST_FORMAT_DEFAULT:
 
57
-          *dest_value =
 
58
-              src_value * scale * mad->frame.header.samplerate / GST_SECOND;
 
59
+          *dest_value = gst_util_uint64_scale_int (src_value,
 
60
+              scale * mad->frame.header.samplerate, GST_SECOND);
 
61
           break;
 
62
         default:
 
63
           res = FALSE;
 
64
@@ -599,18 +611,19 @@
 
65
     }
 
66
     case GST_QUERY_DURATION:
 
67
     {
 
68
-      GstFormat format;
 
69
-      GstFormat rformat;
 
70
+      GstFormat bytes_format = GST_FORMAT_BYTES;
 
71
+      GstFormat time_format = GST_FORMAT_TIME;
 
72
+      GstFormat req_format;
 
73
       gint64 total, total_bytes;
 
74
 
 
75
       /* save requested format */
 
76
-      gst_query_parse_duration (query, &format, NULL);
 
77
+      gst_query_parse_duration (query, &req_format, NULL);
 
78
 
 
79
       if (peer == NULL)
 
80
         goto error;
 
81
 
 
82
       /* try any demuxer before us first */
 
83
-      if (format == GST_FORMAT_TIME && gst_pad_query (peer, query)) {
 
84
+      if (req_format == GST_FORMAT_TIME && gst_pad_query (peer, query)) {
 
85
         gst_query_parse_duration (query, NULL, &total);
 
86
         GST_LOG_OBJECT (mad, "peer returned duration %" GST_TIME_FORMAT,
 
87
             GST_TIME_ARGS (total));
 
88
@@ -618,43 +631,35 @@
 
89
       }
 
90
 
 
91
       /* query peer for total length in bytes */
 
92
-      gst_query_set_duration (query, GST_FORMAT_BYTES, -1);
 
93
-
 
94
-      if (!gst_pad_query (peer, query)) {
 
95
-        GST_LOG_OBJECT (mad, "query on peer pad failed");
 
96
+      if (!gst_pad_query_peer_duration (mad->sinkpad, &bytes_format,
 
97
+              &total_bytes) || total_bytes <= 0) {
 
98
+        GST_LOG_OBJECT (mad, "duration query on peer pad failed");
 
99
         goto error;
 
100
       }
 
101
 
 
102
-      /* get the returned format */
 
103
-      gst_query_parse_duration (query, &rformat, &total_bytes);
 
104
-      if (rformat == GST_FORMAT_BYTES) {
 
105
-        GST_LOG_OBJECT (mad, "peer pad returned total=%lld bytes", total_bytes);
 
106
-      } else if (rformat == GST_FORMAT_TIME) {
 
107
-        GST_LOG_OBJECT (mad, "peer pad returned total time=%", GST_TIME_FORMAT,
 
108
-            GST_TIME_ARGS (total_bytes));
 
109
-      }
 
110
-
 
111
-      /* Check if requested format is returned format */
 
112
-      if (format == rformat)
 
113
-        return TRUE;
 
114
+      GST_LOG_OBJECT (mad, "peer pad returned total=%" G_GINT64_FORMAT
 
115
+          " bytes", total_bytes);
 
116
 
 
117
-      if (total_bytes != -1) {
 
118
-        if (format != GST_FORMAT_BYTES) {
 
119
-          if (!gst_mad_convert_sink (pad, GST_FORMAT_BYTES, total_bytes,
 
120
-                  &format, &total))
 
121
-            goto error;
 
122
-        } else {
 
123
-          total = total_bytes;
 
124
-        }
 
125
-      } else {
 
126
-        total = -1;
 
127
+      if (!gst_mad_convert_sink (pad, GST_FORMAT_BYTES, total_bytes,
 
128
+              &time_format, &total)) {
 
129
+        GST_DEBUG_OBJECT (mad, "conversion BYTE => TIME failed");
 
130
+        goto error;
 
131
+      }
 
132
+      if (!gst_mad_convert_src (pad, GST_FORMAT_TIME, total,
 
133
+              &req_format, &total)) {
 
134
+        GST_DEBUG_OBJECT (mad, "conversion TIME => %s failed",
 
135
+            gst_format_get_name (req_format));
 
136
+        goto error;
 
137
       }
 
138
 
 
139
-      gst_query_set_duration (query, format, total);
 
140
-      if (format == GST_FORMAT_TIME) {
 
141
-        GST_LOG ("duration=%" GST_TIME_FORMAT, GST_TIME_ARGS (total));
 
142
+      gst_query_set_duration (query, req_format, total);
 
143
+
 
144
+      if (req_format == GST_FORMAT_TIME) {
 
145
+        GST_LOG_OBJECT (mad, "duration=%" GST_TIME_FORMAT,
 
146
+            GST_TIME_ARGS (total));
 
147
       } else {
 
148
-        GST_LOG ("duration=%" G_GINT64_FORMAT ", format=%u", total, format);
 
149
+        GST_LOG_OBJECT (mad, "duration=%" G_GINT64_FORMAT " (%s)",
 
150
+            gst_format_get_name (req_format));
 
151
       }
 
152
       break;
 
153
     }
 
154
@@ -1548,8 +1553,11 @@
 
155
           mad->total_samples = total;
 
156
           mad->last_ts = GST_CLOCK_TIME_NONE;
 
157
         }
 
158
-        time_offset = mad->total_samples * (GST_SECOND / mad->rate);
 
159
-        time_duration = (nsamples * (GST_SECOND / mad->rate));
 
160
+        time_offset =
 
161
+            gst_util_uint64_scale_int (mad->total_samples, GST_SECOND,
 
162
+            mad->rate);
 
163
+        time_duration =
 
164
+            gst_util_uint64_scale_int (nsamples, GST_SECOND, mad->rate);
 
165
       }
 
166
 
 
167
       if (mad->index) {
 
168