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 732939 - wavenc doesn't create a proper header for data from omxaacdec
wavenc doesn't create a proper header for data from omxaacdec
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-omx
1.2.4
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-07-09 08:45 UTC by Jun Ji
Modified: 2018-11-03 13:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
header created by wavenc that makes the whole file noise. (12.04 KB, text/plain)
2014-07-09 11:03 UTC, Jun Ji
Details
working header (12.04 KB, text/plain)
2014-07-09 11:04 UTC, Jun Ji
Details
filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink (12.04 KB, text/plain)
2014-07-09 12:59 UTC, Jun Ji
Details
filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink (358.64 KB, text/x-log)
2014-07-09 13:02 UTC, Jun Ji
Details
filesrc ! aacparse ! avdec_aac ! audioconvert ! wavenc ! filesink (4.25 KB, text/x-log)
2014-07-09 13:40 UTC, Jun Ji
Details
filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink (76.41 KB, text/x-log)
2014-07-09 14:11 UTC, Jun Ji
Details
filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink (43.01 KB, text/x-log)
2014-07-10 07:44 UTC, Jun Ji
Details
gst-launch-1.0 filesrc location=/441kHz_stereo.aac ! aacparse ! omxaacdec ! audioconvert ! wavenc ! wavparse ! alsasink -v --gst-debug=*CAPS*:6,*audiocon vert*:6,*omx*:6 (402.25 KB, text/x-log)
2014-07-14 01:56 UTC, Jun Ji
Details
gst-launch-1.0 filesrc location=/temp/22050_6ch.aac ! aacparse ! omxaacd ec ! audioconvert ! wavenc ! wavparse ! alsasink --gst-debug=*:6 (323.70 KB, text/plain)
2014-07-14 07:23 UTC, Jun Ji
Details

Description Jun Ji 2014-07-09 08:45:36 UTC
on my msm89x6, omxaacdec creates an wav data w/o its header and given a proper wav header, the file is played correctly.

However, when the wav data gets an header made by wavenc, the wav file becomes complete noise. (even not able to feel what the original should sound like)

I attach the two files, one with the working header and one with not, created by filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink.
Comment 1 Jun Ji 2014-07-09 08:50:57 UTC
turned out that bugzilla limits the file size so I have to create other sample cases smaller than what I tested.
Comment 2 Jun Ji 2014-07-09 11:03:16 UTC
I just attached the first parts of each file.
Comment 3 Jun Ji 2014-07-09 11:03:57 UTC
Created attachment 280226 [details]
header created by wavenc that makes the whole file noise.
Comment 4 Jun Ji 2014-07-09 11:04:38 UTC
Created attachment 280227 [details]
working header
Comment 5 Jun Ji 2014-07-09 12:59:44 UTC
Created attachment 280259 [details]
filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink
Comment 6 Jun Ji 2014-07-09 13:02:05 UTC
Created attachment 280260 [details]
filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink

the log generated by filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink, currently creating not-working wav header.
Comment 7 Nicolas Dufresne (ndufresne) 2014-07-09 13:13:21 UTC
One thing we notice, is that the input caps have 6 channels, the decoder sets the caps to 6 channels, and then reset it to 2 channels. wavenc receives header with two channels. Something here is not going right. Does the duration of the broken wav file differ ? (e.g. 3 times longer)
Comment 8 Jun Ji 2014-07-09 13:26:44 UTC
the file with a broken wav header sounds that human can't even distinguish. it's like a tv noise you hear when the tv channel isn't aired..
Comment 9 Jun Ji 2014-07-09 13:40:36 UTC
Created attachment 280269 [details]
filesrc ! aacparse ! avdec_aac ! audioconvert ! wavenc ! filesink

not logged in the attached file but it also says,


/temp # gst-launch-1.0 filesrc location=/temp/test_qc.aac ! aacparse ! avdec_aac
  ! audioconvert ! wavenc ! filesink location=/temp/test2.wav -v >> ./avdec_aac_
audioconvert_wavenc.log
0:00:00.282700469  1513   0x155800 ERROR                  libav :0:: channel element 0.0 is not allocated

(gst-launch-1.0:1513): GStreamer-WARNING **: gstpad.c:4652:store_sticky_event:<avdec_aac0:src> Sticky event misordering, got 'segment' before 'caps'

(gst-launch-1.0:1513): GStreamer-WARNING **: gstpad.c:4652:store_sticky_event:<audioconvert0:src> Sticky event misordering, got 'segment' before 'caps'

(gst-launch-1.0:1513): GStreamer-WARNING **: gstpad.c:4652:store_sticky_event:<wavenc0:sink> Sticky event misordering, got 'segment' before 'caps'

