gstopuscommon.c 3.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* GStreamer
 * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
16 17
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
18 19
 */

20 21
#include <stdio.h>
#include <string.h>
22 23 24 25 26 27
#include "gstopuscommon.h"

/* http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9 */
/* copy of the same structure in the vorbis plugin */
const GstAudioChannelPosition gst_opus_channel_positions[][8] = {
  {                             /* Mono */
Mark Nauwelaerts's avatar
Mark Nauwelaerts committed
28
      GST_AUDIO_CHANNEL_POSITION_MONO},
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
  {                             /* Stereo */
        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
      GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT},
  {                             /* Stereo + Centre */
        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
        GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
      GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT},
  {                             /* Quadraphonic */
        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
        GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
        GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
        GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
      },
  {                             /* Stereo + Centre + rear stereo */
        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
        GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
        GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
        GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
        GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
      },
  {                             /* Full 5.1 Surround */
        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
        GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
        GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
        GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
        GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
Mark Nauwelaerts's avatar
Mark Nauwelaerts committed
55
        GST_AUDIO_CHANNEL_POSITION_LFE1,
56 57 58 59 60 61 62 63
      },
  {                             /* 6.1 Surround, in Vorbis spec since 2010-01-13 */
        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
        GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
        GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
        GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
        GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
        GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
Mark Nauwelaerts's avatar
Mark Nauwelaerts committed
64
      GST_AUDIO_CHANNEL_POSITION_LFE1},
65 66 67 68 69 70 71 72
  {                             /* 7.1 Surround, in Vorbis spec since 2010-01-13 */
        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
        GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
        GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
        GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
        GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
        GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
        GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
Mark Nauwelaerts's avatar
Mark Nauwelaerts committed
73
      GST_AUDIO_CHANNEL_POSITION_LFE1},
74
};
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

const char *gst_opus_channel_names[] = {
  "mono",
  "front left",
  "front right",
  "rear center",
  "rear left",
  "rear right",
  "lfe",
  "front center",
  "front left of center",
  "front right of center",
  "side left",
  "side right",
  "none"
};
91 92 93 94 95 96 97

void
gst_opus_common_log_channel_mapping_table (GstElement * element,
    GstDebugCategory * category, const char *msg, int n_channels,
    const guint8 * table)
{
  int n;
98
  GString *s;
99

100 101 102 103
  if (gst_debug_category_get_threshold (category) < GST_LEVEL_INFO)
    return;

  s = g_string_new ("[ ");
104
  for (n = 0; n < n_channels; ++n) {
105
    g_string_append_printf (s, "%d ", table[n]);
106
  }
107 108 109 110
  g_string_append (s, "]");

  GST_CAT_LEVEL_LOG (category, GST_LEVEL_INFO, element, "%s: %s", msg, s->str);
  g_string_free (s, TRUE);
111
}