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 760778 - avenc_* audio encoders have (bad) channel-mask for mono audio in sink pad template
avenc_* audio encoders have (bad) channel-mask for mono audio in sink pad tem...
Status: RESOLVED DUPLICATE of bug 759846
Product: GStreamer
Classification: Platform
Component: gst-libav
1.4.5
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-01-18 12:20 UTC by Nikita Yushchenko
Modified: 2016-01-18 13:43 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Nikita Yushchenko 2016-01-18 12:20:45 UTC
$ gst-inspect avenc_mp2
...
  SINK template: 'sink'
    Availability: Always
    Capabilities:
      audio/x-raw
           channel-mask: 0x0000000000000004
               channels: 1
                   rate: { 48000, 44100, 32000, 24000, 22050, 16000 }
                 layout: interleaved
                 format: S16LE
...

This combination (channels=1, channel-mask=0x4) is not pleased by alsasrc:

$ gst-launch alsasrc ! audioconvert ! avenc_mp2 ! filesink location=/dev/null
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock

** (gst-launch-1.0:492): CRITICAL **: file /home/jenkins/nikita/tke-build/build/
tmp/work/cortexa9hf-vfp-neon-mx6qdl-poky-linux-gnueabi/gstreamer1.0-plugins-base
/1.4.5-r0/gst-plugins-base-1.4.5/gst-libs/gst/audio/gstaudioringbuffer.c: line 1
963 (gst_audio_ring_buffer_set_channel_positions): should not be reached

What happens is:

- on target board audio input is single-channel,

- at caps negotiation time, gst_audio_ring_buffer_parse_caps() for alsasrc is called with caps originating from avenc_mp2 sink pad template,

- because channel-mask is defined, gst_audio_channel_positions_from_mask() is used to compute channel positions for audio ringbuffer; with channel-mask=0x4 this results into position[0] set to GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,

- later, gst_audio_ring_buffer_set_channel_positions() is called from alsasrc_parse_spec(); at this time alsa_position[alsa->channels-1] ipoint to GST_AUDIO_CHANNEL_POSITION_MONO and rignbuffer's position[0] is GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,

- gst_audio_ring_buffer_set_channel_positions() sees the difference nad calls gst_audio_get_channel_reorder_map(),

- gst_audio_get_channel_reorder_map() returns FALSE because it refuces to work with GST_AUDIO_CHANNEL_POSITION_MONO,

- this FALSE return causes the assertion failure.


As far as I understand, root cause of entire thing is that channel-mask should not be defined for channels=1.

Channel-mask property on avenc_mp2's sink pad template originates from gst_ff_aud_caps_new() in gst-libav:ext/libav/gstavcodecmap.c

This routine has two points where channel-mask property is added. First of these is under "if (context->channels > 1)" condition but second is not.

I guess something like below patch is needed

diff --git a/ext/libav/gstavcodecmap.c b/ext/libav/gstavcodecmap.c
index 0c53d10..398aedd 100644
--- a/ext/libav/gstavcodecmap.c
+++ b/ext/libav/gstavcodecmap.c
@@ -634,7 +634,8 @@ gst_ff_aud_caps_new (AVCodecContext * context, AVCodec * codec,
       while (*layouts) {
         gint nbits_set = get_nbits_set (*layouts);
 
-        if (gst_ffmpeg_channel_layout_to_gst (*layouts, nbits_set, pos)) {
+        if (nbits_set > 1 &&
+	     gst_ffmpeg_channel_layout_to_gst (*layouts, nbits_set, pos)) {
           guint64 mask;
 
           if (gst_audio_channel_positions_to_mask (pos, nbits_set, FALSE,

... although not sure.
Comment 1 Sebastian Dröge (slomo) 2016-01-18 13:43:05 UTC
This should be fixed by this already, please reopen otherwise

commit 8e466b73d89a1af18863222438cca1fcfac6c2ab
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Thu Dec 24 13:06:13 2015 +0100

    avcodecmap: Add special mapping for mono channel layouts
    
    In ffmpeg this is the same as FRONT_CENTER, but we distinguish between
    FRONT_CENTER and MONO in GStreamer. Add an explicit mapping for this special
    case in the translations functions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759846

*** This bug has been marked as a duplicate of bug 759846 ***