avimux: Actually store the largest audio chunk size for the VBR case of MP2/MP3
authorSebastian Dröge <sebastian@centricular.com>
Wed, 27 Apr 2016 10:53:00 +0000 (13:53 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 27 Apr 2016 10:54:31 +0000 (13:54 +0300)
3ea338ce271e1f6a96d2ed49d4472b091f6f8b7e changed avimux to do that, but it
never actually kept track of the max audio chunk for MP3 and MP2. These are
knowing the hdr.scale only after parsing the frames instead of at setcaps
time.

gst/avi/gstavimux.c

index 222d863..b28a017 100644 (file)
@@ -643,6 +643,9 @@ refuse_caps:
   }
 }
 
+static void gst_avi_mux_audsink_set_fields (GstAviMux * avimux,
+    GstAviAudioPad * avipad);
+
 static GstFlowReturn
 gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
     GstBuffer * buffer)
@@ -687,9 +690,10 @@ gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
     spf = 576;
   }
 
-  if (G_UNLIKELY (avipad->hdr.scale <= 1))
+  if (G_UNLIKELY (avipad->hdr.scale <= 1)) {
     avipad->hdr.scale = spf;
-  else if (G_UNLIKELY (avipad->hdr.scale != spf)) {
+    gst_avi_mux_audsink_set_fields (avimux, (GstAviAudioPad *) avipad);
+  } else if (G_UNLIKELY (avipad->hdr.scale != spf)) {
     GST_WARNING_OBJECT (avimux, "input mpeg audio has varying frame size");
     goto cbr_fallback;
   }
@@ -708,6 +712,7 @@ cbr_fallback:
   {
     GST_WARNING_OBJECT (avimux, "falling back to CBR muxing");
     avipad->hdr.scale = 1;
+    gst_avi_mux_audsink_set_fields (avimux, (GstAviAudioPad *) avipad);
     /* no need to check further */
     avipad->hook = NULL;
     goto done;