After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 769278 - aacparse: a few fixes and improvements for LOAS parsing
aacparse: a few fixes and improvements for LOAS parsing
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: 1.9.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-07-28 15:49 UTC by Vincent Penquerc'h
Modified: 2016-09-30 07:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
aacparse: a few fixes and improvements for LOAS parsing (7.18 KB, patch)
2016-07-28 15:50 UTC, Vincent Penquerc'h
none Details | Review
strip unneeded slack space (1.04 KB, patch)
2016-09-05 08:41 UTC, Vincent Penquerc'h
committed Details | Review
fix varlength integer reading (920 bytes, patch)
2016-09-05 08:41 UTC, Vincent Penquerc'h
committed Details | Review
improve rate/channel handling (2.52 KB, patch)
2016-09-05 08:42 UTC, Vincent Penquerc'h
none Details | Review
add comments in parsing code (1.25 KB, patch)
2016-09-05 08:42 UTC, Vincent Penquerc'h
committed Details | Review
clearer logs (1.38 KB, patch)
2016-09-05 08:42 UTC, Vincent Penquerc'h
committed Details | Review
more parsing (2.84 KB, patch)
2016-09-05 08:43 UTC, Vincent Penquerc'h
none Details | Review
improve rate/channel handling (5.62 KB, patch)
2016-09-06 09:41 UTC, Vincent Penquerc'h
none Details | Review
more parsing (2.68 KB, patch)
2016-09-06 13:53 UTC, Vincent Penquerc'h
committed Details | Review
improve rate/channel handling (4.63 KB, patch)
2016-09-06 14:07 UTC, Vincent Penquerc'h
committed Details | Review

Description Vincent Penquerc'h 2016-07-28 15:49:31 UTC
A bug in gst_aac_parse_latm_get_value (reading one fewer byte
than needed), a bit more parsing of the AudioSpecificConfig
structure, and keep track of the last parsed channels/rate
fields so they can be used even if the element was not yet
configured. Also some explanatory comments.
Comment 1 Vincent Penquerc'h 2016-07-28 15:50:09 UTC
Created attachment 332284 [details] [review]
aacparse: a few fixes and improvements for LOAS parsing
Comment 2 Sebastian Dröge (slomo) 2016-09-01 11:04:32 UTC
Review of attachment 332284 [details] [review]:

Can you link here to some sample files that your patch helps with? Also this sounds like it should be a few separate commits instead of one huge, looks ok otherwise

::: gst/audioparsers/gstaacparse.c
@@ +586,3 @@
+  (void) extension_audio_object_type;
+  (void) ps;
+  (void) sbr;

Not nice :)
Comment 3 Vincent Penquerc'h 2016-09-05 08:11:16 UTC
I don't have a sample where this helps :) I found those things while trying to make some sample work, but it turns out it's not LOAS but some other obscure type of AAC.

I'll split into several patches.

The casts are because I added parsing of more stuff, but there's tons of other stuff after that, and so these few variables aren't actually used (yet), so GCC would moan about it, and, you know, -Werror is being its usual party pooper. I could remove that extra parsing code, since I don't even know if it works, due to the no-LOAS-file thing above, but it seemed like it was adding something incremental that would be useful later.
Comment 4 Vincent Penquerc'h 2016-09-05 08:41:08 UTC
Created attachment 334767 [details] [review]
strip unneeded slack space
Comment 5 Vincent Penquerc'h 2016-09-05 08:41:37 UTC
Created attachment 334768 [details] [review]
fix varlength integer reading
Comment 6 Vincent Penquerc'h 2016-09-05 08:42:00 UTC
Created attachment 334769 [details] [review]
improve rate/channel handling
Comment 7 Vincent Penquerc'h 2016-09-05 08:42:24 UTC
Created attachment 334770 [details] [review]
add comments in parsing code
Comment 8 Vincent Penquerc'h 2016-09-05 08:42:47 UTC
Created attachment 334771 [details] [review]
clearer logs
Comment 9 Vincent Penquerc'h 2016-09-05 08:43:06 UTC
Created attachment 334772 [details] [review]
more parsing
Comment 10 Vincent Penquerc'h 2016-09-05 08:43:30 UTC
The one with the void casts is last, and can be omitted.
Comment 11 Sebastian Dröge (slomo) 2016-09-06 07:22:43 UTC
Comment on attachment 334769 [details] [review]
improve rate/channel handling

