jiixyj / libebur128

A library implementing the EBU R128 loudness standard.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

7.1 audio channels

MAN-PANG opened this issue · comments

The code currently only supports 5.1 channels. Can we have an update that supports 7.1 channels, thanks!

Hello, as mentioned in the source code

/** \enum channel
you should look at which loudspeaker positions your 7.1 setup is related and use the corresponding value to set the channel type of an 8 channel ebu_r128_state.

Thanks for quick reply but I am confused because the function ebur128_init_channel_map will ignore channel numbers higher than 5. More specifically, the code below will iterate through st-> channels but channel number higher than 5 is deemed to be unused:

  static int ebur128_init_channel_map(ebur128_state* st) {
  size_t i;
  st->d->channel_map = (int*) malloc(st->channels * sizeof(int));
  if (!st->d->channel_map) {
    return EBUR128_ERROR_NOMEM;
  }
  if (st->channels == 4) {
    st->d->channel_map[0] = EBUR128_LEFT;
    st->d->channel_map[1] = EBUR128_RIGHT;
    st->d->channel_map[2] = EBUR128_LEFT_SURROUND;
    st->d->channel_map[3] = EBUR128_RIGHT_SURROUND;
  } else if (st->channels == 5) {
    st->d->channel_map[0] = EBUR128_LEFT;
    st->d->channel_map[1] = EBUR128_RIGHT;
    st->d->channel_map[2] = EBUR128_CENTER;
    st->d->channel_map[3] = EBUR128_LEFT_SURROUND;
    st->d->channel_map[4] = EBUR128_RIGHT_SURROUND;
  } else {
    for (i = 0; i < st->channels; ++i) {
      switch (i) {
        case 0: st->d->channel_map[i] = EBUR128_LEFT; break;
        case 1: st->d->channel_map[i] = EBUR128_RIGHT; break;
        case 2: st->d->channel_map[i] = EBUR128_CENTER; break;
        case 3: st->d->channel_map[i] = EBUR128_UNUSED; break;
        case 4: st->d->channel_map[i] = EBUR128_LEFT_SURROUND; break;
        case 5: st->d->channel_map[i] = EBUR128_RIGHT_SURROUND; break;
        default: st->d->channel_map[i] = EBUR128_UNUSED; break;
      }
    }
  }
  return EBUR128_SUCCESS;
}

You should not use the

static int ebur128_init_channel_map(ebur128_state* st) {
function that is not part of the public api, and seems to be used only for the default channels setup. You should use the
int ebur128_set_channel(ebur128_state* st,
function, setting each channel to it's appropriate value in a loop over channels indexes.

@audionuma Thank you very much for your help. I'll take a look.