(gst-launch-1.0:1513): GStreamer-WARNING **: gstpad.c:4652:store_sticky_event:<audioconvert0:sink> Sticky event misordering, got 'segment' before 'caps'
Comment 10 Nicolas Dufresne (ndufresne) 2014-07-09 13:56:03 UTC
In this "working" scenario, audioconvert will convert from 6 channels to 1 channels, and pass that to waveenc. This does not seem optimal, but wavenc only support 1 or 2 channels. Note that playing a 6 channel audio stream as if it was 2 channels will sound like noise, and nothing else.

So the problem is in gst-omx, or patches you have applied to it.
Comment 11 Jun Ji 2014-07-09 14:11:12 UTC
Created attachment 280272 [details]
filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink

this gstomxaacdec.c is what I made based on gstomxmp3dec.c and possibly wrong.


static void
gst_omx_aac_dec_class_init (GstOMXAACDecClass * klass)
{
  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
  GstOMXAudioDecClass *audiodec_class = GST_OMX_AUDIO_DEC_CLASS (klass);

  audiodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_aac_dec_set_format);
  audiodec_class->is_format_change =
      GST_DEBUG_FUNCPTR (gst_omx_aac_dec_is_format_change);
  audiodec_class->get_samples_per_frame =
      GST_DEBUG_FUNCPTR (gst_omx_aac_dec_get_samples_per_frame);

  audiodec_class->cdata.default_sink_template_caps = "audio/mpeg, "
      "mpegversion=(int)[2,4],"
      "rate=(int)[8000,48000], "
      "channels=(int)[1,2], " "parsed=(boolean) true";


  gst_element_class_set_static_metadata (element_class,
      "OpenMAX AAC Audio Decoder",
      "Codec/Decoder/Audio",
      "Decode AAC audio streams",
      "Sebastian Dröge <sebastian@centricular.com>");

  gst_omx_set_default_role (&audiodec_class->cdata, "audio_decoder.aac");
}
Comment 12 Nicolas Dufresne (ndufresne) 2014-07-09 15:11:24 UTC
(In reply to comment #11)
> Created an attachment (id=280272) [details]
> filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink
> 
> this gstomxaacdec.c is what I made based on gstomxmp3dec.c and possibly wrong.
> 
> 
> static void
> gst_omx_aac_dec_class_init (GstOMXAACDecClass * klass)
> {
>   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
>   GstOMXAudioDecClass *audiodec_class = GST_OMX_AUDIO_DEC_CLASS (klass);
> 
>   audiodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_aac_dec_set_format);
>   audiodec_class->is_format_change =
>       GST_DEBUG_FUNCPTR (gst_omx_aac_dec_is_format_change);
>   audiodec_class->get_samples_per_frame =
>       GST_DEBUG_FUNCPTR (gst_omx_aac_dec_get_samples_per_frame);
> 
>   audiodec_class->cdata.default_sink_template_caps = "audio/mpeg, "
>       "mpegversion=(int)[2,4],"
>       "rate=(int)[8000,48000], "
>       "channels=(int)[1,2], " "parsed=(boolean) true";

I don't think a decoder should set parsed=true. Also, in your test file, you have 6 channels, while your class only supports up to 2. Negotiation should simply fail.
Comment 13 Jun Ji 2014-07-10 02:29:12 UTC
OK, I just changed it to have same sinkcap with avdec_aac so no negotiation issue happens now.

What I still don't understand is that avdec_aac generates wav from the same test aac file that has 6 channels but the wav gets an working wav header by wavenc supposed to support only 1,2 channels.

the rest of the pipeline is totally same except for the decoder element.

- filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc

- filesrc ! aacparse ! avdec_aac ! audioconvert ! wavenc


so does it mean that avdec_aac internally does something more to convert stream so that the stream can work with wavenc?

I don't see related parts for this in avdec_aac but just am suspecting.
Comment 14 Jun Ji 2014-07-10 02:34:47 UTC
I mean even converting the number of channels happens in audioconvert. wav file created by omxaacdec doesn't get an working header from wavenc.. isn't it weird?
Comment 15 Jun Ji 2014-07-10 05:45:49 UTC
stormer, sorry that I didn't understand what you said so far.

---------------------------------------------
One thing we notice, is that the input caps have 6 channels, the decoder sets
the caps to 6 channels, and then reset it to 2 channels. wavenc receives header
with two channels. Something here is not going right. Does the duration of the
broken wav file differ ? (e.g. 3 times longer)
---------------------------------------------

=> this is correct. I'll look into the code and find why it changes channels.
Thanks.
Comment 16 Jun Ji 2014-07-10 07:44:32 UTC
Created attachment 280340 [details]
filesrc ! aacparse ! omxaacdec ! audioconvert ! wavenc ! filesink

This is what happens between the two output settings. Also I confirmed that for this omx audio decoder, I haven't made any change on slomo's original except for gstomxaacdec.c that I made based on gstomxaacmp3.c
Comment 17 Sebastian Dröge (slomo) 2014-07-10 07:49:02 UTC
This looks like a caps negotiation problem somewhere... the log only shows failed attempts of "audioconvert ! wavenc" to negotiate, no succeeded attempt... but nonetheless data is sent to wavenc.

If you use e.g. matroskamux instead of wavenc, does it work better? wavenc has no multichannel support and there seems to be something going wrong in audioconvert here at this point.
Comment 18 Jun Ji 2014-07-10 07:50:16 UTC
it seems that the second output setting happens because there is a moment that
satisfies the condition port->port_def.eDir == OMX_DirOutput &&
port->settings_cookie != port->configured_settings_cookie in
gst_omx_port_acquire_buffer() so that it returns
GST_OMX_ACQUIRE_BUFFER_RECONFIGURE.
Comment 19 Sebastian Dröge (slomo) 2014-07-10 07:52:25 UTC
Also the caps set on the decoder srcpad are not exactly ideal:
audio/x-raw, format=(string)S16BE, layout=(string)interleaved, rate=(int)22050, channels=(int)6, channel-mask=(bitmask)0x0000000000000000

A channel mask full of zeroes here means that we have an undefined channel layout. Either the openmax component didn't tell us any channel layout (bad!) or there is a bug in the code to convert openmax layouts to gstreamer ones.
Comment 20 Jun Ji 2014-07-10 07:57:22 UTC
no luck with matroskamux.

filesrc ! aacparse ! omxaacdec ! audioconvert ! matroskamux ! filesink

gst-typedef identifies the output as audio/x-matroska and when I play the file with playbin, the sound is the same noise.
Comment 22 Jun Ji 2014-07-10 08:34:36 UTC
however, the qc code gives channels, samplerate and etc fixed values.. but works.. confusing..
Comment 23 Jun Ji 2014-07-10 09:42:26 UTC
slomo, what should I do first? if omxaacdec doesn't do second output setting, the channel 6 and samplerate 22050 will be passed to the next as avdec_aac does and the problem would be fixed?
Comment 24 Sebastian Dröge (slomo) 2014-07-10 12:38:44 UTC
This fixes the bug in wavenc, nonetheless there is also something wrong in gst-omx here. It only fails properly now instead of creating broken files.

commit dd5144fd4ef5cfb1ee45d4009ea2bc4775395874
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Thu Jul 10 12:10:45 2014 +0200

    wavenc: Return not-negotiated if we got no caps or caps negotiation failed
    
    And do it always, not inside a g_return_val_if_fail().
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=732939
Comment 25 Sebastian Dröge (slomo) 2014-07-10 12:40:23 UTC
omxaacdec should probably hardcode a channel layout (using the standard AAC channel layouts) if the component does not provide any useful information about it. Then it should work.
Comment 26 Nicolas Dufresne (ndufresne) 2014-07-10 13:20:17 UTC
Ah, I see I see, without layout, audioconvert can't really do the 6 -> 2 conversion.
Comment 27 Jun Ji 2014-07-11 02:14:21 UTC
Thank you for the guide, slomo. I should start from learning channel-mask but can't find how gst-omx handles channel-mask.. nothing is found by grep 'channel-mask' whereas you mentioned that 'there is a bug in the code to convert openmax layouts to gstreamer ones.'

Could you please tell me where the code to convert openmax layouts to gstreamer ones is?
Comment 28 Jun Ji 2014-07-13 03:24:33 UTC
This is msm8926 and I found the below.

1. when it calls OMX_SetParameter( , OMX_IndexParamAudioAac, ) the values set are correctly shown again by OMX_GetParameter(); (nPortIndex is 0);

2. However, for a reason, OMX_EventPortSettingsChanged happens and the port forgets the values and gives me back values that look like default settings. (rate 44100, channel 2).

3. This is a serious problem, right? why OMX_EventPortSettingsChanged is called and is it normal that after OMX_EventPortSettingsChanged, nPortIndex 0 loses setting values??


I'm trying to figure out more..
Comment 29 Jun Ji 2014-07-13 03:29:20 UTC
ah, for the comment #28, the code I looked into was qc's sample code. FYI
Comment 30 Sebastian Dröge (slomo) 2014-07-13 07:50:18 UTC
(In reply to comment #28)
> This is msm8926 and I found the below.
> 
> 1. when it calls OMX_SetParameter( , OMX_IndexParamAudioAac, ) the values set
> are correctly shown again by OMX_GetParameter(); (nPortIndex is 0);
> 
> 2. However, for a reason, OMX_EventPortSettingsChanged happens and the port
> forgets the values and gives me back values that look like default settings.
> (rate 44100, channel 2).
> 
> 3. This is a serious problem, right? why OMX_EventPortSettingsChanged is called
> and is it normal that after OMX_EventPortSettingsChanged, nPortIndex 0 loses
> setting values??

Yes, this is a bug in QCOM's code... that we should nonetheless try to workaround by providing some sensible default channel layouts.


Did you ever try a stereo file though? Those should give much less problems :)
Comment 31 Jun Ji 2014-07-13 08:11:47 UTC
1. so OMX_EventPortSettingsChanged is not called properly?

2. the default channel layouts you mentioned must be set whenever the event occurred so that the port of the nPortIndex 0 forgot the intended values?

3. it's another problem to encode an wav file to an aac.

gst-launch-1.0 filesrc location=[.wav]
! wavparse ! avenc_aac ! filesink location=[.aac]


gst-launch-1.0 filesrc location=[.wav]
! wavparse ! omxaacenc ! filesink location=[.aac]


The ouputs from the above two commands can't be identified by gst-typedef saying 'FAILED: unknown error', even 'aacparse' is appended.

But, appending 'qtmux' makes them to generate correct audio files in video/quicktime and playbin plays them well.

Am I missing something to create an aac file?
Comment 32 Sebastian Dröge (slomo) 2014-07-13 08:16:26 UTC
(In reply to comment #31)
> 1. so OMX_EventPortSettingsChanged is not called properly?

It's probably called properly... but the port must not forget all its settings. Instead it should tell us the correct settings it is using now after the settings-changed event.

> 2. the default channel layouts you mentioned must be set whenever the event
> occurred so that the port of the nPortIndex 0 forgot the intended values?

Yes, as a workaround when we get an invalid channel layout.

Also the channel layout should be on the output port, so nPortIndex 1!


> 3. it's another problem to encode an wav file to an aac.
> 
> gst-launch-1.0 filesrc location=[.wav]
> ! wavparse ! avenc_aac ! filesink location=[.aac]
> 
> 
> gst-launch-1.0 filesrc location=[.wav]
> ! wavparse ! omxaacenc ! filesink location=[.aac]
> 
> 
> The ouputs from the above two commands can't be identified by gst-typedef
> saying 'FAILED: unknown error', even 'aacparse' is appended.
> 
> But, appending 'qtmux' makes them to generate correct audio files in
> video/quicktime and playbin plays them well.
> 
> Am I missing something to create an aac file?

Raw AAC files are generally not very well supported. Usually you would put AAC into an MP4 container with mp4mux.
Comment 33 Jun Ji 2014-07-13 08:21:52 UTC
(In reply to comment #32)
> (In reply to comment #31)
> > 1. so OMX_EventPortSettingsChanged is not called properly?
> 
> It's probably called properly... but the port must not forget all its settings.
> Instead it should tell us the correct settings it is using now after the
> settings-changed event.
> 
> > 2. the default channel layouts you mentioned must be set whenever the event
> > occurred so that the port of the nPortIndex 0 forgot the intended values?
> 
> Yes, as a workaround when we get an invalid channel layout.
> 
> Also the channel layout should be on the output port, so nPortIndex 1!
> 
> 
> > 3. it's another problem to encode an wav file to an aac.
> > 
> > gst-launch-1.0 filesrc location=[.wav]
> > ! wavparse ! avenc_aac ! filesink location=[.aac]
> > 
> > 
> > gst-launch-1.0 filesrc location=[.wav]
> > ! wavparse ! omxaacenc ! filesink location=[.aac]
> > 
> > 
> > The ouputs from the above two commands can't be identified by gst-typedef
> > saying 'FAILED: unknown error', even 'aacparse' is appended.
> > 
> > But, appending 'qtmux' makes them to generate correct audio files in
> > video/quicktime and playbin plays them well.
> > 
> > Am I missing something to create an aac file?
> 
> Raw AAC files are generally not very well supported. Usually you would put AAC
> into an MP4 container with mp4mux.

Right.. so it was hard to get aac file to test. That's right that other test sample with different channel would be helpful to finish this work. Let me try searching again.
Comment 34 Jun Ji 2014-07-13 08:43:43 UTC
ah.. qc's sample code doesn't set OMX_IndexParamAudioPcm but only gets values from it. So what I thought first is that when the inport gets some value by OMX_IndexParamAudioAac, then somehow OMX passes its value to OMX_IndexParamAudioPcm automatically. But gst-omx does set OMX_IndexParamAudioPcm separately so it makes me confusing.
Comment 35 Sebastian Dröge (slomo) 2014-07-13 08:48:38 UTC
Are we talking about the encoder or the decoder now? The decoder only gets OMX_IndexParamAudioPcm in the code I have here (to know what the decoder component will output), while the encoder only sets OMX_IndexParamAudioPcm (to tell the encoder component what data it will soon get).
Comment 36 Jun Ji 2014-07-13 09:21:58 UTC
it's about the decoder :) and you're right. it was my mistake that was confused between gstomxaudioenc.c and gstomxaudiodec.c

I see. Decoder only gets OMX_IndexParamAudioPcm..

if start again from the beginnig,, what's happening on msm8926 is that

1. set OMX_IndexParamAudioAac with attributes of the input wav file, for now, rate 22050 and ch #6.
2. regardless of the values, OMX_IndexParamAudioPcm return 44100 and 2
3. after reconfiguration of the OUTPORT, OMX_IndexParamAudioAac (inport) forgets the initially set value but gives back 44100 and 2. Omx_IndexParamAudioPcm also shows 44100 and 2 as it does from the beginning.


My question, if it normally works, what should be the rate and channels of OMX_IndexParamAudioPcm when the device sets OMX_IndexParamAudioAac with rate 22050 and ch #6 as the current test does??

On my second thought, possibly nothing goes wrong but just I'm misunderstanding things..
Comment 37 Sebastian Dröge (slomo) 2014-07-13 09:35:39 UTC
(In reply to comment #36)

> 1. set OMX_IndexParamAudioAac with attributes of the input wav file, for now,
> rate 22050 and ch #6.
> 2. regardless of the values, OMX_IndexParamAudioPcm return 44100 and 2
> 3. after reconfiguration of the OUTPORT, OMX_IndexParamAudioAac (inport)
> forgets the initially set value but gives back 44100 and 2.

This is a bug.

> Omx_IndexParamAudioPcm also shows 44100 and 2 as it does from the beginning.
> 
> 
> My question, if it normally works, what should be the rate and channels of
> OMX_IndexParamAudioPcm when the device sets OMX_IndexParamAudioAac with rate
> 22050 and ch #6 as the current test does??

It should probably contain some PCM format with 22050Hz sampling rate, 6 channels and some sensible channel layout. The other values in the PCM format depend on the exact codec.

Can you please try if it works with a stereo, 44.1kHz AAC file? :)
Comment 38 Jun Ji 2014-07-14 01:56:45 UTC
Created attachment 280614 [details]
gst-launch-1.0 filesrc location=/441kHz_stereo.aac ! aacparse ! omxaacdec  ! audioconvert ! wavenc ! wavparse ! alsasink -v --gst-debug=*CAPS*:6,*audiocon vert*:6,*omx*:6

unfortunately 44.1kHz stereo AAC also isn't played well. but the width is much more recognizable than the previous 22050 & 6 channel one. I'll keep working on it.
Comment 39 Jun Ji 2014-07-14 03:04:39 UTC
I found that right after OMX_SetParameter(,OMX_IndexParamAudioAac,), OMX_IndexParamAudioPcm sends back the same rate and ch # that OMX_IndexParamAudioAac was given.

so currently OMX_EventPortSettingsChanged looks like the bad one that makes the both ports reset to have 44100 and 2.

Have no idea why this bug is not recognized yet.. probably this decoder hasn't been used on Android.
Comment 40 Jun Ji 2014-07-14 07:23:06 UTC
Created attachment 280627 [details]
gst-launch-1.0 filesrc location=/temp/22050_6ch.aac ! aacparse ! omxaacd ec ! audioconvert ! wavenc ! wavparse ! alsasink --gst-debug=*:6

with the gst-omx 08385fe94425cb935f22dfa8cb399ac5589cbab0
Comment 41 Julien Isorce 2017-12-04 16:45:30 UTC
The second OMX_EventPortSettingsChanged on omxaacdec's output port is fine because
"OMX.qcom.audio.decoder.multiaac" detects 6 which is different from the 2 channels configured though aacparse.
Since aacparse has not detected this change, the "qcom" decoder is probably wrong.

Please try against gstreamer 1.12, if you can still reproduce the problem should you attach 22050_6ch.aac and 441kHz_stereo.aac.
Comment 42 GStreamer system administrator 2018-11-03 13:00:05 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-omx/issues/3.