You probably want to reset these on FLUSH_STOP, PAUSED->READY, maybe new caps and other occasions.
Comment 12 Sebastian Dröge (slomo) 2016-09-06 07:26:10 UTC
Review of attachment 334772 [details] [review]:

::: gst/audioparsers/gstaacparse.c
@@ +568,3 @@
+      return FALSE;
+
+    if (audio_object_type == 22) {

How can we have audio_object_type == 5 || 29 above, and then here suddenly 22? Does get_audio_object_type() read it from a different place than where we got it before?

@@ +586,3 @@
+  (void) extension_audio_object_type;
+  (void) ps;
+  (void) sbr;

I'd rather comment these out. It's relatively common to do these things, but it's actually undefined C behaviour AFAIU. The compiler would be correct to just optimize away the whole function, call system("rm -rf /") or anything else here ;)
Comment 13 Vincent Penquerc'h 2016-09-06 09:41:13 UTC
Created attachment 334887 [details] [review]
improve rate/channel handling
Comment 14 Vincent Penquerc'h 2016-09-06 09:43:20 UTC
(In reply to Sebastian Dröge (slomo) from comment #12)

> +    if (audio_object_type == 22) {
> 
> How can we have audio_object_type == 5 || 29 above, and then here suddenly
> 22? Does get_audio_object_type() read it from a different place than where
> we got it before?

It reads from the bitstream every time, so it's a different place, yes. The spec for all that format here is fascinatingly complex (hence why a lot of it is left out).

> @@ +586,3 @@
> +  (void) extension_audio_object_type;
> +  (void) ps;
> +  (void) sbr;
> 
> I'd rather comment these out. It's relatively common to do these things, but
> it's actually undefined C behaviour AFAIU. The compiler would be correct to
> just optimize away the whole function, call system("rm -rf /") or anything
> else here ;)

Casting a rvalue to void is undefined behavior ?
Comment 15 Sebastian Dröge (slomo) 2016-09-06 11:00:05 UTC
Review of attachment 334887 [details] [review]:

::: gst/audioparsers/gstaacparse.c
@@ +1627,3 @@
+    aacparse->last_parsed_sample_rate = 0;
+  }
+  return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

This is equivalent to just doing it in _start(), no?
Comment 16 Sebastian Dröge (slomo) 2016-09-06 11:01:43 UTC
(In reply to Vincent Penquerc'h from comment #14)
> (In reply to Sebastian Dröge (slomo) from comment #12)
> 
> > +    if (audio_object_type == 22) {
> > 
> > How can we have audio_object_type == 5 || 29 above, and then here suddenly
> > 22? Does get_audio_object_type() read it from a different place than where
> > we got it before?
> 
> It reads from the bitstream every time, so it's a different place, yes. The
> spec for all that format here is fascinatingly complex (hence why a lot of
> it is left out).

Ok then :)

> > @@ +586,3 @@
> > +  (void) extension_audio_object_type;
> > +  (void) ps;
> > +  (void) sbr;
> > 
> > I'd rather comment these out. It's relatively common to do these things, but
> > it's actually undefined C behaviour AFAIU. The compiler would be correct to
> > just optimize away the whole function, call system("rm -rf /") or anything
> > else here ;)
> 
> Casting a rvalue to void is undefined behavior ?

AFAIK yes, but feel free to ignore me
Comment 17 Vincent Penquerc'h 2016-09-06 13:12:26 UTC
(In reply to Sebastian Dröge (slomo) from comment #15)
> Review of attachment 334887 [details] [review] [review]:
> 
> ::: gst/audioparsers/gstaacparse.c
> @@ +1627,3 @@
> +    aacparse->last_parsed_sample_rate = 0;
> +  }
> +  return GST_ELEMENT_CLASS (parent_class)->change_state (element,
> transition);
> 
> This is equivalent to just doing it in _start(), no?

I don't know. baseparse state change doesn't call start directly, but it might well be a side effect.
Comment 18 Vincent Penquerc'h 2016-09-06 13:16:28 UTC
(In reply to Sebastian Dröge (slomo) from comment #16)

> > Casting a rvalue to void is undefined behavior ?
> 
> AFAIK yes, but feel free to ignore me

If you have a reference, I'd like to see that. I can't find confirmation after a cursory search and it seems unlikely.
Comment 19 Tim-Philipp Müller 2016-09-06 13:27:21 UTC
Please use G_GNUC_UNUSED then instead of these void casts :)
Comment 20 Sebastian Dröge (slomo) 2016-09-06 13:47:52 UTC
(In reply to Vincent Penquerc'h from comment #18)
> (In reply to Sebastian Dröge (slomo) from comment #16)
> 
> > > Casting a rvalue to void is undefined behavior ?
> > 
> > AFAIK yes, but feel free to ignore me
> 
> If you have a reference, I'd like to see that. I can't find confirmation
> after a cursory search and it seems unlikely.

Found something in the C++ standard, which says you're right.
Comment 21 Vincent Penquerc'h 2016-09-06 13:53:21 UTC
Created attachment 334906 [details] [review]
more parsing
Comment 22 Sebastian Dröge (slomo) 2016-09-06 14:03:15 UTC
(In reply to Vincent Penquerc'h from comment #17)
> (In reply to Sebastian Dröge (slomo) from comment #15)
> > Review of attachment 334887 [details] [review] [review] [review]:
> > 
> > ::: gst/audioparsers/gstaacparse.c
> > @@ +1627,3 @@
> > +    aacparse->last_parsed_sample_rate = 0;
> > +  }
> > +  return GST_ELEMENT_CLASS (parent_class)->change_state (element,
> > transition);
> > 
> > This is equivalent to just doing it in _start(), no?
> 
> I don't know. baseparse state change doesn't call start directly, but it
> might well be a side effect.

My point was that start() is the perfect place for this. It's called upon pad activation, which is exactly the same in the end :) Can you move that there and remove the state change handler? And then merge
Comment 23 Vincent Penquerc'h 2016-09-06 14:07:27 UTC
Created attachment 334910 [details] [review]
improve rate/channel handling
Comment 24 Vincent Penquerc'h 2016-09-06 14:25:22 UTC
commit c974df1c061157f79124ec84c3e410ed05d2fff7
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Mon Sep 5 09:39:33 2016 +0100

    aacparse: parse a bit more of the humongous LOAS data
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769278

commit e66ee5491c308dfbb6f82956c567d91977d223eb
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Mon Sep 5 09:39:08 2016 +0100

    aacparse: make it clear when a potential LOAS frame is not one
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769278

commit b0f20bacfd66d0c5d04861ec2846ebb9a76d2ad9
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Mon Sep 5 09:38:26 2016 +0100

    aacparse: add a few comments to anchor parsing to the spec
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769278

commit 559546dd3a3715150eac270751620fffa359eaea
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Mon Sep 5 09:37:02 2016 +0100

    aacparse: improve channel/rate handling
    
    Keep track of the last parsed channels/rate fields so they can be
    used even if the element was not yet configured.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769278

commit 740749ac55f680ad61a328f86b595fa2837dd14c
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Mon Sep 5 09:35:53 2016 +0100

    aacparse: fix varlength number reading as per spec
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769278

commit 991e46ce421aa5e47c3d03d54bf9ad00e7c9a07a
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Mon Sep 5 09:35:02 2016 +0100

    aacparse: strip uneeded static arrays slack
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769278